blob: 77123c3e4095b179d5aec0b7bb5b7db4cffbc246 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Jeeja KPdfe66a12015-06-11 14:11:47 +05302#ifndef __SOUND_HDAUDIO_EXT_H
3#define __SOUND_HDAUDIO_EXT_H
4
5#include <sound/hdaudio.h>
6
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -05007int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev,
Jeeja KPdfe66a12015-06-11 14:11:47 +05308 const struct hdac_bus_ops *ops,
Rakesh Ughrejacb04ba32018-06-01 22:53:58 -05009 const struct hdac_ext_bus_ops *ext_ops);
Jeeja KPdfe66a12015-06-11 14:11:47 +053010
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050011void snd_hdac_ext_bus_exit(struct hdac_bus *bus);
Rakesh Ughreja62985422018-06-01 22:53:57 -050012int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr,
Kai Vehmanen163cd102020-09-21 13:08:41 +030013 struct hdac_device *hdev, int type);
Jeeja KPdfe66a12015-06-11 14:11:47 +053014void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050015void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus);
Jeeja KPdfe66a12015-06-11 14:11:47 +053016
Subhransu S. Prustyb6e84c92015-10-19 16:58:46 +053017#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
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050024void 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);
Jeeja KPdfe66a12015-06-11 14:11:47 +053026
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050027void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *chip,
Jeeja KP0b00a562015-06-11 14:11:48 +053028 bool enable, int index);
29
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050030int 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,
Jeeja KP0b00a562015-06-11 14:11:48 +053032 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
Jeeja KPdf203a42015-06-11 14:11:49 +053040/**
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
Jeeja KPee8bc4d2015-08-21 21:36:20 +053046 * @spib_addr: software position in buffers stream pointer
47 * @fifo_addr: software position Max fifos stream pointer
Jeeja KPa9c48f72015-12-18 15:11:59 +053048 * @dpibr_addr: DMA position in buffer resume pointer
49 * @dpib: DMA position in buffer
50 * @lpib: Linear position in buffer
Jeeja KPdf203a42015-06-11 14:11:49 +053051 * @decoupled: stream host and link is decoupled
52 * @link_locked: link is locked
53 * @link_prepared: link is prepared
Pierre-Louis Bossart0c4aa672021-08-12 17:59:04 -050054 * @link_substream: link substream
Jeeja KPdf203a42015-06-11 14:11:49 +053055 */
56struct hdac_ext_stream {
57 struct hdac_stream hstream;
58
59 void __iomem *pphc_addr;
60 void __iomem *pplc_addr;
61
Jeeja KPee8bc4d2015-08-21 21:36:20 +053062 void __iomem *spib_addr;
63 void __iomem *fifo_addr;
64
Jeeja KPa9c48f72015-12-18 15:11:59 +053065 void __iomem *dpibr_addr;
66
67 u32 dpib;
68 u32 lpib;
Jeeja KPdf203a42015-06-11 14:11:49 +053069 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
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050080void snd_hdac_ext_stream_init(struct hdac_bus *bus,
Pierre-Louis Bossart0f7e5ee2021-12-16 17:11:28 -060081 struct hdac_ext_stream *hext_stream, int idx,
82 int direction, int tag);
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050083int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
Pierre-Louis Bossart0f7e5ee2021-12-16 17:11:28 -060084 int num_stream, int dir);
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050085void 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,
Jeeja KPdf203a42015-06-11 14:11:49 +053088 struct snd_pcm_substream *substream,
89 int type);
Pierre-Louis Bossart0f7e5ee2021-12-16 17:11:28 -060090void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type);
Pierre-Louis Bossart868ddfc2021-09-24 14:24:16 -050091void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus,
Pierre-Louis Bossart0f7e5ee2021-12-16 17:11:28 -060092 struct hdac_ext_stream *hext_stream, bool decouple);
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050093void snd_hdac_ext_stream_decouple(struct hdac_bus *bus,
Jeeja KPdf203a42015-06-11 14:11:49 +053094 struct hdac_ext_stream *azx_dev, bool decouple);
Jeeja KPdf203a42015-06-11 14:11:49 +053095
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050096int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus,
Pierre-Louis Bossart0f7e5ee2021-12-16 17:11:28 -060097 struct hdac_ext_stream *hext_stream, u32 value);
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -050098int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus,
Pierre-Louis Bossart0f7e5ee2021-12-16 17:11:28 -060099 struct hdac_ext_stream *hext_stream);
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -0500100void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus,
Jeeja KPa9c48f72015-12-18 15:11:59 +0530101 bool enable, int index);
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -0500102int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus,
Pierre-Louis Bossart0f7e5ee2021-12-16 17:11:28 -0600103 struct hdac_ext_stream *hext_stream, u32 value);
104int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *hext_stream, u32 value);
Jeeja KPee8bc4d2015-08-21 21:36:20 +0530105
Pierre-Louis Bossart0f7e5ee2021-12-16 17:11:28 -0600106void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hext_stream);
107void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hext_stream);
108void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hext_stream);
109int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *hext_stream, int fmt);
Jeeja KPdf203a42015-06-11 14:11:49 +0530110
Jeeja KP0b00a562015-06-11 14:11:48 +0530111struct hdac_ext_link {
112 struct hdac_bus *bus;
113 int index;
114 void __iomem *ml_addr; /* link output stream reg pointer */
115 u32 lcaps; /* link capablities */
116 u16 lsdiid; /* link sdi identifier */
Vinod Koul4446085d2016-05-12 08:58:53 +0530117
118 int ref_count;
119
Jeeja KP0b00a562015-06-11 14:11:48 +0530120 struct list_head list;
121};
122
123int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link);
124int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link);
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -0500125int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus);
126int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus);
Jeeja KP0b00a562015-06-11 14:11:48 +0530127void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link,
128 int stream);
129void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
130 int stream);
131
Rakesh Ughreja76f56fa2018-06-01 22:53:50 -0500132int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, struct hdac_ext_link *link);
133int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *link);
Vinod Koul4446085d2016-05-12 08:58:53 +0530134
Kai Vehmanenf9e5fd12021-02-05 20:46:28 +0200135void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable);
136
Jeeja KP0b00a562015-06-11 14:11:48 +0530137/* update register macro */
138#define snd_hdac_updatel(addr, reg, mask, val) \
139 writel(((readl(addr + reg) & ~(mask)) | (val)), \
140 addr + reg)
141
Jeeja KPdf203a42015-06-11 14:11:49 +0530142#define snd_hdac_updatew(addr, reg, mask, val) \
143 writew(((readw(addr + reg) & ~(mask)) | (val)), \
144 addr + reg)
145
Vinod Koula512f562015-08-21 15:47:41 +0530146
147struct hdac_ext_device;
148
149/* ops common to all codec drivers */
150struct hdac_ext_codec_ops {
151 int (*build_controls)(struct hdac_ext_device *dev);
152 int (*init)(struct hdac_ext_device *dev);
153 void (*free)(struct hdac_ext_device *dev);
154};
155
156struct hda_dai_map {
157 char *dai_name;
158 hda_nid_t nid;
159 u32 maxbps;
160};
161
Subhransu S. Prusty1e83b042015-11-10 18:42:05 +0530162struct hdac_ext_dma_params {
163 u32 format;
164 u8 stream_tag;
165};
Rakesh Ughreja3787a392018-06-01 22:53:49 -0500166
Rakesh Ughrejae1df9312018-06-01 22:53:51 -0500167int snd_hda_ext_driver_register(struct hdac_driver *drv);
168void snd_hda_ext_driver_unregister(struct hdac_driver *drv);
Vinod Koula512f562015-08-21 15:47:41 +0530169
Jeeja KPdfe66a12015-06-11 14:11:47 +0530170#endif /* __SOUND_HDAUDIO_EXT_H */