summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/coda/coda.h
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2018-11-05 10:25:01 -0500
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-11-23 05:26:24 -0500
commit51407c2da0b7baac581d0d9fbfc297d10b7d0424 (patch)
tree6897d63239c5792b443f8eaf8cdce1a6a4ac2b32 /drivers/media/platform/coda/coda.h
parent6c0f5d236fd0205a8dca24b82cfad1b1c6c0a1e0 (diff)
media: coda: always hold back decoder jobs until we have enough bitstream payload
The bitstream prefetch unit reads data in 256 byte blocks with some kind of queueing. For the decoder to see data up to a desired position in the next run, the bitstream has to be filled for 2 256 byte blocks past that position aligned up to the next 256 byte boundary. This should make sure we never run into a buffer underrun condition if userspace does not supply new input buffers fast enough. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hansverk@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/platform/coda/coda.h')
-rw-r--r--drivers/media/platform/coda/coda.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h
index baa04b0f21fb..e35f505053d0 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -296,6 +296,18 @@ static inline unsigned int coda_get_bitstream_payload(struct coda_ctx *ctx)
return kfifo_len(&ctx->bitstream_fifo);
}
+/*
+ * The bitstream prefetcher needs to read at least 2 256 byte periods past
+ * the desired bitstream position for all data to reach the decoder.
+ */
+static inline bool coda_bitstream_can_fetch_past(struct coda_ctx *ctx,
+ unsigned int pos)
+{
+ return (int)(ctx->bitstream_fifo.kfifo.in - ALIGN(pos, 256)) > 512;
+}
+
+bool coda_bitstream_can_fetch_past(struct coda_ctx *ctx, unsigned int pos);
+
void coda_bit_stream_end_flag(struct coda_ctx *ctx);
void coda_m2m_buf_done(struct coda_ctx *ctx, struct vb2_v4l2_buffer *buf,