aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnssi Hannula <anssi.hannula@iki.fi>2013-11-10 13:56:10 -0500
committerTakashi Iwai <tiwai@suse.de>2013-11-11 11:07:49 -0500
commit13122e6ebf24d9f676d8a40edc2e9a265e89b628 (patch)
treee3878736f044b3237dd6c09dd2ddc6571966eaf8
parent71373fddf6dff7cf5e67923e6837fc4de28478ff (diff)
ALSA: hda - hdmi: Add error-checking to some codec reads
Add error checks to HBR status reads (both generic and ATI/AMD) and ATI/AMD codec reads for ELD generation. Unchecked errors in these just caused more errors later on (invalid codec writes for the HBR ones and ELD parsing errors for the ATI/AMD ELD ones), but it is better to catch them earlier. Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/hda_eld.c5
-rw-r--r--sound/pci/hda/patch_hdmi.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c
index 32d3e3855a6e..e8c55f5a34ff 100644
--- a/sound/pci/hda/hda_eld.c
+++ b/sound/pci/hda/hda_eld.c
@@ -680,7 +680,7 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
680 680
681 spkalloc = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SPEAKER_ALLOCATION, 0); 681 spkalloc = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SPEAKER_ALLOCATION, 0);
682 682
683 if (!spkalloc) { 683 if (spkalloc <= 0) {
684 snd_printd(KERN_INFO "HDMI ATI/AMD: no speaker allocation for ELD\n"); 684 snd_printd(KERN_INFO "HDMI ATI/AMD: no speaker allocation for ELD\n");
685 return -EINVAL; 685 return -EINVAL;
686 } 686 }
@@ -742,6 +742,9 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
742 snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_AUDIO_DESCRIPTOR, i << 3); 742 snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_AUDIO_DESCRIPTOR, i << 3);
743 ati_sad = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_AUDIO_DESCRIPTOR, 0); 743 ati_sad = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_AUDIO_DESCRIPTOR, 0);
744 744
745 if (ati_sad <= 0)
746 continue;
747
745 if (ati_sad & ATI_AUDIODESC_RATES) { 748 if (ati_sad & ATI_AUDIODESC_RATES) {
746 /* format is supported, copy SAD as-is */ 749 /* format is supported, copy SAD as-is */
747 buf[pos++] = (ati_sad & 0x0000ff) >> 0; 750 buf[pos++] = (ati_sad & 0x0000ff) >> 0;
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 8aa104cba241..08407bed093e 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1247,6 +1247,9 @@ static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid,
1247 pinctl = snd_hda_codec_read(codec, pin_nid, 0, 1247 pinctl = snd_hda_codec_read(codec, pin_nid, 0,
1248 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 1248 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1249 1249
1250 if (pinctl < 0)
1251 return hbr ? -EINVAL : 0;
1252
1250 new_pinctl = pinctl & ~AC_PINCTL_EPT; 1253 new_pinctl = pinctl & ~AC_PINCTL_EPT;
1251 if (hbr) 1254 if (hbr)
1252 new_pinctl |= AC_PINCTL_EPT_HBR; 1255 new_pinctl |= AC_PINCTL_EPT_HBR;
@@ -3091,7 +3094,7 @@ static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid,
3091 int hbr_ctl, hbr_ctl_new; 3094 int hbr_ctl, hbr_ctl_new;
3092 3095
3093 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); 3096 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0);
3094 if (hbr_ctl & ATI_HBR_CAPABLE) { 3097 if (hbr_ctl >= 0 && (hbr_ctl & ATI_HBR_CAPABLE)) {
3095 if (hbr) 3098 if (hbr)
3096 hbr_ctl_new = hbr_ctl | ATI_HBR_ENABLE; 3099 hbr_ctl_new = hbr_ctl | ATI_HBR_ENABLE;
3097 else 3100 else