From 1851402c8e8e035a6204e02ab5354fa5b27dcf5f Mon Sep 17 00:00:00 2001 From: Xing Zheng Date: Tue, 15 May 2018 15:50:26 +0800 Subject: [PATCH] ASoC: rk3308_codec: set hpdet_jack from machine driver The hpdet_jack should be set from external machine driver. Change-Id: I5f7e154c084434fa730c2a9ff505bfaa4e404a5f Signed-off-by: Xing Zheng --- sound/soc/codecs/rk3308_codec.c | 19 +++++++++++--- sound/soc/codecs/rk3308_codec_provider.h | 33 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 sound/soc/codecs/rk3308_codec_provider.h diff --git a/sound/soc/codecs/rk3308_codec.c b/sound/soc/codecs/rk3308_codec.c index 056cced3bc8f..5fb9a243de45 100644 --- a/sound/soc/codecs/rk3308_codec.c +++ b/sound/soc/codecs/rk3308_codec.c @@ -43,6 +43,7 @@ #include #include "rk3308_codec.h" +#include "rk3308_codec_provider.h" #if defined(CONFIG_DEBUG_FS) #include @@ -83,6 +84,7 @@ struct rk3308_codec_priv { struct clk *mclk_tx; struct gpio_desc *hp_ctl_gpio; struct gpio_desc *spk_ctl_gpio; + struct snd_soc_jack *hpdet_jack; int irq; /* * To select ADCs for groups: @@ -2345,9 +2347,11 @@ static void rk3308_codec_hpdetect_work(struct work_struct *work) dac_output = DAC_HPOUT; rk3308_codec_dac_switch(rk3308, dac_output); - snd_soc_jack_report(asoc_simple_card_get_hp_jack(), - report_type, - SND_JACK_HEADPHONE); + + if (rk3308->hpdet_jack) + snd_soc_jack_report(rk3308->hpdet_jack, + report_type, + SND_JACK_HEADPHONE); } if (need_irq) @@ -2369,6 +2373,15 @@ 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, + struct snd_soc_jack *hpdet_jack) +{ + struct rk3308_codec_priv *rk3308 = snd_soc_codec_get_drvdata(codec); + + rk3308->hpdet_jack = hpdet_jack; +} +EXPORT_SYMBOL_GPL(rk3308_codec_set_jack_detect); + static const struct regmap_config rk3308_codec_regmap_config = { .reg_bits = 32, .reg_stride = 4, diff --git a/sound/soc/codecs/rk3308_codec_provider.h b/sound/soc/codecs/rk3308_codec_provider.h new file mode 100644 index 000000000000..a447f3a92ff4 --- /dev/null +++ b/sound/soc/codecs/rk3308_codec_provider.h @@ -0,0 +1,33 @@ +/* + * rk3308_codec_provider.h -- RK3308 ALSA Soc Audio Driver + * + * Copyright (c) 2018, Fuzhou Rockchip Electronics Co., Ltd All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef __RK3308_CODEC_PROVIDER_H__ +#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) +{ +} +#endif + +#endif /* __RK3308_CODEC_PROVIDER_H__ */