Commit 2d494d4a authored by Hugues Fruchet's avatar Hugues Fruchet Committed by Mauro Carvalho Chehab

media: stm32-dcmi: clarify state logic on buffer starvation

Introduce WAIT_FOR_BUFFER state instead of "active" field checking
to manage buffer starvation case.
Signed-off-by: default avatarHugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent a331df3c
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
enum state { enum state {
STOPPED = 0, STOPPED = 0,
WAIT_FOR_BUFFER,
RUNNING, RUNNING,
STOPPING, STOPPING,
}; };
...@@ -229,6 +230,7 @@ static int dcmi_restart_capture(struct stm32_dcmi *dcmi) ...@@ -229,6 +230,7 @@ static int dcmi_restart_capture(struct stm32_dcmi *dcmi)
if (list_empty(&dcmi->buffers)) { if (list_empty(&dcmi->buffers)) {
dev_dbg(dcmi->dev, "Capture restart is deferred to next buffer queueing\n"); dev_dbg(dcmi->dev, "Capture restart is deferred to next buffer queueing\n");
dcmi->active = NULL; dcmi->active = NULL;
dcmi->state = WAIT_FOR_BUFFER;
spin_unlock_irq(&dcmi->irqlock); spin_unlock_irq(&dcmi->irqlock);
return 0; return 0;
} }
...@@ -547,9 +549,11 @@ static void dcmi_buf_queue(struct vb2_buffer *vb) ...@@ -547,9 +549,11 @@ static void dcmi_buf_queue(struct vb2_buffer *vb)
spin_lock_irq(&dcmi->irqlock); spin_lock_irq(&dcmi->irqlock);
if (dcmi->state == RUNNING && !dcmi->active) {
dcmi->active = buf; dcmi->active = buf;
if (dcmi->state == WAIT_FOR_BUFFER) {
dcmi->state = RUNNING;
dev_dbg(dcmi->dev, "Starting capture on buffer[%d] queued\n", dev_dbg(dcmi->dev, "Starting capture on buffer[%d] queued\n",
buf->vb.vb2_buf.index); buf->vb.vb2_buf.index);
...@@ -629,8 +633,6 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) ...@@ -629,8 +633,6 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
/* Enable dcmi */ /* Enable dcmi */
reg_set(dcmi->regs, DCMI_CR, CR_ENABLE); reg_set(dcmi->regs, DCMI_CR, CR_ENABLE);
dcmi->state = RUNNING;
dcmi->sequence = 0; dcmi->sequence = 0;
dcmi->errors_count = 0; dcmi->errors_count = 0;
dcmi->overrun_count = 0; dcmi->overrun_count = 0;
...@@ -643,6 +645,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) ...@@ -643,6 +645,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
*/ */
if (list_empty(&dcmi->buffers)) { if (list_empty(&dcmi->buffers)) {
dev_dbg(dcmi->dev, "Start streaming is deferred to next buffer queueing\n"); dev_dbg(dcmi->dev, "Start streaming is deferred to next buffer queueing\n");
dcmi->state = WAIT_FOR_BUFFER;
spin_unlock_irq(&dcmi->irqlock); spin_unlock_irq(&dcmi->irqlock);
return 0; return 0;
} }
...@@ -652,6 +655,8 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) ...@@ -652,6 +655,8 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
dev_dbg(dcmi->dev, "Start streaming, starting capture\n"); dev_dbg(dcmi->dev, "Start streaming, starting capture\n");
dcmi->state = RUNNING;
spin_unlock_irq(&dcmi->irqlock); spin_unlock_irq(&dcmi->irqlock);
ret = dcmi_start_capture(dcmi); ret = dcmi_start_capture(dcmi);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment