[media] s5p-mfc: make queue cleanup code common
authorAndrzej Hajda <a.hajda@samsung.com>
Wed, 2 Dec 2015 08:22:29 +0000 (06:22 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Wed, 23 Dec 2015 15:56:14 +0000 (13:56 -0200)
Code for queue cleanup has nothing specific to hardware version.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.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 974b704dad902607ac4f916a3ffb78701c87719a..cff59aa9a615f95fe918a9e564b45230df51d15c 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->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;
index 795ba44d789cc05e6ec1b28b05e1ee338a17bbca..d80ad84b8d4115f3f049ed096776bce1b196b31c 100644 (file)
@@ -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)
index 7f6e4c0be31dccd53b06f8d786e2f48f03001208..b1290ccf5a3df795012ce9883bf95ae7855876ff 100644 (file)
@@ -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);
index a9863998d412e5c3268db05003409e677264c8d4..82d380be49e9133ff71d72a4a58fa99c84d1e9a0 100644 (file)
@@ -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;
        }
index 77a08b19b46d0032220a2a99ef0bd8fefe72f570..b89df89b55d1eb1462578bb843dd51a8b45cdb51 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 d9e5d68a492c7879381c19d6cf18b6addb6773ff..ae4c950f850c42a1b3d3b069f0c6d3b5aa806202 100644 (file)
@@ -1451,21 +1451,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->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_clear_int_flags_v5(struct s5p_mfc_dev *dev)
 {
        mfc_write(dev, 0, S5P_FIMV_RISC_HOST_INT);
@@ -1677,7 +1662,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 f68653f122542d07dac447f0c73832defed30a82..fbff09a1b501fcf6febc1b1c588f656b64deb270 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->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_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,