Commit 15695866 authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

media: tvp5150: fix standard autodetection

Make sure to not overwrite decoder->norm when setting the standard
in hardware, but only when instructed by V4L2 API calls.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarMarco Felsch <m.felsch@pengutronix.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent b440b733
...@@ -736,8 +736,6 @@ static int tvp5150_set_std(struct v4l2_subdev *sd, v4l2_std_id std) ...@@ -736,8 +736,6 @@ static int tvp5150_set_std(struct v4l2_subdev *sd, v4l2_std_id std)
struct tvp5150 *decoder = to_tvp5150(sd); struct tvp5150 *decoder = to_tvp5150(sd);
int fmt = 0; int fmt = 0;
decoder->norm = std;
/* First tests should be against specific std */ /* First tests should be against specific std */
if (std == V4L2_STD_NTSC_443) { if (std == V4L2_STD_NTSC_443) {
...@@ -774,13 +772,37 @@ static int tvp5150_s_std(struct v4l2_subdev *sd, v4l2_std_id std) ...@@ -774,13 +772,37 @@ static int tvp5150_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
else else
decoder->rect.height = TVP5150_V_MAX_OTHERS; decoder->rect.height = TVP5150_V_MAX_OTHERS;
decoder->norm = std;
return tvp5150_set_std(sd, std); return tvp5150_set_std(sd, std);
} }
static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd)
{
int val = tvp5150_read(sd, TVP5150_STATUS_REG_5);
switch (val & 0x0F) {
case 0x01:
return V4L2_STD_NTSC;
case 0x03:
return V4L2_STD_PAL;
case 0x05:
return V4L2_STD_PAL_M;
case 0x07:
return V4L2_STD_PAL_N | V4L2_STD_PAL_Nc;
case 0x09:
return V4L2_STD_NTSC_443;
case 0xb:
return V4L2_STD_SECAM;
default:
return V4L2_STD_UNKNOWN;
}
}
static int tvp5150_reset(struct v4l2_subdev *sd, u32 val) static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
{ {
struct tvp5150 *decoder = to_tvp5150(sd); struct tvp5150 *decoder = to_tvp5150(sd);
v4l2_std_id std;
/* Initializes TVP5150 to its default values */ /* Initializes TVP5150 to its default values */
tvp5150_write_inittab(sd, tvp5150_init_default); tvp5150_write_inittab(sd, tvp5150_init_default);
...@@ -797,7 +819,13 @@ static int tvp5150_reset(struct v4l2_subdev *sd, u32 val) ...@@ -797,7 +819,13 @@ static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
/* Initialize image preferences */ /* Initialize image preferences */
v4l2_ctrl_handler_setup(&decoder->hdl); v4l2_ctrl_handler_setup(&decoder->hdl);
tvp5150_set_std(sd, decoder->norm); if (decoder->norm == V4L2_STD_ALL)
std = tvp5150_read_std(sd);
else
std = decoder->norm;
/* Disable autoswitch mode */
tvp5150_set_std(sd, std);
if (decoder->mbus_type == V4L2_MBUS_PARALLEL) if (decoder->mbus_type == V4L2_MBUS_PARALLEL)
/* 8-bit 4:2:2 YUV with discrete sync output */ /* 8-bit 4:2:2 YUV with discrete sync output */
...@@ -834,28 +862,6 @@ static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -834,28 +862,6 @@ static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
return -EINVAL; return -EINVAL;
} }
static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd)
{
int val = tvp5150_read(sd, TVP5150_STATUS_REG_5);
switch (val & 0x0F) {
case 0x01:
return V4L2_STD_NTSC;
case 0x03:
return V4L2_STD_PAL;
case 0x05:
return V4L2_STD_PAL_M;
case 0x07:
return V4L2_STD_PAL_N | V4L2_STD_PAL_Nc;
case 0x09:
return V4L2_STD_NTSC_443;
case 0xb:
return V4L2_STD_SECAM;
default:
return V4L2_STD_UNKNOWN;
}
}
static void tvp5150_set_default(v4l2_std_id std, struct v4l2_rect *crop) static void tvp5150_set_default(v4l2_std_id std, struct v4l2_rect *crop)
{ {
/* Default is no cropping */ /* Default is no cropping */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment