Skip to content

Commit d16c893

Browse files
Amadeusz Sławińskibroonie
authored andcommitted
ASoC: Intel: avs: max98357a: Explicitly define codec format
max98357a is speaker codec configured in 48000/2/S16_LE format regardless of front end format, so force it to be so. Reviewed-by: Cezary Rojewski <[email protected]> Signed-off-by: Amadeusz Sławiński <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent fe15c26 commit d16c893

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

sound/soc/intel/avs/boards/max98357a.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/module.h>
1010
#include <linux/platform_device.h>
11+
#include <sound/pcm_params.h>
1112
#include <sound/soc.h>
1213
#include <sound/soc-acpi.h>
1314
#include <sound/soc-dapm.h>
@@ -24,6 +25,26 @@ static const struct snd_soc_dapm_route card_base_routes[] = {
2425
{ "Spk", NULL, "Speaker" },
2526
};
2627

28+
static int
29+
avs_max98357a_be_fixup(struct snd_soc_pcm_runtime *runrime, struct snd_pcm_hw_params *params)
30+
{
31+
struct snd_interval *rate, *channels;
32+
struct snd_mask *fmt;
33+
34+
rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
35+
channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
36+
fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
37+
38+
/* The ADSP will convert the FE rate to 48k, stereo */
39+
rate->min = rate->max = 48000;
40+
channels->min = channels->max = 2;
41+
42+
/* set SSP0 to 16 bit */
43+
snd_mask_none(fmt);
44+
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
45+
return 0;
46+
}
47+
2748
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port,
2849
struct snd_soc_dai_link **dai_link)
2950
{
@@ -55,6 +76,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
5576
dl->num_platforms = 1;
5677
dl->id = 0;
5778
dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
79+
dl->be_hw_params_fixup = avs_max98357a_be_fixup;
5880
dl->nonatomic = 1;
5981
dl->no_pcm = 1;
6082
dl->dpcm_playback = 1;

0 commit comments

Comments
 (0)