All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda - Reset sample sizes and max bitrates when reading ELD
@ 2010-12-07 19:19 Anssi Hannula
  2010-12-07 20:21 ` Anssi Hannula
  0 siblings, 1 reply; 3+ messages in thread
From: Anssi Hannula @ 2010-12-07 19:19 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

When a new HDMI/DP device is plugged in, hdmi_update_short_audio_desc()
is called for every SAD (Short Audio Descriptor) in the ELD data. For
LPCM coding type SAD defines the supported sample sizes. For several
other coding types (such as AC-3), a maximum bitrate is defined.

The maximum bitrate and sample size fields are not always cleared.
Therefore, if a device is unplugged and a different one is plugged in,
and the coding types of some SAD positions differ between the devices,
the old max_bitrate or sample_bits values will persist if the new SADs
do not define those values.

The leftover max_bitrate and sample_bits do not cause any issues other
than wrongly showing up in eld#X.Y procfs file and kernel log.

Fix that by always clearing sample_bits and max_bitrate when reading
SADs.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
---
 sound/pci/hda/hda_eld.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c
index 009031f..4a66347 100644
--- a/sound/pci/hda/hda_eld.c
+++ b/sound/pci/hda/hda_eld.c
@@ -189,6 +189,9 @@ static void hdmi_update_short_audio_desc(struct cea_sad *a,
 	a->channels = GRAB_BITS(buf, 0, 0, 3);
 	a->channels++;
 
+	a->sample_bits = 0;
+	a->max_bitrate = 0;
+
 	a->format = GRAB_BITS(buf, 0, 3, 4);
 	switch (a->format) {
 	case AUDIO_CODING_TYPE_REF_STREAM_HEADER:
@@ -198,7 +201,6 @@ static void hdmi_update_short_audio_desc(struct cea_sad *a,
 
 	case AUDIO_CODING_TYPE_LPCM:
 		val = GRAB_BITS(buf, 2, 0, 3);
-		a->sample_bits = 0;
 		for (i = 0; i < 3; i++)
 			if (val & (1 << i))
 				a->sample_bits |= cea_sample_sizes[i + 1];
-- 
1.7.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ALSA: hda - Reset sample sizes and max bitrates when reading ELD
  2010-12-07 19:19 [PATCH] ALSA: hda - Reset sample sizes and max bitrates when reading ELD Anssi Hannula
@ 2010-12-07 20:21 ` Anssi Hannula
  2010-12-08  7:37   ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Anssi Hannula @ 2010-12-07 20:21 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

On 07.12.2010 21:19, Anssi Hannula wrote:
> When a new HDMI/DP device is plugged in, hdmi_update_short_audio_desc()
> is called for every SAD (Short Audio Descriptor) in the ELD data. For
> LPCM coding type SAD defines the supported sample sizes. For several
> other coding types (such as AC-3), a maximum bitrate is defined.
> 
> The maximum bitrate and sample size fields are not always cleared.
> Therefore, if a device is unplugged and a different one is plugged in,
> and the coding types of some SAD positions differ between the devices,
> the old max_bitrate or sample_bits values will persist if the new SADs
> do not define those values.
> 
> The leftover max_bitrate and sample_bits do not cause any issues other
> than wrongly showing up in eld#X.Y procfs file and kernel log.

Actually, only max_bitrate will be shown there, the coding type seems to
be checked for LPCM before outputting sample_bits into eld#X.Y or log.

It is still probably better to clear that value as well, though.

> Fix that by always clearing sample_bits and max_bitrate when reading
> SADs.
> 
> Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
> ---
>  sound/pci/hda/hda_eld.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c
> index 009031f..4a66347 100644
> --- a/sound/pci/hda/hda_eld.c
> +++ b/sound/pci/hda/hda_eld.c
> @@ -189,6 +189,9 @@ static void hdmi_update_short_audio_desc(struct cea_sad *a,
>  	a->channels = GRAB_BITS(buf, 0, 0, 3);
>  	a->channels++;
>  
> +	a->sample_bits = 0;
> +	a->max_bitrate = 0;
> +
>  	a->format = GRAB_BITS(buf, 0, 3, 4);
>  	switch (a->format) {
>  	case AUDIO_CODING_TYPE_REF_STREAM_HEADER:
> @@ -198,7 +201,6 @@ static void hdmi_update_short_audio_desc(struct cea_sad *a,
>  
>  	case AUDIO_CODING_TYPE_LPCM:
>  		val = GRAB_BITS(buf, 2, 0, 3);
> -		a->sample_bits = 0;
>  		for (i = 0; i < 3; i++)
>  			if (val & (1 << i))
>  				a->sample_bits |= cea_sample_sizes[i + 1];


-- 
Anssi Hannula

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ALSA: hda - Reset sample sizes and max bitrates when reading ELD
  2010-12-07 20:21 ` Anssi Hannula
@ 2010-12-08  7:37   ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2010-12-08  7:37 UTC (permalink / raw)
  To: Anssi Hannula; +Cc: alsa-devel

At Tue, 07 Dec 2010 22:21:57 +0200,
Anssi Hannula wrote:
> 
> On 07.12.2010 21:19, Anssi Hannula wrote:
> > When a new HDMI/DP device is plugged in, hdmi_update_short_audio_desc()
> > is called for every SAD (Short Audio Descriptor) in the ELD data. For
> > LPCM coding type SAD defines the supported sample sizes. For several
> > other coding types (such as AC-3), a maximum bitrate is defined.
> > 
> > The maximum bitrate and sample size fields are not always cleared.
> > Therefore, if a device is unplugged and a different one is plugged in,
> > and the coding types of some SAD positions differ between the devices,
> > the old max_bitrate or sample_bits values will persist if the new SADs
> > do not define those values.
> > 
> > The leftover max_bitrate and sample_bits do not cause any issues other
> > than wrongly showing up in eld#X.Y procfs file and kernel log.
> 
> Actually, only max_bitrate will be shown there, the coding type seems to
> be checked for LPCM before outputting sample_bits into eld#X.Y or log.
> 
> It is still probably better to clear that value as well, though.

Fair enough.  I took your patch as is now.

Thanks!

Takashi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-08  7:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-07 19:19 [PATCH] ALSA: hda - Reset sample sizes and max bitrates when reading ELD Anssi Hannula
2010-12-07 20:21 ` Anssi Hannula
2010-12-08  7:37   ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.