* [PATCH] ALSA: hda: Report a change when only the channel status bytes move
@ 2026-09-08 13:41 HyeongJun An
2026-09-08 14:25 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: HyeongJun An @ 2026-09-08 13:41 UTC (permalink / raw)
To: Takashi Iwai, Jaroslav Kysela
Cc: Cássio Gabriel, linux-sound, linux-kernel, HyeongJun An
The put() callback of "IEC958 Playback Default" returns whether the
converted register value moved. The convert_from_spdif_status() helper
reads part of the first two channel status bytes and none of the last
two, while the get() callback returns all four. So a write that lands
only in the bits it does not read changes what userspace reads back and
reports no change. Of the 31 bits above the mode bit, 20 are such bits
in consumer mode and 29 in professional mode. The core notifies only on
a positive return.
Toggling status[2] bit 0 on an HDA HDMI codec moves the read-back from
04 00 00 00 to 04 00 01 00 with no event. Toggling the non-audio bit
in status[0] gives one.
Compare the stored status as well, the way the ac97 code does. The
write to the codec stays gated on the converted value.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
Assisted-by: Claude:claude-opus-5
---
sound/hda/common/codec.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/hda/common/codec.c b/sound/hda/common/codec.c
index 7d17d773cfbf..5d9b53bd64ea 100644
--- a/sound/hda/common/codec.c
+++ b/sound/hda/common/codec.c
@@ -2277,6 +2277,7 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol,
int idx = kcontrol->private_value;
struct hda_spdif_out *spdif;
hda_nid_t nid;
+ unsigned int old_status;
unsigned short val;
int change;
@@ -2285,6 +2286,7 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol,
guard(mutex)(&codec->spdif_mutex);
spdif = snd_array_elem(&codec->spdif_out, idx);
nid = spdif->nid;
+ old_status = spdif->status;
spdif->status = ucontrol->value.iec958.status[0] |
((unsigned int)ucontrol->value.iec958.status[1] << 8) |
((unsigned int)ucontrol->value.iec958.status[2] << 16) |
@@ -2295,7 +2297,7 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol,
spdif->ctls = val;
if (change && nid != (u16)-1)
set_dig_out_convert(codec, nid, val & 0xff, (val >> 8) & 0xff);
- return change;
+ return change || spdif->status != old_status;
}
#define snd_hda_spdif_out_switch_info snd_ctl_boolean_mono_info
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: hda: Report a change when only the channel status bytes move
2026-09-08 13:41 [PATCH] ALSA: hda: Report a change when only the channel status bytes move HyeongJun An
@ 2026-09-08 14:25 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-09-08 14:25 UTC (permalink / raw)
To: HyeongJun An
Cc: Takashi Iwai, Jaroslav Kysela, Cássio Gabriel, linux-sound,
linux-kernel
On Tue, 08 Sep 2026 15:41:53 +0200,
HyeongJun An wrote:
>
> The put() callback of "IEC958 Playback Default" returns whether the
> converted register value moved. The convert_from_spdif_status() helper
> reads part of the first two channel status bytes and none of the last
> two, while the get() callback returns all four. So a write that lands
> only in the bits it does not read changes what userspace reads back and
> reports no change. Of the 31 bits above the mode bit, 20 are such bits
> in consumer mode and 29 in professional mode. The core notifies only on
> a positive return.
>
> Toggling status[2] bit 0 on an HDA HDMI codec moves the read-back from
> 04 00 00 00 to 04 00 01 00 with no event. Toggling the non-audio bit
> in status[0] gives one.
>
> Compare the stored status as well, the way the ac97 code does. The
> write to the codec stays gated on the converted value.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
> Assisted-by: Claude:claude-opus-5
Applied now. Thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-08 14:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 13:41 [PATCH] ALSA: hda: Report a change when only the channel status bytes move HyeongJun An
2026-09-08 14:25 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).