ASoC: cs42l42: Add support for set_jack calls
Subsystems (3)
PATCH 1/3 ASoC: cs42l42: Add support for set_jack calls
Replace the internal jack creation by set_jack call, so users can map buttons in their machine driver
Also only enable jack detection IRQ after set_jack call
--- sound/soc/codecs/cs42l42.c | 43 ++++++++++++++++++++++---------------- sound/soc/codecs/cs42l42.h | 2 +- 2 files changed, 26 insertions(+), 19 deletions(-)
sound/soc/codecs/cs42l42.c +25 -18
@@ -518,26 +518,33 @@ static const struct snd_soc_dapm_route cs42l42_audio_map[] = { { "SDOUT2", NULL, "ASP TX EN" }, }; +static int cs42l42_set_jack (struct snd_soc_component *component,struct snd_soc_jack *jk,void *d) +{ +struct cs42l42_private *cs42l42 =snd_soc_component_get_drvdata (component); + + cs42l42->jack = jk; + +regmap_update_bits (cs42l42->regmap,CS42L42_TSRS_PLUG_INT_MASK , +CS42L42_RS_PLUG_MASK |CS42L42_RS_UNPLUG_MASK | +CS42L42_TS_PLUG_MASK |CS42L42_TS_UNPLUG_MASK , + (1 <<CS42L42_RS_PLUG_SHIFT ) | (1 <<CS42L42_RS_UNPLUG_SHIFT ) | + (0 <<CS42L42_TS_PLUG_SHIFT ) | (0 <<CS42L42_TS_UNPLUG_SHIFT )); + +return 0 ; +} +static int cs42l42_component_probe (struct snd_soc_component *component) { -struct cs42l42_private *cs42l42 = - (struct cs42l42_private *)snd_soc_component_get_drvdata (component); -struct snd_soc_card *crd = component->card; -int ret =0 ; +struct cs42l42_private *cs42l42 =snd_soc_component_get_drvdata (component); cs42l42->component = component; - ret =snd_soc_card_jack_new (crd,"CS42L42 Headset" ,SND_JACK_HEADSET |SND_JACK_BTN_0 | -SND_JACK_BTN_1 |SND_JACK_BTN_2 |SND_JACK_BTN_3 , - &cs42l42->jack,NULL ,0 ); -if (ret <0 ) -dev_err (component->dev,"Cannot create CS42L42 Headset: %d\n" , ret); - -return ret; +return 0 ; }static const struct snd_soc_component_driver soc_component_dev_cs42l42 = { .probe = cs42l42_component_probe, + .set_jack = cs42l42_set_jack, .dapm_widgets = cs42l42_dapm_widgets, .num_dapm_widgets =ARRAY_SIZE (cs42l42_dapm_widgets), .dapm_routes = cs42l42_audio_map,
@@ -1410,11 +1417,11 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data)switch (cs42l42->hs_type){case CS42L42_PLUG_CTIA :case CS42L42_PLUG_OMTP : -snd_soc_jack_report (&cs42l42->jack,SND_JACK_HEADSET , +snd_soc_jack_report (cs42l42->jack,SND_JACK_HEADSET ,SND_JACK_HEADSET );break ;case CS42L42_PLUG_HEADPHONE : -snd_soc_jack_report (&cs42l42->jack,SND_JACK_HEADPHONE , +snd_soc_jack_report (cs42l42->jack,SND_JACK_HEADPHONE ,SND_JACK_HEADPHONE );break ;default :
@@ -1442,10 +1449,10 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data)switch (cs42l42->hs_type){case CS42L42_PLUG_CTIA :case CS42L42_PLUG_OMTP : -snd_soc_jack_report (&cs42l42->jack,0 ,SND_JACK_HEADSET ); +snd_soc_jack_report (cs42l42->jack,0 ,SND_JACK_HEADSET );break ;case CS42L42_PLUG_HEADPHONE : -snd_soc_jack_report (&cs42l42->jack,0 ,SND_JACK_HEADPHONE ); +snd_soc_jack_report (cs42l42->jack,0 ,SND_JACK_HEADPHONE );break ;default :break ;
@@ -1472,7 +1479,7 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) report =cs42l42_handle_button_press (cs42l42); } -snd_soc_jack_report (&cs42l42->jack, report,SND_JACK_BTN_0 |SND_JACK_BTN_1 | +snd_soc_jack_report (cs42l42->jack, report,SND_JACK_BTN_0 |SND_JACK_BTN_1 |SND_JACK_BTN_2 |SND_JACK_BTN_3 ); } }
@@ -1579,8 +1586,8 @@ static void cs42l42_set_interrupt_masks(struct cs42l42_private *cs42l42)CS42L42_TS_UNPLUG_MASK , (1 <<CS42L42_RS_PLUG_SHIFT ) | (1 <<CS42L42_RS_UNPLUG_SHIFT ) | - (0 <<CS42L42_TS_PLUG_SHIFT ) | - (0 << CS42L42_TS_UNPLUG_SHIFT)); + (1 <<CS42L42_TS_PLUG_SHIFT ) | + (1 << CS42L42_TS_UNPLUG_SHIFT)); }static void cs42l42_setup_hs_type_detect (struct cs42l42_private *cs42l42)
sound/soc/codecs/cs42l42.h +1 -1
@@ -773,7 +773,7 @@ struct cs42l42_private {struct regulator_bulk_data supplies[CS42L42_NUM_SUPPLIES ];struct gpio_desc *reset_gpio;struct completion pdn_done; -struct snd_soc_jack jack; +struct snd_soc_jack *jack;int bclk;u32 sclk;u32 srate;
--
2.31.1
PATCH 2/3 ASoC: cs42l42: Use device_property API instead of of_property
From: Richard Fitzgerald <[email protected]>
Use the device_property APIs so that the code will work on devicetree and ACPI systems.
--- sound/soc/codecs/cs42l42.c | 60 +++++++++++++++----------------------- 1 file changed, 24 insertions(+), 36 deletions(-)
sound/soc/codecs/cs42l42.c +24 -36
@@ -20,10 +20,9 @@#include <linux/regmap.h> #include <linux/slab.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/regulator/consumer.h> #include <linux/gpio/consumer.h> -#include <linux/of.h> -#include <linux/of_gpio.h> #include <linux/of_device.h> #include <linux/pm_runtime.h> #include <sound/core.h>
@@ -1637,17 +1636,15 @@ static const unsigned int threshold_defaults[] = { CS42L42_HS_DET_LEVEL_1 }; -static int cs42l42_handle_device_data (struct i2c_client *i2c_client, +static int cs42l42_handle_device_data (struct device *dev,struct cs42l42_private *cs42l42) { -struct device_node *np = i2c_client->dev.of_node;unsigned int val; -unsigned int thresholds[CS42L42_NUM_BIASES ]; +u32 thresholds[CS42L42_NUM_BIASES ];int ret;int i; - ret =of_property_read_u32 (np,"cirrus,ts-inv" , &val); - + ret =device_property_read_u32 (dev,"cirrus,ts-inv" , &val);if (!ret) {switch (val) {case CS42L42_TS_INV_EN :
@@ -1655,7 +1652,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, cs42l42->ts_inv = val;break ;default : -dev_err (&i2c_client->dev, +dev_err (dev,"Wrong cirrus,ts-inv DT value %d\n" , val); cs42l42->ts_inv =CS42L42_TS_INV_DIS ;
@@ -1668,8 +1665,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client,CS42L42_TS_INV_MASK , (cs42l42->ts_inv << CS42L42_TS_INV_SHIFT)); - ret =of_property_read_u32 (np,"cirrus,ts-dbnc-rise" , &val); - + ret =device_property_read_u32 (dev,"cirrus,ts-dbnc-rise" , &val);if (!ret) {switch (val) {case CS42L42_TS_DBNCE_0 :
@@ -1683,7 +1679,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, cs42l42->ts_dbnc_rise = val;break ;default : -dev_err (&i2c_client->dev, +dev_err (dev,"Wrong cirrus,ts-dbnc-rise DT value %d\n" , val); cs42l42->ts_dbnc_rise =CS42L42_TS_DBNCE_1000 ;
@@ -1697,8 +1693,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, (cs42l42->ts_dbnc_rise << CS42L42_TS_RISE_DBNCE_TIME_SHIFT)); - ret =of_property_read_u32 (np,"cirrus,ts-dbnc-fall" , &val); - + ret =device_property_read_u32 (dev,"cirrus,ts-dbnc-fall" , &val);if (!ret) {switch (val) {case CS42L42_TS_DBNCE_0 :
@@ -1712,7 +1707,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, cs42l42->ts_dbnc_fall = val;break ;default : -dev_err (&i2c_client->dev, +dev_err (dev,"Wrong cirrus,ts-dbnc-fall DT value %d\n" , val); cs42l42->ts_dbnc_fall =CS42L42_TS_DBNCE_0 ;
@@ -1726,13 +1721,12 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, (cs42l42->ts_dbnc_fall << CS42L42_TS_FALL_DBNCE_TIME_SHIFT)); - ret =of_property_read_u32 (np,"cirrus,btn-det-init-dbnce" , &val); - + ret =device_property_read_u32 (dev,"cirrus,btn-det-init-dbnce" , &val);if (!ret) {if (val <=CS42L42_BTN_DET_INIT_DBNCE_MAX ) cs42l42->btn_det_init_dbnce = val;else { -dev_err (&i2c_client->dev, +dev_err (dev,"Wrong cirrus,btn-det-init-dbnce DT value %d\n" , val); cs42l42->btn_det_init_dbnce =
@@ -1743,14 +1737,13 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client,CS42L42_BTN_DET_INIT_DBNCE_DEFAULT ; } - ret =of_property_read_u32 (np,"cirrus,btn-det-event-dbnce" , &val); - + ret =device_property_read_u32 (dev,"cirrus,btn-det-event-dbnce" , &val);if (!ret) {if (val <=CS42L42_BTN_DET_EVENT_DBNCE_MAX ) cs42l42->btn_det_event_dbnce = val;else { -dev_err (&i2c_client->dev, -"Wrong cirrus,btn-det-event-dbnce DT value %d\n" , val); +dev_err (dev, +"Wrong cirrus,btn-det-event-dbnce DT value %d\n" , val); cs42l42->btn_det_event_dbnce =CS42L42_BTN_DET_EVENT_DBNCE_DEFAULT ; }
@@ -1759,19 +1752,17 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client,CS42L42_BTN_DET_EVENT_DBNCE_DEFAULT ; } - ret =of_property_read_u32_array (np,"cirrus,bias-lvls" , - (u32 *)thresholds,CS42L42_NUM_BIASES ); - + ret =device_property_read_u32_array (dev,"cirrus,bias-lvls" , + thresholds,ARRAY_SIZE (thresholds));if (!ret) {for (i =0 ; i <CS42L42_NUM_BIASES ; i++) {if (thresholds[i] <=CS42L42_HS_DET_LEVEL_MAX ) cs42l42->bias_thresholds[i] = thresholds[i];else { -dev_err (&i2c_client->dev, -"Wrong cirrus,bias-lvls[%d] DT value %d\n" , i, +dev_err (dev, +"Wrong cirrus,bias-lvls[%d] DT value %d\n" , i, thresholds[i]); - cs42l42->bias_thresholds[i] = - threshold_defaults[i]; + cs42l42->bias_thresholds[i] = threshold_defaults[i]; } } }else {
@@ -1779,8 +1770,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, cs42l42->bias_thresholds[i] = threshold_defaults[i]; } - ret =of_property_read_u32 (np,"cirrus,hs-bias-ramp-rate" , &val); - + ret =device_property_read_u32 (dev,"cirrus,hs-bias-ramp-rate" , &val);if (!ret) {switch (val) {case CS42L42_HSBIAS_RAMP_FAST_RISE_SLOW_FALL :
@@ -1800,7 +1790,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, cs42l42->hs_bias_ramp_time =CS42L42_HSBIAS_RAMP_TIME3 ;break ;default : -dev_err (&i2c_client->dev, +dev_err (dev,"Wrong cirrus,hs-bias-ramp-rate DT value %d\n" , val); cs42l42->hs_bias_ramp_rate =CS42L42_HSBIAS_RAMP_SLOW ;
@@ -1930,11 +1920,9 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client, (1 <<CS42L42_ADC_PDN_SHIFT ) | (0 << CS42L42_PDN_ALL_SHIFT)); -if (i2c_client->dev.of_node) { - ret =cs42l42_handle_device_data (i2c_client, cs42l42); -if (ret !=0 ) - goto err_disable; - } + ret =cs42l42_handle_device_data (&i2c_client->dev, cs42l42); +if (ret !=0 ) + goto err_disable;/* Setup headset detection */ cs42l42_setup_hs_type_detect (cs42l42);
--
2.31.1
PATCH 3/3 ASoC: cs42l42: Add support for ACPI table match entry
In reply to Lucas TanureFrom: Vitaly Rodionov <[email protected]>
Adding support for ACPI-based systems.
--- sound/soc/codecs/cs42l42.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
sound/soc/codecs/cs42l42.c +13 -2
@@ -19,6 +19,7 @@#include <linux/gpio.h> #include <linux/regmap.h> #include <linux/slab.h> +#include <linux/acpi.h> #include <linux/platform_device.h> #include <linux/property.h> #include <linux/regulator/consumer.h>
@@ -2001,12 +2002,21 @@ static const struct dev_pm_ops cs42l42_runtime_pm = { NULL) }; +#ifdef CONFIG_OF static const struct of_device_id cs42l42_of_match[] = { { .compatible ="cirrus,cs42l42" , }, - {}, + {} };MODULE_DEVICE_TABLE (of, cs42l42_of_match); +#endif +#ifdef CONFIG_ACPI +static const struct acpi_device_id cs42l42_acpi_match[] = { + {"10134242" ,0 ,}, + {} +}; +MODULE_DEVICE_TABLE (acpi, cs42l42_acpi_match); +#endif static const struct i2c_device_id cs42l42_id[] = { {"cs42l42" ,0 },
@@ -2019,7 +2029,8 @@ static struct i2c_driver cs42l42_i2c_driver = { .driver = { .name = "cs42l42", .pm = &cs42l42_runtime_pm, - .of_match_table = cs42l42_of_match, + .of_match_table = of_match_ptr(cs42l42_of_match), + .acpi_match_table =ACPI_PTR (cs42l42_acpi_match), }, .id_table = cs42l42_id, .probe = cs42l42_i2c_probe,
--
2.31.1
Mark Brown
maintainerQuoted 3 lines · Lucas Tanure
Replace the internal jack creation by
set_jackcall, so users can map buttons in their machine driver
Also only enable jack detection IRQ afterset_jackcall
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/3] ASoC: cs42l42: Add support for set_jack calls
commit: c26a5289e86597e8826ad3093ad71ca0d5d9510a
[2/3] ASoC: cs42l42: Use device_property API instead of of_property
commit: ab78322a0dc8e5e472ff66ac7e18c94acc17587f
[3/3] ASoC: cs42l42: Add support for ACPI table match entry
commit: 66df9477bd35dd851e9803e5fdbbf40ee4598af5All 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