Commit 6bbd4fec authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

[media] videobuf2-dma-contig: allow to vmap contiguous dma buffers

This allows drivers to vmap contiguous dma buffers so they can inspect the
buffer contents with the CPU. This will be needed for the CODA driver's JPEG
handling. On CODA960, the header parsing has to be done on the CPU. The
hardware modules can only process the entropy coded segment after all
registers and tables are set up.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Acked-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent a85fd20f
...@@ -98,6 +98,9 @@ static void *vb2_dc_vaddr(void *buf_priv) ...@@ -98,6 +98,9 @@ static void *vb2_dc_vaddr(void *buf_priv)
{ {
struct vb2_dc_buf *buf = buf_priv; struct vb2_dc_buf *buf = buf_priv;
if (!buf->vaddr && buf->db_attach)
buf->vaddr = dma_buf_vmap(buf->db_attach->dmabuf);
return buf->vaddr; return buf->vaddr;
} }
...@@ -735,6 +738,7 @@ static int vb2_dc_map_dmabuf(void *mem_priv) ...@@ -735,6 +738,7 @@ static int vb2_dc_map_dmabuf(void *mem_priv)
buf->dma_addr = sg_dma_address(sgt->sgl); buf->dma_addr = sg_dma_address(sgt->sgl);
buf->dma_sgt = sgt; buf->dma_sgt = sgt;
buf->vaddr = NULL;
return 0; return 0;
} }
...@@ -754,6 +758,10 @@ static void vb2_dc_unmap_dmabuf(void *mem_priv) ...@@ -754,6 +758,10 @@ static void vb2_dc_unmap_dmabuf(void *mem_priv)
return; return;
} }
if (buf->vaddr) {
dma_buf_vunmap(buf->db_attach->dmabuf, buf->vaddr);
buf->vaddr = NULL;
}
dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir); dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir);
buf->dma_addr = 0; buf->dma_addr = 0;
......
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