From patchwork Tue May 21 10:04:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 17077 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 26C74238F5 for ; Tue, 21 May 2013 10:05:53 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id ox1sf552112veb.8 for ; Tue, 21 May 2013 03:05:02 -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=mLQ9ZS30nu8+fGERZgqGbPyE86XxSJOf11Vioq3uOb8=; b=DcXfFUaq9onc7zx4Z4XLS4S6tFURZ90z0LkKM05+8oNVD+E7pdNNbioRCe8t4OnaGh Dvu8ApRjV4+/O5u7YwB7hatphK8TX6gzx7P2pqn/COCYq4CvmyohAaKqWRPhleW7+hus 2F+NLYls3NYP7NfqOhWWmr7l3NrfbqR+AwxqBFC4ThJ0XDby5JfTedJvmPglSrlA8SJi oznI1j5MXz09J8Yyk4GICdjwmvbHD6VJ9kJJdqIOLfH26DtNBuqzrrG365iglGyWb7i4 36tJMh0et1cjHgL3LHZev4I4UMHU4fpDFLVZv//xQnT36sruJHdVFgsNGhtuq1EGGnwx UgSA== X-Received: by 10.224.217.195 with SMTP id hn3mr1158392qab.5.1369130702577; Tue, 21 May 2013 03:05:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.127.114 with SMTP id nf18ls201400qeb.8.gmail; Tue, 21 May 2013 03:05:02 -0700 (PDT) X-Received: by 10.52.110.133 with SMTP id ia5mr487270vdb.129.1369130702404; Tue, 21 May 2013 03:05:02 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id zp6si999581vdb.145.2013.05.21.03.05.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 May 2013 03:05:02 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id m17so272155vca.30 for ; Tue, 21 May 2013 03:05:02 -0700 (PDT) X-Received: by 10.52.233.34 with SMTP id tt2mr500556vdc.70.1369130702204; Tue, 21 May 2013 03:05:02 -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 c10csp122859vcs; Tue, 21 May 2013 03:05:01 -0700 (PDT) X-Received: by 10.205.68.195 with SMTP id xz3mr671250bkb.41.1369130701162; Tue, 21 May 2013 03:05:01 -0700 (PDT) Received: from mail-ea0-x229.google.com (mail-ea0-x229.google.com [2a00:1450:4013:c01::229]) by mx.google.com with ESMTPS id b6si2568701eez.21.2013.05.21.03.05.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 May 2013 03:05:01 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:4013:c01::229 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=2a00:1450:4013:c01::229; Received: by mail-ea0-f169.google.com with SMTP id m14so274450eaj.0 for ; Tue, 21 May 2013 03:05:00 -0700 (PDT) X-Received: by 10.15.35.71 with SMTP id f47mr4852859eev.15.1369130700524; Tue, 21 May 2013 03:05:00 -0700 (PDT) Received: from localhost ([2a01:2003:1:12f3:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPSA id bn53sm2461871eeb.7.2013.05.21.03.04.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 21 May 2013 03:04:59 -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 2/2] ASoC: ab8500-codec: Set rx dai slots from rx_mask Date: Tue, 21 May 2013 12:04:09 +0200 Message-Id: <1369130649-15179-3-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: ALoCoQnQhtOkl3XtK8J6a3zWXWDFvwYZ+vvcUeAB+CUxcC+SRPU2w04A7lO52ZluWGTVmG5wIhGa X-Original-Sender: fabio.baltieri@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 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 rx slot numbers from ab8500_codec_set_dai_tdm_slot using the ones requested by the machine driver in rx_mask instead. Signed-off-by: Fabio Baltieri --- sound/soc/codecs/ab8500-codec.c | 29 ++++++++++++++++++++--------- sound/soc/codecs/ab8500-codec.h | 35 +++++++++++++++-------------------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index bace321..4ca45b9 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c @@ -2334,25 +2334,36 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, } /* Setup TDM AD according to active RX-slots */ + + if (rx_mask & ~0xff) + return -EINVAL; + + rx_mask = rx_mask << AB8500_AD_DATA0_OFFSET; slots_active = hweight32(rx_mask); + dev_dbg(dai->codec->dev, "%s: Slots, active, RX: %d\n", __func__, slots_active); + switch (slots_active) { case 0: break; case 1: - /* AD_OUT3 -> slot 0 & 1 */ - snd_soc_update_bits(codec, AB8500_ADSLOTSEL1, AB8500_MASK_ALL, - AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_EVEN | - AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_ODD); + slot = find_first_bit((unsigned long *)&rx_mask, 32); + snd_soc_update_bits(codec, AB8500_ADSLOTSEL(slot), + AB8500_MASK_SLOT(slot), + AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); break; case 2: - /* AD_OUT3 -> slot 0, AD_OUT2 -> slot 1 */ + slot = find_first_bit((unsigned long *)&rx_mask, 32); + snd_soc_update_bits(codec, + AB8500_ADSLOTSEL(slot), + AB8500_MASK_SLOT(slot), + AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); + slot = find_next_bit((unsigned long *)&rx_mask, 32, slot + 1); snd_soc_update_bits(codec, - AB8500_ADSLOTSEL1, - AB8500_MASK_ALL, - AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_EVEN | - AB8500_ADSLOTSELX_AD_OUT2_TO_SLOT_ODD); + AB8500_ADSLOTSEL(slot), + AB8500_MASK_SLOT(slot), + AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT2, 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 64c14ce..e2e5442 100644 --- a/sound/soc/codecs/ab8500-codec.h +++ b/sound/soc/codecs/ab8500-codec.h @@ -80,6 +80,7 @@ #define AB8500_ADSLOTSEL14 0x2C #define AB8500_ADSLOTSEL15 0x2D #define AB8500_ADSLOTSEL16 0x2E +#define AB8500_ADSLOTSEL(slot) (AB8500_ADSLOTSEL1 + (slot >> 1)) #define AB8500_ADSLOTHIZCTRL1 0x2F #define AB8500_ADSLOTHIZCTRL2 0x30 #define AB8500_ADSLOTHIZCTRL3 0x31 @@ -151,6 +152,7 @@ #define AB8500_CACHEREGNUM (AB8500_LAST_REG + 1) #define AB8500_MASK_ALL 0xFF +#define AB8500_MASK_SLOT(slot) ((slot & 1) ? 0xF0 : 0x0F) #define AB8500_MASK_NONE 0x00 /* AB8500_POWERUP */ @@ -354,28 +356,21 @@ #define AB8500_DIGIFCONF4_IF1WL0 0 /* AB8500_ADSLOTSELX */ -#define AB8500_ADSLOTSELX_AD_OUT1_TO_SLOT_ODD 0x00 -#define AB8500_ADSLOTSELX_AD_OUT2_TO_SLOT_ODD 0x10 -#define AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_ODD 0x20 -#define AB8500_ADSLOTSELX_AD_OUT4_TO_SLOT_ODD 0x30 -#define AB8500_ADSLOTSELX_AD_OUT5_TO_SLOT_ODD 0x40 -#define AB8500_ADSLOTSELX_AD_OUT6_TO_SLOT_ODD 0x50 -#define AB8500_ADSLOTSELX_AD_OUT7_TO_SLOT_ODD 0x60 -#define AB8500_ADSLOTSELX_AD_OUT8_TO_SLOT_ODD 0x70 -#define AB8500_ADSLOTSELX_ZEROES_TO_SLOT_ODD 0x80 -#define AB8500_ADSLOTSELX_TRISTATE_TO_SLOT_ODD 0xF0 -#define AB8500_ADSLOTSELX_AD_OUT1_TO_SLOT_EVEN 0x00 -#define AB8500_ADSLOTSELX_AD_OUT2_TO_SLOT_EVEN 0x01 -#define AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_EVEN 0x02 -#define AB8500_ADSLOTSELX_AD_OUT4_TO_SLOT_EVEN 0x03 -#define AB8500_ADSLOTSELX_AD_OUT5_TO_SLOT_EVEN 0x04 -#define AB8500_ADSLOTSELX_AD_OUT6_TO_SLOT_EVEN 0x05 -#define AB8500_ADSLOTSELX_AD_OUT7_TO_SLOT_EVEN 0x06 -#define AB8500_ADSLOTSELX_AD_OUT8_TO_SLOT_EVEN 0x07 -#define AB8500_ADSLOTSELX_ZEROES_TO_SLOT_EVEN 0x08 -#define AB8500_ADSLOTSELX_TRISTATE_TO_SLOT_EVEN 0x0F +#define AB8500_AD_OUT1 0x0 +#define AB8500_AD_OUT2 0x1 +#define AB8500_AD_OUT3 0x2 +#define AB8500_AD_OUT4 0x3 +#define AB8500_AD_OUT5 0x4 +#define AB8500_AD_OUT6 0x5 +#define AB8500_AD_OUT7 0x6 +#define AB8500_AD_OUT8 0x7 +#define AB8500_ZEROES 0x8 +#define AB8500_TRISTATE 0xF #define AB8500_ADSLOTSELX_EVEN_SHIFT 0 #define AB8500_ADSLOTSELX_ODD_SHIFT 4 +#define AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(out, slot) \ + ((out) << (((slot) & 1) ? \ + AB8500_ADSLOTSELX_ODD_SHIFT : AB8500_ADSLOTSELX_EVEN_SHIFT)) /* AB8500_ADSLOTHIZCTRL1 */ /* AB8500_ADSLOTHIZCTRL2 */