[alsa-devel] [PATCH 00/12] ASoC: intel: add device_link to HDMI audio
From: Libin Yang libin.yang@intel.com
This patchset add the device_link between the machine devices of intel boards and HDMI audio codec. This can make sure that display audio power domain is always turned on before operating on the HDMI audio codecs.
patch 2 adds the helper functions in a new created header file. However skl_hda_dsp_generic doesn't use these helper functions because skl_hda_dsp_generic is a special driver, the add link and delete link operations are in different source code files. If it includes the header file, there is compiling warning.
Libin Yang (12): ASoC: intel: skl_hda_dsp_generic: add device_link to HDMI audio ASoC: intel: boards: define some general functions for hdac_hdmi ASoC: intel: bxt_da7219_max98357a: add device_link to HDMI audio ASoC: intel: bxt_rt298: add device_link to HDMI audio ASoC: intel: glk_rt5682_max98357a: add device_link to HDMI audio ASoC: intel: kbl_da7219_max98357a: add device_link to HDMI audio ASoC: intel: kbl_da7219_max98927: add device_link to HDMI audio ASoC: intel: kbl_rt5660: add device_link to HDMI audio ASoC: intel: kbl_rt5663_max98927 add device_link to HDMI audio ASoC: intel: kbl_rt5663_rt5514_max98927 add device_link to HDMI audio ASoC: intel: skl_nau88l25_max98357a add device_link to HDMI audio ASoC: intel: skl_nau88l25_ssm4567 add device_link to HDMI audio
sound/soc/intel/boards/bxt_da7219_max98357a.c | 14 +++++++ sound/soc/intel/boards/bxt_rt298.c | 14 ++++++- sound/soc/intel/boards/glk_rt5682_max98357a.c | 14 +++++++ sound/soc/intel/boards/hdac_hdmi_common.h | 46 ++++++++++++++++++++++ sound/soc/intel/boards/kbl_da7219_max98357a.c | 14 +++++++ sound/soc/intel/boards/kbl_da7219_max98927.c | 14 +++++++ sound/soc/intel/boards/kbl_rt5660.c | 14 ++++++- sound/soc/intel/boards/kbl_rt5663_max98927.c | 14 ++++++- .../soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 14 ++++++- sound/soc/intel/boards/skl_hda_dsp_common.c | 22 +++++++++++ sound/soc/intel/boards/skl_hda_dsp_common.h | 1 + sound/soc/intel/boards/skl_hda_dsp_generic.c | 12 ++++++ sound/soc/intel/boards/skl_nau88l25_max98357a.c | 36 ++++++++++++++++- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 36 ++++++++++++++++- 14 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 sound/soc/intel/boards/hdac_hdmi_common.h
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between cAVS generic machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/skl_hda_dsp_common.c | 22 ++++++++++++++++++++++ sound/soc/intel/boards/skl_hda_dsp_common.h | 1 + sound/soc/intel/boards/skl_hda_dsp_generic.c | 12 ++++++++++++ 3 files changed, 35 insertions(+)
diff --git a/sound/soc/intel/boards/skl_hda_dsp_common.c b/sound/soc/intel/boards/skl_hda_dsp_common.c index 3fdbf23..9144e38 100644 --- a/sound/soc/intel/boards/skl_hda_dsp_common.c +++ b/sound/soc/intel/boards/skl_hda_dsp_common.c @@ -17,6 +17,25 @@
#define NAME_SIZE 32
+static int skl_hdmi_init(struct snd_soc_pcm_runtime *rtd) +{ + struct skl_hda_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *dai = rtd->codec_dai; + + /* + * Setup a device_link between machine device and HDMI codec device. + * The machine device is the consumer and the HDMI codec device is + * the supplier. With this setting, we can make sure that the audio + * domain in display power will be always turned on before operating + * on the HDMI audio codec registers. + */ + if (!ctx->link) + ctx->link = device_link_add(rtd->card->dev, dai->dev, + DL_FLAG_RPM_ACTIVE); + + return 0; +} + int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device) { struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card); @@ -48,6 +67,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = { .cpu_dai_name = "iDisp1 Pin", .codec_name = "ehdaudio0D2", .codec_dai_name = "intel-hdmi-hifi1", + .init = skl_hdmi_init, .dpcm_playback = 1, .no_pcm = 1, }, @@ -57,6 +77,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = { .cpu_dai_name = "iDisp2 Pin", .codec_name = "ehdaudio0D2", .codec_dai_name = "intel-hdmi-hifi2", + .init = skl_hdmi_init, .dpcm_playback = 1, .no_pcm = 1, }, @@ -66,6 +87,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = { .cpu_dai_name = "iDisp3 Pin", .codec_name = "ehdaudio0D2", .codec_dai_name = "intel-hdmi-hifi3", + .init = skl_hdmi_init, .dpcm_playback = 1, .no_pcm = 1, }, diff --git a/sound/soc/intel/boards/skl_hda_dsp_common.h b/sound/soc/intel/boards/skl_hda_dsp_common.h index 87c50af..df5cc6b 100644 --- a/sound/soc/intel/boards/skl_hda_dsp_common.h +++ b/sound/soc/intel/boards/skl_hda_dsp_common.h @@ -29,6 +29,7 @@ struct skl_hda_private { int pcm_count; int dai_index; const char *platform_name; + struct device_link *link; };
extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS]; diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c index b9a21e6..ceca11e 100644 --- a/sound/soc/intel/boards/skl_hda_dsp_generic.c +++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c @@ -166,8 +166,20 @@ static int skl_hda_audio_probe(struct platform_device *pdev) return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card); }
+static int skl_hda_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card); + + if (ctx->link) + device_link_del(ctx->link); + + return 0; +} + static struct platform_driver skl_hda_audio = { .probe = skl_hda_audio_probe, + .remove = skl_hda_audio_remove, .driver = { .name = "skl_hda_dsp_generic", .pm = &snd_soc_pm_ops,
From: Libin Yang libin.yang@intel.com
Create hdac_hdmi_common.h and define some general functions related to hdac_hdmi codec.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/hdac_hdmi_common.h | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sound/soc/intel/boards/hdac_hdmi_common.h
diff --git a/sound/soc/intel/boards/hdac_hdmi_common.h b/sound/soc/intel/boards/hdac_hdmi_common.h new file mode 100644 index 0000000..565906cf --- /dev/null +++ b/sound/soc/intel/boards/hdac_hdmi_common.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright(c) 2019 Intel Corporation. + */ + +/* + * This file includes the general functions related to hdac_hdmi codec, + * which is used by the different boards + */ + +#ifndef __SOUND_SOC_HDAC_HDMI_COMMON +#define __SOUND_SOC_HDAC_HDMI_COMMON + +static int hdac_hdmi_add_device_link(struct device *consumer, + struct device *supplier, + struct device_link **link) +{ + /* + * Setup a device_link between machine device and HDMI codec device. + * The machine device is the consumer and the HDMI codec device is + * the supplier. With this setting, we can make sure that the audio + * domain in display power will be always turned on before operating + * on the HDMI audio codec registers. + */ + if (!(*link)) + *link = device_link_add(consumer, supplier, DL_FLAG_RPM_ACTIVE); + + if (!(*link)) + dev_warn(consumer, + "failed creating device_link for HDMI codec\n"); + + return 0; +} + +static int hdac_hdmi_del_device_link(struct device_link **link) +{ + /* + * delete the device_link between machine device and HDMI codec device. + */ + if (*link) + device_link_del(*link); + + return 0; +} + +#endif /* __SOUND_SOC_HDAC_HDMI_COMMON */
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between bxt_da7219_max98357a machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/bxt_da7219_max98357a.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c index 5cadb7f..9a0ec2c 100644 --- a/sound/soc/intel/boards/bxt_da7219_max98357a.c +++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c @@ -29,6 +29,7 @@ #include "../../codecs/hdac_hdmi.h" #include "../../codecs/da7219.h" #include "../../codecs/da7219-aad.h" +#include "hdac_hdmi_common.h"
#define BXT_DIALOG_CODEC_DAI "da7219-hifi" #define BXT_MAXIM_CODEC_DAI "HiFi" @@ -46,6 +47,7 @@ struct bxt_hdmi_pcm {
struct bxt_card_private { struct list_head hdmi_pcm_list; + struct device_link *link; };
enum { @@ -237,7 +239,8 @@ static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int broxton_da7219_fe_init(struct snd_soc_pcm_runtime *rtd) @@ -684,8 +687,17 @@ static const struct platform_device_id bxt_board_ids[] = { { } };
+static int broxton_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card); + + return hdac_hdmi_del_device_link(&ctx->link); +} + static struct platform_driver broxton_audio = { .probe = broxton_audio_probe, + .remove = broxton_audio_remove, .driver = { .name = "bxt_da7219_max98357a", .pm = &snd_soc_pm_ops,
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between bxt_rt298 machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/bxt_rt298.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c index e91057f..1d40dd3 100644 --- a/sound/soc/intel/boards/bxt_rt298.c +++ b/sound/soc/intel/boards/bxt_rt298.c @@ -26,6 +26,7 @@ #include <sound/pcm_params.h> #include "../../codecs/hdac_hdmi.h" #include "../../codecs/rt298.h" +#include "hdac_hdmi_common.h"
/* Headset jack detection DAPM pins */ static struct snd_soc_jack broxton_headset; @@ -39,6 +40,7 @@ struct bxt_hdmi_pcm {
struct bxt_rt286_private { struct list_head hdmi_pcm_list; + struct device_link *link; };
enum { @@ -204,7 +206,8 @@ static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int broxton_ssp5_fixup(struct snd_soc_pcm_runtime *rtd, @@ -626,8 +629,17 @@ static const struct platform_device_id bxt_board_ids[] = { {} };
+static int broxton_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(card); + + return hdac_hdmi_del_device_link(&ctx->link); +} + static struct platform_driver broxton_audio = { .probe = broxton_audio_probe, + .remove = broxton_audio_remove, .driver = { .name = "bxt_alc298s_i2s", .pm = &snd_soc_pm_ops,
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between glk_rt5682_max98357a machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/glk_rt5682_max98357a.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/boards/glk_rt5682_max98357a.c b/sound/soc/intel/boards/glk_rt5682_max98357a.c index d17126f..f35ea41 100644 --- a/sound/soc/intel/boards/glk_rt5682_max98357a.c +++ b/sound/soc/intel/boards/glk_rt5682_max98357a.c @@ -20,6 +20,7 @@ #include "../skylake/skl.h" #include "../../codecs/rt5682.h" #include "../../codecs/hdac_hdmi.h" +#include "hdac_hdmi_common.h"
/* The platform clock outputs 19.2Mhz clock to codec as I2S MCLK */ #define GLK_PLAT_CLK_FREQ 19200000 @@ -42,6 +43,7 @@ struct glk_hdmi_pcm { struct glk_card_private { struct snd_soc_jack geminilake_headset; struct list_head hdmi_pcm_list; + struct device_link *link; };
enum { @@ -218,7 +220,8 @@ static int geminilake_hdmi_init(struct snd_soc_pcm_runtime *rtd)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int geminilake_rt5682_fe_init(struct snd_soc_pcm_runtime *rtd) @@ -607,8 +610,17 @@ static const struct platform_device_id glk_board_ids[] = { { } };
+static int geminilake_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct glk_card_private *ctx = snd_soc_card_get_drvdata(card); + + return hdac_hdmi_del_device_link(&ctx->link); +} + static struct platform_driver geminilake_audio = { .probe = geminilake_audio_probe, + .remove = geminilake_audio_remove, .driver = { .name = "glk_rt5682_max98357a", .pm = &snd_soc_pm_ops,
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between kbl_da7219_max98357a machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/kbl_da7219_max98357a.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c index 38f6ab7..2f67a9f 100644 --- a/sound/soc/intel/boards/kbl_da7219_max98357a.c +++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c @@ -21,6 +21,7 @@ #include "../../codecs/hdac_hdmi.h" #include "../skylake/skl.h" #include "../../codecs/da7219-aad.h" +#include "hdac_hdmi_common.h"
#define KBL_DIALOG_CODEC_DAI "da7219-hifi" #define KBL_MAXIM_CODEC_DAI "HiFi" @@ -40,6 +41,7 @@ struct kbl_hdmi_pcm { struct kbl_codec_private { struct snd_soc_jack kabylake_headset; struct list_head hdmi_pcm_list; + struct device_link *link; };
enum { @@ -216,7 +218,8 @@ static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) @@ -597,8 +600,17 @@ static const struct platform_device_id kbl_board_ids[] = { { } };
+static int kabylake_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); + + return hdac_hdmi_del_device_link(&ctx->link); +} + static struct platform_driver kabylake_audio = { .probe = kabylake_audio_probe, + .remove = kabylake_audio_remove, .driver = { .name = "kbl_da7219_max98357a", .pm = &snd_soc_pm_ops,
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between kbl_da7219_max98927 machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/kbl_da7219_max98927.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/boards/kbl_da7219_max98927.c b/sound/soc/intel/boards/kbl_da7219_max98927.c index f72a7bf..5ae6ddb 100644 --- a/sound/soc/intel/boards/kbl_da7219_max98927.c +++ b/sound/soc/intel/boards/kbl_da7219_max98927.c @@ -21,6 +21,7 @@ #include "../../codecs/hdac_hdmi.h" #include "../skylake/skl.h" #include "../../codecs/da7219-aad.h" +#include "hdac_hdmi_common.h"
#define KBL_DIALOG_CODEC_DAI "da7219-hifi" #define MAX98927_CODEC_DAI "max98927-aif1" @@ -48,6 +49,7 @@ struct kbl_hdmi_pcm { struct kbl_codec_private { struct snd_soc_jack kabylake_headset; struct list_head hdmi_pcm_list; + struct device_link *link; };
enum { @@ -339,7 +341,8 @@ static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) @@ -1113,8 +1116,17 @@ static const struct platform_device_id kbl_board_ids[] = { { } };
+static int kabylake_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); + + return hdac_hdmi_del_device_link(&ctx->link); +} + static struct platform_driver kabylake_audio = { .probe = kabylake_audio_probe, + .remove = kabylake_audio_remove, .driver = { .name = "kbl_da7219_max98_927_373", .pm = &snd_soc_pm_ops,
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between kbl_rt5660 machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/kbl_rt5660.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/boards/kbl_rt5660.c b/sound/soc/intel/boards/kbl_rt5660.c index 3255e00..3150aa9 100644 --- a/sound/soc/intel/boards/kbl_rt5660.c +++ b/sound/soc/intel/boards/kbl_rt5660.c @@ -23,6 +23,7 @@
#include "../../codecs/hdac_hdmi.h" #include "../../codecs/rt5660.h" +#include "hdac_hdmi_common.h"
#define KBL_RT5660_CODEC_DAI "rt5660-aif1" #define DUAL_CHANNEL 2 @@ -41,6 +42,7 @@ struct kbl_hdmi_pcm { struct kbl_codec_private { struct gpio_desc *gpio_lo_mute; struct list_head hdmi_pcm_list; + struct device_link *link; };
enum { @@ -222,7 +224,8 @@ static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) @@ -525,8 +528,17 @@ static const struct platform_device_id kbl_board_ids[] = { { } };
+static int kabylake_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); + + return hdac_hdmi_del_device_link(&ctx->link); +} + static struct platform_driver kabylake_audio = { .probe = kabylake_audio_probe, + .remove = kabylake_audio_remove, .driver = { .name = "kbl_rt5660", .pm = &snd_soc_pm_ops,
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between kbl_rt5663_max98927 machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index d714752..6e23461 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -31,6 +31,7 @@ #include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/clkdev.h> +#include "hdac_hdmi_common.h"
#define KBL_REALTEK_CODEC_DAI "rt5663-aif" #define KBL_MAXIM_CODEC_DAI "max98927-aif1" @@ -53,6 +54,7 @@ struct kbl_rt5663_private { struct list_head hdmi_pcm_list; struct clk *mclk; struct clk *sclk; + struct device_link *link; };
enum { @@ -336,7 +338,8 @@ static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) @@ -1033,8 +1036,17 @@ static const struct platform_device_id kbl_board_ids[] = { { } };
+static int kabylake_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card); + + return hdac_hdmi_del_device_link(&ctx->link); +} + static struct platform_driver kabylake_audio = { .probe = kabylake_audio_probe, + .remove = kabylake_audio_remove, .driver = { .name = "kbl_rt5663_m98927", .pm = &snd_soc_pm_ops,
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between kbl_rt5663_rt5514_max98927 machine device(consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 879f142..e9ec696 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -30,6 +30,7 @@ #include "../../codecs/rt5514.h" #include "../../codecs/rt5663.h" #include "../../codecs/hdac_hdmi.h" +#include "hdac_hdmi_common.h"
#define KBL_REALTEK_CODEC_DAI "rt5663-aif" #define KBL_REALTEK_DMIC_CODEC_DAI "rt5514-aif1" @@ -58,6 +59,7 @@ struct kbl_codec_private { struct snd_soc_jack kabylake_headset; struct list_head hdmi_pcm_list; struct snd_soc_jack kabylake_hdmi[2]; + struct device_link *link; };
enum { @@ -224,7 +226,8 @@ static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) @@ -672,8 +675,17 @@ static const struct platform_device_id kbl_board_ids[] = { { } };
+static int kabylake_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); + + return hdac_hdmi_del_device_link(&ctx->link); +} + static struct platform_driver kabylake_audio = { .probe = kabylake_audio_probe, + .remove = kabylake_audio_remove, .driver = { .name = "kbl_r5514_5663_max", .pm = &snd_soc_pm_ops,
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between skl_nau88l25_max98357a machine device(consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/skl_nau88l25_max98357a.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c index 0922106..38d599b 100644 --- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c +++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c @@ -24,6 +24,7 @@ #include <sound/soc-acpi.h> #include "../../codecs/nau8825.h" #include "../../codecs/hdac_hdmi.h" +#include "hdac_hdmi_common.h"
#define SKL_NUVOTON_CODEC_DAI "nau8825-hifi" #define SKL_MAXIM_CODEC_DAI "HiFi" @@ -42,6 +43,7 @@ struct skl_hdmi_pcm {
struct skl_nau8825_private { struct list_head hdmi_pcm_list; + struct device_link *link; };
enum { @@ -202,7 +204,8 @@ static int skylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) @@ -220,7 +223,8 @@ static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int skylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd) @@ -238,7 +242,8 @@ static int skylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int skylake_nau8825_fe_init(struct snd_soc_pcm_runtime *rtd) @@ -666,8 +671,17 @@ static const struct platform_device_id skl_board_ids[] = { { } };
+static int skylake_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(card); + + return hdac_hdmi_del_device_link(&ctx->link); +} + static struct platform_driver skylake_audio = { .probe = skylake_audio_probe, + .remove = skylake_audio_remove, .driver = { .name = "skl_n88l25_m98357a", .pm = &snd_soc_pm_ops,
From: Libin Yang libin.yang@intel.com
In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.
This patch adds the device_link between skl_nau88l25_ssm4567 machine device(consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.
Signed-off-by: Libin Yang libin.yang@intel.com --- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c index 8433c52..949f1eb 100644 --- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c +++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c @@ -28,6 +28,7 @@ #include <sound/pcm_params.h> #include "../../codecs/nau8825.h" #include "../../codecs/hdac_hdmi.h" +#include "hdac_hdmi_common.h"
#define SKL_NUVOTON_CODEC_DAI "nau8825-hifi" #define SKL_SSM_CODEC_DAI "ssm4567-hifi" @@ -46,6 +47,7 @@ struct skl_hdmi_pcm {
struct skl_nau88125_private { struct list_head hdmi_pcm_list; + struct device_link *link; }; enum { SKL_DPCM_AUDIO_PB = 0, @@ -232,7 +234,8 @@ static int skylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) @@ -250,7 +253,8 @@ static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
@@ -269,7 +273,8 @@ static int skylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
- return 0; + /* Setup a device_link between machine device and HDMI codec device. */ + return hdac_hdmi_add_device_link(rtd->card->dev, dai->dev, &ctx->link); }
static int skylake_nau8825_fe_init(struct snd_soc_pcm_runtime *rtd) @@ -719,8 +724,17 @@ static const struct platform_device_id skl_board_ids[] = { { } };
+static int skylake_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(card); + + return hdac_hdmi_del_device_link(&ctx->link); +} + static struct platform_driver skylake_audio = { .probe = skylake_audio_probe, + .remove = skylake_audio_remove, .driver = { .name = "skl_n88l25_s4567", .pm = &snd_soc_pm_ops,
On Thu, 11 Apr 2019 11:34:47 +0200, libin.yang@intel.com wrote:
From: Libin Yang libin.yang@intel.com
This patchset add the device_link between the machine devices of intel boards and HDMI audio codec. This can make sure that display audio power domain is always turned on before operating on the HDMI audio codecs.
patch 2 adds the helper functions in a new created header file. However skl_hda_dsp_generic doesn't use these helper functions because skl_hda_dsp_generic is a special driver, the add link and delete link operations are in different source code files. If it includes the header file, there is compiling warning.
Now I took a look at the core implementation, and wonder whether we may drop the device_link_del() call if we create the link with DL_FLAG_AUTOREMOVE_CONSUMER? If that works, you don't have to track the link pointer, so it can be dropped as well; i.e. the only addition would be just the extra call of device_link_add() for each machine driver.
thanks,
Takashi
Libin Yang (12): ASoC: intel: skl_hda_dsp_generic: add device_link to HDMI audio ASoC: intel: boards: define some general functions for hdac_hdmi ASoC: intel: bxt_da7219_max98357a: add device_link to HDMI audio ASoC: intel: bxt_rt298: add device_link to HDMI audio ASoC: intel: glk_rt5682_max98357a: add device_link to HDMI audio ASoC: intel: kbl_da7219_max98357a: add device_link to HDMI audio ASoC: intel: kbl_da7219_max98927: add device_link to HDMI audio ASoC: intel: kbl_rt5660: add device_link to HDMI audio ASoC: intel: kbl_rt5663_max98927 add device_link to HDMI audio ASoC: intel: kbl_rt5663_rt5514_max98927 add device_link to HDMI audio ASoC: intel: skl_nau88l25_max98357a add device_link to HDMI audio ASoC: intel: skl_nau88l25_ssm4567 add device_link to HDMI audio
sound/soc/intel/boards/bxt_da7219_max98357a.c | 14 +++++++ sound/soc/intel/boards/bxt_rt298.c | 14 ++++++- sound/soc/intel/boards/glk_rt5682_max98357a.c | 14 +++++++ sound/soc/intel/boards/hdac_hdmi_common.h | 46 ++++++++++++++++++++++ sound/soc/intel/boards/kbl_da7219_max98357a.c | 14 +++++++ sound/soc/intel/boards/kbl_da7219_max98927.c | 14 +++++++ sound/soc/intel/boards/kbl_rt5660.c | 14 ++++++- sound/soc/intel/boards/kbl_rt5663_max98927.c | 14 ++++++- .../soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 14 ++++++- sound/soc/intel/boards/skl_hda_dsp_common.c | 22 +++++++++++ sound/soc/intel/boards/skl_hda_dsp_common.h | 1 + sound/soc/intel/boards/skl_hda_dsp_generic.c | 12 ++++++ sound/soc/intel/boards/skl_nau88l25_max98357a.c | 36 ++++++++++++++++- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 36 ++++++++++++++++- 14 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 sound/soc/intel/boards/hdac_hdmi_common.h
-- 2.7.4
Hi Takashi,
-----Original Message----- From: Takashi Iwai [mailto:tiwai@suse.de] Sent: Thursday, April 11, 2019 6:10 PM To: Yang, Libin libin.yang@intel.com Cc: alsa-devel@alsa-project.org; broonie@kernel.org; pierre- louis.bossart@linux.intel.com Subject: Re: [PATCH 00/12] ASoC: intel: add device_link to HDMI audio
On Thu, 11 Apr 2019 11:34:47 +0200, libin.yang@intel.com wrote:
From: Libin Yang libin.yang@intel.com
This patchset add the device_link between the machine devices of intel boards and HDMI audio codec. This can make sure that display audio power domain is always turned on before operating on the HDMI audio codecs.
patch 2 adds the helper functions in a new created header file. However skl_hda_dsp_generic doesn't use these helper functions because skl_hda_dsp_generic is a special driver, the add link and delete link operations are in different source code files. If it includes the header file, there is compiling warning.
Now I took a look at the core implementation, and wonder whether we may drop the device_link_del() call if we create the link with DL_FLAG_AUTOREMOVE_CONSUMER? If that works, you don't have to track the link pointer, so it can be dropped as well; i.e. the only addition would be just the extra call of device_link_add() for each machine driver.
In the machine drivers, each dai_link will call device_link_add(). So I use the link pointer to check whether it is already created or not to avoid creating the link several times. Like the below code: + if (!(*link)) + *link = device_link_add(consumer, supplier, DL_FLAG_RPM_ACTIVE);
Regards, Libin
thanks,
Takashi
Libin Yang (12): ASoC: intel: skl_hda_dsp_generic: add device_link to HDMI audio ASoC: intel: boards: define some general functions for hdac_hdmi ASoC: intel: bxt_da7219_max98357a: add device_link to HDMI audio ASoC: intel: bxt_rt298: add device_link to HDMI audio ASoC: intel: glk_rt5682_max98357a: add device_link to HDMI audio ASoC: intel: kbl_da7219_max98357a: add device_link to HDMI audio ASoC: intel: kbl_da7219_max98927: add device_link to HDMI audio ASoC: intel: kbl_rt5660: add device_link to HDMI audio ASoC: intel: kbl_rt5663_max98927 add device_link to HDMI audio ASoC: intel: kbl_rt5663_rt5514_max98927 add device_link to HDMI audio ASoC: intel: skl_nau88l25_max98357a add device_link to HDMI audio ASoC: intel: skl_nau88l25_ssm4567 add device_link to HDMI audio
sound/soc/intel/boards/bxt_da7219_max98357a.c | 14 +++++++ sound/soc/intel/boards/bxt_rt298.c | 14 ++++++- sound/soc/intel/boards/glk_rt5682_max98357a.c | 14 +++++++ sound/soc/intel/boards/hdac_hdmi_common.h | 46
++++++++++++++++++++++
sound/soc/intel/boards/kbl_da7219_max98357a.c | 14 +++++++ sound/soc/intel/boards/kbl_da7219_max98927.c | 14 +++++++ sound/soc/intel/boards/kbl_rt5660.c | 14 ++++++- sound/soc/intel/boards/kbl_rt5663_max98927.c | 14 ++++++- .../soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 14 ++++++- sound/soc/intel/boards/skl_hda_dsp_common.c | 22 +++++++++++ sound/soc/intel/boards/skl_hda_dsp_common.h | 1 + sound/soc/intel/boards/skl_hda_dsp_generic.c | 12 ++++++ sound/soc/intel/boards/skl_nau88l25_max98357a.c | 36
++++++++++++++++-
sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 36
++++++++++++++++-
14 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 sound/soc/intel/boards/hdac_hdmi_common.h
-- 2.7.4
On Thu, 11 Apr 2019 14:24:13 +0200, Yang, Libin wrote:
Hi Takashi,
-----Original Message----- From: Takashi Iwai [mailto:tiwai@suse.de] Sent: Thursday, April 11, 2019 6:10 PM To: Yang, Libin libin.yang@intel.com Cc: alsa-devel@alsa-project.org; broonie@kernel.org; pierre- louis.bossart@linux.intel.com Subject: Re: [PATCH 00/12] ASoC: intel: add device_link to HDMI audio
On Thu, 11 Apr 2019 11:34:47 +0200, libin.yang@intel.com wrote:
From: Libin Yang libin.yang@intel.com
This patchset add the device_link between the machine devices of intel boards and HDMI audio codec. This can make sure that display audio power domain is always turned on before operating on the HDMI audio codecs.
patch 2 adds the helper functions in a new created header file. However skl_hda_dsp_generic doesn't use these helper functions because skl_hda_dsp_generic is a special driver, the add link and delete link operations are in different source code files. If it includes the header file, there is compiling warning.
Now I took a look at the core implementation, and wonder whether we may drop the device_link_del() call if we create the link with DL_FLAG_AUTOREMOVE_CONSUMER? If that works, you don't have to track the link pointer, so it can be dropped as well; i.e. the only addition would be just the extra call of device_link_add() for each machine driver.
In the machine drivers, each dai_link will call device_link_add(). So I use the link pointer to check whether it is already created or not to avoid creating the link several times. Like the below code:
if (!(*link))
*link = device_link_add(consumer, supplier, DL_FLAG_RPM_ACTIVE);
Yes, that's fine. What I meant is the rest part, device_link_del() call and keeping the link pointer. Both look superfluous once when you create a device link with DL_FLAG_AUTOREMOVE_CONSUMER flag, then the device link will be automatically cleaned up at the device removal.
thanks,
Takashi
participants (3)
-
libin.yang@intel.com
-
Takashi Iwai
-
Yang, Libin