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_ssp_amp: 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
12 additions
and
48 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 |
---|---|---|
|
@@ -18,8 +18,6 @@ | |
#include <sound/pcm_params.h> | ||
#include <sound/sof.h> | ||
#include "sof_board_helpers.h" | ||
#include "sof_realtek_common.h" | ||
#include "sof_cirrus_common.h" | ||
#include "sof_ssp_common.h" | ||
|
||
/* SSP port ID for speaker amplifier */ | ||
|
@@ -98,7 +96,7 @@ static struct snd_soc_dai_link_component platform_component[] = { | |
|
||
static struct snd_soc_dai_link * | ||
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, | ||
int ssp_codec, int dmic_be_num, int hdmi_num, | ||
int ssp_amp, int dmic_be_num, int hdmi_num, | ||
bool idisp_codec) | ||
{ | ||
struct snd_soc_dai_link_component *cpus; | ||
|
@@ -152,34 +150,10 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, | |
|
||
/* codec SSP */ | ||
if (amp_type != CODEC_NONE) { | ||
links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_codec); | ||
if (!links[id].name) | ||
return NULL; | ||
|
||
links[id].id = fixed_be ? SPK_BE_ID : id; | ||
|
||
switch (amp_type) { | ||
case CODEC_CS35L41: | ||
cs35l41_set_dai_link(&links[id]); | ||
break; | ||
case CODEC_RT1308: | ||
sof_rt1308_dai_link(&links[id]); | ||
break; | ||
default: | ||
dev_err(dev, "invalid amp type %d\n", amp_type); | ||
return NULL; | ||
} | ||
|
||
links[id].platforms = platform_component; | ||
links[id].num_platforms = ARRAY_SIZE(platform_component); | ||
links[id].dpcm_playback = 1; | ||
/* feedback from amplifier 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; | ||
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_codec); | ||
if (!links[id].cpus->dai_name) | ||
be_id = fixed_be ? SPK_BE_ID : id; | ||
ret = sof_intel_board_set_amp_link(dev, &links[id], be_id, | ||
amp_type, ssp_amp); | ||
if (ret) | ||
return NULL; | ||
|
||
id++; | ||
|
@@ -254,7 +228,7 @@ static int sof_ssp_amp_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_codec; | ||
int ret; | ||
|
||
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); | ||
if (!ctx) | ||
|
@@ -270,7 +244,7 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) | |
else | ||
ctx->dmic_be_num = 0; | ||
|
||
ssp_codec = sof_ssp_amp_quirk & SOF_AMPLIFIER_SSP_MASK; | ||
ctx->ssp_amp = sof_ssp_amp_quirk & SOF_AMPLIFIER_SSP_MASK; | ||
|
||
/* set number of dai links */ | ||
sof_ssp_amp_card.num_links = ctx->dmic_be_num; | ||
|
@@ -301,7 +275,7 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) | |
sof_ssp_amp_card.num_links++; | ||
|
||
dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type, | ||
ssp_codec, ctx->dmic_be_num, | ||
ctx->ssp_amp, ctx->dmic_be_num, | ||
ctx->hdmi_num, | ||
ctx->hdmi.idisp_codec); | ||
if (!dai_links) | ||
|
@@ -310,18 +284,10 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) | |
sof_ssp_amp_card.dai_link = dai_links; | ||
|
||
/* update codec_conf */ | ||
switch (ctx->amp_type) { | ||
case CODEC_CS35L41: | ||
cs35l41_set_codec_conf(&sof_ssp_amp_card); | ||
break; | ||
case CODEC_NONE: | ||
case CODEC_RT1308: | ||
/* 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_ssp_amp_card, | ||
ctx->amp_type); | ||
if (ret) | ||
return ret; | ||
|
||
sof_ssp_amp_card.dev = &pdev->dev; | ||
|
||
|
@@ -402,6 +368,4 @@ MODULE_AUTHOR("Balamurugan C <[email protected]>"); | |
MODULE_AUTHOR("Brent Lu <[email protected]>"); | ||
MODULE_LICENSE("GPL"); | ||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS); | ||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON); | ||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_CIRRUS_COMMON); | ||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON); |