From patchwork Tue Aug 5 05:52:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 4676081 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6283F9F373 for ; Tue, 5 Aug 2014 05:53:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 621E820160 for ; Tue, 5 Aug 2014 05:53:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D334B2013A for ; Tue, 5 Aug 2014 05:53:47 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 06667262626; Tue, 5 Aug 2014 07:53:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id D0436261AC3; Tue, 5 Aug 2014 07:53:35 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id A72F5261ADA; Tue, 5 Aug 2014 07:53:33 +0200 (CEST) Received: from rtits2.realtek.com (rtits2.realtek.com [60.250.210.242]) by alsa0.perex.cz (Postfix) with ESMTP id D510D261ABF for ; Tue, 5 Aug 2014 07:53:24 +0200 (CEST) X-SpamFilter-By: BOX Solutions SpamTrap 5.39 with qID s755rG9X001432, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtitcas11.realtek.com.tw[172.21.6.12]) by rtits2.realtek.com (8.14.5/2.37/5.60) with ESMTP id s755rG9X001432 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Tue, 5 Aug 2014 13:53:17 +0800 Received: from sw-server.rtdomain (172.21.81.164) by RTITCAS11.realtek.com.tw (172.21.6.12) with Microsoft SMTP Server id 14.3.181.6; Tue, 5 Aug 2014 13:53:16 +0800 From: To: , Date: Tue, 5 Aug 2014 13:52:50 +0800 Message-ID: <1407217970-20126-1-git-send-email-bardliao@realtek.com> X-Mailer: git-send-email 1.8.1.1.439.g50a6b54 MIME-Version: 1.0 X-Originating-IP: [172.21.81.164] Cc: oder_chiou@realtek.com, Bard Liao , alsa-devel@alsa-project.org, lars@metafoo.de, flove@realtek.com Subject: [alsa-devel] [PATCH] ASoC: rt286: Add API to set supported jack type X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bard Liao RT286 need to configure the jack type (combo or non-combo) according to the HW design. This function is given a easy way to set the correct jacy type for those without platform data supported. Signed-off-by: Bard Liao --- sound/soc/codecs/rt286.c | 33 +++++++++++++++++++++++++++++++++ sound/soc/codecs/rt286.h | 7 +++++++ 2 files changed, 40 insertions(+) diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index e4f6102..dd6b454 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -414,6 +414,39 @@ int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) } EXPORT_SYMBOL_GPL(rt286_mic_detect); +/** + * rt286_set_jack_type - Configure the HW supported jack type + * + * @codec: RT286 codec + * @type: supported jack type + * + * RT286 need to configure the jack type (combo or non-combo) according to the + * HW design. This function is given a easy way to set the correct jacy type + * for those without platform data supported. + */ +void rt286_set_jack_type(struct snd_soc_codec *codec, + enum rt286_jack_type type) +{ + struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + + if (RT286_TYPE_COMBO == type) + rt286->pdata.cbj_en = true; + else + rt286->pdata.cbj_en = false; + + if (!rt286->pdata.cbj_en) { + regmap_write(rt286->regmap, RT286_CBJ_CTRL2, 0x0000); + regmap_write(rt286->regmap, RT286_MIC1_DET_CTRL, 0x0816); + regmap_write(rt286->regmap, RT286_MISC_CTRL1, 0x0000); + regmap_update_bits(rt286->regmap, + RT286_CBJ_CTRL1, 0xf000, 0xb000); + } else { + regmap_update_bits(rt286->regmap, + RT286_CBJ_CTRL1, 0xf000, 0x5000); + } +} +EXPORT_SYMBOL_GPL(rt286_set_jack_type); + static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6350, 50, 0); static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0); diff --git a/sound/soc/codecs/rt286.h b/sound/soc/codecs/rt286.h index b539b73..2b1cbe6 100644 --- a/sound/soc/codecs/rt286.h +++ b/sound/soc/codecs/rt286.h @@ -192,7 +192,14 @@ enum { RT286_AIFS, }; +enum rt286_jack_type { + RT286_TYPE_COMBO, + RT286_TYPE_NONCOMBO, +}; + int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +void rt286_set_jack_type(struct snd_soc_codec *codec, + enum rt286_jack_type type); #endif /* __RT286_H__ */