Thread (4 messages) 4 messages, 3 authors, 2021-05-19

Re: [PATCH] ASoC: meson: g12a-toacodec: add support for SM1 TOACODEC

From: Neil Armstrong <hidden>
Date: 2021-04-30 08:31:19
Also in: alsa-devel, linux-amlogic, lkml

On 29/04/2021 19:43, Jerome Brunet wrote:
On Thu 29 Apr 2021 at 19:01, Neil Armstrong [off-list ref] wrote:

quoted
 
+static int sm1_toacodec_mux_put_enum(struct snd_kcontrol *kcontrol,
+				     struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_dapm_kcontrol_component(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 mux, changed;
+
+	mux = snd_soc_enum_item_to_val(e, ucontrol->value.enumerated.item[0]);
+	changed = snd_soc_component_test_bits(component, e->reg,
+					      CTRL0_DAT_SEL_SM1,
+					      FIELD_PREP(CTRL0_DAT_SEL_SM1, mux));
+
+	if (!changed)
+		return 0;
+
+	/* Force disconnect of the mux while updating */
+	snd_soc_dapm_mux_update_power(dapm, kcontrol, 0, NULL, NULL);
+
+	snd_soc_component_update_bits(component, e->reg,
+				      CTRL0_DAT_SEL_SM1 |
+				      CTRL0_LRCLK_SEL_SM1 |
+				      CTRL0_BCLK_SEL_SM1,
+				      FIELD_PREP(CTRL0_DAT_SEL_SM1, mux) |
+				      FIELD_PREP(CTRL0_LRCLK_SEL_SM1, mux) |
+				      FIELD_PREP(CTRL0_BCLK_SEL_SM1, mux));
+
+	/*
+	 * FIXME:
+	 * On this soc, the glue gets the MCLK directly from the clock
+	 * controller instead of going the through the TDM interface.
+	 *
+	 * Here we assume interface A uses clock A, etc ... While it is
+	 * true for now, it could be different. Instead the glue should
+	 * find out the clock used by the interface and select the same
+	 * 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_dapm_mux_update_power(dapm, kcontrol, mux, e, NULL);
+
+	return 0;
+}
Instead of duplicating this function, I'd prefer if you could use regmap fields
Sure, will do

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help