ctdaio.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #include <sound/core.h>
  25. /* Define the descriptor of a daio resource */
  26. enum DAIOTYP {
  27. LINEO1,
  28. LINEO2,
  29. LINEO3,
  30. LINEO4,
  31. SPDIFOO, /* S/PDIF Out (Flexijack/Optical) */
  32. LINEIM,
  33. SPDIFIO, /* S/PDIF In (Flexijack/Optical) on the card */
  34. MIC, /* Dedicated mic on Titanium HD */
  35. SPDIFI1, /* S/PDIF In on internal Drive Bay */
  36. NUM_DAIOTYP
  37. };
  38. struct dao_rsc_ops;
  39. struct dai_rsc_ops;
  40. struct daio_mgr;
  41. struct daio {
  42. struct rsc rscl; /* Basic resource info for left TX/RX */
  43. struct rsc rscr; /* Basic resource info for right TX/RX */
  44. enum DAIOTYP type;
  45. };
  46. struct dao {
  47. struct daio daio;
  48. struct dao_rsc_ops *ops; /* DAO specific operations */
  49. struct imapper **imappers;
  50. struct daio_mgr *mgr;
  51. struct hw *hw;
  52. void *ctrl_blk;
  53. };
  54. struct dai {
  55. struct daio daio;
  56. struct dai_rsc_ops *ops; /* DAI specific operations */
  57. struct hw *hw;
  58. void *ctrl_blk;
  59. };
  60. struct dao_desc {
  61. unsigned int msr:4;
  62. unsigned int passthru:1;
  63. };
  64. struct dao_rsc_ops {
  65. int (*set_spos)(struct dao *dao, unsigned int spos);
  66. int (*commit_write)(struct dao *dao);
  67. int (*get_spos)(struct dao *dao, unsigned int *spos);
  68. int (*reinit)(struct dao *dao, const struct dao_desc *desc);
  69. int (*set_left_input)(struct dao *dao, struct rsc *input);
  70. int (*set_right_input)(struct dao *dao, struct rsc *input);
  71. int (*clear_left_input)(struct dao *dao);
  72. int (*clear_right_input)(struct dao *dao);
  73. };
  74. struct dai_rsc_ops {
  75. int (*set_srt_srcl)(struct dai *dai, struct rsc *src);
  76. int (*set_srt_srcr)(struct dai *dai, struct rsc *src);
  77. int (*set_srt_msr)(struct dai *dai, unsigned int msr);
  78. int (*set_enb_src)(struct dai *dai, unsigned int enb);
  79. int (*set_enb_srt)(struct dai *dai, unsigned int enb);
  80. int (*commit_write)(struct dai *dai);
  81. };
  82. /* Define daio resource request description info */
  83. struct daio_desc {
  84. unsigned int type:4;
  85. unsigned int msr:4;
  86. unsigned int passthru:1;
  87. };
  88. struct daio_mgr {
  89. struct rsc_mgr mgr; /* Basic resource manager info */
  90. struct snd_card *card; /* pointer to this card */
  91. spinlock_t mgr_lock;
  92. spinlock_t imap_lock;
  93. struct list_head imappers;
  94. struct imapper *init_imap;
  95. unsigned int init_imap_added;
  96. /* request one daio resource */
  97. int (*get_daio)(struct daio_mgr *mgr,
  98. const struct daio_desc *desc, struct daio **rdaio);
  99. /* return one daio resource */
  100. int (*put_daio)(struct daio_mgr *mgr, struct daio *daio);
  101. int (*daio_enable)(struct daio_mgr *mgr, struct daio *daio);
  102. int (*daio_disable)(struct daio_mgr *mgr, struct daio *daio);
  103. int (*imap_add)(struct daio_mgr *mgr, struct imapper *entry);
  104. int (*imap_delete)(struct daio_mgr *mgr, struct imapper *entry);
  105. int (*commit_write)(struct daio_mgr *mgr);
  106. };
  107. /* Constructor and destructor of daio resource manager */
  108. int daio_mgr_create(struct hw *hw, struct daio_mgr **rdaio_mgr);
  109. int daio_mgr_destroy(struct daio_mgr *daio_mgr);
  110. #endif /* CTDAIO_H */