s5p-mfc: make queue cleanup code common
authorAndrzej Hajda <a.hajda@samsung.com>
Tue, 10 Nov 2015 11:48:25 +0000 (12:48 +0100)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 14 Dec 2016 04:48:57 +0000 (13:48 +0900)
Code for queue cleanup has nothing specific to hardware version.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
drivers/media/platform/s5p-mfc/s5p_mfc.c
drivers/media/platform/s5p-mfc/s5p_mfc_common.h
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c

index 726b17d..a4d8181 100644 (file)
@@ -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->num_planes; i++)
+                       vb2_set_plane_payload(b->b, i, 0);
+               vb2_buffer_done(b->b, 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);
        }
@@ -464,11 +476,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;
index 4a12c8a..1bef7fe 100644 (file)
@@ -717,6 +717,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)
index f659c5f..084fdcf 100644 (file)
@@ -1073,8 +1073,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;
@@ -1091,8 +1090,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);
index 8b4d1a8..b353906 100644 (file)
@@ -1985,15 +1985,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;
        }
index 37afe2d..fb89b91 100644 (file)
@@ -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);
index bf6a231..76bcd9b 100644 (file)
@@ -1449,21 +1449,6 @@ static void s5p_mfc_try_run_v5(struct s5p_mfc_dev *dev)
        }
 }
 
-
-static void s5p_mfc_cleanup_queue_v5(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->num_planes; i++)
-                       vb2_set_plane_payload(b->b, i, 0);
-               vb2_buffer_done(b->b, VB2_BUF_STATE_ERROR);
-               list_del(&b->list);
-       }
-}
-
 static void s5p_mfc_clear_int_flags_v5(struct s5p_mfc_dev *dev)
 {
        mfc_write(dev, 0, S5P_FIMV_RISC_HOST_INT);
@@ -1675,7 +1660,6 @@ static struct s5p_mfc_hw_ops s5p_mfc_ops_v5 = {
        .init_encode = s5p_mfc_init_encode_v5,
        .encode_one_frame = s5p_mfc_encode_one_frame_v5,
        .try_run = s5p_mfc_try_run_v5,
-       .cleanup_queue = s5p_mfc_cleanup_queue_v5,
        .clear_int_flags = s5p_mfc_clear_int_flags_v5,
        .write_info = s5p_mfc_write_info_v5,
        .read_info = s5p_mfc_read_info_v5,
index 84632d5..d1e432e 100644 (file)
@@ -1822,21 +1822,6 @@ static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev)
        }
 }
 
-
-static void s5p_mfc_cleanup_queue_v6(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->num_planes; i++)
-                       vb2_set_plane_payload(b->b, i, 0);
-               vb2_buffer_done(b->b, VB2_BUF_STATE_ERROR);
-               list_del(&b->list);
-       }
-}
-
 static void s5p_mfc_clear_int_flags_v6(struct s5p_mfc_dev *dev)
 {
        const struct s5p_mfc_regs *mfc_regs = dev->mfc_regs;
@@ -2268,7 +2253,6 @@ static struct s5p_mfc_hw_ops s5p_mfc_ops_v6 = {
        .init_encode = s5p_mfc_init_encode_v6,
        .encode_one_frame = s5p_mfc_encode_one_frame_v6,
        .try_run = s5p_mfc_try_run_v6,
-       .cleanup_queue = s5p_mfc_cleanup_queue_v6,
        .clear_int_flags = s5p_mfc_clear_int_flags_v6,
        .write_info = s5p_mfc_write_info_v6,
        .read_info = s5p_mfc_read_info_v6,