From patchwork Fri Oct 31 01:22:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 5201181 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 969F1C11AC for ; Fri, 31 Oct 2014 01:23:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 92EAA2024C for ; Fri, 31 Oct 2014 01:23:21 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 4F80820219 for ; Fri, 31 Oct 2014 01:23:20 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4EBFD2654CD; Fri, 31 Oct 2014 02:23:19 +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, NO_DNS_FOR_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 10E7B265336; Fri, 31 Oct 2014 02:23:08 +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 8A58F265372; Fri, 31 Oct 2014 02:23:06 +0100 (CET) Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by alsa0.perex.cz (Postfix) with ESMTP id 20B68260671 for ; Fri, 31 Oct 2014 02:22:43 +0100 (CET) Received: by mail-pd0-f171.google.com with SMTP id r10so6217670pdi.16 for ; Thu, 30 Oct 2014 18:22:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:from:subject:user-agent:to:cc:in-reply-to :references:mime-version:content-type; bh=1wC3xpip+EOVxvLaHiuKyPRAR01Sa2EFOCXzZw9KU+c=; b=kGZngngMpbTTuXgUwWy45OPZ2+fi1OBehu6j8z0SnLtMHCFQXVFDn5JFZs6gxCfmDq dRPA4X4MErHTvAELVS5BzlTQGcq7MMlChi78nLGOhNQiwOFOc6+V2BUe+WHzynvw0RIL RKgfxcd+254BQWFmuu+qskS1vTsk+jm5f9PqOTuAwbEqZNHnAuPhlqEfEcy3d4aSmZTt VA7oUrt8oYO+qiIVtDKadZFgAdELAUcC+IfZnXa4YrUeIoB3sU0r5H0G0jYoPinhQuPC gb0bOZk+AU7slxhZJBme6y4p2pB4H7e37doo9CVq7w/AnMMaXfluWYNYZZrun6iKDTbZ T0tQ== X-Received: by 10.66.118.136 with SMTP id km8mr21742803pab.100.1414718563065; Thu, 30 Oct 2014 18:22:43 -0700 (PDT) Received: from remon.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id gn6sm8262280pbc.40.2014.10.30.18.22.41 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 30 Oct 2014 18:22:42 -0700 (PDT) Date: Thu, 30 Oct 2014 18:22:42 -0700 (PDT) Message-ID: <877fzh2ftq.wl%kuninori.morimoto.gx@gmail.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 To: Mark Brown In-Reply-To: <87egtp2g05.wl%kuninori.morimoto.gx@gmail.com> References: <87egtp2g05.wl%kuninori.morimoto.gx@gmail.com> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: Linux-ALSA , Simon , Liam Girdwood , Kuninori Morimoto Subject: [alsa-devel] [PATCH 5/5 v2] 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. This sample indicates Mute -> Volume 100% -> Mute amixer set "DVC Out Ramp Up Rate" 0x10 amixer set "DVC Out Ramp Down Rate" 0x13 amixer set "DVC Out Ramp" 0% // Mute as default amixer set "DVC Out Ramp" on // Volume Ramp ON aplay xxx.wav & amixer set "DVC Out Ramp" 100% // Ramp up to 100% amixer set "DVC Out Ramp" 0% // Ramp down to Mute Signed-off-by: Kuninori Morimoto --- v1 -> v2 - "Period" -> "Rate" - add Up/Down rate - Ramp Volume was inverted for user experience - "Ramp Enable" -> "Ramp Switch" sound/soc/sh/rcar/dvc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/sh/rcar/gen.c | 3 +++ sound/soc/sh/rcar/rsnd.h | 6 ++++++ 3 files changed, 53 insertions(+) diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 55c8d7c..9ccf77b 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -37,6 +37,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) \ @@ -66,6 +70,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; @@ -290,6 +305,35 @@ 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_s(mod, rdai, rtd, + rsnd_dai_is_play(rdai, io) ? + "DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate", + &dvc->rup, 0x17); /* 10111 */ + if (ret < 0) + return ret; + + ret = _rsnd_dvc_pcm_new_s(mod, rdai, rtd, + rsnd_dai_is_play(rdai, io) ? + "DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate", + &dvc->rdown, 0x17); /* 10111 */ + 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 56b93a0..08c686d 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;