From 40e8e711ad3bc31dad3102ee8f20bbc0bdb4a201 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 10 Oct 2016 21:21:44 +0300 Subject: [PATCH] vb2: replace void *alloc_ctxs by struct device *alloc_devs Upstream: torvalds/linux@36c0f8b32c4bd4f668cedfba6d97afaa84f055fb ("[media] vb2: replace void *alloc_ctxs by struct device *alloc_devs") --- fthd_drv.h | 2 ++ fthd_v4l2.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/fthd_drv.h b/fthd_drv.h index 06b9ef9..21c5f74 100644 --- a/fthd_drv.h +++ b/fthd_drv.h @@ -118,7 +118,9 @@ struct fthd_private { struct vb2_queue vb2_queue; struct mutex vb2_queue_lock; struct list_head buffer_queue; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0) struct vb2_alloc_ctx *alloc_ctx; +#endif struct h2t_buf_ctx h2t_bufs[FTHD_BUFFERS]; struct v4l2_ctrl_handler v4l2_ctrl_handler; diff --git a/fthd_v4l2.c b/fthd_v4l2.c index e3793e2..9bb5bdf 100644 --- a/fthd_v4l2.c +++ b/fthd_v4l2.c @@ -52,7 +52,11 @@ static int fthd_buffer_queue_setup( unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0) + struct device *alloc_devs[] +#else void *alloc_ctxs[] +#endif ) { struct fthd_private *dev_priv = vb2_get_drv_priv(vq); @@ -70,7 +74,11 @@ static int fthd_buffer_queue_setup( /* FIXME: We assume single plane format here but not below */ for (i = 0; i < *nplanes; i++) { sizes[i] = cur_fmt->sizeimage; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0) + alloc_devs[i] = &dev_priv->pdev->dev; +#else alloc_ctxs[i] = dev_priv->alloc_ctx; +#endif total_size += sizes[i]; } @@ -711,7 +719,9 @@ int fthd_v4l2_register(struct fthd_private *dev_priv) v4l2_ctrl_handler_free(&dev_priv->v4l2_ctrl_handler); goto fail; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0) dev_priv->alloc_ctx = vb2_dma_sg_init_ctx(&dev_priv->pdev->dev); +#endif vdev->v4l2_dev = v4l2_dev; strcpy(vdev->name, "Apple Facetime HD"); // XXX: Length? vdev->vfl_dir = VFL_DIR_RX; @@ -746,7 +756,9 @@ void fthd_v4l2_unregister(struct fthd_private *dev_priv) { v4l2_ctrl_handler_free(&dev_priv->v4l2_ctrl_handler); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0) vb2_dma_sg_cleanup_ctx(dev_priv->alloc_ctx); +#endif video_unregister_device(dev_priv->videodev); v4l2_device_unregister(&dev_priv->v4l2_dev); }