Skip to content

Commit b28d701

Browse files
Lad, PrabhakarMauro Carvalho Chehab
Lad, Prabhakar
authored and
Mauro Carvalho Chehab
committed
[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 <[email protected]> Signed-off-by: Manjunath Hadli <[email protected]> Acked-by: Laurent Pinchart <[email protected]> Acked-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 117a711 commit b28d701

File tree

3 files changed

+55
-40
lines changed

3 files changed

+55
-40
lines changed

drivers/media/i2c/mt9p031.c

+5-14
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@ static int mt9p031_set_crop(struct v4l2_subdev *subdev,
574574
* V4L2 subdev control operations
575575
*/
576576

577-
#define V4L2_CID_TEST_PATTERN (V4L2_CID_USER_BASE | 0x1001)
578577
#define V4L2_CID_BLC_AUTO (V4L2_CID_USER_BASE | 0x1002)
579578
#define V4L2_CID_BLC_TARGET_LEVEL (V4L2_CID_USER_BASE | 0x1003)
580579
#define V4L2_CID_BLC_ANALOG_OFFSET (V4L2_CID_USER_BASE | 0x1004)
@@ -739,18 +738,6 @@ static const char * const mt9p031_test_pattern_menu[] = {
739738

740739
static const struct v4l2_ctrl_config mt9p031_ctrls[] = {
741740
{
742-
.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-
}, {
754741
.ops = &mt9p031_ctrl_ops,
755742
.id = V4L2_CID_BLC_AUTO,
756743
.type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -950,7 +937,7 @@ static int mt9p031_probe(struct i2c_client *client,
950937
mt9p031->model = did->driver_data;
951938
mt9p031->reset = -1;
952939

953-
v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 5);
940+
v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 6);
954941

955942
v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
956943
V4L2_CID_EXPOSURE, MT9P031_SHUTTER_WIDTH_MIN,
@@ -966,6 +953,10 @@ static int mt9p031_probe(struct i2c_client *client,
966953
v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
967954
V4L2_CID_PIXEL_RATE, pdata->target_freq,
968955
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);
969960

970961
for (i = 0; i < ARRAY_SIZE(mt9p031_ctrls); ++i)
971962
v4l2_ctrl_new_custom(&mt9p031->ctrls, &mt9p031_ctrls[i], NULL);

drivers/media/i2c/mt9t001.c

+15-7
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static int mt9t001_set_crop(struct v4l2_subdev *subdev,
371371
* V4L2 subdev control operations
372372
*/
373373

374-
#define V4L2_CID_TEST_PATTERN (V4L2_CID_USER_BASE | 0x1001)
374+
#define V4L2_CID_TEST_PATTERN_COLOR (V4L2_CID_USER_BASE | 0x1001)
375375
#define V4L2_CID_BLACK_LEVEL_AUTO (V4L2_CID_USER_BASE | 0x1002)
376376
#define V4L2_CID_BLACK_LEVEL_OFFSET (V4L2_CID_USER_BASE | 0x1003)
377377
#define V4L2_CID_BLACK_LEVEL_CALIBRATE (V4L2_CID_USER_BASE | 0x1004)
@@ -487,12 +487,11 @@ static int mt9t001_s_ctrl(struct v4l2_ctrl *ctrl)
487487
ctrl->val >> 16);
488488

489489
case V4L2_CID_TEST_PATTERN:
490-
ret = mt9t001_set_output_control(mt9t001,
490+
return mt9t001_set_output_control(mt9t001,
491491
ctrl->val ? 0 : MT9T001_OUTPUT_CONTROL_TEST_DATA,
492492
ctrl->val ? MT9T001_OUTPUT_CONTROL_TEST_DATA : 0);
493-
if (ret < 0)
494-
return ret;
495493

494+
case V4L2_CID_TEST_PATTERN_COLOR:
496495
return mt9t001_write(client, MT9T001_TEST_DATA, ctrl->val << 2);
497496

498497
case V4L2_CID_BLACK_LEVEL_AUTO:
@@ -533,12 +532,17 @@ static struct v4l2_ctrl_ops mt9t001_ctrl_ops = {
533532
.s_ctrl = mt9t001_s_ctrl,
534533
};
535534

535+
static const char * const mt9t001_test_pattern_menu[] = {
536+
"Disabled",
537+
"Enabled",
538+
};
539+
536540
static const struct v4l2_ctrl_config mt9t001_ctrls[] = {
537541
{
538542
.ops = &mt9t001_ctrl_ops,
539-
.id = V4L2_CID_TEST_PATTERN,
543+
.id = V4L2_CID_TEST_PATTERN_COLOR,
540544
.type = V4L2_CTRL_TYPE_INTEGER,
541-
.name = "Test pattern",
545+
.name = "Test Pattern Color",
542546
.min = 0,
543547
.max = 1023,
544548
.step = 1,
@@ -741,7 +745,7 @@ static int mt9t001_probe(struct i2c_client *client,
741745
return -ENOMEM;
742746

743747
v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) +
744-
ARRAY_SIZE(mt9t001_gains) + 3);
748+
ARRAY_SIZE(mt9t001_gains) + 4);
745749

746750
v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops,
747751
V4L2_CID_EXPOSURE, MT9T001_SHUTTER_WIDTH_MIN,
@@ -752,6 +756,10 @@ static int mt9t001_probe(struct i2c_client *client,
752756
v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops,
753757
V4L2_CID_PIXEL_RATE, pdata->ext_clk, pdata->ext_clk,
754758
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);
755763

756764
for (i = 0; i < ARRAY_SIZE(mt9t001_ctrls); ++i)
757765
v4l2_ctrl_new_custom(&mt9t001->ctrls, &mt9t001_ctrls[i], NULL);

drivers/media/i2c/mt9v032.c

+35-19
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ struct mt9v032 {
141141
u16 chip_control;
142142
u16 aec_agc;
143143
u16 hblank;
144+
struct {
145+
struct v4l2_ctrl *test_pattern;
146+
struct v4l2_ctrl *test_pattern_color;
147+
};
144148
};
145149

146150
static struct mt9v032 *to_mt9v032(struct v4l2_subdev *sd)
@@ -500,7 +504,7 @@ static int mt9v032_set_crop(struct v4l2_subdev *subdev,
500504
* V4L2 subdev control operations
501505
*/
502506

503-
#define V4L2_CID_TEST_PATTERN (V4L2_CID_USER_BASE | 0x1001)
507+
#define V4L2_CID_TEST_PATTERN_COLOR (V4L2_CID_USER_BASE | 0x1001)
504508

505509
static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
506510
{
@@ -545,7 +549,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
545549
break;
546550

547551
case V4L2_CID_TEST_PATTERN:
548-
switch (ctrl->val) {
552+
switch (mt9v032->test_pattern->val) {
549553
case 0:
550554
data = 0;
551555
break;
@@ -562,13 +566,13 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
562566
| MT9V032_TEST_PATTERN_ENABLE;
563567
break;
564568
default:
565-
data = (ctrl->val << MT9V032_TEST_PATTERN_DATA_SHIFT)
569+
data = (mt9v032->test_pattern_color->val <<
570+
MT9V032_TEST_PATTERN_DATA_SHIFT)
566571
| MT9V032_TEST_PATTERN_USE_DATA
567572
| MT9V032_TEST_PATTERN_ENABLE
568573
| MT9V032_TEST_PATTERN_FLIP;
569574
break;
570575
}
571-
572576
return mt9v032_write(client, MT9V032_TEST_PATTERN, data);
573577
}
574578

@@ -579,18 +583,24 @@ static struct v4l2_ctrl_ops mt9v032_ctrl_ops = {
579583
.s_ctrl = mt9v032_s_ctrl,
580584
};
581585

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,
594604
};
595605

596606
/* -----------------------------------------------------------------------------
@@ -741,7 +751,7 @@ static int mt9v032_probe(struct i2c_client *client,
741751
mutex_init(&mt9v032->power_lock);
742752
mt9v032->pdata = pdata;
743753

744-
v4l2_ctrl_handler_init(&mt9v032->ctrls, ARRAY_SIZE(mt9v032_ctrls) + 8);
754+
v4l2_ctrl_handler_init(&mt9v032->ctrls, 10);
745755

746756
v4l2_ctrl_new_std(&mt9v032->ctrls, &mt9v032_ctrl_ops,
747757
V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
@@ -763,6 +773,14 @@ static int mt9v032_probe(struct i2c_client *client,
763773
V4L2_CID_VBLANK, MT9V032_VERTICAL_BLANKING_MIN,
764774
MT9V032_VERTICAL_BLANKING_MAX, 1,
765775
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);
766784

767785
mt9v032->pixel_rate =
768786
v4l2_ctrl_new_std(&mt9v032->ctrls, &mt9v032_ctrl_ops,
@@ -784,8 +802,6 @@ static int mt9v032_probe(struct i2c_client *client,
784802
v4l2_ctrl_cluster(2, &mt9v032->link_freq);
785803
}
786804

787-
for (i = 0; i < ARRAY_SIZE(mt9v032_ctrls); ++i)
788-
v4l2_ctrl_new_custom(&mt9v032->ctrls, &mt9v032_ctrls[i], NULL);
789805

790806
mt9v032->subdev.ctrl_handler = &mt9v032->ctrls;
791807

0 commit comments

Comments
 (0)