Skip to content

Commit

Permalink
ASoC: Intel: sof_sdw: Modify maxim helper functions and structure names
Browse files Browse the repository at this point in the history
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@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Signed-off-by: Uday M Bhat <uday.m.bhat@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230602202225.249209-26-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Uday M Bhat authored and Mark Brown committed Jun 5, 2023
1 parent 85565f8 commit fcb3f0f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 27 deletions.
2 changes: 1 addition & 1 deletion sound/soc/intel/boards/sof_sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions sound/soc/intel/boards/sof_sdw_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
52 changes: 32 additions & 20 deletions sound/soc/intel/boards/sof_sdw_maxim.c
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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"),
};
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

0 comments on commit fcb3f0f

Please sign in to comment.