hdaudio_ext.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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_ext_bus_ops *ext_ops);
  8. void snd_hdac_ext_bus_exit(struct hdac_bus *bus);
  9. void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus);
  10. #define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \
  11. { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \
  12. .api_version = HDA_DEV_ASOC, \
  13. .driver_data = (unsigned long)(drv_data) }
  14. #define HDA_CODEC_EXT_ENTRY(_vid, _revid, _name, _drv_data) \
  15. HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data)
  16. void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *chip, bool enable);
  17. void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *chip, bool enable);
  18. int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus);
  19. struct hdac_ext_link *snd_hdac_ext_bus_get_hlink_by_addr(struct hdac_bus *bus, int addr);
  20. struct hdac_ext_link *snd_hdac_ext_bus_get_hlink_by_name(struct hdac_bus *bus,
  21. const char *codec_name);
  22. enum hdac_ext_stream_type {
  23. HDAC_EXT_STREAM_TYPE_COUPLED = 0,
  24. HDAC_EXT_STREAM_TYPE_HOST,
  25. HDAC_EXT_STREAM_TYPE_LINK
  26. };
  27. /**
  28. * hdac_ext_stream: HDAC extended stream for extended HDA caps
  29. *
  30. * @hstream: hdac_stream
  31. * @pphc_addr: processing pipe host stream pointer
  32. * @pplc_addr: processing pipe link stream pointer
  33. * @decoupled: stream host and link is decoupled
  34. * @link_locked: link is locked
  35. * @link_prepared: link is prepared
  36. * @link_substream: link substream
  37. */
  38. struct hdac_ext_stream {
  39. struct hdac_stream hstream;
  40. void __iomem *pphc_addr;
  41. void __iomem *pplc_addr;
  42. u32 pphcllpl;
  43. u32 pphcllpu;
  44. u32 pphcldpl;
  45. u32 pphcldpu;
  46. u32 pplcllpl;
  47. u32 pplcllpu;
  48. bool decoupled:1;
  49. bool link_locked:1;
  50. bool link_prepared;
  51. int (*host_setup)(struct hdac_stream *, bool);
  52. struct snd_pcm_substream *link_substream;
  53. };
  54. #define hdac_stream(s) (&(s)->hstream)
  55. #define stream_to_hdac_ext_stream(s) \
  56. container_of(s, struct hdac_ext_stream, hstream)
  57. int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
  58. int num_stream, int dir);
  59. void snd_hdac_ext_stream_free_all(struct hdac_bus *bus);
  60. void snd_hdac_ext_link_free_all(struct hdac_bus *bus);
  61. struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus,
  62. struct snd_pcm_substream *substream,
  63. int type);
  64. void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type);
  65. struct hdac_ext_stream *snd_hdac_ext_cstream_assign(struct hdac_bus *bus,
  66. struct snd_compr_stream *cstream);
  67. void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus,
  68. struct hdac_ext_stream *hext_stream, bool decouple);
  69. void snd_hdac_ext_stream_decouple(struct hdac_bus *bus,
  70. struct hdac_ext_stream *azx_dev, bool decouple);
  71. void snd_hdac_ext_stream_start(struct hdac_ext_stream *hext_stream);
  72. void snd_hdac_ext_stream_clear(struct hdac_ext_stream *hext_stream);
  73. void snd_hdac_ext_stream_reset(struct hdac_ext_stream *hext_stream);
  74. int snd_hdac_ext_stream_setup(struct hdac_ext_stream *hext_stream, int fmt);
  75. int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream, bool code_loading);
  76. struct hdac_ext_link {
  77. struct hdac_bus *bus;
  78. int index;
  79. void __iomem *ml_addr; /* link output stream reg pointer */
  80. u32 lcaps; /* link capablities */
  81. u16 lsdiid; /* link sdi identifier */
  82. int ref_count;
  83. struct list_head list;
  84. };
  85. int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *hlink);
  86. int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *hlink);
  87. int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus);
  88. int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus);
  89. void snd_hdac_ext_bus_link_set_stream_id(struct hdac_ext_link *hlink,
  90. int stream);
  91. void snd_hdac_ext_bus_link_clear_stream_id(struct hdac_ext_link *hlink,
  92. int stream);
  93. int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, struct hdac_ext_link *hlink);
  94. int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *hlink);
  95. void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable);
  96. struct hdac_ext_device;
  97. /* ops common to all codec drivers */
  98. struct hdac_ext_codec_ops {
  99. int (*build_controls)(struct hdac_ext_device *dev);
  100. int (*init)(struct hdac_ext_device *dev);
  101. void (*free)(struct hdac_ext_device *dev);
  102. };
  103. struct hda_dai_map {
  104. char *dai_name;
  105. hda_nid_t nid;
  106. u32 maxbps;
  107. };
  108. struct hdac_ext_dma_params {
  109. u32 format;
  110. u8 stream_tag;
  111. };
  112. int snd_hda_ext_driver_register(struct hdac_driver *drv);
  113. void snd_hda_ext_driver_unregister(struct hdac_driver *drv);
  114. #endif /* __SOUND_HDAUDIO_EXT_H */