]>
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 RU |
9 | const struct hdac_io_ops *io_ops, |
10 | const struct hdac_ext_bus_ops *ext_ops); | |
dfe66a18 | 11 | |
76f56fae | 12 | void snd_hdac_ext_bus_exit(struct hdac_bus *bus); |
6298542f RU |
13 | int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr, |
14 | struct hdac_device *hdev); | |
dfe66a18 | 15 | void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev); |
76f56fae | 16 | void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus); |
dfe66a18 | 17 | |
b6e84c99 SP |
18 | #define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \ |
19 | { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \ | |
20 | .api_version = HDA_DEV_ASOC, \ | |
21 | .driver_data = (unsigned long)(drv_data) } | |
22 | #define HDA_CODEC_EXT_ENTRY(_vid, _revid, _name, _drv_data) \ | |
23 | HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data) | |
24 | ||
76f56fae RU |
25 | void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *chip, bool enable); |
26 | void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *chip, bool enable); | |
dfe66a18 | 27 | |
76f56fae | 28 | void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *chip, |
0b00a561 JK |
29 | bool enable, int index); |
30 | ||
76f56fae RU |
31 | int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus); |
32 | struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus, | |
0b00a561 JK |
33 | const char *codec_name); |
34 | ||
35 | enum hdac_ext_stream_type { | |
36 | HDAC_EXT_STREAM_TYPE_COUPLED = 0, | |
37 | HDAC_EXT_STREAM_TYPE_HOST, | |
38 | HDAC_EXT_STREAM_TYPE_LINK | |
39 | }; | |
40 | ||
df203a4e JK |
41 | /** |
42 | * hdac_ext_stream: HDAC extended stream for extended HDA caps | |
43 | * | |
44 | * @hstream: hdac_stream | |
45 | * @pphc_addr: processing pipe host stream pointer | |
46 | * @pplc_addr: processing pipe link stream pointer | |
ee8bc4df JK |
47 | * @spib_addr: software position in buffers stream pointer |
48 | * @fifo_addr: software position Max fifos stream pointer | |
a9c48f7f JK |
49 | * @dpibr_addr: DMA position in buffer resume pointer |
50 | * @dpib: DMA position in buffer | |
51 | * @lpib: Linear position in buffer | |
df203a4e JK |
52 | * @decoupled: stream host and link is decoupled |
53 | * @link_locked: link is locked | |
54 | * @link_prepared: link is prepared | |
55 | * link_substream: link substream | |
56 | */ | |
57 | struct hdac_ext_stream { | |
58 | struct hdac_stream hstream; | |
59 | ||
60 | void __iomem *pphc_addr; | |
61 | void __iomem *pplc_addr; | |
62 | ||
ee8bc4df JK |
63 | void __iomem *spib_addr; |
64 | void __iomem *fifo_addr; | |
65 | ||
a9c48f7f JK |
66 | void __iomem *dpibr_addr; |
67 | ||
68 | u32 dpib; | |
69 | u32 lpib; | |
df203a4e JK |
70 | bool decoupled:1; |
71 | bool link_locked:1; | |
72 | bool link_prepared; | |
73 | ||
74 | struct snd_pcm_substream *link_substream; | |
75 | }; | |
76 | ||
77 | #define hdac_stream(s) (&(s)->hstream) | |
78 | #define stream_to_hdac_ext_stream(s) \ | |
79 | container_of(s, struct hdac_ext_stream, hstream) | |
80 | ||
76f56fae | 81 | void snd_hdac_ext_stream_init(struct hdac_bus *bus, |
df203a4e JK |
82 | struct hdac_ext_stream *stream, int idx, |
83 | int direction, int tag); | |
76f56fae | 84 | int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, |
e7a3484d | 85 | int num_stream, int dir); |
76f56fae RU |
86 | void snd_hdac_stream_free_all(struct hdac_bus *bus); |
87 | void snd_hdac_link_free_all(struct hdac_bus *bus); | |
88 | struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus, | |
df203a4e JK |
89 | struct snd_pcm_substream *substream, |
90 | int type); | |
91 | void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type); | |
76f56fae | 92 | void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, |
df203a4e | 93 | struct hdac_ext_stream *azx_dev, bool decouple); |
76f56fae | 94 | void snd_hdac_ext_stop_streams(struct hdac_bus *bus); |
df203a4e | 95 | |
76f56fae | 96 | int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus, |
ee8bc4df | 97 | struct hdac_ext_stream *stream, u32 value); |
76f56fae | 98 | int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus, |
ee8bc4df | 99 | struct hdac_ext_stream *stream); |
76f56fae | 100 | void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus, |
a9c48f7f | 101 | bool enable, int index); |
76f56fae | 102 | int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus, |
a9c48f7f JK |
103 | struct hdac_ext_stream *stream, u32 value); |
104 | int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *stream, u32 value); | |
ee8bc4df | 105 | |
df203a4e JK |
106 | void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream); |
107 | void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream); | |
108 | void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream); | |
109 | int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt); | |
110 | ||
0b00a561 JK |
111 | struct hdac_ext_link { |
112 | struct hdac_bus *bus; | |
113 | int index; | |
114 | void __iomem *ml_addr; /* link output stream reg pointer */ | |
115 | u32 lcaps; /* link capablities */ | |
116 | u16 lsdiid; /* link sdi identifier */ | |
4446085d VK |
117 | |
118 | int ref_count; | |
119 | ||
0b00a561 JK |
120 | struct list_head list; |
121 | }; | |
122 | ||
123 | int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link); | |
124 | int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link); | |
76f56fae RU |
125 | int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus); |
126 | int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus); | |
0b00a561 JK |
127 | void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link, |
128 | int stream); | |
129 | void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link, | |
130 | int stream); | |
131 | ||
76f56fae RU |
132 | int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, struct hdac_ext_link *link); |
133 | int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *link); | |
4446085d | 134 | |
0b00a561 JK |
135 | /* update register macro */ |
136 | #define snd_hdac_updatel(addr, reg, mask, val) \ | |
137 | writel(((readl(addr + reg) & ~(mask)) | (val)), \ | |
138 | addr + reg) | |
139 | ||
df203a4e JK |
140 | #define snd_hdac_updatew(addr, reg, mask, val) \ |
141 | writew(((readw(addr + reg) & ~(mask)) | (val)), \ | |
142 | addr + reg) | |
143 | ||
a512f561 VK |
144 | |
145 | struct hdac_ext_device; | |
146 | ||
147 | /* ops common to all codec drivers */ | |
148 | struct hdac_ext_codec_ops { | |
149 | int (*build_controls)(struct hdac_ext_device *dev); | |
150 | int (*init)(struct hdac_ext_device *dev); | |
151 | void (*free)(struct hdac_ext_device *dev); | |
152 | }; | |
153 | ||
154 | struct hda_dai_map { | |
155 | char *dai_name; | |
156 | hda_nid_t nid; | |
157 | u32 maxbps; | |
158 | }; | |
159 | ||
1e83b047 SP |
160 | struct hdac_ext_dma_params { |
161 | u32 format; | |
162 | u8 stream_tag; | |
163 | }; | |
3787a398 | 164 | |
e1df9317 RU |
165 | int snd_hda_ext_driver_register(struct hdac_driver *drv); |
166 | void snd_hda_ext_driver_unregister(struct hdac_driver *drv); | |
a512f561 | 167 | |
dfe66a18 | 168 | #endif /* __SOUND_HDAUDIO_EXT_H */ |