All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links
@ 2016-04-27  8:49 ` Peter Rosin
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Rosin @ 2016-04-27  8:49 UTC (permalink / raw)
  To: alsa-devel
  Cc: Peter Rosin, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, linux-kernel

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-05-09 12:17 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.