mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 17:44:14 +08:00
Merge series "MFD/extcon/ASoC: Rework arizona codec jack-detect support" from Hans de Goede <hdegoede@redhat.com>:
Hi All, Here is v4 of my series to rework the arizona codec jack-detect support to use the snd_soc_jack helpers instead of direct extcon reporting. As discussed before here is a resend rebased on 5.12-rc2, making sure that all patches this depends on are in place. Lee, can you pick-up patches 1-6 through the MFD tree and then send a pull-req to Mark so that Mark can merge the Asoc parts throught the ASoC tree ? Patches 2-6 touch drivers/extcon, these all have an Ack from Chanwoo Choi for merging these through the MFD tree. Here is some more generic info on this series from the previous cover-letter: This is done by reworking the extcon driver into an arizona-jackdet library and then modifying the codec drivers to use that directly, replacing the old separate extcon child-devices and extcon-driver. This brings the arizona-codec jack-detect handling inline with how all other ASoC codec driver do this. This was developed and tested on a Lenovo Yoga Tablet 1051L with a WM5102 codec. This was also tested by Charles Keepax, one of the Cirrus Codec folks. Regards, Hans Hans de Goede (13): mfd: arizona: Drop arizona-extcon cells extcon: arizona: Fix some issues when HPDET IRQ fires after the jack has been unplugged extcon: arizona: Fix various races on driver unbind extcon: arizona: Fix flags parameter to the gpiod_get("wlf,micd-pol") call extcon: arizona: Always use pm_runtime_get_sync() when we need the device to be awake ASoC/extcon: arizona: Move arizona jack code to sound/soc/codecs/arizona-jack.c ASoC: arizona-jack: Move jack-detect variables to struct arizona_priv ASoC: arizona-jack: Use arizona->dev for runtime-pm ASoC: arizona-jack: convert into a helper library for codec drivers ASoC: arizona-jack: Use snd_soc_jack to report jack events ASoC: arizona-jack: Cleanup logging ASoC: arizona: Make the wm5102, wm5110, wm8997 and wm8998 drivers use the new jack library ASoC: Intel: bytcr_wm5102: Add jack detect support MAINTAINERS | 3 +- drivers/extcon/Kconfig | 8 - drivers/extcon/Makefile | 1 - drivers/mfd/arizona-core.c | 20 - sound/soc/codecs/Makefile | 2 +- .../soc/codecs/arizona-jack.c | 577 +++++++----------- sound/soc/codecs/arizona.h | 44 ++ sound/soc/codecs/wm5102.c | 12 +- sound/soc/codecs/wm5110.c | 12 +- sound/soc/codecs/wm8997.c | 14 +- sound/soc/codecs/wm8998.c | 9 + sound/soc/intel/boards/bytcr_wm5102.c | 28 +- 12 files changed, 325 insertions(+), 405 deletions(-) rename drivers/extcon/extcon-arizona.c => sound/soc/codecs/arizona-jack.c (76%) -- 2.30.1
This commit is contained in:
commit
3f994c2586
@ -43,7 +43,7 @@ snd-soc-ak4642-objs := ak4642.o
|
||||
snd-soc-ak4671-objs := ak4671.o
|
||||
snd-soc-ak5386-objs := ak5386.o
|
||||
snd-soc-ak5558-objs := ak5558.o
|
||||
snd-soc-arizona-objs := arizona.o
|
||||
snd-soc-arizona-objs := arizona.o arizona-jack.o
|
||||
snd-soc-bd28623-objs := bd28623.o
|
||||
snd-soc-bt-sco-objs := bt-sco.o
|
||||
snd-soc-cpcap-objs := cpcap.o
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -91,6 +91,41 @@ struct arizona_priv {
|
||||
unsigned int dvfs_reqs;
|
||||
struct mutex dvfs_lock;
|
||||
bool dvfs_cached;
|
||||
|
||||
/* Variables used by arizona-jack.c code */
|
||||
struct mutex lock;
|
||||
struct delayed_work hpdet_work;
|
||||
struct delayed_work micd_detect_work;
|
||||
struct delayed_work micd_timeout_work;
|
||||
struct snd_soc_jack *jack;
|
||||
struct regulator *micvdd;
|
||||
struct gpio_desc *micd_pol_gpio;
|
||||
|
||||
u16 last_jackdet;
|
||||
|
||||
int micd_mode;
|
||||
const struct arizona_micd_config *micd_modes;
|
||||
int micd_num_modes;
|
||||
|
||||
int micd_button_mask;
|
||||
const struct arizona_micd_range *micd_ranges;
|
||||
int num_micd_ranges;
|
||||
|
||||
bool micd_reva;
|
||||
bool micd_clamp;
|
||||
|
||||
bool hpdet_active;
|
||||
bool hpdet_done;
|
||||
bool hpdet_retried;
|
||||
|
||||
bool mic;
|
||||
bool detecting;
|
||||
|
||||
int num_hpdet_res;
|
||||
unsigned int hpdet_res[3];
|
||||
|
||||
int jack_flips;
|
||||
int hpdet_ip_version;
|
||||
};
|
||||
|
||||
struct arizona_voice_trigger_info {
|
||||
@ -222,6 +257,9 @@ extern unsigned int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
|
||||
#define ARIZONA_RATE_ENUM_SIZE 4
|
||||
#define ARIZONA_SAMPLE_RATE_ENUM_SIZE 14
|
||||
|
||||
/* SND_JACK_* mask for supported cable/switch types */
|
||||
#define ARIZONA_JACK_MASK (SND_JACK_HEADSET | SND_JACK_LINEOUT | SND_JACK_MECHANICAL)
|
||||
|
||||
extern const char * const arizona_rate_text[ARIZONA_RATE_ENUM_SIZE];
|
||||
extern const unsigned int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE];
|
||||
extern const char * const arizona_sample_rate_text[ARIZONA_SAMPLE_RATE_ENUM_SIZE];
|
||||
@ -351,4 +389,10 @@ static inline int arizona_unregister_notifier(struct snd_soc_component *componen
|
||||
|
||||
int arizona_of_get_audio_pdata(struct arizona *arizona);
|
||||
|
||||
int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev);
|
||||
int arizona_jack_codec_dev_remove(struct arizona_priv *info);
|
||||
|
||||
int arizona_jack_set_jack(struct snd_soc_component *component,
|
||||
struct snd_soc_jack *jack, void *data);
|
||||
|
||||
#endif
|
||||
|
@ -2004,6 +2004,7 @@ static const struct snd_soc_component_driver soc_component_dev_wm5102 = {
|
||||
.remove = wm5102_component_remove,
|
||||
.set_sysclk = arizona_set_sysclk,
|
||||
.set_pll = wm5102_set_fll,
|
||||
.set_jack = arizona_jack_set_jack,
|
||||
.name = DRV_NAME,
|
||||
.compress_ops = &wm5102_compress_ops,
|
||||
.controls = wm5102_snd_controls,
|
||||
@ -2057,6 +2058,11 @@ static int wm5102_probe(struct platform_device *pdev)
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
/* This may return -EPROBE_DEFER, so do this early on */
|
||||
ret = arizona_jack_codec_dev_probe(&wm5102->core, &pdev->dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(wm5102->fll); i++)
|
||||
wm5102->fll[i].vco_mult = 1;
|
||||
|
||||
@ -2089,7 +2095,7 @@ static int wm5102_probe(struct platform_device *pdev)
|
||||
wm5102);
|
||||
if (ret != 0) {
|
||||
dev_err(&pdev->dev, "Failed to request DSP IRQ: %d\n", ret);
|
||||
return ret;
|
||||
goto err_jack_codec_dev;
|
||||
}
|
||||
|
||||
ret = arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 1);
|
||||
@ -2123,6 +2129,8 @@ err_spk_irqs:
|
||||
err_dsp_irq:
|
||||
arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 0);
|
||||
arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, wm5102);
|
||||
err_jack_codec_dev:
|
||||
arizona_jack_codec_dev_remove(&wm5102->core);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -2141,6 +2149,8 @@ static int wm5102_remove(struct platform_device *pdev)
|
||||
arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 0);
|
||||
arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, wm5102);
|
||||
|
||||
arizona_jack_codec_dev_remove(&wm5102->core);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2370,6 +2370,7 @@ static const struct snd_soc_component_driver soc_component_dev_wm5110 = {
|
||||
.remove = wm5110_component_remove,
|
||||
.set_sysclk = arizona_set_sysclk,
|
||||
.set_pll = wm5110_set_fll,
|
||||
.set_jack = arizona_jack_set_jack,
|
||||
.name = DRV_NAME,
|
||||
.compress_ops = &wm5110_compress_ops,
|
||||
.controls = wm5110_snd_controls,
|
||||
@ -2424,6 +2425,11 @@ static int wm5110_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* This may return -EPROBE_DEFER, so do this early on */
|
||||
ret = arizona_jack_codec_dev_probe(&wm5110->core, &pdev->dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(wm5110->fll); i++)
|
||||
wm5110->fll[i].vco_mult = 3;
|
||||
|
||||
@ -2456,7 +2462,7 @@ static int wm5110_probe(struct platform_device *pdev)
|
||||
wm5110);
|
||||
if (ret != 0) {
|
||||
dev_err(&pdev->dev, "Failed to request DSP IRQ: %d\n", ret);
|
||||
return ret;
|
||||
goto err_jack_codec_dev;
|
||||
}
|
||||
|
||||
ret = arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 1);
|
||||
@ -2490,6 +2496,8 @@ err_spk_irqs:
|
||||
err_dsp_irq:
|
||||
arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 0);
|
||||
arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, wm5110);
|
||||
err_jack_codec_dev:
|
||||
arizona_jack_codec_dev_remove(&wm5110->core);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -2510,6 +2518,8 @@ static int wm5110_remove(struct platform_device *pdev)
|
||||
arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 0);
|
||||
arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, wm5110);
|
||||
|
||||
arizona_jack_codec_dev_remove(&wm5110->core);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1096,6 +1096,7 @@ static const struct snd_soc_component_driver soc_component_dev_wm8997 = {
|
||||
.remove = wm8997_component_remove,
|
||||
.set_sysclk = arizona_set_sysclk,
|
||||
.set_pll = wm8997_set_fll,
|
||||
.set_jack = arizona_jack_set_jack,
|
||||
.controls = wm8997_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(wm8997_snd_controls),
|
||||
.dapm_widgets = wm8997_dapm_widgets,
|
||||
@ -1132,6 +1133,11 @@ static int wm8997_probe(struct platform_device *pdev)
|
||||
|
||||
arizona_init_dvfs(&wm8997->core);
|
||||
|
||||
/* This may return -EPROBE_DEFER, so do this early on */
|
||||
ret = arizona_jack_codec_dev_probe(&wm8997->core, &pdev->dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(wm8997->fll); i++)
|
||||
wm8997->fll[i].vco_mult = 1;
|
||||
|
||||
@ -1163,10 +1169,10 @@ static int wm8997_probe(struct platform_device *pdev)
|
||||
|
||||
ret = arizona_init_vol_limit(arizona);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto err_jack_codec_dev;
|
||||
ret = arizona_init_spk_irqs(arizona);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto err_jack_codec_dev;
|
||||
|
||||
ret = devm_snd_soc_register_component(&pdev->dev,
|
||||
&soc_component_dev_wm8997,
|
||||
@ -1181,6 +1187,8 @@ static int wm8997_probe(struct platform_device *pdev)
|
||||
|
||||
err_spk_irqs:
|
||||
arizona_free_spk_irqs(arizona);
|
||||
err_jack_codec_dev:
|
||||
arizona_jack_codec_dev_remove(&wm8997->core);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1194,6 +1202,8 @@ static int wm8997_remove(struct platform_device *pdev)
|
||||
|
||||
arizona_free_spk_irqs(arizona);
|
||||
|
||||
arizona_jack_codec_dev_remove(&wm8997->core);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1316,6 +1316,7 @@ static const struct snd_soc_component_driver soc_component_dev_wm8998 = {
|
||||
.remove = wm8998_component_remove,
|
||||
.set_sysclk = arizona_set_sysclk,
|
||||
.set_pll = wm8998_set_fll,
|
||||
.set_jack = arizona_jack_set_jack,
|
||||
.controls = wm8998_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(wm8998_snd_controls),
|
||||
.dapm_widgets = wm8998_dapm_widgets,
|
||||
@ -1350,6 +1351,11 @@ static int wm8998_probe(struct platform_device *pdev)
|
||||
wm8998->core.arizona = arizona;
|
||||
wm8998->core.num_inputs = 3; /* IN1L, IN1R, IN2 */
|
||||
|
||||
/* This may return -EPROBE_DEFER, so do this early on */
|
||||
ret = arizona_jack_codec_dev_probe(&wm8998->core, &pdev->dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(wm8998->fll); i++)
|
||||
wm8998->fll[i].vco_mult = 1;
|
||||
|
||||
@ -1392,6 +1398,7 @@ err_spk_irqs:
|
||||
arizona_free_spk_irqs(arizona);
|
||||
err_pm_disable:
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
arizona_jack_codec_dev_remove(&wm8998->core);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1405,6 +1412,8 @@ static int wm8998_remove(struct platform_device *pdev)
|
||||
|
||||
arizona_free_spk_irqs(arizona);
|
||||
|
||||
arizona_jack_codec_dev_remove(&wm8998->core);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <sound/jack.h>
|
||||
#include <sound/pcm.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/soc.h>
|
||||
@ -31,6 +32,7 @@
|
||||
#define WM5102_MAX_SYSCLK_11025 45158400 /* max sysclk for 11.025K family */
|
||||
|
||||
struct byt_wm5102_private {
|
||||
struct snd_soc_jack jack;
|
||||
struct clk *mclk;
|
||||
struct gpio_desc *spkvdd_en_gpio;
|
||||
};
|
||||
@ -177,11 +179,23 @@ static const struct snd_kcontrol_new byt_wm5102_controls[] = {
|
||||
SOC_DAPM_PIN_SWITCH("Speaker"),
|
||||
};
|
||||
|
||||
static struct snd_soc_jack_pin byt_wm5102_pins[] = {
|
||||
{
|
||||
.pin = "Headphone",
|
||||
.mask = SND_JACK_HEADPHONE,
|
||||
},
|
||||
{
|
||||
.pin = "Headset Mic",
|
||||
.mask = SND_JACK_MICROPHONE,
|
||||
},
|
||||
};
|
||||
|
||||
static int byt_wm5102_init(struct snd_soc_pcm_runtime *runtime)
|
||||
{
|
||||
struct snd_soc_card *card = runtime->card;
|
||||
struct byt_wm5102_private *priv = snd_soc_card_get_drvdata(card);
|
||||
int ret;
|
||||
struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
|
||||
int ret, jack_type;
|
||||
|
||||
card->dapm.idle_bias_off = true;
|
||||
|
||||
@ -210,6 +224,18 @@ static int byt_wm5102_init(struct snd_soc_pcm_runtime *runtime)
|
||||
return ret;
|
||||
}
|
||||
|
||||
jack_type = ARIZONA_JACK_MASK | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
|
||||
SND_JACK_BTN_2 | SND_JACK_BTN_3;
|
||||
ret = snd_soc_card_jack_new(card, "Headset", jack_type,
|
||||
&priv->jack, byt_wm5102_pins,
|
||||
ARRAY_SIZE(byt_wm5102_pins));
|
||||
if (ret) {
|
||||
dev_err(card->dev, "Error creating jack: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
snd_soc_component_set_jack(component, &priv->jack, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user