From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753482AbcD0UqD (ORCPT ); Wed, 27 Apr 2016 16:46:03 -0400 Received: from mail-am1on0123.outbound.protection.outlook.com ([157.56.112.123]:36116 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752280AbcD0UqA (ORCPT ); Wed, 27 Apr 2016 16:46:00 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=axentia.se; Subject: Re: [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links To: Mark Brown References: <1461746959-11443-1-git-send-email-peda@axentia.se> <20160427161504.GZ3217@sirena.org.uk> CC: , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , From: Peter Rosin Message-ID: <122ca84a-230e-654e-425f-3adb0ca00ec7@axentia.se> Date: Wed, 27 Apr 2016 22:45:48 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <20160427161504.GZ3217@sirena.org.uk> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [217.210.101.82] X-ClientProxiedBy: HE1PR09CA0040.eurprd09.prod.outlook.com (10.162.19.50) To HE1PR02MB1306.eurprd02.prod.outlook.com (10.169.115.152) X-MS-Office365-Filtering-Correlation-Id: d154b4e7-5cf8-4449-a52d-08d36edced7d X-Microsoft-Exchange-Diagnostics: 1;HE1PR02MB1306;2:f4g3vwVP1LYqdo8rhFxfKqQoYw1YwjSOEoXCqNlarf0W5Fy1Y433obzU2klOJJ//METkVPqxHYLKIdTj7u9YYzvFcEJBWnS8BFk1a+v2HPnKAf/+jZAlUMtdyWbuzZkvlUI959Os3U+uhmk9lnjMCQf3Rna/d7ZyRIxZgQ3H/XrGDu6W/VJ8qtmvtsyHrxYs;3:nZAFDLvrxw8vmVu6GCFcvf6N/rqnyQ1SEuPGJ2yBFFUod/RuHiIqiRm22DhZ5qiG77cyDMmXn6y8uOMQQI69tVF202cosgofYFkNmJJNmJdCuc4PCJeuP8nGAQJX7MTK;25:DLMv1aDZ/uU6PYJA9KftNUyykcxdovPMFi2R4dIQIlftZAAPg5x5GjLI2knJpYzkZcokx6yDnV7ws/f7qCS80Jj24NbHErqjVxDEV7I/Vg8whyVTbUvhv56y/MgKEc2VlDXZHfDJPw11BQD+4d5iqwPdEzlstFRqVWiSDb06wivAuTZCwBjsdg7D6q5W/ZDXrFQtovY4YME5jzPY/C0oLlKbhpmqag4sZKAtAnj7WJ6KPwondU0eIm0BpZU5xzVHcVd2SR52CLLEPkTGkYeoFmYTeepMg3z+IO5my1AQWZMEGhuvaUQz6Mt+wG9gbiRoq3ZQDwnl3uzGPYipv/j7orwDXRJIPEqE5eWIgZOv5fR7rU5qjCwEO5A9tXt8PqxUnSIexW2gV1E+9+QF4DNXSrXjsPe6Z2FVc6vYwG8hYkgI3hjiXBWQ643fG2y9pPC7/U0aHqzW63BZrtKuFEIqlfsN4L8nGwgdgFuIVdR3ZTlAfvFjb6Uwdcx96UbWaRh8tGXbZTiWmDEouopmosNeigj4Qo/tAOoXaL1IeOErDlqVu4FdROtx2sB5Gau8SBsHwmGAiCYfNCvzy+e/yqHFtM+e8/d6hl2PSLdKBewULRdJ/38IgWE98niwkQUYJRGC X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB1306; 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)(8121501046)(5005006)(10201501046)(3002001)(6041072)(6043046);SRVR:HE1PR02MB1306;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB1306; X-Microsoft-Exchange-Diagnostics: 1;HE1PR02MB1306;4:bp6NbDWC0Kc9WXH6PaIe7AvlNTgut74zJYsee/qcOXAnK4E73TF/asiuwuCL0yVUe6/OL9UpcGO2Y7MUsMM4/pKjTEtcmVLHvdF4+8KmOJzNb1OX4epsAhalY4RAzh4GBS5scSSX0llYeW47ZZ60opLRu/VuNH+jTxwZjZWoFc9eLiOKn2cjIebEC+OoJc1ivOL6DtgbQod8hpnrau24UMLs6fwe/LjMYEOjWPjbIoXEt7S4qFfNH+eGgpLnnB4HNIsh1oy4kFHkfEzhmKE43gzFHf/Da9ou5IbWTbuWze2mIOn9b4aLx+1K2LAWpITDM3incijgv+H+cJrL2/jyk4KgYpFfx5adTNW5amHJwCkFx3MSBK50SxpcM5/b3XSovU9ju+3n5RWWewPVKegibWWSQZwdPR69YQmEihFzY16NfvtJ5cF3sxrhmf1DlNS/M+QOJ/2TTg6SowXZaThKTg== X-Forefront-PRVS: 0925081676 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(24454002)(377424004)(54356999)(86362001)(77096005)(81166005)(2950100001)(31686004)(117156001)(92566002)(42186005)(31696002)(4326007)(76176999)(50986999)(74482002)(2906002)(5004730100002)(66066001)(33646002)(23746002)(47776003)(64126003)(4001350100001)(586003)(6116002)(65956001)(3846002)(1096002)(5008740100001)(65806001)(189998001)(230700001)(36756003)(110136002)(83506001)(65826006)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR02MB1306;H:[192.168.0.125];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;HE1PR02MB1306;23:jCQ0fsXRGzj16L6jsLFyXIUV07LwvP3JlbRwy?= =?Windows-1252?Q?TV2FHYROATZLjXRGgEsB1cJfeoixPTufRWcTNB/VpZWuTImyzAdVKHbc?= =?Windows-1252?Q?uvLwep2wh2mRyPdBfC/jcaZIcBmOLm8qw4pZrwT3jM37HpeF53hPaIPE?= =?Windows-1252?Q?DqMa8SPYMyfJV35vcV/4H22CYKFWblqt0kfqQc2gwDScEwKHuESt+CG7?= =?Windows-1252?Q?uMcLtaxbu44KImBgejDANJ3pDmivyYX09ybTXGf32KWOUsbvSGiRPnKz?= =?Windows-1252?Q?mU43FXi12/UpCAGAuIgUZByKVskEHITD968GuN0FsPFLv5RKckmt3xZM?= =?Windows-1252?Q?Ah0GkbTVf43E2upXGjzF/sqH6PZFQcl2bjc9OBvVeg/sKLMHInc9zze7?= =?Windows-1252?Q?uRdbIYI8ze6rDaJFWNfFKTsKnzXFuvBQurkjVVY1Bl9sKDK86DtNcQTK?= =?Windows-1252?Q?Qiri/7MEirpBnmBIbhTiVyYbendB98fAHYKmxWMj3NP331fTN9MrLL+F?= =?Windows-1252?Q?Ux/04pMDlYjxVE4+lfgL4hd2azXPeJurLq/2lcxFYE6CPyukkTRwoRf0?= =?Windows-1252?Q?pz+ScDGUETN038jBCVqbYx9WakGfIopDO7VkU5YG7L17aCPJ0R7G0iis?= =?Windows-1252?Q?kyazbd/qJQUk5YB8AD1hjyFnlSb5CmB6rhYoi4p2OuUodAMO8N7263ZN?= =?Windows-1252?Q?lkdqaeZ0YjnXQDTrq0yrcNfCSsIwK9zYwPincPbY46/N2Cr/QcBxsqxN?= =?Windows-1252?Q?OUgKRGBNOEl7IYonRCoKBZnhKdnYpTZbuJsoOzndB9klOlVgGPVFnqu0?= =?Windows-1252?Q?AZCXbv66pxeKQFiTAYuexh7RboQPTd5qnXRpz0LHzKHNXW0Vqq3/gbMX?= =?Windows-1252?Q?3OxJ6+c0niKCFGqIbSv9yMc3WoZ35qeQHVbd4mP+uMb7z10EoE6cn8iV?= =?Windows-1252?Q?R9wuov14FC1ar+R0v0IHUVL87+7NmM4EoSATXtAFtIyhrw3Lj1nBbbpp?= =?Windows-1252?Q?d7Mx9grdDkPLVq7y/T8wCwDuMBwsGPyuM8jWmPSyobtXyA1mMrw5C/fk?= =?Windows-1252?Q?apaT5CwqIcn1h4Cjn7IWJYrQUxrtV6IKG+1ALgkMpPFPJLEXWW6qbCeb?= =?Windows-1252?Q?pTEKT8YGlpCZe3EG4RGGm794vAIj+9Bf5LPl8urdl7/?= X-Microsoft-Exchange-Diagnostics: 1;HE1PR02MB1306;5:3mRo0C917iqWqTAKQFPzf0Q/i/1UtHp9GwyVbeQvtb1JgQf6iMqBYjL5LGekMpHqFrF7ruEtR41hvIIw3Kt3tAinyWCHw4ZR75OCGu+DMgKk6YvoJZgBxBz62SpV+BhEYGl+/n77NzesVgEUh3zrpw==;24:0stV58Zov7KyDPBEf3QgUN2JyrrZgIYkzH0eNDustb7ole9n+ohUK9UJltuKBjT4Bf9hkgxrNXxwhG1a1Ir/6qk0rI/JTDrBP62Lxu0+0LI=;7:JtbQAKXRHcE8vqsJLPWpecLz+gwRAN2ZSQwyvqPvvQhgQ/qksiwCLAq2Gp+0vDbicT0elDHpiFXN9kkd75rkIuxhae53tBGWvHS/4kQi5J8ua6AzNsgXTCYIQ8E5gGd+Ywcx1t+t7jVOKypyauAfwYhnPeGnCDTiTIsSWC/CgkWS93qNiEd0j+dbpN+zKtHu SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2016 20:45:54.0510 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR02MB1306 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016-04-27 18:15, Mark Brown wrote: > On Wed, Apr 27, 2016 at 10:49:19AM +0200, Peter Rosin wrote: > >> The below program fails on a dai link with symmetric rates without this >> patch. The patch makes it work. > > You've not articulated the problem you're trying to fix here, what in > concrete terms is the program trying to accomplish and why should it > succeed? It is opening an OSS fd, and setting some parameters, but changing the speed fails (in this case, since the codec dai has .symmetric_rates). As far as I know this is how you specify a specific speed when using OSS and it is simply not possibly when one of the involved dais is symmetric in any way. Which is silly since there is only one stream, so symmetry should not be an issue. >> if ((fd = open("/dev/dsp", O_WRONLY, 0)) == -1) { >> perror("open"); >> return 1; >> } > > This is using the OSS interfaces which really haven't ever been > especially supported for ASoC. Apparently, how should I know? >> + 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)); > > This means we've opened up a race where the stream is configured but not > started where the opposite direction can configure a different setup. > Since starting both directions very close together is a common operation > it seems likely to cause issues. Ouch, that's no good. Scrap the patch. I haven't looked really closely at the userspace side of this, but the big picture is that we're using a (closed source) library that in its documentation has an example where they open /dev/dsp like this and feeds the fd to the lib. We are simply replicating that in our code. I don't know if the library does anything OSSy with the fd, or if it would be equally happy with an ALSA fd. I'll investigate that... Cheers, Peter From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Rosin Subject: Re: [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links Date: Wed, 27 Apr 2016 22:45:48 +0200 Message-ID: <122ca84a-230e-654e-425f-3adb0ca00ec7@axentia.se> References: <1461746959-11443-1-git-send-email-peda@axentia.se> <20160427161504.GZ3217@sirena.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0125.outbound.protection.outlook.com [157.55.234.125]) by alsa0.perex.cz (Postfix) with ESMTP id EB9C1264FFF for ; Wed, 27 Apr 2016 22:45:57 +0200 (CEST) In-Reply-To: <20160427161504.GZ3217@sirena.org.uk> 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 To: Mark Brown Cc: Takashi Iwai , linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Liam Girdwood List-Id: alsa-devel@alsa-project.org On 2016-04-27 18:15, Mark Brown wrote: > On Wed, Apr 27, 2016 at 10:49:19AM +0200, Peter Rosin wrote: > >> The below program fails on a dai link with symmetric rates without this >> patch. The patch makes it work. > > You've not articulated the problem you're trying to fix here, what in > concrete terms is the program trying to accomplish and why should it > succeed? It is opening an OSS fd, and setting some parameters, but changing the speed fails (in this case, since the codec dai has .symmetric_rates). As far as I know this is how you specify a specific speed when using OSS and it is simply not possibly when one of the involved dais is symmetric in any way. Which is silly since there is only one stream, so symmetry should not be an issue. >> if ((fd = open("/dev/dsp", O_WRONLY, 0)) == -1) { >> perror("open"); >> return 1; >> } > > This is using the OSS interfaces which really haven't ever been > especially supported for ASoC. Apparently, how should I know? >> + 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)); > > This means we've opened up a race where the stream is configured but not > started where the opposite direction can configure a different setup. > Since starting both directions very close together is a common operation > it seems likely to cause issues. Ouch, that's no good. Scrap the patch. I haven't looked really closely at the userspace side of this, but the big picture is that we're using a (closed source) library that in its documentation has an example where they open /dev/dsp like this and feeds the fd to the lib. We are simply replicating that in our code. I don't know if the library does anything OSSy with the fd, or if it would be equally happy with an ALSA fd. I'll investigate that... Cheers, Peter