ASoC: Intel: avs: rt5682: Add missing components
authorCezary Rojewski <cezary.rojewski@intel.com>
Thu, 29 Jun 2023 11:24:48 +0000 (13:24 +0200)
committerMark Brown <broonie@kernel.org>
Sun, 9 Jul 2023 21:47:22 +0000 (22:47 +0100)
Align with what's done for all other boards and allocate jacks pins
dynamically and explicitly specify ->dai_fmt for the DAI link.

The latter clears any ambiguity - given the current implementation
of the codec driver, specifying format is optional but should the
implementation change, the sound card behaviour may be undesired.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20230629112449.1755928-8-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/avs/boards/rt5682.c

index 7142a67..bd0902b 100644 (file)
@@ -79,14 +79,31 @@ static const struct snd_soc_dapm_route card_base_routes[] = {
        { "IN1P", NULL, "Headset Mic" },
 };
 
+static struct snd_soc_jack_pin card_jack_pins[] = {
+       {
+               .pin = "Headphone Jack",
+               .mask = SND_JACK_HEADPHONE,
+       },
+       {
+               .pin = "Headset Mic",
+               .mask = SND_JACK_MICROPHONE,
+       },
+};
+
 static int avs_rt5682_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
        struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
-       struct snd_soc_jack *jack;
        struct snd_soc_card *card = runtime->card;
-       int ret;
+       struct snd_soc_jack_pin *pins;
+       struct snd_soc_jack *jack;
+       int num_pins, ret;
 
        jack = snd_soc_card_get_drvdata(card);
+       num_pins = ARRAY_SIZE(card_jack_pins);
+
+       pins = devm_kmemdup(card->dev, card_jack_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
+       if (!pins)
+               return -ENOMEM;
 
        /* Need to enable ASRC function for 24MHz mclk rate */
        if ((avs_rt5682_quirk & AVS_RT5682_MCLK_EN) &&
@@ -95,12 +112,10 @@ static int avs_rt5682_codec_init(struct snd_soc_pcm_runtime *runtime)
                                        RT5682_AD_STEREO1_FILTER, RT5682_CLK_SEL_I2S1_ASRC);
        }
 
-       /*
-        * Headset buttons map to the google Reference headset.
-        * These can be configured by userspace.
-        */
-       ret = snd_soc_card_jack_new(card, "Headset", SND_JACK_HEADSET | SND_JACK_BTN_0 |
-                                   SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3, jack);
+
+       ret = snd_soc_card_jack_new_pins(card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_BTN_0 |
+                                        SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3, jack,
+                                        pins, num_pins);
        if (ret) {
                dev_err(card->dev, "Headset Jack creation failed: %d\n", ret);
                return ret;
@@ -220,6 +235,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
        dl->platforms = platform;
        dl->num_platforms = 1;
        dl->id = 0;
+       dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC;
        dl->init = avs_rt5682_codec_init;
        dl->exit = avs_rt5682_codec_exit;
        dl->be_hw_params_fixup = avs_rt5682_be_fixup;