aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/mt9v032.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/i2c/mt9v032.c')
-rw-r--r--drivers/media/i2c/mt9v032.c54
1 files changed, 35 insertions, 19 deletions
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