alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoc: rt286: Fix combojack detection for ALC3263 (Dell XPS 13 9343)
@ 2021-03-08 22:18 David Ward
  2021-03-08 22:18 ` [PATCH 1/3] ASoC: rt286: Make RT286_SET_GPIO_* readable and writable David Ward
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Ward @ 2021-03-08 22:18 UTC (permalink / raw)
  To: Oder Chiou, alsa-devel; +Cc: Rafael J. Wysocki, Bard Liao, David Ward

This fixes a longstanding issue that prevented jack detection from working
on systems with the ALC3263 codec, such as the Dell XPS 13 9343, when using
I2S mode for audio (instead of HDA mode).

There is currently an ACPI quirk for the Dell XPS 13 9343 that forces it to
use HDA mode instead of I2S mode, because jack detection did not work. See:

https://lore.kernel.org/alsa-devel/CAPeXnHv07HkvcHrYFmZMr8OTp7U7F=k_k=LPYnUtp89iPn2d2Q@mail.gmail.com/

There are very likely codec fixups for the HDA driver which should be added
to the I2S codec driver, to attempt to achieve parity. Commit 394c97f824fa
("ALSA: hda/realtek - Change EAPD to verb control") describes an issue that
still seems to be present in the I2S codec driver, for example. In any case
this change should move closer to allowing the Dell XPS 13 9343 to default
to I2S mode; and it resolves this issue for systems which use I2S mode now,
including the Dell Latitude 7350 and the Dell Venue 11 Pro 7140.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=114171
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=150601
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205961
Signed-off-by: David Ward <david.ward@gatech.edu>

David Ward (3):
  ASoC: rt286: Make RT286_SET_GPIO_* readable and writable
  ASoC: rt286: Handle all devices with ALC3263 codec
  ASoc: rt286: Handle headphones in combo jack correctly

 sound/soc/codecs/rt286.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

-- 
2.30.1


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

* [PATCH 1/3] ASoC: rt286: Make RT286_SET_GPIO_* readable and writable
  2021-03-08 22:18 [PATCH 0/3] ASoc: rt286: Fix combojack detection for ALC3263 (Dell XPS 13 9343) David Ward
@ 2021-03-08 22:18 ` David Ward
  2021-03-08 22:18 ` [PATCH 2/3] ASoC: rt286: Handle all devices with ALC3263 codec David Ward
  2021-03-08 22:18 ` [PATCH 3/3] ASoc: rt286: Handle headphones in combo jack correctly David Ward
  2 siblings, 0 replies; 4+ messages in thread
From: David Ward @ 2021-03-08 22:18 UTC (permalink / raw)
  To: Oder Chiou, alsa-devel; +Cc: Rafael J. Wysocki, Bard Liao, David Ward

Otherwise, the GPIO configuration for the Dell XPS 13 9343 is not actually
applied, so the headset microphone does not work.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=114171
Signed-off-by: David Ward <david.ward@gatech.edu>
---
 sound/soc/codecs/rt286.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index f9b29782b62a..e16e7237156f 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -171,6 +171,9 @@ static bool rt286_readable_register(struct device *dev, unsigned int reg)
 	case RT286_PROC_COEF:
 	case RT286_SET_AMP_GAIN_ADC_IN1:
 	case RT286_SET_AMP_GAIN_ADC_IN2:
+	case RT286_SET_GPIO_MASK:
+	case RT286_SET_GPIO_DIRECTION:
+	case RT286_SET_GPIO_DATA:
 	case RT286_SET_POWER(RT286_DAC_OUT1):
 	case RT286_SET_POWER(RT286_DAC_OUT2):
 	case RT286_SET_POWER(RT286_ADC_IN1):
-- 
2.30.1


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

* [PATCH 2/3] ASoC: rt286: Handle all devices with ALC3263 codec
  2021-03-08 22:18 [PATCH 0/3] ASoc: rt286: Fix combojack detection for ALC3263 (Dell XPS 13 9343) David Ward
  2021-03-08 22:18 ` [PATCH 1/3] ASoC: rt286: Make RT286_SET_GPIO_* readable and writable David Ward
@ 2021-03-08 22:18 ` David Ward
  2021-03-08 22:18 ` [PATCH 3/3] ASoc: rt286: Handle headphones in combo jack correctly David Ward
  2 siblings, 0 replies; 4+ messages in thread
From: David Ward @ 2021-03-08 22:18 UTC (permalink / raw)
  To: Oder Chiou, alsa-devel; +Cc: Rafael J. Wysocki, Bard Liao, David Ward

The ALC3263 codec on the Dell XPS 13 9343 is also on the Dell Latitude 7350
and the Dell Venue 11 Pro 7140. These require the same handling: GPIO pin 6
needs to be set for a headset or microphone to work in the combo jack.

This is implemented for the HDA driver, which always sets GPIO pin 6 on the
ALC3263. It is detected using the codec vendor/device ID 0x10ec0288 and the
PCI subsystem vendor ID 0x1028 (Dell). Because the I2S codec driver doesn't
use PCI, adapt this by using DMI to check if Dell is the system vendor.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=150601
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205961
Signed-off-by: David Ward <david.ward@gatech.edu>
---
 sound/soc/codecs/rt286.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index e16e7237156f..c0129edf5993 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -1120,12 +1120,11 @@ static const struct dmi_system_id force_combo_jack_table[] = {
 	{ }
 };
 
-static const struct dmi_system_id dmi_dell_dino[] = {
+static const struct dmi_system_id dmi_dell[] = {
 	{
-		.ident = "Dell Dino",
+		.ident = "Dell",
 		.matches = {
 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
-			DMI_MATCH(DMI_PRODUCT_NAME, "XPS 13 9343")
 		}
 	},
 	{ }
@@ -1136,7 +1135,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
 {
 	struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev);
 	struct rt286_priv *rt286;
-	int i, ret, val;
+	int i, ret, vendor_id;
 
 	rt286 = devm_kzalloc(&i2c->dev,	sizeof(*rt286),
 				GFP_KERNEL);
@@ -1152,14 +1151,15 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
 	}
 
 	ret = regmap_read(rt286->regmap,
-		RT286_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val);
+		RT286_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &vendor_id);
 	if (ret != 0) {
 		dev_err(&i2c->dev, "I2C error %d\n", ret);
 		return ret;
 	}
-	if (val != RT286_VENDOR_ID && val != RT288_VENDOR_ID) {
+	if (vendor_id != RT286_VENDOR_ID && vendor_id != RT288_VENDOR_ID) {
 		dev_err(&i2c->dev,
-			"Device with ID register %#x is not rt286\n", val);
+			"Device with ID register %#x is not rt286\n",
+			vendor_id);
 		return -ENODEV;
 	}
 
@@ -1183,8 +1183,8 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
 	if (pdata)
 		rt286->pdata = *pdata;
 
-	if (dmi_check_system(force_combo_jack_table) ||
-		dmi_check_system(dmi_dell_dino))
+	if ((vendor_id == RT288_VENDOR_ID && dmi_check_system(dmi_dell)) ||
+		dmi_check_system(force_combo_jack_table))
 		rt286->pdata.cbj_en = true;
 
 	regmap_write(rt286->regmap, RT286_SET_AUDIO_POWER, AC_PWRST_D3);
@@ -1223,7 +1223,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
 	regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL3, 0xf777, 0x4737);
 	regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL4, 0x00ff, 0x003f);
 
-	if (dmi_check_system(dmi_dell_dino)) {
+	if (vendor_id == RT288_VENDOR_ID && dmi_check_system(dmi_dell)) {
 		regmap_update_bits(rt286->regmap,
 			RT286_SET_GPIO_MASK, 0x40, 0x40);
 		regmap_update_bits(rt286->regmap,
-- 
2.30.1


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

* [PATCH 3/3] ASoc: rt286: Handle headphones in combo jack correctly
  2021-03-08 22:18 [PATCH 0/3] ASoc: rt286: Fix combojack detection for ALC3263 (Dell XPS 13 9343) David Ward
  2021-03-08 22:18 ` [PATCH 1/3] ASoC: rt286: Make RT286_SET_GPIO_* readable and writable David Ward
  2021-03-08 22:18 ` [PATCH 2/3] ASoC: rt286: Handle all devices with ALC3263 codec David Ward
@ 2021-03-08 22:18 ` David Ward
  2 siblings, 0 replies; 4+ messages in thread
From: David Ward @ 2021-03-08 22:18 UTC (permalink / raw)
  To: Oder Chiou, alsa-devel; +Cc: Rafael J. Wysocki, Bard Liao, David Ward

If headphones are detected in the combo jack instead of a headset, set the
index register RT286_CBJ_CTRL1 to the correct value (from the HDA driver).

Signed-off-by: David Ward <david.ward@gatech.edu>
---
 sound/soc/codecs/rt286.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index c0129edf5993..7e67165a43e6 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -260,6 +260,12 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic)
 				else
 					*mic = false;
 			}
+
+			if (!*mic) {
+				regmap_update_bits(rt286->regmap,
+					RT286_CBJ_CTRL1, 0xfcc0, 0xc400);
+			}
+
 			regmap_update_bits(rt286->regmap,
 				RT286_DC_GAIN, 0x200, 0x0);
 
-- 
2.30.1


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

end of thread, other threads:[~2021-03-09  7:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08 22:18 [PATCH 0/3] ASoc: rt286: Fix combojack detection for ALC3263 (Dell XPS 13 9343) David Ward
2021-03-08 22:18 ` [PATCH 1/3] ASoC: rt286: Make RT286_SET_GPIO_* readable and writable David Ward
2021-03-08 22:18 ` [PATCH 2/3] ASoC: rt286: Handle all devices with ALC3263 codec David Ward
2021-03-08 22:18 ` [PATCH 3/3] ASoc: rt286: Handle headphones in combo jack correctly David Ward

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).