struct vsp1_dl_body *vsp1_dl_body_get(struct vsp1_dl_body_pool *pool)
{
struct vsp1_dl_body *dlb = NULL;
- unsigned long flags;
- spin_lock_irqsave(&pool->lock, flags);
+ guard(spinlock_irqsave)(&pool->lock);
if (!list_empty(&pool->free)) {
dlb = list_first_entry(&pool->free, struct vsp1_dl_body, free);
refcount_set(&dlb->refcnt, 1);
}
- spin_unlock_irqrestore(&pool->lock, flags);
-
return dlb;
}
*/
void vsp1_dl_body_put(struct vsp1_dl_body *dlb)
{
- unsigned long flags;
-
if (!dlb)
return;
dlb->num_entries = 0;
- spin_lock_irqsave(&dlb->pool->lock, flags);
+ guard(spinlock_irqsave)(&dlb->pool->lock);
+
list_add_tail(&dlb->free, &dlb->pool->free);
- spin_unlock_irqrestore(&dlb->pool->lock, flags);
}
/**
struct vsp1_dl_ext_cmd *vsp1_dl_ext_cmd_get(struct vsp1_dl_cmd_pool *pool)
{
struct vsp1_dl_ext_cmd *cmd = NULL;
- unsigned long flags;
- spin_lock_irqsave(&pool->lock, flags);
+ guard(spinlock_irqsave)(&pool->lock);
if (!list_empty(&pool->free)) {
cmd = list_first_entry(&pool->free, struct vsp1_dl_ext_cmd,
list_del(&cmd->free);
}
- spin_unlock_irqrestore(&pool->lock, flags);
-
return cmd;
}
static void vsp1_dl_ext_cmd_put(struct vsp1_dl_ext_cmd *cmd)
{
- unsigned long flags;
-
if (!cmd)
return;
/* Reset flags, these mark data usage. */
cmd->flags = 0;
- spin_lock_irqsave(&cmd->pool->lock, flags);
+ guard(spinlock_irqsave)(&cmd->pool->lock);
+
list_add_tail(&cmd->free, &cmd->pool->free);
- spin_unlock_irqrestore(&cmd->pool->lock, flags);
}
static void vsp1_dl_ext_cmd_pool_destroy(struct vsp1_dl_cmd_pool *pool)
struct vsp1_dl_list *vsp1_dl_list_get(struct vsp1_dl_manager *dlm)
{
struct vsp1_dl_list *dl = NULL;
- unsigned long flags;
lockdep_assert_not_held(&dlm->lock);
- spin_lock_irqsave(&dlm->lock, flags);
+ guard(spinlock_irqsave)(&dlm->lock);
if (!list_empty(&dlm->free)) {
dl = list_first_entry(&dlm->free, struct vsp1_dl_list, list);
dl->allocated = true;
}
- spin_unlock_irqrestore(&dlm->lock, flags);
-
return dl;
}
*/
void vsp1_dl_list_put(struct vsp1_dl_list *dl)
{
- unsigned long flags;
-
if (!dl)
return;
- spin_lock_irqsave(&dl->dlm->lock, flags);
+ guard(spinlock_irqsave)(&dl->dlm->lock);
+
__vsp1_dl_list_put(dl);
- spin_unlock_irqrestore(&dl->dlm->lock, flags);
}
/**
{
struct vsp1_dl_manager *dlm = dl->dlm;
struct vsp1_dl_list *dl_next;
- unsigned long flags;
/* Fill the header for the head and chained display lists. */
vsp1_dl_list_fill_header(dl, list_empty(&dl->chain));
dl->flags = dl_flags & ~VSP1_DL_FRAME_END_COMPLETED;
- spin_lock_irqsave(&dlm->lock, flags);
+ guard(spinlock_irqsave)(&dlm->lock);
if (dlm->singleshot)
vsp1_dl_list_commit_singleshot(dl);
else
vsp1_dl_list_commit_continuous(dl);
-
- spin_unlock_irqrestore(&dlm->lock, flags);
}
/* -----------------------------------------------------------------------------
u32 status = vsp1_read(vsp1, VI6_STATUS);
unsigned int flags = 0;
- spin_lock(&dlm->lock);
+ guard(spinlock)(&dlm->lock);
/*
* The mem-to-mem pipelines work in single-shot mode. No new display
__vsp1_dl_list_put(dlm->active);
dlm->active = NULL;
flags |= VSP1_DL_FRAME_END_COMPLETED;
- goto done;
+ return flags;
}
/*
* and retry.
*/
if (vsp1_dl_list_hw_update_pending(dlm))
- goto done;
+ return flags;
/*
* Progressive streams report only TOP fields. If we have a BOTTOM
* next frame end interrupt.
*/
if (status & VI6_STATUS_FLD_STD(dlm->index))
- goto done;
+ return flags;
/*
* If the active display list has the writeback flag set, the frame
dlm->pending = NULL;
}
-done:
- spin_unlock(&dlm->lock);
-
return flags;
}
struct vsp1_histogram_buffer *
vsp1_histogram_buffer_get(struct vsp1_histogram *histo)
{
- struct vsp1_histogram_buffer *buf = NULL;
+ struct vsp1_histogram_buffer *buf;
- spin_lock(&histo->irqlock);
+ guard(spinlock)(&histo->irqlock);
if (list_empty(&histo->irqqueue))
- goto done;
+ return NULL;
buf = list_first_entry(&histo->irqqueue, struct vsp1_histogram_buffer,
queue);
list_del(&buf->queue);
histo->readout = true;
-done:
- spin_unlock(&histo->irqlock);
return buf;
}
vb2_set_plane_payload(&buf->buf.vb2_buf, 0, size);
vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE);
- spin_lock(&histo->irqlock);
+ guard(spinlock)(&histo->irqlock);
+
histo->readout = false;
wake_up(&histo->wait_queue);
- spin_unlock(&histo->irqlock);
}
/* -----------------------------------------------------------------------------
struct vsp1_histogram *histo = vb2_get_drv_priv(vb->vb2_queue);
struct vsp1_histogram_buffer *buf = to_vsp1_histogram_buffer(vbuf);
- spin_lock_irq(&histo->irqlock);
+ guard(spinlock_irq)(&histo->irqlock);
+
list_add_tail(&buf->queue, &histo->irqqueue);
- spin_unlock_irq(&histo->irqlock);
}
static int histo_start_streaming(struct vb2_queue *vq, unsigned int count)
struct vsp1_histogram *histo = vb2_get_drv_priv(vq);
struct vsp1_histogram_buffer *buffer;
- spin_lock_irq(&histo->irqlock);
+ guard(spinlock_irq)(&histo->irqlock);
/* Remove all buffers from the IRQ queue. */
list_for_each_entry(buffer, &histo->irqqueue, queue)
/* Wait for the buffer being read out (if any) to complete. */
wait_event_lock_irq(histo->wait_queue, !histo->readout, histo->irqlock);
-
- spin_unlock_irq(&histo->irqlock);
}
static const struct vb2_ops histo_video_queue_qops = {
bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe)
{
- unsigned long flags;
- bool stopped;
-
- spin_lock_irqsave(&pipe->irqlock, flags);
- stopped = pipe->state == VSP1_PIPELINE_STOPPED;
- spin_unlock_irqrestore(&pipe->irqlock, flags);
+ guard(spinlock_irqsave)(&pipe->irqlock);
- return stopped;
+ return pipe->state == VSP1_PIPELINE_STOPPED;
}
int vsp1_pipeline_stop(struct vsp1_pipeline *pipe)
if (!empty)
return;
- spin_lock_irqsave(&pipe->irqlock, flags);
+ guard(spinlock_irqsave)(&pipe->irqlock);
video->rwpf->mem = buf->mem;
pipe->buffers_ready |= 1 << video->pipe_index;
if (vb2_start_streaming_called(&video->queue) &&
vsp1_pipeline_ready(pipe))
vsp1_video_pipeline_run(pipe);
-
- spin_unlock_irqrestore(&pipe->irqlock, flags);
}
static int vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe)
static void vsp1_video_release_buffers(struct vsp1_video *video)
{
struct vsp1_vb2_buffer *buffer;
- unsigned long flags;
/* Remove all buffers from the IRQ queue. */
- spin_lock_irqsave(&video->irqlock, flags);
+ guard(spinlock_irqsave)(&video->irqlock);
+
list_for_each_entry(buffer, &video->irqqueue, queue)
vb2_buffer_done(&buffer->buf.vb2_buf, VB2_BUF_STATE_ERROR);
INIT_LIST_HEAD(&video->irqqueue);
- spin_unlock_irqrestore(&video->irqlock, flags);
}
static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe)
struct vsp1_video *video = vb2_get_drv_priv(vq);
struct vsp1_pipeline *pipe = video->rwpf->entity.pipe;
bool start_pipeline = false;
- unsigned long flags;
int ret;
scoped_guard(mutex, &pipe->lock) {
if (!start_pipeline)
return 0;
- spin_lock_irqsave(&pipe->irqlock, flags);
+ guard(spinlock_irqsave)(&pipe->irqlock);
+
if (vsp1_pipeline_ready(pipe))
vsp1_video_pipeline_run(pipe);
- spin_unlock_irqrestore(&pipe->irqlock, flags);
return 0;
}
if (rotation == 180 || rotation == 270)
flip ^= BIT(WPF_CTRL_VFLIP) | BIT(WPF_CTRL_HFLIP);
- spin_lock_irq(&wpf->flip.lock);
+ guard(spinlock_irq)(&wpf->flip.lock);
+
wpf->flip.pending = flip;
- spin_unlock_irq(&wpf->flip.lock);
return 0;
}