All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: Intel: ACPI-related fixes
@ 2018-01-03 17:02 Pierre-Louis Bossart
  2018-01-03 17:02 ` [PATCH 1/3] [PATCH] ASoC: acpi: fix machine driver selection based on quirk Pierre-Louis Bossart
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-01-03 17:02 UTC (permalink / raw)
  To: alsa-devel
  Cc: liam.r.girdwood, tiwai, Pierre-Louis Bossart, jeremy, vinod.koul,
	broonie, andriy.shevchenko

Here are 3 patches that were provided earlier on the mailing list or
in Bugzilla entries, I rebased and ported them on top of the latest
ACPI/KConfig fixes.

Jeremy Cline (1):
  ASoC: Replace snd_soc_acpi_check_hid with acpi_dev_present

Pierre-Louis Bossart (2):
  ASoC: acpi: fix machine driver selection based on quirk
  ASoC: Intel: bytcht_es8316: fix HID handling

 include/sound/soc-acpi.h               |  3 ---
 sound/soc/intel/boards/Kconfig         |  1 +
 sound/soc/intel/boards/bytcht_es8316.c | 26 ++++++++++++++++++++++-
 sound/soc/soc-acpi.c                   | 38 ++++------------------------------
 4 files changed, 30 insertions(+), 38 deletions(-)

-- 
2.14.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/3] [PATCH] ASoC: acpi: fix machine driver selection based on quirk
  2018-01-03 17:02 [PATCH 0/3] ASoC: Intel: ACPI-related fixes Pierre-Louis Bossart
@ 2018-01-03 17:02 ` Pierre-Louis Bossart
  2018-01-04 13:08   ` Andy Shevchenko
  2018-01-03 17:02 ` [PATCH 2/3] ASoC: Replace snd_soc_acpi_check_hid with acpi_dev_present Pierre-Louis Bossart
  2018-01-03 17:02 ` [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling Pierre-Louis Bossart
  2 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-01-03 17:02 UTC (permalink / raw)
  To: alsa-devel
  Cc: liam.r.girdwood, tiwai, Pierre-Louis Bossart, jeremy, vinod.koul,
	broonie, andriy.shevchenko

The ACPI/machine-driver code refactoring introduced in 4.13 introduced
a regression for cases where we need a DMI-based quirk to select the
machine driver (the BIOS reports an invalid HID). The fix is just to
make sure the results of the quirk are actually used.

Fixes: 54746dabf770 ('ASoC: Improve machine driver selection based on quirk data')
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=96691
Tested-by: Nicole Færber <nicole.faerber@dpin.de>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/soc-acpi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/soc-acpi.c b/sound/soc/soc-acpi.c
index f21df28bc28e..e103f3571b55 100644
--- a/sound/soc/soc-acpi.c
+++ b/sound/soc/soc-acpi.c
@@ -84,11 +84,9 @@ snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines)
 
 	for (mach = machines; mach->id[0]; mach++) {
 		if (snd_soc_acpi_check_hid(mach->id) == true) {
-			if (mach->machine_quirk == NULL)
-				return mach;
-
 			if (mach->machine_quirk(mach) != NULL)
-				return mach;
+				mach = mach->machine_quirk(mach);
+			return mach;
 		}
 	}
 	return NULL;
-- 
2.14.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/3] ASoC: Replace snd_soc_acpi_check_hid with acpi_dev_present
  2018-01-03 17:02 [PATCH 0/3] ASoC: Intel: ACPI-related fixes Pierre-Louis Bossart
  2018-01-03 17:02 ` [PATCH 1/3] [PATCH] ASoC: acpi: fix machine driver selection based on quirk Pierre-Louis Bossart
@ 2018-01-03 17:02 ` Pierre-Louis Bossart
  2018-01-04 13:09   ` Andy Shevchenko
  2018-01-03 17:02 ` [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling Pierre-Louis Bossart
  2 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-01-03 17:02 UTC (permalink / raw)
  To: alsa-devel
  Cc: liam.r.girdwood, tiwai, Pierre-Louis Bossart, jeremy, vinod.koul,
	broonie, andriy.shevchenko

From: Jeremy Cline <jeremy@jcline.org>

Replace snd_soc_acpi_check_hid() with the generic acpi_dev_present()
and remove the now unused snd_soc_acpi_check_hid function. This should
have no functional change.

Signed-off-by: Jeremy Cline <jeremy@jcline.org>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 include/sound/soc-acpi.h |  3 ---
 sound/soc/soc-acpi.c     | 32 ++------------------------------
 2 files changed, 2 insertions(+), 33 deletions(-)

diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h
index a93436089bf5..d1aaf876cd26 100644
--- a/include/sound/soc-acpi.h
+++ b/include/sound/soc-acpi.h
@@ -50,9 +50,6 @@ snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
 struct snd_soc_acpi_mach *
 snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);
 
-/* acpi check hid */
-bool snd_soc_acpi_check_hid(const u8 hid[ACPI_ID_LEN]);
-
 /**
  * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
  * related to the hardware, except for the firmware and topology file names.
diff --git a/sound/soc/soc-acpi.c b/sound/soc/soc-acpi.c
index e103f3571b55..06d2aaccdb32 100644
--- a/sound/soc/soc-acpi.c
+++ b/sound/soc/soc-acpi.c
@@ -49,41 +49,13 @@ const char *snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
 }
 EXPORT_SYMBOL_GPL(snd_soc_acpi_find_name_from_hid);
 
-static acpi_status snd_soc_acpi_mach_match(acpi_handle handle, u32 level,
-				       void *context, void **ret)
-{
-	unsigned long long sta;
-	acpi_status status;
-
-	*(bool *)context = true;
-	status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
-	if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT))
-		*(bool *)context = false;
-
-	return AE_OK;
-}
-
-bool snd_soc_acpi_check_hid(const u8 hid[ACPI_ID_LEN])
-{
-	acpi_status status;
-	bool found = false;
-
-	status = acpi_get_devices(hid, snd_soc_acpi_mach_match, &found, NULL);
-
-	if (ACPI_FAILURE(status))
-		return false;
-
-	return found;
-}
-EXPORT_SYMBOL_GPL(snd_soc_acpi_check_hid);
-
 struct snd_soc_acpi_mach *
 snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines)
 {
 	struct snd_soc_acpi_mach *mach;
 
 	for (mach = machines; mach->id[0]; mach++) {
-		if (snd_soc_acpi_check_hid(mach->id) == true) {
+		if (acpi_dev_present(mach->id, NULL, -1)) {
 			if (mach->machine_quirk(mach) != NULL)
 				mach = mach->machine_quirk(mach);
 			return mach;
@@ -161,7 +133,7 @@ struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)
 		return mach;
 
 	for (i = 0; i < codec_list->num_codecs; i++) {
-		if (snd_soc_acpi_check_hid(codec_list->codecs[i]) != true)
+		if (!acpi_dev_present(codec_list->codecs[i], NULL, -1))
 			return NULL;
 	}
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling
  2018-01-03 17:02 [PATCH 0/3] ASoC: Intel: ACPI-related fixes Pierre-Louis Bossart
  2018-01-03 17:02 ` [PATCH 1/3] [PATCH] ASoC: acpi: fix machine driver selection based on quirk Pierre-Louis Bossart
  2018-01-03 17:02 ` [PATCH 2/3] ASoC: Replace snd_soc_acpi_check_hid with acpi_dev_present Pierre-Louis Bossart
@ 2018-01-03 17:02 ` Pierre-Louis Bossart
  2018-01-04 14:57   ` Andy Shevchenko
  2018-01-12 21:09   ` Applied "ASoC: Intel: bytcht_es8316: fix HID handling" to the asoc tree Mark Brown
  2 siblings, 2 replies; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-01-03 17:02 UTC (permalink / raw)
  To: alsa-devel
  Cc: liam.r.girdwood, tiwai, Pierre-Louis Bossart, jeremy, vinod.koul,
	broonie, andriy.shevchenko

Same problem as with previous machine drivers, the codec dai
uses a hard-coded name of "i2c-ESSX8316:00" but ACPI provides
"i2c-ESSX8316:01" in some systems.

Fix by overriding the hard-coded value with the codec name derived
from the HID information

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189261
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/boards/Kconfig         |  1 +
 sound/soc/intel/boards/bytcht_es8316.c | 26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
index 89a73e3d9d2d..4af2393160bf 100644
--- a/sound/soc/intel/boards/Kconfig
+++ b/sound/soc/intel/boards/Kconfig
@@ -153,6 +153,7 @@ config SND_SOC_INTEL_BYT_CHT_DA7213_MACH
 config SND_SOC_INTEL_BYT_CHT_ES8316_MACH
 	tristate "Baytrail & Cherrytrail with ES8316 codec"
 	depends on X86_INTEL_LPSS && I2C && ACPI
+	select SND_SOC_ACPI
 	select SND_SOC_ES8316
 	help
 	  This adds support for ASoC machine driver for Intel(R) Baytrail &
diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index 8088396717e3..ae24f6205f05 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -232,15 +232,39 @@ static struct snd_soc_card byt_cht_es8316_card = {
 	.fully_routed = true,
 };
 
+static char codec_name[16]; /* i2c-<HID>:00 with HID being 8 chars */
+
 static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 {
-	int ret = 0;
 	struct byt_cht_es8316_private *priv;
+	struct snd_soc_acpi_mach *mach;
+	const char *i2c_name = NULL;
+	int dai_index = 0;
+	int i;
+	int ret = 0;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_ATOMIC);
 	if (!priv)
 		return -ENOMEM;
 
+	mach = (&pdev->dev)->platform_data;
+	/* fix index of codec dai */
+	for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) {
+		if (!strcmp(byt_cht_es8316_dais[i].codec_name,
+			    "i2c-ESSX8316:00")) {
+			dai_index = i;
+			break;
+		}
+	}
+
+	/* fixup codec name based on HID */
+	i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
+	if (i2c_name) {
+		snprintf(codec_name, sizeof(codec_name),
+			"%s%s", "i2c-", i2c_name);
+		byt_cht_es8316_dais[dai_index].codec_name = codec_name;
+	}
+
 	/* register the soc card */
 	byt_cht_es8316_card.dev = &pdev->dev;
 	snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv);
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] [PATCH] ASoC: acpi: fix machine driver selection based on quirk
  2018-01-03 17:02 ` [PATCH 1/3] [PATCH] ASoC: acpi: fix machine driver selection based on quirk Pierre-Louis Bossart
@ 2018-01-04 13:08   ` Andy Shevchenko
  2018-01-04 15:18     ` Pierre-Louis Bossart
  0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2018-01-04 13:08 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel
  Cc: tiwai, vinod.koul, broonie, jeremy, liam.r.girdwood

On Wed, 2018-01-03 at 11:02 -0600, Pierre-Louis Bossart wrote:
> The ACPI/machine-driver code refactoring introduced in 4.13 introduced
> a regression for cases where we need a DMI-based quirk to select the
> machine driver (the BIOS reports an invalid HID). The fix is just to
> make sure the results of the quirk are actually used.
> 

>  	for (mach = machines; mach->id[0]; mach++) {
>  		if (snd_soc_acpi_check_hid(mach->id) == true) {
>  			if (mach->machine_quirk(mach) != NULL)

Just a nit: perhaps use more natural style, i.e. drop " != NULL" part
off?

> +				mach = mach->machine_quirk(mach);
> +			return mach;
>  		}
>  	}
>  	return NULL;

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/3] ASoC: Replace snd_soc_acpi_check_hid with acpi_dev_present
  2018-01-03 17:02 ` [PATCH 2/3] ASoC: Replace snd_soc_acpi_check_hid with acpi_dev_present Pierre-Louis Bossart
@ 2018-01-04 13:09   ` Andy Shevchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2018-01-04 13:09 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel
  Cc: tiwai, vinod.koul, broonie, jeremy, liam.r.girdwood

On Wed, 2018-01-03 at 11:02 -0600, Pierre-Louis Bossart wrote:
> From: Jeremy Cline <jeremy@jcline.org>
> 
> Replace snd_soc_acpi_check_hid() with the generic acpi_dev_present()
> and remove the now unused snd_soc_acpi_check_hid function. This should
> 
> have no functional change.

Nice catch!

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> 
> Signed-off-by: Jeremy Cline <jeremy@jcline.org>
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.
> com>
> ---
>  include/sound/soc-acpi.h |  3 ---
>  sound/soc/soc-acpi.c     | 32 ++------------------------------
>  2 files changed, 2 insertions(+), 33 deletions(-)
> 
> diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h
> index a93436089bf5..d1aaf876cd26 100644
> --- a/include/sound/soc-acpi.h
> +++ b/include/sound/soc-acpi.h
> @@ -50,9 +50,6 @@ snd_soc_acpi_find_package_from_hid(const u8
> hid[ACPI_ID_LEN],
>  struct snd_soc_acpi_mach *
>  snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);
>  
> -/* acpi check hid */
> -bool snd_soc_acpi_check_hid(const u8 hid[ACPI_ID_LEN]);
> -
>  /**
>   * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the
> fields are
>   * related to the hardware, except for the firmware and topology file
> names.
> diff --git a/sound/soc/soc-acpi.c b/sound/soc/soc-acpi.c
> index e103f3571b55..06d2aaccdb32 100644
> --- a/sound/soc/soc-acpi.c
> +++ b/sound/soc/soc-acpi.c
> @@ -49,41 +49,13 @@ const char *snd_soc_acpi_find_name_from_hid(const
> u8 hid[ACPI_ID_LEN])
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_acpi_find_name_from_hid);
>  
> -static acpi_status snd_soc_acpi_mach_match(acpi_handle handle, u32
> level,
> -				       void *context, void **ret)
> -{
> -	unsigned long long sta;
> -	acpi_status status;
> -
> -	*(bool *)context = true;
> -	status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
> -	if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT))
> -		*(bool *)context = false;
> -
> -	return AE_OK;
> -}
> -
> -bool snd_soc_acpi_check_hid(const u8 hid[ACPI_ID_LEN])
> -{
> -	acpi_status status;
> -	bool found = false;
> -
> -	status = acpi_get_devices(hid, snd_soc_acpi_mach_match,
> &found, NULL);
> -
> -	if (ACPI_FAILURE(status))
> -		return false;
> -
> -	return found;
> -}
> -EXPORT_SYMBOL_GPL(snd_soc_acpi_check_hid);
> -
>  struct snd_soc_acpi_mach *
>  snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines)
>  {
>  	struct snd_soc_acpi_mach *mach;
>  
>  	for (mach = machines; mach->id[0]; mach++) {
> -		if (snd_soc_acpi_check_hid(mach->id) == true) {
> +		if (acpi_dev_present(mach->id, NULL, -1)) {
>  			if (mach->machine_quirk(mach) != NULL)
>  				mach = mach->machine_quirk(mach);
>  			return mach;
> @@ -161,7 +133,7 @@ struct snd_soc_acpi_mach
> *snd_soc_acpi_codec_list(void *arg)
>  		return mach;
>  
>  	for (i = 0; i < codec_list->num_codecs; i++) {
> -		if (snd_soc_acpi_check_hid(codec_list->codecs[i]) !=
> true)
> +		if (!acpi_dev_present(codec_list->codecs[i], NULL,
> -1))
>  			return NULL;
>  	}
>  

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling
  2018-01-03 17:02 ` [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling Pierre-Louis Bossart
@ 2018-01-04 14:57   ` Andy Shevchenko
  2018-01-04 15:24     ` Pierre-Louis Bossart
  2018-01-12 21:09   ` Applied "ASoC: Intel: bytcht_es8316: fix HID handling" to the asoc tree Mark Brown
  1 sibling, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2018-01-04 14:57 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel
  Cc: tiwai, vinod.koul, broonie, jeremy, liam.r.girdwood

On Wed, 2018-01-03 at 11:02 -0600, Pierre-Louis Bossart wrote:
> Same problem as with previous machine drivers, the codec dai
> uses a hard-coded name of "i2c-ESSX8316:00" but ACPI provides
> "i2c-ESSX8316:01" in some systems.

Yeah, that's why using device instances is fragile...

> 
> Fix by overriding the hard-coded value with the codec name derived
> from the HID information

The patch makes me think about introducing acpi_dev_get_dev_name() and
utilize it here since I need something similar to have in one of GPIO
drivers.

> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189261
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.
> com>
> ---
>  sound/soc/intel/boards/Kconfig         |  1 +
>  sound/soc/intel/boards/bytcht_es8316.c | 26
> +++++++++++++++++++++++++-
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/intel/boards/Kconfig
> b/sound/soc/intel/boards/Kconfig
> index 89a73e3d9d2d..4af2393160bf 100644
> --- a/sound/soc/intel/boards/Kconfig
> +++ b/sound/soc/intel/boards/Kconfig
> @@ -153,6 +153,7 @@ config SND_SOC_INTEL_BYT_CHT_DA7213_MACH
>  config SND_SOC_INTEL_BYT_CHT_ES8316_MACH
>  	tristate "Baytrail & Cherrytrail with ES8316 codec"
>  	depends on X86_INTEL_LPSS && I2C && ACPI
> +	select SND_SOC_ACPI
>  	select SND_SOC_ES8316
>  	help
>  	  This adds support for ASoC machine driver for Intel(R)
> Baytrail &
> diff --git a/sound/soc/intel/boards/bytcht_es8316.c
> b/sound/soc/intel/boards/bytcht_es8316.c
> index 8088396717e3..ae24f6205f05 100644
> --- a/sound/soc/intel/boards/bytcht_es8316.c
> +++ b/sound/soc/intel/boards/bytcht_es8316.c
> @@ -232,15 +232,39 @@ static struct snd_soc_card byt_cht_es8316_card =
> {
>  	.fully_routed = true,
>  };
>  
> +static char codec_name[16]; /* i2c-<HID>:00 with HID being 8 chars */
> +

I would rather do use 4 + ACPI_ID_LEN + 3 /* or 1 + 2 */ + 1 and explain
each part in the comment above.

>  static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
>  {
> -	int ret = 0;
>  	struct byt_cht_es8316_private *priv;
> +	struct snd_soc_acpi_mach *mach;
> +	const char *i2c_name = NULL;
> +	int dai_index = 0;
> +	int i;
> +	int ret = 0;
>  
>  	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_ATOMIC);
>  	if (!priv)
>  		return -ENOMEM;
>  
> +	mach = (&pdev->dev)->platform_data;
> +	/* fix index of codec dai */
> +	for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) {
> +		if (!strcmp(byt_cht_es8316_dais[i].codec_name,
> +			    "i2c-ESSX8316:00")) {
> +			dai_index = i;
> +			break;
> +		}

Perhaps at some point you can do such in more generic (across Intel
ASoCs) ?

> +	}
> +
> +	/* fixup codec name based on HID */
> +	i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
> +	if (i2c_name) {
> +		snprintf(codec_name, sizeof(codec_name),
> +			"%s%s", "i2c-", i2c_name);
> +		byt_cht_es8316_dais[dai_index].codec_name =
> codec_name;
> +	}
> +
>  	/* register the soc card */
>  	byt_cht_es8316_card.dev = &pdev->dev;
>  	snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv);

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] [PATCH] ASoC: acpi: fix machine driver selection based on quirk
  2018-01-04 13:08   ` Andy Shevchenko
@ 2018-01-04 15:18     ` Pierre-Louis Bossart
  2018-01-05  0:58       ` Pierre-Louis Bossart
  0 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-01-04 15:18 UTC (permalink / raw)
  To: Andy Shevchenko, alsa-devel
  Cc: tiwai, vinod.koul, broonie, jeremy, liam.r.girdwood

On 1/4/18 7:08 AM, Andy Shevchenko wrote:
> On Wed, 2018-01-03 at 11:02 -0600, Pierre-Louis Bossart wrote:
>> The ACPI/machine-driver code refactoring introduced in 4.13 introduced
>> a regression for cases where we need a DMI-based quirk to select the
>> machine driver (the BIOS reports an invalid HID). The fix is just to
>> make sure the results of the quirk are actually used.
>>
> 
>>   	for (mach = machines; mach->id[0]; mach++) {
>>   		if (snd_soc_acpi_check_hid(mach->id) == true) {
>>   			if (mach->machine_quirk(mach) != NULL)
> 
> Just a nit: perhaps use more natural style, i.e. drop " != NULL" part
> off?

ok.

> 
>> +				mach = mach->machine_quirk(mach);
>> +			return mach;
>>   		}
>>   	}
>>   	return NULL;
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling
  2018-01-04 14:57   ` Andy Shevchenko
@ 2018-01-04 15:24     ` Pierre-Louis Bossart
  2018-01-04 16:00       ` Andy Shevchenko
  0 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-01-04 15:24 UTC (permalink / raw)
  To: Andy Shevchenko, alsa-devel
  Cc: tiwai, vinod.koul, broonie, jeremy, liam.r.girdwood

On 1/4/18 8:57 AM, Andy Shevchenko wrote:
> On Wed, 2018-01-03 at 11:02 -0600, Pierre-Louis Bossart wrote:
>> Same problem as with previous machine drivers, the codec dai
>> uses a hard-coded name of "i2c-ESSX8316:00" but ACPI provides
>> "i2c-ESSX8316:01" in some systems.
> 
> Yeah, that's why using device instances is fragile...
> 
>>
>> Fix by overriding the hard-coded value with the codec name derived
>> from the HID information
> 
> The patch makes me think about introducing acpi_dev_get_dev_name() and
> utilize it here since I need something similar to have in one of GPIO
> drivers.

we use this: snd_soc_acpi_find_name_from_hid(mach->id)

When I started all this the recommendation was to do all this on the 
audio side of things, I have no objections to a move of the 
functionality in acpi.

[snip]

>> diff --git a/sound/soc/intel/boards/bytcht_es8316.c
>> b/sound/soc/intel/boards/bytcht_es8316.c
>> index 8088396717e3..ae24f6205f05 100644
>> --- a/sound/soc/intel/boards/bytcht_es8316.c
>> +++ b/sound/soc/intel/boards/bytcht_es8316.c
>> @@ -232,15 +232,39 @@ static struct snd_soc_card byt_cht_es8316_card =
>> {
>>   	.fully_routed = true,
>>   };
>>   
>> +static char codec_name[16]; /* i2c-<HID>:00 with HID being 8 chars */
>> +
> 
> I would rather do use 4 + ACPI_ID_LEN + 3 /* or 1 + 2 */ + 1 and explain
> each part in the comment above.

yes we could do this. this is the same code as in other machine drivers, 
so we should do the replacement across all of them in one shot in a 
separate patch.

> 
>>   static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
>>   {
>> -	int ret = 0;
>>   	struct byt_cht_es8316_private *priv;
>> +	struct snd_soc_acpi_mach *mach;
>> +	const char *i2c_name = NULL;
>> +	int dai_index = 0;
>> +	int i;
>> +	int ret = 0;
>>   
>>   	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_ATOMIC);
>>   	if (!priv)
>>   		return -ENOMEM;
>>   
>> +	mach = (&pdev->dev)->platform_data;
>> +	/* fix index of codec dai */
>> +	for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) {
>> +		if (!strcmp(byt_cht_es8316_dais[i].codec_name,
>> +			    "i2c-ESSX8316:00")) {
>> +			dai_index = i;
>> +			break;
>> +		}
> 
> Perhaps at some point you can do such in more generic (across Intel
> ASoCs) ?

Not sure what you are hinting at here? Did you mean changing the name of 
the array? Or adding a helper function to do this?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling
  2018-01-04 15:24     ` Pierre-Louis Bossart
@ 2018-01-04 16:00       ` Andy Shevchenko
  2018-01-04 17:06         ` Pierre-Louis Bossart
  0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2018-01-04 16:00 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel
  Cc: tiwai, vinod.koul, broonie, jeremy, liam.r.girdwood

On Thu, 2018-01-04 at 09:24 -0600, Pierre-Louis Bossart wrote:
> On 1/4/18 8:57 AM, Andy Shevchenko wrote:
> > On Wed, 2018-01-03 at 11:02 -0600, Pierre-Louis Bossart wrote:
> > > 
> > > Fix by overriding the hard-coded value with the codec name derived
> > > from the HID information
> > 
> > The patch makes me think about introducing acpi_dev_get_dev_name()
> > and
> > utilize it here since I need something similar to have in one of
> > GPIO
> > drivers.
> 
> we use this: snd_soc_acpi_find_name_from_hid(mach->id)
> 
> When I started all this the recommendation was to do all this on the 
> audio side of things, I have no objections to a move of the 
> functionality in acpi.

I almost done a patch. I will Cc you for the series.

> > > +static char codec_name[16]; /* i2c-<HID>:00 with HID being 8
> > > chars */
> > > +
> > 
> > I would rather do use 4 + ACPI_ID_LEN + 3 /* or 1 + 2 */ + 1 and
> > explain
> > each part in the comment above.
> 
> yes we could do this. this is the same code as in other machine
> drivers, 
> so we should do the replacement across all of them in one shot in a 
> separate patch.

Whatever you prefer, it's minor.
  
> > > +	mach = (&pdev->dev)->platform_data;
> > > +	/* fix index of codec dai */
> > > +	for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) {
> > > +		if (!strcmp(byt_cht_es8316_dais[i].codec_name,
> > > +			    "i2c-ESSX8316:00")) {
> > > +			dai_index = i;
> > > +			break;
> > > +		}
> > 
> > Perhaps at some point you can do such in more generic (across Intel
> > ASoCs) ?
> 
> Not sure what you are hinting at here? Did you mean changing the name
> of 
> the array? Or adding a helper function to do this?

Suggestion is to create a helper out of similar for-loops-fix-name in
all current users.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling
  2018-01-04 16:00       ` Andy Shevchenko
@ 2018-01-04 17:06         ` Pierre-Louis Bossart
  2018-01-04 17:13           ` Andy Shevchenko
  0 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-01-04 17:06 UTC (permalink / raw)
  To: Andy Shevchenko, alsa-devel
  Cc: tiwai, vinod.koul, broonie, jeremy, liam.r.girdwood

On 1/4/18 10:00 AM, Andy Shevchenko wrote:
> On Thu, 2018-01-04 at 09:24 -0600, Pierre-Louis Bossart wrote:
>> On 1/4/18 8:57 AM, Andy Shevchenko wrote:
>>> On Wed, 2018-01-03 at 11:02 -0600, Pierre-Louis Bossart wrote:
>>>>
>>>> Fix by overriding the hard-coded value with the codec name derived
>>>> from the HID information
>>>
>>> The patch makes me think about introducing acpi_dev_get_dev_name()
>>> and
>>> utilize it here since I need something similar to have in one of
>>> GPIO
>>> drivers.
>>
>> we use this: snd_soc_acpi_find_name_from_hid(mach->id)
>>
>> When I started all this the recommendation was to do all this on the
>> audio side of things, I have no objections to a move of the
>> functionality in acpi.
> 
> I almost done a patch. I will Cc you for the series.

ok. The only concern I have is that this needs to be a somewhat 
contained change that doesn't depend on all sorts of other ACPI/GPIO 
changes. We will have to maintain a v4.14-based branch for a very very 
long time and the simpler we make it for people who back-port or 
cherry-pick the better.

> 
>>>> +static char codec_name[16]; /* i2c-<HID>:00 with HID being 8
>>>> chars */
>>>> +
>>>
>>> I would rather do use 4 + ACPI_ID_LEN + 3 /* or 1 + 2 */ + 1 and
>>> explain
>>> each part in the comment above.
>>
>> yes we could do this. this is the same code as in other machine
>> drivers,
>> so we should do the replacement across all of them in one shot in a
>> separate patch.
> 
> Whatever you prefer, it's minor.
>    
>>>> +	mach = (&pdev->dev)->platform_data;
>>>> +	/* fix index of codec dai */
>>>> +	for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) {
>>>> +		if (!strcmp(byt_cht_es8316_dais[i].codec_name,
>>>> +			    "i2c-ESSX8316:00")) {
>>>> +			dai_index = i;
>>>> +			break;
>>>> +		}
>>>
>>> Perhaps at some point you can do such in more generic (across Intel
>>> ASoCs) ?
>>
>> Not sure what you are hinting at here? Did you mean changing the name
>> of
>> the array? Or adding a helper function to do this?
> 
> Suggestion is to create a helper out of similar for-loops-fix-name in
> all current users.

ok, I'll work on this. Thanks for the suggestion.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling
  2018-01-04 17:06         ` Pierre-Louis Bossart
@ 2018-01-04 17:13           ` Andy Shevchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2018-01-04 17:13 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel
  Cc: tiwai, vinod.koul, broonie, jeremy, liam.r.girdwood

On Thu, 2018-01-04 at 11:06 -0600, Pierre-Louis Bossart wrote:
> On 1/4/18 10:00 AM, Andy Shevchenko wrote:
> > On Thu, 2018-01-04 at 09:24 -0600, Pierre-Louis Bossart wrote:

> > > we use this: snd_soc_acpi_find_name_from_hid(mach->id)
> > > 
> > > When I started all this the recommendation was to do all this on
> > > the
> > > audio side of things, I have no objections to a move of the
> > > functionality in acpi.
> > 
> > I almost done a patch. I will Cc you for the series.
> 
> ok. The only concern I have is that this needs to be a somewhat 
> contained change that doesn't depend on all sorts of other ACPI/GPIO 
> changes. We will have to maintain a v4.14-based branch for a very
> very 
> long time and the simpler we make it for people who back-port or 
> cherry-pick the better.

Yes, that is how series has been prepared. You basically need two first
patches out of three from it. It had been sent already.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] [PATCH] ASoC: acpi: fix machine driver selection based on quirk
  2018-01-04 15:18     ` Pierre-Louis Bossart
@ 2018-01-05  0:58       ` Pierre-Louis Bossart
  0 siblings, 0 replies; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-01-05  0:58 UTC (permalink / raw)
  To: Andy Shevchenko, alsa-devel
  Cc: tiwai, vinod.koul, broonie, jeremy, liam.r.girdwood



On 01/04/2018 09:18 AM, Pierre-Louis Bossart wrote:
> On 1/4/18 7:08 AM, Andy Shevchenko wrote:
>> On Wed, 2018-01-03 at 11:02 -0600, Pierre-Louis Bossart wrote:
>>> The ACPI/machine-driver code refactoring introduced in 4.13 introduced
>>> a regression for cases where we need a DMI-based quirk to select the
>>> machine driver (the BIOS reports an invalid HID). The fix is just to
>>> make sure the results of the quirk are actually used.
>>>
>>
>>>       for (mach = machines; mach->id[0]; mach++) {
>>>           if (snd_soc_acpi_check_hid(mach->id) == true) {
>>>               if (mach->machine_quirk(mach) != NULL)
>>
>> Just a nit: perhaps use more natural style, i.e. drop " != NULL" part
>> off?
>
> ok.
I found out while testing Andy's patches that there was a 
merge/copy-paste mistake here which wasn't detected in my tests - not 
sure how. it should be (as in the initial patch on bugzilla)

if (mach->machine_quirk)
                 mach = mach->machine_quirk(mach);

Will fix in the next version

>
>>
>>> +                mach = mach->machine_quirk(mach);
>>> +            return mach;
>>>           }
>>>       }
>>>       return NULL;
>>
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Applied "ASoC: Intel: bytcht_es8316: fix HID handling" to the asoc tree
  2018-01-03 17:02 ` [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling Pierre-Louis Bossart
  2018-01-04 14:57   ` Andy Shevchenko
@ 2018-01-12 21:09   ` Mark Brown
  1 sibling, 0 replies; 14+ messages in thread
From: Mark Brown @ 2018-01-12 21:09 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: jeremy, alsa-devel, tiwai, liam.r.girdwood, vinod.koul, broonie,
	andriy.shevchenko

The patch

   ASoC: Intel: bytcht_es8316: fix HID handling

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 3c22a73fb87366851dcf48d852357a6d808921cc Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date: Thu, 11 Jan 2018 13:52:08 -0600
Subject: [PATCH] ASoC: Intel: bytcht_es8316: fix HID handling

Same problem as with previous machine drivers, the codec dai
uses a hard-coded name of "i2c-ESSX8316:00" but ACPI provides
"i2c-ESSX8316:01" in some systems.

Fix by overriding the hard-coded value with the codec name derived
from the HID information

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189261
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/boards/Kconfig         |  1 +
 sound/soc/intel/boards/bytcht_es8316.c | 26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
index de598dcbef30..d4e103615f51 100644
--- a/sound/soc/intel/boards/Kconfig
+++ b/sound/soc/intel/boards/Kconfig
@@ -139,6 +139,7 @@ config SND_SOC_INTEL_BYT_CHT_DA7213_MACH
 config SND_SOC_INTEL_BYT_CHT_ES8316_MACH
 	tristate "Baytrail & Cherrytrail with ES8316 codec"
 	depends on X86_INTEL_LPSS && I2C && ACPI
+	select SND_SOC_ACPI
 	select SND_SOC_ES8316
 	help
 	  This adds support for ASoC machine driver for Intel(R) Baytrail &
diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index 8088396717e3..ae24f6205f05 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -232,15 +232,39 @@ static struct snd_soc_card byt_cht_es8316_card = {
 	.fully_routed = true,
 };
 
+static char codec_name[16]; /* i2c-<HID>:00 with HID being 8 chars */
+
 static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 {
-	int ret = 0;
 	struct byt_cht_es8316_private *priv;
+	struct snd_soc_acpi_mach *mach;
+	const char *i2c_name = NULL;
+	int dai_index = 0;
+	int i;
+	int ret = 0;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_ATOMIC);
 	if (!priv)
 		return -ENOMEM;
 
+	mach = (&pdev->dev)->platform_data;
+	/* fix index of codec dai */
+	for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) {
+		if (!strcmp(byt_cht_es8316_dais[i].codec_name,
+			    "i2c-ESSX8316:00")) {
+			dai_index = i;
+			break;
+		}
+	}
+
+	/* fixup codec name based on HID */
+	i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
+	if (i2c_name) {
+		snprintf(codec_name, sizeof(codec_name),
+			"%s%s", "i2c-", i2c_name);
+		byt_cht_es8316_dais[dai_index].codec_name = codec_name;
+	}
+
 	/* register the soc card */
 	byt_cht_es8316_card.dev = &pdev->dev;
 	snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv);
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-01-12 21:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-03 17:02 [PATCH 0/3] ASoC: Intel: ACPI-related fixes Pierre-Louis Bossart
2018-01-03 17:02 ` [PATCH 1/3] [PATCH] ASoC: acpi: fix machine driver selection based on quirk Pierre-Louis Bossart
2018-01-04 13:08   ` Andy Shevchenko
2018-01-04 15:18     ` Pierre-Louis Bossart
2018-01-05  0:58       ` Pierre-Louis Bossart
2018-01-03 17:02 ` [PATCH 2/3] ASoC: Replace snd_soc_acpi_check_hid with acpi_dev_present Pierre-Louis Bossart
2018-01-04 13:09   ` Andy Shevchenko
2018-01-03 17:02 ` [PATCH 3/3] ASoC: Intel: bytcht_es8316: fix HID handling Pierre-Louis Bossart
2018-01-04 14:57   ` Andy Shevchenko
2018-01-04 15:24     ` Pierre-Louis Bossart
2018-01-04 16:00       ` Andy Shevchenko
2018-01-04 17:06         ` Pierre-Louis Bossart
2018-01-04 17:13           ` Andy Shevchenko
2018-01-12 21:09   ` Applied "ASoC: Intel: bytcht_es8316: fix HID handling" to the asoc tree Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.