diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-03-21 07:03:21 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-15 15:08:22 -0400 |
commit | 2b61d46e2c44568886bc099f8085aefc7107e372 (patch) | |
tree | e948595df69c6e9ad5c22a3bc00e93fb0a8ef93d /drivers/media/video/mx2_camera.c | |
parent | 584943aa0692fea9ec3356c7d4677dd7a225cdef (diff) |
[media] soc_camera: Use soc_camera_device::sizeimage to compute buffer sizes
Instead of computing the buffer size manually in the videobuf queue
setup and buffer prepare callbacks, use the previously negotiated
soc_camera_device::sizeimage value.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mx2_camera.c')
-rw-r--r-- | drivers/media/video/mx2_camera.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 36d17f3483eb..368049dbe105 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c | |||
@@ -538,8 +538,6 @@ static int mx2_videobuf_setup(struct vb2_queue *vq, | |||
538 | struct soc_camera_device *icd = soc_camera_from_vb2q(vq); | 538 | struct soc_camera_device *icd = soc_camera_from_vb2q(vq); |
539 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 539 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
540 | struct mx2_camera_dev *pcdev = ici->priv; | 540 | struct mx2_camera_dev *pcdev = ici->priv; |
541 | int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width, | ||
542 | icd->current_fmt->host_fmt); | ||
543 | 541 | ||
544 | dev_dbg(icd->parent, "count=%d, size=%d\n", *count, sizes[0]); | 542 | dev_dbg(icd->parent, "count=%d, size=%d\n", *count, sizes[0]); |
545 | 543 | ||
@@ -547,12 +545,9 @@ static int mx2_videobuf_setup(struct vb2_queue *vq, | |||
547 | if (fmt != NULL) | 545 | if (fmt != NULL) |
548 | return -ENOTTY; | 546 | return -ENOTTY; |
549 | 547 | ||
550 | if (bytes_per_line < 0) | ||
551 | return bytes_per_line; | ||
552 | |||
553 | alloc_ctxs[0] = pcdev->alloc_ctx; | 548 | alloc_ctxs[0] = pcdev->alloc_ctx; |
554 | 549 | ||
555 | sizes[0] = bytes_per_line * icd->user_height; | 550 | sizes[0] = icd->sizeimage; |
556 | 551 | ||
557 | if (0 == *count) | 552 | if (0 == *count) |
558 | *count = 32; | 553 | *count = 32; |
@@ -568,16 +563,11 @@ static int mx2_videobuf_setup(struct vb2_queue *vq, | |||
568 | static int mx2_videobuf_prepare(struct vb2_buffer *vb) | 563 | static int mx2_videobuf_prepare(struct vb2_buffer *vb) |
569 | { | 564 | { |
570 | struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue); | 565 | struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue); |
571 | int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width, | ||
572 | icd->current_fmt->host_fmt); | ||
573 | int ret = 0; | 566 | int ret = 0; |
574 | 567 | ||
575 | dev_dbg(icd->parent, "%s (vb=0x%p) 0x%p %lu\n", __func__, | 568 | dev_dbg(icd->parent, "%s (vb=0x%p) 0x%p %lu\n", __func__, |
576 | vb, vb2_plane_vaddr(vb, 0), vb2_get_plane_payload(vb, 0)); | 569 | vb, vb2_plane_vaddr(vb, 0), vb2_get_plane_payload(vb, 0)); |
577 | 570 | ||
578 | if (bytes_per_line < 0) | ||
579 | return bytes_per_line; | ||
580 | |||
581 | #ifdef DEBUG | 571 | #ifdef DEBUG |
582 | /* | 572 | /* |
583 | * This can be useful if you want to see if we actually fill | 573 | * This can be useful if you want to see if we actually fill |
@@ -587,7 +577,7 @@ static int mx2_videobuf_prepare(struct vb2_buffer *vb) | |||
587 | 0xaa, vb2_get_plane_payload(vb, 0)); | 577 | 0xaa, vb2_get_plane_payload(vb, 0)); |
588 | #endif | 578 | #endif |
589 | 579 | ||
590 | vb2_set_plane_payload(vb, 0, bytes_per_line * icd->user_height); | 580 | vb2_set_plane_payload(vb, 0, icd->sizeimage); |
591 | if (vb2_plane_vaddr(vb, 0) && | 581 | if (vb2_plane_vaddr(vb, 0) && |
592 | vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) { | 582 | vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) { |
593 | ret = -EINVAL; | 583 | ret = -EINVAL; |