Commit aff808e8 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] v4l: tvp5150: Reset device at probe time, not in get/set format handlers

The tvp5150 doesn't support format setting through the subdev pad API
and thus implements the set format handler as a get format operation.
The single handler, tvp5150_fill_fmt(), resets the device by calling
tvp5150_reset(). This causes malfunction as the device can be reset at
will, possibly from userspace when the subdev userspace API is enabled.

The reset call was added in commit ec2c4f3f ("[media] media:
tvp5150: Add mbus_fmt callbacks"), probably as an attempt to set the
device to a known state before detecting the current TV standard.
However, the get format handler doesn't access the hardware to get the
TV standard since commit 963ddc63 ("[media] media: tvp5150: Add
cropping support"). There is thus no need to reset the device when
getting the format.

However, removing the tvp5150_reset() from the get/set format handlers
results in the function not being called at all if the bridge driver
doesn't use the .reset() operation. The operation is nowadays abused and
shouldn't be used, so shouldn't expect bridge drivers to call it. To
make sure the device is properly initialize, move the reset call from
the format handlers to the probe function.

Cc: stable@vger.kernel.org # For Kernel 4.5 and upper
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 48775cb7
...@@ -861,8 +861,6 @@ static int tvp5150_fill_fmt(struct v4l2_subdev *sd, ...@@ -861,8 +861,6 @@ static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
f = &format->format; f = &format->format;
tvp5150_reset(sd, 0);
f->width = decoder->rect.width; f->width = decoder->rect.width;
f->height = decoder->rect.height / 2; f->height = decoder->rect.height / 2;
...@@ -1524,7 +1522,6 @@ static int tvp5150_probe(struct i2c_client *c, ...@@ -1524,7 +1522,6 @@ static int tvp5150_probe(struct i2c_client *c,
res = core->hdl.error; res = core->hdl.error;
goto err; goto err;
} }
v4l2_ctrl_handler_setup(&core->hdl);
/* Default is no cropping */ /* Default is no cropping */
core->rect.top = 0; core->rect.top = 0;
...@@ -1535,6 +1532,8 @@ static int tvp5150_probe(struct i2c_client *c, ...@@ -1535,6 +1532,8 @@ static int tvp5150_probe(struct i2c_client *c,
core->rect.left = 0; core->rect.left = 0;
core->rect.width = TVP5150_H_MAX; core->rect.width = TVP5150_H_MAX;
tvp5150_reset(sd, 0); /* Calls v4l2_ctrl_handler_setup() */
res = v4l2_async_register_subdev(sd); res = v4l2_async_register_subdev(sd);
if (res < 0) if (res < 0)
goto err; goto err;
......
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