1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __SOUND_HDAUDIO_EXT_H 3 #define __SOUND_HDAUDIO_EXT_H 4 5 #include <sound/hdaudio.h> 6 7 int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, 8 const struct hdac_bus_ops *ops, 9 const struct hdac_ext_bus_ops *ext_ops); 10 11 void snd_hdac_ext_bus_exit(struct hdac_bus *bus); 12 void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus); 13 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 21 void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *chip, bool enable); 22 void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *chip, bool enable); 23 24 int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus); 25 struct hdac_ext_link *snd_hdac_ext_bus_get_hlink_by_addr(struct hdac_bus *bus, int addr); 26 struct hdac_ext_link *snd_hdac_ext_bus_get_hlink_by_name(struct hdac_bus *bus, 27 const char *codec_name); 28 29 enum hdac_ext_stream_type { 30 HDAC_EXT_STREAM_TYPE_COUPLED = 0, 31 HDAC_EXT_STREAM_TYPE_HOST, 32 HDAC_EXT_STREAM_TYPE_LINK 33 }; 34 35 /** 36 * hdac_ext_stream: HDAC extended stream for extended HDA caps 37 * 38 * @hstream: hdac_stream 39 * @pphc_addr: processing pipe host stream pointer 40 * @pplc_addr: processing pipe link stream pointer 41 * @decoupled: stream host and link is decoupled 42 * @link_locked: link is locked 43 * @link_prepared: link is prepared 44 * @link_substream: link substream 45 */ 46 struct hdac_ext_stream { 47 struct hdac_stream hstream; 48 49 void __iomem *pphc_addr; 50 void __iomem *pplc_addr; 51 52 u32 pphcllpl; 53 u32 pphcllpu; 54 u32 pphcldpl; 55 u32 pphcldpu; 56 57 u32 pplcllpl; 58 u32 pplcllpu; 59 60 bool decoupled:1; 61 bool link_locked:1; 62 bool link_prepared; 63 64 int (*host_setup)(struct hdac_stream *, bool); 65 66 struct snd_pcm_substream *link_substream; 67 }; 68 69 #define hdac_stream(s) (&(s)->hstream) 70 #define stream_to_hdac_ext_stream(s) \ 71 container_of(s, struct hdac_ext_stream, hstream) 72 73 int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, 74 int num_stream, int dir); 75 void snd_hdac_ext_stream_free_all(struct hdac_bus *bus); 76 void snd_hdac_ext_link_free_all(struct hdac_bus *bus); 77 struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus, 78 struct snd_pcm_substream *substream, 79 int type); 80 void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type); 81 struct hdac_ext_stream *snd_hdac_ext_cstream_assign(struct hdac_bus *bus, 82 struct snd_compr_stream *cstream); 83 void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus, 84 struct hdac_ext_stream *hext_stream, bool decouple); 85 void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, 86 struct hdac_ext_stream *azx_dev, bool decouple); 87 88 void snd_hdac_ext_stream_start(struct hdac_ext_stream *hext_stream); 89 void snd_hdac_ext_stream_clear(struct hdac_ext_stream *hext_stream); 90 void snd_hdac_ext_stream_reset(struct hdac_ext_stream *hext_stream); 91 int snd_hdac_ext_stream_setup(struct hdac_ext_stream *hext_stream, int fmt); 92 int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream, bool code_loading); 93 94 struct hdac_ext_link { 95 struct hdac_bus *bus; 96 int index; 97 void __iomem *ml_addr; /* link output stream reg pointer */ 98 u32 lcaps; /* link capablities */ 99 u16 lsdiid; /* link sdi identifier */ 100 101 int ref_count; 102 103 struct list_head list; 104 }; 105 106 int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *hlink); 107 int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *hlink); 108 int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus); 109 int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus); 110 void snd_hdac_ext_bus_link_set_stream_id(struct hdac_ext_link *hlink, 111 int stream); 112 void snd_hdac_ext_bus_link_clear_stream_id(struct hdac_ext_link *hlink, 113 int stream); 114 115 int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, struct hdac_ext_link *hlink); 116 int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *hlink); 117 118 void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable); 119 120 struct hdac_ext_device; 121 122 /* ops common to all codec drivers */ 123 struct hdac_ext_codec_ops { 124 int (*build_controls)(struct hdac_ext_device *dev); 125 int (*init)(struct hdac_ext_device *dev); 126 void (*free)(struct hdac_ext_device *dev); 127 }; 128 129 struct hda_dai_map { 130 char *dai_name; 131 hda_nid_t nid; 132 u32 maxbps; 133 }; 134 135 struct hdac_ext_dma_params { 136 u32 format; 137 u8 stream_tag; 138 }; 139 140 int snd_hda_ext_driver_register(struct hdac_driver *drv); 141 void snd_hda_ext_driver_unregister(struct hdac_driver *drv); 142 143 #endif /* __SOUND_HDAUDIO_EXT_H */ 144