From patchwork Tue Sep 2 03:30:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Hsu X-Patchwork-Id: 36438 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E936A2032B for ; Tue, 2 Sep 2014 03:30:55 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rp18sf35212309iec.0 for ; Mon, 01 Sep 2014 20:30:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=isT6FHItmKnwuQFGjbPMvmBCs4WAjPQw7N/kR6mmmwU=; b=PFDZHCp557l00DoB5KAfp5AYf3DBkuJEilaHzrg+FIqxtqAdgFNAzCDP/BHokyu0xY BcEw4PtHTxHKAakD8CDJMunBrc0HKL5XVbLyRX84MRaObSvS1zVSpQPH7aHZCcAMUrmA 4bCRkZAbG43rzCFdeG/vLDwqZKXx3ebjeJNZNHm9en8O38ph24uAQWe1Pit6Qb6lQaar aOnVSpBKbPDivA3Z4AvJvoL5SH3oAJ7RGGODxSQjSII3VUhpZCOp7SkfyfplKw8++Ld6 BV2kh2vZzIrzvxOEAWrw8cQ/K+FgigA/s+jPjrq0CHKVA1zTgjI6v11D7e6L1cZKuzpr diVA== X-Gm-Message-State: ALoCoQmJbuIzyaJ1DRIBenVGRNmZlz0NpNW6/xIgcMAcBmhf9KMvm37GFwUQF9clnWJjF1DKGgkt X-Received: by 10.50.25.129 with SMTP id c1mr5230609igg.7.1409628655587; Mon, 01 Sep 2014 20:30:55 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.235 with SMTP id q98ls2180226qga.91.gmail; Mon, 01 Sep 2014 20:30:55 -0700 (PDT) X-Received: by 10.52.135.133 with SMTP id ps5mr22428183vdb.33.1409628655497; Mon, 01 Sep 2014 20:30:55 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id t6si1766774vdf.14.2014.09.01.20.30.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 20:30:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id im17so6292401vcb.41 for ; Mon, 01 Sep 2014 20:30:55 -0700 (PDT) X-Received: by 10.220.81.132 with SMTP id x4mr28176557vck.0.1409628655426; Mon, 01 Sep 2014 20:30:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp465335vcb; Mon, 1 Sep 2014 20:30:54 -0700 (PDT) X-Received: by 10.70.45.74 with SMTP id k10mr42615448pdm.78.1409628654597; Mon, 01 Sep 2014 20:30:54 -0700 (PDT) Received: from Kraken ([124.219.7.128]) by mx.google.com with ESMTP id fa12si3616878pad.170.2014.09.01.20.30.52 for ; Mon, 01 Sep 2014 20:30:54 -0700 (PDT) Received-SPF: none (google.com: xavier@kraken does not designate permitted sender hosts) client-ip=124.219.7.128; Received: by Kraken (Postfix, from userid 1011) id 7BD536A27A3; Tue, 2 Sep 2014 11:30:51 +0800 (CST) From: Xavier Hsu To: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, patches@linaro.org Cc: lars@metafoo.de, ckeepax@opensource.wolfsonmicro.com, Xavier Hsu , Andy Green Subject: [PATCHv3 3/9] WM8971 uses TLV information Date: Tue, 2 Sep 2014 11:30:42 +0800 Message-Id: <1409628648-13732-3-git-send-email-xavier.hsu@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1409628648-13732-1-git-send-email-xavier.hsu@linaro.org> References: <1409628648-13732-1-git-send-email-xavier.hsu@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: xavier.hsu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch improves WM8971. We use TLV information. Any comments about improving the patch are welcome. Thanks. Signed-off-by: Xavier Hsu Signed-off-by: Andy Green --- sound/soc/codecs/wm8971.c | 59 ++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 59c4828..7c2b175 100755 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c @@ -30,10 +30,11 @@ #include #include #include +#include #include "wm8971.h" -#define WM8971_REG_COUNT 43 +#define WM8971_REG_COUNT 43 static struct workqueue_struct *wm8971_workq; @@ -205,8 +206,19 @@ static const SOC_ENUM_SINGLE_DECL(capture_polarity, WM8971_ADCDAC, 5, wm8971_adcpol); static const SOC_ENUM_SINGLE_DECL(monomux, WM8971_ADCIN, 6, wm8971_mono_mux); +static const DECLARE_TLV_DB_SCALE(in_vol, -1725, 75, 0); +static const DECLARE_TLV_DB_SCALE(out_vol, -6700, 91, 0); +static const DECLARE_TLV_DB_SCALE(attenuate_6db, -600, 600, 0); +static const DECLARE_TLV_DB_SCALE(dac_vol, -12700, 50, 0); +static const DECLARE_TLV_DB_SCALE(tone_vol, -600, 150, 0); +static const DECLARE_TLV_DB_SCALE(alc_tar_vol, -2850, 150, 0); +static const DECLARE_TLV_DB_SCALE(alc_max_vol, -1200, 600, 0); +static const DECLARE_TLV_DB_SCALE(adc_vol, -9700, 50, 0); +static const DECLARE_TLV_DB_SCALE(bypass_out_vol, -1500, 300, 0); + static const struct snd_kcontrol_new wm8971_snd_controls[] = { - SOC_DOUBLE_R("Capture Volume", WM8971_LINVOL, WM8971_RINVOL, 0, 63, 0), + SOC_DOUBLE_R_TLV("Capture Volume", WM8971_LINVOL, WM8971_RINVOL, + 0, 63, 0, in_vol), SOC_DOUBLE_R("Capture ZC Switch", WM8971_LINVOL, WM8971_RINVOL, 6, 1, 0), SOC_DOUBLE_R("Capture Switch", WM8971_LINVOL, WM8971_RINVOL, 7, 1, 1), @@ -217,31 +229,35 @@ static const struct snd_kcontrol_new wm8971_snd_controls[] = { WM8971_ROUT2V, 7, 1, 0), SOC_SINGLE("Mono Playback ZC Switch", WM8971_MOUTV, 7, 1, 0), - SOC_DOUBLE_R("PCM Volume", WM8971_LDAC, WM8971_RDAC, 0, 255, 0), + SOC_DOUBLE_R_TLV("PCM Volume", WM8971_LDAC, WM8971_RDAC, + 0, 255, 0, dac_vol), - SOC_DOUBLE_R("Bypass Left Playback Volume", WM8971_LOUTM1, - WM8971_LOUTM2, 4, 7, 1), - SOC_DOUBLE_R("Bypass Right Playback Volume", WM8971_ROUTM1, - WM8971_ROUTM2, 4, 7, 1), - SOC_DOUBLE_R("Bypass Mono Playback Volume", WM8971_MOUTM1, - WM8971_MOUTM2, 4, 7, 1), + SOC_DOUBLE_R_TLV("Bypass Left Playback Volume", WM8971_LOUTM1, + WM8971_LOUTM2, 4, 7, 1, bypass_out_vol), + SOC_DOUBLE_R_TLV("Bypass Right Playback Volume", WM8971_ROUTM1, + WM8971_ROUTM2, 4, 7, 1, bypass_out_vol), + SOC_DOUBLE_R_TLV("Bypass Mono Playback Volume", WM8971_MOUTM1, + WM8971_MOUTM2, 4, 7, 1, bypass_out_vol), - SOC_DOUBLE_R("Headphone Playback Volume", WM8971_LOUT1V, - WM8971_ROUT1V, 0, 127, 0), - SOC_DOUBLE_R("Speaker Playback Volume", WM8971_LOUT2V, - WM8971_ROUT2V, 0, 127, 0), + SOC_DOUBLE_R_TLV("Headphone Playback Volume", WM8971_LOUT1V, + WM8971_ROUT1V, 0, 127, 0, out_vol), + SOC_DOUBLE_R_TLV("Speaker Playback Volume", WM8971_LOUT2V, + WM8971_ROUT2V, 0, 127, 0, out_vol), + SOC_SINGLE_TLV("Mono Playback Volume", WM8971_MOUTV, + 0, 127, 0, out_vol), SOC_ENUM("Bass Boost", bass_boost), SOC_ENUM("Bass Filter", bass_filter), - SOC_SINGLE("Bass Volume", WM8971_BASS, 0, 7, 1), + SOC_SINGLE_TLV("Bass Volume", WM8971_BASS, 0, 15, 1, tone_vol), - SOC_SINGLE("Treble Volume", WM8971_TREBLE, 0, 7, 0), + SOC_SINGLE_TLV("Treble Volume", WM8971_TREBLE, 0, 15, 0, tone_vol), SOC_ENUM("Treble Cut-off", treble_cutoff), SOC_SINGLE("Capture Filter Switch", WM8971_ADCDAC, 0, 1, 1), - SOC_SINGLE("ALC Target Volume", WM8971_ALC1, 0, 7, 0), - SOC_SINGLE("ALC Max Volume", WM8971_ALC1, 4, 7, 0), + SOC_SINGLE_TLV("ALC Target Volume", WM8971_ALC1, + 0, 15, 0, alc_tar_vol), + SOC_SINGLE_TLV("ALC Max Volume", WM8971_ALC1, 4, 7, 0, alc_max_vol), SOC_SINGLE("ALC Capture Target Volume", WM8971_ALC1, 0, 7, 0), SOC_SINGLE("ALC Capture Max Volume", WM8971_ALC1, 4, 7, 0), @@ -254,8 +270,10 @@ static const struct snd_kcontrol_new wm8971_snd_controls[] = { SOC_ENUM("ALC Capture NG Type", alc_capture_ngtype), SOC_SINGLE("ALC Capture NG Switch", WM8971_NGATE, 0, 1, 0), - SOC_SINGLE("Capture 6dB Attenuate", WM8971_ADCDAC, 8, 1, 0), - SOC_SINGLE("Playback 6dB Attenuate", WM8971_ADCDAC, 7, 1, 0), + SOC_SINGLE_TLV("Capture 6dB Attenuate", WM8971_ADCDAC, + 8, 1, 0, attenuate_6db), + SOC_SINGLE_TLV("Playback 6dB Attenuate", WM8971_ADCDAC, + 7, 1, 0, attenuate_6db), SOC_SINGLE_BOOL_EXT("Playback De-emphasis Switch", 0, wm8971_get_deemph, wm8971_put_deemph), @@ -263,6 +281,9 @@ static const struct snd_kcontrol_new wm8971_snd_controls[] = { SOC_ENUM("Playback Phase", dac_phase_inv), SOC_DOUBLE_R("Mic Boost", WM8971_LADCIN, WM8971_RADCIN, 4, 3, 0), + + SOC_DOUBLE_R_TLV("ADC Volume", WM8971_LADC, WM8971_RADC, + 0, 255, 0, adc_vol), }; /*