From patchwork Sun Aug 2 15:19:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 6924911 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3AAF99F373 for ; Sun, 2 Aug 2015 15:21:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F4DF20426 for ; Sun, 2 Aug 2015 15:21:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 36AA820429 for ; Sun, 2 Aug 2015 15:21:07 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7FB502650CC; Sun, 2 Aug 2015 17:21:04 +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=-2.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 4A66C26149E; Sun, 2 Aug 2015 17:20:26 +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 518782608D4; Sun, 2 Aug 2015 17:20:24 +0200 (CEST) Received: from smtp-out-138.synserver.de (smtp-out-138.synserver.de [212.40.185.138]) by alsa0.perex.cz (Postfix) with ESMTP id 2AB922606A6 for ; Sun, 2 Aug 2015 17:20:17 +0200 (CEST) Received: (qmail 31339 invoked by uid 0); 2 Aug 2015 15:20:16 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 31181 Received: from ppp-188-174-94-41.dynamic.mnet-online.de (HELO lars-laptop.fritz.box) [188.174.94.41] by 217.119.54.81 with SMTP; 2 Aug 2015 15:20:16 -0000 From: Lars-Peter Clausen To: Mark Brown , Liam Girdwood Date: Sun, 2 Aug 2015 17:19:29 +0200 Message-Id: <1438528810-23498-2-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438528810-23498-1-git-send-email-lars@metafoo.de> References: <1438528810-23498-1-git-send-email-lars@metafoo.de> Cc: Oder Chiou , Brian Austin , Lars-Peter Clausen , Support Opensource , Anish Kumar , patches@opensource.wolfsonmicro.com, alsa-devel@alsa-project.org, Paul Handrigan , Peter Ujfalusi , Bard Liao , Charles Keepax Subject: [alsa-devel] [PATCH 01/42] ASoC: 88pm860x: Replace TLV_DB_RANGE_HEAD with DECLARE_TLV_DB_RANGE 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 DECLARE_TLV_DB_RANGE() has the advantage over using TLV_DB_RANGE_HEAD() that it automatically calculates the number of items in the TLV and is hence less prone to manual error. Generate using the following coccinelle script // @@ declarer name DECLARE_TLV_DB_RANGE; identifier tlv; constant x; @@ -unsigned int tlv[] = { - TLV_DB_RANGE_HEAD(x), +DECLARE_TLV_DB_RANGE(tlv, ... -}; +); // Signed-off-by: Lars-Peter Clausen --- sound/soc/codecs/88pm860x-codec.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index 4d91a6a..e8bed6b 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -156,33 +156,29 @@ static const DECLARE_TLV_DB_SCALE(dpga_tlv, -9450, 150, 1); static const DECLARE_TLV_DB_SCALE(adc_tlv, -900, 300, 0); /* {-23, -17, -13.5, -11, -9, -6, -3, 0}dB */ -static const unsigned int mic_tlv[] = { - TLV_DB_RANGE_HEAD(5), +static const DECLARE_TLV_DB_RANGE(mic_tlv, 0, 0, TLV_DB_SCALE_ITEM(-2300, 0, 0), 1, 1, TLV_DB_SCALE_ITEM(-1700, 0, 0), 2, 2, TLV_DB_SCALE_ITEM(-1350, 0, 0), 3, 3, TLV_DB_SCALE_ITEM(-1100, 0, 0), - 4, 7, TLV_DB_SCALE_ITEM(-900, 300, 0), -}; + 4, 7, TLV_DB_SCALE_ITEM(-900, 300, 0) +); /* {0, 0, 0, -6, 0, 6, 12, 18}dB */ -static const unsigned int aux_tlv[] = { - TLV_DB_RANGE_HEAD(2), +static const DECLARE_TLV_DB_RANGE(aux_tlv, 0, 2, TLV_DB_SCALE_ITEM(0, 0, 0), - 3, 7, TLV_DB_SCALE_ITEM(-600, 600, 0), -}; + 3, 7, TLV_DB_SCALE_ITEM(-600, 600, 0) +); /* {-16, -13, -10, -7, -5.2, -3,3, -2.2, 0}dB, mute instead of -16dB */ -static const unsigned int out_tlv[] = { - TLV_DB_RANGE_HEAD(4), +static const DECLARE_TLV_DB_RANGE(out_tlv, 0, 3, TLV_DB_SCALE_ITEM(-1600, 300, 1), 4, 4, TLV_DB_SCALE_ITEM(-520, 0, 0), 5, 5, TLV_DB_SCALE_ITEM(-330, 0, 0), - 6, 7, TLV_DB_SCALE_ITEM(-220, 220, 0), -}; + 6, 7, TLV_DB_SCALE_ITEM(-220, 220, 0) +); -static const unsigned int st_tlv[] = { - TLV_DB_RANGE_HEAD(8), +static const DECLARE_TLV_DB_RANGE(st_tlv, 0, 1, TLV_DB_SCALE_ITEM(-12041, 602, 0), 2, 3, TLV_DB_SCALE_ITEM(-11087, 250, 0), 4, 5, TLV_DB_SCALE_ITEM(-10643, 158, 0), @@ -190,8 +186,8 @@ static const unsigned int st_tlv[] = { 8, 9, TLV_DB_SCALE_ITEM(-10133, 92, 0), 10, 13, TLV_DB_SCALE_ITEM(-9958, 70, 0), 14, 17, TLV_DB_SCALE_ITEM(-9689, 53, 0), - 18, 271, TLV_DB_SCALE_ITEM(-9484, 37, 0), -}; + 18, 271, TLV_DB_SCALE_ITEM(-9484, 37, 0) +); /* Sidetone Gain = M * 2^(-5-N) */ struct st_gain {