aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tw9910.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/tw9910.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/tw9910.c')
-rw-r--r--drivers/media/video/tw9910.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/drivers/media/video/tw9910.c b/drivers/media/video/tw9910.c
index a006df1d28ec..7199e0f71b2a 100644
--- a/drivers/media/video/tw9910.c
+++ b/drivers/media/video/tw9910.c
@@ -715,8 +715,8 @@ static int tw9910_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
715 struct soc_camera_device *icd = client->dev.platform_data; 715 struct soc_camera_device *icd = client->dev.platform_data;
716 struct v4l2_pix_format *pix = &f->fmt.pix; 716 struct v4l2_pix_format *pix = &f->fmt.pix;
717 struct v4l2_rect rect = { 717 struct v4l2_rect rect = {
718 .left = icd->x_current, 718 .left = icd->rect_current.left,
719 .top = icd->y_current, 719 .top = icd->rect_current.top,
720 .width = pix->width, 720 .width = pix->width,
721 .height = pix->height, 721 .height = pix->height,
722 }; 722 };
@@ -840,6 +840,19 @@ static struct v4l2_subdev_ops tw9910_subdev_ops = {
840 * i2c_driver function 840 * i2c_driver function
841 */ 841 */
842 842
843static void limit_to_scale(struct soc_camera_device *icd,
844 const struct tw9910_scale_ctrl *scale)
845{
846 if (scale->width > icd->rect_max.width)
847 icd->rect_max.width = scale->width;
848 if (scale->width < icd->width_min)
849 icd->width_min = scale->width;
850 if (scale->height > icd->rect_max.height)
851 icd->rect_max.height = scale->height;
852 if (scale->height < icd->height_min)
853 icd->height_min = scale->height;
854}
855
843static int tw9910_probe(struct i2c_client *client, 856static int tw9910_probe(struct i2c_client *client,
844 const struct i2c_device_id *did) 857 const struct i2c_device_id *did)
845 858
@@ -885,25 +898,18 @@ static int tw9910_probe(struct i2c_client *client,
885 /* 898 /*
886 * set width and height 899 * set width and height
887 */ 900 */
888 icd->width_max = tw9910_ntsc_scales[0].width; /* set default */ 901 icd->rect_max.width = tw9910_ntsc_scales[0].width; /* set default */
889 icd->width_min = tw9910_ntsc_scales[0].width; 902 icd->width_min = tw9910_ntsc_scales[0].width;
890 icd->height_max = tw9910_ntsc_scales[0].height; 903 icd->rect_max.height = tw9910_ntsc_scales[0].height;
891 icd->height_min = tw9910_ntsc_scales[0].height; 904 icd->height_min = tw9910_ntsc_scales[0].height;
892 905
893 scale = tw9910_ntsc_scales; 906 scale = tw9910_ntsc_scales;
894 for (i = 0; i < ARRAY_SIZE(tw9910_ntsc_scales); i++) { 907 for (i = 0; i < ARRAY_SIZE(tw9910_ntsc_scales); i++)
895 icd->width_max = max(scale[i].width, icd->width_max); 908 limit_to_scale(icd, scale + i);
896 icd->width_min = min(scale[i].width, icd->width_min); 909
897 icd->height_max = max(scale[i].height, icd->height_max);
898 icd->height_min = min(scale[i].height, icd->height_min);
899 }
900 scale = tw9910_pal_scales; 910 scale = tw9910_pal_scales;
901 for (i = 0; i < ARRAY_SIZE(tw9910_pal_scales); i++) { 911 for (i = 0; i < ARRAY_SIZE(tw9910_pal_scales); i++)
902 icd->width_max = max(scale[i].width, icd->width_max); 912 limit_to_scale(icd, scale + i);
903 icd->width_min = min(scale[i].width, icd->width_min);
904 icd->height_max = max(scale[i].height, icd->height_max);
905 icd->height_min = min(scale[i].height, icd->height_min);
906 }
907 913
908 ret = tw9910_video_probe(icd, client); 914 ret = tw9910_video_probe(icd, client);
909 if (ret) { 915 if (ret) {