aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubhransu S. Prusty <subhransu.s.prusty@intel.com>2016-02-17 11:04:00 -0500
committerMark Brown <broonie@kernel.org>2016-02-19 10:56:53 -0500
commit54dfa1eaf4f8222811900922c67f539e60cc69c2 (patch)
treeab192c33f37ec59471727de1ec10e6b40b7856e5
parent6793a3d70676c6f3d2ec0ce4e1e241617541702c (diff)
ASoC: hdac_hdmi: Don't fail in dai startup to make userland happy
In dai startup, driver was checking for ELD and would fail if no monitor is connected. This causes userland like PA, CRAS to be unhappy as they scan the device list at bootup. So move the ELD check to hw_params and fail if valid ELD is not found. Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/hdac_hdmi.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index d2a2e1882fdd..f12af62a2084 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -398,10 +398,20 @@ static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream,
398 struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai) 398 struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai)
399{ 399{
400 struct hdac_ext_device *hdac = snd_soc_dai_get_drvdata(dai); 400 struct hdac_ext_device *hdac = snd_soc_dai_get_drvdata(dai);
401 struct hdac_hdmi_priv *hdmi = hdac->private_data;
402 struct hdac_hdmi_dai_pin_map *dai_map;
403 struct hdac_hdmi_pin *pin;
401 struct hdac_ext_dma_params *dd; 404 struct hdac_ext_dma_params *dd;
402 405
403 if (dai->id > 0) { 406 dai_map = &hdmi->dai_map[dai->id];
404 dev_err(&hdac->hdac.dev, "Only one dai supported as of now\n"); 407 pin = dai_map->pin;
408
409 if (!pin)
410 return -ENODEV;
411
412 if ((!pin->eld.monitor_present) || (!pin->eld.eld_valid)) {
413 dev_err(&hdac->hdac.dev, "device is not configured for this pin: %d\n",
414 pin->nid);
405 return -ENODEV; 415 return -ENODEV;
406 } 416 }
407 417
@@ -431,11 +441,6 @@ static int hdac_hdmi_playback_cleanup(struct snd_pcm_substream *substream,
431 441
432 dai_map = &hdmi->dai_map[dai->id]; 442 dai_map = &hdmi->dai_map[dai->id];
433 443
434 snd_hdac_codec_write(&edev->hdac, dai_map->cvt->nid, 0,
435 AC_VERB_SET_CHANNEL_STREAMID, 0);
436 snd_hdac_codec_write(&edev->hdac, dai_map->cvt->nid, 0,
437 AC_VERB_SET_STREAM_FORMAT, 0);
438
439 dd = (struct hdac_ext_dma_params *)snd_soc_dai_get_dma_data(dai, substream); 444 dd = (struct hdac_ext_dma_params *)snd_soc_dai_get_dma_data(dai, substream);
440 445
441 if (dd) { 446 if (dd) {
@@ -536,6 +541,11 @@ static struct hdac_hdmi_pin *hdac_hdmi_get_pin_from_cvt(
536 return NULL; 541 return NULL;
537} 542}
538 543
544/*
545 * This tries to get a valid pin and set the HW constraints based on the
546 * ELD. Even if a valid pin is not found return success so that device open
547 * doesn't fail.
548 */
539static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, 549static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream,
540 struct snd_soc_dai *dai) 550 struct snd_soc_dai *dai)
541{ 551{
@@ -550,17 +560,22 @@ static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream,
550 560
551 cvt = dai_map->cvt; 561 cvt = dai_map->cvt;
552 pin = hdac_hdmi_get_pin_from_cvt(hdac, hdmi, cvt); 562 pin = hdac_hdmi_get_pin_from_cvt(hdac, hdmi, cvt);
563
564 /*
565 * To make PA and other userland happy.
566 * userland scans devices so returning error does not help.
567 */
553 if (!pin) 568 if (!pin)
554 return -EIO; 569 return 0;
555 570
556 if ((!pin->eld.monitor_present) || 571 if ((!pin->eld.monitor_present) ||
557 (!pin->eld.eld_valid)) { 572 (!pin->eld.eld_valid)) {
558 573
559 dev_err(&hdac->hdac.dev, 574 dev_warn(&hdac->hdac.dev,
560 "Failed: montior present? %d ELD valid?: %d for pin: %d\n", 575 "Failed: montior present? %d ELD valid?: %d for pin: %d\n",
561 pin->eld.monitor_present, pin->eld.eld_valid, pin->nid); 576 pin->eld.monitor_present, pin->eld.eld_valid, pin->nid);
562 577
563 return -ENODEV; 578 return 0;
564 } 579 }
565 580
566 dai_map->pin = pin; 581 dai_map->pin = pin;
@@ -587,12 +602,19 @@ static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream,
587 602
588 dai_map = &hdmi->dai_map[dai->id]; 603 dai_map = &hdmi->dai_map[dai->id];
589 604
590 hdac_hdmi_set_power_state(hdac, dai_map, AC_PWRST_D3); 605 if (dai_map->pin) {
606 snd_hdac_codec_write(&hdac->hdac, dai_map->cvt->nid, 0,
607 AC_VERB_SET_CHANNEL_STREAMID, 0);
608 snd_hdac_codec_write(&hdac->hdac, dai_map->cvt->nid, 0,
609 AC_VERB_SET_STREAM_FORMAT, 0);
610
611 hdac_hdmi_set_power_state(hdac, dai_map, AC_PWRST_D3);
591 612
592 snd_hdac_codec_write(&hdac->hdac, dai_map->pin->nid, 0, 613 snd_hdac_codec_write(&hdac->hdac, dai_map->pin->nid, 0,
593 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); 614 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
594 615
595 dai_map->pin = NULL; 616 dai_map->pin = NULL;
617 }
596} 618}
597 619
598static int 620static int