Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: qcom: x1e80100: Support boards with two speakers

Some Qualcomm X1E laptops have only two speakers. Regardless whether
this sound card driver is suitable for them (we could re-use one for
some older SoC), we should set reasonable channel map depending on the
number of channels, not always 4-speaker setup.

This change is necessary for bringing audio support on Lenovo Thinkpad
T14s with Qualcomm X1E78100 and only two speakers.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20241023124152.130706-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Mark Brown
15909885 8f5fab53

+35 -5
+35 -5
sound/soc/qcom/x1e80100.c
··· 95 95 return qcom_snd_sdw_hw_params(substream, params, &data->sruntime[cpu_dai->id]); 96 96 } 97 97 98 + static int x1e80100_snd_hw_map_channels(unsigned int *ch_map, int num) 99 + { 100 + switch (num) { 101 + case 1: 102 + ch_map[0] = PCM_CHANNEL_FC; 103 + break; 104 + case 2: 105 + ch_map[0] = PCM_CHANNEL_FL; 106 + ch_map[1] = PCM_CHANNEL_FR; 107 + break; 108 + case 3: 109 + ch_map[0] = PCM_CHANNEL_FL; 110 + ch_map[1] = PCM_CHANNEL_FR; 111 + ch_map[2] = PCM_CHANNEL_FC; 112 + break; 113 + case 4: 114 + ch_map[0] = PCM_CHANNEL_FL; 115 + ch_map[1] = PCM_CHANNEL_LB; 116 + ch_map[2] = PCM_CHANNEL_FR; 117 + ch_map[3] = PCM_CHANNEL_RB; 118 + break; 119 + default: 120 + return -EINVAL; 121 + } 122 + 123 + return 0; 124 + } 125 + 98 126 static int x1e80100_snd_prepare(struct snd_pcm_substream *substream) 99 127 { 100 128 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 101 129 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 102 130 struct x1e80100_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 103 131 struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; 104 - const unsigned int rx_slot[4] = { PCM_CHANNEL_FL, 105 - PCM_CHANNEL_LB, 106 - PCM_CHANNEL_FR, 107 - PCM_CHANNEL_RB }; 132 + unsigned int channels = substream->runtime->channels; 133 + unsigned int rx_slot[4]; 108 134 int ret; 109 135 110 136 switch (cpu_dai->id) { 111 137 case WSA_CODEC_DMA_RX_0: 112 138 case WSA_CODEC_DMA_RX_1: 139 + ret = x1e80100_snd_hw_map_channels(rx_slot, channels); 140 + if (ret) 141 + return ret; 142 + 113 143 ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, 114 - ARRAY_SIZE(rx_slot), rx_slot); 144 + channels, rx_slot); 115 145 if (ret) 116 146 return ret; 117 147 break;