if (!state)
return -EINVAL;
- mutex_lock(&brx->entity.lock);
- sel->r = *v4l2_subdev_state_get_compose(state, sel->pad);
- mutex_unlock(&brx->entity.lock);
+ scoped_guard(mutex, &brx->entity.lock) {
+ sel->r = *v4l2_subdev_state_get_compose(state, sel->pad);
+ }
+
return 0;
default:
__func__, pipe_index, cfg->width, cfg->height,
pipe->interlaced ? "i" : "");
- mutex_lock(&vsp1->drm->lock);
-
- /* Setup formats through the pipeline. */
- ret = vsp1_du_pipeline_setup_inputs(vsp1, pipe);
- if (ret < 0)
- goto unlock;
-
- ret = vsp1_du_pipeline_setup_output(vsp1, pipe);
- if (ret < 0)
- goto unlock;
-
- vsp1_pipeline_dump(pipe, "DU enable");
+ scoped_guard(mutex, &vsp1->drm->lock) {
+ /* Setup formats through the pipeline. */
+ ret = vsp1_du_pipeline_setup_inputs(vsp1, pipe);
+ if (ret < 0)
+ return ret;
- /* Enable the VSP1. */
- ret = vsp1_device_get(vsp1);
- if (ret < 0)
- goto unlock;
+ ret = vsp1_du_pipeline_setup_output(vsp1, pipe);
+ if (ret < 0)
+ return ret;
- /*
- * Register a callback to allow us to notify the DRM driver of frame
- * completion events.
- */
- drm_pipe->du_complete = cfg->callback;
- drm_pipe->du_private = cfg->callback_data;
+ vsp1_pipeline_dump(pipe, "DU enable");
- /* Disable the display interrupts. */
- vsp1_write(vsp1, VI6_DISP_IRQ_STA(pipe_index), 0);
- vsp1_write(vsp1, VI6_DISP_IRQ_ENB(pipe_index), 0);
+ /* Enable the VSP1. */
+ ret = vsp1_device_get(vsp1);
+ if (ret < 0)
+ return ret;
- /* Configure all entities in the pipeline. */
- vsp1_du_pipeline_configure(pipe);
+ /*
+ * Register a callback to allow us to notify the DRM driver of frame
+ * completion events.
+ */
+ drm_pipe->du_complete = cfg->callback;
+ drm_pipe->du_private = cfg->callback_data;
-unlock:
- mutex_unlock(&vsp1->drm->lock);
+ /* Disable the display interrupts. */
+ vsp1_write(vsp1, VI6_DISP_IRQ_STA(pipe_index), 0);
+ vsp1_write(vsp1, VI6_DISP_IRQ_ENB(pipe_index), 0);
- if (ret < 0)
- return ret;
+ /* Configure all entities in the pipeline. */
+ vsp1_du_pipeline_configure(pipe);
+ }
/* Start the pipeline. */
spin_lock_irqsave(&pipe->irqlock, flags);
struct vsp1_device *vsp1 = dev_get_drvdata(dev);
struct vsp1_drm_pipeline *drm_pipe;
struct vsp1_pipeline *pipe;
- struct vsp1_brx *brx;
unsigned int i;
int ret;
drm_pipe = &vsp1->drm->pipe[pipe_index];
pipe = &drm_pipe->pipe;
- mutex_lock(&vsp1->drm->lock);
-
- brx = to_brx(&pipe->brx->subdev);
-
- ret = vsp1_pipeline_stop(pipe);
- if (ret == -ETIMEDOUT)
- dev_err(vsp1->dev, "DRM pipeline stop timeout\n");
+ scoped_guard(mutex, &vsp1->drm->lock) {
+ struct vsp1_brx *brx = to_brx(&pipe->brx->subdev);
- for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) {
- struct vsp1_rwpf *rpf = pipe->inputs[i];
+ ret = vsp1_pipeline_stop(pipe);
+ if (ret == -ETIMEDOUT)
+ dev_err(vsp1->dev, "DRM pipeline stop timeout\n");
- if (!rpf)
- continue;
+ for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) {
+ struct vsp1_rwpf *rpf = pipe->inputs[i];
- /*
- * Remove the RPF from the pipe and the list of BRx
- * inputs.
- */
- WARN_ON(!rpf->entity.pipe);
- rpf->entity.pipe = NULL;
- list_del(&rpf->entity.list_pipe);
- pipe->inputs[i] = NULL;
+ if (!rpf)
+ continue;
- brx->inputs[rpf->brx_input].rpf = NULL;
- }
+ /*
+ * Remove the RPF from the pipe and the list of BRx
+ * inputs.
+ */
+ WARN_ON(!rpf->entity.pipe);
+ rpf->entity.pipe = NULL;
+ list_del(&rpf->entity.list_pipe);
+ pipe->inputs[i] = NULL;
- drm_pipe->du_complete = NULL;
- pipe->num_inputs = 0;
+ brx->inputs[rpf->brx_input].rpf = NULL;
+ }
- dev_dbg(vsp1->dev, "%s: pipe %u: releasing %s\n",
- __func__, pipe->lif->index,
- BRX_NAME(pipe->brx));
+ drm_pipe->du_complete = NULL;
+ pipe->num_inputs = 0;
- list_del(&pipe->brx->list_pipe);
- pipe->brx->pipe = NULL;
- pipe->brx = NULL;
+ dev_dbg(vsp1->dev, "%s: pipe %u: releasing %s\n",
+ __func__, pipe->lif->index,
+ BRX_NAME(pipe->brx));
- mutex_unlock(&vsp1->drm->lock);
+ list_del(&pipe->brx->list_pipe);
+ pipe->brx->pipe = NULL;
+ pipe->brx = NULL;
+ }
vsp1_dlm_reset(pipe->output->dlm);
vsp1_device_put(vsp1);
if (!state)
return -EINVAL;
- mutex_lock(&entity->lock);
- format = v4l2_subdev_state_get_format(state, 0);
- code->code = format->code;
- mutex_unlock(&entity->lock);
+ scoped_guard(mutex, &entity->lock) {
+ format = v4l2_subdev_state_get_format(state, 0);
+ code->code = format->code;
+ }
}
return 0;
(crop->width << VI6_HGO_SIZE_HSIZE_SHIFT) |
(crop->height << VI6_HGO_SIZE_VSIZE_SHIFT));
- mutex_lock(hgo->ctrls.handler.lock);
- hgo->max_rgb = hgo->ctrls.max_rgb->cur.val;
- if (hgo->ctrls.num_bins)
- hgo->num_bins = hgo_num_bins[hgo->ctrls.num_bins->cur.val];
- mutex_unlock(hgo->ctrls.handler.lock);
+ scoped_guard(mutex, hgo->ctrls.handler.lock) {
+ hgo->max_rgb = hgo->ctrls.max_rgb->cur.val;
+ if (hgo->ctrls.num_bins)
+ hgo->num_bins = hgo_num_bins[hgo->ctrls.num_bins->cur.val];
+ }
hratio = crop->width * 2 / compose->width / 3;
vratio = crop->height * 2 / compose->height / 3;
(crop->width << VI6_HGT_SIZE_HSIZE_SHIFT) |
(crop->height << VI6_HGT_SIZE_VSIZE_SHIFT));
- mutex_lock(hgt->ctrls.lock);
- for (i = 0; i < HGT_NUM_HUE_AREAS; ++i) {
- lower = hgt->hue_areas[i*2 + 0];
- upper = hgt->hue_areas[i*2 + 1];
- vsp1_hgt_write(hgt, dlb, VI6_HGT_HUE_AREA(i),
- (lower << VI6_HGT_HUE_AREA_LOWER_SHIFT) |
- (upper << VI6_HGT_HUE_AREA_UPPER_SHIFT));
+ scoped_guard(mutex, hgt->ctrls.lock) {
+ for (i = 0; i < HGT_NUM_HUE_AREAS; ++i) {
+ lower = hgt->hue_areas[i*2 + 0];
+ upper = hgt->hue_areas[i*2 + 1];
+ vsp1_hgt_write(hgt, dlb, VI6_HGT_HUE_AREA(i),
+ (lower << VI6_HGT_HUE_AREA_LOWER_SHIFT) |
+ (upper << VI6_HGT_HUE_AREA_UPPER_SHIFT));
+ }
}
- mutex_unlock(hgt->ctrls.lock);
hratio = crop->width * 2 / compose->width / 3;
vratio = crop->height * 2 / compose->height / 3;
unsigned long flags;
int ret;
- mutex_lock(&pipe->lock);
- if (pipe->stream_count == pipe->num_inputs) {
- ret = vsp1_video_setup_pipeline(pipe);
- if (ret < 0) {
- vsp1_video_release_buffers(video);
- vsp1_video_cleanup_pipeline(pipe);
- mutex_unlock(&pipe->lock);
- return ret;
+ scoped_guard(mutex, &pipe->lock) {
+ if (pipe->stream_count == pipe->num_inputs) {
+ ret = vsp1_video_setup_pipeline(pipe);
+ if (ret < 0) {
+ vsp1_video_release_buffers(video);
+ vsp1_video_cleanup_pipeline(pipe);
+ return ret;
+ }
+
+ start_pipeline = true;
}
- start_pipeline = true;
+ pipe->stream_count++;
}
- pipe->stream_count++;
- mutex_unlock(&pipe->lock);
-
/*
* vsp1_pipeline_ready() is not sufficient to establish that all streams
* are prepared and the pipeline is configured, as multiple streams
pipe->buffers_ready &= ~(1 << video->pipe_index);
spin_unlock_irqrestore(&video->irqlock, flags);
- mutex_lock(&pipe->lock);
- if (--pipe->stream_count == pipe->num_inputs) {
- /* Stop the pipeline. */
- ret = vsp1_pipeline_stop(pipe);
- if (ret == -ETIMEDOUT)
- dev_err(video->vsp1->dev, "pipeline stop timeout\n");
+ scoped_guard(mutex, &pipe->lock) {
+ if (--pipe->stream_count == pipe->num_inputs) {
+ /* Stop the pipeline. */
+ ret = vsp1_pipeline_stop(pipe);
+ if (ret == -ETIMEDOUT)
+ dev_err(video->vsp1->dev,
+ "pipeline stop timeout\n");
- vsp1_video_cleanup_pipeline(pipe);
+ vsp1_video_cleanup_pipeline(pipe);
+ }
}
- mutex_unlock(&pipe->lock);
video_device_pipeline_stop(&video->video);
vsp1_video_release_buffers(video);
* touching an entity in the pipeline can be activated or deactivated
* once streaming is started.
*/
- mutex_lock(&mdev->graph_mutex);
-
- pipe = vsp1_video_pipeline_get(video);
- if (IS_ERR(pipe)) {
- mutex_unlock(&mdev->graph_mutex);
- return PTR_ERR(pipe);
- }
+ scoped_guard(mutex, &mdev->graph_mutex) {
+ pipe = vsp1_video_pipeline_get(video);
+ if (IS_ERR(pipe))
+ return PTR_ERR(pipe);
- ret = __video_device_pipeline_start(&video->video, &pipe->pipe);
- if (ret < 0) {
- mutex_unlock(&mdev->graph_mutex);
- goto err_pipe;
+ ret = __video_device_pipeline_start(&video->video, &pipe->pipe);
+ if (ret < 0)
+ goto err_pipe;
}
- mutex_unlock(&mdev->graph_mutex);
-
/*
* Verify that the configured format matches the output of the connected
* subdev.