aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorLad, Prabhakar <prabhakar.lad@ti.com>2012-09-25 08:35:43 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-05 20:49:32 -0400
commitb28d70176e9f05fb94256678b4ff5b3527e81b7f (patch)
treec97cca79efc860b95eaea6c726abe3db93342809 /drivers/media/i2c
parent117a711a2c37a0309a3e39fbd13486642b63453b (diff)
[media] media: mt9p031/mt9t001/mt9v032: use V4L2_CID_TEST_PATTERN for test pattern control
V4L2_CID_TEST_PATTERN is now a standard control. This patch replaces the user defined control for test pattern to make use of standard control V4L2_CID_TEST_PATTERN. Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com> Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r--drivers/media/i2c/mt9p031.c19
-rw-r--r--drivers/media/i2c/mt9t001.c22
-rw-r--r--drivers/media/i2c/mt9v032.c54
3 files changed, 55 insertions, 40 deletions
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 2c0f4077c491..e32833262d32 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -574,7 +574,6 @@ static int mt9p031_set_crop(struct v4l2_subdev *subdev,
574 * V4L2 subdev control operations 574 * V4L2 subdev control operations
575 */ 575 */
576 576
577#define V4L2_CID_TEST_PATTERN (V4L2_CID_USER_BASE | 0x1001)
578#define V4L2_CID_BLC_AUTO (V4L2_CID_USER_BASE | 0x1002) 577#define V4L2_CID_BLC_AUTO (V4L2_CID_USER_BASE | 0x1002)
579#define V4L2_CID_BLC_TARGET_LEVEL (V4L2_CID_USER_BASE | 0x1003) 578#define V4L2_CID_BLC_TARGET_LEVEL (V4L2_CID_USER_BASE | 0x1003)
580#define V4L2_CID_BLC_ANALOG_OFFSET (V4L2_CID_USER_BASE | 0x1004) 579#define V4L2_CID_BLC_ANALOG_OFFSET (V4L2_CID_USER_BASE | 0x1004)
@@ -740,18 +739,6 @@ static const char * const mt9p031_test_pattern_menu[] = {
740static const struct v4l2_ctrl_config mt9p031_ctrls[] = { 739static const struct v4l2_ctrl_config mt9p031_ctrls[] = {
741 { 740 {
742 .ops = &mt9p031_ctrl_ops, 741 .ops = &mt9p031_ctrl_ops,
743 .id = V4L2_CID_TEST_PATTERN,
744 .type = V4L2_CTRL_TYPE_MENU,
745 .name = "Test Pattern",
746 .min = 0,
747 .max = ARRAY_SIZE(mt9p031_test_pattern_menu) - 1,
748 .step = 0,
749 .def = 0,
750 .flags = 0,
751 .menu_skip_mask = 0,
752 .qmenu = mt9p031_test_pattern_menu,
753 }, {
754 .ops = &mt9p031_ctrl_ops,
755 .id = V4L2_CID_BLC_AUTO, 742 .id = V4L2_CID_BLC_AUTO,
756 .type = V4L2_CTRL_TYPE_BOOLEAN, 743 .type = V4L2_CTRL_TYPE_BOOLEAN,
757 .name = "BLC, Auto", 744 .name = "BLC, Auto",
@@ -950,7 +937,7 @@ static int mt9p031_probe(struct i2c_client *client,
950 mt9p031->model = did->driver_data; 937 mt9p031->model = did->driver_data;
951 mt9p031->reset = -1; 938 mt9p031->reset = -1;
952 939
953 v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 5); 940 v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 6);
954 941
955 v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops, 942 v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
956 V4L2_CID_EXPOSURE, MT9P031_SHUTTER_WIDTH_MIN, 943 V4L2_CID_EXPOSURE, MT9P031_SHUTTER_WIDTH_MIN,
@@ -966,6 +953,10 @@ static int mt9p031_probe(struct i2c_client *client,
966 v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops, 953 v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
967 V4L2_CID_PIXEL_RATE, pdata->target_freq, 954 V4L2_CID_PIXEL_RATE, pdata->target_freq,
968 pdata->target_freq, 1, pdata->target_freq); 955 pdata->target_freq, 1, pdata->target_freq);
956 v4l2_ctrl_new_std_menu_items(&mt9p031->ctrls, &mt9p031_ctrl_ops,
957 V4L2_CID_TEST_PATTERN,
958 ARRAY_SIZE(mt9p031_test_pattern_menu) - 1, 0,
959 0, mt9p031_test_pattern_menu);
969 960
970 for (i = 0; i < ARRAY_SIZE(mt9p031_ctrls); ++i) 961 for (i = 0; i < ARRAY_SIZE(mt9p031_ctrls); ++i)
971 v4l2_ctrl_new_custom(&mt9p031->ctrls, &mt9p031_ctrls[i], NULL); 962 v4l2_ctrl_new_custom(&mt9p031->ctrls, &mt9p031_ctrls[i], NULL);
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index 6d343adf891d..2e189d8b71bb 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -371,7 +371,7 @@ static int mt9t001_set_crop(struct v4l2_subdev *subdev,
371 * V4L2 subdev control operations 371 * V4L2 subdev control operations
372 */ 372 */
373 373
374#define V4L2_CID_TEST_PATTERN (V4L2_CID_USER_BASE | 0x1001) 374#define V4L2_CID_TEST_PATTERN_COLOR (V4L2_CID_USER_BASE | 0x1001)
375#define V4L2_CID_BLACK_LEVEL_AUTO (V4L2_CID_USER_BASE | 0x1002) 375#define V4L2_CID_BLACK_LEVEL_AUTO (V4L2_CID_USER_BASE | 0x1002)
376#define V4L2_CID_BLACK_LEVEL_OFFSET (V4L2_CID_USER_BASE | 0x1003) 376#define V4L2_CID_BLACK_LEVEL_OFFSET (V4L2_CID_USER_BASE | 0x1003)
377#define V4L2_CID_BLACK_LEVEL_CALIBRATE (V4L2_CID_USER_BASE | 0x1004) 377#define V4L2_CID_BLACK_LEVEL_CALIBRATE (V4L2_CID_USER_BASE | 0x1004)
@@ -487,12 +487,11 @@ static int mt9t001_s_ctrl(struct v4l2_ctrl *ctrl)
487 ctrl->val >> 16); 487 ctrl->val >> 16);
488 488
489 case V4L2_CID_TEST_PATTERN: 489 case V4L2_CID_TEST_PATTERN:
490 ret = mt9t001_set_output_control(mt9t001, 490 return mt9t001_set_output_control(mt9t001,
491 ctrl->val ? 0 : MT9T001_OUTPUT_CONTROL_TEST_DATA, 491 ctrl->val ? 0 : MT9T001_OUTPUT_CONTROL_TEST_DATA,
492 ctrl->val ? MT9T001_OUTPUT_CONTROL_TEST_DATA : 0); 492 ctrl->val ? MT9T001_OUTPUT_CONTROL_TEST_DATA : 0);
493 if (ret < 0)
494 return ret;
495 493
494 case V4L2_CID_TEST_PATTERN_COLOR:
496 return mt9t001_write(client, MT9T001_TEST_DATA, ctrl->val << 2); 495 return mt9t001_write(client, MT9T001_TEST_DATA, ctrl->val << 2);
497 496
498 case V4L2_CID_BLACK_LEVEL_AUTO: 497 case V4L2_CID_BLACK_LEVEL_AUTO:
@@ -533,12 +532,17 @@ static struct v4l2_ctrl_ops mt9t001_ctrl_ops = {
533 .s_ctrl = mt9t001_s_ctrl, 532 .s_ctrl = mt9t001_s_ctrl,
534}; 533};
535 534
535static const char * const mt9t001_test_pattern_menu[] = {
536 "Disabled",
537 "Enabled",
538};
539
536static const struct v4l2_ctrl_config mt9t001_ctrls[] = { 540static const struct v4l2_ctrl_config mt9t001_ctrls[] = {
537 { 541 {
538 .ops = &mt9t001_ctrl_ops, 542 .ops = &mt9t001_ctrl_ops,
539 .id = V4L2_CID_TEST_PATTERN, 543 .id = V4L2_CID_TEST_PATTERN_COLOR,
540 .type = V4L2_CTRL_TYPE_INTEGER, 544 .type = V4L2_CTRL_TYPE_INTEGER,
541 .name = "Test pattern", 545 .name = "Test Pattern Color",
542 .min = 0, 546 .min = 0,
543 .max = 1023, 547 .max = 1023,
544 .step = 1, 548 .step = 1,
@@ -741,7 +745,7 @@ static int mt9t001_probe(struct i2c_client *client,
741 return -ENOMEM; 745 return -ENOMEM;
742 746
743 v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) + 747 v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) +
744 ARRAY_SIZE(mt9t001_gains) + 3); 748 ARRAY_SIZE(mt9t001_gains) + 4);
745 749
746 v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, 750 v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops,
747 V4L2_CID_EXPOSURE, MT9T001_SHUTTER_WIDTH_MIN, 751 V4L2_CID_EXPOSURE, MT9T001_SHUTTER_WIDTH_MIN,
@@ -752,6 +756,10 @@ static int mt9t001_probe(struct i2c_client *client,
752 v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, 756 v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops,
753 V4L2_CID_PIXEL_RATE, pdata->ext_clk, pdata->ext_clk, 757 V4L2_CID_PIXEL_RATE, pdata->ext_clk, pdata->ext_clk,
754 1, pdata->ext_clk); 758 1, pdata->ext_clk);
759 v4l2_ctrl_new_std_menu_items(&mt9t001->ctrls, &mt9t001_ctrl_ops,
760 V4L2_CID_TEST_PATTERN,
761 ARRAY_SIZE(mt9t001_test_pattern_menu) - 1, 0,
762 0, mt9t001_test_pattern_menu);
755 763
756 for (i = 0; i < ARRAY_SIZE(mt9t001_ctrls); ++i) 764 for (i = 0; i < ARRAY_SIZE(mt9t001_ctrls); ++i)
757 v4l2_ctrl_new_custom(&mt9t001->ctrls, &mt9t001_ctrls[i], NULL); 765 v4l2_ctrl_new_custom(&mt9t001->ctrls, &mt9t001_ctrls[i], NULL);
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index e2177405dad2..3f356cb28256 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -141,6 +141,10 @@ struct mt9v032 {
141 u16 chip_control; 141 u16 chip_control;
142 u16 aec_agc; 142 u16 aec_agc;
143 u16 hblank; 143 u16 hblank;
144 struct {
145 struct v4l2_ctrl *test_pattern;
146 struct v4l2_ctrl *test_pattern_color;
147 };
144}; 148};
145 149
146static struct mt9v032 *to_mt9v032(struct v4l2_subdev *sd) 150static struct mt9v032 *to_mt9v032(struct v4l2_subdev *sd)
@@ -500,7 +504,7 @@ static int mt9v032_set_crop(struct v4l2_subdev *subdev,
500 * V4L2 subdev control operations 504 * V4L2 subdev control operations
501 */ 505 */
502 506
503#define V4L2_CID_TEST_PATTERN (V4L2_CID_USER_BASE | 0x1001) 507#define V4L2_CID_TEST_PATTERN_COLOR (V4L2_CID_USER_BASE | 0x1001)
504 508
505static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl) 509static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
506{ 510{
@@ -545,7 +549,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
545 break; 549 break;
546 550
547 case V4L2_CID_TEST_PATTERN: 551 case V4L2_CID_TEST_PATTERN:
548 switch (ctrl->val) { 552 switch (mt9v032->test_pattern->val) {
549 case 0: 553 case 0:
550 data = 0; 554 data = 0;
551 break; 555 break;
@@ -562,13 +566,13 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
562 | MT9V032_TEST_PATTERN_ENABLE; 566 | MT9V032_TEST_PATTERN_ENABLE;
563 break; 567 break;
564 default: 568 default:
565 data = (ctrl->val << MT9V032_TEST_PATTERN_DATA_SHIFT) 569 data = (mt9v032->test_pattern_color->val <<
570 MT9V032_TEST_PATTERN_DATA_SHIFT)
566 | MT9V032_TEST_PATTERN_USE_DATA 571 | MT9V032_TEST_PATTERN_USE_DATA
567 | MT9V032_TEST_PATTERN_ENABLE 572 | MT9V032_TEST_PATTERN_ENABLE
568 | MT9V032_TEST_PATTERN_FLIP; 573 | MT9V032_TEST_PATTERN_FLIP;
569 break; 574 break;
570 } 575 }
571
572 return mt9v032_write(client, MT9V032_TEST_PATTERN, data); 576 return mt9v032_write(client, MT9V032_TEST_PATTERN, data);
573 } 577 }
574 578
@@ -579,18 +583,24 @@ static struct v4l2_ctrl_ops mt9v032_ctrl_ops = {
579 .s_ctrl = mt9v032_s_ctrl, 583 .s_ctrl = mt9v032_s_ctrl,
580}; 584};
581 585
582static const struct v4l2_ctrl_config mt9v032_ctrls[] = { 586static const char * const mt9v032_test_pattern_menu[] = {
583 { 587 "Disabled",
584 .ops = &mt9v032_ctrl_ops, 588 "Gray Vertical Shade",
585 .id = V4L2_CID_TEST_PATTERN, 589 "Gray Horizontal Shade",
586 .type = V4L2_CTRL_TYPE_INTEGER, 590 "Gray Diagonal Shade",
587 .name = "Test pattern", 591 "Plain",
588 .min = 0, 592};
589 .max = 1023, 593
590 .step = 1, 594static const struct v4l2_ctrl_config mt9v032_test_pattern_color = {
591 .def = 0, 595 .ops = &mt9v032_ctrl_ops,
592 .flags = 0, 596 .id = V4L2_CID_TEST_PATTERN_COLOR,
593 } 597 .type = V4L2_CTRL_TYPE_INTEGER,
598 .name = "Test Pattern Color",
599 .min = 0,
600 .max = 1023,
601 .step = 1,
602 .def = 0,
603 .flags = 0,
594}; 604};
595 605
596/* ----------------------------------------------------------------------------- 606/* -----------------------------------------------------------------------------
@@ -741,7 +751,7 @@ static int mt9v032_probe(struct i2c_client *client,
741 mutex_init(&mt9v032->power_lock); 751 mutex_init(&mt9v032->power_lock);
742 mt9v032->pdata = pdata; 752 mt9v032->pdata = pdata;
743 753
744 v4l2_ctrl_handler_init(&mt9v032->ctrls, ARRAY_SIZE(mt9v032_ctrls) + 8); 754 v4l2_ctrl_handler_init(&mt9v032->ctrls, 10);
745 755
746 v4l2_ctrl_new_std(&mt9v032->ctrls, &mt9v032_ctrl_ops, 756 v4l2_ctrl_new_std(&mt9v032->ctrls, &mt9v032_ctrl_ops,
747 V4L2_CID_AUTOGAIN, 0, 1, 1, 1); 757 V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
@@ -763,6 +773,14 @@ static int mt9v032_probe(struct i2c_client *client,
763 V4L2_CID_VBLANK, MT9V032_VERTICAL_BLANKING_MIN, 773 V4L2_CID_VBLANK, MT9V032_VERTICAL_BLANKING_MIN,
764 MT9V032_VERTICAL_BLANKING_MAX, 1, 774 MT9V032_VERTICAL_BLANKING_MAX, 1,
765 MT9V032_VERTICAL_BLANKING_DEF); 775 MT9V032_VERTICAL_BLANKING_DEF);
776 mt9v032->test_pattern = v4l2_ctrl_new_std_menu_items(&mt9v032->ctrls,
777 &mt9v032_ctrl_ops, V4L2_CID_TEST_PATTERN,
778 ARRAY_SIZE(mt9v032_test_pattern_menu) - 1, 0, 0,
779 mt9v032_test_pattern_menu);
780 mt9v032->test_pattern_color = v4l2_ctrl_new_custom(&mt9v032->ctrls,
781 &mt9v032_test_pattern_color, NULL);
782
783 v4l2_ctrl_cluster(2, &mt9v032->test_pattern);
766 784
767 mt9v032->pixel_rate = 785 mt9v032->pixel_rate =
768 v4l2_ctrl_new_std(&mt9v032->ctrls, &mt9v032_ctrl_ops, 786 v4l2_ctrl_new_std(&mt9v032->ctrls, &mt9v032_ctrl_ops,
@@ -784,8 +802,6 @@ static int mt9v032_probe(struct i2c_client *client,
784 v4l2_ctrl_cluster(2, &mt9v032->link_freq); 802 v4l2_ctrl_cluster(2, &mt9v032->link_freq);
785 } 803 }
786 804
787 for (i = 0; i < ARRAY_SIZE(mt9v032_ctrls); ++i)
788 v4l2_ctrl_new_custom(&mt9v032->ctrls, &mt9v032_ctrls[i], NULL);
789 805
790 mt9v032->subdev.ctrl_handler = &mt9v032->ctrls; 806 mt9v032->subdev.ctrl_handler = &mt9v032->ctrls;
791 807