Commit 52be2c49 authored by Maciej Strozek's avatar Maciej Strozek Committed by Mark Brown

ASoC: cs43130: Allow configuration of bit clock and frame inversion

Signed-off-by: default avatarMaciej Strozek <mstrozek@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20231124095030.24539-1-mstrozek@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent fa91703d
...@@ -620,6 +620,27 @@ static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk, ...@@ -620,6 +620,27 @@ static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk,
return -EINVAL; return -EINVAL;
} }
switch (cs43130->dais[dai_id].dai_invert) {
case SND_SOC_DAIFMT_NB_NF:
sclk_edge = 1;
lrck_edge = 0;
break;
case SND_SOC_DAIFMT_IB_NF:
sclk_edge = 0;
lrck_edge = 0;
break;
case SND_SOC_DAIFMT_NB_IF:
sclk_edge = 1;
lrck_edge = 1;
break;
case SND_SOC_DAIFMT_IB_IF:
sclk_edge = 0;
lrck_edge = 1;
break;
default:
return -EINVAL;
}
switch (cs43130->dais[dai_id].dai_mode) { switch (cs43130->dais[dai_id].dai_mode) {
case SND_SOC_DAIFMT_CBS_CFS: case SND_SOC_DAIFMT_CBS_CFS:
dai_mode_val = 0; dai_mode_val = 0;
...@@ -632,8 +653,6 @@ static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk, ...@@ -632,8 +653,6 @@ static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk,
} }
frm_size = bitwidth_sclk * params_channels(params); frm_size = bitwidth_sclk * params_channels(params);
sclk_edge = 1;
lrck_edge = 0;
loc_ch1 = 0; loc_ch1 = 0;
loc_ch2 = bitwidth_sclk * (params_channels(params) - 1); loc_ch2 = bitwidth_sclk * (params_channels(params) - 1);
...@@ -1516,6 +1535,25 @@ static int cs43130_pcm_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -1516,6 +1535,25 @@ static int cs43130_pcm_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
return -EINVAL; return -EINVAL;
} }
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_NB_NF:
cs43130->dais[codec_dai->id].dai_invert = SND_SOC_DAIFMT_NB_NF;
break;
case SND_SOC_DAIFMT_IB_NF:
cs43130->dais[codec_dai->id].dai_invert = SND_SOC_DAIFMT_IB_NF;
break;
case SND_SOC_DAIFMT_NB_IF:
cs43130->dais[codec_dai->id].dai_invert = SND_SOC_DAIFMT_NB_IF;
break;
case SND_SOC_DAIFMT_IB_IF:
cs43130->dais[codec_dai->id].dai_invert = SND_SOC_DAIFMT_IB_IF;
break;
default:
dev_err(cs43130->dev, "Unsupported invert mode 0x%x\n",
fmt & SND_SOC_DAIFMT_INV_MASK);
return -EINVAL;
}
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_I2S:
cs43130->dais[codec_dai->id].dai_format = SND_SOC_DAIFMT_I2S; cs43130->dais[codec_dai->id].dai_format = SND_SOC_DAIFMT_I2S;
......
...@@ -497,6 +497,7 @@ struct cs43130_dai { ...@@ -497,6 +497,7 @@ struct cs43130_dai {
unsigned int sclk; unsigned int sclk;
unsigned int dai_format; unsigned int dai_format;
unsigned int dai_mode; unsigned int dai_mode;
unsigned int dai_invert;
}; };
struct cs43130_private { struct cs43130_private {
......
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