From patchwork Wed Jul 3 18:48:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 11030111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA0EF138D for ; Wed, 3 Jul 2019 18:49:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB84028961 for ; Wed, 3 Jul 2019 18:49:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF5622898B; Wed, 3 Jul 2019 18:49:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4E8E928961 for ; Wed, 3 Jul 2019 18:49:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TpvKtCHQlMkPiJpZEJKxoLOMjdrtBF4rvOdKdaAGMxI=; b=a8CczJLwRzZkVv /1Eo6E6NvC3I2NbCG4oFhVbh1MVkdy5rEtC8S6jhic5O90Bf45MNxgdyYyqloWfIBGqT41Kg0MwoG KCgsXL4wjl6eVnHMYgkXa5YfYa70BDGQF8Lr20zntcYSrfbhqMEXpqJx+5bebcRNIYD0KENgoQZqE ZvOXP6lGY+YsyJT2H4c5KVq4hgK1MEnxFmzqNwegMy89UVoimDwWes4uFvKn6Gf2s8L0SnpyDvpFj k64uuwrPlOIeF6wfAAbIxYikmIoDK71FMs+emYB+dVyy1ZICXskBN7JeAqjVdcttGSka959dWXF9y tYKxv+9jA26jUet2r4wg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hikK2-0000ud-47; Wed, 03 Jul 2019 18:49:38 +0000 Received: from mail.z3ntu.xyz ([128.199.32.197]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hikJz-0000tv-0f for linux-arm-kernel@lists.infradead.org; Wed, 03 Jul 2019 18:49:36 +0000 Received: from localhost.localdomain (80-110-121-20.cgn.dynamic.surfer.at [80.110.121.20]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id 0074BC642D; Wed, 3 Jul 2019 18:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=z3ntu.xyz; s=z3ntu; t=1562179772; bh=9DizQ8OziyzZDK+fmM5mzABZl479bhqpI8LTwVmMOKE=; h=From:To:Cc:Subject:Date; b=jAVEnO7uq2QTRWst/+QFsN5w8bdWbv4Yu49XUV4jnqn02gYxiZCP5+eUopcycjO0g nC3c2tYhQL4HY3kK28juYm59IkLBCEmq4xwhkkJHrd6EgwmZb2TVIrL3s2769eJ9AC pTGoG5yeYxZ/Ifz0xSAWg5lZAr6+O4hLE1Rk7dzM= From: Luca Weiss To: alsa-devel@alsa-project.org Subject: [PATCH v2] ASoC: sunxi: sun50i-codec-analog: Add earpiece Date: Wed, 3 Jul 2019 20:48:11 +0200 Message-Id: <20190703184814.27191-1-luca@z3ntu.xyz> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190703_114935_413793_2A81B060 X-CRM114-Status: UNSURE ( 9.19 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Maxime Ripard , ~martijnbraam/pmos-upstream@lists.sr.ht, Takashi Iwai , Liam Girdwood , Luca Weiss , Chen-Yu Tsai , Mark Brown , Jaroslav Kysela , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This adds the necessary registers and audio routes to play audio using the Earpiece, that's supported on the A64. Signed-off-by: Luca Weiss Reviewed-by: Chen-Yu Tsai --- Changes v1 -> v2: * Make the earpiece enable register a DAPM widget * Adjust the audio routes to include the new Earpiece Amp widget * Left/Right Analog Mixer => Left/Right Mixer sound/soc/sunxi/sun50i-codec-analog.c | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/sound/soc/sunxi/sun50i-codec-analog.c b/sound/soc/sunxi/sun50i-codec-analog.c index d105c90c3706..6d1de565350e 100644 --- a/sound/soc/sunxi/sun50i-codec-analog.c +++ b/sound/soc/sunxi/sun50i-codec-analog.c @@ -49,6 +49,15 @@ #define SUN50I_ADDA_OR_MIX_CTRL_DACR 1 #define SUN50I_ADDA_OR_MIX_CTRL_DACL 0 +#define SUN50I_ADDA_EARPIECE_CTRL0 0x03 +#define SUN50I_ADDA_EARPIECE_CTRL0_EAR_RAMP_TIME 4 +#define SUN50I_ADDA_EARPIECE_CTRL0_ESPSR 0 + +#define SUN50I_ADDA_EARPIECE_CTRL1 0x04 +#define SUN50I_ADDA_EARPIECE_CTRL1_ESPPA_EN 7 +#define SUN50I_ADDA_EARPIECE_CTRL1_ESPPA_MUTE 6 +#define SUN50I_ADDA_EARPIECE_CTRL1_ESP_VOL 0 + #define SUN50I_ADDA_LINEOUT_CTRL0 0x05 #define SUN50I_ADDA_LINEOUT_CTRL0_LEN 7 #define SUN50I_ADDA_LINEOUT_CTRL0_REN 6 @@ -172,6 +181,10 @@ static const DECLARE_TLV_DB_RANGE(sun50i_codec_lineout_vol_scale, 2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0), ); +static const DECLARE_TLV_DB_RANGE(sun50i_codec_earpiece_vol_scale, + 0, 1, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), + 2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0), +); /* volume / mute controls */ static const struct snd_kcontrol_new sun50i_a64_codec_controls[] = { @@ -225,6 +238,15 @@ static const struct snd_kcontrol_new sun50i_a64_codec_controls[] = { SUN50I_ADDA_LINEOUT_CTRL0_LEN, SUN50I_ADDA_LINEOUT_CTRL0_REN, 1, 0), + SOC_SINGLE_TLV("Earpiece Playback Volume", + SUN50I_ADDA_EARPIECE_CTRL1, + SUN50I_ADDA_EARPIECE_CTRL1_ESP_VOL, 0x1f, 0, + sun50i_codec_earpiece_vol_scale), + + SOC_SINGLE("Earpiece Playback Switch", + SUN50I_ADDA_EARPIECE_CTRL1, + SUN50I_ADDA_EARPIECE_CTRL1_ESPPA_MUTE, 1, 0), + }; static const char * const sun50i_codec_hp_src_enum_text[] = { @@ -257,6 +279,20 @@ static const struct snd_kcontrol_new sun50i_codec_lineout_src[] = { sun50i_codec_lineout_src_enum), }; +static const char * const sun50i_codec_earpiece_src_enum_text[] = { + "DACR", "DACL", "Right Mixer", "Left Mixer", +}; + +static SOC_ENUM_SINGLE_DECL(sun50i_codec_earpiece_src_enum, + SUN50I_ADDA_EARPIECE_CTRL0, + SUN50I_ADDA_EARPIECE_CTRL0_ESPSR, + sun50i_codec_earpiece_src_enum_text); + +static const struct snd_kcontrol_new sun50i_codec_earpiece_src[] = { + SOC_DAPM_ENUM("Earpiece Source Playback Route", + sun50i_codec_earpiece_src_enum), +}; + static const struct snd_soc_dapm_widget sun50i_a64_codec_widgets[] = { /* DAC */ SND_SOC_DAPM_DAC("Left DAC", NULL, SUN50I_ADDA_MIX_DAC_CTRL, @@ -285,6 +321,12 @@ static const struct snd_soc_dapm_widget sun50i_a64_codec_widgets[] = { SND_SOC_NOPM, 0, 0, sun50i_codec_lineout_src), SND_SOC_DAPM_OUTPUT("LINEOUT"), + SND_SOC_DAPM_MUX("Earpiece Source Playback Route", + SND_SOC_NOPM, 0, 0, sun50i_codec_earpiece_src), + SND_SOC_DAPM_OUT_DRV("Earpiece Amp", SUN50I_ADDA_EARPIECE_CTRL1, + SUN50I_ADDA_EARPIECE_CTRL1_ESPPA_EN, 0, NULL, 0), + SND_SOC_DAPM_OUTPUT("EARPIECE"), + /* Microphone inputs */ SND_SOC_DAPM_INPUT("MIC1"), @@ -388,6 +430,14 @@ static const struct snd_soc_dapm_route sun50i_a64_codec_routes[] = { { "Line Out Source Playback Route", "Mono Differential", "Right Mixer" }, { "LINEOUT", NULL, "Line Out Source Playback Route" }, + + /* Earpiece Routes */ + { "Earpiece Source Playback Route", "DACL", "Left DAC" }, + { "Earpiece Source Playback Route", "DACR", "Right DAC" }, + { "Earpiece Source Playback Route", "Left Mixer", "Left Mixer" }, + { "Earpiece Source Playback Route", "Right Mixer", "Right Mixer" }, + { "Earpiece Amp", NULL, "Earpiece Source Playback Route" }, + { "EARPIECE", NULL, "Earpiece Amp" }, }; static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = {