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