* [PATCH v2 0/4] ASoC: meson: g12a-toacodec: add support for A1 SoC
@ 2025-03-09 18:15 Jan Dakinevich
2025-03-09 18:15 ` [PATCH v2 1/4] ASoC: meson: codec-glue: add support for capture stream Jan Dakinevich
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Jan Dakinevich @ 2025-03-09 18:15 UTC (permalink / raw)
To: Jan Dakinevich, Conor Dooley, devicetree, Jaroslav Kysela,
Jerome Brunet, Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, linux-kernel, linux-sound,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Rob Herring,
Takashi Iwai
This series adds support for A1 SoC family in g12a-toacodec driver. The main
change is that the driver now supports capture streams which are suitable for
ADC found on A1's internal audio codec.
Changes v1 [1] -> v2
- detached from v1's series (patch 6, 7, 8, 9)
- reworked the definition of bits
Links:
[1] https://lore.kernel.org/lkml/20240314232201.2102178-1-jan.dakinevich@salutedevices.com/
Jan Dakinevich (4):
ASoC: meson: codec-glue: add support for capture stream
ASoC: meson: g12a-toacodec: drop the definition of bits
ASoC: dt-bindings: meson: g12a-toacodec: add support for A1 SoC family
ASoC: meson: g12a-toacodec: add support for A1 SoC family
.../bindings/sound/amlogic,g12a-toacodec.yaml | 1 +
.../dt-bindings/sound/meson-g12a-toacodec.h | 5 +
sound/soc/meson/g12a-toacodec.c | 242 ++++++++++++++----
sound/soc/meson/meson-codec-glue.c | 174 ++++++++++---
sound/soc/meson/meson-codec-glue.h | 23 ++
5 files changed, 358 insertions(+), 87 deletions(-)
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/4] ASoC: meson: codec-glue: add support for capture stream
2025-03-09 18:15 [PATCH v2 0/4] ASoC: meson: g12a-toacodec: add support for A1 SoC Jan Dakinevich
@ 2025-03-09 18:15 ` Jan Dakinevich
2025-03-09 18:15 ` [PATCH v2 2/4] ASoC: meson: g12a-toacodec: drop the definition of bits Jan Dakinevich
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Jan Dakinevich @ 2025-03-09 18:15 UTC (permalink / raw)
To: Jan Dakinevich, Conor Dooley, devicetree, Jaroslav Kysela,
Jerome Brunet, Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, linux-kernel, linux-sound,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Rob Herring,
Takashi Iwai
The glue saves stream's private data in front-end dai and then backend
dai can reach them searching backward from sink to source. For capture
stream everything left the same, but searching should be performed from
source to sink.
Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
---
Hope, I haven't misinterpreted the terminology and codec-glue's behavior
too much.
---
sound/soc/meson/meson-codec-glue.c | 174 ++++++++++++++++++++++-------
sound/soc/meson/meson-codec-glue.h | 23 ++++
2 files changed, 158 insertions(+), 39 deletions(-)
diff --git a/sound/soc/meson/meson-codec-glue.c b/sound/soc/meson/meson-codec-glue.c
index f8c5643f3cfe..da6d65e58d90 100644
--- a/sound/soc/meson/meson-codec-glue.c
+++ b/sound/soc/meson/meson-codec-glue.c
@@ -11,65 +11,94 @@
#include "meson-codec-glue.h"
static struct snd_soc_dapm_widget *
-meson_codec_glue_get_input(struct snd_soc_dapm_widget *w)
+meson_codec_glue_get_data_widget(struct snd_soc_dapm_widget *w, bool playback)
{
struct snd_soc_dapm_path *p;
- struct snd_soc_dapm_widget *in;
-
- snd_soc_dapm_widget_for_each_source_path(w, p) {
+ struct snd_soc_dapm_widget *node;
+ enum snd_soc_dapm_type id = playback ? snd_soc_dapm_dai_in
+ : snd_soc_dapm_dai_out;
+ enum snd_soc_dapm_direction dir = playback ? SND_SOC_DAPM_DIR_IN
+ : SND_SOC_DAPM_DIR_OUT;
+ enum snd_soc_dapm_direction rdir = playback ? SND_SOC_DAPM_DIR_OUT
+ : SND_SOC_DAPM_DIR_IN;
+
+ snd_soc_dapm_widget_for_each_path(w, rdir, p) {
if (!p->connect)
continue;
/* Check that we still are in the same component */
if (snd_soc_dapm_to_component(w->dapm) !=
- snd_soc_dapm_to_component(p->source->dapm))
+ snd_soc_dapm_to_component(p->node[dir]->dapm))
continue;
- if (p->source->id == snd_soc_dapm_dai_in)
- return p->source;
+ if (p->node[dir]->id == id)
+ return p->node[dir];
- in = meson_codec_glue_get_input(p->source);
- if (in)
- return in;
+ node = meson_codec_glue_get_data_widget(p->node[dir], playback);
+ if (node)
+ return node;
}
return NULL;
}
-static void meson_codec_glue_input_set_data(struct snd_soc_dai *dai,
- struct meson_codec_glue_input *data)
+static void meson_codec_glue_set_data(struct snd_soc_dai *dai,
+ struct meson_codec_glue_input *data,
+ bool playback)
+{
+ int stream = playback ? SNDRV_PCM_STREAM_PLAYBACK
+ : SNDRV_PCM_STREAM_CAPTURE;
+
+ snd_soc_dai_dma_data_set(dai, stream, data);
+}
+
+static struct meson_codec_glue_input *
+meson_codec_glue_get_data(struct snd_soc_dai *dai, bool playback)
{
- snd_soc_dai_dma_data_set_playback(dai, data);
+ int stream = playback ? SNDRV_PCM_STREAM_PLAYBACK
+ : SNDRV_PCM_STREAM_CAPTURE;
+
+ return snd_soc_dai_dma_data_get(dai, stream);
}
struct meson_codec_glue_input *
meson_codec_glue_input_get_data(struct snd_soc_dai *dai)
{
- return snd_soc_dai_dma_data_get_playback(dai);
+ return meson_codec_glue_get_data(dai, true);
}
EXPORT_SYMBOL_GPL(meson_codec_glue_input_get_data);
+struct meson_codec_glue_input *
+meson_codec_glue_capture_output_get_data(struct snd_soc_dai *dai)
+{
+ return meson_codec_glue_get_data(dai, false);
+}
+EXPORT_SYMBOL_GPL(meson_codec_glue_capture_output_get_data);
+
static struct meson_codec_glue_input *
-meson_codec_glue_output_get_input_data(struct snd_soc_dapm_widget *w)
+meson_codec_glue_data(struct snd_soc_dapm_widget *w, bool playback)
{
- struct snd_soc_dapm_widget *in =
- meson_codec_glue_get_input(w);
+ struct snd_soc_dapm_widget *node =
+ meson_codec_glue_get_data_widget(w, playback);
struct snd_soc_dai *dai;
- if (WARN_ON(!in))
+ if (WARN_ON(!node))
return NULL;
- dai = in->priv;
+ dai = node->priv;
- return meson_codec_glue_input_get_data(dai);
+ return meson_codec_glue_get_data(dai, playback);
}
-int meson_codec_glue_input_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai)
+static int meson_codec_glue_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai,
+ bool playback)
{
struct meson_codec_glue_input *data =
- meson_codec_glue_input_get_data(dai);
+ meson_codec_glue_get_data(dai, playback);
+ struct snd_soc_pcm_stream *stream = playback ? &dai->driver->playback
+ : &dai->driver->capture;
data->params.rates = snd_pcm_rate_to_rate_bit(params_rate(params));
data->params.rate_min = params_rate(params);
@@ -77,32 +106,64 @@ int meson_codec_glue_input_hw_params(struct snd_pcm_substream *substream,
data->params.formats = 1ULL << (__force int) params_format(params);
data->params.channels_min = params_channels(params);
data->params.channels_max = params_channels(params);
- data->params.sig_bits = dai->driver->playback.sig_bits;
+ data->params.sig_bits = stream->sig_bits;
return 0;
}
+
+int meson_codec_glue_input_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai)
+{
+ return meson_codec_glue_hw_params(substream, params, dai, true);
+}
EXPORT_SYMBOL_GPL(meson_codec_glue_input_hw_params);
-int meson_codec_glue_input_set_fmt(struct snd_soc_dai *dai,
- unsigned int fmt)
+int meson_codec_glue_capture_output_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai)
+{
+ return meson_codec_glue_hw_params(substream, params, dai, false);
+}
+EXPORT_SYMBOL_GPL(meson_codec_glue_capture_output_hw_params);
+
+static int meson_codec_glue_set_fmt(struct snd_soc_dai *dai,
+ unsigned int fmt,
+ bool playback)
{
struct meson_codec_glue_input *data =
- meson_codec_glue_input_get_data(dai);
+ meson_codec_glue_get_data(dai, playback);
/* Save the source stream format for the downstream link */
data->fmt = fmt;
return 0;
}
+
+int meson_codec_glue_input_set_fmt(struct snd_soc_dai *dai,
+ unsigned int fmt)
+{
+ return meson_codec_glue_set_fmt(dai, fmt, true);
+}
EXPORT_SYMBOL_GPL(meson_codec_glue_input_set_fmt);
-int meson_codec_glue_output_startup(struct snd_pcm_substream *substream,
- struct snd_soc_dai *dai)
+int meson_codec_glue_capture_output_set_fmt(struct snd_soc_dai *dai,
+ unsigned int fmt)
+{
+ return meson_codec_glue_set_fmt(dai, fmt, false);
+}
+EXPORT_SYMBOL_GPL(meson_codec_glue_capture_output_set_fmt);
+
+static int meson_codec_glue_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai,
+ bool playback)
{
+ int stream = playback ? SNDRV_PCM_STREAM_CAPTURE
+ : SNDRV_PCM_STREAM_PLAYBACK;
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
- struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget_capture(dai);
- struct meson_codec_glue_input *in_data = meson_codec_glue_output_get_input_data(w);
+ struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, stream);
+ struct meson_codec_glue_input *data = meson_codec_glue_data(w, playback);
- if (!in_data)
+ if (!data)
return -ENODEV;
if (WARN_ON(!rtd->dai_link->c2c_params)) {
@@ -111,14 +172,27 @@ int meson_codec_glue_output_startup(struct snd_pcm_substream *substream,
}
/* Replace link params with the input params */
- rtd->dai_link->c2c_params = &in_data->params;
+ rtd->dai_link->c2c_params = &data->params;
rtd->dai_link->num_c2c_params = 1;
- return snd_soc_runtime_set_dai_fmt(rtd, in_data->fmt);
+ return snd_soc_runtime_set_dai_fmt(rtd, data->fmt);
+}
+
+int meson_codec_glue_output_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ return meson_codec_glue_startup(substream, dai, true);
}
EXPORT_SYMBOL_GPL(meson_codec_glue_output_startup);
-int meson_codec_glue_input_dai_probe(struct snd_soc_dai *dai)
+int meson_codec_glue_capture_input_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ return meson_codec_glue_startup(substream, dai, false);
+}
+EXPORT_SYMBOL_GPL(meson_codec_glue_capture_input_startup);
+
+static int meson_codec_glue_dai_probe(struct snd_soc_dai *dai, bool playback)
{
struct meson_codec_glue_input *data;
@@ -126,21 +200,43 @@ int meson_codec_glue_input_dai_probe(struct snd_soc_dai *dai)
if (!data)
return -ENOMEM;
- meson_codec_glue_input_set_data(dai, data);
+ meson_codec_glue_set_data(dai, data, playback);
return 0;
}
+
+int meson_codec_glue_input_dai_probe(struct snd_soc_dai *dai)
+{
+ return meson_codec_glue_dai_probe(dai, true);
+}
EXPORT_SYMBOL_GPL(meson_codec_glue_input_dai_probe);
-int meson_codec_glue_input_dai_remove(struct snd_soc_dai *dai)
+int meson_codec_glue_capture_output_dai_probe(struct snd_soc_dai *dai)
+{
+ return meson_codec_glue_dai_probe(dai, false);
+}
+EXPORT_SYMBOL_GPL(meson_codec_glue_capture_output_dai_probe);
+
+static int meson_codec_glue_dai_remove(struct snd_soc_dai *dai, bool playback)
{
struct meson_codec_glue_input *data =
- meson_codec_glue_input_get_data(dai);
+ meson_codec_glue_get_data(dai, playback);
kfree(data);
return 0;
}
+
+int meson_codec_glue_input_dai_remove(struct snd_soc_dai *dai)
+{
+ return meson_codec_glue_dai_remove(dai, true);
+}
EXPORT_SYMBOL_GPL(meson_codec_glue_input_dai_remove);
+int meson_codec_glue_capture_output_dai_remove(struct snd_soc_dai *dai)
+{
+ return meson_codec_glue_dai_remove(dai, false);
+}
+EXPORT_SYMBOL_GPL(meson_codec_glue_capture_output_dai_remove);
+
MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
MODULE_DESCRIPTION("Amlogic Codec Glue Helpers");
MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/meson/meson-codec-glue.h b/sound/soc/meson/meson-codec-glue.h
index 07f99446c0c6..75d20aa75638 100644
--- a/sound/soc/meson/meson-codec-glue.h
+++ b/sound/soc/meson/meson-codec-glue.h
@@ -14,6 +14,10 @@ struct meson_codec_glue_input {
unsigned int fmt;
};
+/*
+ * Playback stream
+ */
+
/* Input helpers */
struct meson_codec_glue_input *
meson_codec_glue_input_get_data(struct snd_soc_dai *dai);
@@ -29,4 +33,23 @@ int meson_codec_glue_input_dai_remove(struct snd_soc_dai *dai);
int meson_codec_glue_output_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai);
+/*
+ * Capture stream
+ */
+
+/* Output helpers */
+struct meson_codec_glue_input *
+meson_codec_glue_capture_output_get_data(struct snd_soc_dai *dai);
+int meson_codec_glue_capture_output_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai);
+int meson_codec_glue_capture_output_set_fmt(struct snd_soc_dai *dai,
+ unsigned int fmt);
+int meson_codec_glue_capture_output_dai_probe(struct snd_soc_dai *dai);
+int meson_codec_glue_capture_output_dai_remove(struct snd_soc_dai *dai);
+
+/* Input helpers */
+int meson_codec_glue_capture_input_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai);
+
#endif /* _MESON_CODEC_GLUE_H */
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/4] ASoC: meson: g12a-toacodec: drop the definition of bits
2025-03-09 18:15 [PATCH v2 0/4] ASoC: meson: g12a-toacodec: add support for A1 SoC Jan Dakinevich
2025-03-09 18:15 ` [PATCH v2 1/4] ASoC: meson: codec-glue: add support for capture stream Jan Dakinevich
@ 2025-03-09 18:15 ` Jan Dakinevich
2025-03-10 2:02 ` kernel test robot
2025-03-09 18:15 ` [PATCH v2 3/4] ASoC: dt-bindings: meson: g12a-toacodec: add support for A1 SoC family Jan Dakinevich
2025-03-09 18:16 ` [PATCH v2 4/4] ASoC: " Jan Dakinevich
3 siblings, 1 reply; 7+ messages in thread
From: Jan Dakinevich @ 2025-03-09 18:15 UTC (permalink / raw)
To: Jan Dakinevich, Conor Dooley, devicetree, Jaroslav Kysela,
Jerome Brunet, Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, linux-kernel, linux-sound,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Rob Herring,
Takashi Iwai
There are many of defines, but several of them are unused, other are
used once. It would easier to read if these values would occure in the
place of their usage.
Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
---
Also, there was an another attempt to rework bits' definition:
https://lore.kernel.org/all/20240325235311.411920-1-jan.dakinevich@salutedevices.com/
---
sound/soc/meson/g12a-toacodec.c | 45 ++++++++-------------------------
1 file changed, 10 insertions(+), 35 deletions(-)
diff --git a/sound/soc/meson/g12a-toacodec.c b/sound/soc/meson/g12a-toacodec.c
index 531bb8707a3e..03bde8d8d192 100644
--- a/sound/soc/meson/g12a-toacodec.c
+++ b/sound/soc/meson/g12a-toacodec.c
@@ -20,26 +20,6 @@
#define G12A_TOACODEC_DRV_NAME "g12a-toacodec"
#define TOACODEC_CTRL0 0x0
-#define CTRL0_ENABLE_SHIFT 31
-#define CTRL0_DAT_SEL_SM1_MSB 19
-#define CTRL0_DAT_SEL_SM1_LSB 18
-#define CTRL0_DAT_SEL_MSB 15
-#define CTRL0_DAT_SEL_LSB 14
-#define CTRL0_LANE_SEL_SM1 16
-#define CTRL0_LANE_SEL 12
-#define CTRL0_LRCLK_SEL_SM1_MSB 14
-#define CTRL0_LRCLK_SEL_SM1_LSB 12
-#define CTRL0_LRCLK_SEL_MSB 9
-#define CTRL0_LRCLK_SEL_LSB 8
-#define CTRL0_LRCLK_INV_SM1 BIT(10)
-#define CTRL0_BLK_CAP_INV_SM1 BIT(9)
-#define CTRL0_BLK_CAP_INV BIT(7)
-#define CTRL0_BCLK_O_INV_SM1 BIT(8)
-#define CTRL0_BCLK_O_INV BIT(6)
-#define CTRL0_BCLK_SEL_SM1_MSB 6
-#define CTRL0_BCLK_SEL_MSB 5
-#define CTRL0_BCLK_SEL_LSB 4
-#define CTRL0_MCLK_SEL GENMASK(2, 0)
#define TOACODEC_OUT_CHMAX 2
@@ -69,6 +49,7 @@ static int g12a_toacodec_mux_put_enum(struct snd_kcontrol *kcontrol,
struct snd_soc_dapm_context *dapm =
snd_soc_dapm_kcontrol_dapm(kcontrol);
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+ unsigned int mclk_sel = GENMASK(2, 0);
unsigned int mux, reg;
if (ucontrol->value.enumerated.item[0] >= e->items)
@@ -98,21 +79,18 @@ static int g12a_toacodec_mux_put_enum(struct snd_kcontrol *kcontrol,
* source. For that, we will need regmap backed clock mux which
* is a work in progress
*/
- snd_soc_component_update_bits(component, e->reg,
- CTRL0_MCLK_SEL,
- FIELD_PREP(CTRL0_MCLK_SEL, mux));
+ snd_soc_component_update_bits(component, e->reg, mclk_sel,
+ FIELD_PREP(mclk_sel, mux));
snd_soc_dapm_mux_update_power(dapm, kcontrol, mux, e, NULL);
return 1;
}
-static SOC_ENUM_SINGLE_DECL(g12a_toacodec_mux_enum, TOACODEC_CTRL0,
- CTRL0_DAT_SEL_LSB,
+static SOC_ENUM_SINGLE_DECL(g12a_toacodec_mux_enum, TOACODEC_CTRL0, 14,
g12a_toacodec_mux_texts);
-static SOC_ENUM_SINGLE_DECL(sm1_toacodec_mux_enum, TOACODEC_CTRL0,
- CTRL0_DAT_SEL_SM1_LSB,
+static SOC_ENUM_SINGLE_DECL(sm1_toacodec_mux_enum, TOACODEC_CTRL0, 18,
g12a_toacodec_mux_texts);
static const struct snd_kcontrol_new g12a_toacodec_mux =
@@ -126,8 +104,7 @@ static const struct snd_kcontrol_new sm1_toacodec_mux =
g12a_toacodec_mux_put_enum);
static const struct snd_kcontrol_new g12a_toacodec_out_enable =
- SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0,
- CTRL0_ENABLE_SHIFT, 1, 0);
+ SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0, 31, 1, 0);
static const struct snd_soc_dapm_widget g12a_toacodec_widgets[] = {
SND_SOC_DAPM_MUX("SRC", SND_SOC_NOPM, 0, 0,
@@ -209,15 +186,13 @@ static struct snd_soc_dai_driver g12a_toacodec_dai_drv[] = {
static int g12a_toacodec_component_probe(struct snd_soc_component *c)
{
/* Initialize the static clock parameters */
- return snd_soc_component_write(c, TOACODEC_CTRL0,
- CTRL0_BLK_CAP_INV);
+ return snd_soc_component_write(c, TOACODEC_CTRL0, BIT(7));
}
static int sm1_toacodec_component_probe(struct snd_soc_component *c)
{
/* Initialize the static clock parameters */
- return snd_soc_component_write(c, TOACODEC_CTRL0,
- CTRL0_BLK_CAP_INV_SM1);
+ return snd_soc_component_write(c, TOACODEC_CTRL0, BIT(9));
}
static const struct snd_soc_dapm_route g12a_toacodec_routes[] = {
@@ -229,11 +204,11 @@ static const struct snd_soc_dapm_route g12a_toacodec_routes[] = {
};
static const struct snd_kcontrol_new g12a_toacodec_controls[] = {
- SOC_SINGLE("Lane Select", TOACODEC_CTRL0, CTRL0_LANE_SEL, 3, 0),
+ SOC_SINGLE("Lane Select", TOACODEC_CTRL0, 12, 3, 0),
};
static const struct snd_kcontrol_new sm1_toacodec_controls[] = {
- SOC_SINGLE("Lane Select", TOACODEC_CTRL0, CTRL0_LANE_SEL_SM1, 3, 0),
+ SOC_SINGLE("Lane Select", TOACODEC_CTRL0, 16, 3, 0),
};
static const struct snd_soc_component_driver g12a_toacodec_component_drv = {
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/4] ASoC: dt-bindings: meson: g12a-toacodec: add support for A1 SoC family
2025-03-09 18:15 [PATCH v2 0/4] ASoC: meson: g12a-toacodec: add support for A1 SoC Jan Dakinevich
2025-03-09 18:15 ` [PATCH v2 1/4] ASoC: meson: codec-glue: add support for capture stream Jan Dakinevich
2025-03-09 18:15 ` [PATCH v2 2/4] ASoC: meson: g12a-toacodec: drop the definition of bits Jan Dakinevich
@ 2025-03-09 18:15 ` Jan Dakinevich
2025-03-11 19:26 ` Rob Herring (Arm)
2025-03-09 18:16 ` [PATCH v2 4/4] ASoC: " Jan Dakinevich
3 siblings, 1 reply; 7+ messages in thread
From: Jan Dakinevich @ 2025-03-09 18:15 UTC (permalink / raw)
To: Jan Dakinevich, Conor Dooley, devicetree, Jaroslav Kysela,
Jerome Brunet, Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, linux-kernel, linux-sound,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Rob Herring,
Takashi Iwai
Add support for "toacodec" audio component found A1 SoC family. On this
SoC the component supports capture streams, additional DAI ids are added
to configure this feature.
Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
---
.../devicetree/bindings/sound/amlogic,g12a-toacodec.yaml | 1 +
include/dt-bindings/sound/meson-g12a-toacodec.h | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/amlogic,g12a-toacodec.yaml b/Documentation/devicetree/bindings/sound/amlogic,g12a-toacodec.yaml
index 23f82bb89750..c47604aa590f 100644
--- a/Documentation/devicetree/bindings/sound/amlogic,g12a-toacodec.yaml
+++ b/Documentation/devicetree/bindings/sound/amlogic,g12a-toacodec.yaml
@@ -26,6 +26,7 @@ properties:
- items:
- enum:
- amlogic,sm1-toacodec
+ - amlogic,a1-toacodec
- const: amlogic,g12a-toacodec
reg:
diff --git a/include/dt-bindings/sound/meson-g12a-toacodec.h b/include/dt-bindings/sound/meson-g12a-toacodec.h
index 69d7a75592a2..f726e2c6064d 100644
--- a/include/dt-bindings/sound/meson-g12a-toacodec.h
+++ b/include/dt-bindings/sound/meson-g12a-toacodec.h
@@ -7,4 +7,9 @@
#define TOACODEC_IN_C 2
#define TOACODEC_OUT 3
+#define TOACODEC_CAPTURE_OUT_A 4
+#define TOACODEC_CAPTURE_OUT_B 5
+#define TOACODEC_CAPTURE_OUT_C 6
+#define TOACODEC_CAPTURE_IN 7
+
#endif /* __DT_MESON_G12A_TOACODEC_H */
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/4] ASoC: meson: g12a-toacodec: add support for A1 SoC family
2025-03-09 18:15 [PATCH v2 0/4] ASoC: meson: g12a-toacodec: add support for A1 SoC Jan Dakinevich
` (2 preceding siblings ...)
2025-03-09 18:15 ` [PATCH v2 3/4] ASoC: dt-bindings: meson: g12a-toacodec: add support for A1 SoC family Jan Dakinevich
@ 2025-03-09 18:16 ` Jan Dakinevich
3 siblings, 0 replies; 7+ messages in thread
From: Jan Dakinevich @ 2025-03-09 18:16 UTC (permalink / raw)
To: Jan Dakinevich, Conor Dooley, devicetree, Jaroslav Kysela,
Jerome Brunet, Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, linux-kernel, linux-sound,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Rob Herring,
Takashi Iwai
Internal codec on A1 SoC has ADC and this commit adds support for
capturing from it.
Also, regmap now uses caching for all platforms. Values that are written
to toacodec's register on A1 SoC can not be read back, that breaks
regmap_update_bits() functionality. Let's hope the caching will not
break anything on other platforms. Since .max_register now is explicitly
equal to 0, .reg_stride is also removed.
Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
---
sound/soc/meson/g12a-toacodec.c | 197 +++++++++++++++++++++++++++++---
1 file changed, 184 insertions(+), 13 deletions(-)
diff --git a/sound/soc/meson/g12a-toacodec.c b/sound/soc/meson/g12a-toacodec.c
index 03bde8d8d192..431fcd364001 100644
--- a/sound/soc/meson/g12a-toacodec.c
+++ b/sound/soc/meson/g12a-toacodec.c
@@ -31,6 +31,8 @@ struct g12a_toacodec {
struct g12a_toacodec_match_data {
const struct snd_soc_component_driver *component_drv;
+ struct snd_soc_dai_driver *dai_drv;
+ int num_dai_drv;
struct reg_field field_dat_sel;
struct reg_field field_lrclk_sel;
struct reg_field field_bclk_sel;
@@ -40,6 +42,10 @@ static const char * const g12a_toacodec_mux_texts[] = {
"I2S A", "I2S B", "I2S C",
};
+static const char * const a1_toacodec_mux_texts[] = {
+ "I2S A", "I2S B",
+};
+
static int g12a_toacodec_mux_put_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
@@ -93,8 +99,11 @@ static SOC_ENUM_SINGLE_DECL(g12a_toacodec_mux_enum, TOACODEC_CTRL0, 14,
static SOC_ENUM_SINGLE_DECL(sm1_toacodec_mux_enum, TOACODEC_CTRL0, 18,
g12a_toacodec_mux_texts);
-static const struct snd_kcontrol_new g12a_toacodec_mux =
- SOC_DAPM_ENUM_EXT("Source", g12a_toacodec_mux_enum,
+static SOC_ENUM_SINGLE_DECL(a1_toacodec_mux_enum, TOACODEC_CTRL0, 19,
+ a1_toacodec_mux_texts);
+
+static const struct snd_kcontrol_new a1_toacodec_mux =
+ SOC_DAPM_ENUM_EXT("Source", a1_toacodec_mux_enum,
snd_soc_dapm_get_enum_double,
g12a_toacodec_mux_put_enum);
@@ -103,9 +112,20 @@ static const struct snd_kcontrol_new sm1_toacodec_mux =
snd_soc_dapm_get_enum_double,
g12a_toacodec_mux_put_enum);
+static const struct snd_kcontrol_new g12a_toacodec_mux =
+ SOC_DAPM_ENUM_EXT("Source", g12a_toacodec_mux_enum,
+ snd_soc_dapm_get_enum_double,
+ g12a_toacodec_mux_put_enum);
+
static const struct snd_kcontrol_new g12a_toacodec_out_enable =
SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0, 31, 1, 0);
+/* Don't use AUTODISABLE unlike G12A. On A1 it causes noise after playback
+ * is stopped.
+ */
+static const struct snd_kcontrol_new a1_toacodec_enable =
+ SOC_DAPM_SINGLE("Switch", TOACODEC_CTRL0, 31, 1, 0);
+
static const struct snd_soc_dapm_widget g12a_toacodec_widgets[] = {
SND_SOC_DAPM_MUX("SRC", SND_SOC_NOPM, 0, 0,
&g12a_toacodec_mux),
@@ -120,19 +140,34 @@ static const struct snd_soc_dapm_widget sm1_toacodec_widgets[] = {
&g12a_toacodec_out_enable),
};
-static int g12a_toacodec_input_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai)
+static const struct snd_soc_dapm_widget a1_toacodec_widgets[] = {
+ SND_SOC_DAPM_SWITCH("EN", SND_SOC_NOPM, 0, 0,
+ &a1_toacodec_enable),
+ SND_SOC_DAPM_MUX("Playback SRC", SND_SOC_NOPM, 0, 0,
+ &a1_toacodec_mux),
+ SND_SOC_DAPM_MUX("Capture SRC A", SND_SOC_NOPM, 0, 0,
+ &a1_toacodec_mux),
+ SND_SOC_DAPM_MUX("Capture SRC B", SND_SOC_NOPM, 0, 0,
+ &a1_toacodec_mux),
+};
+
+static int g12a_toacodec_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai,
+ bool playback)
{
struct meson_codec_glue_input *data;
int ret;
- ret = meson_codec_glue_input_hw_params(substream, params, dai);
+ ret = playback ? meson_codec_glue_input_hw_params(substream, params, dai)
+ : meson_codec_glue_capture_output_hw_params(substream,
+ params, dai);
if (ret)
return ret;
/* The glue will provide 1 lane out of the 4 to the output */
- data = meson_codec_glue_input_get_data(dai);
+ data = playback ? meson_codec_glue_input_get_data(dai)
+ : meson_codec_glue_capture_output_get_data(dai);
data->params.channels_min = min_t(unsigned int, TOACODEC_OUT_CHMAX,
data->params.channels_min);
data->params.channels_max = min_t(unsigned int, TOACODEC_OUT_CHMAX,
@@ -141,6 +176,21 @@ static int g12a_toacodec_input_hw_params(struct snd_pcm_substream *substream,
return 0;
}
+static int g12a_toacodec_input_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai)
+{
+ return g12a_toacodec_hw_params(substream, params, dai, true);
+}
+
+static int
+g12a_toacodec_capture_output_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai)
+{
+ return g12a_toacodec_hw_params(substream, params, dai, false);
+}
+
static const struct snd_soc_dai_ops g12a_toacodec_input_ops = {
.probe = meson_codec_glue_input_dai_probe,
.remove = meson_codec_glue_input_dai_remove,
@@ -152,6 +202,17 @@ static const struct snd_soc_dai_ops g12a_toacodec_output_ops = {
.startup = meson_codec_glue_output_startup,
};
+static const struct snd_soc_dai_ops g12a_toacodec_capture_output_ops = {
+ .probe = meson_codec_glue_capture_output_dai_probe,
+ .remove = meson_codec_glue_capture_output_dai_remove,
+ .hw_params = g12a_toacodec_capture_output_hw_params,
+ .set_fmt = meson_codec_glue_capture_output_set_fmt,
+};
+
+static const struct snd_soc_dai_ops g12a_toacodec_capture_input_ops = {
+ .startup = meson_codec_glue_capture_input_startup,
+};
+
#define TOACODEC_STREAM(xname, xsuffix, xchmax) \
{ \
.stream_name = xname " " xsuffix, \
@@ -176,6 +237,20 @@ static const struct snd_soc_dai_ops g12a_toacodec_output_ops = {
.ops = &g12a_toacodec_output_ops, \
}
+#define TOACODEC_CAPTURE_INPUT(xname, xid) { \
+ .name = xname, \
+ .id = (xid), \
+ .playback = TOACODEC_STREAM(xname, "Playback", 2), \
+ .ops = &g12a_toacodec_capture_input_ops, \
+}
+
+#define TOACODEC_CAPTURE_OUTPUT(xname, xid) { \
+ .name = xname, \
+ .id = (xid), \
+ .capture = TOACODEC_STREAM(xname, "Capture", 2), \
+ .ops = &g12a_toacodec_capture_output_ops, \
+}
+
static struct snd_soc_dai_driver g12a_toacodec_dai_drv[] = {
TOACODEC_INPUT("IN A", TOACODEC_IN_A),
TOACODEC_INPUT("IN B", TOACODEC_IN_B),
@@ -183,6 +258,16 @@ static struct snd_soc_dai_driver g12a_toacodec_dai_drv[] = {
TOACODEC_OUTPUT("OUT", TOACODEC_OUT),
};
+static struct snd_soc_dai_driver a1_toacodec_dai_drv[] = {
+ TOACODEC_INPUT("IN A", TOACODEC_IN_A),
+ TOACODEC_INPUT("IN B", TOACODEC_IN_B),
+ TOACODEC_OUTPUT("OUT", TOACODEC_OUT),
+
+ TOACODEC_CAPTURE_OUTPUT("OUT A", TOACODEC_CAPTURE_OUT_A),
+ TOACODEC_CAPTURE_OUTPUT("OUT B", TOACODEC_CAPTURE_OUT_B),
+ TOACODEC_CAPTURE_INPUT("IN", TOACODEC_CAPTURE_IN),
+};
+
static int g12a_toacodec_component_probe(struct snd_soc_component *c)
{
/* Initialize the static clock parameters */
@@ -195,6 +280,31 @@ static int sm1_toacodec_component_probe(struct snd_soc_component *c)
return snd_soc_component_write(c, TOACODEC_CTRL0, BIT(9));
}
+static int a1_toacodec_component_probe(struct snd_soc_component *c)
+{
+ /* Initialize the static clock parameters */
+ return snd_soc_component_write(c, TOACODEC_CTRL0, BIT(9));
+}
+
+static int a1_toacodec_of_xlate_dai_name(struct snd_soc_component *component,
+ const struct of_phandle_args *args,
+ const char **dai_name)
+{
+ struct snd_soc_dai *dai;
+
+ if (args->args_count != 1)
+ return -EINVAL;
+
+ for_each_component_dais(component, dai) {
+ if (dai->id == args->args[0]) {
+ *dai_name = dai->driver->name;
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+}
+
static const struct snd_soc_dapm_route g12a_toacodec_routes[] = {
{ "SRC", "I2S A", "IN A Playback" },
{ "SRC", "I2S B", "IN B Playback" },
@@ -203,6 +313,19 @@ static const struct snd_soc_dapm_route g12a_toacodec_routes[] = {
{ "OUT Capture", NULL, "OUT EN" },
};
+static const struct snd_soc_dapm_route a1_toacodec_routes[] = {
+ { "Playback SRC", "I2S A", "IN A Playback" },
+ { "Playback SRC", "I2S B", "IN B Playback" },
+ { "EN", "Switch", "Playback SRC" },
+ { "OUT Capture", NULL, "Playback SRC" },
+
+ { "EN", "Switch", "IN Playback" },
+ { "Capture SRC A", "I2S A", "EN" },
+ { "Capture SRC B", "I2S B", "EN" },
+ { "OUT A Capture", NULL, "Capture SRC A" },
+ { "OUT B Capture", NULL, "Capture SRC B" },
+};
+
static const struct snd_kcontrol_new g12a_toacodec_controls[] = {
SOC_SINGLE("Lane Select", TOACODEC_CTRL0, 12, 3, 0),
};
@@ -211,6 +334,10 @@ static const struct snd_kcontrol_new sm1_toacodec_controls[] = {
SOC_SINGLE("Lane Select", TOACODEC_CTRL0, 16, 3, 0),
};
+static const struct snd_kcontrol_new a1_toacodec_controls[] = {
+ SOC_SINGLE("Lane Select", TOACODEC_CTRL0, 16, 3, 0),
+};
+
static const struct snd_soc_component_driver g12a_toacodec_component_drv = {
.probe = g12a_toacodec_component_probe,
.controls = g12a_toacodec_controls,
@@ -233,14 +360,43 @@ static const struct snd_soc_component_driver sm1_toacodec_component_drv = {
.endianness = 1,
};
+static const struct snd_soc_component_driver a1_toacodec_component_drv = {
+ .probe = a1_toacodec_component_probe,
+ .of_xlate_dai_name = a1_toacodec_of_xlate_dai_name,
+ .controls = a1_toacodec_controls,
+ .num_controls = ARRAY_SIZE(a1_toacodec_controls),
+ .dapm_widgets = a1_toacodec_widgets,
+ .num_dapm_widgets = ARRAY_SIZE(a1_toacodec_widgets),
+ .dapm_routes = a1_toacodec_routes,
+ .num_dapm_routes = ARRAY_SIZE(a1_toacodec_routes),
+ .endianness = 1,
+};
+
+static const struct reg_default g12a_toacodec_reg_default[] = {
+ { TOACODEC_CTRL0, 0x0 },
+};
+
+static bool g12_toacodec_readable_reg(struct device *dev, unsigned int reg)
+{
+ /* There are no readable registers */
+ return false;
+}
+
static const struct regmap_config g12a_toacodec_regmap_cfg = {
- .reg_bits = 32,
- .val_bits = 32,
- .reg_stride = 4,
+ .reg_bits = 32,
+ .val_bits = 32,
+ .max_register = TOACODEC_CTRL0,
+ .max_register_is_0 = true,
+ .cache_type = REGCACHE_FLAT,
+ .reg_defaults = g12a_toacodec_reg_default,
+ .num_reg_defaults = ARRAY_SIZE(g12a_toacodec_reg_default),
+ .readable_reg = g12_toacodec_readable_reg,
};
static const struct g12a_toacodec_match_data g12a_toacodec_match_data = {
.component_drv = &g12a_toacodec_component_drv,
+ .dai_drv = g12a_toacodec_dai_drv,
+ .num_dai_drv = ARRAY_SIZE(g12a_toacodec_dai_drv),
.field_dat_sel = REG_FIELD(TOACODEC_CTRL0, 14, 15),
.field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 8, 9),
.field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 5),
@@ -248,11 +404,22 @@ static const struct g12a_toacodec_match_data g12a_toacodec_match_data = {
static const struct g12a_toacodec_match_data sm1_toacodec_match_data = {
.component_drv = &sm1_toacodec_component_drv,
+ .dai_drv = g12a_toacodec_dai_drv,
+ .num_dai_drv = ARRAY_SIZE(g12a_toacodec_dai_drv),
.field_dat_sel = REG_FIELD(TOACODEC_CTRL0, 18, 19),
.field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 12, 14),
.field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 6),
};
+static const struct g12a_toacodec_match_data a1_toacodec_match_data = {
+ .component_drv = &a1_toacodec_component_drv,
+ .dai_drv = a1_toacodec_dai_drv,
+ .num_dai_drv = ARRAY_SIZE(a1_toacodec_dai_drv),
+ .field_dat_sel = REG_FIELD(TOACODEC_CTRL0, 19, 19),
+ .field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 12, 14),
+ .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 6),
+};
+
static const struct of_device_id g12a_toacodec_of_match[] = {
{
.compatible = "amlogic,g12a-toacodec",
@@ -262,6 +429,10 @@ static const struct of_device_id g12a_toacodec_of_match[] = {
.compatible = "amlogic,sm1-toacodec",
.data = &sm1_toacodec_match_data,
},
+ {
+ .compatible = "amlogic,a1-toacodec",
+ .data = &a1_toacodec_match_data,
+ },
{}
};
MODULE_DEVICE_TABLE(of, g12a_toacodec_of_match);
@@ -314,9 +485,9 @@ static int g12a_toacodec_probe(struct platform_device *pdev)
if (IS_ERR(priv->field_bclk_sel))
return PTR_ERR(priv->field_bclk_sel);
- return devm_snd_soc_register_component(dev,
- data->component_drv, g12a_toacodec_dai_drv,
- ARRAY_SIZE(g12a_toacodec_dai_drv));
+ return devm_snd_soc_register_component(dev, data->component_drv,
+ data->dai_drv,
+ data->num_dai_drv);
}
static struct platform_driver g12a_toacodec_pdrv = {
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/4] ASoC: meson: g12a-toacodec: drop the definition of bits
2025-03-09 18:15 ` [PATCH v2 2/4] ASoC: meson: g12a-toacodec: drop the definition of bits Jan Dakinevich
@ 2025-03-10 2:02 ` kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2025-03-10 2:02 UTC (permalink / raw)
To: Jan Dakinevich, Conor Dooley, devicetree, Jaroslav Kysela,
Jerome Brunet, Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, linux-kernel, linux-sound,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Rob Herring,
Takashi Iwai
Cc: llvm, oe-kbuild-all
Hi Jan,
kernel test robot noticed the following build warnings:
[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on linus/master v6.14-rc5 next-20250307]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jan-Dakinevich/ASoC-meson-codec-glue-add-support-for-capture-stream/20250310-022013
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link: https://lore.kernel.org/r/20250309181600.1322701-3-jan.dakinevich%40salutedevices.com
patch subject: [PATCH v2 2/4] ASoC: meson: g12a-toacodec: drop the definition of bits
config: i386-buildonly-randconfig-005-20250310 (https://download.01.org/0day-ci/archive/20250310/202503100909.xnqNYW9u-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250310/202503100909.xnqNYW9u-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503100909.xnqNYW9u-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> sound/soc/meson/g12a-toacodec.c:83:11: warning: result of comparison of constant 18446744073709551615 with expression of type 'typeof (_Generic((mclk_sel), char: (unsigned char)0, unsigned char: (unsigned char)0, signed char: (unsigned char)0, unsigned short: (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long: (unsigned long)0, unsigned long long: (unsigned long long)0, long long: (unsigned long long)0, default: (mclk_sel)))' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
83 | FIELD_PREP(mclk_sel, mux));
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:115:3: note: expanded from macro 'FIELD_PREP'
115 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:72:53: note: expanded from macro '__BF_FIELD_CHECK'
72 | BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask) > \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
73 | __bf_cast_unsigned(_reg, ~0ull), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 | _pfx "type of reg too small for mask"); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
include/linux/compiler_types.h:542:22: note: expanded from macro 'compiletime_assert'
542 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:530:23: note: expanded from macro '_compiletime_assert'
530 | __compiletime_assert(condition, msg, prefix, suffix)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:522:9: note: expanded from macro '__compiletime_assert'
522 | if (!(condition)) \
| ^~~~~~~~~
1 warning generated.
vim +83 sound/soc/meson/g12a-toacodec.c
42
43 static int g12a_toacodec_mux_put_enum(struct snd_kcontrol *kcontrol,
44 struct snd_ctl_elem_value *ucontrol)
45 {
46 struct snd_soc_component *component =
47 snd_soc_dapm_kcontrol_component(kcontrol);
48 struct g12a_toacodec *priv = snd_soc_component_get_drvdata(component);
49 struct snd_soc_dapm_context *dapm =
50 snd_soc_dapm_kcontrol_dapm(kcontrol);
51 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
52 unsigned int mclk_sel = GENMASK(2, 0);
53 unsigned int mux, reg;
54
55 if (ucontrol->value.enumerated.item[0] >= e->items)
56 return -EINVAL;
57
58 mux = snd_soc_enum_item_to_val(e, ucontrol->value.enumerated.item[0]);
59 regmap_field_read(priv->field_dat_sel, ®);
60
61 if (mux == reg)
62 return 0;
63
64 /* Force disconnect of the mux while updating */
65 snd_soc_dapm_mux_update_power(dapm, kcontrol, 0, NULL, NULL);
66
67 regmap_field_write(priv->field_dat_sel, mux);
68 regmap_field_write(priv->field_lrclk_sel, mux);
69 regmap_field_write(priv->field_bclk_sel, mux);
70
71 /*
72 * FIXME:
73 * On this soc, the glue gets the MCLK directly from the clock
74 * controller instead of going the through the TDM interface.
75 *
76 * Here we assume interface A uses clock A, etc ... While it is
77 * true for now, it could be different. Instead the glue should
78 * find out the clock used by the interface and select the same
79 * source. For that, we will need regmap backed clock mux which
80 * is a work in progress
81 */
82 snd_soc_component_update_bits(component, e->reg, mclk_sel,
> 83 FIELD_PREP(mclk_sel, mux));
84
85 snd_soc_dapm_mux_update_power(dapm, kcontrol, mux, e, NULL);
86
87 return 1;
88 }
89
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/4] ASoC: dt-bindings: meson: g12a-toacodec: add support for A1 SoC family
2025-03-09 18:15 ` [PATCH v2 3/4] ASoC: dt-bindings: meson: g12a-toacodec: add support for A1 SoC family Jan Dakinevich
@ 2025-03-11 19:26 ` Rob Herring (Arm)
0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring (Arm) @ 2025-03-11 19:26 UTC (permalink / raw)
To: Jan Dakinevich
Cc: Neil Armstrong, Liam Girdwood, Jaroslav Kysela, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, linux-amlogic, Conor Dooley,
linux-kernel, linux-sound, Mark Brown, Krzysztof Kozlowski,
Takashi Iwai, linux-arm-kernel, devicetree
On Sun, 09 Mar 2025 21:15:59 +0300, Jan Dakinevich wrote:
> Add support for "toacodec" audio component found A1 SoC family. On this
> SoC the component supports capture streams, additional DAI ids are added
> to configure this feature.
>
> Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
> ---
> .../devicetree/bindings/sound/amlogic,g12a-toacodec.yaml | 1 +
> include/dt-bindings/sound/meson-g12a-toacodec.h | 5 +++++
> 2 files changed, 6 insertions(+)
>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-03-11 19:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-09 18:15 [PATCH v2 0/4] ASoC: meson: g12a-toacodec: add support for A1 SoC Jan Dakinevich
2025-03-09 18:15 ` [PATCH v2 1/4] ASoC: meson: codec-glue: add support for capture stream Jan Dakinevich
2025-03-09 18:15 ` [PATCH v2 2/4] ASoC: meson: g12a-toacodec: drop the definition of bits Jan Dakinevich
2025-03-10 2:02 ` kernel test robot
2025-03-09 18:15 ` [PATCH v2 3/4] ASoC: dt-bindings: meson: g12a-toacodec: add support for A1 SoC family Jan Dakinevich
2025-03-11 19:26 ` Rob Herring (Arm)
2025-03-09 18:16 ` [PATCH v2 4/4] ASoC: " Jan Dakinevich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox