ctdaio.h 3.2 KB

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