Skip to content

Commit 551626e

Browse files
committed
ALSA: hda/hdmi - Don't report spurious jack state changes
The HDMI jack handling reports the state change always via snd_jack_report() whenever hdmi_present_sense() is called, even if the state itself doesn't change from the previous time. This is mostly harmless but still a bit confusing to user-space. This patch reduces such spurious jack state changes and reports only when the state really changed. Also, as a minor optimization, avoid overwriting the pin ELD data when the state is identical. Reviewed-by: Kai Vehmanen <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 5f9e832 commit 551626e

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

sound/pci/hda/patch_hdmi.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ static void hdmi_pcm_reset_pin(struct hdmi_spec *spec,
14211421
/* update per_pin ELD from the given new ELD;
14221422
* setup info frame and notification accordingly
14231423
*/
1424-
static void update_eld(struct hda_codec *codec,
1424+
static bool update_eld(struct hda_codec *codec,
14251425
struct hdmi_spec_per_pin *per_pin,
14261426
struct hdmi_eld *eld)
14271427
{
@@ -1452,18 +1452,22 @@ static void update_eld(struct hda_codec *codec,
14521452
snd_hdmi_show_eld(codec, &eld->info);
14531453

14541454
eld_changed = (pin_eld->eld_valid != eld->eld_valid);
1455-
if (eld->eld_valid && pin_eld->eld_valid)
1455+
eld_changed |= (pin_eld->monitor_present != eld->monitor_present);
1456+
if (!eld_changed && eld->eld_valid && pin_eld->eld_valid)
14561457
if (pin_eld->eld_size != eld->eld_size ||
14571458
memcmp(pin_eld->eld_buffer, eld->eld_buffer,
14581459
eld->eld_size) != 0)
14591460
eld_changed = true;
14601461

1461-
pin_eld->monitor_present = eld->monitor_present;
1462-
pin_eld->eld_valid = eld->eld_valid;
1463-
pin_eld->eld_size = eld->eld_size;
1464-
if (eld->eld_valid)
1465-
memcpy(pin_eld->eld_buffer, eld->eld_buffer, eld->eld_size);
1466-
pin_eld->info = eld->info;
1462+
if (eld_changed) {
1463+
pin_eld->monitor_present = eld->monitor_present;
1464+
pin_eld->eld_valid = eld->eld_valid;
1465+
pin_eld->eld_size = eld->eld_size;
1466+
if (eld->eld_valid)
1467+
memcpy(pin_eld->eld_buffer, eld->eld_buffer,
1468+
eld->eld_size);
1469+
pin_eld->info = eld->info;
1470+
}
14671471

14681472
/*
14691473
* Re-setup pin and infoframe. This is needed e.g. when
@@ -1481,6 +1485,7 @@ static void update_eld(struct hda_codec *codec,
14811485
SNDRV_CTL_EVENT_MASK_VALUE |
14821486
SNDRV_CTL_EVENT_MASK_INFO,
14831487
&get_hdmi_pcm(spec, pcm_idx)->eld_ctl->id);
1488+
return eld_changed;
14841489
}
14851490

14861491
/* update ELD and jack state via HD-audio verbs */
@@ -1582,6 +1587,7 @@ static void sync_eld_via_acomp(struct hda_codec *codec,
15821587
struct hdmi_spec *spec = codec->spec;
15831588
struct hdmi_eld *eld = &spec->temp_eld;
15841589
struct snd_jack *jack = NULL;
1590+
bool changed;
15851591
int size;
15861592

15871593
mutex_lock(&per_pin->lock);
@@ -1608,15 +1614,13 @@ static void sync_eld_via_acomp(struct hda_codec *codec,
16081614
* disconnected event. Jack must be fetched before update_eld()
16091615
*/
16101616
jack = pin_idx_to_jack(codec, per_pin);
1611-
update_eld(codec, per_pin, eld);
1617+
changed = update_eld(codec, per_pin, eld);
16121618
if (jack == NULL)
16131619
jack = pin_idx_to_jack(codec, per_pin);
1614-
if (jack == NULL)
1615-
goto unlock;
1616-
snd_jack_report(jack,
1617-
(eld->monitor_present && eld->eld_valid) ?
1620+
if (changed && jack)
1621+
snd_jack_report(jack,
1622+
(eld->monitor_present && eld->eld_valid) ?
16181623
SND_JACK_AVOUT : 0);
1619-
unlock:
16201624
mutex_unlock(&per_pin->lock);
16211625
}
16221626

0 commit comments

Comments
 (0)