alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Anssi Hannula <anssi.hannula@iki.fi>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, stable@vger.kernel.org
Subject: Re: [PATCH] ALSA: hda - hdmi: Fix channel map switch not taking effect
Date: Mon, 07 Oct 2013 13:31:17 +0300	[thread overview]
Message-ID: <73e325dd7c696e2d16946890a66dc838@mail.onse.fi> (raw)
In-Reply-To: <s5hzjqlseqt.wl%tiwai@suse.de>

Takashi Iwai kirjoitti 2013-10-07 10:48:
> At Wed,  2 Oct 2013 21:13:32 +0300,
> Anssi Hannula wrote:
> 
> Currently hdmi_setup_audio_infoframe() reprograms the HDA channel
> mapping only when the infoframe is not up-to-date or the non-PCM flag
> has changed.
> 
> However, when just the channel map has been changed, the infoframe may
> still be up-to-date and non-PCM flag may not have changed, so the new
> channel map is not actually programmed into the HDA codec.
> 
> Notably, this failing case is also always triggered when the device is
> already in a prepared state and a new channel map is configured while
> changing only the channel positions (for example, plain
> "speaker-test -c2 -m FR,FL").
> 
> Fix that by keeping track of the last programmed channel map and making
> hdmi_setup_audio_infoframe() always update the hardware mapping if the
> channel map has changed.
> 
> Hmm, maybe it's easier (and safer) to remove the check and always call
> hdmi_setup_channel_mapping()?  Of course, the drawback is the
> unnecessary verbs, but it's not too much.

Easier, yes. I don't really have that good of an idea how big of a delay
do 8 write verbs cause, so I'll rely on your judgment :)

I guess I could replace the writes with read-and-write-if-differs cycles
when I add the set_slot ops for ATI/AMD, since it seems to be used for
other similar cases (like channel count)?

> Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
> Cc: <stable@vger.kernel.org>
> ---
> 
> BTW, is there some mechanism preventing hdmi_chmap_ctl_put() to be 
> called
> at the same time with generic_hdmi_playback_pcm_prepare() that I didn't
> see with a quick look?
> Both of them call hdmi_setup_audio_infoframe() which is not 
> thread-safe.
> 
> Yeah, we need to introduce a mutex there.

I guess hdmi_present_sense() is the same, as it can also call
hdmi_setup_audio_infoframe()?

BTW, shouldn't hdmi_present_sense() call hdmi_setup_audio_infoframe() 
always
when eld_changed is true? hdmi_setup_audio_infoframe() does not do its
stuff if !monitor_present, so if one starts playback before plugging in,
the channel mappings etc will never be set even when plug-in happens
(from what I can see, that is -  did not test yet).


> thanks,
> 
> Takashi
> 
> sound/pci/hda/patch_hdmi.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
> index 7ea0245..09f38a1 100644
> --- a/sound/pci/hda/patch_hdmi.c
> +++ b/sound/pci/hda/patch_hdmi.c
> @@ -74,6 +74,8 @@ struct hdmi_spec_per_pin {
> 	bool non_pcm;
> 	bool chmap_set;		/* channel-map override by ALSA API? */
> 	unsigned char chmap[8]; /* ALSA API channel-map */
> +	bool last_chmap_set;	/* channel-map override programmed? */
> +	unsigned char last_chmap[8]; /* last programmed channel-map */
> 	char pcm_name[8];	/* filled in build_pcm callbacks */
> };
> 
> @@ -955,15 +957,21 @@ static void hdmi_setup_audio_infoframe(struct 
> hda_codec *codec,
> 					    ai.bytes, sizeof(ai));
> 		hdmi_start_infoframe_trans(codec, pin_nid);
> 	} else {
> -		/* For non-pcm audio switch, setup new channel mapping
> -		 * accordingly */
> -		if (per_pin->non_pcm != non_pcm)
> +		/* For non-pcm audio switch or channel-map switch,
> +		 * setup new channel mapping accordingly */
> +		if (per_pin->non_pcm != non_pcm
> +		    || per_pin->chmap_set != per_pin->last_chmap_set
> +		    || (per_pin->chmap_set && memcmp(per_pin->chmap, 
> per_pin->last_chmap,
> +						     ARRAY_SIZE(per_pin->chmap)) != 0))
> 			hdmi_setup_channel_mapping(codec, pin_nid, non_pcm, ca,
> 						   channels, per_pin->chmap,
> 						   per_pin->chmap_set);
> 	}
> 
> 	per_pin->non_pcm = non_pcm;
> +	per_pin->last_chmap_set = per_pin->chmap_set;
> +	if (per_pin->chmap_set)
> +		memcpy(per_pin->last_chmap, per_pin->chmap, 
> ARRAY_SIZE(per_pin->chmap));
> }
> 
> 
> --
> 1.8.1.5
> 

  reply	other threads:[~2013-10-07 10:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 18:13 [PATCH] ALSA: hda - hdmi: Fix channel map switch not taking effect Anssi Hannula
2013-10-07  7:48 ` Takashi Iwai
2013-10-07 10:31   ` Anssi Hannula [this message]
2013-10-07 10:43     ` Takashi Iwai
2013-10-07 12:45       ` Anssi Hannula
2013-10-07 13:09         ` Takashi Iwai
2013-10-15 15:32           ` Takashi Iwai
2013-10-15 16:22             ` Anssi Hannula
2013-10-24 11:01               ` Takashi Iwai
2013-10-24 14:20                 ` Anssi Hannula
2013-10-24 16:11                   ` Takashi Iwai
2013-10-07 16:24         ` [PATCH v2] " Anssi Hannula
2013-10-08  7:33           ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=73e325dd7c696e2d16946890a66dc838@mail.onse.fi \
    --to=anssi.hannula@iki.fi \
    --cc=alsa-devel@alsa-project.org \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).