[3/7] ASoC: cs43130: Allow configuration of bit clock and frame inversion
Commit Message
Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
---
sound/soc/codecs/cs43130.c | 42 ++++++++++++++++++++++++++++++++++++--
sound/soc/codecs/cs43130.h | 1 +
2 files changed, 41 insertions(+), 2 deletions(-)
Comments
On Fri, Nov 17, 2023 at 02:13:40PM +0000, Maciej Strozek wrote:
> Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
This breaks an x86 allmodconfig build:
In file included from /build/stage/linux/include/linux/device.h:15,
from /build/stage/linux/include/linux/platform_device.h:13,
from /build/stage/linux/sound/soc/codecs/cs43130.c:16:
/build/stage/linux/sound/soc/codecs/cs43130.c: In function ‘cs43130_pcm_set_fmt’
:
/build/stage/linux/sound/soc/codecs/cs43130.c:1519:32: error: ‘struct cs43130_pr
ivate’ has no member named ‘dev’
1519 | dev_err(cs43130->dev, "Unsupported invert mode 0x%x\n",
| ^~
/build/stage/linux/include/linux/dev_printk.h:110:25: note: in definition of mac
ro ‘dev_printk_index_wrap’
110 | _p_func(dev, fmt, ##__VA_ARGS__);
\
| ^~~
/build/stage/linux/sound/soc/codecs/cs43130.c:1519:17: note: in expansion of macro ‘dev_err’
1519 | dev_err(cs43130->dev, "Unsupported invert mode 0x%x\n",
| ^~~~~~~
@@ -595,6 +595,27 @@ static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk,
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) {
case SND_SOC_DAIFMT_CBS_CFS:
dai_mode_val = 0;
@@ -607,8 +628,6 @@ static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk,
}
frm_size = bitwidth_sclk * params_channels(params);
- sclk_edge = 1;
- lrck_edge = 0;
loc_ch1 = 0;
loc_ch2 = bitwidth_sclk * (params_channels(params) - 1);
@@ -1483,6 +1502,25 @@ static int cs43130_pcm_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
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) {
case SND_SOC_DAIFMT_I2S:
cs43130->dais[codec_dai->id].dai_format = SND_SOC_DAIFMT_I2S;
@@ -497,6 +497,7 @@ struct cs43130_dai {
unsigned int sclk;
unsigned int dai_format;
unsigned int dai_mode;
+ unsigned int dai_invert;
};
struct cs43130_private {