Message ID | 20241212004727.2903846-15-alexey.klimov@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | qrb4210-rb2: add wsa audio playback and capture support | expand |
On 12.12.2024 1:47 AM, Alexey Klimov wrote: > In case of mono configurations we need to enforce single channel > output. This is required for audio playback on QRB4210 RB2 board > since it has only one WSA8815 amplifier. > Implement data variant for qrb4210-rb2-sndcard with > sm8250_qrb4210_fixup_params() that does that. > > Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- Would it not be enough to set channels->min = 1? Konrad
On Thu Dec 12, 2024 at 5:22 PM GMT, Konrad Dybcio wrote: > On 12.12.2024 1:47 AM, Alexey Klimov wrote: > > In case of mono configurations we need to enforce single channel > > output. This is required for audio playback on QRB4210 RB2 board > > since it has only one WSA8815 amplifier. > > Implement data variant for qrb4210-rb2-sndcard with > > sm8250_qrb4210_fixup_params() that does that. > > > > Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> > > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > > --- > > Would it not be enough to set channels->min = 1? Enough for what or to do what exactly?
On 13.12.2024 12:54 PM, Alexey Klimov wrote: > On Thu Dec 12, 2024 at 5:22 PM GMT, Konrad Dybcio wrote: >> On 12.12.2024 1:47 AM, Alexey Klimov wrote: >>> In case of mono configurations we need to enforce single channel >>> output. This is required for audio playback on QRB4210 RB2 board >>> since it has only one WSA8815 amplifier. >>> Implement data variant for qrb4210-rb2-sndcard with >>> sm8250_qrb4210_fixup_params() that does that. >>> >>> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> >>> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >>> --- >> >> Would it not be enough to set channels->min = 1? > > Enough for what or to do what exactly? Enough to make the rest of this patch unnecessary Konrad
diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c index 45e0c33fc3f3..b54acaee8dd1 100644 --- a/sound/soc/qcom/sm8250.c +++ b/sound/soc/qcom/sm8250.c @@ -23,8 +23,23 @@ struct sm8250_snd_data { struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; struct snd_soc_jack jack; bool jack_setup; + void (*sndcard_fixup_params)(struct snd_interval *channels, + struct snd_soc_dai *cpu_dai); }; +static void sm8250_qrb4210_fixup_params(struct snd_interval *channels, + struct snd_soc_dai *cpu_dai) +{ + /* QRB410 RB2 board has only one WSA8815 amplifier */ + switch (cpu_dai->id) { + case RX_CODEC_DMA_RX_1: + channels->min = channels->max = 1; + break; + default: + break; + } +} + static int sm8250_snd_init(struct snd_soc_pcm_runtime *rtd) { struct sm8250_snd_data *data = snd_soc_card_get_drvdata(rtd->card); @@ -35,14 +50,19 @@ static int sm8250_snd_init(struct snd_soc_pcm_runtime *rtd) static int sm8250_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { + struct sm8250_snd_data *data = snd_soc_card_get_drvdata(rtd->card); struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); rate->min = rate->max = 48000; channels->min = channels->max = 2; + if (data->sndcard_fixup_params) + data->sndcard_fixup_params(channels, cpu_dai); + return 0; } @@ -168,6 +188,7 @@ static int sm8250_platform_probe(struct platform_device *pdev) if (!data) return -ENOMEM; + data->sndcard_fixup_params = device_get_match_data(&pdev->dev); card->dev = dev; dev_set_drvdata(dev, card); snd_soc_card_set_drvdata(card, data); @@ -181,9 +202,10 @@ static int sm8250_platform_probe(struct platform_device *pdev) } static const struct of_device_id snd_sm8250_dt_match[] = { - {.compatible = "qcom,sm8250-sndcard"}, - {.compatible = "qcom,qrb4210-rb2-sndcard"}, - {.compatible = "qcom,qrb5165-rb5-sndcard"}, + {.compatible = "qcom,sm8250-sndcard", .data = NULL }, + {.compatible = "qcom,qrb4210-rb2-sndcard", + .data = sm8250_qrb4210_fixup_params }, + {.compatible = "qcom,qrb5165-rb5-sndcard", .data = NULL }, {} };
In case of mono configurations we need to enforce single channel output. This is required for audio playback on QRB4210 RB2 board since it has only one WSA8815 amplifier. Implement data variant for qrb4210-rb2-sndcard with sm8250_qrb4210_fixup_params() that does that. Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- sound/soc/qcom/sm8250.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)