mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
media: renesas: vsp1: Use mutex guards
Replace manual mutex locking and unlocking with guards. This simplifies error paths and reduces the amount of code. Limit the changes to locations where the guard covers until the end of the function to ease review. Scoped guards will be introduced separately. Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Link: https://patch.msgid.link/20260511235637.3468558-6-laurent.pinchart+renesas@ideasonboard.com Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
parent
6579799e96
commit
38abda35a6
|
|
@ -130,15 +130,12 @@ static int brx_set_format(struct v4l2_subdev *subdev,
|
|||
struct vsp1_brx *brx = to_brx(subdev);
|
||||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&brx->entity.lock);
|
||||
guard(mutex)(&brx->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&brx->entity, sd_state, fmt->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
brx_try_format(brx, state, fmt->pad, &fmt->format);
|
||||
|
||||
|
|
@ -172,9 +169,7 @@ static int brx_set_format(struct v4l2_subdev *subdev,
|
|||
*format = fmt->format;
|
||||
}
|
||||
|
||||
done:
|
||||
mutex_unlock(&brx->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int brx_get_selection(struct v4l2_subdev *subdev,
|
||||
|
|
@ -219,7 +214,6 @@ static int brx_set_selection(struct v4l2_subdev *subdev,
|
|||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
struct v4l2_rect *compose;
|
||||
int ret = 0;
|
||||
|
||||
if (sel->pad == brx->entity.source_pad)
|
||||
return -EINVAL;
|
||||
|
|
@ -227,13 +221,11 @@ static int brx_set_selection(struct v4l2_subdev *subdev,
|
|||
if (sel->target != V4L2_SEL_TGT_COMPOSE)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&brx->entity.lock);
|
||||
guard(mutex)(&brx->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&brx->entity, sd_state, sel->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* The compose rectangle top left corner must be inside the output
|
||||
|
|
@ -254,9 +246,7 @@ static int brx_set_selection(struct v4l2_subdev *subdev,
|
|||
compose = v4l2_subdev_state_get_compose(state, sel->pad);
|
||||
*compose = sel->r;
|
||||
|
||||
done:
|
||||
mutex_unlock(&brx->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct v4l2_subdev_pad_ops brx_pad_ops = {
|
||||
|
|
|
|||
|
|
@ -920,7 +920,7 @@ void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index,
|
|||
|
||||
drm_pipe->crc = cfg->crc;
|
||||
|
||||
mutex_lock(&vsp1->drm->lock);
|
||||
guard(mutex)(&vsp1->drm->lock);
|
||||
|
||||
if (cfg->writeback.pixelformat) {
|
||||
const struct vsp1_du_writeback_config *wb_cfg = &cfg->writeback;
|
||||
|
|
@ -929,7 +929,7 @@ void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index,
|
|||
wb_cfg->pixelformat,
|
||||
wb_cfg->pitch);
|
||||
if (WARN_ON(ret < 0))
|
||||
goto done;
|
||||
return;
|
||||
|
||||
pipe->output->mem.addr[0] = wb_cfg->mem[0];
|
||||
pipe->output->mem.addr[1] = wb_cfg->mem[1];
|
||||
|
|
@ -942,9 +942,6 @@ void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index,
|
|||
vsp1_pipeline_dump(pipe, "atomic update");
|
||||
|
||||
vsp1_du_pipeline_configure(pipe);
|
||||
|
||||
done:
|
||||
mutex_unlock(&vsp1->drm->lock);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vsp1_du_atomic_flush);
|
||||
|
||||
|
|
|
|||
|
|
@ -172,9 +172,9 @@ int vsp1_subdev_get_pad_format(struct v4l2_subdev *subdev,
|
|||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&entity->lock);
|
||||
guard(mutex)(&entity->lock);
|
||||
|
||||
fmt->format = *v4l2_subdev_state_get_format(state, fmt->pad);
|
||||
mutex_unlock(&entity->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -308,22 +308,19 @@ int vsp1_subdev_set_pad_format(struct v4l2_subdev *subdev,
|
|||
struct v4l2_mbus_framefmt *format;
|
||||
struct v4l2_rect *selection;
|
||||
unsigned int i;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&entity->lock);
|
||||
guard(mutex)(&entity->lock);
|
||||
|
||||
state = vsp1_entity_get_state(entity, sd_state, fmt->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
format = v4l2_subdev_state_get_format(state, fmt->pad);
|
||||
|
||||
if (fmt->pad == entity->source_pad) {
|
||||
/* The output format can't be modified. */
|
||||
fmt->format = *format;
|
||||
goto done;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -369,9 +366,7 @@ int vsp1_subdev_set_pad_format(struct v4l2_subdev *subdev,
|
|||
selection->width = format->width;
|
||||
selection->height = format->height;
|
||||
|
||||
done:
|
||||
mutex_unlock(&entity->lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vsp1_entity_init_state(struct v4l2_subdev *subdev,
|
||||
|
|
|
|||
|
|
@ -196,18 +196,15 @@ static int histo_get_selection(struct v4l2_subdev *subdev,
|
|||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
struct v4l2_rect *crop;
|
||||
int ret = 0;
|
||||
|
||||
if (sel->pad != HISTO_PAD_SINK)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&histo->entity.lock);
|
||||
guard(mutex)(&histo->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&histo->entity, sd_state, sel->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
switch (sel->target) {
|
||||
case V4L2_SEL_TGT_COMPOSE_BOUNDS:
|
||||
|
|
@ -237,13 +234,10 @@ static int histo_get_selection(struct v4l2_subdev *subdev,
|
|||
break;
|
||||
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
done:
|
||||
mutex_unlock(&histo->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int histo_set_crop(struct v4l2_subdev *subdev,
|
||||
|
|
@ -321,29 +315,22 @@ static int histo_set_selection(struct v4l2_subdev *subdev,
|
|||
{
|
||||
struct vsp1_histogram *histo = subdev_to_histo(subdev);
|
||||
struct v4l2_subdev_state *state;
|
||||
int ret;
|
||||
|
||||
if (sel->pad != HISTO_PAD_SINK)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&histo->entity.lock);
|
||||
guard(mutex)(&histo->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&histo->entity, sd_state, sel->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
if (sel->target == V4L2_SEL_TGT_CROP)
|
||||
ret = histo_set_crop(subdev, state, sel);
|
||||
return histo_set_crop(subdev, state, sel);
|
||||
else if (sel->target == V4L2_SEL_TGT_COMPOSE)
|
||||
ret = histo_set_compose(subdev, state, sel);
|
||||
return histo_set_compose(subdev, state, sel);
|
||||
else
|
||||
ret = -EINVAL;
|
||||
|
||||
done:
|
||||
mutex_unlock(&histo->entity.lock);
|
||||
return ret;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int histo_set_format(struct v4l2_subdev *subdev,
|
||||
|
|
|
|||
|
|
@ -115,15 +115,12 @@ static int hsit_set_format(struct v4l2_subdev *subdev,
|
|||
struct vsp1_hsit *hsit = to_hsit(subdev);
|
||||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&hsit->entity.lock);
|
||||
guard(mutex)(&hsit->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&hsit->entity, sd_state, fmt->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
format = v4l2_subdev_state_get_format(state, fmt->pad);
|
||||
|
||||
|
|
@ -133,7 +130,7 @@ static int hsit_set_format(struct v4l2_subdev *subdev,
|
|||
* modified.
|
||||
*/
|
||||
fmt->format = *format;
|
||||
goto done;
|
||||
return 0;
|
||||
}
|
||||
|
||||
format->code = hsit->inverse ? MEDIA_BUS_FMT_AHSV8888_1X32
|
||||
|
|
@ -161,9 +158,7 @@ static int hsit_set_format(struct v4l2_subdev *subdev,
|
|||
|
||||
vsp1_entity_adjust_color_space(format);
|
||||
|
||||
done:
|
||||
mutex_unlock(&hsit->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct v4l2_subdev_pad_ops hsit_pad_ops = {
|
||||
|
|
|
|||
|
|
@ -116,15 +116,12 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
|
|||
struct vsp1_rwpf *rwpf = to_rwpf(subdev);
|
||||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&rwpf->entity.lock);
|
||||
guard(mutex)(&rwpf->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&rwpf->entity, sd_state, fmt->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
/* Default to YUV if the requested format is not supported. */
|
||||
if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 &&
|
||||
|
|
@ -174,7 +171,7 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
|
|||
fmt->format = *format;
|
||||
fmt->format.flags = flags;
|
||||
|
||||
goto done;
|
||||
return 0;
|
||||
}
|
||||
|
||||
format->code = fmt->format.code;
|
||||
|
|
@ -213,9 +210,7 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
|
|||
format->height = fmt->format.width;
|
||||
}
|
||||
|
||||
done:
|
||||
mutex_unlock(&rwpf->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
|
||||
|
|
@ -225,7 +220,6 @@ static int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
|
|||
struct vsp1_rwpf *rwpf = to_rwpf(subdev);
|
||||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
int ret = 0;
|
||||
|
||||
/*
|
||||
* Cropping is only supported on the RPF and is implemented on the sink
|
||||
|
|
@ -234,13 +228,11 @@ static int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
|
|||
if (rwpf->entity.type == VSP1_ENTITY_WPF || sel->pad != RWPF_PAD_SINK)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&rwpf->entity.lock);
|
||||
guard(mutex)(&rwpf->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&rwpf->entity, sd_state, sel->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
switch (sel->target) {
|
||||
case V4L2_SEL_TGT_CROP:
|
||||
|
|
@ -256,13 +248,10 @@ static int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
|
|||
break;
|
||||
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
done:
|
||||
mutex_unlock(&rwpf->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
|
||||
|
|
@ -275,7 +264,6 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
|
|||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
struct v4l2_rect *crop;
|
||||
int ret = 0;
|
||||
|
||||
/*
|
||||
* Cropping is only supported on the RPF and is implemented on the sink
|
||||
|
|
@ -287,13 +275,11 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
|
|||
if (sel->target != V4L2_SEL_TGT_CROP)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&rwpf->entity.lock);
|
||||
guard(mutex)(&rwpf->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&rwpf->entity, sd_state, sel->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
/* Make sure the crop rectangle is entirely contained in the image. */
|
||||
format = v4l2_subdev_state_get_format(state, RWPF_PAD_SINK);
|
||||
|
|
@ -342,9 +328,7 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
|
|||
format->width = crop->width;
|
||||
format->height = crop->height;
|
||||
|
||||
done:
|
||||
mutex_unlock(&rwpf->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct v4l2_subdev_pad_ops vsp1_rwpf_pad_ops = {
|
||||
|
|
|
|||
|
|
@ -216,15 +216,12 @@ static int sru_set_format(struct v4l2_subdev *subdev,
|
|||
struct vsp1_sru *sru = to_sru(subdev);
|
||||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&sru->entity.lock);
|
||||
guard(mutex)(&sru->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&sru->entity, sd_state, fmt->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
sru_try_format(sru, state, fmt->pad, &fmt->format);
|
||||
|
||||
|
|
@ -239,9 +236,7 @@ static int sru_set_format(struct v4l2_subdev *subdev,
|
|||
sru_try_format(sru, state, SRU_PAD_SOURCE, format);
|
||||
}
|
||||
|
||||
done:
|
||||
mutex_unlock(&sru->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct v4l2_subdev_pad_ops sru_pad_ops = {
|
||||
|
|
|
|||
|
|
@ -199,15 +199,12 @@ static int uds_set_format(struct v4l2_subdev *subdev,
|
|||
struct vsp1_uds *uds = to_uds(subdev);
|
||||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&uds->entity.lock);
|
||||
guard(mutex)(&uds->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&uds->entity, sd_state, fmt->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
uds_try_format(uds, state, fmt->pad, &fmt->format);
|
||||
|
||||
|
|
@ -222,9 +219,7 @@ static int uds_set_format(struct v4l2_subdev *subdev,
|
|||
uds_try_format(uds, state, UDS_PAD_SOURCE, format);
|
||||
}
|
||||
|
||||
done:
|
||||
mutex_unlock(&uds->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -60,18 +60,15 @@ static int uif_get_selection(struct v4l2_subdev *subdev,
|
|||
struct vsp1_uif *uif = to_uif(subdev);
|
||||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
int ret = 0;
|
||||
|
||||
if (sel->pad != UIF_PAD_SINK)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&uif->entity.lock);
|
||||
guard(mutex)(&uif->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&uif->entity, sd_state, sel->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
switch (sel->target) {
|
||||
case V4L2_SEL_TGT_CROP_BOUNDS:
|
||||
|
|
@ -88,13 +85,10 @@ static int uif_get_selection(struct v4l2_subdev *subdev,
|
|||
break;
|
||||
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
done:
|
||||
mutex_unlock(&uif->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uif_set_selection(struct v4l2_subdev *subdev,
|
||||
|
|
@ -105,19 +99,16 @@ static int uif_set_selection(struct v4l2_subdev *subdev,
|
|||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
struct v4l2_rect *selection;
|
||||
int ret = 0;
|
||||
|
||||
if (sel->pad != UIF_PAD_SINK ||
|
||||
sel->target != V4L2_SEL_TGT_CROP)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&uif->entity.lock);
|
||||
guard(mutex)(&uif->entity.lock);
|
||||
|
||||
state = vsp1_entity_get_state(&uif->entity, sd_state, sel->which);
|
||||
if (!state) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (!state)
|
||||
return -EINVAL;
|
||||
|
||||
/* The crop rectangle must be inside the input frame. */
|
||||
format = v4l2_subdev_state_get_format(state, UIF_PAD_SINK);
|
||||
|
|
@ -133,9 +124,7 @@ static int uif_set_selection(struct v4l2_subdev *subdev,
|
|||
selection = v4l2_subdev_state_get_crop(state, sel->pad);
|
||||
*selection = sel->r;
|
||||
|
||||
done:
|
||||
mutex_unlock(&uif->entity.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -595,9 +595,9 @@ static void vsp1_video_pipeline_put(struct vsp1_pipeline *pipe)
|
|||
{
|
||||
struct media_device *mdev = &pipe->output->entity.vsp1->media_dev;
|
||||
|
||||
mutex_lock(&mdev->graph_mutex);
|
||||
guard(mutex)(&mdev->graph_mutex);
|
||||
|
||||
kref_put(&pipe->kref, vsp1_video_pipeline_release);
|
||||
mutex_unlock(&mdev->graph_mutex);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -938,9 +938,9 @@ vsp1_video_get_format(struct file *file, void *fh, struct v4l2_format *format)
|
|||
if (format->type != video->queue.type)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&video->lock);
|
||||
guard(mutex)(&video->lock);
|
||||
|
||||
format->fmt.pix_mp = video->rwpf->format;
|
||||
mutex_unlock(&video->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -972,19 +972,15 @@ vsp1_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&video->lock);
|
||||
guard(mutex)(&video->lock);
|
||||
|
||||
if (vb2_is_busy(&video->queue)) {
|
||||
ret = -EBUSY;
|
||||
goto done;
|
||||
}
|
||||
if (vb2_is_busy(&video->queue))
|
||||
return -EBUSY;
|
||||
|
||||
video->rwpf->format = format->fmt.pix_mp;
|
||||
video->rwpf->fmtinfo = info;
|
||||
|
||||
done:
|
||||
mutex_unlock(&video->lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ static int vsp1_wpf_set_rotation(struct vsp1_rwpf *wpf, unsigned int rotation)
|
|||
struct v4l2_mbus_framefmt *sink_format;
|
||||
struct v4l2_mbus_framefmt *source_format;
|
||||
bool rotate;
|
||||
int ret = 0;
|
||||
|
||||
/*
|
||||
* Only consider the 0°/180° from/to 90°/270° modifications, the rest
|
||||
|
|
@ -58,19 +57,17 @@ static int vsp1_wpf_set_rotation(struct vsp1_rwpf *wpf, unsigned int rotation)
|
|||
return 0;
|
||||
|
||||
/* Changing rotation isn't allowed when buffers are allocated. */
|
||||
mutex_lock(&video->lock);
|
||||
guard(mutex)(&video->lock);
|
||||
|
||||
if (vb2_is_busy(&video->queue)) {
|
||||
ret = -EBUSY;
|
||||
goto done;
|
||||
}
|
||||
if (vb2_is_busy(&video->queue))
|
||||
return -EBUSY;
|
||||
|
||||
sink_format = v4l2_subdev_state_get_format(wpf->entity.state,
|
||||
RWPF_PAD_SINK);
|
||||
source_format = v4l2_subdev_state_get_format(wpf->entity.state,
|
||||
RWPF_PAD_SOURCE);
|
||||
|
||||
mutex_lock(&wpf->entity.lock);
|
||||
guard(mutex)(&wpf->entity.lock);
|
||||
|
||||
if (rotate) {
|
||||
source_format->width = sink_format->height;
|
||||
|
|
@ -82,11 +79,7 @@ static int vsp1_wpf_set_rotation(struct vsp1_rwpf *wpf, unsigned int rotation)
|
|||
|
||||
wpf->flip.rotate = rotate;
|
||||
|
||||
mutex_unlock(&wpf->entity.lock);
|
||||
|
||||
done:
|
||||
mutex_unlock(&video->lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vsp1_wpf_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user