aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-07-29 07:41:01 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-08-18 07:20:30 -0400
commit041649048149b3e4afa56428e6d1b081b9dd49f5 (patch)
treeceff2af394191a71851e644193858d21941f9ee2 /drivers/media/i2c
parente36552684e24f8b21569dec47381c36b50a7966b (diff)
[media] ths8200/ad9389b: use new dv_timings helpers
Simplify the code by using the new dv_timings helpers. 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/ad9389b.c108
-rw-r--r--drivers/media/i2c/ths8200.c55
2 files changed, 31 insertions, 132 deletions
diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 5295234deb51..7e68d8f9676f 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -635,95 +635,34 @@ static int ad9389b_s_stream(struct v4l2_subdev *sd, int enable)
635 return 0; 635 return 0;
636} 636}
637 637
638static const struct v4l2_dv_timings ad9389b_timings[] = { 638static const struct v4l2_dv_timings_cap ad9389b_timings_cap = {
639 V4L2_DV_BT_CEA_720X480P59_94, 639 .type = V4L2_DV_BT_656_1120,
640 V4L2_DV_BT_CEA_720X576P50, 640 .bt = {
641 V4L2_DV_BT_CEA_1280X720P24, 641 .max_width = 1920,
642 V4L2_DV_BT_CEA_1280X720P25, 642 .max_height = 1200,
643 V4L2_DV_BT_CEA_1280X720P30, 643 .min_pixelclock = 27000000,
644 V4L2_DV_BT_CEA_1280X720P50, 644 .max_pixelclock = 170000000,
645 V4L2_DV_BT_CEA_1280X720P60, 645 .standards = V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
646 V4L2_DV_BT_CEA_1920X1080P24, 646 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
647 V4L2_DV_BT_CEA_1920X1080P25, 647 .capabilities = V4L2_DV_BT_CAP_PROGRESSIVE |
648 V4L2_DV_BT_CEA_1920X1080P30, 648 V4L2_DV_BT_CAP_REDUCED_BLANKING | V4L2_DV_BT_CAP_CUSTOM,
649 V4L2_DV_BT_CEA_1920X1080P50, 649 },
650 V4L2_DV_BT_CEA_1920X1080P60,
651
652 V4L2_DV_BT_DMT_640X350P85,
653 V4L2_DV_BT_DMT_640X400P85,
654 V4L2_DV_BT_DMT_720X400P85,
655 V4L2_DV_BT_DMT_640X480P60,
656 V4L2_DV_BT_DMT_640X480P72,
657 V4L2_DV_BT_DMT_640X480P75,
658 V4L2_DV_BT_DMT_640X480P85,
659 V4L2_DV_BT_DMT_800X600P56,
660 V4L2_DV_BT_DMT_800X600P60,
661 V4L2_DV_BT_DMT_800X600P72,
662 V4L2_DV_BT_DMT_800X600P75,
663 V4L2_DV_BT_DMT_800X600P85,
664 V4L2_DV_BT_DMT_848X480P60,
665 V4L2_DV_BT_DMT_1024X768P60,
666 V4L2_DV_BT_DMT_1024X768P70,
667 V4L2_DV_BT_DMT_1024X768P75,
668 V4L2_DV_BT_DMT_1024X768P85,
669 V4L2_DV_BT_DMT_1152X864P75,
670 V4L2_DV_BT_DMT_1280X768P60_RB,
671 V4L2_DV_BT_DMT_1280X768P60,
672 V4L2_DV_BT_DMT_1280X768P75,
673 V4L2_DV_BT_DMT_1280X768P85,
674 V4L2_DV_BT_DMT_1280X800P60_RB,
675 V4L2_DV_BT_DMT_1280X800P60,
676 V4L2_DV_BT_DMT_1280X800P75,
677 V4L2_DV_BT_DMT_1280X800P85,
678 V4L2_DV_BT_DMT_1280X960P60,
679 V4L2_DV_BT_DMT_1280X960P85,
680 V4L2_DV_BT_DMT_1280X1024P60,
681 V4L2_DV_BT_DMT_1280X1024P75,
682 V4L2_DV_BT_DMT_1280X1024P85,
683 V4L2_DV_BT_DMT_1360X768P60,
684 V4L2_DV_BT_DMT_1400X1050P60_RB,
685 V4L2_DV_BT_DMT_1400X1050P60,
686 V4L2_DV_BT_DMT_1400X1050P75,
687 V4L2_DV_BT_DMT_1400X1050P85,
688 V4L2_DV_BT_DMT_1440X900P60_RB,
689 V4L2_DV_BT_DMT_1440X900P60,
690 V4L2_DV_BT_DMT_1600X1200P60,
691 V4L2_DV_BT_DMT_1680X1050P60_RB,
692 V4L2_DV_BT_DMT_1680X1050P60,
693 V4L2_DV_BT_DMT_1792X1344P60,
694 V4L2_DV_BT_DMT_1856X1392P60,
695 V4L2_DV_BT_DMT_1920X1200P60_RB,
696 V4L2_DV_BT_DMT_1366X768P60,
697 V4L2_DV_BT_DMT_1920X1080P60,
698 {},
699}; 650};
700 651
701static int ad9389b_s_dv_timings(struct v4l2_subdev *sd, 652static int ad9389b_s_dv_timings(struct v4l2_subdev *sd,
702 struct v4l2_dv_timings *timings) 653 struct v4l2_dv_timings *timings)
703{ 654{
704 struct ad9389b_state *state = get_ad9389b_state(sd); 655 struct ad9389b_state *state = get_ad9389b_state(sd);
705 int i;
706 656
707 v4l2_dbg(1, debug, sd, "%s:\n", __func__); 657 v4l2_dbg(1, debug, sd, "%s:\n", __func__);
708 658
709 /* quick sanity check */ 659 /* quick sanity check */
710 if (timings->type != V4L2_DV_BT_656_1120) 660 if (!v4l2_dv_valid_timings(timings, &ad9389b_timings_cap))
711 return -EINVAL;
712
713 if (timings->bt.interlaced)
714 return -EINVAL;
715 if (timings->bt.pixelclock < 27000000 ||
716 timings->bt.pixelclock > 170000000)
717 return -EINVAL; 661 return -EINVAL;
718 662
719 /* Fill the optional fields .standards and .flags in struct v4l2_dv_timings 663 /* Fill the optional fields .standards and .flags in struct v4l2_dv_timings
720 if the format is listed in ad9389b_timings[] */ 664 if the format is one of the CEA or DMT timings. */
721 for (i = 0; ad9389b_timings[i].bt.width; i++) { 665 v4l2_find_dv_timings_cap(timings, &ad9389b_timings_cap, 0);
722 if (v4l_match_dv_timings(timings, &ad9389b_timings[i], 0)) {
723 *timings = ad9389b_timings[i];
724 break;
725 }
726 }
727 666
728 timings->bt.flags &= ~V4L2_DV_FL_REDUCED_FPS; 667 timings->bt.flags &= ~V4L2_DV_FL_REDUCED_FPS;
729 668
@@ -761,26 +700,13 @@ static int ad9389b_g_dv_timings(struct v4l2_subdev *sd,
761static int ad9389b_enum_dv_timings(struct v4l2_subdev *sd, 700static int ad9389b_enum_dv_timings(struct v4l2_subdev *sd,
762 struct v4l2_enum_dv_timings *timings) 701 struct v4l2_enum_dv_timings *timings)
763{ 702{
764 if (timings->index >= ARRAY_SIZE(ad9389b_timings)) 703 return v4l2_enum_dv_timings_cap(timings, &ad9389b_timings_cap);
765 return -EINVAL;
766
767 memset(timings->reserved, 0, sizeof(timings->reserved));
768 timings->timings = ad9389b_timings[timings->index];
769 return 0;
770} 704}
771 705
772static int ad9389b_dv_timings_cap(struct v4l2_subdev *sd, 706static int ad9389b_dv_timings_cap(struct v4l2_subdev *sd,
773 struct v4l2_dv_timings_cap *cap) 707 struct v4l2_dv_timings_cap *cap)
774{ 708{
775 cap->type = V4L2_DV_BT_656_1120; 709 *cap = ad9389b_timings_cap;
776 cap->bt.max_width = 1920;
777 cap->bt.max_height = 1200;
778 cap->bt.min_pixelclock = 27000000;
779 cap->bt.max_pixelclock = 170000000;
780 cap->bt.standards = V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
781 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT;
782 cap->bt.capabilities = V4L2_DV_BT_CAP_PROGRESSIVE |
783 V4L2_DV_BT_CAP_REDUCED_BLANKING | V4L2_DV_BT_CAP_CUSTOM;
784 return 0; 710 return 0;
785} 711}
786 712
diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c
index 28932e9c1f08..7a60a8fda5df 100644
--- a/drivers/media/i2c/ths8200.c
+++ b/drivers/media/i2c/ths8200.c
@@ -44,18 +44,16 @@ struct ths8200_state {
44 struct v4l2_dv_timings dv_timings; 44 struct v4l2_dv_timings dv_timings;
45}; 45};
46 46
47static const struct v4l2_dv_timings ths8200_timings[] = { 47static const struct v4l2_dv_timings_cap ths8200_timings_cap = {
48 V4L2_DV_BT_CEA_720X480P59_94, 48 .type = V4L2_DV_BT_656_1120,
49 V4L2_DV_BT_CEA_1280X720P24, 49 .bt = {
50 V4L2_DV_BT_CEA_1280X720P25, 50 .max_width = 1920,
51 V4L2_DV_BT_CEA_1280X720P30, 51 .max_height = 1080,
52 V4L2_DV_BT_CEA_1280X720P50, 52 .min_pixelclock = 27000000,
53 V4L2_DV_BT_CEA_1280X720P60, 53 .max_pixelclock = 148500000,
54 V4L2_DV_BT_CEA_1920X1080P24, 54 .standards = V4L2_DV_BT_STD_CEA861,
55 V4L2_DV_BT_CEA_1920X1080P25, 55 .capabilities = V4L2_DV_BT_CAP_PROGRESSIVE,
56 V4L2_DV_BT_CEA_1920X1080P30, 56 },
57 V4L2_DV_BT_CEA_1920X1080P50,
58 V4L2_DV_BT_CEA_1920X1080P60,
59}; 57};
60 58
61static inline struct ths8200_state *to_state(struct v4l2_subdev *sd) 59static inline struct ths8200_state *to_state(struct v4l2_subdev *sd)
@@ -411,25 +409,13 @@ static int ths8200_s_dv_timings(struct v4l2_subdev *sd,
411 struct v4l2_dv_timings *timings) 409 struct v4l2_dv_timings *timings)
412{ 410{
413 struct ths8200_state *state = to_state(sd); 411 struct ths8200_state *state = to_state(sd);
414 int i;
415 412
416 v4l2_dbg(1, debug, sd, "%s:\n", __func__); 413 v4l2_dbg(1, debug, sd, "%s:\n", __func__);
417 414
418 if (timings->type != V4L2_DV_BT_656_1120) 415 if (!v4l2_dv_valid_timings(timings, &ths8200_timings_cap))
419 return -EINVAL; 416 return -EINVAL;
420 417
421 /* TODO Support interlaced formats */ 418 if (!v4l2_find_dv_timings_cap(timings, &ths8200_timings_cap, 10)) {
422 if (timings->bt.interlaced) {
423 v4l2_dbg(1, debug, sd, "TODO Support interlaced formats\n");
424 return -EINVAL;
425 }
426
427 for (i = 0; i < ARRAY_SIZE(ths8200_timings); i++) {
428 if (v4l_match_dv_timings(&ths8200_timings[i], timings, 10))
429 break;
430 }
431
432 if (i == ARRAY_SIZE(ths8200_timings)) {
433 v4l2_dbg(1, debug, sd, "Unsupported format\n"); 419 v4l2_dbg(1, debug, sd, "Unsupported format\n");
434 return -EINVAL; 420 return -EINVAL;
435 } 421 }
@@ -459,26 +445,13 @@ static int ths8200_g_dv_timings(struct v4l2_subdev *sd,
459static int ths8200_enum_dv_timings(struct v4l2_subdev *sd, 445static int ths8200_enum_dv_timings(struct v4l2_subdev *sd,
460 struct v4l2_enum_dv_timings *timings) 446 struct v4l2_enum_dv_timings *timings)
461{ 447{
462 /* Check requested format index is within range */ 448 return v4l2_enum_dv_timings_cap(timings, &ths8200_timings_cap);
463 if (timings->index >= ARRAY_SIZE(ths8200_timings))
464 return -EINVAL;
465
466 timings->timings = ths8200_timings[timings->index];
467
468 return 0;
469} 449}
470 450
471static int ths8200_dv_timings_cap(struct v4l2_subdev *sd, 451static int ths8200_dv_timings_cap(struct v4l2_subdev *sd,
472 struct v4l2_dv_timings_cap *cap) 452 struct v4l2_dv_timings_cap *cap)
473{ 453{
474 cap->type = V4L2_DV_BT_656_1120; 454 *cap = ths8200_timings_cap;
475 cap->bt.max_width = 1920;
476 cap->bt.max_height = 1080;
477 cap->bt.min_pixelclock = 27000000;
478 cap->bt.max_pixelclock = 148500000;
479 cap->bt.standards = V4L2_DV_BT_STD_CEA861;
480 cap->bt.capabilities = V4L2_DV_BT_CAP_PROGRESSIVE;
481
482 return 0; 455 return 0;
483} 456}
484 457