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 #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)
50 int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus
*sbus
);
51 void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus
*chip
, bool enable
);
52 void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus
*chip
, bool enable
);
54 void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus
*chip
,
55 bool enable
, int index
);
57 int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus
*bus
);
58 struct hdac_ext_link
*snd_hdac_ext_bus_get_link(struct hdac_ext_bus
*bus
,
59 const char *codec_name
);
61 enum hdac_ext_stream_type
{
62 HDAC_EXT_STREAM_TYPE_COUPLED
= 0,
63 HDAC_EXT_STREAM_TYPE_HOST
,
64 HDAC_EXT_STREAM_TYPE_LINK
68 * hdac_ext_stream: HDAC extended stream for extended HDA caps
70 * @hstream: hdac_stream
71 * @pphc_addr: processing pipe host stream pointer
72 * @pplc_addr: processing pipe link stream pointer
73 * @spib_addr: software position in buffers stream pointer
74 * @fifo_addr: software position Max fifos stream pointer
75 * @decoupled: stream host and link is decoupled
76 * @link_locked: link is locked
77 * @link_prepared: link is prepared
78 * link_substream: link substream
80 struct hdac_ext_stream
{
81 struct hdac_stream hstream
;
83 void __iomem
*pphc_addr
;
84 void __iomem
*pplc_addr
;
86 void __iomem
*spib_addr
;
87 void __iomem
*fifo_addr
;
93 struct snd_pcm_substream
*link_substream
;
96 #define hdac_stream(s) (&(s)->hstream)
97 #define stream_to_hdac_ext_stream(s) \
98 container_of(s, struct hdac_ext_stream, hstream)
100 void snd_hdac_ext_stream_init(struct hdac_ext_bus
*bus
,
101 struct hdac_ext_stream
*stream
, int idx
,
102 int direction
, int tag
);
103 int snd_hdac_ext_stream_init_all(struct hdac_ext_bus
*ebus
, int start_idx
,
104 int num_stream
, int dir
);
105 void snd_hdac_stream_free_all(struct hdac_ext_bus
*ebus
);
106 void snd_hdac_link_free_all(struct hdac_ext_bus
*ebus
);
107 struct hdac_ext_stream
*snd_hdac_ext_stream_assign(struct hdac_ext_bus
*bus
,
108 struct snd_pcm_substream
*substream
,
110 void snd_hdac_ext_stream_release(struct hdac_ext_stream
*azx_dev
, int type
);
111 void snd_hdac_ext_stream_decouple(struct hdac_ext_bus
*bus
,
112 struct hdac_ext_stream
*azx_dev
, bool decouple
);
113 void snd_hdac_ext_stop_streams(struct hdac_ext_bus
*sbus
);
115 int snd_hdac_ext_stream_set_spib(struct hdac_ext_bus
*ebus
,
116 struct hdac_ext_stream
*stream
, u32 value
);
117 int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_ext_bus
*ebus
,
118 struct hdac_ext_stream
*stream
);
120 void snd_hdac_ext_link_stream_start(struct hdac_ext_stream
*hstream
);
121 void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream
*hstream
);
122 void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream
*hstream
);
123 int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream
*stream
, int fmt
);
125 struct hdac_ext_link
{
126 struct hdac_bus
*bus
;
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
;
134 int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link
*link
);
135 int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link
*link
);
136 int snd_hdac_ext_bus_link_power_down_all(struct hdac_ext_bus
*ebus
);
137 void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link
*link
,
139 void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link
*link
,
142 /* update register macro */
143 #define snd_hdac_updatel(addr, reg, mask, val) \
144 writel(((readl(addr + reg) & ~(mask)) | (val)), \
147 #define snd_hdac_updatew(addr, reg, mask, val) \
148 writew(((readw(addr + reg) & ~(mask)) | (val)), \
152 struct hdac_ext_device
;
154 /* ops common to all codec drivers */
155 struct 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
);
167 #define HDA_MAX_NIDS 16
170 * struct hdac_ext_device - HDAC Ext device
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
178 struct hdac_ext_device
{
179 struct hdac_device hdac
;
180 struct hdac_ext_bus
*ebus
;
182 /* soc-dai to nid map */
183 struct hda_dai_map nid_list
[HDA_MAX_NIDS
];
184 unsigned int map_cur_idx
;
187 struct hdac_ext_codec_ops ops
;
192 #define to_ehdac_device(dev) (container_of((dev), \
193 struct hdac_ext_device, hdac))
195 * HD-audio codec base driver
197 struct hdac_ext_driver
{
198 struct hdac_driver hdac
;
200 int (*probe
)(struct hdac_ext_device
*dev
);
201 int (*remove
)(struct hdac_ext_device
*dev
);
202 void (*shutdown
)(struct hdac_ext_device
*dev
);
205 int snd_hda_ext_driver_register(struct hdac_ext_driver
*drv
);
206 void snd_hda_ext_driver_unregister(struct hdac_ext_driver
*drv
);
208 #define to_ehdac_driver(_drv) container_of(_drv, struct hdac_ext_driver, hdac)
210 #endif /* __SOUND_HDAUDIO_EXT_H */