From patchwork Tue Jun 9 10:55:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: arun@accosted.net X-Patchwork-Id: 6571121 X-Patchwork-Delegate: tiwai@suse.de 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B5097C0020 for ; Tue, 9 Jun 2015 10:56:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5FA120498 for ; Tue, 9 Jun 2015 10:56:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 31F0E20495 for ; Tue, 9 Jun 2015 10:56:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2F279265255; Tue, 9 Jun 2015 12:55:59 +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.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 9936D2651A8; Tue, 9 Jun 2015 12:55:50 +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 4163F2651B4; Tue, 9 Jun 2015 12:55:49 +0200 (CEST) Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by alsa0.perex.cz (Postfix) with ESMTP id 15A20265173 for ; Tue, 9 Jun 2015 12:55:42 +0200 (CEST) Received: by pdjn11 with SMTP id n11so12562565pdj.0 for ; Tue, 09 Jun 2015 03:55:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QZ/Vq9EHoiZ52tG6LzxqOHEHEq8Jjoz7nCg+LLEyThM=; b=eEwTbxH07my9ZO3738Tzxw3kb/fdCsjQmLvgqIATzusanRtAsXgHAwD1I3Oq6SvVHB xAKAXaRzoNd7czYgnddycLdk3pop8FwcHImIggvFpusufansZGcntWI6+7ENGEyTYnrP OAoFzYON1v/VLPhQvJCT+T2fF8aNd9SiLe2yOPXvv4B5R9fTGDzRCcdINkA7oFsnDuuH jFjaIE9oZ2zQCnEk2t37PcDDm3n1vX/C3RJkY1z0rHUyOg4TYMJIFLnLAnLs6NR429JF QC/MC829eD6j1hE2QcFG9ltZDVK+quG4BbQ0nEPrptTcgj5D8xf9kdSMlwD/CwjM8Gsn MHLA== X-Gm-Message-State: ALoCoQllrolR82tyf2RFXQQdXyoeSkp0CTCk3dvSVqpoXUa8QR7jNnM7NvgPyJQlueDMrLCxdqUE X-Received: by 10.68.110.3 with SMTP id hw3mr37598501pbb.128.1433847340637; Tue, 09 Jun 2015 03:55:40 -0700 (PDT) Received: from falcon.localdomain ([106.51.233.83]) by mx.google.com with ESMTPSA id b4sm5265091pbu.71.2015.06.09.03.55.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jun 2015 03:55:39 -0700 (PDT) From: arun@accosted.net To: alsa-devel@alsa-project.org Date: Tue, 9 Jun 2015 16:25:07 +0530 Message-Id: <1433847307-26125-1-git-send-email-arun@accosted.net> X-Mailer: git-send-email 2.4.2 Cc: Arun Raghavan Subject: [alsa-devel] [PATCH] control: Allow cset'ing specific values in the multi-value case 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Arun Raghavan This works with syntax like ... amixer cset 'IIR1 Band1' ,,200 ... to set the third value of the control to 200. --- src/control/ctlparse.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c index 8d6c385..64c6480 100644 --- a/src/control/ctlparse.c +++ b/src/control/ctlparse.c @@ -48,9 +48,9 @@ static inline long int convert_prange1(long val, long min, long max) #define check_range(val, min, max) \ ((val < min) ? (min) : ((val > max) ? (max) : (val))) -static long get_integer(const char **ptr, long min, long max) +static long get_integer(const char **ptr, long def, long min, long max) { - long val = min; + long val = def; char *p = (char *)*ptr, *s; if (*p == ':') @@ -351,6 +351,8 @@ int snd_ctl_ascii_value_parse(snd_ctl_t *handle, break; case SND_CTL_ELEM_TYPE_INTEGER: tmp = get_integer(&ptr, + snd_ctl_elem_value_get_integer(dst, + idx), snd_ctl_elem_info_get_min(info), snd_ctl_elem_info_get_max(info)); snd_ctl_elem_value_set_integer(dst, idx, tmp); @@ -364,12 +366,12 @@ int snd_ctl_ascii_value_parse(snd_ctl_t *handle, case SND_CTL_ELEM_TYPE_ENUMERATED: tmp = get_ctl_enum_item_index(handle, info, &ptr); if (tmp < 0) - tmp = get_integer(&ptr, 0, + tmp = get_integer(&ptr, 0, 0, snd_ctl_elem_info_get_items(info) - 1); snd_ctl_elem_value_set_enumerated(dst, idx, tmp); break; case SND_CTL_ELEM_TYPE_BYTES: - tmp = get_integer(&ptr, 0, 255); + tmp = get_integer(&ptr, 0, 0, 255); snd_ctl_elem_value_set_byte(dst, idx, tmp); break; default: