forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ASoC: Intel: sof_rt5682: use common module for amp link
Use intel_board module to initialize DAI link and update codec conf structure for speaker amplifier. Signed-off-by: Brent Lu <[email protected]>
- Loading branch information
Showing
1 changed file
with
14 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,6 @@ | |
#include "../../codecs/rt5645.h" | ||
#include "../common/soc-intel-quirks.h" | ||
#include "sof_board_helpers.h" | ||
#include "sof_maxim_common.h" | ||
#include "sof_realtek_common.h" | ||
#include "sof_ssp_common.h" | ||
|
||
#define SOF_RT5682_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) | ||
|
@@ -666,41 +664,12 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type, | |
|
||
/* speaker amp */ | ||
if (amp_type != CODEC_NONE) { | ||
links[id].name = devm_kasprintf(dev, GFP_KERNEL, | ||
"SSP%d-Codec", ssp_amp); | ||
if (!links[id].name) | ||
goto devm_err; | ||
|
||
links[id].id = id; | ||
ret = sof_intel_board_set_amp_link(dev, &links[id], id, amp_type, | ||
ssp_amp); | ||
if (ret) | ||
return NULL; | ||
|
||
switch (amp_type) { | ||
case CODEC_MAX98357A: | ||
max_98357a_dai_link(&links[id]); | ||
break; | ||
case CODEC_MAX98360A: | ||
max_98360a_dai_link(&links[id]); | ||
break; | ||
case CODEC_MAX98373: | ||
links[id].codecs = max_98373_components; | ||
links[id].num_codecs = ARRAY_SIZE(max_98373_components); | ||
links[id].init = max_98373_spk_codec_init; | ||
links[id].ops = &max_98373_ops; | ||
break; | ||
case CODEC_MAX98390: | ||
max_98390_dai_link(dev, &links[id]); | ||
break; | ||
case CODEC_RT1011: | ||
sof_rt1011_dai_link(&links[id]); | ||
break; | ||
case CODEC_RT1015: | ||
sof_rt1015_dai_link(&links[id]); | ||
break; | ||
case CODEC_RT1015P: | ||
sof_rt1015p_dai_link(&links[id]); | ||
break; | ||
case CODEC_RT1019P: | ||
sof_rt1019p_dai_link(&links[id]); | ||
break; | ||
case CODEC_RT5650: | ||
/* use AIF2 to support speaker pipeline */ | ||
links[id].codecs = &rt5650_components[1]; | ||
|
@@ -709,33 +678,9 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type, | |
links[id].ops = &sof_rt5682_ops; | ||
break; | ||
default: | ||
dev_err(dev, "invalid amp type %d\n", amp_type); | ||
return NULL; | ||
break; | ||
} | ||
|
||
links[id].platforms = platform_component; | ||
links[id].num_platforms = ARRAY_SIZE(platform_component); | ||
links[id].dpcm_playback = 1; | ||
/* feedback stream or firmware-generated echo reference */ | ||
links[id].dpcm_capture = 1; | ||
|
||
links[id].no_pcm = 1; | ||
links[id].cpus = &cpus[id]; | ||
links[id].num_cpus = 1; | ||
if (is_legacy_cpu) { | ||
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, | ||
"ssp%d-port", | ||
ssp_amp); | ||
if (!links[id].cpus->dai_name) | ||
goto devm_err; | ||
|
||
} else { | ||
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, | ||
"SSP%d Pin", | ||
ssp_amp); | ||
if (!links[id].cpus->dai_name) | ||
goto devm_err; | ||
} | ||
id++; | ||
} | ||
|
||
|
@@ -801,7 +746,7 @@ static int sof_audio_probe(struct platform_device *pdev) | |
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; | ||
struct snd_soc_dai_link *dai_links; | ||
struct sof_card_private *ctx; | ||
int ret, ssp_amp; | ||
int ret; | ||
|
||
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); | ||
if (!ctx) | ||
|
@@ -867,7 +812,7 @@ static int sof_audio_probe(struct platform_device *pdev) | |
|
||
dev_dbg(&pdev->dev, "sof_rt5682_quirk = %lx\n", sof_rt5682_quirk); | ||
|
||
ssp_amp = (sof_rt5682_quirk & SOF_RT5682_SSP_AMP_MASK) >> | ||
ctx->ssp_amp = (sof_rt5682_quirk & SOF_RT5682_SSP_AMP_MASK) >> | ||
SOF_RT5682_SSP_AMP_SHIFT; | ||
|
||
ctx->ssp_codec = sof_rt5682_quirk & SOF_RT5682_SSP_CODEC_MASK; | ||
|
@@ -887,8 +832,9 @@ static int sof_audio_probe(struct platform_device *pdev) | |
SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT); | ||
|
||
dai_links = sof_card_dai_links_create(&pdev->dev, ctx->codec_type, | ||
ctx->amp_type, ctx->ssp_codec, ssp_amp, | ||
ctx->dmic_be_num, ctx->hdmi_num, | ||
ctx->amp_type, ctx->ssp_codec, | ||
ctx->ssp_amp, ctx->dmic_be_num, | ||
ctx->hdmi_num, | ||
ctx->hdmi.idisp_codec, | ||
ctx->rt5682.is_legacy_cpu); | ||
if (!dai_links) | ||
|
@@ -897,33 +843,10 @@ static int sof_audio_probe(struct platform_device *pdev) | |
sof_audio_card_rt5682.dai_link = dai_links; | ||
|
||
/* update codec_conf */ | ||
switch (ctx->amp_type) { | ||
case CODEC_MAX98373: | ||
max_98373_set_codec_conf(&sof_audio_card_rt5682); | ||
break; | ||
case CODEC_MAX98390: | ||
max_98390_set_codec_conf(&pdev->dev, &sof_audio_card_rt5682); | ||
break; | ||
case CODEC_RT1011: | ||
sof_rt1011_codec_conf(&sof_audio_card_rt5682); | ||
break; | ||
case CODEC_RT1015: | ||
sof_rt1015_codec_conf(&sof_audio_card_rt5682); | ||
break; | ||
case CODEC_RT1015P: | ||
sof_rt1015p_codec_conf(&sof_audio_card_rt5682); | ||
break; | ||
case CODEC_NONE: | ||
case CODEC_MAX98357A: | ||
case CODEC_MAX98360A: | ||
case CODEC_RT1019P: | ||
case CODEC_RT5650: | ||
/* no codec conf required */ | ||
break; | ||
default: | ||
dev_err(&pdev->dev, "invalid amp type %d\n", ctx->amp_type); | ||
return -EINVAL; | ||
} | ||
ret = sof_intel_board_set_codec_conf(&pdev->dev, &sof_audio_card_rt5682, | ||
ctx->amp_type); | ||
if (ret) | ||
return ret; | ||
|
||
sof_audio_card_rt5682.dev = &pdev->dev; | ||
|
||
|
@@ -1151,6 +1074,4 @@ MODULE_AUTHOR("Brent Lu <[email protected]>"); | |
MODULE_AUTHOR("Mac Chiang <[email protected]>"); | ||
MODULE_LICENSE("GPL v2"); | ||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS); | ||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); | ||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON); | ||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON); |