summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/tas2552.c
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2015-06-04 16:04:29 +0300
committerMark Brown <broonie@kernel.org>2015-06-05 18:53:36 +0100
commitd20b098dd98ec9e0a205ad59e32d93a636a783b3 (patch)
treeb516eb33dc61304ef205c38e182c8dbee1e24811 /sound/soc/codecs/tas2552.c
parent7d78502502f3984894c0bb8d330ef894f2c2c04c (diff)
downloadlinux-d20b098dd98ec9e0a205ad59e32d93a636a783b3.tar.bz2
ASoC: tas2552: Add support for word length configuration
Configure the word length based on the params_width of the stream. Also configure the clock per frame value which is used when tas2552 is bus master. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/tas2552.c')
-rw-r--r--sound/soc/codecs/tas2552.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
index 9c081344bd90..13b435f9a9b1 100644
--- a/sound/soc/codecs/tas2552.c
+++ b/sound/soc/codecs/tas2552.c
@@ -166,7 +166,45 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream,
struct tas2552_data *tas2552 = dev_get_drvdata(codec->dev);
int sample_rate, pll_clk;
int d;
+ int cpf;
u8 p, j;
+ u8 ser_ctrl1_reg;
+
+ switch (params_width(params)) {
+ case 16:
+ ser_ctrl1_reg = TAS2552_WORDLENGTH_16BIT;
+ cpf = 32 + tas2552->tdm_delay;
+ break;
+ case 20:
+ ser_ctrl1_reg = TAS2552_WORDLENGTH_20BIT;
+ cpf = 64 + tas2552->tdm_delay;
+ break;
+ case 24:
+ ser_ctrl1_reg = TAS2552_WORDLENGTH_24BIT;
+ cpf = 64 + tas2552->tdm_delay;
+ break;
+ case 32:
+ ser_ctrl1_reg = TAS2552_WORDLENGTH_32BIT;
+ cpf = 64 + tas2552->tdm_delay;
+ break;
+ default:
+ dev_err(codec->dev, "Not supported sample size: %d\n",
+ params_width(params));
+ return -EINVAL;
+ }
+
+ if (cpf <= 32)
+ ser_ctrl1_reg |= TAS2552_CLKSPERFRAME_32;
+ else if (cpf <= 64)
+ ser_ctrl1_reg |= TAS2552_CLKSPERFRAME_64;
+ else if (cpf <= 128)
+ ser_ctrl1_reg |= TAS2552_CLKSPERFRAME_128;
+ else
+ ser_ctrl1_reg |= TAS2552_CLKSPERFRAME_256;
+
+ snd_soc_update_bits(codec, TAS2552_SER_CTRL_1,
+ TAS2552_WORDLENGTH_MASK | TAS2552_CLKSPERFRAME_MASK,
+ ser_ctrl1_reg);
if (!tas2552->pll_clkin)
return -EINVAL;