hdaudio_ext.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. #define ebus_to_hbus(ebus) (&(ebus)->bus)
  32. #define hbus_to_ebus(_bus) \
  33. container_of(_bus, struct hdac_ext_bus, bus)
  34. int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus);
  35. void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable);
  36. void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable);
  37. void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip,
  38. bool enable, int index);
  39. int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *bus);
  40. struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *bus,
  41. const char *codec_name);
  42. enum hdac_ext_stream_type {
  43. HDAC_EXT_STREAM_TYPE_COUPLED = 0,
  44. HDAC_EXT_STREAM_TYPE_HOST,
  45. HDAC_EXT_STREAM_TYPE_LINK
  46. };
  47. /**
  48. * hdac_ext_stream: HDAC extended stream for extended HDA caps
  49. *
  50. * @hstream: hdac_stream
  51. * @pphc_addr: processing pipe host stream pointer
  52. * @pplc_addr: processing pipe link stream pointer
  53. * @decoupled: stream host and link is decoupled
  54. * @link_locked: link is locked
  55. * @link_prepared: link is prepared
  56. * link_substream: link substream
  57. */
  58. struct hdac_ext_stream {
  59. struct hdac_stream hstream;
  60. void __iomem *pphc_addr;
  61. void __iomem *pplc_addr;
  62. bool decoupled:1;
  63. bool link_locked:1;
  64. bool link_prepared;
  65. struct snd_pcm_substream *link_substream;
  66. };
  67. #define hdac_stream(s) (&(s)->hstream)
  68. #define stream_to_hdac_ext_stream(s) \
  69. container_of(s, struct hdac_ext_stream, hstream)
  70. void snd_hdac_ext_stream_init(struct hdac_ext_bus *bus,
  71. struct hdac_ext_stream *stream, int idx,
  72. int direction, int tag);
  73. int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx,
  74. int num_stream, int dir);
  75. void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus);
  76. void snd_hdac_link_free_all(struct hdac_ext_bus *ebus);
  77. struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus,
  78. struct snd_pcm_substream *substream,
  79. int type);
  80. void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type);
  81. void snd_hdac_ext_stream_decouple(struct hdac_ext_bus *bus,
  82. struct hdac_ext_stream *azx_dev, bool decouple);
  83. void snd_hdac_ext_stop_streams(struct hdac_ext_bus *sbus);
  84. void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream);
  85. void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream);
  86. void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream);
  87. int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt);
  88. struct hdac_ext_link {
  89. struct hdac_bus *bus;
  90. int index;
  91. void __iomem *ml_addr; /* link output stream reg pointer */
  92. u32 lcaps; /* link capablities */
  93. u16 lsdiid; /* link sdi identifier */
  94. struct list_head list;
  95. };
  96. int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link);
  97. int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link);
  98. void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link,
  99. int stream);
  100. void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
  101. int stream);
  102. /* update register macro */
  103. #define snd_hdac_updatel(addr, reg, mask, val) \
  104. writel(((readl(addr + reg) & ~(mask)) | (val)), \
  105. addr + reg)
  106. #define snd_hdac_updatew(addr, reg, mask, val) \
  107. writew(((readw(addr + reg) & ~(mask)) | (val)), \
  108. addr + reg)
  109. #endif /* __SOUND_HDAUDIO_EXT_H */