Skip to content

Instantly share code, notes, and snippets.

@tonylambiris
Created October 11, 2016 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonylambiris/2e4485e09eac8585485d597406531877 to your computer and use it in GitHub Desktop.
Save tonylambiris/2e4485e09eac8585485d597406531877 to your computer and use it in GitHub Desktop.
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment