summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/ak4613.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2022-04-05 02:06:17 +0000
committerMark Brown <broonie@kernel.org>2022-04-05 18:49:56 +0100
commitf7c0e14f5717aabc5db7e4eb6324d750d415d022 (patch)
tree5dc1d84c3e9072c302a2d708828cd5a9c6ffffe1 /sound/soc/codecs/ak4613.c
parent3407e36dc78f4a980588c9347076aee9925ca51f (diff)
ASoC: ak4613: tidyup ak4613_interface
ak4613 driver is assuming symmetric format. Thus, we don't need to have asymmetric table for judging the iface at .hw_param. This patch cleanup ak4613_interface for it. This is prepare for TDM support. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87ee2cp9lz.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/ak4613.c')
-rw-r--r--sound/soc/codecs/ak4613.c55
1 files changed, 24 insertions, 31 deletions
diff --git a/sound/soc/codecs/ak4613.c b/sound/soc/codecs/ak4613.c
index e0d9a8c58e10..a20bbf82e8df 100644
--- a/sound/soc/codecs/ak4613.c
+++ b/sound/soc/codecs/ak4613.c
@@ -78,14 +78,10 @@
/* OCTRL */
#define OCTRL_MASK (0x3F)
-struct ak4613_formats {
+struct ak4613_interface {
unsigned int width;
unsigned int fmt;
-};
-
-struct ak4613_interface {
- struct ak4613_formats capture;
- struct ak4613_formats playback;
+ u8 dif;
};
struct ak4613_priv {
@@ -137,13 +133,22 @@ static const struct reg_default ak4613_reg[] = {
{ 0x14, 0x00 }, { 0x15, 0x00 }, { 0x16, 0x00 },
};
-#define AUDIO_IFACE_TO_VAL(fmts) ((fmts - ak4613_iface) << 3)
-#define AUDIO_IFACE(b, fmt) { b, SND_SOC_DAIFMT_##fmt }
+/*
+ * CTRL1 register
+ * see
+ * Table 11/12/13/14
+ */
+#define AUDIO_IFACE(_val, _width, _fmt) \
+ { \
+ .dif = (_val << 3), \
+ .width = _width, \
+ .fmt = SND_SOC_DAIFMT_##_fmt,\
+ }
static const struct ak4613_interface ak4613_iface[] = {
- /* capture */ /* playback */
- /* [0] - [2] are not supported */
- [3] = { AUDIO_IFACE(24, LEFT_J), AUDIO_IFACE(24, LEFT_J) },
- [4] = { AUDIO_IFACE(24, I2S), AUDIO_IFACE(24, I2S) },
+ /* It doesn't support asymmetric format */
+
+ AUDIO_IFACE(0x03, 24, LEFT_J),
+ AUDIO_IFACE(0x04, 24, I2S),
};
static const struct regmap_config ak4613_regmap_cfg = {
@@ -344,20 +349,13 @@ static int ak4613_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
}
static bool ak4613_dai_fmt_matching(const struct ak4613_interface *iface,
- int is_play,
unsigned int fmt, unsigned int width)
{
- const struct ak4613_formats *fmts;
-
- fmts = (is_play) ? &iface->playback : &iface->capture;
+ if ((iface->fmt == fmt) &&
+ (iface->width == width))
+ return true;
- if (fmts->fmt != fmt)
- return false;
-
- if (fmts->width != width)
- return false;
-
- return true;
+ return false;
}
static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
@@ -371,9 +369,8 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
unsigned int width = params_width(params);
unsigned int fmt = priv->fmt;
unsigned int rate;
- int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
int i, ret;
- u8 fmt_ctrl, ctrl2;
+ u8 ctrl2;
rate = params_rate(params);
switch (rate) {
@@ -401,18 +398,16 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
*
* It doesn't support TDM at this point
*/
- fmt_ctrl = NO_FMT;
ret = -EINVAL;
iface = NULL;
mutex_lock(&priv->lock);
if (priv->iface) {
- if (ak4613_dai_fmt_matching(priv->iface, is_play, fmt, width))
+ if (ak4613_dai_fmt_matching(priv->iface, fmt, width))
iface = priv->iface;
} else {
for (i = ARRAY_SIZE(ak4613_iface) - 1; i >= 0; i--) {
if (!ak4613_dai_fmt_matching(ak4613_iface + i,
- is_play,
fmt, width))
continue;
iface = ak4613_iface + i;
@@ -430,9 +425,7 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
if (ret < 0)
goto hw_params_end;
- fmt_ctrl = AUDIO_IFACE_TO_VAL(iface);
-
- snd_soc_component_update_bits(component, CTRL1, FMT_MASK, fmt_ctrl);
+ snd_soc_component_update_bits(component, CTRL1, FMT_MASK, iface->dif);
snd_soc_component_update_bits(component, CTRL2, DFS_MASK, ctrl2);
snd_soc_component_update_bits(component, ICTRL, ICTRL_MASK, priv->ic);