From b6ba2057f7823352bbc44ee846faa03b36e8b6ac Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 1 Mar 2013 15:44:20 -0300 Subject: [media] videobuf2: add gfp_flags Some drivers have special memory requirements for their buffers, usually related to DMA (e.g. GFP_DMA or __GFP_DMA32). Make it possible to specify additional GFP flags for those buffers by adding a gfp_flags field to vb2_queue. Note that this field will be replaced in the future with a different mechanism, but that is still work in progress and we need this feature now so we won't be able to convert drivers with such requirements to vb2. Signed-off-by: Hans Verkuil Acked-by: Marek Szyprowski Acked-by: Federico Vaga Signed-off-by: Mauro Carvalho Chehab --- include/media/videobuf2-core.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include/media/videobuf2-core.h') diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index a2d427450780..d88a098d1aff 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -27,7 +27,9 @@ struct vb2_fileio_data; * return NULL on failure or a pointer to allocator private, * per-buffer data on success; the returned private structure * will then be passed as buf_priv argument to other ops in this - * structure + * structure. Additional gfp_flags to use when allocating the + * are also passed to this operation. These flags are from the + * gfp_flags field of vb2_queue. * @put: inform the allocator that the buffer will no longer be used; * usually will result in the allocator freeing the buffer (if * no other users of this buffer are present); the buf_priv @@ -79,7 +81,7 @@ struct vb2_fileio_data; * unmap_dmabuf. */ struct vb2_mem_ops { - void *(*alloc)(void *alloc_ctx, unsigned long size); + void *(*alloc)(void *alloc_ctx, unsigned long size, gfp_t gfp_flags); void (*put)(void *buf_priv); struct dma_buf *(*get_dmabuf)(void *buf_priv); @@ -302,6 +304,9 @@ struct v4l2_fh; * @buf_struct_size: size of the driver-specific buffer structure; * "0" indicates the driver doesn't want to use a custom buffer * structure type, so sizeof(struct vb2_buffer) will is used + * @gfp_flags: additional gfp flags used when allocating the buffers. + * Typically this is 0, but it may be e.g. GFP_DMA or __GFP_DMA32 + * to force the buffer allocation to a specific memory zone. * * @memory: current memory type used * @bufs: videobuf buffer structures @@ -327,6 +332,7 @@ struct vb2_queue { void *drv_priv; unsigned int buf_struct_size; u32 timestamp_type; + gfp_t gfp_flags; /* private: internal use only */ enum v4l2_memory memory; -- cgit v1.2.3-59-g8ed1b