All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define
@ 2021-10-02 21:14 Hans de Goede
  2021-10-02 21:14 ` [PATCH 2/4] ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detect Hans de Goede
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Hans de Goede @ 2021-10-02 21:14 UTC (permalink / raw)
  To: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Jie Yang,
	Mark Brown
  Cc: Hans de Goede, alsa-devel

The NAU8824_JACK_LOGIC define was wrong, for active high jack-detect
to work bit 1 needs to be set, rather then bit 0.

The correct bit was found in the Android kernel source dump for
a Cyberbook T116 tablet; and this was also tested on that same tablet.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 sound/soc/codecs/nau8824.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8824.h b/sound/soc/codecs/nau8824.h
index 1d7bdd8e0523..6e61405f623b 100644
--- a/sound/soc/codecs/nau8824.h
+++ b/sound/soc/codecs/nau8824.h
@@ -197,7 +197,7 @@
 /* JACK_DET_CTRL (0x0D) */
 #define NAU8824_JACK_EJECT_DT_SFT	2
 #define NAU8824_JACK_EJECT_DT_MASK (0x3 << NAU8824_JACK_EJECT_DT_SFT)
-#define NAU8824_JACK_LOGIC		0x1
+#define NAU8824_JACK_LOGIC		(0x1 << 1)
 
 
 /* INTERRUPT_SETTING_1 (0x0F) */
-- 
2.31.1


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

* [PATCH 2/4] ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detect
  2021-10-02 21:14 [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define Hans de Goede
@ 2021-10-02 21:14 ` Hans de Goede
  2021-10-02 21:14 ` [PATCH 3/4] ASoC: nau8824: Add a nau8824_components() helper Hans de Goede
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2021-10-02 21:14 UTC (permalink / raw)
  To: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Jie Yang,
	Mark Brown
  Cc: Hans de Goede, alsa-devel

Add a quirk mechanism to allow specifying that active-high jack-detection
should be used on platforms where this info is not available in devicetree.

And add an entry for the Cyberbook T116 tablet to the DMI table, so that
jack-detection will work properly on this tablet.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 sound/soc/codecs/nau8824.c | 40 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c
index f946ef65a4c1..f7018f2dd21f 100644
--- a/sound/soc/codecs/nau8824.c
+++ b/sound/soc/codecs/nau8824.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/delay.h>
+#include <linux/dmi.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
 #include <linux/regmap.h>
@@ -27,6 +28,12 @@
 
 #include "nau8824.h"
 
+#define NAU8824_JD_ACTIVE_HIGH			BIT(0)
+
+static int nau8824_quirk;
+static int quirk_override = -1;
+module_param_named(quirk, quirk_override, uint, 0444);
+MODULE_PARM_DESC(quirk, "Board-specific quirk override");
 
 static int nau8824_config_sysclk(struct nau8824 *nau8824,
 	int clk_id, unsigned int freq);
@@ -1845,6 +1852,34 @@ static int nau8824_read_device_properties(struct device *dev,
 	return 0;
 }
 
+/* Please keep this list alphabetically sorted */
+static const struct dmi_system_id nau8824_quirk_table[] = {
+	{
+		/* Cyberbook T116 rugged tablet */
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Default string"),
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
+			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "20170531"),
+		},
+		.driver_data = (void *)(NAU8824_JD_ACTIVE_HIGH),
+	},
+	{}
+};
+
+static void nau8824_check_quirks(void)
+{
+	const struct dmi_system_id *dmi_id;
+
+	if (quirk_override != -1) {
+		nau8824_quirk = quirk_override;
+		return;
+	}
+
+	dmi_id = dmi_first_match(nau8824_quirk_table);
+	if (dmi_id)
+		nau8824_quirk = (unsigned long)dmi_id->driver_data;
+}
+
 static int nau8824_i2c_probe(struct i2c_client *i2c,
 	const struct i2c_device_id *id)
 {
@@ -1869,6 +1904,11 @@ static int nau8824_i2c_probe(struct i2c_client *i2c,
 	nau8824->irq = i2c->irq;
 	sema_init(&nau8824->jd_sem, 1);
 
+	nau8824_check_quirks();
+
+	if (nau8824_quirk & NAU8824_JD_ACTIVE_HIGH)
+		nau8824->jkdet_polarity = 0;
+
 	nau8824_print_device_properties(nau8824);
 
 	ret = regmap_read(nau8824->regmap, NAU8824_REG_I2C_DEVICE_ID, &value);
-- 
2.31.1


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

* [PATCH 3/4] ASoC: nau8824: Add a nau8824_components() helper
  2021-10-02 21:14 [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define Hans de Goede
  2021-10-02 21:14 ` [PATCH 2/4] ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detect Hans de Goede
@ 2021-10-02 21:14 ` Hans de Goede
  2021-10-02 21:14 ` [PATCH 4/4] ASoC: Intel: cht_bsw_nau8824: Set card.components string Hans de Goede
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2021-10-02 21:14 UTC (permalink / raw)
  To: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Jie Yang,
	Mark Brown
  Cc: Hans de Goede, alsa-devel

Some devices using the NAU8824 have only one speaker. To still have things
working properly this requires the left + right channels to both be mixed
to the left speaker output.

This mixer setup is done by userspace based on UCM profiles. But this
requires userspace to know that there is a mono-speaker. Add a helper
function (for the machine driver) to get a components string providing
this info.

This is done inside the codec driver because the codec driver already
has a DMI quirk table.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 sound/soc/codecs/nau8824.c | 32 +++++++++++++++++++++++++++++++-
 sound/soc/codecs/nau8824.h |  1 +
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c
index f7018f2dd21f..d0dd1542f78a 100644
--- a/sound/soc/codecs/nau8824.c
+++ b/sound/soc/codecs/nau8824.c
@@ -29,6 +29,7 @@
 #include "nau8824.h"
 
 #define NAU8824_JD_ACTIVE_HIGH			BIT(0)
+#define NAU8824_MONO_SPEAKER			BIT(1)
 
 static int nau8824_quirk;
 static int quirk_override = -1;
@@ -1861,7 +1862,25 @@ static const struct dmi_system_id nau8824_quirk_table[] = {
 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "20170531"),
 		},
-		.driver_data = (void *)(NAU8824_JD_ACTIVE_HIGH),
+		.driver_data = (void *)(NAU8824_JD_ACTIVE_HIGH |
+					NAU8824_MONO_SPEAKER),
+	},
+	{
+		/* CUBE iwork8 Air */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "cube"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"),
+			DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
+		},
+		.driver_data = (void *)(NAU8824_MONO_SPEAKER),
+	},
+	{
+		/* Pipo W2S */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "PIPO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "W2S"),
+		},
+		.driver_data = (void *)(NAU8824_MONO_SPEAKER),
 	},
 	{}
 };
@@ -1880,6 +1899,17 @@ static void nau8824_check_quirks(void)
 		nau8824_quirk = (unsigned long)dmi_id->driver_data;
 }
 
+const char *nau8824_components(void)
+{
+	nau8824_check_quirks();
+
+	if (nau8824_quirk & NAU8824_MONO_SPEAKER)
+		return "cfg-spk:1";
+	else
+		return "cfg-spk:2";
+}
+EXPORT_SYMBOL_GPL(nau8824_components);
+
 static int nau8824_i2c_probe(struct i2c_client *i2c,
 	const struct i2c_device_id *id)
 {
diff --git a/sound/soc/codecs/nau8824.h b/sound/soc/codecs/nau8824.h
index 6e61405f623b..de4bae8281d0 100644
--- a/sound/soc/codecs/nau8824.h
+++ b/sound/soc/codecs/nau8824.h
@@ -470,6 +470,7 @@ struct nau8824_osr_attr {
 
 int nau8824_enable_jack_detect(struct snd_soc_component *component,
 	struct snd_soc_jack *jack);
+const char *nau8824_components(void);
 
 #endif				/* _NAU8824_H */
 
-- 
2.31.1


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

* [PATCH 4/4] ASoC: Intel: cht_bsw_nau8824: Set card.components string
  2021-10-02 21:14 [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define Hans de Goede
  2021-10-02 21:14 ` [PATCH 2/4] ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detect Hans de Goede
  2021-10-02 21:14 ` [PATCH 3/4] ASoC: nau8824: Add a nau8824_components() helper Hans de Goede
@ 2021-10-02 21:14 ` Hans de Goede
  2021-10-04 14:22 ` [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define Pierre-Louis Bossart
  2021-10-04 17:02 ` Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2021-10-02 21:14 UTC (permalink / raw)
  To: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Jie Yang,
	Mark Brown
  Cc: Hans de Goede, alsa-devel

Set the card.components string using the new nau8824_components() helper
which returns a components string based on the DMI quirks inside the
nau8824 codec driver.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 sound/soc/intel/boards/cht_bsw_nau8824.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/intel/boards/cht_bsw_nau8824.c b/sound/soc/intel/boards/cht_bsw_nau8824.c
index da5a5cbc8759..7e6b68186db1 100644
--- a/sound/soc/intel/boards/cht_bsw_nau8824.c
+++ b/sound/soc/intel/boards/cht_bsw_nau8824.c
@@ -278,6 +278,8 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 		snd_soc_card_cht.driver_name = DRIVER_NAME;
 	}
 
+	snd_soc_card_cht.components = nau8824_components();
+
 	/* set pm ops */
 	if (sof_parent)
 		pdev->dev.driver->pm = &snd_soc_pm_ops;
-- 
2.31.1


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

* Re: [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define
  2021-10-02 21:14 [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define Hans de Goede
                   ` (2 preceding siblings ...)
  2021-10-02 21:14 ` [PATCH 4/4] ASoC: Intel: cht_bsw_nau8824: Set card.components string Hans de Goede
@ 2021-10-04 14:22 ` Pierre-Louis Bossart
  2021-10-04 17:02 ` Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Pierre-Louis Bossart @ 2021-10-04 14:22 UTC (permalink / raw)
  To: Hans de Goede, Cezary Rojewski, Liam Girdwood, Jie Yang, Mark Brown
  Cc: alsa-devel



On 10/2/21 4:14 PM, Hans de Goede wrote:
> The NAU8824_JACK_LOGIC define was wrong, for active high jack-detect
> to work bit 1 needs to be set, rather then bit 0.
> 
> The correct bit was found in the Android kernel source dump for
> a Cyberbook T116 tablet; and this was also tested on that same tablet.

For the series

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  sound/soc/codecs/nau8824.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/nau8824.h b/sound/soc/codecs/nau8824.h
> index 1d7bdd8e0523..6e61405f623b 100644
> --- a/sound/soc/codecs/nau8824.h
> +++ b/sound/soc/codecs/nau8824.h
> @@ -197,7 +197,7 @@
>  /* JACK_DET_CTRL (0x0D) */
>  #define NAU8824_JACK_EJECT_DT_SFT	2
>  #define NAU8824_JACK_EJECT_DT_MASK (0x3 << NAU8824_JACK_EJECT_DT_SFT)
> -#define NAU8824_JACK_LOGIC		0x1
> +#define NAU8824_JACK_LOGIC		(0x1 << 1)
>  
>  
>  /* INTERRUPT_SETTING_1 (0x0F) */
> 

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

* Re: [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define
  2021-10-02 21:14 [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define Hans de Goede
                   ` (3 preceding siblings ...)
  2021-10-04 14:22 ` [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define Pierre-Louis Bossart
@ 2021-10-04 17:02 ` Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2021-10-04 17:02 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Liam Girdwood, Jie Yang, Cezary Rojewski,
	Hans de Goede
  Cc: alsa-devel, Mark Brown

On Sat, 2 Oct 2021 23:14:56 +0200, Hans de Goede wrote:
> The NAU8824_JACK_LOGIC define was wrong, for active high jack-detect
> to work bit 1 needs to be set, rather then bit 0.
> 
> The correct bit was found in the Android kernel source dump for
> a Cyberbook T116 tablet; and this was also tested on that same tablet.
> 
> 
> [...]

Applied to

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

Thanks!

[1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define
      commit: d316597c538abd110ff32761fc79f7adff8d619a
[2/4] ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detect
      commit: 92d3360108f1839ca40451bad20ff67dd24a1964
[3/4] ASoC: nau8824: Add a nau8824_components() helper
      commit: efee0fca19cbc9a0946a2d7dab2d5546aee2098f
[4/4] ASoC: Intel: cht_bsw_nau8824: Set card.components string
      commit: 7924f1bc94041a3d512f2922065b196ca8e1210e

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

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

end of thread, other threads:[~2021-10-04 17:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-02 21:14 [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define Hans de Goede
2021-10-02 21:14 ` [PATCH 2/4] ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detect Hans de Goede
2021-10-02 21:14 ` [PATCH 3/4] ASoC: nau8824: Add a nau8824_components() helper Hans de Goede
2021-10-02 21:14 ` [PATCH 4/4] ASoC: Intel: cht_bsw_nau8824: Set card.components string Hans de Goede
2021-10-04 14:22 ` [PATCH 1/4] ASoC: nau8824: Fix NAU8824_JACK_LOGIC define Pierre-Louis Bossart
2021-10-04 17:02 ` 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.