Commit 1abb43ae authored by Samuel Holland's avatar Samuel Holland Committed by Mark Brown

ASoC: sun8i-codec: Use the provided word size

The hardware supports 8 to 24-bit word sizes on all three of its DAIs,
only one of which is connected to the CPU DAI. Program the word size
based on the actual selected format, instead of assuming limitations
from another driver (which, incedentally, has patches pending to remove
that limitation).
Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-5-samuel@sholland.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent c56f5f1c
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
#define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV 9 #define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV 9
#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV 6 #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV 6
#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ 4 #define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ 4
#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16 (1 << 4)
#define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT 2 #define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT 2
#define SUN8I_AIF1_ADCDAT_CTRL 0x044 #define SUN8I_AIF1_ADCDAT_CTRL 0x044
#define SUN8I_AIF1_ADCDAT_CTRL_AIF1_AD0L_ENA 15 #define SUN8I_AIF1_ADCDAT_CTRL_AIF1_AD0L_ENA 15
...@@ -322,16 +321,30 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream, ...@@ -322,16 +321,30 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct sun8i_codec *scodec = snd_soc_dai_get_drvdata(dai); struct sun8i_codec *scodec = snd_soc_dai_get_drvdata(dai);
int sample_rate, lrck_div; int lrck_div, sample_rate, word_size;
u8 bclk_div; u8 bclk_div;
/* /* word size */
* The CPU DAI handles only a sample of 16 bits. Configure the switch (params_width(params)) {
* codec to handle this type of sample resolution. case 8:
*/ word_size = 0x0;
break;
case 16:
word_size = 0x1;
break;
case 20:
word_size = 0x2;
break;
case 24:
word_size = 0x3;
break;
default:
return -EINVAL;
}
regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL,
SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_MASK, SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_MASK,
SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16); word_size << SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ);
bclk_div = sun8i_codec_get_bclk_div(scodec, params_rate(params), 16); bclk_div = sun8i_codec_get_bclk_div(scodec, params_rate(params), 16);
regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment