]> git.itanic.dy.fi Git - linux-stable/commitdiff
ASoC: rt5645: Add a rt5645_components() helper
authorHans de Goede <hdegoede@redhat.com>
Sun, 26 Nov 2023 21:40:22 +0000 (22:40 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 21 Dec 2023 21:00:46 +0000 (21:00 +0000)
The rt5645 codec driver uses DMI quirks to configure the DMIC data-pins,
which means that it knows which DMIC interface is used on a specific
device.

ATM we duplicate this DMI matching inside the UCM profiles to select
the right DMIC interface. Add a rt5645_components() helper which the
machine-driver can use to set the components string of the card so
that UCM can get the info from the components string.

This way we only need to add new DMI quirks in one place.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://msgid.link/r/20231126214024.300505-6-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt5645.c
sound/soc/codecs/rt5645.h

index f79a447eaffeac45007bdd790a7776f7fad101d4..4f3ef004f555037bfdae502bd236de2fa80c0dcb 100644 (file)
@@ -3902,6 +3902,30 @@ static void rt5645_get_pdata(struct device *codec_dev, struct rt5645_platform_da
        }
 }
 
+const char *rt5645_components(struct device *codec_dev)
+{
+       struct rt5645_platform_data pdata = { };
+       static char buf[32];
+       const char *mic;
+       int spk = 2;
+
+       rt5645_get_pdata(codec_dev, &pdata);
+
+       if (pdata.dmic1_data_pin && pdata.dmic2_data_pin)
+               mic = "dmics12";
+       else if (pdata.dmic1_data_pin)
+               mic = "dmic1";
+       else if (pdata.dmic2_data_pin)
+               mic = "dmic2";
+       else
+               mic = "in2";
+
+       snprintf(buf, sizeof(buf), "cfg-spk:%d cfg-mic:%s", spk, mic);
+
+       return buf;
+}
+EXPORT_SYMBOL_GPL(rt5645_components);
+
 static int rt5645_i2c_probe(struct i2c_client *i2c)
 {
        struct rt5645_priv *rt5645;
index ac3de6f3bc2f027738a0266f71ac514296fa6083..90816b2c5489fa8141113d171a7eae9310606dfc 100644 (file)
@@ -2201,4 +2201,7 @@ int rt5645_sel_asrc_clk_src(struct snd_soc_component *component,
 int rt5645_set_jack_detect(struct snd_soc_component *component,
        struct snd_soc_jack *hp_jack, struct snd_soc_jack *mic_jack,
        struct snd_soc_jack *btn_jack);
+
+const char *rt5645_components(struct device *codec_dev);
+
 #endif /* __RT5645_H__ */