From patchwork Sun Jul 6 18:25:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: atx@atx.name X-Patchwork-Id: 4493961 X-Patchwork-Delegate: tiwai@suse.de 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 46C559F1AC for ; Mon, 7 Jul 2014 08:57:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 528D320265 for ; Mon, 7 Jul 2014 08:57:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 045B72024D for ; Mon, 7 Jul 2014 08:57:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id EC0682655AC; Mon, 7 Jul 2014 10:57:20 +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, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 4864826504F; Mon, 7 Jul 2014 10:56:36 +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 814272650D5; Sun, 6 Jul 2014 20:25:19 +0200 (CEST) Received: from we2-f167.wedos.net (w-smtp-out-7.wedos.net [46.28.106.5]) by alsa0.perex.cz (Postfix) with ESMTP id 62DAD265086; Sun, 6 Jul 2014 20:25:11 +0200 (CEST) Received: from ([213.226.206.59]) by we2-f167.wedos.net (WEDOS Mail Server mail2) with ASMTP (SSL) id SDF00109; Sun, 06 Jul 2014 20:25:09 +0200 Date: Sun, 6 Jul 2014 20:25:10 +0200 From: Josef Gajdusek To: patch@alsa-project.org Message-ID: <20140706182510.GA6314@dashie> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.22 (2013-10-16) X-Mailman-Approved-At: Mon, 07 Jul 2014 10:56:33 +0200 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH] amixer: Fix convert_prange1 not rounding correctly 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 The convert_prange1 macro was not the exact inverse of convert_prange. This was causing the volume percentage set by 'amixer set' to differ from the one displayed by 'amixer get'. Signed-off-by: Josef Gajdusek --- amixer/amixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amixer/amixer.c b/amixer/amixer.c index cf82892..577a2ca 100644 --- a/amixer/amixer.c +++ b/amixer/amixer.c @@ -201,7 +201,7 @@ static int convert_prange(long val, long min, long max) /* Function to convert from percentage to volume. val = percentage */ #define convert_prange1(val, min, max) \ - ceil((val) * ((max) - (min)) * 0.01 + (min)) + rint((val) * ((max) - (min)) * 0.01 + (min)) struct volume_ops { int (*get_range)(snd_mixer_elem_t *elem, long *min, long *max);