Skip to content

Commit 5758072

Browse files
Yu-Hsuan HsuLee Jones
authored andcommitted
ASoC: max98090: remove 24-bit format support if RJ is 0
[ Upstream commit 5628c89 ] The supported formats are S16_LE and S24_LE now. However, by datasheet of max98090, S24_LE is only supported when it is in the right justified mode. We should remove 24-bit format if it is not in that mode to avoid triggering error. Signed-off-by: Yu-Hsuan Hsu <yuhsuan@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Change-Id: I68110cd295e9cd1c692bbd3cc3fbc247d92759a0
1 parent 7d43891 commit 5758072

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

sound/soc/codecs/max98090.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,21 @@ static const int dmic_comp[6][6] = {
18471847
{7, 8, 3, 3, 3, 3}
18481848
};
18491849

1850+
static int max98090_dai_startup(struct snd_pcm_substream *substream,
1851+
struct snd_soc_dai *dai)
1852+
{
1853+
struct snd_soc_component *component = dai->component;
1854+
struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
1855+
unsigned int fmt = max98090->dai_fmt;
1856+
1857+
/* Remove 24-bit format support if it is not in right justified mode. */
1858+
if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_RIGHT_J) {
1859+
substream->runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
1860+
snd_pcm_hw_constraint_msbits(substream->runtime, 0, 16, 16);
1861+
}
1862+
return 0;
1863+
}
1864+
18501865
static int max98090_dai_hw_params(struct snd_pcm_substream *substream,
18511866
struct snd_pcm_hw_params *params,
18521867
struct snd_soc_dai *dai)
@@ -2274,6 +2289,7 @@ EXPORT_SYMBOL_GPL(max98090_mic_detect);
22742289
#define MAX98090_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
22752290

22762291
static struct snd_soc_dai_ops max98090_dai_ops = {
2292+
.startup = max98090_dai_startup,
22772293
.set_sysclk = max98090_dai_set_sysclk,
22782294
.set_fmt = max98090_dai_set_fmt,
22792295
.set_tdm_slot = max98090_set_tdm_slot,

0 commit comments

Comments
 (0)