From patchwork Wed Nov 5 04:29:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 5232321 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 21079C11AC for ; Wed, 5 Nov 2014 04:34:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 250952015E for ; Wed, 5 Nov 2014 04:34:14 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 84F0E20114 for ; Wed, 5 Nov 2014 04:34:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7E458261A1A; Wed, 5 Nov 2014 05:34:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 07DF7261A95; Wed, 5 Nov 2014 05:31:47 +0100 (CET) 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 A7E49261A3B; Wed, 5 Nov 2014 05:31:44 +0100 (CET) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by alsa0.perex.cz (Postfix) with ESMTP id 2923E261A01 for ; Wed, 5 Nov 2014 05:29:55 +0100 (CET) Received: by mail-pa0-f48.google.com with SMTP id ey11so15888450pad.35 for ; Tue, 04 Nov 2014 20:29:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:from:subject:user-agent:mime-version:to:cc :in-reply-to:references:content-type; bh=rHgJuLmvUrdtCAt3Gd9bZ5/pmRcDxGyzvv3jFnw/Vg0=; b=oqjT6q4NeTmzwe+AOBK/eR6sLXVz/Y5nRXj337pqHM31btWW7uHaT149SxoLhdnMZk alUK7SGKydW78UL/OkAfVykndX5QFS8Q+rylgKCdC0YcqBBQkVLfix5eEH0vdB9Njvz9 pgoN+2UgIjYz7ppH43T9TMaWHodvVHus34ZWrMGnNVae12e5IUV/SACLgjxvDOCdWD4c qOHGQFQTwgocwSSDzUZydygTWEkDSnMu485AnFiwNTELpN91i/cYwE5eZh7tBoYmrum9 gecla6nAjc4dvTqPpdY8PrG86d8vyVgojIrMQCTArmSi6Y2bINSz73Dg5OUd7ofiEtT9 l0eA== X-Received: by 10.70.48.138 with SMTP id l10mr2934488pdn.139.1415161794272; Tue, 04 Nov 2014 20:29:54 -0800 (PST) Received: from remon.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id rj8sm1773204pdb.55.2014.11.04.20.29.52 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 04 Nov 2014 20:29:53 -0800 (PST) Date: Tue, 04 Nov 2014 20:29:53 -0800 (PST) Message-ID: <8761eu46cz.wl%kuninori.morimoto.gx@gmail.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") To: Mark Brown In-Reply-To: <87egti46j7.wl%kuninori.morimoto.gx@gmail.com> References: <87egtp2g05.wl%kuninori.morimoto.gx@gmail.com> <87egti46j7.wl%kuninori.morimoto.gx@gmail.com> Cc: Linux-ALSA , Simon , Liam Girdwood , Kuninori Morimoto Subject: [alsa-devel] [PATCH 6/6 v3] ASoC: rsnd: Add Volume Ramp support 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: Kuninori Morimoto This patch adds Volume Ramp to Renesas sound driver. Below sample indicates Mute -> Volume 100% -> Mute. Here, - Mute (= Normal Volume x 0%) - Volume 100% (= Normal Volume x 100%) amixer set "DVC Out" 100% // = Normal Volume amixer set "DVC Out Ramp Up Rate" "0.125 dB/64 steps" amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps" amixer set "DVC Out Ramp" 0% // Mute = Normal Volume x 0% amixer set "DVC Out Ramp" on // Volume Ramp ON aplay xxx.wav & amixer set "DVC Out Ramp" 100% // Mute to Normal Volume x 100% amixer set "DVC Out Ramp" 0% // Normal Volume x 100% to Mute Signed-off-by: Kuninori Morimoto --- v2 -> v3 - use enumerated list - it is using datasheet words (= xxx dB / yy step) sound/soc/sh/rcar/dvc.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/sh/rcar/gen.c | 3 ++ sound/soc/sh/rcar/rsnd.h | 6 ++++ 3 files changed, 83 insertions(+) diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 8504f6b..0b38f888 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -38,6 +38,10 @@ struct rsnd_dvc { struct clk *clk; struct rsnd_dvc_cfg_m volume; struct rsnd_dvc_cfg_m mute; + struct rsnd_dvc_cfg_s ren; /* Ramp Enable */ + struct rsnd_dvc_cfg_s rup; /* Ramp Rate Up */ + struct rsnd_dvc_cfg_s rdown; /* Ramp Rate Down */ + struct rsnd_dvc_cfg_s rvol; /* Ramp Volume */ }; #define rsnd_mod_to_dvc(_mod) \ @@ -49,6 +53,33 @@ struct rsnd_dvc { ((pos) = (struct rsnd_dvc *)(priv)->dvc + i); \ i++) +static const char const *dvc_ramp_rate[] = { + "128 dB/1 step", /* 00000 */ + "64 dB/1 step", /* 00001 */ + "32 dB/1 step", /* 00010 */ + "16 dB/1 step", /* 00011 */ + "8 dB/1 step", /* 00100 */ + "4 dB/1 step", /* 00101 */ + "2 dB/1 step", /* 00110 */ + "1 dB/1 step", /* 00111 */ + "0.5 dB/1 step", /* 01000 */ + "0.25 dB/1 step", /* 01001 */ + "0.125 dB/1 step", /* 01010 */ + "0.125 dB/2 steps", /* 01011 */ + "0.125 dB/4 steps", /* 01100 */ + "0.125 dB/8 steps", /* 01101 */ + "0.125 dB/16 steps", /* 01110 */ + "0.125 dB/32 steps", /* 01111 */ + "0.125 dB/64 steps", /* 10000 */ + "0.125 dB/128 steps", /* 10001 */ + "0.125 dB/256 steps", /* 10010 */ + "0.125 dB/512 steps", /* 10011 */ + "0.125 dB/1024 steps", /* 10100 */ + "0.125 dB/2048 steps", /* 10101 */ + "0.125 dB/4096 steps", /* 10110 */ + "0.125 dB/8192 steps", /* 10111 */ +}; + static void rsnd_dvc_volume_update(struct rsnd_mod *mod) { struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); @@ -67,6 +98,17 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod) rsnd_mod_write(mod, DVC_VOL0R, dvc->volume.val[0]); rsnd_mod_write(mod, DVC_VOL1R, dvc->volume.val[1]); + /* Enable Ramp */ + if (dvc->ren.val) { + dvucr |= 0x10; + rsnd_mod_write(mod, DVC_VRCTR, 0xff); + rsnd_mod_write(mod, DVC_VRPDR, dvc->rup.val << 8 | + dvc->rdown.val); + /* use inverted value for user experience */ + rsnd_mod_write(mod, DVC_VRDBR, dvc->rvol.cfg.max - + dvc->rvol.val); + } + /* Enable Mute */ if (mute) { dvucr |= 0x1; @@ -323,6 +365,38 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, if (ret < 0) return ret; + /* Ramp */ + ret = _rsnd_dvc_pcm_new_s(mod, rdai, rtd, + rsnd_dai_is_play(rdai, io) ? + "DVC Out Ramp Switch" : "DVC In Ramp Switch", + &dvc->ren, 1); + if (ret < 0) + return ret; + + ret = _rsnd_dvc_pcm_new_e(mod, rdai, rtd, + rsnd_dai_is_play(rdai, io) ? + "DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate", + &dvc->rup, + dvc_ramp_rate, ARRAY_SIZE(dvc_ramp_rate)); + if (ret < 0) + return ret; + + ret = _rsnd_dvc_pcm_new_e(mod, rdai, rtd, + rsnd_dai_is_play(rdai, io) ? + "DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate", + &dvc->rdown, + dvc_ramp_rate, ARRAY_SIZE(dvc_ramp_rate)); + + if (ret < 0) + return ret; + + ret = _rsnd_dvc_pcm_new_s(mod, rdai, rtd, + rsnd_dai_is_play(rdai, io) ? + "DVC Out Ramp Volume" : "DVC In Ramp Volume", + &dvc->rvol, 0x3ff); + if (ret < 0) + return ret; + return 0; } diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index 61dee68..4cb3202 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c @@ -324,6 +324,9 @@ static int rsnd_gen2_probe(struct platform_device *pdev, RSND_GEN_M_REG(DVC_ADINR, 0xe08, 0x100), RSND_GEN_M_REG(DVC_DVUCR, 0xe10, 0x100), RSND_GEN_M_REG(DVC_ZCMCR, 0xe14, 0x100), + RSND_GEN_M_REG(DVC_VRCTR, 0xe18, 0x100), + RSND_GEN_M_REG(DVC_VRPDR, 0xe1c, 0x100), + RSND_GEN_M_REG(DVC_VRDBR, 0xe20, 0x100), RSND_GEN_M_REG(DVC_VOL0R, 0xe28, 0x100), RSND_GEN_M_REG(DVC_VOL1R, 0xe2c, 0x100), RSND_GEN_M_REG(DVC_DVUER, 0xe48, 0x100), diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index d119adf..ed44ca8 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -91,6 +91,9 @@ enum rsnd_reg { RSND_REG_SHARE20, RSND_REG_SHARE21, RSND_REG_SHARE22, + RSND_REG_SHARE23, + RSND_REG_SHARE24, + RSND_REG_SHARE25, RSND_REG_MAX, }; @@ -129,6 +132,9 @@ enum rsnd_reg { #define RSND_REG_CMD_CTRL RSND_REG_SHARE20 #define RSND_REG_CMDOUT_TIMSEL RSND_REG_SHARE21 #define RSND_REG_BUSIF_DALIGN RSND_REG_SHARE22 +#define RSND_REG_DVC_VRCTR RSND_REG_SHARE23 +#define RSND_REG_DVC_VRPDR RSND_REG_SHARE24 +#define RSND_REG_DVC_VRDBR RSND_REG_SHARE25 struct rsnd_of_data; struct rsnd_priv;