From: Peter Rosin <peda@axentia.se> To: Mark Brown <broonie@kernel.org> Cc: <alsa-devel@alsa-project.org>, Liam Girdwood <lgirdwood@gmail.com>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>, <linux-kernel@vger.kernel.org> Subject: Re: [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links Date: Wed, 27 Apr 2016 22:45:48 +0200 [thread overview] Message-ID: <122ca84a-230e-654e-425f-3adb0ca00ec7@axentia.se> (raw) In-Reply-To: <20160427161504.GZ3217@sirena.org.uk> 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
WARNING: multiple messages have this Message-ID (diff)
From: Peter Rosin <peda@axentia.se> To: Mark Brown <broonie@kernel.org> Cc: Takashi Iwai <tiwai@suse.de>, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Liam Girdwood <lgirdwood@gmail.com> Subject: Re: [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links Date: Wed, 27 Apr 2016 22:45:48 +0200 [thread overview] Message-ID: <122ca84a-230e-654e-425f-3adb0ca00ec7@axentia.se> (raw) In-Reply-To: <20160427161504.GZ3217@sirena.org.uk> 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
next prev parent reply other threads:[~2016-04-27 20:46 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-04-27 8:49 [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links Peter Rosin 2016-04-27 8:49 ` Peter Rosin 2016-04-27 16:15 ` Mark Brown 2016-04-27 16:15 ` Mark Brown 2016-04-27 20:45 ` Peter Rosin [this message] 2016-04-27 20:45 ` Peter Rosin 2016-04-28 10:38 ` Mark Brown 2016-04-28 10:38 ` Mark Brown 2016-04-28 11:03 ` Takashi Iwai 2016-04-28 11:10 ` Mark Brown 2016-04-28 11:26 ` Takashi Iwai 2016-04-28 11:41 ` Mark Brown 2016-04-28 12:02 ` Takashi Iwai 2016-04-28 17:13 ` Mark Brown 2016-04-28 17:13 ` Mark Brown 2016-05-02 7:43 ` Peter Rosin 2016-05-02 7:43 ` Peter Rosin 2016-05-04 16:49 ` Mark Brown 2016-05-09 12:17 ` [alsa-devel] " Takashi Iwai 2016-05-09 12:17 ` Takashi Iwai
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=122ca84a-230e-654e-425f-3adb0ca00ec7@axentia.se \ --to=peda@axentia.se \ --cc=alsa-devel@alsa-project.org \ --cc=broonie@kernel.org \ --cc=lgirdwood@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=perex@perex.cz \ --cc=tiwai@suse.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.