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