linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [media] videobuf2-dma-contig: allow to vmap contiguous dma buffers
@ 2014-05-26 14:17 Philipp Zabel
  2014-05-29 13:14 ` Marek Szyprowski
  0 siblings, 1 reply; 2+ messages in thread
From: Philipp Zabel @ 2014-05-26 14:17 UTC (permalink / raw)
  To: Pawel Osciak
  Cc: Marek Szyprowski, Kyungmin Park, Mauro Carvalho Chehab,
	linux-media, Philipp Zabel

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>
---
 drivers/media/v4l2-core/videobuf2-dma-contig.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 880be07..6b254b8 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -98,6 +98,9 @@ static void *vb2_dc_vaddr(void *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;
 }
 
@@ -735,6 +738,7 @@ static int vb2_dc_map_dmabuf(void *mem_priv)
 
 	buf->dma_addr = sg_dma_address(sgt->sgl);
 	buf->dma_sgt = sgt;
+	buf->vaddr = NULL;
 
 	return 0;
 }
@@ -754,6 +758,10 @@ static void vb2_dc_unmap_dmabuf(void *mem_priv)
 		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);
 
 	buf->dma_addr = 0;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [media] videobuf2-dma-contig: allow to vmap contiguous dma buffers
  2014-05-26 14:17 [PATCH] [media] videobuf2-dma-contig: allow to vmap contiguous dma buffers Philipp Zabel
@ 2014-05-29 13:14 ` Marek Szyprowski
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Szyprowski @ 2014-05-29 13:14 UTC (permalink / raw)
  To: Philipp Zabel, Pawel Osciak
  Cc: Kyungmin Park, Mauro Carvalho Chehab, linux-media

Hello,

On 2014-05-26 16:17, Philipp Zabel wrote:
> 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>

> ---
>   drivers/media/v4l2-core/videobuf2-dma-contig.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
> index 880be07..6b254b8 100644
> --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
> +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
> @@ -98,6 +98,9 @@ static void *vb2_dc_vaddr(void *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;
>   }
>   
> @@ -735,6 +738,7 @@ static int vb2_dc_map_dmabuf(void *mem_priv)
>   
>   	buf->dma_addr = sg_dma_address(sgt->sgl);
>   	buf->dma_sgt = sgt;
> +	buf->vaddr = NULL;
>   
>   	return 0;
>   }
> @@ -754,6 +758,10 @@ static void vb2_dc_unmap_dmabuf(void *mem_priv)
>   		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);
>   
>   	buf->dma_addr = 0;

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-29 13:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-26 14:17 [PATCH] [media] videobuf2-dma-contig: allow to vmap contiguous dma buffers Philipp Zabel
2014-05-29 13:14 ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).