Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62bbd72b authored by Andrzej Hajda's avatar Andrzej Hajda Committed by Mauro Carvalho Chehab
Browse files

[media] s5p-mfc: make queue cleanup code common



Code for queue cleanup has nothing specific to hardware version.

Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Signed-off-by: default avatarKamil Debski <k.debski@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 05d1d0f0
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -125,6 +125,20 @@ static void wake_up_dev(struct s5p_mfc_dev *dev, unsigned int reason,
	wake_up(&dev->queue);
}

void s5p_mfc_cleanup_queue(struct list_head *lh, struct vb2_queue *vq)
{
	struct s5p_mfc_buf *b;
	int i;

	while (!list_empty(lh)) {
		b = list_entry(lh->next, struct s5p_mfc_buf, list);
		for (i = 0; i < b->b->vb2_buf.num_planes; i++)
			vb2_set_plane_payload(&b->b->vb2_buf, i, 0);
		vb2_buffer_done(&b->b->vb2_buf, VB2_BUF_STATE_ERROR);
		list_del(&b->list);
	}
}

static void s5p_mfc_watchdog(unsigned long arg)
{
	struct s5p_mfc_dev *dev = (struct s5p_mfc_dev *)arg;
@@ -170,10 +184,8 @@ static void s5p_mfc_watchdog_worker(struct work_struct *work)
		if (!ctx)
			continue;
		ctx->state = MFCINST_ERROR;
		s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
						&ctx->dst_queue, &ctx->vq_dst);
		s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
						&ctx->src_queue, &ctx->vq_src);
		s5p_mfc_cleanup_queue(&ctx->dst_queue, &ctx->vq_dst);
		s5p_mfc_cleanup_queue(&ctx->src_queue, &ctx->vq_src);
		clear_work_bit(ctx);
		wake_up_ctx(ctx, S5P_MFC_R2H_CMD_ERR_RET, 0);
	}
@@ -471,11 +483,9 @@ static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev,
			ctx->state = MFCINST_ERROR;
			/* Mark all dst buffers as having an error */
			spin_lock_irqsave(&dev->irqlock, flags);
			s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
						&ctx->dst_queue, &ctx->vq_dst);
			s5p_mfc_cleanup_queue(&ctx->dst_queue, &ctx->vq_dst);
			/* Mark all src buffers as having an error */
			s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
						&ctx->src_queue, &ctx->vq_src);
			s5p_mfc_cleanup_queue(&ctx->src_queue, &ctx->vq_src);
			spin_unlock_irqrestore(&dev->irqlock, flags);
			wake_up_ctx(ctx, reason, err);
			break;
+1 −0
Original line number Diff line number Diff line
@@ -711,6 +711,7 @@ void set_work_bit(struct s5p_mfc_ctx *ctx);
void clear_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
int s5p_mfc_get_new_ctx(struct s5p_mfc_dev *dev);
void s5p_mfc_cleanup_queue(struct list_head *lh, struct vb2_queue *vq);

#define HAS_PORTNUM(dev)	(dev ? (dev->variant ? \
				(dev->variant->port_num ? 1 : 0) : 0) : 0)
+2 −4
Original line number Diff line number Diff line
@@ -1033,8 +1033,7 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
	}
	if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
		spin_lock_irqsave(&dev->irqlock, flags);
		s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
						&ctx->dst_queue, &ctx->vq_dst);
		s5p_mfc_cleanup_queue(&ctx->dst_queue, &ctx->vq_dst);
		INIT_LIST_HEAD(&ctx->dst_queue);
		ctx->dst_queue_cnt = 0;
		ctx->dpb_flush_flag = 1;
@@ -1051,8 +1050,7 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
	}
	if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
		spin_lock_irqsave(&dev->irqlock, flags);
		s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
						&ctx->src_queue, &ctx->vq_src);
		s5p_mfc_cleanup_queue(&ctx->src_queue, &ctx->vq_src);
		INIT_LIST_HEAD(&ctx->src_queue);
		ctx->src_queue_cnt = 0;
		spin_unlock_irqrestore(&dev->irqlock, flags);
+2 −4
Original line number Diff line number Diff line
@@ -1989,15 +1989,13 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
	ctx->state = MFCINST_FINISHED;
	spin_lock_irqsave(&dev->irqlock, flags);
	if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
		s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
						&ctx->dst_queue, &ctx->vq_dst);
		s5p_mfc_cleanup_queue(&ctx->dst_queue, &ctx->vq_dst);
		INIT_LIST_HEAD(&ctx->dst_queue);
		ctx->dst_queue_cnt = 0;
	}
	if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
		cleanup_ref_queue(ctx);
		s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue, &ctx->src_queue,
				&ctx->vq_src);
		s5p_mfc_cleanup_queue(&ctx->src_queue, &ctx->vq_src);
		INIT_LIST_HEAD(&ctx->src_queue);
		ctx->src_queue_cnt = 0;
	}
+0 −2
Original line number Diff line number Diff line
@@ -296,8 +296,6 @@ struct s5p_mfc_hw_ops {
	int (*init_encode)(struct s5p_mfc_ctx *ctx);
	int (*encode_one_frame)(struct s5p_mfc_ctx *ctx);
	void (*try_run)(struct s5p_mfc_dev *dev);
	void (*cleanup_queue)(struct list_head *lh,
			struct vb2_queue *vq);
	void (*clear_int_flags)(struct s5p_mfc_dev *dev);
	void (*write_info)(struct s5p_mfc_ctx *ctx, unsigned int data,
			unsigned int ofs);
Loading