From patchwork Wed Oct 22 01:14:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 5129111 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 81F22C11AC for ; Wed, 22 Oct 2014 01:16:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8821B20121 for ; Wed, 22 Oct 2014 01:16:34 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2E64920107 for ; Wed, 22 Oct 2014 01:16:33 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 435172625EA; Wed, 22 Oct 2014 03:16:32 +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.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 42F21261AB0; Wed, 22 Oct 2014 03:15:26 +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 945C5261B1E; Wed, 22 Oct 2014 03:15:25 +0200 (CEST) Received: from mail-pd0-f174.google.com (mail-pd0-f174.google.com [209.85.192.174]) by alsa0.perex.cz (Postfix) with ESMTP id 4DBE4261AB0 for ; Wed, 22 Oct 2014 03:14:16 +0200 (CEST) Received: by mail-pd0-f174.google.com with SMTP id p10so464579pdj.33 for ; Tue, 21 Oct 2014 18:14:15 -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=MQShqQGMI3PIIT7QElwl6Xe8BnD7ywBLCvScwvRdTww=; b=HHq88urOBqdPzj/WM6BNTEzVOYyh2LLKx/co5e5RqJfz+k82m2SLMM7wwSdueJ10Ig LqB0WjJxZlzlIOvoFQJs4gyvrHjj2s3W43PSzdlO4bzvS+UYwhpS9X9o8MWRJUW7r3F7 FJJ0R6kfROpjIlN3LGQi+NQa4XCZHtCMil8d6M+ZHNlv748QchcN6lJ2B8Lpd8gIbSbM /TtRD5YGl06A454PI+N8BslYcPIdBWRaXwuFtxht55ttNs30Rnbi0esJsAkBURS4nDBG kxwTLkPd/DtA1/OsWeTXmCf0c7VVnaTohtFphPjuziinvRYQ3noNFW6VKRAMjZBu/OCv r9cw== X-Received: by 10.70.127.239 with SMTP id nj15mr15238937pdb.125.1413940455259; Tue, 21 Oct 2014 18:14:15 -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 ke5sm13112843pad.34.2014.10.21.18.14.12 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 21 Oct 2014 18:14:14 -0700 (PDT) Date: Tue, 21 Oct 2014 18:14:14 -0700 (PDT) Message-ID: <871tq07voc.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: <8761fc7vpx.wl%kuninori.morimoto.gx@gmail.com> References: <8761fc7vpx.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 3/8] ASoC: rsnd: add struct rsnd_dvc_cfg and control DVC settings 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 DVC can control Digital Volume / Mute / Volume Ramp etc, and these uses different max value. Current driver is using fixed max value for each settings. This patch adds new struct rsnd_dvc_cfg, and control these. Signed-off-by: Kuninori Morimoto --- sound/soc/sh/rcar/dvc.c | 51 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index b5f95ad4..deaf0fa 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -11,17 +11,21 @@ #include "rsnd.h" #define RSND_DVC_NAME_SIZE 16 -#define RSND_DVC_VOLUME_MAX 100 #define RSND_DVC_CHANNELS 2 #define DVC_NAME "dvc" +struct rsnd_dvc_cfg { + unsigned int max; + u32 val[RSND_DVC_CHANNELS]; +}; + struct rsnd_dvc { struct rsnd_dvc_platform_info *info; /* rcar_snd.h */ struct rsnd_mod mod; struct clk *clk; - u8 volume[RSND_DVC_CHANNELS]; - u8 mute[RSND_DVC_CHANNELS]; + struct rsnd_dvc_cfg volume; + struct rsnd_dvc_cfg mute; }; #define rsnd_mod_to_dvc(_mod) \ @@ -36,18 +40,15 @@ struct rsnd_dvc { static void rsnd_dvc_volume_update(struct rsnd_mod *mod) { struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); - u32 max = (0x00800000 - 1); - u32 vol[RSND_DVC_CHANNELS]; u32 mute = 0; int i; for (i = 0; i < RSND_DVC_CHANNELS; i++) { - vol[i] = max / RSND_DVC_VOLUME_MAX * dvc->volume[i]; - mute |= (!!dvc->mute[i]) << i; + mute |= (!!dvc->mute.val[i]) << i; } - rsnd_mod_write(mod, DVC_VOL0R, vol[0]); - rsnd_mod_write(mod, DVC_VOL1R, vol[1]); + rsnd_mod_write(mod, DVC_VOL0R, dvc->volume.val[0]); + rsnd_mod_write(mod, DVC_VOL1R, dvc->volume.val[1]); rsnd_mod_write(mod, DVC_ZCMCR, mute); } @@ -146,20 +147,16 @@ static int rsnd_dvc_stop(struct rsnd_mod *mod, static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl, struct snd_ctl_elem_info *uinfo) { - struct rsnd_mod *mod = snd_kcontrol_chip(kctrl); - struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); - u8 *val = (u8 *)kctrl->private_value; + struct rsnd_dvc_cfg *cfg = (struct rsnd_dvc_cfg *)kctrl->private_value; uinfo->count = RSND_DVC_CHANNELS; uinfo->value.integer.min = 0; + uinfo->value.integer.max = cfg->max; - if (val == dvc->volume) { - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->value.integer.max = RSND_DVC_VOLUME_MAX; - } else { + if (cfg->max == 1) uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; - uinfo->value.integer.max = 1; - } + else + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; return 0; } @@ -167,11 +164,11 @@ static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl, static int rsnd_dvc_volume_get(struct snd_kcontrol *kctrl, struct snd_ctl_elem_value *ucontrol) { - u8 *val = (u8 *)kctrl->private_value; + struct rsnd_dvc_cfg *cfg = (struct rsnd_dvc_cfg *)kctrl->private_value; int i; for (i = 0; i < RSND_DVC_CHANNELS; i++) - ucontrol->value.integer.value[i] = val[i]; + ucontrol->value.integer.value[i] = cfg->val[i]; return 0; } @@ -180,12 +177,12 @@ static int rsnd_dvc_volume_put(struct snd_kcontrol *kctrl, struct snd_ctl_elem_value *ucontrol) { struct rsnd_mod *mod = snd_kcontrol_chip(kctrl); - u8 *val = (u8 *)kctrl->private_value; + struct rsnd_dvc_cfg *cfg = (struct rsnd_dvc_cfg *)kctrl->private_value; int i, change = 0; for (i = 0; i < RSND_DVC_CHANNELS; i++) { - change |= (ucontrol->value.integer.value[i] != val[i]); - val[i] = ucontrol->value.integer.value[i]; + change |= (ucontrol->value.integer.value[i] != cfg->val[i]); + cfg->val[i] = ucontrol->value.integer.value[i]; } if (change) @@ -198,7 +195,7 @@ static int __rsnd_dvc_pcm_new(struct rsnd_mod *mod, struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, - u8 *private) + struct rsnd_dvc_cfg *private) { struct snd_card *card = rtd->card->snd_card; struct snd_kcontrol *kctrl; @@ -232,18 +229,20 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, int ret; /* Volume */ + dvc->volume.max = 0x00800000 - 1; ret = __rsnd_dvc_pcm_new(mod, rdai, rtd, rsnd_dai_is_play(rdai, io) ? "DVC Out Playback Volume" : "DVC In Capture Volume", - dvc->volume); + &dvc->volume); if (ret < 0) return ret; /* Mute */ + dvc->mute.max = 1; ret = __rsnd_dvc_pcm_new(mod, rdai, rtd, rsnd_dai_is_play(rdai, io) ? "DVC Out Mute Switch" : "DVC In Mute Switch", - dvc->mute); + &dvc->mute); if (ret < 0) return ret;