Commit 99adeeb6 authored by Dafna Hirschfeld's avatar Dafna Hirschfeld Committed by Mauro Carvalho Chehab

media: staging: rkisp1: add serialization to the isp subdev ops

For subdevices drivers, the drivers themself are responsible
for serializing their operations.
This patch adds serialization to the isp subdevice.
Signed-off-by: default avatarDafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: default avatarHelen Koike <helen.koike@collabora.com>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 129f757c
...@@ -96,6 +96,7 @@ struct rkisp1_sensor_async { ...@@ -96,6 +96,7 @@ struct rkisp1_sensor_async {
* @sink_crop: crop for sink pad * @sink_crop: crop for sink pad
* @src_fmt: output format * @src_fmt: output format
* @src_crop: output size * @src_crop: output size
* @ops_lock: ops serialization
* *
* @is_dphy_errctrl_disabled : if dphy errctrl is disabled (avoid endless interrupt) * @is_dphy_errctrl_disabled : if dphy errctrl is disabled (avoid endless interrupt)
* @frame_sequence: used to synchronize frame_id between video devices. * @frame_sequence: used to synchronize frame_id between video devices.
...@@ -107,6 +108,7 @@ struct rkisp1_isp { ...@@ -107,6 +108,7 @@ struct rkisp1_isp {
struct v4l2_subdev_pad_config pad_cfg[RKISP1_ISP_PAD_MAX]; struct v4l2_subdev_pad_config pad_cfg[RKISP1_ISP_PAD_MAX];
const struct rkisp1_isp_mbus_info *sink_fmt; const struct rkisp1_isp_mbus_info *sink_fmt;
const struct rkisp1_isp_mbus_info *src_fmt; const struct rkisp1_isp_mbus_info *src_fmt;
struct mutex ops_lock;
bool is_dphy_errctrl_disabled; bool is_dphy_errctrl_disabled;
atomic_t frame_sequence; atomic_t frame_sequence;
}; };
......
...@@ -791,7 +791,9 @@ static int rkisp1_isp_get_fmt(struct v4l2_subdev *sd, ...@@ -791,7 +791,9 @@ static int rkisp1_isp_get_fmt(struct v4l2_subdev *sd,
{ {
struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd); struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
mutex_lock(&isp->ops_lock);
fmt->format = *rkisp1_isp_get_pad_fmt(isp, cfg, fmt->pad, fmt->which); fmt->format = *rkisp1_isp_get_pad_fmt(isp, cfg, fmt->pad, fmt->which);
mutex_unlock(&isp->ops_lock);
return 0; return 0;
} }
...@@ -801,6 +803,7 @@ static int rkisp1_isp_set_fmt(struct v4l2_subdev *sd, ...@@ -801,6 +803,7 @@ static int rkisp1_isp_set_fmt(struct v4l2_subdev *sd,
{ {
struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd); struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
mutex_lock(&isp->ops_lock);
if (fmt->pad == RKISP1_ISP_PAD_SINK_VIDEO) if (fmt->pad == RKISP1_ISP_PAD_SINK_VIDEO)
rkisp1_isp_set_sink_fmt(isp, cfg, &fmt->format, fmt->which); rkisp1_isp_set_sink_fmt(isp, cfg, &fmt->format, fmt->which);
else if (fmt->pad == RKISP1_ISP_PAD_SOURCE_VIDEO) else if (fmt->pad == RKISP1_ISP_PAD_SOURCE_VIDEO)
...@@ -809,6 +812,7 @@ static int rkisp1_isp_set_fmt(struct v4l2_subdev *sd, ...@@ -809,6 +812,7 @@ static int rkisp1_isp_set_fmt(struct v4l2_subdev *sd,
fmt->format = *rkisp1_isp_get_pad_fmt(isp, cfg, fmt->pad, fmt->format = *rkisp1_isp_get_pad_fmt(isp, cfg, fmt->pad,
fmt->which); fmt->which);
mutex_unlock(&isp->ops_lock);
return 0; return 0;
} }
...@@ -817,11 +821,13 @@ static int rkisp1_isp_get_selection(struct v4l2_subdev *sd, ...@@ -817,11 +821,13 @@ static int rkisp1_isp_get_selection(struct v4l2_subdev *sd,
struct v4l2_subdev_selection *sel) struct v4l2_subdev_selection *sel)
{ {
struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd); struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
int ret = 0;
if (sel->pad != RKISP1_ISP_PAD_SOURCE_VIDEO && if (sel->pad != RKISP1_ISP_PAD_SOURCE_VIDEO &&
sel->pad != RKISP1_ISP_PAD_SINK_VIDEO) sel->pad != RKISP1_ISP_PAD_SINK_VIDEO)
return -EINVAL; return -EINVAL;
mutex_lock(&isp->ops_lock);
switch (sel->target) { switch (sel->target) {
case V4L2_SEL_TGT_CROP_BOUNDS: case V4L2_SEL_TGT_CROP_BOUNDS:
if (sel->pad == RKISP1_ISP_PAD_SINK_VIDEO) { if (sel->pad == RKISP1_ISP_PAD_SINK_VIDEO) {
...@@ -844,10 +850,10 @@ static int rkisp1_isp_get_selection(struct v4l2_subdev *sd, ...@@ -844,10 +850,10 @@ static int rkisp1_isp_get_selection(struct v4l2_subdev *sd,
sel->which); sel->which);
break; break;
default: default:
return -EINVAL; ret = -EINVAL;
} }
mutex_unlock(&isp->ops_lock);
return 0; return ret;
} }
static int rkisp1_isp_set_selection(struct v4l2_subdev *sd, static int rkisp1_isp_set_selection(struct v4l2_subdev *sd,
...@@ -857,21 +863,23 @@ static int rkisp1_isp_set_selection(struct v4l2_subdev *sd, ...@@ -857,21 +863,23 @@ static int rkisp1_isp_set_selection(struct v4l2_subdev *sd,
struct rkisp1_device *rkisp1 = struct rkisp1_device *rkisp1 =
container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev); container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev);
struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd); struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
int ret = 0;
if (sel->target != V4L2_SEL_TGT_CROP) if (sel->target != V4L2_SEL_TGT_CROP)
return -EINVAL; return -EINVAL;
dev_dbg(rkisp1->dev, "%s: pad: %d sel(%d,%d)/%dx%d\n", __func__, dev_dbg(rkisp1->dev, "%s: pad: %d sel(%d,%d)/%dx%d\n", __func__,
sel->pad, sel->r.left, sel->r.top, sel->r.width, sel->r.height); sel->pad, sel->r.left, sel->r.top, sel->r.width, sel->r.height);
mutex_lock(&isp->ops_lock);
if (sel->pad == RKISP1_ISP_PAD_SINK_VIDEO) if (sel->pad == RKISP1_ISP_PAD_SINK_VIDEO)
rkisp1_isp_set_sink_crop(isp, cfg, &sel->r, sel->which); rkisp1_isp_set_sink_crop(isp, cfg, &sel->r, sel->which);
else if (sel->pad == RKISP1_ISP_PAD_SOURCE_VIDEO) else if (sel->pad == RKISP1_ISP_PAD_SOURCE_VIDEO)
rkisp1_isp_set_src_crop(isp, cfg, &sel->r, sel->which); rkisp1_isp_set_src_crop(isp, cfg, &sel->r, sel->which);
else else
return -EINVAL; ret = -EINVAL;
return 0; mutex_unlock(&isp->ops_lock);
return ret;
} }
static int rkisp1_subdev_link_validate(struct media_link *link) static int rkisp1_subdev_link_validate(struct media_link *link)
...@@ -932,6 +940,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) ...@@ -932,6 +940,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable)
{ {
struct rkisp1_device *rkisp1 = struct rkisp1_device *rkisp1 =
container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev); container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev);
struct rkisp1_isp *isp = &rkisp1->isp;
struct v4l2_subdev *sensor_sd; struct v4l2_subdev *sensor_sd;
int ret = 0; int ret = 0;
...@@ -951,16 +960,19 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) ...@@ -951,16 +960,19 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable)
return -EINVAL; return -EINVAL;
atomic_set(&rkisp1->isp.frame_sequence, -1); atomic_set(&rkisp1->isp.frame_sequence, -1);
mutex_lock(&isp->ops_lock);
ret = rkisp1_config_cif(rkisp1); ret = rkisp1_config_cif(rkisp1);
if (ret) if (ret)
return ret; goto mutex_unlock;
ret = rkisp1_mipi_csi2_start(&rkisp1->isp, rkisp1->active_sensor); ret = rkisp1_mipi_csi2_start(&rkisp1->isp, rkisp1->active_sensor);
if (ret) if (ret)
return ret; goto mutex_unlock;
rkisp1_isp_start(rkisp1); rkisp1_isp_start(rkisp1);
mutex_unlock:
mutex_unlock(&isp->ops_lock);
return ret; return ret;
} }
...@@ -1020,6 +1032,7 @@ int rkisp1_isp_register(struct rkisp1_device *rkisp1, ...@@ -1020,6 +1032,7 @@ int rkisp1_isp_register(struct rkisp1_device *rkisp1,
isp->sink_fmt = rkisp1_isp_mbus_info_get(RKISP1_DEF_SINK_PAD_FMT); isp->sink_fmt = rkisp1_isp_mbus_info_get(RKISP1_DEF_SINK_PAD_FMT);
isp->src_fmt = rkisp1_isp_mbus_info_get(RKISP1_DEF_SRC_PAD_FMT); isp->src_fmt = rkisp1_isp_mbus_info_get(RKISP1_DEF_SRC_PAD_FMT);
mutex_init(&isp->ops_lock);
ret = media_entity_pads_init(&sd->entity, RKISP1_ISP_PAD_MAX, pads); ret = media_entity_pads_init(&sd->entity, RKISP1_ISP_PAD_MAX, pads);
if (ret) if (ret)
return ret; return ret;
......
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