aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-12-16 08:30:43 -0200
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-08 14:34:16 -0300
commit20be7ab8dba68072b34ae2285c282290b2344339 (patch)
tree3f48444cfc4f0acf9c6e6fe102cbf0bbb628d556
parent[media] vb2: move dma_attrs to vb2_queue (diff)
downloadlinux-dev-20be7ab8dba68072b34ae2285c282290b2344339.tar.xz
linux-dev-20be7ab8dba68072b34ae2285c282290b2344339.zip
[media] vb2: add a dev field to use for the default allocation context
The allocation context is nothing more than a per-plane device pointer to use when allocating buffers. So just provide a dev pointer in vb2_queue for that purpose and drivers can skip allocating/releasing/filling in the allocation context unless they require different per-plane device pointers as used by some Samsung SoCs. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Sakari Ailus <sakari.ailus@iki.fi> Cc: Florian Echtler <floe@butterbrot.org> Cc: Federico Vaga <federico.vaga@gmail.com> Cc: "Lad, Prabhakar" <prabhakar.csengg@gmail.com> Cc: Scott Jiang <scott.jiang.linux@gmail.com> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Cc: Fabien Dessenne <fabien.dessenne@st.com> Acked-by: Benoit Parrot <bparrot@ti.com> Cc: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Ludovic Desroches <ludovic.desroches@atmel.com> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c14
-rw-r--r--include/media/videobuf2-core.h3
2 files changed, 11 insertions, 6 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 36f4392df571..aabb03e406f0 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -206,7 +206,8 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
for (plane = 0; plane < vb->num_planes; ++plane) {
unsigned long size = PAGE_ALIGN(vb->planes[plane].length);
- mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane],
+ mem_priv = call_ptr_memop(vb, alloc,
+ q->alloc_ctx[plane] ? : &q->dev,
q->dma_attrs, size, dma_dir, q->gfp_flags);
if (IS_ERR_OR_NULL(mem_priv))
goto free;
@@ -1131,9 +1132,10 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const void *pb)
vb->planes[plane].data_offset = 0;
/* Acquire each plane's memory */
- mem_priv = call_ptr_memop(vb, get_userptr, q->alloc_ctx[plane],
- planes[plane].m.userptr,
- planes[plane].length, dma_dir);
+ mem_priv = call_ptr_memop(vb, get_userptr,
+ q->alloc_ctx[plane] ? : &q->dev,
+ planes[plane].m.userptr,
+ planes[plane].length, dma_dir);
if (IS_ERR_OR_NULL(mem_priv)) {
dprintk(1, "failed acquiring userspace "
"memory for plane %d\n", plane);
@@ -1256,8 +1258,8 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const void *pb)
/* Acquire each plane's memory */
mem_priv = call_ptr_memop(vb, attach_dmabuf,
- q->alloc_ctx[plane], dbuf, planes[plane].length,
- dma_dir);
+ q->alloc_ctx[plane] ? : &q->dev,
+ dbuf, planes[plane].length, dma_dir);
if (IS_ERR(mem_priv)) {
dprintk(1, "failed to attach dmabuf\n");
ret = PTR_ERR(mem_priv);
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 444ef3b9d39f..d38668c2ea06 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -400,6 +400,8 @@ struct vb2_buf_ops {
* caller. For example, for V4L2, it should match
* the V4L2_BUF_TYPE_* in include/uapi/linux/videodev2.h
* @io_modes: supported io methods (see vb2_io_modes enum)
+ * @dev: device to use for the default allocation context if the driver
+ * doesn't fill in the @alloc_ctx array.
* @dma_attrs: DMA attributes to use for the DMA. May be NULL.
* @fileio_read_once: report EOF after reading the first buffer
* @fileio_write_immediately: queue buffer after each write() call
@@ -467,6 +469,7 @@ struct vb2_buf_ops {
struct vb2_queue {
unsigned int type;
unsigned int io_modes;
+ struct device *dev;
const struct dma_attrs *dma_attrs;
unsigned fileio_read_once:1;
unsigned fileio_write_immediately:1;