From: Bard Liao yung-chuan.liao@linux.intel.com
Let rename rt711_sdca to rt_sdca_jack and let it be used for all Realtek sdca jacks. The commit uses component->name_prefix to construct card->components, and determine which codec it is. So, we have to set name_prefix properly.
Signed-off-by: Bard Liao yung-chuan.liao@linux.intel.com Signed-off-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com --- sound/soc/intel/boards/Makefile | 2 +- sound/soc/intel/boards/sof_sdw.c | 4 +- sound/soc/intel/boards/sof_sdw_common.h | 12 ++-- ...1_sdca.c => sof_sdw_rt_sdca_jack_common.c} | 57 ++++++++++--------- 4 files changed, 40 insertions(+), 35 deletions(-) rename sound/soc/intel/boards/{sof_sdw_rt711_sdca.c => sof_sdw_rt_sdca_jack_common.c} (68%)
diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index d1fd7a2b32db..7fa45569cfb1 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -39,7 +39,7 @@ snd-soc-sof-ssp-amp-objs := sof_ssp_amp.o snd-soc-sof-sdw-objs += sof_sdw.o \ sof_sdw_max98373.o sof_sdw_rt_amp.o \ sof_sdw_rt5682.o sof_sdw_rt700.o \ - sof_sdw_rt711.o sof_sdw_rt711_sdca.o \ + sof_sdw_rt711.o sof_sdw_rt_sdca_jack_common.o \ sof_sdw_rt715.o sof_sdw_rt715_sdca.o \ sof_sdw_dmic.o sof_sdw_hdmi.o obj-$(CONFIG_SND_SOC_INTEL_SOF_RT5682_MACH) += snd-soc-sof_rt5682.o diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index d925e3005394..8310fb094d15 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -583,8 +583,8 @@ static struct sof_sdw_codec_info codec_info_list[] = { .dai_name = "rt711-sdca-aif1", .dai_type = SOF_SDW_DAI_TYPE_JACK, .dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID}, - .init = sof_sdw_rt711_sdca_init, - .exit = sof_sdw_rt711_sdca_exit, + .init = sof_sdw_rt_sdca_jack_init, + .exit = sof_sdw_rt_sdca_jack_exit, }, }, .dai_num = 1, diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h index 9640fd6dbd12..bc9dfa626c32 100644 --- a/sound/soc/intel/boards/sof_sdw_common.h +++ b/sound/soc/intel/boards/sof_sdw_common.h @@ -123,12 +123,12 @@ int sof_sdw_rt711_init(struct snd_soc_card *card, int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
/* RT711-SDCA support */ -int sof_sdw_rt711_sdca_init(struct snd_soc_card *card, - const struct snd_soc_acpi_link_adr *link, - struct snd_soc_dai_link *dai_links, - struct sof_sdw_codec_info *info, - bool playback); -int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); +int sof_sdw_rt_sdca_jack_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, + struct snd_soc_dai_link *dai_links, + struct sof_sdw_codec_info *info, + bool playback); +int sof_sdw_rt_sdca_jack_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
/* RT700 support */ int sof_sdw_rt700_init(struct snd_soc_card *card, diff --git a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c b/sound/soc/intel/boards/sof_sdw_rt_sdca_jack_common.c similarity index 68% rename from sound/soc/intel/boards/sof_sdw_rt711_sdca.c rename to sound/soc/intel/boards/sof_sdw_rt_sdca_jack_common.c index a9ae0aa5ce0a..399f28a79110 100644 --- a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c +++ b/sound/soc/intel/boards/sof_sdw_rt_sdca_jack_common.c @@ -21,7 +21,7 @@ * Note this MUST be called before snd_soc_register_card(), so that the props * are in place before the codec component driver's probe function parses them. */ -static int rt711_sdca_add_codec_device_props(struct device *sdw_dev) +static int rt_sdca_jack_add_codec_device_props(struct device *sdw_dev) { struct property_entry props[MAX_NO_PROPS] = {}; struct fwnode_handle *fwnode; @@ -43,7 +43,7 @@ static int rt711_sdca_add_codec_device_props(struct device *sdw_dev) return ret; }
-static const struct snd_soc_dapm_widget rt711_sdca_widgets[] = { +static const struct snd_soc_dapm_widget rt_sdca_jack_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), }; @@ -54,12 +54,12 @@ static const struct snd_soc_dapm_route rt711_sdca_map[] = { { "rt711 MIC2", NULL, "Headset Mic" }, };
-static const struct snd_kcontrol_new rt711_sdca_controls[] = { +static const struct snd_kcontrol_new rt_sdca_jack_controls[] = { SOC_DAPM_PIN_SWITCH("Headphone"), SOC_DAPM_PIN_SWITCH("Headset Mic"), };
-static struct snd_soc_jack_pin rt711_sdca_jack_pins[] = { +static struct snd_soc_jack_pin rt_sdca_jack_pins[] = { { .pin = "Headphone", .mask = SND_JACK_HEADPHONE, @@ -70,7 +70,7 @@ static struct snd_soc_jack_pin rt711_sdca_jack_pins[] = { }, };
-static int rt711_sdca_rtd_init(struct snd_soc_pcm_runtime *rtd) +static int rt_sdca_jack_rtd_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_card *card = rtd->card; struct mc_private *ctx = snd_soc_card_get_drvdata(card); @@ -80,30 +80,35 @@ static int rt711_sdca_rtd_init(struct snd_soc_pcm_runtime *rtd) int ret;
card->components = devm_kasprintf(card->dev, GFP_KERNEL, - "%s hs:rt711-sdca", - card->components); + "%s hs:%s-sdca", + card->components, component->name_prefix); if (!card->components) return -ENOMEM;
- ret = snd_soc_add_card_controls(card, rt711_sdca_controls, - ARRAY_SIZE(rt711_sdca_controls)); + ret = snd_soc_add_card_controls(card, rt_sdca_jack_controls, + ARRAY_SIZE(rt_sdca_jack_controls)); if (ret) { - dev_err(card->dev, "rt711-sdca controls addition failed: %d\n", ret); + dev_err(card->dev, "rt sdca jack controls addition failed: %d\n", ret); return ret; }
- ret = snd_soc_dapm_new_controls(&card->dapm, rt711_sdca_widgets, - ARRAY_SIZE(rt711_sdca_widgets)); + ret = snd_soc_dapm_new_controls(&card->dapm, rt_sdca_jack_widgets, + ARRAY_SIZE(rt_sdca_jack_widgets)); if (ret) { - dev_err(card->dev, "rt711-sdca widgets addition failed: %d\n", ret); + dev_err(card->dev, "rt sdca jack widgets addition failed: %d\n", ret); return ret; }
- ret = snd_soc_dapm_add_routes(&card->dapm, rt711_sdca_map, - ARRAY_SIZE(rt711_sdca_map)); + if (strstr(component->name_prefix, "rt711")) { + ret = snd_soc_dapm_add_routes(&card->dapm, rt711_sdca_map, + ARRAY_SIZE(rt711_sdca_map)); + } else { + dev_err(card->dev, "%s is not supported\n", component->name_prefix); + return -EINVAL; + }
if (ret) { - dev_err(card->dev, "rt711-sdca map addition failed: %d\n", ret); + dev_err(card->dev, "rt sdca jack map addition failed: %d\n", ret); return ret; }
@@ -112,8 +117,8 @@ static int rt711_sdca_rtd_init(struct snd_soc_pcm_runtime *rtd) SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3, &ctx->sdw_headset, - rt711_sdca_jack_pins, - ARRAY_SIZE(rt711_sdca_jack_pins)); + rt_sdca_jack_pins, + ARRAY_SIZE(rt_sdca_jack_pins)); if (ret) { dev_err(rtd->card->dev, "Headset Jack creation failed: %d\n", ret); @@ -136,7 +141,7 @@ static int rt711_sdca_rtd_init(struct snd_soc_pcm_runtime *rtd) return ret; }
-int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) +int sof_sdw_rt_sdca_jack_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { struct mc_private *ctx = snd_soc_card_get_drvdata(card);
@@ -152,11 +157,11 @@ int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link * return 0; }
-int sof_sdw_rt711_sdca_init(struct snd_soc_card *card, - const struct snd_soc_acpi_link_adr *link, - struct snd_soc_dai_link *dai_links, - struct sof_sdw_codec_info *info, - bool playback) +int sof_sdw_rt_sdca_jack_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, + struct snd_soc_dai_link *dai_links, + struct sof_sdw_codec_info *info, + bool playback) { struct mc_private *ctx = snd_soc_card_get_drvdata(card); struct device *sdw_dev; @@ -173,14 +178,14 @@ int sof_sdw_rt711_sdca_init(struct snd_soc_card *card, if (!sdw_dev) return -EPROBE_DEFER;
- ret = rt711_sdca_add_codec_device_props(sdw_dev); + ret = rt_sdca_jack_add_codec_device_props(sdw_dev); if (ret < 0) { put_device(sdw_dev); return ret; } ctx->headset_codec_dev = sdw_dev;
- dai_links->init = rt711_sdca_rtd_init; + dai_links->init = rt_sdca_jack_rtd_init;
return 0; }