From: Charles Keepax Date: Thu, 18 Apr 2013 10:02:38 +0000 (+0100) Subject: ASoC: soc-compress: Deduce stream direction X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=daa2db59ce7e36011a6c92a0342cd0919b9fb7d3;p=linux-beck.git ASoC: soc-compress: Deduce stream direction 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 Signed-off-by: Richard Fitzgerald Acked-by: Vinod Koul Signed-off-by: Takashi Iwai --- diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index da83e5658f62..3853f7eb3f28 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -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");