MLK-12060 media: output: pxp_v4l2: Add filter function for dma_request_channel
authorRobby Cai <robby.cai@nxp.com>
Fri, 25 Dec 2015 06:04:54 +0000 (14:04 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:49:35 +0000 (14:49 -0500)
Without the filter function, the dma_request_channel() API could possibly get
a sdma channel. The dma_request_channel() API does not return error but the
consequent operations on that channel will be invalid then the upper level
application expects to be stuck.

The patch added the filter functions to get right dma channel for the fix.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
drivers/media/platform/mxc/output/mxc_pxp_v4l2.c

index 67d133a..17f3c07 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/delay.h>
 #include <linux/console.h>
 #include <linux/mxcfb.h>
+#include <linux/platform_data/dma-imx.h>
 
 #include <media/videobuf-dma-contig.h>
 #include <media/v4l2-common.h>
@@ -242,6 +243,14 @@ static void video_dma_done(void *arg)
        spin_unlock(&pxp->lock);
 }
 
+static bool chan_filter(struct dma_chan *chan, void *arg)
+{
+       if (imx_dma_is_pxp(chan))
+               return true;
+       else
+               return false;
+}
+
 static int acquire_dma_channel(struct pxps *pxp)
 {
        dma_cap_mask_t mask;
@@ -263,7 +272,7 @@ static int acquire_dma_channel(struct pxps *pxp)
        dma_cap_zero(mask);
        dma_cap_set(DMA_SLAVE, mask);
        dma_cap_set(DMA_PRIVATE, mask);
-       chan = dma_request_channel(mask, NULL, NULL);
+       chan = dma_request_channel(mask, chan_filter, NULL);
        if (!chan)
                return -EBUSY;