Skip to content

Commit 1590988

Browse files
krzkbroonie
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 8f5fab5 commit 1590988

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

sound/soc/qcom/x1e80100.c

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,53 @@ static int x1e80100_snd_hw_params(struct snd_pcm_substream *substream,
9595
return qcom_snd_sdw_hw_params(substream, params, &data->sruntime[cpu_dai->id]);
9696
}
9797

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+
98126
static int x1e80100_snd_prepare(struct snd_pcm_substream *substream)
99127
{
100128
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
101129
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
102130
struct x1e80100_snd_data *data = snd_soc_card_get_drvdata(rtd->card);
103131
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];
108134
int ret;
109135

110136
switch (cpu_dai->id) {
111137
case WSA_CODEC_DMA_RX_0:
112138
case WSA_CODEC_DMA_RX_1:
139+
ret = x1e80100_snd_hw_map_channels(rx_slot, channels);
140+
if (ret)
141+
return ret;
142+
113143
ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL,
114-
ARRAY_SIZE(rx_slot), rx_slot);
144+
channels, rx_slot);
115145
if (ret)
116146
return ret;
117147
break;

0 commit comments

Comments
 (0)