From patchwork Wed Nov 5 04:28:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 5232311 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 98EA59F2ED for ; Wed, 5 Nov 2014 04:32:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A89662015A for ; Wed, 5 Nov 2014 04:32:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6880820114 for ; Wed, 5 Nov 2014 04:32:42 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 718652617E0; Wed, 5 Nov 2014 05:32:41 +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 7307E2619F0; Wed, 5 Nov 2014 05:30:46 +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 D192E261B03; Wed, 5 Nov 2014 05:30:37 +0100 (CET) Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by alsa0.perex.cz (Postfix) with ESMTP id 3F7DB2619DD for ; Wed, 5 Nov 2014 05:28:52 +0100 (CET) Received: by mail-pd0-f178.google.com with SMTP id fp1so15023588pdb.37 for ; Tue, 04 Nov 2014 20:28:51 -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=wOnky470JYNQI9fdHncw2zqYWg3sRWuW97oNE0KpNNk=; b=OXEa3OAXAF4uIrpFOscJnn6J+/7vgYp8YtRtz2Jar/Tq7zoevv0YL8bjvTJNMb8oeq tLLA14sy5cVpgQWTDpYM198kiA/HSn31iqL8UoTGrN4r0/tEDC/ZxQqwF8YzmmYykWMz s+k1AZhalPd79dAI0Ga/GslomI7Td/EiQNMIwWM9hWWVqKzUReY3kQMjhnBwWOras1/t xh1VSiK7/kNlXzq8o+CnerXv7foDoj7izmcfkFLsXsMp/UGnhPZRQwahPr4HKRnxk9oi TWNwd3BNzn3MF1PeYE43OEI6CTPvYd1nj4ph4WGfCPpIqIz06y5Kx9TbtSsrvSKLJopW gKqg== X-Received: by 10.68.175.196 with SMTP id cc4mr12882812pbc.147.1415161731278; Tue, 04 Nov 2014 20:28:51 -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 qn8sm1723536pdb.90.2014.11.04.20.28.49 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 04 Nov 2014 20:28:50 -0800 (PST) Date: Tue, 04 Nov 2014 20:28:50 -0800 (PST) Message-ID: <877fza46eq.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 5/6 v3] ASoC: rsnd: enable enumerated DVC valume 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 controls some digital volume features. Volume Ramp is listed as "XX dB / YY steps", and this enumerated settings are easy for users. This patch adds rsnd_dvc_cfg_e and care about enumerated settings. Compiler will report like below at this point, but, it will be removed if Volume Ramp was supported. warning: '_rsnd_dvc_pcm_new_e' defined but not used Signed-off-by: Kuninori Morimoto --- v2 -> v3 - new patch sound/soc/sh/rcar/dvc.c | 55 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index e7cfc71..8504f6b 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -19,6 +19,7 @@ struct rsnd_dvc_cfg { unsigned int max; unsigned int size; u32 *val; + const char * const *texts; }; struct rsnd_dvc_cfg_m { @@ -169,14 +170,23 @@ static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl, { struct rsnd_dvc_cfg *cfg = (struct rsnd_dvc_cfg *)kctrl->private_value; - uinfo->count = cfg->size; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = cfg->max; - - if (cfg->max == 1) - uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; - else - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + if (cfg->texts) { + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = cfg->size; + uinfo->value.enumerated.items = cfg->max; + if (uinfo->value.enumerated.item >= cfg->max) + uinfo->value.enumerated.item = cfg->max - 1; + strlcpy(uinfo->value.enumerated.name, + cfg->texts[uinfo->value.enumerated.item], + sizeof(uinfo->value.enumerated.name)); + } else { + uinfo->count = cfg->size; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = cfg->max; + uinfo->type = (cfg->max == 1) ? + SNDRV_CTL_ELEM_TYPE_BOOLEAN : + SNDRV_CTL_ELEM_TYPE_INTEGER; + } return 0; } @@ -188,7 +198,10 @@ static int rsnd_dvc_volume_get(struct snd_kcontrol *kctrl, int i; for (i = 0; i < cfg->size; i++) - ucontrol->value.integer.value[i] = cfg->val[i]; + if (cfg->texts) + ucontrol->value.enumerated.item[i] = cfg->val[i]; + else + ucontrol->value.integer.value[i] = cfg->val[i]; return 0; } @@ -201,8 +214,13 @@ static int rsnd_dvc_volume_put(struct snd_kcontrol *kctrl, int i, change = 0; for (i = 0; i < cfg->size; i++) { - change |= (ucontrol->value.integer.value[i] != cfg->val[i]); - cfg->val[i] = ucontrol->value.integer.value[i]; + if (cfg->texts) { + change |= (ucontrol->value.enumerated.item[i] != cfg->val[i]); + cfg->val[i] = ucontrol->value.enumerated.item[i]; + } else { + change |= (ucontrol->value.integer.value[i] != cfg->val[i]); + cfg->val[i] = ucontrol->value.integer.value[i]; + } } if (change) @@ -266,6 +284,21 @@ static int _rsnd_dvc_pcm_new_s(struct rsnd_mod *mod, return __rsnd_dvc_pcm_new(mod, rdai, rtd, name, &private->cfg); } +static int _rsnd_dvc_pcm_new_e(struct rsnd_mod *mod, + struct rsnd_dai *rdai, + struct snd_soc_pcm_runtime *rtd, + const unsigned char *name, + struct rsnd_dvc_cfg_s *private, + const char * const *texts, + u32 max) +{ + private->cfg.max = max; + private->cfg.size = 1; + private->cfg.val = &private->val; + private->cfg.texts = texts; + return __rsnd_dvc_pcm_new(mod, rdai, rtd, name, &private->cfg); +} + static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd)