hdaudio_ext.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __SOUND_HDAUDIO_EXT_H
  3. #define __SOUND_HDAUDIO_EXT_H
  4. #include <sound/hdaudio.h>
  5. int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev,
  6. const struct hdac_bus_ops *ops,
  7. const struct hdac_io_ops *io_ops,
  8. const struct hdac_ext_bus_ops *ext_ops);
  9. void snd_hdac_ext_bus_exit(struct hdac_bus *bus);
  10. int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr,
  11. struct hdac_device *hdev);
  12. void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
  13. void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus);
  14. #define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \
  15. { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \
  16. .api_version = HDA_DEV_ASOC, \
  17. .driver_data = (unsigned long)(drv_data) }
  18. #define HDA_CODEC_EXT_ENTRY(_vid, _revid, _name, _drv_data) \
  19. HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data)
  20. void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *chip, bool enable);
  21. void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *chip, bool enable);
  22. void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *chip,
  23. bool enable, int index);
  24. int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus);
  25. struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus,
  26. const char *codec_name);
  27. enum hdac_ext_stream_type {
  28. HDAC_EXT_STREAM_TYPE_COUPLED = 0,
  29. HDAC_EXT_STREAM_TYPE_HOST,
  30. HDAC_EXT_STREAM_TYPE_LINK
  31. };
  32. /**
  33. * hdac_ext_stream: HDAC extended stream for extended HDA caps
  34. *
  35. * @hstream: hdac_stream
  36. * @pphc_addr: processing pipe host stream pointer
  37. * @pplc_addr: processing pipe link stream pointer
  38. * @spib_addr: software position in buffers stream pointer
  39. * @fifo_addr: software position Max fifos stream pointer
  40. * @dpibr_addr: DMA position in buffer resume pointer
  41. * @dpib: DMA position in buffer
  42. * @lpib: Linear position in buffer
  43. * @decoupled: stream host and link is decoupled
  44. * @link_locked: link is locked
  45. * @link_prepared: link is prepared
  46. * link_substream: link substream
  47. */
  48. struct hdac_ext_stream {
  49. struct hdac_stream hstream;
  50. void __iomem *pphc_addr;
  51. void __iomem *pplc_addr;
  52. void __iomem *spib_addr;
  53. void __iomem *fifo_addr;
  54. void __iomem *dpibr_addr;
  55. u32 dpib;
  56. u32 lpib;
  57. bool decoupled:1;
  58. bool link_locked:1;
  59. bool link_prepared;
  60. struct snd_pcm_substream *link_substream;
  61. };
  62. #define hdac_stream(s) (&(s)->hstream)
  63. #define stream_to_hdac_ext_stream(s) \
  64. container_of(s, struct hdac_ext_stream, hstream)
  65. void snd_hdac_ext_stream_init(struct hdac_bus *bus,
  66. struct hdac_ext_stream *stream, int idx,
  67. int direction, int tag);
  68. int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
  69. int num_stream, int dir);
  70. void snd_hdac_stream_free_all(struct hdac_bus *bus);
  71. void snd_hdac_link_free_all(struct hdac_bus *bus);
  72. struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus,
  73. struct snd_pcm_substream *substream,
  74. int type);
  75. void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type);
  76. void snd_hdac_ext_stream_decouple(struct hdac_bus *bus,
  77. struct hdac_ext_stream *azx_dev, bool decouple);
  78. void snd_hdac_ext_stop_streams(struct hdac_bus *bus);
  79. int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus,
  80. struct hdac_ext_stream *stream, u32 value);
  81. int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus,
  82. struct hdac_ext_stream *stream);
  83. void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus,
  84. bool enable, int index);
  85. int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus,
  86. struct hdac_ext_stream *stream, u32 value);
  87. int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *stream, u32 value);
  88. void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream);
  89. void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream);
  90. void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream);
  91. int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt);
  92. struct hdac_ext_link {
  93. struct hdac_bus *bus;
  94. int index;
  95. void __iomem *ml_addr; /* link output stream reg pointer */
  96. u32 lcaps; /* link capablities */
  97. u16 lsdiid; /* link sdi identifier */
  98. int ref_count;
  99. struct list_head list;
  100. };
  101. int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link);
  102. int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link);
  103. int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus);
  104. int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus);
  105. void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link,
  106. int stream);
  107. void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
  108. int stream);
  109. int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, struct hdac_ext_link *link);
  110. int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *link);
  111. /* update register macro */
  112. #define snd_hdac_updatel(addr, reg, mask, val) \
  113. writel(((readl(addr + reg) & ~(mask)) | (val)), \
  114. addr + reg)
  115. #define snd_hdac_updatew(addr, reg, mask, val) \
  116. writew(((readw(addr + reg) & ~(mask)) | (val)), \
  117. addr + reg)
  118. struct hdac_ext_device;
  119. /* ops common to all codec drivers */
  120. struct hdac_ext_codec_ops {
  121. int (*build_controls)(struct hdac_ext_device *dev);
  122. int (*init)(struct hdac_ext_device *dev);
  123. void (*free)(struct hdac_ext_device *dev);
  124. };
  125. struct hda_dai_map {
  126. char *dai_name;
  127. hda_nid_t nid;
  128. u32 maxbps;
  129. };
  130. struct hdac_ext_dma_params {
  131. u32 format;
  132. u8 stream_tag;
  133. };
  134. int snd_hda_ext_driver_register(struct hdac_driver *drv);
  135. void snd_hda_ext_driver_unregister(struct hdac_driver *drv);
  136. #endif /* __SOUND_HDAUDIO_EXT_H */