|
@@ -67,10 +67,15 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
|
|
|
struct v4l2_subdev_pad_config *config;
|
|
|
struct v4l2_mbus_framefmt *format;
|
|
|
struct v4l2_rect *crop;
|
|
|
+ int ret = 0;
|
|
|
+
|
|
|
+ mutex_lock(&rwpf->entity.lock);
|
|
|
|
|
|
config = vsp1_entity_get_pad_config(&rwpf->entity, cfg, fmt->which);
|
|
|
- if (!config)
|
|
|
- return -EINVAL;
|
|
|
+ if (!config) {
|
|
|
+ ret = -EINVAL;
|
|
|
+ goto done;
|
|
|
+ }
|
|
|
|
|
|
/* Default to YUV if the requested format is not supported. */
|
|
|
if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 &&
|
|
@@ -85,7 +90,7 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
|
|
|
*/
|
|
|
format->code = fmt->format.code;
|
|
|
fmt->format = *format;
|
|
|
- return 0;
|
|
|
+ goto done;
|
|
|
}
|
|
|
|
|
|
format->code = fmt->format.code;
|
|
@@ -110,7 +115,9 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
|
|
|
RWPF_PAD_SOURCE);
|
|
|
*format = fmt->format;
|
|
|
|
|
|
- return 0;
|
|
|
+done:
|
|
|
+ mutex_unlock(&rwpf->entity.lock);
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
static int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
|
|
@@ -120,14 +127,19 @@ static int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
|
|
|
struct vsp1_rwpf *rwpf = to_rwpf(subdev);
|
|
|
struct v4l2_subdev_pad_config *config;
|
|
|
struct v4l2_mbus_framefmt *format;
|
|
|
+ int ret = 0;
|
|
|
|
|
|
/* Cropping is implemented on the sink pad. */
|
|
|
if (sel->pad != RWPF_PAD_SINK)
|
|
|
return -EINVAL;
|
|
|
|
|
|
+ mutex_lock(&rwpf->entity.lock);
|
|
|
+
|
|
|
config = vsp1_entity_get_pad_config(&rwpf->entity, cfg, sel->which);
|
|
|
- if (!config)
|
|
|
- return -EINVAL;
|
|
|
+ if (!config) {
|
|
|
+ ret = -EINVAL;
|
|
|
+ goto done;
|
|
|
+ }
|
|
|
|
|
|
switch (sel->target) {
|
|
|
case V4L2_SEL_TGT_CROP:
|
|
@@ -144,10 +156,13 @@ static int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- return -EINVAL;
|
|
|
+ ret = -EINVAL;
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
- return 0;
|
|
|
+done:
|
|
|
+ mutex_unlock(&rwpf->entity.lock);
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
|
|
@@ -158,6 +173,7 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
|
|
|
struct v4l2_subdev_pad_config *config;
|
|
|
struct v4l2_mbus_framefmt *format;
|
|
|
struct v4l2_rect *crop;
|
|
|
+ int ret = 0;
|
|
|
|
|
|
/* Cropping is implemented on the sink pad. */
|
|
|
if (sel->pad != RWPF_PAD_SINK)
|
|
@@ -166,9 +182,13 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
|
|
|
if (sel->target != V4L2_SEL_TGT_CROP)
|
|
|
return -EINVAL;
|
|
|
|
|
|
+ mutex_lock(&rwpf->entity.lock);
|
|
|
+
|
|
|
config = vsp1_entity_get_pad_config(&rwpf->entity, cfg, sel->which);
|
|
|
- if (!config)
|
|
|
- return -EINVAL;
|
|
|
+ if (!config) {
|
|
|
+ ret = -EINVAL;
|
|
|
+ goto done;
|
|
|
+ }
|
|
|
|
|
|
/* Make sure the crop rectangle is entirely contained in the image. The
|
|
|
* WPF top and left offsets are limited to 255.
|
|
@@ -206,7 +226,9 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
|
|
|
format->width = crop->width;
|
|
|
format->height = crop->height;
|
|
|
|
|
|
- return 0;
|
|
|
+done:
|
|
|
+ mutex_unlock(&rwpf->entity.lock);
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
const struct v4l2_subdev_pad_ops vsp1_rwpf_pad_ops = {
|