@@ -141,6 +141,10 @@ struct mt9v032 {
141
141
u16 chip_control ;
142
142
u16 aec_agc ;
143
143
u16 hblank ;
144
+ struct {
145
+ struct v4l2_ctrl * test_pattern ;
146
+ struct v4l2_ctrl * test_pattern_color ;
147
+ };
144
148
};
145
149
146
150
static struct mt9v032 * to_mt9v032 (struct v4l2_subdev * sd )
@@ -500,7 +504,7 @@ static int mt9v032_set_crop(struct v4l2_subdev *subdev,
500
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
505
509
static int mt9v032_s_ctrl (struct v4l2_ctrl * ctrl )
506
510
{
@@ -545,7 +549,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
545
549
break ;
546
550
547
551
case V4L2_CID_TEST_PATTERN :
548
- switch (ctrl -> val ) {
552
+ switch (mt9v032 -> test_pattern -> val ) {
549
553
case 0 :
550
554
data = 0 ;
551
555
break ;
@@ -562,13 +566,13 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
562
566
| MT9V032_TEST_PATTERN_ENABLE ;
563
567
break ;
564
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
571
| MT9V032_TEST_PATTERN_USE_DATA
567
572
| MT9V032_TEST_PATTERN_ENABLE
568
573
| MT9V032_TEST_PATTERN_FLIP ;
569
574
break ;
570
575
}
571
-
572
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
583
.s_ctrl = mt9v032_s_ctrl ,
580
584
};
581
585
582
- static const struct v4l2_ctrl_config mt9v032_ctrls [] = {
583
- {
584
- .ops = & mt9v032_ctrl_ops ,
585
- .id = V4L2_CID_TEST_PATTERN ,
586
- .type = V4L2_CTRL_TYPE_INTEGER ,
587
- .name = "Test pattern" ,
588
- .min = 0 ,
589
- .max = 1023 ,
590
- .step = 1 ,
591
- .def = 0 ,
592
- .flags = 0 ,
593
- }
586
+ static const char * const mt9v032_test_pattern_menu [] = {
587
+ "Disabled" ,
588
+ "Gray Vertical Shade" ,
589
+ "Gray Horizontal Shade" ,
590
+ "Gray Diagonal Shade" ,
591
+ "Plain" ,
592
+ };
593
+
594
+ static const struct v4l2_ctrl_config mt9v032_test_pattern_color = {
595
+ .ops = & mt9v032_ctrl_ops ,
596
+ .id = V4L2_CID_TEST_PATTERN_COLOR ,
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
751
mutex_init (& mt9v032 -> power_lock );
742
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
756
v4l2_ctrl_new_std (& mt9v032 -> ctrls , & mt9v032_ctrl_ops ,
747
757
V4L2_CID_AUTOGAIN , 0 , 1 , 1 , 1 );
@@ -763,6 +773,14 @@ static int mt9v032_probe(struct i2c_client *client,
763
773
V4L2_CID_VBLANK , MT9V032_VERTICAL_BLANKING_MIN ,
764
774
MT9V032_VERTICAL_BLANKING_MAX , 1 ,
765
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
785
mt9v032 -> pixel_rate =
768
786
v4l2_ctrl_new_std (& mt9v032 -> ctrls , & mt9v032_ctrl_ops ,
@@ -784,8 +802,6 @@ static int mt9v032_probe(struct i2c_client *client,
784
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
806
mt9v032 -> subdev .ctrl_handler = & mt9v032 -> ctrls ;
791
807
0 commit comments