Commit bee2fe44 authored by Bard Liao's avatar Bard Liao Committed by Mark Brown

ASoC: Intel: sof_sdw: use generic rtd_init function for Realtek SDW DMICs

The only thing that the rt_xxx_rtd_init() functions do is to set
card->components. And we can set card->components with name_prefix
as rt712_sdca_dmic_rtd_init() does.
And sof_sdw_rtd_init() will always select the first dai with the
given dai->name from codec_info_list[]. Unfortunately, we have
different codecs with the same dai name. For example, dai name of
rt715 and rt715-sdca are both "rt715-aif2". Using a generic rtd_init
allow sof_sdw_rtd_init() run the rtd_init() callback from a similar
codec dai.

Fixes: 8266c731 ("ASoC: Intel: sof_sdw: add common sdw dai link init")
Reviewed-by: default avatarChao Song <chao.song@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://msgid.link/r/20240326160429.13560-25-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 59bf457d
......@@ -42,6 +42,7 @@ snd-soc-sof-sdw-objs += sof_sdw.o \
sof_sdw_rt711.o sof_sdw_rt_sdca_jack_common.o \
sof_sdw_rt712_sdca.o sof_sdw_rt715.o \
sof_sdw_rt715_sdca.o sof_sdw_rt722_sdca.o \
sof_sdw_rt_dmic.o \
sof_sdw_cs42l42.o sof_sdw_cs42l43.o \
sof_sdw_cs_amp.o \
sof_sdw_dmic.o \
......
......@@ -749,7 +749,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_name = "rt712-sdca-dmic-aif1",
.dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.rtd_init = rt712_sdca_dmic_rtd_init,
.rtd_init = rt_dmic_rtd_init,
},
},
.dai_num = 1,
......@@ -779,7 +779,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_name = "rt712-sdca-dmic-aif1",
.dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.rtd_init = rt712_sdca_dmic_rtd_init,
.rtd_init = rt_dmic_rtd_init,
},
},
.dai_num = 1,
......@@ -841,7 +841,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_name = "rt715-aif2",
.dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.rtd_init = rt715_sdca_rtd_init,
.rtd_init = rt_dmic_rtd_init,
},
},
.dai_num = 1,
......@@ -856,7 +856,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_name = "rt715-aif2",
.dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.rtd_init = rt715_sdca_rtd_init,
.rtd_init = rt_dmic_rtd_init,
},
},
.dai_num = 1,
......@@ -871,7 +871,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_name = "rt715-aif2",
.dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.rtd_init = rt715_rtd_init,
.rtd_init = rt_dmic_rtd_init,
},
},
.dai_num = 1,
......@@ -886,7 +886,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_name = "rt715-aif2",
.dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.rtd_init = rt715_rtd_init,
.rtd_init = rt_dmic_rtd_init,
},
},
.dai_num = 1,
......
......@@ -197,6 +197,7 @@ int rt712_sdca_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd);
int rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd);
int rt715_rtd_init(struct snd_soc_pcm_runtime *rtd);
int rt715_sdca_rtd_init(struct snd_soc_pcm_runtime *rtd);
int rt_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd);
int rt_amp_spk_rtd_init(struct snd_soc_pcm_runtime *rtd);
int rt_sdca_jack_rtd_init(struct snd_soc_pcm_runtime *rtd);
......
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2024 Intel Corporation
/*
* sof_sdw_rt_dmic - Helpers to handle Realtek SDW DMIC from generic machine driver
*/
#include <linux/device.h>
#include <linux/errno.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include "sof_board_helpers.h"
#include "sof_sdw_common.h"
static const char * const dmics[] = {
"rt715",
"rt712-sdca-dmic",
};
int rt_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
struct snd_soc_component *component;
struct snd_soc_dai *codec_dai;
char *mic_name;
codec_dai = get_codec_dai_by_name(rtd, dmics, ARRAY_SIZE(dmics));
if (!codec_dai)
return -EINVAL;
component = codec_dai->component;
/*
* rt715-sdca (aka rt714) is a special case that uses different name in card->components
* and component->name_prefix.
*/
if (!strcmp(component->name_prefix, "rt714"))
mic_name = devm_kasprintf(card->dev, GFP_KERNEL, "rt715-sdca");
else
mic_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s", component->name_prefix);
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
"%s mic:%s", card->components,
mic_name);
if (!card->components)
return -ENOMEM;
dev_dbg(card->dev, "card->components: %s\n", card->components);
return 0;
}
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS);
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