Skip to content

Commit c43875f

Browse files
committed
[media] tvp5150: replace MEDIA_ENT_F_CONN_TEST by a control
MEDIA_ENT_F_CONN_TEST is not really a connector, it is actually a signal generator. Also, as other drivers use the V4L2_CID_TEST_PATTERN control for signal generators, let's change the driver accordingly. Tested with Terratec Grabster AV350. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
1 parent 22d50e9 commit c43875f

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

drivers/media/i2c/tvp5150.c

+28-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* tvp5150 - Texas Instruments TVP5150A/AM1 video decoder driver
2+
* tvp5150 - Texas Instruments TVP5150A/AM1 and TVP5151 video decoder driver
33
*
44
* Copyright (c) 2005,2006 Mauro Carvalho Chehab (mchehab@infradead.org)
55
* This code is placed under the terms of the GNU General Public License v2
@@ -27,7 +27,7 @@
2727
#define TVP5150_MAX_CROP_TOP 127
2828
#define TVP5150_CROP_SHIFT 2
2929

30-
MODULE_DESCRIPTION("Texas Instruments TVP5150A video decoder driver");
30+
MODULE_DESCRIPTION("Texas Instruments TVP5150A/TVP5150AM1/TVP5151 video decoder driver");
3131
MODULE_AUTHOR("Mauro Carvalho Chehab");
3232
MODULE_LICENSE("GPL");
3333

@@ -259,8 +259,12 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd)
259259
int input = 0;
260260
int val;
261261

262-
if ((decoder->output & TVP5150_BLACK_SCREEN) || !decoder->enable)
263-
input = 8;
262+
/* Only tvp5150am1 and tvp5151 have signal generator support */
263+
if ((decoder->dev_id == 0x5150 && decoder->rom_ver == 0x0400) ||
264+
(decoder->dev_id == 0x5151 && decoder->rom_ver == 0x0100)) {
265+
if (!decoder->enable)
266+
input = 8;
267+
}
264268

265269
switch (decoder->input) {
266270
case TVP5150_COMPOSITE1:
@@ -795,6 +799,7 @@ static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
795799
static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
796800
{
797801
struct v4l2_subdev *sd = to_sd(ctrl);
802+
struct tvp5150 *decoder = to_tvp5150(sd);
798803

799804
switch (ctrl->id) {
800805
case V4L2_CID_BRIGHTNESS:
@@ -808,6 +813,9 @@ static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
808813
return 0;
809814
case V4L2_CID_HUE:
810815
tvp5150_write(sd, TVP5150_HUE_CTL, ctrl->val);
816+
case V4L2_CID_TEST_PATTERN:
817+
decoder->enable = ctrl->val ? false : true;
818+
tvp5150_selmux(sd);
811819
return 0;
812820
}
813821
return -EINVAL;
@@ -1022,15 +1030,6 @@ static int tvp5150_link_setup(struct media_entity *entity,
10221030

10231031
decoder->input = i;
10241032

1025-
/* Only tvp5150am1 and tvp5151 have signal generator support */
1026-
if ((decoder->dev_id == 0x5150 && decoder->rom_ver == 0x0400) ||
1027-
(decoder->dev_id == 0x5151 && decoder->rom_ver == 0x0100)) {
1028-
decoder->output = (i == TVP5150_GENERATOR ?
1029-
TVP5150_BLACK_SCREEN : TVP5150_NORMAL);
1030-
} else {
1031-
decoder->output = TVP5150_NORMAL;
1032-
}
1033-
10341033
tvp5150_selmux(sd);
10351034
#endif
10361035

@@ -1074,6 +1073,12 @@ static int tvp5150_s_routing(struct v4l2_subdev *sd,
10741073

10751074
decoder->input = input;
10761075
decoder->output = output;
1076+
1077+
if (output == TVP5150_BLACK_SCREEN)
1078+
decoder->enable = false;
1079+
else
1080+
decoder->enable = true;
1081+
10771082
tvp5150_selmux(sd);
10781083
return 0;
10791084
}
@@ -1405,9 +1410,6 @@ static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
14051410
case TVP5150_SVIDEO:
14061411
input->function = MEDIA_ENT_F_CONN_SVIDEO;
14071412
break;
1408-
case TVP5150_GENERATOR:
1409-
input->function = MEDIA_ENT_F_CONN_TEST;
1410-
break;
14111413
}
14121414

14131415
input->flags = MEDIA_ENT_FL_CONNECTOR;
@@ -1431,6 +1433,11 @@ static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
14311433
return ret;
14321434
}
14331435

1436+
static const char * const tvp5150_test_patterns[2] = {
1437+
"Disabled",
1438+
"Black screen"
1439+
};
1440+
14341441
static int tvp5150_probe(struct i2c_client *c,
14351442
const struct i2c_device_id *id)
14361443
{
@@ -1488,7 +1495,7 @@ static int tvp5150_probe(struct i2c_client *c,
14881495

14891496
core->norm = V4L2_STD_ALL; /* Default is autodetect */
14901497
core->input = TVP5150_COMPOSITE1;
1491-
core->enable = 1;
1498+
core->enable = true;
14921499

14931500
v4l2_ctrl_handler_init(&core->hdl, 5);
14941501
v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
@@ -1502,6 +1509,10 @@ static int tvp5150_probe(struct i2c_client *c,
15021509
v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
15031510
V4L2_CID_PIXEL_RATE, 27000000,
15041511
27000000, 1, 27000000);
1512+
v4l2_ctrl_new_std_menu_items(&core->hdl, &tvp5150_ctrl_ops,
1513+
V4L2_CID_TEST_PATTERN,
1514+
ARRAY_SIZE(tvp5150_test_patterns),
1515+
0, 0, tvp5150_test_patterns);
15051516
sd->ctrl_handler = &core->hdl;
15061517
if (core->hdl.error) {
15071518
res = core->hdl.error;

include/dt-bindings/media/tvp5150.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
#define TVP5150_COMPOSITE0 0
2626
#define TVP5150_COMPOSITE1 1
2727
#define TVP5150_SVIDEO 2
28-
#define TVP5150_GENERATOR 3
2928

30-
#define TVP5150_INPUT_NUM 4
29+
#define TVP5150_INPUT_NUM 3
3130

3231
/* TVP5150 HW outputs */
3332
#define TVP5150_NORMAL 0

0 commit comments

Comments
 (0)