From patchwork Wed Apr 27 08:49:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 8953781 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A9BDFBF29F for ; Wed, 27 Apr 2016 08:49:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D75BC200F3 for ; Wed, 27 Apr 2016 08:49:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A6829200F0 for ; Wed, 27 Apr 2016 08:49:54 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5A6C3265E0E; Wed, 27 Apr 2016 10:49:48 +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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id CD12C265A89; Wed, 27 Apr 2016 10:49:39 +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 9B05F265D01; Wed, 27 Apr 2016 10:49:38 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0103.outbound.protection.outlook.com [104.47.1.103]) by alsa0.perex.cz (Postfix) with ESMTP id 0F8BC265A72 for ; Wed, 27 Apr 2016 10:49:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentiatech.onmicrosoft.com; s=selector1-axentia-se; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=cn4YLHtbArYWZooTcsgk73XvT40WvierZoWI/TJ+uYI=; b=efntDnsn1/mbsUd4Tr5SVXr+q8Ra0jciZIWUf4lLBosTUAqgjcUgQwrhZ9aYlS+qNGHjM/X7L6fSHLSqi56qa71iNoRz8A1olE56ofuW2Oi9mqSUg2ly/Ywxa9DyBjvRoqUUDpeQgD9+K9UurGES3jiP8V+iKhudCF77IxrmqWs= Authentication-Results: alsa-project.org; dkim=none (message not signed) header.d=none;alsa-project.org; dmarc=none action=none header.from=axentia.se; Received: from localhost.localdomain (217.210.101.82) by VI1PR02MB1309.eurprd02.prod.outlook.com (10.165.231.151) with Microsoft SMTP Server (TLS) id 15.1.477.8; Wed, 27 Apr 2016 08:49:30 +0000 From: Peter Rosin To: Date: Wed, 27 Apr 2016 10:49:19 +0200 Message-ID: <1461746959-11443-1-git-send-email-peda@axentia.se> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-Originating-IP: [217.210.101.82] X-ClientProxiedBy: DB5PR03CA0066.eurprd03.prod.outlook.com (10.164.34.34) To VI1PR02MB1309.eurprd02.prod.outlook.com (10.165.231.151) X-MS-Office365-Filtering-Correlation-Id: 0c0f054c-6b6b-4ad0-a550-08d36e78d98c X-Microsoft-Exchange-Diagnostics: 1; VI1PR02MB1309; 2:mdxqLvkCO+CgOGZj0I9VDdTFXTwyqMaZQVm4tdGcyf4tfGAabYCuUOkqZw0JtwMIkOgobGx1VmfyiUpRD+5WCINqjtjv9ZMWgXlovdJmVvC7o1pXVvdjy9r1+UXgN7eKAdFMVJ+nTYqU7hrOWi6q6MKnBOl3Z1Rkuh7HOuJPKt44155DvNw1r7ZAJObu0RAe; 3:LW5GMOwwS8PYblGBuc0dhEFoEU3dmCwi+KZXN2QGCwHOl5TQmFBdm8qHUV79R1dDoljRnH4uneanpdvUXfE8pT3eMUdC5biSF01VVCv99lj7J51na/IgmEPVx+EkZ3Ot X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB1309; X-Microsoft-Exchange-Diagnostics: 1; VI1PR02MB1309; 25:QnswLBGo+xbT9kOYVoG2zHX5nJ8N5ig27RvwwFpKUv+nGa55+BksulkcspGcu8oiR8YU2xJ9UhNjUaOOueLJIG2OCGlQTzMApo1Hf0jZY7eaY2xVqp2UydtOBeg1HISRpIZ9XJS+g72ytDUwoRrdVQ6Etqx58HpE+jEY5G0LkfYVJxexi1q/X10W6NL5nCBAxuXfxTkBm5uHCvzu/ZuPCrD54Z4pB/zDPCG2XPMlR6dh2OaneD6GmuyqyUtClXfIi0KOfrwJpBLLP/jTfVezWT6G4cOH4thzHeuaweX+n739KnZuoKj817FhTSJBn7miOjeFTI0ClFQ3mL8GrO2zknhZHCNJCmGYur9zIlBA0lYWa+qWBSdsSlHyu0BD6yoA5esiO6U/SBK1AX0Se9ucetHUhULhFMleiRSTVbhhcZMsqAsWAIOPHh8HMGh+jXoWax2w/DuGCGj2/8kFJlUaMUnu4wmGXN6bJi4i6mOjfKnOxREnAfhekIk3PC7P+5TDOgSeV7P8gPtQpDHINS4zPacrr2gVeLxAivbIIpXkpgJYYi7oLZbFCH5xFkoQVvDk+LhAKB8jO7InYOettaeC/6Z3iDTiZI9yD0v3nQ8OqFGTPGZbOZSYoVfOKN7KniNaGt0iMT+jJiWWYnVUCSknHA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(9101521072)(6040130)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041072)(6043046); SRVR:VI1PR02MB1309; BCL:0; PCL:0; RULEID:; SRVR:VI1PR02MB1309; X-Microsoft-Exchange-Diagnostics: 1; VI1PR02MB1309; 4:/iDEKzGHUfhWVaZxOI7GuijGSBdetsXstL0OGFBvOrt+c04o2c8FLFLWg+TjjOa9MJ6WgpYems6Yi+mp6TmV19M3VpbuXE56o4bbQc4alqnMVpjpiCcEgDtrEhdcT8umuUAZZ4QX6yOffaRLqfReQqjGawqD22XEq9h+iWRFZOzD9yOfRPca6duUzaK9doWXr5KhDdO0Jdjsr2M06XaQIQA5hAbsCgcaRxRP7KjH/mjBEpJXfSqYZ6TCEvL1dfvADjZ7VDCaEAoB+7q3xh9eRTbqw2t8DxVup4HzTlK4qRtUJwFwL4EVPnRWjwbmQvhV8XCB98n6RX5hnj8Zyk+wc7FhJci8ZXRYQQKzCQod1trhlSZBAvU8muI0/czn0sPLljaD8v74su7KQBl4Mr6+BMFMFfMpWLkpAgMp3NqANhMi/+MTQP63Scw7ABvqjVLR/hTa5G0kEBulYKc4lhChwQ== X-Forefront-PRVS: 0925081676 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(36756003)(5003940100001)(33646002)(5004730100002)(86362001)(189998001)(74482002)(2906002)(2351001)(4326007)(50986999)(92566002)(77096005)(81166005)(229853001)(66066001)(48376002)(5008740100001)(19580395003)(586003)(19580405001)(110136002)(3846002)(6116002)(1096002)(50466002)(42186005)(47776003)(50226002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR02MB1309; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; VI1PR02MB1309; 23:jt7HXIh9WqCMgjakQNNnavCBKM5HlrpL08Kclq39cvqN7mdU6yGbumvynJ7UytlAfbG/n0xm927oodjePbfHqD2DkGbYD5zXnx4DObNMMzMrTPpH8Fv2W4goFjL74NdagtBdhlTDONa6gY5zD8G1bah8yd0iIc3lxxgtz/TpJ5LeuBidcUFVC6Df3YE58nRYM96m/ADXldu/1rUUeu/VsKn5eyNXHuu9x9EchQ7/q1LXPSTxdSbvq/6omywejLcvELaNg5Su15RZKWqAHmHOv1WvvcstHPHuAjkuODyvfpV5b5tfxYqMsIPi0YsmV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NnN9W09hWpF2lRA SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2016 08:49:30.1562 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR02MB1309 Cc: Liam Girdwood , Takashi Iwai , linux-kernel@vger.kernel.org, Mark Brown , Peter Rosin Subject: [alsa-devel] [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links 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 The below program fails on a dai link with symmetric rates without this patch. The patch makes it work. #include #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 = 22050; if (ioctl(fd, SNDCTL_DSP_SPEED, &speed) == -1) { perror("SNDCTL_DSP_SPEED"); return 1; } return 0; } Signed-off-by: Peter Rosin --- sound/soc/soc-pcm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 35fe58f4fa86..1e876ff23524 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -237,6 +237,14 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai = rtd->cpu_dai; unsigned int rate, channels, sample_bits, symmetry, i; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (!cpu_dai->capture_active) + return 0; + } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { + if (!cpu_dai->playback_active) + return 0; + } + rate = params_rate(params); channels = params_channels(params); sample_bits = snd_pcm_format_physical_width(params_format(params));