blob: 425af06745579f42d784bbe8b19e3d12c3ecced4 [file] [log] [blame]
Jeeja KPdfe66a12015-06-11 14:11:47 +05301#ifndef __SOUND_HDAUDIO_EXT_H
2#define __SOUND_HDAUDIO_EXT_H
3
4#include <sound/hdaudio.h>
5
6/**
7 * hdac_ext_bus: HDAC extended bus for extended HDA caps
8 *
9 * @bus: hdac bus
10 * @num_streams: streams supported
11 * @ppcap: pp capabilities pointer
12 * @spbcap: SPIB capabilities pointer
13 * @mlcap: MultiLink capabilities pointer
14 * @gtscap: gts capabilities pointer
15 * @hlink_list: link list of HDA links
16 */
17struct hdac_ext_bus {
18 struct hdac_bus bus;
19 int num_streams;
20 int idx;
21
22 void __iomem *ppcap;
23 void __iomem *spbcap;
24 void __iomem *mlcap;
25 void __iomem *gtscap;
26
27 struct list_head hlink_list;
28};
29
30int snd_hdac_ext_bus_init(struct hdac_ext_bus *sbus, struct device *dev,
31 const struct hdac_bus_ops *ops,
32 const struct hdac_io_ops *io_ops);
33
34void snd_hdac_ext_bus_exit(struct hdac_ext_bus *sbus);
35int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr);
36void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
Vinod Koulee2d51b2015-08-21 15:47:40 +053037void snd_hdac_ext_bus_device_remove(struct hdac_ext_bus *ebus);
Jeeja KPdfe66a12015-06-11 14:11:47 +053038
39#define ebus_to_hbus(ebus) (&(ebus)->bus)
40#define hbus_to_ebus(_bus) \
41 container_of(_bus, struct hdac_ext_bus, bus)
42
Subhransu S. Prustyb6e84c92015-10-19 16:58:46 +053043#define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \
44 { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \
45 .api_version = HDA_DEV_ASOC, \
46 .driver_data = (unsigned long)(drv_data) }
47#define HDA_CODEC_EXT_ENTRY(_vid, _revid, _name, _drv_data) \
48 HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data)
49
Jeeja KPdfe66a12015-06-11 14:11:47 +053050int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus);
51void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable);
52void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable);
53
Jeeja KP0b00a562015-06-11 14:11:48 +053054void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip,
55 bool enable, int index);
56
57int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *bus);
Jeeja KP0b00a562015-06-11 14:11:48 +053058struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *bus,
59 const char *codec_name);
60
61enum hdac_ext_stream_type {
62 HDAC_EXT_STREAM_TYPE_COUPLED = 0,
63 HDAC_EXT_STREAM_TYPE_HOST,
64 HDAC_EXT_STREAM_TYPE_LINK
65};
66
Jeeja KPdf203a42015-06-11 14:11:49 +053067/**
68 * hdac_ext_stream: HDAC extended stream for extended HDA caps
69 *
70 * @hstream: hdac_stream
71 * @pphc_addr: processing pipe host stream pointer
72 * @pplc_addr: processing pipe link stream pointer
Jeeja KPee8bc4d2015-08-21 21:36:20 +053073 * @spib_addr: software position in buffers stream pointer
74 * @fifo_addr: software position Max fifos stream pointer
Jeeja KPdf203a42015-06-11 14:11:49 +053075 * @decoupled: stream host and link is decoupled
76 * @link_locked: link is locked
77 * @link_prepared: link is prepared
78 * link_substream: link substream
79 */
80struct hdac_ext_stream {
81 struct hdac_stream hstream;
82
83 void __iomem *pphc_addr;
84 void __iomem *pplc_addr;
85
Jeeja KPee8bc4d2015-08-21 21:36:20 +053086 void __iomem *spib_addr;
87 void __iomem *fifo_addr;
88
Jeeja KPdf203a42015-06-11 14:11:49 +053089 bool decoupled:1;
90 bool link_locked:1;
91 bool link_prepared;
92
93 struct snd_pcm_substream *link_substream;
94};
95
96#define hdac_stream(s) (&(s)->hstream)
97#define stream_to_hdac_ext_stream(s) \
98 container_of(s, struct hdac_ext_stream, hstream)
99
100void snd_hdac_ext_stream_init(struct hdac_ext_bus *bus,
101 struct hdac_ext_stream *stream, int idx,
102 int direction, int tag);
Vinod Koule7a34842015-06-17 11:20:16 +0530103int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx,
104 int num_stream, int dir);
105void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus);
Vinod Koulbab44452015-06-17 11:20:17 +0530106void snd_hdac_link_free_all(struct hdac_ext_bus *ebus);
Jeeja KPdf203a42015-06-11 14:11:49 +0530107struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus,
108 struct snd_pcm_substream *substream,
109 int type);
110void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type);
111void snd_hdac_ext_stream_decouple(struct hdac_ext_bus *bus,
112 struct hdac_ext_stream *azx_dev, bool decouple);
113void snd_hdac_ext_stop_streams(struct hdac_ext_bus *sbus);
114
Jeeja KPee8bc4d2015-08-21 21:36:20 +0530115int snd_hdac_ext_stream_set_spib(struct hdac_ext_bus *ebus,
116 struct hdac_ext_stream *stream, u32 value);
Vinod Koul54d1d2f2015-08-23 11:52:50 +0530117int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_ext_bus *ebus,
Jeeja KPee8bc4d2015-08-21 21:36:20 +0530118 struct hdac_ext_stream *stream);
119
Jeeja KPdf203a42015-06-11 14:11:49 +0530120void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream);
121void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream);
122void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream);
123int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt);
124
Jeeja KP0b00a562015-06-11 14:11:48 +0530125struct hdac_ext_link {
126 struct hdac_bus *bus;
127 int index;
128 void __iomem *ml_addr; /* link output stream reg pointer */
129 u32 lcaps; /* link capablities */
130 u16 lsdiid; /* link sdi identifier */
131 struct list_head list;
132};
133
134int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link);
135int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link);
Jeeja KPc5b0c092015-08-21 21:36:18 +0530136int snd_hdac_ext_bus_link_power_down_all(struct hdac_ext_bus *ebus);
Jeeja KP0b00a562015-06-11 14:11:48 +0530137void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link,
138 int stream);
139void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
140 int stream);
141
142/* update register macro */
143#define snd_hdac_updatel(addr, reg, mask, val) \
144 writel(((readl(addr + reg) & ~(mask)) | (val)), \
145 addr + reg)
146
Jeeja KPdf203a42015-06-11 14:11:49 +0530147#define snd_hdac_updatew(addr, reg, mask, val) \
148 writew(((readw(addr + reg) & ~(mask)) | (val)), \
149 addr + reg)
150
Vinod Koula512f562015-08-21 15:47:41 +0530151
152struct hdac_ext_device;
153
154/* ops common to all codec drivers */
155struct hdac_ext_codec_ops {
156 int (*build_controls)(struct hdac_ext_device *dev);
157 int (*init)(struct hdac_ext_device *dev);
158 void (*free)(struct hdac_ext_device *dev);
159};
160
161struct hda_dai_map {
162 char *dai_name;
163 hda_nid_t nid;
164 u32 maxbps;
165};
166
167#define HDA_MAX_NIDS 16
168
169/**
170 * struct hdac_ext_device - HDAC Ext device
171 *
172 * @hdac: hdac core device
173 * @nid_list - the dai map which matches the dai-name with the nid
174 * @map_cur_idx - the idx in use in dai_map
175 * @ops - the hda codec ops common to all codec drivers
176 * @pvt_data - private data, for asoc contains asoc codec object
177 */
178struct hdac_ext_device {
179 struct hdac_device hdac;
180 struct hdac_ext_bus *ebus;
181
182 /* soc-dai to nid map */
183 struct hda_dai_map nid_list[HDA_MAX_NIDS];
184 unsigned int map_cur_idx;
185
186 /* codec ops */
187 struct hdac_ext_codec_ops ops;
188
Subhransu S. Prusty1e83b042015-11-10 18:42:05 +0530189 struct snd_card *card;
190 void *scodec;
Vinod Koula512f562015-08-21 15:47:41 +0530191 void *private_data;
192};
193
Subhransu S. Prusty1e83b042015-11-10 18:42:05 +0530194struct hdac_ext_dma_params {
195 u32 format;
196 u8 stream_tag;
197};
Vinod Koula512f562015-08-21 15:47:41 +0530198#define to_ehdac_device(dev) (container_of((dev), \
199 struct hdac_ext_device, hdac))
Vinod Kould51783c2015-08-21 15:47:42 +0530200/*
201 * HD-audio codec base driver
202 */
203struct hdac_ext_driver {
204 struct hdac_driver hdac;
205
206 int (*probe)(struct hdac_ext_device *dev);
207 int (*remove)(struct hdac_ext_device *dev);
208 void (*shutdown)(struct hdac_ext_device *dev);
209};
210
211int snd_hda_ext_driver_register(struct hdac_ext_driver *drv);
212void snd_hda_ext_driver_unregister(struct hdac_ext_driver *drv);
213
214#define to_ehdac_driver(_drv) container_of(_drv, struct hdac_ext_driver, hdac)
Vinod Koula512f562015-08-21 15:47:41 +0530215
Jeeja KPdfe66a12015-06-11 14:11:47 +0530216#endif /* __SOUND_HDAUDIO_EXT_H */