hdaudio_ext.h 4.8 KB

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