From e5ec404571f67257faaaf2cebeb4abaec7cdb037 Mon Sep 17 00:00:00 2001 From: Xing Zheng Date: Mon, 24 Jun 2019 18:34:48 +0800 Subject: [PATCH] ASoC: multicodecs&rk3308_codec: handle the request during no codec instance and hp det If there is no codec instance or headphone jack, we should not request headphone jack from machine driver. Change-Id: If05ac2f4bbfd3fc495a75c0701a44a325e5010cd Signed-off-by: Xing Zheng --- sound/soc/codecs/rk3308_codec.c | 12 ++++++++++-- sound/soc/codecs/rk3308_codec_provider.h | 9 ++------- sound/soc/rockchip/rockchip_multicodecs.c | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/rk3308_codec.c b/sound/soc/codecs/rk3308_codec.c index 82eeedf1fe4c..aadcd7f698fb 100644 --- a/sound/soc/codecs/rk3308_codec.c +++ b/sound/soc/codecs/rk3308_codec.c @@ -4251,7 +4251,11 @@ static irqreturn_t rk3308_codec_hpdet_isr(int irq, void *data) return IRQ_HANDLED; } -void rk3308_codec_set_jack_detect(struct snd_soc_codec *codec, +void (*rk3308_codec_set_jack_detect_cb)(struct snd_soc_codec *codec, + struct snd_soc_jack *hpdet_jack); +EXPORT_SYMBOL_GPL(rk3308_codec_set_jack_detect_cb); + +static void rk3308_codec_set_jack_detect(struct snd_soc_codec *codec, struct snd_soc_jack *hpdet_jack) { struct rk3308_codec_priv *rk3308 = snd_soc_codec_get_drvdata(codec); @@ -4262,8 +4266,10 @@ void rk3308_codec_set_jack_detect(struct snd_soc_codec *codec, disable_irq_nosync(rk3308->irq); queue_delayed_work(system_power_efficient_wq, &rk3308->hpdet_work, msecs_to_jiffies(10)); + + dev_info(rk3308->plat_dev, "%s: Request detect hp jack once\n", + __func__); } -EXPORT_SYMBOL_GPL(rk3308_codec_set_jack_detect); static const struct regmap_config rk3308_codec_regmap_config = { .reg_bits = 32, @@ -4964,6 +4970,8 @@ static int rk3308_platform_probe(struct platform_device *pdev) (HPDET_BOTH_NEG_POS << 16) | HPDET_BOTH_NEG_POS); } + + rk3308_codec_set_jack_detect_cb = rk3308_codec_set_jack_detect; } if (rk3308->codec_ver == ACODEC_VERSION_A) diff --git a/sound/soc/codecs/rk3308_codec_provider.h b/sound/soc/codecs/rk3308_codec_provider.h index a447f3a92ff4..68042b1328dc 100644 --- a/sound/soc/codecs/rk3308_codec_provider.h +++ b/sound/soc/codecs/rk3308_codec_provider.h @@ -21,13 +21,8 @@ #define __RK3308_CODEC_PROVIDER_H__ #ifdef CONFIG_SND_SOC_RK3308 -void rk3308_codec_set_jack_detect(struct snd_soc_codec *codec, - struct snd_soc_jack *hpdet_jack); -#else -static inline void rk3308_codec_set_jack_detect(struct snd_soc_codec *codec, - struct snd_soc_jack *hpdet_jack) -{ -} +extern void (*rk3308_codec_set_jack_detect_cb)(struct snd_soc_codec *codec, + struct snd_soc_jack *hpdet_jack); #endif #endif /* __RK3308_CODEC_PROVIDER_H__ */ diff --git a/sound/soc/rockchip/rockchip_multicodecs.c b/sound/soc/rockchip/rockchip_multicodecs.c index 517d081abac8..bf42850ef302 100644 --- a/sound/soc/rockchip/rockchip_multicodecs.c +++ b/sound/soc/rockchip/rockchip_multicodecs.c @@ -87,7 +87,8 @@ static int rk_dailink_init(struct snd_soc_pcm_runtime *rtd) &mc_hp_jack, NULL, 0); #ifdef CONFIG_SND_SOC_RK3308 - rk3308_codec_set_jack_detect(rtd->codec, &mc_hp_jack); + if (rk3308_codec_set_jack_detect_cb) + rk3308_codec_set_jack_detect_cb(rtd->codec, &mc_hp_jack); #endif }