These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / media / pci / sta2x11 / sta2x11_vip.c
index d384a6b..6367b45 100644 (file)
 
 
 struct vip_buffer {
-       struct vb2_buffer       vb;
+       struct vb2_v4l2_buffer vb;
        struct list_head        list;
        dma_addr_t              dma;
 };
-static inline struct vip_buffer *to_vip_buffer(struct vb2_buffer *vb2)
+static inline struct vip_buffer *to_vip_buffer(struct vb2_v4l2_buffer *vb2)
 {
        return container_of(vb2, struct vip_buffer, vb);
 }
@@ -265,7 +265,7 @@ static void vip_active_buf_next(struct sta2x11_vip *vip)
 
 
 /* Videobuf2 Operations */
-static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
+static int queue_setup(struct vb2_queue *vq, const void *parg,
                       unsigned int *nbuffers, unsigned int *nplanes,
                       unsigned int sizes[], void *alloc_ctxs[])
 {
@@ -287,7 +287,8 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
 };
 static int buffer_init(struct vb2_buffer *vb)
 {
-       struct vip_buffer *vip_buf = to_vip_buffer(vb);
+       struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+       struct vip_buffer *vip_buf = to_vip_buffer(vbuf);
 
        vip_buf->dma = vb2_dma_contig_plane_dma_addr(vb, 0);
        INIT_LIST_HEAD(&vip_buf->list);
@@ -296,8 +297,9 @@ static int buffer_init(struct vb2_buffer *vb)
 
 static int buffer_prepare(struct vb2_buffer *vb)
 {
+       struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct sta2x11_vip *vip = vb2_get_drv_priv(vb->vb2_queue);
-       struct vip_buffer *vip_buf = to_vip_buffer(vb);
+       struct vip_buffer *vip_buf = to_vip_buffer(vbuf);
        unsigned long size;
 
        size = vip->format.sizeimage;
@@ -307,14 +309,15 @@ static int buffer_prepare(struct vb2_buffer *vb)
                return -EINVAL;
        }
 
-       vb2_set_plane_payload(&vip_buf->vb, 0, size);
+       vb2_set_plane_payload(&vip_buf->vb.vb2_buf, 0, size);
 
        return 0;
 }
 static void buffer_queue(struct vb2_buffer *vb)
 {
+       struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct sta2x11_vip *vip = vb2_get_drv_priv(vb->vb2_queue);
-       struct vip_buffer *vip_buf = to_vip_buffer(vb);
+       struct vip_buffer *vip_buf = to_vip_buffer(vbuf);
 
        spin_lock(&vip->lock);
        list_add_tail(&vip_buf->list, &vip->buffer_list);
@@ -329,8 +332,9 @@ static void buffer_queue(struct vb2_buffer *vb)
 }
 static void buffer_finish(struct vb2_buffer *vb)
 {
+       struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct sta2x11_vip *vip = vb2_get_drv_priv(vb->vb2_queue);
-       struct vip_buffer *vip_buf = to_vip_buffer(vb);
+       struct vip_buffer *vip_buf = to_vip_buffer(vbuf);
 
        /* Buffer handled, remove it from the list */
        spin_lock(&vip->lock);
@@ -370,7 +374,7 @@ static void stop_streaming(struct vb2_queue *vq)
        /* Release all active buffers */
        spin_lock(&vip->lock);
        list_for_each_entry_safe(vip_buf, node, &vip->buffer_list, list) {
-               vb2_buffer_done(&vip_buf->vb, VB2_BUF_STATE_ERROR);
+               vb2_buffer_done(&vip_buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
                list_del(&vip_buf->list);
        }
        spin_unlock(&vip->lock);
@@ -813,9 +817,9 @@ static irqreturn_t vip_irq(int irq, struct sta2x11_vip *vip)
                /* Disable acquisition */
                reg_write(vip, DVP_CTL, reg_read(vip, DVP_CTL) & ~DVP_CTL_ENA);
                /* Remove the active buffer from the list */
-               do_gettimeofday(&vip->active->vb.v4l2_buf.timestamp);
-               vip->active->vb.v4l2_buf.sequence = vip->sequence++;
-               vb2_buffer_done(&vip->active->vb, VB2_BUF_STATE_DONE);
+               v4l2_get_timestamp(&vip->active->vb.timestamp);
+               vip->active->vb.sequence = vip->sequence++;
+               vb2_buffer_done(&vip->active->vb.vb2_buf, VB2_BUF_STATE_DONE);
        }
 
        return IRQ_HANDLED;
@@ -864,6 +868,7 @@ static int sta2x11_vip_init_buffer(struct sta2x11_vip *vip)
        vip->vb_vidq.buf_struct_size = sizeof(struct vip_buffer);
        vip->vb_vidq.ops = &vip_video_qops;
        vip->vb_vidq.mem_ops = &vb2_dma_contig_memops;
+       vip->vb_vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        err = vb2_queue_init(&vip->vb_vidq);
        if (err)
                return err;