Unverified Commit 3f994c25 authored by Mark Brown's avatar Mark Brown
Browse files

Merge series "MFD/extcon/ASoC: Rework arizona codec jack-detect support" from...

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
parents b5cf28f7 ecd77d49
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+191 −353

File changed.

Preview size limit exceeded, changes collapsed.

+44 −0
Original line number Diff line number Diff line
@@ -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
+11 −1
Original line number Diff line number Diff line
@@ -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 @@ static int wm5102_probe(struct platform_device *pdev)
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;
}

+11 −1
Original line number Diff line number Diff line
@@ -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 @@ static int wm5110_probe(struct platform_device *pdev)
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;
}

Loading