From: Uday M Bhat <uday.m.bhat@xxxxxxxxx> Init function and structure names are modified to use maxim instead of max98373. Card components and speaker names are updated based on part id. Reviewed-by: Ranjani Sridharan <ranjani.sridharan@xxxxxxxxxxxxxxx> Signed-off-by: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx> Signed-off-by: Yong Zhi <yong.zhi@xxxxxxxxx> Signed-off-by: Uday M Bhat <uday.m.bhat@xxxxxxxxx> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx> --- sound/soc/intel/boards/sof_sdw.c | 2 +- sound/soc/intel/boards/sof_sdw_common.h | 12 +++--- sound/soc/intel/boards/sof_sdw_maxim.c | 52 +++++++++++++++---------- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index 60ce8100e1dc..04d050eac00d 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -805,7 +805,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { .dai_name = "max98373-aif1", .dai_type = SOF_SDW_DAI_TYPE_AMP, .dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID}, - .init = sof_sdw_mx8373_init, + .init = sof_sdw_maxim_init, }, }, .dai_num = 1, diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h index f98d1ded5b1a..64cfa5d1aceb 100644 --- a/sound/soc/intel/boards/sof_sdw_common.h +++ b/sound/soc/intel/boards/sof_sdw_common.h @@ -182,12 +182,12 @@ int sof_sdw_rt715_sdca_init(struct snd_soc_card *card, struct sof_sdw_codec_info *info, bool playback); -/* MAX98373 support */ -int sof_sdw_mx8373_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); +/* MAXIM codec support */ +int sof_sdw_maxim_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); /* RT5682 support */ int sof_sdw_rt5682_init(struct snd_soc_card *card, diff --git a/sound/soc/intel/boards/sof_sdw_maxim.c b/sound/soc/intel/boards/sof_sdw_maxim.c index 3d7df58c0f1d..3cc47ae98c5e 100644 --- a/sound/soc/intel/boards/sof_sdw_maxim.c +++ b/sound/soc/intel/boards/sof_sdw_maxim.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only // Copyright (c) 2020 Intel Corporation // -// sof_sdw_max98373 - Helpers to handle 2x MAX98373 +// sof_sdw_maxim - Helpers to handle maxim codecs // codec devices from generic machine driver #include <linux/device.h> @@ -13,12 +13,15 @@ #include "sof_sdw_common.h" #include "sof_maxim_common.h" -static const struct snd_soc_dapm_widget mx8373_widgets[] = { +static int maxim_part_id; +#define SOF_SDW_PART_ID_MAX98373 0x8373 + +static const struct snd_soc_dapm_widget maxim_widgets[] = { SND_SOC_DAPM_SPK("Left Spk", NULL), SND_SOC_DAPM_SPK("Right Spk", NULL), }; -static const struct snd_kcontrol_new mx8373_controls[] = { +static const struct snd_kcontrol_new maxim_controls[] = { SOC_DAPM_PIN_SWITCH("Left Spk"), SOC_DAPM_PIN_SWITCH("Right Spk"), }; @@ -29,22 +32,25 @@ static int spk_init(struct snd_soc_pcm_runtime *rtd) int ret; card->components = devm_kasprintf(card->dev, GFP_KERNEL, - "%s spk:mx8373", - card->components); + "%s spk:mx%04x", + card->components, maxim_part_id); if (!card->components) return -ENOMEM; - ret = snd_soc_add_card_controls(card, mx8373_controls, - ARRAY_SIZE(mx8373_controls)); + dev_dbg(card->dev, "soundwire maxim card components assigned : %s\n", + card->components); + + ret = snd_soc_add_card_controls(card, maxim_controls, + ARRAY_SIZE(maxim_controls)); if (ret) { - dev_err(card->dev, "mx8373 ctrls addition failed: %d\n", ret); + dev_err(card->dev, "mx%04x ctrls addition failed: %d\n", maxim_part_id, ret); return ret; } - ret = snd_soc_dapm_new_controls(&card->dapm, mx8373_widgets, - ARRAY_SIZE(mx8373_widgets)); + ret = snd_soc_dapm_new_controls(&card->dapm, maxim_widgets, + ARRAY_SIZE(maxim_widgets)); if (ret) { - dev_err(card->dev, "mx8373 widgets addition failed: %d\n", ret); + dev_err(card->dev, "mx%04x widgets addition failed: %d\n", maxim_part_id, ret); return ret; } @@ -130,19 +136,25 @@ static int mx8373_sdw_late_probe(struct snd_soc_card *card) return snd_soc_dapm_sync(dapm); } -int sof_sdw_mx8373_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_maxim_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) { info->amp_num++; if (info->amp_num == 2) dai_links->init = spk_init; - info->codec_card_late_probe = mx8373_sdw_late_probe; - - dai_links->ops = &max_98373_sdw_ops; - + maxim_part_id = info->part_id; + switch (maxim_part_id) { + case SOF_SDW_PART_ID_MAX98373: + info->codec_card_late_probe = mx8373_sdw_late_probe; + dai_links->ops = &max_98373_sdw_ops; + break; + default: + dev_err(card->dev, "Invalid maxim_part_id %#x\n", maxim_part_id); + return -EINVAL; + } return 0; } -- 2.37.2