Commit d935c57e authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] vb2: add dma_dir to the alloc memop

This is needed for the next patch where the dma-sg alloc memop needs
to know the dma_dir.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Acked-by: default avatarPawel Osciak <pawel@osciak.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent cd474037
...@@ -189,6 +189,8 @@ static void __vb2_queue_cancel(struct vb2_queue *q); ...@@ -189,6 +189,8 @@ static void __vb2_queue_cancel(struct vb2_queue *q);
static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
{ {
struct vb2_queue *q = vb->vb2_queue; struct vb2_queue *q = vb->vb2_queue;
enum dma_data_direction dma_dir =
V4L2_TYPE_IS_OUTPUT(q->type) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
void *mem_priv; void *mem_priv;
int plane; int plane;
...@@ -200,7 +202,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) ...@@ -200,7 +202,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
unsigned long size = PAGE_ALIGN(q->plane_sizes[plane]); unsigned long size = PAGE_ALIGN(q->plane_sizes[plane]);
mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane], mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane],
size, q->gfp_flags); size, dma_dir, q->gfp_flags);
if (IS_ERR_OR_NULL(mem_priv)) if (IS_ERR_OR_NULL(mem_priv))
goto free; goto free;
......
...@@ -155,7 +155,8 @@ static void vb2_dc_put(void *buf_priv) ...@@ -155,7 +155,8 @@ static void vb2_dc_put(void *buf_priv)
kfree(buf); kfree(buf);
} }
static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size,
enum dma_data_direction dma_dir, gfp_t gfp_flags)
{ {
struct vb2_dc_conf *conf = alloc_ctx; struct vb2_dc_conf *conf = alloc_ctx;
struct device *dev = conf->dev; struct device *dev = conf->dev;
...@@ -176,6 +177,7 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) ...@@ -176,6 +177,7 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags)
/* Prevent the device from being released while the buffer is used */ /* Prevent the device from being released while the buffer is used */
buf->dev = get_device(dev); buf->dev = get_device(dev);
buf->size = size; buf->size = size;
buf->dma_dir = dma_dir;
buf->handler.refcount = &buf->refcount; buf->handler.refcount = &buf->refcount;
buf->handler.put = vb2_dc_put; buf->handler.put = vb2_dc_put;
......
...@@ -86,7 +86,8 @@ static int vb2_dma_sg_alloc_compacted(struct vb2_dma_sg_buf *buf, ...@@ -86,7 +86,8 @@ static int vb2_dma_sg_alloc_compacted(struct vb2_dma_sg_buf *buf,
return 0; return 0;
} }
static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size,
enum dma_data_direction dma_dir, gfp_t gfp_flags)
{ {
struct vb2_dma_sg_buf *buf; struct vb2_dma_sg_buf *buf;
int ret; int ret;
...@@ -97,7 +98,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_fla ...@@ -97,7 +98,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_fla
return NULL; return NULL;
buf->vaddr = NULL; buf->vaddr = NULL;
buf->dma_dir = DMA_NONE; buf->dma_dir = dma_dir;
buf->offset = 0; buf->offset = 0;
buf->size = size; buf->size = size;
/* size is already page aligned */ /* size is already page aligned */
......
...@@ -35,7 +35,8 @@ struct vb2_vmalloc_buf { ...@@ -35,7 +35,8 @@ struct vb2_vmalloc_buf {
static void vb2_vmalloc_put(void *buf_priv); static void vb2_vmalloc_put(void *buf_priv);
static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long size,
enum dma_data_direction dma_dir, gfp_t gfp_flags)
{ {
struct vb2_vmalloc_buf *buf; struct vb2_vmalloc_buf *buf;
...@@ -45,6 +46,7 @@ static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_fl ...@@ -45,6 +46,7 @@ static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_fl
buf->size = size; buf->size = size;
buf->vaddr = vmalloc_user(buf->size); buf->vaddr = vmalloc_user(buf->size);
buf->dma_dir = dma_dir;
buf->handler.refcount = &buf->refcount; buf->handler.refcount = &buf->refcount;
buf->handler.put = vb2_vmalloc_put; buf->handler.put = vb2_vmalloc_put;
buf->handler.arg = buf; buf->handler.arg = buf;
......
...@@ -82,7 +82,9 @@ struct vb2_threadio_data; ...@@ -82,7 +82,9 @@ struct vb2_threadio_data;
* unmap_dmabuf. * unmap_dmabuf.
*/ */
struct vb2_mem_ops { struct vb2_mem_ops {
void *(*alloc)(void *alloc_ctx, unsigned long size, gfp_t gfp_flags); void *(*alloc)(void *alloc_ctx, unsigned long size,
enum dma_data_direction dma_dir,
gfp_t gfp_flags);
void (*put)(void *buf_priv); void (*put)(void *buf_priv);
struct dma_buf *(*get_dmabuf)(void *buf_priv, unsigned long flags); struct dma_buf *(*get_dmabuf)(void *buf_priv, unsigned long flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment