Skip to contentSkip to conversation

ALSA: hda - Update HDMI monitor_present from a temporary structure

PATCH In review Hyungwon Hwang 2 participants 4 messages Apr 13, 2016 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hda - Update HDMI monitor_present from a temporary structure

pin_eld is a temporary structure. So before calling update_eld(), eld should be updated from pin_eld.

---
 sound/pci/hda/patch_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/pci/hda/patch_hdmi.c +2 -0
index 5af372d..9de114d 100644
@@ -1414,6 +1414,8 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
 
 	mutex_lock(&per_pin->lock);
 	pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
+	eld->monitor_present = pin_eld->monitor_present;
+
 	if (pin_eld->monitor_present)
 		eld->eld_valid  = !!(present & AC_PINSENSE_ELDV);
 	else
Signature · 1 line
2.5.5
#1 lore raw
Quoted 5 lines · Hyungwon Hwang

pin_eld is a temporary structure. So before calling update_eld(), eld should be updated from pin_eld.

It's not clear what you're trying to solve only by the description above alone. It's about the inconsistent "monitor present" appearance in eld proc file, right? You need to write "why your patch is necessary" in your patch description.

Now back to the code change:

Quoted 9 lines
---
 sound/pci/hda/patch_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/pci/hda/patch_hdmi.c +0 -0
index 5af372d..9de114d 100644

sound/pci/hda/patch_hdmi.c static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin, · line 1421

Quoted 8 lines
sound/pci/hda/patch_hdmi.c +2 -0
@@ -1414,6 +1414,8 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
 
 	mutex_lock(&per_pin->lock);
 	pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
+	eld->monitor_present = pin_eld->monitor_present;
+
 	if (pin_eld->monitor_present)
 		eld->eld_valid  = !!(present & AC_PINSENSE_ELDV);
 	else

OK, this would work, but the fundamental problem is that pin_eld is modified in this function. This used to work in the past casually due to a bug, but I plugged it in the commit bd48128539ab
ALSA: hda - Fix forgotten HDMI monitor_present update
but overlooked the regression in non-component side. My bad.

So, the real fix is to replace the all pin_eld with eld in this function. The untested patch is below. Could you check whether this works for you?

Though, as a stable fix, maybe applying your oneliner patch would be safer. It restores to the old behavior, at least. Then we can apply the patch below on the top.

thanks,

Takashi

---

sound/pci/hda/patch_hdmi.c +4 -5
index 5af372d01834..c83c1a8d9742 100644
@@ -1396,7 +1396,6 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
 	struct hda_codec *codec = per_pin->codec;
 	struct hdmi_spec *spec = codec->spec;
 	struct hdmi_eld *eld = &spec->temp_eld;
-	struct hdmi_eld *pin_eld = &per_pin->sink_eld;
 	hda_nid_t pin_nid = per_pin->pin_nid;
 	/*
 	 * Always execute a GetPinSense verb here, even when called from
@@ -1413,15 +1412,15 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
 	present = snd_hda_pin_sense(codec, pin_nid);
 
 	mutex_lock(&per_pin->lock);
-	pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
-	if (pin_eld->monitor_present)
+	eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
+	if (eld->monitor_present)
 		eld->eld_valid  = !!(present & AC_PINSENSE_ELDV);
 	else
 		eld->eld_valid = false;
 
 	codec_dbg(codec,
 		"HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
-		codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid);
+		codec->addr, pin_nid, eld->monitor_present, eld->eld_valid);
 
 	if (eld->eld_valid) {
 		if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer,
@@ -1441,7 +1440,7 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
 	else
 		update_eld(codec, per_pin, eld);
 
-	ret = !repoll || !pin_eld->monitor_present || pin_eld->eld_valid;
+	ret = !repoll || !eld->monitor_present || eld->eld_valid;
 
 	jack = snd_hda_jack_tbl_get(codec, pin_nid);
 	if (jack)
#2 lore raw

2016년 04월 13일 16:33에 Takashi Iwai 이(가) 쓴 글:

Quoted 39 lines
Quoted 5 lines · Hyungwon Hwang

pin_eld is a temporary structure. So before calling update_eld(), eld should be updated from pin_eld.

It's not clear what you're trying to solve only by the description above alone. It's about the inconsistent "monitor present" appearance in eld proc file, right? You need to write "why your patch is necessary" in your patch description.

Now back to the code change:

Quoted 9 lines
---
 sound/pci/hda/patch_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/pci/hda/patch_hdmi.c +0 -0
index 5af372d..9de114d 100644

sound/pci/hda/patch_hdmi.c static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin, · line 1421

Quoted 8 lines
sound/pci/hda/patch_hdmi.c +2 -0
@@ -1414,6 +1414,8 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
 
 	mutex_lock(&per_pin->lock);
 	pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
+	eld->monitor_present = pin_eld->monitor_present;
+
 	if (pin_eld->monitor_present)
 		eld->eld_valid  = !!(present & AC_PINSENSE_ELDV);
 	else

OK, this would work, but the fundamental problem is that pin_eld is modified in this function. This used to work in the past casually due to a bug, but I plugged it in the commit bd48128539ab
ALSA: hda - Fix forgotten HDMI monitor_present update
but overlooked the regression in non-component side. My bad.

Quoted 3 lines

So, the real fix is to replace the all pin_eld with eld in this function. The untested patch is below. Could you check whether this works for you?

Your code works well in my case, and seems more reasonable even to me. Thanks for your review and work.

Thanks,
Hyungwon Hwang

Quoted 44 lines

Though, as a stable fix, maybe applying your oneliner patch would be safer. It restores to the old behavior, at least. Then we can apply the patch below on the top.

thanks,

Takashi

---

sound/pci/hda/patch_hdmi.c +3 -4
index 5af372d01834..c83c1a8d9742 100644
@@ -1396,7 +1396,6 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
 	struct hda_codec *codec = per_pin->codec;
 	struct hdmi_spec *spec = codec->spec;
 	struct hdmi_eld *eld = &spec->temp_eld;
-	struct hdmi_eld *pin_eld = &per_pin->sink_eld;
 	hda_nid_t pin_nid = per_pin->pin_nid;
 	/*
 	 * Always execute a GetPinSense verb here, even when called from
@@ -1413,15 +1412,15 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
 	present = snd_hda_pin_sense(codec, pin_nid);
 
 	mutex_lock(&per_pin->lock);
-	pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
-	if (pin_eld->monitor_present)
+	eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
+	if (eld->monitor_present)
 		eld->eld_valid  = !!(present & AC_PINSENSE_ELDV);
 	else
 		eld->eld_valid = false;
 
 	codec_dbg(codec,
 		"HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
-		codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid);
+		codec->addr, pin_nid, eld->monitor_present, eld->eld_valid);
 
 	if (eld->eld_valid) {
 		if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer,

sound/pci/hda/patch_hdmi.c static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin, · line 1446

Quoted 8 lines
sound/pci/hda/patch_hdmi.c +1 -1
@@ -1441,7 +1440,7 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
 	else
 		update_eld(codec, per_pin, eld);
 
-	ret = !repoll || !pin_eld->monitor_present || pin_eld->eld_valid;
+	ret = !repoll || !eld->monitor_present || eld->eld_valid;
 
 	jack = snd_hda_jack_tbl_get(codec, pin_nid);
 	if (jack)

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw
Quoted 41 lines · Hyungwon Hwang

2016년 04월 13일 16:33에 Takashi Iwai 이(가) 쓴 글:

Quoted 39 lines
Quoted 5 lines · Hyungwon Hwang

pin_eld is a temporary structure. So before calling update_eld(), eld should be updated from pin_eld.

It's not clear what you're trying to solve only by the description above alone. It's about the inconsistent "monitor present" appearance in eld proc file, right? You need to write "why your patch is necessary" in your patch description.

Now back to the code change:

Quoted 9 lines
---
 sound/pci/hda/patch_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/pci/hda/patch_hdmi.c +0 -0
index 5af372d..9de114d 100644

sound/pci/hda/patch_hdmi.c static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin, · line 1421

Quoted 8 lines
sound/pci/hda/patch_hdmi.c +2 -0
@@ -1414,6 +1414,8 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
 
 	mutex_lock(&per_pin->lock);
 	pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
+	eld->monitor_present = pin_eld->monitor_present;
+
 	if (pin_eld->monitor_present)
 		eld->eld_valid  = !!(present & AC_PINSENSE_ELDV);
 	else

OK, this would work, but the fundamental problem is that pin_eld is modified in this function. This used to work in the past casually due to a bug, but I plugged it in the commit bd48128539ab
ALSA: hda - Fix forgotten HDMI monitor_present update
but overlooked the regression in non-component side. My bad.

Quoted 6 lines
Quoted 3 lines

So, the real fix is to replace the all pin_eld with eld in this function. The untested patch is below. Could you check whether this works for you?

Your code works well in my case, and seems more reasonable even to me. Thanks for your review and work.

OK, I resubmit your and my patches with slightly more comments, then apply them to for-linus branch.

thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel