[media] s5p-mfc: Fix REQBUFS(0) for encoder
authorPawel Osciak <posciak@chromium.org>
Tue, 21 Oct 2014 11:06:56 +0000 (08:06 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 28 Oct 2014 17:42:21 +0000 (15:42 -0200)
Handle REQBUFS(0) for CAPTURE queue as well. Also use the proper queue to call
it on for OUTPUT.

Signed-off-by: Pawel Osciak <posciak@chromium.org>
Signed-off-by: Kiran AVND <avnd.kiran@samsung.com>
Signed-off-by: Arun Kumar K <arun.kk@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c

index 4816f31acf68a226378920dd8ea02eb7c6f0fe2c..6a1c890a390d128a7e4299f4004bc36be53e5ed4 100644 (file)
@@ -1147,6 +1147,11 @@ static int vidioc_reqbufs(struct file *file, void *priv,
                (reqbufs->memory != V4L2_MEMORY_USERPTR))
                return -EINVAL;
        if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+               if (reqbufs->count == 0) {
+                       ret = vb2_reqbufs(&ctx->vq_dst, reqbufs);
+                       ctx->capture_state = QUEUE_FREE;
+                       return ret;
+               }
                if (ctx->capture_state != QUEUE_FREE) {
                        mfc_err("invalid capture state: %d\n",
                                                        ctx->capture_state);
@@ -1168,6 +1173,14 @@ static int vidioc_reqbufs(struct file *file, void *priv,
                        return -ENOMEM;
                }
        } else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+               if (reqbufs->count == 0) {
+                       mfc_debug(2, "Freeing buffers\n");
+                       ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
+                       s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers,
+                                       ctx);
+                       ctx->output_state = QUEUE_FREE;
+                       return ret;
+               }
                if (ctx->output_state != QUEUE_FREE) {
                        mfc_err("invalid output state: %d\n",
                                                        ctx->output_state);