aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/soc_camera.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-08-25 10:46:17 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-18 23:18:43 -0400
commita0705b07f1816ae2b85388fcda71de69c221b4b8 (patch)
tree7406da18408564e38645eeaa22ea49324fd1ca6a /drivers/media/video/soc_camera.c
parent4a6110bc50da9a1883bf45614ac1d591253f0457 (diff)
V4L/DVB (12515): soc-camera: use struct v4l2_rect in struct soc_camera_device
Switch to using struct v4l2_rect in struct soc_camera_device for uniformity and simplicity. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/soc_camera.c')
-rw-r--r--drivers/media/video/soc_camera.c62
1 files changed, 36 insertions, 26 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index b3fb8f290ad5..5028023b72aa 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -288,17 +288,17 @@ static int soc_camera_set_fmt(struct soc_camera_file *icf,
288 return -EINVAL; 288 return -EINVAL;
289 } 289 }
290 290
291 icd->width = pix->width; 291 icd->rect_current.width = pix->width;
292 icd->height = pix->height; 292 icd->rect_current.height = pix->height;
293 icf->vb_vidq.field = 293 icf->vb_vidq.field =
294 icd->field = pix->field; 294 icd->field = pix->field;
295 295
296 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 296 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
297 dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n", 297 dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n",
298 f->type); 298 f->type);
299 299
300 dev_dbg(&icd->dev, "set width: %d height: %d\n", 300 dev_dbg(&icd->dev, "set width: %d height: %d\n",
301 icd->width, icd->height); 301 icd->rect_current.width, icd->rect_current.height);
302 302
303 /* set physical bus parameters */ 303 /* set physical bus parameters */
304 return ici->ops->set_bus_param(icd, pix->pixelformat); 304 return ici->ops->set_bus_param(icd, pix->pixelformat);
@@ -341,8 +341,8 @@ static int soc_camera_open(struct file *file)
341 struct v4l2_format f = { 341 struct v4l2_format f = {
342 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, 342 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
343 .fmt.pix = { 343 .fmt.pix = {
344 .width = icd->width, 344 .width = icd->rect_current.width,
345 .height = icd->height, 345 .height = icd->rect_current.height,
346 .field = icd->field, 346 .field = icd->field,
347 }, 347 },
348 }; 348 };
@@ -553,8 +553,8 @@ static int soc_camera_g_fmt_vid_cap(struct file *file, void *priv,
553 553
554 WARN_ON(priv != file->private_data); 554 WARN_ON(priv != file->private_data);
555 555
556 pix->width = icd->width; 556 pix->width = icd->rect_current.width;
557 pix->height = icd->height; 557 pix->height = icd->rect_current.height;
558 pix->field = icf->vb_vidq.field; 558 pix->field = icf->vb_vidq.field;
559 pix->pixelformat = icd->current_fmt->fourcc; 559 pix->pixelformat = icd->current_fmt->fourcc;
560 pix->bytesperline = pix->width * 560 pix->bytesperline = pix->width *
@@ -718,12 +718,9 @@ static int soc_camera_cropcap(struct file *file, void *fh,
718 struct soc_camera_device *icd = icf->icd; 718 struct soc_camera_device *icd = icf->icd;
719 719
720 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 720 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
721 a->bounds.left = icd->x_min; 721 a->bounds = icd->rect_max;
722 a->bounds.top = icd->y_min; 722 a->defrect.left = icd->rect_max.left;
723 a->bounds.width = icd->width_max; 723 a->defrect.top = icd->rect_max.top;
724 a->bounds.height = icd->height_max;
725 a->defrect.left = icd->x_min;
726 a->defrect.top = icd->y_min;
727 a->defrect.width = DEFAULT_WIDTH; 724 a->defrect.width = DEFAULT_WIDTH;
728 a->defrect.height = DEFAULT_HEIGHT; 725 a->defrect.height = DEFAULT_HEIGHT;
729 a->pixelaspect.numerator = 1; 726 a->pixelaspect.numerator = 1;
@@ -738,11 +735,8 @@ static int soc_camera_g_crop(struct file *file, void *fh,
738 struct soc_camera_file *icf = file->private_data; 735 struct soc_camera_file *icf = file->private_data;
739 struct soc_camera_device *icd = icf->icd; 736 struct soc_camera_device *icd = icf->icd;
740 737
741 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 738 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
742 a->c.left = icd->x_current; 739 a->c = icd->rect_current;
743 a->c.top = icd->y_current;
744 a->c.width = icd->width;
745 a->c.height = icd->height;
746 740
747 return 0; 741 return 0;
748} 742}
@@ -761,13 +755,29 @@ static int soc_camera_s_crop(struct file *file, void *fh,
761 /* Cropping is allowed during a running capture, guard consistency */ 755 /* Cropping is allowed during a running capture, guard consistency */
762 mutex_lock(&icf->vb_vidq.vb_lock); 756 mutex_lock(&icf->vb_vidq.vb_lock);
763 757
758 if (a->c.width > icd->rect_max.width)
759 a->c.width = icd->rect_max.width;
760
761 if (a->c.width < icd->width_min)
762 a->c.width = icd->width_min;
763
764 if (a->c.height > icd->rect_max.height)
765 a->c.height = icd->rect_max.height;
766
767 if (a->c.height < icd->height_min)
768 a->c.height = icd->height_min;
769
770 if (a->c.width + a->c.left > icd->rect_max.width + icd->rect_max.left)
771 a->c.left = icd->rect_max.width + icd->rect_max.left -
772 a->c.width;
773
774 if (a->c.height + a->c.top > icd->rect_max.height + icd->rect_max.top)
775 a->c.top = icd->rect_max.height + icd->rect_max.top -
776 a->c.height;
777
764 ret = ici->ops->set_crop(icd, &a->c); 778 ret = ici->ops->set_crop(icd, &a->c);
765 if (!ret) { 779 if (!ret)
766 icd->width = a->c.width; 780 icd->rect_current = a->c;
767 icd->height = a->c.height;
768 icd->x_current = a->c.left;
769 icd->y_current = a->c.top;
770 }
771 781
772 mutex_unlock(&icf->vb_vidq.vb_lock); 782 mutex_unlock(&icf->vb_vidq.vb_lock);
773 783