Skip to content

Commit ff3f449

Browse files
Aakarsh JainHans Verkuil
authored andcommitted
media: s5p-mfc: Add support for DMABUF for encoder
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>
1 parent 15fe06f commit ff3f449

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ static int s5p_mfc_open(struct file *file)
865865
q->io_modes = VB2_MMAP;
866866
q->ops = get_dec_queue_ops();
867867
} else if (vdev == dev->vfd_enc) {
868-
q->io_modes = VB2_MMAP | VB2_USERPTR;
868+
q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
869869
q->ops = get_enc_queue_ops();
870870
} else {
871871
ret = -ENOENT;
@@ -892,7 +892,7 @@ static int s5p_mfc_open(struct file *file)
892892
q->io_modes = VB2_MMAP;
893893
q->ops = get_dec_queue_ops();
894894
} else if (vdev == dev->vfd_enc) {
895-
q->io_modes = VB2_MMAP | VB2_USERPTR;
895+
q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
896896
q->ops = get_enc_queue_ops();
897897
} else {
898898
ret = -ENOENT;

drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,9 +1538,10 @@ static int vidioc_reqbufs(struct file *file, void *priv,
15381538
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
15391539
int ret = 0;
15401540

1541-
/* if memory is not mmp or userptr return error */
1541+
/* if memory is not mmp or userptr or dmabuf return error */
15421542
if ((reqbufs->memory != V4L2_MEMORY_MMAP) &&
1543-
(reqbufs->memory != V4L2_MEMORY_USERPTR))
1543+
(reqbufs->memory != V4L2_MEMORY_USERPTR) &&
1544+
(reqbufs->memory != V4L2_MEMORY_DMABUF))
15441545
return -EINVAL;
15451546
if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
15461547
if (reqbufs->count == 0) {
@@ -1617,9 +1618,10 @@ static int vidioc_querybuf(struct file *file, void *priv,
16171618
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
16181619
int ret = 0;
16191620

1620-
/* if memory is not mmp or userptr return error */
1621+
/* if memory is not mmp or userptr or dmabuf return error */
16211622
if ((buf->memory != V4L2_MEMORY_MMAP) &&
1622-
(buf->memory != V4L2_MEMORY_USERPTR))
1623+
(buf->memory != V4L2_MEMORY_USERPTR) &&
1624+
(buf->memory != V4L2_MEMORY_DMABUF))
16231625
return -EINVAL;
16241626
if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
16251627
if (ctx->state != MFCINST_GOT_INST) {
@@ -2581,11 +2583,11 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
25812583
S5P_MFC_R2H_CMD_SEQ_DONE_RET,
25822584
0);
25832585
}
2584-
2585-
if (ctx->src_bufs_cnt < ctx->pb_count) {
2586-
mfc_err("Need minimum %d OUTPUT buffers\n",
2587-
ctx->pb_count);
2588-
return -ENOBUFS;
2586+
if (q->memory != V4L2_MEMORY_DMABUF) {
2587+
if (ctx->src_bufs_cnt < ctx->pb_count) {
2588+
mfc_err("Need minimum %d OUTPUT buffers\n", ctx->pb_count);
2589+
return -ENOBUFS;
2590+
}
25892591
}
25902592
}
25912593

0 commit comments

Comments
 (0)