ctdaio.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /**
  2. * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
  3. *
  4. * This source file is released under GPL v2 license (no other versions).
  5. * See the COPYING file included in the main directory of this source
  6. * distribution for the license terms and conditions.
  7. *
  8. * @File ctdaio.h
  9. *
  10. * @Brief
  11. * This file contains the definition of Digital Audio Input Output
  12. * resource management object.
  13. *
  14. * @Author Liu Chun
  15. * @Date May 23 2008
  16. *
  17. */
  18. #ifndef CTDAIO_H
  19. #define CTDAIO_H
  20. #include "ctresource.h"
  21. #include "ctimap.h"
  22. #include <linux/spinlock.h>
  23. #include <linux/list.h>
  24. /* Define the descriptor of a daio resource */
  25. enum DAIOTYP {
  26. LINEO1,
  27. LINEO2,
  28. LINEO3,
  29. LINEO4,
  30. SPDIFOO, /* S/PDIF Out (Flexijack/Optical) */
  31. LINEIM,
  32. SPDIFIO, /* S/PDIF In (Flexijack/Optical) on the card */
  33. SPDIFI1, /* S/PDIF In on internal Drive Bay */
  34. NUM_DAIOTYP
  35. };
  36. struct dao_rsc_ops;
  37. struct dai_rsc_ops;
  38. struct daio_mgr;
  39. struct daio {
  40. struct rsc rscl; /* Basic resource info for left TX/RX */
  41. struct rsc rscr; /* Basic resource info for right TX/RX */
  42. enum DAIOTYP type;
  43. };
  44. struct dao {
  45. struct daio daio;
  46. struct dao_rsc_ops *ops; /* DAO specific operations */
  47. struct imapper **imappers;
  48. struct daio_mgr *mgr;
  49. void *hw;
  50. void *ctrl_blk;
  51. };
  52. struct dai {
  53. struct daio daio;
  54. struct dai_rsc_ops *ops; /* DAI specific operations */
  55. void *hw;
  56. void *ctrl_blk;
  57. };
  58. struct dao_desc {
  59. unsigned int msr:4;
  60. unsigned int passthru:1;
  61. };
  62. struct dao_rsc_ops {
  63. int (*set_spos)(struct dao *dao, unsigned int spos);
  64. int (*commit_write)(struct dao *dao);
  65. int (*get_spos)(struct dao *dao, unsigned int *spos);
  66. int (*reinit)(struct dao *dao, const struct dao_desc *desc);
  67. int (*set_left_input)(struct dao *dao, struct rsc *input);
  68. int (*set_right_input)(struct dao *dao, struct rsc *input);
  69. int (*clear_left_input)(struct dao *dao);
  70. int (*clear_right_input)(struct dao *dao);
  71. };
  72. struct dai_rsc_ops {
  73. int (*set_srt_srcl)(struct dai *dai, struct rsc *src);
  74. int (*set_srt_srcr)(struct dai *dai, struct rsc *src);
  75. int (*set_srt_msr)(struct dai *dai, unsigned int msr);
  76. int (*set_enb_src)(struct dai *dai, unsigned int enb);
  77. int (*set_enb_srt)(struct dai *dai, unsigned int enb);
  78. int (*commit_write)(struct dai *dai);
  79. };
  80. /* Define daio resource request description info */
  81. struct daio_desc {
  82. unsigned int type:4;
  83. unsigned int msr:4;
  84. unsigned int passthru:1;
  85. };
  86. struct daio_mgr {
  87. struct rsc_mgr mgr; /* Basic resource manager info */
  88. spinlock_t mgr_lock;
  89. spinlock_t imap_lock;
  90. struct list_head imappers;
  91. struct imapper *init_imap;
  92. unsigned int init_imap_added;
  93. /* request one daio resource */
  94. int (*get_daio)(struct daio_mgr *mgr,
  95. const struct daio_desc *desc, struct daio **rdaio);
  96. /* return one daio resource */
  97. int (*put_daio)(struct daio_mgr *mgr, struct daio *daio);
  98. int (*daio_enable)(struct daio_mgr *mgr, struct daio *daio);
  99. int (*daio_disable)(struct daio_mgr *mgr, struct daio *daio);
  100. int (*imap_add)(struct daio_mgr *mgr, struct imapper *entry);
  101. int (*imap_delete)(struct daio_mgr *mgr, struct imapper *entry);
  102. int (*commit_write)(struct daio_mgr *mgr);
  103. };
  104. /* Constructor and destructor of daio resource manager */
  105. int daio_mgr_create(void *hw, struct daio_mgr **rdaio_mgr);
  106. int daio_mgr_destroy(struct daio_mgr *daio_mgr);
  107. #endif /* CTDAIO_H */