ASoC: rt5651: Drop pdata, move over to device-properties
Subsystems (5)
cover 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
RFC 1/7 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.
--- include/sound/rt5651.h | 8 -------- sound/soc/codecs/rt5651.c | 47 +++++++++-------------------------------------- sound/soc/codecs/rt5651.h | 2 +- 3 files changed, 10 insertions(+), 47 deletions(-)
include/sound/rt5651.h +0 -8
@@ -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
sound/soc/codecs/rt5651.c +9 -38
108 lines not on this page · raw message
sound/soc/codecs/rt5651.h +1 -1
@@ -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;
Signature · 1 line
2.14.3
Mark Brown
maintainerApplied "ASoC: rt5651: Remove unused rt5651_platform_data" to the asoc tree
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
Quoted 1 line
From
54e3a3a152a6f466f3a94b28be10f08b86905bc0Mon Sep 17 00:00:00 2001
From: Hans de Goede <[email protected]>
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.
--- include/sound/rt5651.h | 8 -------- sound/soc/codecs/rt5651.c | 47 +++++++++-------------------------------------- sound/soc/codecs/rt5651.h | 2 +- 3 files changed, 10 insertions(+), 47 deletions(-)
include/sound/rt5651.h +0 -8
@@ -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
sound/soc/codecs/rt5651.c +9 -38
108 lines not on this page · raw message
sound/soc/codecs/rt5651.h +1 -1
@@ -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;
Signature · 1 line
2.16.2
RFC 2/7 ASoC: rt5651: Move all jack-detect initialization to rt5651_set_jack_detect
In reply to Hans de GoedeMove 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.
--- sound/soc/codecs/rt5651.c | 118 ++++++++++++++++++++++------------------------ sound/soc/codecs/rt5651.h | 1 + 2 files changed, 57 insertions(+), 62 deletions(-)
sound/soc/codecs/rt5651.c +56 -62
@@ -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));
sound/soc/codecs/rt5651.h +1 -0
@@ -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 ];
Signature · 1 line
2.14.3
RFC 3/7 ASoC: rt5651: Move 2 functions higher up in rt5651.c
In reply to Hans de GoedeMove 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.
--- sound/soc/codecs/rt5651.c | 152 +++++++++++++++++++++++----------------------- 1 file changed, 76 insertions(+), 76 deletions(-)
sound/soc/codecs/rt5651.c +76 -76
@@ -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) {
Signature · 1 line
2.14.3
RFC 4/7 ASoC: rt5651: Use standard component set_jack callback
In reply to Hans de GoedeUse the standard component set_jack callback instead of defining a codec private API for this.
--- 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(-)
sound/soc/codecs/rt5651.c +3 -3
@@ -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,
sound/soc/codecs/rt5651.h +0 -2
@@ -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__ */
sound/soc/intel/boards/bytcr_rt5651.c +1 -1
@@ -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; }
Signature · 1 line
2.14.3
Mark Brown
maintainerApplied "ASoC: rt5651: Use standard component set_jack callback" to the asoc tree
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
Quoted 1 line
From
6f0b819ae2b36614a514824c622ac0e02650b718Mon Sep 17 00:00:00 2001
From: Hans de Goede <[email protected]>
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.
--- 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(-)
sound/soc/codecs/rt5651.c +3 -3
@@ -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,
sound/soc/codecs/rt5651.h +0 -2
@@ -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__ */
sound/soc/intel/boards/bytcr_rt5651.c +1 -1
@@ -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; }
Signature · 1 line
2.16.2
RFC 5/7 ASoC: rt5651: Add rt5651_apply_properties() helper function
In reply to Hans de GoedeMove 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.
--- sound/soc/codecs/rt5651.c | 21 +++++++++++++-------- sound/soc/codecs/rt5651.h | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-)
sound/soc/codecs/rt5651.c +13 -8
@@ -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 ;
sound/soc/codecs/rt5651.h +2 -0
@@ -2080,4 +2080,6 @@ struct rt5651_priv { bool hp_mute; }; +void rt5651_apply_properties (struct snd_soc_component *component); +#endif /* __RT5651_H__ */
Signature · 1 line
2.14.3
RFC 6/7 ASoC: rt5651: Configure jack-detect source through a device-property
In reply to Hans de GoedeConfigure 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.
--- 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(-)
Documentation/devicetree/bindings/sound/rt5651.txt +6 -0
@@ -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
include/sound/rt5651.h +4 -0
@@ -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,
sound/soc/codecs/rt5651.c +5 -26
@@ -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);
sound/soc/intel/boards/bytcr_rt5651.c +29 -5
@@ -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 2struct 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));
Signature · 1 line
2.14.3
RFC 7/7 ASoC: Intel: bytcr_rt5651: Actually honor the DMIC_EN quirk if specified
In reply to Hans de GoedeBefore 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.
--- sound/soc/intel/boards/bytcr_rt5651.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/intel/boards/bytcr_rt5651.c +7 -3
@@ -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 3struct 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));
Signature · 1 line
2.14.3