aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorRicardo Ribalda <ricardo.ribalda@gmail.com>2013-11-26 03:31:42 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-07 05:02:39 -0500
commitf90580ca0133c533763a6cb3e632a21098a382df (patch)
tree05e66bbea641292153c2a78d781d49d866a16379 /drivers/media/i2c
parentda4a733946aa360e2219ce2d33b8d25ce4aa1959 (diff)
[media] videodev2: Set vb2_rect's width and height as unsigned
As discussed on the media summit 2013, there is no reason for the width and height to be signed. Therefore this patch is an attempt to convert those fields from __s32 to __u32. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> (documentation and smiapp) Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r--drivers/media/i2c/mt9m032.c16
-rw-r--r--drivers/media/i2c/mt9p031.c28
-rw-r--r--drivers/media/i2c/mt9t001.c26
-rw-r--r--drivers/media/i2c/mt9v032.c38
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c8
-rw-r--r--drivers/media/i2c/soc_camera/mt9m111.c4
-rw-r--r--drivers/media/i2c/tvp5150.c14
7 files changed, 74 insertions, 60 deletions
diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
index 846b15f0bf64..85ec3bacdf1c 100644
--- a/drivers/media/i2c/mt9m032.c
+++ b/drivers/media/i2c/mt9m032.c
@@ -459,13 +459,15 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev *subdev,
459 MT9M032_COLUMN_START_MAX); 459 MT9M032_COLUMN_START_MAX);
460 rect.top = clamp(ALIGN(crop->rect.top, 2), MT9M032_ROW_START_MIN, 460 rect.top = clamp(ALIGN(crop->rect.top, 2), MT9M032_ROW_START_MIN,
461 MT9M032_ROW_START_MAX); 461 MT9M032_ROW_START_MAX);
462 rect.width = clamp(ALIGN(crop->rect.width, 2), MT9M032_COLUMN_SIZE_MIN, 462 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2),
463 MT9M032_COLUMN_SIZE_MAX); 463 MT9M032_COLUMN_SIZE_MIN, MT9M032_COLUMN_SIZE_MAX);
464 rect.height = clamp(ALIGN(crop->rect.height, 2), MT9M032_ROW_SIZE_MIN, 464 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2),
465 MT9M032_ROW_SIZE_MAX); 465 MT9M032_ROW_SIZE_MIN, MT9M032_ROW_SIZE_MAX);
466 466
467 rect.width = min(rect.width, MT9M032_PIXEL_ARRAY_WIDTH - rect.left); 467 rect.width = min_t(unsigned int, rect.width,
468 rect.height = min(rect.height, MT9M032_PIXEL_ARRAY_HEIGHT - rect.top); 468 MT9M032_PIXEL_ARRAY_WIDTH - rect.left);
469 rect.height = min_t(unsigned int, rect.height,
470 MT9M032_PIXEL_ARRAY_HEIGHT - rect.top);
469 471
470 __crop = __mt9m032_get_pad_crop(sensor, fh, crop->which); 472 __crop = __mt9m032_get_pad_crop(sensor, fh, crop->which);
471 473
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 1c2303d18bf4..e5ddf47030fd 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -519,11 +519,13 @@ static int mt9p031_set_format(struct v4l2_subdev *subdev,
519 519
520 /* Clamp the width and height to avoid dividing by zero. */ 520 /* Clamp the width and height to avoid dividing by zero. */
521 width = clamp_t(unsigned int, ALIGN(format->format.width, 2), 521 width = clamp_t(unsigned int, ALIGN(format->format.width, 2),
522 max(__crop->width / 7, MT9P031_WINDOW_WIDTH_MIN), 522 max_t(unsigned int, __crop->width / 7,
523 MT9P031_WINDOW_WIDTH_MIN),
523 __crop->width); 524 __crop->width);
524 height = clamp_t(unsigned int, ALIGN(format->format.height, 2), 525 height = clamp_t(unsigned int, ALIGN(format->format.height, 2),
525 max(__crop->height / 8, MT9P031_WINDOW_HEIGHT_MIN), 526 max_t(unsigned int, __crop->height / 8,
526 __crop->height); 527 MT9P031_WINDOW_HEIGHT_MIN),
528 __crop->height);
527 529
528 hratio = DIV_ROUND_CLOSEST(__crop->width, width); 530 hratio = DIV_ROUND_CLOSEST(__crop->width, width);
529 vratio = DIV_ROUND_CLOSEST(__crop->height, height); 531 vratio = DIV_ROUND_CLOSEST(__crop->height, height);
@@ -565,15 +567,17 @@ static int mt9p031_set_crop(struct v4l2_subdev *subdev,
565 MT9P031_COLUMN_START_MAX); 567 MT9P031_COLUMN_START_MAX);
566 rect.top = clamp(ALIGN(crop->rect.top, 2), MT9P031_ROW_START_MIN, 568 rect.top = clamp(ALIGN(crop->rect.top, 2), MT9P031_ROW_START_MIN,
567 MT9P031_ROW_START_MAX); 569 MT9P031_ROW_START_MAX);
568 rect.width = clamp(ALIGN(crop->rect.width, 2), 570 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2),
569 MT9P031_WINDOW_WIDTH_MIN, 571 MT9P031_WINDOW_WIDTH_MIN,
570 MT9P031_WINDOW_WIDTH_MAX); 572 MT9P031_WINDOW_WIDTH_MAX);
571 rect.height = clamp(ALIGN(crop->rect.height, 2), 573 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2),
572 MT9P031_WINDOW_HEIGHT_MIN, 574 MT9P031_WINDOW_HEIGHT_MIN,
573 MT9P031_WINDOW_HEIGHT_MAX); 575 MT9P031_WINDOW_HEIGHT_MAX);
574 576
575 rect.width = min(rect.width, MT9P031_PIXEL_ARRAY_WIDTH - rect.left); 577 rect.width = min_t(unsigned int, rect.width,
576 rect.height = min(rect.height, MT9P031_PIXEL_ARRAY_HEIGHT - rect.top); 578 MT9P031_PIXEL_ARRAY_WIDTH - rect.left);
579 rect.height = min_t(unsigned int, rect.height,
580 MT9P031_PIXEL_ARRAY_HEIGHT - rect.top);
577 581
578 __crop = __mt9p031_get_pad_crop(mt9p031, fh, crop->pad, crop->which); 582 __crop = __mt9p031_get_pad_crop(mt9p031, fh, crop->pad, crop->which);
579 583
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index 796463466ef0..d41c70eaf838 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -291,10 +291,12 @@ static int mt9t001_set_format(struct v4l2_subdev *subdev,
291 291
292 /* Clamp the width and height to avoid dividing by zero. */ 292 /* Clamp the width and height to avoid dividing by zero. */
293 width = clamp_t(unsigned int, ALIGN(format->format.width, 2), 293 width = clamp_t(unsigned int, ALIGN(format->format.width, 2),
294 max(__crop->width / 8, MT9T001_WINDOW_HEIGHT_MIN + 1), 294 max_t(unsigned int, __crop->width / 8,
295 MT9T001_WINDOW_HEIGHT_MIN + 1),
295 __crop->width); 296 __crop->width);
296 height = clamp_t(unsigned int, ALIGN(format->format.height, 2), 297 height = clamp_t(unsigned int, ALIGN(format->format.height, 2),
297 max(__crop->height / 8, MT9T001_WINDOW_HEIGHT_MIN + 1), 298 max_t(unsigned int, __crop->height / 8,
299 MT9T001_WINDOW_HEIGHT_MIN + 1),
298 __crop->height); 300 __crop->height);
299 301
300 hratio = DIV_ROUND_CLOSEST(__crop->width, width); 302 hratio = DIV_ROUND_CLOSEST(__crop->width, width);
@@ -339,15 +341,17 @@ static int mt9t001_set_crop(struct v4l2_subdev *subdev,
339 rect.top = clamp(ALIGN(crop->rect.top, 2), 341 rect.top = clamp(ALIGN(crop->rect.top, 2),
340 MT9T001_ROW_START_MIN, 342 MT9T001_ROW_START_MIN,
341 MT9T001_ROW_START_MAX); 343 MT9T001_ROW_START_MAX);
342 rect.width = clamp(ALIGN(crop->rect.width, 2), 344 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2),
343 MT9T001_WINDOW_WIDTH_MIN + 1, 345 MT9T001_WINDOW_WIDTH_MIN + 1,
344 MT9T001_WINDOW_WIDTH_MAX + 1); 346 MT9T001_WINDOW_WIDTH_MAX + 1);
345 rect.height = clamp(ALIGN(crop->rect.height, 2), 347 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2),
346 MT9T001_WINDOW_HEIGHT_MIN + 1, 348 MT9T001_WINDOW_HEIGHT_MIN + 1,
347 MT9T001_WINDOW_HEIGHT_MAX + 1); 349 MT9T001_WINDOW_HEIGHT_MAX + 1);
348 350
349 rect.width = min(rect.width, MT9T001_PIXEL_ARRAY_WIDTH - rect.left); 351 rect.width = min_t(unsigned int, rect.width,
350 rect.height = min(rect.height, MT9T001_PIXEL_ARRAY_HEIGHT - rect.top); 352 MT9T001_PIXEL_ARRAY_WIDTH - rect.left);
353 rect.height = min_t(unsigned int, rect.height,
354 MT9T001_PIXEL_ARRAY_HEIGHT - rect.top);
351 355
352 __crop = __mt9t001_get_pad_crop(mt9t001, fh, crop->pad, crop->which); 356 __crop = __mt9t001_get_pad_crop(mt9t001, fh, crop->pad, crop->which);
353 357
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 0d2b4a8cf911..36c504b78f2c 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -305,8 +305,8 @@ mt9v032_update_hblank(struct mt9v032 *mt9v032)
305 305
306 if (mt9v032->version->version == MT9V034_CHIP_ID_REV1) 306 if (mt9v032->version->version == MT9V034_CHIP_ID_REV1)
307 min_hblank += (mt9v032->hratio - 1) * 10; 307 min_hblank += (mt9v032->hratio - 1) * 10;
308 min_hblank = max((int)mt9v032->model->data->min_row_time - crop->width, 308 min_hblank = max_t(unsigned int, (int)mt9v032->model->data->min_row_time - crop->width,
309 (int)min_hblank); 309 (int)min_hblank);
310 hblank = max_t(unsigned int, mt9v032->hblank, min_hblank); 310 hblank = max_t(unsigned int, mt9v032->hblank, min_hblank);
311 311
312 return mt9v032_write(client, MT9V032_HORIZONTAL_BLANKING, hblank); 312 return mt9v032_write(client, MT9V032_HORIZONTAL_BLANKING, hblank);
@@ -525,12 +525,14 @@ static int mt9v032_set_format(struct v4l2_subdev *subdev,
525 format->which); 525 format->which);
526 526
527 /* Clamp the width and height to avoid dividing by zero. */ 527 /* Clamp the width and height to avoid dividing by zero. */
528 width = clamp_t(unsigned int, ALIGN(format->format.width, 2), 528 width = clamp(ALIGN(format->format.width, 2),
529 max(__crop->width / 4, MT9V032_WINDOW_WIDTH_MIN), 529 max_t(unsigned int, __crop->width / 4,
530 __crop->width); 530 MT9V032_WINDOW_WIDTH_MIN),
531 height = clamp_t(unsigned int, ALIGN(format->format.height, 2), 531 __crop->width);
532 max(__crop->height / 4, MT9V032_WINDOW_HEIGHT_MIN), 532 height = clamp(ALIGN(format->format.height, 2),
533 __crop->height); 533 max_t(unsigned int, __crop->height / 4,
534 MT9V032_WINDOW_HEIGHT_MIN),
535 __crop->height);
534 536
535 hratio = mt9v032_calc_ratio(__crop->width, width); 537 hratio = mt9v032_calc_ratio(__crop->width, width);
536 vratio = mt9v032_calc_ratio(__crop->height, height); 538 vratio = mt9v032_calc_ratio(__crop->height, height);
@@ -580,15 +582,17 @@ static int mt9v032_set_crop(struct v4l2_subdev *subdev,
580 rect.top = clamp(ALIGN(crop->rect.top + 1, 2) - 1, 582 rect.top = clamp(ALIGN(crop->rect.top + 1, 2) - 1,
581 MT9V032_ROW_START_MIN, 583 MT9V032_ROW_START_MIN,
582 MT9V032_ROW_START_MAX); 584 MT9V032_ROW_START_MAX);
583 rect.width = clamp(ALIGN(crop->rect.width, 2), 585 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2),
584 MT9V032_WINDOW_WIDTH_MIN, 586 MT9V032_WINDOW_WIDTH_MIN,
585 MT9V032_WINDOW_WIDTH_MAX); 587 MT9V032_WINDOW_WIDTH_MAX);
586 rect.height = clamp(ALIGN(crop->rect.height, 2), 588 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2),
587 MT9V032_WINDOW_HEIGHT_MIN, 589 MT9V032_WINDOW_HEIGHT_MIN,
588 MT9V032_WINDOW_HEIGHT_MAX); 590 MT9V032_WINDOW_HEIGHT_MAX);
589 591
590 rect.width = min(rect.width, MT9V032_PIXEL_ARRAY_WIDTH - rect.left); 592 rect.width = min_t(unsigned int,
591 rect.height = min(rect.height, MT9V032_PIXEL_ARRAY_HEIGHT - rect.top); 593 rect.width, MT9V032_PIXEL_ARRAY_WIDTH - rect.left);
594 rect.height = min_t(unsigned int,
595 rect.height, MT9V032_PIXEL_ARRAY_HEIGHT - rect.top);
592 596
593 __crop = __mt9v032_get_pad_crop(mt9v032, fh, crop->pad, crop->which); 597 __crop = __mt9v032_get_pad_crop(mt9v032, fh, crop->pad, crop->which);
594 598
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index fbd48f04b5c8..8741cae9c9f2 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2027,8 +2027,8 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev,
2027 sel->r.width = min(sel->r.width, src_size->width); 2027 sel->r.width = min(sel->r.width, src_size->width);
2028 sel->r.height = min(sel->r.height, src_size->height); 2028 sel->r.height = min(sel->r.height, src_size->height);
2029 2029
2030 sel->r.left = min(sel->r.left, src_size->width - sel->r.width); 2030 sel->r.left = min_t(int, sel->r.left, src_size->width - sel->r.width);
2031 sel->r.top = min(sel->r.top, src_size->height - sel->r.height); 2031 sel->r.top = min_t(int, sel->r.top, src_size->height - sel->r.height);
2032 2032
2033 *crops[sel->pad] = sel->r; 2033 *crops[sel->pad] = sel->r;
2034 2034
@@ -2120,8 +2120,8 @@ static int smiapp_set_selection(struct v4l2_subdev *subdev,
2120 2120
2121 sel->r.left = max(0, sel->r.left & ~1); 2121 sel->r.left = max(0, sel->r.left & ~1);
2122 sel->r.top = max(0, sel->r.top & ~1); 2122 sel->r.top = max(0, sel->r.top & ~1);
2123 sel->r.width = max(0, SMIAPP_ALIGN_DIM(sel->r.width, sel->flags)); 2123 sel->r.width = SMIAPP_ALIGN_DIM(sel->r.width, sel->flags);
2124 sel->r.height = max(0, SMIAPP_ALIGN_DIM(sel->r.height, sel->flags)); 2124 sel->r.height = SMIAPP_ALIGN_DIM(sel->r.height, sel->flags);
2125 2125
2126 sel->r.width = max_t(unsigned int, 2126 sel->r.width = max_t(unsigned int,
2127 sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE], 2127 sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE],
diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c
index 6f4056668bbc..ccf59406a172 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -208,8 +208,8 @@ struct mt9m111 {
208 struct mt9m111_context *ctx; 208 struct mt9m111_context *ctx;
209 struct v4l2_rect rect; /* cropping rectangle */ 209 struct v4l2_rect rect; /* cropping rectangle */
210 struct v4l2_clk *clk; 210 struct v4l2_clk *clk;
211 int width; /* output */ 211 unsigned int width; /* output */
212 int height; /* sizes */ 212 unsigned int height; /* sizes */
213 struct mutex power_lock; /* lock to protect power_count */ 213 struct mutex power_lock; /* lock to protect power_count */
214 int power_count; 214 int power_count;
215 const struct mt9m111_datafmt *fmt; 215 const struct mt9m111_datafmt *fmt;
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 2ed05b67218b..542d2528b3f9 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -863,7 +863,7 @@ static int tvp5150_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
863 struct v4l2_rect rect = a->c; 863 struct v4l2_rect rect = a->c;
864 struct tvp5150 *decoder = to_tvp5150(sd); 864 struct tvp5150 *decoder = to_tvp5150(sd);
865 v4l2_std_id std; 865 v4l2_std_id std;
866 int hmax; 866 unsigned int hmax;
867 867
868 v4l2_dbg(1, debug, sd, "%s left=%d, top=%d, width=%d, height=%d\n", 868 v4l2_dbg(1, debug, sd, "%s left=%d, top=%d, width=%d, height=%d\n",
869 __func__, rect.left, rect.top, rect.width, rect.height); 869 __func__, rect.left, rect.top, rect.width, rect.height);
@@ -873,9 +873,9 @@ static int tvp5150_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
873 873
874 /* tvp5150 has some special limits */ 874 /* tvp5150 has some special limits */
875 rect.left = clamp(rect.left, 0, TVP5150_MAX_CROP_LEFT); 875 rect.left = clamp(rect.left, 0, TVP5150_MAX_CROP_LEFT);
876 rect.width = clamp(rect.width, 876 rect.width = clamp_t(unsigned int, rect.width,
877 TVP5150_H_MAX - TVP5150_MAX_CROP_LEFT - rect.left, 877 TVP5150_H_MAX - TVP5150_MAX_CROP_LEFT - rect.left,
878 TVP5150_H_MAX - rect.left); 878 TVP5150_H_MAX - rect.left);
879 rect.top = clamp(rect.top, 0, TVP5150_MAX_CROP_TOP); 879 rect.top = clamp(rect.top, 0, TVP5150_MAX_CROP_TOP);
880 880
881 /* Calculate height based on current standard */ 881 /* Calculate height based on current standard */
@@ -889,9 +889,9 @@ static int tvp5150_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
889 else 889 else
890 hmax = TVP5150_V_MAX_OTHERS; 890 hmax = TVP5150_V_MAX_OTHERS;
891 891
892 rect.height = clamp(rect.height, 892 rect.height = clamp_t(unsigned int, rect.height,
893 hmax - TVP5150_MAX_CROP_TOP - rect.top, 893 hmax - TVP5150_MAX_CROP_TOP - rect.top,
894 hmax - rect.top); 894 hmax - rect.top);
895 895
896 tvp5150_write(sd, TVP5150_VERT_BLANKING_START, rect.top); 896 tvp5150_write(sd, TVP5150_VERT_BLANKING_START, rect.top);
897 tvp5150_write(sd, TVP5150_VERT_BLANKING_STOP, 897 tvp5150_write(sd, TVP5150_VERT_BLANKING_STOP,