Path: blob/master/sound/soc/intel/boards/skl_hda_dsp_generic.c
26493 views
// SPDX-License-Identifier: GPL-2.0-only1// Copyright(c) 2015-18 Intel Corporation.23/*4* Machine Driver for SKL+ platforms with DSP and iDisp, HDA Codecs5*/67#include <linux/module.h>8#include <linux/platform_device.h>9#include <sound/core.h>10#include <sound/hda_codec.h>11#include <sound/jack.h>12#include <sound/pcm.h>13#include <sound/pcm_params.h>14#include <sound/soc.h>15#include <sound/soc-acpi.h>16#include "../../codecs/hdac_hda.h"17#include "../../sof/intel/hda.h"18#include "sof_board_helpers.h"1920static int skl_hda_card_late_probe(struct snd_soc_card *card)21{22return sof_intel_board_card_late_probe(card);23}2425#define HDA_CODEC_AUTOSUSPEND_DELAY_MS 10002627static void skl_set_hda_codec_autosuspend_delay(struct snd_soc_card *card)28{29struct snd_soc_pcm_runtime *rtd;30struct hdac_hda_priv *hda_pvt;31struct snd_soc_dai *dai;3233for_each_card_rtds(card, rtd) {34if (!strstr(rtd->dai_link->codecs->name, "ehdaudio0D0"))35continue;36dai = snd_soc_rtd_to_codec(rtd, 0);37hda_pvt = snd_soc_component_get_drvdata(dai->component);38if (hda_pvt) {39/*40* all codecs are on the same bus, so it's sufficient41* to look up only the first one42*/43snd_hda_set_power_save(hda_pvt->codec->bus,44HDA_CODEC_AUTOSUSPEND_DELAY_MS);45break;46}47}48}4950#define IDISP_HDMI_BE_ID 151#define HDA_BE_ID 452#define DMIC01_BE_ID 653#define DMIC16K_BE_ID 754#define BT_OFFLOAD_BE_ID 85556#define HDA_LINK_ORDER SOF_LINK_ORDER(SOF_LINK_IDISP_HDMI, \57SOF_LINK_HDA, \58SOF_LINK_DMIC01, \59SOF_LINK_DMIC16K, \60SOF_LINK_BT_OFFLOAD, \61SOF_LINK_NONE, \62SOF_LINK_NONE)6364#define HDA_LINK_IDS SOF_LINK_ORDER(IDISP_HDMI_BE_ID, \65HDA_BE_ID, \66DMIC01_BE_ID, \67DMIC16K_BE_ID, \68BT_OFFLOAD_BE_ID, \690, \700)7172static unsigned long73skl_hda_get_board_quirk(struct snd_soc_acpi_mach_params *mach_params)74{75unsigned long board_quirk = 0;76int ssp_bt;7778if (hweight_long(mach_params->bt_link_mask) == 1) {79ssp_bt = fls(mach_params->bt_link_mask) - 1;80board_quirk |= SOF_SSP_PORT_BT_OFFLOAD(ssp_bt) |81SOF_BT_OFFLOAD_PRESENT;82}8384return board_quirk;85}8687static int skl_hda_add_dai_link(struct snd_soc_card *card,88struct snd_soc_dai_link *link)89{90struct sof_card_private *ctx = snd_soc_card_get_drvdata(card);9192/* Ignore the HDMI PCM link if iDisp is not present */93if (strstr(link->stream_name, "HDMI") && !ctx->hdmi.idisp_codec)94link->ignore = true;9596return 0;97}9899static int skl_hda_audio_probe(struct platform_device *pdev)100{101struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;102struct sof_card_private *ctx;103struct snd_soc_card *card;104unsigned long board_quirk = skl_hda_get_board_quirk(&mach->mach_params);105int ret;106107card = devm_kzalloc(&pdev->dev, sizeof(struct snd_soc_card), GFP_KERNEL);108if (!card)109return -ENOMEM;110111card->name = "hda-dsp";112card->owner = THIS_MODULE;113card->fully_routed = true;114card->late_probe = skl_hda_card_late_probe;115card->add_dai_link = skl_hda_add_dai_link;116117dev_dbg(&pdev->dev, "board_quirk = %lx\n", board_quirk);118119/* initialize ctx with board quirk */120ctx = sof_intel_board_get_ctx(&pdev->dev, board_quirk);121if (!ctx)122return -ENOMEM;123124if (HDA_EXT_CODEC(mach->mach_params.codec_mask))125ctx->hda_codec_present = true;126127if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)128ctx->hdmi.idisp_codec = true;129130ctx->link_order_overwrite = HDA_LINK_ORDER;131ctx->link_id_overwrite = HDA_LINK_IDS;132133/* update dai_link */134ret = sof_intel_board_set_dai_link(&pdev->dev, card, ctx);135if (ret)136return ret;137138card->dev = &pdev->dev;139140if (mach->mach_params.dmic_num > 0) {141card->components = devm_kasprintf(card->dev, GFP_KERNEL,142"cfg-dmics:%d",143mach->mach_params.dmic_num);144if (!card->components)145return -ENOMEM;146}147148ret = snd_soc_fixup_dai_links_platform_name(card,149mach->mach_params.platform);150if (ret)151return ret;152153snd_soc_card_set_drvdata(card, ctx);154155ret = devm_snd_soc_register_card(&pdev->dev, card);156if (!ret)157skl_set_hda_codec_autosuspend_delay(card);158159return ret;160}161162static struct platform_driver skl_hda_audio = {163.probe = skl_hda_audio_probe,164.driver = {165.name = "skl_hda_dsp_generic",166.pm = &snd_soc_pm_ops,167},168};169170module_platform_driver(skl_hda_audio)171172/* Module information */173MODULE_DESCRIPTION("SKL/KBL/BXT/APL HDA Generic Machine driver");174MODULE_AUTHOR("Rakesh Ughreja <[email protected]>");175MODULE_LICENSE("GPL v2");176MODULE_ALIAS("platform:skl_hda_dsp_generic");177MODULE_IMPORT_NS("SND_SOC_INTEL_SOF_BOARD_HELPERS");178179180