Skip to contentSkip to conversation

s5p-mfc: end-of-stream handling for newer encoders

PATCH Superseded Andrzej Hajda 2 participants 5 messages Oct 2, 2015 – Oct 7, 2015

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 s5p-mfc: end-of-stream handling for newer encoders

MFC encoder supports end-of-stream handling for encoder in version 5 of hardware. This patch adds it also for newer version. It was successfully tested on MFC-v8.

---
Hi,

This version is rebased on latest media_tree branch.

Regards
Andrzej

---
 drivers/media/platform/s5p-mfc/s5p_mfc.c        | 25 ++++++------
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c    |  5 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 51 ++++++++++++++++---------
 3 files changed, 49 insertions(+), 32 deletions(-)
drivers/media/platform/s5p-mfc/s5p_mfc.c +12 -13
index 7b646c2..05a31ee 100644
@@ -181,13 +181,6 @@ unlock:
 		mutex_unlock(&dev->mfc_mutex);
 }
 
-static void s5p_mfc_clear_int_flags(struct s5p_mfc_dev *dev)
-{
-	mfc_write(dev, 0, S5P_FIMV_RISC_HOST_INT);
-	mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD);
-	mfc_write(dev, 0xffff, S5P_FIMV_SI_RTN_CHID);
-}
-
 static void s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx *ctx)
 {
 	struct s5p_mfc_buf *dst_buf;
@@ -579,17 +572,13 @@ static void s5p_mfc_handle_init_buffers(struct s5p_mfc_ctx *ctx,
 	}
 }
 
-static void s5p_mfc_handle_stream_complete(struct s5p_mfc_ctx *ctx,
-				 unsigned int reason, unsigned int err)
+static void s5p_mfc_handle_stream_complete(struct s5p_mfc_ctx *ctx)
 {
 	struct s5p_mfc_dev *dev = ctx->dev;
 	struct s5p_mfc_buf *mb_entry;
 
 	mfc_debug(2, "Stream completed\n");
 
-	s5p_mfc_clear_int_flags(dev);
-	ctx->int_type = reason;
-	ctx->int_err = err;
 	ctx->state = MFCINST_FINISHED;
 
 	spin_lock(&dev->irqlock);
@@ -646,6 +635,13 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
 		if (ctx->c_ops->post_frame_start) {
 			if (ctx->c_ops->post_frame_start(ctx))
 				mfc_err("post_frame_start() failed\n");
+
+			if (ctx->state == MFCINST_FINISHING &&
+						list_empty(&ctx->ref_queue)) {
+				s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev);
+				s5p_mfc_handle_stream_complete(ctx);
+				break;
+			}
 			s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev);
 			wake_up_ctx(ctx, reason, err);
 			WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
@@ -691,7 +687,10 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
 		break;
 
 	case S5P_MFC_R2H_CMD_COMPLETE_SEQ_RET:
-		s5p_mfc_handle_stream_complete(ctx, reason, err);
+		s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev);
+		ctx->int_type = reason;
+		ctx->int_err = err;
+		s5p_mfc_handle_stream_complete(ctx);
 		break;
 
 	case S5P_MFC_R2H_CMD_DPB_FLUSH_RET:
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +3 -2
index 94868f7..d082d47 100644
@@ -907,9 +907,9 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
 			list_add_tail(&mb_entry->list, &ctx->ref_queue);
 			ctx->ref_queue_cnt++;
 		}
-		mfc_debug(2, "enc src count: %d, enc ref count: %d\n",
-			  ctx->src_queue_cnt, ctx->ref_queue_cnt);
 	}
+	mfc_debug(2, "enc src count: %d, enc ref count: %d\n",
+		  ctx->src_queue_cnt, ctx->ref_queue_cnt);
 	if ((ctx->dst_queue_cnt > 0) && (strm_size > 0)) {
 		mb_entry = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf,
 									list);
@@ -932,6 +932,7 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
 	spin_unlock_irqrestore(&dev->irqlock, flags);
 	if ((ctx->src_queue_cnt == 0) || (ctx->dst_queue_cnt == 0))
 		clear_work_bit(ctx);
+
 	return 0;
 }
 
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +34 -17

104 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 2/2 s5p-mfc: use MFC_BUF_FLAG_EOS to identify last buffers in decoder capture queue

MFC driver never delivered EOS event to apps feeding constantly its capture buffer with fresh buffers. The patch fixes it by marking last buffers returned by MFC with MFC_BUF_FLAG_EOS flag and firing EOS event on de-queuing such buffers.

---
Hi,

This version is rebased on latest media_tree branch.

Regards
Andrzej

---
 drivers/media/platform/s5p-mfc/s5p_mfc.c     |  1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 21 +++++++++++++--------
 2 files changed, 14 insertions(+), 8 deletions(-)
drivers/media/platform/s5p-mfc/s5p_mfc.c +1 -0
index 05a31ee..3ffe2ec 100644
@@ -196,6 +196,7 @@ static void s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx *ctx)
 		vb2_set_plane_payload(&dst_buf->b->vb2_buf, 0, 0);
 		vb2_set_plane_payload(&dst_buf->b->vb2_buf, 1, 0);
 		list_del(&dst_buf->list);
+		dst_buf->flags |= MFC_BUF_FLAG_EOS;
 		ctx->dst_queue_cnt--;
 		dst_buf->b->sequence = (ctx->sequence++);
 
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +13 -8
index 1734775..8d3d40c 100644
@@ -645,17 +645,22 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
 		mfc_err("Call on DQBUF after unrecoverable error\n");
 		return -EIO;
 	}
-	if (buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
-		ret = vb2_dqbuf(&ctx->vq_src, buf, file->f_flags & O_NONBLOCK);
-	else if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+
+	switch (buf->type) {
+	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
+		return vb2_dqbuf(&ctx->vq_src, buf, file->f_flags & O_NONBLOCK);
+	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
 		ret = vb2_dqbuf(&ctx->vq_dst, buf, file->f_flags & O_NONBLOCK);
-		if (ret == 0 && ctx->state == MFCINST_FINISHED &&
-				list_empty(&ctx->vq_dst.done_list))
+		if (ret)
+			return ret;
+
+		if (ctx->state == MFCINST_FINISHED &&
+		    (ctx->dst_bufs[buf->index].flags & MFC_BUF_FLAG_EOS))
 			v4l2_event_queue_fh(&ctx->fh, &ev);
-	} else {
-		ret = -EINVAL;
+		return 0;
+	default:
+		return -EINVAL;
 	}
-	return ret;
 }
 
 /* Export DMA buffer */
Signature · 1 line
1.9.1
#2 lore raw

RE: [PATCH v2 2/2] s5p-mfc: use MFC_BUF_FLAG_EOS to identify last buffers in decoder capture queue

Hi Andrzej,

Quoted 4 lines

From: Andrzej Hajda [mailto:[email protected]]
Sent: Friday, October 02, 2015 2:10 PM

MFC driver never delivered EOS event to apps feeding constantly its

capture

Quoted 1 line

buffer with fresh buffers. The patch fixes it by marking last buffers

returned

Quoted 2 lines

by MFC with MFC_BUF_FLAG_EOS flag and firing EOS event on de-queuing such buffers.

Checkpatch complains that lines in the description are too long.
WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#23:

Best wishes,

Signature · 2 lines
Kamil Debski
Samsung R&D Institute Poland

drivers/media/platform/s5p-mfc/s5p_mfc_dec.c static int vidioc_dqbuf(struct file *file, void

Quoted 35 lines

---
Hi,

This version is rebased on latest media_tree branch.

Regards
Andrzej

---
 drivers/media/platform/s5p-mfc/s5p_mfc.c     |  1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 21 +++++++++++++-------
(quoted diff) +0 -1
-
 2 files changed, 14 insertions(+), 8 deletions(-)
drivers/media/platform/s5p-mfc/s5p_mfc.c +1 -0
index 05a31ee..3ffe2ec 100644
@@ -196,6 +196,7 @@ static void
 s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx *ctx)
 		vb2_set_plane_payload(&dst_buf->b->vb2_buf, 0, 0);
 		vb2_set_plane_payload(&dst_buf->b->vb2_buf, 1, 0);
 		list_del(&dst_buf->list);
+		dst_buf->flags |= MFC_BUF_FLAG_EOS;
 		ctx->dst_queue_cnt--;
 		dst_buf->b->sequence = (ctx->sequence++);
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +0 -0
index 1734775..8d3d40c 100644
@@ -645,17 +645,22 @@ static int vidioc_dqbuf(struct file *file, void

*priv,

Quoted 36 lines
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +13 -9
 struct v4l2_buffer *buf)
 		mfc_err("Call on DQBUF after unrecoverable error\n");
 		return -EIO;
 	}
-	if (buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
-		ret = vb2_dqbuf(&ctx->vq_src, buf, file->f_flags &
 O_NONBLOCK);
-	else if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+
+	switch (buf->type) {
+	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
+		return vb2_dqbuf(&ctx->vq_src, buf, file->f_flags &
 O_NONBLOCK);
+	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
 		ret = vb2_dqbuf(&ctx->vq_dst, buf, file->f_flags &
 O_NONBLOCK);
-		if (ret == 0 && ctx->state == MFCINST_FINISHED &&
-				list_empty(&ctx->vq_dst.done_list))
+		if (ret)
+			return ret;
+
+		if (ctx->state == MFCINST_FINISHED &&
+		    (ctx->dst_bufs[buf->index].flags & MFC_BUF_FLAG_EOS))
 			v4l2_event_queue_fh(&ctx->fh, &ev);
-	} else {
-		ret = -EINVAL;
+		return 0;
+	default:
+		return -EINVAL;
 	}
-	return ret;
 }
 
 /* Export DMA buffer */
--

1.9.1

#3 lore raw

PATCH v3 2/2 s5p-mfc: use MFC_BUF_FLAG_EOS to identify last buffers in decoder capture queue

In reply to Andrzej Hajda

MFC driver never delivered EOS event to apps feeding constantly its capture buffer with fresh buffers. The patch fixes it by marking last buffers returned by MFC with MFC_BUF_FLAG_EOS flag and firing EOS event on de-queuing such buffers.

---
Hi Kamil,

Commit message fixed.

Regards
Andrzej

---
 drivers/media/platform/s5p-mfc/s5p_mfc.c     |  1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 21 +++++++++++++--------
 2 files changed, 14 insertions(+), 8 deletions(-)
drivers/media/platform/s5p-mfc/s5p_mfc.c +1 -0
index 05a31ee..3ffe2ec 100644
@@ -196,6 +196,7 @@ static void s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx *ctx)
 		vb2_set_plane_payload(&dst_buf->b->vb2_buf, 0, 0);
 		vb2_set_plane_payload(&dst_buf->b->vb2_buf, 1, 0);
 		list_del(&dst_buf->list);
+		dst_buf->flags |= MFC_BUF_FLAG_EOS;
 		ctx->dst_queue_cnt--;
 		dst_buf->b->sequence = (ctx->sequence++);
 
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +13 -8
index 1734775..8d3d40c 100644
@@ -645,17 +645,22 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
 		mfc_err("Call on DQBUF after unrecoverable error\n");
 		return -EIO;
 	}
-	if (buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
-		ret = vb2_dqbuf(&ctx->vq_src, buf, file->f_flags & O_NONBLOCK);
-	else if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+
+	switch (buf->type) {
+	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
+		return vb2_dqbuf(&ctx->vq_src, buf, file->f_flags & O_NONBLOCK);
+	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
 		ret = vb2_dqbuf(&ctx->vq_dst, buf, file->f_flags & O_NONBLOCK);
-		if (ret == 0 && ctx->state == MFCINST_FINISHED &&
-				list_empty(&ctx->vq_dst.done_list))
+		if (ret)
+			return ret;
+
+		if (ctx->state == MFCINST_FINISHED &&
+		    (ctx->dst_bufs[buf->index].flags & MFC_BUF_FLAG_EOS))
 			v4l2_event_queue_fh(&ctx->fh, &ev);
-	} else {
-		ret = -EINVAL;
+		return 0;
+	default:
+		return -EINVAL;
 	}
-	return ret;
 }
 
 /* Export DMA buffer */
Signature · 1 line
1.9.1
#4 lore raw
In reply to Andrzej Hajda

Hi Andrzej,

Thank you for your patch, I have a minor comment. Please find it below.

Quoted 28 lines

From: Andrzej Hajda [mailto:[email protected]]
Sent: Friday, October 02, 2015 2:10 PM

MFC encoder supports end-of-stream handling for encoder in version 5 of hardware. This patch adds it also for newer version.
It was successfully tested on MFC-v8.

---
Hi,

This version is rebased on latest media_tree branch.

Regards
Andrzej

---
 drivers/media/platform/s5p-mfc/s5p_mfc.c        | 25 ++++++------
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c    |  5 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 51
++++++++++++++++---------
 3 files changed, 49 insertions(+), 32 deletions(-)
drivers/media/platform/s5p-mfc/s5p_mfc.c +0 -0
index 7b646c2..05a31ee 100644

drivers/media/platform/s5p-mfc/s5p_mfc.c unlock: · line 184

Quoted 10 lines
drivers/media/platform/s5p-mfc/s5p_mfc.c +0 -6
@@ -181,13 +181,6 @@ unlock:
 		mutex_unlock(&dev->mfc_mutex);
 }
 
-static void s5p_mfc_clear_int_flags(struct s5p_mfc_dev *dev) -{
-	mfc_write(dev, 0, S5P_FIMV_RISC_HOST_INT);
-	mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD);
-	mfc_write(dev, 0xffff, S5P_FIMV_SI_RTN_CHID);
-}
-
 static void s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx *ctx)

{

Quoted 38 lines
drivers/media/platform/s5p-mfc/s5p_mfc.c +1 -5
 	struct s5p_mfc_buf *dst_buf;
@@ -579,17 +572,13 @@ static void s5p_mfc_handle_init_buffers(struct
 s5p_mfc_ctx *ctx,
 	}
 }
 
-static void s5p_mfc_handle_stream_complete(struct s5p_mfc_ctx *ctx,
-				 unsigned int reason, unsigned int err)
+static void s5p_mfc_handle_stream_complete(struct s5p_mfc_ctx *ctx)
 {
 	struct s5p_mfc_dev *dev = ctx->dev;
 	struct s5p_mfc_buf *mb_entry;
 
 	mfc_debug(2, "Stream completed\n");
 
-	s5p_mfc_clear_int_flags(dev);
-	ctx->int_type = reason;
-	ctx->int_err = err;
 	ctx->state = MFCINST_FINISHED;
 
drivers/media/platform/s5p-mfc/s5p_mfc.c +7 -0
 	spin_lock(&dev->irqlock);
@@ -646,6 +635,13 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
 		if (ctx->c_ops->post_frame_start) {
 			if (ctx->c_ops->post_frame_start(ctx))
 				mfc_err("post_frame_start() failed\n");
+
+			if (ctx->state == MFCINST_FINISHING &&
+						list_empty(&ctx->ref_queue))
 {
+				s5p_mfc_hw_call_void(dev->mfc_ops,
 clear_int_flags, dev);
+				s5p_mfc_handle_stream_complete(ctx);
+				break;
+			}
 			s5p_mfc_hw_call_void(dev->mfc_ops,

clear_int_flags, dev);

drivers/media/platform/s5p-mfc/s5p_mfc.c +0 -0
 			wake_up_ctx(ctx, reason, err);
 			WARN_ON(test_and_clear_bit(0, &dev->hw_lock) ==
Quoted 1 line

0); @@ -691,7 +687,10 @@ static irqreturn_t s5p_mfc_irq(int irq, void

*priv)

Quoted 28 lines
drivers/media/platform/s5p-mfc/s5p_mfc.c +4 -1
 		break;
 
 	case S5P_MFC_R2H_CMD_COMPLETE_SEQ_RET:
-		s5p_mfc_handle_stream_complete(ctx, reason, err);
+		s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev);
+		ctx->int_type = reason;
+		ctx->int_err = err;
+		s5p_mfc_handle_stream_complete(ctx);
 		break;
 
 	case S5P_MFC_R2H_CMD_DPB_FLUSH_RET:
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +2 -2
index 94868f7..d082d47 100644
@@ -907,9 +907,9 @@ static int enc_post_frame_start(struct s5p_mfc_ctx
 *ctx)
 			list_add_tail(&mb_entry->list, &ctx->ref_queue);
 			ctx->ref_queue_cnt++;
 		}
-		mfc_debug(2, "enc src count: %d, enc ref count: %d\n",
-			  ctx->src_queue_cnt, ctx->ref_queue_cnt);
 	}
+	mfc_debug(2, "enc src count: %d, enc ref count: %d\n",
+		  ctx->src_queue_cnt, ctx->ref_queue_cnt);
 	if ((ctx->dst_queue_cnt > 0) && (strm_size > 0)) {
 		mb_entry = list_entry(ctx->dst_queue.next, struct
Quoted 2 lines

s5p_mfc_buf,

list);

Quoted 15 lines
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +1 -0
@@ -932,6 +932,7 @@ static int enc_post_frame_start(struct s5p_mfc_ctx
 *ctx)
 	spin_unlock_irqrestore(&dev->irqlock, flags);
 	if ((ctx->src_queue_cnt == 0) || (ctx->dst_queue_cnt == 0))
 		clear_work_bit(ctx);
+
 	return 0;
 }
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +0 -0
index e0924a52..69a6880 100644

drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c static int s5p_mfc_set_enc_stream_buffer_v6(struct · line 526

Quoted 6 lines
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +1 -1
@@ -522,7 +522,7 @@ static int s5p_mfc_set_enc_stream_buffer_v6(struct
 s5p_mfc_ctx *ctx,
 	writel(addr, mfc_regs->e_stream_buffer_addr); /* 16B align */
 	writel(size, mfc_regs->e_stream_buffer_size);
 
-	mfc_debug(2, "stream buf addr: 0x%08lx, size: 0x%x\n",
+	mfc_debug(2, "stream buf addr: 0x%08lx, size: 0x%d\n",

A small mistake/type is present here - 0x is left when the formatting was changed from %x to %d. I am not sure what your intention was, hence I prefer to ask you instead of fixing this in my repo.

Quoted 126 lines
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +0 -0
 		  addr, size);
 
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +9 -3
 	return 0;
@@ -554,7 +554,7 @@ static void s5p_mfc_get_enc_frame_buffer_v6(struct
 s5p_mfc_ctx *ctx,
 	enc_recon_y_addr = readl(mfc_regs->e_recon_luma_dpb_addr);
 	enc_recon_c_addr = readl(mfc_regs->e_recon_chroma_dpb_addr);
 
-	mfc_debug(2, "recon y addr: 0x%08lx\n", enc_recon_y_addr);
+	mfc_debug(2, "recon y addr: 0x%08lx y_addr: 0x%08lx\n",
+enc_recon_y_addr, *y_addr);
 	mfc_debug(2, "recon c addr: 0x%08lx\n", enc_recon_c_addr);  }
@@ -1483,6 +1483,7 @@ static int s5p_mfc_encode_one_frame_v6(struct
 s5p_mfc_ctx *ctx)  {
 	struct s5p_mfc_dev *dev = ctx->dev;
 	const struct s5p_mfc_regs *mfc_regs = dev->mfc_regs;
+	int cmd;
 
 	mfc_debug(2, "++\n");
 
@@ -1493,9 +1494,13 @@ static int s5p_mfc_encode_one_frame_v6(struct
 s5p_mfc_ctx *ctx)
 
 	s5p_mfc_set_slice_mode(ctx);
 
+	if (ctx->state != MFCINST_FINISHING)
+		cmd = S5P_FIMV_CH_FRAME_START_V6;
+	else
+		cmd = S5P_FIMV_CH_LAST_FRAME_V6;
+
 	writel(ctx->inst_no, mfc_regs->instance_id);
-	s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev,
-			S5P_FIMV_CH_FRAME_START_V6, NULL);
+	s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, cmd,
 NULL);
 
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +2 -2
 	mfc_debug(2, "--\n");
@@ -1563,8 +1568,8 @@ static inline int s5p_mfc_run_dec_frame(struct
 s5p_mfc_ctx *ctx)
 	temp_vb->flags |= MFC_BUF_FLAG_USED;
 	s5p_mfc_set_dec_stream_buffer_v6(ctx,
 		vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf,
 0),
-		ctx->consumed_stream,
-		temp_vb->b->vb2_buf.planes[0].bytesused);
+			ctx->consumed_stream,
+			temp_vb->b->vb2_buf.planes[0].bytesused);
 	spin_unlock_irqrestore(&dev->irqlock, flags);
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +1 -1
 	dev->curr_ctx = ctx->num;
@@ -1592,7 +1597,7 @@ static inline int s5p_mfc_run_enc_frame(struct
 s5p_mfc_ctx *ctx)
 
 	spin_lock_irqsave(&dev->irqlock, flags);
 
-	if (list_empty(&ctx->src_queue)) {
+	if (list_empty(&ctx->src_queue) && ctx->state !=
 MFCINST_FINISHING) {
 		mfc_debug(2, "no src buffers.\n");
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +14 -6
 		spin_unlock_irqrestore(&dev->irqlock, flags);
 		return -EAGAIN;
@@ -1604,15 +1609,28 @@ static inline int s5p_mfc_run_enc_frame(struct
 s5p_mfc_ctx *ctx)
 		return -EAGAIN;
 	}
 
-	src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
-	src_mb->flags |= MFC_BUF_FLAG_USED;
-	src_y_addr = vb2_dma_contig_plane_dma_addr(&src_mb->b-
 >vb2_buf, 0);
-	src_c_addr = vb2_dma_contig_plane_dma_addr(&src_mb->b-
 >vb2_buf, 1);
+	if (list_empty(&ctx->src_queue)) {
+		/* send null frame */
+		s5p_mfc_set_enc_frame_buffer_v6(ctx, 0, 0);
+		src_mb = NULL;
+	} else {
+		src_mb = list_entry(ctx->src_queue.next, struct
 s5p_mfc_buf, list);
+		src_mb->flags |= MFC_BUF_FLAG_USED;
+		if (src_mb->b->vb2_buf.planes[0].bytesused == 0) {
+			s5p_mfc_set_enc_frame_buffer_v6(ctx, 0, 0);
+			ctx->state = MFCINST_FINISHING;
+		} else {
+			src_y_addr =
 vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 0);
+			src_c_addr =
 vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 1);
 
-	mfc_debug(2, "enc src y addr: 0x%08lx\n", src_y_addr);
-	mfc_debug(2, "enc src c addr: 0x%08lx\n", src_c_addr);
+			mfc_debug(2, "enc src y addr: 0x%08lx\n",

src_y_addr);

drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +1 -0
+			mfc_debug(2, "enc src c addr: 0x%08lx\n",

src_c_addr);

drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +1 -1
-	s5p_mfc_set_enc_frame_buffer_v6(ctx, src_y_addr, src_c_addr);
+			s5p_mfc_set_enc_frame_buffer_v6(ctx, src_y_addr,

src_c_addr);

drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +7 -4
+			if (src_mb->flags & MFC_BUF_FLAG_EOS)
+				ctx->state = MFCINST_FINISHING;
+		}
+	}
 
 	dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
 	dst_mb->flags |= MFC_BUF_FLAG_USED;
@@ -1639,11 +1657,10 @@ static inline void s5p_mfc_run_init_dec(struct
 s5p_mfc_ctx *ctx)
 	spin_lock_irqsave(&dev->irqlock, flags);
 	mfc_debug(2, "Preparing to init decoding.\n");
 	temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
-	mfc_debug(2, "Header size: %d\n",
-		temp_vb->b->vb2_buf.planes[0].bytesused);
+	mfc_debug(2, "Header size: %d\n",
+temp_vb->b->vb2_buf.planes[0].bytesused);
 	s5p_mfc_set_dec_stream_buffer_v6(ctx,
 		vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf,
 0), 0,
-		temp_vb->b->vb2_buf.planes[0].bytesused);
+			temp_vb->b->vb2_buf.planes[0].bytesused);
 	spin_unlock_irqrestore(&dev->irqlock, flags);
 	dev->curr_ctx = ctx->num;
 	s5p_mfc_init_decode_v6(ctx);
--
Quoted 1 line

1.9.1

Best wishes,

Signature · 2 lines
Kamil Debski
Samsung R&D Institute Poland