Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 2 | #ifndef __SOUND_HDAUDIO_EXT_H |
| 3 | #define __SOUND_HDAUDIO_EXT_H |
| 4 | |
| 5 | #include <sound/hdaudio.h> |
| 6 | |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 7 | int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, |
Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 8 | const struct hdac_bus_ops *ops, |
| 9 | const struct hdac_io_ops *io_ops); |
| 10 | |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 11 | void snd_hdac_ext_bus_exit(struct hdac_bus *bus); |
| 12 | int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr); |
Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 13 | void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev); |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 14 | void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus); |
Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 15 | |
Subhransu S. Prusty | b6e84c9 | 2015-10-19 16:58:46 +0530 | [diff] [blame] | 16 | #define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \ |
| 17 | { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \ |
| 18 | .api_version = HDA_DEV_ASOC, \ |
| 19 | .driver_data = (unsigned long)(drv_data) } |
| 20 | #define HDA_CODEC_EXT_ENTRY(_vid, _revid, _name, _drv_data) \ |
| 21 | HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data) |
| 22 | |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 23 | void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *chip, bool enable); |
| 24 | void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *chip, bool enable); |
Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 25 | |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 26 | void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *chip, |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 27 | bool enable, int index); |
| 28 | |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 29 | int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus); |
| 30 | struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus, |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 31 | const char *codec_name); |
| 32 | |
| 33 | enum hdac_ext_stream_type { |
| 34 | HDAC_EXT_STREAM_TYPE_COUPLED = 0, |
| 35 | HDAC_EXT_STREAM_TYPE_HOST, |
| 36 | HDAC_EXT_STREAM_TYPE_LINK |
| 37 | }; |
| 38 | |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 39 | /** |
| 40 | * hdac_ext_stream: HDAC extended stream for extended HDA caps |
| 41 | * |
| 42 | * @hstream: hdac_stream |
| 43 | * @pphc_addr: processing pipe host stream pointer |
| 44 | * @pplc_addr: processing pipe link stream pointer |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 45 | * @spib_addr: software position in buffers stream pointer |
| 46 | * @fifo_addr: software position Max fifos stream pointer |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 47 | * @dpibr_addr: DMA position in buffer resume pointer |
| 48 | * @dpib: DMA position in buffer |
| 49 | * @lpib: Linear position in buffer |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 50 | * @decoupled: stream host and link is decoupled |
| 51 | * @link_locked: link is locked |
| 52 | * @link_prepared: link is prepared |
| 53 | * link_substream: link substream |
| 54 | */ |
| 55 | struct hdac_ext_stream { |
| 56 | struct hdac_stream hstream; |
| 57 | |
| 58 | void __iomem *pphc_addr; |
| 59 | void __iomem *pplc_addr; |
| 60 | |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 61 | void __iomem *spib_addr; |
| 62 | void __iomem *fifo_addr; |
| 63 | |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 64 | void __iomem *dpibr_addr; |
| 65 | |
| 66 | u32 dpib; |
| 67 | u32 lpib; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 68 | bool decoupled:1; |
| 69 | bool link_locked:1; |
| 70 | bool link_prepared; |
| 71 | |
| 72 | struct snd_pcm_substream *link_substream; |
| 73 | }; |
| 74 | |
| 75 | #define hdac_stream(s) (&(s)->hstream) |
| 76 | #define stream_to_hdac_ext_stream(s) \ |
| 77 | container_of(s, struct hdac_ext_stream, hstream) |
| 78 | |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 79 | void snd_hdac_ext_stream_init(struct hdac_bus *bus, |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 80 | struct hdac_ext_stream *stream, int idx, |
| 81 | int direction, int tag); |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 82 | int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 83 | int num_stream, int dir); |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 84 | void snd_hdac_stream_free_all(struct hdac_bus *bus); |
| 85 | void snd_hdac_link_free_all(struct hdac_bus *bus); |
| 86 | struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus, |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 87 | struct snd_pcm_substream *substream, |
| 88 | int type); |
| 89 | void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type); |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 90 | void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 91 | struct hdac_ext_stream *azx_dev, bool decouple); |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 92 | void snd_hdac_ext_stop_streams(struct hdac_bus *bus); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 93 | |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 94 | int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus, |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 95 | struct hdac_ext_stream *stream, u32 value); |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 96 | int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus, |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 97 | struct hdac_ext_stream *stream); |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 98 | void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus, |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 99 | bool enable, int index); |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 100 | int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus, |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 101 | struct hdac_ext_stream *stream, u32 value); |
| 102 | int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *stream, u32 value); |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 103 | |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 104 | void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream); |
| 105 | void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream); |
| 106 | void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream); |
| 107 | int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt); |
| 108 | |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 109 | struct hdac_ext_link { |
| 110 | struct hdac_bus *bus; |
| 111 | int index; |
| 112 | void __iomem *ml_addr; /* link output stream reg pointer */ |
| 113 | u32 lcaps; /* link capablities */ |
| 114 | u16 lsdiid; /* link sdi identifier */ |
Vinod Koul | 4446085d | 2016-05-12 08:58:53 +0530 | [diff] [blame] | 115 | |
| 116 | int ref_count; |
| 117 | |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 118 | struct list_head list; |
| 119 | }; |
| 120 | |
| 121 | int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link); |
| 122 | int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link); |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 123 | int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus); |
| 124 | int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus); |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 125 | void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link, |
| 126 | int stream); |
| 127 | void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link, |
| 128 | int stream); |
| 129 | |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame^] | 130 | int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, struct hdac_ext_link *link); |
| 131 | int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *link); |
Vinod Koul | 4446085d | 2016-05-12 08:58:53 +0530 | [diff] [blame] | 132 | |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 133 | /* update register macro */ |
| 134 | #define snd_hdac_updatel(addr, reg, mask, val) \ |
| 135 | writel(((readl(addr + reg) & ~(mask)) | (val)), \ |
| 136 | addr + reg) |
| 137 | |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 138 | #define snd_hdac_updatew(addr, reg, mask, val) \ |
| 139 | writew(((readw(addr + reg) & ~(mask)) | (val)), \ |
| 140 | addr + reg) |
| 141 | |
Vinod Koul | a512f56 | 2015-08-21 15:47:41 +0530 | [diff] [blame] | 142 | |
| 143 | struct hdac_ext_device; |
| 144 | |
| 145 | /* ops common to all codec drivers */ |
| 146 | struct hdac_ext_codec_ops { |
| 147 | int (*build_controls)(struct hdac_ext_device *dev); |
| 148 | int (*init)(struct hdac_ext_device *dev); |
| 149 | void (*free)(struct hdac_ext_device *dev); |
| 150 | }; |
| 151 | |
| 152 | struct hda_dai_map { |
| 153 | char *dai_name; |
| 154 | hda_nid_t nid; |
| 155 | u32 maxbps; |
| 156 | }; |
| 157 | |
Subhransu S. Prusty | 1e83b04 | 2015-11-10 18:42:05 +0530 | [diff] [blame] | 158 | struct hdac_ext_dma_params { |
| 159 | u32 format; |
| 160 | u8 stream_tag; |
| 161 | }; |
Rakesh Ughreja | 3787a39 | 2018-06-01 22:53:49 -0500 | [diff] [blame] | 162 | |
Vinod Koul | d51783c | 2015-08-21 15:47:42 +0530 | [diff] [blame] | 163 | /* |
| 164 | * HD-audio codec base driver |
| 165 | */ |
| 166 | struct hdac_ext_driver { |
| 167 | struct hdac_driver hdac; |
| 168 | |
Rakesh Ughreja | 3787a39 | 2018-06-01 22:53:49 -0500 | [diff] [blame] | 169 | int (*probe)(struct hdac_device *dev); |
| 170 | int (*remove)(struct hdac_device *dev); |
| 171 | void (*shutdown)(struct hdac_device *dev); |
Vinod Koul | d51783c | 2015-08-21 15:47:42 +0530 | [diff] [blame] | 172 | }; |
| 173 | |
| 174 | int snd_hda_ext_driver_register(struct hdac_ext_driver *drv); |
| 175 | void snd_hda_ext_driver_unregister(struct hdac_ext_driver *drv); |
| 176 | |
| 177 | #define to_ehdac_driver(_drv) container_of(_drv, struct hdac_ext_driver, hdac) |
Vinod Koul | a512f56 | 2015-08-21 15:47:41 +0530 | [diff] [blame] | 178 | |
Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 179 | #endif /* __SOUND_HDAUDIO_EXT_H */ |