From patchwork Wed Oct 22 15:13:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 5133241 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AF4DC9F349 for ; Wed, 22 Oct 2014 15:16:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D185A2015E for ; Wed, 22 Oct 2014 15:16:06 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A52BB20138 for ; Wed, 22 Oct 2014 15:16:05 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 32336265249; Wed, 22 Oct 2014 17:16: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=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 1CE062651EF; Wed, 22 Oct 2014 17:15:53 +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 889152651FD; Wed, 22 Oct 2014 17:15:52 +0200 (CEST) Received: from EMAIL.axentia.se (axentia.se [87.96.186.132]) by alsa0.perex.cz (Postfix) with ESMTP id 72F8C2651EE for ; Wed, 22 Oct 2014 17:15:44 +0200 (CEST) Received: from EMAIL.axentia.se (192.168.2.5) by EMAIL.axentia.se (192.168.2.5) with Microsoft SMTP Server (TLS) id 15.0.775.38; Wed, 22 Oct 2014 17:13:56 +0200 Received: from EMAIL.axentia.se ([fe80::5810:5f52:e9e0:1395]) by EMAIL.axentia.se ([fe80::5810:5f52:e9e0:1395%10]) with mapi id 15.00.0775.031; Wed, 22 Oct 2014 17:13:56 +0200 From: Peter Rosin To: Bo Shen Thread-Topic: [PATCH v2] ASoC: atmel_ssc_dai: Match the CMR divider only in full duplex. Thread-Index: Ac/uCq+7f2mIJZfwS7Gq4jwDTeKBCg== Date: Wed, 22 Oct 2014 15:13:55 +0000 Message-ID: <5733bb4302d148feb0bbd8ffd8c054a2@EMAIL.axentia.se> Accept-Language: en-US, sv-SE Content-Language: sv-SE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [217.210.101.82] x-gfi-smtp-submission: 1 x-gfi-smtp-hellodomain: EMAIL.axentia.se x-gfi-smtp-remoteip: 192.168.2.5 MIME-Version: 1.0 Cc: Takashi Iwai , "'alsa-devel@alsa-project.org'" , Mark Brown , "linux-kernel@vger.kernel.org" , Liam Girdwood Subject: [alsa-devel] [PATCH v2] ASoC: atmel_ssc_dai: Match the CMR divider only in full duplex. 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From 86be84c4de4e7b21cfda9656a02a902c543210af Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 22 Oct 2014 16:45:29 +0200 Subject: [PATCH v2] ASoC: atmel_ssc_dai: Match the CMR divider only in full duplex. The CMR divider register is shared by playback and capture. The SSC driver therefore tries to enforce rules so that the needed register content do not conflict during simultaneous playback/capture. However, the implementation also prevents changing the register content in half-duplex scenarios, which is needed when using the OSS API. Thus, only lock the divider if there is a stream in the other direction. Fixes the below program to not fail with the atmel ssc dai in master mode. #include #include #include #include int main(void) { int fd; int format; int channels; int speed; if ((fd = open("/dev/dsp", O_WRONLY, 0)) == -1) { perror("open"); return 1; } format = AFMT_S16_LE; if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) == -1) { perror("SNDCTL_DSP_SETFMT"); return 1; } channels = 2; if (ioctl(fd, SNDCTL_DSP_CHANNELS, &channels) == -1) { perror("SNDCTL_DSP_CHANNELS"); return 1; } speed = 22025; if (ioctl(fd, SNDCTL_DSP_SPEED, &speed) == -1) { perror("SNDCTL_DSP_SPEED"); return 1; } return 0; } Signed-off-by: Peter Rosin Acked-by: Bo Shen --- sound/soc/atmel/atmel_ssc_dai.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index de433cfd..9ae8475 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -310,7 +310,10 @@ static int atmel_ssc_set_dai_clkdiv(struct snd_soc_dai *cpu_dai, * transmit and receive, so if a value has already * been set, it must match this value. */ - if (ssc_p->cmr_div == 0) + if (ssc_p->dir_mask != + (SSC_DIR_MASK_PLAYBACK | SSC_DIR_MASK_CAPTURE)) + ssc_p->cmr_div = div; + else if (ssc_p->cmr_div == 0) ssc_p->cmr_div = div; else if (div != ssc_p->cmr_div)