aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-12-04 04:54:52 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-12-22 15:11:34 -0500
commit1a023feb9c880bdf61502c5f8ef7b499133de8da (patch)
tree4e8bebe308513e7b19be5c68f30e91a0ee3cfa50
parent215cedec379b69427c457104f0c36b389edc471c (diff)
[media] v4l2 subdevs: replace get/set_crop by get/set_selection
The crop and selection pad ops are duplicates. Replace all uses of get/set_crop by get/set_selection. This will make it possible to drop get/set_crop altogether. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Prabhakar Lad <prabhakar.csengg@gmail.com> Cc: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/i2c/mt9m032.c42
-rw-r--r--drivers/media/i2c/mt9p031.c41
-rw-r--r--drivers/media/i2c/mt9t001.c41
-rw-r--r--drivers/media/i2c/mt9v032.c43
-rw-r--r--drivers/media/i2c/s5k6aa.c44
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_isif.c69
6 files changed, 156 insertions, 124 deletions
diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
index 45b3fca188ca..76431223f0ff 100644
--- a/drivers/media/i2c/mt9m032.c
+++ b/drivers/media/i2c/mt9m032.c
@@ -422,22 +422,25 @@ done:
422 return ret; 422 return ret;
423} 423}
424 424
425static int mt9m032_get_pad_crop(struct v4l2_subdev *subdev, 425static int mt9m032_get_pad_selection(struct v4l2_subdev *subdev,
426 struct v4l2_subdev_fh *fh, 426 struct v4l2_subdev_fh *fh,
427 struct v4l2_subdev_crop *crop) 427 struct v4l2_subdev_selection *sel)
428{ 428{
429 struct mt9m032 *sensor = to_mt9m032(subdev); 429 struct mt9m032 *sensor = to_mt9m032(subdev);
430 430
431 if (sel->target != V4L2_SEL_TGT_CROP)
432 return -EINVAL;
433
431 mutex_lock(&sensor->lock); 434 mutex_lock(&sensor->lock);
432 crop->rect = *__mt9m032_get_pad_crop(sensor, fh, crop->which); 435 sel->r = *__mt9m032_get_pad_crop(sensor, fh, sel->which);
433 mutex_unlock(&sensor->lock); 436 mutex_unlock(&sensor->lock);
434 437
435 return 0; 438 return 0;
436} 439}
437 440
438static int mt9m032_set_pad_crop(struct v4l2_subdev *subdev, 441static int mt9m032_set_pad_selection(struct v4l2_subdev *subdev,
439 struct v4l2_subdev_fh *fh, 442 struct v4l2_subdev_fh *fh,
440 struct v4l2_subdev_crop *crop) 443 struct v4l2_subdev_selection *sel)
441{ 444{
442 struct mt9m032 *sensor = to_mt9m032(subdev); 445 struct mt9m032 *sensor = to_mt9m032(subdev);
443 struct v4l2_mbus_framefmt *format; 446 struct v4l2_mbus_framefmt *format;
@@ -445,9 +448,12 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev *subdev,
445 struct v4l2_rect rect; 448 struct v4l2_rect rect;
446 int ret = 0; 449 int ret = 0;
447 450
451 if (sel->target != V4L2_SEL_TGT_CROP)
452 return -EINVAL;
453
448 mutex_lock(&sensor->lock); 454 mutex_lock(&sensor->lock);
449 455
450 if (sensor->streaming && crop->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 456 if (sensor->streaming && sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
451 ret = -EBUSY; 457 ret = -EBUSY;
452 goto done; 458 goto done;
453 } 459 }
@@ -455,13 +461,13 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev *subdev,
455 /* Clamp the crop rectangle boundaries and align them to a multiple of 2 461 /* Clamp the crop rectangle boundaries and align them to a multiple of 2
456 * pixels to ensure a GRBG Bayer pattern. 462 * pixels to ensure a GRBG Bayer pattern.
457 */ 463 */
458 rect.left = clamp(ALIGN(crop->rect.left, 2), MT9M032_COLUMN_START_MIN, 464 rect.left = clamp(ALIGN(sel->r.left, 2), MT9M032_COLUMN_START_MIN,
459 MT9M032_COLUMN_START_MAX); 465 MT9M032_COLUMN_START_MAX);
460 rect.top = clamp(ALIGN(crop->rect.top, 2), MT9M032_ROW_START_MIN, 466 rect.top = clamp(ALIGN(sel->r.top, 2), MT9M032_ROW_START_MIN,
461 MT9M032_ROW_START_MAX); 467 MT9M032_ROW_START_MAX);
462 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2), 468 rect.width = clamp_t(unsigned int, ALIGN(sel->r.width, 2),
463 MT9M032_COLUMN_SIZE_MIN, MT9M032_COLUMN_SIZE_MAX); 469 MT9M032_COLUMN_SIZE_MIN, MT9M032_COLUMN_SIZE_MAX);
464 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2), 470 rect.height = clamp_t(unsigned int, ALIGN(sel->r.height, 2),
465 MT9M032_ROW_SIZE_MIN, MT9M032_ROW_SIZE_MAX); 471 MT9M032_ROW_SIZE_MIN, MT9M032_ROW_SIZE_MAX);
466 472
467 rect.width = min_t(unsigned int, rect.width, 473 rect.width = min_t(unsigned int, rect.width,
@@ -469,21 +475,21 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev *subdev,
469 rect.height = min_t(unsigned int, rect.height, 475 rect.height = min_t(unsigned int, rect.height,
470 MT9M032_PIXEL_ARRAY_HEIGHT - rect.top); 476 MT9M032_PIXEL_ARRAY_HEIGHT - rect.top);
471 477
472 __crop = __mt9m032_get_pad_crop(sensor, fh, crop->which); 478 __crop = __mt9m032_get_pad_crop(sensor, fh, sel->which);
473 479
474 if (rect.width != __crop->width || rect.height != __crop->height) { 480 if (rect.width != __crop->width || rect.height != __crop->height) {
475 /* Reset the output image size if the crop rectangle size has 481 /* Reset the output image size if the crop rectangle size has
476 * been modified. 482 * been modified.
477 */ 483 */
478 format = __mt9m032_get_pad_format(sensor, fh, crop->which); 484 format = __mt9m032_get_pad_format(sensor, fh, sel->which);
479 format->width = rect.width; 485 format->width = rect.width;
480 format->height = rect.height; 486 format->height = rect.height;
481 } 487 }
482 488
483 *__crop = rect; 489 *__crop = rect;
484 crop->rect = rect; 490 sel->r = rect;
485 491
486 if (crop->which == V4L2_SUBDEV_FORMAT_ACTIVE) 492 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE)
487 ret = mt9m032_update_geom_timing(sensor); 493 ret = mt9m032_update_geom_timing(sensor);
488 494
489done: 495done:
@@ -690,8 +696,8 @@ static const struct v4l2_subdev_pad_ops mt9m032_pad_ops = {
690 .enum_frame_size = mt9m032_enum_frame_size, 696 .enum_frame_size = mt9m032_enum_frame_size,
691 .get_fmt = mt9m032_get_pad_format, 697 .get_fmt = mt9m032_get_pad_format,
692 .set_fmt = mt9m032_set_pad_format, 698 .set_fmt = mt9m032_set_pad_format,
693 .set_crop = mt9m032_set_pad_crop, 699 .set_selection = mt9m032_set_pad_selection,
694 .get_crop = mt9m032_get_pad_crop, 700 .get_selection = mt9m032_get_pad_selection,
695}; 701};
696 702
697static const struct v4l2_subdev_ops mt9m032_ops = { 703static const struct v4l2_subdev_ops mt9m032_ops = {
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index edb76bd33d16..e3acae9a2ec3 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -581,37 +581,42 @@ static int mt9p031_set_format(struct v4l2_subdev *subdev,
581 return 0; 581 return 0;
582} 582}
583 583
584static int mt9p031_get_crop(struct v4l2_subdev *subdev, 584static int mt9p031_get_selection(struct v4l2_subdev *subdev,
585 struct v4l2_subdev_fh *fh, 585 struct v4l2_subdev_fh *fh,
586 struct v4l2_subdev_crop *crop) 586 struct v4l2_subdev_selection *sel)
587{ 587{
588 struct mt9p031 *mt9p031 = to_mt9p031(subdev); 588 struct mt9p031 *mt9p031 = to_mt9p031(subdev);
589 589
590 crop->rect = *__mt9p031_get_pad_crop(mt9p031, fh, crop->pad, 590 if (sel->target != V4L2_SEL_TGT_CROP)
591 crop->which); 591 return -EINVAL;
592
593 sel->r = *__mt9p031_get_pad_crop(mt9p031, fh, sel->pad, sel->which);
592 return 0; 594 return 0;
593} 595}
594 596
595static int mt9p031_set_crop(struct v4l2_subdev *subdev, 597static int mt9p031_set_selection(struct v4l2_subdev *subdev,
596 struct v4l2_subdev_fh *fh, 598 struct v4l2_subdev_fh *fh,
597 struct v4l2_subdev_crop *crop) 599 struct v4l2_subdev_selection *sel)
598{ 600{
599 struct mt9p031 *mt9p031 = to_mt9p031(subdev); 601 struct mt9p031 *mt9p031 = to_mt9p031(subdev);
600 struct v4l2_mbus_framefmt *__format; 602 struct v4l2_mbus_framefmt *__format;
601 struct v4l2_rect *__crop; 603 struct v4l2_rect *__crop;
602 struct v4l2_rect rect; 604 struct v4l2_rect rect;
603 605
606 if (sel->target != V4L2_SEL_TGT_CROP)
607 return -EINVAL;
608
604 /* Clamp the crop rectangle boundaries and align them to a multiple of 2 609 /* Clamp the crop rectangle boundaries and align them to a multiple of 2
605 * pixels to ensure a GRBG Bayer pattern. 610 * pixels to ensure a GRBG Bayer pattern.
606 */ 611 */
607 rect.left = clamp(ALIGN(crop->rect.left, 2), MT9P031_COLUMN_START_MIN, 612 rect.left = clamp(ALIGN(sel->r.left, 2), MT9P031_COLUMN_START_MIN,
608 MT9P031_COLUMN_START_MAX); 613 MT9P031_COLUMN_START_MAX);
609 rect.top = clamp(ALIGN(crop->rect.top, 2), MT9P031_ROW_START_MIN, 614 rect.top = clamp(ALIGN(sel->r.top, 2), MT9P031_ROW_START_MIN,
610 MT9P031_ROW_START_MAX); 615 MT9P031_ROW_START_MAX);
611 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2), 616 rect.width = clamp_t(unsigned int, ALIGN(sel->r.width, 2),
612 MT9P031_WINDOW_WIDTH_MIN, 617 MT9P031_WINDOW_WIDTH_MIN,
613 MT9P031_WINDOW_WIDTH_MAX); 618 MT9P031_WINDOW_WIDTH_MAX);
614 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2), 619 rect.height = clamp_t(unsigned int, ALIGN(sel->r.height, 2),
615 MT9P031_WINDOW_HEIGHT_MIN, 620 MT9P031_WINDOW_HEIGHT_MIN,
616 MT9P031_WINDOW_HEIGHT_MAX); 621 MT9P031_WINDOW_HEIGHT_MAX);
617 622
@@ -620,20 +625,20 @@ static int mt9p031_set_crop(struct v4l2_subdev *subdev,
620 rect.height = min_t(unsigned int, rect.height, 625 rect.height = min_t(unsigned int, rect.height,
621 MT9P031_PIXEL_ARRAY_HEIGHT - rect.top); 626 MT9P031_PIXEL_ARRAY_HEIGHT - rect.top);
622 627
623 __crop = __mt9p031_get_pad_crop(mt9p031, fh, crop->pad, crop->which); 628 __crop = __mt9p031_get_pad_crop(mt9p031, fh, sel->pad, sel->which);
624 629
625 if (rect.width != __crop->width || rect.height != __crop->height) { 630 if (rect.width != __crop->width || rect.height != __crop->height) {
626 /* Reset the output image size if the crop rectangle size has 631 /* Reset the output image size if the crop rectangle size has
627 * been modified. 632 * been modified.
628 */ 633 */
629 __format = __mt9p031_get_pad_format(mt9p031, fh, crop->pad, 634 __format = __mt9p031_get_pad_format(mt9p031, fh, sel->pad,
630 crop->which); 635 sel->which);
631 __format->width = rect.width; 636 __format->width = rect.width;
632 __format->height = rect.height; 637 __format->height = rect.height;
633 } 638 }
634 639
635 *__crop = rect; 640 *__crop = rect;
636 crop->rect = rect; 641 sel->r = rect;
637 642
638 return 0; 643 return 0;
639} 644}
@@ -980,8 +985,8 @@ static struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
980 .enum_frame_size = mt9p031_enum_frame_size, 985 .enum_frame_size = mt9p031_enum_frame_size,
981 .get_fmt = mt9p031_get_format, 986 .get_fmt = mt9p031_get_format,
982 .set_fmt = mt9p031_set_format, 987 .set_fmt = mt9p031_set_format,
983 .get_crop = mt9p031_get_crop, 988 .get_selection = mt9p031_get_selection,
984 .set_crop = mt9p031_set_crop, 989 .set_selection = mt9p031_set_selection,
985}; 990};
986 991
987static struct v4l2_subdev_ops mt9p031_subdev_ops = { 992static struct v4l2_subdev_ops mt9p031_subdev_ops = {
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index d9e9889b579f..f6ca636b538d 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -401,39 +401,44 @@ static int mt9t001_set_format(struct v4l2_subdev *subdev,
401 return 0; 401 return 0;
402} 402}
403 403
404static int mt9t001_get_crop(struct v4l2_subdev *subdev, 404static int mt9t001_get_selection(struct v4l2_subdev *subdev,
405 struct v4l2_subdev_fh *fh, 405 struct v4l2_subdev_fh *fh,
406 struct v4l2_subdev_crop *crop) 406 struct v4l2_subdev_selection *sel)
407{ 407{
408 struct mt9t001 *mt9t001 = to_mt9t001(subdev); 408 struct mt9t001 *mt9t001 = to_mt9t001(subdev);
409 409
410 crop->rect = *__mt9t001_get_pad_crop(mt9t001, fh, crop->pad, 410 if (sel->target != V4L2_SEL_TGT_CROP)
411 crop->which); 411 return -EINVAL;
412
413 sel->r = *__mt9t001_get_pad_crop(mt9t001, fh, sel->pad, sel->which);
412 return 0; 414 return 0;
413} 415}
414 416
415static int mt9t001_set_crop(struct v4l2_subdev *subdev, 417static int mt9t001_set_selection(struct v4l2_subdev *subdev,
416 struct v4l2_subdev_fh *fh, 418 struct v4l2_subdev_fh *fh,
417 struct v4l2_subdev_crop *crop) 419 struct v4l2_subdev_selection *sel)
418{ 420{
419 struct mt9t001 *mt9t001 = to_mt9t001(subdev); 421 struct mt9t001 *mt9t001 = to_mt9t001(subdev);
420 struct v4l2_mbus_framefmt *__format; 422 struct v4l2_mbus_framefmt *__format;
421 struct v4l2_rect *__crop; 423 struct v4l2_rect *__crop;
422 struct v4l2_rect rect; 424 struct v4l2_rect rect;
423 425
426 if (sel->target != V4L2_SEL_TGT_CROP)
427 return -EINVAL;
428
424 /* Clamp the crop rectangle boundaries and align them to a multiple of 2 429 /* Clamp the crop rectangle boundaries and align them to a multiple of 2
425 * pixels. 430 * pixels.
426 */ 431 */
427 rect.left = clamp(ALIGN(crop->rect.left, 2), 432 rect.left = clamp(ALIGN(sel->r.left, 2),
428 MT9T001_COLUMN_START_MIN, 433 MT9T001_COLUMN_START_MIN,
429 MT9T001_COLUMN_START_MAX); 434 MT9T001_COLUMN_START_MAX);
430 rect.top = clamp(ALIGN(crop->rect.top, 2), 435 rect.top = clamp(ALIGN(sel->r.top, 2),
431 MT9T001_ROW_START_MIN, 436 MT9T001_ROW_START_MIN,
432 MT9T001_ROW_START_MAX); 437 MT9T001_ROW_START_MAX);
433 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2), 438 rect.width = clamp_t(unsigned int, ALIGN(sel->r.width, 2),
434 MT9T001_WINDOW_WIDTH_MIN + 1, 439 MT9T001_WINDOW_WIDTH_MIN + 1,
435 MT9T001_WINDOW_WIDTH_MAX + 1); 440 MT9T001_WINDOW_WIDTH_MAX + 1);
436 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2), 441 rect.height = clamp_t(unsigned int, ALIGN(sel->r.height, 2),
437 MT9T001_WINDOW_HEIGHT_MIN + 1, 442 MT9T001_WINDOW_HEIGHT_MIN + 1,
438 MT9T001_WINDOW_HEIGHT_MAX + 1); 443 MT9T001_WINDOW_HEIGHT_MAX + 1);
439 444
@@ -442,20 +447,20 @@ static int mt9t001_set_crop(struct v4l2_subdev *subdev,
442 rect.height = min_t(unsigned int, rect.height, 447 rect.height = min_t(unsigned int, rect.height,
443 MT9T001_PIXEL_ARRAY_HEIGHT - rect.top); 448 MT9T001_PIXEL_ARRAY_HEIGHT - rect.top);
444 449
445 __crop = __mt9t001_get_pad_crop(mt9t001, fh, crop->pad, crop->which); 450 __crop = __mt9t001_get_pad_crop(mt9t001, fh, sel->pad, sel->which);
446 451
447 if (rect.width != __crop->width || rect.height != __crop->height) { 452 if (rect.width != __crop->width || rect.height != __crop->height) {
448 /* Reset the output image size if the crop rectangle size has 453 /* Reset the output image size if the crop rectangle size has
449 * been modified. 454 * been modified.
450 */ 455 */
451 __format = __mt9t001_get_pad_format(mt9t001, fh, crop->pad, 456 __format = __mt9t001_get_pad_format(mt9t001, fh, sel->pad,
452 crop->which); 457 sel->which);
453 __format->width = rect.width; 458 __format->width = rect.width;
454 __format->height = rect.height; 459 __format->height = rect.height;
455 } 460 }
456 461
457 *__crop = rect; 462 *__crop = rect;
458 crop->rect = rect; 463 sel->r = rect;
459 464
460 return 0; 465 return 0;
461} 466}
@@ -819,8 +824,8 @@ static struct v4l2_subdev_pad_ops mt9t001_subdev_pad_ops = {
819 .enum_frame_size = mt9t001_enum_frame_size, 824 .enum_frame_size = mt9t001_enum_frame_size,
820 .get_fmt = mt9t001_get_format, 825 .get_fmt = mt9t001_get_format,
821 .set_fmt = mt9t001_set_format, 826 .set_fmt = mt9t001_set_format,
822 .get_crop = mt9t001_get_crop, 827 .get_selection = mt9t001_get_selection,
823 .set_crop = mt9t001_set_crop, 828 .set_selection = mt9t001_set_selection,
824}; 829};
825 830
826static struct v4l2_subdev_ops mt9t001_subdev_ops = { 831static struct v4l2_subdev_ops mt9t001_subdev_ops = {
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 93687c1e4097..bd3f979a4d49 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -552,39 +552,44 @@ static int mt9v032_set_format(struct v4l2_subdev *subdev,
552 return 0; 552 return 0;
553} 553}
554 554
555static int mt9v032_get_crop(struct v4l2_subdev *subdev, 555static int mt9v032_get_selection(struct v4l2_subdev *subdev,
556 struct v4l2_subdev_fh *fh, 556 struct v4l2_subdev_fh *fh,
557 struct v4l2_subdev_crop *crop) 557 struct v4l2_subdev_selection *sel)
558{ 558{
559 struct mt9v032 *mt9v032 = to_mt9v032(subdev); 559 struct mt9v032 *mt9v032 = to_mt9v032(subdev);
560 560
561 crop->rect = *__mt9v032_get_pad_crop(mt9v032, fh, crop->pad, 561 if (sel->target != V4L2_SEL_TGT_CROP)
562 crop->which); 562 return -EINVAL;
563
564 sel->r = *__mt9v032_get_pad_crop(mt9v032, fh, sel->pad, sel->which);
563 return 0; 565 return 0;
564} 566}
565 567
566static int mt9v032_set_crop(struct v4l2_subdev *subdev, 568static int mt9v032_set_selection(struct v4l2_subdev *subdev,
567 struct v4l2_subdev_fh *fh, 569 struct v4l2_subdev_fh *fh,
568 struct v4l2_subdev_crop *crop) 570 struct v4l2_subdev_selection *sel)
569{ 571{
570 struct mt9v032 *mt9v032 = to_mt9v032(subdev); 572 struct mt9v032 *mt9v032 = to_mt9v032(subdev);
571 struct v4l2_mbus_framefmt *__format; 573 struct v4l2_mbus_framefmt *__format;
572 struct v4l2_rect *__crop; 574 struct v4l2_rect *__crop;
573 struct v4l2_rect rect; 575 struct v4l2_rect rect;
574 576
577 if (sel->target != V4L2_SEL_TGT_CROP)
578 return -EINVAL;
579
575 /* Clamp the crop rectangle boundaries and align them to a non multiple 580 /* Clamp the crop rectangle boundaries and align them to a non multiple
576 * of 2 pixels to ensure a GRBG Bayer pattern. 581 * of 2 pixels to ensure a GRBG Bayer pattern.
577 */ 582 */
578 rect.left = clamp(ALIGN(crop->rect.left + 1, 2) - 1, 583 rect.left = clamp(ALIGN(sel->r.left + 1, 2) - 1,
579 MT9V032_COLUMN_START_MIN, 584 MT9V032_COLUMN_START_MIN,
580 MT9V032_COLUMN_START_MAX); 585 MT9V032_COLUMN_START_MAX);
581 rect.top = clamp(ALIGN(crop->rect.top + 1, 2) - 1, 586 rect.top = clamp(ALIGN(sel->r.top + 1, 2) - 1,
582 MT9V032_ROW_START_MIN, 587 MT9V032_ROW_START_MIN,
583 MT9V032_ROW_START_MAX); 588 MT9V032_ROW_START_MAX);
584 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2), 589 rect.width = clamp_t(unsigned int, ALIGN(sel->r.width, 2),
585 MT9V032_WINDOW_WIDTH_MIN, 590 MT9V032_WINDOW_WIDTH_MIN,
586 MT9V032_WINDOW_WIDTH_MAX); 591 MT9V032_WINDOW_WIDTH_MAX);
587 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2), 592 rect.height = clamp_t(unsigned int, ALIGN(sel->r.height, 2),
588 MT9V032_WINDOW_HEIGHT_MIN, 593 MT9V032_WINDOW_HEIGHT_MIN,
589 MT9V032_WINDOW_HEIGHT_MAX); 594 MT9V032_WINDOW_HEIGHT_MAX);
590 595
@@ -593,17 +598,17 @@ static int mt9v032_set_crop(struct v4l2_subdev *subdev,
593 rect.height = min_t(unsigned int, 598 rect.height = min_t(unsigned int,
594 rect.height, MT9V032_PIXEL_ARRAY_HEIGHT - rect.top); 599 rect.height, MT9V032_PIXEL_ARRAY_HEIGHT - rect.top);
595 600
596 __crop = __mt9v032_get_pad_crop(mt9v032, fh, crop->pad, crop->which); 601 __crop = __mt9v032_get_pad_crop(mt9v032, fh, sel->pad, sel->which);
597 602
598 if (rect.width != __crop->width || rect.height != __crop->height) { 603 if (rect.width != __crop->width || rect.height != __crop->height) {
599 /* Reset the output image size if the crop rectangle size has 604 /* Reset the output image size if the crop rectangle size has
600 * been modified. 605 * been modified.
601 */ 606 */
602 __format = __mt9v032_get_pad_format(mt9v032, fh, crop->pad, 607 __format = __mt9v032_get_pad_format(mt9v032, fh, sel->pad,
603 crop->which); 608 sel->which);
604 __format->width = rect.width; 609 __format->width = rect.width;
605 __format->height = rect.height; 610 __format->height = rect.height;
606 if (crop->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 611 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
607 mt9v032->hratio = 1; 612 mt9v032->hratio = 1;
608 mt9v032->vratio = 1; 613 mt9v032->vratio = 1;
609 mt9v032_configure_pixel_rate(mt9v032); 614 mt9v032_configure_pixel_rate(mt9v032);
@@ -611,7 +616,7 @@ static int mt9v032_set_crop(struct v4l2_subdev *subdev,
611 } 616 }
612 617
613 *__crop = rect; 618 *__crop = rect;
614 crop->rect = rect; 619 sel->r = rect;
615 620
616 return 0; 621 return 0;
617} 622}
@@ -844,8 +849,8 @@ static struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
844 .enum_frame_size = mt9v032_enum_frame_size, 849 .enum_frame_size = mt9v032_enum_frame_size,
845 .get_fmt = mt9v032_get_format, 850 .get_fmt = mt9v032_get_format,
846 .set_fmt = mt9v032_set_format, 851 .set_fmt = mt9v032_set_format,
847 .get_crop = mt9v032_get_crop, 852 .get_selection = mt9v032_get_selection,
848 .set_crop = mt9v032_set_crop, 853 .set_selection = mt9v032_set_selection,
849}; 854};
850 855
851static struct v4l2_subdev_ops mt9v032_subdev_ops = { 856static struct v4l2_subdev_ops mt9v032_subdev_ops = {
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index 2851581e0061..19edafb82b5b 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -1161,17 +1161,21 @@ static int s5k6aa_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1161 return ret; 1161 return ret;
1162} 1162}
1163 1163
1164static int s5k6aa_get_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1164static int s5k6aa_get_selection(struct v4l2_subdev *sd,
1165 struct v4l2_subdev_crop *crop) 1165 struct v4l2_subdev_fh *fh,
1166 struct v4l2_subdev_selection *sel)
1166{ 1167{
1167 struct s5k6aa *s5k6aa = to_s5k6aa(sd); 1168 struct s5k6aa *s5k6aa = to_s5k6aa(sd);
1168 struct v4l2_rect *rect; 1169 struct v4l2_rect *rect;
1169 1170
1170 memset(crop->reserved, 0, sizeof(crop->reserved)); 1171 if (sel->target != V4L2_SEL_TGT_CROP)
1172 return -EINVAL;
1173
1174 memset(sel->reserved, 0, sizeof(sel->reserved));
1171 1175
1172 mutex_lock(&s5k6aa->lock); 1176 mutex_lock(&s5k6aa->lock);
1173 rect = __s5k6aa_get_crop_rect(s5k6aa, fh, crop->which); 1177 rect = __s5k6aa_get_crop_rect(s5k6aa, fh, sel->which);
1174 crop->rect = *rect; 1178 sel->r = *rect;
1175 mutex_unlock(&s5k6aa->lock); 1179 mutex_unlock(&s5k6aa->lock);
1176 1180
1177 v4l2_dbg(1, debug, sd, "Current crop rectangle: (%d,%d)/%dx%d\n", 1181 v4l2_dbg(1, debug, sd, "Current crop rectangle: (%d,%d)/%dx%d\n",
@@ -1180,35 +1184,39 @@ static int s5k6aa_get_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1180 return 0; 1184 return 0;
1181} 1185}
1182 1186
1183static int s5k6aa_set_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1187static int s5k6aa_set_selection(struct v4l2_subdev *sd,
1184 struct v4l2_subdev_crop *crop) 1188 struct v4l2_subdev_fh *fh,
1189 struct v4l2_subdev_selection *sel)
1185{ 1190{
1186 struct s5k6aa *s5k6aa = to_s5k6aa(sd); 1191 struct s5k6aa *s5k6aa = to_s5k6aa(sd);
1187 struct v4l2_mbus_framefmt *mf; 1192 struct v4l2_mbus_framefmt *mf;
1188 unsigned int max_x, max_y; 1193 unsigned int max_x, max_y;
1189 struct v4l2_rect *crop_r; 1194 struct v4l2_rect *crop_r;
1190 1195
1196 if (sel->target != V4L2_SEL_TGT_CROP)
1197 return -EINVAL;
1198
1191 mutex_lock(&s5k6aa->lock); 1199 mutex_lock(&s5k6aa->lock);
1192 crop_r = __s5k6aa_get_crop_rect(s5k6aa, fh, crop->which); 1200 crop_r = __s5k6aa_get_crop_rect(s5k6aa, fh, sel->which);
1193 1201
1194 if (crop->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 1202 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
1195 mf = &s5k6aa->preset->mbus_fmt; 1203 mf = &s5k6aa->preset->mbus_fmt;
1196 s5k6aa->apply_crop = 1; 1204 s5k6aa->apply_crop = 1;
1197 } else { 1205 } else {
1198 mf = v4l2_subdev_get_try_format(fh, 0); 1206 mf = v4l2_subdev_get_try_format(fh, 0);
1199 } 1207 }
1200 v4l_bound_align_image(&crop->rect.width, mf->width, 1208 v4l_bound_align_image(&sel->r.width, mf->width,
1201 S5K6AA_WIN_WIDTH_MAX, 1, 1209 S5K6AA_WIN_WIDTH_MAX, 1,
1202 &crop->rect.height, mf->height, 1210 &sel->r.height, mf->height,
1203 S5K6AA_WIN_HEIGHT_MAX, 1, 0); 1211 S5K6AA_WIN_HEIGHT_MAX, 1, 0);
1204 1212
1205 max_x = (S5K6AA_WIN_WIDTH_MAX - crop->rect.width) & ~1; 1213 max_x = (S5K6AA_WIN_WIDTH_MAX - sel->r.width) & ~1;
1206 max_y = (S5K6AA_WIN_HEIGHT_MAX - crop->rect.height) & ~1; 1214 max_y = (S5K6AA_WIN_HEIGHT_MAX - sel->r.height) & ~1;
1207 1215
1208 crop->rect.left = clamp_t(unsigned int, crop->rect.left, 0, max_x); 1216 sel->r.left = clamp_t(unsigned int, sel->r.left, 0, max_x);
1209 crop->rect.top = clamp_t(unsigned int, crop->rect.top, 0, max_y); 1217 sel->r.top = clamp_t(unsigned int, sel->r.top, 0, max_y);
1210 1218
1211 *crop_r = crop->rect; 1219 *crop_r = sel->r;
1212 1220
1213 mutex_unlock(&s5k6aa->lock); 1221 mutex_unlock(&s5k6aa->lock);
1214 1222
@@ -1224,8 +1232,8 @@ static const struct v4l2_subdev_pad_ops s5k6aa_pad_ops = {
1224 .enum_frame_interval = s5k6aa_enum_frame_interval, 1232 .enum_frame_interval = s5k6aa_enum_frame_interval,
1225 .get_fmt = s5k6aa_get_fmt, 1233 .get_fmt = s5k6aa_get_fmt,
1226 .set_fmt = s5k6aa_set_fmt, 1234 .set_fmt = s5k6aa_set_fmt,
1227 .get_crop = s5k6aa_get_crop, 1235 .get_selection = s5k6aa_get_selection,
1228 .set_crop = s5k6aa_set_crop, 1236 .set_selection = s5k6aa_set_selection,
1229}; 1237};
1230 1238
1231static const struct v4l2_subdev_video_ops s5k6aa_video_ops = { 1239static const struct v4l2_subdev_video_ops s5k6aa_video_ops = {
diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c
index 0ba0bf2c1cff..bcf762bc233d 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_isif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c
@@ -1535,7 +1535,7 @@ isif_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1535} 1535}
1536 1536
1537/* 1537/*
1538 * isif_pad_set_crop() - set crop rectangle on pad 1538 * isif_pad_set_selection() - set crop rectangle on pad
1539 * @sd: VPFE isif V4L2 subdevice 1539 * @sd: VPFE isif V4L2 subdevice
1540 * @fh: V4L2 subdev file handle 1540 * @fh: V4L2 subdev file handle
1541 * @code: pointer to v4l2_subdev_mbus_code_enum structure 1541 * @code: pointer to v4l2_subdev_mbus_code_enum structure
@@ -1543,35 +1543,36 @@ isif_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1543 * Return 0 on success, -EINVAL if pad is invalid 1543 * Return 0 on success, -EINVAL if pad is invalid
1544 */ 1544 */
1545static int 1545static int
1546isif_pad_set_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1546isif_pad_set_selection(struct v4l2_subdev *sd,
1547 struct v4l2_subdev_crop *crop) 1547 struct v4l2_subdev_fh *fh,
1548 struct v4l2_subdev_selection *sel)
1548{ 1549{
1549 struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd); 1550 struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd);
1550 struct v4l2_mbus_framefmt *format; 1551 struct v4l2_mbus_framefmt *format;
1551 1552
1552 /* check wether its a valid pad */ 1553 /* check whether it's a valid pad and target */
1553 if (crop->pad != ISIF_PAD_SINK) 1554 if (sel->pad != ISIF_PAD_SINK || sel->target != V4L2_SEL_TGT_CROP)
1554 return -EINVAL; 1555 return -EINVAL;
1555 1556
1556 format = __isif_get_format(vpfe_isif, fh, crop->pad, crop->which); 1557 format = __isif_get_format(vpfe_isif, fh, sel->pad, sel->which);
1557 if (format == NULL) 1558 if (format == NULL)
1558 return -EINVAL; 1559 return -EINVAL;
1559 1560
1560 /* check wether crop rect is within limits */ 1561 /* check wether crop rect is within limits */
1561 if (crop->rect.top < 0 || crop->rect.left < 0 || 1562 if (sel->r.top < 0 || sel->r.left < 0 ||
1562 (crop->rect.left + crop->rect.width > 1563 (sel->r.left + sel->r.width >
1563 vpfe_isif->formats[ISIF_PAD_SINK].width) || 1564 vpfe_isif->formats[ISIF_PAD_SINK].width) ||
1564 (crop->rect.top + crop->rect.height > 1565 (sel->r.top + sel->r.height >
1565 vpfe_isif->formats[ISIF_PAD_SINK].height)) { 1566 vpfe_isif->formats[ISIF_PAD_SINK].height)) {
1566 crop->rect.left = 0; 1567 sel->r.left = 0;
1567 crop->rect.top = 0; 1568 sel->r.top = 0;
1568 crop->rect.width = format->width; 1569 sel->r.width = format->width;
1569 crop->rect.height = format->height; 1570 sel->r.height = format->height;
1570 } 1571 }
1571 /* adjust the width to 16 pixel boundary */ 1572 /* adjust the width to 16 pixel boundary */
1572 crop->rect.width = ((crop->rect.width + 15) & ~0xf); 1573 sel->r.width = ((sel->r.width + 15) & ~0xf);
1573 vpfe_isif->crop = crop->rect; 1574 vpfe_isif->crop = sel->r;
1574 if (crop->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 1575 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
1575 isif_set_image_window(vpfe_isif); 1576 isif_set_image_window(vpfe_isif);
1576 } else { 1577 } else {
1577 struct v4l2_rect *rect; 1578 struct v4l2_rect *rect;
@@ -1583,7 +1584,7 @@ isif_pad_set_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1583} 1584}
1584 1585
1585/* 1586/*
1586 * isif_pad_get_crop() - get crop rectangle on pad 1587 * isif_pad_get_selection() - get crop rectangle on pad
1587 * @sd: VPFE isif V4L2 subdevice 1588 * @sd: VPFE isif V4L2 subdevice
1588 * @fh: V4L2 subdev file handle 1589 * @fh: V4L2 subdev file handle
1589 * @code: pointer to v4l2_subdev_mbus_code_enum structure 1590 * @code: pointer to v4l2_subdev_mbus_code_enum structure
@@ -1591,22 +1592,23 @@ isif_pad_set_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1591 * Return 0 on success, -EINVAL if pad is invalid 1592 * Return 0 on success, -EINVAL if pad is invalid
1592 */ 1593 */
1593static int 1594static int
1594isif_pad_get_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1595isif_pad_get_selection(struct v4l2_subdev *sd,
1595 struct v4l2_subdev_crop *crop) 1596 struct v4l2_subdev_fh *fh,
1597 struct v4l2_subdev_selection *sel)
1596{ 1598{
1597 struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd); 1599 struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd);
1598 1600
1599 /* check wether its a valid pad */ 1601 /* check whether it's a valid pad and target */
1600 if (crop->pad != ISIF_PAD_SINK) 1602 if (sel->pad != ISIF_PAD_SINK || sel->target != V4L2_SEL_TGT_CROP)
1601 return -EINVAL; 1603 return -EINVAL;
1602 1604
1603 if (crop->which == V4L2_SUBDEV_FORMAT_TRY) { 1605 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1604 struct v4l2_rect *rect; 1606 struct v4l2_rect *rect;
1605 1607
1606 rect = v4l2_subdev_get_try_crop(fh, ISIF_PAD_SINK); 1608 rect = v4l2_subdev_get_try_crop(fh, ISIF_PAD_SINK);
1607 memcpy(&crop->rect, rect, sizeof(*rect)); 1609 memcpy(&sel->r, rect, sizeof(*rect));
1608 } else { 1610 } else {
1609 crop->rect = vpfe_isif->crop; 1611 sel->r = vpfe_isif->crop;
1610 } 1612 }
1611 1613
1612 return 0; 1614 return 0;
@@ -1626,7 +1628,7 @@ isif_init_formats(struct v4l2_subdev *sd,
1626 struct v4l2_subdev_fh *fh) 1628 struct v4l2_subdev_fh *fh)
1627{ 1629{
1628 struct v4l2_subdev_format format; 1630 struct v4l2_subdev_format format;
1629 struct v4l2_subdev_crop crop; 1631 struct v4l2_subdev_selection sel;
1630 1632
1631 memset(&format, 0, sizeof(format)); 1633 memset(&format, 0, sizeof(format));
1632 format.pad = ISIF_PAD_SINK; 1634 format.pad = ISIF_PAD_SINK;
@@ -1644,12 +1646,13 @@ isif_init_formats(struct v4l2_subdev *sd,
1644 format.format.height = MAX_HEIGHT; 1646 format.format.height = MAX_HEIGHT;
1645 isif_set_format(sd, fh, &format); 1647 isif_set_format(sd, fh, &format);
1646 1648
1647 memset(&crop, 0, sizeof(crop)); 1649 memset(&sel, 0, sizeof(sel));
1648 crop.pad = ISIF_PAD_SINK; 1650 sel.pad = ISIF_PAD_SINK;
1649 crop.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; 1651 sel.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
1650 crop.rect.width = MAX_WIDTH; 1652 sel.target = V4L2_SEL_TGT_CROP;
1651 crop.rect.height = MAX_HEIGHT; 1653 sel.r.width = MAX_WIDTH;
1652 isif_pad_set_crop(sd, fh, &crop); 1654 sel.r.height = MAX_HEIGHT;
1655 isif_pad_set_selection(sd, fh, &sel);
1653 1656
1654 return 0; 1657 return 0;
1655} 1658}
@@ -1675,8 +1678,8 @@ static const struct v4l2_subdev_pad_ops isif_v4l2_pad_ops = {
1675 .enum_frame_size = isif_enum_frame_size, 1678 .enum_frame_size = isif_enum_frame_size,
1676 .get_fmt = isif_get_format, 1679 .get_fmt = isif_get_format,
1677 .set_fmt = isif_set_format, 1680 .set_fmt = isif_set_format,
1678 .set_crop = isif_pad_set_crop, 1681 .set_selection = isif_pad_set_selection,
1679 .get_crop = isif_pad_get_crop, 1682 .get_selection = isif_pad_get_selection,
1680}; 1683};
1681 1684
1682/* subdev operations */ 1685/* subdev operations */