diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index de003acb1951f3..01bd41e4aa9da0 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -64,7 +64,7 @@ static const struct snd_soc_dai_ops hdac_hda_dai_ops = { static struct snd_soc_dai_driver hdac_hda_dais[] = { { .id = HDAC_ANALOG_DAI_ID, - .name = "Analog Codec DAI", + .name = HDAC_ANALOG_CODEC_DAI_NAME, .ops = &hdac_hda_dai_ops, .playback = { .stream_name = "Analog Codec Playback", @@ -127,7 +127,7 @@ static struct snd_soc_dai_driver hdac_hda_dais[] = { }, { .id = HDAC_HDMI_0_DAI_ID, - .name = "intel-hdmi-hifi1", + .name = HDAC_HDMI0_DAI_NAME, .ops = &hdac_hda_dai_ops, .playback = { .stream_name = "hifi1", diff --git a/sound/soc/codecs/hdac_hda.h b/sound/soc/codecs/hdac_hda.h index 598b07d9b6fea0..daebb17fc7e6b8 100644 --- a/sound/soc/codecs/hdac_hda.h +++ b/sound/soc/codecs/hdac_hda.h @@ -17,6 +17,9 @@ enum { HDAC_LAST_DAI_ID = HDAC_HDMI_3_DAI_ID, }; +#define HDAC_ANALOG_CODEC_DAI_NAME "Analog Codec DAI" +#define HDAC_HDMI0_DAI_NAME "intel-hdmi-hifi1" + struct hdac_hda_pcm { int stream_tag[2]; unsigned int format_val[2]; diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c index 3be764299ab003..4d18b3456672d8 100644 --- a/sound/soc/intel/boards/skl_hda_dsp_generic.c +++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c @@ -168,6 +168,29 @@ static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params) return 0; } +#define HDA_CODEC_AUTOSUSPEND_DELAY_MS 1000 + +static void skl_set_hda_codec_autosuspend_delay(struct snd_soc_card *card, + const char *codec_dai_name) +{ + struct snd_soc_dai *codec_dai; + struct hdac_hda_priv *hda_pvt; + struct hdac_device *hdev; + + codec_dai = snd_soc_card_get_codec_dai(card, codec_dai_name); + if (!codec_dai) + return; + + hda_pvt = snd_soc_component_get_drvdata(codec_dai->component); + hdev = &hda_pvt->codec.core; + pm_runtime_get_noresume(&hdev->dev); + pm_runtime_set_autosuspend_delay(&hdev->dev, + HDA_CODEC_AUTOSUSPEND_DELAY_MS); + pm_runtime_use_autosuspend(&hdev->dev); + pm_runtime_mark_last_busy(&hdev->dev); + pm_runtime_put_autosuspend(&hdev->dev); +} + static int skl_hda_audio_probe(struct platform_device *pdev) { struct snd_soc_acpi_mach *mach; @@ -206,7 +229,16 @@ static int skl_hda_audio_probe(struct platform_device *pdev) hda_soc_card.components = hda_soc_components; } - return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card); + ret = devm_snd_soc_register_card(&pdev->dev, &hda_soc_card); + if (!ret) { + /* set hda analog codec */ + skl_set_hda_codec_autosuspend_delay(&hda_soc_card, + HDAC_ANALOG_CODEC_DAI_NAME); + /* set hda hdmi/dp codec */ + skl_set_hda_codec_autosuspend_delay(&hda_soc_card, + HDAC_HDMI0_DAI_NAME); + } + return ret; } static struct platform_driver skl_hda_audio = {