alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: rt5645: Move rt5645_platform_data to sound/soc/codecs/rt5645.c
@ 2021-03-06 23:02 Hans de Goede
  2021-03-06 23:02 ` [PATCH 2/2] ASoC: rt5645: The ALC3270 variant does not have a headset-mic pin Hans de Goede
  2021-03-08 16:06 ` [PATCH 1/2] ASoC: rt5645: Move rt5645_platform_data to sound/soc/codecs/rt5645.c Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Hans de Goede @ 2021-03-06 23:02 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Liam Girdwood, Mark Brown
  Cc: Oder Chiou, Hans de Goede, alsa-devel, Bard Liao

sound/soc/codecs/rt5645.c is the only user of the rt5645_platform_data,
move its definition to sound/soc/codecs/rt5645.c and remove the now
empty include/sound/rt5645.h file.

Note since the DMI quirk mechanism uses pointers to the
rt5645_platform_data struct we can NOT simply add its members to
the rt5645_priv struct and completely remove the struct.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 include/sound/rt5645.h    | 32 --------------------------------
 sound/soc/codecs/rt5645.c | 23 ++++++++++++++++++++++-
 sound/soc/codecs/rt5645.h |  2 --
 3 files changed, 22 insertions(+), 35 deletions(-)
 delete mode 100644 include/sound/rt5645.h

diff --git a/include/sound/rt5645.h b/include/sound/rt5645.h
deleted file mode 100644
index 710c95be5509..000000000000
--- a/include/sound/rt5645.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * linux/sound/rt5645.h -- Platform data for RT5645
- *
- * Copyright 2013 Realtek Microelectronics
- */
-
-#ifndef __LINUX_SND_RT5645_H
-#define __LINUX_SND_RT5645_H
-
-struct rt5645_platform_data {
-	/* IN2 can optionally be differential */
-	bool in2_diff;
-
-	unsigned int dmic1_data_pin;
-	/* 0 = IN2N; 1 = GPIO5; 2 = GPIO11 */
-	unsigned int dmic2_data_pin;
-	/* 0 = IN2P; 1 = GPIO6; 2 = GPIO10; 3 = GPIO12 */
-
-	unsigned int jd_mode;
-	/* Use level triggered irq */
-	bool level_trigger_irq;
-	/* Invert JD1_1 status polarity */
-	bool inv_jd1_1;
-	/* Invert HP detect status polarity */
-	bool inv_hp_pol;
-
-	/* Value to asign to snd_soc_card.long_name */
-	const char *long_name;
-};
-
-#endif
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 63a7e052eaa0..06ea6fce427c 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -411,6 +411,27 @@ static const char *const rt5645_supply_names[] = {
 	"cpvdd",
 };
 
+struct rt5645_platform_data {
+	/* IN2 can optionally be differential */
+	bool in2_diff;
+
+	unsigned int dmic1_data_pin;
+	/* 0 = IN2N; 1 = GPIO5; 2 = GPIO11 */
+	unsigned int dmic2_data_pin;
+	/* 0 = IN2P; 1 = GPIO6; 2 = GPIO10; 3 = GPIO12 */
+
+	unsigned int jd_mode;
+	/* Use level triggered irq */
+	bool level_trigger_irq;
+	/* Invert JD1_1 status polarity */
+	bool inv_jd1_1;
+	/* Invert HP detect status polarity */
+	bool inv_hp_pol;
+
+	/* Value to assign to snd_soc_card.long_name */
+	const char *long_name;
+};
+
 struct rt5645_priv {
 	struct snd_soc_component *component;
 	struct rt5645_platform_data pdata;
@@ -3834,7 +3855,7 @@ static int rt5645_parse_dt(struct rt5645_priv *rt5645, struct device *dev)
 static int rt5645_i2c_probe(struct i2c_client *i2c,
 		    const struct i2c_device_id *id)
 {
-	struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev);
+	struct rt5645_platform_data *pdata = NULL;
 	const struct dmi_system_id *dmi_data;
 	struct rt5645_priv *rt5645;
 	int ret, i;
diff --git a/sound/soc/codecs/rt5645.h b/sound/soc/codecs/rt5645.h
index e2d72ae17484..ac3de6f3bc2f 100644
--- a/sound/soc/codecs/rt5645.h
+++ b/sound/soc/codecs/rt5645.h
@@ -9,8 +9,6 @@
 #ifndef __RT5645_H__
 #define __RT5645_H__
 
-#include <sound/rt5645.h>
-
 /* Info */
 #define RT5645_RESET				0x00
 #define RT5645_VENDOR_ID			0xfd
-- 
2.30.1


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

* [PATCH 2/2] ASoC: rt5645: The ALC3270 variant does not have a headset-mic pin
  2021-03-06 23:02 [PATCH 1/2] ASoC: rt5645: Move rt5645_platform_data to sound/soc/codecs/rt5645.c Hans de Goede
@ 2021-03-06 23:02 ` Hans de Goede
  2021-03-08 16:06 ` [PATCH 1/2] ASoC: rt5645: Move rt5645_platform_data to sound/soc/codecs/rt5645.c Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2021-03-06 23:02 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Liam Girdwood, Mark Brown
  Cc: Oder Chiou, Hans de Goede, alsa-devel, Bard Liao

The Asus T100HA and T101HA 2-in-1s use a rt5645 family codec and always
report that a headset (rather then headphones) are plugged in even when
regular headphones are plugged in.

And when a headset is used, then the headset-microphone does not work.
According to RealTek the ALC3270 variant used in these devices does not
support headsets only headphones.

Since the ALC3270 is a budget version of the regular ALC5645 codec,
I assume that it is using a package with less pins and the headset-mic
pin is simply not connected.

Detect if the codec is an ALC3270 based on the ACPI HID and if it is
an ALC3270 then always report SND_JACK_MICROPHONE as false, so that
userspace will not try to use the not-connected headset-mic.

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

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 06ea6fce427c..a468d76a680d 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -430,6 +430,9 @@ struct rt5645_platform_data {
 
 	/* Value to assign to snd_soc_card.long_name */
 	const char *long_name;
+
+	/* Some (package) variants have the headset-mic pin not-connected */
+	bool no_headset_mic;
 };
 
 struct rt5645_priv {
@@ -3180,7 +3183,7 @@ static int rt5645_jack_detect(struct snd_soc_component *component, int jack_inse
 		val &= 0x7;
 		dev_dbg(component->dev, "val = %d\n", val);
 
-		if (val == 1 || val == 2) {
+		if ((val == 1 || val == 2) && !rt5645->pdata.no_headset_mic) {
 			rt5645->jack_type = SND_JACK_HEADSET;
 			if (rt5645->en_button_func) {
 				rt5645_enable_push_button_irq(component, true);
@@ -3893,9 +3896,16 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
 		rt5645->pdata.dmic2_data_pin = QUIRK_DMIC2_DATA_PIN(quirk);
 	}
 
-	if (cht_rt5645_gpios && has_acpi_companion(&i2c->dev))
-		if (devm_acpi_dev_add_driver_gpios(&i2c->dev, cht_rt5645_gpios))
-			dev_dbg(&i2c->dev, "Failed to add driver gpios\n");
+	if (has_acpi_companion(&i2c->dev)) {
+		if (cht_rt5645_gpios) {
+			if (devm_acpi_dev_add_driver_gpios(&i2c->dev, cht_rt5645_gpios))
+				dev_dbg(&i2c->dev, "Failed to add driver gpios\n");
+		}
+
+		/* The ALC3270 package has the headset-mic pin not-connected */
+		if (acpi_dev_hid_uid_match(ACPI_COMPANION(&i2c->dev), "10EC3270", NULL))
+			rt5645->pdata.no_headset_mic = true;
+	}
 
 	rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect",
 						       GPIOD_IN);
-- 
2.30.1


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

* Re: [PATCH 1/2] ASoC: rt5645: Move rt5645_platform_data to sound/soc/codecs/rt5645.c
  2021-03-06 23:02 [PATCH 1/2] ASoC: rt5645: Move rt5645_platform_data to sound/soc/codecs/rt5645.c Hans de Goede
  2021-03-06 23:02 ` [PATCH 2/2] ASoC: rt5645: The ALC3270 variant does not have a headset-mic pin Hans de Goede
@ 2021-03-08 16:06 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2021-03-08 16:06 UTC (permalink / raw)
  To: Hans de Goede, Liam Girdwood, Pierre-Louis Bossart
  Cc: Oder Chiou, alsa-devel, Bard Liao

On Sun, 7 Mar 2021 00:02:22 +0100, Hans de Goede wrote:
> sound/soc/codecs/rt5645.c is the only user of the rt5645_platform_data,
> move its definition to sound/soc/codecs/rt5645.c and remove the now
> empty include/sound/rt5645.h file.
> 
> Note since the DMI quirk mechanism uses pointers to the
> rt5645_platform_data struct we can NOT simply add its members to
> the rt5645_priv struct and completely remove the struct.

Applied to

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

Thanks!

[1/2] ASoC: rt5645: Move rt5645_platform_data to sound/soc/codecs/rt5645.c
      commit: b0c95242ebc233f8907366ae815ce1d8e7516907
[2/2] ASoC: rt5645: The ALC3270 variant does not have a headset-mic pin
      commit: 2eac35f48c075dcd939bc418fe786f4f221aee8e

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] 3+ messages in thread

end of thread, other threads:[~2021-03-08 16:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-06 23:02 [PATCH 1/2] ASoC: rt5645: Move rt5645_platform_data to sound/soc/codecs/rt5645.c Hans de Goede
2021-03-06 23:02 ` [PATCH 2/2] ASoC: rt5645: The ALC3270 variant does not have a headset-mic pin Hans de Goede
2021-03-08 16:06 ` [PATCH 1/2] ASoC: rt5645: Move rt5645_platform_data to sound/soc/codecs/rt5645.c Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).