From patchwork Tue May 21 10:04:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 17076 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 539CE238F5 for ; Tue, 21 May 2013 10:05:40 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id a41sf539500yho.10 for ; Tue, 21 May 2013 03:04:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=Tk8Ht2i2SGCrykjgJs34avF1nLCDxdtnYGq2b9CSGmQ=; b=WCde+Zl7h9dL8pnEjTnh816pD/j4dS2dKKFzvuIPjz2uzroN/QBEzeduPiEDh3/mWM V/dRw38FLbaNyb/QAkHWics60zjjJBsPn4SJ1CM04yDlieYINQQOKfSccuzqrU1q+noE 2jImn4ze/M4wmcQyCoQqrCZKHGVfc/2llIuxreKBY8R3+airP2HUnf7eU3GXkS357nRv 58Ds2GKZTyv+m4I8nUgDlQB8w4BkD7TY8ihFluDHI8Fi9BhBaR+gypv8Eqw8i0O+Q2ko rJfDwYUsluAyIuY0PHP0vwzNkJ09K9Jt0rKpWlCFofQZ/MlLhM9TNEgI/2T+RRxlHSBx vcfw== X-Received: by 10.224.59.205 with SMTP id m13mr1156137qah.7.1369130690043; Tue, 21 May 2013 03:04:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.83.36 with SMTP id n4ls200901qey.76.gmail; Tue, 21 May 2013 03:04:49 -0700 (PDT) X-Received: by 10.58.180.196 with SMTP id dq4mr604064vec.10.1369130689906; Tue, 21 May 2013 03:04:49 -0700 (PDT) Received: from mail-vb0-x229.google.com (mail-vb0-x229.google.com [2607:f8b0:400c:c02::229]) by mx.google.com with ESMTPS id b7si1021604vcv.53.2013.05.21.03.04.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 May 2013 03:04:49 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::229 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::229; Received: by mail-vb0-f41.google.com with SMTP id p14so268340vbm.28 for ; Tue, 21 May 2013 03:04:49 -0700 (PDT) X-Received: by 10.52.69.200 with SMTP id g8mr514247vdu.4.1369130689729; Tue, 21 May 2013 03:04:49 -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.220.126.138 with SMTP id c10csp122851vcs; Tue, 21 May 2013 03:04:49 -0700 (PDT) X-Received: by 10.204.172.80 with SMTP id k16mr662880bkz.123.1369130688539; Tue, 21 May 2013 03:04:48 -0700 (PDT) Received: from mail-ee0-f46.google.com (mail-ee0-f46.google.com [74.125.83.46]) by mx.google.com with ESMTPS id v46si2461547een.259.2013.05.21.03.04.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 May 2013 03:04:48 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.46 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=74.125.83.46; Received: by mail-ee0-f46.google.com with SMTP id e49so274576eek.33 for ; Tue, 21 May 2013 03:04:48 -0700 (PDT) X-Received: by 10.14.181.131 with SMTP id l3mr4825020eem.16.1369130687925; Tue, 21 May 2013 03:04:47 -0700 (PDT) Received: from localhost ([2a01:2003:1:12f3:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPSA id x41sm2402624eey.17.2013.05.21.03.04.41 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 21 May 2013 03:04:47 -0700 (PDT) From: Fabio Baltieri To: Mark Brown Cc: Liam Girdwood , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Linus Walleij , Lee Jones , Ola Lilja , Fabio Baltieri Subject: [PATCH 1/2] ASoC: ab8500-codec: Set tx dai slots from tx_mask Date: Tue, 21 May 2013 12:04:08 +0200 Message-Id: <1369130649-15179-2-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.2 In-Reply-To: <1369130649-15179-1-git-send-email-fabio.baltieri@linaro.org> References: <1369130649-15179-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQljbdJBVuonXxU6F7UL4HAwRsyCG3DRs1UNUuFVAccsyWWo40fYtgk1SlCpuTdb2F8+RV/Z X-Original-Sender: fabio.baltieri@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::229 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , Replace hard-coded tx slot numbers from ab8500_codec_set_dai_tdm_slot using the ones requested by the machine driver in tx_mask instead. Signed-off-by: Fabio Baltieri --- sound/soc/codecs/ab8500-codec.c | 31 +++++++++++++++++++------------ sound/soc/codecs/ab8500-codec.h | 7 +++++++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 3126cac..bace321 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c @@ -2236,7 +2236,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, int slots, int slot_width) { struct snd_soc_codec *codec = dai->codec; - unsigned int val, mask, slots_active; + unsigned int val, mask, slot, slots_active; mask = BIT(AB8500_DIGIFCONF2_IF0WL0) | BIT(AB8500_DIGIFCONF2_IF0WL1); @@ -2292,27 +2292,34 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, snd_soc_update_bits(codec, AB8500_DIGIFCONF1, mask, val); /* Setup TDM DA according to active tx slots */ + + if (tx_mask & ~0xff) + return -EINVAL; + mask = AB8500_DASLOTCONFX_SLTODAX_MASK; + tx_mask = tx_mask << AB8500_DA_DATA0_OFFSET; slots_active = hweight32(tx_mask); + dev_dbg(dai->codec->dev, "%s: Slots, active, TX: %d\n", __func__, slots_active); + switch (slots_active) { case 0: break; case 1: - /* Slot 9 -> DA_IN1 & DA_IN3 */ - snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, 11); - snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, 11); - snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, 11); - snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, 11); + slot = find_first_bit((unsigned long *)&tx_mask, 32); + snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); + snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); + snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); + snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); break; case 2: - /* Slot 9 -> DA_IN1 & DA_IN3, Slot 11 -> DA_IN2 & DA_IN4 */ - snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, 9); - snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, 9); - snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, 11); - snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, 11); - + slot = find_first_bit((unsigned long *)&tx_mask, 32); + snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); + snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); + slot = find_next_bit((unsigned long *)&tx_mask, 32, slot + 1); + snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); + snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); break; case 8: dev_dbg(dai->codec->dev, diff --git a/sound/soc/codecs/ab8500-codec.h b/sound/soc/codecs/ab8500-codec.h index 306d0bc..64c14ce 100644 --- a/sound/soc/codecs/ab8500-codec.h +++ b/sound/soc/codecs/ab8500-codec.h @@ -24,6 +24,13 @@ #define AB8500_SUPPORTED_RATE (SNDRV_PCM_RATE_48000) #define AB8500_SUPPORTED_FMT (SNDRV_PCM_FMTBIT_S16_LE) +/* AB8500 interface slot offset definitions */ + +#define AB8500_AD_DATA0_OFFSET 0 +#define AB8500_DA_DATA0_OFFSET 8 +#define AB8500_AD_DATA1_OFFSET 16 +#define AB8500_DA_DATA1_OFFSET 24 + /* AB8500 audio bank (0x0d) register definitions */ #define AB8500_POWERUP 0x00