]> www.infradead.org Git - users/willy/xarray.git/commitdiff
media: s5p-mfc: Add support for DMABUF for encoder
authorAakarsh Jain <aakarsh.jain@samsung.com>
Wed, 13 Dec 2023 08:11:02 +0000 (13:41 +0530)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 13 Dec 2023 13:33:49 +0000 (14:33 +0100)
Add dmabuf support for mfc encoder

Cc: linux-fsd@tesla.com
Signed-off-by: Smitha T Murthy <smithatmurthy@gmail.com>
Signed-off-by: Aakarsh Jain <aakarsh.jain@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c

index dee9ef0179974cb82770ec0eb8e3491d3b4643df..bd055dea827e9f939e6f09d6a6d0b2d9d790334a 100644 (file)
@@ -865,7 +865,7 @@ static int s5p_mfc_open(struct file *file)
                q->io_modes = VB2_MMAP;
                q->ops = get_dec_queue_ops();
        } else if (vdev == dev->vfd_enc) {
-               q->io_modes = VB2_MMAP | VB2_USERPTR;
+               q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
                q->ops = get_enc_queue_ops();
        } else {
                ret = -ENOENT;
@@ -892,7 +892,7 @@ static int s5p_mfc_open(struct file *file)
                q->io_modes = VB2_MMAP;
                q->ops = get_dec_queue_ops();
        } else if (vdev == dev->vfd_enc) {
-               q->io_modes = VB2_MMAP | VB2_USERPTR;
+               q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
                q->ops = get_enc_queue_ops();
        } else {
                ret = -ENOENT;
index 67fe0302464fa3f834df027624d946945abdc18d..ae3764969473d566a2c8a0bc4ce5a0a6a39a3af1 100644 (file)
@@ -1538,9 +1538,10 @@ static int vidioc_reqbufs(struct file *file, void *priv,
        struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
        int ret = 0;
 
-       /* if memory is not mmp or userptr return error */
+       /* if memory is not mmp or userptr or dmabuf return error */
        if ((reqbufs->memory != V4L2_MEMORY_MMAP) &&
-               (reqbufs->memory != V4L2_MEMORY_USERPTR))
+               (reqbufs->memory != V4L2_MEMORY_USERPTR) &&
+               (reqbufs->memory != V4L2_MEMORY_DMABUF))
                return -EINVAL;
        if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
                if (reqbufs->count == 0) {
@@ -1617,9 +1618,10 @@ static int vidioc_querybuf(struct file *file, void *priv,
        struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
        int ret = 0;
 
-       /* if memory is not mmp or userptr return error */
+       /* if memory is not mmp or userptr or dmabuf return error */
        if ((buf->memory != V4L2_MEMORY_MMAP) &&
-               (buf->memory != V4L2_MEMORY_USERPTR))
+               (buf->memory != V4L2_MEMORY_USERPTR) &&
+               (buf->memory != V4L2_MEMORY_DMABUF))
                return -EINVAL;
        if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
                if (ctx->state != MFCINST_GOT_INST) {
@@ -2581,11 +2583,11 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
                                                S5P_MFC_R2H_CMD_SEQ_DONE_RET,
                                                0);
                }
-
-               if (ctx->src_bufs_cnt < ctx->pb_count) {
-                       mfc_err("Need minimum %d OUTPUT buffers\n",
-                                       ctx->pb_count);
-                       return -ENOBUFS;
+               if (q->memory != V4L2_MEMORY_DMABUF) {
+                       if (ctx->src_bufs_cnt < ctx->pb_count) {
+                               mfc_err("Need minimum %d OUTPUT buffers\n", ctx->pb_count);
+                               return -ENOBUFS;
+                       }
                }
        }