mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 18:43:33 +02:00
media: i2c: ov5647: switch to {enable,disable}_streams
Switch from s_stream to enable_streams and disable_streams callbacks. Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tarang Raval <tarang.raval@siliconsignals.io> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
parent
ebcb6cafd1
commit
98cf5594c2
|
|
@ -510,23 +510,42 @@ static int ov5647_set_mode(struct v4l2_subdev *sd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ov5647_stream_on(struct v4l2_subdev *sd)
|
||||
static int ov5647_stream_stop(struct ov5647 *sensor)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
cci_write(sensor->regmap, OV5647_REG_MIPI_CTRL00,
|
||||
MIPI_CTRL00_CLOCK_LANE_GATE | MIPI_CTRL00_BUS_IDLE |
|
||||
MIPI_CTRL00_CLOCK_LANE_DISABLE, &ret);
|
||||
cci_write(sensor->regmap, OV5647_REG_FRAME_OFF_NUMBER, 0x0f, &ret);
|
||||
cci_write(sensor->regmap, OV5640_REG_PAD_OUT, 0x01, &ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ov5647_enable_streams(struct v4l2_subdev *sd,
|
||||
struct v4l2_subdev_state *state, u32 pad,
|
||||
u64 streams_mask)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct ov5647 *sensor = to_sensor(sd);
|
||||
u8 val = MIPI_CTRL00_BUS_IDLE;
|
||||
int ret;
|
||||
|
||||
ret = pm_runtime_resume_and_get(&client->dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = ov5647_set_mode(sd);
|
||||
if (ret) {
|
||||
dev_err(&client->dev, "Failed to program sensor mode: %d\n", ret);
|
||||
return ret;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Apply customized values from user when stream starts. */
|
||||
ret = __v4l2_ctrl_handler_setup(sd->ctrl_handler);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto done;
|
||||
|
||||
if (sensor->clock_ncont)
|
||||
val |= MIPI_CTRL00_CLOCK_LANE_GATE |
|
||||
|
|
@ -536,19 +555,24 @@ static int ov5647_stream_on(struct v4l2_subdev *sd)
|
|||
cci_write(sensor->regmap, OV5647_REG_FRAME_OFF_NUMBER, 0x00, &ret);
|
||||
cci_write(sensor->regmap, OV5640_REG_PAD_OUT, 0x00, &ret);
|
||||
|
||||
done:
|
||||
if (ret)
|
||||
pm_runtime_put(&client->dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ov5647_stream_off(struct v4l2_subdev *sd)
|
||||
static int ov5647_disable_streams(struct v4l2_subdev *sd,
|
||||
struct v4l2_subdev_state *state, u32 pad,
|
||||
u64 streams_mask)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct ov5647 *sensor = to_sensor(sd);
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
cci_write(sensor->regmap, OV5647_REG_MIPI_CTRL00,
|
||||
MIPI_CTRL00_CLOCK_LANE_GATE | MIPI_CTRL00_BUS_IDLE |
|
||||
MIPI_CTRL00_CLOCK_LANE_DISABLE, &ret);
|
||||
cci_write(sensor->regmap, OV5647_REG_FRAME_OFF_NUMBER, 0x0f, &ret);
|
||||
cci_write(sensor->regmap, OV5640_REG_PAD_OUT, 0x01, &ret);
|
||||
ret = ov5647_stream_stop(sensor);
|
||||
|
||||
pm_runtime_put(&client->dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -588,7 +612,7 @@ static int ov5647_power_on(struct device *dev)
|
|||
}
|
||||
|
||||
/* Stream off to coax lanes into LP-11 state. */
|
||||
ret = ov5647_stream_off(&sensor->sd);
|
||||
ret = ov5647_stream_stop(sensor);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "camera not available, check power\n");
|
||||
goto error_clk_disable;
|
||||
|
|
@ -682,47 +706,8 @@ __ov5647_get_pad_crop(struct ov5647 *ov5647,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int ov5647_s_stream(struct v4l2_subdev *sd, int enable)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct v4l2_subdev_state *state;
|
||||
int ret;
|
||||
|
||||
state = v4l2_subdev_lock_and_get_active_state(sd);
|
||||
|
||||
if (enable) {
|
||||
ret = pm_runtime_resume_and_get(&client->dev);
|
||||
if (ret < 0)
|
||||
goto error_unlock;
|
||||
|
||||
ret = ov5647_stream_on(sd);
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "stream start failed: %d\n", ret);
|
||||
goto error_pm;
|
||||
}
|
||||
} else {
|
||||
ret = ov5647_stream_off(sd);
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "stream stop failed: %d\n", ret);
|
||||
goto error_pm;
|
||||
}
|
||||
pm_runtime_put(&client->dev);
|
||||
}
|
||||
|
||||
v4l2_subdev_unlock_state(state);
|
||||
|
||||
return 0;
|
||||
|
||||
error_pm:
|
||||
pm_runtime_put(&client->dev);
|
||||
error_unlock:
|
||||
v4l2_subdev_unlock_state(state);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct v4l2_subdev_video_ops ov5647_subdev_video_ops = {
|
||||
.s_stream = ov5647_s_stream,
|
||||
.s_stream = v4l2_subdev_s_stream_helper,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -892,6 +877,8 @@ static const struct v4l2_subdev_pad_ops ov5647_subdev_pad_ops = {
|
|||
.set_fmt = ov5647_set_pad_fmt,
|
||||
.get_fmt = ov5647_get_pad_fmt,
|
||||
.get_selection = ov5647_get_selection,
|
||||
.enable_streams = ov5647_enable_streams,
|
||||
.disable_streams = ov5647_disable_streams,
|
||||
};
|
||||
|
||||
static const struct v4l2_subdev_ops ov5647_subdev_ops = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user