aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2018-01-12 16:19:05 -0500
committerMark Brown <broonie@kernel.org>2018-01-12 16:19:05 -0500
commit05a76e8101828950a4e7faa3178d418d7fad3db7 (patch)
tree405116936da312164edb683101a603d385fec40e
parent2be2d57986431626e905ee344086affa44c5bb9b (diff)
parent1e02dac395fadfff1f2c6bd90f1180f64a9cbebe (diff)
Merge branch 'topic/hdac-hdmi' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-intel
-rw-r--r--include/sound/hdaudio_ext.h4
-rw-r--r--sound/hda/ext/hdac_ext_bus.c2
-rw-r--r--sound/soc/codecs/hdac_hdmi.c356
3 files changed, 178 insertions, 184 deletions
diff --git a/include/sound/hdaudio_ext.h b/include/sound/hdaudio_ext.h
index ca00130cb028..9c14e21dda85 100644
--- a/include/sound/hdaudio_ext.h
+++ b/include/sound/hdaudio_ext.h
@@ -193,7 +193,7 @@ struct hda_dai_map {
193 * @pvt_data - private data, for asoc contains asoc codec object 193 * @pvt_data - private data, for asoc contains asoc codec object
194 */ 194 */
195struct hdac_ext_device { 195struct hdac_ext_device {
196 struct hdac_device hdac; 196 struct hdac_device hdev;
197 struct hdac_ext_bus *ebus; 197 struct hdac_ext_bus *ebus;
198 198
199 /* soc-dai to nid map */ 199 /* soc-dai to nid map */
@@ -213,7 +213,7 @@ struct hdac_ext_dma_params {
213 u8 stream_tag; 213 u8 stream_tag;
214}; 214};
215#define to_ehdac_device(dev) (container_of((dev), \ 215#define to_ehdac_device(dev) (container_of((dev), \
216 struct hdac_ext_device, hdac)) 216 struct hdac_ext_device, hdev))
217/* 217/*
218 * HD-audio codec base driver 218 * HD-audio codec base driver
219 */ 219 */
diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c
index 31b510c5ca0b..0daf31383084 100644
--- a/sound/hda/ext/hdac_ext_bus.c
+++ b/sound/hda/ext/hdac_ext_bus.c
@@ -146,7 +146,7 @@ int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *ebus, int addr)
146 edev = kzalloc(sizeof(*edev), GFP_KERNEL); 146 edev = kzalloc(sizeof(*edev), GFP_KERNEL);
147 if (!edev) 147 if (!edev)
148 return -ENOMEM; 148 return -ENOMEM;
149 hdev = &edev->hdac; 149 hdev = &edev->hdev;
150 edev->ebus = ebus; 150 edev->ebus = ebus;
151 151
152 snprintf(name, sizeof(name), "ehdaudio%dD%d", ebus->idx, addr); 152 snprintf(name, sizeof(name), "ehdaudio%dD%d", ebus->idx, addr);
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index f3b4f4dfae6a..15c3638fe345 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -136,8 +136,11 @@ struct hdac_hdmi_priv {
136 struct mutex pin_mutex; 136 struct mutex pin_mutex;
137 struct hdac_chmap chmap; 137 struct hdac_chmap chmap;
138 struct hdac_hdmi_drv_data *drv_data; 138 struct hdac_hdmi_drv_data *drv_data;
139 struct snd_soc_dai_driver *dai_drv;
139}; 140};
140 141
142#define hdev_to_hdmi_priv(_hdev) ((to_ehdac_device(_hdev))->private_data)
143
141static struct hdac_hdmi_pcm * 144static struct hdac_hdmi_pcm *
142hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi, 145hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi,
143 struct hdac_hdmi_cvt *cvt) 146 struct hdac_hdmi_cvt *cvt)
@@ -169,7 +172,7 @@ static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm,
169 * ports. 172 * ports.
170 */ 173 */
171 if (pcm->jack_event == 0) { 174 if (pcm->jack_event == 0) {
172 dev_dbg(&edev->hdac.dev, 175 dev_dbg(&edev->hdev.dev,
173 "jack report for pcm=%d\n", 176 "jack report for pcm=%d\n",
174 pcm->pcm_id); 177 pcm->pcm_id);
175 snd_soc_jack_report(pcm->jack, SND_JACK_AVOUT, 178 snd_soc_jack_report(pcm->jack, SND_JACK_AVOUT,
@@ -195,18 +198,18 @@ static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm,
195/* 198/*
196 * Get the no devices that can be connected to a port on the Pin widget. 199 * Get the no devices that can be connected to a port on the Pin widget.
197 */ 200 */
198static int hdac_hdmi_get_port_len(struct hdac_ext_device *hdac, hda_nid_t nid) 201static int hdac_hdmi_get_port_len(struct hdac_ext_device *edev, hda_nid_t nid)
199{ 202{
200 unsigned int caps; 203 unsigned int caps;
201 unsigned int type, param; 204 unsigned int type, param;
202 205
203 caps = get_wcaps(&hdac->hdac, nid); 206 caps = get_wcaps(&edev->hdev, nid);
204 type = get_wcaps_type(caps); 207 type = get_wcaps_type(caps);
205 208
206 if (!(caps & AC_WCAP_DIGITAL) || (type != AC_WID_PIN)) 209 if (!(caps & AC_WCAP_DIGITAL) || (type != AC_WID_PIN))
207 return 0; 210 return 0;
208 211
209 param = snd_hdac_read_parm_uncached(&hdac->hdac, nid, 212 param = snd_hdac_read_parm_uncached(&edev->hdev, nid,
210 AC_PAR_DEVLIST_LEN); 213 AC_PAR_DEVLIST_LEN);
211 if (param == -1) 214 if (param == -1)
212 return param; 215 return param;
@@ -219,10 +222,10 @@ static int hdac_hdmi_get_port_len(struct hdac_ext_device *hdac, hda_nid_t nid)
219 * id selected on the pin. Return 0 means the first port entry 222 * id selected on the pin. Return 0 means the first port entry
220 * is selected or MST is not supported. 223 * is selected or MST is not supported.
221 */ 224 */
222static int hdac_hdmi_port_select_get(struct hdac_ext_device *hdac, 225static int hdac_hdmi_port_select_get(struct hdac_ext_device *edev,
223 struct hdac_hdmi_port *port) 226 struct hdac_hdmi_port *port)
224{ 227{
225 return snd_hdac_codec_read(&hdac->hdac, port->pin->nid, 228 return snd_hdac_codec_read(&edev->hdev, port->pin->nid,
226 0, AC_VERB_GET_DEVICE_SEL, 0); 229 0, AC_VERB_GET_DEVICE_SEL, 0);
227} 230}
228 231
@@ -230,7 +233,7 @@ static int hdac_hdmi_port_select_get(struct hdac_ext_device *hdac,
230 * Sets the selected port entry for the configuring Pin widget verb. 233 * Sets the selected port entry for the configuring Pin widget verb.
231 * returns error if port set is not equal to port get otherwise success 234 * returns error if port set is not equal to port get otherwise success
232 */ 235 */
233static int hdac_hdmi_port_select_set(struct hdac_ext_device *hdac, 236static int hdac_hdmi_port_select_set(struct hdac_ext_device *edev,
234 struct hdac_hdmi_port *port) 237 struct hdac_hdmi_port *port)
235{ 238{
236 int num_ports; 239 int num_ports;
@@ -239,7 +242,7 @@ static int hdac_hdmi_port_select_set(struct hdac_ext_device *hdac,
239 return 0; 242 return 0;
240 243
241 /* AC_PAR_DEVLIST_LEN is 0 based. */ 244 /* AC_PAR_DEVLIST_LEN is 0 based. */
242 num_ports = hdac_hdmi_get_port_len(hdac, port->pin->nid); 245 num_ports = hdac_hdmi_get_port_len(edev, port->pin->nid);
243 246
244 if (num_ports < 0) 247 if (num_ports < 0)
245 return -EIO; 248 return -EIO;
@@ -250,13 +253,13 @@ static int hdac_hdmi_port_select_set(struct hdac_ext_device *hdac,
250 if (num_ports + 1 < port->id) 253 if (num_ports + 1 < port->id)
251 return 0; 254 return 0;
252 255
253 snd_hdac_codec_write(&hdac->hdac, port->pin->nid, 0, 256 snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0,
254 AC_VERB_SET_DEVICE_SEL, port->id); 257 AC_VERB_SET_DEVICE_SEL, port->id);
255 258
256 if (port->id != hdac_hdmi_port_select_get(hdac, port)) 259 if (port->id != hdac_hdmi_port_select_get(edev, port))
257 return -EIO; 260 return -EIO;
258 261
259 dev_dbg(&hdac->hdac.dev, "Selected the port=%d\n", port->id); 262 dev_dbg(&edev->hdev.dev, "Selected the port=%d\n", port->id);
260 263
261 return 0; 264 return 0;
262} 265}
@@ -276,9 +279,9 @@ static struct hdac_hdmi_pcm *get_hdmi_pcm_from_id(struct hdac_hdmi_priv *hdmi,
276 279
277static inline struct hdac_ext_device *to_hda_ext_device(struct device *dev) 280static inline struct hdac_ext_device *to_hda_ext_device(struct device *dev)
278{ 281{
279 struct hdac_device *hdac = dev_to_hdac_dev(dev); 282 struct hdac_device *hdev = dev_to_hdac_dev(dev);
280 283
281 return to_ehdac_device(hdac); 284 return to_ehdac_device(hdev);
282} 285}
283 286
284static unsigned int sad_format(const u8 *sad) 287static unsigned int sad_format(const u8 *sad)
@@ -321,14 +324,14 @@ format_constraint:
321} 324}
322 325
323static void 326static void
324hdac_hdmi_set_dip_index(struct hdac_ext_device *hdac, hda_nid_t pin_nid, 327hdac_hdmi_set_dip_index(struct hdac_ext_device *edev, hda_nid_t pin_nid,
325 int packet_index, int byte_index) 328 int packet_index, int byte_index)
326{ 329{
327 int val; 330 int val;
328 331
329 val = (packet_index << 5) | (byte_index & 0x1f); 332 val = (packet_index << 5) | (byte_index & 0x1f);
330 333
331 snd_hdac_codec_write(&hdac->hdac, pin_nid, 0, 334 snd_hdac_codec_write(&edev->hdev, pin_nid, 0,
332 AC_VERB_SET_HDMI_DIP_INDEX, val); 335 AC_VERB_SET_HDMI_DIP_INDEX, val);
333} 336}
334 337
@@ -344,14 +347,14 @@ struct dp_audio_infoframe {
344 u8 LFEPBL01_LSV36_DM_INH7; 347 u8 LFEPBL01_LSV36_DM_INH7;
345}; 348};
346 349
347static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *hdac, 350static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *edev,
348 struct hdac_hdmi_pcm *pcm, struct hdac_hdmi_port *port) 351 struct hdac_hdmi_pcm *pcm, struct hdac_hdmi_port *port)
349{ 352{
350 uint8_t buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE]; 353 uint8_t buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE];
351 struct hdmi_audio_infoframe frame; 354 struct hdmi_audio_infoframe frame;
352 struct hdac_hdmi_pin *pin = port->pin; 355 struct hdac_hdmi_pin *pin = port->pin;
353 struct dp_audio_infoframe dp_ai; 356 struct dp_audio_infoframe dp_ai;
354 struct hdac_hdmi_priv *hdmi = hdac->private_data; 357 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
355 struct hdac_hdmi_cvt *cvt = pcm->cvt; 358 struct hdac_hdmi_cvt *cvt = pcm->cvt;
356 u8 *dip; 359 u8 *dip;
357 int ret; 360 int ret;
@@ -360,11 +363,11 @@ static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *hdac,
360 u8 conn_type; 363 u8 conn_type;
361 int channels, ca; 364 int channels, ca;
362 365
363 ca = snd_hdac_channel_allocation(&hdac->hdac, port->eld.info.spk_alloc, 366 ca = snd_hdac_channel_allocation(&edev->hdev, port->eld.info.spk_alloc,
364 pcm->channels, pcm->chmap_set, true, pcm->chmap); 367 pcm->channels, pcm->chmap_set, true, pcm->chmap);
365 368
366 channels = snd_hdac_get_active_channels(ca); 369 channels = snd_hdac_get_active_channels(ca);
367 hdmi->chmap.ops.set_channel_count(&hdac->hdac, cvt->nid, channels); 370 hdmi->chmap.ops.set_channel_count(&edev->hdev, cvt->nid, channels);
368 371
369 snd_hdac_setup_channel_mapping(&hdmi->chmap, pin->nid, false, ca, 372 snd_hdac_setup_channel_mapping(&hdmi->chmap, pin->nid, false, ca,
370 pcm->channels, pcm->chmap, pcm->chmap_set); 373 pcm->channels, pcm->chmap, pcm->chmap_set);
@@ -397,32 +400,32 @@ static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *hdac,
397 break; 400 break;
398 401
399 default: 402 default:
400 dev_err(&hdac->hdac.dev, "Invalid connection type: %d\n", 403 dev_err(&edev->hdev.dev, "Invalid connection type: %d\n",
401 conn_type); 404 conn_type);
402 return -EIO; 405 return -EIO;
403 } 406 }
404 407
405 /* stop infoframe transmission */ 408 /* stop infoframe transmission */
406 hdac_hdmi_set_dip_index(hdac, pin->nid, 0x0, 0x0); 409 hdac_hdmi_set_dip_index(edev, pin->nid, 0x0, 0x0);
407 snd_hdac_codec_write(&hdac->hdac, pin->nid, 0, 410 snd_hdac_codec_write(&edev->hdev, pin->nid, 0,
408 AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_DISABLE); 411 AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_DISABLE);
409 412
410 413
411 /* Fill infoframe. Index auto-incremented */ 414 /* Fill infoframe. Index auto-incremented */
412 hdac_hdmi_set_dip_index(hdac, pin->nid, 0x0, 0x0); 415 hdac_hdmi_set_dip_index(edev, pin->nid, 0x0, 0x0);
413 if (conn_type == DRM_ELD_CONN_TYPE_HDMI) { 416 if (conn_type == DRM_ELD_CONN_TYPE_HDMI) {
414 for (i = 0; i < sizeof(buffer); i++) 417 for (i = 0; i < sizeof(buffer); i++)
415 snd_hdac_codec_write(&hdac->hdac, pin->nid, 0, 418 snd_hdac_codec_write(&edev->hdev, pin->nid, 0,
416 AC_VERB_SET_HDMI_DIP_DATA, buffer[i]); 419 AC_VERB_SET_HDMI_DIP_DATA, buffer[i]);
417 } else { 420 } else {
418 for (i = 0; i < sizeof(dp_ai); i++) 421 for (i = 0; i < sizeof(dp_ai); i++)
419 snd_hdac_codec_write(&hdac->hdac, pin->nid, 0, 422 snd_hdac_codec_write(&edev->hdev, pin->nid, 0,
420 AC_VERB_SET_HDMI_DIP_DATA, dip[i]); 423 AC_VERB_SET_HDMI_DIP_DATA, dip[i]);
421 } 424 }
422 425
423 /* Start infoframe */ 426 /* Start infoframe */
424 hdac_hdmi_set_dip_index(hdac, pin->nid, 0x0, 0x0); 427 hdac_hdmi_set_dip_index(edev, pin->nid, 0x0, 0x0);
425 snd_hdac_codec_write(&hdac->hdac, pin->nid, 0, 428 snd_hdac_codec_write(&edev->hdev, pin->nid, 0,
426 AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_BEST); 429 AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_BEST);
427 430
428 return 0; 431 return 0;
@@ -433,11 +436,11 @@ static int hdac_hdmi_set_tdm_slot(struct snd_soc_dai *dai,
433 int slots, int slot_width) 436 int slots, int slot_width)
434{ 437{
435 struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); 438 struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai);
436 struct hdac_hdmi_priv *hdmi = edev->private_data; 439 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
437 struct hdac_hdmi_dai_port_map *dai_map; 440 struct hdac_hdmi_dai_port_map *dai_map;
438 struct hdac_hdmi_pcm *pcm; 441 struct hdac_hdmi_pcm *pcm;
439 442
440 dev_dbg(&edev->hdac.dev, "%s: strm_tag: %d\n", __func__, tx_mask); 443 dev_dbg(&edev->hdev.dev, "%s: strm_tag: %d\n", __func__, tx_mask);
441 444
442 dai_map = &hdmi->dai_map[dai->id]; 445 dai_map = &hdmi->dai_map[dai->id];
443 446
@@ -452,8 +455,8 @@ static int hdac_hdmi_set_tdm_slot(struct snd_soc_dai *dai,
452static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream, 455static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream,
453 struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai) 456 struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai)
454{ 457{
455 struct hdac_ext_device *hdac = snd_soc_dai_get_drvdata(dai); 458 struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai);
456 struct hdac_hdmi_priv *hdmi = hdac->private_data; 459 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
457 struct hdac_hdmi_dai_port_map *dai_map; 460 struct hdac_hdmi_dai_port_map *dai_map;
458 struct hdac_hdmi_port *port; 461 struct hdac_hdmi_port *port;
459 struct hdac_hdmi_pcm *pcm; 462 struct hdac_hdmi_pcm *pcm;
@@ -466,7 +469,7 @@ static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream,
466 return -ENODEV; 469 return -ENODEV;
467 470
468 if ((!port->eld.monitor_present) || (!port->eld.eld_valid)) { 471 if ((!port->eld.monitor_present) || (!port->eld.eld_valid)) {
469 dev_err(&hdac->hdac.dev, 472 dev_err(&edev->hdev.dev,
470 "device is not configured for this pin:port%d:%d\n", 473 "device is not configured for this pin:port%d:%d\n",
471 port->pin->nid, port->id); 474 port->pin->nid, port->id);
472 return -ENODEV; 475 return -ENODEV;
@@ -486,28 +489,28 @@ static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream,
486 return 0; 489 return 0;
487} 490}
488 491
489static int hdac_hdmi_query_port_connlist(struct hdac_ext_device *hdac, 492static int hdac_hdmi_query_port_connlist(struct hdac_ext_device *edev,
490 struct hdac_hdmi_pin *pin, 493 struct hdac_hdmi_pin *pin,
491 struct hdac_hdmi_port *port) 494 struct hdac_hdmi_port *port)
492{ 495{
493 if (!(get_wcaps(&hdac->hdac, pin->nid) & AC_WCAP_CONN_LIST)) { 496 if (!(get_wcaps(&edev->hdev, pin->nid) & AC_WCAP_CONN_LIST)) {
494 dev_warn(&hdac->hdac.dev, 497 dev_warn(&edev->hdev.dev,
495 "HDMI: pin %d wcaps %#x does not support connection list\n", 498 "HDMI: pin %d wcaps %#x does not support connection list\n",
496 pin->nid, get_wcaps(&hdac->hdac, pin->nid)); 499 pin->nid, get_wcaps(&edev->hdev, pin->nid));
497 return -EINVAL; 500 return -EINVAL;
498 } 501 }
499 502
500 if (hdac_hdmi_port_select_set(hdac, port) < 0) 503 if (hdac_hdmi_port_select_set(edev, port) < 0)
501 return -EIO; 504 return -EIO;
502 505
503 port->num_mux_nids = snd_hdac_get_connections(&hdac->hdac, pin->nid, 506 port->num_mux_nids = snd_hdac_get_connections(&edev->hdev, pin->nid,
504 port->mux_nids, HDA_MAX_CONNECTIONS); 507 port->mux_nids, HDA_MAX_CONNECTIONS);
505 if (port->num_mux_nids == 0) 508 if (port->num_mux_nids == 0)
506 dev_warn(&hdac->hdac.dev, 509 dev_warn(&edev->hdev.dev,
507 "No connections found for pin:port %d:%d\n", 510 "No connections found for pin:port %d:%d\n",
508 pin->nid, port->id); 511 pin->nid, port->id);
509 512
510 dev_dbg(&hdac->hdac.dev, "num_mux_nids %d for pin:port %d:%d\n", 513 dev_dbg(&edev->hdev.dev, "num_mux_nids %d for pin:port %d:%d\n",
511 port->num_mux_nids, pin->nid, port->id); 514 port->num_mux_nids, pin->nid, port->id);
512 515
513 return port->num_mux_nids; 516 return port->num_mux_nids;
@@ -565,8 +568,8 @@ static struct hdac_hdmi_port *hdac_hdmi_get_port_from_cvt(
565static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, 568static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream,
566 struct snd_soc_dai *dai) 569 struct snd_soc_dai *dai)
567{ 570{
568 struct hdac_ext_device *hdac = snd_soc_dai_get_drvdata(dai); 571 struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai);
569 struct hdac_hdmi_priv *hdmi = hdac->private_data; 572 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
570 struct hdac_hdmi_dai_port_map *dai_map; 573 struct hdac_hdmi_dai_port_map *dai_map;
571 struct hdac_hdmi_cvt *cvt; 574 struct hdac_hdmi_cvt *cvt;
572 struct hdac_hdmi_port *port; 575 struct hdac_hdmi_port *port;
@@ -575,7 +578,7 @@ static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream,
575 dai_map = &hdmi->dai_map[dai->id]; 578 dai_map = &hdmi->dai_map[dai->id];
576 579
577 cvt = dai_map->cvt; 580 cvt = dai_map->cvt;
578 port = hdac_hdmi_get_port_from_cvt(hdac, hdmi, cvt); 581 port = hdac_hdmi_get_port_from_cvt(edev, hdmi, cvt);
579 582
580 /* 583 /*
581 * To make PA and other userland happy. 584 * To make PA and other userland happy.
@@ -586,7 +589,7 @@ static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream,
586 if ((!port->eld.monitor_present) || 589 if ((!port->eld.monitor_present) ||
587 (!port->eld.eld_valid)) { 590 (!port->eld.eld_valid)) {
588 591
589 dev_warn(&hdac->hdac.dev, 592 dev_warn(&edev->hdev.dev,
590 "Failed: present?:%d ELD valid?:%d pin:port: %d:%d\n", 593 "Failed: present?:%d ELD valid?:%d pin:port: %d:%d\n",
591 port->eld.monitor_present, port->eld.eld_valid, 594 port->eld.monitor_present, port->eld.eld_valid,
592 port->pin->nid, port->id); 595 port->pin->nid, port->id);
@@ -608,8 +611,8 @@ static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream,
608static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream, 611static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream,
609 struct snd_soc_dai *dai) 612 struct snd_soc_dai *dai)
610{ 613{
611 struct hdac_ext_device *hdac = snd_soc_dai_get_drvdata(dai); 614 struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai);
612 struct hdac_hdmi_priv *hdmi = hdac->private_data; 615 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
613 struct hdac_hdmi_dai_port_map *dai_map; 616 struct hdac_hdmi_dai_port_map *dai_map;
614 struct hdac_hdmi_pcm *pcm; 617 struct hdac_hdmi_pcm *pcm;
615 618
@@ -630,14 +633,13 @@ static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream,
630} 633}
631 634
632static int 635static int
633hdac_hdmi_query_cvt_params(struct hdac_device *hdac, struct hdac_hdmi_cvt *cvt) 636hdac_hdmi_query_cvt_params(struct hdac_device *hdev, struct hdac_hdmi_cvt *cvt)
634{ 637{
635 unsigned int chans; 638 unsigned int chans;
636 struct hdac_ext_device *edev = to_ehdac_device(hdac); 639 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
637 struct hdac_hdmi_priv *hdmi = edev->private_data;
638 int err; 640 int err;
639 641
640 chans = get_wcaps(hdac, cvt->nid); 642 chans = get_wcaps(hdev, cvt->nid);
641 chans = get_wcaps_channels(chans); 643 chans = get_wcaps_channels(chans);
642 644
643 cvt->params.channels_min = 2; 645 cvt->params.channels_min = 2;
@@ -646,12 +648,12 @@ hdac_hdmi_query_cvt_params(struct hdac_device *hdac, struct hdac_hdmi_cvt *cvt)
646 if (chans > hdmi->chmap.channels_max) 648 if (chans > hdmi->chmap.channels_max)
647 hdmi->chmap.channels_max = chans; 649 hdmi->chmap.channels_max = chans;
648 650
649 err = snd_hdac_query_supported_pcm(hdac, cvt->nid, 651 err = snd_hdac_query_supported_pcm(hdev, cvt->nid,
650 &cvt->params.rates, 652 &cvt->params.rates,
651 &cvt->params.formats, 653 &cvt->params.formats,
652 &cvt->params.maxbps); 654 &cvt->params.maxbps);
653 if (err < 0) 655 if (err < 0)
654 dev_err(&hdac->dev, 656 dev_err(&hdev->dev,
655 "Failed to query pcm params for nid %d: %d\n", 657 "Failed to query pcm params for nid %d: %d\n",
656 cvt->nid, err); 658 cvt->nid, err);
657 659
@@ -696,7 +698,7 @@ static void hdac_hdmi_fill_route(struct snd_soc_dapm_route *route,
696static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_ext_device *edev, 698static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_ext_device *edev,
697 struct hdac_hdmi_port *port) 699 struct hdac_hdmi_port *port)
698{ 700{
699 struct hdac_hdmi_priv *hdmi = edev->private_data; 701 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
700 struct hdac_hdmi_pcm *pcm = NULL; 702 struct hdac_hdmi_pcm *pcm = NULL;
701 struct hdac_hdmi_port *p; 703 struct hdac_hdmi_port *p;
702 704
@@ -716,9 +718,9 @@ static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_ext_device *edev,
716static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, 718static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev,
717 hda_nid_t nid, unsigned int pwr_state) 719 hda_nid_t nid, unsigned int pwr_state)
718{ 720{
719 if (get_wcaps(&edev->hdac, nid) & AC_WCAP_POWER) { 721 if (get_wcaps(&edev->hdev, nid) & AC_WCAP_POWER) {
720 if (!snd_hdac_check_power_state(&edev->hdac, nid, pwr_state)) 722 if (!snd_hdac_check_power_state(&edev->hdev, nid, pwr_state))
721 snd_hdac_codec_write(&edev->hdac, nid, 0, 723 snd_hdac_codec_write(&edev->hdev, nid, 0,
722 AC_VERB_SET_POWER_STATE, pwr_state); 724 AC_VERB_SET_POWER_STATE, pwr_state);
723 } 725 }
724} 726}
@@ -726,8 +728,8 @@ static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev,
726static void hdac_hdmi_set_amp(struct hdac_ext_device *edev, 728static void hdac_hdmi_set_amp(struct hdac_ext_device *edev,
727 hda_nid_t nid, int val) 729 hda_nid_t nid, int val)
728{ 730{
729 if (get_wcaps(&edev->hdac, nid) & AC_WCAP_OUT_AMP) 731 if (get_wcaps(&edev->hdev, nid) & AC_WCAP_OUT_AMP)
730 snd_hdac_codec_write(&edev->hdac, nid, 0, 732 snd_hdac_codec_write(&edev->hdev, nid, 0,
731 AC_VERB_SET_AMP_GAIN_MUTE, val); 733 AC_VERB_SET_AMP_GAIN_MUTE, val);
732} 734}
733 735
@@ -739,7 +741,7 @@ static int hdac_hdmi_pin_output_widget_event(struct snd_soc_dapm_widget *w,
739 struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev); 741 struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev);
740 struct hdac_hdmi_pcm *pcm; 742 struct hdac_hdmi_pcm *pcm;
741 743
742 dev_dbg(&edev->hdac.dev, "%s: widget: %s event: %x\n", 744 dev_dbg(&edev->hdev.dev, "%s: widget: %s event: %x\n",
743 __func__, w->name, event); 745 __func__, w->name, event);
744 746
745 pcm = hdac_hdmi_get_pcm(edev, port); 747 pcm = hdac_hdmi_get_pcm(edev, port);
@@ -755,7 +757,7 @@ static int hdac_hdmi_pin_output_widget_event(struct snd_soc_dapm_widget *w,
755 hdac_hdmi_set_power_state(edev, port->pin->nid, AC_PWRST_D0); 757 hdac_hdmi_set_power_state(edev, port->pin->nid, AC_PWRST_D0);
756 758
757 /* Enable out path for this pin widget */ 759 /* Enable out path for this pin widget */
758 snd_hdac_codec_write(&edev->hdac, port->pin->nid, 0, 760 snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0,
759 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 761 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
760 762
761 hdac_hdmi_set_amp(edev, port->pin->nid, AMP_OUT_UNMUTE); 763 hdac_hdmi_set_amp(edev, port->pin->nid, AMP_OUT_UNMUTE);
@@ -766,7 +768,7 @@ static int hdac_hdmi_pin_output_widget_event(struct snd_soc_dapm_widget *w,
766 hdac_hdmi_set_amp(edev, port->pin->nid, AMP_OUT_MUTE); 768 hdac_hdmi_set_amp(edev, port->pin->nid, AMP_OUT_MUTE);
767 769
768 /* Disable out path for this pin widget */ 770 /* Disable out path for this pin widget */
769 snd_hdac_codec_write(&edev->hdac, port->pin->nid, 0, 771 snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0,
770 AC_VERB_SET_PIN_WIDGET_CONTROL, 0); 772 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
771 773
772 hdac_hdmi_set_power_state(edev, port->pin->nid, AC_PWRST_D3); 774 hdac_hdmi_set_power_state(edev, port->pin->nid, AC_PWRST_D3);
@@ -782,10 +784,10 @@ static int hdac_hdmi_cvt_output_widget_event(struct snd_soc_dapm_widget *w,
782{ 784{
783 struct hdac_hdmi_cvt *cvt = w->priv; 785 struct hdac_hdmi_cvt *cvt = w->priv;
784 struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev); 786 struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev);
785 struct hdac_hdmi_priv *hdmi = edev->private_data; 787 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
786 struct hdac_hdmi_pcm *pcm; 788 struct hdac_hdmi_pcm *pcm;
787 789
788 dev_dbg(&edev->hdac.dev, "%s: widget: %s event: %x\n", 790 dev_dbg(&edev->hdev.dev, "%s: widget: %s event: %x\n",
789 __func__, w->name, event); 791 __func__, w->name, event);
790 792
791 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, cvt); 793 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, cvt);
@@ -797,23 +799,23 @@ static int hdac_hdmi_cvt_output_widget_event(struct snd_soc_dapm_widget *w,
797 hdac_hdmi_set_power_state(edev, cvt->nid, AC_PWRST_D0); 799 hdac_hdmi_set_power_state(edev, cvt->nid, AC_PWRST_D0);
798 800
799 /* Enable transmission */ 801 /* Enable transmission */
800 snd_hdac_codec_write(&edev->hdac, cvt->nid, 0, 802 snd_hdac_codec_write(&edev->hdev, cvt->nid, 0,
801 AC_VERB_SET_DIGI_CONVERT_1, 1); 803 AC_VERB_SET_DIGI_CONVERT_1, 1);
802 804
803 /* Category Code (CC) to zero */ 805 /* Category Code (CC) to zero */
804 snd_hdac_codec_write(&edev->hdac, cvt->nid, 0, 806 snd_hdac_codec_write(&edev->hdev, cvt->nid, 0,
805 AC_VERB_SET_DIGI_CONVERT_2, 0); 807 AC_VERB_SET_DIGI_CONVERT_2, 0);
806 808
807 snd_hdac_codec_write(&edev->hdac, cvt->nid, 0, 809 snd_hdac_codec_write(&edev->hdev, cvt->nid, 0,
808 AC_VERB_SET_CHANNEL_STREAMID, pcm->stream_tag); 810 AC_VERB_SET_CHANNEL_STREAMID, pcm->stream_tag);
809 snd_hdac_codec_write(&edev->hdac, cvt->nid, 0, 811 snd_hdac_codec_write(&edev->hdev, cvt->nid, 0,
810 AC_VERB_SET_STREAM_FORMAT, pcm->format); 812 AC_VERB_SET_STREAM_FORMAT, pcm->format);
811 break; 813 break;
812 814
813 case SND_SOC_DAPM_POST_PMD: 815 case SND_SOC_DAPM_POST_PMD:
814 snd_hdac_codec_write(&edev->hdac, cvt->nid, 0, 816 snd_hdac_codec_write(&edev->hdev, cvt->nid, 0,
815 AC_VERB_SET_CHANNEL_STREAMID, 0); 817 AC_VERB_SET_CHANNEL_STREAMID, 0);
816 snd_hdac_codec_write(&edev->hdac, cvt->nid, 0, 818 snd_hdac_codec_write(&edev->hdev, cvt->nid, 0,
817 AC_VERB_SET_STREAM_FORMAT, 0); 819 AC_VERB_SET_STREAM_FORMAT, 0);
818 820
819 hdac_hdmi_set_power_state(edev, cvt->nid, AC_PWRST_D3); 821 hdac_hdmi_set_power_state(edev, cvt->nid, AC_PWRST_D3);
@@ -831,7 +833,7 @@ static int hdac_hdmi_pin_mux_widget_event(struct snd_soc_dapm_widget *w,
831 struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev); 833 struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev);
832 int mux_idx; 834 int mux_idx;
833 835
834 dev_dbg(&edev->hdac.dev, "%s: widget: %s event: %x\n", 836 dev_dbg(&edev->hdev.dev, "%s: widget: %s event: %x\n",
835 __func__, w->name, event); 837 __func__, w->name, event);
836 838
837 if (!kc) 839 if (!kc)
@@ -844,7 +846,7 @@ static int hdac_hdmi_pin_mux_widget_event(struct snd_soc_dapm_widget *w,
844 return -EIO; 846 return -EIO;
845 847
846 if (mux_idx > 0) { 848 if (mux_idx > 0) {
847 snd_hdac_codec_write(&edev->hdac, port->pin->nid, 0, 849 snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0,
848 AC_VERB_SET_CONNECT_SEL, (mux_idx - 1)); 850 AC_VERB_SET_CONNECT_SEL, (mux_idx - 1));
849 } 851 }
850 852
@@ -864,7 +866,7 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol,
864 struct snd_soc_dapm_context *dapm = w->dapm; 866 struct snd_soc_dapm_context *dapm = w->dapm;
865 struct hdac_hdmi_port *port = w->priv; 867 struct hdac_hdmi_port *port = w->priv;
866 struct hdac_ext_device *edev = to_hda_ext_device(dapm->dev); 868 struct hdac_ext_device *edev = to_hda_ext_device(dapm->dev);
867 struct hdac_hdmi_priv *hdmi = edev->private_data; 869 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
868 struct hdac_hdmi_pcm *pcm = NULL; 870 struct hdac_hdmi_pcm *pcm = NULL;
869 const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0]]; 871 const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0]];
870 872
@@ -922,7 +924,7 @@ static int hdac_hdmi_create_pin_port_muxs(struct hdac_ext_device *edev,
922 struct snd_soc_dapm_widget *widget, 924 struct snd_soc_dapm_widget *widget,
923 const char *widget_name) 925 const char *widget_name)
924{ 926{
925 struct hdac_hdmi_priv *hdmi = edev->private_data; 927 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
926 struct hdac_hdmi_pin *pin = port->pin; 928 struct hdac_hdmi_pin *pin = port->pin;
927 struct snd_kcontrol_new *kc; 929 struct snd_kcontrol_new *kc;
928 struct hdac_hdmi_cvt *cvt; 930 struct hdac_hdmi_cvt *cvt;
@@ -934,17 +936,17 @@ static int hdac_hdmi_create_pin_port_muxs(struct hdac_ext_device *edev,
934 int i = 0; 936 int i = 0;
935 int num_items = hdmi->num_cvt + 1; 937 int num_items = hdmi->num_cvt + 1;
936 938
937 kc = devm_kzalloc(&edev->hdac.dev, sizeof(*kc), GFP_KERNEL); 939 kc = devm_kzalloc(&edev->hdev.dev, sizeof(*kc), GFP_KERNEL);
938 if (!kc) 940 if (!kc)
939 return -ENOMEM; 941 return -ENOMEM;
940 942
941 se = devm_kzalloc(&edev->hdac.dev, sizeof(*se), GFP_KERNEL); 943 se = devm_kzalloc(&edev->hdev.dev, sizeof(*se), GFP_KERNEL);
942 if (!se) 944 if (!se)
943 return -ENOMEM; 945 return -ENOMEM;
944 946
945 snprintf(kc_name, NAME_SIZE, "Pin %d port %d Input", 947 snprintf(kc_name, NAME_SIZE, "Pin %d port %d Input",
946 pin->nid, port->id); 948 pin->nid, port->id);
947 kc->name = devm_kstrdup(&edev->hdac.dev, kc_name, GFP_KERNEL); 949 kc->name = devm_kstrdup(&edev->hdev.dev, kc_name, GFP_KERNEL);
948 if (!kc->name) 950 if (!kc->name)
949 return -ENOMEM; 951 return -ENOMEM;
950 952
@@ -962,24 +964,24 @@ static int hdac_hdmi_create_pin_port_muxs(struct hdac_ext_device *edev,
962 se->mask = roundup_pow_of_two(se->items) - 1; 964 se->mask = roundup_pow_of_two(se->items) - 1;
963 965
964 sprintf(mux_items, "NONE"); 966 sprintf(mux_items, "NONE");
965 items[i] = devm_kstrdup(&edev->hdac.dev, mux_items, GFP_KERNEL); 967 items[i] = devm_kstrdup(&edev->hdev.dev, mux_items, GFP_KERNEL);
966 if (!items[i]) 968 if (!items[i])
967 return -ENOMEM; 969 return -ENOMEM;
968 970
969 list_for_each_entry(cvt, &hdmi->cvt_list, head) { 971 list_for_each_entry(cvt, &hdmi->cvt_list, head) {
970 i++; 972 i++;
971 sprintf(mux_items, "cvt %d", cvt->nid); 973 sprintf(mux_items, "cvt %d", cvt->nid);
972 items[i] = devm_kstrdup(&edev->hdac.dev, mux_items, GFP_KERNEL); 974 items[i] = devm_kstrdup(&edev->hdev.dev, mux_items, GFP_KERNEL);
973 if (!items[i]) 975 if (!items[i])
974 return -ENOMEM; 976 return -ENOMEM;
975 } 977 }
976 978
977 se->texts = devm_kmemdup(&edev->hdac.dev, items, 979 se->texts = devm_kmemdup(&edev->hdev.dev, items,
978 (num_items * sizeof(char *)), GFP_KERNEL); 980 (num_items * sizeof(char *)), GFP_KERNEL);
979 if (!se->texts) 981 if (!se->texts)
980 return -ENOMEM; 982 return -ENOMEM;
981 983
982 return hdac_hdmi_fill_widget_info(&edev->hdac.dev, widget, 984 return hdac_hdmi_fill_widget_info(&edev->hdev.dev, widget,
983 snd_soc_dapm_mux, port, widget_name, NULL, kc, 1, 985 snd_soc_dapm_mux, port, widget_name, NULL, kc, 1,
984 hdac_hdmi_pin_mux_widget_event, 986 hdac_hdmi_pin_mux_widget_event,
985 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_REG); 987 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_REG);
@@ -990,7 +992,7 @@ static void hdac_hdmi_add_pinmux_cvt_route(struct hdac_ext_device *edev,
990 struct snd_soc_dapm_widget *widgets, 992 struct snd_soc_dapm_widget *widgets,
991 struct snd_soc_dapm_route *route, int rindex) 993 struct snd_soc_dapm_route *route, int rindex)
992{ 994{
993 struct hdac_hdmi_priv *hdmi = edev->private_data; 995 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
994 const struct snd_kcontrol_new *kc; 996 const struct snd_kcontrol_new *kc;
995 struct soc_enum *se; 997 struct soc_enum *se;
996 int mux_index = hdmi->num_cvt + hdmi->num_ports; 998 int mux_index = hdmi->num_cvt + hdmi->num_ports;
@@ -1033,8 +1035,8 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm)
1033 struct snd_soc_dapm_widget *widgets; 1035 struct snd_soc_dapm_widget *widgets;
1034 struct snd_soc_dapm_route *route; 1036 struct snd_soc_dapm_route *route;
1035 struct hdac_ext_device *edev = to_hda_ext_device(dapm->dev); 1037 struct hdac_ext_device *edev = to_hda_ext_device(dapm->dev);
1036 struct hdac_hdmi_priv *hdmi = edev->private_data; 1038 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1037 struct snd_soc_dai_driver *dai_drv = dapm->component->dai_drv; 1039 struct snd_soc_dai_driver *dai_drv = hdmi->dai_drv;
1038 char widget_name[NAME_SIZE]; 1040 char widget_name[NAME_SIZE];
1039 struct hdac_hdmi_cvt *cvt; 1041 struct hdac_hdmi_cvt *cvt;
1040 struct hdac_hdmi_pin *pin; 1042 struct hdac_hdmi_pin *pin;
@@ -1134,7 +1136,7 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm)
1134 1136
1135static int hdac_hdmi_init_dai_map(struct hdac_ext_device *edev) 1137static int hdac_hdmi_init_dai_map(struct hdac_ext_device *edev)
1136{ 1138{
1137 struct hdac_hdmi_priv *hdmi = edev->private_data; 1139 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1138 struct hdac_hdmi_dai_port_map *dai_map; 1140 struct hdac_hdmi_dai_port_map *dai_map;
1139 struct hdac_hdmi_cvt *cvt; 1141 struct hdac_hdmi_cvt *cvt;
1140 int dai_id = 0; 1142 int dai_id = 0;
@@ -1150,7 +1152,7 @@ static int hdac_hdmi_init_dai_map(struct hdac_ext_device *edev)
1150 dai_id++; 1152 dai_id++;
1151 1153
1152 if (dai_id == HDA_MAX_CVTS) { 1154 if (dai_id == HDA_MAX_CVTS) {
1153 dev_warn(&edev->hdac.dev, 1155 dev_warn(&edev->hdev.dev,
1154 "Max dais supported: %d\n", dai_id); 1156 "Max dais supported: %d\n", dai_id);
1155 break; 1157 break;
1156 } 1158 }
@@ -1161,7 +1163,7 @@ static int hdac_hdmi_init_dai_map(struct hdac_ext_device *edev)
1161 1163
1162static int hdac_hdmi_add_cvt(struct hdac_ext_device *edev, hda_nid_t nid) 1164static int hdac_hdmi_add_cvt(struct hdac_ext_device *edev, hda_nid_t nid)
1163{ 1165{
1164 struct hdac_hdmi_priv *hdmi = edev->private_data; 1166 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1165 struct hdac_hdmi_cvt *cvt; 1167 struct hdac_hdmi_cvt *cvt;
1166 char name[NAME_SIZE]; 1168 char name[NAME_SIZE];
1167 1169
@@ -1176,7 +1178,7 @@ static int hdac_hdmi_add_cvt(struct hdac_ext_device *edev, hda_nid_t nid)
1176 list_add_tail(&cvt->head, &hdmi->cvt_list); 1178 list_add_tail(&cvt->head, &hdmi->cvt_list);
1177 hdmi->num_cvt++; 1179 hdmi->num_cvt++;
1178 1180
1179 return hdac_hdmi_query_cvt_params(&edev->hdac, cvt); 1181 return hdac_hdmi_query_cvt_params(&edev->hdev, cvt);
1180} 1182}
1181 1183
1182static int hdac_hdmi_parse_eld(struct hdac_ext_device *edev, 1184static int hdac_hdmi_parse_eld(struct hdac_ext_device *edev,
@@ -1188,7 +1190,7 @@ static int hdac_hdmi_parse_eld(struct hdac_ext_device *edev,
1188 >> DRM_ELD_VER_SHIFT; 1190 >> DRM_ELD_VER_SHIFT;
1189 1191
1190 if (ver != ELD_VER_CEA_861D && ver != ELD_VER_PARTIAL) { 1192 if (ver != ELD_VER_CEA_861D && ver != ELD_VER_PARTIAL) {
1191 dev_err(&edev->hdac.dev, "HDMI: Unknown ELD version %d\n", ver); 1193 dev_err(&edev->hdev.dev, "HDMI: Unknown ELD version %d\n", ver);
1192 return -EINVAL; 1194 return -EINVAL;
1193 } 1195 }
1194 1196
@@ -1196,7 +1198,7 @@ static int hdac_hdmi_parse_eld(struct hdac_ext_device *edev,
1196 DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT; 1198 DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT;
1197 1199
1198 if (mnl > ELD_MAX_MNL) { 1200 if (mnl > ELD_MAX_MNL) {
1199 dev_err(&edev->hdac.dev, "HDMI: MNL Invalid %d\n", mnl); 1201 dev_err(&edev->hdev.dev, "HDMI: MNL Invalid %d\n", mnl);
1200 return -EINVAL; 1202 return -EINVAL;
1201 } 1203 }
1202 1204
@@ -1209,7 +1211,7 @@ static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin,
1209 struct hdac_hdmi_port *port) 1211 struct hdac_hdmi_port *port)
1210{ 1212{
1211 struct hdac_ext_device *edev = pin->edev; 1213 struct hdac_ext_device *edev = pin->edev;
1212 struct hdac_hdmi_priv *hdmi = edev->private_data; 1214 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1213 struct hdac_hdmi_pcm *pcm; 1215 struct hdac_hdmi_pcm *pcm;
1214 int size = 0; 1216 int size = 0;
1215 int port_id = -1; 1217 int port_id = -1;
@@ -1227,7 +1229,7 @@ static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin,
1227 if (pin->mst_capable) 1229 if (pin->mst_capable)
1228 port_id = port->id; 1230 port_id = port->id;
1229 1231
1230 size = snd_hdac_acomp_get_eld(&edev->hdac, pin->nid, port_id, 1232 size = snd_hdac_acomp_get_eld(&edev->hdev, pin->nid, port_id,
1231 &port->eld.monitor_present, 1233 &port->eld.monitor_present,
1232 port->eld.eld_buffer, 1234 port->eld.eld_buffer,
1233 ELD_MAX_SIZE); 1235 ELD_MAX_SIZE);
@@ -1250,7 +1252,7 @@ static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin,
1250 1252
1251 if (!port->eld.monitor_present || !port->eld.eld_valid) { 1253 if (!port->eld.monitor_present || !port->eld.eld_valid) {
1252 1254
1253 dev_err(&edev->hdac.dev, "%s: disconnect for pin:port %d:%d\n", 1255 dev_err(&edev->hdev.dev, "%s: disconnect for pin:port %d:%d\n",
1254 __func__, pin->nid, port->id); 1256 __func__, pin->nid, port->id);
1255 1257
1256 /* 1258 /*
@@ -1304,7 +1306,7 @@ static int hdac_hdmi_add_ports(struct hdac_hdmi_priv *hdmi,
1304 1306
1305static int hdac_hdmi_add_pin(struct hdac_ext_device *edev, hda_nid_t nid) 1307static int hdac_hdmi_add_pin(struct hdac_ext_device *edev, hda_nid_t nid)
1306{ 1308{
1307 struct hdac_hdmi_priv *hdmi = edev->private_data; 1309 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1308 struct hdac_hdmi_pin *pin; 1310 struct hdac_hdmi_pin *pin;
1309 int ret; 1311 int ret;
1310 1312
@@ -1333,40 +1335,38 @@ static int hdac_hdmi_add_pin(struct hdac_ext_device *edev, hda_nid_t nid)
1333#define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */ 1335#define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */
1334#define INTEL_EN_ALL_PIN_CVTS 0x01 /* enable 2nd & 3rd pins and convertors */ 1336#define INTEL_EN_ALL_PIN_CVTS 0x01 /* enable 2nd & 3rd pins and convertors */
1335 1337
1336static void hdac_hdmi_skl_enable_all_pins(struct hdac_device *hdac) 1338static void hdac_hdmi_skl_enable_all_pins(struct hdac_device *hdev)
1337{ 1339{
1338 unsigned int vendor_param; 1340 unsigned int vendor_param;
1339 struct hdac_ext_device *edev = to_ehdac_device(hdac); 1341 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
1340 struct hdac_hdmi_priv *hdmi = edev->private_data;
1341 unsigned int vendor_nid = hdmi->drv_data->vendor_nid; 1342 unsigned int vendor_nid = hdmi->drv_data->vendor_nid;
1342 1343
1343 vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0, 1344 vendor_param = snd_hdac_codec_read(hdev, vendor_nid, 0,
1344 INTEL_GET_VENDOR_VERB, 0); 1345 INTEL_GET_VENDOR_VERB, 0);
1345 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) 1346 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS)
1346 return; 1347 return;
1347 1348
1348 vendor_param |= INTEL_EN_ALL_PIN_CVTS; 1349 vendor_param |= INTEL_EN_ALL_PIN_CVTS;
1349 vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0, 1350 vendor_param = snd_hdac_codec_read(hdev, vendor_nid, 0,
1350 INTEL_SET_VENDOR_VERB, vendor_param); 1351 INTEL_SET_VENDOR_VERB, vendor_param);
1351 if (vendor_param == -1) 1352 if (vendor_param == -1)
1352 return; 1353 return;
1353} 1354}
1354 1355
1355static void hdac_hdmi_skl_enable_dp12(struct hdac_device *hdac) 1356static void hdac_hdmi_skl_enable_dp12(struct hdac_device *hdev)
1356{ 1357{
1357 unsigned int vendor_param; 1358 unsigned int vendor_param;
1358 struct hdac_ext_device *edev = to_ehdac_device(hdac); 1359 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
1359 struct hdac_hdmi_priv *hdmi = edev->private_data;
1360 unsigned int vendor_nid = hdmi->drv_data->vendor_nid; 1360 unsigned int vendor_nid = hdmi->drv_data->vendor_nid;
1361 1361
1362 vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0, 1362 vendor_param = snd_hdac_codec_read(hdev, vendor_nid, 0,
1363 INTEL_GET_VENDOR_VERB, 0); 1363 INTEL_GET_VENDOR_VERB, 0);
1364 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) 1364 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12)
1365 return; 1365 return;
1366 1366
1367 /* enable DP1.2 mode */ 1367 /* enable DP1.2 mode */
1368 vendor_param |= INTEL_EN_DP12; 1368 vendor_param |= INTEL_EN_DP12;
1369 vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0, 1369 vendor_param = snd_hdac_codec_read(hdev, vendor_nid, 0,
1370 INTEL_SET_VENDOR_VERB, vendor_param); 1370 INTEL_SET_VENDOR_VERB, vendor_param);
1371 if (vendor_param == -1) 1371 if (vendor_param == -1)
1372 return; 1372 return;
@@ -1384,7 +1384,7 @@ static const struct snd_soc_dai_ops hdmi_dai_ops = {
1384 * Each converter can support a stream independently. So a dai is created 1384 * Each converter can support a stream independently. So a dai is created
1385 * based on the number of converter queried. 1385 * based on the number of converter queried.
1386 */ 1386 */
1387static int hdac_hdmi_create_dais(struct hdac_device *hdac, 1387static int hdac_hdmi_create_dais(struct hdac_device *hdev,
1388 struct snd_soc_dai_driver **dais, 1388 struct snd_soc_dai_driver **dais,
1389 struct hdac_hdmi_priv *hdmi, int num_dais) 1389 struct hdac_hdmi_priv *hdmi, int num_dais)
1390{ 1390{
@@ -1397,20 +1397,20 @@ static int hdac_hdmi_create_dais(struct hdac_device *hdac,
1397 u64 formats; 1397 u64 formats;
1398 int ret; 1398 int ret;
1399 1399
1400 hdmi_dais = devm_kzalloc(&hdac->dev, 1400 hdmi_dais = devm_kzalloc(&hdev->dev,
1401 (sizeof(*hdmi_dais) * num_dais), 1401 (sizeof(*hdmi_dais) * num_dais),
1402 GFP_KERNEL); 1402 GFP_KERNEL);
1403 if (!hdmi_dais) 1403 if (!hdmi_dais)
1404 return -ENOMEM; 1404 return -ENOMEM;
1405 1405
1406 list_for_each_entry(cvt, &hdmi->cvt_list, head) { 1406 list_for_each_entry(cvt, &hdmi->cvt_list, head) {
1407 ret = snd_hdac_query_supported_pcm(hdac, cvt->nid, 1407 ret = snd_hdac_query_supported_pcm(hdev, cvt->nid,
1408 &rates, &formats, &bps); 1408 &rates, &formats, &bps);
1409 if (ret) 1409 if (ret)
1410 return ret; 1410 return ret;
1411 1411
1412 sprintf(dai_name, "intel-hdmi-hifi%d", i+1); 1412 sprintf(dai_name, "intel-hdmi-hifi%d", i+1);
1413 hdmi_dais[i].name = devm_kstrdup(&hdac->dev, 1413 hdmi_dais[i].name = devm_kstrdup(&hdev->dev,
1414 dai_name, GFP_KERNEL); 1414 dai_name, GFP_KERNEL);
1415 1415
1416 if (!hdmi_dais[i].name) 1416 if (!hdmi_dais[i].name)
@@ -1418,7 +1418,7 @@ static int hdac_hdmi_create_dais(struct hdac_device *hdac,
1418 1418
1419 snprintf(name, sizeof(name), "hifi%d", i+1); 1419 snprintf(name, sizeof(name), "hifi%d", i+1);
1420 hdmi_dais[i].playback.stream_name = 1420 hdmi_dais[i].playback.stream_name =
1421 devm_kstrdup(&hdac->dev, name, GFP_KERNEL); 1421 devm_kstrdup(&hdev->dev, name, GFP_KERNEL);
1422 if (!hdmi_dais[i].playback.stream_name) 1422 if (!hdmi_dais[i].playback.stream_name)
1423 return -ENOMEM; 1423 return -ENOMEM;
1424 1424
@@ -1438,6 +1438,7 @@ static int hdac_hdmi_create_dais(struct hdac_device *hdac,
1438 } 1438 }
1439 1439
1440 *dais = hdmi_dais; 1440 *dais = hdmi_dais;
1441 hdmi->dai_drv = hdmi_dais;
1441 1442
1442 return 0; 1443 return 0;
1443} 1444}
@@ -1451,29 +1452,26 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev,
1451{ 1452{
1452 hda_nid_t nid; 1453 hda_nid_t nid;
1453 int i, num_nodes; 1454 int i, num_nodes;
1454 struct hdac_device *hdac = &edev->hdac;
1455 struct hdac_hdmi_priv *hdmi = edev->private_data;
1456 struct hdac_hdmi_cvt *temp_cvt, *cvt_next; 1455 struct hdac_hdmi_cvt *temp_cvt, *cvt_next;
1457 struct hdac_hdmi_pin *temp_pin, *pin_next; 1456 struct hdac_hdmi_pin *temp_pin, *pin_next;
1457 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1458 struct hdac_device *hdev = &edev->hdev;
1458 int ret; 1459 int ret;
1459 1460
1460 hdac_hdmi_skl_enable_all_pins(hdac); 1461 hdac_hdmi_skl_enable_all_pins(hdev);
1461 hdac_hdmi_skl_enable_dp12(hdac); 1462 hdac_hdmi_skl_enable_dp12(hdev);
1462 1463
1463 num_nodes = snd_hdac_get_sub_nodes(hdac, hdac->afg, &nid); 1464 num_nodes = snd_hdac_get_sub_nodes(hdev, hdev->afg, &nid);
1464 if (!nid || num_nodes <= 0) { 1465 if (!nid || num_nodes <= 0) {
1465 dev_warn(&hdac->dev, "HDMI: failed to get afg sub nodes\n"); 1466 dev_warn(&hdev->dev, "HDMI: failed to get afg sub nodes\n");
1466 return -EINVAL; 1467 return -EINVAL;
1467 } 1468 }
1468 1469
1469 hdac->num_nodes = num_nodes; 1470 for (i = 0; i < num_nodes; i++, nid++) {
1470 hdac->start_nid = nid;
1471
1472 for (i = 0; i < hdac->num_nodes; i++, nid++) {
1473 unsigned int caps; 1471 unsigned int caps;
1474 unsigned int type; 1472 unsigned int type;
1475 1473
1476 caps = get_wcaps(hdac, nid); 1474 caps = get_wcaps(hdev, nid);
1477 type = get_wcaps_type(caps); 1475 type = get_wcaps_type(caps);
1478 1476
1479 if (!(caps & AC_WCAP_DIGITAL)) 1477 if (!(caps & AC_WCAP_DIGITAL))
@@ -1495,16 +1493,14 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev,
1495 } 1493 }
1496 } 1494 }
1497 1495
1498 hdac->end_nid = nid;
1499
1500 if (!hdmi->num_pin || !hdmi->num_cvt) { 1496 if (!hdmi->num_pin || !hdmi->num_cvt) {
1501 ret = -EIO; 1497 ret = -EIO;
1502 goto free_widgets; 1498 goto free_widgets;
1503 } 1499 }
1504 1500
1505 ret = hdac_hdmi_create_dais(hdac, dais, hdmi, hdmi->num_cvt); 1501 ret = hdac_hdmi_create_dais(hdev, dais, hdmi, hdmi->num_cvt);
1506 if (ret) { 1502 if (ret) {
1507 dev_err(&hdac->dev, "Failed to create dais with err: %d\n", 1503 dev_err(&hdev->dev, "Failed to create dais with err: %d\n",
1508 ret); 1504 ret);
1509 goto free_widgets; 1505 goto free_widgets;
1510 } 1506 }
@@ -1537,7 +1533,7 @@ free_widgets:
1537static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) 1533static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
1538{ 1534{
1539 struct hdac_ext_device *edev = aptr; 1535 struct hdac_ext_device *edev = aptr;
1540 struct hdac_hdmi_priv *hdmi = edev->private_data; 1536 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1541 struct hdac_hdmi_pin *pin = NULL; 1537 struct hdac_hdmi_pin *pin = NULL;
1542 struct hdac_hdmi_port *hport = NULL; 1538 struct hdac_hdmi_port *hport = NULL;
1543 struct snd_soc_codec *codec = edev->scodec; 1539 struct snd_soc_codec *codec = edev->scodec;
@@ -1546,7 +1542,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
1546 /* Don't know how this mapping is derived */ 1542 /* Don't know how this mapping is derived */
1547 hda_nid_t pin_nid = port + 0x04; 1543 hda_nid_t pin_nid = port + 0x04;
1548 1544
1549 dev_dbg(&edev->hdac.dev, "%s: for pin:%d port=%d\n", __func__, 1545 dev_dbg(&edev->hdev.dev, "%s: for pin:%d port=%d\n", __func__,
1550 pin_nid, pipe); 1546 pin_nid, pipe);
1551 1547
1552 /* 1548 /*
@@ -1559,7 +1555,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
1559 SNDRV_CTL_POWER_D0) 1555 SNDRV_CTL_POWER_D0)
1560 return; 1556 return;
1561 1557
1562 if (atomic_read(&edev->hdac.in_pm)) 1558 if (atomic_read(&edev->hdev.in_pm))
1563 return; 1559 return;
1564 1560
1565 list_for_each_entry(pin, &hdmi->pin_list, head) { 1561 list_for_each_entry(pin, &hdmi->pin_list, head) {
@@ -1614,7 +1610,7 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card,
1614 char *name; 1610 char *name;
1615 int i = 0, j; 1611 int i = 0, j;
1616 struct snd_soc_codec *codec = edev->scodec; 1612 struct snd_soc_codec *codec = edev->scodec;
1617 struct hdac_hdmi_priv *hdmi = edev->private_data; 1613 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1618 1614
1619 kc = devm_kcalloc(codec->dev, hdmi->num_ports, 1615 kc = devm_kcalloc(codec->dev, hdmi->num_ports,
1620 sizeof(*kc), GFP_KERNEL); 1616 sizeof(*kc), GFP_KERNEL);
@@ -1652,7 +1648,7 @@ int hdac_hdmi_jack_port_init(struct snd_soc_codec *codec,
1652 struct snd_soc_dapm_context *dapm) 1648 struct snd_soc_dapm_context *dapm)
1653{ 1649{
1654 struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); 1650 struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec);
1655 struct hdac_hdmi_priv *hdmi = edev->private_data; 1651 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1656 struct hdac_hdmi_pin *pin; 1652 struct hdac_hdmi_pin *pin;
1657 struct snd_soc_dapm_widget *widgets; 1653 struct snd_soc_dapm_widget *widgets;
1658 struct snd_soc_dapm_route *route; 1654 struct snd_soc_dapm_route *route;
@@ -1728,7 +1724,7 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device,
1728{ 1724{
1729 struct snd_soc_codec *codec = dai->codec; 1725 struct snd_soc_codec *codec = dai->codec;
1730 struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); 1726 struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec);
1731 struct hdac_hdmi_priv *hdmi = edev->private_data; 1727 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1732 struct hdac_hdmi_pcm *pcm; 1728 struct hdac_hdmi_pcm *pcm;
1733 struct snd_pcm *snd_pcm; 1729 struct snd_pcm *snd_pcm;
1734 int err; 1730 int err;
@@ -1750,7 +1746,7 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device,
1750 if (snd_pcm) { 1746 if (snd_pcm) {
1751 err = snd_hdac_add_chmap_ctls(snd_pcm, device, &hdmi->chmap); 1747 err = snd_hdac_add_chmap_ctls(snd_pcm, device, &hdmi->chmap);
1752 if (err < 0) { 1748 if (err < 0) {
1753 dev_err(&edev->hdac.dev, 1749 dev_err(&edev->hdev.dev,
1754 "chmap control add failed with err: %d for pcm: %d\n", 1750 "chmap control add failed with err: %d for pcm: %d\n",
1755 err, device); 1751 err, device);
1756 kfree(pcm); 1752 kfree(pcm);
@@ -1791,7 +1787,7 @@ static void hdac_hdmi_present_sense_all_pins(struct hdac_ext_device *edev,
1791static int hdmi_codec_probe(struct snd_soc_codec *codec) 1787static int hdmi_codec_probe(struct snd_soc_codec *codec)
1792{ 1788{
1793 struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); 1789 struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec);
1794 struct hdac_hdmi_priv *hdmi = edev->private_data; 1790 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1795 struct snd_soc_dapm_context *dapm = 1791 struct snd_soc_dapm_context *dapm =
1796 snd_soc_component_get_dapm(&codec->component); 1792 snd_soc_component_get_dapm(&codec->component);
1797 struct hdac_ext_link *hlink = NULL; 1793 struct hdac_ext_link *hlink = NULL;
@@ -1803,9 +1799,9 @@ static int hdmi_codec_probe(struct snd_soc_codec *codec)
1803 * hold the ref while we probe, also no need to drop the ref on 1799 * hold the ref while we probe, also no need to drop the ref on
1804 * exit, we call pm_runtime_suspend() so that will do for us 1800 * exit, we call pm_runtime_suspend() so that will do for us
1805 */ 1801 */
1806 hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdac.dev)); 1802 hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdev.dev));
1807 if (!hlink) { 1803 if (!hlink) {
1808 dev_err(&edev->hdac.dev, "hdac link not found\n"); 1804 dev_err(&edev->hdev.dev, "hdac link not found\n");
1809 return -EIO; 1805 return -EIO;
1810 } 1806 }
1811 1807
@@ -1818,7 +1814,7 @@ static int hdmi_codec_probe(struct snd_soc_codec *codec)
1818 aops.audio_ptr = edev; 1814 aops.audio_ptr = edev;
1819 ret = snd_hdac_i915_register_notifier(&aops); 1815 ret = snd_hdac_i915_register_notifier(&aops);
1820 if (ret < 0) { 1816 if (ret < 0) {
1821 dev_err(&edev->hdac.dev, "notifier register failed: err: %d\n", 1817 dev_err(&edev->hdev.dev, "notifier register failed: err: %d\n",
1822 ret); 1818 ret);
1823 return ret; 1819 return ret;
1824 } 1820 }
@@ -1831,9 +1827,9 @@ static int hdmi_codec_probe(struct snd_soc_codec *codec)
1831 * hdac_device core already sets the state to active and calls 1827 * hdac_device core already sets the state to active and calls
1832 * get_noresume. So enable runtime and set the device to suspend. 1828 * get_noresume. So enable runtime and set the device to suspend.
1833 */ 1829 */
1834 pm_runtime_enable(&edev->hdac.dev); 1830 pm_runtime_enable(&edev->hdev.dev);
1835 pm_runtime_put(&edev->hdac.dev); 1831 pm_runtime_put(&edev->hdev.dev);
1836 pm_runtime_suspend(&edev->hdac.dev); 1832 pm_runtime_suspend(&edev->hdev.dev);
1837 1833
1838 return 0; 1834 return 0;
1839} 1835}
@@ -1842,7 +1838,7 @@ static int hdmi_codec_remove(struct snd_soc_codec *codec)
1842{ 1838{
1843 struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); 1839 struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec);
1844 1840
1845 pm_runtime_disable(&edev->hdac.dev); 1841 pm_runtime_disable(&edev->hdev.dev);
1846 return 0; 1842 return 0;
1847} 1843}
1848 1844
@@ -1850,9 +1846,9 @@ static int hdmi_codec_remove(struct snd_soc_codec *codec)
1850static int hdmi_codec_prepare(struct device *dev) 1846static int hdmi_codec_prepare(struct device *dev)
1851{ 1847{
1852 struct hdac_ext_device *edev = to_hda_ext_device(dev); 1848 struct hdac_ext_device *edev = to_hda_ext_device(dev);
1853 struct hdac_device *hdac = &edev->hdac; 1849 struct hdac_device *hdev = &edev->hdev;
1854 1850
1855 pm_runtime_get_sync(&edev->hdac.dev); 1851 pm_runtime_get_sync(&edev->hdev.dev);
1856 1852
1857 /* 1853 /*
1858 * Power down afg. 1854 * Power down afg.
@@ -1861,7 +1857,7 @@ static int hdmi_codec_prepare(struct device *dev)
1861 * is received. So setting power state is ensured without using loop 1857 * is received. So setting power state is ensured without using loop
1862 * to read the state. 1858 * to read the state.
1863 */ 1859 */
1864 snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, 1860 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
1865 AC_PWRST_D3); 1861 AC_PWRST_D3);
1866 1862
1867 return 0; 1863 return 0;
@@ -1870,15 +1866,15 @@ static int hdmi_codec_prepare(struct device *dev)
1870static void hdmi_codec_complete(struct device *dev) 1866static void hdmi_codec_complete(struct device *dev)
1871{ 1867{
1872 struct hdac_ext_device *edev = to_hda_ext_device(dev); 1868 struct hdac_ext_device *edev = to_hda_ext_device(dev);
1873 struct hdac_hdmi_priv *hdmi = edev->private_data; 1869 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
1874 struct hdac_device *hdac = &edev->hdac; 1870 struct hdac_device *hdev = &edev->hdev;
1875 1871
1876 /* Power up afg */ 1872 /* Power up afg */
1877 snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, 1873 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
1878 AC_PWRST_D0); 1874 AC_PWRST_D0);
1879 1875
1880 hdac_hdmi_skl_enable_all_pins(&edev->hdac); 1876 hdac_hdmi_skl_enable_all_pins(&edev->hdev);
1881 hdac_hdmi_skl_enable_dp12(&edev->hdac); 1877 hdac_hdmi_skl_enable_dp12(&edev->hdev);
1882 1878
1883 /* 1879 /*
1884 * As the ELD notify callback request is not entertained while the 1880 * As the ELD notify callback request is not entertained while the
@@ -1888,7 +1884,7 @@ static void hdmi_codec_complete(struct device *dev)
1888 */ 1884 */
1889 hdac_hdmi_present_sense_all_pins(edev, hdmi, false); 1885 hdac_hdmi_present_sense_all_pins(edev, hdmi, false);
1890 1886
1891 pm_runtime_put_sync(&edev->hdac.dev); 1887 pm_runtime_put_sync(&edev->hdev.dev);
1892} 1888}
1893#else 1889#else
1894#define hdmi_codec_prepare NULL 1890#define hdmi_codec_prepare NULL
@@ -1901,21 +1897,20 @@ static const struct snd_soc_codec_driver hdmi_hda_codec = {
1901 .idle_bias_off = true, 1897 .idle_bias_off = true,
1902}; 1898};
1903 1899
1904static void hdac_hdmi_get_chmap(struct hdac_device *hdac, int pcm_idx, 1900static void hdac_hdmi_get_chmap(struct hdac_device *hdev, int pcm_idx,
1905 unsigned char *chmap) 1901 unsigned char *chmap)
1906{ 1902{
1907 struct hdac_ext_device *edev = to_ehdac_device(hdac); 1903 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
1908 struct hdac_hdmi_priv *hdmi = edev->private_data;
1909 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); 1904 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
1910 1905
1911 memcpy(chmap, pcm->chmap, ARRAY_SIZE(pcm->chmap)); 1906 memcpy(chmap, pcm->chmap, ARRAY_SIZE(pcm->chmap));
1912} 1907}
1913 1908
1914static void hdac_hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx, 1909static void hdac_hdmi_set_chmap(struct hdac_device *hdev, int pcm_idx,
1915 unsigned char *chmap, int prepared) 1910 unsigned char *chmap, int prepared)
1916{ 1911{
1917 struct hdac_ext_device *edev = to_ehdac_device(hdac); 1912 struct hdac_ext_device *edev = to_ehdac_device(hdev);
1918 struct hdac_hdmi_priv *hdmi = edev->private_data; 1913 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
1919 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); 1914 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
1920 struct hdac_hdmi_port *port; 1915 struct hdac_hdmi_port *port;
1921 1916
@@ -1934,10 +1929,9 @@ static void hdac_hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx,
1934 mutex_unlock(&pcm->lock); 1929 mutex_unlock(&pcm->lock);
1935} 1930}
1936 1931
1937static bool is_hdac_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx) 1932static bool is_hdac_hdmi_pcm_attached(struct hdac_device *hdev, int pcm_idx)
1938{ 1933{
1939 struct hdac_ext_device *edev = to_ehdac_device(hdac); 1934 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
1940 struct hdac_hdmi_priv *hdmi = edev->private_data;
1941 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); 1935 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
1942 1936
1943 if (!pcm) 1937 if (!pcm)
@@ -1949,10 +1943,9 @@ static bool is_hdac_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx)
1949 return true; 1943 return true;
1950} 1944}
1951 1945
1952static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdac, int pcm_idx) 1946static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdev, int pcm_idx)
1953{ 1947{
1954 struct hdac_ext_device *edev = to_ehdac_device(hdac); 1948 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
1955 struct hdac_hdmi_priv *hdmi = edev->private_data;
1956 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); 1949 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
1957 struct hdac_hdmi_port *port; 1950 struct hdac_hdmi_port *port;
1958 1951
@@ -1983,30 +1976,30 @@ static struct hdac_hdmi_drv_data intel_drv_data = {
1983 1976
1984static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) 1977static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev)
1985{ 1978{
1986 struct hdac_device *codec = &edev->hdac; 1979 struct hdac_device *hdev = &edev->hdev;
1987 struct hdac_hdmi_priv *hdmi_priv; 1980 struct hdac_hdmi_priv *hdmi_priv;
1988 struct snd_soc_dai_driver *hdmi_dais = NULL; 1981 struct snd_soc_dai_driver *hdmi_dais = NULL;
1989 struct hdac_ext_link *hlink = NULL; 1982 struct hdac_ext_link *hlink = NULL;
1990 int num_dais = 0; 1983 int num_dais = 0;
1991 int ret = 0; 1984 int ret = 0;
1992 struct hdac_driver *hdrv = drv_to_hdac_driver(codec->dev.driver); 1985 struct hdac_driver *hdrv = drv_to_hdac_driver(hdev->dev.driver);
1993 const struct hda_device_id *hdac_id = hdac_get_device_id(codec, hdrv); 1986 const struct hda_device_id *hdac_id = hdac_get_device_id(hdev, hdrv);
1994 1987
1995 /* hold the ref while we probe */ 1988 /* hold the ref while we probe */
1996 hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdac.dev)); 1989 hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdev.dev));
1997 if (!hlink) { 1990 if (!hlink) {
1998 dev_err(&edev->hdac.dev, "hdac link not found\n"); 1991 dev_err(&edev->hdev.dev, "hdac link not found\n");
1999 return -EIO; 1992 return -EIO;
2000 } 1993 }
2001 1994
2002 snd_hdac_ext_bus_link_get(edev->ebus, hlink); 1995 snd_hdac_ext_bus_link_get(edev->ebus, hlink);
2003 1996
2004 hdmi_priv = devm_kzalloc(&codec->dev, sizeof(*hdmi_priv), GFP_KERNEL); 1997 hdmi_priv = devm_kzalloc(&hdev->dev, sizeof(*hdmi_priv), GFP_KERNEL);
2005 if (hdmi_priv == NULL) 1998 if (hdmi_priv == NULL)
2006 return -ENOMEM; 1999 return -ENOMEM;
2007 2000
2008 edev->private_data = hdmi_priv; 2001 edev->private_data = hdmi_priv;
2009 snd_hdac_register_chmap_ops(codec, &hdmi_priv->chmap); 2002 snd_hdac_register_chmap_ops(hdev, &hdmi_priv->chmap);
2010 hdmi_priv->chmap.ops.get_chmap = hdac_hdmi_get_chmap; 2003 hdmi_priv->chmap.ops.get_chmap = hdac_hdmi_get_chmap;
2011 hdmi_priv->chmap.ops.set_chmap = hdac_hdmi_set_chmap; 2004 hdmi_priv->chmap.ops.set_chmap = hdac_hdmi_set_chmap;
2012 hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; 2005 hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached;
@@ -2021,7 +2014,7 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev)
2021 else 2014 else
2022 hdmi_priv->drv_data = &intel_drv_data; 2015 hdmi_priv->drv_data = &intel_drv_data;
2023 2016
2024 dev_set_drvdata(&codec->dev, edev); 2017 dev_set_drvdata(&hdev->dev, edev);
2025 2018
2026 INIT_LIST_HEAD(&hdmi_priv->pin_list); 2019 INIT_LIST_HEAD(&hdmi_priv->pin_list);
2027 INIT_LIST_HEAD(&hdmi_priv->cvt_list); 2020 INIT_LIST_HEAD(&hdmi_priv->cvt_list);
@@ -2032,9 +2025,9 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev)
2032 * Turned off in the runtime_suspend during the first explicit 2025 * Turned off in the runtime_suspend during the first explicit
2033 * pm_runtime_suspend call. 2026 * pm_runtime_suspend call.
2034 */ 2027 */
2035 ret = snd_hdac_display_power(edev->hdac.bus, true); 2028 ret = snd_hdac_display_power(edev->hdev.bus, true);
2036 if (ret < 0) { 2029 if (ret < 0) {
2037 dev_err(&edev->hdac.dev, 2030 dev_err(&edev->hdev.dev,
2038 "Cannot turn on display power on i915 err: %d\n", 2031 "Cannot turn on display power on i915 err: %d\n",
2039 ret); 2032 ret);
2040 return ret; 2033 return ret;
@@ -2042,13 +2035,14 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev)
2042 2035
2043 ret = hdac_hdmi_parse_and_map_nid(edev, &hdmi_dais, &num_dais); 2036 ret = hdac_hdmi_parse_and_map_nid(edev, &hdmi_dais, &num_dais);
2044 if (ret < 0) { 2037 if (ret < 0) {
2045 dev_err(&codec->dev, 2038 dev_err(&hdev->dev,
2046 "Failed in parse and map nid with err: %d\n", ret); 2039 "Failed in parse and map nid with err: %d\n", ret);
2047 return ret; 2040 return ret;
2048 } 2041 }
2042 snd_hdac_refresh_widgets(hdev, true);
2049 2043
2050 /* ASoC specific initialization */ 2044 /* ASoC specific initialization */
2051 ret = snd_soc_register_codec(&codec->dev, &hdmi_hda_codec, 2045 ret = snd_soc_register_codec(&hdev->dev, &hdmi_hda_codec,
2052 hdmi_dais, num_dais); 2046 hdmi_dais, num_dais);
2053 2047
2054 snd_hdac_ext_bus_link_put(edev->ebus, hlink); 2048 snd_hdac_ext_bus_link_put(edev->ebus, hlink);
@@ -2058,14 +2052,14 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev)
2058 2052
2059static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev) 2053static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev)
2060{ 2054{
2061 struct hdac_hdmi_priv *hdmi = edev->private_data; 2055 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
2062 struct hdac_hdmi_pin *pin, *pin_next; 2056 struct hdac_hdmi_pin *pin, *pin_next;
2063 struct hdac_hdmi_cvt *cvt, *cvt_next; 2057 struct hdac_hdmi_cvt *cvt, *cvt_next;
2064 struct hdac_hdmi_pcm *pcm, *pcm_next; 2058 struct hdac_hdmi_pcm *pcm, *pcm_next;
2065 struct hdac_hdmi_port *port, *port_next; 2059 struct hdac_hdmi_port *port, *port_next;
2066 int i; 2060 int i;
2067 2061
2068 snd_soc_unregister_codec(&edev->hdac.dev); 2062 snd_soc_unregister_codec(&edev->hdev.dev);
2069 2063
2070 list_for_each_entry_safe(pcm, pcm_next, &hdmi->pcm_list, head) { 2064 list_for_each_entry_safe(pcm, pcm_next, &hdmi->pcm_list, head) {
2071 pcm->cvt = NULL; 2065 pcm->cvt = NULL;
@@ -2101,8 +2095,8 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev)
2101static int hdac_hdmi_runtime_suspend(struct device *dev) 2095static int hdac_hdmi_runtime_suspend(struct device *dev)
2102{ 2096{
2103 struct hdac_ext_device *edev = to_hda_ext_device(dev); 2097 struct hdac_ext_device *edev = to_hda_ext_device(dev);
2104 struct hdac_device *hdac = &edev->hdac; 2098 struct hdac_device *hdev = &edev->hdev;
2105 struct hdac_bus *bus = hdac->bus; 2099 struct hdac_bus *bus = hdev->bus;
2106 struct hdac_ext_bus *ebus = hbus_to_ebus(bus); 2100 struct hdac_ext_bus *ebus = hbus_to_ebus(bus);
2107 struct hdac_ext_link *hlink = NULL; 2101 struct hdac_ext_link *hlink = NULL;
2108 int err; 2102 int err;
@@ -2120,7 +2114,7 @@ static int hdac_hdmi_runtime_suspend(struct device *dev)
2120 * is received. So setting power state is ensured without using loop 2114 * is received. So setting power state is ensured without using loop
2121 * to read the state. 2115 * to read the state.
2122 */ 2116 */
2123 snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, 2117 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
2124 AC_PWRST_D3); 2118 AC_PWRST_D3);
2125 err = snd_hdac_display_power(bus, false); 2119 err = snd_hdac_display_power(bus, false);
2126 if (err < 0) { 2120 if (err < 0) {
@@ -2142,8 +2136,8 @@ static int hdac_hdmi_runtime_suspend(struct device *dev)
2142static int hdac_hdmi_runtime_resume(struct device *dev) 2136static int hdac_hdmi_runtime_resume(struct device *dev)
2143{ 2137{
2144 struct hdac_ext_device *edev = to_hda_ext_device(dev); 2138 struct hdac_ext_device *edev = to_hda_ext_device(dev);
2145 struct hdac_device *hdac = &edev->hdac; 2139 struct hdac_device *hdev = &edev->hdev;
2146 struct hdac_bus *bus = hdac->bus; 2140 struct hdac_bus *bus = hdev->bus;
2147 struct hdac_ext_bus *ebus = hbus_to_ebus(bus); 2141 struct hdac_ext_bus *ebus = hbus_to_ebus(bus);
2148 struct hdac_ext_link *hlink = NULL; 2142 struct hdac_ext_link *hlink = NULL;
2149 int err; 2143 int err;
@@ -2168,11 +2162,11 @@ static int hdac_hdmi_runtime_resume(struct device *dev)
2168 return err; 2162 return err;
2169 } 2163 }
2170 2164
2171 hdac_hdmi_skl_enable_all_pins(&edev->hdac); 2165 hdac_hdmi_skl_enable_all_pins(&edev->hdev);
2172 hdac_hdmi_skl_enable_dp12(&edev->hdac); 2166 hdac_hdmi_skl_enable_dp12(&edev->hdev);
2173 2167
2174 /* Power up afg */ 2168 /* Power up afg */
2175 snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, 2169 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
2176 AC_PWRST_D0); 2170 AC_PWRST_D0);
2177 2171
2178 return 0; 2172 return 0;