--- zzzz-none-000/linux-3.10.107/drivers/media/pci/sta2x11/sta2x11_vip.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/pci/sta2x11/sta2x11_vip.c 2021-02-04 17:41:59.000000000 +0000 @@ -88,11 +88,11 @@ 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); } @@ -127,7 +127,7 @@ */ struct sta2x11_vip { struct v4l2_device v4l2_dev; - struct video_device *video_dev; + struct video_device video_dev; struct pci_dev *pdev; struct i2c_adapter *adapter; unsigned int register_save_area[IRQ_COUNT + SAVE_COUNT + AUX_COUNT]; @@ -152,7 +152,7 @@ int tcount, bcount; int overflow; - void *iomem; /* I/O Memory */ + void __iomem *iomem; /* I/O Memory */ struct vip_config *config; }; @@ -265,7 +265,7 @@ /* 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 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_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 @@ 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); @@ -327,19 +330,19 @@ } spin_unlock(&vip->lock); } -static int buffer_finish(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); list_del_init(&vip_buf->list); spin_unlock(&vip->lock); - vip_active_buf_next(vip); - - return 0; + if (vb2_is_streaming(vb->vb2_queue)) + vip_active_buf_next(vip); } static int start_streaming(struct vb2_queue *vq, unsigned int count) @@ -358,7 +361,7 @@ } /* abort streaming and wait for last buffer */ -static int stop_streaming(struct vb2_queue *vq) +static void stop_streaming(struct vb2_queue *vq) { struct sta2x11_vip *vip = vb2_get_drv_priv(vq); struct vip_buffer *vip_buf, *node; @@ -371,11 +374,10 @@ /* 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); - return 0; } static struct vb2_ops vip_video_qops = { @@ -446,7 +448,7 @@ int status; if (V4L2_STD_ALL == std) { - v4l2_subdev_call(vip->decoder, core, s_std, std); + v4l2_subdev_call(vip->decoder, video, s_std, std); ssleep(2); v4l2_subdev_call(vip->decoder, video, querystd, &newstd); v4l2_subdev_call(vip->decoder, video, g_input_status, &status); @@ -469,7 +471,7 @@ vip->format = formats_50[0]; } - return v4l2_subdev_call(vip->decoder, core, s_std, std); + return v4l2_subdev_call(vip->decoder, video, s_std, std); } /** @@ -642,7 +644,6 @@ f->fmt.pix.bytesperline = f->fmt.pix.width * 2; f->fmt.pix.sizeimage = f->fmt.pix.width * 2 * f->fmt.pix.height; f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; - f->fmt.pix.priv = 0; return 0; } @@ -766,7 +767,7 @@ static struct video_device video_dev_template = { .name = KBUILD_MODNAME, - .release = video_device_release, + .release = video_device_release_empty, .fops = &vip_fops, .ioctl_ops = &vip_ioctl_ops, .tvnorms = V4L2_STD_ALL, @@ -816,9 +817,9 @@ /* 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; @@ -867,6 +868,7 @@ 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; @@ -1047,7 +1049,8 @@ ret = sta2x11_vip_init_controls(vip); if (ret) goto free_mem; - if (v4l2_device_register(&pdev->dev, &vip->v4l2_dev)) + ret = v4l2_device_register(&pdev->dev, &vip->v4l2_dev); + if (ret) goto free_mem; dev_dbg(&pdev->dev, "BAR #0 at 0x%lx 0x%lx irq %d\n", @@ -1084,20 +1087,13 @@ goto release_buf; } - /* Alloc, initialize and register video device */ - vip->video_dev = video_device_alloc(); - if (!vip->video_dev) { - ret = -ENOMEM; - goto release_irq; - } + /* Initialize and register video device */ + vip->video_dev = video_dev_template; + vip->video_dev.v4l2_dev = &vip->v4l2_dev; + vip->video_dev.queue = &vip->vb_vidq; + video_set_drvdata(&vip->video_dev, vip); - vip->video_dev = &video_dev_template; - vip->video_dev->v4l2_dev = &vip->v4l2_dev; - vip->video_dev->queue = &vip->vb_vidq; - set_bit(V4L2_FL_USE_FH_PRIO, &vip->video_dev->flags); - video_set_drvdata(vip->video_dev, vip); - - ret = video_register_device(vip->video_dev, VFL_TYPE_GRABBER, -1); + ret = video_register_device(&vip->video_dev, VFL_TYPE_GRABBER, -1); if (ret) goto vrelease; @@ -1127,13 +1123,9 @@ return 0; vunreg: - video_set_drvdata(vip->video_dev, NULL); + video_set_drvdata(&vip->video_dev, NULL); vrelease: - if (video_is_registered(vip->video_dev)) - video_unregister_device(vip->video_dev); - else - video_device_release(vip->video_dev); -release_irq: + video_unregister_device(&vip->video_dev); free_irq(pdev->irq, vip); release_buf: sta2x11_vip_release_buffer(vip); @@ -1178,9 +1170,8 @@ sta2x11_vip_clear_register(vip); - video_set_drvdata(vip->video_dev, NULL); - video_unregister_device(vip->video_dev); - /*do not call video_device_release() here, is already done */ + video_set_drvdata(&vip->video_dev, NULL); + video_unregister_device(&vip->video_dev); free_irq(pdev->irq, vip); pci_disable_msi(pdev); vb2_queue_release(&vip->vb_vidq); @@ -1302,7 +1293,7 @@ #endif -static DEFINE_PCI_DEVICE_TABLE(sta2x11_vip_pci_tbl) = { +static const struct pci_device_id sta2x11_vip_pci_tbl[] = { {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_VIP)}, {0,} };