1 #ifndef __SOUND_HDAUDIO_EXT_H
2 #define __SOUND_HDAUDIO_EXT_H
4 #include <sound/hdaudio.h>
7 * hdac_ext_bus: HDAC extended bus for extended HDA caps
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
27 struct list_head hlink_list;
30 int 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);
34 void snd_hdac_ext_bus_exit(struct hdac_ext_bus *sbus);
35 int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr);
36 void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
37 void snd_hdac_ext_bus_device_remove(struct hdac_ext_bus *ebus);
39 #define ebus_to_hbus(ebus) (&(ebus)->bus)
40 #define hbus_to_ebus(_bus) \
41 container_of(_bus, struct hdac_ext_bus, bus)
43 int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus);
44 void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable);
45 void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable);
47 void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip,
48 bool enable, int index);
50 int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *bus);
51 struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *bus,
52 const char *codec_name);
54 enum hdac_ext_stream_type {
55 HDAC_EXT_STREAM_TYPE_COUPLED = 0,
56 HDAC_EXT_STREAM_TYPE_HOST,
57 HDAC_EXT_STREAM_TYPE_LINK
61 * hdac_ext_stream: HDAC extended stream for extended HDA caps
63 * @hstream: hdac_stream
64 * @pphc_addr: processing pipe host stream pointer
65 * @pplc_addr: processing pipe link stream pointer
66 * @spib_addr: software position in buffers stream pointer
67 * @fifo_addr: software position Max fifos stream pointer
68 * @decoupled: stream host and link is decoupled
69 * @link_locked: link is locked
70 * @link_prepared: link is prepared
71 * link_substream: link substream
73 struct hdac_ext_stream {
74 struct hdac_stream hstream;
76 void __iomem *pphc_addr;
77 void __iomem *pplc_addr;
79 void __iomem *spib_addr;
80 void __iomem *fifo_addr;
86 struct snd_pcm_substream *link_substream;
89 #define hdac_stream(s) (&(s)->hstream)
90 #define stream_to_hdac_ext_stream(s) \
91 container_of(s, struct hdac_ext_stream, hstream)
93 void snd_hdac_ext_stream_init(struct hdac_ext_bus *bus,
94 struct hdac_ext_stream *stream, int idx,
95 int direction, int tag);
96 int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx,
97 int num_stream, int dir);
98 void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus);
99 void snd_hdac_link_free_all(struct hdac_ext_bus *ebus);
100 struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus,
101 struct snd_pcm_substream *substream,
103 void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type);
104 void snd_hdac_ext_stream_decouple(struct hdac_ext_bus *bus,
105 struct hdac_ext_stream *azx_dev, bool decouple);
106 void snd_hdac_ext_stop_streams(struct hdac_ext_bus *sbus);
108 int snd_hdac_ext_stream_set_spib(struct hdac_ext_bus *ebus,
109 struct hdac_ext_stream *stream, u32 value);
110 int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_ext_bus *ebus,
111 struct hdac_ext_stream *stream);
113 void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream);
114 void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream);
115 void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream);
116 int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt);
118 struct hdac_ext_link {
119 struct hdac_bus *bus;
121 void __iomem *ml_addr; /* link output stream reg pointer */
122 u32 lcaps; /* link capablities */
123 u16 lsdiid; /* link sdi identifier */
124 struct list_head list;
127 int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link);
128 int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link);
129 int snd_hdac_ext_bus_link_power_down_all(struct hdac_ext_bus *ebus);
130 void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link,
132 void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
135 /* update register macro */
136 #define snd_hdac_updatel(addr, reg, mask, val) \
137 writel(((readl(addr + reg) & ~(mask)) | (val)), \
140 #define snd_hdac_updatew(addr, reg, mask, val) \
141 writew(((readw(addr + reg) & ~(mask)) | (val)), \
145 struct hdac_ext_device;
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);
160 #define HDA_MAX_NIDS 16
163 * struct hdac_ext_device - HDAC Ext device
165 * @hdac: hdac core device
166 * @nid_list - the dai map which matches the dai-name with the nid
167 * @map_cur_idx - the idx in use in dai_map
168 * @ops - the hda codec ops common to all codec drivers
169 * @pvt_data - private data, for asoc contains asoc codec object
171 struct hdac_ext_device {
172 struct hdac_device hdac;
173 struct hdac_ext_bus *ebus;
175 /* soc-dai to nid map */
176 struct hda_dai_map nid_list[HDA_MAX_NIDS];
177 unsigned int map_cur_idx;
180 struct hdac_ext_codec_ops ops;
185 #define to_ehdac_device(dev) (container_of((dev), \
186 struct hdac_ext_device, hdac))
188 * HD-audio codec base driver
190 struct hdac_ext_driver {
191 struct hdac_driver hdac;
193 int (*probe)(struct hdac_ext_device *dev);
194 int (*remove)(struct hdac_ext_device *dev);
195 void (*shutdown)(struct hdac_ext_device *dev);
198 int snd_hda_ext_driver_register(struct hdac_ext_driver *drv);
199 void snd_hda_ext_driver_unregister(struct hdac_ext_driver *drv);
201 #define to_ehdac_driver(_drv) container_of(_drv, struct hdac_ext_driver, hdac)
203 #endif /* __SOUND_HDAUDIO_EXT_H */