Commit fcb3f0fb authored by Uday M Bhat's avatar Uday M Bhat Committed by Mark Brown

ASoC: Intel: sof_sdw: Modify maxim helper functions and structure names

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: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarYong Zhi <yong.zhi@intel.com>
Signed-off-by: default avatarUday M Bhat <uday.m.bhat@intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230602202225.249209-26-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 85565f80
...@@ -805,7 +805,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -805,7 +805,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_name = "max98373-aif1", .dai_name = "max98373-aif1",
.dai_type = SOF_SDW_DAI_TYPE_AMP, .dai_type = SOF_SDW_DAI_TYPE_AMP,
.dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID}, .dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID},
.init = sof_sdw_mx8373_init, .init = sof_sdw_maxim_init,
}, },
}, },
.dai_num = 1, .dai_num = 1,
......
...@@ -182,8 +182,8 @@ int sof_sdw_rt715_sdca_init(struct snd_soc_card *card, ...@@ -182,8 +182,8 @@ int sof_sdw_rt715_sdca_init(struct snd_soc_card *card,
struct sof_sdw_codec_info *info, struct sof_sdw_codec_info *info,
bool playback); bool playback);
/* MAX98373 support */ /* MAXIM codec support */
int sof_sdw_mx8373_init(struct snd_soc_card *card, int sof_sdw_maxim_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link, const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links, struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info, struct sof_sdw_codec_info *info,
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2020 Intel Corporation // 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 // codec devices from generic machine driver
#include <linux/device.h> #include <linux/device.h>
...@@ -13,12 +13,15 @@ ...@@ -13,12 +13,15 @@
#include "sof_sdw_common.h" #include "sof_sdw_common.h"
#include "sof_maxim_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("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right 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("Left Spk"),
SOC_DAPM_PIN_SWITCH("Right Spk"), SOC_DAPM_PIN_SWITCH("Right Spk"),
}; };
...@@ -29,22 +32,25 @@ static int spk_init(struct snd_soc_pcm_runtime *rtd) ...@@ -29,22 +32,25 @@ static int spk_init(struct snd_soc_pcm_runtime *rtd)
int ret; int ret;
card->components = devm_kasprintf(card->dev, GFP_KERNEL, card->components = devm_kasprintf(card->dev, GFP_KERNEL,
"%s spk:mx8373", "%s spk:mx%04x",
card->components); card->components, maxim_part_id);
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_add_card_controls(card, mx8373_controls, dev_dbg(card->dev, "soundwire maxim card components assigned : %s\n",
ARRAY_SIZE(mx8373_controls)); card->components);
ret = snd_soc_add_card_controls(card, maxim_controls,
ARRAY_SIZE(maxim_controls));
if (ret) { 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; return ret;
} }
ret = snd_soc_dapm_new_controls(&card->dapm, mx8373_widgets, ret = snd_soc_dapm_new_controls(&card->dapm, maxim_widgets,
ARRAY_SIZE(mx8373_widgets)); ARRAY_SIZE(maxim_widgets));
if (ret) { 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; return ret;
} }
...@@ -130,7 +136,7 @@ static int mx8373_sdw_late_probe(struct snd_soc_card *card) ...@@ -130,7 +136,7 @@ static int mx8373_sdw_late_probe(struct snd_soc_card *card)
return snd_soc_dapm_sync(dapm); return snd_soc_dapm_sync(dapm);
} }
int sof_sdw_mx8373_init(struct snd_soc_card *card, int sof_sdw_maxim_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link, const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links, struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info, struct sof_sdw_codec_info *info,
...@@ -140,9 +146,15 @@ int sof_sdw_mx8373_init(struct snd_soc_card *card, ...@@ -140,9 +146,15 @@ int sof_sdw_mx8373_init(struct snd_soc_card *card,
if (info->amp_num == 2) if (info->amp_num == 2)
dai_links->init = spk_init; dai_links->init = spk_init;
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; info->codec_card_late_probe = mx8373_sdw_late_probe;
dai_links->ops = &max_98373_sdw_ops; 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; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment