hdaudio_ext.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. #ifndef __SOUND_HDAUDIO_EXT_H
  2. #define __SOUND_HDAUDIO_EXT_H
  3. #include <sound/hdaudio.h>
  4. /**
  5. * hdac_ext_bus: HDAC extended bus for extended HDA caps
  6. *
  7. * @bus: hdac bus
  8. * @num_streams: streams supported
  9. * @ppcap: pp capabilities pointer
  10. * @spbcap: SPIB capabilities pointer
  11. * @mlcap: MultiLink capabilities pointer
  12. * @gtscap: gts capabilities pointer
  13. * @hlink_list: link list of HDA links
  14. */
  15. struct hdac_ext_bus {
  16. struct hdac_bus bus;
  17. int num_streams;
  18. int idx;
  19. void __iomem *ppcap;
  20. void __iomem *spbcap;
  21. void __iomem *mlcap;
  22. void __iomem *gtscap;
  23. struct list_head hlink_list;
  24. };
  25. int snd_hdac_ext_bus_init(struct hdac_ext_bus *sbus, struct device *dev,
  26. const struct hdac_bus_ops *ops,
  27. const struct hdac_io_ops *io_ops);
  28. void snd_hdac_ext_bus_exit(struct hdac_ext_bus *sbus);
  29. int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr);
  30. void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
  31. void snd_hdac_ext_bus_device_remove(struct hdac_ext_bus *ebus);
  32. #define ebus_to_hbus(ebus) (&(ebus)->bus)
  33. #define hbus_to_ebus(_bus) \
  34. container_of(_bus, struct hdac_ext_bus, bus)
  35. #define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \
  36. { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \
  37. .api_version = HDA_DEV_ASOC, \
  38. .driver_data = (unsigned long)(drv_data) }
  39. #define HDA_CODEC_EXT_ENTRY(_vid, _revid, _name, _drv_data) \
  40. HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data)
  41. int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus);
  42. void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable);
  43. void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable);
  44. void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip,
  45. bool enable, int index);
  46. int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *bus);
  47. struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *bus,
  48. const char *codec_name);
  49. enum hdac_ext_stream_type {
  50. HDAC_EXT_STREAM_TYPE_COUPLED = 0,
  51. HDAC_EXT_STREAM_TYPE_HOST,
  52. HDAC_EXT_STREAM_TYPE_LINK
  53. };
  54. /**
  55. * hdac_ext_stream: HDAC extended stream for extended HDA caps
  56. *
  57. * @hstream: hdac_stream
  58. * @pphc_addr: processing pipe host stream pointer
  59. * @pplc_addr: processing pipe link stream pointer
  60. * @spib_addr: software position in buffers stream pointer
  61. * @fifo_addr: software position Max fifos stream pointer
  62. * @decoupled: stream host and link is decoupled
  63. * @link_locked: link is locked
  64. * @link_prepared: link is prepared
  65. * link_substream: link substream
  66. */
  67. struct hdac_ext_stream {
  68. struct hdac_stream hstream;
  69. void __iomem *pphc_addr;
  70. void __iomem *pplc_addr;
  71. void __iomem *spib_addr;
  72. void __iomem *fifo_addr;
  73. bool decoupled:1;
  74. bool link_locked:1;
  75. bool link_prepared;
  76. struct snd_pcm_substream *link_substream;
  77. };
  78. #define hdac_stream(s) (&(s)->hstream)
  79. #define stream_to_hdac_ext_stream(s) \
  80. container_of(s, struct hdac_ext_stream, hstream)
  81. void snd_hdac_ext_stream_init(struct hdac_ext_bus *bus,
  82. struct hdac_ext_stream *stream, int idx,
  83. int direction, int tag);
  84. int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx,
  85. int num_stream, int dir);
  86. void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus);
  87. void snd_hdac_link_free_all(struct hdac_ext_bus *ebus);
  88. struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus,
  89. struct snd_pcm_substream *substream,
  90. int type);
  91. void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type);
  92. void snd_hdac_ext_stream_decouple(struct hdac_ext_bus *bus,
  93. struct hdac_ext_stream *azx_dev, bool decouple);
  94. void snd_hdac_ext_stop_streams(struct hdac_ext_bus *sbus);
  95. int snd_hdac_ext_stream_set_spib(struct hdac_ext_bus *ebus,
  96. struct hdac_ext_stream *stream, u32 value);
  97. int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_ext_bus *ebus,
  98. struct hdac_ext_stream *stream);
  99. void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream);
  100. void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream);
  101. void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream);
  102. int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt);
  103. struct hdac_ext_link {
  104. struct hdac_bus *bus;
  105. int index;
  106. void __iomem *ml_addr; /* link output stream reg pointer */
  107. u32 lcaps; /* link capablities */
  108. u16 lsdiid; /* link sdi identifier */
  109. struct list_head list;
  110. };
  111. int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link);
  112. int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link);
  113. int snd_hdac_ext_bus_link_power_down_all(struct hdac_ext_bus *ebus);
  114. void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link,
  115. int stream);
  116. void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
  117. int stream);
  118. /* update register macro */
  119. #define snd_hdac_updatel(addr, reg, mask, val) \
  120. writel(((readl(addr + reg) & ~(mask)) | (val)), \
  121. addr + reg)
  122. #define snd_hdac_updatew(addr, reg, mask, val) \
  123. writew(((readw(addr + reg) & ~(mask)) | (val)), \
  124. addr + reg)
  125. struct hdac_ext_device;
  126. /* ops common to all codec drivers */
  127. struct hdac_ext_codec_ops {
  128. int (*build_controls)(struct hdac_ext_device *dev);
  129. int (*init)(struct hdac_ext_device *dev);
  130. void (*free)(struct hdac_ext_device *dev);
  131. };
  132. struct hda_dai_map {
  133. char *dai_name;
  134. hda_nid_t nid;
  135. u32 maxbps;
  136. };
  137. #define HDA_MAX_NIDS 16
  138. /**
  139. * struct hdac_ext_device - HDAC Ext device
  140. *
  141. * @hdac: hdac core device
  142. * @nid_list - the dai map which matches the dai-name with the nid
  143. * @map_cur_idx - the idx in use in dai_map
  144. * @ops - the hda codec ops common to all codec drivers
  145. * @pvt_data - private data, for asoc contains asoc codec object
  146. */
  147. struct hdac_ext_device {
  148. struct hdac_device hdac;
  149. struct hdac_ext_bus *ebus;
  150. /* soc-dai to nid map */
  151. struct hda_dai_map nid_list[HDA_MAX_NIDS];
  152. unsigned int map_cur_idx;
  153. /* codec ops */
  154. struct hdac_ext_codec_ops ops;
  155. void *private_data;
  156. };
  157. #define to_ehdac_device(dev) (container_of((dev), \
  158. struct hdac_ext_device, hdac))
  159. /*
  160. * HD-audio codec base driver
  161. */
  162. struct hdac_ext_driver {
  163. struct hdac_driver hdac;
  164. int (*probe)(struct hdac_ext_device *dev);
  165. int (*remove)(struct hdac_ext_device *dev);
  166. void (*shutdown)(struct hdac_ext_device *dev);
  167. };
  168. int snd_hda_ext_driver_register(struct hdac_ext_driver *drv);
  169. void snd_hda_ext_driver_unregister(struct hdac_ext_driver *drv);
  170. #define to_ehdac_driver(_drv) container_of(_drv, struct hdac_ext_driver, hdac)
  171. #endif /* __SOUND_HDAUDIO_EXT_H */