mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
ASoC: intel: split soundwire machine driver private data
Split intel generic SoundWire machine driver private data into two structures. One structure is generic one which can be used by other platform machine driver and the other one is intel specific one. Move generic machine driver private data to soc_sdw_utils.h. Define a void pointer in generic machine driver private data structure and assign the vendor specific structure in mc_probe() call. Link: https://github.com/thesofproject/linux/pull/5068 Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://patch.msgid.link/20240801091446.10457-15-Vijendar.Mukunda@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
89b3456e9a
commit
4f54856b4e
@ -55,6 +55,16 @@ struct asoc_sdw_codec_info {
|
||||
struct snd_soc_codec_conf **codec_conf);
|
||||
};
|
||||
|
||||
struct asoc_sdw_mc_private {
|
||||
struct snd_soc_card card;
|
||||
struct snd_soc_jack sdw_headset;
|
||||
struct device *headset_codec_dev; /* only one headset per card */
|
||||
struct device *amp_dev1, *amp_dev2;
|
||||
bool append_dai_type;
|
||||
bool ignore_internal_dmic;
|
||||
void *private;
|
||||
};
|
||||
|
||||
int asoc_sdw_startup(struct snd_pcm_substream *substream);
|
||||
int asoc_sdw_prepare(struct snd_pcm_substream *substream);
|
||||
int asoc_sdw_prepare(struct snd_pcm_substream *substream);
|
||||
|
@ -1319,7 +1319,7 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
|
||||
int *num_devs)
|
||||
{
|
||||
struct device *dev = card->dev;
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct snd_soc_acpi_mach *mach = dev_get_platdata(dev);
|
||||
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
|
||||
const struct snd_soc_acpi_link_adr *adr_link;
|
||||
@ -1440,7 +1440,8 @@ static int create_sdw_dailink(struct snd_soc_card *card,
|
||||
int *be_id, struct snd_soc_codec_conf **codec_conf)
|
||||
{
|
||||
struct device *dev = card->dev;
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct intel_mc_ctx *intel_ctx = (struct intel_mc_ctx *)ctx->private;
|
||||
struct sof_sdw_endpoint *sof_end;
|
||||
int stream;
|
||||
int ret;
|
||||
@ -1519,7 +1520,7 @@ static int create_sdw_dailink(struct snd_soc_card *card,
|
||||
|
||||
if (cur_link != sof_end->link_mask) {
|
||||
int link_num = ffs(sof_end->link_mask) - 1;
|
||||
int pin_num = ctx->sdw_pin_index[link_num]++;
|
||||
int pin_num = intel_ctx->sdw_pin_index[link_num]++;
|
||||
|
||||
cur_link = sof_end->link_mask;
|
||||
|
||||
@ -1573,11 +1574,12 @@ static int create_sdw_dailinks(struct snd_soc_card *card,
|
||||
struct sof_sdw_dailink *sof_dais,
|
||||
struct snd_soc_codec_conf **codec_conf)
|
||||
{
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct intel_mc_ctx *intel_ctx = (struct intel_mc_ctx *)ctx->private;
|
||||
int ret, i;
|
||||
|
||||
for (i = 0; i < SDW_MAX_LINKS; i++)
|
||||
ctx->sdw_pin_index[i] = SOC_SDW_INTEL_BIDIR_PDI_BASE;
|
||||
intel_ctx->sdw_pin_index[i] = SOC_SDW_INTEL_BIDIR_PDI_BASE;
|
||||
|
||||
/* generate DAI links by each sdw link */
|
||||
while (sof_dais->initialised) {
|
||||
@ -1665,7 +1667,8 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
|
||||
int hdmi_num)
|
||||
{
|
||||
struct device *dev = card->dev;
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct intel_mc_ctx *intel_ctx = (struct intel_mc_ctx *)ctx->private;
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < hdmi_num; i++) {
|
||||
@ -1673,7 +1676,7 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
|
||||
char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d Pin", i + 1);
|
||||
char *codec_name, *codec_dai_name;
|
||||
|
||||
if (ctx->hdmi.idisp_codec) {
|
||||
if (intel_ctx->hdmi.idisp_codec) {
|
||||
codec_name = "ehdaudio0D2";
|
||||
codec_dai_name = devm_kasprintf(dev, GFP_KERNEL,
|
||||
"intel-hdmi-hifi%d", i + 1);
|
||||
@ -1721,7 +1724,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
|
||||
struct device *dev = card->dev;
|
||||
struct snd_soc_acpi_mach *mach = dev_get_platdata(card->dev);
|
||||
int sdw_be_num = 0, ssp_num = 0, dmic_num = 0, bt_num = 0;
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct intel_mc_ctx *intel_ctx = (struct intel_mc_ctx *)ctx->private;
|
||||
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
|
||||
struct snd_soc_codec_conf *codec_conf;
|
||||
struct asoc_sdw_codec_info *ssp_info;
|
||||
@ -1773,7 +1777,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
|
||||
}
|
||||
|
||||
if (mach_params->codec_mask & IDISP_CODEC_MASK)
|
||||
ctx->hdmi.idisp_codec = true;
|
||||
intel_ctx->hdmi.idisp_codec = true;
|
||||
|
||||
if (sof_sdw_quirk & SOF_SDW_TGL_HDMI)
|
||||
hdmi_num = SOF_TGL_HDMI_COUNT;
|
||||
@ -1789,7 +1793,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
|
||||
|
||||
dev_dbg(dev, "sdw %d, ssp %d, dmic %d, hdmi %d, bt: %d\n",
|
||||
sdw_be_num, ssp_num, dmic_num,
|
||||
ctx->hdmi.idisp_codec ? hdmi_num : 0, bt_num);
|
||||
intel_ctx->hdmi.idisp_codec ? hdmi_num : 0, bt_num);
|
||||
|
||||
codec_conf = devm_kcalloc(dev, num_devs, sizeof(*codec_conf), GFP_KERNEL);
|
||||
if (!codec_conf) {
|
||||
@ -1862,7 +1866,8 @@ err_dai:
|
||||
|
||||
static int sof_sdw_card_late_probe(struct snd_soc_card *card)
|
||||
{
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct intel_mc_ctx *intel_ctx = (struct intel_mc_ctx *)ctx->private;
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
@ -1875,7 +1880,7 @@ static int sof_sdw_card_late_probe(struct snd_soc_card *card)
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->hdmi.idisp_codec)
|
||||
if (intel_ctx->hdmi.idisp_codec)
|
||||
ret = sof_sdw_hdmi_card_late_probe(card);
|
||||
|
||||
return ret;
|
||||
@ -1934,16 +1939,22 @@ static int mc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct snd_soc_acpi_mach *mach = dev_get_platdata(&pdev->dev);
|
||||
struct snd_soc_card *card;
|
||||
struct mc_private *ctx;
|
||||
struct asoc_sdw_mc_private *ctx;
|
||||
struct intel_mc_ctx *intel_ctx;
|
||||
int amp_num = 0, i;
|
||||
int ret;
|
||||
|
||||
dev_dbg(&pdev->dev, "Entry\n");
|
||||
|
||||
intel_ctx = devm_kzalloc(&pdev->dev, sizeof(*intel_ctx), GFP_KERNEL);
|
||||
if (!intel_ctx)
|
||||
return -ENOMEM;
|
||||
|
||||
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
|
||||
if (!ctx)
|
||||
return -ENOMEM;
|
||||
|
||||
ctx->private = intel_ctx;
|
||||
card = &ctx->card;
|
||||
card->dev = &pdev->dev;
|
||||
card->name = "soundwire";
|
||||
|
@ -78,16 +78,10 @@ enum {
|
||||
#define SOC_SDW_DAI_TYPE_AMP 1
|
||||
#define SOC_SDW_DAI_TYPE_MIC 2
|
||||
|
||||
struct mc_private {
|
||||
struct snd_soc_card card;
|
||||
struct snd_soc_jack sdw_headset;
|
||||
struct intel_mc_ctx {
|
||||
struct sof_hdmi_private hdmi;
|
||||
struct device *headset_codec_dev; /* only one headset per card */
|
||||
struct device *amp_dev1, *amp_dev2;
|
||||
/* To store SDW Pin index for each SoundWire link */
|
||||
unsigned int sdw_pin_index[SDW_MAX_LINKS];
|
||||
bool append_dai_type;
|
||||
bool ignore_internal_dmic;
|
||||
};
|
||||
|
||||
extern unsigned long sof_sdw_quirk;
|
||||
|
@ -39,7 +39,7 @@ static struct snd_soc_jack_pin cs42l42_jack_pins[] = {
|
||||
int asoc_sdw_cs42l42_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct snd_soc_component *component;
|
||||
struct snd_soc_jack *jack;
|
||||
int ret;
|
||||
|
@ -51,7 +51,7 @@ static struct snd_soc_jack_pin sof_jack_pins[] = {
|
||||
int asoc_sdw_cs42l43_hs_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_jack *jack = &ctx->sdw_headset;
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
int ret;
|
||||
|
@ -17,23 +17,25 @@
|
||||
|
||||
int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct intel_mc_ctx *intel_ctx = (struct intel_mc_ctx *)ctx->private;
|
||||
struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0);
|
||||
|
||||
ctx->hdmi.hdmi_comp = dai->component;
|
||||
intel_ctx->hdmi.hdmi_comp = dai->component;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card)
|
||||
{
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct intel_mc_ctx *intel_ctx = (struct intel_mc_ctx *)ctx->private;
|
||||
|
||||
if (!ctx->hdmi.idisp_codec)
|
||||
if (!intel_ctx->hdmi.idisp_codec)
|
||||
return 0;
|
||||
|
||||
if (!ctx->hdmi.hdmi_comp)
|
||||
if (!intel_ctx->hdmi.hdmi_comp)
|
||||
return -EINVAL;
|
||||
|
||||
return hda_dsp_hdmi_build_controls(card, ctx->hdmi.hdmi_comp);
|
||||
return hda_dsp_hdmi_build_controls(card, intel_ctx->hdmi.hdmi_comp);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ static struct snd_soc_jack_pin rt5682_jack_pins[] = {
|
||||
int asoc_sdw_rt5682_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct snd_soc_component *component;
|
||||
struct snd_soc_jack *jack;
|
||||
int ret;
|
||||
|
@ -36,7 +36,7 @@ static struct snd_soc_jack_pin rt700_jack_pins[] = {
|
||||
int asoc_sdw_rt700_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct snd_soc_component *component;
|
||||
struct snd_soc_jack *jack;
|
||||
int ret;
|
||||
|
@ -62,7 +62,7 @@ static struct snd_soc_jack_pin rt711_jack_pins[] = {
|
||||
int asoc_sdw_rt711_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct snd_soc_component *component;
|
||||
struct snd_soc_jack *jack;
|
||||
int ret;
|
||||
@ -113,7 +113,7 @@ int asoc_sdw_rt711_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai
|
||||
|
||||
int asoc_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link)
|
||||
{
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
|
||||
if (!ctx->headset_codec_dev)
|
||||
return 0;
|
||||
@ -129,7 +129,7 @@ int asoc_sdw_rt711_init(struct snd_soc_card *card,
|
||||
struct asoc_sdw_codec_info *info,
|
||||
bool playback)
|
||||
{
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct device *sdw_dev;
|
||||
int ret;
|
||||
|
||||
|
@ -239,7 +239,7 @@ const struct snd_soc_ops soc_sdw_rt1308_i2s_ops = {
|
||||
|
||||
int asoc_sdw_rt_amp_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link)
|
||||
{
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
|
||||
if (ctx->amp_dev1) {
|
||||
device_remove_software_node(ctx->amp_dev1);
|
||||
@ -259,7 +259,7 @@ int asoc_sdw_rt_amp_init(struct snd_soc_card *card,
|
||||
struct asoc_sdw_codec_info *info,
|
||||
bool playback)
|
||||
{
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct device *sdw_dev1, *sdw_dev2;
|
||||
int ret;
|
||||
|
||||
|
@ -86,7 +86,7 @@ static const char * const need_sdca_suffix[] = {
|
||||
int asoc_sdw_rt_sdca_jack_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct snd_soc_component *component;
|
||||
struct snd_soc_jack *jack;
|
||||
int ret;
|
||||
@ -163,7 +163,7 @@ int asoc_sdw_rt_sdca_jack_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_s
|
||||
|
||||
int asoc_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);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
|
||||
if (!ctx->headset_codec_dev)
|
||||
return 0;
|
||||
@ -183,7 +183,7 @@ int asoc_sdw_rt_sdca_jack_init(struct snd_soc_card *card,
|
||||
struct asoc_sdw_codec_info *info,
|
||||
bool playback)
|
||||
{
|
||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||
struct device *sdw_dev;
|
||||
int ret;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user