ASoC: soc-compress: Deduce stream direction
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Thu, 18 Apr 2013 10:02:38 +0000 (11:02 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sun, 21 Apr 2013 07:53:43 +0000 (09:53 +0200)
Previously we just hard coded all streams as playback streams, this
patch checks the DAI to see if it is a capture or playback stream. It is
worth noting that at this time only unidirectional streams are
supported.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/soc/soc-compress.c

index da83e5658f624e326980929d2f8b535a00997835..3853f7eb3f2843f35c8f908cf47caab47931952a 100644 (file)
@@ -384,7 +384,14 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
        /* check client and interface hw capabilities */
        snprintf(new_name, sizeof(new_name), "%s %s-%d",
                        rtd->dai_link->stream_name, codec_dai->name, num);
-       direction = SND_COMPRESS_PLAYBACK;
+
+       if (codec_dai->driver->playback.channels_min)
+               direction = SND_COMPRESS_PLAYBACK;
+       else if (codec_dai->driver->capture.channels_min)
+               direction = SND_COMPRESS_CAPTURE;
+       else
+               return -EINVAL;
+
        compr = kzalloc(sizeof(*compr), GFP_KERNEL);
        if (compr == NULL) {
                snd_printk(KERN_ERR "Cannot allocate compr\n");