From patchwork Tue May 7 10:12:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 10932723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20B8B13AD for ; Tue, 7 May 2019 10:31:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E04628754 for ; Tue, 7 May 2019 10:31:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C73B2898B; Tue, 7 May 2019 10:31:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0BE3728987 for ; Tue, 7 May 2019 10:31:57 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5768C18A4; Tue, 7 May 2019 12:13:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5768C18A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1557224082; bh=QvvDzMxeWJA7SGj0diSpZbFBLnuKpApJDYyEqKm6eXs=; h=Date:In-Reply-To:References:From:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ENsYTTfc4gso86M8xJvKpa9pV2x4/JN6aeXJrrSjyEUeUU0/5GijNPOZzXkiO3sM5 Hs6wrjWXsQsHFA1augr6w+bGaFAjLBWcCClSrDcdl7YMF8/OGEzCzu4amOXL6kQoZO uetWxQKjYawMApqZ0poVRiTxU7aEELWosi6GKGRQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E6968F896DA; Tue, 7 May 2019 12:13:00 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1CB58F896EC; Tue, 7 May 2019 12:12:59 +0200 (CEST) Received: from mail-yw1-xc49.google.com (mail-yw1-xc49.google.com [IPv6:2607:f8b0:4864:20::c49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CDB67F89682 for ; Tue, 7 May 2019 12:12:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CDB67F89682 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="c4BkH8PB" Received: by mail-yw1-xc49.google.com with SMTP id b189so18017483ywa.19 for ; Tue, 07 May 2019 03:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pEs0YAvpVnOXt4JVkdCiFZqbRy+rm3fq+3JWY10YEQU=; b=c4BkH8PBLGS+qBp4V6RPqreYoE57I8tSGB6i/7uwu3d9bUvWfPK1/Go0bNPO1+tqPb c88JPinlV84R0YG0zEW+TiCwYpp/ytQnWzvLgN7nH0DGgMhgEP5zXaeQ6iCmJm8kNWMY uG1xivpq4OIxoDhGiVtQ703eRRS9B1Eig4brGJCydv22CoAy/NIygwMhbex9K78eCiVo ZtebXkJrxlHI5PvHZLmX46Sie5Q2cLo6L9ubUtWqIUXLJYKlN3owNiiKtjuB43tgZlVZ iAKtEeLWpW5WiGp1fYJWF8P8ozOJTq3RcpASKJz1jQo4ZBUq9Gn2BK73S4jG1BkLmyto TpeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=pEs0YAvpVnOXt4JVkdCiFZqbRy+rm3fq+3JWY10YEQU=; b=amQ4eZTc3ooELd3w0IUFYO+8PO4Sc4veg2Or1JETeCqar7G+tNk+ExDJN/8r2MQy8G EtVAUJdTGEnaqvmnVHe6mmrm+uMAdZVHSWsWSv2exLBIr1DGrBM15dljvwZH8bcWwMO2 UKyvF0c3CVKEhENa95hUe7gtOVD8v7UZRR2ujnzYWXpOf/bTMH/3YoHClxAzf5vAPh59 gkbpX/GTgISPmJe3BLOYTfS626NJ6/KXgz8e7Sy1iEVjF0DcuWJ8HKFDN3a5XXxEB3xg SmT7XcCdWXNxRc4J21x7ludHB4W9nBgYTP1VUmDsmzX0kXCmbhO4xboVkQIY2Woo1QfO nK/A== X-Gm-Message-State: APjAAAUhZ6Ek2Y8GWWhkyb9xJrnqqWKOyF2uxWjL+4Y8ApRu0XwrhCMR W/G/YUZJx1LGamu6B0OYXbnwv5otiBtj X-Google-Smtp-Source: APXvYqx3q+rVt6nHw7Q3W+MKT568yVbp4Fx30fN5sz2RETBeaJP64CAtnFQOy+MaIZNJrJFmNUvN6vlNm+im X-Received: by 2002:a0d:c481:: with SMTP id g123mr11460226ywd.230.1557223975376; Tue, 07 May 2019 03:12:55 -0700 (PDT) Date: Tue, 7 May 2019 18:12:18 +0800 In-Reply-To: <20190507101220.182466-1-tzungbi@google.com> Message-Id: <20190507101220.182466-2-tzungbi@google.com> Mime-Version: 1.0 References: <20190507101220.182466-1-tzungbi@google.com> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog From: Tzung-Bi Shih To: broonie@kernel.org, tiwai@suse.com Cc: tzungbi@google.com, alsa-devel@alsa-project.org, dgreid@google.com, cychiang@google.com Subject: [alsa-devel] [PATCH 1/3] ASoC: mediatek: mt6358: initialize setting when ramping volume X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP Mt6358 ramps up from the smallest volume (i.e. -10dB) to target dB when opening and ramps down from target dB to mute (i.e. -40dB) when closing. If target is equal to -10dB when opening, headset_volume_ramp() simply leaves current setting (which may not be -10dB) unchanged. Execute the loop at least once to initialize the setting to the starting point (i.e. from). Signed-off-by: Tzung-Bi Shih --- sound/soc/codecs/mt6358.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/mt6358.c b/sound/soc/codecs/mt6358.c index d4c4fee6d3d9..96547ae50a5d 100644 --- a/sound/soc/codecs/mt6358.c +++ b/sound/soc/codecs/mt6358.c @@ -405,10 +405,9 @@ static bool is_valid_hp_pga_idx(int reg_idx) reg_idx == DL_GAIN_N_40DB; } -static void headset_volume_ramp(struct mt6358_priv *priv, - int from, int to) +static void headset_volume_ramp(struct mt6358_priv *priv, int from, int to) { - int offset = 0, count = 1, reg_idx; + int offset = 0, count = 0, reg_idx; if (!is_valid_hp_pga_idx(from) || !is_valid_hp_pga_idx(to)) dev_warn(priv->dev, "%s(), volume index is not valid, from %d, to %d\n", @@ -422,7 +421,7 @@ static void headset_volume_ramp(struct mt6358_priv *priv, else offset = from - to; - while (offset > 0) { + while (offset >= 0) { if (to > from) reg_idx = from + count; else