aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/tw68
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-11-24 06:50:31 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-11-25 06:01:16 -0500
commitd790b7eda953df474f470169ebdf111c02fa7a2d (patch)
tree31ad9dce666141bf0d83989717188fe8700ac310 /drivers/media/pci/tw68
parent0c3a14c177aa85afb991e7c2be3921aa9a52a893 (diff)
[media] vb2-dma-sg: move dma_(un)map_sg here
This moves dma_(un)map_sg to the get_userptr/put_userptr and alloc/put memops of videobuf2-dma-sg.c and adds dma_sync_sg_for_device/cpu to the prepare/finish memops. Now that vb2-dma-sg will sync the buffers for you in the prepare/finish memops we can drop that from the drivers that use dma-sg. For the solo6x10 driver that was a bit more involved because it needs to copy JPEG or MPEG headers to the buffer before returning it to userspace, and that cannot be done in the old place since the buffer there is still setup for DMA access, not for CPU access. However, the buf_finish op is the ideal place to do this. By the time buf_finish is called the buffer is available for CPU access, so copying to the buffer is fine. [mchehab@osg.samsung.com: Fix a compilation breakage: drivers/media/v4l2-core/videobuf2-dma-sg.c:150:19: error: 'struct vb2_dma_sg_buf' has no member named 'dma_sgt'] Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Pawel Osciak <pawel@osciak.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/pci/tw68')
-rw-r--r--drivers/media/pci/tw68/tw68-video.c8
1 files changed, 0 insertions, 8 deletions
diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index 50dcce6251f6..8355e55b4e8e 100644
--- a/drivers/media/pci/tw68/tw68-video.c
+++ b/drivers/media/pci/tw68/tw68-video.c
@@ -462,17 +462,12 @@ static int tw68_buf_prepare(struct vb2_buffer *vb)
462 struct tw68_buf *buf = container_of(vb, struct tw68_buf, vb); 462 struct tw68_buf *buf = container_of(vb, struct tw68_buf, vb);
463 struct sg_table *dma = vb2_dma_sg_plane_desc(vb, 0); 463 struct sg_table *dma = vb2_dma_sg_plane_desc(vb, 0);
464 unsigned size, bpl; 464 unsigned size, bpl;
465 int rc;
466 465
467 size = (dev->width * dev->height * dev->fmt->depth) >> 3; 466 size = (dev->width * dev->height * dev->fmt->depth) >> 3;
468 if (vb2_plane_size(vb, 0) < size) 467 if (vb2_plane_size(vb, 0) < size)
469 return -EINVAL; 468 return -EINVAL;
470 vb2_set_plane_payload(vb, 0, size); 469 vb2_set_plane_payload(vb, 0, size);
471 470
472 rc = dma_map_sg(&dev->pci->dev, dma->sgl, dma->nents, DMA_FROM_DEVICE);
473 if (!rc)
474 return -EIO;
475
476 bpl = (dev->width * dev->fmt->depth) >> 3; 471 bpl = (dev->width * dev->fmt->depth) >> 3;
477 switch (dev->field) { 472 switch (dev->field) {
478 case V4L2_FIELD_TOP: 473 case V4L2_FIELD_TOP:
@@ -506,11 +501,8 @@ static void tw68_buf_finish(struct vb2_buffer *vb)
506{ 501{
507 struct vb2_queue *vq = vb->vb2_queue; 502 struct vb2_queue *vq = vb->vb2_queue;
508 struct tw68_dev *dev = vb2_get_drv_priv(vq); 503 struct tw68_dev *dev = vb2_get_drv_priv(vq);
509 struct sg_table *dma = vb2_dma_sg_plane_desc(vb, 0);
510 struct tw68_buf *buf = container_of(vb, struct tw68_buf, vb); 504 struct tw68_buf *buf = container_of(vb, struct tw68_buf, vb);
511 505
512 dma_unmap_sg(&dev->pci->dev, dma->sgl, dma->nents, DMA_FROM_DEVICE);
513
514 pci_free_consistent(dev->pci, buf->size, buf->cpu, buf->dma); 506 pci_free_consistent(dev->pci, buf->size, buf->cpu, buf->dma);
515} 507}
516 508