ASoC: Intel: Link handling rework and fixes
Subsystems (3)
Peter Ujfalusi
maintainercover ASoC: Intel: Link handling rework and fixes
Hi,
SOF board updates for 6.8 including few small fix and the majority is to add generic helpers for codec, amp, BT offload, HDMI-In and DAI link generation among various machine drivers.
Regards,
Peter
---
Bard Liao (2):
ASoC: Intel: sof_maxim_common: add else between 2 if test
ASoC: Intel: sof_maxim_common: check return value
Brent Lu (24):
ASoC: Intel: sof_ssp_amp: remove dead code
ASoC: Intel: ssp-common: get codec name function
ASoC: Intel: board_helpers: support codec link initialization
ASoC: Intel: sof_cs42l42: use common module for codec link
ASoC: Intel: sof_nau8825: use common module for codec link
ASoC: Intel: sof_rt5682: use common module for codec link
ASoC: Intel: board_helpers: support amp link initialization
ASoC: Intel: sof_cs42l42: use common module for amp link
ASoC: Intel: sof_nau8825: use common module for amp link
ASoC: Intel: sof_rt5682: use common module for amp link
ASoC: Intel: sof_ssp_amp: use common module for amp link
ASoC: Intel: sof_ssp_amp: rename function parameter
ASoC: Intel: board_helpers: support BT offload link initialization
ASoC: Intel: sof_cs42l42: use common module for BT offload link
ASoC: Intel: sof_nau8825: use common module for BT offload link
ASoC: Intel: sof_rt5682: use common module for BT offload link
ASoC: Intel: sof_ssp_amp: use common module for BT offload link
ASoC: Intel: sof_ssp_amp: simplify HDMI-In quirks
ASoC: Intel: board_helpers: support HDMI-In link initialization
ASoC: Intel: sof_rt5682: use common module for HDMI-In link
ASoC: Intel: sof_ssp_amp: use common module for HDMI-In link
ASoC: Intel: board_helpers: support DAI link array generation
ASoC: Intel: sof_nau8825: use common module for DAI link generation
ASoC: Intel: sof_rt5682: use common module for DAI link generation
Chao Song (1):
ASoC: Intel: cht_bsw_rt5672: check return value
sound/soc/intel/boards/cht_bsw_rt5672.c | 8 +- sound/soc/intel/boards/sof_board_helpers.c | 330 +++++++++++++++++++++ sound/soc/intel/boards/sof_board_helpers.h | 31 ++ sound/soc/intel/boards/sof_cs42l42.c | 229 ++++---------- sound/soc/intel/boards/sof_maxim_common.c | 13 +- sound/soc/intel/boards/sof_nau8825.c | 224 ++++---------- sound/soc/intel/boards/sof_rt5682.c | 328 ++++++-------------- sound/soc/intel/boards/sof_ssp_amp.c | 160 ++++------ sound/soc/intel/boards/sof_ssp_common.c | 21 ++ sound/soc/intel/boards/sof_ssp_common.h | 1 + 10 files changed, 653 insertions(+), 692 deletions(-)
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 1/27 ASoC: Intel: sof_ssp_amp: remove dead code
From: Brent Lu <[email protected]>
This patch fixes a dead code problem when calculating BE ID for each HDMI-In link.
--- sound/soc/intel/boards/sof_ssp_amp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/boards/sof_ssp_amp.c +3 -1
@@ -124,6 +124,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,/* the topology supports HDMI-IN uses fixed BE ID for DAI links */ fixed_be = true; + be_id =HDMI_IN_BE_ID ;for (i =1 ; i <= num_of_hdmi_ssp; i++) { int port = (i == 1 ? (sof_ssp_amp_quirk & SOF_HDMI_CAPTURE_1_SSP_MASK) >> SOF_HDMI_CAPTURE_1_SSP_SHIFT :
@@ -138,7 +139,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, links[id].name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-HDMI" , port);if (!links[id].name)return NULL ; - links[id].id = fixed_be ? (HDMI_IN_BE_ID + i -1 ) : id; + links[id].id = be_id; links[id].codecs = &snd_soc_dummy_dlc; links[id].num_codecs =1 ; links[id].platforms = platform_component;
@@ -147,6 +148,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, links[id].no_pcm =1 ; links[id].num_cpus =1 ; id++; + be_id++; } }
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 2/27 ASoC: Intel: sof_maxim_common: add else between 2 if test
In reply to Peter UjfalusiFrom: Bard Liao <[email protected]>
if (!strcmp(codec_dai->component->name, MAX_98373_DEV0_NAME)) and if (!strcmp(codec_dai->component->name, MAX_98373_DEV1_NAME)) can't be true at the same time. Add an else to clarify it.
--- sound/soc/intel/boards/sof_maxim_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/intel/boards/sof_maxim_common.c +1 -2
@@ -67,8 +67,7 @@ static int max_98373_hw_params(struct snd_pcm_substream *substream,if (!strcmp (codec_dai->component->name,MAX_98373_DEV0_NAME )) {/* DEV0 tdm slot configuration */ snd_soc_dai_set_tdm_slot (codec_dai,0x03 ,3 ,8 ,32 ); - } -if (!strcmp (codec_dai->component->name,MAX_98373_DEV1_NAME )) { + }else if (!strcmp (codec_dai->component->name,MAX_98373_DEV1_NAME )) {/* DEV1 tdm slot configuration */ snd_soc_dai_set_tdm_slot (codec_dai,0x0C ,3 ,8 ,32 ); }
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 3/27 ASoC: Intel: sof_maxim_common: check return value
In reply to Peter UjfalusiFrom: Bard Liao <[email protected]>
snd_soc_dai_set_tdm_slot() could return error.
--- sound/soc/intel/boards/sof_maxim_common.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
sound/soc/intel/boards/sof_maxim_common.c +8 -2
@@ -61,15 +61,21 @@ static int max_98373_hw_params(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct snd_soc_dai *codec_dai; +int ret =0 ;int j;for_each_rtd_codec_dais (rtd, j, codec_dai) {if (!strcmp (codec_dai->component->name,MAX_98373_DEV0_NAME )) {/* DEV0 tdm slot configuration */ -snd_soc_dai_set_tdm_slot (codec_dai,0x03 ,3 ,8 ,32 ); + ret =snd_soc_dai_set_tdm_slot (codec_dai,0x03 ,3 ,8 ,32 ); }else if (!strcmp (codec_dai->component->name,MAX_98373_DEV1_NAME )) {/* DEV1 tdm slot configuration */ -snd_soc_dai_set_tdm_slot (codec_dai,0x0C ,3 ,8 ,32 ); + ret =snd_soc_dai_set_tdm_slot (codec_dai,0x0C ,3 ,8 ,32 ); + } +if (ret <0 ) { +dev_err (codec_dai->dev,"fail to set tdm slot, ret %d\n" , + ret); +return ret; } }return 0 ;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 4/27 ASoC: Intel: cht_bsw_rt5672: check return value
In reply to Peter UjfalusiFrom: Chao Song <[email protected]>
Set codec sysclk could fail and return error, add
error check for it.
--- sound/soc/intel/boards/cht_bsw_rt5672.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
sound/soc/intel/boards/cht_bsw_rt5672.c +6 -2
@@ -93,8 +93,12 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,* when codec is runtime suspended. Codec needs clock for jack * detection and button press. */ -snd_soc_dai_set_sysclk (codec_dai,RT5670_SCLK_S_RCCLK , -48000 *512 ,SND_SOC_CLOCK_IN ); + ret =snd_soc_dai_set_sysclk (codec_dai,RT5670_SCLK_S_RCCLK , +48000 *512 ,SND_SOC_CLOCK_IN ); +if (ret <0 ) { +dev_err (card->dev,"failed to set codec sysclk: %d\n" , ret); +return ret; + }if (ctx->mclk)clk_disable_unprepare (ctx->mclk);
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 5/27 ASoC: Intel: ssp-common: get codec name function
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Add a helper function to get codec name string from codec type enum value.
--- sound/soc/intel/boards/sof_ssp_common.c | 21 +++++++++++++++++++++ sound/soc/intel/boards/sof_ssp_common.h | 1 + 2 files changed, 22 insertions(+)
sound/soc/intel/boards/sof_ssp_common.c +21 -0
@@ -96,6 +96,27 @@ enum sof_ssp_codec sof_ssp_detect_amp_type(struct device *dev) }EXPORT_SYMBOL_NS (sof_ssp_detect_amp_type,SND_SOC_INTEL_SOF_SSP_COMMON ); +const char *sof_ssp_get_codec_name (enum sof_ssp_codec codec_type) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (codecs); i++) { +if (codecs[i].codec_type != codec_type) +continue ; + +return codecs[i].name; + } +for (i =0 ; i <ARRAY_SIZE (amps); i++) { +if (amps[i].codec_type != codec_type) +continue ; + +return amps[i].name; + } + +return NULL ; +} +EXPORT_SYMBOL_NS (sof_ssp_get_codec_name,SND_SOC_INTEL_SOF_SSP_COMMON ); +MODULE_DESCRIPTION ("ASoC Intel SOF Common Machine Driver Helpers" );MODULE_AUTHOR ("Brent Lu <[email protected]>" );MODULE_LICENSE ("GPL" );
sound/soc/intel/boards/sof_ssp_common.h +1 -0
@@ -67,5 +67,6 @@ enum sof_ssp_codec {enum sof_ssp_codec sof_ssp_detect_codec_type (struct device *dev);enum sof_ssp_codec sof_ssp_detect_amp_type (struct device *dev); +const char *sof_ssp_get_codec_name (enum sof_ssp_codec codec_type);#endif /* __SOF_SSP_COMMON_H */
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 6/27 ASoC: Intel: board_helpers: support codec link initialization
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Add a helper function for machine drivers to initialize headphone codec DAI links. The function will initialize common fields and let caller to initialize codec-specific fields like codec, init, exit, and ops fields.
--- sound/soc/intel/boards/sof_board_helpers.c | 51 ++++++++++++++++++++++ sound/soc/intel/boards/sof_board_helpers.h | 6 +++ 2 files changed, 57 insertions(+)
sound/soc/intel/boards/sof_board_helpers.c +51 -0
@@ -3,6 +3,7 @@// Copyright(c) 2023 Intel Corporation. All rights reserved. #include <sound/soc.h> +#include "../common/soc-intel-quirks.h" #include "hda_dsp_common.h" #include "sof_board_helpers.h"
@@ -86,6 +87,55 @@ static struct snd_soc_dai_link_component platform_component[] = { } }; +int sof_intel_board_set_codec_link (struct device *dev, +struct snd_soc_dai_link *link,int be_id, +enum sof_ssp_codec codec_type,int ssp_codec) +{ +struct snd_soc_dai_link_component *cpus; + +dev_dbg (dev,"link %d: codec %s, ssp %d\n" , be_id, +sof_ssp_get_codec_name (codec_type), ssp_codec); + +/* link name */ + link->name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-Codec" , ssp_codec); +if (!link->name) +return -ENOMEM ; + +/* cpus */ + cpus =devm_kzalloc (dev,sizeof (struct snd_soc_dai_link_component ), +GFP_KERNEL ); +if (!cpus) +return -ENOMEM ; + +if (soc_intel_is_byt () ||soc_intel_is_cht ()) { +/* backward-compatibility for BYT/CHT boards */ + cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL ,"ssp%d-port" , + ssp_codec); + }else { + cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d Pin" , + ssp_codec); + } +if (!cpus->dai_name) +return -ENOMEM ; + + link->cpus = cpus; + link->num_cpus =1 ; + +/* codecs - caller to handle */ + +/* platforms */ + link->platforms = platform_component; + link->num_platforms =ARRAY_SIZE (platform_component); + + link->id = be_id; + link->no_pcm =1 ; + link->dpcm_capture =1 ; + link->dpcm_playback =1 ; + +return 0 ; +} +EXPORT_SYMBOL_NS (sof_intel_board_set_codec_link,SND_SOC_INTEL_SOF_BOARD_HELPERS ); +int sof_intel_board_set_dmic_link (struct device *dev,struct snd_soc_dai_link *link,int be_id,enum sof_dmic_be_type be_type)
@@ -202,3 +252,4 @@ MODULE_DESCRIPTION("ASoC Intel SOF Machine Driver Board Helpers");MODULE_AUTHOR ("Brent Lu <[email protected]>" );MODULE_LICENSE ("GPL" );MODULE_IMPORT_NS (SND_SOC_INTEL_HDA_DSP_COMMON ); +MODULE_IMPORT_NS (SND_SOC_INTEL_SOF_SSP_COMMON );
sound/soc/intel/boards/sof_board_helpers.h +6 -0
@@ -30,6 +30,7 @@ struct sof_rt5682_private {* @amp_type: type of speaker amplifier * @dmic_be_num: number of Intel PCH DMIC BE link * @hdmi_num: number of Intel HDMI BE link +* @ssp_codec: ssp port number of headphone BE link * @rt5682: private data for rt5682 machine driver */ struct sof_card_private {
@@ -42,6 +43,8 @@ struct sof_card_private {int dmic_be_num;int hdmi_num; +int ssp_codec; +union {struct sof_rt5682_private rt5682; };
@@ -54,6 +57,9 @@ enum sof_dmic_be_type {int sof_intel_board_card_late_probe (struct snd_soc_card *card); +int sof_intel_board_set_codec_link (struct device *dev, +struct snd_soc_dai_link *link,int be_id, +enum sof_ssp_codec codec_type,int ssp_codec);int sof_intel_board_set_dmic_link (struct device *dev,struct snd_soc_dai_link *link,int be_id,enum sof_dmic_be_type be_type);
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 7/27 ASoC: Intel: sof_cs42l42: use common module for codec link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for headphone codec DAI link initialization.
--- sound/soc/intel/boards/sof_cs42l42.c | 60 ++++++++-------------------- 1 file changed, 16 insertions(+), 44 deletions(-)
sound/soc/intel/boards/sof_cs42l42.c +16 -44
@@ -245,45 +245,6 @@ static int create_spk_amp_dai_links(struct device *dev,return ret; } -static int create_hp_codec_dai_links (struct device *dev, -struct snd_soc_dai_link *links, -struct snd_soc_dai_link_component *cpus, -int *id,int ssp_codec) -{ -/* codec SSP */ - links[*id].name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-Codec" , - ssp_codec); -if (!links[*id].name) - goto devm_err; - - links[*id].id = *id; - links[*id].codecs = cs42l42_component; - links[*id].num_codecs =ARRAY_SIZE (cs42l42_component); - links[*id].platforms = platform_component; - links[*id].num_platforms =ARRAY_SIZE (platform_component); - links[*id].init = sof_cs42l42_init; - links[*id].exit = sof_cs42l42_exit; - links[*id].ops = &sof_cs42l42_ops; - links[*id].dpcm_playback =1 ; - 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) - goto devm_err; - - (*id)++; - -return 0 ; - -devm_err: -return -ENOMEM ; -} - static int create_bt_offload_dai_links(struct device *dev, struct snd_soc_dai_link *links, struct snd_soc_dai_link_component *cpus,
@@ -350,12 +311,23 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,switch (link_type) {case LINK_HP : - ret =create_hp_codec_dai_links (dev, links, cpus, &id, ssp_codec); -if (ret <0 ) { + ret =sof_intel_board_set_codec_link (dev, &links[id], id, +CODEC_CS42L42 , + ssp_codec); +if (ret) {dev_err (dev,"fail to create hp codec dai links, ret %d\n" , ret); goto devm_err; } + +/* codec-specific fields */ + links[id].codecs = cs42l42_component; + links[id].num_codecs =ARRAY_SIZE (cs42l42_component); + links[id].init = sof_cs42l42_init; + links[id].exit = sof_cs42l42_exit; + links[id].ops = &sof_cs42l42_ops; + + id++;break ;case LINK_SPK : ret = create_spk_amp_dai_links(dev, links, cpus, &id,
@@ -440,7 +412,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_bt, ssp_amp, ssp_codec; +int ret, ssp_bt, ssp_amp; ctx =devm_kzalloc (&pdev->dev,sizeof (*ctx),GFP_KERNEL );if (!ctx)
@@ -475,7 +447,7 @@ static int sof_audio_probe(struct platform_device *pdev) ssp_amp = (sof_cs42l42_quirk &SOF_CS42L42_SSP_AMP_MASK ) >>SOF_CS42L42_SSP_AMP_SHIFT ; - ssp_codec = sof_cs42l42_quirk &SOF_CS42L42_SSP_CODEC_MASK ; + ctx->ssp_codec = sof_cs42l42_quirk &SOF_CS42L42_SSP_CODEC_MASK ;/* compute number of dai links */ sof_audio_card_cs42l42.num_links =1 + ctx->dmic_be_num + ctx->hdmi_num;
@@ -486,7 +458,7 @@ static int sof_audio_probe(struct platform_device *pdev) sof_audio_card_cs42l42.num_links++; dai_links =sof_card_dai_links_create (&pdev->dev, ctx->amp_type, - ssp_codec, ssp_amp, ssp_bt, + ctx->ssp_codec, ssp_amp, ssp_bt, ctx->dmic_be_num, ctx->hdmi_num, ctx->hdmi.idisp_codec);if (!dai_links)
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 8/27 ASoC: Intel: sof_nau8825: use common module for codec link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for headphone codec DAI link initialization.
--- sound/soc/intel/boards/sof_nau8825.c | 29 ++++++++-------------------- 1 file changed, 8 insertions(+), 21 deletions(-)
sound/soc/intel/boards/sof_nau8825.c +8 -21
@@ -226,30 +226,17 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, goto devm_err;/* codec SSP */ - links[id].name =devm_kasprintf (dev,GFP_KERNEL , -"SSP%d-Codec" , ssp_codec); -if (!links[id].name) - goto devm_err; + ret =sof_intel_board_set_codec_link (dev, &links[id], id,CODEC_NAU8825 , + ssp_codec); +if (ret) +return NULL ; - links[id].id = id; +/* codec-specific fields */ links[id].codecs = nau8825_component; links[id].num_codecs =ARRAY_SIZE (nau8825_component); - links[id].platforms = platform_component; - links[id].num_platforms =ARRAY_SIZE (platform_component); links[id].init = sof_nau8825_codec_init; links[id].exit = sof_nau8825_codec_exit; links[id].ops = &sof_nau8825_ops; - links[id].dpcm_playback =1 ; - 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) - goto devm_err; id++;
@@ -368,7 +355,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, ssp_codec; +int ret, ssp_amp; ctx =devm_kzalloc (&pdev->dev,sizeof (*ctx),GFP_KERNEL );if (!ctx)
@@ -396,7 +383,7 @@ static int sof_audio_probe(struct platform_device *pdev) ssp_amp = (sof_nau8825_quirk &SOF_NAU8825_SSP_AMP_MASK ) >>SOF_NAU8825_SSP_AMP_SHIFT ; - ssp_codec = sof_nau8825_quirk &SOF_NAU8825_SSP_CODEC_MASK ; + ctx->ssp_codec = sof_nau8825_quirk &SOF_NAU8825_SSP_CODEC_MASK ;/* compute number of dai links */ sof_audio_card_nau8825.num_links =1 + ctx->dmic_be_num + ctx->hdmi_num;
@@ -408,7 +395,7 @@ static int sof_audio_probe(struct platform_device *pdev) sof_audio_card_nau8825.num_links++; dai_links =sof_card_dai_links_create (&pdev->dev, ctx->amp_type, - ssp_codec, ssp_amp, + ctx->ssp_codec, ssp_amp, ctx->dmic_be_num, ctx->hdmi_num, ctx->hdmi.idisp_codec);if (!dai_links)
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 9/27 ASoC: Intel: sof_rt5682: use common module for codec link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for headphone codec DAI link initialization.
--- sound/soc/intel/boards/sof_rt5682.c | 38 ++++++++--------------------- 1 file changed, 10 insertions(+), 28 deletions(-)
sound/soc/intel/boards/sof_rt5682.c +10 -28
@@ -591,13 +591,12 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type, goto devm_err;/* codec SSP */ - links[id].name =devm_kasprintf (dev,GFP_KERNEL , -"SSP%d-Codec" , ssp_codec); -if (!links[id].name) - goto devm_err; - - links[id].id = id; + ret =sof_intel_board_set_codec_link (dev, &links[id], id, codec_type, + ssp_codec); +if (ret) +return NULL ; +/* codec-specific fields */ switch (codec_type) {case CODEC_RT5650 : links[id].codecs = &rt5650_components[0 ];
@@ -616,23 +615,11 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type,return NULL ; } - links[id].platforms = platform_component; - links[id].num_platforms =ARRAY_SIZE (platform_component); links[id].init = sof_rt5682_codec_init; links[id].exit = sof_rt5682_codec_exit; links[id].ops = &sof_rt5682_ops; - links[id].dpcm_playback =1 ; - 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_codec); -if (!links[id].cpus->dai_name) - goto devm_err; - }else { + +if (!is_legacy_cpu) {/* * Currently, On SKL+ platforms MCLK will be turned off in sof * runtime suspended, and it will go into runtime suspended
@@ -643,11 +630,6 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type,* It can be removed once we can control MCLK by driver. */ links[id].ignore_pmdown_time =1 ; - links[id].cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL , -"SSP%d Pin" , - ssp_codec); -if (!links[id].cpus->dai_name) - goto devm_err; } id++;
@@ -819,7 +801,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, ssp_codec; +int ret, ssp_amp; ctx =devm_kzalloc (&pdev->dev,sizeof (*ctx),GFP_KERNEL );if (!ctx)
@@ -888,7 +870,7 @@ static int sof_audio_probe(struct platform_device *pdev) ssp_amp = (sof_rt5682_quirk &SOF_RT5682_SSP_AMP_MASK ) >>SOF_RT5682_SSP_AMP_SHIFT ; - ssp_codec = sof_rt5682_quirk &SOF_RT5682_SSP_CODEC_MASK ; + ctx->ssp_codec = sof_rt5682_quirk &SOF_RT5682_SSP_CODEC_MASK ;/* compute number of dai links */ sof_audio_card_rt5682.num_links =1 + ctx->dmic_be_num + ctx->hdmi_num;
@@ -905,7 +887,7 @@ 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, ssp_codec, ssp_amp, + ctx->amp_type, ctx->ssp_codec, ssp_amp, ctx->dmic_be_num, ctx->hdmi_num, ctx->hdmi.idisp_codec, ctx->rt5682.is_legacy_cpu);
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 10/27 ASoC: Intel: board_helpers: support amp link initialization
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Add a helper function for machine drivers to initialize speaker amplifier DAI link. The function will initialize common fields and let caller to initialize codec-specific fields like codec, init, exit, and ops fields.
--- sound/soc/intel/boards/sof_board_helpers.c | 42 ++++++++++++++++++++++ sound/soc/intel/boards/sof_board_helpers.h | 5 +++ 2 files changed, 47 insertions(+)
sound/soc/intel/boards/sof_board_helpers.c +42 -0
@@ -248,6 +248,48 @@ int sof_intel_board_set_intel_hdmi_link(struct device *dev, }EXPORT_SYMBOL_NS (sof_intel_board_set_intel_hdmi_link,SND_SOC_INTEL_SOF_BOARD_HELPERS ); +int sof_intel_board_set_ssp_amp_link (struct device *dev, +struct snd_soc_dai_link *link,int be_id, +enum sof_ssp_codec amp_type,int ssp_amp) +{ +struct snd_soc_dai_link_component *cpus; + +dev_dbg (dev,"link %d: ssp amp %s, ssp %d\n" , be_id, +sof_ssp_get_codec_name (amp_type), ssp_amp); + +/* link name */ + link->name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-Codec" , ssp_amp); +if (!link->name) +return -ENOMEM ; + +/* cpus */ + cpus =devm_kzalloc (dev,sizeof (struct snd_soc_dai_link_component ), +GFP_KERNEL ); +if (!cpus) +return -ENOMEM ; + + cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d Pin" , ssp_amp); +if (!cpus->dai_name) +return -ENOMEM ; + + link->cpus = cpus; + link->num_cpus =1 ; + +/* codecs - caller to handle */ + +/* platforms */ + link->platforms = platform_component; + link->num_platforms =ARRAY_SIZE (platform_component); + + link->id = be_id; + link->no_pcm =1 ; + link->dpcm_capture =1 ;/* feedback stream or firmware-generated echo reference */ + link->dpcm_playback =1 ; + +return 0 ; +} +EXPORT_SYMBOL_NS (sof_intel_board_set_ssp_amp_link,SND_SOC_INTEL_SOF_BOARD_HELPERS ); +MODULE_DESCRIPTION ("ASoC Intel SOF Machine Driver Board Helpers" );MODULE_AUTHOR ("Brent Lu <[email protected]>" );MODULE_LICENSE ("GPL" );
sound/soc/intel/boards/sof_board_helpers.h +5 -0
@@ -31,6 +31,7 @@ struct sof_rt5682_private {* @dmic_be_num: number of Intel PCH DMIC BE link * @hdmi_num: number of Intel HDMI BE link * @ssp_codec: ssp port number of headphone BE link +* @ssp_amp: ssp port number of speaker BE link * @rt5682: private data for rt5682 machine driver */ struct sof_card_private {
@@ -44,6 +45,7 @@ struct sof_card_private {int hdmi_num;int ssp_codec; +int ssp_amp;union {struct sof_rt5682_private rt5682;
@@ -66,5 +68,8 @@ int sof_intel_board_set_dmic_link(struct device *dev,int sof_intel_board_set_intel_hdmi_link (struct device *dev,struct snd_soc_dai_link *link,int be_id,int hdmi_id,bool idisp_codec); +int sof_intel_board_set_ssp_amp_link (struct device *dev, +struct snd_soc_dai_link *link,int be_id, +enum sof_ssp_codec amp_type,int ssp_amp);#endif /* __SOF_INTEL_BOARD_HELPERS_H */
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 11/27 ASoC: Intel: sof_cs42l42: use common module for amp link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for speaker amplifier DAI link initialization.
--- sound/soc/intel/boards/sof_cs42l42.c | 98 +++++++++------------------- 1 file changed, 32 insertions(+), 66 deletions(-)
sound/soc/intel/boards/sof_cs42l42.c +32 -66
@@ -189,62 +189,6 @@ static struct snd_soc_dai_link_component cs42l42_component[] = { } }; -static int create_spk_amp_dai_links (struct device *dev, -struct snd_soc_dai_link *links, -struct snd_soc_dai_link_component *cpus, -int *id,enum sof_ssp_codec amp_type, -int ssp_amp) -{ -int ret =0 ; - -/* speaker amp */ -if (amp_type ==CODEC_NONE ) -return 0 ; - - links[*id].name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-Codec" , - ssp_amp); -if (!links[*id].name) { - ret = -ENOMEM ; - goto devm_err; - } - - links[*id].id = *id; - -switch (amp_type) { -case CODEC_MAX98357A : -max_98357a_dai_link (&links[*id]); -break ; -case CODEC_MAX98360A : -max_98360a_dai_link (&links[*id]); -break ; -default : -dev_err (dev,"invalid amp type %d\n" , amp_type); -return -EINVAL ; - } - - links[*id].platforms = platform_component; - links[*id].num_platforms =ARRAY_SIZE (platform_component); - links[*id].dpcm_playback =1 ; -/* 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_amp); -if (!links[*id].cpus->dai_name) { - ret = -ENOMEM ; - goto devm_err; - } - - (*id)++; - -devm_err: -return ret; -} - static int create_bt_offload_dai_links(struct device *dev, struct snd_soc_dai_link *links, struct snd_soc_dai_link_component *cpus,
@@ -330,12 +274,33 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, id++;break ;case LINK_SPK : - ret =create_spk_amp_dai_links (dev, links, cpus, &id, - amp_type, ssp_amp); -if (ret <0 ) { -dev_err (dev,"fail to create spk amp dai links, ret %d\n" , - ret); - goto devm_err; +if (amp_type !=CODEC_NONE ) { + ret =sof_intel_board_set_ssp_amp_link (dev, + &links[id], + id, + amp_type, + ssp_amp); +if (ret) { +dev_err (dev,"fail to create spk amp dai links, ret %d\n" , + ret); + goto devm_err; + } + +/* codec-specific fields */ +switch (amp_type) { +case CODEC_MAX98357A : +max_98357a_dai_link (&links[id]); +break ; +case CODEC_MAX98360A : +max_98360a_dai_link (&links[id]); +break ; +default : +dev_err (dev,"invalid amp type %d\n" , + amp_type); + goto devm_err; + } + + id++; }break ;case LINK_DMIC :
@@ -412,7 +377,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_bt, ssp_amp; +int ret, ssp_bt; ctx =devm_kzalloc (&pdev->dev,sizeof (*ctx),GFP_KERNEL );if (!ctx)
@@ -444,7 +409,7 @@ static int sof_audio_probe(struct platform_device *pdev) ssp_bt = (sof_cs42l42_quirk &SOF_CS42L42_SSP_BT_MASK ) >>SOF_CS42L42_SSP_BT_SHIFT ; - ssp_amp = (sof_cs42l42_quirk &SOF_CS42L42_SSP_AMP_MASK ) >> + ctx->ssp_amp = (sof_cs42l42_quirk &SOF_CS42L42_SSP_AMP_MASK ) >>SOF_CS42L42_SSP_AMP_SHIFT ; ctx->ssp_codec = sof_cs42l42_quirk &SOF_CS42L42_SSP_CODEC_MASK ;
@@ -458,8 +423,9 @@ static int sof_audio_probe(struct platform_device *pdev) sof_audio_card_cs42l42.num_links++; dai_links =sof_card_dai_links_create (&pdev->dev, ctx->amp_type, - ctx->ssp_codec, ssp_amp, ssp_bt, - ctx->dmic_be_num, ctx->hdmi_num, + ctx->ssp_codec, ctx->ssp_amp, + ssp_bt, ctx->dmic_be_num, + ctx->hdmi_num, ctx->hdmi.idisp_codec);if (!dai_links)return -ENOMEM ;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 12/27 ASoC: Intel: sof_nau8825: use common module for amp link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for speaker amplifier DAI link initialization.
--- sound/soc/intel/boards/sof_nau8825.c | 31 +++++++--------------------- 1 file changed, 8 insertions(+), 23 deletions(-)
sound/soc/intel/boards/sof_nau8825.c +8 -23
@@ -273,13 +273,12 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_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_ssp_amp_link (dev, &links[id], id, + amp_type, ssp_amp); +if (ret) +return NULL ; +/* codec-specific fields */ switch (amp_type) {case CODEC_MAX98360A :max_98360a_dai_link (&links[id]);
@@ -304,20 +303,6 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,return NULL ; } - 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 ; - 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++; }
@@ -355,7 +340,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)
@@ -380,7 +365,7 @@ static int sof_audio_probe(struct platform_device *pdev)if (mach->mach_params.codec_mask &IDISP_CODEC_MASK ) ctx->hdmi.idisp_codec = true; - ssp_amp = (sof_nau8825_quirk &SOF_NAU8825_SSP_AMP_MASK ) >> + ctx->ssp_amp = (sof_nau8825_quirk &SOF_NAU8825_SSP_AMP_MASK ) >>SOF_NAU8825_SSP_AMP_SHIFT ; ctx->ssp_codec = sof_nau8825_quirk &SOF_NAU8825_SSP_CODEC_MASK ;
@@ -395,7 +380,7 @@ static int sof_audio_probe(struct platform_device *pdev) sof_audio_card_nau8825.num_links++; dai_links =sof_card_dai_links_create (&pdev->dev, ctx->amp_type, - ctx->ssp_codec, ssp_amp, + ctx->ssp_codec, ctx->ssp_amp, ctx->dmic_be_num, ctx->hdmi_num, ctx->hdmi.idisp_codec);if (!dai_links)
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 13/27 ASoC: Intel: sof_rt5682: use common module for amp link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for speaker amplifier DAI link initialization.
--- sound/soc/intel/boards/sof_rt5682.c | 43 +++++++---------------------- 1 file changed, 10 insertions(+), 33 deletions(-)
sound/soc/intel/boards/sof_rt5682.c +10 -33
@@ -666,13 +666,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_ssp_amp_link (dev, &links[id], id, + amp_type, ssp_amp); +if (ret) +return NULL ; +/* codec-specific fields */ switch (amp_type) {case CODEC_MAX98357A :max_98357a_dai_link (&links[id]);
@@ -713,29 +712,6 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type,return NULL ; } - 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 +777,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 +843,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 +863,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)
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 14/27 ASoC: Intel: sof_ssp_amp: use common module for amp link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for speaker amplifier DAI link initialization.
--- sound/soc/intel/boards/sof_ssp_amp.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
sound/soc/intel/boards/sof_ssp_amp.c +8 -19
@@ -154,12 +154,13 @@ 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) + be_id = fixed_be ?SPK_BE_ID : id; + ret =sof_intel_board_set_ssp_amp_link (dev, &links[id], be_id, + amp_type, ssp_codec); +if (ret)return NULL ; - links[id].id = fixed_be ?SPK_BE_ID : id; - +/* codec-specific fields */ switch (amp_type) {case CODEC_CS35L41 :cs35l41_set_dai_link (&links[id]);
@@ -172,18 +173,6 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec 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) -return NULL ; - id++; }
@@ -256,7 +245,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)
@@ -272,7 +261,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;
@@ -303,7 +292,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)
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 15/27 ASoC: Intel: sof_ssp_amp: rename function parameter
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Rename the parameter 'ssp_codec' of sof_card_dai_links_create() since it's the port number of speaker amplifier. No functional change in this commit.
--- sound/soc/intel/boards/sof_ssp_amp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/intel/boards/sof_ssp_amp.c +2 -2
@@ -98,7 +98,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;
@@ -156,7 +156,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,if (amp_type !=CODEC_NONE ) { be_id = fixed_be ?SPK_BE_ID : id; ret =sof_intel_board_set_ssp_amp_link (dev, &links[id], be_id, - amp_type, ssp_codec); + amp_type, ssp_amp);if (ret)return NULL ;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 16/27 ASoC: Intel: board_helpers: support BT offload link initialization
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Add a helper function for machine drivers to initialize BT offload DAI link.
--- sound/soc/intel/boards/sof_board_helpers.c | 43 ++++++++++++++++++++++ sound/soc/intel/boards/sof_board_helpers.h | 8 ++++ 2 files changed, 51 insertions(+)
sound/soc/intel/boards/sof_board_helpers.c +43 -0
@@ -290,6 +290,49 @@ int sof_intel_board_set_ssp_amp_link(struct device *dev, }EXPORT_SYMBOL_NS (sof_intel_board_set_ssp_amp_link,SND_SOC_INTEL_SOF_BOARD_HELPERS ); +int sof_intel_board_set_bt_link (struct device *dev, +struct snd_soc_dai_link *link,int be_id, +int ssp_bt) +{ +struct snd_soc_dai_link_component *cpus; + +dev_dbg (dev,"link %d: bt offload, ssp %d\n" , be_id, ssp_bt); + +/* link name */ + link->name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-BT" , ssp_bt); +if (!link->name) +return -ENOMEM ; + +/* cpus */ + cpus =devm_kzalloc (dev,sizeof (struct snd_soc_dai_link_component ), +GFP_KERNEL ); +if (!cpus) +return -ENOMEM ; + + cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d Pin" , ssp_bt); +if (!cpus->dai_name) +return -ENOMEM ; + + link->cpus = cpus; + link->num_cpus =1 ; + +/* codecs */ + link->codecs = &snd_soc_dummy_dlc; + link->num_codecs =1 ; + +/* platforms */ + link->platforms = platform_component; + link->num_platforms =ARRAY_SIZE (platform_component); + + link->id = be_id; + link->no_pcm =1 ; + link->dpcm_capture =1 ; + link->dpcm_playback =1 ; + +return 0 ; +} +EXPORT_SYMBOL_NS (sof_intel_board_set_bt_link,SND_SOC_INTEL_SOF_BOARD_HELPERS ); +MODULE_DESCRIPTION ("ASoC Intel SOF Machine Driver Board Helpers" );MODULE_AUTHOR ("Brent Lu <[email protected]>" );MODULE_LICENSE ("GPL" );
sound/soc/intel/boards/sof_board_helpers.h +8 -0
@@ -32,6 +32,8 @@ struct sof_rt5682_private {* @hdmi_num: number of Intel HDMI BE link * @ssp_codec: ssp port number of headphone BE link * @ssp_amp: ssp port number of speaker BE link +* @ssp_bt: ssp port number of BT offload BE link +* @bt_offload_present: true to create BT offload BE link * @rt5682: private data for rt5682 machine driver */ struct sof_card_private {
@@ -46,6 +48,9 @@ struct sof_card_private {int ssp_codec;int ssp_amp; +int ssp_bt; + +bool bt_offload_present;union {struct sof_rt5682_private rt5682;
@@ -71,5 +76,8 @@ int sof_intel_board_set_intel_hdmi_link(struct device *dev,int sof_intel_board_set_ssp_amp_link (struct device *dev,struct snd_soc_dai_link *link,int be_id,enum sof_ssp_codec amp_type,int ssp_amp); +int sof_intel_board_set_bt_link (struct device *dev, +struct snd_soc_dai_link *link,int be_id, +int ssp_bt);#endif /* __SOF_INTEL_BOARD_HELPERS_H */
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 17/27 ASoC: Intel: sof_cs42l42: use common module for BT offload link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for BT offload DAI link initialization.
--- sound/soc/intel/boards/sof_cs42l42.c | 79 +++++++--------------------- 1 file changed, 19 insertions(+), 60 deletions(-)
sound/soc/intel/boards/sof_cs42l42.c +19 -60
@@ -138,13 +138,6 @@ static const struct snd_soc_ops sof_cs42l42_ops = { .hw_params = sof_cs42l42_hw_params, }; -static struct snd_soc_dai_link_component platform_component[] = { - { -/* name might be overridden during probe */ - .name ="0000:00:1f.3" - } -}; -static int sof_card_late_probe (struct snd_soc_card *card) {return sof_intel_board_card_late_probe (card);
@@ -189,52 +182,11 @@ static struct snd_soc_dai_link_component cs42l42_component[] = { } }; -static int create_bt_offload_dai_links (struct device *dev, -struct snd_soc_dai_link *links, -struct snd_soc_dai_link_component *cpus, -int *id,int ssp_bt) -{ -/* bt offload */ -if (!(sof_cs42l42_quirk &SOF_BT_OFFLOAD_PRESENT )) -return 0 ; - - links[*id].name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-BT" , - ssp_bt); -if (!links[*id].name) - goto devm_err; - - links[*id].id = *id; - links[*id].codecs = &snd_soc_dummy_dlc; - links[*id].num_codecs =1 ; - links[*id].platforms = platform_component; - links[*id].num_platforms =ARRAY_SIZE (platform_component); - - links[*id].dpcm_playback =1 ; - 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_bt); -if (!links[*id].cpus->dai_name) - goto devm_err; - - (*id)++; - -return 0 ; - -devm_err: -return -ENOMEM ; -} -static struct snd_soc_dai_link *sof_card_dai_links_create (struct device *dev,enum sof_ssp_codec amp_type,int ssp_codec,int ssp_amp,int ssp_bt,int dmic_be_num,int hdmi_num,bool idisp_codec) { -struct snd_soc_dai_link_component *cpus;struct snd_soc_dai_link *links;int ret;int id =0 ;
@@ -243,9 +195,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, links =devm_kcalloc (dev, sof_audio_card_cs42l42.num_links,sizeof (struct snd_soc_dai_link ),GFP_KERNEL ); - cpus =devm_kcalloc (dev, sof_audio_card_cs42l42.num_links, -sizeof (struct snd_soc_dai_link_component ),GFP_KERNEL ); -if (!links || !cpus) +if (!links) goto devm_err; link_seq = (sof_cs42l42_quirk &SOF_CS42L42_DAILINK_MASK ) >>SOF_CS42L42_DAILINK_SHIFT ;
@@ -350,11 +300,17 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, }break ;case LINK_BT : - ret =create_bt_offload_dai_links (dev, links, cpus, &id, ssp_bt); -if (ret <0 ) { -dev_err (dev,"fail to create bt offload dai links, ret %d\n" , - ret); - goto devm_err; +if (sof_cs42l42_quirk &SOF_BT_OFFLOAD_PRESENT ) { + ret =sof_intel_board_set_bt_link (dev, + &links[id], id, + ssp_bt); +if (ret) { +dev_err (dev,"fail to create bt offload dai links, ret %d\n" , + ret); + goto devm_err; + } + + id++; }break ;case LINK_NONE :
@@ -377,7 +333,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_bt; +int ret; ctx =devm_kzalloc (&pdev->dev,sizeof (*ctx),GFP_KERNEL );if (!ctx)
@@ -406,7 +362,8 @@ static int sof_audio_probe(struct platform_device *pdev)dev_dbg (&pdev->dev,"sof_cs42l42_quirk = %lx\n" , sof_cs42l42_quirk); - ssp_bt = (sof_cs42l42_quirk &SOF_CS42L42_SSP_BT_MASK ) >> +/* port number of peripherals attached to ssp interface */ + ctx->ssp_bt = (sof_cs42l42_quirk &SOF_CS42L42_SSP_BT_MASK ) >>SOF_CS42L42_SSP_BT_SHIFT ; ctx->ssp_amp = (sof_cs42l42_quirk & SOF_CS42L42_SSP_AMP_MASK) >>
@@ -419,12 +376,14 @@ static int sof_audio_probe(struct platform_device *pdev)if (ctx->amp_type !=CODEC_NONE ) sof_audio_card_cs42l42.num_links++; -if (sof_cs42l42_quirk &SOF_BT_OFFLOAD_PRESENT ) +if (sof_cs42l42_quirk &SOF_BT_OFFLOAD_PRESENT ) { + ctx->bt_offload_present = true; sof_audio_card_cs42l42.num_links++; + } dai_links =sof_card_dai_links_create (&pdev->dev, ctx->amp_type, ctx->ssp_codec, ctx->ssp_amp, - ssp_bt, ctx->dmic_be_num, + ctx->ssp_bt, ctx->dmic_be_num, ctx->hdmi_num, ctx->hdmi.idisp_codec);if (!dai_links)
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 18/27 ASoC: Intel: sof_nau8825: use common module for BT offload link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for BT offload DAI link initialization.
--- sound/soc/intel/boards/sof_nau8825.c | 42 +++++++++------------------- 1 file changed, 13 insertions(+), 29 deletions(-)
sound/soc/intel/boards/sof_nau8825.c +13 -29
@@ -138,13 +138,6 @@ static struct snd_soc_ops sof_nau8825_ops = { .hw_params = sof_nau8825_hw_params, }; -static struct snd_soc_dai_link_component platform_component[] = { - { -/* name might be overridden during probe */ - .name ="0000:00:1f.3" - } -}; -static int sof_card_late_probe (struct snd_soc_card *card) {struct sof_card_private *ctx =snd_soc_card_get_drvdata (card);
@@ -212,7 +205,6 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, int ssp_codec, int ssp_amp, int dmic_be_num, int hdmi_num, bool idisp_codec) { - struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link *links;int i;int id =0 ;
@@ -220,9 +212,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, links =devm_kcalloc (dev, sof_audio_card_nau8825.num_links,sizeof (struct snd_soc_dai_link ),GFP_KERNEL ); - cpus =devm_kcalloc (dev, sof_audio_card_nau8825.num_links, -sizeof (struct snd_soc_dai_link_component ),GFP_KERNEL ); -if (!links || !cpus) +if (!links) goto devm_err;/* codec SSP */
@@ -311,23 +301,11 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,int port = (sof_nau8825_quirk &SOF_BT_OFFLOAD_SSP_MASK ) >>SOF_BT_OFFLOAD_SSP_SHIFT ; - links[id].id = id; - links[id].cpus = &cpus[id]; - links[id].cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL , -"SSP%d Pin" , port); -if (!links[id].cpus->dai_name) - goto devm_err; - links[id].name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-BT" , port); -if (!links[id].name) - goto devm_err; - links[id].codecs = &snd_soc_dummy_dlc; - links[id].num_codecs =1 ; - links[id].platforms = platform_component; - links[id].num_platforms =ARRAY_SIZE (platform_component); - links[id].dpcm_playback =1 ; - links[id].dpcm_capture =1 ; - links[id].no_pcm =1 ; - links[id].num_cpus =1 ; + ret =sof_intel_board_set_bt_link (dev, &links[id], id, port); +if (ret) +return NULL ; + + id++; }return links;
@@ -365,6 +343,10 @@ static int sof_audio_probe(struct platform_device *pdev)if (mach->mach_params.codec_mask &IDISP_CODEC_MASK ) ctx->hdmi.idisp_codec = true; +/* port number of peripherals attached to ssp interface */ + ctx->ssp_bt = (sof_nau8825_quirk &SOF_BT_OFFLOAD_SSP_MASK ) >> +SOF_BT_OFFLOAD_SSP_SHIFT ; + ctx->ssp_amp = (sof_nau8825_quirk &SOF_NAU8825_SSP_AMP_MASK ) >>SOF_NAU8825_SSP_AMP_SHIFT ;
@@ -376,8 +358,10 @@ static int sof_audio_probe(struct platform_device *pdev)if (ctx->amp_type !=CODEC_NONE ) sof_audio_card_nau8825.num_links++; -if (sof_nau8825_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) +if (sof_nau8825_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) { + ctx->bt_offload_present = true; sof_audio_card_nau8825.num_links++; + } dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type, ctx->ssp_codec, ctx->ssp_amp,
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 19/27 ASoC: Intel: sof_rt5682: use common module for BT offload link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for BT offload DAI link initialization.
--- sound/soc/intel/boards/sof_rt5682.c | 30 ++++++++++++----------------- 1 file changed, 12 insertions(+), 18 deletions(-)
sound/soc/intel/boards/sof_rt5682.c +12 -18
@@ -720,23 +720,11 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type,int port = (sof_rt5682_quirk &SOF_BT_OFFLOAD_SSP_MASK ) >>SOF_BT_OFFLOAD_SSP_SHIFT ; - links[id].id = id; - links[id].cpus = &cpus[id]; - links[id].cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL , -"SSP%d Pin" , port); -if (!links[id].cpus->dai_name) - goto devm_err; - links[id].name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-BT" , port); -if (!links[id].name) - goto devm_err; - links[id].codecs = &snd_soc_dummy_dlc; - links[id].num_codecs =1 ; - links[id].platforms = platform_component; - links[id].num_platforms =ARRAY_SIZE (platform_component); - links[id].dpcm_playback =1 ; - links[id].dpcm_capture =1 ; - links[id].no_pcm =1 ; - links[id].num_cpus =1 ; + ret =sof_intel_board_set_bt_link (dev, &links[id], id, port); +if (ret) +return NULL ; + + id++; }/* HDMI-In SSP */
@@ -843,6 +831,10 @@ static int sof_audio_probe(struct platform_device *pdev)dev_dbg (&pdev->dev,"sof_rt5682_quirk = %lx\n" , sof_rt5682_quirk); +/* port number of peripherals attached to ssp interface */ + ctx->ssp_bt = (sof_rt5682_quirk &SOF_BT_OFFLOAD_SSP_MASK ) >> +SOF_BT_OFFLOAD_SSP_SHIFT ; + ctx->ssp_amp = (sof_rt5682_quirk &SOF_RT5682_SSP_AMP_MASK ) >>SOF_RT5682_SSP_AMP_SHIFT ;
@@ -854,8 +846,10 @@ static int sof_audio_probe(struct platform_device *pdev)if (ctx->amp_type !=CODEC_NONE ) sof_audio_card_rt5682.num_links++; -if (sof_rt5682_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) +if (sof_rt5682_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) { + ctx->bt_offload_present = true; sof_audio_card_rt5682.num_links++; + }if (sof_rt5682_quirk &SOF_SSP_HDMI_CAPTURE_PRESENT_MASK ) sof_audio_card_rt5682.num_links +=
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 20/27 ASoC: Intel: sof_ssp_amp: use common module for BT offload link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for BT offload DAI link initialization.
--- sound/soc/intel/boards/sof_ssp_amp.c | 31 ++++++++++------------------ 1 file changed, 11 insertions(+), 20 deletions(-)
sound/soc/intel/boards/sof_ssp_amp.c +11 -20
@@ -215,29 +215,14 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,int port = (sof_ssp_amp_quirk &SOF_BT_OFFLOAD_SSP_MASK ) >>SOF_BT_OFFLOAD_SSP_SHIFT ; - links[id].id = id; - links[id].cpus = &cpus[id]; - links[id].cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL , -"SSP%d Pin" , port); -if (!links[id].cpus->dai_name) - goto devm_err; - links[id].name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-BT" , port); -if (!links[id].name) - goto devm_err; - links[id].codecs = &snd_soc_dummy_dlc; - links[id].num_codecs =1 ; - links[id].platforms = platform_component; - links[id].num_platforms =ARRAY_SIZE (platform_component); - links[id].dpcm_playback =1 ; - links[id].dpcm_capture =1 ; - links[id].no_pcm =1 ; - links[id].num_cpus =1 ; + ret =sof_intel_board_set_bt_link (dev, &links[id], id, port); +if (ret) +return NULL ; + id++; }return links; -devm_err: -return NULL ; }static int sof_ssp_amp_probe (struct platform_device *pdev)
@@ -261,6 +246,10 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)else ctx->dmic_be_num =0 ; +/* port number of peripherals attached to ssp interface */ + ctx->ssp_bt = (sof_ssp_amp_quirk &SOF_BT_OFFLOAD_SSP_MASK ) >> +SOF_BT_OFFLOAD_SSP_SHIFT ; + ctx->ssp_amp = sof_ssp_amp_quirk &SOF_AMPLIFIER_SSP_MASK ;/* set number of dai links */
@@ -288,8 +277,10 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) ctx->hdmi_num =0 ; } -if (sof_ssp_amp_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) +if (sof_ssp_amp_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) { + ctx->bt_offload_present = true; sof_ssp_amp_card.num_links++; + } dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type, ctx->ssp_amp, ctx->dmic_be_num,
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 21/27 ASoC: Intel: sof_ssp_amp: simplify HDMI-In quirks
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use bit mask to handle SSP port number of HDMI-In devices to simplify the code. No functional change in this patch.
--- sound/soc/intel/boards/sof_ssp_amp.c | 70 +++++++++++----------------- 1 file changed, 26 insertions(+), 44 deletions(-)
sound/soc/intel/boards/sof_ssp_amp.c +26 -44
@@ -27,21 +27,10 @@#define SOF_AMPLIFIER_SSP_MASK (GENMASK(3, 0))/* HDMI capture*/ -#define SOF_SSP_HDMI_CAPTURE_PRESENT BIT(4) -#define SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT 5 -#define SOF_NO_OF_HDMI_CAPTURE_SSP_MASK (GENMASK(6, 5)) -#define SOF_NO_OF_HDMI_CAPTURE_SSP (quirk) \ - (((quirk) << SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT) & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) - -#define SOF_HDMI_CAPTURE_1_SSP_SHIFT 7 -#define SOF_HDMI_CAPTURE_1_SSP_MASK (GENMASK(9, 7)) -#define SOF_HDMI_CAPTURE_1_SSP (quirk) \ - (((quirk) << SOF_HDMI_CAPTURE_1_SSP_SHIFT) & SOF_HDMI_CAPTURE_1_SSP_MASK) - -#define SOF_HDMI_CAPTURE_2_SSP_SHIFT 10 -#define SOF_HDMI_CAPTURE_2_SSP_MASK (GENMASK(12, 10)) -#define SOF_HDMI_CAPTURE_2_SSP (quirk) \ - (((quirk) << SOF_HDMI_CAPTURE_2_SSP_SHIFT) & SOF_HDMI_CAPTURE_2_SSP_MASK) +#define SOF_HDMI_CAPTURE_SSP_MASK_SHIFT 4 +#define SOF_HDMI_CAPTURE_SSP_MASK_MASK (GENMASK(9, 4)) +#define SOF_HDMI_CAPTURE_SSP_MASK (quirk) \ + (((quirk) << SOF_HDMI_CAPTURE_SSP_MASK_SHIFT) & SOF_HDMI_CAPTURE_SSP_MASK_MASK)/* HDMI playback */ #define SOF_HDMI_PLAYBACK_PRESENT BIT(13)
@@ -108,6 +97,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,int ret;bool fixed_be = false;int be_id; +unsigned long ssp_mask_hdmi_in; links =devm_kcalloc (dev, sof_ssp_amp_card.num_links,sizeof (struct snd_soc_dai_link ),GFP_KERNEL );
@@ -117,20 +107,17 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,return NULL ;/* HDMI-In SSP */ -if (sof_ssp_amp_quirk &SOF_SSP_HDMI_CAPTURE_PRESENT ) { -int num_of_hdmi_ssp = (sof_ssp_amp_quirk &SOF_NO_OF_HDMI_CAPTURE_SSP_MASK ) >> -SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT ; + ssp_mask_hdmi_in = (sof_ssp_amp_quirk &SOF_HDMI_CAPTURE_SSP_MASK_MASK ) >> +SOF_HDMI_CAPTURE_SSP_MASK_SHIFT ; + +if (ssp_mask_hdmi_in) { +int port =0 ;/* the topology supports HDMI-IN uses fixed BE ID for DAI links */ fixed_be = true; be_id =HDMI_IN_BE_ID ; -for (i =1 ; i <= num_of_hdmi_ssp; i++) { -int port = (i ==1 ? (sof_ssp_amp_quirk &SOF_HDMI_CAPTURE_1_SSP_MASK ) >> -SOF_HDMI_CAPTURE_1_SSP_SHIFT : - (sof_ssp_amp_quirk &SOF_HDMI_CAPTURE_2_SSP_MASK ) >> -SOF_HDMI_CAPTURE_2_SSP_SHIFT ); - +for_each_set_bit (port, &ssp_mask_hdmi_in,32 ) { links[id].cpus = &cpus[id]; links[id].cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d Pin" , port);
@@ -231,6 +218,7 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)struct snd_soc_dai_link *dai_links;struct sof_card_private *ctx;int ret; +unsigned long ssp_mask_hdmi_in; ctx =devm_kzalloc (&pdev->dev,sizeof (*ctx),GFP_KERNEL );if (!ctx)
@@ -246,7 +234,10 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)else ctx->dmic_be_num =0 ; -/* port number of peripherals attached to ssp interface */ +/* port number/mask of peripherals attached to ssp interface */ + ssp_mask_hdmi_in = (sof_ssp_amp_quirk &SOF_HDMI_CAPTURE_SSP_MASK_MASK ) >> +SOF_HDMI_CAPTURE_SSP_MASK_SHIFT ; + ctx->ssp_bt = (sof_ssp_amp_quirk &SOF_BT_OFFLOAD_SSP_MASK ) >>SOF_BT_OFFLOAD_SSP_SHIFT ;
@@ -258,9 +249,8 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)if (ctx->amp_type !=CODEC_NONE ) sof_ssp_amp_card.num_links++; -if (sof_ssp_amp_quirk &SOF_SSP_HDMI_CAPTURE_PRESENT ) - sof_ssp_amp_card.num_links += (sof_ssp_amp_quirk &SOF_NO_OF_HDMI_CAPTURE_SSP_MASK ) >> -SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT ; +if (ssp_mask_hdmi_in) + sof_ssp_amp_card.num_links +=hweight32 (ssp_mask_hdmi_in);if (sof_ssp_amp_quirk &SOF_HDMI_PLAYBACK_PRESENT ) { ctx->hdmi_num = (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_PLAYBACK_MASK) >>
@@ -325,10 +315,8 @@ static const struct platform_device_id board_ids[] = { { .name = "tgl_rt1308_hdmi_ssp", .driver_data = (kernel_ulong_t)(SOF_AMPLIFIER_SSP(2) | - SOF_NO_OF_HDMI_CAPTURE_SSP(2) | - SOF_HDMI_CAPTURE_1_SSP(1) | - SOF_HDMI_CAPTURE_2_SSP(5) | - SOF_SSP_HDMI_CAPTURE_PRESENT), + SOF_HDMI_CAPTURE_SSP_MASK(0x22)), + /* SSP 1 and SSP 5 are used for HDMI IN */ }, { .name = "adl_cs35l41",
@@ -340,28 +328,22 @@ static const struct platform_device_id board_ids[] = { }, { .name = "adl_lt6911_hdmi_ssp", - .driver_data = (kernel_ulong_t)(SOF_NO_OF_HDMI_CAPTURE_SSP (2 ) | -SOF_HDMI_CAPTURE_1_SSP (0 ) | -SOF_HDMI_CAPTURE_2_SSP (2 ) | -SOF_SSP_HDMI_CAPTURE_PRESENT | + .driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) | + /* SSP 0 and SSP 2 are used for HDMI IN */ SOF_NO_OF_HDMI_PLAYBACK(3) | SOF_HDMI_PLAYBACK_PRESENT), }, { .name = "rpl_lt6911_hdmi_ssp", - .driver_data = (kernel_ulong_t)(SOF_NO_OF_HDMI_CAPTURE_SSP (2 ) | -SOF_HDMI_CAPTURE_1_SSP (0 ) | -SOF_HDMI_CAPTURE_2_SSP (2 ) | -SOF_SSP_HDMI_CAPTURE_PRESENT | + .driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) | + /* SSP 0 and SSP 2 are used for HDMI IN */ SOF_NO_OF_HDMI_PLAYBACK(3) | SOF_HDMI_PLAYBACK_PRESENT), }, { .name = "mtl_lt6911_hdmi_ssp", - .driver_data = (kernel_ulong_t)(SOF_NO_OF_HDMI_CAPTURE_SSP (2 ) | -SOF_HDMI_CAPTURE_1_SSP (0 ) | -SOF_HDMI_CAPTURE_2_SSP (2 ) | -SOF_SSP_HDMI_CAPTURE_PRESENT | + .driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) | + /* SSP 0 and SSP 2 are used for HDMI IN */ SOF_NO_OF_HDMI_PLAYBACK(3) | SOF_HDMI_PLAYBACK_PRESENT), },
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 22/27 ASoC: Intel: board_helpers: support HDMI-In link initialization
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Add a helper function for machine drivers to initialize HDMI-In DAI link.
--- sound/soc/intel/boards/sof_board_helpers.c | 42 ++++++++++++++++++++++ sound/soc/intel/boards/sof_board_helpers.h | 5 +++ 2 files changed, 47 insertions(+)
sound/soc/intel/boards/sof_board_helpers.c +42 -0
@@ -333,6 +333,48 @@ int sof_intel_board_set_bt_link(struct device *dev, }EXPORT_SYMBOL_NS (sof_intel_board_set_bt_link,SND_SOC_INTEL_SOF_BOARD_HELPERS ); +int sof_intel_board_set_hdmi_in_link (struct device *dev, +struct snd_soc_dai_link *link,int be_id, +int ssp_hdmi) +{ +struct snd_soc_dai_link_component *cpus; + +dev_dbg (dev,"link %d: hdmi-in, ssp %d\n" , be_id, ssp_hdmi); + +/* link name */ + link->name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-HDMI" , ssp_hdmi); +if (!link->name) +return -ENOMEM ; + +/* cpus */ + cpus =devm_kzalloc (dev,sizeof (struct snd_soc_dai_link_component ), +GFP_KERNEL ); +if (!cpus) +return -ENOMEM ; + + cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d Pin" , ssp_hdmi); +if (!cpus->dai_name) +return -ENOMEM ; + + link->cpus = cpus; + link->num_cpus =1 ; + +/* codecs */ + link->codecs = &snd_soc_dummy_dlc; + link->num_codecs =1 ; + +/* platforms */ + link->platforms = platform_component; + link->num_platforms =ARRAY_SIZE (platform_component); + + link->id = be_id; + link->no_pcm =1 ; + link->dpcm_capture =1 ; + +return 0 ; +} +EXPORT_SYMBOL_NS (sof_intel_board_set_hdmi_in_link,SND_SOC_INTEL_SOF_BOARD_HELPERS ); +MODULE_DESCRIPTION ("ASoC Intel SOF Machine Driver Board Helpers" );MODULE_AUTHOR ("Brent Lu <[email protected]>" );MODULE_LICENSE ("GPL" );
sound/soc/intel/boards/sof_board_helpers.h +5 -0
@@ -33,6 +33,7 @@ struct sof_rt5682_private {* @ssp_codec: ssp port number of headphone BE link * @ssp_amp: ssp port number of speaker BE link * @ssp_bt: ssp port number of BT offload BE link +* @ssp_mask_hdmi_in: ssp port mask of HDMI-IN BE link * @bt_offload_present: true to create BT offload BE link * @rt5682: private data for rt5682 machine driver */
@@ -49,6 +50,7 @@ struct sof_card_private {int ssp_codec;int ssp_amp;int ssp_bt; +unsigned long ssp_mask_hdmi_in;bool bt_offload_present;
@@ -79,5 +81,8 @@ int sof_intel_board_set_ssp_amp_link(struct device *dev,int sof_intel_board_set_bt_link (struct device *dev,struct snd_soc_dai_link *link,int be_id,int ssp_bt); +int sof_intel_board_set_hdmi_in_link (struct device *dev, +struct snd_soc_dai_link *link,int be_id, +int ssp_hdmi);#endif /* __SOF_INTEL_BOARD_HELPERS_H */
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 23/27 ASoC: Intel: sof_rt5682: use common module for HDMI-In link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for HDMI-In DAI link initialization.
--- sound/soc/intel/boards/sof_rt5682.c | 37 +++++++---------------------- 1 file changed, 9 insertions(+), 28 deletions(-)
sound/soc/intel/boards/sof_rt5682.c +9 -28
@@ -463,13 +463,6 @@ static struct snd_soc_ops sof_rt5682_ops = { .hw_params = sof_rt5682_hw_params, }; -static struct snd_soc_dai_link_component platform_component[] = { - { -/* name might be overridden during probe */ - .name ="0000:00:1f.3" - } -}; -static int sof_card_late_probe (struct snd_soc_card *card) {struct sof_card_private *ctx =snd_soc_card_get_drvdata (card);
@@ -576,18 +569,14 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type, int ssp_amp, int dmic_be_num, int hdmi_num, bool idisp_codec, bool is_legacy_cpu) { - struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link *links;int i;int id =0 ;int ret; -int hdmi_id_offset =0 ; links =devm_kcalloc (dev, sof_audio_card_rt5682.num_links,sizeof (struct snd_soc_dai_link ),GFP_KERNEL ); - cpus =devm_kcalloc (dev, sof_audio_card_rt5682.num_links, -sizeof (struct snd_soc_dai_link_component ),GFP_KERNEL ); -if (!links || !cpus) +if (!links) goto devm_err;/* codec SSP */
@@ -735,22 +724,11 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type,int port =0 ;for_each_set_bit (port, &hdmi_in_ssp,32 ) { - links[id].cpus = &cpus[id]; - links[id].cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL , -"SSP%d Pin" , port); -if (!links[id].cpus->dai_name) -return NULL ; - links[id].name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-HDMI" , port); -if (!links[id].name) + ret =sof_intel_board_set_hdmi_in_link (dev, &links[id], + id, port); +if (ret)return NULL ; - links[id].id = id + hdmi_id_offset; - links[id].codecs = &snd_soc_dummy_dlc; - links[id].num_codecs =1 ; - links[id].platforms = platform_component; - links[id].num_platforms =ARRAY_SIZE (platform_component); - links[id].dpcm_capture =1 ; - links[id].no_pcm =1 ; - links[id].num_cpus =1 ; + id++; } }
@@ -831,7 +809,10 @@ static int sof_audio_probe(struct platform_device *pdev)dev_dbg (&pdev->dev,"sof_rt5682_quirk = %lx\n" , sof_rt5682_quirk); -/* port number of peripherals attached to ssp interface */ +/* port number/mask of peripherals attached to ssp interface */ + ctx->ssp_mask_hdmi_in = (sof_rt5682_quirk &SOF_SSP_HDMI_CAPTURE_PRESENT_MASK ) >> +SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT ; + ctx->ssp_bt = (sof_rt5682_quirk &SOF_BT_OFFLOAD_SSP_MASK ) >>SOF_BT_OFFLOAD_SSP_SHIFT ;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 24/27 ASoC: Intel: sof_ssp_amp: use common module for HDMI-In link
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module for HDMI-In DAI link initialization.
--- sound/soc/intel/boards/sof_ssp_amp.c | 38 ++++++---------------------- 1 file changed, 8 insertions(+), 30 deletions(-)
sound/soc/intel/boards/sof_ssp_amp.c +8 -30
@@ -71,13 +71,6 @@ static struct snd_soc_card sof_ssp_amp_card = { .late_probe = sof_card_late_probe, }; -static struct snd_soc_dai_link_component platform_component[] = { - { -/* name might be overridden during probe */ - .name ="0000:00:1f.3" - } -}; -/* BE ID defined in sof-tgl-rt1308-hdmi-ssp.m4 */ #define HDMI_IN_BE_ID 0#define SPK_BE_ID 2
@@ -90,7 +83,6 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, int ssp_amp, int dmic_be_num, int hdmi_num, bool idisp_codec) { - struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link *links;int i;int id =0 ;
@@ -101,9 +93,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, links =devm_kcalloc (dev, sof_ssp_amp_card.num_links,sizeof (struct snd_soc_dai_link ),GFP_KERNEL ); - cpus =devm_kcalloc (dev, sof_ssp_amp_card.num_links, -sizeof (struct snd_soc_dai_link_component ),GFP_KERNEL ); -if (!links || !cpus) +if (!links)return NULL ;/* HDMI-In SSP */
@@ -118,22 +108,11 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, be_id =HDMI_IN_BE_ID ;for_each_set_bit (port, &ssp_mask_hdmi_in,32 ) { - links[id].cpus = &cpus[id]; - links[id].cpus->dai_name =devm_kasprintf (dev,GFP_KERNEL , -"SSP%d Pin" , port); -if (!links[id].cpus->dai_name) + ret =sof_intel_board_set_hdmi_in_link (dev, &links[id], + be_id, port); +if (ret)return NULL ; - links[id].name =devm_kasprintf (dev,GFP_KERNEL ,"SSP%d-HDMI" , port); -if (!links[id].name) -return NULL ; - links[id].id = be_id; - links[id].codecs = &snd_soc_dummy_dlc; - links[id].num_codecs =1 ; - links[id].platforms = platform_component; - links[id].num_platforms =ARRAY_SIZE (platform_component); - links[id].dpcm_capture =1 ; - links[id].no_pcm =1 ; - links[id].num_cpus =1 ; + id++; be_id++; }
@@ -218,7 +197,6 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)struct snd_soc_dai_link *dai_links;struct sof_card_private *ctx;int ret; -unsigned long ssp_mask_hdmi_in; ctx =devm_kzalloc (&pdev->dev,sizeof (*ctx),GFP_KERNEL );if (!ctx)
@@ -235,7 +213,7 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) ctx->dmic_be_num =0 ;/* port number/mask of peripherals attached to ssp interface */ - ssp_mask_hdmi_in = (sof_ssp_amp_quirk &SOF_HDMI_CAPTURE_SSP_MASK_MASK ) >> + ctx->ssp_mask_hdmi_in = (sof_ssp_amp_quirk &SOF_HDMI_CAPTURE_SSP_MASK_MASK ) >>SOF_HDMI_CAPTURE_SSP_MASK_SHIFT ; ctx->ssp_bt = (sof_ssp_amp_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
@@ -249,8 +227,8 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)if (ctx->amp_type !=CODEC_NONE ) sof_ssp_amp_card.num_links++; -if (ssp_mask_hdmi_in) - sof_ssp_amp_card.num_links +=hweight32 (ssp_mask_hdmi_in); +if (ctx->ssp_mask_hdmi_in) + sof_ssp_amp_card.num_links +=hweight32 (ctx->ssp_mask_hdmi_in);if (sof_ssp_amp_quirk &SOF_HDMI_PLAYBACK_PRESENT ) { ctx->hdmi_num = (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_PLAYBACK_MASK) >>
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 25/27 ASoC: Intel: board_helpers: support DAI link array generation
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Add a helper function for machine drivers to initialize dai_link and num_links of a snd_soc_card structure. Machine driver needs to initialize sof_card_private structure in driver probe function then board_helpers module will create entire DAI link array for this board.
--- sound/soc/intel/boards/sof_board_helpers.c | 152 +++++++++++++++++++++ sound/soc/intel/boards/sof_board_helpers.h | 7 + 2 files changed, 159 insertions(+)
sound/soc/intel/boards/sof_board_helpers.c +152 -0
@@ -375,6 +375,158 @@ int sof_intel_board_set_hdmi_in_link(struct device *dev, }EXPORT_SYMBOL_NS (sof_intel_board_set_hdmi_in_link,SND_SOC_INTEL_SOF_BOARD_HELPERS ); +static int calculate_num_links (struct sof_card_private *ctx) +{ +int num_links =0 ; + +/* headphone codec */ +if (ctx->codec_type !=CODEC_NONE ) + num_links++; + +/* dmic01 and dmic16k */ +if (ctx->dmic_be_num >0 ) + num_links++; + +if (ctx->dmic_be_num >1 ) + num_links++; + +/* idisp HDMI */ + num_links += ctx->hdmi_num; + +/* speaker amp */ +if (ctx->amp_type !=CODEC_NONE ) + num_links++; + +/* BT audio offload */ +if (ctx->bt_offload_present) + num_links++; + +/* HDMI-In */ + num_links +=hweight32 (ctx->ssp_mask_hdmi_in); + +return num_links; +} + +int sof_intel_board_set_dai_link (struct device *dev,struct snd_soc_card *card, +struct sof_card_private *ctx) +{ +struct snd_soc_dai_link *links; +int num_links; +int i; +int idx =0 ; +int ret; +int ssp_hdmi_in =0 ; + + num_links =calculate_num_links (ctx); + + links =devm_kcalloc (dev, num_links,sizeof (struct snd_soc_dai_link ), +GFP_KERNEL ); +if (!links) +return -ENOMEM ; + +/* headphone codec */ +if (ctx->codec_type !=CODEC_NONE ) { + ret =sof_intel_board_set_codec_link (dev, &links[idx], idx, + ctx->codec_type, + ctx->ssp_codec); +if (ret) { +dev_err (dev,"fail to set codec link, ret %d\n" , ret); +return ret; + } + + ctx->codec_link = &links[idx]; + idx++; + } + +/* dmic01 and dmic16k */ +if (ctx->dmic_be_num >0 ) { +/* at least we have dmic01 */ + ret =sof_intel_board_set_dmic_link (dev, &links[idx], idx, +SOF_DMIC_01 ); +if (ret) { +dev_err (dev,"fail to set dmic01 link, ret %d\n" , ret); +return ret; + } + + idx++; + } + +if (ctx->dmic_be_num >1 ) { +/* set up 2 BE links at most */ + ret =sof_intel_board_set_dmic_link (dev, &links[idx], idx, +SOF_DMIC_16K ); +if (ret) { +dev_err (dev,"fail to set dmic16k link, ret %d\n" , ret); +return ret; + } + + idx++; + } + +/* idisp HDMI */ +for (i =1 ; i <= ctx->hdmi_num; i++) { + ret =sof_intel_board_set_intel_hdmi_link (dev, &links[idx], idx, + i, + ctx->hdmi.idisp_codec); +if (ret) { +dev_err (dev,"fail to set hdmi link, ret %d\n" , ret); +return ret; + } + + idx++; + } + +/* speaker amp */ +if (ctx->amp_type !=CODEC_NONE ) { + ret =sof_intel_board_set_ssp_amp_link (dev, &links[idx], idx, + ctx->amp_type, + ctx->ssp_amp); +if (ret) { +dev_err (dev,"fail to set amp link, ret %d\n" , ret); +return ret; + } + + ctx->amp_link = &links[idx]; + idx++; + } + +/* BT audio offload */ +if (ctx->bt_offload_present) { + ret =sof_intel_board_set_bt_link (dev, &links[idx], idx, + ctx->ssp_bt); +if (ret) { +dev_err (dev,"fail to set bt link, ret %d\n" , ret); +return ret; + } + + idx++; + } + +/* HDMI-In */ +for_each_set_bit (ssp_hdmi_in, &ctx->ssp_mask_hdmi_in,32 ) { + ret =sof_intel_board_set_hdmi_in_link (dev, &links[idx], idx, + ssp_hdmi_in); +if (ret) { +dev_err (dev,"fail to set hdmi-in link, ret %d\n" , ret); +return ret; + } + + idx++; + } + +if (idx != num_links) { +dev_err (dev,"link number mismatch, idx %d, num_links %d\n" , idx, + num_links); +return -EINVAL ; + } + + card->dai_link = links; + card->num_links = num_links; + +return 0 ; +} +EXPORT_SYMBOL_NS (sof_intel_board_set_dai_link,SND_SOC_INTEL_SOF_BOARD_HELPERS ); +MODULE_DESCRIPTION ("ASoC Intel SOF Machine Driver Board Helpers" );MODULE_AUTHOR ("Brent Lu <[email protected]>" );MODULE_LICENSE ("GPL" );
sound/soc/intel/boards/sof_board_helpers.h +7 -0
@@ -35,6 +35,8 @@ struct sof_rt5682_private {* @ssp_bt: ssp port number of BT offload BE link * @ssp_mask_hdmi_in: ssp port mask of HDMI-IN BE link * @bt_offload_present: true to create BT offload BE link +* @codec_link: pointer to headset codec dai link +* @amp_link: pointer to speaker amplifier dai link * @rt5682: private data for rt5682 machine driver */ struct sof_card_private {
@@ -54,6 +56,9 @@ struct sof_card_private {bool bt_offload_present; +struct snd_soc_dai_link *codec_link; +struct snd_soc_dai_link *amp_link; +union {struct sof_rt5682_private rt5682; };
@@ -65,6 +70,8 @@ enum sof_dmic_be_type { };int sof_intel_board_card_late_probe (struct snd_soc_card *card); +int sof_intel_board_set_dai_link (struct device *dev,struct snd_soc_card *card, +struct sof_card_private *ctx); int sof_intel_board_set_codec_link(struct device *dev, struct snd_soc_dai_link *link, int be_id,
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 26/27 ASoC: Intel: sof_nau8825: use common module for DAI link generation
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module to generate DAI link array and update num_links field in snd_soc_card structure.
--- sound/soc/intel/boards/sof_nau8825.c | 164 ++++++++------------------- 1 file changed, 48 insertions(+), 116 deletions(-)
sound/soc/intel/boards/sof_nau8825.c +48 -116
@@ -200,123 +200,67 @@ static struct snd_soc_dai_link_component nau8825_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 ssp_amp,int dmic_be_num, -int hdmi_num,bool idisp_codec) +static int +sof_card_dai_links_create (struct device *dev,struct snd_soc_card *card, +struct sof_card_private *ctx) { -struct snd_soc_dai_link *links; -int i; -int id =0 ;int ret; - links =devm_kcalloc (dev, sof_audio_card_nau8825.num_links, -sizeof (struct snd_soc_dai_link ),GFP_KERNEL ); -if (!links) - goto devm_err; - -/* codec SSP */ - ret =sof_intel_board_set_codec_link (dev, &links[id], id,CODEC_NAU8825 , - ssp_codec); + ret =sof_intel_board_set_dai_link (dev, card, ctx);if (ret) -return NULL ; - -/* codec-specific fields */ - links[id].codecs = nau8825_component; - links[id].num_codecs =ARRAY_SIZE (nau8825_component); - links[id].init = sof_nau8825_codec_init; - links[id].exit = sof_nau8825_codec_exit; - links[id].ops = &sof_nau8825_ops; - - id++; - -/* dmic */ -if (dmic_be_num >0 ) { -/* at least we have dmic01 */ - ret =sof_intel_board_set_dmic_link (dev, &links[id], id, -SOF_DMIC_01 ); -if (ret) -return NULL ; - - id++; - } - -if (dmic_be_num >1 ) { -/* set up 2 BE links at most */ - ret =sof_intel_board_set_dmic_link (dev, &links[id], id, -SOF_DMIC_16K ); -if (ret) -return NULL ; +return ret; - id++; +if (!ctx->codec_link) { +dev_err (dev,"codec link not available" ); +return -EINVAL ; } -/* HDMI */ -for (i =1 ; i <= hdmi_num; i++) { - ret =sof_intel_board_set_intel_hdmi_link (dev, &links[id], id, - i, idisp_codec); -if (ret) -return NULL ; +/* codec-specific fields for headphone codec */ + ctx->codec_link->codecs = nau8825_component; + ctx->codec_link->num_codecs =ARRAY_SIZE (nau8825_component); + ctx->codec_link->init = sof_nau8825_codec_init; + ctx->codec_link->exit = sof_nau8825_codec_exit; + ctx->codec_link->ops = &sof_nau8825_ops; - id++; - } +if (ctx->amp_type ==CODEC_NONE ) +return 0 ; -/* speaker amp */ -if (amp_type !=CODEC_NONE ) { - ret =sof_intel_board_set_ssp_amp_link (dev, &links[id], id, - amp_type, ssp_amp); -if (ret) -return NULL ; - -/* codec-specific fields */ -switch (amp_type) { -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_NAU8318 : -nau8318_set_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 ; -default : -dev_err (dev,"invalid amp type %d\n" , amp_type); -return NULL ; - } - - id++; +if (!ctx->amp_link) { +dev_err (dev,"amp link not available" ); +return -EINVAL ; } -/* BT audio offload */ -if (sof_nau8825_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) { -int port = (sof_nau8825_quirk &SOF_BT_OFFLOAD_SSP_MASK ) >> -SOF_BT_OFFLOAD_SSP_SHIFT ; - - ret =sof_intel_board_set_bt_link (dev, &links[id], id, port); -if (ret) -return NULL ; - - id++; +/* codec-specific fields for speaker amplifier */ +switch (ctx->amp_type) { +case CODEC_MAX98360A : +max_98360a_dai_link (ctx->amp_link); +break ; +case CODEC_MAX98373 : + ctx->amp_link->codecs = max_98373_components; + ctx->amp_link->num_codecs =ARRAY_SIZE (max_98373_components); + ctx->amp_link->init = max_98373_spk_codec_init; + ctx->amp_link->ops = &max_98373_ops; +break ; +case CODEC_NAU8318 : +nau8318_set_dai_link (ctx->amp_link); +break ; +case CODEC_RT1015P : +sof_rt1015p_dai_link (ctx->amp_link); +break ; +case CODEC_RT1019P : +sof_rt1019p_dai_link (ctx->amp_link); +break ; +default : +dev_err (dev,"invalid amp type %d\n" , ctx->amp_type); +return -EINVAL ; } -return links; -devm_err: -return NULL ; +return 0 ; }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;
@@ -352,25 +296,13 @@ static int sof_audio_probe(struct platform_device *pdev) ctx->ssp_codec = sof_nau8825_quirk &SOF_NAU8825_SSP_CODEC_MASK ; -/* compute number of dai links */ - sof_audio_card_nau8825.num_links =1 + ctx->dmic_be_num + ctx->hdmi_num; - -if (ctx->amp_type !=CODEC_NONE ) - sof_audio_card_nau8825.num_links++; - -if (sof_nau8825_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) { +if (sof_nau8825_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) ctx->bt_offload_present = true; - sof_audio_card_nau8825.num_links++; - } - dai_links =sof_card_dai_links_create (&pdev->dev, ctx->amp_type, - ctx->ssp_codec, ctx->ssp_amp, - ctx->dmic_be_num, ctx->hdmi_num, - ctx->hdmi.idisp_codec); -if (!dai_links) -return -ENOMEM ; - - sof_audio_card_nau8825.dai_link = dai_links; +/* update dai_link */ + ret =sof_card_dai_links_create (&pdev->dev, &sof_audio_card_nau8825, ctx); +if (ret) +return ret;/* update codec_conf */ switch (ctx->amp_type) {
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 27/27 ASoC: Intel: sof_rt5682: use common module for DAI link generation
In reply to Peter UjfalusiFrom: Brent Lu <[email protected]>
Use intel_board module to generate DAI link array and update num_links field in snd_soc_card structure.
--- sound/soc/intel/boards/sof_rt5682.c | 242 +++++++++------------------- 1 file changed, 75 insertions(+), 167 deletions(-)
sound/soc/intel/boards/sof_rt5682.c +75 -167
@@ -563,52 +563,45 @@ static struct snd_soc_dai_link_component rt5650_components[] = { } }; -static struct snd_soc_dai_link * -sof_card_dai_links_create (struct device *dev,enum sof_ssp_codec codec_type, -enum sof_ssp_codec amp_type,int ssp_codec, -int ssp_amp,int dmic_be_num,int hdmi_num, -bool idisp_codec,bool is_legacy_cpu) +static int +sof_card_dai_links_create (struct device *dev,struct snd_soc_card *card, +struct sof_card_private *ctx) { -struct snd_soc_dai_link *links; -int i; -int id =0 ;int ret; - links =devm_kcalloc (dev, sof_audio_card_rt5682.num_links, -sizeof (struct snd_soc_dai_link ),GFP_KERNEL ); -if (!links) - goto devm_err; - -/* codec SSP */ - ret =sof_intel_board_set_codec_link (dev, &links[id], id, codec_type, - ssp_codec); + ret =sof_intel_board_set_dai_link (dev, card, ctx);if (ret) -return NULL ; +return ret; + +if (!ctx->codec_link) { +dev_err (dev,"codec link not available" ); +return -EINVAL ; + } -/* codec-specific fields */ -switch (codec_type) { +/* codec-specific fields for headphone codec */ +switch (ctx->codec_type) {case CODEC_RT5650 : - links[id].codecs = &rt5650_components[0 ]; - links[id].num_codecs =1 ; + ctx->codec_link->codecs = &rt5650_components[0 ]; + ctx->codec_link->num_codecs =1 ;break ;case CODEC_RT5682 : - links[id].codecs = rt5682_component; - links[id].num_codecs =ARRAY_SIZE (rt5682_component); + ctx->codec_link->codecs = rt5682_component; + ctx->codec_link->num_codecs =ARRAY_SIZE (rt5682_component);break ;case CODEC_RT5682S : - links[id].codecs = rt5682s_component; - links[id].num_codecs =ARRAY_SIZE (rt5682s_component); + ctx->codec_link->codecs = rt5682s_component; + ctx->codec_link->num_codecs =ARRAY_SIZE (rt5682s_component);break ;default : -dev_err (dev,"invalid codec type %d\n" , codec_type); -return NULL ; +dev_err (dev,"invalid codec type %d\n" , ctx->codec_type); +return -EINVAL ; } - links[id].init = sof_rt5682_codec_init; - links[id].exit = sof_rt5682_codec_exit; - links[id].ops = &sof_rt5682_ops; + ctx->codec_link->init = sof_rt5682_codec_init; + ctx->codec_link->exit = sof_rt5682_codec_exit; + ctx->codec_link->ops = &sof_rt5682_ops; -if (!is_legacy_cpu) { +if (!ctx->rt5682.is_legacy_cpu) {/* * Currently, On SKL+ platforms MCLK will be turned off in sof * runtime suspended, and it will go into runtime suspended
@@ -618,130 +611,64 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type,* avoid the noise. * It can be removed once we can control MCLK by driver. */ - links[id].ignore_pmdown_time =1 ; + ctx->codec_link->ignore_pmdown_time =1 ; } - id++; -/* dmic */ -if (dmic_be_num >0 ) { -/* at least we have dmic01 */ - ret =sof_intel_board_set_dmic_link (dev, &links[id], id, -SOF_DMIC_01 ); -if (ret) -return NULL ; - - id++; - } +if (ctx->amp_type ==CODEC_NONE ) +return 0 ; -if (dmic_be_num >1 ) { -/* set up 2 BE links at most */ - ret =sof_intel_board_set_dmic_link (dev, &links[id], id, -SOF_DMIC_16K ); -if (ret) -return NULL ; - - id++; - } - -/* HDMI */ -for (i =1 ; i <= hdmi_num; i++) { - ret =sof_intel_board_set_intel_hdmi_link (dev, &links[id], id, - i, idisp_codec); -if (ret) -return NULL ; - - id++; - } - -/* speaker amp */ -if (amp_type !=CODEC_NONE ) { - ret =sof_intel_board_set_ssp_amp_link (dev, &links[id], id, - amp_type, ssp_amp); -if (ret) -return NULL ; - -/* codec-specific fields */ -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 ]; - links[id].num_codecs =1 ; - links[id].init = rt5650_spk_init; - links[id].ops = &sof_rt5682_ops; -break ; -default : -dev_err (dev,"invalid amp type %d\n" , amp_type); -return NULL ; - } - - id++; - } - -/* BT audio offload */ -if (sof_rt5682_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) { -int port = (sof_rt5682_quirk &SOF_BT_OFFLOAD_SSP_MASK ) >> -SOF_BT_OFFLOAD_SSP_SHIFT ; - - ret =sof_intel_board_set_bt_link (dev, &links[id], id, port); -if (ret) -return NULL ; - - id++; +if (!ctx->amp_link) { +dev_err (dev,"amp link not available" ); +return -EINVAL ; } -/* HDMI-In SSP */ -if (sof_rt5682_quirk &SOF_SSP_HDMI_CAPTURE_PRESENT_MASK ) { -unsigned long hdmi_in_ssp = (sof_rt5682_quirk & -SOF_SSP_HDMI_CAPTURE_PRESENT_MASK ) >> -SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT ; -int port =0 ; - -for_each_set_bit (port, &hdmi_in_ssp,32 ) { - ret =sof_intel_board_set_hdmi_in_link (dev, &links[id], - id, port); -if (ret) -return NULL ; - - id++; - } +/* codec-specific fields for speaker amplifier */ +switch (ctx->amp_type) { +case CODEC_MAX98357A : +max_98357a_dai_link (ctx->amp_link); +break ; +case CODEC_MAX98360A : +max_98360a_dai_link (ctx->amp_link); +break ; +case CODEC_MAX98373 : + ctx->amp_link->codecs = max_98373_components; + ctx->amp_link->num_codecs =ARRAY_SIZE (max_98373_components); + ctx->amp_link->init = max_98373_spk_codec_init; + ctx->amp_link->ops = &max_98373_ops; +break ; +case CODEC_MAX98390 : +max_98390_dai_link (dev, ctx->amp_link); +break ; +case CODEC_RT1011 : +sof_rt1011_dai_link (ctx->amp_link); +break ; +case CODEC_RT1015 : +sof_rt1015_dai_link (ctx->amp_link); +break ; +case CODEC_RT1015P : +sof_rt1015p_dai_link (ctx->amp_link); +break ; +case CODEC_RT1019P : +sof_rt1019p_dai_link (ctx->amp_link); +break ; +case CODEC_RT5650 : +/* use AIF2 to support speaker pipeline */ + ctx->amp_link->codecs = &rt5650_components[1 ]; + ctx->amp_link->num_codecs =1 ; + ctx->amp_link->init = rt5650_spk_init; + ctx->amp_link->ops = &sof_rt5682_ops; +break ; +default : +dev_err (dev,"invalid amp type %d\n" , ctx->amp_type); +return -EINVAL ; } -return links; -devm_err: -return NULL ; +return 0 ; }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;
@@ -821,32 +748,13 @@ static int sof_audio_probe(struct platform_device *pdev) ctx->ssp_codec = sof_rt5682_quirk &SOF_RT5682_SSP_CODEC_MASK ; -/* compute number of dai links */ - sof_audio_card_rt5682.num_links =1 + ctx->dmic_be_num + ctx->hdmi_num; - -if (ctx->amp_type !=CODEC_NONE ) - sof_audio_card_rt5682.num_links++; - -if (sof_rt5682_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) { +if (sof_rt5682_quirk &SOF_SSP_BT_OFFLOAD_PRESENT ) ctx->bt_offload_present = true; - sof_audio_card_rt5682.num_links++; - } -if (sof_rt5682_quirk &SOF_SSP_HDMI_CAPTURE_PRESENT_MASK ) - sof_audio_card_rt5682.num_links += -hweight32 ((sof_rt5682_quirk &SOF_SSP_HDMI_CAPTURE_PRESENT_MASK ) >> -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, - ctx->ssp_amp, ctx->dmic_be_num, - ctx->hdmi_num, - ctx->hdmi.idisp_codec, - ctx->rt5682.is_legacy_cpu); -if (!dai_links) -return -ENOMEM ; - - sof_audio_card_rt5682.dai_link = dai_links; +/* update dai_link */ + ret =sof_card_dai_links_create (&pdev->dev, &sof_audio_card_rt5682, ctx); +if (ret) +return ret;/* update codec_conf */ switch (ctx->amp_type) {
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 8 lines · Peter Ujfalusi
SOF board updates for 6.8 including few small fix and the majority is to add generic helpers for codec, amp, BT offload, HDMI-In and DAI link generation among various machine drivers.
Regards,
Peter[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/27] ASoC: Intel: sof_ssp_amp: remove dead code
commit: 9425039741e84120fc936fbb5a9a7a1410fd9409
[02/27] ASoC: Intel: sof_maxim_common: add else between 2 if test
commit: 06dea47be6d3d0ad3ef5f7c9dd0947d1c825e0ff
[03/27] ASoC: Intel: sof_maxim_common: check return value
commit: 007d9a638b877f71a0ef28a906525904e44f6aa2
[04/27] ASoC: Intel: cht_bsw_rt5672: check return value
commit: 65b2df10a1e6264dd199c88623a9e4bbf8849c9b
[05/27] ASoC: Intel: ssp-common: get codec name function
commit: 93f74ebf3d7623b8b647d2ce5f2e23545f9702df
[06/27] ASoC: Intel: board_helpers: support codec link initialization
commit: e111dece012f29707da634c341d3f3277bd94528
[07/27] ASoC: Intel: sof_cs42l42: use common module for codec link
commit: f46f07fe264a26daf8d6a5e16535229ee48108a7
[08/27] ASoC: Intel: sof_nau8825: use common module for codec link
commit: 99f7422805c96d56a093dbe71beca658b793d0cb
[09/27] ASoC: Intel: sof_rt5682: use common module for codec link
commit: 84c280af16b72fc202fbd9dcecadb6e256956c41
[10/27] ASoC: Intel: board_helpers: support amp link initialization
commit: ba0c7c328762d78573d3cac4adad9ea9e695f244
[11/27] ASoC: Intel: sof_cs42l42: use common module for amp link
commit: 8739841805744bd1a1d12e2485dc5d0f1d880f64
[12/27] ASoC: Intel: sof_nau8825: use common module for amp link
commit: adf711655ba21c5d54d52b79aa8df87fbb39df6b
[13/27] ASoC: Intel: sof_rt5682: use common module for amp link
commit: e45cd972a50d2212ad232af33de970fb6923aaf6
[14/27] ASoC: Intel: sof_ssp_amp: use common module for amp link
commit: 5cdc7a82594eaad27e98dcd6fbd72592edbc0f39
[15/27] ASoC: Intel: sof_ssp_amp: rename function parameter
commit: 823404815fcdf32950b2223ed2c665f077d6b98f
[16/27] ASoC: Intel: board_helpers: support BT offload link initialization
commit: 53d8df6d3f0a1d6fd520865fb12c11868fe6cf81
[17/27] ASoC: Intel: sof_cs42l42: use common module for BT offload link
commit: 117445d7655945b0a601a1247842029d0325c7e4
[18/27] ASoC: Intel: sof_nau8825: use common module for BT offload link
commit: 87ddfdc9dc37032492704b51ab468bda1262d155
[19/27] ASoC: Intel: sof_rt5682: use common module for BT offload link
commit: 3d5b77b9bee016cd1363f3856a3616eaed9026b8
[20/27] ASoC: Intel: sof_ssp_amp: use common module for BT offload link
commit: dc3d7dcb04eae6af5b9c882dc30eede75bbd7fe7
[21/27] ASoC: Intel: sof_ssp_amp: simplify HDMI-In quirks
commit: 9fadbf3f11c378fa307517f20bd793eb9773a15e
[22/27] ASoC: Intel: board_helpers: support HDMI-In link initialization
commit: f7c015add5b1a6a94fb39420ac0a885c8d7b63ad
[23/27] ASoC: Intel: sof_rt5682: use common module for HDMI-In link
commit: 426cbd0de2da2553de9c8a2366f956807f94d5b4
[24/27] ASoC: Intel: sof_ssp_amp: use common module for HDMI-In link
commit: ee2486d5219e9f724372084d5926070697e84836
[25/27] ASoC: Intel: board_helpers: support DAI link array generation
commit: a6881210f175ae309721b3c76f54eebc8a258339
[26/27] ASoC: Intel: sof_nau8825: use common module for DAI link generation
commit: 5da85a3523b5acd3a00347cae32ae2ffe4f4ac8a
[27/27] ASoC: Intel: sof_rt5682: use common module for DAI link generation
commit: 8fa1116e1cae4858ab69d31da36f1fae9113c29dAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark