From 4d661ea606424816d77b4cf935c27c1e78e0ae99 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 7 Nov 2018 13:28:07 -0600 Subject: [PATCH 01/10] ASoC: Intel: bxt_pcm512x: make HDMI optional Make sure we can test without the HDMI/HDAC dependencies Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/bxt_pcm512x.c | 116 +++++++++++++++------------ 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/sound/soc/intel/boards/bxt_pcm512x.c b/sound/soc/intel/boards/bxt_pcm512x.c index 258dcfd34e8336..728a53876374ce 100644 --- a/sound/soc/intel/boards/bxt_pcm512x.c +++ b/sound/soc/intel/boards/bxt_pcm512x.c @@ -32,6 +32,7 @@ #include "../../codecs/pcm512x.h" #include "../atom/sst-atom-controls.h" +#ifdef CONFIG_SND_SOC_HDAC_HDMI static struct snd_soc_jack broxton_hdmi[3]; struct bxt_hdmi_pcm { @@ -40,6 +41,64 @@ struct bxt_hdmi_pcm { int device; }; +static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd) +{ + struct bxt_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *dai = rtd->codec_dai; + struct bxt_hdmi_pcm *pcm; + + pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); + if (!pcm) + return -ENOMEM; + + pcm->device = dai->id; + pcm->codec_dai = dai; + + list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); + + return 0; +} + +#define NAME_SIZE 32 +static int bxt_card_late_probe(struct snd_soc_card *card) +{ + struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card); + struct bxt_hdmi_pcm *pcm; + struct snd_soc_component *component = NULL; + int err, i = 0; + char jack_name[NAME_SIZE]; + + list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { + component = pcm->codec_dai->component; + snprintf(jack_name, sizeof(jack_name), + "HDMI/DP, pcm=%d Jack", pcm->device); + err = snd_soc_card_jack_new(card, jack_name, + SND_JACK_AVOUT, &broxton_hdmi[i], + NULL, 0); + + if (err) + return err; + + err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, + &broxton_hdmi[i]); + if (err < 0) + return err; + + i++; + } + + if (!component) + return -EINVAL; + + return hdac_hdmi_jack_port_init(component, &card->dapm); +} +#else +static int bxt_card_late_probe(struct snd_soc_card *card) +{ + return 0; +} +#endif + struct bxt_card_private { struct list_head hdmi_pcm_list; }; @@ -114,24 +173,6 @@ static const struct snd_soc_ops aif1_ops = { .shutdown = aif1_shutdown, }; -static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd) -{ - struct bxt_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_dai *dai = rtd->codec_dai; - struct bxt_hdmi_pcm *pcm; - - pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); - if (!pcm) - return -ENOMEM; - - pcm->device = dai->id; - pcm->codec_dai = dai; - - list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); - - return 0; -} - static struct snd_soc_dai_link dailink[] = { /* CODEC<->CODEC link */ /* back ends */ @@ -151,6 +192,7 @@ static struct snd_soc_dai_link dailink[] = { .dpcm_playback = 1, .dpcm_capture = 1, }, +#ifdef CONFIG_SND_SOC_HDAC_HDMI { .name = "iDisp1", .id = 1, @@ -184,42 +226,9 @@ static struct snd_soc_dai_link dailink[] = { .dpcm_playback = 1, .no_pcm = 1, }, - +#endif }; -#define NAME_SIZE 32 -static int bxt_card_late_probe(struct snd_soc_card *card) -{ - struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card); - struct bxt_hdmi_pcm *pcm; - struct snd_soc_component *component = NULL; - int err, i = 0; - char jack_name[NAME_SIZE]; - - list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - component = pcm->codec_dai->component; - snprintf(jack_name, sizeof(jack_name), - "HDMI/DP, pcm=%d Jack", pcm->device); - err = snd_soc_card_jack_new(card, jack_name, - SND_JACK_AVOUT, &broxton_hdmi[i], - NULL, 0); - - if (err) - return err; - - err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, - &broxton_hdmi[i]); - if (err < 0) - return err; - - i++; - } - - if (!component) - return -EINVAL; - - return hdac_hdmi_jack_port_init(component, &card->dapm); -} /* SoC card */ static struct snd_soc_card bxt_pcm512x_card = { @@ -250,7 +259,8 @@ static int bxt_pcm512x_probe(struct platform_device *pdev) if (!ctx) return -ENOMEM; - INIT_LIST_HEAD(&ctx->hdmi_pcm_list); + if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) + INIT_LIST_HEAD(&ctx->hdmi_pcm_list); mach = (&pdev->dev)->platform_data; card = &bxt_pcm512x_card; From e0477ba63f4935829d2496dfcc6fef16ec0f4426 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 7 Nov 2018 14:03:43 -0600 Subject: [PATCH 02/10] ASoC: SOF: core: unregister machine device on remove Make sure the machine driver goes through its .remove step. This enables load/unload module cases. Tested on Up2 with Hifiberry DAC+ (no HDA/HDMI to avoid HDAC contagion) Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index edd5ea3e505fa8..c528246c96e5b8 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -379,6 +379,10 @@ static int sof_probe(struct platform_device *pdev) static int sof_remove(struct platform_device *pdev) { struct snd_sof_dev *sdev = dev_get_drvdata(&pdev->dev); + struct snd_sof_pdata *pdata = sdev->pdata; + + if (pdata && !IS_ERR(pdata->pdev_mach)) + platform_device_unregister(pdata->pdev_mach); snd_soc_unregister_component(&pdev->dev); snd_sof_fw_unload(sdev); From 1239ff9354f2c2440f6503dabc3fb457f0fe0a3e Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 8 Nov 2018 14:51:13 -0600 Subject: [PATCH 03/10] ASoC: SOF: pci: don't unregister machine platform device The machine platform device is unregistered in the SOF core .remove. Doing this here creates problems with sysfs, likely due to a device hierarchy issue (only the parent should unregister the child?) Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/sof-pci-dev.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index 98f041247b3922..d3ecbc8b6bc46f 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -281,9 +281,6 @@ static void sof_pci_remove(struct pci_dev *pci) struct sof_platform_priv *priv = pci_get_drvdata(pci); struct snd_sof_pdata *sof_pdata = priv->sof_pdata; - /* unregister machine driver */ - platform_device_unregister(sof_pdata->pdev_mach); - /* unregister sof-audio platform driver */ if (!IS_ERR_OR_NULL(priv->pdev_pcm)) platform_device_unregister(priv->pdev_pcm); From 80c4f5bbeb1143e64a49024505796337459c283f Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 8 Nov 2018 15:09:28 -0600 Subject: [PATCH 04/10] ASoC: SOF: pci: use IS_ERR to test platform device platform_device_register_data only returns an ERR_PTR Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/sof-pci-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index d3ecbc8b6bc46f..450de9d779a951 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -282,7 +282,7 @@ static void sof_pci_remove(struct pci_dev *pci) struct snd_sof_pdata *sof_pdata = priv->sof_pdata; /* unregister sof-audio platform driver */ - if (!IS_ERR_OR_NULL(priv->pdev_pcm)) + if (!IS_ERR(priv->pdev_pcm)) platform_device_unregister(priv->pdev_pcm); /* release firmware */ From 690dd93738ca34254b87e7ba4fbb7120f6deee94 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 8 Nov 2018 14:59:55 -0600 Subject: [PATCH 05/10] ASoC: SOF: acpi: don't unregister machine platform device The machine platform device is unregistered in the SOF core .remove Also remove an error case handling which isn't possible. If the platform device creation fails then the machine platform device isn't created either. Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/sof-acpi-dev.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 7fe49c91c84fc2..1d5e4faea29858 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -258,7 +258,6 @@ static int sof_acpi_probe(struct platform_device *pdev) /* register sof-audio platform driver */ ret = sof_create_platform_device(priv); if (ret) { - platform_device_unregister(sof_pdata->pdev_mach); dev_err(dev, "error: failed to create platform device!\n"); return ret; } @@ -281,7 +280,6 @@ static int sof_acpi_remove(struct platform_device *pdev) struct sof_platform_priv *priv = dev_get_drvdata(&pdev->dev); struct snd_sof_pdata *sof_pdata = priv->sof_pdata; - platform_device_unregister(sof_pdata->pdev_mach); if (!IS_ERR_OR_NULL(priv->pdev_pcm)) platform_device_unregister(priv->pdev_pcm); release_firmware(sof_pdata->fw); From fe00de2056064d916c131af83a47f18dd84c4acd Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 8 Nov 2018 15:11:25 -0600 Subject: [PATCH 06/10] ASoC: SOF: acpi: use IS_ERR to test platform device platform_device_register_data only returns an ERR_PTR Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/sof-acpi-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 1d5e4faea29858..dc44c5c1146f88 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -280,7 +280,7 @@ static int sof_acpi_remove(struct platform_device *pdev) struct sof_platform_priv *priv = dev_get_drvdata(&pdev->dev); struct snd_sof_pdata *sof_pdata = priv->sof_pdata; - if (!IS_ERR_OR_NULL(priv->pdev_pcm)) + if (!IS_ERR(priv->pdev_pcm)) platform_device_unregister(priv->pdev_pcm); release_firmware(sof_pdata->fw); From 949e5f045dcfd007411d0fcca3c4b0e9f4f4014e Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 8 Nov 2018 15:03:33 -0600 Subject: [PATCH 07/10] ASoC: SOF: spi: don't unregister machine platform device The machine platform device is unregistered in the SOF core .remove Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/sof-spi-dev.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/sof/sof-spi-dev.c b/sound/soc/sof/sof-spi-dev.c index dc5867b7fa4a4e..3556bb35764f0a 100644 --- a/sound/soc/sof/sof-spi-dev.c +++ b/sound/soc/sof/sof-spi-dev.c @@ -152,7 +152,6 @@ static int sof_spi_remove(struct spi_device *spi) struct sof_platform_priv *priv = spi_get_drvdata(spi); struct snd_sof_pdata *sof_pdata = priv->sof_pdata; - platform_device_unregister(sof_pdata->pdev_mach); if (!IS_ERR_OR_NULL(priv->pdev_pcm)) platform_device_unregister(priv->pdev_pcm); release_firmware(sof_pdata->fw); From eed5e14ea6f17469d263a454cc0c90a6f20d3059 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 8 Nov 2018 15:11:42 -0600 Subject: [PATCH 08/10] ASoC: SOF: spi: use IS_ERR to test platform device platform_device_register_data only returns an ERR_PTR Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/sof-spi-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/sof/sof-spi-dev.c b/sound/soc/sof/sof-spi-dev.c index 3556bb35764f0a..4445a91a732683 100644 --- a/sound/soc/sof/sof-spi-dev.c +++ b/sound/soc/sof/sof-spi-dev.c @@ -152,7 +152,7 @@ static int sof_spi_remove(struct spi_device *spi) struct sof_platform_priv *priv = spi_get_drvdata(spi); struct snd_sof_pdata *sof_pdata = priv->sof_pdata; - if (!IS_ERR_OR_NULL(priv->pdev_pcm)) + if (!IS_ERR(priv->pdev_pcm)) platform_device_unregister(priv->pdev_pcm); release_firmware(sof_pdata->fw); From 8f420021162f138055059245f89f2ab7450c0d15 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 8 Nov 2018 15:12:04 -0600 Subject: [PATCH 09/10] ASoC: SOF: intel: hda use IS_ERR to test platform device platform_device_register_data only returns an ERR_PTR Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/intel/hda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 89fbb3321b55ec..67c6c7852a0bf7 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -688,7 +688,7 @@ int hda_dsp_remove(struct snd_sof_dev *sdev) struct pci_dev *pci = sdev->pci; const struct sof_intel_dsp_desc *chip = sdev->hda->desc; - if (sdev->hda && (!IS_ERR_OR_NULL(sdev->hda->dmic_dev))) + if (sdev->hda && (!IS_ERR(sdev->hda->dmic_dev))) platform_device_unregister(sdev->hda->dmic_dev); /* disable DSP IRQ */ From 0ac74e32e0fbdcd7bc05ff59dc9b882442dea8a8 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 7 Nov 2018 16:51:33 -0600 Subject: [PATCH 10/10] ASoC: SOF: nocodec: fix card prefix The "sof-" prefix is added by the code, don't add it to the card name. This helps make sure the card is named "sof-nocodec" instead of "sof-sof-nocodec", e.g. root@ubilinux4:~# aplay -l **** List of PLAYBACK Hardware Devices **** card 0: sofnocodec [sof-nocodec], device 0: Port0 (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0 Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/nocodec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/sof/nocodec.c b/sound/soc/sof/nocodec.c index 3ec658f96b3d08..d3ea428ab8e262 100644 --- a/sound/soc/sof/nocodec.c +++ b/sound/soc/sof/nocodec.c @@ -23,7 +23,7 @@ #include "sof-priv.h" static struct snd_soc_card sof_nocodec_card = { - .name = "sof-nocodec", + .name = "nocodec", /* the sof- prefix is added by the core */ }; int sof_nocodec_setup(struct device *dev,