blob: 0044caa1915595078974087924155fb921ae3aae [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);
37
38#define ebus_to_hbus(ebus) (&(ebus)->bus)
39#define hbus_to_ebus(_bus) \
40 container_of(_bus, struct hdac_ext_bus, bus)
41
42int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus);
43void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable);
44void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable);
45
Jeeja KP0b00a562015-06-11 14:11:48 +053046void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip,
47 bool enable, int index);
48
49int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *bus);
50int snd_hdac_ext_bus_map_codec_to_link(struct hdac_ext_bus *bus, int addr);
51struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *bus,
52 const char *codec_name);
53
54enum hdac_ext_stream_type {
55 HDAC_EXT_STREAM_TYPE_COUPLED = 0,
56 HDAC_EXT_STREAM_TYPE_HOST,
57 HDAC_EXT_STREAM_TYPE_LINK
58};
59
Jeeja KPdf203a42015-06-11 14:11:49 +053060/**
61 * hdac_ext_stream: HDAC extended stream for extended HDA caps
62 *
63 * @hstream: hdac_stream
64 * @pphc_addr: processing pipe host stream pointer
65 * @pplc_addr: processing pipe link stream pointer
66 * @decoupled: stream host and link is decoupled
67 * @link_locked: link is locked
68 * @link_prepared: link is prepared
69 * link_substream: link substream
70 */
71struct hdac_ext_stream {
72 struct hdac_stream hstream;
73
74 void __iomem *pphc_addr;
75 void __iomem *pplc_addr;
76
77 bool decoupled:1;
78 bool link_locked:1;
79 bool link_prepared;
80
81 struct snd_pcm_substream *link_substream;
82};
83
84#define hdac_stream(s) (&(s)->hstream)
85#define stream_to_hdac_ext_stream(s) \
86 container_of(s, struct hdac_ext_stream, hstream)
87
88void snd_hdac_ext_stream_init(struct hdac_ext_bus *bus,
89 struct hdac_ext_stream *stream, int idx,
90 int direction, int tag);
91struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus,
92 struct snd_pcm_substream *substream,
93 int type);
94void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type);
95void snd_hdac_ext_stream_decouple(struct hdac_ext_bus *bus,
96 struct hdac_ext_stream *azx_dev, bool decouple);
97void snd_hdac_ext_stop_streams(struct hdac_ext_bus *sbus);
98
99void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream);
100void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream);
101void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream);
102int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt);
103
Jeeja KP0b00a562015-06-11 14:11:48 +0530104struct hdac_ext_link {
105 struct hdac_bus *bus;
106 int index;
107 void __iomem *ml_addr; /* link output stream reg pointer */
108 u32 lcaps; /* link capablities */
109 u16 lsdiid; /* link sdi identifier */
110 struct list_head list;
111};
112
113int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link);
114int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link);
115void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link,
116 int stream);
117void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
118 int stream);
119
120/* update register macro */
121#define snd_hdac_updatel(addr, reg, mask, val) \
122 writel(((readl(addr + reg) & ~(mask)) | (val)), \
123 addr + reg)
124
Jeeja KPdf203a42015-06-11 14:11:49 +0530125#define snd_hdac_updatew(addr, reg, mask, val) \
126 writew(((readw(addr + reg) & ~(mask)) | (val)), \
127 addr + reg)
128
Jeeja KPdfe66a12015-06-11 14:11:47 +0530129#endif /* __SOUND_HDAUDIO_EXT_H */