[PATCH] ASoC: meson: g12a-toacodec: add support for SM1 TOACODEC
Neil Armstrong
narmstrong at baylibre.com
Fri Apr 30 10:31:13 CEST 2021
On 29/04/2021 19:43, Jerome Brunet wrote:
>
> On Thu 29 Apr 2021 at 19:01, Neil Armstrong <narmstrong at baylibre.com> wrote:
>
>
>>
>> +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
More information about the Alsa-devel
mailing list