Linux 6.14-rc1
[linux.git] / include / sound / hdaudio_ext.h
blob4c7a40e149a594dbe0f31205b7714dc7012982bb
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __SOUND_HDAUDIO_EXT_H
3 #define __SOUND_HDAUDIO_EXT_H
5 #include <sound/hdaudio.h>
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);
11 void snd_hdac_ext_bus_exit(struct hdac_bus *bus);
12 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)
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);
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);
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
35 /**
36 * hdac_ext_stream: HDAC extended stream for extended HDA caps
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
46 struct hdac_ext_stream {
47 struct hdac_stream hstream;
49 void __iomem *pphc_addr;
50 void __iomem *pplc_addr;
52 u32 pphcllpl;
53 u32 pphcllpu;
54 u32 pphcldpl;
55 u32 pphcldpu;
57 u32 pplcllpl;
58 u32 pplcllpu;
60 bool decoupled:1;
61 bool link_locked:1;
62 bool link_prepared;
64 int (*host_setup)(struct hdac_stream *, bool);
66 struct snd_pcm_substream *link_substream;
69 #define hdac_stream(s) (&(s)->hstream)
70 #define stream_to_hdac_ext_stream(s) \
71 container_of(s, struct hdac_ext_stream, hstream)
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);
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);
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 */
101 int ref_count;
103 struct list_head list;
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);
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);
118 void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable);
120 struct hdac_ext_device;
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);
129 struct hda_dai_map {
130 char *dai_name;
131 hda_nid_t nid;
132 u32 maxbps;
135 struct hdac_ext_dma_params {
136 u32 format;
137 u8 stream_tag;
140 int snd_hda_ext_driver_register(struct hdac_driver *drv);
141 void snd_hda_ext_driver_unregister(struct hdac_driver *drv);
143 #endif /* __SOUND_HDAUDIO_EXT_H */