Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'topic/hda-core-intel' into topic/hda-acomp

+605 -674
+29
include/sound/hdaudio.h
··· 188 188 const struct hda_device_id *id_table; 189 189 int (*match)(struct hdac_device *dev, struct hdac_driver *drv); 190 190 void (*unsol_event)(struct hdac_device *dev, unsigned int event); 191 + 192 + /* fields used by ext bus APIs */ 193 + int (*probe)(struct hdac_device *dev); 194 + int (*remove)(struct hdac_device *dev); 195 + void (*shutdown)(struct hdac_device *dev); 191 196 }; 192 197 193 198 #define drv_to_hdac_driver(_drv) container_of(_drv, struct hdac_driver, driver) ··· 211 206 unsigned int *res); 212 207 /* control the link power */ 213 208 int (*link_power)(struct hdac_bus *bus, bool enable); 209 + }; 210 + 211 + /* 212 + * ops used for ASoC HDA codec drivers 213 + */ 214 + struct hdac_ext_bus_ops { 215 + int (*hdev_attach)(struct hdac_device *hdev); 216 + int (*hdev_detach)(struct hdac_device *hdev); 214 217 }; 215 218 216 219 /* ··· 263 250 * @mlcap: MultiLink capabilities pointer 264 251 * @gtscap: gts capabilities pointer 265 252 * @drsmcap: dma resume capabilities pointer 253 + * @num_streams: streams supported 254 + * @idx: HDA link index 255 + * @hlink_list: link list of HDA links 256 + * @lock: lock for link mgmt 257 + * @cmd_dma_state: state of cmd DMAs: CORB and RIRB 266 258 */ 267 259 struct hdac_bus { 268 260 struct device *dev; 269 261 const struct hdac_bus_ops *ops; 270 262 const struct hdac_io_ops *io_ops; 263 + const struct hdac_ext_bus_ops *ext_ops; 271 264 272 265 /* h/w resources */ 273 266 unsigned long addr; ··· 336 317 /* i915 component interface */ 337 318 struct i915_audio_component *audio_component; 338 319 int i915_power_refcount; 320 + 321 + /* parameters required for enhanced capabilities */ 322 + int num_streams; 323 + int idx; 324 + 325 + struct list_head hlink_list; 326 + 327 + struct mutex lock; 328 + bool cmd_dma_state; 329 + 339 330 }; 340 331 341 332 int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev,
+29 -94
include/sound/hdaudio_ext.h
··· 4 4 5 5 #include <sound/hdaudio.h> 6 6 7 - /** 8 - * hdac_ext_bus: HDAC extended bus for extended HDA caps 9 - * 10 - * @bus: hdac bus 11 - * @num_streams: streams supported 12 - * @hlink_list: link list of HDA links 13 - * @lock: lock for link mgmt 14 - * @cmd_dma_state: state of cmd DMAs: CORB and RIRB 15 - */ 16 - struct hdac_ext_bus { 17 - struct hdac_bus bus; 18 - int num_streams; 19 - int idx; 20 - 21 - struct list_head hlink_list; 22 - 23 - struct mutex lock; 24 - bool cmd_dma_state; 25 - }; 26 - 27 - int snd_hdac_ext_bus_init(struct hdac_ext_bus *sbus, struct device *dev, 7 + int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, 28 8 const struct hdac_bus_ops *ops, 29 - const struct hdac_io_ops *io_ops); 9 + const struct hdac_io_ops *io_ops, 10 + const struct hdac_ext_bus_ops *ext_ops); 30 11 31 - void snd_hdac_ext_bus_exit(struct hdac_ext_bus *sbus); 32 - int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr); 12 + void snd_hdac_ext_bus_exit(struct hdac_bus *bus); 13 + int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr, 14 + struct hdac_device *hdev); 33 15 void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev); 34 - void snd_hdac_ext_bus_device_remove(struct hdac_ext_bus *ebus); 35 - 36 - #define ebus_to_hbus(ebus) (&(ebus)->bus) 37 - #define hbus_to_ebus(_bus) \ 38 - container_of(_bus, struct hdac_ext_bus, bus) 16 + void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus); 39 17 40 18 #define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \ 41 19 { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \ ··· 22 44 #define HDA_CODEC_EXT_ENTRY(_vid, _revid, _name, _drv_data) \ 23 45 HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data) 24 46 25 - void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable); 26 - void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); 47 + void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *chip, bool enable); 48 + void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *chip, bool enable); 27 49 28 - void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip, 50 + void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *chip, 29 51 bool enable, int index); 30 52 31 - int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *bus); 32 - struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *bus, 53 + int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus); 54 + struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus, 33 55 const char *codec_name); 34 56 35 57 enum hdac_ext_stream_type { ··· 78 100 #define stream_to_hdac_ext_stream(s) \ 79 101 container_of(s, struct hdac_ext_stream, hstream) 80 102 81 - void snd_hdac_ext_stream_init(struct hdac_ext_bus *bus, 103 + void snd_hdac_ext_stream_init(struct hdac_bus *bus, 82 104 struct hdac_ext_stream *stream, int idx, 83 105 int direction, int tag); 84 - int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx, 106 + int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, 85 107 int num_stream, int dir); 86 - void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus); 87 - void snd_hdac_link_free_all(struct hdac_ext_bus *ebus); 88 - struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus, 108 + void snd_hdac_stream_free_all(struct hdac_bus *bus); 109 + void snd_hdac_link_free_all(struct hdac_bus *bus); 110 + struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus, 89 111 struct snd_pcm_substream *substream, 90 112 int type); 91 113 void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type); 92 - void snd_hdac_ext_stream_decouple(struct hdac_ext_bus *bus, 114 + void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, 93 115 struct hdac_ext_stream *azx_dev, bool decouple); 94 - void snd_hdac_ext_stop_streams(struct hdac_ext_bus *sbus); 116 + void snd_hdac_ext_stop_streams(struct hdac_bus *bus); 95 117 96 - int snd_hdac_ext_stream_set_spib(struct hdac_ext_bus *ebus, 118 + int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus, 97 119 struct hdac_ext_stream *stream, u32 value); 98 - int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_ext_bus *ebus, 120 + int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus, 99 121 struct hdac_ext_stream *stream); 100 - void snd_hdac_ext_stream_drsm_enable(struct hdac_ext_bus *ebus, 122 + void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus, 101 123 bool enable, int index); 102 - int snd_hdac_ext_stream_set_dpibr(struct hdac_ext_bus *ebus, 124 + int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus, 103 125 struct hdac_ext_stream *stream, u32 value); 104 126 int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *stream, u32 value); 105 127 ··· 122 144 123 145 int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link); 124 146 int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link); 125 - int snd_hdac_ext_bus_link_power_up_all(struct hdac_ext_bus *ebus); 126 - int snd_hdac_ext_bus_link_power_down_all(struct hdac_ext_bus *ebus); 147 + int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus); 148 + int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus); 127 149 void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link, 128 150 int stream); 129 151 void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link, 130 152 int stream); 131 153 132 - int snd_hdac_ext_bus_link_get(struct hdac_ext_bus *ebus, 133 - struct hdac_ext_link *link); 134 - int snd_hdac_ext_bus_link_put(struct hdac_ext_bus *ebus, 135 - struct hdac_ext_link *link); 154 + int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, struct hdac_ext_link *link); 155 + int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *link); 136 156 137 157 /* update register macro */ 138 158 #define snd_hdac_updatel(addr, reg, mask, val) \ ··· 157 181 u32 maxbps; 158 182 }; 159 183 160 - #define HDA_MAX_NIDS 16 161 - 162 - /** 163 - * struct hdac_ext_device - HDAC Ext device 164 - * 165 - * @hdac: hdac core device 166 - * @nid_list - the dai map which matches the dai-name with the nid 167 - * @map_cur_idx - the idx in use in dai_map 168 - * @ops - the hda codec ops common to all codec drivers 169 - * @pvt_data - private data, for asoc contains asoc codec object 170 - */ 171 - struct hdac_ext_device { 172 - struct hdac_device hdev; 173 - struct hdac_ext_bus *ebus; 174 - 175 - /* soc-dai to nid map */ 176 - struct hda_dai_map nid_list[HDA_MAX_NIDS]; 177 - unsigned int map_cur_idx; 178 - 179 - /* codec ops */ 180 - struct hdac_ext_codec_ops ops; 181 - 182 - struct snd_card *card; 183 - void *scodec; 184 - void *private_data; 185 - }; 186 - 187 184 struct hdac_ext_dma_params { 188 185 u32 format; 189 186 u8 stream_tag; 190 187 }; 191 - #define to_ehdac_device(dev) (container_of((dev), \ 192 - struct hdac_ext_device, hdev)) 193 - /* 194 - * HD-audio codec base driver 195 - */ 196 - struct hdac_ext_driver { 197 - struct hdac_driver hdac; 198 188 199 - int (*probe)(struct hdac_ext_device *dev); 200 - int (*remove)(struct hdac_ext_device *dev); 201 - void (*shutdown)(struct hdac_ext_device *dev); 202 - }; 203 - 204 - int snd_hda_ext_driver_register(struct hdac_ext_driver *drv); 205 - void snd_hda_ext_driver_unregister(struct hdac_ext_driver *drv); 206 - 207 - #define to_ehdac_driver(_drv) container_of(_drv, struct hdac_ext_driver, hdac) 189 + int snd_hda_ext_driver_register(struct hdac_driver *drv); 190 + void snd_hda_ext_driver_unregister(struct hdac_driver *drv); 208 191 209 192 #endif /* __SOUND_HDAUDIO_EXT_H */
+35 -45
sound/hda/ext/hdac_ext_bus.c
··· 87 87 * 88 88 * Returns 0 if successful, or a negative error code. 89 89 */ 90 - int snd_hdac_ext_bus_init(struct hdac_ext_bus *ebus, struct device *dev, 90 + int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, 91 91 const struct hdac_bus_ops *ops, 92 - const struct hdac_io_ops *io_ops) 92 + const struct hdac_io_ops *io_ops, 93 + const struct hdac_ext_bus_ops *ext_ops) 93 94 { 94 95 int ret; 95 96 static int idx; ··· 99 98 if (io_ops == NULL) 100 99 io_ops = &hdac_ext_default_io; 101 100 102 - ret = snd_hdac_bus_init(&ebus->bus, dev, ops, io_ops); 101 + ret = snd_hdac_bus_init(bus, dev, ops, io_ops); 103 102 if (ret < 0) 104 103 return ret; 105 104 106 - INIT_LIST_HEAD(&ebus->hlink_list); 107 - ebus->idx = idx++; 105 + bus->ext_ops = ext_ops; 106 + INIT_LIST_HEAD(&bus->hlink_list); 107 + bus->idx = idx++; 108 108 109 - mutex_init(&ebus->lock); 110 - ebus->cmd_dma_state = true; 109 + mutex_init(&bus->lock); 110 + bus->cmd_dma_state = true; 111 111 112 112 return 0; 113 113 } ··· 118 116 * snd_hdac_ext_bus_exit - clean up a HD-audio extended bus 119 117 * @ebus: the pointer to extended bus object 120 118 */ 121 - void snd_hdac_ext_bus_exit(struct hdac_ext_bus *ebus) 119 + void snd_hdac_ext_bus_exit(struct hdac_bus *bus) 122 120 { 123 - snd_hdac_bus_exit(&ebus->bus); 124 - WARN_ON(!list_empty(&ebus->hlink_list)); 121 + snd_hdac_bus_exit(bus); 122 + WARN_ON(!list_empty(&bus->hlink_list)); 125 123 } 126 124 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_exit); 127 125 ··· 137 135 * 138 136 * Returns zero for success or a negative error code. 139 137 */ 140 - int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *ebus, int addr) 138 + int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr, 139 + struct hdac_device *hdev) 141 140 { 142 - struct hdac_ext_device *edev; 143 - struct hdac_device *hdev = NULL; 144 - struct hdac_bus *bus = ebus_to_hbus(ebus); 145 141 char name[15]; 146 142 int ret; 147 143 148 - edev = kzalloc(sizeof(*edev), GFP_KERNEL); 149 - if (!edev) 150 - return -ENOMEM; 151 - hdev = &edev->hdev; 152 - edev->ebus = ebus; 144 + hdev->bus = bus; 153 145 154 - snprintf(name, sizeof(name), "ehdaudio%dD%d", ebus->idx, addr); 146 + snprintf(name, sizeof(name), "ehdaudio%dD%d", bus->idx, addr); 155 147 156 148 ret = snd_hdac_device_init(hdev, bus, name, addr); 157 149 if (ret < 0) { ··· 172 176 */ 173 177 void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev) 174 178 { 175 - struct hdac_ext_device *edev = to_ehdac_device(hdev); 176 - 177 179 snd_hdac_device_exit(hdev); 178 - kfree(edev); 180 + kfree(hdev); 179 181 } 180 182 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit); 181 183 ··· 182 188 * 183 189 * @ebus: HD-audio extended bus 184 190 */ 185 - void snd_hdac_ext_bus_device_remove(struct hdac_ext_bus *ebus) 191 + void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus) 186 192 { 187 193 struct hdac_device *codec, *__codec; 188 194 /* 189 195 * we need to remove all the codec devices objects created in the 190 196 * snd_hdac_ext_bus_device_init 191 197 */ 192 - list_for_each_entry_safe(codec, __codec, &ebus->bus.codec_list, list) { 198 + list_for_each_entry_safe(codec, __codec, &bus->codec_list, list) { 193 199 snd_hdac_device_unregister(codec); 194 200 put_device(&codec->dev); 195 201 } ··· 198 204 #define dev_to_hdac(dev) (container_of((dev), \ 199 205 struct hdac_device, dev)) 200 206 201 - static inline struct hdac_ext_driver *get_edrv(struct device *dev) 207 + static inline struct hdac_driver *get_hdrv(struct device *dev) 202 208 { 203 209 struct hdac_driver *hdrv = drv_to_hdac_driver(dev->driver); 204 - struct hdac_ext_driver *edrv = to_ehdac_driver(hdrv); 205 - 206 - return edrv; 210 + return hdrv; 207 211 } 208 212 209 - static inline struct hdac_ext_device *get_edev(struct device *dev) 213 + static inline struct hdac_device *get_hdev(struct device *dev) 210 214 { 211 215 struct hdac_device *hdev = dev_to_hdac_dev(dev); 212 - struct hdac_ext_device *edev = to_ehdac_device(hdev); 213 - 214 - return edev; 216 + return hdev; 215 217 } 216 218 217 219 static int hda_ext_drv_probe(struct device *dev) 218 220 { 219 - return (get_edrv(dev))->probe(get_edev(dev)); 221 + return (get_hdrv(dev))->probe(get_hdev(dev)); 220 222 } 221 223 222 224 static int hdac_ext_drv_remove(struct device *dev) 223 225 { 224 - return (get_edrv(dev))->remove(get_edev(dev)); 226 + return (get_hdrv(dev))->remove(get_hdev(dev)); 225 227 } 226 228 227 229 static void hdac_ext_drv_shutdown(struct device *dev) 228 230 { 229 - return (get_edrv(dev))->shutdown(get_edev(dev)); 231 + return (get_hdrv(dev))->shutdown(get_hdev(dev)); 230 232 } 231 233 232 234 /** ··· 230 240 * 231 241 * @drv: ext hda driver structure 232 242 */ 233 - int snd_hda_ext_driver_register(struct hdac_ext_driver *drv) 243 + int snd_hda_ext_driver_register(struct hdac_driver *drv) 234 244 { 235 - drv->hdac.type = HDA_DEV_ASOC; 236 - drv->hdac.driver.bus = &snd_hda_bus_type; 245 + drv->type = HDA_DEV_ASOC; 246 + drv->driver.bus = &snd_hda_bus_type; 237 247 /* we use default match */ 238 248 239 249 if (drv->probe) 240 - drv->hdac.driver.probe = hda_ext_drv_probe; 250 + drv->driver.probe = hda_ext_drv_probe; 241 251 if (drv->remove) 242 - drv->hdac.driver.remove = hdac_ext_drv_remove; 252 + drv->driver.remove = hdac_ext_drv_remove; 243 253 if (drv->shutdown) 244 - drv->hdac.driver.shutdown = hdac_ext_drv_shutdown; 254 + drv->driver.shutdown = hdac_ext_drv_shutdown; 245 255 246 - return driver_register(&drv->hdac.driver); 256 + return driver_register(&drv->driver); 247 257 } 248 258 EXPORT_SYMBOL_GPL(snd_hda_ext_driver_register); 249 259 ··· 252 262 * 253 263 * @drv: ext hda driver structure 254 264 */ 255 - void snd_hda_ext_driver_unregister(struct hdac_ext_driver *drv) 265 + void snd_hda_ext_driver_unregister(struct hdac_driver *drv) 256 266 { 257 - driver_unregister(&drv->hdac.driver); 267 + driver_unregister(&drv->driver); 258 268 } 259 269 EXPORT_SYMBOL_GPL(snd_hda_ext_driver_unregister);
+35 -29
sound/hda/ext/hdac_ext_controller.c
··· 39 39 * @ebus: HD-audio extended core bus 40 40 * @enable: flag to turn on/off the capability 41 41 */ 42 - void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *ebus, bool enable) 42 + void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *bus, bool enable) 43 43 { 44 - struct hdac_bus *bus = &ebus->bus; 45 44 46 45 if (!bus->ppcap) { 47 46 dev_err(bus->dev, "Address of PP capability is NULL"); ··· 59 60 * @ebus: HD-audio extended core bus 60 61 * @enable: flag to enable/disable interrupt 61 62 */ 62 - void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *ebus, bool enable) 63 + void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *bus, bool enable) 63 64 { 64 - struct hdac_bus *bus = &ebus->bus; 65 65 66 66 if (!bus->ppcap) { 67 67 dev_err(bus->dev, "Address of PP capability is NULL\n"); ··· 87 89 * in hlink_list of extended hdac bus 88 90 * Note: this will be freed on bus exit by driver 89 91 */ 90 - int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *ebus) 92 + int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus) 91 93 { 92 94 int idx; 93 95 u32 link_count; 94 96 struct hdac_ext_link *hlink; 95 - struct hdac_bus *bus = &ebus->bus; 96 97 97 98 link_count = readl(bus->mlcap + AZX_REG_ML_MLCD) + 1; 98 99 ··· 111 114 /* since link in On, update the ref */ 112 115 hlink->ref_count = 1; 113 116 114 - list_add_tail(&hlink->list, &ebus->hlink_list); 117 + list_add_tail(&hlink->list, &bus->hlink_list); 115 118 } 116 119 117 120 return 0; ··· 124 127 * @ebus: HD-audio ext core bus 125 128 */ 126 129 127 - void snd_hdac_link_free_all(struct hdac_ext_bus *ebus) 130 + void snd_hdac_link_free_all(struct hdac_bus *bus) 128 131 { 129 132 struct hdac_ext_link *l; 130 133 131 - while (!list_empty(&ebus->hlink_list)) { 132 - l = list_first_entry(&ebus->hlink_list, struct hdac_ext_link, list); 134 + while (!list_empty(&bus->hlink_list)) { 135 + l = list_first_entry(&bus->hlink_list, struct hdac_ext_link, list); 133 136 list_del(&l->list); 134 137 kfree(l); 135 138 } ··· 141 144 * @ebus: HD-audio extended core bus 142 145 * @codec_name: codec name 143 146 */ 144 - struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *ebus, 147 + struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus, 145 148 const char *codec_name) 146 149 { 147 150 int i; ··· 150 153 151 154 if (sscanf(codec_name, "ehdaudio%dD%d", &bus_idx, &addr) != 2) 152 155 return NULL; 153 - if (ebus->idx != bus_idx) 156 + if (bus->idx != bus_idx) 154 157 return NULL; 155 158 156 - list_for_each_entry(hlink, &ebus->hlink_list, list) { 159 + list_for_each_entry(hlink, &bus->hlink_list, list) { 157 160 for (i = 0; i < HDA_MAX_CODECS; i++) { 158 161 if (hlink->lsdiid & (0x1 << addr)) 159 162 return hlink; ··· 216 219 * snd_hdac_ext_bus_link_power_up_all -power up all hda link 217 220 * @ebus: HD-audio extended bus 218 221 */ 219 - int snd_hdac_ext_bus_link_power_up_all(struct hdac_ext_bus *ebus) 222 + int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus) 220 223 { 221 224 struct hdac_ext_link *hlink = NULL; 222 225 int ret; 223 226 224 - list_for_each_entry(hlink, &ebus->hlink_list, list) { 227 + list_for_each_entry(hlink, &bus->hlink_list, list) { 225 228 snd_hdac_updatel(hlink->ml_addr, 226 229 AZX_REG_ML_LCTL, 0, AZX_MLCTL_SPA); 227 230 ret = check_hdac_link_power_active(hlink, true); ··· 237 240 * snd_hdac_ext_bus_link_power_down_all -power down all hda link 238 241 * @ebus: HD-audio extended bus 239 242 */ 240 - int snd_hdac_ext_bus_link_power_down_all(struct hdac_ext_bus *ebus) 243 + int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus) 241 244 { 242 245 struct hdac_ext_link *hlink = NULL; 243 246 int ret; 244 247 245 - list_for_each_entry(hlink, &ebus->hlink_list, list) { 248 + list_for_each_entry(hlink, &bus->hlink_list, list) { 246 249 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, AZX_MLCTL_SPA, 0); 247 250 ret = check_hdac_link_power_active(hlink, false); 248 251 if (ret < 0) ··· 253 256 } 254 257 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_down_all); 255 258 256 - int snd_hdac_ext_bus_link_get(struct hdac_ext_bus *ebus, 259 + int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, 257 260 struct hdac_ext_link *link) 258 261 { 259 262 int ret = 0; 260 263 261 - mutex_lock(&ebus->lock); 264 + mutex_lock(&bus->lock); 262 265 263 266 /* 264 267 * if we move from 0 to 1, count will be 1 so power up this link 265 268 * as well, also check the dma status and trigger that 266 269 */ 267 270 if (++link->ref_count == 1) { 268 - if (!ebus->cmd_dma_state) { 269 - snd_hdac_bus_init_cmd_io(&ebus->bus); 270 - ebus->cmd_dma_state = true; 271 + if (!bus->cmd_dma_state) { 272 + snd_hdac_bus_init_cmd_io(bus); 273 + bus->cmd_dma_state = true; 271 274 } 272 275 273 276 ret = snd_hdac_ext_bus_link_power_up(link); 277 + 278 + /* 279 + * wait for 521usec for codec to report status 280 + * HDA spec section 4.3 - Codec Discovery 281 + */ 282 + udelay(521); 283 + bus->codec_mask = snd_hdac_chip_readw(bus, STATESTS); 284 + dev_dbg(bus->dev, "codec_mask = 0x%lx\n", bus->codec_mask); 285 + snd_hdac_chip_writew(bus, STATESTS, bus->codec_mask); 274 286 } 275 287 276 - mutex_unlock(&ebus->lock); 288 + mutex_unlock(&bus->lock); 277 289 return ret; 278 290 } 279 291 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_get); 280 292 281 - int snd_hdac_ext_bus_link_put(struct hdac_ext_bus *ebus, 293 + int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, 282 294 struct hdac_ext_link *link) 283 295 { 284 296 int ret = 0; 285 297 struct hdac_ext_link *hlink; 286 298 bool link_up = false; 287 299 288 - mutex_lock(&ebus->lock); 300 + mutex_lock(&bus->lock); 289 301 290 302 /* 291 303 * if we move from 1 to 0, count will be 0 ··· 307 301 * now check if all links are off, if so turn off 308 302 * cmd dma as well 309 303 */ 310 - list_for_each_entry(hlink, &ebus->hlink_list, list) { 304 + list_for_each_entry(hlink, &bus->hlink_list, list) { 311 305 if (hlink->ref_count) { 312 306 link_up = true; 313 307 break; ··· 315 309 } 316 310 317 311 if (!link_up) { 318 - snd_hdac_bus_stop_cmd_io(&ebus->bus); 319 - ebus->cmd_dma_state = false; 312 + snd_hdac_bus_stop_cmd_io(bus); 313 + bus->cmd_dma_state = false; 320 314 } 321 315 } 322 316 323 - mutex_unlock(&ebus->lock); 317 + mutex_unlock(&bus->lock); 324 318 return ret; 325 319 } 326 320 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_put);
+45 -59
sound/hda/ext/hdac_ext_stream.c
··· 25 25 26 26 /** 27 27 * snd_hdac_ext_stream_init - initialize each stream (aka device) 28 - * @ebus: HD-audio ext core bus 28 + * @bus: HD-audio core bus 29 29 * @stream: HD-audio ext core stream object to initialize 30 30 * @idx: stream index number 31 31 * @direction: stream direction (SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE) ··· 34 34 * initialize the stream, if ppcap is enabled then init those and then 35 35 * invoke hdac stream initialization routine 36 36 */ 37 - void snd_hdac_ext_stream_init(struct hdac_ext_bus *ebus, 37 + void snd_hdac_ext_stream_init(struct hdac_bus *bus, 38 38 struct hdac_ext_stream *stream, 39 39 int idx, int direction, int tag) 40 40 { 41 - struct hdac_bus *bus = &ebus->bus; 42 - 43 41 if (bus->ppcap) { 44 42 stream->pphc_addr = bus->ppcap + AZX_PPHC_BASE + 45 43 AZX_PPHC_INTERVAL * idx; 46 44 47 45 stream->pplc_addr = bus->ppcap + AZX_PPLC_BASE + 48 - AZX_PPLC_MULTI * ebus->num_streams + 46 + AZX_PPLC_MULTI * bus->num_streams + 49 47 AZX_PPLC_INTERVAL * idx; 50 48 } 51 49 ··· 69 71 /** 70 72 * snd_hdac_ext_stream_init_all - create and initialize the stream objects 71 73 * for an extended hda bus 72 - * @ebus: HD-audio ext core bus 74 + * @bus: HD-audio core bus 73 75 * @start_idx: start index for streams 74 76 * @num_stream: number of streams to initialize 75 77 * @dir: direction of streams 76 78 */ 77 - int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx, 79 + int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, 78 80 int num_stream, int dir) 79 81 { 80 82 int stream_tag = 0; ··· 86 88 if (!stream) 87 89 return -ENOMEM; 88 90 tag = ++stream_tag; 89 - snd_hdac_ext_stream_init(ebus, stream, idx, dir, tag); 91 + snd_hdac_ext_stream_init(bus, stream, idx, dir, tag); 90 92 idx++; 91 93 } 92 94 ··· 98 100 /** 99 101 * snd_hdac_stream_free_all - free hdac extended stream objects 100 102 * 101 - * @ebus: HD-audio ext core bus 103 + * @bus: HD-audio core bus 102 104 */ 103 - void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus) 105 + void snd_hdac_stream_free_all(struct hdac_bus *bus) 104 106 { 105 107 struct hdac_stream *s, *_s; 106 108 struct hdac_ext_stream *stream; 107 - struct hdac_bus *bus = ebus_to_hbus(ebus); 108 109 109 110 list_for_each_entry_safe(s, _s, &bus->stream_list, list) { 110 111 stream = stream_to_hdac_ext_stream(s); 111 - snd_hdac_ext_stream_decouple(ebus, stream, false); 112 + snd_hdac_ext_stream_decouple(bus, stream, false); 112 113 list_del(&s->list); 113 114 kfree(stream); 114 115 } ··· 116 119 117 120 /** 118 121 * snd_hdac_ext_stream_decouple - decouple the hdac stream 119 - * @ebus: HD-audio ext core bus 122 + * @bus: HD-audio core bus 120 123 * @stream: HD-audio ext core stream object to initialize 121 124 * @decouple: flag to decouple 122 125 */ 123 - void snd_hdac_ext_stream_decouple(struct hdac_ext_bus *ebus, 126 + void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, 124 127 struct hdac_ext_stream *stream, bool decouple) 125 128 { 126 129 struct hdac_stream *hstream = &stream->hstream; 127 - struct hdac_bus *bus = &ebus->bus; 128 130 u32 val; 129 131 int mask = AZX_PPCTL_PROCEN(hstream->index); 130 132 ··· 247 251 EXPORT_SYMBOL_GPL(snd_hdac_ext_link_clear_stream_id); 248 252 249 253 static struct hdac_ext_stream * 250 - hdac_ext_link_stream_assign(struct hdac_ext_bus *ebus, 254 + hdac_ext_link_stream_assign(struct hdac_bus *bus, 251 255 struct snd_pcm_substream *substream) 252 256 { 253 257 struct hdac_ext_stream *res = NULL; 254 258 struct hdac_stream *stream = NULL; 255 - struct hdac_bus *hbus = &ebus->bus; 256 259 257 - if (!hbus->ppcap) { 258 - dev_err(hbus->dev, "stream type not supported\n"); 260 + if (!bus->ppcap) { 261 + dev_err(bus->dev, "stream type not supported\n"); 259 262 return NULL; 260 263 } 261 264 262 - list_for_each_entry(stream, &hbus->stream_list, list) { 265 + list_for_each_entry(stream, &bus->stream_list, list) { 263 266 struct hdac_ext_stream *hstream = container_of(stream, 264 267 struct hdac_ext_stream, 265 268 hstream); ··· 272 277 } 273 278 274 279 if (!hstream->link_locked) { 275 - snd_hdac_ext_stream_decouple(ebus, hstream, true); 280 + snd_hdac_ext_stream_decouple(bus, hstream, true); 276 281 res = hstream; 277 282 break; 278 283 } 279 284 } 280 285 if (res) { 281 - spin_lock_irq(&hbus->reg_lock); 286 + spin_lock_irq(&bus->reg_lock); 282 287 res->link_locked = 1; 283 288 res->link_substream = substream; 284 - spin_unlock_irq(&hbus->reg_lock); 289 + spin_unlock_irq(&bus->reg_lock); 285 290 } 286 291 return res; 287 292 } 288 293 289 294 static struct hdac_ext_stream * 290 - hdac_ext_host_stream_assign(struct hdac_ext_bus *ebus, 295 + hdac_ext_host_stream_assign(struct hdac_bus *bus, 291 296 struct snd_pcm_substream *substream) 292 297 { 293 298 struct hdac_ext_stream *res = NULL; 294 299 struct hdac_stream *stream = NULL; 295 - struct hdac_bus *hbus = &ebus->bus; 296 300 297 - if (!hbus->ppcap) { 298 - dev_err(hbus->dev, "stream type not supported\n"); 301 + if (!bus->ppcap) { 302 + dev_err(bus->dev, "stream type not supported\n"); 299 303 return NULL; 300 304 } 301 305 302 - list_for_each_entry(stream, &hbus->stream_list, list) { 306 + list_for_each_entry(stream, &bus->stream_list, list) { 303 307 struct hdac_ext_stream *hstream = container_of(stream, 304 308 struct hdac_ext_stream, 305 309 hstream); ··· 307 313 308 314 if (!stream->opened) { 309 315 if (!hstream->decoupled) 310 - snd_hdac_ext_stream_decouple(ebus, hstream, true); 316 + snd_hdac_ext_stream_decouple(bus, hstream, true); 311 317 res = hstream; 312 318 break; 313 319 } 314 320 } 315 321 if (res) { 316 - spin_lock_irq(&hbus->reg_lock); 322 + spin_lock_irq(&bus->reg_lock); 317 323 res->hstream.opened = 1; 318 324 res->hstream.running = 0; 319 325 res->hstream.substream = substream; 320 - spin_unlock_irq(&hbus->reg_lock); 326 + spin_unlock_irq(&bus->reg_lock); 321 327 } 322 328 323 329 return res; ··· 325 331 326 332 /** 327 333 * snd_hdac_ext_stream_assign - assign a stream for the PCM 328 - * @ebus: HD-audio ext core bus 334 + * @bus: HD-audio core bus 329 335 * @substream: PCM substream to assign 330 336 * @type: type of stream (coupled, host or link stream) 331 337 * ··· 340 346 * the same stream object when it's used beforehand. when a stream is 341 347 * decoupled, it becomes a host stream and link stream. 342 348 */ 343 - struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *ebus, 349 + struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus, 344 350 struct snd_pcm_substream *substream, 345 351 int type) 346 352 { 347 353 struct hdac_ext_stream *hstream = NULL; 348 354 struct hdac_stream *stream = NULL; 349 - struct hdac_bus *hbus = &ebus->bus; 350 355 351 356 switch (type) { 352 357 case HDAC_EXT_STREAM_TYPE_COUPLED: 353 - stream = snd_hdac_stream_assign(hbus, substream); 358 + stream = snd_hdac_stream_assign(bus, substream); 354 359 if (stream) 355 360 hstream = container_of(stream, 356 361 struct hdac_ext_stream, hstream); 357 362 return hstream; 358 363 359 364 case HDAC_EXT_STREAM_TYPE_HOST: 360 - return hdac_ext_host_stream_assign(ebus, substream); 365 + return hdac_ext_host_stream_assign(bus, substream); 361 366 362 367 case HDAC_EXT_STREAM_TYPE_LINK: 363 - return hdac_ext_link_stream_assign(ebus, substream); 368 + return hdac_ext_link_stream_assign(bus, substream); 364 369 365 370 default: 366 371 return NULL; ··· 377 384 void snd_hdac_ext_stream_release(struct hdac_ext_stream *stream, int type) 378 385 { 379 386 struct hdac_bus *bus = stream->hstream.bus; 380 - struct hdac_ext_bus *ebus = hbus_to_ebus(bus); 381 387 382 388 switch (type) { 383 389 case HDAC_EXT_STREAM_TYPE_COUPLED: ··· 385 393 386 394 case HDAC_EXT_STREAM_TYPE_HOST: 387 395 if (stream->decoupled && !stream->link_locked) 388 - snd_hdac_ext_stream_decouple(ebus, stream, false); 396 + snd_hdac_ext_stream_decouple(bus, stream, false); 389 397 snd_hdac_stream_release(&stream->hstream); 390 398 break; 391 399 392 400 case HDAC_EXT_STREAM_TYPE_LINK: 393 401 if (stream->decoupled && !stream->hstream.opened) 394 - snd_hdac_ext_stream_decouple(ebus, stream, false); 402 + snd_hdac_ext_stream_decouple(bus, stream, false); 395 403 spin_lock_irq(&bus->reg_lock); 396 404 stream->link_locked = 0; 397 405 stream->link_substream = NULL; ··· 407 415 408 416 /** 409 417 * snd_hdac_ext_stream_spbcap_enable - enable SPIB for a stream 410 - * @ebus: HD-audio ext core bus 418 + * @bus: HD-audio core bus 411 419 * @enable: flag to enable/disable SPIB 412 420 * @index: stream index for which SPIB need to be enabled 413 421 */ 414 - void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *ebus, 422 + void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *bus, 415 423 bool enable, int index) 416 424 { 417 425 u32 mask = 0; 418 426 u32 register_mask = 0; 419 - struct hdac_bus *bus = &ebus->bus; 420 427 421 428 if (!bus->spbcap) { 422 429 dev_err(bus->dev, "Address of SPB capability is NULL\n"); ··· 437 446 438 447 /** 439 448 * snd_hdac_ext_stream_set_spib - sets the spib value of a stream 440 - * @ebus: HD-audio ext core bus 449 + * @bus: HD-audio core bus 441 450 * @stream: hdac_ext_stream 442 451 * @value: spib value to set 443 452 */ 444 - int snd_hdac_ext_stream_set_spib(struct hdac_ext_bus *ebus, 453 + int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus, 445 454 struct hdac_ext_stream *stream, u32 value) 446 455 { 447 - struct hdac_bus *bus = &ebus->bus; 448 456 449 457 if (!bus->spbcap) { 450 458 dev_err(bus->dev, "Address of SPB capability is NULL\n"); ··· 458 468 459 469 /** 460 470 * snd_hdac_ext_stream_get_spbmaxfifo - gets the spib value of a stream 461 - * @ebus: HD-audio ext core bus 471 + * @bus: HD-audio core bus 462 472 * @stream: hdac_ext_stream 463 473 * 464 474 * Return maxfifo for the stream 465 475 */ 466 - int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_ext_bus *ebus, 476 + int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus, 467 477 struct hdac_ext_stream *stream) 468 478 { 469 - struct hdac_bus *bus = &ebus->bus; 470 479 471 480 if (!bus->spbcap) { 472 481 dev_err(bus->dev, "Address of SPB capability is NULL\n"); ··· 479 490 480 491 /** 481 492 * snd_hdac_ext_stop_streams - stop all stream if running 482 - * @ebus: HD-audio ext core bus 493 + * @bus: HD-audio core bus 483 494 */ 484 - void snd_hdac_ext_stop_streams(struct hdac_ext_bus *ebus) 495 + void snd_hdac_ext_stop_streams(struct hdac_bus *bus) 485 496 { 486 - struct hdac_bus *bus = ebus_to_hbus(ebus); 487 497 struct hdac_stream *stream; 488 498 489 499 if (bus->chip_init) { ··· 495 507 496 508 /** 497 509 * snd_hdac_ext_stream_drsm_enable - enable DMA resume for a stream 498 - * @ebus: HD-audio ext core bus 510 + * @bus: HD-audio core bus 499 511 * @enable: flag to enable/disable DRSM 500 512 * @index: stream index for which DRSM need to be enabled 501 513 */ 502 - void snd_hdac_ext_stream_drsm_enable(struct hdac_ext_bus *ebus, 514 + void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus, 503 515 bool enable, int index) 504 516 { 505 517 u32 mask = 0; 506 518 u32 register_mask = 0; 507 - struct hdac_bus *bus = &ebus->bus; 508 519 509 520 if (!bus->drsmcap) { 510 521 dev_err(bus->dev, "Address of DRSM capability is NULL\n"); ··· 525 538 526 539 /** 527 540 * snd_hdac_ext_stream_set_dpibr - sets the dpibr value of a stream 528 - * @ebus: HD-audio ext core bus 541 + * @bus: HD-audio core bus 529 542 * @stream: hdac_ext_stream 530 543 * @value: dpib value to set 531 544 */ 532 - int snd_hdac_ext_stream_set_dpibr(struct hdac_ext_bus *ebus, 545 + int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus, 533 546 struct hdac_ext_stream *stream, u32 value) 534 547 { 535 - struct hdac_bus *bus = &ebus->bus; 536 548 537 549 if (!bus->drsmcap) { 538 550 dev_err(bus->dev, "Address of DRSM capability is NULL\n"); ··· 546 560 547 561 /** 548 562 * snd_hdac_ext_stream_set_lpib - sets the lpib value of a stream 549 - * @ebus: HD-audio ext core bus 563 + * @bus: HD-audio core bus 550 564 * @stream: hdac_ext_stream 551 565 * @value: lpib value to set 552 566 */
+51 -17
sound/pci/hda/hda_codec.c
··· 858 858 kfree(codec); 859 859 } 860 860 861 + #define DEV_NAME_LEN 31 862 + 863 + static int snd_hda_codec_device_init(struct hda_bus *bus, struct snd_card *card, 864 + unsigned int codec_addr, struct hda_codec **codecp) 865 + { 866 + char name[DEV_NAME_LEN]; 867 + struct hda_codec *codec; 868 + int err; 869 + 870 + dev_dbg(card->dev, "%s: entry\n", __func__); 871 + 872 + if (snd_BUG_ON(!bus)) 873 + return -EINVAL; 874 + if (snd_BUG_ON(codec_addr > HDA_MAX_CODEC_ADDRESS)) 875 + return -EINVAL; 876 + 877 + codec = kzalloc(sizeof(*codec), GFP_KERNEL); 878 + if (!codec) 879 + return -ENOMEM; 880 + 881 + sprintf(name, "hdaudioC%dD%d", card->number, codec_addr); 882 + err = snd_hdac_device_init(&codec->core, &bus->core, name, codec_addr); 883 + if (err < 0) { 884 + kfree(codec); 885 + return err; 886 + } 887 + 888 + codec->core.type = HDA_DEV_LEGACY; 889 + *codecp = codec; 890 + 891 + return err; 892 + } 893 + 861 894 /** 862 895 * snd_hda_codec_new - create a HDA codec 863 896 * @bus: the bus to assign ··· 902 869 int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card, 903 870 unsigned int codec_addr, struct hda_codec **codecp) 904 871 { 905 - struct hda_codec *codec; 872 + int ret; 873 + 874 + ret = snd_hda_codec_device_init(bus, card, codec_addr, codecp); 875 + if (ret < 0) 876 + return ret; 877 + 878 + return snd_hda_codec_device_new(bus, card, codec_addr, *codecp); 879 + } 880 + EXPORT_SYMBOL_GPL(snd_hda_codec_new); 881 + 882 + int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card, 883 + unsigned int codec_addr, struct hda_codec *codec) 884 + { 906 885 char component[31]; 907 886 hda_nid_t fg; 908 887 int err; ··· 924 879 .dev_free = snd_hda_codec_dev_free, 925 880 }; 926 881 882 + dev_dbg(card->dev, "%s: entry\n", __func__); 883 + 927 884 if (snd_BUG_ON(!bus)) 928 885 return -EINVAL; 929 886 if (snd_BUG_ON(codec_addr > HDA_MAX_CODEC_ADDRESS)) 930 887 return -EINVAL; 931 888 932 - codec = kzalloc(sizeof(*codec), GFP_KERNEL); 933 - if (!codec) 934 - return -ENOMEM; 935 - 936 - sprintf(component, "hdaudioC%dD%d", card->number, codec_addr); 937 - err = snd_hdac_device_init(&codec->core, &bus->core, component, 938 - codec_addr); 939 - if (err < 0) { 940 - kfree(codec); 941 - return err; 942 - } 943 - 944 889 codec->core.dev.release = snd_hda_codec_dev_release; 945 - codec->core.type = HDA_DEV_LEGACY; 946 890 codec->core.exec_verb = codec_exec_verb; 947 891 948 892 codec->bus = bus; ··· 991 957 if (err < 0) 992 958 goto error; 993 959 994 - if (codecp) 995 - *codecp = codec; 996 960 return 0; 997 961 998 962 error: 999 963 put_device(hda_codec_dev(codec)); 1000 964 return err; 1001 965 } 1002 - EXPORT_SYMBOL_GPL(snd_hda_codec_new); 966 + EXPORT_SYMBOL_GPL(snd_hda_codec_device_new); 1003 967 1004 968 /** 1005 969 * snd_hda_codec_update_widgets - Refresh widget caps and pin defaults ··· 3024 2992 sync_power_up_states(codec); 3025 2993 return 0; 3026 2994 } 2995 + EXPORT_SYMBOL_GPL(snd_hda_codec_build_controls); 3027 2996 3028 2997 /* 3029 2998 * PCM stuff ··· 3230 3197 3231 3198 return 0; 3232 3199 } 3200 + EXPORT_SYMBOL_GPL(snd_hda_codec_parse_pcms); 3233 3201 3234 3202 /* assign all PCMs of the given codec */ 3235 3203 int snd_hda_codec_build_pcms(struct hda_codec *codec)
+2
sound/pci/hda/hda_codec.h
··· 308 308 */ 309 309 int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card, 310 310 unsigned int codec_addr, struct hda_codec **codecp); 311 + int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card, 312 + unsigned int codec_addr, struct hda_codec *codec); 311 313 int snd_hda_codec_configure(struct hda_codec *codec); 312 314 int snd_hda_codec_update_widgets(struct hda_codec *codec); 313 315
+197 -219
sound/soc/codecs/hdac_hdmi.c
··· 85 85 bool mst_capable; 86 86 struct hdac_hdmi_port *ports; 87 87 int num_ports; 88 - struct hdac_ext_device *edev; 88 + struct hdac_device *hdev; 89 89 }; 90 90 91 91 struct hdac_hdmi_port { ··· 126 126 }; 127 127 128 128 struct hdac_hdmi_priv { 129 + struct hdac_device *hdev; 130 + struct snd_soc_component *component; 131 + struct snd_card *card; 129 132 struct hdac_hdmi_dai_port_map dai_map[HDA_MAX_CVTS]; 130 133 struct list_head pin_list; 131 134 struct list_head cvt_list; ··· 142 139 struct snd_soc_dai_driver *dai_drv; 143 140 }; 144 141 145 - #define hdev_to_hdmi_priv(_hdev) ((to_ehdac_device(_hdev))->private_data) 142 + #define hdev_to_hdmi_priv(_hdev) dev_get_drvdata(&(_hdev)->dev) 146 143 147 144 static struct hdac_hdmi_pcm * 148 145 hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi, ··· 161 158 static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm, 162 159 struct hdac_hdmi_port *port, bool is_connect) 163 160 { 164 - struct hdac_ext_device *edev = port->pin->edev; 161 + struct hdac_device *hdev = port->pin->hdev; 165 162 166 163 if (is_connect) 167 164 snd_soc_dapm_enable_pin(port->dapm, port->jack_pin); ··· 175 172 * ports. 176 173 */ 177 174 if (pcm->jack_event == 0) { 178 - dev_dbg(&edev->hdev.dev, 175 + dev_dbg(&hdev->dev, 179 176 "jack report for pcm=%d\n", 180 177 pcm->pcm_id); 181 178 snd_soc_jack_report(pcm->jack, SND_JACK_AVOUT, ··· 201 198 /* 202 199 * Get the no devices that can be connected to a port on the Pin widget. 203 200 */ 204 - static int hdac_hdmi_get_port_len(struct hdac_ext_device *edev, hda_nid_t nid) 201 + static int hdac_hdmi_get_port_len(struct hdac_device *hdev, hda_nid_t nid) 205 202 { 206 203 unsigned int caps; 207 204 unsigned int type, param; 208 205 209 - caps = get_wcaps(&edev->hdev, nid); 206 + caps = get_wcaps(hdev, nid); 210 207 type = get_wcaps_type(caps); 211 208 212 209 if (!(caps & AC_WCAP_DIGITAL) || (type != AC_WID_PIN)) 213 210 return 0; 214 211 215 - param = snd_hdac_read_parm_uncached(&edev->hdev, nid, 216 - AC_PAR_DEVLIST_LEN); 212 + param = snd_hdac_read_parm_uncached(hdev, nid, AC_PAR_DEVLIST_LEN); 217 213 if (param == -1) 218 214 return param; 219 215 ··· 224 222 * id selected on the pin. Return 0 means the first port entry 225 223 * is selected or MST is not supported. 226 224 */ 227 - static int hdac_hdmi_port_select_get(struct hdac_ext_device *edev, 225 + static int hdac_hdmi_port_select_get(struct hdac_device *hdev, 228 226 struct hdac_hdmi_port *port) 229 227 { 230 - return snd_hdac_codec_read(&edev->hdev, port->pin->nid, 228 + return snd_hdac_codec_read(hdev, port->pin->nid, 231 229 0, AC_VERB_GET_DEVICE_SEL, 0); 232 230 } 233 231 ··· 235 233 * Sets the selected port entry for the configuring Pin widget verb. 236 234 * returns error if port set is not equal to port get otherwise success 237 235 */ 238 - static int hdac_hdmi_port_select_set(struct hdac_ext_device *edev, 236 + static int hdac_hdmi_port_select_set(struct hdac_device *hdev, 239 237 struct hdac_hdmi_port *port) 240 238 { 241 239 int num_ports; ··· 244 242 return 0; 245 243 246 244 /* AC_PAR_DEVLIST_LEN is 0 based. */ 247 - num_ports = hdac_hdmi_get_port_len(edev, port->pin->nid); 248 - 245 + num_ports = hdac_hdmi_get_port_len(hdev, port->pin->nid); 249 246 if (num_ports < 0) 250 247 return -EIO; 251 248 /* ··· 254 253 if (num_ports + 1 < port->id) 255 254 return 0; 256 255 257 - snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0, 256 + snd_hdac_codec_write(hdev, port->pin->nid, 0, 258 257 AC_VERB_SET_DEVICE_SEL, port->id); 259 258 260 - if (port->id != hdac_hdmi_port_select_get(edev, port)) 259 + if (port->id != hdac_hdmi_port_select_get(hdev, port)) 261 260 return -EIO; 262 261 263 - dev_dbg(&edev->hdev.dev, "Selected the port=%d\n", port->id); 262 + dev_dbg(&hdev->dev, "Selected the port=%d\n", port->id); 264 263 265 264 return 0; 266 265 } ··· 276 275 } 277 276 278 277 return NULL; 279 - } 280 - 281 - static inline struct hdac_ext_device *to_hda_ext_device(struct device *dev) 282 - { 283 - struct hdac_device *hdev = dev_to_hdac_dev(dev); 284 - 285 - return to_ehdac_device(hdev); 286 278 } 287 279 288 280 static unsigned int sad_format(const u8 *sad) ··· 318 324 } 319 325 320 326 static void 321 - hdac_hdmi_set_dip_index(struct hdac_ext_device *edev, hda_nid_t pin_nid, 327 + hdac_hdmi_set_dip_index(struct hdac_device *hdev, hda_nid_t pin_nid, 322 328 int packet_index, int byte_index) 323 329 { 324 330 int val; 325 331 326 332 val = (packet_index << 5) | (byte_index & 0x1f); 327 - 328 - snd_hdac_codec_write(&edev->hdev, pin_nid, 0, 329 - AC_VERB_SET_HDMI_DIP_INDEX, val); 333 + snd_hdac_codec_write(hdev, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); 330 334 } 331 335 332 336 struct dp_audio_infoframe { ··· 339 347 u8 LFEPBL01_LSV36_DM_INH7; 340 348 }; 341 349 342 - static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *edev, 350 + static int hdac_hdmi_setup_audio_infoframe(struct hdac_device *hdev, 343 351 struct hdac_hdmi_pcm *pcm, struct hdac_hdmi_port *port) 344 352 { 345 353 uint8_t buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE]; 346 354 struct hdmi_audio_infoframe frame; 347 355 struct hdac_hdmi_pin *pin = port->pin; 348 356 struct dp_audio_infoframe dp_ai; 349 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 357 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 350 358 struct hdac_hdmi_cvt *cvt = pcm->cvt; 351 359 u8 *dip; 352 360 int ret; ··· 355 363 u8 conn_type; 356 364 int channels, ca; 357 365 358 - ca = snd_hdac_channel_allocation(&edev->hdev, port->eld.info.spk_alloc, 366 + ca = snd_hdac_channel_allocation(hdev, port->eld.info.spk_alloc, 359 367 pcm->channels, pcm->chmap_set, true, pcm->chmap); 360 368 361 369 channels = snd_hdac_get_active_channels(ca); 362 - hdmi->chmap.ops.set_channel_count(&edev->hdev, cvt->nid, channels); 370 + hdmi->chmap.ops.set_channel_count(hdev, cvt->nid, channels); 363 371 364 372 snd_hdac_setup_channel_mapping(&hdmi->chmap, pin->nid, false, ca, 365 373 pcm->channels, pcm->chmap, pcm->chmap_set); ··· 392 400 break; 393 401 394 402 default: 395 - dev_err(&edev->hdev.dev, "Invalid connection type: %d\n", 396 - conn_type); 403 + dev_err(&hdev->dev, "Invalid connection type: %d\n", conn_type); 397 404 return -EIO; 398 405 } 399 406 400 407 /* stop infoframe transmission */ 401 - hdac_hdmi_set_dip_index(edev, pin->nid, 0x0, 0x0); 402 - snd_hdac_codec_write(&edev->hdev, pin->nid, 0, 408 + hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); 409 + snd_hdac_codec_write(hdev, pin->nid, 0, 403 410 AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_DISABLE); 404 411 405 412 406 413 /* Fill infoframe. Index auto-incremented */ 407 - hdac_hdmi_set_dip_index(edev, pin->nid, 0x0, 0x0); 414 + hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); 408 415 if (conn_type == DRM_ELD_CONN_TYPE_HDMI) { 409 416 for (i = 0; i < sizeof(buffer); i++) 410 - snd_hdac_codec_write(&edev->hdev, pin->nid, 0, 417 + snd_hdac_codec_write(hdev, pin->nid, 0, 411 418 AC_VERB_SET_HDMI_DIP_DATA, buffer[i]); 412 419 } else { 413 420 for (i = 0; i < sizeof(dp_ai); i++) 414 - snd_hdac_codec_write(&edev->hdev, pin->nid, 0, 421 + snd_hdac_codec_write(hdev, pin->nid, 0, 415 422 AC_VERB_SET_HDMI_DIP_DATA, dip[i]); 416 423 } 417 424 418 425 /* Start infoframe */ 419 - hdac_hdmi_set_dip_index(edev, pin->nid, 0x0, 0x0); 420 - snd_hdac_codec_write(&edev->hdev, pin->nid, 0, 426 + hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); 427 + snd_hdac_codec_write(hdev, pin->nid, 0, 421 428 AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_BEST); 422 429 423 430 return 0; ··· 426 435 unsigned int tx_mask, unsigned int rx_mask, 427 436 int slots, int slot_width) 428 437 { 429 - struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); 430 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 438 + struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); 439 + struct hdac_device *hdev = hdmi->hdev; 431 440 struct hdac_hdmi_dai_port_map *dai_map; 432 441 struct hdac_hdmi_pcm *pcm; 433 442 434 - dev_dbg(&edev->hdev.dev, "%s: strm_tag: %d\n", __func__, tx_mask); 443 + dev_dbg(&hdev->dev, "%s: strm_tag: %d\n", __func__, tx_mask); 435 444 436 445 dai_map = &hdmi->dai_map[dai->id]; 437 446 ··· 446 455 static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream, 447 456 struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai) 448 457 { 449 - struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); 450 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 458 + struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); 459 + struct hdac_device *hdev = hdmi->hdev; 451 460 struct hdac_hdmi_dai_port_map *dai_map; 452 461 struct hdac_hdmi_port *port; 453 462 struct hdac_hdmi_pcm *pcm; ··· 460 469 return -ENODEV; 461 470 462 471 if ((!port->eld.monitor_present) || (!port->eld.eld_valid)) { 463 - dev_err(&edev->hdev.dev, 472 + dev_err(&hdev->dev, 464 473 "device is not configured for this pin:port%d:%d\n", 465 474 port->pin->nid, port->id); 466 475 return -ENODEV; ··· 480 489 return 0; 481 490 } 482 491 483 - static int hdac_hdmi_query_port_connlist(struct hdac_ext_device *edev, 492 + static int hdac_hdmi_query_port_connlist(struct hdac_device *hdev, 484 493 struct hdac_hdmi_pin *pin, 485 494 struct hdac_hdmi_port *port) 486 495 { 487 - if (!(get_wcaps(&edev->hdev, pin->nid) & AC_WCAP_CONN_LIST)) { 488 - dev_warn(&edev->hdev.dev, 496 + if (!(get_wcaps(hdev, pin->nid) & AC_WCAP_CONN_LIST)) { 497 + dev_warn(&hdev->dev, 489 498 "HDMI: pin %d wcaps %#x does not support connection list\n", 490 - pin->nid, get_wcaps(&edev->hdev, pin->nid)); 499 + pin->nid, get_wcaps(hdev, pin->nid)); 491 500 return -EINVAL; 492 501 } 493 502 494 - if (hdac_hdmi_port_select_set(edev, port) < 0) 503 + if (hdac_hdmi_port_select_set(hdev, port) < 0) 495 504 return -EIO; 496 505 497 - port->num_mux_nids = snd_hdac_get_connections(&edev->hdev, pin->nid, 506 + port->num_mux_nids = snd_hdac_get_connections(hdev, pin->nid, 498 507 port->mux_nids, HDA_MAX_CONNECTIONS); 499 508 if (port->num_mux_nids == 0) 500 - dev_warn(&edev->hdev.dev, 509 + dev_warn(&hdev->dev, 501 510 "No connections found for pin:port %d:%d\n", 502 511 pin->nid, port->id); 503 512 504 - dev_dbg(&edev->hdev.dev, "num_mux_nids %d for pin:port %d:%d\n", 513 + dev_dbg(&hdev->dev, "num_mux_nids %d for pin:port %d:%d\n", 505 514 port->num_mux_nids, pin->nid, port->id); 506 515 507 516 return port->num_mux_nids; ··· 517 526 * connected. 518 527 */ 519 528 static struct hdac_hdmi_port *hdac_hdmi_get_port_from_cvt( 520 - struct hdac_ext_device *edev, 529 + struct hdac_device *hdev, 521 530 struct hdac_hdmi_priv *hdmi, 522 531 struct hdac_hdmi_cvt *cvt) 523 532 { ··· 532 541 533 542 list_for_each_entry(port, &pcm->port_list, head) { 534 543 mutex_lock(&pcm->lock); 535 - ret = hdac_hdmi_query_port_connlist(edev, 544 + ret = hdac_hdmi_query_port_connlist(hdev, 536 545 port->pin, port); 537 546 mutex_unlock(&pcm->lock); 538 547 if (ret < 0) ··· 559 568 static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, 560 569 struct snd_soc_dai *dai) 561 570 { 562 - struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); 563 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 571 + struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); 572 + struct hdac_device *hdev = hdmi->hdev; 564 573 struct hdac_hdmi_dai_port_map *dai_map; 565 574 struct hdac_hdmi_cvt *cvt; 566 575 struct hdac_hdmi_port *port; ··· 569 578 dai_map = &hdmi->dai_map[dai->id]; 570 579 571 580 cvt = dai_map->cvt; 572 - port = hdac_hdmi_get_port_from_cvt(edev, hdmi, cvt); 581 + port = hdac_hdmi_get_port_from_cvt(hdev, hdmi, cvt); 573 582 574 583 /* 575 584 * To make PA and other userland happy. ··· 580 589 if ((!port->eld.monitor_present) || 581 590 (!port->eld.eld_valid)) { 582 591 583 - dev_warn(&edev->hdev.dev, 592 + dev_warn(&hdev->dev, 584 593 "Failed: present?:%d ELD valid?:%d pin:port: %d:%d\n", 585 594 port->eld.monitor_present, port->eld.eld_valid, 586 595 port->pin->nid, port->id); ··· 602 611 static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream, 603 612 struct snd_soc_dai *dai) 604 613 { 605 - struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); 606 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 614 + struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); 607 615 struct hdac_hdmi_dai_port_map *dai_map; 608 616 struct hdac_hdmi_pcm *pcm; 609 617 ··· 685 695 route->connected = handler; 686 696 } 687 697 688 - static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_ext_device *edev, 698 + static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_device *hdev, 689 699 struct hdac_hdmi_port *port) 690 700 { 691 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 701 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 692 702 struct hdac_hdmi_pcm *pcm = NULL; 693 703 struct hdac_hdmi_port *p; 694 704 ··· 705 715 return NULL; 706 716 } 707 717 708 - static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, 718 + static void hdac_hdmi_set_power_state(struct hdac_device *hdev, 709 719 hda_nid_t nid, unsigned int pwr_state) 710 720 { 711 721 int count; 712 722 unsigned int state; 713 723 714 - if (get_wcaps(&edev->hdev, nid) & AC_WCAP_POWER) { 715 - if (!snd_hdac_check_power_state(&edev->hdev, nid, pwr_state)) { 724 + if (get_wcaps(hdev, nid) & AC_WCAP_POWER) { 725 + if (!snd_hdac_check_power_state(hdev, nid, pwr_state)) { 716 726 for (count = 0; count < 10; count++) { 717 - snd_hdac_codec_read(&edev->hdev, nid, 0, 727 + snd_hdac_codec_read(hdev, nid, 0, 718 728 AC_VERB_SET_POWER_STATE, 719 729 pwr_state); 720 - state = snd_hdac_sync_power_state(&edev->hdev, 730 + state = snd_hdac_sync_power_state(hdev, 721 731 nid, pwr_state); 722 732 if (!(state & AC_PWRST_ERROR)) 723 733 break; 724 734 } 725 735 } 726 - 727 736 } 728 737 } 729 738 730 - static void hdac_hdmi_set_amp(struct hdac_ext_device *edev, 739 + static void hdac_hdmi_set_amp(struct hdac_device *hdev, 731 740 hda_nid_t nid, int val) 732 741 { 733 - if (get_wcaps(&edev->hdev, nid) & AC_WCAP_OUT_AMP) 734 - snd_hdac_codec_write(&edev->hdev, nid, 0, 742 + if (get_wcaps(hdev, nid) & AC_WCAP_OUT_AMP) 743 + snd_hdac_codec_write(hdev, nid, 0, 735 744 AC_VERB_SET_AMP_GAIN_MUTE, val); 736 745 } 737 746 ··· 739 750 struct snd_kcontrol *kc, int event) 740 751 { 741 752 struct hdac_hdmi_port *port = w->priv; 742 - struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev); 753 + struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); 743 754 struct hdac_hdmi_pcm *pcm; 744 755 745 - dev_dbg(&edev->hdev.dev, "%s: widget: %s event: %x\n", 756 + dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", 746 757 __func__, w->name, event); 747 758 748 - pcm = hdac_hdmi_get_pcm(edev, port); 759 + pcm = hdac_hdmi_get_pcm(hdev, port); 749 760 if (!pcm) 750 761 return -EIO; 751 762 752 763 /* set the device if pin is mst_capable */ 753 - if (hdac_hdmi_port_select_set(edev, port) < 0) 764 + if (hdac_hdmi_port_select_set(hdev, port) < 0) 754 765 return -EIO; 755 766 756 767 switch (event) { 757 768 case SND_SOC_DAPM_PRE_PMU: 758 - hdac_hdmi_set_power_state(edev, port->pin->nid, AC_PWRST_D0); 769 + hdac_hdmi_set_power_state(hdev, port->pin->nid, AC_PWRST_D0); 759 770 760 771 /* Enable out path for this pin widget */ 761 - snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0, 772 + snd_hdac_codec_write(hdev, port->pin->nid, 0, 762 773 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 763 774 764 - hdac_hdmi_set_amp(edev, port->pin->nid, AMP_OUT_UNMUTE); 775 + hdac_hdmi_set_amp(hdev, port->pin->nid, AMP_OUT_UNMUTE); 765 776 766 - return hdac_hdmi_setup_audio_infoframe(edev, pcm, port); 777 + return hdac_hdmi_setup_audio_infoframe(hdev, pcm, port); 767 778 768 779 case SND_SOC_DAPM_POST_PMD: 769 - hdac_hdmi_set_amp(edev, port->pin->nid, AMP_OUT_MUTE); 780 + hdac_hdmi_set_amp(hdev, port->pin->nid, AMP_OUT_MUTE); 770 781 771 782 /* Disable out path for this pin widget */ 772 - snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0, 783 + snd_hdac_codec_write(hdev, port->pin->nid, 0, 773 784 AC_VERB_SET_PIN_WIDGET_CONTROL, 0); 774 785 775 - hdac_hdmi_set_power_state(edev, port->pin->nid, AC_PWRST_D3); 786 + hdac_hdmi_set_power_state(hdev, port->pin->nid, AC_PWRST_D3); 776 787 break; 777 788 778 789 } ··· 784 795 struct snd_kcontrol *kc, int event) 785 796 { 786 797 struct hdac_hdmi_cvt *cvt = w->priv; 787 - struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev); 788 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 798 + struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); 799 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 789 800 struct hdac_hdmi_pcm *pcm; 790 801 791 - dev_dbg(&edev->hdev.dev, "%s: widget: %s event: %x\n", 802 + dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", 792 803 __func__, w->name, event); 793 804 794 805 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, cvt); ··· 797 808 798 809 switch (event) { 799 810 case SND_SOC_DAPM_PRE_PMU: 800 - hdac_hdmi_set_power_state(edev, cvt->nid, AC_PWRST_D0); 811 + hdac_hdmi_set_power_state(hdev, cvt->nid, AC_PWRST_D0); 801 812 802 813 /* Enable transmission */ 803 - snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, 814 + snd_hdac_codec_write(hdev, cvt->nid, 0, 804 815 AC_VERB_SET_DIGI_CONVERT_1, 1); 805 816 806 817 /* Category Code (CC) to zero */ 807 - snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, 818 + snd_hdac_codec_write(hdev, cvt->nid, 0, 808 819 AC_VERB_SET_DIGI_CONVERT_2, 0); 809 820 810 - snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, 821 + snd_hdac_codec_write(hdev, cvt->nid, 0, 811 822 AC_VERB_SET_CHANNEL_STREAMID, pcm->stream_tag); 812 - snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, 823 + snd_hdac_codec_write(hdev, cvt->nid, 0, 813 824 AC_VERB_SET_STREAM_FORMAT, pcm->format); 814 825 break; 815 826 816 827 case SND_SOC_DAPM_POST_PMD: 817 - snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, 828 + snd_hdac_codec_write(hdev, cvt->nid, 0, 818 829 AC_VERB_SET_CHANNEL_STREAMID, 0); 819 - snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, 830 + snd_hdac_codec_write(hdev, cvt->nid, 0, 820 831 AC_VERB_SET_STREAM_FORMAT, 0); 821 832 822 - hdac_hdmi_set_power_state(edev, cvt->nid, AC_PWRST_D3); 833 + hdac_hdmi_set_power_state(hdev, cvt->nid, AC_PWRST_D3); 823 834 break; 824 835 825 836 } ··· 831 842 struct snd_kcontrol *kc, int event) 832 843 { 833 844 struct hdac_hdmi_port *port = w->priv; 834 - struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev); 845 + struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); 835 846 int mux_idx; 836 847 837 - dev_dbg(&edev->hdev.dev, "%s: widget: %s event: %x\n", 848 + dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", 838 849 __func__, w->name, event); 839 850 840 851 if (!kc) ··· 843 854 mux_idx = dapm_kcontrol_get_value(kc); 844 855 845 856 /* set the device if pin is mst_capable */ 846 - if (hdac_hdmi_port_select_set(edev, port) < 0) 857 + if (hdac_hdmi_port_select_set(hdev, port) < 0) 847 858 return -EIO; 848 859 849 860 if (mux_idx > 0) { 850 - snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0, 861 + snd_hdac_codec_write(hdev, port->pin->nid, 0, 851 862 AC_VERB_SET_CONNECT_SEL, (mux_idx - 1)); 852 863 } 853 864 ··· 866 877 struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kcontrol); 867 878 struct snd_soc_dapm_context *dapm = w->dapm; 868 879 struct hdac_hdmi_port *port = w->priv; 869 - struct hdac_ext_device *edev = to_hda_ext_device(dapm->dev); 870 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 880 + struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); 881 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 871 882 struct hdac_hdmi_pcm *pcm = NULL; 872 883 const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0]]; 873 884 ··· 920 931 * care of selecting the right one and leaving all other inputs selected to 921 932 * "NONE" 922 933 */ 923 - static int hdac_hdmi_create_pin_port_muxs(struct hdac_ext_device *edev, 934 + static int hdac_hdmi_create_pin_port_muxs(struct hdac_device *hdev, 924 935 struct hdac_hdmi_port *port, 925 936 struct snd_soc_dapm_widget *widget, 926 937 const char *widget_name) 927 938 { 928 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 939 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 929 940 struct hdac_hdmi_pin *pin = port->pin; 930 941 struct snd_kcontrol_new *kc; 931 942 struct hdac_hdmi_cvt *cvt; ··· 937 948 int i = 0; 938 949 int num_items = hdmi->num_cvt + 1; 939 950 940 - kc = devm_kzalloc(&edev->hdev.dev, sizeof(*kc), GFP_KERNEL); 951 + kc = devm_kzalloc(&hdev->dev, sizeof(*kc), GFP_KERNEL); 941 952 if (!kc) 942 953 return -ENOMEM; 943 954 944 - se = devm_kzalloc(&edev->hdev.dev, sizeof(*se), GFP_KERNEL); 955 + se = devm_kzalloc(&hdev->dev, sizeof(*se), GFP_KERNEL); 945 956 if (!se) 946 957 return -ENOMEM; 947 958 948 959 snprintf(kc_name, NAME_SIZE, "Pin %d port %d Input", 949 960 pin->nid, port->id); 950 - kc->name = devm_kstrdup(&edev->hdev.dev, kc_name, GFP_KERNEL); 961 + kc->name = devm_kstrdup(&hdev->dev, kc_name, GFP_KERNEL); 951 962 if (!kc->name) 952 963 return -ENOMEM; 953 964 ··· 965 976 se->mask = roundup_pow_of_two(se->items) - 1; 966 977 967 978 sprintf(mux_items, "NONE"); 968 - items[i] = devm_kstrdup(&edev->hdev.dev, mux_items, GFP_KERNEL); 979 + items[i] = devm_kstrdup(&hdev->dev, mux_items, GFP_KERNEL); 969 980 if (!items[i]) 970 981 return -ENOMEM; 971 982 972 983 list_for_each_entry(cvt, &hdmi->cvt_list, head) { 973 984 i++; 974 985 sprintf(mux_items, "cvt %d", cvt->nid); 975 - items[i] = devm_kstrdup(&edev->hdev.dev, mux_items, GFP_KERNEL); 986 + items[i] = devm_kstrdup(&hdev->dev, mux_items, GFP_KERNEL); 976 987 if (!items[i]) 977 988 return -ENOMEM; 978 989 } 979 990 980 - se->texts = devm_kmemdup(&edev->hdev.dev, items, 991 + se->texts = devm_kmemdup(&hdev->dev, items, 981 992 (num_items * sizeof(char *)), GFP_KERNEL); 982 993 if (!se->texts) 983 994 return -ENOMEM; 984 995 985 - return hdac_hdmi_fill_widget_info(&edev->hdev.dev, widget, 996 + return hdac_hdmi_fill_widget_info(&hdev->dev, widget, 986 997 snd_soc_dapm_mux, port, widget_name, NULL, kc, 1, 987 998 hdac_hdmi_pin_mux_widget_event, 988 999 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_REG); 989 1000 } 990 1001 991 1002 /* Add cvt <- input <- mux route map */ 992 - static void hdac_hdmi_add_pinmux_cvt_route(struct hdac_ext_device *edev, 1003 + static void hdac_hdmi_add_pinmux_cvt_route(struct hdac_device *hdev, 993 1004 struct snd_soc_dapm_widget *widgets, 994 1005 struct snd_soc_dapm_route *route, int rindex) 995 1006 { 996 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1007 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 997 1008 const struct snd_kcontrol_new *kc; 998 1009 struct soc_enum *se; 999 1010 int mux_index = hdmi->num_cvt + hdmi->num_ports; ··· 1035 1046 { 1036 1047 struct snd_soc_dapm_widget *widgets; 1037 1048 struct snd_soc_dapm_route *route; 1038 - struct hdac_ext_device *edev = to_hda_ext_device(dapm->dev); 1039 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1049 + struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); 1050 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1040 1051 struct snd_soc_dai_driver *dai_drv = hdmi->dai_drv; 1041 1052 char widget_name[NAME_SIZE]; 1042 1053 struct hdac_hdmi_cvt *cvt; ··· 1088 1099 for (j = 0; j < pin->num_ports; j++) { 1089 1100 sprintf(widget_name, "Pin%d-Port%d Mux", 1090 1101 pin->nid, pin->ports[j].id); 1091 - ret = hdac_hdmi_create_pin_port_muxs(edev, 1102 + ret = hdac_hdmi_create_pin_port_muxs(hdev, 1092 1103 &pin->ports[j], &widgets[i], 1093 1104 widget_name); 1094 1105 if (ret < 0) ··· 1123 1134 } 1124 1135 } 1125 1136 1126 - hdac_hdmi_add_pinmux_cvt_route(edev, widgets, route, i); 1137 + hdac_hdmi_add_pinmux_cvt_route(hdev, widgets, route, i); 1127 1138 1128 1139 snd_soc_dapm_new_controls(dapm, widgets, 1129 1140 ((2 * hdmi->num_ports) + hdmi->num_cvt)); ··· 1135 1146 1136 1147 } 1137 1148 1138 - static int hdac_hdmi_init_dai_map(struct hdac_ext_device *edev) 1149 + static int hdac_hdmi_init_dai_map(struct hdac_device *hdev) 1139 1150 { 1140 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1151 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1141 1152 struct hdac_hdmi_dai_port_map *dai_map; 1142 1153 struct hdac_hdmi_cvt *cvt; 1143 1154 int dai_id = 0; ··· 1153 1164 dai_id++; 1154 1165 1155 1166 if (dai_id == HDA_MAX_CVTS) { 1156 - dev_warn(&edev->hdev.dev, 1167 + dev_warn(&hdev->dev, 1157 1168 "Max dais supported: %d\n", dai_id); 1158 1169 break; 1159 1170 } ··· 1162 1173 return 0; 1163 1174 } 1164 1175 1165 - static int hdac_hdmi_add_cvt(struct hdac_ext_device *edev, hda_nid_t nid) 1176 + static int hdac_hdmi_add_cvt(struct hdac_device *hdev, hda_nid_t nid) 1166 1177 { 1167 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1178 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1168 1179 struct hdac_hdmi_cvt *cvt; 1169 1180 char name[NAME_SIZE]; 1170 1181 ··· 1179 1190 list_add_tail(&cvt->head, &hdmi->cvt_list); 1180 1191 hdmi->num_cvt++; 1181 1192 1182 - return hdac_hdmi_query_cvt_params(&edev->hdev, cvt); 1193 + return hdac_hdmi_query_cvt_params(hdev, cvt); 1183 1194 } 1184 1195 1185 - static int hdac_hdmi_parse_eld(struct hdac_ext_device *edev, 1196 + static int hdac_hdmi_parse_eld(struct hdac_device *hdev, 1186 1197 struct hdac_hdmi_port *port) 1187 1198 { 1188 1199 unsigned int ver, mnl; ··· 1191 1202 >> DRM_ELD_VER_SHIFT; 1192 1203 1193 1204 if (ver != ELD_VER_CEA_861D && ver != ELD_VER_PARTIAL) { 1194 - dev_err(&edev->hdev.dev, "HDMI: Unknown ELD version %d\n", ver); 1205 + dev_err(&hdev->dev, "HDMI: Unknown ELD version %d\n", ver); 1195 1206 return -EINVAL; 1196 1207 } 1197 1208 ··· 1199 1210 DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT; 1200 1211 1201 1212 if (mnl > ELD_MAX_MNL) { 1202 - dev_err(&edev->hdev.dev, "HDMI: MNL Invalid %d\n", mnl); 1213 + dev_err(&hdev->dev, "HDMI: MNL Invalid %d\n", mnl); 1203 1214 return -EINVAL; 1204 1215 } 1205 1216 ··· 1211 1222 static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin, 1212 1223 struct hdac_hdmi_port *port) 1213 1224 { 1214 - struct hdac_ext_device *edev = pin->edev; 1215 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1225 + struct hdac_device *hdev = pin->hdev; 1226 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1216 1227 struct hdac_hdmi_pcm *pcm; 1217 1228 int size = 0; 1218 1229 int port_id = -1; ··· 1230 1241 if (pin->mst_capable) 1231 1242 port_id = port->id; 1232 1243 1233 - size = snd_hdac_acomp_get_eld(&edev->hdev, pin->nid, port_id, 1244 + size = snd_hdac_acomp_get_eld(hdev, pin->nid, port_id, 1234 1245 &port->eld.monitor_present, 1235 1246 port->eld.eld_buffer, 1236 1247 ELD_MAX_SIZE); 1237 1248 1238 1249 if (size > 0) { 1239 1250 size = min(size, ELD_MAX_SIZE); 1240 - if (hdac_hdmi_parse_eld(edev, port) < 0) 1251 + if (hdac_hdmi_parse_eld(hdev, port) < 0) 1241 1252 size = -EINVAL; 1242 1253 } 1243 1254 ··· 1249 1260 port->eld.eld_size = 0; 1250 1261 } 1251 1262 1252 - pcm = hdac_hdmi_get_pcm(edev, port); 1263 + pcm = hdac_hdmi_get_pcm(hdev, port); 1253 1264 1254 1265 if (!port->eld.monitor_present || !port->eld.eld_valid) { 1255 1266 1256 - dev_err(&edev->hdev.dev, "%s: disconnect for pin:port %d:%d\n", 1267 + dev_err(&hdev->dev, "%s: disconnect for pin:port %d:%d\n", 1257 1268 __func__, pin->nid, port->id); 1258 1269 1259 1270 /* ··· 1305 1316 return 0; 1306 1317 } 1307 1318 1308 - static int hdac_hdmi_add_pin(struct hdac_ext_device *edev, hda_nid_t nid) 1319 + static int hdac_hdmi_add_pin(struct hdac_device *hdev, hda_nid_t nid) 1309 1320 { 1310 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1321 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1311 1322 struct hdac_hdmi_pin *pin; 1312 1323 int ret; 1313 1324 ··· 1317 1328 1318 1329 pin->nid = nid; 1319 1330 pin->mst_capable = false; 1320 - pin->edev = edev; 1331 + pin->hdev = hdev; 1321 1332 ret = hdac_hdmi_add_ports(hdmi, pin); 1322 1333 if (ret < 0) 1323 1334 return ret; ··· 1448 1459 * Parse all nodes and store the cvt/pin nids in array 1449 1460 * Add one time initialization for pin and cvt widgets 1450 1461 */ 1451 - static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev, 1462 + static int hdac_hdmi_parse_and_map_nid(struct hdac_device *hdev, 1452 1463 struct snd_soc_dai_driver **dais, int *num_dais) 1453 1464 { 1454 1465 hda_nid_t nid; 1455 1466 int i, num_nodes; 1456 1467 struct hdac_hdmi_cvt *temp_cvt, *cvt_next; 1457 1468 struct hdac_hdmi_pin *temp_pin, *pin_next; 1458 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1459 - struct hdac_device *hdev = &edev->hdev; 1469 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1460 1470 int ret; 1461 1471 1462 1472 hdac_hdmi_skl_enable_all_pins(hdev); ··· 1480 1492 switch (type) { 1481 1493 1482 1494 case AC_WID_AUD_OUT: 1483 - ret = hdac_hdmi_add_cvt(edev, nid); 1495 + ret = hdac_hdmi_add_cvt(hdev, nid); 1484 1496 if (ret < 0) 1485 1497 goto free_widgets; 1486 1498 break; 1487 1499 1488 1500 case AC_WID_PIN: 1489 - ret = hdac_hdmi_add_pin(edev, nid); 1501 + ret = hdac_hdmi_add_pin(hdev, nid); 1490 1502 if (ret < 0) 1491 1503 goto free_widgets; 1492 1504 break; ··· 1506 1518 } 1507 1519 1508 1520 *num_dais = hdmi->num_cvt; 1509 - ret = hdac_hdmi_init_dai_map(edev); 1521 + ret = hdac_hdmi_init_dai_map(hdev); 1510 1522 if (ret < 0) 1511 1523 goto free_widgets; 1512 1524 ··· 1532 1544 1533 1545 static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) 1534 1546 { 1535 - struct hdac_ext_device *edev = aptr; 1536 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1547 + struct hdac_device *hdev = aptr; 1548 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1537 1549 struct hdac_hdmi_pin *pin = NULL; 1538 1550 struct hdac_hdmi_port *hport = NULL; 1539 - struct snd_soc_component *component = edev->scodec; 1551 + struct snd_soc_component *component = hdmi->component; 1540 1552 int i; 1541 1553 1542 1554 /* Don't know how this mapping is derived */ 1543 1555 hda_nid_t pin_nid = port + 0x04; 1544 1556 1545 - dev_dbg(&edev->hdev.dev, "%s: for pin:%d port=%d\n", __func__, 1557 + dev_dbg(&hdev->dev, "%s: for pin:%d port=%d\n", __func__, 1546 1558 pin_nid, pipe); 1547 1559 1548 1560 /* ··· 1555 1567 SNDRV_CTL_POWER_D0) 1556 1568 return; 1557 1569 1558 - if (atomic_read(&edev->hdev.in_pm)) 1570 + if (atomic_read(&hdev->in_pm)) 1559 1571 return; 1560 1572 1561 1573 list_for_each_entry(pin, &hdmi->pin_list, head) { ··· 1602 1614 1603 1615 /* create jack pin kcontrols */ 1604 1616 static int create_fill_jack_kcontrols(struct snd_soc_card *card, 1605 - struct hdac_ext_device *edev) 1617 + struct hdac_device *hdev) 1606 1618 { 1607 1619 struct hdac_hdmi_pin *pin; 1608 1620 struct snd_kcontrol_new *kc; 1609 1621 char kc_name[NAME_SIZE], xname[NAME_SIZE]; 1610 1622 char *name; 1611 1623 int i = 0, j; 1612 - struct snd_soc_component *component = edev->scodec; 1613 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1624 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1625 + struct snd_soc_component *component = hdmi->component; 1614 1626 1615 1627 kc = devm_kcalloc(component->dev, hdmi->num_ports, 1616 1628 sizeof(*kc), GFP_KERNEL); ··· 1647 1659 int hdac_hdmi_jack_port_init(struct snd_soc_component *component, 1648 1660 struct snd_soc_dapm_context *dapm) 1649 1661 { 1650 - struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); 1651 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1662 + struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); 1663 + struct hdac_device *hdev = hdmi->hdev; 1652 1664 struct hdac_hdmi_pin *pin; 1653 1665 struct snd_soc_dapm_widget *widgets; 1654 1666 struct snd_soc_dapm_route *route; ··· 1703 1715 return ret; 1704 1716 1705 1717 /* Add Jack Pin switch Kcontrol */ 1706 - ret = create_fill_jack_kcontrols(dapm->card, edev); 1718 + ret = create_fill_jack_kcontrols(dapm->card, hdev); 1707 1719 1708 1720 if (ret < 0) 1709 1721 return ret; ··· 1723 1735 struct snd_soc_jack *jack) 1724 1736 { 1725 1737 struct snd_soc_component *component = dai->component; 1726 - struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); 1727 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1738 + struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); 1739 + struct hdac_device *hdev = hdmi->hdev; 1728 1740 struct hdac_hdmi_pcm *pcm; 1729 1741 struct snd_pcm *snd_pcm; 1730 1742 int err; ··· 1746 1758 if (snd_pcm) { 1747 1759 err = snd_hdac_add_chmap_ctls(snd_pcm, device, &hdmi->chmap); 1748 1760 if (err < 0) { 1749 - dev_err(&edev->hdev.dev, 1761 + dev_err(&hdev->dev, 1750 1762 "chmap control add failed with err: %d for pcm: %d\n", 1751 1763 err, device); 1752 1764 kfree(pcm); ··· 1760 1772 } 1761 1773 EXPORT_SYMBOL_GPL(hdac_hdmi_jack_init); 1762 1774 1763 - static void hdac_hdmi_present_sense_all_pins(struct hdac_ext_device *edev, 1775 + static void hdac_hdmi_present_sense_all_pins(struct hdac_device *hdev, 1764 1776 struct hdac_hdmi_priv *hdmi, bool detect_pin_caps) 1765 1777 { 1766 1778 int i; ··· 1769 1781 list_for_each_entry(pin, &hdmi->pin_list, head) { 1770 1782 if (detect_pin_caps) { 1771 1783 1772 - if (hdac_hdmi_get_port_len(edev, pin->nid) == 0) 1784 + if (hdac_hdmi_get_port_len(hdev, pin->nid) == 0) 1773 1785 pin->mst_capable = false; 1774 1786 else 1775 1787 pin->mst_capable = true; ··· 1786 1798 1787 1799 static int hdmi_codec_probe(struct snd_soc_component *component) 1788 1800 { 1789 - struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); 1790 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1801 + struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); 1802 + struct hdac_device *hdev = hdmi->hdev; 1791 1803 struct snd_soc_dapm_context *dapm = 1792 1804 snd_soc_component_get_dapm(component); 1793 1805 struct hdac_ext_link *hlink = NULL; 1794 1806 int ret; 1795 1807 1796 - edev->scodec = component; 1808 + hdmi->component = component; 1797 1809 1798 1810 /* 1799 1811 * hold the ref while we probe, also no need to drop the ref on 1800 1812 * exit, we call pm_runtime_suspend() so that will do for us 1801 1813 */ 1802 - hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdev.dev)); 1814 + hlink = snd_hdac_ext_bus_get_link(hdev->bus, dev_name(&hdev->dev)); 1803 1815 if (!hlink) { 1804 - dev_err(&edev->hdev.dev, "hdac link not found\n"); 1816 + dev_err(&hdev->dev, "hdac link not found\n"); 1805 1817 return -EIO; 1806 1818 } 1807 1819 1808 - snd_hdac_ext_bus_link_get(edev->ebus, hlink); 1820 + snd_hdac_ext_bus_link_get(hdev->bus, hlink); 1809 1821 1810 1822 ret = create_fill_widget_route_map(dapm); 1811 1823 if (ret < 0) 1812 1824 return ret; 1813 1825 1814 - aops.audio_ptr = edev; 1826 + aops.audio_ptr = hdev; 1815 1827 ret = snd_hdac_i915_register_notifier(&aops); 1816 1828 if (ret < 0) { 1817 - dev_err(&edev->hdev.dev, "notifier register failed: err: %d\n", 1818 - ret); 1829 + dev_err(&hdev->dev, "notifier register failed: err: %d\n", ret); 1819 1830 return ret; 1820 1831 } 1821 1832 1822 - hdac_hdmi_present_sense_all_pins(edev, hdmi, true); 1833 + hdac_hdmi_present_sense_all_pins(hdev, hdmi, true); 1823 1834 /* Imp: Store the card pointer in hda_codec */ 1824 - edev->card = dapm->card->snd_card; 1835 + hdmi->card = dapm->card->snd_card; 1825 1836 1826 1837 /* 1827 1838 * hdac_device core already sets the state to active and calls 1828 1839 * get_noresume. So enable runtime and set the device to suspend. 1829 1840 */ 1830 - pm_runtime_enable(&edev->hdev.dev); 1831 - pm_runtime_put(&edev->hdev.dev); 1832 - pm_runtime_suspend(&edev->hdev.dev); 1841 + pm_runtime_enable(&hdev->dev); 1842 + pm_runtime_put(&hdev->dev); 1843 + pm_runtime_suspend(&hdev->dev); 1833 1844 1834 1845 return 0; 1835 1846 } 1836 1847 1837 1848 static void hdmi_codec_remove(struct snd_soc_component *component) 1838 1849 { 1839 - struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); 1850 + struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); 1851 + struct hdac_device *hdev = hdmi->hdev; 1840 1852 1841 - pm_runtime_disable(&edev->hdev.dev); 1853 + pm_runtime_disable(&hdev->dev); 1842 1854 } 1843 1855 1844 1856 #ifdef CONFIG_PM 1845 1857 static int hdmi_codec_prepare(struct device *dev) 1846 1858 { 1847 - struct hdac_ext_device *edev = to_hda_ext_device(dev); 1848 - struct hdac_device *hdev = &edev->hdev; 1859 + struct hdac_device *hdev = dev_to_hdac_dev(dev); 1849 1860 1850 - pm_runtime_get_sync(&edev->hdev.dev); 1861 + pm_runtime_get_sync(&hdev->dev); 1851 1862 1852 1863 /* 1853 1864 * Power down afg. ··· 1863 1876 1864 1877 static void hdmi_codec_complete(struct device *dev) 1865 1878 { 1866 - struct hdac_ext_device *edev = to_hda_ext_device(dev); 1867 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 1868 - struct hdac_device *hdev = &edev->hdev; 1879 + struct hdac_device *hdev = dev_to_hdac_dev(dev); 1880 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1869 1881 1870 1882 /* Power up afg */ 1871 1883 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, 1872 1884 AC_PWRST_D0); 1873 1885 1874 - hdac_hdmi_skl_enable_all_pins(&edev->hdev); 1875 - hdac_hdmi_skl_enable_dp12(&edev->hdev); 1886 + hdac_hdmi_skl_enable_all_pins(hdev); 1887 + hdac_hdmi_skl_enable_dp12(hdev); 1876 1888 1877 1889 /* 1878 1890 * As the ELD notify callback request is not entertained while the ··· 1879 1893 * all pins here. pin capablity change is not support, so use the 1880 1894 * already set pin caps. 1881 1895 */ 1882 - hdac_hdmi_present_sense_all_pins(edev, hdmi, false); 1896 + hdac_hdmi_present_sense_all_pins(hdev, hdmi, false); 1883 1897 1884 - pm_runtime_put_sync(&edev->hdev.dev); 1898 + pm_runtime_put_sync(&hdev->dev); 1885 1899 } 1886 1900 #else 1887 1901 #define hdmi_codec_prepare NULL ··· 1908 1922 static void hdac_hdmi_set_chmap(struct hdac_device *hdev, int pcm_idx, 1909 1923 unsigned char *chmap, int prepared) 1910 1924 { 1911 - struct hdac_ext_device *edev = to_ehdac_device(hdev); 1912 1925 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1913 1926 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); 1914 1927 struct hdac_hdmi_port *port; ··· 1923 1938 memcpy(pcm->chmap, chmap, ARRAY_SIZE(pcm->chmap)); 1924 1939 list_for_each_entry(port, &pcm->port_list, head) 1925 1940 if (prepared) 1926 - hdac_hdmi_setup_audio_infoframe(edev, pcm, port); 1941 + hdac_hdmi_setup_audio_infoframe(hdev, pcm, port); 1927 1942 mutex_unlock(&pcm->lock); 1928 1943 } 1929 1944 ··· 1972 1987 .vendor_nid = INTEL_VENDOR_NID, 1973 1988 }; 1974 1989 1975 - static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) 1990 + static int hdac_hdmi_dev_probe(struct hdac_device *hdev) 1976 1991 { 1977 - struct hdac_device *hdev = &edev->hdev; 1978 - struct hdac_hdmi_priv *hdmi_priv; 1992 + struct hdac_hdmi_priv *hdmi_priv = NULL; 1979 1993 struct snd_soc_dai_driver *hdmi_dais = NULL; 1980 1994 struct hdac_ext_link *hlink = NULL; 1981 1995 int num_dais = 0; ··· 1983 1999 const struct hda_device_id *hdac_id = hdac_get_device_id(hdev, hdrv); 1984 2000 1985 2001 /* hold the ref while we probe */ 1986 - hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdev.dev)); 2002 + hlink = snd_hdac_ext_bus_get_link(hdev->bus, dev_name(&hdev->dev)); 1987 2003 if (!hlink) { 1988 - dev_err(&edev->hdev.dev, "hdac link not found\n"); 2004 + dev_err(&hdev->dev, "hdac link not found\n"); 1989 2005 return -EIO; 1990 2006 } 1991 2007 1992 - snd_hdac_ext_bus_link_get(edev->ebus, hlink); 2008 + snd_hdac_ext_bus_link_get(hdev->bus, hlink); 1993 2009 1994 2010 hdmi_priv = devm_kzalloc(&hdev->dev, sizeof(*hdmi_priv), GFP_KERNEL); 1995 2011 if (hdmi_priv == NULL) 1996 2012 return -ENOMEM; 1997 2013 1998 - edev->private_data = hdmi_priv; 1999 2014 snd_hdac_register_chmap_ops(hdev, &hdmi_priv->chmap); 2000 2015 hdmi_priv->chmap.ops.get_chmap = hdac_hdmi_get_chmap; 2001 2016 hdmi_priv->chmap.ops.set_chmap = hdac_hdmi_set_chmap; 2002 2017 hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; 2003 2018 hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc; 2019 + hdmi_priv->hdev = hdev; 2004 2020 2005 2021 if (!hdac_id) 2006 2022 return -ENODEV; ··· 2011 2027 else 2012 2028 hdmi_priv->drv_data = &intel_drv_data; 2013 2029 2014 - dev_set_drvdata(&hdev->dev, edev); 2030 + dev_set_drvdata(&hdev->dev, hdmi_priv); 2015 2031 2016 2032 INIT_LIST_HEAD(&hdmi_priv->pin_list); 2017 2033 INIT_LIST_HEAD(&hdmi_priv->cvt_list); ··· 2022 2038 * Turned off in the runtime_suspend during the first explicit 2023 2039 * pm_runtime_suspend call. 2024 2040 */ 2025 - ret = snd_hdac_display_power(edev->hdev.bus, true); 2041 + ret = snd_hdac_display_power(hdev->bus, true); 2026 2042 if (ret < 0) { 2027 - dev_err(&edev->hdev.dev, 2043 + dev_err(&hdev->dev, 2028 2044 "Cannot turn on display power on i915 err: %d\n", 2029 2045 ret); 2030 2046 return ret; 2031 2047 } 2032 2048 2033 - ret = hdac_hdmi_parse_and_map_nid(edev, &hdmi_dais, &num_dais); 2049 + ret = hdac_hdmi_parse_and_map_nid(hdev, &hdmi_dais, &num_dais); 2034 2050 if (ret < 0) { 2035 2051 dev_err(&hdev->dev, 2036 2052 "Failed in parse and map nid with err: %d\n", ret); ··· 2042 2058 ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec, 2043 2059 hdmi_dais, num_dais); 2044 2060 2045 - snd_hdac_ext_bus_link_put(edev->ebus, hlink); 2061 + snd_hdac_ext_bus_link_put(hdev->bus, hlink); 2046 2062 2047 2063 return ret; 2048 2064 } 2049 2065 2050 - static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev) 2066 + static int hdac_hdmi_dev_remove(struct hdac_device *hdev) 2051 2067 { 2052 - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); 2068 + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 2053 2069 struct hdac_hdmi_pin *pin, *pin_next; 2054 2070 struct hdac_hdmi_cvt *cvt, *cvt_next; 2055 2071 struct hdac_hdmi_pcm *pcm, *pcm_next; ··· 2089 2105 #ifdef CONFIG_PM 2090 2106 static int hdac_hdmi_runtime_suspend(struct device *dev) 2091 2107 { 2092 - struct hdac_ext_device *edev = to_hda_ext_device(dev); 2093 - struct hdac_device *hdev = &edev->hdev; 2108 + struct hdac_device *hdev = dev_to_hdac_dev(dev); 2094 2109 struct hdac_bus *bus = hdev->bus; 2095 - struct hdac_ext_bus *ebus = hbus_to_ebus(bus); 2096 2110 struct hdac_ext_link *hlink = NULL; 2097 2111 int err; 2098 2112 ··· 2111 2129 AC_PWRST_D3); 2112 2130 err = snd_hdac_display_power(bus, false); 2113 2131 if (err < 0) { 2114 - dev_err(bus->dev, "Cannot turn on display power on i915\n"); 2132 + dev_err(dev, "Cannot turn on display power on i915\n"); 2115 2133 return err; 2116 2134 } 2117 2135 2118 - hlink = snd_hdac_ext_bus_get_link(ebus, dev_name(dev)); 2136 + hlink = snd_hdac_ext_bus_get_link(bus, dev_name(dev)); 2119 2137 if (!hlink) { 2120 2138 dev_err(dev, "hdac link not found\n"); 2121 2139 return -EIO; 2122 2140 } 2123 2141 2124 - snd_hdac_ext_bus_link_put(ebus, hlink); 2142 + snd_hdac_ext_bus_link_put(bus, hlink); 2125 2143 2126 2144 return 0; 2127 2145 } 2128 2146 2129 2147 static int hdac_hdmi_runtime_resume(struct device *dev) 2130 2148 { 2131 - struct hdac_ext_device *edev = to_hda_ext_device(dev); 2132 - struct hdac_device *hdev = &edev->hdev; 2149 + struct hdac_device *hdev = dev_to_hdac_dev(dev); 2133 2150 struct hdac_bus *bus = hdev->bus; 2134 - struct hdac_ext_bus *ebus = hbus_to_ebus(bus); 2135 2151 struct hdac_ext_link *hlink = NULL; 2136 2152 int err; 2137 2153 ··· 2139 2159 if (!bus) 2140 2160 return 0; 2141 2161 2142 - hlink = snd_hdac_ext_bus_get_link(ebus, dev_name(dev)); 2162 + hlink = snd_hdac_ext_bus_get_link(bus, dev_name(dev)); 2143 2163 if (!hlink) { 2144 2164 dev_err(dev, "hdac link not found\n"); 2145 2165 return -EIO; 2146 2166 } 2147 2167 2148 - snd_hdac_ext_bus_link_get(ebus, hlink); 2168 + snd_hdac_ext_bus_link_get(bus, hlink); 2149 2169 2150 2170 err = snd_hdac_display_power(bus, true); 2151 2171 if (err < 0) { 2152 - dev_err(bus->dev, "Cannot turn on display power on i915\n"); 2172 + dev_err(dev, "Cannot turn on display power on i915\n"); 2153 2173 return err; 2154 2174 } 2155 2175 2156 - hdac_hdmi_skl_enable_all_pins(&edev->hdev); 2157 - hdac_hdmi_skl_enable_dp12(&edev->hdev); 2176 + hdac_hdmi_skl_enable_all_pins(hdev); 2177 + hdac_hdmi_skl_enable_dp12(hdev); 2158 2178 2159 2179 /* Power up afg */ 2160 2180 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, ··· 2186 2206 2187 2207 MODULE_DEVICE_TABLE(hdaudio, hdmi_list); 2188 2208 2189 - static struct hdac_ext_driver hdmi_driver = { 2190 - . hdac = { 2191 - .driver = { 2192 - .name = "HDMI HDA Codec", 2193 - .pm = &hdac_hdmi_pm, 2194 - }, 2195 - .id_table = hdmi_list, 2209 + static struct hdac_driver hdmi_driver = { 2210 + .driver = { 2211 + .name = "HDMI HDA Codec", 2212 + .pm = &hdac_hdmi_pm, 2196 2213 }, 2214 + .id_table = hdmi_list, 2197 2215 .probe = hdac_hdmi_dev_probe, 2198 2216 .remove = hdac_hdmi_dev_remove, 2199 2217 };
+22 -28
sound/soc/intel/skylake/skl-messages.c
··· 33 33 static int skl_alloc_dma_buf(struct device *dev, 34 34 struct snd_dma_buffer *dmab, size_t size) 35 35 { 36 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 37 - struct hdac_bus *bus = ebus_to_hbus(ebus); 36 + struct hdac_bus *bus = dev_get_drvdata(dev); 38 37 39 38 if (!bus) 40 39 return -ENODEV; ··· 43 44 44 45 static int skl_free_dma_buf(struct device *dev, struct snd_dma_buffer *dmab) 45 46 { 46 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 47 - struct hdac_bus *bus = ebus_to_hbus(ebus); 47 + struct hdac_bus *bus = dev_get_drvdata(dev); 48 48 49 49 if (!bus) 50 50 return -ENODEV; ··· 87 89 static int skl_dsp_setup_spib(struct device *dev, unsigned int size, 88 90 int stream_tag, int enable) 89 91 { 90 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 91 - struct hdac_bus *bus = ebus_to_hbus(ebus); 92 + struct hdac_bus *bus = dev_get_drvdata(dev); 92 93 struct hdac_stream *stream = snd_hdac_get_stream(bus, 93 94 SNDRV_PCM_STREAM_PLAYBACK, stream_tag); 94 95 struct hdac_ext_stream *estream; ··· 97 100 98 101 estream = stream_to_hdac_ext_stream(stream); 99 102 /* enable/disable SPIB for this hdac stream */ 100 - snd_hdac_ext_stream_spbcap_enable(ebus, enable, stream->index); 103 + snd_hdac_ext_stream_spbcap_enable(bus, enable, stream->index); 101 104 102 105 /* set the spib value */ 103 - snd_hdac_ext_stream_set_spib(ebus, estream, size); 106 + snd_hdac_ext_stream_set_spib(bus, estream, size); 104 107 105 108 return 0; 106 109 } ··· 108 111 static int skl_dsp_prepare(struct device *dev, unsigned int format, 109 112 unsigned int size, struct snd_dma_buffer *dmab) 110 113 { 111 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 112 - struct hdac_bus *bus = ebus_to_hbus(ebus); 114 + struct hdac_bus *bus = dev_get_drvdata(dev); 113 115 struct hdac_ext_stream *estream; 114 116 struct hdac_stream *stream; 115 117 struct snd_pcm_substream substream; ··· 120 124 memset(&substream, 0, sizeof(substream)); 121 125 substream.stream = SNDRV_PCM_STREAM_PLAYBACK; 122 126 123 - estream = snd_hdac_ext_stream_assign(ebus, &substream, 127 + estream = snd_hdac_ext_stream_assign(bus, &substream, 124 128 HDAC_EXT_STREAM_TYPE_HOST); 125 129 if (!estream) 126 130 return -ENODEV; ··· 139 143 140 144 static int skl_dsp_trigger(struct device *dev, bool start, int stream_tag) 141 145 { 142 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 146 + struct hdac_bus *bus = dev_get_drvdata(dev); 143 147 struct hdac_stream *stream; 144 - struct hdac_bus *bus = ebus_to_hbus(ebus); 145 148 146 149 if (!bus) 147 150 return -ENODEV; ··· 158 163 static int skl_dsp_cleanup(struct device *dev, 159 164 struct snd_dma_buffer *dmab, int stream_tag) 160 165 { 161 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 166 + struct hdac_bus *bus = dev_get_drvdata(dev); 162 167 struct hdac_stream *stream; 163 168 struct hdac_ext_stream *estream; 164 - struct hdac_bus *bus = ebus_to_hbus(ebus); 165 169 166 170 if (!bus) 167 171 return -ENODEV; ··· 264 270 int skl_init_dsp(struct skl *skl) 265 271 { 266 272 void __iomem *mmio_base; 267 - struct hdac_ext_bus *ebus = &skl->ebus; 268 - struct hdac_bus *bus = ebus_to_hbus(ebus); 273 + struct hdac_bus *bus = skl_to_bus(skl); 269 274 struct skl_dsp_loader_ops loader_ops; 270 275 int irq = bus->irq; 271 276 const struct skl_dsp_ops *ops; ··· 272 279 int ret; 273 280 274 281 /* enable ppcap interrupt */ 275 - snd_hdac_ext_bus_ppcap_enable(&skl->ebus, true); 276 - snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, true); 282 + snd_hdac_ext_bus_ppcap_enable(bus, true); 283 + snd_hdac_ext_bus_ppcap_int_enable(bus, true); 277 284 278 285 /* read the BAR of the ADSP MMIO */ 279 286 mmio_base = pci_ioremap_bar(skl->pci, 4); ··· 328 335 329 336 int skl_free_dsp(struct skl *skl) 330 337 { 331 - struct hdac_ext_bus *ebus = &skl->ebus; 332 - struct hdac_bus *bus = ebus_to_hbus(ebus); 338 + struct hdac_bus *bus = skl_to_bus(skl); 333 339 struct skl_sst *ctx = skl->skl_sst; 334 340 335 341 /* disable ppcap interrupt */ 336 - snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, false); 342 + snd_hdac_ext_bus_ppcap_int_enable(bus, false); 337 343 338 344 ctx->dsp_ops->cleanup(bus->dev, ctx); 339 345 ··· 375 383 int skl_suspend_dsp(struct skl *skl) 376 384 { 377 385 struct skl_sst *ctx = skl->skl_sst; 386 + struct hdac_bus *bus = skl_to_bus(skl); 378 387 int ret; 379 388 380 389 /* if ppcap is not supported return 0 */ 381 - if (!skl->ebus.bus.ppcap) 390 + if (!bus->ppcap) 382 391 return 0; 383 392 384 393 ret = skl_dsp_sleep(ctx->dsp); ··· 387 394 return ret; 388 395 389 396 /* disable ppcap interrupt */ 390 - snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, false); 391 - snd_hdac_ext_bus_ppcap_enable(&skl->ebus, false); 397 + snd_hdac_ext_bus_ppcap_int_enable(bus, false); 398 + snd_hdac_ext_bus_ppcap_enable(bus, false); 392 399 393 400 return 0; 394 401 } ··· 396 403 int skl_resume_dsp(struct skl *skl) 397 404 { 398 405 struct skl_sst *ctx = skl->skl_sst; 406 + struct hdac_bus *bus = skl_to_bus(skl); 399 407 int ret; 400 408 401 409 /* if ppcap is not supported return 0 */ 402 - if (!skl->ebus.bus.ppcap) 410 + if (!bus->ppcap) 403 411 return 0; 404 412 405 413 /* enable ppcap interrupt */ 406 - snd_hdac_ext_bus_ppcap_enable(&skl->ebus, true); 407 - snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, true); 414 + snd_hdac_ext_bus_ppcap_enable(bus, true); 415 + snd_hdac_ext_bus_ppcap_int_enable(bus, true); 408 416 409 417 /* check if DSP 1st boot is done */ 410 418 if (skl->skl_sst->is_first_boot == true)
+4 -4
sound/soc/intel/skylake/skl-nhlt.c
··· 141 141 { 142 142 struct nhlt_fmt *fmt; 143 143 struct nhlt_endpoint *epnt; 144 - struct hdac_bus *bus = ebus_to_hbus(&skl->ebus); 144 + struct hdac_bus *bus = skl_to_bus(skl); 145 145 struct device *dev = bus->dev; 146 146 struct nhlt_specific_cfg *sp_config; 147 147 struct nhlt_acpi_table *nhlt = skl->nhlt; ··· 228 228 int skl_nhlt_update_topology_bin(struct skl *skl) 229 229 { 230 230 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; 231 - struct hdac_bus *bus = ebus_to_hbus(&skl->ebus); 231 + struct hdac_bus *bus = skl_to_bus(skl); 232 232 struct device *dev = bus->dev; 233 233 234 234 dev_dbg(dev, "oem_id %.6s, oem_table_id %8s oem_revision %d\n", ··· 248 248 struct device_attribute *attr, char *buf) 249 249 { 250 250 struct pci_dev *pci = to_pci_dev(dev); 251 - struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 252 - struct skl *skl = ebus_to_skl(ebus); 251 + struct hdac_bus *bus = pci_get_drvdata(pci); 252 + struct skl *skl = bus_to_skl(bus); 253 253 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; 254 254 char platform_id[32]; 255 255
+54 -58
sound/soc/intel/skylake/skl-pcm.c
··· 67 67 return substream->runtime->private_data; 68 68 } 69 69 70 - static struct hdac_ext_bus *get_bus_ctx(struct snd_pcm_substream *substream) 70 + static struct hdac_bus *get_bus_ctx(struct snd_pcm_substream *substream) 71 71 { 72 72 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); 73 73 struct hdac_stream *hstream = hdac_stream(stream); 74 74 struct hdac_bus *bus = hstream->bus; 75 - 76 - return hbus_to_ebus(bus); 75 + return bus; 77 76 } 78 77 79 - static int skl_substream_alloc_pages(struct hdac_ext_bus *ebus, 78 + static int skl_substream_alloc_pages(struct hdac_bus *bus, 80 79 struct snd_pcm_substream *substream, 81 80 size_t size) 82 81 { ··· 94 95 return snd_pcm_lib_free_pages(substream); 95 96 } 96 97 97 - static void skl_set_pcm_constrains(struct hdac_ext_bus *ebus, 98 + static void skl_set_pcm_constrains(struct hdac_bus *bus, 98 99 struct snd_pcm_runtime *runtime) 99 100 { 100 101 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); ··· 104 105 20, 178000000); 105 106 } 106 107 107 - static enum hdac_ext_stream_type skl_get_host_stream_type(struct hdac_ext_bus *ebus) 108 + static enum hdac_ext_stream_type skl_get_host_stream_type(struct hdac_bus *bus) 108 109 { 109 - if ((ebus_to_hbus(ebus))->ppcap) 110 + if (bus->ppcap) 110 111 return HDAC_EXT_STREAM_TYPE_HOST; 111 112 else 112 113 return HDAC_EXT_STREAM_TYPE_COUPLED; ··· 122 123 static void skl_set_suspend_active(struct snd_pcm_substream *substream, 123 124 struct snd_soc_dai *dai, bool enable) 124 125 { 125 - struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev); 126 + struct hdac_bus *bus = dev_get_drvdata(dai->dev); 126 127 struct snd_soc_dapm_widget *w; 127 - struct skl *skl = ebus_to_skl(ebus); 128 + struct skl *skl = bus_to_skl(bus); 128 129 129 130 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 130 131 w = dai->playback_widget; ··· 139 140 140 141 int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params) 141 142 { 142 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 143 - struct hdac_bus *bus = ebus_to_hbus(ebus); 143 + struct hdac_bus *bus = dev_get_drvdata(dev); 144 144 unsigned int format_val; 145 145 struct hdac_stream *hstream; 146 146 struct hdac_ext_stream *stream; ··· 151 153 return -EINVAL; 152 154 153 155 stream = stream_to_hdac_ext_stream(hstream); 154 - snd_hdac_ext_stream_decouple(ebus, stream, true); 156 + snd_hdac_ext_stream_decouple(bus, stream, true); 155 157 156 158 format_val = snd_hdac_calc_stream_format(params->s_freq, 157 159 params->ch, params->format, params->host_bps, 0); ··· 175 177 176 178 int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params) 177 179 { 178 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 179 - struct hdac_bus *bus = ebus_to_hbus(ebus); 180 + struct hdac_bus *bus = dev_get_drvdata(dev); 180 181 unsigned int format_val; 181 182 struct hdac_stream *hstream; 182 183 struct hdac_ext_stream *stream; ··· 187 190 return -EINVAL; 188 191 189 192 stream = stream_to_hdac_ext_stream(hstream); 190 - snd_hdac_ext_stream_decouple(ebus, stream, true); 193 + snd_hdac_ext_stream_decouple(bus, stream, true); 191 194 format_val = snd_hdac_calc_stream_format(params->s_freq, params->ch, 192 195 params->format, params->link_bps, 0); 193 196 ··· 198 201 199 202 snd_hdac_ext_link_stream_setup(stream, format_val); 200 203 201 - list_for_each_entry(link, &ebus->hlink_list, list) { 204 + list_for_each_entry(link, &bus->hlink_list, list) { 202 205 if (link->index == params->link_index) 203 206 snd_hdac_ext_link_set_stream_id(link, 204 207 hstream->stream_tag); ··· 212 215 static int skl_pcm_open(struct snd_pcm_substream *substream, 213 216 struct snd_soc_dai *dai) 214 217 { 215 - struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev); 218 + struct hdac_bus *bus = dev_get_drvdata(dai->dev); 216 219 struct hdac_ext_stream *stream; 217 220 struct snd_pcm_runtime *runtime = substream->runtime; 218 221 struct skl_dma_params *dma_params; ··· 221 224 222 225 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); 223 226 224 - stream = snd_hdac_ext_stream_assign(ebus, substream, 225 - skl_get_host_stream_type(ebus)); 227 + stream = snd_hdac_ext_stream_assign(bus, substream, 228 + skl_get_host_stream_type(bus)); 226 229 if (stream == NULL) 227 230 return -EBUSY; 228 231 229 - skl_set_pcm_constrains(ebus, runtime); 232 + skl_set_pcm_constrains(bus, runtime); 230 233 231 234 /* 232 235 * disable WALLCLOCK timestamps for capture streams ··· 298 301 struct snd_pcm_hw_params *params, 299 302 struct snd_soc_dai *dai) 300 303 { 301 - struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev); 304 + struct hdac_bus *bus = dev_get_drvdata(dai->dev); 302 305 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); 303 306 struct snd_pcm_runtime *runtime = substream->runtime; 304 307 struct skl_pipe_params p_params = {0}; ··· 306 309 int ret, dma_id; 307 310 308 311 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); 309 - ret = skl_substream_alloc_pages(ebus, substream, 312 + ret = skl_substream_alloc_pages(bus, substream, 310 313 params_buffer_bytes(params)); 311 314 if (ret < 0) 312 315 return ret; ··· 340 343 struct snd_soc_dai *dai) 341 344 { 342 345 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); 343 - struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev); 346 + struct hdac_bus *bus = dev_get_drvdata(dai->dev); 344 347 struct skl_dma_params *dma_params = NULL; 345 - struct skl *skl = ebus_to_skl(ebus); 348 + struct skl *skl = bus_to_skl(bus); 346 349 struct skl_module_cfg *mconfig; 347 350 348 351 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); 349 352 350 - snd_hdac_ext_stream_release(stream, skl_get_host_stream_type(ebus)); 353 + snd_hdac_ext_stream_release(stream, skl_get_host_stream_type(bus)); 351 354 352 355 dma_params = snd_soc_dai_get_dma_data(dai, substream); 353 356 /* ··· 377 380 static int skl_pcm_hw_free(struct snd_pcm_substream *substream, 378 381 struct snd_soc_dai *dai) 379 382 { 380 - struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev); 383 + struct hdac_bus *bus = dev_get_drvdata(dai->dev); 381 384 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); 382 385 struct skl *skl = get_skl_ctx(dai->dev); 383 386 struct skl_module_cfg *mconfig; ··· 397 400 snd_hdac_stream_cleanup(hdac_stream(stream)); 398 401 hdac_stream(stream)->prepared = 0; 399 402 400 - return skl_substream_free_pages(ebus_to_hbus(ebus), substream); 403 + return skl_substream_free_pages(bus, substream); 401 404 } 402 405 403 406 static int skl_be_hw_params(struct snd_pcm_substream *substream, ··· 417 420 static int skl_decoupled_trigger(struct snd_pcm_substream *substream, 418 421 int cmd) 419 422 { 420 - struct hdac_ext_bus *ebus = get_bus_ctx(substream); 421 - struct hdac_bus *bus = ebus_to_hbus(ebus); 423 + struct hdac_bus *bus = get_bus_ctx(substream); 422 424 struct hdac_ext_stream *stream; 423 425 int start; 424 426 unsigned long cookie; ··· 466 470 struct skl *skl = get_skl_ctx(dai->dev); 467 471 struct skl_sst *ctx = skl->skl_sst; 468 472 struct skl_module_cfg *mconfig; 469 - struct hdac_ext_bus *ebus = get_bus_ctx(substream); 473 + struct hdac_bus *bus = get_bus_ctx(substream); 470 474 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); 471 475 struct snd_soc_dapm_widget *w; 472 476 int ret; ··· 488 492 * dpib & lpib position to resume before starting the 489 493 * DMA 490 494 */ 491 - snd_hdac_ext_stream_drsm_enable(ebus, true, 495 + snd_hdac_ext_stream_drsm_enable(bus, true, 492 496 hdac_stream(stream)->index); 493 - snd_hdac_ext_stream_set_dpibr(ebus, stream, 497 + snd_hdac_ext_stream_set_dpibr(bus, stream, 494 498 stream->lpib); 495 499 snd_hdac_ext_stream_set_lpib(stream, stream->lpib); 496 500 } ··· 524 528 ret = skl_decoupled_trigger(substream, cmd); 525 529 if ((cmd == SNDRV_PCM_TRIGGER_SUSPEND) && !w->ignore_suspend) { 526 530 /* save the dpib and lpib positions */ 527 - stream->dpib = readl(ebus->bus.remap_addr + 531 + stream->dpib = readl(bus->remap_addr + 528 532 AZX_REG_VS_SDXDPIB_XBASE + 529 533 (AZX_REG_VS_SDXDPIB_XINTERVAL * 530 534 hdac_stream(stream)->index)); 531 535 532 536 stream->lpib = snd_hdac_stream_get_pos_lpib( 533 537 hdac_stream(stream)); 534 - snd_hdac_ext_stream_decouple(ebus, stream, false); 538 + snd_hdac_ext_stream_decouple(bus, stream, false); 535 539 } 536 540 break; 537 541 ··· 542 546 return 0; 543 547 } 544 548 549 + 545 550 static int skl_link_hw_params(struct snd_pcm_substream *substream, 546 551 struct snd_pcm_hw_params *params, 547 552 struct snd_soc_dai *dai) 548 553 { 549 - struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev); 554 + struct hdac_bus *bus = dev_get_drvdata(dai->dev); 550 555 struct hdac_ext_stream *link_dev; 551 556 struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); 552 557 struct snd_soc_dai *codec_dai = rtd->codec_dai; ··· 555 558 struct hdac_ext_link *link; 556 559 int stream_tag; 557 560 558 - link_dev = snd_hdac_ext_stream_assign(ebus, substream, 561 + link_dev = snd_hdac_ext_stream_assign(bus, substream, 559 562 HDAC_EXT_STREAM_TYPE_LINK); 560 563 if (!link_dev) 561 564 return -EBUSY; 562 565 563 566 snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev); 564 567 565 - link = snd_hdac_ext_bus_get_link(ebus, codec_dai->component->name); 568 + link = snd_hdac_ext_bus_get_link(bus, codec_dai->component->name); 566 569 if (!link) 567 570 return -EINVAL; 568 571 ··· 607 610 { 608 611 struct hdac_ext_stream *link_dev = 609 612 snd_soc_dai_get_dma_data(dai, substream); 610 - struct hdac_ext_bus *ebus = get_bus_ctx(substream); 613 + struct hdac_bus *bus = get_bus_ctx(substream); 611 614 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); 612 615 613 616 dev_dbg(dai->dev, "In %s cmd=%d\n", __func__, cmd); ··· 623 626 case SNDRV_PCM_TRIGGER_STOP: 624 627 snd_hdac_ext_link_stream_clear(link_dev); 625 628 if (cmd == SNDRV_PCM_TRIGGER_SUSPEND) 626 - snd_hdac_ext_stream_decouple(ebus, stream, false); 629 + snd_hdac_ext_stream_decouple(bus, stream, false); 627 630 break; 628 631 629 632 default: ··· 635 638 static int skl_link_hw_free(struct snd_pcm_substream *substream, 636 639 struct snd_soc_dai *dai) 637 640 { 638 - struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev); 641 + struct hdac_bus *bus = dev_get_drvdata(dai->dev); 639 642 struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); 640 643 struct hdac_ext_stream *link_dev = 641 644 snd_soc_dai_get_dma_data(dai, substream); ··· 645 648 646 649 link_dev->link_prepared = 0; 647 650 648 - link = snd_hdac_ext_bus_get_link(ebus, rtd->codec_dai->component->name); 651 + link = snd_hdac_ext_bus_get_link(bus, rtd->codec_dai->component->name); 649 652 if (!link) 650 653 return -EINVAL; 651 654 ··· 1038 1041 static int skl_coupled_trigger(struct snd_pcm_substream *substream, 1039 1042 int cmd) 1040 1043 { 1041 - struct hdac_ext_bus *ebus = get_bus_ctx(substream); 1042 - struct hdac_bus *bus = ebus_to_hbus(ebus); 1044 + struct hdac_bus *bus = get_bus_ctx(substream); 1043 1045 struct hdac_ext_stream *stream; 1044 1046 struct snd_pcm_substream *s; 1045 1047 bool start; ··· 1111 1115 static int skl_platform_pcm_trigger(struct snd_pcm_substream *substream, 1112 1116 int cmd) 1113 1117 { 1114 - struct hdac_ext_bus *ebus = get_bus_ctx(substream); 1118 + struct hdac_bus *bus = get_bus_ctx(substream); 1115 1119 1116 - if (!(ebus_to_hbus(ebus))->ppcap) 1120 + if (!bus->ppcap) 1117 1121 return skl_coupled_trigger(substream, cmd); 1118 1122 1119 1123 return 0; ··· 1123 1127 (struct snd_pcm_substream *substream) 1124 1128 { 1125 1129 struct hdac_ext_stream *hstream = get_hdac_ext_stream(substream); 1126 - struct hdac_ext_bus *ebus = get_bus_ctx(substream); 1130 + struct hdac_bus *bus = get_bus_ctx(substream); 1127 1131 unsigned int pos; 1128 1132 1129 1133 /* ··· 1148 1152 */ 1149 1153 1150 1154 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1151 - pos = readl(ebus->bus.remap_addr + AZX_REG_VS_SDXDPIB_XBASE + 1155 + pos = readl(bus->remap_addr + AZX_REG_VS_SDXDPIB_XBASE + 1152 1156 (AZX_REG_VS_SDXDPIB_XINTERVAL * 1153 1157 hdac_stream(hstream)->index)); 1154 1158 } else { 1155 1159 udelay(20); 1156 - readl(ebus->bus.remap_addr + 1160 + readl(bus->remap_addr + 1157 1161 AZX_REG_VS_SDXDPIB_XBASE + 1158 1162 (AZX_REG_VS_SDXDPIB_XINTERVAL * 1159 1163 hdac_stream(hstream)->index)); ··· 1238 1242 static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd) 1239 1243 { 1240 1244 struct snd_soc_dai *dai = rtd->cpu_dai; 1241 - struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev); 1245 + struct hdac_bus *bus = dev_get_drvdata(dai->dev); 1242 1246 struct snd_pcm *pcm = rtd->pcm; 1243 1247 unsigned int size; 1244 1248 int retval = 0; 1245 - struct skl *skl = ebus_to_skl(ebus); 1249 + struct skl *skl = bus_to_skl(bus); 1246 1250 1247 1251 if (dai->driver->playback.channels_min || 1248 1252 dai->driver->capture.channels_min) { ··· 1352 1356 1353 1357 static int skl_platform_soc_probe(struct snd_soc_component *component) 1354 1358 { 1355 - struct hdac_ext_bus *ebus = dev_get_drvdata(component->dev); 1356 - struct skl *skl = ebus_to_skl(ebus); 1359 + struct hdac_bus *bus = dev_get_drvdata(component->dev); 1360 + struct skl *skl = bus_to_skl(bus); 1357 1361 const struct skl_dsp_ops *ops; 1358 1362 int ret; 1359 1363 1360 1364 pm_runtime_get_sync(component->dev); 1361 - if ((ebus_to_hbus(ebus))->ppcap) { 1365 + if (bus->ppcap) { 1362 1366 skl->component = component; 1363 1367 1364 1368 /* init debugfs */ 1365 1369 skl->debugfs = skl_debugfs_init(skl); 1366 1370 1367 - ret = skl_tplg_init(component, ebus); 1371 + ret = skl_tplg_init(component, bus); 1368 1372 if (ret < 0) { 1369 1373 dev_err(component->dev, "Failed to init topology!\n"); 1370 1374 return ret; ··· 1421 1425 int skl_platform_register(struct device *dev) 1422 1426 { 1423 1427 int ret; 1424 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 1425 - struct skl *skl = ebus_to_skl(ebus); 1426 1428 struct snd_soc_dai_driver *dais; 1427 1429 int num_dais = ARRAY_SIZE(skl_platform_dai); 1430 + struct hdac_bus *bus = dev_get_drvdata(dev); 1431 + struct skl *skl = bus_to_skl(bus); 1428 1432 1429 1433 INIT_LIST_HEAD(&skl->ppl_list); 1430 1434 INIT_LIST_HEAD(&skl->bind_list); ··· 1460 1464 1461 1465 int skl_platform_unregister(struct device *dev) 1462 1466 { 1463 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 1464 - struct skl *skl = ebus_to_skl(ebus); 1467 + struct hdac_bus *bus = dev_get_drvdata(dev); 1468 + struct skl *skl = bus_to_skl(bus); 1465 1469 struct skl_module_deferred_bind *modules, *tmp; 1466 1470 1467 1471 if (!list_empty(&skl->bind_list)) {
+8 -12
sound/soc/intel/skylake/skl-topology.c
··· 934 934 struct soc_bytes_ext *sb = (void *) k->private_value; 935 935 struct skl_algo_data *bc = (struct skl_algo_data *)sb->dobj.private; 936 936 struct skl_kpb_params *uuid_params, *params; 937 - struct hdac_bus *bus = ebus_to_hbus(skl_to_ebus(skl)); 937 + struct hdac_bus *bus = skl_to_bus(skl); 938 938 int i, size, module_id; 939 939 940 940 if (bc->set_params == SKL_PARAM_BIND && bc->max) { ··· 3029 3029 struct snd_soc_tplg_dapm_widget *tplg_w) 3030 3030 { 3031 3031 int ret; 3032 - struct hdac_ext_bus *ebus = snd_soc_component_get_drvdata(cmpnt); 3033 - struct skl *skl = ebus_to_skl(ebus); 3034 - struct hdac_bus *bus = ebus_to_hbus(ebus); 3032 + struct hdac_bus *bus = snd_soc_component_get_drvdata(cmpnt); 3033 + struct skl *skl = bus_to_skl(bus); 3035 3034 struct skl_module_cfg *mconfig; 3036 3035 3037 3036 if (!tplg_w->priv.size) ··· 3136 3137 struct soc_bytes_ext *sb; 3137 3138 struct snd_soc_tplg_bytes_control *tplg_bc; 3138 3139 struct snd_soc_tplg_enum_control *tplg_ec; 3139 - struct hdac_ext_bus *ebus = snd_soc_component_get_drvdata(cmpnt); 3140 - struct hdac_bus *bus = ebus_to_hbus(ebus); 3140 + struct hdac_bus *bus = snd_soc_component_get_drvdata(cmpnt); 3141 3141 struct soc_enum *se; 3142 3142 3143 3143 switch (hdr->ops.info) { ··· 3620 3622 static int skl_manifest_load(struct snd_soc_component *cmpnt, 3621 3623 struct snd_soc_tplg_manifest *manifest) 3622 3624 { 3623 - struct hdac_ext_bus *ebus = snd_soc_component_get_drvdata(cmpnt); 3624 - struct hdac_bus *bus = ebus_to_hbus(ebus); 3625 - struct skl *skl = ebus_to_skl(ebus); 3625 + struct hdac_bus *bus = snd_soc_component_get_drvdata(cmpnt); 3626 + struct skl *skl = bus_to_skl(bus); 3626 3627 3627 3628 /* proceed only if we have private data defined */ 3628 3629 if (manifest->priv.size == 0) ··· 3710 3713 /* 3711 3714 * SKL topology init routine 3712 3715 */ 3713 - int skl_tplg_init(struct snd_soc_component *component, struct hdac_ext_bus *ebus) 3716 + int skl_tplg_init(struct snd_soc_component *component, struct hdac_bus *bus) 3714 3717 { 3715 3718 int ret; 3716 3719 const struct firmware *fw; 3717 - struct hdac_bus *bus = ebus_to_hbus(ebus); 3718 - struct skl *skl = ebus_to_skl(ebus); 3720 + struct skl *skl = bus_to_skl(bus); 3719 3721 struct skl_pipeline *ppl; 3720 3722 3721 3723 ret = request_firmware(&fw, skl->tplg_name, bus->dev);
+3 -3
sound/soc/intel/skylake/skl-topology.h
··· 458 458 459 459 static inline struct skl *get_skl_ctx(struct device *dev) 460 460 { 461 - struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 461 + struct hdac_bus *bus = dev_get_drvdata(dev); 462 462 463 - return ebus_to_skl(ebus); 463 + return bus_to_skl(bus); 464 464 } 465 465 466 466 int skl_tplg_be_update_params(struct snd_soc_dai *dai, ··· 470 470 void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai, 471 471 struct skl_pipe_params *params, int stream); 472 472 int skl_tplg_init(struct snd_soc_component *component, 473 - struct hdac_ext_bus *ebus); 473 + struct hdac_bus *ebus); 474 474 struct skl_module_cfg *skl_tplg_fe_get_cpr_module( 475 475 struct snd_soc_dai *dai, int stream); 476 476 int skl_tplg_update_pipe_params(struct device *dev,
+88 -102
sound/soc/intel/skylake/skl.c
··· 54 54 55 55 static void skl_init_pci(struct skl *skl) 56 56 { 57 - struct hdac_ext_bus *ebus = &skl->ebus; 57 + struct hdac_bus *bus = skl_to_bus(skl); 58 58 59 59 /* 60 60 * Clear bits 0-2 of PCI register TCSEL (at offset 0x44) ··· 63 63 * codecs. 64 64 * The PCI register TCSEL is defined in the Intel manuals. 65 65 */ 66 - dev_dbg(ebus_to_hbus(ebus)->dev, "Clearing TCSEL\n"); 66 + dev_dbg(bus->dev, "Clearing TCSEL\n"); 67 67 skl_update_pci_byte(skl->pci, AZX_PCIREG_TCSEL, 0x07, 0); 68 68 } 69 69 ··· 103 103 static void skl_clock_power_gating(struct device *dev, bool enable) 104 104 { 105 105 struct pci_dev *pci = to_pci_dev(dev); 106 - struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 107 - struct hdac_bus *bus = ebus_to_hbus(ebus); 106 + struct hdac_bus *bus = pci_get_drvdata(pci); 108 107 u32 val; 109 108 110 109 /* Update PDCGE bit of CGCTL register */ ··· 126 127 */ 127 128 static int skl_init_chip(struct hdac_bus *bus, bool full_reset) 128 129 { 129 - struct hdac_ext_bus *ebus = hbus_to_ebus(bus); 130 130 struct hdac_ext_link *hlink; 131 131 int ret; 132 132 ··· 133 135 ret = snd_hdac_bus_init_chip(bus, full_reset); 134 136 135 137 /* Reset stream-to-link mapping */ 136 - list_for_each_entry(hlink, &ebus->hlink_list, list) 138 + list_for_each_entry(hlink, &bus->hlink_list, list) 137 139 bus->io_ops->reg_writel(0, hlink->ml_addr + AZX_REG_ML_LOSIDV); 138 140 139 141 skl_enable_miscbdcge(bus->dev, true); ··· 144 146 void skl_update_d0i3c(struct device *dev, bool enable) 145 147 { 146 148 struct pci_dev *pci = to_pci_dev(dev); 147 - struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 148 - struct hdac_bus *bus = ebus_to_hbus(ebus); 149 + struct hdac_bus *bus = pci_get_drvdata(pci); 149 150 u8 reg; 150 151 int timeout = 50; 151 152 ··· 194 197 195 198 static irqreturn_t skl_interrupt(int irq, void *dev_id) 196 199 { 197 - struct hdac_ext_bus *ebus = dev_id; 198 - struct hdac_bus *bus = ebus_to_hbus(ebus); 200 + struct hdac_bus *bus = dev_id; 199 201 u32 status; 200 202 201 203 if (!pm_runtime_active(bus->dev)) ··· 223 227 224 228 static irqreturn_t skl_threaded_handler(int irq, void *dev_id) 225 229 { 226 - struct hdac_ext_bus *ebus = dev_id; 227 - struct hdac_bus *bus = ebus_to_hbus(ebus); 230 + struct hdac_bus *bus = dev_id; 228 231 u32 status; 229 232 230 233 status = snd_hdac_chip_readl(bus, INTSTS); ··· 233 238 return IRQ_HANDLED; 234 239 } 235 240 236 - static int skl_acquire_irq(struct hdac_ext_bus *ebus, int do_disconnect) 241 + static int skl_acquire_irq(struct hdac_bus *bus, int do_disconnect) 237 242 { 238 - struct skl *skl = ebus_to_skl(ebus); 239 - struct hdac_bus *bus = ebus_to_hbus(ebus); 243 + struct skl *skl = bus_to_skl(bus); 240 244 int ret; 241 245 242 246 ret = request_threaded_irq(skl->pci->irq, skl_interrupt, 243 247 skl_threaded_handler, 244 248 IRQF_SHARED, 245 - KBUILD_MODNAME, ebus); 249 + KBUILD_MODNAME, bus); 246 250 if (ret) { 247 251 dev_err(bus->dev, 248 252 "unable to grab IRQ %d, disabling device\n", ··· 258 264 static int skl_suspend_late(struct device *dev) 259 265 { 260 266 struct pci_dev *pci = to_pci_dev(dev); 261 - struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 262 - struct skl *skl = ebus_to_skl(ebus); 267 + struct hdac_bus *bus = pci_get_drvdata(pci); 268 + struct skl *skl = bus_to_skl(bus); 263 269 264 270 return skl_suspend_late_dsp(skl); 265 271 } 266 272 267 273 #ifdef CONFIG_PM 268 - static int _skl_suspend(struct hdac_ext_bus *ebus) 274 + static int _skl_suspend(struct hdac_bus *bus) 269 275 { 270 - struct skl *skl = ebus_to_skl(ebus); 271 - struct hdac_bus *bus = ebus_to_hbus(ebus); 276 + struct skl *skl = bus_to_skl(bus); 272 277 struct pci_dev *pci = to_pci_dev(bus->dev); 273 278 int ret; 274 279 275 - snd_hdac_ext_bus_link_power_down_all(ebus); 280 + snd_hdac_ext_bus_link_power_down_all(bus); 276 281 277 282 ret = skl_suspend_dsp(skl); 278 283 if (ret < 0) ··· 288 295 return 0; 289 296 } 290 297 291 - static int _skl_resume(struct hdac_ext_bus *ebus) 298 + static int _skl_resume(struct hdac_bus *bus) 292 299 { 293 - struct skl *skl = ebus_to_skl(ebus); 294 - struct hdac_bus *bus = ebus_to_hbus(ebus); 300 + struct skl *skl = bus_to_skl(bus); 295 301 296 302 skl_init_pci(skl); 297 303 skl_init_chip(bus, true); ··· 306 314 static int skl_suspend(struct device *dev) 307 315 { 308 316 struct pci_dev *pci = to_pci_dev(dev); 309 - struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 310 - struct skl *skl = ebus_to_skl(ebus); 311 - struct hdac_bus *bus = ebus_to_hbus(ebus); 317 + struct hdac_bus *bus = pci_get_drvdata(pci); 318 + struct skl *skl = bus_to_skl(bus); 312 319 int ret = 0; 313 320 314 321 /* ··· 316 325 */ 317 326 if (skl->supend_active) { 318 327 /* turn off the links and stop the CORB/RIRB DMA if it is On */ 319 - snd_hdac_ext_bus_link_power_down_all(ebus); 328 + snd_hdac_ext_bus_link_power_down_all(bus); 320 329 321 - if (ebus->cmd_dma_state) 322 - snd_hdac_bus_stop_cmd_io(&ebus->bus); 330 + if (bus->cmd_dma_state) 331 + snd_hdac_bus_stop_cmd_io(bus); 323 332 324 333 enable_irq_wake(bus->irq); 325 334 pci_save_state(pci); 326 335 } else { 327 - ret = _skl_suspend(ebus); 336 + ret = _skl_suspend(bus); 328 337 if (ret < 0) 329 338 return ret; 330 339 skl->skl_sst->fw_loaded = false; ··· 343 352 static int skl_resume(struct device *dev) 344 353 { 345 354 struct pci_dev *pci = to_pci_dev(dev); 346 - struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 347 - struct skl *skl = ebus_to_skl(ebus); 348 - struct hdac_bus *bus = ebus_to_hbus(ebus); 355 + struct hdac_bus *bus = pci_get_drvdata(pci); 356 + struct skl *skl = bus_to_skl(bus); 349 357 struct hdac_ext_link *hlink = NULL; 350 358 int ret; 351 359 ··· 364 374 */ 365 375 if (skl->supend_active) { 366 376 pci_restore_state(pci); 367 - snd_hdac_ext_bus_link_power_up_all(ebus); 377 + snd_hdac_ext_bus_link_power_up_all(bus); 368 378 disable_irq_wake(bus->irq); 369 379 /* 370 380 * turn On the links which are On before active suspend 371 381 * and start the CORB/RIRB DMA if On before 372 382 * active suspend. 373 383 */ 374 - list_for_each_entry(hlink, &ebus->hlink_list, list) { 384 + list_for_each_entry(hlink, &bus->hlink_list, list) { 375 385 if (hlink->ref_count) 376 386 snd_hdac_ext_bus_link_power_up(hlink); 377 387 } 378 388 379 - if (ebus->cmd_dma_state) 380 - snd_hdac_bus_init_cmd_io(&ebus->bus); 381 389 ret = 0; 390 + if (bus->cmd_dma_state) 391 + snd_hdac_bus_init_cmd_io(bus); 382 392 } else { 383 - ret = _skl_resume(ebus); 393 + ret = _skl_resume(bus); 384 394 385 395 /* turn off the links which are off before suspend */ 386 - list_for_each_entry(hlink, &ebus->hlink_list, list) { 396 + list_for_each_entry(hlink, &bus->hlink_list, list) { 387 397 if (!hlink->ref_count) 388 398 snd_hdac_ext_bus_link_power_down(hlink); 389 399 } 390 400 391 - if (!ebus->cmd_dma_state) 392 - snd_hdac_bus_stop_cmd_io(&ebus->bus); 401 + if (!bus->cmd_dma_state) 402 + snd_hdac_bus_stop_cmd_io(bus); 393 403 } 394 404 395 405 return ret; ··· 400 410 static int skl_runtime_suspend(struct device *dev) 401 411 { 402 412 struct pci_dev *pci = to_pci_dev(dev); 403 - struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 404 - struct hdac_bus *bus = ebus_to_hbus(ebus); 413 + struct hdac_bus *bus = pci_get_drvdata(pci); 405 414 406 415 dev_dbg(bus->dev, "in %s\n", __func__); 407 416 408 - return _skl_suspend(ebus); 417 + return _skl_suspend(bus); 409 418 } 410 419 411 420 static int skl_runtime_resume(struct device *dev) 412 421 { 413 422 struct pci_dev *pci = to_pci_dev(dev); 414 - struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 415 - struct hdac_bus *bus = ebus_to_hbus(ebus); 423 + struct hdac_bus *bus = pci_get_drvdata(pci); 416 424 417 425 dev_dbg(bus->dev, "in %s\n", __func__); 418 426 419 - return _skl_resume(ebus); 427 + return _skl_resume(bus); 420 428 } 421 429 #endif /* CONFIG_PM */ 422 430 ··· 427 439 /* 428 440 * destructor 429 441 */ 430 - static int skl_free(struct hdac_ext_bus *ebus) 442 + static int skl_free(struct hdac_bus *bus) 431 443 { 432 - struct skl *skl = ebus_to_skl(ebus); 433 - struct hdac_bus *bus = ebus_to_hbus(ebus); 444 + struct skl *skl = bus_to_skl(bus); 434 445 435 446 skl->init_done = 0; /* to be sure */ 436 447 437 - snd_hdac_ext_stop_streams(ebus); 448 + snd_hdac_ext_stop_streams(bus); 438 449 439 450 if (bus->irq >= 0) 440 - free_irq(bus->irq, (void *)ebus); 451 + free_irq(bus->irq, (void *)bus); 441 452 snd_hdac_bus_free_stream_pages(bus); 442 - snd_hdac_stream_free_all(ebus); 443 - snd_hdac_link_free_all(ebus); 453 + snd_hdac_stream_free_all(bus); 454 + snd_hdac_link_free_all(bus); 444 455 445 456 if (bus->remap_addr) 446 457 iounmap(bus->remap_addr); ··· 447 460 pci_release_regions(skl->pci); 448 461 pci_disable_device(skl->pci); 449 462 450 - snd_hdac_ext_bus_exit(ebus); 463 + snd_hdac_ext_bus_exit(bus); 451 464 452 465 cancel_work_sync(&skl->probe_work); 453 466 if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) 454 - snd_hdac_i915_exit(&ebus->bus); 467 + snd_hdac_i915_exit(bus); 455 468 456 469 return 0; 457 470 } ··· 475 488 476 489 static int skl_find_machine(struct skl *skl, void *driver_data) 477 490 { 491 + struct hdac_bus *bus = skl_to_bus(skl); 478 492 struct snd_soc_acpi_mach *mach = driver_data; 479 - struct hdac_bus *bus = ebus_to_hbus(&skl->ebus); 480 493 struct skl_machine_pdata *pdata; 481 494 482 495 mach = snd_soc_acpi_find_machine(mach); ··· 497 510 498 511 static int skl_machine_device_register(struct skl *skl) 499 512 { 500 - struct hdac_bus *bus = ebus_to_hbus(&skl->ebus); 513 + struct hdac_bus *bus = skl_to_bus(skl); 501 514 struct snd_soc_acpi_mach *mach = skl->mach; 502 515 struct platform_device *pdev; 503 516 int ret; ··· 531 544 532 545 static int skl_dmic_device_register(struct skl *skl) 533 546 { 534 - struct hdac_bus *bus = ebus_to_hbus(&skl->ebus); 547 + struct hdac_bus *bus = skl_to_bus(skl); 535 548 struct platform_device *pdev; 536 549 int ret; 537 550 ··· 630 643 /* 631 644 * Probe the given codec address 632 645 */ 633 - static int probe_codec(struct hdac_ext_bus *ebus, int addr) 646 + static int probe_codec(struct hdac_bus *bus, int addr) 634 647 { 635 - struct hdac_bus *bus = ebus_to_hbus(ebus); 636 648 unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) | 637 649 (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID; 638 650 unsigned int res = -1; 651 + struct skl *skl = bus_to_skl(bus); 652 + struct hdac_device *hdev; 639 653 640 654 mutex_lock(&bus->cmd_mutex); 641 655 snd_hdac_bus_send_cmd(bus, cmd); ··· 646 658 return -EIO; 647 659 dev_dbg(bus->dev, "codec #%d probed OK\n", addr); 648 660 649 - return snd_hdac_ext_bus_device_init(ebus, addr); 661 + hdev = devm_kzalloc(&skl->pci->dev, sizeof(*hdev), GFP_KERNEL); 662 + if (!hdev) 663 + return -ENOMEM; 664 + 665 + return snd_hdac_ext_bus_device_init(bus, addr, hdev); 650 666 } 651 667 652 668 /* Codec initialization */ 653 - static void skl_codec_create(struct hdac_ext_bus *ebus) 669 + static void skl_codec_create(struct hdac_bus *bus) 654 670 { 655 - struct hdac_bus *bus = ebus_to_hbus(ebus); 656 671 int c, max_slots; 657 672 658 673 max_slots = HDA_MAX_CODECS; ··· 663 672 /* First try to probe all given codec slots */ 664 673 for (c = 0; c < max_slots; c++) { 665 674 if ((bus->codec_mask & (1 << c))) { 666 - if (probe_codec(ebus, c) < 0) { 675 + if (probe_codec(bus, c) < 0) { 667 676 /* 668 677 * Some BIOSen give you wrong codec addresses 669 678 * that don't exist ··· 713 722 static void skl_probe_work(struct work_struct *work) 714 723 { 715 724 struct skl *skl = container_of(work, struct skl, probe_work); 716 - struct hdac_ext_bus *ebus = &skl->ebus; 717 - struct hdac_bus *bus = ebus_to_hbus(ebus); 725 + struct hdac_bus *bus = skl_to_bus(skl); 718 726 struct hdac_ext_link *hlink = NULL; 719 727 int err; 720 728 ··· 734 744 dev_info(bus->dev, "no hda codecs found!\n"); 735 745 736 746 /* create codec instances */ 737 - skl_codec_create(ebus); 747 + skl_codec_create(bus); 738 748 739 749 /* register platform dai and controls */ 740 750 err = skl_platform_register(bus->dev); ··· 763 773 /* 764 774 * we are done probing so decrement link counts 765 775 */ 766 - list_for_each_entry(hlink, &ebus->hlink_list, list) 767 - snd_hdac_ext_bus_link_put(ebus, hlink); 776 + list_for_each_entry(hlink, &bus->hlink_list, list) 777 + snd_hdac_ext_bus_link_put(bus, hlink); 768 778 769 779 /* configure PM */ 770 780 pm_runtime_put_noidle(bus->dev); ··· 786 796 struct skl **rskl) 787 797 { 788 798 struct skl *skl; 789 - struct hdac_ext_bus *ebus; 799 + struct hdac_bus *bus; 790 800 791 801 int err; 792 802 ··· 801 811 pci_disable_device(pci); 802 812 return -ENOMEM; 803 813 } 804 - ebus = &skl->ebus; 805 - snd_hdac_ext_bus_init(ebus, &pci->dev, &bus_core_ops, io_ops); 806 - ebus->bus.use_posbuf = 1; 814 + 815 + bus = skl_to_bus(skl); 816 + snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, io_ops, NULL); 817 + bus->use_posbuf = 1; 807 818 skl->pci = pci; 808 819 INIT_WORK(&skl->probe_work, skl_probe_work); 809 - 810 - ebus->bus.bdl_pos_adj = 0; 820 + bus->bdl_pos_adj = 0; 811 821 812 822 *rskl = skl; 813 823 814 824 return 0; 815 825 } 816 826 817 - static int skl_first_init(struct hdac_ext_bus *ebus) 827 + static int skl_first_init(struct hdac_bus *bus) 818 828 { 819 - struct skl *skl = ebus_to_skl(ebus); 820 - struct hdac_bus *bus = ebus_to_hbus(ebus); 829 + struct skl *skl = bus_to_skl(bus); 821 830 struct pci_dev *pci = skl->pci; 822 831 int err; 823 832 unsigned short gcap; ··· 837 848 838 849 snd_hdac_bus_parse_capabilities(bus); 839 850 840 - if (skl_acquire_irq(ebus, 0) < 0) 851 + if (skl_acquire_irq(bus, 0) < 0) 841 852 return -EBUSY; 842 853 843 854 pci_set_master(pci); ··· 861 872 if (!pb_streams && !cp_streams) 862 873 return -EIO; 863 874 864 - ebus->num_streams = cp_streams + pb_streams; 875 + bus->num_streams = cp_streams + pb_streams; 865 876 866 877 /* initialize streams */ 867 878 snd_hdac_ext_stream_init_all 868 - (ebus, 0, cp_streams, SNDRV_PCM_STREAM_CAPTURE); 879 + (bus, 0, cp_streams, SNDRV_PCM_STREAM_CAPTURE); 869 880 start_idx = cp_streams; 870 881 snd_hdac_ext_stream_init_all 871 - (ebus, start_idx, pb_streams, SNDRV_PCM_STREAM_PLAYBACK); 882 + (bus, start_idx, pb_streams, SNDRV_PCM_STREAM_PLAYBACK); 872 883 873 884 err = snd_hdac_bus_alloc_stream_pages(bus); 874 885 if (err < 0) ··· 884 895 const struct pci_device_id *pci_id) 885 896 { 886 897 struct skl *skl; 887 - struct hdac_ext_bus *ebus = NULL; 888 898 struct hdac_bus *bus = NULL; 889 899 int err; 890 900 ··· 892 904 if (err < 0) 893 905 return err; 894 906 895 - ebus = &skl->ebus; 896 - bus = ebus_to_hbus(ebus); 907 + bus = skl_to_bus(skl); 897 908 898 - err = skl_first_init(ebus); 909 + err = skl_first_init(bus); 899 910 if (err < 0) 900 911 goto out_free; 901 912 ··· 915 928 916 929 skl_nhlt_update_topology_bin(skl); 917 930 918 - pci_set_drvdata(skl->pci, ebus); 931 + pci_set_drvdata(skl->pci, bus); 919 932 920 933 skl_dmic_data.dmic_num = skl_get_dmic_geo(skl); 921 934 ··· 939 952 skl->skl_sst->clock_power_gating = skl_clock_power_gating; 940 953 } 941 954 if (bus->mlcap) 942 - snd_hdac_ext_bus_get_ml_capabilities(ebus); 955 + snd_hdac_ext_bus_get_ml_capabilities(bus); 943 956 944 957 snd_hdac_bus_stop_chip(bus); 945 958 ··· 959 972 out_nhlt_free: 960 973 skl_nhlt_free(skl->nhlt); 961 974 out_free: 962 - skl_free(ebus); 975 + skl_free(bus); 963 976 964 977 return err; 965 978 } 966 979 967 980 static void skl_shutdown(struct pci_dev *pci) 968 981 { 969 - struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 970 - struct hdac_bus *bus = ebus_to_hbus(ebus); 982 + struct hdac_bus *bus = pci_get_drvdata(pci); 971 983 struct hdac_stream *s; 972 984 struct hdac_ext_stream *stream; 973 985 struct skl *skl; 974 986 975 - if (ebus == NULL) 987 + if (!bus) 976 988 return; 977 989 978 - skl = ebus_to_skl(ebus); 990 + skl = bus_to_skl(bus); 979 991 980 992 if (!skl->init_done) 981 993 return; 982 994 983 - snd_hdac_ext_stop_streams(ebus); 995 + snd_hdac_ext_stop_streams(bus); 984 996 list_for_each_entry(s, &bus->stream_list, list) { 985 997 stream = stream_to_hdac_ext_stream(s); 986 - snd_hdac_ext_stream_decouple(ebus, stream, false); 998 + snd_hdac_ext_stream_decouple(bus, stream, false); 987 999 } 988 1000 989 1001 snd_hdac_bus_stop_chip(bus); ··· 990 1004 991 1005 static void skl_remove(struct pci_dev *pci) 992 1006 { 993 - struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 994 - struct skl *skl = ebus_to_skl(ebus); 1007 + struct hdac_bus *bus = pci_get_drvdata(pci); 1008 + struct skl *skl = bus_to_skl(bus); 995 1009 996 1010 release_firmware(skl->tplg); 997 1011 998 1012 pm_runtime_get_noresume(&pci->dev); 999 1013 1000 1014 /* codec removal, invoke bus_device_remove */ 1001 - snd_hdac_ext_bus_device_remove(ebus); 1015 + snd_hdac_ext_bus_device_remove(bus); 1002 1016 1003 1017 skl->debugfs = NULL; 1004 1018 skl_platform_unregister(&pci->dev); ··· 1008 1022 skl_clock_device_unregister(skl); 1009 1023 skl_nhlt_remove_sysfs(skl); 1010 1024 skl_nhlt_free(skl->nhlt); 1011 - skl_free(ebus); 1025 + skl_free(bus); 1012 1026 dev_set_drvdata(&pci->dev, NULL); 1013 1027 } 1014 1028
+3 -4
sound/soc/intel/skylake/skl.h
··· 71 71 }; 72 72 73 73 struct skl { 74 - struct hdac_ext_bus ebus; 74 + struct hdac_bus hbus; 75 75 struct pci_dev *pci; 76 76 77 77 unsigned int init_done:1; /* delayed init status */ ··· 105 105 struct snd_soc_acpi_mach *mach; 106 106 }; 107 107 108 - #define skl_to_ebus(s) (&(s)->ebus) 109 - #define ebus_to_skl(sbus) \ 110 - container_of(sbus, struct skl, sbus) 108 + #define skl_to_bus(s) (&(s)->hbus) 109 + #define bus_to_skl(bus) container_of(bus, struct skl, hbus) 111 110 112 111 /* to pass dai dma data */ 113 112 struct skl_dma_params {