[alsa-devel] [PATCH 0/4] ASoC: rt5645: GPD Win jack support
Hi,
this is a patchset containing the fixes for the inverted jack detection on RT5645 codec and a quirk for GPD Win device. Possibly the newer one, GPD Pocket, would work with the same quirk. First three are from Bard, and the last one is the suggested by Hans.
You may notice the ugliness there, but unfortunately this is the only way to identify the machine. Blame BIOS programmer.
thanks,
Takashi
===
Bard Liao (3): ASoC: rt5645: read jd1_1 status for jd detection ASoC: rt5645: rename jd_invert flag in platform data ASoC: rt5645: add inv_jd1_1 flag
Takashi Iwai (1): ASoC: rt5645: Add jack detection workaround for GPD Win
include/sound/rt5645.h | 6 ++-- sound/soc/codecs/rt5645.c | 72 +++++++++++++++++++++++++++++------------------ 2 files changed, 49 insertions(+), 29 deletions(-)
From: Bard Liao bardliao@realtek.com
Read the jd status after invert control. The benefit is we don't need to invert the reading jd status when jd invert is needed.
Signed-off-by: Bard Liao bardliao@realtek.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/soc/codecs/rt5645.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 87844a45886a..8e419ea418e9 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3238,24 +3238,16 @@ static void rt5645_jack_detect_work(struct work_struct *work) snd_soc_jack_report(rt5645->mic_jack, report, SND_JACK_MICROPHONE); return; - case 1: /* 2 port */ - val = snd_soc_read(rt5645->codec, RT5645_A_JD_CTRL1) & 0x0070; - break; - default: /* 1 port */ - val = snd_soc_read(rt5645->codec, RT5645_A_JD_CTRL1) & 0x0020; + default: /* read rt5645 jd1_1 status */ + val = snd_soc_read(rt5645->codec, RT5645_INT_IRQ_ST) & 0x1000; break;
}
- switch (val) { - /* jack in */ - case 0x30: /* 2 port */ - case 0x0: /* 1 port or 2 port */ - if (rt5645->jack_type == 0) { - report = rt5645_jack_detect(rt5645->codec, 1); - /* for push button and jack out */ - break; - } + if (!val && (rt5645->jack_type == 0)) { /* jack in */ + report = rt5645_jack_detect(rt5645->codec, 1); + } else if (!val && rt5645->jack_type != 0) { + /* for push button and jack out */ btn_type = 0; if (snd_soc_read(rt5645->codec, RT5645_INT_IRQ_ST) & 0x4) { /* button pressed */ @@ -3302,19 +3294,12 @@ static void rt5645_jack_detect_work(struct work_struct *work) mod_timer(&rt5645->btn_check_timer, msecs_to_jiffies(100)); } - - break; - /* jack out */ - case 0x70: /* 2 port */ - case 0x10: /* 2 port */ - case 0x20: /* 1 port */ + } else { + /* jack out */ report = 0; snd_soc_update_bits(rt5645->codec, RT5645_INT_IRQ_ST, 0x1, 0x0); rt5645_jack_detect(rt5645->codec, 0); - break; - default: - break; }
snd_soc_jack_report(rt5645->hp_jack, report, SND_JACK_HEADPHONE);
The patch
ASoC: rt5645: read jd1_1 status for jd detection
has been applied to the asoc tree at
git://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 6b5da66322c50b4fa22f9343dcb968496f831361 Mon Sep 17 00:00:00 2001
From: Bard Liao bardliao@realtek.com Date: Wed, 28 Jun 2017 14:49:36 +0200 Subject: [PATCH] ASoC: rt5645: read jd1_1 status for jd detection
Read the jd status after invert control. The benefit is we don't need to invert the reading jd status when jd invert is needed.
Signed-off-by: Bard Liao bardliao@realtek.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/rt5645.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 87844a45886a..8e419ea418e9 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3238,24 +3238,16 @@ static void rt5645_jack_detect_work(struct work_struct *work) snd_soc_jack_report(rt5645->mic_jack, report, SND_JACK_MICROPHONE); return; - case 1: /* 2 port */ - val = snd_soc_read(rt5645->codec, RT5645_A_JD_CTRL1) & 0x0070; - break; - default: /* 1 port */ - val = snd_soc_read(rt5645->codec, RT5645_A_JD_CTRL1) & 0x0020; + default: /* read rt5645 jd1_1 status */ + val = snd_soc_read(rt5645->codec, RT5645_INT_IRQ_ST) & 0x1000; break;
}
- switch (val) { - /* jack in */ - case 0x30: /* 2 port */ - case 0x0: /* 1 port or 2 port */ - if (rt5645->jack_type == 0) { - report = rt5645_jack_detect(rt5645->codec, 1); - /* for push button and jack out */ - break; - } + if (!val && (rt5645->jack_type == 0)) { /* jack in */ + report = rt5645_jack_detect(rt5645->codec, 1); + } else if (!val && rt5645->jack_type != 0) { + /* for push button and jack out */ btn_type = 0; if (snd_soc_read(rt5645->codec, RT5645_INT_IRQ_ST) & 0x4) { /* button pressed */ @@ -3302,19 +3294,12 @@ static void rt5645_jack_detect_work(struct work_struct *work) mod_timer(&rt5645->btn_check_timer, msecs_to_jiffies(100)); } - - break; - /* jack out */ - case 0x70: /* 2 port */ - case 0x10: /* 2 port */ - case 0x20: /* 1 port */ + } else { + /* jack out */ report = 0; snd_soc_update_bits(rt5645->codec, RT5645_INT_IRQ_ST, 0x1, 0x0); rt5645_jack_detect(rt5645->codec, 0); - break; - default: - break; }
snd_soc_jack_report(rt5645->hp_jack, report, SND_JACK_HEADPHONE);
From: Bard Liao bardliao@realtek.com
The jd_invert flag is actually used for level triggered IRQ. Rename it to let code more readable.
Signed-off-by: Bard Liao bardliao@realtek.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de --- include/sound/rt5645.h | 4 ++-- sound/soc/codecs/rt5645.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/sound/rt5645.h b/include/sound/rt5645.h index a5cf6152e778..c427f10a39ae 100644 --- a/include/sound/rt5645.h +++ b/include/sound/rt5645.h @@ -21,8 +21,8 @@ struct rt5645_platform_data { /* 0 = IN2P; 1 = GPIO6; 2 = GPIO10; 3 = GPIO12 */
unsigned int jd_mode; - /* Invert JD when jack insert */ - bool jd_invert; + /* Use level triggered irq */ + bool level_trigger_irq; };
#endif diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 8e419ea418e9..e0c09bbd3f12 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3151,7 +3151,7 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) snd_soc_dapm_sync(dapm); rt5645->jack_type = SND_JACK_HEADPHONE; } - if (rt5645->pdata.jd_invert) + if (rt5645->pdata.level_trigger_irq) regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, RT5645_JD_1_1_MASK, RT5645_JD_1_1_NOR); } else { /* jack out */ @@ -3172,7 +3172,7 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) snd_soc_dapm_disable_pin(dapm, "LDO2"); snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); - if (rt5645->pdata.jd_invert) + if (rt5645->pdata.level_trigger_irq) regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV); } @@ -3586,7 +3586,7 @@ static struct rt5645_platform_data buddy_platform_data = { .dmic1_data_pin = RT5645_DMIC_DATA_GPIO5, .dmic2_data_pin = RT5645_DMIC_DATA_IN2P, .jd_mode = 3, - .jd_invert = true, + .level_trigger_irq = true, };
static struct dmi_system_id dmi_platform_intel_broadwell[] = { @@ -3838,7 +3838,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, regmap_update_bits(rt5645->regmap, RT5645_ADDA_CLK1, RT5645_I2S_PD1_MASK, RT5645_I2S_PD1_2);
- if (rt5645->pdata.jd_invert) { + if (rt5645->pdata.level_trigger_irq) { regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV); }
The patch
ASoC: rt5645: rename jd_invert flag in platform data
has been applied to the asoc tree at
git://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 895750228c9d3361ed82e9786322604de3232466 Mon Sep 17 00:00:00 2001
From: Bard Liao bardliao@realtek.com Date: Wed, 28 Jun 2017 14:49:37 +0200 Subject: [PATCH] ASoC: rt5645: rename jd_invert flag in platform data
The jd_invert flag is actually used for level triggered IRQ. Rename it to let code more readable.
Signed-off-by: Bard Liao bardliao@realtek.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de Signed-off-by: Mark Brown broonie@kernel.org --- include/sound/rt5645.h | 4 ++-- sound/soc/codecs/rt5645.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/sound/rt5645.h b/include/sound/rt5645.h index a5cf6152e778..c427f10a39ae 100644 --- a/include/sound/rt5645.h +++ b/include/sound/rt5645.h @@ -21,8 +21,8 @@ struct rt5645_platform_data { /* 0 = IN2P; 1 = GPIO6; 2 = GPIO10; 3 = GPIO12 */
unsigned int jd_mode; - /* Invert JD when jack insert */ - bool jd_invert; + /* Use level triggered irq */ + bool level_trigger_irq; };
#endif diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 8e419ea418e9..e0c09bbd3f12 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3151,7 +3151,7 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) snd_soc_dapm_sync(dapm); rt5645->jack_type = SND_JACK_HEADPHONE; } - if (rt5645->pdata.jd_invert) + if (rt5645->pdata.level_trigger_irq) regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, RT5645_JD_1_1_MASK, RT5645_JD_1_1_NOR); } else { /* jack out */ @@ -3172,7 +3172,7 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) snd_soc_dapm_disable_pin(dapm, "LDO2"); snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); - if (rt5645->pdata.jd_invert) + if (rt5645->pdata.level_trigger_irq) regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV); } @@ -3586,7 +3586,7 @@ static struct rt5645_platform_data buddy_platform_data = { .dmic1_data_pin = RT5645_DMIC_DATA_GPIO5, .dmic2_data_pin = RT5645_DMIC_DATA_IN2P, .jd_mode = 3, - .jd_invert = true, + .level_trigger_irq = true, };
static struct dmi_system_id dmi_platform_intel_broadwell[] = { @@ -3838,7 +3838,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, regmap_update_bits(rt5645->regmap, RT5645_ADDA_CLK1, RT5645_I2S_PD1_MASK, RT5645_I2S_PD1_2);
- if (rt5645->pdata.jd_invert) { + if (rt5645->pdata.level_trigger_irq) { regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV); }
From: Bard Liao bardliao@realtek.com
The flag will invert jd1_1 status. Which will be used if the jack connector is normal closed.
Signed-off-by: Bard Liao bardliao@realtek.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de --- include/sound/rt5645.h | 2 ++ sound/soc/codecs/rt5645.c | 4 ++++ 2 files changed, 6 insertions(+)
diff --git a/include/sound/rt5645.h b/include/sound/rt5645.h index c427f10a39ae..d0c33a9972b9 100644 --- a/include/sound/rt5645.h +++ b/include/sound/rt5645.h @@ -23,6 +23,8 @@ struct rt5645_platform_data { unsigned int jd_mode; /* Use level triggered irq */ bool level_trigger_irq; + /* Invert JD1_1 status polarity */ + bool inv_jd1_1; };
#endif diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index e0c09bbd3f12..162044d82632 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3833,6 +3833,10 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, default: break; } + if (rt5645->pdata.inv_jd1_1) { + regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, + RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV); + } }
regmap_update_bits(rt5645->regmap, RT5645_ADDA_CLK1,
The patch
ASoC: rt5645: add inv_jd1_1 flag
has been applied to the asoc tree at
git://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 aea086dda2d5df659a7c5d9efe85721e9442a133 Mon Sep 17 00:00:00 2001
From: Bard Liao bardliao@realtek.com Date: Wed, 28 Jun 2017 14:49:38 +0200 Subject: [PATCH] ASoC: rt5645: add inv_jd1_1 flag
The flag will invert jd1_1 status. Which will be used if the jack connector is normal closed.
Signed-off-by: Bard Liao bardliao@realtek.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de Signed-off-by: Mark Brown broonie@kernel.org --- include/sound/rt5645.h | 2 ++ sound/soc/codecs/rt5645.c | 4 ++++ 2 files changed, 6 insertions(+)
diff --git a/include/sound/rt5645.h b/include/sound/rt5645.h index c427f10a39ae..d0c33a9972b9 100644 --- a/include/sound/rt5645.h +++ b/include/sound/rt5645.h @@ -23,6 +23,8 @@ struct rt5645_platform_data { unsigned int jd_mode; /* Use level triggered irq */ bool level_trigger_irq; + /* Invert JD1_1 status polarity */ + bool inv_jd1_1; };
#endif diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index e0c09bbd3f12..162044d82632 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3833,6 +3833,10 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, default: break; } + if (rt5645->pdata.inv_jd1_1) { + regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, + RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV); + } }
regmap_update_bits(rt5645->regmap, RT5645_ADDA_CLK1,
GPD Win requires jd_mode=3 and the inverted flag for making the jack detection working. Unfortunately, the BIOS doesn't give a nice way to match with DMI strings, and the only working way so far is to match with the board vendor/name/version/date to some known patterns.
Hopefully other vendors won't do such a stupid setup, too...
Thanks to Hans de Goede for the DMI matching suggestion.
Suggested-by: Hans de Goede hdegoede@redhat.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/soc/codecs/rt5645.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 162044d82632..308c22f5909a 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3599,6 +3599,33 @@ static struct dmi_system_id dmi_platform_intel_broadwell[] = { { } };
+static struct rt5645_platform_data gpd_win_platform_data = { + .jd_mode = 3, + .inv_jd1_1 = true, +}; + +static const struct dmi_system_id dmi_platform_gpd_win[] = { + { + /* + * Match for the GPDwin which unfortunately uses somewhat + * generic dmi strings, which is why we test for 4 strings. + * Comparing against 23 other byt/cht boards, board_vendor + * and board_name are unique to the GPDwin, where as only one + * other board has the same board_serial and 3 others have + * the same default product_name. Also the GPDwin is the + * only device to have both board_ and product_name not set. + */ + .ident = "GPD Win", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), + DMI_MATCH(DMI_BOARD_NAME, "Default string"), + DMI_MATCH(DMI_BOARD_SERIAL, "Default string"), + DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), + }, + }, + {} +}; + static bool rt5645_check_dp(struct device *dev) { if (device_property_present(dev, "realtek,in2-differential") || @@ -3649,6 +3676,8 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, rt5645_parse_dt(rt5645, &i2c->dev); else if (dmi_check_system(dmi_platform_intel_braswell)) rt5645->pdata = general_platform_data; + else if (dmi_check_system(dmi_platform_gpd_win)) + rt5645->pdata = gpd_win_platform_data;
rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect", GPIOD_IN);
The patch
ASoC: rt5645: Add jack detection workaround for GPD Win
has been applied to the asoc tree at
git://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 ea2b5a6e3a386b89d7f9148ff8be6c78d13542a0 Mon Sep 17 00:00:00 2001
From: Takashi Iwai tiwai@suse.de Date: Wed, 28 Jun 2017 14:49:39 +0200 Subject: [PATCH] ASoC: rt5645: Add jack detection workaround for GPD Win
GPD Win requires jd_mode=3 and the inverted flag for making the jack detection working. Unfortunately, the BIOS doesn't give a nice way to match with DMI strings, and the only working way so far is to match with the board vendor/name/version/date to some known patterns.
Hopefully other vendors won't do such a stupid setup, too...
Thanks to Hans de Goede for the DMI matching suggestion.
Suggested-by: Hans de Goede hdegoede@redhat.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/rt5645.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 162044d82632..308c22f5909a 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3599,6 +3599,33 @@ static struct dmi_system_id dmi_platform_intel_broadwell[] = { { } };
+static struct rt5645_platform_data gpd_win_platform_data = { + .jd_mode = 3, + .inv_jd1_1 = true, +}; + +static const struct dmi_system_id dmi_platform_gpd_win[] = { + { + /* + * Match for the GPDwin which unfortunately uses somewhat + * generic dmi strings, which is why we test for 4 strings. + * Comparing against 23 other byt/cht boards, board_vendor + * and board_name are unique to the GPDwin, where as only one + * other board has the same board_serial and 3 others have + * the same default product_name. Also the GPDwin is the + * only device to have both board_ and product_name not set. + */ + .ident = "GPD Win", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), + DMI_MATCH(DMI_BOARD_NAME, "Default string"), + DMI_MATCH(DMI_BOARD_SERIAL, "Default string"), + DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), + }, + }, + {} +}; + static bool rt5645_check_dp(struct device *dev) { if (device_property_present(dev, "realtek,in2-differential") || @@ -3649,6 +3676,8 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, rt5645_parse_dt(rt5645, &i2c->dev); else if (dmi_check_system(dmi_platform_intel_braswell)) rt5645->pdata = general_platform_data; + else if (dmi_check_system(dmi_platform_gpd_win)) + rt5645->pdata = gpd_win_platform_data;
rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect", GPIOD_IN);
On 6/28/17 7:49 AM, Takashi Iwai wrote:
GPD Win requires jd_mode=3 and the inverted flag for making the jack detection working. Unfortunately, the BIOS doesn't give a nice way to match with DMI strings, and the only working way so far is to match with the board vendor/name/version/date to some known patterns.
Hopefully other vendors won't do such a stupid setup, too...
Thanks to Hans de Goede for the DMI matching suggestion.
Suggested-by: Hans de Goede hdegoede@redhat.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de
sound/soc/codecs/rt5645.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 162044d82632..308c22f5909a 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3599,6 +3599,33 @@ static struct dmi_system_id dmi_platform_intel_broadwell[] = { { } };
+static struct rt5645_platform_data gpd_win_platform_data = {
- .jd_mode = 3,
- .inv_jd1_1 = true,
+};
+static const struct dmi_system_id dmi_platform_gpd_win[] = {
- {
/*
* Match for the GPDwin which unfortunately uses somewhat
* generic dmi strings, which is why we test for 4 strings.
* Comparing against 23 other byt/cht boards, board_vendor
* and board_name are unique to the GPDwin, where as only one
* other board has the same board_serial and 3 others have
* the same default product_name. Also the GPDwin is the
* only device to have both board_ and product_name not set.
*/
.ident = "GPD Win",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
DMI_MATCH(DMI_BOARD_NAME, "Default string"),
DMI_MATCH(DMI_BOARD_SERIAL, "Default string"),
DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
},
- },
- {}
it feels like it's time to add a quirk parameter for this codec module to avoid chasing all possible DMI/BIOS issues?
+};
static bool rt5645_check_dp(struct device *dev) { if (device_property_present(dev, "realtek,in2-differential") || @@ -3649,6 +3676,8 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, rt5645_parse_dt(rt5645, &i2c->dev); else if (dmi_check_system(dmi_platform_intel_braswell)) rt5645->pdata = general_platform_data;
else if (dmi_check_system(dmi_platform_gpd_win))
rt5645->pdata = gpd_win_platform_data;
rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect", GPIOD_IN);
On Wed, Jun 28, 2017 at 04:07:01PM -0500, Pierre-Louis Bossart wrote:
On 6/28/17 7:49 AM, Takashi Iwai wrote:
GPD Win requires jd_mode=3 and the inverted flag for making the jack detection working. Unfortunately, the BIOS doesn't give a nice way to match with DMI strings, and the only working way so far is to match with the board vendor/name/version/date to some known patterns.
Hopefully other vendors won't do such a stupid setup, too...
Takashi, no such luck, see below.
Thanks to Hans de Goede for the DMI matching suggestion.
Suggested-by: Hans de Goede hdegoede@redhat.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de
sound/soc/codecs/rt5645.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 162044d82632..308c22f5909a 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3599,6 +3599,33 @@ static struct dmi_system_id dmi_platform_intel_broadwell[] = { { } };
+static struct rt5645_platform_data gpd_win_platform_data = {
- .jd_mode = 3,
- .inv_jd1_1 = true,
+};
+static const struct dmi_system_id dmi_platform_gpd_win[] = {
- {
/*
* Match for the GPDwin which unfortunately uses somewhat
* generic dmi strings, which is why we test for 4 strings.
* Comparing against 23 other byt/cht boards, board_vendor
* and board_name are unique to the GPDwin, where as only one
* other board has the same board_serial and 3 others have
* the same default product_name. Also the GPDwin is the
* only device to have both board_ and product_name not set.
*/
.ident = "GPD Win",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
DMI_MATCH(DMI_BOARD_NAME, "Default string"),
DMI_MATCH(DMI_BOARD_SERIAL, "Default string"),
DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
},
- },
- {}
it feels like it's time to add a quirk parameter for this codec module to avoid chasing all possible DMI/BIOS issues?
That would be nice.
Tested against 4.12.0-rc7, this series fixes silent headphones, and headset microphone. So guys, if appropriate, and not too late, please add my
Tested-by: James Cameron quozl@laptop.org
Test was with the system previously described here: https://www.spinics.net/lists/alsa-devel/msg63279.html
The DMI match was hacked as part of the test.
Still silent built-in microphone; PCB traces to codec pins suggest a DMIC1. System vendor has not given any data; says because Intel doesn't support the SOC on Linux, they won't either. ;-)
...
On Wed, 28 Jun 2017 23:07:01 +0200, Pierre-Louis Bossart wrote:
On 6/28/17 7:49 AM, Takashi Iwai wrote:
GPD Win requires jd_mode=3 and the inverted flag for making the jack detection working. Unfortunately, the BIOS doesn't give a nice way to match with DMI strings, and the only working way so far is to match with the board vendor/name/version/date to some known patterns.
Hopefully other vendors won't do such a stupid setup, too...
Thanks to Hans de Goede for the DMI matching suggestion.
Suggested-by: Hans de Goede hdegoede@redhat.com Tested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Takashi Iwai tiwai@suse.de
sound/soc/codecs/rt5645.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 162044d82632..308c22f5909a 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3599,6 +3599,33 @@ static struct dmi_system_id dmi_platform_intel_broadwell[] = { { } };
+static struct rt5645_platform_data gpd_win_platform_data = {
- .jd_mode = 3,
- .inv_jd1_1 = true,
+};
+static const struct dmi_system_id dmi_platform_gpd_win[] = {
- {
/*
* Match for the GPDwin which unfortunately uses somewhat
* generic dmi strings, which is why we test for 4 strings.
* Comparing against 23 other byt/cht boards, board_vendor
* and board_name are unique to the GPDwin, where as only one
* other board has the same board_serial and 3 others have
* the same default product_name. Also the GPDwin is the
* only device to have both board_ and product_name not set.
*/
.ident = "GPD Win",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
DMI_MATCH(DMI_BOARD_NAME, "Default string"),
DMI_MATCH(DMI_BOARD_SERIAL, "Default string"),
DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
},
- },
- {}
it feels like it's time to add a quirk parameter for this codec module to avoid chasing all possible DMI/BIOS issues?
Yes, my very first version was such one, but we ended up with this version as the weird-looking DMI matching was confirmed to work uniquely.
If Realtek guys agree, I can submit the patch to add module options in addition.
thanks,
Takashi
-----Original Message-----
it feels like it's time to add a quirk parameter for this codec module to avoid chasing all possible DMI/BIOS issues?
Yes, my very first version was such one, but we ended up with this version as the weird-looking DMI matching was confirmed to work uniquely.
If Realtek guys agree, I can submit the patch to add module options in addition.
Yes, I agree to and appreciate it. Please cc me when you submit the patch.
Thanks.
thanks,
Takashi
------Please consider the environment before printing this e-mail.
participants (5)
-
Bard Liao
-
James Cameron
-
Mark Brown
-
Pierre-Louis Bossart
-
Takashi Iwai