All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: rt5645: Add quirk override by module option
@ 2017-06-29 16:08 Takashi Iwai
  2017-06-29 23:40 ` James Cameron
  2017-06-30 11:58 ` Applied "ASoC: rt5645: Add quirk override by module option" to the asoc tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Takashi Iwai @ 2017-06-29 16:08 UTC (permalink / raw)
  To: Mark Brown
  Cc: Oder Chiou, Bard Liao, alsa-devel, Pierre-Louis Bossart, James Cameron

For making the development easier, add quirk module option to override
the platform data setup.  For example, a platform with inverted jack
detection with jd_mode=2, pass the value 0x21 (0x1 = inv_jd1_1, 0x20 =
jd_mode=2).  It overrides the whole pdata fields, so pass it
carefully.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/codecs/rt5645.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 308c22f5909a..22771e6ab3fa 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -34,6 +34,17 @@
 #include "rl6231.h"
 #include "rt5645.h"
 
+#define QUIRK_INV_JD1_1(q)	((q) & 1)
+#define QUIRK_LEVEL_IRQ(q)	(((q) >> 1) & 1)
+#define QUIRK_IN2_DIFF(q)	(((q) >> 2) & 1)
+#define QUIRK_JD_MODE(q)	(((q) >> 4) & 7)
+#define QUIRK_DMIC1_DATA_PIN(q)	(((q) >> 8) & 3)
+#define QUIRK_DMIC2_DATA_PIN(q)	(((q) >> 12) & 3)
+
+static unsigned int quirk = -1;
+module_param(quirk, uint, 0444);
+MODULE_PARM_DESC(quirk, "RT5645 pdata quirk override");
+
 #define RT5645_DEVICE_ID 0x6308
 #define RT5650_DEVICE_ID 0x6419
 
@@ -3679,6 +3690,15 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
 	else if (dmi_check_system(dmi_platform_gpd_win))
 		rt5645->pdata = gpd_win_platform_data;
 
+	if (quirk != -1) {
+		rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk);
+		rt5645->pdata.level_trigger_irq = QUIRK_LEVEL_IRQ(quirk);
+		rt5645->pdata.inv_jd1_1 = QUIRK_INV_JD1_1(quirk);
+		rt5645->pdata.jd_mode = QUIRK_JD_MODE(quirk);
+		rt5645->pdata.dmic1_data_pin = QUIRK_DMIC1_DATA_PIN(quirk);
+		rt5645->pdata.dmic2_data_pin = QUIRK_DMIC2_DATA_PIN(quirk);
+	}
+
 	rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect",
 						       GPIOD_IN);
 
-- 
2.13.2

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

* Re: [PATCH] ASoC: rt5645: Add quirk override by module option
  2017-06-29 16:08 [PATCH] ASoC: rt5645: Add quirk override by module option Takashi Iwai
@ 2017-06-29 23:40 ` James Cameron
  2017-06-30 11:58 ` Applied "ASoC: rt5645: Add quirk override by module option" to the asoc tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: James Cameron @ 2017-06-29 23:40 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Oder Chiou, Bard Liao, alsa-devel, Mark Brown, Pierre-Louis Bossart

On Thu, Jun 29, 2017 at 06:08:33PM +0200, Takashi Iwai wrote:
> For making the development easier, add quirk module option to override
> the platform data setup.  For example, a platform with inverted jack
> detection with jd_mode=2, pass the value 0x21 (0x1 = inv_jd1_1, 0x20 =
> jd_mode=2).  It overrides the whole pdata fields, so pass it
> carefully.
> 
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

Tested-by: James Cameron <quozl@laptop.org>

Now I've a working internal digital microphone, using
snd_soc_rt5645.quirk=0x1031

-- 
James Cameron
http://quozl.netrek.org/

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

* Applied "ASoC: rt5645: Add quirk override by module option" to the asoc tree
  2017-06-29 16:08 [PATCH] ASoC: rt5645: Add quirk override by module option Takashi Iwai
  2017-06-29 23:40 ` James Cameron
@ 2017-06-30 11:58 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2017-06-30 11:58 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Oder Chiou, alsa-devel, James Cameron, Pierre-Louis Bossart,
	Mark Brown, Bard Liao

The patch

   ASoC: rt5645: Add quirk override by module option

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 4999b0214b05a08b42bbafcb29a0b9c413002d3f Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Thu, 29 Jun 2017 18:08:33 +0200
Subject: [PATCH] ASoC: rt5645: Add quirk override by module option

For making the development easier, add quirk module option to override
the platform data setup.  For example, a platform with inverted jack
detection with jd_mode=2, pass the value 0x21 (0x1 = inv_jd1_1, 0x20 =
jd_mode=2).  It overrides the whole pdata fields, so pass it
carefully.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Tested-by: James Cameron <quozl@laptop.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/rt5645.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 630374ee692a..909f4a6aaef1 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -34,6 +34,17 @@
 #include "rl6231.h"
 #include "rt5645.h"
 
+#define QUIRK_INV_JD1_1(q)	((q) & 1)
+#define QUIRK_LEVEL_IRQ(q)	(((q) >> 1) & 1)
+#define QUIRK_IN2_DIFF(q)	(((q) >> 2) & 1)
+#define QUIRK_JD_MODE(q)	(((q) >> 4) & 7)
+#define QUIRK_DMIC1_DATA_PIN(q)	(((q) >> 8) & 3)
+#define QUIRK_DMIC2_DATA_PIN(q)	(((q) >> 12) & 3)
+
+static unsigned int quirk = -1;
+module_param(quirk, uint, 0444);
+MODULE_PARM_DESC(quirk, "RT5645 pdata quirk override");
+
 #define RT5645_DEVICE_ID 0x6308
 #define RT5650_DEVICE_ID 0x6419
 
@@ -3679,6 +3690,15 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
 	else if (dmi_check_system(dmi_platform_gpd_win))
 		rt5645->pdata = gpd_win_platform_data;
 
+	if (quirk != -1) {
+		rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk);
+		rt5645->pdata.level_trigger_irq = QUIRK_LEVEL_IRQ(quirk);
+		rt5645->pdata.inv_jd1_1 = QUIRK_INV_JD1_1(quirk);
+		rt5645->pdata.jd_mode = QUIRK_JD_MODE(quirk);
+		rt5645->pdata.dmic1_data_pin = QUIRK_DMIC1_DATA_PIN(quirk);
+		rt5645->pdata.dmic2_data_pin = QUIRK_DMIC2_DATA_PIN(quirk);
+	}
+
 	rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect",
 						       GPIOD_IN);
 
-- 
2.13.2

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

end of thread, other threads:[~2017-06-30 11:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 16:08 [PATCH] ASoC: rt5645: Add quirk override by module option Takashi Iwai
2017-06-29 23:40 ` James Cameron
2017-06-30 11:58 ` Applied "ASoC: rt5645: Add quirk override by module option" 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.