These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / media / platform / s5p-mfc / s5p_mfc_opr_v5.c
index b09bcd1..873c933 100644 (file)
@@ -41,7 +41,7 @@ static int s5p_mfc_alloc_dec_temp_buffers_v5(struct s5p_mfc_ctx *ctx)
        int ret;
 
        ctx->dsc.size = buf_size->dsc;
-       ret =  s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &ctx->dsc);
+       ret =  s5p_mfc_alloc_priv_buf(dev->mem_dev_l, dev->bank1, &ctx->dsc);
        if (ret) {
                mfc_err("Failed to allocate temporary buffer\n");
                return ret;
@@ -172,7 +172,8 @@ static int s5p_mfc_alloc_codec_buffers_v5(struct s5p_mfc_ctx *ctx)
        /* Allocate only if memory from bank 1 is necessary */
        if (ctx->bank1.size > 0) {
 
-               ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &ctx->bank1);
+               ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, dev->bank1,
+                                            &ctx->bank1);
                if (ret) {
                        mfc_err("Failed to allocate Bank1 temporary buffer\n");
                        return ret;
@@ -181,10 +182,11 @@ static int s5p_mfc_alloc_codec_buffers_v5(struct s5p_mfc_ctx *ctx)
        }
        /* Allocate only if memory from bank 2 is necessary */
        if (ctx->bank2.size > 0) {
-               ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_r, &ctx->bank2);
+               ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_r, dev->bank2,
+                                            &ctx->bank2);
                if (ret) {
                        mfc_err("Failed to allocate Bank2 temporary buffer\n");
-               s5p_mfc_release_priv_buf(ctx->dev->mem_dev_l, &ctx->bank1);
+                       s5p_mfc_release_priv_buf(ctx->dev->mem_dev_l, &ctx->bank1);
                        return ret;
                }
                BUG_ON(ctx->bank2.dma & ((1 << MFC_BANK2_ALIGN_ORDER) - 1));
@@ -212,7 +214,7 @@ static int s5p_mfc_alloc_instance_buffer_v5(struct s5p_mfc_ctx *ctx)
        else
                ctx->ctx.size = buf_size->non_h264_ctx;
 
-       ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &ctx->ctx);
+       ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, dev->bank1, &ctx->ctx);
        if (ret) {
                mfc_err("Failed to allocate instance buffer\n");
                return ret;
@@ -225,7 +227,7 @@ static int s5p_mfc_alloc_instance_buffer_v5(struct s5p_mfc_ctx *ctx)
 
        /* Initialize shared memory */
        ctx->shm.size = buf_size->shm;
-       ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &ctx->shm);
+       ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, dev->bank1, &ctx->shm);
        if (ret) {
                mfc_err("Failed to allocate shared memory buffer\n");
                s5p_mfc_release_priv_buf(dev->mem_dev_l, &ctx->ctx);
@@ -263,7 +265,7 @@ static void s5p_mfc_release_dev_context_buffer_v5(struct s5p_mfc_dev *dev)
 static void s5p_mfc_write_info_v5(struct s5p_mfc_ctx *ctx, unsigned int data,
                        unsigned int ofs)
 {
-       writel(data, (void *)(ctx->shm.virt + ofs));
+       *(u32 *)(ctx->shm.virt + ofs) = data;
        wmb();
 }
 
@@ -271,7 +273,7 @@ static unsigned int s5p_mfc_read_info_v5(struct s5p_mfc_ctx *ctx,
                                unsigned long ofs)
 {
        rmb();
-       return readl((void *)(ctx->shm.virt + ofs));
+       return *(u32 *)(ctx->shm.virt + ofs);
 }
 
 static void s5p_mfc_dec_calc_dpb_size_v5(struct s5p_mfc_ctx *ctx)
@@ -1206,11 +1208,11 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame)
        temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
        temp_vb->flags |= MFC_BUF_FLAG_USED;
        s5p_mfc_set_dec_stream_buffer_v5(ctx,
-               vb2_dma_contig_plane_dma_addr(temp_vb->b, 0),
-               ctx->consumed_stream, temp_vb->b->v4l2_planes[0].bytesused);
+               vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
+               ctx->consumed_stream, temp_vb->b->vb2_buf.planes[0].bytesused);
        spin_unlock_irqrestore(&dev->irqlock, flags);
        dev->curr_ctx = ctx->num;
-       if (temp_vb->b->v4l2_planes[0].bytesused == 0) {
+       if (temp_vb->b->vb2_buf.planes[0].bytesused == 0) {
                last_frame = MFC_DEC_LAST_FRAME;
                mfc_debug(2, "Setting ctx->state to FINISHING\n");
                ctx->state = MFCINST_FINISHING;
@@ -1247,16 +1249,16 @@ static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
                src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf,
                                                                        list);
                src_mb->flags |= MFC_BUF_FLAG_USED;
-               if (src_mb->b->v4l2_planes[0].bytesused == 0) {
+               if (src_mb->b->vb2_buf.planes[0].bytesused == 0) {
                        /* send null frame */
                        s5p_mfc_set_enc_frame_buffer_v5(ctx, dev->bank2,
                                                                dev->bank2);
                        ctx->state = MFCINST_FINISHING;
                } else {
-                       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_set_enc_frame_buffer_v5(ctx, src_y_addr,
                                                                src_c_addr);
                        if (src_mb->flags & MFC_BUF_FLAG_EOS)
@@ -1265,13 +1267,13 @@ static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
        }
        dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
        dst_mb->flags |= MFC_BUF_FLAG_USED;
-       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_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size);
        spin_unlock_irqrestore(&dev->irqlock, flags);
        dev->curr_ctx = ctx->num;
        mfc_debug(2, "encoding buffer with index=%d state=%d\n",
-                 src_mb ? src_mb->b->v4l2_buf.index : -1, ctx->state);
+                 src_mb ? src_mb->b->vb2_buf.index : -1, ctx->state);
        s5p_mfc_encode_one_frame_v5(ctx);
        return 0;
 }
@@ -1287,10 +1289,11 @@ static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
        mfc_debug(2, "Preparing to init decoding\n");
        temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
        s5p_mfc_set_dec_desc_buffer(ctx);
-       mfc_debug(2, "Header size: %d\n", temp_vb->b->v4l2_planes[0].bytesused);
+       mfc_debug(2, "Header size: %d\n",
+                       temp_vb->b->vb2_buf.planes[0].bytesused);
        s5p_mfc_set_dec_stream_buffer_v5(ctx,
-                               vb2_dma_contig_plane_dma_addr(temp_vb->b, 0),
-                               0, temp_vb->b->v4l2_planes[0].bytesused);
+                       vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
+                       0, temp_vb->b->vb2_buf.planes[0].bytesused);
        spin_unlock_irqrestore(&dev->irqlock, flags);
        dev->curr_ctx = ctx->num;
        s5p_mfc_init_decode_v5(ctx);
@@ -1307,8 +1310,8 @@ static void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx)
        s5p_mfc_set_enc_ref_buffer_v5(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_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size);
        spin_unlock_irqrestore(&dev->irqlock, flags);
        dev->curr_ctx = ctx->num;
@@ -1340,10 +1343,11 @@ static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
                return -EIO;
        }
        temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
-       mfc_debug(2, "Header size: %d\n", temp_vb->b->v4l2_planes[0].bytesused);
+       mfc_debug(2, "Header size: %d\n",
+                       temp_vb->b->vb2_buf.planes[0].bytesused);
        s5p_mfc_set_dec_stream_buffer_v5(ctx,
-                               vb2_dma_contig_plane_dma_addr(temp_vb->b, 0),
-                               0, temp_vb->b->v4l2_planes[0].bytesused);
+                       vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
+                       0, temp_vb->b->vb2_buf.planes[0].bytesused);
        spin_unlock_irqrestore(&dev->irqlock, flags);
        dev->curr_ctx = ctx->num;
        ret = s5p_mfc_set_dec_frame_buffer_v5(ctx);
@@ -1476,9 +1480,9 @@ static void s5p_mfc_cleanup_queue_v5(struct list_head *lh, struct vb2_queue *vq)
 
        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);
+               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);
        }
 }