diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2009-08-25 10:46:52 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:18:58 -0400 |
commit | 68a54f0e53b62806040fb7884b2e0d79b922bf00 (patch) | |
tree | 268b4431e352fdfb928c744d450572f52f48dfd5 /drivers/media | |
parent | 123ab622c075e2252b46565c81dbf5c0748a82af (diff) |
V4L/DVB (12524): soc-camera: S_CROP V4L2 API compliance fix
V4L2 API mandates, that drivers do not update the argument of the S_CROP
ioctl() with the actual geometry. Comply.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/soc_camera.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 44a94dc934f..a22fcd0ff8b 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -747,12 +747,19 @@ static int soc_camera_g_crop(struct file *file, void *fh, | |||
747 | return 0; | 747 | return 0; |
748 | } | 748 | } |
749 | 749 | ||
750 | /* | ||
751 | * According to the V4L2 API, drivers shall not update the struct v4l2_crop | ||
752 | * argument with the actual geometry, instead, the user shall use G_CROP to | ||
753 | * retrieve it. However, we expect camera host and client drivers to update | ||
754 | * the argument, which we then use internally, but do not return to the user. | ||
755 | */ | ||
750 | static int soc_camera_s_crop(struct file *file, void *fh, | 756 | static int soc_camera_s_crop(struct file *file, void *fh, |
751 | struct v4l2_crop *a) | 757 | struct v4l2_crop *a) |
752 | { | 758 | { |
753 | struct soc_camera_file *icf = file->private_data; | 759 | struct soc_camera_file *icf = file->private_data; |
754 | struct soc_camera_device *icd = icf->icd; | 760 | struct soc_camera_device *icd = icf->icd; |
755 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | 761 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); |
762 | struct v4l2_rect rect = a->c; | ||
756 | int ret; | 763 | int ret; |
757 | 764 | ||
758 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 765 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
@@ -761,29 +768,29 @@ static int soc_camera_s_crop(struct file *file, void *fh, | |||
761 | /* Cropping is allowed during a running capture, guard consistency */ | 768 | /* Cropping is allowed during a running capture, guard consistency */ |
762 | mutex_lock(&icf->vb_vidq.vb_lock); | 769 | mutex_lock(&icf->vb_vidq.vb_lock); |
763 | 770 | ||
764 | if (a->c.width > icd->rect_max.width) | 771 | if (rect.width > icd->rect_max.width) |
765 | a->c.width = icd->rect_max.width; | 772 | rect.width = icd->rect_max.width; |
766 | 773 | ||
767 | if (a->c.width < icd->width_min) | 774 | if (rect.width < icd->width_min) |
768 | a->c.width = icd->width_min; | 775 | rect.width = icd->width_min; |
769 | 776 | ||
770 | if (a->c.height > icd->rect_max.height) | 777 | if (rect.height > icd->rect_max.height) |
771 | a->c.height = icd->rect_max.height; | 778 | rect.height = icd->rect_max.height; |
772 | 779 | ||
773 | if (a->c.height < icd->height_min) | 780 | if (rect.height < icd->height_min) |
774 | a->c.height = icd->height_min; | 781 | rect.height = icd->height_min; |
775 | 782 | ||
776 | if (a->c.width + a->c.left > icd->rect_max.width + icd->rect_max.left) | 783 | if (rect.width + rect.left > icd->rect_max.width + icd->rect_max.left) |
777 | a->c.left = icd->rect_max.width + icd->rect_max.left - | 784 | rect.left = icd->rect_max.width + icd->rect_max.left - |
778 | a->c.width; | 785 | rect.width; |
779 | 786 | ||
780 | if (a->c.height + a->c.top > icd->rect_max.height + icd->rect_max.top) | 787 | if (rect.height + rect.top > icd->rect_max.height + icd->rect_max.top) |
781 | a->c.top = icd->rect_max.height + icd->rect_max.top - | 788 | rect.top = icd->rect_max.height + icd->rect_max.top - |
782 | a->c.height; | 789 | rect.height; |
783 | 790 | ||
784 | ret = ici->ops->set_crop(icd, &a->c); | 791 | ret = ici->ops->set_crop(icd, &rect); |
785 | if (!ret) | 792 | if (!ret) |
786 | icd->rect_current = a->c; | 793 | icd->rect_current = rect; |
787 | 794 | ||
788 | mutex_unlock(&icf->vb_vidq.vb_lock); | 795 | mutex_unlock(&icf->vb_vidq.vb_lock); |
789 | 796 | ||