From patchwork Mon Apr 18 11:20:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhengxing X-Patchwork-Id: 8871161 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EF8F29F39D for ; Mon, 18 Apr 2016 11:20:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D13A320340 for ; Mon, 18 Apr 2016 11:20:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A0C8D20320 for ; Mon, 18 Apr 2016 11:20:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1as7ES-0005CA-MF; Mon, 18 Apr 2016 11:20:44 +0000 Received: from regular1.263xmail.com ([211.150.99.130]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1as7EP-0004yB-3b for linux-rockchip@lists.infradead.org; Mon, 18 Apr 2016 11:20:42 +0000 Received: from zhengxing?rock-chips.com (unknown [192.168.167.225]) by regular1.263xmail.com (Postfix) with SMTP id 18332B475; Mon, 18 Apr 2016 19:20:15 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 X-KSVirus-check: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 9E50D28BF; Mon, 18 Apr 2016 19:20:13 +0800 (CST) X-RL-SENDER: zhengxing@rock-chips.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: zhengxing@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: zhengxing@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith SMTP id 11846SD0Y23; Mon, 18 Apr 2016 19:20:15 +0800 (CST) From: Xing Zheng To: linux-rockchip@lists.infradead.org Subject: [PATCH v2 1/3] ASoC: jack: Add an export of a function that calls the codec jack detection Date: Mon, 18 Apr 2016 19:20:01 +0800 Message-Id: <1460978403-4754-2-git-send-email-zhengxing@rock-chips.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1460978403-4754-1-git-send-email-zhengxing@rock-chips.com> References: <1460978403-4754-1-git-send-email-zhengxing@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160418_042041_694273_C87B8C3E X-CRM114-Status: UNSURE ( 8.67 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, heiko@sntech.de, Xing Zheng , linux-kernel@vger.kernel.org, Takashi Iwai , dianders@chromium.org, Liam Girdwood , sugar.zhang@rock-chips.com, Adam.Thomson@diasemi.com, broonie@kernel.org, Jaroslav Kysela , jay.xu@rock-chips.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add an export of a function. We can fill the detect_jack function in the struct snd_soc_codec_driver, and to tell sound machine driver (simple-card) that the codec supports the jack detection feature. Then, the machine driver (simple-card) call the export function of the sound framework to initialize jack detection via the codec. Signed-off-by: Xing Zheng --- Changes in v1: - clean up the commit message and notes include/sound/soc.h | 7 +++++++ sound/soc/soc-jack.c | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index 02b4a21..64e3f4a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -547,6 +547,10 @@ static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, } #endif +/* call and init jack detect via the codec */ +void snd_soc_jack_codec_detect(struct snd_soc_codec *codec, + struct snd_soc_jack *jack); + /* codec register bit access */ int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg, unsigned int mask, unsigned int value); @@ -920,6 +924,9 @@ struct snd_soc_codec_driver { enum snd_soc_dapm_type, int); bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */ + + /* fill this function if the codec supports jack detection */ + void (*detect_jack)(struct snd_soc_codec *codec, struct snd_soc_jack *jack); }; /* SoC platform interface */ diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index fbaa1bb..ccaf546 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -436,3 +436,20 @@ void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, } EXPORT_SYMBOL_GPL(snd_soc_jack_free_gpios); #endif /* CONFIG_GPIOLIB */ + +/** + * snd_soc_jack_codec_detect - Call and init jack detection if the codec support it + * + * @codec: ASoC codec + * @jack: ASoC jack + * + * Call and initialize the codec jack detection if the codec supports it and fills + * the detect_jack function in the struct snd_soc_codec_driver. + */ +void snd_soc_jack_codec_detect(struct snd_soc_codec *codec, + struct snd_soc_jack *jack) +{ + if (codec && codec->driver && codec->driver->detect_jack) + codec->driver->detect_jack(codec, jack); +} +EXPORT_SYMBOL_GPL(snd_soc_jack_codec_detect);