Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1388812 > unrolled thread
| Started by | Peter Rosin <peda@axentia.se> |
|---|---|
| First post | 2016-04-27 11:10 +0200 |
| Last post | 2016-04-27 22:50 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links Peter Rosin <peda@axentia.se> - 2016-04-27 11:10 +0200
Re: [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links Mark Brown <broonie@kernel.org> - 2016-04-27 18:20 +0200
Re: [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links Peter Rosin <peda@axentia.se> - 2016-04-27 22:50 +0200
| From | Peter Rosin <peda@axentia.se> |
|---|---|
| Date | 2016-04-27 11:10 +0200 |
| Subject | [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links |
| Message-ID | <rstDQ-779-3@gated-at.bofh.it> |
The below program fails on a dai link with symmetric rates without this
patch. The patch makes it work.
#include <sys/soundcard.h>
#include <unistd.h>
#include <fcntl.h>
#include <stropts.h>
#include <stdio.h>
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 <peda@axentia.se>
---
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));
--
2.1.4
[toc] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-04-27 18:20 +0200 |
| Subject | Re: [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links |
| Message-ID | <rsAlY-41b-15@gated-at.bofh.it> |
| In reply to | #1388812 |
[Multipart message — attachments visible in raw view] — view raw
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?
> 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.
> + 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.
[toc] | [prev] | [next] | [standalone]
| From | Peter Rosin <peda@axentia.se> |
|---|---|
| Date | 2016-04-27 22:50 +0200 |
| Subject | Re: [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links |
| Message-ID | <rsEzf-7F4-3@gated-at.bofh.it> |
| In reply to | #1389311 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web