| // SPDX-License-Identifier: GPL-2.0-only |
| // |
| // Copyright(c) 2023 Intel Corporation |
| |
| #include <sound/soc.h> |
| #include "../common/soc-intel-quirks.h" |
| #include "hda_dsp_common.h" |
| #include "sof_board_helpers.h" |
| |
| /* |
| * Intel HDMI DAI Link |
| */ |
| static int hdmi_init(struct snd_soc_pcm_runtime *rtd) |
| { |
| struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
| struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0); |
| |
| ctx->hdmi.hdmi_comp = dai->component; |
| |
| return 0; |
| } |
| |
| int sof_intel_board_card_late_probe(struct snd_soc_card *card) |
| { |
| struct sof_card_private *ctx = snd_soc_card_get_drvdata(card); |
| |
| if (!ctx->hdmi_num) |
| return 0; |
| |
| if (!ctx->hdmi.idisp_codec) |
| return 0; |
| |
| if (!ctx->hdmi.hdmi_comp) |
| return -EINVAL; |
| |
| return hda_dsp_hdmi_build_controls(card, ctx->hdmi.hdmi_comp); |
| } |
| EXPORT_SYMBOL_NS(sof_intel_board_card_late_probe, SND_SOC_INTEL_SOF_BOARD_HELPERS); |
| |
| /* |
| * DMIC DAI Link |
| */ |
| static const struct snd_soc_dapm_widget dmic_widgets[] = { |
| SND_SOC_DAPM_MIC("SoC DMIC", NULL), |
| }; |
| |
| static const struct snd_soc_dapm_route dmic_routes[] = { |
| {"DMic", NULL, "SoC DMIC"}, |
| }; |
| |
| static int dmic_init(struct snd_soc_pcm_runtime *rtd) |
| { |
| struct snd_soc_card *card = rtd->card; |
| int ret; |
| |
| ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, |
| ARRAY_SIZE(dmic_widgets)); |
| if (ret) { |
| dev_err(rtd->dev, "fail to add dmic widgets, ret %d\n", ret); |
| return ret; |
| } |
| |
| ret = snd_soc_dapm_add_routes(&card->dapm, dmic_routes, |
| ARRAY_SIZE(dmic_routes)); |
| if (ret) { |
| dev_err(rtd->dev, "fail to add dmic routes, ret %d\n", ret); |
| return ret; |
| } |
| |
| return 0; |
| } |
| |
| /* |
| * HDA External Codec DAI Link |
| */ |
| static const struct snd_soc_dapm_widget hda_widgets[] = { |
| SND_SOC_DAPM_MIC("Analog In", NULL), |
| SND_SOC_DAPM_MIC("Digital In", NULL), |
| SND_SOC_DAPM_MIC("Alt Analog In", NULL), |
| |
| SND_SOC_DAPM_HP("Analog Out", NULL), |
| SND_SOC_DAPM_SPK("Digital Out", NULL), |
| SND_SOC_DAPM_HP("Alt Analog Out", NULL), |
| }; |
| |
| static const struct snd_soc_dapm_route hda_routes[] = { |
| { "Codec Input Pin1", NULL, "Analog In" }, |
| { "Codec Input Pin2", NULL, "Digital In" }, |
| { "Codec Input Pin3", NULL, "Alt Analog In" }, |
| |
| { "Analog Out", NULL, "Codec Output Pin1" }, |
| { "Digital Out", NULL, "Codec Output Pin2" }, |
| { "Alt Analog Out", NULL, "Codec Output Pin3" }, |
| |
| /* CODEC BE connections */ |
| { "codec0_in", NULL, "Analog CPU Capture" }, |
| { "Analog CPU Capture", NULL, "Analog Codec Capture" }, |
| { "codec1_in", NULL, "Digital CPU Capture" }, |
| { "Digital CPU Capture", NULL, "Digital Codec Capture" }, |
| { "codec2_in", NULL, "Alt Analog CPU Capture" }, |
| { "Alt Analog CPU Capture", NULL, "Alt Analog Codec Capture" }, |
| |
| { "Analog Codec Playback", NULL, "Analog CPU Playback" }, |
| { "Analog CPU Playback", NULL, "codec0_out" }, |
| { "Digital Codec Playback", NULL, "Digital CPU Playback" }, |
| { "Digital CPU Playback", NULL, "codec1_out" }, |
| { "Alt Analog Codec Playback", NULL, "Alt Analog CPU Playback" }, |
| { "Alt Analog CPU Playback", NULL, "codec2_out" }, |
| }; |
| |
| static int hda_init(struct snd_soc_pcm_runtime *rtd) |
| { |
| struct snd_soc_card *card = rtd->card; |
| int ret; |
| |
| ret = snd_soc_dapm_new_controls(&card->dapm, hda_widgets, |
| ARRAY_SIZE(hda_widgets)); |
| if (ret) { |
| dev_err(rtd->dev, "fail to add hda widgets, ret %d\n", ret); |
| return ret; |
| } |
| |
| ret = snd_soc_dapm_add_routes(&card->dapm, hda_routes, |
| ARRAY_SIZE(hda_routes)); |
| if (ret) |
| dev_err(rtd->dev, "fail to add hda routes, ret %d\n", ret); |
| |
| return ret; |
| } |
| |
| /* |
| * DAI Link Helpers |
| */ |
| |
| enum sof_dmic_be_type { |
| SOF_DMIC_01, |
| SOF_DMIC_16K, |
| }; |
| |
| enum sof_hda_be_type { |
| SOF_HDA_ANALOG, |
| SOF_HDA_DIGITAL, |
| }; |
| |
| /* DEFAULT_LINK_ORDER: the order used in sof_rt5682 */ |
| #define DEFAULT_LINK_ORDER SOF_LINK_ORDER(SOF_LINK_CODEC, \ |
| SOF_LINK_DMIC01, \ |
| SOF_LINK_DMIC16K, \ |
| SOF_LINK_IDISP_HDMI, \ |
| SOF_LINK_AMP, \ |
| SOF_LINK_BT_OFFLOAD, \ |
| SOF_LINK_HDMI_IN) |
| |
| static struct snd_soc_dai_link_component dmic_component[] = { |
| { |
| .name = "dmic-codec", |
| .dai_name = "dmic-hifi", |
| } |
| }; |
| |
| SND_SOC_DAILINK_DEF(hda_analog_cpus, |
| DAILINK_COMP_ARRAY(COMP_CPU("Analog CPU DAI"))); |
| SND_SOC_DAILINK_DEF(hda_analog_codecs, |
| DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D0", "Analog Codec DAI"))); |
| |
| SND_SOC_DAILINK_DEF(hda_digital_cpus, |
| DAILINK_COMP_ARRAY(COMP_CPU("Digital CPU DAI"))); |
| SND_SOC_DAILINK_DEF(hda_digital_codecs, |
| DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D0", "Digital Codec DAI"))); |
| |
| static struct snd_soc_dai_link_component platform_component[] = { |
| { |
| /* name might be overridden during probe */ |
| .name = "0000:00:1f.3" |
| } |
| }; |
| |
| static int set_ssp_codec_link(struct device *dev, struct snd_soc_dai_link *link, |
| int be_id, enum snd_soc_acpi_intel_codec codec_type, |
| int ssp_codec) |
| { |
| struct snd_soc_dai_link_component *cpus; |
| |
| dev_dbg(dev, "link %d: ssp codec %s, ssp %d\n", be_id, |
| snd_soc_acpi_intel_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; |
| } |
| |
| static int set_dmic_link(struct device *dev, struct snd_soc_dai_link *link, |
| int be_id, enum sof_dmic_be_type be_type) |
| { |
| struct snd_soc_dai_link_component *cpus; |
| |
| /* cpus */ |
| cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component), |
| GFP_KERNEL); |
| if (!cpus) |
| return -ENOMEM; |
| |
| switch (be_type) { |
| case SOF_DMIC_01: |
| dev_dbg(dev, "link %d: dmic01\n", be_id); |
| |
| link->name = "dmic01"; |
| cpus->dai_name = "DMIC01 Pin"; |
| break; |
| case SOF_DMIC_16K: |
| dev_dbg(dev, "link %d: dmic16k\n", be_id); |
| |
| link->name = "dmic16k"; |
| cpus->dai_name = "DMIC16k Pin"; |
| break; |
| default: |
| dev_err(dev, "invalid be type %d\n", be_type); |
| return -EINVAL; |
| } |
| |
| link->cpus = cpus; |
| link->num_cpus = 1; |
| |
| /* codecs */ |
| link->codecs = dmic_component; |
| link->num_codecs = ARRAY_SIZE(dmic_component); |
| |
| /* platforms */ |
| link->platforms = platform_component; |
| link->num_platforms = ARRAY_SIZE(platform_component); |
| |
| link->id = be_id; |
| if (be_type == SOF_DMIC_01) |
| link->init = dmic_init; |
| link->ignore_suspend = 1; |
| link->no_pcm = 1; |
| link->dpcm_capture = 1; |
| |
| return 0; |
| } |
| |
| static int set_idisp_hdmi_link(struct device *dev, struct snd_soc_dai_link *link, |
| int be_id, int hdmi_id, bool idisp_codec) |
| { |
| struct snd_soc_dai_link_component *cpus, *codecs; |
| |
| dev_dbg(dev, "link %d: idisp hdmi %d, idisp codec %d\n", be_id, hdmi_id, |
| idisp_codec); |
| |
| /* link name */ |
| link->name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d", hdmi_id); |
| 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, "iDisp%d Pin", hdmi_id); |
| if (!cpus->dai_name) |
| return -ENOMEM; |
| |
| link->cpus = cpus; |
| link->num_cpus = 1; |
| |
| /* codecs */ |
| if (idisp_codec) { |
| codecs = devm_kzalloc(dev, |
| sizeof(struct snd_soc_dai_link_component), |
| GFP_KERNEL); |
| if (!codecs) |
| return -ENOMEM; |
| |
| codecs->name = "ehdaudio0D2"; |
| codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, |
| "intel-hdmi-hifi%d", hdmi_id); |
| if (!codecs->dai_name) |
| return -ENOMEM; |
| |
| link->codecs = codecs; |
| } else { |
| 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->init = (hdmi_id == 1) ? hdmi_init : NULL; |
| link->no_pcm = 1; |
| link->dpcm_playback = 1; |
| |
| return 0; |
| } |
| |
| static int set_ssp_amp_link(struct device *dev, struct snd_soc_dai_link *link, |
| int be_id, enum snd_soc_acpi_intel_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, |
| snd_soc_acpi_intel_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; |
| } |
| |
| static int set_bt_offload_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; |
| } |
| |
| static int 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; |
| } |
| |
| static int set_hda_codec_link(struct device *dev, struct snd_soc_dai_link *link, |
| int be_id, enum sof_hda_be_type be_type) |
| { |
| switch (be_type) { |
| case SOF_HDA_ANALOG: |
| dev_dbg(dev, "link %d: hda analog\n", be_id); |
| |
| link->name = "Analog Playback and Capture"; |
| |
| /* cpus */ |
| link->cpus = hda_analog_cpus; |
| link->num_cpus = ARRAY_SIZE(hda_analog_cpus); |
| |
| /* codecs */ |
| link->codecs = hda_analog_codecs; |
| link->num_codecs = ARRAY_SIZE(hda_analog_codecs); |
| break; |
| case SOF_HDA_DIGITAL: |
| dev_dbg(dev, "link %d: hda digital\n", be_id); |
| |
| link->name = "Digital Playback and Capture"; |
| |
| /* cpus */ |
| link->cpus = hda_digital_cpus; |
| link->num_cpus = ARRAY_SIZE(hda_digital_cpus); |
| |
| /* codecs */ |
| link->codecs = hda_digital_codecs; |
| link->num_codecs = ARRAY_SIZE(hda_digital_codecs); |
| break; |
| default: |
| dev_err(dev, "invalid be type %d\n", be_type); |
| return -EINVAL; |
| } |
| |
| /* platforms */ |
| link->platforms = platform_component; |
| link->num_platforms = ARRAY_SIZE(platform_component); |
| |
| link->id = be_id; |
| if (be_type == SOF_HDA_ANALOG) |
| link->init = hda_init; |
| link->no_pcm = 1; |
| link->dpcm_capture = 1; |
| link->dpcm_playback = 1; |
| |
| return 0; |
| } |
| |
| 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); |
| |
| /* HDA external codec */ |
| if (ctx->hda_codec_present) |
| num_links += 2; |
| |
| 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; |
| unsigned long link_order, link; |
| unsigned long link_ids, be_id; |
| |
| num_links = calculate_num_links(ctx); |
| |
| links = devm_kcalloc(dev, num_links, sizeof(struct snd_soc_dai_link), |
| GFP_KERNEL); |
| if (!links) |
| return -ENOMEM; |
| |
| if (ctx->link_order_overwrite) |
| link_order = ctx->link_order_overwrite; |
| else |
| link_order = DEFAULT_LINK_ORDER; |
| |
| if (ctx->link_id_overwrite) |
| link_ids = ctx->link_id_overwrite; |
| else |
| link_ids = 0; |
| |
| dev_dbg(dev, "create dai links, link_order 0x%lx, id_overwrite 0x%lx\n", |
| link_order, link_ids); |
| |
| while (link_order) { |
| link = link_order & SOF_LINK_ORDER_MASK; |
| link_order >>= SOF_LINK_ORDER_SHIFT; |
| |
| if (ctx->link_id_overwrite) { |
| be_id = link_ids & SOF_LINK_IDS_MASK; |
| link_ids >>= SOF_LINK_IDS_SHIFT; |
| } else { |
| /* use array index as link id */ |
| be_id = idx; |
| } |
| |
| switch (link) { |
| case SOF_LINK_CODEC: |
| /* headphone codec */ |
| if (ctx->codec_type == CODEC_NONE) |
| continue; |
| |
| ret = set_ssp_codec_link(dev, &links[idx], be_id, |
| 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++; |
| break; |
| case SOF_LINK_DMIC01: |
| /* dmic01 */ |
| if (ctx->dmic_be_num == 0) |
| continue; |
| |
| /* at least we have dmic01 */ |
| ret = set_dmic_link(dev, &links[idx], be_id, SOF_DMIC_01); |
| if (ret) { |
| dev_err(dev, "fail to set dmic01 link, ret %d\n", |
| ret); |
| return ret; |
| } |
| |
| idx++; |
| break; |
| case SOF_LINK_DMIC16K: |
| /* dmic16k */ |
| if (ctx->dmic_be_num <= 1) |
| continue; |
| |
| /* set up 2 BE links at most */ |
| ret = set_dmic_link(dev, &links[idx], be_id, |
| SOF_DMIC_16K); |
| if (ret) { |
| dev_err(dev, "fail to set dmic16k link, ret %d\n", |
| ret); |
| return ret; |
| } |
| |
| idx++; |
| break; |
| case SOF_LINK_IDISP_HDMI: |
| /* idisp HDMI */ |
| for (i = 1; i <= ctx->hdmi_num; i++) { |
| ret = set_idisp_hdmi_link(dev, &links[idx], |
| be_id, i, |
| ctx->hdmi.idisp_codec); |
| if (ret) { |
| dev_err(dev, "fail to set hdmi link, ret %d\n", |
| ret); |
| return ret; |
| } |
| |
| idx++; |
| be_id++; |
| } |
| break; |
| case SOF_LINK_AMP: |
| /* speaker amp */ |
| if (ctx->amp_type == CODEC_NONE) |
| continue; |
| |
| ret = set_ssp_amp_link(dev, &links[idx], be_id, |
| 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++; |
| break; |
| case SOF_LINK_BT_OFFLOAD: |
| /* BT audio offload */ |
| if (!ctx->bt_offload_present) |
| continue; |
| |
| ret = set_bt_offload_link(dev, &links[idx], be_id, |
| ctx->ssp_bt); |
| if (ret) { |
| dev_err(dev, "fail to set bt link, ret %d\n", |
| ret); |
| return ret; |
| } |
| |
| idx++; |
| break; |
| case SOF_LINK_HDMI_IN: |
| /* HDMI-In */ |
| for_each_set_bit(ssp_hdmi_in, &ctx->ssp_mask_hdmi_in, 32) { |
| ret = set_hdmi_in_link(dev, &links[idx], be_id, |
| ssp_hdmi_in); |
| if (ret) { |
| dev_err(dev, "fail to set hdmi-in link, ret %d\n", |
| ret); |
| return ret; |
| } |
| |
| idx++; |
| be_id++; |
| } |
| break; |
| case SOF_LINK_HDA: |
| /* HDA external codec */ |
| if (!ctx->hda_codec_present) |
| continue; |
| |
| ret = set_hda_codec_link(dev, &links[idx], be_id, |
| SOF_HDA_ANALOG); |
| if (ret) { |
| dev_err(dev, "fail to set hda analog link, ret %d\n", |
| ret); |
| return ret; |
| } |
| |
| idx++; |
| be_id++; |
| |
| ret = set_hda_codec_link(dev, &links[idx], be_id, |
| SOF_HDA_DIGITAL); |
| if (ret) { |
| dev_err(dev, "fail to set hda digital link, ret %d\n", |
| ret); |
| return ret; |
| } |
| |
| idx++; |
| break; |
| case SOF_LINK_NONE: |
| /* caught here if it's not used as terminator in macro */ |
| fallthrough; |
| default: |
| dev_err(dev, "invalid link type %ld\n", link); |
| return -EINVAL; |
| } |
| } |
| |
| 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); |
| |
| struct sof_card_private * |
| sof_intel_board_get_ctx(struct device *dev, unsigned long board_quirk) |
| { |
| struct sof_card_private *ctx; |
| |
| dev_dbg(dev, "create ctx, board_quirk 0x%lx\n", board_quirk); |
| |
| ctx = devm_kzalloc(dev, sizeof(struct sof_card_private), GFP_KERNEL); |
| if (!ctx) |
| return NULL; |
| |
| ctx->codec_type = snd_soc_acpi_intel_detect_codec_type(dev); |
| ctx->amp_type = snd_soc_acpi_intel_detect_amp_type(dev); |
| |
| ctx->dmic_be_num = 2; |
| ctx->hdmi_num = (board_quirk & SOF_NUM_IDISP_HDMI_MASK) >> |
| SOF_NUM_IDISP_HDMI_SHIFT; |
| /* default number of HDMI DAI's */ |
| if (!ctx->hdmi_num) |
| ctx->hdmi_num = 3; |
| |
| /* port number/mask of peripherals attached to ssp interface */ |
| if (ctx->codec_type != CODEC_NONE) |
| ctx->ssp_codec = (board_quirk & SOF_SSP_PORT_CODEC_MASK) >> |
| SOF_SSP_PORT_CODEC_SHIFT; |
| |
| if (ctx->amp_type != CODEC_NONE) |
| ctx->ssp_amp = (board_quirk & SOF_SSP_PORT_AMP_MASK) >> |
| SOF_SSP_PORT_AMP_SHIFT; |
| |
| if (board_quirk & SOF_BT_OFFLOAD_PRESENT) { |
| ctx->bt_offload_present = true; |
| ctx->ssp_bt = (board_quirk & SOF_SSP_PORT_BT_OFFLOAD_MASK) >> |
| SOF_SSP_PORT_BT_OFFLOAD_SHIFT; |
| } |
| |
| ctx->ssp_mask_hdmi_in = (board_quirk & SOF_SSP_MASK_HDMI_CAPTURE_MASK) >> |
| SOF_SSP_MASK_HDMI_CAPTURE_SHIFT; |
| |
| return ctx; |
| } |
| EXPORT_SYMBOL_NS(sof_intel_board_get_ctx, SND_SOC_INTEL_SOF_BOARD_HELPERS); |
| |
| MODULE_DESCRIPTION("ASoC Intel SOF Machine Driver Board Helpers"); |
| MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>"); |
| MODULE_LICENSE("GPL"); |
| MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); |
| MODULE_IMPORT_NS(SND_SOC_ACPI_INTEL_MATCH); |