[alsa-devel] [RFC 0/7] ASoC: rt5651: Drop pdata, move over to device-properties
Hi Mark, et al.,
Here is a second attempt to stop having duplicated DMI quirk entries between the rt5651 codec and machine drivers.
Note this is only compile tested, I'm looking for some quick feedback if this seems to be going in the right direction, as I'm planning on rebuilding the rest of my jack-detect cleanup / fix series on top of this.
The diffstat for this entire set is:
Documentation/devicetree/bindings/sound/rt5651.txt | 6 include/sound/rt5651.h | 12 sound/soc/codecs/rt5651.c | 375 +++++++++------------ sound/soc/codecs/rt5651.h | 7 sound/soc/intel/boards/bytcr_rt5651.c | 46 ++ 5 files changed, 213 insertions(+), 233 deletions(-)
So besides making the code cleaner (IMHO) it also makes it somewhat smaller and as an added bonus it fixes support the DMIC_EN quirk which was broken.
Regards,
Hans
There are no in tree users of platform-data for the rt5651 codec driver, so lets remove support for it.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- include/sound/rt5651.h | 8 -------- sound/soc/codecs/rt5651.c | 47 +++++++++-------------------------------------- sound/soc/codecs/rt5651.h | 2 +- 3 files changed, 10 insertions(+), 47 deletions(-)
diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h index 18b79a761f10..1612462bf5ad 100644 --- a/include/sound/rt5651.h +++ b/include/sound/rt5651.h @@ -18,12 +18,4 @@ enum rt5651_jd_src { RT5651_JD2, };
-struct rt5651_platform_data { - /* IN2 can optionally be differential */ - bool in2_diff; - - bool dmic_en; - enum rt5651_jd_src jd_src; -}; - #endif diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index de9034418ce3..2aa070554743 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -33,8 +33,6 @@ #include "rt5651.h"
#define RT5651_JD_MAP(quirk) ((quirk) & GENMASK(7, 0)) -#define RT5651_IN2_DIFF BIT(16) -#define RT5651_DMIC_EN BIT(17)
#define RT5651_DEVICE_ID_VALUE 0x6281
@@ -1569,7 +1567,7 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000); snd_soc_component_write(component, RT5651_PWR_VOL, 0x0000); snd_soc_component_write(component, RT5651_PWR_MIXER, 0x0000); - if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) { snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0204); snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0002); } else { @@ -1604,7 +1602,7 @@ static int rt5651_probe(struct snd_soc_component *component)
snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
- if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) { snd_soc_dapm_force_enable_pin(dapm, "JD Power"); snd_soc_dapm_force_enable_pin(dapm, "LDO"); snd_soc_dapm_sync(dapm); @@ -1765,26 +1763,6 @@ static const struct dmi_system_id rt5651_quirk_table[] = { {} };
-static int rt5651_parse_dt(struct rt5651_priv *rt5651, struct device_node *np) -{ - if (of_property_read_bool(np, "realtek,in2-differential")) - rt5651_quirk |= RT5651_IN2_DIFF; - if (of_property_read_bool(np, "realtek,dmic-en")) - rt5651_quirk |= RT5651_DMIC_EN; - - return 0; -} - -static void rt5651_set_pdata(struct rt5651_priv *rt5651) -{ - if (rt5651_quirk & RT5651_IN2_DIFF) - rt5651->pdata.in2_diff = true; - if (rt5651_quirk & RT5651_DMIC_EN) - rt5651->pdata.dmic_en = true; - if (RT5651_JD_MAP(rt5651_quirk)) - rt5651->pdata.jd_src = RT5651_JD_MAP(rt5651_quirk); -} - static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1841,7 +1819,7 @@ static void rt5651_jack_detect_work(struct work_struct *work) if (!rt5651->component) return;
- switch (rt5651->pdata.jd_src) { + switch (rt5651->jd_src) { case RT5651_JD1_1: val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x1000; break; @@ -1875,7 +1853,6 @@ EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); static int rt5651_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { - struct rt5651_platform_data *pdata = dev_get_platdata(&i2c->dev); struct rt5651_priv *rt5651; int ret;
@@ -1886,14 +1863,8 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, rt5651);
- if (pdata) - rt5651->pdata = *pdata; - else if (i2c->dev.of_node) - rt5651_parse_dt(rt5651, i2c->dev.of_node); - else - dmi_check_system(rt5651_quirk_table); - - rt5651_set_pdata(rt5651); + dmi_check_system(rt5651_quirk_table); + rt5651->jd_src = RT5651_JD_MAP(rt5651_quirk);
rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); if (IS_ERR(rt5651->regmap)) { @@ -1917,23 +1888,23 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
- if (rt5651->pdata.in2_diff) + if (device_property_read_bool(&i2c->dev, "realtek,in2-differential")) regmap_update_bits(rt5651->regmap, RT5651_IN1_IN2, RT5651_IN_DF2, RT5651_IN_DF2);
- if (rt5651->pdata.dmic_en) + if (device_property_read_bool(&i2c->dev, "realtek,dmic-en")) regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL);
rt5651->hp_mute = 1;
- if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) {
/* IRQ output on GPIO1 */ regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ);
- switch (rt5651->pdata.jd_src) { + switch (rt5651->jd_src) { case RT5651_JD1_1: regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, RT5651_JD_TRG_SEL_MASK, diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 1ef38429e6a0..148e139e6a26 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2060,10 +2060,10 @@ struct rt5651_pll_code {
struct rt5651_priv { struct snd_soc_component *component; - struct rt5651_platform_data pdata; struct regmap *regmap; struct snd_soc_jack *hp_jack; struct delayed_work jack_detect_work; + enum rt5651_jd_src jd_src;
int sysclk; int sysclk_src;
The patch
ASoC: rt5651: Remove unused rt5651_platform_data
has been applied to the asoc tree at
https://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 54e3a3a152a6f466f3a94b28be10f08b86905bc0 Mon Sep 17 00:00:00 2001
From: Hans de Goede hdegoede@redhat.com Date: Sun, 25 Feb 2018 11:46:42 +0100 Subject: [PATCH] ASoC: rt5651: Remove unused rt5651_platform_data
There are no in tree users of platform-data for the rt5651 codec driver, so lets remove support for it.
Signed-off-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Mark Brown broonie@kernel.org --- include/sound/rt5651.h | 8 -------- sound/soc/codecs/rt5651.c | 47 +++++++++-------------------------------------- sound/soc/codecs/rt5651.h | 2 +- 3 files changed, 10 insertions(+), 47 deletions(-)
diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h index 18b79a761f10..1612462bf5ad 100644 --- a/include/sound/rt5651.h +++ b/include/sound/rt5651.h @@ -18,12 +18,4 @@ enum rt5651_jd_src { RT5651_JD2, };
-struct rt5651_platform_data { - /* IN2 can optionally be differential */ - bool in2_diff; - - bool dmic_en; - enum rt5651_jd_src jd_src; -}; - #endif diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 3a844725684b..eecd6e662210 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -33,8 +33,6 @@ #include "rt5651.h"
#define RT5651_JD_MAP(quirk) ((quirk) & GENMASK(7, 0)) -#define RT5651_IN2_DIFF BIT(16) -#define RT5651_DMIC_EN BIT(17)
#define RT5651_DEVICE_ID_VALUE 0x6281
@@ -1569,7 +1567,7 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000); snd_soc_component_write(component, RT5651_PWR_VOL, 0x0000); snd_soc_component_write(component, RT5651_PWR_MIXER, 0x0000); - if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) { snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0204); snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0002); } else { @@ -1604,7 +1602,7 @@ static int rt5651_probe(struct snd_soc_component *component)
snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
- if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) { snd_soc_dapm_force_enable_pin(dapm, "JD Power"); snd_soc_dapm_force_enable_pin(dapm, "LDO"); snd_soc_dapm_sync(dapm); @@ -1764,26 +1762,6 @@ static const struct dmi_system_id rt5651_quirk_table[] = { {} };
-static int rt5651_parse_dt(struct rt5651_priv *rt5651, struct device_node *np) -{ - if (of_property_read_bool(np, "realtek,in2-differential")) - rt5651_quirk |= RT5651_IN2_DIFF; - if (of_property_read_bool(np, "realtek,dmic-en")) - rt5651_quirk |= RT5651_DMIC_EN; - - return 0; -} - -static void rt5651_set_pdata(struct rt5651_priv *rt5651) -{ - if (rt5651_quirk & RT5651_IN2_DIFF) - rt5651->pdata.in2_diff = true; - if (rt5651_quirk & RT5651_DMIC_EN) - rt5651->pdata.dmic_en = true; - if (RT5651_JD_MAP(rt5651_quirk)) - rt5651->pdata.jd_src = RT5651_JD_MAP(rt5651_quirk); -} - static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1840,7 +1818,7 @@ static void rt5651_jack_detect_work(struct work_struct *work) if (!rt5651->component) return;
- switch (rt5651->pdata.jd_src) { + switch (rt5651->jd_src) { case RT5651_JD1_1: val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x1000; break; @@ -1874,7 +1852,6 @@ EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); static int rt5651_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { - struct rt5651_platform_data *pdata = dev_get_platdata(&i2c->dev); struct rt5651_priv *rt5651; int ret;
@@ -1885,14 +1862,8 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, rt5651);
- if (pdata) - rt5651->pdata = *pdata; - else if (i2c->dev.of_node) - rt5651_parse_dt(rt5651, i2c->dev.of_node); - else - dmi_check_system(rt5651_quirk_table); - - rt5651_set_pdata(rt5651); + dmi_check_system(rt5651_quirk_table); + rt5651->jd_src = RT5651_JD_MAP(rt5651_quirk);
rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); if (IS_ERR(rt5651->regmap)) { @@ -1916,23 +1887,23 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
- if (rt5651->pdata.in2_diff) + if (device_property_read_bool(&i2c->dev, "realtek,in2-differential")) regmap_update_bits(rt5651->regmap, RT5651_IN1_IN2, RT5651_IN_DF2, RT5651_IN_DF2);
- if (rt5651->pdata.dmic_en) + if (device_property_read_bool(&i2c->dev, "realtek,dmic-en")) regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL);
rt5651->hp_mute = 1;
- if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) {
/* IRQ output on GPIO1 */ regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ);
- switch (rt5651->pdata.jd_src) { + switch (rt5651->jd_src) { case RT5651_JD1_1: regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, RT5651_JD_TRG_SEL_MASK, diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 1ef38429e6a0..148e139e6a26 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2060,10 +2060,10 @@ struct rt5651_pll_code {
struct rt5651_priv { struct snd_soc_component *component; - struct rt5651_platform_data pdata; struct regmap *regmap; struct snd_soc_jack *hp_jack; struct delayed_work jack_detect_work; + enum rt5651_jd_src jd_src;
int sysclk; int sysclk_src;
Move all jack-detect initialization to rt5651_set_jack_detect. The main reason to do this is so that platform code can setup jack-detect properties after the device has been probed, which unfortunately is necessary on some platforms.
This has 2 additional advantages: 1) Grouping all jack-detect init together makes it easier to follow what is happening and results in a small reduction in the number of loc. 2) Before we would register the irq handler before rt5651->hp_jack was assigned, leading to a potential NULL deref if the jack_detect work runs before the machine driver has called set_jack.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- sound/soc/codecs/rt5651.c | 118 ++++++++++++++++++++++------------------------ sound/soc/codecs/rt5651.h | 1 + 2 files changed, 57 insertions(+), 62 deletions(-)
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 2aa070554743..5704482341e8 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1586,7 +1586,6 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, static int rt5651_probe(struct snd_soc_component *component) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
rt5651->component = component;
@@ -1602,15 +1601,6 @@ static int rt5651_probe(struct snd_soc_component *component)
snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
- if (rt5651->jd_src) { - snd_soc_dapm_force_enable_pin(dapm, "JD Power"); - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - - regmap_update_bits(rt5651->regmap, RT5651_MICBIAS, - 0x38, 0x38); - } - return 0; }
@@ -1841,10 +1831,64 @@ static void rt5651_jack_detect_work(struct work_struct *work) int rt5651_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack) { + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + int ret; + + if (!rt5651->irq) + return -EINVAL; + + /* IRQ output on GPIO1 */ + snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, + RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); + + switch (rt5651->jd_src) { + case RT5651_JD1_1: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_1); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_1_IRQ_EN, RT5651_JD1_1_IRQ_EN); + break; + case RT5651_JD1_2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_2_IRQ_EN, RT5651_JD1_2_IRQ_EN); + break; + case RT5651_JD2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD2_IRQ_EN, RT5651_JD2_IRQ_EN); + break; + case RT5651_JD_NULL: + return 0; + default: + dev_warn(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); + return 0; + } + + snd_soc_dapm_force_enable_pin(dapm, "JD Power"); + snd_soc_dapm_force_enable_pin(dapm, "LDO"); + snd_soc_dapm_sync(dapm); + + snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38);
rt5651->hp_jack = hp_jack; - rt5651_irq(0, rt5651); + + ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, + rt5651_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, "rt5651", rt5651); + if (ret) { + dev_err(component->dev, "Failed to reguest IRQ: %d\n", ret); + return ret; + } + + /* sync initial jack state */ + queue_delayed_work(system_power_efficient_wq, + &rt5651->jack_detect_work, 0);
return 0; } @@ -1896,61 +1940,11 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL);
+ rt5651->irq = i2c->irq; rt5651->hp_mute = 1;
- if (rt5651->jd_src) { - - /* IRQ output on GPIO1 */ - regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, - RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); - - switch (rt5651->jd_src) { - case RT5651_JD1_1: - regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, - RT5651_JD_TRG_SEL_JD1_1); - regmap_update_bits(rt5651->regmap, RT5651_IRQ_CTRL1, - RT5651_JD1_1_IRQ_EN, - RT5651_JD1_1_IRQ_EN); - break; - case RT5651_JD1_2: - regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, - RT5651_JD_TRG_SEL_JD1_2); - regmap_update_bits(rt5651->regmap, RT5651_IRQ_CTRL1, - RT5651_JD1_2_IRQ_EN, - RT5651_JD1_2_IRQ_EN); - break; - case RT5651_JD2: - regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, - RT5651_JD_TRG_SEL_JD2); - regmap_update_bits(rt5651->regmap, RT5651_IRQ_CTRL1, - RT5651_JD2_IRQ_EN, - RT5651_JD2_IRQ_EN); - break; - case RT5651_JD_NULL: - break; - default: - dev_warn(&i2c->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); - break; - } - } - INIT_DELAYED_WORK(&rt5651->jack_detect_work, rt5651_jack_detect_work);
- if (i2c->irq) { - ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, - rt5651_irq, - IRQF_TRIGGER_RISING | - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, "rt5651", rt5651); - if (ret) { - dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret); - return ret; - } - } - ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5651, rt5651_dai, ARRAY_SIZE(rt5651_dai)); diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 148e139e6a26..8f128d057ff0 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2065,6 +2065,7 @@ struct rt5651_priv { struct delayed_work jack_detect_work; enum rt5651_jd_src jd_src;
+ int irq; int sysclk; int sysclk_src; int lrck[RT5651_AIFS];
Move 2 functions higher up in rt5651.c, this is a preparation patch to avoid needing forward declarations when moving over from a codec private function to the standard snd_soc_component_set_jack().
This commit purely moves these 2 functions up, not a single line is changed.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- sound/soc/codecs/rt5651.c | 152 +++++++++++++++++++++++----------------------- 1 file changed, 76 insertions(+), 76 deletions(-)
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 5704482341e8..ae9fa14aa652 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1583,6 +1583,82 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, return 0; }
+static irqreturn_t rt5651_irq(int irq, void *data) +{ + struct rt5651_priv *rt5651 = data; + + queue_delayed_work(system_power_efficient_wq, + &rt5651->jack_detect_work, msecs_to_jiffies(250)); + + return IRQ_HANDLED; +} + +int rt5651_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *hp_jack) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + int ret; + + if (!rt5651->irq) + return -EINVAL; + + /* IRQ output on GPIO1 */ + snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, + RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); + + switch (rt5651->jd_src) { + case RT5651_JD1_1: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_1); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_1_IRQ_EN, RT5651_JD1_1_IRQ_EN); + break; + case RT5651_JD1_2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_2_IRQ_EN, RT5651_JD1_2_IRQ_EN); + break; + case RT5651_JD2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD2_IRQ_EN, RT5651_JD2_IRQ_EN); + break; + case RT5651_JD_NULL: + return 0; + default: + dev_warn(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); + return 0; + } + + snd_soc_dapm_force_enable_pin(dapm, "JD Power"); + snd_soc_dapm_force_enable_pin(dapm, "LDO"); + snd_soc_dapm_sync(dapm); + + snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); + + rt5651->hp_jack = hp_jack; + + ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, + rt5651_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, "rt5651", rt5651); + if (ret) { + dev_err(component->dev, "Failed to reguest IRQ: %d\n", ret); + return ret; + } + + /* sync initial jack state */ + queue_delayed_work(system_power_efficient_wq, + &rt5651->jack_detect_work, 0); + + return 0; +} +EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); + static int rt5651_probe(struct snd_soc_component *component) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); @@ -1753,16 +1829,6 @@ static const struct dmi_system_id rt5651_quirk_table[] = { {} };
-static irqreturn_t rt5651_irq(int irq, void *data) -{ - struct rt5651_priv *rt5651 = data; - - queue_delayed_work(system_power_efficient_wq, - &rt5651->jack_detect_work, msecs_to_jiffies(250)); - - return IRQ_HANDLED; -} - static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); @@ -1828,72 +1894,6 @@ static void rt5651_jack_detect_work(struct work_struct *work) snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); }
-int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack) -{ - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); - int ret; - - if (!rt5651->irq) - return -EINVAL; - - /* IRQ output on GPIO1 */ - snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, - RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); - - switch (rt5651->jd_src) { - case RT5651_JD1_1: - snd_soc_component_update_bits(component, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_1); - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, - RT5651_JD1_1_IRQ_EN, RT5651_JD1_1_IRQ_EN); - break; - case RT5651_JD1_2: - snd_soc_component_update_bits(component, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_2); - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, - RT5651_JD1_2_IRQ_EN, RT5651_JD1_2_IRQ_EN); - break; - case RT5651_JD2: - snd_soc_component_update_bits(component, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD2); - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, - RT5651_JD2_IRQ_EN, RT5651_JD2_IRQ_EN); - break; - case RT5651_JD_NULL: - return 0; - default: - dev_warn(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); - return 0; - } - - snd_soc_dapm_force_enable_pin(dapm, "JD Power"); - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - - snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); - - rt5651->hp_jack = hp_jack; - - ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, - rt5651_irq, - IRQF_TRIGGER_RISING | - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, "rt5651", rt5651); - if (ret) { - dev_err(component->dev, "Failed to reguest IRQ: %d\n", ret); - return ret; - } - - /* sync initial jack state */ - queue_delayed_work(system_power_efficient_wq, - &rt5651->jack_detect_work, 0); - - return 0; -} -EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); - static int rt5651_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) {
Use the standard component set_jack callback instead of defining a codec private API for this.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- sound/soc/codecs/rt5651.c | 6 +++--- sound/soc/codecs/rt5651.h | 2 -- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index ae9fa14aa652..2a27be289630 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1593,8 +1593,8 @@ static irqreturn_t rt5651_irq(int irq, void *data) return IRQ_HANDLED; }
-int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack) +static int rt5651_set_jack(struct snd_soc_component *component, + struct snd_soc_jack *hp_jack, void *data) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); @@ -1657,7 +1657,6 @@ int rt5651_set_jack_detect(struct snd_soc_component *component,
return 0; } -EXPORT_SYMBOL_GPL(rt5651_set_jack_detect);
static int rt5651_probe(struct snd_soc_component *component) { @@ -1761,6 +1760,7 @@ static const struct snd_soc_component_driver soc_component_dev_rt5651 = { .suspend = rt5651_suspend, .resume = rt5651_resume, .set_bias_level = rt5651_set_bias_level, + .set_jack = rt5651_set_jack, .controls = rt5651_snd_controls, .num_controls = ARRAY_SIZE(rt5651_snd_controls), .dapm_widgets = rt5651_dapm_widgets, diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 8f128d057ff0..f3158488fc89 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2080,6 +2080,4 @@ struct rt5651_priv { bool hp_mute; };
-int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack); #endif /* __RT5651_H__ */ diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 1f8407b17d2b..8008a027cc93 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -368,7 +368,7 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) return ret; }
- rt5651_set_jack_detect(codec, &priv->jack); + snd_soc_component_set_jack(codec, &priv->jack, NULL);
return ret; }
The patch
ASoC: rt5651: Use standard component set_jack callback
has been applied to the asoc tree at
https://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 6f0b819ae2b36614a514824c622ac0e02650b718 Mon Sep 17 00:00:00 2001
From: Hans de Goede hdegoede@redhat.com Date: Sun, 25 Feb 2018 11:46:45 +0100 Subject: [PATCH] ASoC: rt5651: Use standard component set_jack callback
Use the standard component set_jack callback instead of defining a codec private API for this.
Tested-by: Carlo Caione carlo@endlessm.com Signed-off-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/rt5651.c | 6 +++--- sound/soc/codecs/rt5651.h | 2 -- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index c9698229fc33..030889143249 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1593,8 +1593,8 @@ static irqreturn_t rt5651_irq(int irq, void *data) return IRQ_HANDLED; }
-int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack) +static int rt5651_set_jack(struct snd_soc_component *component, + struct snd_soc_jack *hp_jack, void *data) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); @@ -1658,7 +1658,6 @@ int rt5651_set_jack_detect(struct snd_soc_component *component,
return 0; } -EXPORT_SYMBOL_GPL(rt5651_set_jack_detect);
static int rt5651_probe(struct snd_soc_component *component) { @@ -1762,6 +1761,7 @@ static const struct snd_soc_component_driver soc_component_dev_rt5651 = { .suspend = rt5651_suspend, .resume = rt5651_resume, .set_bias_level = rt5651_set_bias_level, + .set_jack = rt5651_set_jack, .controls = rt5651_snd_controls, .num_controls = ARRAY_SIZE(rt5651_snd_controls), .dapm_widgets = rt5651_dapm_widgets, diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 8f128d057ff0..f3158488fc89 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2080,6 +2080,4 @@ struct rt5651_priv { bool hp_mute; };
-int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack); #endif /* __RT5651_H__ */ diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index b6bf92191b9a..afb27e5e6756 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -370,7 +370,7 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) return ret; }
- rt5651_set_jack_detect(codec, &priv->jack); + snd_soc_component_set_jack(codec, &priv->jack, NULL);
return ret; }
Move the applying of the differential input and dmic properties to a new rt5651_apply_properties() helper function. This new function can be called by platform code which attaches properties after probe() has run to apply these new properties.
Note this also moves the time when we apply these properties for DT platforms from i2c-probe to snd-component-probe time, this should not result in any functional difference.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- sound/soc/codecs/rt5651.c | 21 +++++++++++++-------- sound/soc/codecs/rt5651.h | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 2a27be289630..476e424b32ef 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1658,6 +1658,17 @@ static int rt5651_set_jack(struct snd_soc_component *component, return 0; }
+void rt5651_apply_properties(struct snd_soc_component *component) +{ + if (device_property_read_bool(component->dev, "realtek,in2-differential")) + snd_soc_component_update_bits(component, RT5651_IN1_IN2, + RT5651_IN_DF2, RT5651_IN_DF2); + + if (device_property_read_bool(component->dev, "realtek,dmic-en")) + snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, + RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); +} + static int rt5651_probe(struct snd_soc_component *component) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); @@ -1676,6 +1687,8 @@ static int rt5651_probe(struct snd_soc_component *component)
snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
+ rt5651_apply_properties(component); + return 0; }
@@ -1932,14 +1945,6 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
- if (device_property_read_bool(&i2c->dev, "realtek,in2-differential")) - regmap_update_bits(rt5651->regmap, RT5651_IN1_IN2, - RT5651_IN_DF2, RT5651_IN_DF2); - - if (device_property_read_bool(&i2c->dev, "realtek,dmic-en")) - regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, - RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); - rt5651->irq = i2c->irq; rt5651->hp_mute = 1;
diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index f3158488fc89..7d9d5fa09d6f 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2080,4 +2080,6 @@ struct rt5651_priv { bool hp_mute; };
+void rt5651_apply_properties(struct snd_soc_component *component); + #endif /* __RT5651_H__ */
Configure the jack-detect source through a device-property which can be set by code outside of the codec driver. Rather then putting platform specific DMI quirks inside the generic codec driver.
And move the jack-detect-source quirk for the KIANO SlimNote 14.2, which was present inside the codec driver to the machine driver, where we can bundle it together with the other quirks already present for this laptop.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- Documentation/devicetree/bindings/sound/rt5651.txt | 6 ++++ include/sound/rt5651.h | 4 +++ sound/soc/codecs/rt5651.c | 31 ++++---------------- sound/soc/intel/boards/bytcr_rt5651.c | 34 ++++++++++++++++++---- 4 files changed, 44 insertions(+), 31 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/rt5651.txt b/Documentation/devicetree/bindings/sound/rt5651.txt index 3875233095f5..1632c0cf6123 100644 --- a/Documentation/devicetree/bindings/sound/rt5651.txt +++ b/Documentation/devicetree/bindings/sound/rt5651.txt @@ -16,6 +16,12 @@ Optional properties: - realtek,dmic-en Boolean. true if dmic is used.
+- realtek,jack-detect-source + u32. Valid values: + 1: Use JD1_1 pin for jack-dectect + 2: Use JD1_2 pin for jack-dectect + 3: Use JD2 pin for jack-dectect + Pins on the device (for linking into audio routes) for RT5651:
* DMIC L1 diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h index 1612462bf5ad..0eadb1e90a84 100644 --- a/include/sound/rt5651.h +++ b/include/sound/rt5651.h @@ -11,6 +11,10 @@ #ifndef __LINUX_SND_RT5651_H #define __LINUX_SND_RT5651_H
+/* + * Note the MUST match the values from the DT binding: + * Documentation/devicetree/bindings/sound/rt5651.txt + */ enum rt5651_jd_src { RT5651_JD_NULL, RT5651_JD1_1, diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 476e424b32ef..a555ae7cccb0 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -19,7 +19,6 @@ #include <linux/platform_device.h> #include <linux/spi/spi.h> #include <linux/acpi.h> -#include <linux/dmi.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -32,8 +31,6 @@ #include "rl6231.h" #include "rt5651.h"
-#define RT5651_JD_MAP(quirk) ((quirk) & GENMASK(7, 0)) - #define RT5651_DEVICE_ID_VALUE 0x6281
#define RT5651_PR_RANGE_BASE (0xff + 1) @@ -41,8 +38,6 @@
#define RT5651_PR_BASE (RT5651_PR_RANGE_BASE + (0 * RT5651_PR_SPACING))
-static unsigned long rt5651_quirk; - static const struct regmap_range_cfg rt5651_ranges[] = { { .name = "PR", .range_min = RT5651_PR_BASE, .range_max = RT5651_PR_BASE + 0xb4, @@ -1599,6 +1594,11 @@ static int rt5651_set_jack(struct snd_soc_component *component, struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); int ret; + u32 val; + + if (device_property_read_u32(component->dev, + "realtek,jack-detect-source", &val) == 0) + rt5651->jd_src = val;
if (!rt5651->irq) return -EINVAL; @@ -1824,24 +1824,6 @@ static const struct i2c_device_id rt5651_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id);
-static int rt5651_quirk_cb(const struct dmi_system_id *id) -{ - rt5651_quirk = (unsigned long) id->driver_data; - return 1; -} - -static const struct dmi_system_id rt5651_quirk_table[] = { - { - .callback = rt5651_quirk_cb, - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "KIANO"), - DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"), - }, - .driver_data = (unsigned long *) RT5651_JD1_1, - }, - {} -}; - static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); @@ -1920,9 +1902,6 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, rt5651);
- dmi_check_system(rt5651_quirk_table); - rt5651->jd_src = RT5651_JD_MAP(rt5651_quirk); - rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); if (IS_ERR(rt5651->regmap)) { ret = PTR_ERR(rt5651->regmap); diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 8008a027cc93..ccefe356d528 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -20,6 +20,7 @@ #include <linux/init.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/acpi.h> #include <linux/clk.h> #include <linux/device.h> @@ -42,10 +43,21 @@ enum { BYT_RT5651_IN3_MAP, };
-#define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(7, 0)) -#define BYT_RT5651_DMIC_EN BIT(16) -#define BYT_RT5651_MCLK_EN BIT(17) -#define BYT_RT5651_MCLK_25MHZ BIT(18) +enum { + BYT_RT5651_JD_NULL = (RT5651_JD_NULL << 4), + BYT_RT5651_JD1_1 = (RT5651_JD1_1 << 4), + BYT_RT5651_JD1_2 = (RT5651_JD1_2 << 4), + BYT_RT5651_JD2 = (RT5651_JD2 << 4), +}; + +#define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(3, 0)) +#define BYT_RT5651_JDSRC(quirk) (((quirk) & GENMASK(7, 4)) >> 4) +#define BYT_RT5651_DMIC_EN BIT(16) +#define BYT_RT5651_MCLK_EN BIT(17) +#define BYT_RT5651_MCLK_25MHZ BIT(18) + +/* jack-detect-source + terminating empty entry */ +#define MAX_NO_PROPS 2
struct byt_rt5651_private { struct clk *mclk; @@ -66,6 +78,9 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk IN2_MAP enabled"); if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN3_MAP) dev_info(dev, "quirk IN3_MAP enabled"); + if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) + dev_info(dev, "quirk jack-detect src %ld\n", + BYT_RT5651_JDSRC(byt_rt5651_quirk)); if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) dev_info(dev, "quirk DMIC enabled"); if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) @@ -288,6 +303,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"), }, .driver_data = (void *)(BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | BYT_RT5651_IN1_IN2_MAP), }, {} @@ -298,8 +314,9 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) struct snd_soc_card *card = runtime->card; struct snd_soc_component *codec = runtime->codec_dai->component; struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card); + struct property_entry props[MAX_NO_PROPS] = {}; const struct snd_soc_dapm_route *custom_map; - int num_routes; + int num_routes, no_props = 0; int ret;
card->dapm.idle_bias_off = true; @@ -360,6 +377,13 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) dev_err(card->dev, "unable to set MCLK rate\n"); }
+ props[no_props++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source", + BYT_RT5651_JDSRC(byt_rt5651_quirk)); + + ret = device_add_properties(codec->dev, props); + if (ret) + return ret; + ret = snd_soc_card_jack_new(runtime->card, "Headset", SND_JACK_HEADSET, &priv->jack, bytcr_jack_pins, ARRAY_SIZE(bytcr_jack_pins));
Before this commit it was possible to set the DMIC_EN quirk in the machine driver, but it would never be passed to the codec driver so it was a nop.
This commit adds code to actually pass the quirk to the codec driver.
Since the DMIC_EN quirk was ignored before, this commit removes it from the default quirk settings, to avoid this causing an unexpected functional change. If we really want the DMIC_EN behavior anywhere it should be specifically enabled by follow up commits.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- sound/soc/intel/boards/bytcr_rt5651.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index ccefe356d528..8f7a2e823f7f 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -56,8 +56,8 @@ enum { #define BYT_RT5651_MCLK_EN BIT(17) #define BYT_RT5651_MCLK_25MHZ BIT(18)
-/* jack-detect-source + terminating empty entry */ -#define MAX_NO_PROPS 2 +/* jack-detect-source + dmic-en + terminating empty entry */ +#define MAX_NO_PROPS 3
struct byt_rt5651_private { struct clk *mclk; @@ -65,7 +65,6 @@ struct byt_rt5651_private { };
static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC_MAP | - BYT_RT5651_DMIC_EN | BYT_RT5651_MCLK_EN;
static void log_quirks(struct device *dev) @@ -380,10 +379,15 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) props[no_props++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source", BYT_RT5651_JDSRC(byt_rt5651_quirk));
+ if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) + props[no_props++] = PROPERTY_ENTRY_BOOL("realtek,dmic-en"); + ret = device_add_properties(codec->dev, props); if (ret) return ret;
+ rt5651_apply_properties(codec); + ret = snd_soc_card_jack_new(runtime->card, "Headset", SND_JACK_HEADSET, &priv->jack, bytcr_jack_pins, ARRAY_SIZE(bytcr_jack_pins));
participants (2)
-
Hans de Goede
-
Mark Brown