aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/marvell-ccic
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/platform/marvell-ccic
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/platform/marvell-ccic')
-rw-r--r--drivers/media/platform/marvell-ccic/mcam-core.c18
1 files changed, 1 insertions, 17 deletions
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index c3ff5388aeb3..ce00cbaf850e 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1220,17 +1220,12 @@ static int mcam_vb_sg_buf_init(struct vb2_buffer *vb)
1220static int mcam_vb_sg_buf_prepare(struct vb2_buffer *vb) 1220static int mcam_vb_sg_buf_prepare(struct vb2_buffer *vb)
1221{ 1221{
1222 struct mcam_vb_buffer *mvb = vb_to_mvb(vb); 1222 struct mcam_vb_buffer *mvb = vb_to_mvb(vb);
1223 struct mcam_camera *cam = vb2_get_drv_priv(vb->vb2_queue);
1224 struct sg_table *sg_table = vb2_dma_sg_plane_desc(vb, 0); 1223 struct sg_table *sg_table = vb2_dma_sg_plane_desc(vb, 0);
1225 struct mcam_dma_desc *desc = mvb->dma_desc; 1224 struct mcam_dma_desc *desc = mvb->dma_desc;
1226 struct scatterlist *sg; 1225 struct scatterlist *sg;
1227 int i; 1226 int i;
1228 1227
1229 mvb->dma_desc_nent = dma_map_sg(cam->dev, sg_table->sgl, 1228 for_each_sg(sg_table->sgl, sg, sg_table->nents, i) {
1230 sg_table->nents, DMA_FROM_DEVICE);
1231 if (mvb->dma_desc_nent <= 0)
1232 return -EIO; /* Not sure what's right here */
1233 for_each_sg(sg_table->sgl, sg, mvb->dma_desc_nent, i) {
1234 desc->dma_addr = sg_dma_address(sg); 1229 desc->dma_addr = sg_dma_address(sg);
1235 desc->segment_len = sg_dma_len(sg); 1230 desc->segment_len = sg_dma_len(sg);
1236 desc++; 1231 desc++;
@@ -1238,16 +1233,6 @@ static int mcam_vb_sg_buf_prepare(struct vb2_buffer *vb)
1238 return 0; 1233 return 0;
1239} 1234}
1240 1235
1241static void mcam_vb_sg_buf_finish(struct vb2_buffer *vb)
1242{
1243 struct mcam_camera *cam = vb2_get_drv_priv(vb->vb2_queue);
1244 struct sg_table *sg_table = vb2_dma_sg_plane_desc(vb, 0);
1245
1246 if (sg_table)
1247 dma_unmap_sg(cam->dev, sg_table->sgl,
1248 sg_table->nents, DMA_FROM_DEVICE);
1249}
1250
1251static void mcam_vb_sg_buf_cleanup(struct vb2_buffer *vb) 1236static void mcam_vb_sg_buf_cleanup(struct vb2_buffer *vb)
1252{ 1237{
1253 struct mcam_camera *cam = vb2_get_drv_priv(vb->vb2_queue); 1238 struct mcam_camera *cam = vb2_get_drv_priv(vb->vb2_queue);
@@ -1264,7 +1249,6 @@ static const struct vb2_ops mcam_vb2_sg_ops = {
1264 .buf_init = mcam_vb_sg_buf_init, 1249 .buf_init = mcam_vb_sg_buf_init,
1265 .buf_prepare = mcam_vb_sg_buf_prepare, 1250 .buf_prepare = mcam_vb_sg_buf_prepare,
1266 .buf_queue = mcam_vb_buf_queue, 1251 .buf_queue = mcam_vb_buf_queue,
1267 .buf_finish = mcam_vb_sg_buf_finish,
1268 .buf_cleanup = mcam_vb_sg_buf_cleanup, 1252 .buf_cleanup = mcam_vb_sg_buf_cleanup,
1269 .start_streaming = mcam_vb_start_streaming, 1253 .start_streaming = mcam_vb_start_streaming,
1270 .stop_streaming = mcam_vb_stop_streaming, 1254 .stop_streaming = mcam_vb_stop_streaming,