ASoC: rt5645: Fix the electric noise due to the CBJ contacts floating
Subsystems (2)
Sasha Levin
maintainerPATCH 1/4 ASoC: rt5645: Fix the electric noise due to the CBJ contacts floating
From: Derek Fang <[email protected]>
[ Upstream commit 103abab975087e1f01b76fcb54c91dbb65dbc249 ]
The codec leaves tie combo jack's sleeve/ring2 to floating status default. It would cause electric noise while connecting the active speaker jack during boot or shutdown.
This patch requests a gpio to control the additional jack circuit to tie the contacts to the ground or floating.
--- sound/soc/codecs/rt5645.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
sound/soc/codecs/rt5645.c +25 -0
@@ -412,6 +412,7 @@ struct rt5645_priv {struct regmap *regmap;struct i2c_client *i2c;struct gpio_desc *gpiod_hp_det; +struct gpio_desc *gpiod_cbj_sleeve;struct snd_soc_jack *hp_jack;struct snd_soc_jack *mic_jack;struct snd_soc_jack *btn_jack;
@@ -3206,6 +3207,9 @@ static int rt5645_jack_detect(struct snd_soc_component *component, int jack_inseregmap_update_bits (rt5645->regmap,RT5645_IN1_CTRL2 ,RT5645_CBJ_MN_JD ,0 ); +if (rt5645->gpiod_cbj_sleeve) +gpiod_set_value (rt5645->gpiod_cbj_sleeve,1 ); +msleep (600 );regmap_read (rt5645->regmap,RT5645_IN1_CTRL3 , &val); val &=0x7 ;
@@ -3222,6 +3226,8 @@ static int rt5645_jack_detect(struct snd_soc_component *component, int jack_insesnd_soc_dapm_disable_pin (dapm,"Mic Det Power" );snd_soc_dapm_sync (dapm); rt5645->jack_type =SND_JACK_HEADPHONE ; +if (rt5645->gpiod_cbj_sleeve) +gpiod_set_value (rt5645->gpiod_cbj_sleeve,0 ); }if (rt5645->pdata.level_trigger_irq) regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
@@ -3247,6 +3253,9 @@ static int rt5645_jack_detect(struct snd_soc_component *component, int jack_inseif (rt5645->pdata.level_trigger_irq)regmap_update_bits (rt5645->regmap,RT5645_IRQ_CTRL2 ,RT5645_JD_1_1_MASK ,RT5645_JD_1_1_INV ); + +if (rt5645->gpiod_cbj_sleeve) +gpiod_set_value (rt5645->gpiod_cbj_sleeve,0 ); }return rt5645->jack_type;
@@ -3892,6 +3901,16 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,return ret; } + rt5645->gpiod_cbj_sleeve =devm_gpiod_get_optional (&i2c->dev,"cbj-sleeve" , +GPIOD_OUT_LOW ); + +if (IS_ERR (rt5645->gpiod_cbj_sleeve)) { + ret =PTR_ERR (rt5645->gpiod_cbj_sleeve); +dev_info (&i2c->dev,"failed to initialize gpiod, ret=%d\n" , ret); +if (ret != -ENOENT ) +return ret; + } +for (i =0 ; i <ARRAY_SIZE (rt5645->supplies); i++) rt5645->supplies[i].supply = rt5645_supply_names[i];
@@ -4135,6 +4154,9 @@ static int rt5645_i2c_remove(struct i2c_client *i2c)cancel_delayed_work_sync (&rt5645->jack_detect_work);cancel_delayed_work_sync (&rt5645->rcclock_work); +if (rt5645->gpiod_cbj_sleeve) +gpiod_set_value (rt5645->gpiod_cbj_sleeve,0 ); +regulator_bulk_disable (ARRAY_SIZE (rt5645->supplies), rt5645->supplies);return 0 ;
@@ -4152,6 +4174,9 @@ static void rt5645_i2c_shutdown(struct i2c_client *i2c) 0);msleep (20 );regmap_write (rt5645->regmap,RT5645_RESET ,0 ); + +if (rt5645->gpiod_cbj_sleeve) +gpiod_set_value (rt5645->gpiod_cbj_sleeve,0 ); }static struct i2c_driver rt5645_i2c_driver = {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/4 ASoC: dt-bindings: rt5645: add cbj sleeve gpio property
From: Derek Fang <[email protected]>
[ Upstream commit 306b38e3fa727d22454a148a364123709e356600 ]
Add an optional gpio property to control external CBJ circuits to avoid some electric noise caused by sleeve/ring2 contacts floating.
--- Documentation/devicetree/bindings/sound/rt5645.txt | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/sound/rt5645.txt +6 -0
@@ -16,6 +16,11 @@ Optional properties: a GPIO spec for the external headphone detect pin. If jd-mode = 0, we will get the JD status by getting the value of hp-detect-gpios. +- cbj-sleeve-gpios: + a GPIO spec to control the external combo jack circuit to tie the sleeve/ring2 + contacts to the ground or floating. It could avoid some electric noise from the + active speaker jacks. + - realtek,in2-differential Boolean. Indicate MIC2 input are differential, rather than single-ended.
@@ -64,6 +69,7 @@ codec: rt5650@1a { compatible = "realtek,rt5650"; reg = <0x1a>; hp-detect-gpios = <&gpio 19 0>; + cbj-sleeve-gpios = <&gpio 20 0>; interrupt-parent = <&gpio>; interrupts = <7 IRQ_TYPE_EDGE_FALLING>; realtek,dmic-en = "true";
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/4 firewire: nosy: ensure user_length is taken into account when fetching packet contents
In reply to Sasha LevinFrom: Thanassis Avgerinos <[email protected]>
[ Upstream commit 38762a0763c10c24a4915feee722d7aa6e73eb98 ]
Ensure that packet_buffer_get respects the user_length provided. If the length of the head packet exceeds the user_length, packet_buffer_get will now return 0 to signify to the user that no data were read and a larger buffer size is required. Helps prevent user space overflows.
--- drivers/firewire/nosy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/firewire/nosy.c +4 -2
@@ -161,10 +161,12 @@ packet_buffer_get(struct client *client, char __user *data, size_t user_length)if (atomic_read (&buffer->size) ==0 )return -ENODEV ; -/* FIXME: Check length <= user_length. */ + length = buffer->head->length; + +if (length > user_length) +return 0 ; end = buffer->data + buffer->capacity; - length = buffer->head->length;if (&buffer->head->data[length] < end) {if (copy_to_user (data, buffer->head->data, length))
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/4 ASoC: da7219-aad: fix usage of device_get_named_child_node()
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit e8a6a5ad73acbafd98e8fd3f0cbf6e379771bb76 ]
The documentation for device_get_named_child_node() mentions this important point:
"
The caller is responsible for calling fwnode_handle_put() on the returned fwnode pointer.
"
Add fwnode_handle_put() to avoid a leaked reference.
--- sound/soc/codecs/da7219-aad.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/codecs/da7219-aad.c +5 -1
@@ -634,8 +634,10 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_componentreturn NULL ; aad_pdata =devm_kzalloc (dev,sizeof (*aad_pdata),GFP_KERNEL ); -if (!aad_pdata) +if (!aad_pdata) { +fwnode_handle_put (aad_np);return NULL ; + } aad_pdata->irq = i2c->irq;
@@ -710,6 +712,8 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_componentelse aad_pdata->adc_1bit_rpt =DA7219_AAD_ADC_1BIT_RPT_1 ; +fwnode_handle_put (aad_np); +return aad_pdata; }
Signature · 1 line
2.43.0