]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[media] coda: first step at error recovery
authorLucas Stach <l.stach@pengutronix.de>
Wed, 5 Apr 2017 13:09:54 +0000 (10:09 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 20 Jun 2017 12:03:51 +0000 (09:03 -0300)
This implements a simple handler for the case where decode did not finish
sucessfully. This might be helpful during normal streaming, but for now it
only handles the case where the context would deadlock with userspace,
i.e. userspace issued DEC_CMD_STOP and waits for EOS, but after the failed
decode run we would hold the context and wait for userspace to queue more
buffers.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/coda/coda-bit.c
drivers/media/platform/coda/coda-common.c
drivers/media/platform/coda/coda.h

index 325035bb0a7770980c51aa4b601da1aa26119216..25cbf9e5ac5a749bf4a8a7c2f47a6b36cd6843cd 100644 (file)
@@ -2198,12 +2198,32 @@ static void coda_finish_decode(struct coda_ctx *ctx)
        ctx->display_idx = display_idx;
 }
 
+static void coda_error_decode(struct coda_ctx *ctx)
+{
+       struct vb2_v4l2_buffer *dst_buf;
+
+       /*
+        * For now this only handles the case where we would deadlock with
+        * userspace, i.e. userspace issued DEC_CMD_STOP and waits for EOS,
+        * but after a failed decode run we would hold the context and wait for
+        * userspace to queue more buffers.
+        */
+       if (!(ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG))
+               return;
+
+       dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
+       dst_buf->sequence = ctx->qsequence - 1;
+
+       coda_m2m_buf_done(ctx, dst_buf, VB2_BUF_STATE_ERROR);
+}
+
 const struct coda_context_ops coda_bit_decode_ops = {
        .queue_init = coda_decoder_queue_init,
        .reqbufs = coda_decoder_reqbufs,
        .start_streaming = coda_start_decoding,
        .prepare_run = coda_prepare_decode,
        .finish_run = coda_finish_decode,
+       .error_run = coda_error_decode,
        .seq_end_work = coda_seq_end_work,
        .release = coda_bit_release,
 };
index 78bd9a4ace0e4d643f753ac1f0f3b0f82ace106d..f92cc7df58fb8e64d039217dcb5fcba5fe60d479 100644 (file)
@@ -1163,6 +1163,9 @@ static void coda_pic_run_work(struct work_struct *work)
                ctx->hold = true;
 
                coda_hw_reset(ctx);
+
+               if (ctx->ops->error_run)
+                       ctx->ops->error_run(ctx);
        } else if (!ctx->aborting) {
                ctx->ops->finish_run(ctx);
        }
index 76d059431ca13a3d0999205d7f2e535f426e84eb..40fe22f0d757327f03b8e9dce43546a745da9b6a 100644 (file)
@@ -183,6 +183,7 @@ struct coda_context_ops {
        int (*start_streaming)(struct coda_ctx *ctx);
        int (*prepare_run)(struct coda_ctx *ctx);
        void (*finish_run)(struct coda_ctx *ctx);
+       void (*error_run)(struct coda_ctx *ctx);
        void (*seq_end_work)(struct work_struct *work);
        void (*release)(struct coda_ctx *ctx);
 };