Commit 199d101e authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Mauro Carvalho Chehab

[media] v4l: vb2-dma-contig: add prepare/finish to dma-contig allocator

Add prepare/finish callbacks to vb2-dma-contig allocator.
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Tested-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 3e0c2f20
...@@ -103,6 +103,28 @@ static unsigned int vb2_dc_num_users(void *buf_priv) ...@@ -103,6 +103,28 @@ static unsigned int vb2_dc_num_users(void *buf_priv)
return atomic_read(&buf->refcount); return atomic_read(&buf->refcount);
} }
static void vb2_dc_prepare(void *buf_priv)
{
struct vb2_dc_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;
if (!sgt)
return;
dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
}
static void vb2_dc_finish(void *buf_priv)
{
struct vb2_dc_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;
if (!sgt)
return;
dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
}
/*********************************************/ /*********************************************/
/* callbacks for MMAP buffers */ /* callbacks for MMAP buffers */
/*********************************************/ /*********************************************/
...@@ -366,6 +388,8 @@ const struct vb2_mem_ops vb2_dma_contig_memops = { ...@@ -366,6 +388,8 @@ const struct vb2_mem_ops vb2_dma_contig_memops = {
.mmap = vb2_dc_mmap, .mmap = vb2_dc_mmap,
.get_userptr = vb2_dc_get_userptr, .get_userptr = vb2_dc_get_userptr,
.put_userptr = vb2_dc_put_userptr, .put_userptr = vb2_dc_put_userptr,
.prepare = vb2_dc_prepare,
.finish = vb2_dc_finish,
.num_users = vb2_dc_num_users, .num_users = vb2_dc_num_users,
}; };
EXPORT_SYMBOL_GPL(vb2_dma_contig_memops); EXPORT_SYMBOL_GPL(vb2_dma_contig_memops);
......
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