ASoC: Intel: avs: rt5682: Add missing components

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>
This commit is contained in:
Cezary Rojewski 2023-06-29 13:24:48 +02:00 committed by Mark Brown
parent 3ed180ac3c
commit 27cd41698d
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 24 additions and 8 deletions

View File

@ -79,14 +79,31 @@ static const struct snd_soc_dapm_route card_base_routes[] = {
{ "IN1P", NULL, "Headset Mic" }, { "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) 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_component *component = asoc_rtd_to_codec(runtime, 0)->component;
struct snd_soc_jack *jack;
struct snd_soc_card *card = runtime->card; 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); 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 */ /* Need to enable ASRC function for 24MHz mclk rate */
if ((avs_rt5682_quirk & AVS_RT5682_MCLK_EN) && 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); RT5682_AD_STEREO1_FILTER, RT5682_CLK_SEL_I2S1_ASRC);
} }
/*
* Headset buttons map to the google Reference headset. ret = snd_soc_card_jack_new_pins(card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_BTN_0 |
* These can be configured by userspace. SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3, jack,
*/ pins, num_pins);
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);
if (ret) { if (ret) {
dev_err(card->dev, "Headset Jack creation failed: %d\n", ret); dev_err(card->dev, "Headset Jack creation failed: %d\n", ret);
return 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->platforms = platform;
dl->num_platforms = 1; dl->num_platforms = 1;
dl->id = 0; 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->init = avs_rt5682_codec_init;
dl->exit = avs_rt5682_codec_exit; dl->exit = avs_rt5682_codec_exit;
dl->be_hw_params_fixup = avs_rt5682_be_fixup; dl->be_hw_params_fixup = avs_rt5682_be_fixup;