[alsa-devel] [PATCH] ALSA: hda - hdmi: Fallback to ALSA allocation when selecting CA

Anssi Hannula anssi.hannula at iki.fi
Mon Sep 2 16:14:02 CEST 2013


02.09.2013 16:06, Takashi Iwai kirjoitti:
> At Sun,  1 Sep 2013 14:36:47 +0300,
> Anssi Hannula wrote:
>> BTW, the hdmi_channel_allocation() logic seems also otherwise somewhat
>> suspect to me. Shouldn't we always select an allocation matching ALSA
>> channel mapping, instead of re-assigning channels received from
>> userspace "randomly" to sink speakers (in case of unusual sink speaker
>> mask)?
> 
> If per_pin->chmap_set is set beforehand,
> hdmi_manual_channel_allocation() is called instead.  So it should be
> fine.

I was talking about the "non-chmap" case.

Example:

Sink has FL + FR + FC + LFE.

Application plays 4 channel audio via ALSA, i.e. FL + FR + RL + RR as
per ALSA API channel allocation.

Instead of sending CA for FL + FR + RL + RR (0x06) which is what the
audio really is, hdmi_channel_allocation() selects CA for  FL + FR + FC
+ LFE (0x03), since that is what the sink reported as present. As a
result rear channels are mapped to FC and LFE.


Of course this is rather unusual case (in terms of sink speaker mask),
and it may be argued that the user actually _wanted_ to output the
second pair of channels to FC+LFE despite them normally being RL+RR in ALSA.



> Takashi
> 
>> Anyway, I let it be for now at least.
>>
>>
>>  sound/pci/hda/patch_hdmi.c | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
>> index 030ca86..354fc55 100644
>> --- a/sound/pci/hda/patch_hdmi.c
>> +++ b/sound/pci/hda/patch_hdmi.c
>> @@ -551,6 +551,17 @@ static int hdmi_channel_allocation(struct hdmi_eld *eld, int channels)
>>  		}
>>  	}
>>  
>> +	if (!ca) {
>> +		/* if there was no match, select the regular ALSA channel
>> +		 * allocation with the matching number of channels */
>> +		for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
>> +			if (channels == channel_allocations[i].channels) {
>> +				ca = channel_allocations[i].ca_index;
>> +				break;
>> +			}
>> +		}
>> +	}
>> +
>>  	snd_print_channel_allocation(eld->info.spk_alloc, buf, sizeof(buf));
>>  	snd_printdd("HDMI: select CA 0x%x for %d-channel allocation: %s\n",
>>  		    ca, channels, buf);
>> -- 
>> 1.8.1.5
>>


-- 
Anssi Hannula


More information about the Alsa-devel mailing list