]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
Merge remote-tracking branch 'v4l-dvb/master'
[karo-tx-linux.git] / drivers / media / platform / s5p-mfc / s5p_mfc_enc.c
index 2e57e9f45b85e1a19002d60c9a98acde65373c00..5c678ec9c9f26ad7e4c1025e139b76b8623b6ca8 100644 (file)
@@ -23,7 +23,7 @@
 #include <media/v4l2-event.h>
 #include <linux/workqueue.h>
 #include <media/v4l2-ctrls.h>
-#include <media/videobuf2-core.h>
+#include <media/videobuf2-v4l2.h>
 #include "s5p_mfc_common.h"
 #include "s5p_mfc_ctrl.h"
 #include "s5p_mfc_debug.h"
@@ -773,8 +773,8 @@ static int enc_pre_seq_start(struct s5p_mfc_ctx *ctx)
 
        spin_lock_irqsave(&dev->irqlock, flags);
        dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
-       dst_addr = vb2_dma_contig_plane_dma_addr(dst_mb->b, 0);
-       dst_size = vb2_plane_size(dst_mb->b, 0);
+       dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
+       dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
        s5p_mfc_hw_call_void(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr,
                        dst_size);
        spin_unlock_irqrestore(&dev->irqlock, flags);
@@ -796,10 +796,11 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
                                        struct s5p_mfc_buf, list);
                        list_del(&dst_mb->list);
                        ctx->dst_queue_cnt--;
-                       vb2_set_plane_payload(dst_mb->b, 0,
+                       vb2_set_plane_payload(&dst_mb->b->vb2_buf, 0,
                                s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size,
                                                dev));
-                       vb2_buffer_done(dst_mb->b, VB2_BUF_STATE_DONE);
+                       vb2_buffer_done(&dst_mb->b->vb2_buf,
+                                       VB2_BUF_STATE_DONE);
                }
                spin_unlock_irqrestore(&dev->irqlock, flags);
        }
@@ -831,16 +832,16 @@ static int enc_pre_frame_start(struct s5p_mfc_ctx *ctx)
 
        spin_lock_irqsave(&dev->irqlock, flags);
        src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
-       src_y_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 0);
-       src_c_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 1);
+       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);
        s5p_mfc_hw_call_void(dev->mfc_ops, set_enc_frame_buffer, ctx,
                                                        src_y_addr, src_c_addr);
        spin_unlock_irqrestore(&dev->irqlock, flags);
 
        spin_lock_irqsave(&dev->irqlock, flags);
        dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
-       dst_addr = vb2_dma_contig_plane_dma_addr(dst_mb->b, 0);
-       dst_size = vb2_plane_size(dst_mb->b, 0);
+       dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
+       dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
        s5p_mfc_hw_call_void(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr,
                        dst_size);
        spin_unlock_irqrestore(&dev->irqlock, flags);
@@ -869,25 +870,29 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
                s5p_mfc_hw_call_void(dev->mfc_ops, get_enc_frame_buffer, ctx,
                                &enc_y_addr, &enc_c_addr);
                list_for_each_entry(mb_entry, &ctx->src_queue, list) {
-                       mb_y_addr = vb2_dma_contig_plane_dma_addr(mb_entry->b, 0);
-                       mb_c_addr = vb2_dma_contig_plane_dma_addr(mb_entry->b, 1);
+                       mb_y_addr = vb2_dma_contig_plane_dma_addr(
+                                       &mb_entry->b->vb2_buf, 0);
+                       mb_c_addr = vb2_dma_contig_plane_dma_addr(
+                                       &mb_entry->b->vb2_buf, 1);
                        if ((enc_y_addr == mb_y_addr) &&
                                                (enc_c_addr == mb_c_addr)) {
                                list_del(&mb_entry->list);
                                ctx->src_queue_cnt--;
-                               vb2_buffer_done(mb_entry->b,
+                               vb2_buffer_done(&mb_entry->b->vb2_buf,
                                                        VB2_BUF_STATE_DONE);
                                break;
                        }
                }
                list_for_each_entry(mb_entry, &ctx->ref_queue, list) {
-                       mb_y_addr = vb2_dma_contig_plane_dma_addr(mb_entry->b, 0);
-                       mb_c_addr = vb2_dma_contig_plane_dma_addr(mb_entry->b, 1);
+                       mb_y_addr = vb2_dma_contig_plane_dma_addr(
+                                       &mb_entry->b->vb2_buf, 0);
+                       mb_c_addr = vb2_dma_contig_plane_dma_addr(
+                                       &mb_entry->b->vb2_buf, 1);
                        if ((enc_y_addr == mb_y_addr) &&
                                                (enc_c_addr == mb_c_addr)) {
                                list_del(&mb_entry->list);
                                ctx->ref_queue_cnt--;
-                               vb2_buffer_done(mb_entry->b,
+                               vb2_buffer_done(&mb_entry->b->vb2_buf,
                                                        VB2_BUF_STATE_DONE);
                                break;
                        }
@@ -902,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);
@@ -912,21 +917,22 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
                ctx->dst_queue_cnt--;
                switch (slice_type) {
                case S5P_FIMV_ENC_SI_SLICE_TYPE_I:
-                       mb_entry->b->v4l2_buf.flags |= V4L2_BUF_FLAG_KEYFRAME;
+                       mb_entry->b->flags |= V4L2_BUF_FLAG_KEYFRAME;
                        break;
                case S5P_FIMV_ENC_SI_SLICE_TYPE_P:
-                       mb_entry->b->v4l2_buf.flags |= V4L2_BUF_FLAG_PFRAME;
+                       mb_entry->b->flags |= V4L2_BUF_FLAG_PFRAME;
                        break;
                case S5P_FIMV_ENC_SI_SLICE_TYPE_B:
-                       mb_entry->b->v4l2_buf.flags |= V4L2_BUF_FLAG_BFRAME;
+                       mb_entry->b->flags |= V4L2_BUF_FLAG_BFRAME;
                        break;
                }
-               vb2_set_plane_payload(mb_entry->b, 0, strm_size);
-               vb2_buffer_done(mb_entry->b, VB2_BUF_STATE_DONE);
+               vb2_set_plane_payload(&mb_entry->b->vb2_buf, 0, strm_size);
+               vb2_buffer_done(&mb_entry->b->vb2_buf, VB2_BUF_STATE_DONE);
        }
        spin_unlock_irqrestore(&dev->irqlock, flags);
        if ((ctx->src_queue_cnt == 0) || (ctx->dst_queue_cnt == 0))
                clear_work_bit(ctx);
+
        return 0;
 }
 
@@ -1806,13 +1812,13 @@ static int check_vb_with_fmt(struct s5p_mfc_fmt *fmt, struct vb2_buffer *vb)
                        return -EINVAL;
                }
                mfc_debug(2, "index: %d, plane[%d] cookie: %pad\n",
-                         vb->v4l2_buf.index, i, &dma);
+                         vb->index, i, &dma);
        }
        return 0;
 }
 
 static int s5p_mfc_queue_setup(struct vb2_queue *vq,
-                       const struct v4l2_format *fmt,
+                       const void *parg,
                        unsigned int *buf_count, unsigned int *plane_count,
                        unsigned int psize[], void *allocators[])
 {
@@ -1821,7 +1827,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
 
        if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
                if (ctx->state != MFCINST_GOT_INST) {
-                       mfc_err("inavlid state: %d\n", ctx->state);
+                       mfc_err("invalid state: %d\n", ctx->state);
                        return -EINVAL;
                }
 
@@ -1861,7 +1867,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
                                ctx->dev->alloc_ctx[MFC_BANK2_ALLOC_CTX];
                }
        } else {
-               mfc_err("inavlid queue type: %d\n", vq->type);
+               mfc_err("invalid queue type: %d\n", vq->type);
                return -EINVAL;
        }
        return 0;
@@ -1869,6 +1875,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
 
 static int s5p_mfc_buf_init(struct vb2_buffer *vb)
 {
+       struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct vb2_queue *vq = vb->vb2_queue;
        struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
        unsigned int i;
@@ -1878,8 +1885,8 @@ static int s5p_mfc_buf_init(struct vb2_buffer *vb)
                ret = check_vb_with_fmt(ctx->dst_fmt, vb);
                if (ret < 0)
                        return ret;
-               i = vb->v4l2_buf.index;
-               ctx->dst_bufs[i].b = vb;
+               i = vb->index;
+               ctx->dst_bufs[i].b = vbuf;
                ctx->dst_bufs[i].cookie.stream =
                                        vb2_dma_contig_plane_dma_addr(vb, 0);
                ctx->dst_bufs_cnt++;
@@ -1887,15 +1894,15 @@ static int s5p_mfc_buf_init(struct vb2_buffer *vb)
                ret = check_vb_with_fmt(ctx->src_fmt, vb);
                if (ret < 0)
                        return ret;
-               i = vb->v4l2_buf.index;
-               ctx->src_bufs[i].b = vb;
+               i = vb->index;
+               ctx->src_bufs[i].b = vbuf;
                ctx->src_bufs[i].cookie.raw.luma =
                                        vb2_dma_contig_plane_dma_addr(vb, 0);
                ctx->src_bufs[i].cookie.raw.chroma =
                                        vb2_dma_contig_plane_dma_addr(vb, 1);
                ctx->src_bufs_cnt++;
        } else {
-               mfc_err("inavlid queue type: %d\n", vq->type);
+               mfc_err("invalid queue type: %d\n", vq->type);
                return -EINVAL;
        }
        return 0;
@@ -1931,7 +1938,7 @@ static int s5p_mfc_buf_prepare(struct vb2_buffer *vb)
                        return -EINVAL;
                }
        } else {
-               mfc_err("inavlid queue type: %d\n", vq->type);
+               mfc_err("invalid queue type: %d\n", vq->type);
                return -EINVAL;
        }
        return 0;
@@ -2012,7 +2019,7 @@ static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
                return;
        }
        if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-               mfc_buf = &ctx->dst_bufs[vb->v4l2_buf.index];
+               mfc_buf = &ctx->dst_bufs[vb->index];
                mfc_buf->flags &= ~MFC_BUF_FLAG_USED;
                /* Mark destination as available for use by MFC */
                spin_lock_irqsave(&dev->irqlock, flags);
@@ -2020,7 +2027,7 @@ static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
                ctx->dst_queue_cnt++;
                spin_unlock_irqrestore(&dev->irqlock, flags);
        } else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
-               mfc_buf = &ctx->src_bufs[vb->v4l2_buf.index];
+               mfc_buf = &ctx->src_bufs[vb->index];
                mfc_buf->flags &= ~MFC_BUF_FLAG_USED;
                spin_lock_irqsave(&dev->irqlock, flags);
                list_add_tail(&mfc_buf->list, &ctx->src_queue);