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);
*format = fmt->format;
}
-done:
- mutex_unlock(&brx->entity.lock);
- return ret;
+ return 0;
}
static int brx_get_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;
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
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 = {
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;
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];
vsp1_pipeline_dump(pipe, "atomic update");
vsp1_du_pipeline_configure(pipe);
-
-done:
- mutex_unlock(&vsp1->drm->lock);
}
EXPORT_SYMBOL_GPL(vsp1_du_atomic_flush);
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;
}
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;
}
/*
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,
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:
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,
{
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,
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);
* modified.
*/
fmt->format = *format;
- goto done;
+ return 0;
}
format->code = hsit->inverse ? MEDIA_BUS_FMT_AHSV8888_1X32
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 = {
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 &&
fmt->format = *format;
fmt->format.flags = flags;
- goto done;
+ return 0;
}
format->code = fmt->format.code;
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,
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
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:
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,
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
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);
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 = {
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);
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 = {
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);
uds_try_format(uds, state, UDS_PAD_SOURCE, format);
}
-done:
- mutex_unlock(&uds->entity.lock);
- return ret;
+ return 0;
}
/* -----------------------------------------------------------------------------
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:
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,
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);
selection = v4l2_subdev_state_get_crop(state, sel->pad);
*selection = sel->r;
-done:
- mutex_unlock(&uif->entity.lock);
- return ret;
+ return 0;
}
/* -----------------------------------------------------------------------------
{
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);
}
/* -----------------------------------------------------------------------------
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;
}
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
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
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;
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)