From patchwork Tue May 28 14:16:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 17246 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 74EC323911 for ; Tue, 28 May 2013 14:18:02 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id hq7sf2540215wib.8 for ; Tue, 28 May 2013 07:16:55 -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 :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=mykq6rOuue2vYshJaXqzkyUygYwbGD72JRJF0AmKHBA=; b=cXu/7LhXBBZtMac2zcCjZKo4yXKSR/rG/MAsZDQFrZHBzIsSJCrEJAIuFRQL219d8D fKuTSGo2sDC/nNmUO/aAAeD5H6Aoe3dnHTFVK4SgWapfJ7luZ9E9ql6NVwOBREeYtxAF rkWeMrv6Ah5iCI6jz0/0I0nA9N2O5g18KjMjOpUGQUlZkkMPlxVbi4QOTK+02Tq5DbJ2 8p1h8E+YIrhBJKZL96uxnHk7WGSES9NoCgYotumV/lb7lxP1mjvzMzjVwxN+v3bGcFpA yTLRn4+hf17y0DGM+pPxHFx4iCDeAI4NrmQwnmtw1GSAhsCNP9LTZ3XbEZmjB1+8rgW2 1O6Q== X-Received: by 10.180.12.200 with SMTP id a8mr4905434wic.1.1369750614584; Tue, 28 May 2013 07:16:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.19.227 with SMTP id i3ls1096940wie.25.gmail; Tue, 28 May 2013 07:16:54 -0700 (PDT) X-Received: by 10.180.11.176 with SMTP id r16mr12183333wib.58.1369750614526; Tue, 28 May 2013 07:16:54 -0700 (PDT) Received: from mail-ve0-x229.google.com (mail-ve0-x229.google.com [2607:f8b0:400c:c01::229]) by mx.google.com with ESMTPS id w1si5773888wij.77.2013.05.28.07.16.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 May 2013 07:16:54 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::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:c01::229; Received: by mail-ve0-f169.google.com with SMTP id jw11so5991903veb.28 for ; Tue, 28 May 2013 07:16:53 -0700 (PDT) X-Received: by 10.52.69.200 with SMTP id g8mr15212205vdu.4.1369750613438; Tue, 28 May 2013 07:16:53 -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.229.199 with SMTP id jj7csp41740vcb; Tue, 28 May 2013 07:16:52 -0700 (PDT) X-Received: by 10.204.76.205 with SMTP id d13mr4177112bkk.147.1369750611684; Tue, 28 May 2013 07:16:51 -0700 (PDT) Received: from mail-bk0-x234.google.com (mail-bk0-x234.google.com [2a00:1450:4008:c01::234]) by mx.google.com with ESMTPS id ls9si4348592bkb.260.2013.05.28.07.16.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 May 2013 07:16:51 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:4008:c01::234 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=2a00:1450:4008:c01::234; Received: by mail-bk0-f52.google.com with SMTP id mz10so4228556bkb.39 for ; Tue, 28 May 2013 07:16:51 -0700 (PDT) X-Received: by 10.204.239.199 with SMTP id kx7mr4238756bkb.153.1369750610906; Tue, 28 May 2013 07:16:50 -0700 (PDT) Received: from localhost ([2a01:2003:1:12f3:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPSA id de16sm4414331bkb.5.2013.05.28.07.16.47 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 28 May 2013 07:16:49 -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] ASoC: ux500: Ensure consistent configuration between DAIs Date: Tue, 28 May 2013 16:16:39 +0200 Message-Id: <1369750599-10795-1-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.2 X-Gm-Message-State: ALoCoQndVAeJQsW7NT5BWJeYIw1yjCEuzBeLtCgQsdDmFsYcD+I9OblcKYHHkCj6lq9/kVgqixZC X-Original-Sender: fabio.baltieri@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::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: , Current implementation of mop500_ab8500 allows for inconsistent sample rate and channel count configuration between the playback and recording interfaces, through in the hardware the two MSP controllers share common clock and frame sync signals. This patch adds the necessary code to ensure that the two device are configure consistently. The check is added at machine driver level, as how to lock DAI configuration depend of the actual hardware implementation. Signed-off-by: Fabio Baltieri --- sound/soc/ux500/mop500_ab8500.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/sound/soc/ux500/mop500_ab8500.c b/sound/soc/ux500/mop500_ab8500.c index 5e0f146..7e923ec 100644 --- a/sound/soc/ux500/mop500_ab8500.c +++ b/sound/soc/ux500/mop500_ab8500.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,12 @@ static unsigned int tx_slots = DEF_TX_SLOTS; static unsigned int rx_slots = DEF_RX_SLOTS; +/* Configuration consistency parameters */ +static DEFINE_MUTEX(mop500_ab8500_params_lock); +static unsigned long mop500_ab8500_usage; +static int mop500_ab8500_rate; +static int mop500_ab8500_channels; + /* Clocks */ static const char * const enum_mclk[] = { "SYSCLK", @@ -231,6 +238,21 @@ static int mop500_ab8500_hw_params(struct snd_pcm_substream *substream, substream->name, substream->number); + /* Ensure configuration consistency between DAIs */ + mutex_lock(&mop500_ab8500_params_lock); + if (mop500_ab8500_usage) { + if (mop500_ab8500_rate != params_rate(params) || + mop500_ab8500_channels != params_channels(params)) { + mutex_unlock(&mop500_ab8500_params_lock); + return -EBUSY; + } + } else { + mop500_ab8500_rate = params_rate(params); + mop500_ab8500_channels = params_channels(params); + } + __set_bit(cpu_dai->id, &mop500_ab8500_usage); + mutex_unlock(&mop500_ab8500_params_lock); + channels = params_channels(params); switch (params_format(params)) { @@ -329,9 +351,22 @@ static int mop500_ab8500_hw_params(struct snd_pcm_substream *substream, return 0; } +static int mop500_ab8500_hw_free(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + + mutex_lock(&mop500_ab8500_params_lock); + __clear_bit(cpu_dai->id, &mop500_ab8500_usage); + mutex_unlock(&mop500_ab8500_params_lock); + + return 0; +} + struct snd_soc_ops mop500_ab8500_ops[] = { { .hw_params = mop500_ab8500_hw_params, + .hw_free = mop500_ab8500_hw_free, .startup = mop500_ab8500_startup, .shutdown = mop500_ab8500_shutdown, }