Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 1 | #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 | */ |
| 17 | struct 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 | |
| 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); |
| 33 | |
| 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); |
Vinod Koul | ee2d51b | 2015-08-21 15:47:40 +0530 | [diff] [blame] | 37 | void snd_hdac_ext_bus_device_remove(struct hdac_ext_bus *ebus); |
Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 38 | |
| 39 | #define ebus_to_hbus(ebus) (&(ebus)->bus) |
| 40 | #define hbus_to_ebus(_bus) \ |
| 41 | container_of(_bus, struct hdac_ext_bus, bus) |
| 42 | |
Subhransu S. Prusty | b6e84c9 | 2015-10-19 16:58:46 +0530 | [diff] [blame] | 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) |
| 49 | |
Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 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); |
| 53 | |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 54 | void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip, |
| 55 | bool enable, int index); |
| 56 | |
| 57 | int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *bus); |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 58 | struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *bus, |
| 59 | const char *codec_name); |
| 60 | |
| 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 |
| 65 | }; |
| 66 | |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 67 | /** |
| 68 | * hdac_ext_stream: HDAC extended stream for extended HDA caps |
| 69 | * |
| 70 | * @hstream: hdac_stream |
| 71 | * @pphc_addr: processing pipe host stream pointer |
| 72 | * @pplc_addr: processing pipe link stream pointer |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 73 | * @spib_addr: software position in buffers stream pointer |
| 74 | * @fifo_addr: software position Max fifos stream pointer |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 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 |
| 79 | */ |
| 80 | struct hdac_ext_stream { |
| 81 | struct hdac_stream hstream; |
| 82 | |
| 83 | void __iomem *pphc_addr; |
| 84 | void __iomem *pplc_addr; |
| 85 | |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 86 | void __iomem *spib_addr; |
| 87 | void __iomem *fifo_addr; |
| 88 | |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 89 | bool decoupled:1; |
| 90 | bool link_locked:1; |
| 91 | bool link_prepared; |
| 92 | |
| 93 | struct snd_pcm_substream *link_substream; |
| 94 | }; |
| 95 | |
| 96 | #define hdac_stream(s) (&(s)->hstream) |
| 97 | #define stream_to_hdac_ext_stream(s) \ |
| 98 | container_of(s, struct hdac_ext_stream, hstream) |
| 99 | |
| 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); |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 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); |
Vinod Koul | bab4445 | 2015-06-17 11:20:17 +0530 | [diff] [blame] | 106 | void snd_hdac_link_free_all(struct hdac_ext_bus *ebus); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 107 | struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus, |
| 108 | struct snd_pcm_substream *substream, |
| 109 | int type); |
| 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); |
| 114 | |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 115 | int snd_hdac_ext_stream_set_spib(struct hdac_ext_bus *ebus, |
| 116 | struct hdac_ext_stream *stream, u32 value); |
Vinod Koul | 54d1d2f | 2015-08-23 11:52:50 +0530 | [diff] [blame] | 117 | int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_ext_bus *ebus, |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 118 | struct hdac_ext_stream *stream); |
| 119 | |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 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); |
| 124 | |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 125 | struct hdac_ext_link { |
| 126 | struct hdac_bus *bus; |
| 127 | int index; |
| 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; |
| 132 | }; |
| 133 | |
| 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); |
Jeeja KP | c5b0c09 | 2015-08-21 21:36:18 +0530 | [diff] [blame] | 136 | int snd_hdac_ext_bus_link_power_down_all(struct hdac_ext_bus *ebus); |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 137 | void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link, |
| 138 | int stream); |
| 139 | void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link, |
| 140 | int stream); |
| 141 | |
| 142 | /* update register macro */ |
| 143 | #define snd_hdac_updatel(addr, reg, mask, val) \ |
| 144 | writel(((readl(addr + reg) & ~(mask)) | (val)), \ |
| 145 | addr + reg) |
| 146 | |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 147 | #define snd_hdac_updatew(addr, reg, mask, val) \ |
| 148 | writew(((readw(addr + reg) & ~(mask)) | (val)), \ |
| 149 | addr + reg) |
| 150 | |
Vinod Koul | a512f56 | 2015-08-21 15:47:41 +0530 | [diff] [blame] | 151 | |
| 152 | struct hdac_ext_device; |
| 153 | |
| 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); |
| 159 | }; |
| 160 | |
| 161 | struct hda_dai_map { |
| 162 | char *dai_name; |
| 163 | hda_nid_t nid; |
| 164 | u32 maxbps; |
| 165 | }; |
| 166 | |
| 167 | #define HDA_MAX_NIDS 16 |
| 168 | |
| 169 | /** |
| 170 | * struct hdac_ext_device - HDAC Ext device |
| 171 | * |
| 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 |
| 177 | */ |
| 178 | struct hdac_ext_device { |
| 179 | struct hdac_device hdac; |
| 180 | struct hdac_ext_bus *ebus; |
| 181 | |
| 182 | /* soc-dai to nid map */ |
| 183 | struct hda_dai_map nid_list[HDA_MAX_NIDS]; |
| 184 | unsigned int map_cur_idx; |
| 185 | |
| 186 | /* codec ops */ |
| 187 | struct hdac_ext_codec_ops ops; |
| 188 | |
Subhransu S. Prusty | 1e83b04 | 2015-11-10 18:42:05 +0530 | [diff] [blame^] | 189 | struct snd_card *card; |
| 190 | void *scodec; |
Vinod Koul | a512f56 | 2015-08-21 15:47:41 +0530 | [diff] [blame] | 191 | void *private_data; |
| 192 | }; |
| 193 | |
Subhransu S. Prusty | 1e83b04 | 2015-11-10 18:42:05 +0530 | [diff] [blame^] | 194 | struct hdac_ext_dma_params { |
| 195 | u32 format; |
| 196 | u8 stream_tag; |
| 197 | }; |
Vinod Koul | a512f56 | 2015-08-21 15:47:41 +0530 | [diff] [blame] | 198 | #define to_ehdac_device(dev) (container_of((dev), \ |
| 199 | struct hdac_ext_device, hdac)) |
Vinod Koul | d51783c | 2015-08-21 15:47:42 +0530 | [diff] [blame] | 200 | /* |
| 201 | * HD-audio codec base driver |
| 202 | */ |
| 203 | struct hdac_ext_driver { |
| 204 | struct hdac_driver hdac; |
| 205 | |
| 206 | int (*probe)(struct hdac_ext_device *dev); |
| 207 | int (*remove)(struct hdac_ext_device *dev); |
| 208 | void (*shutdown)(struct hdac_ext_device *dev); |
| 209 | }; |
| 210 | |
| 211 | int snd_hda_ext_driver_register(struct hdac_ext_driver *drv); |
| 212 | void snd_hda_ext_driver_unregister(struct hdac_ext_driver *drv); |
| 213 | |
| 214 | #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] | 215 | |
Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 216 | #endif /* __SOUND_HDAUDIO_EXT_H */ |