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 | |
| 43 | int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus); |
| 44 | void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable); |
| 45 | void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); |
| 46 | |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 47 | void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip, |
| 48 | bool enable, int index); |
| 49 | |
| 50 | 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] | 51 | struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *bus, |
| 52 | const char *codec_name); |
| 53 | |
| 54 | enum 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 KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 60 | /** |
| 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 | */ |
| 71 | struct 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 | |
| 88 | void snd_hdac_ext_stream_init(struct hdac_ext_bus *bus, |
| 89 | struct hdac_ext_stream *stream, int idx, |
| 90 | int direction, int tag); |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 91 | int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx, |
| 92 | int num_stream, int dir); |
| 93 | void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus); |
Vinod Koul | bab4445 | 2015-06-17 11:20:17 +0530 | [diff] [blame] | 94 | void snd_hdac_link_free_all(struct hdac_ext_bus *ebus); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 95 | struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus, |
| 96 | struct snd_pcm_substream *substream, |
| 97 | int type); |
| 98 | void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type); |
| 99 | void snd_hdac_ext_stream_decouple(struct hdac_ext_bus *bus, |
| 100 | struct hdac_ext_stream *azx_dev, bool decouple); |
| 101 | void snd_hdac_ext_stop_streams(struct hdac_ext_bus *sbus); |
| 102 | |
| 103 | void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream); |
| 104 | void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream); |
| 105 | void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream); |
| 106 | int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt); |
| 107 | |
Jeeja KP | 0b00a56 | 2015-06-11 14:11:48 +0530 | [diff] [blame] | 108 | struct hdac_ext_link { |
| 109 | struct hdac_bus *bus; |
| 110 | int index; |
| 111 | void __iomem *ml_addr; /* link output stream reg pointer */ |
| 112 | u32 lcaps; /* link capablities */ |
| 113 | u16 lsdiid; /* link sdi identifier */ |
| 114 | struct list_head list; |
| 115 | }; |
| 116 | |
| 117 | int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link); |
| 118 | int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link); |
| 119 | void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link, |
| 120 | int stream); |
| 121 | void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link, |
| 122 | int stream); |
| 123 | |
| 124 | /* update register macro */ |
| 125 | #define snd_hdac_updatel(addr, reg, mask, val) \ |
| 126 | writel(((readl(addr + reg) & ~(mask)) | (val)), \ |
| 127 | addr + reg) |
| 128 | |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 129 | #define snd_hdac_updatew(addr, reg, mask, val) \ |
| 130 | writew(((readw(addr + reg) & ~(mask)) | (val)), \ |
| 131 | addr + reg) |
| 132 | |
Vinod Koul | a512f56 | 2015-08-21 15:47:41 +0530 | [diff] [blame^] | 133 | |
| 134 | struct hdac_ext_device; |
| 135 | |
| 136 | /* ops common to all codec drivers */ |
| 137 | struct hdac_ext_codec_ops { |
| 138 | int (*build_controls)(struct hdac_ext_device *dev); |
| 139 | int (*init)(struct hdac_ext_device *dev); |
| 140 | void (*free)(struct hdac_ext_device *dev); |
| 141 | }; |
| 142 | |
| 143 | struct hda_dai_map { |
| 144 | char *dai_name; |
| 145 | hda_nid_t nid; |
| 146 | u32 maxbps; |
| 147 | }; |
| 148 | |
| 149 | #define HDA_MAX_NIDS 16 |
| 150 | |
| 151 | /** |
| 152 | * struct hdac_ext_device - HDAC Ext device |
| 153 | * |
| 154 | * @hdac: hdac core device |
| 155 | * @nid_list - the dai map which matches the dai-name with the nid |
| 156 | * @map_cur_idx - the idx in use in dai_map |
| 157 | * @ops - the hda codec ops common to all codec drivers |
| 158 | * @pvt_data - private data, for asoc contains asoc codec object |
| 159 | */ |
| 160 | struct hdac_ext_device { |
| 161 | struct hdac_device hdac; |
| 162 | struct hdac_ext_bus *ebus; |
| 163 | |
| 164 | /* soc-dai to nid map */ |
| 165 | struct hda_dai_map nid_list[HDA_MAX_NIDS]; |
| 166 | unsigned int map_cur_idx; |
| 167 | |
| 168 | /* codec ops */ |
| 169 | struct hdac_ext_codec_ops ops; |
| 170 | |
| 171 | void *private_data; |
| 172 | }; |
| 173 | |
| 174 | #define to_ehdac_device(dev) (container_of((dev), \ |
| 175 | struct hdac_ext_device, hdac)) |
| 176 | |
Jeeja KP | dfe66a1 | 2015-06-11 14:11:47 +0530 | [diff] [blame] | 177 | #endif /* __SOUND_HDAUDIO_EXT_H */ |