Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Philipp Zabel and committed by
Mauro Carvalho Chehab
6bbd4fec a85fd20f

+8
+8
drivers/media/v4l2-core/videobuf2-dma-contig.c
··· 98 98 { 99 99 struct vb2_dc_buf *buf = buf_priv; 100 100 101 + if (!buf->vaddr && buf->db_attach) 102 + buf->vaddr = dma_buf_vmap(buf->db_attach->dmabuf); 103 + 101 104 return buf->vaddr; 102 105 } 103 106 ··· 738 735 739 736 buf->dma_addr = sg_dma_address(sgt->sgl); 740 737 buf->dma_sgt = sgt; 738 + buf->vaddr = NULL; 741 739 742 740 return 0; 743 741 } ··· 758 754 return; 759 755 } 760 756 757 + if (buf->vaddr) { 758 + dma_buf_vunmap(buf->db_attach->dmabuf, buf->vaddr); 759 + buf->vaddr = NULL; 760 + } 761 761 dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir); 762 762 763 763 buf->dma_addr = 0;