[media] mem2mem: add support for hardware buffered queue
On mem2mem decoders with a hardware bitstream ringbuffer, to drain the buffer at the end of the stream, remaining frames might need to be decoded from the bitstream buffer without additional input buffers being provided. To achieve this, allow a queue to be marked as buffered by the driver, and allow scheduling of device_runs when buffered ready queues are empty. This also allows a driver to copy input buffers into their bitstream ringbuffer and immediately mark them as done to be dequeued. The motivation for this patch is hardware assisted h.264 reordering support in the coda driver. For high profile streams, the coda can hold back out-of-order frames, causing a few mem2mem device runs in the beginning, that don't produce any decompressed buffer at the v4l2 capture side. At the same time, the last few frames can be decoded from the bitstream with mem2mem device runs that don't need a new input buffer at the v4l2 output side. The decoder command ioctl can be used to put the decoder into the ringbuffer draining end-of-stream mode. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
parent
c859e6ef33
commit
33bdd5a88a
|
@ -196,6 +196,10 @@ static void v4l2_m2m_try_run(struct v4l2_m2m_dev *m2m_dev)
|
||||||
* 2) at least one destination buffer has to be queued,
|
* 2) at least one destination buffer has to be queued,
|
||||||
* 3) streaming has to be on.
|
* 3) streaming has to be on.
|
||||||
*
|
*
|
||||||
|
* If a queue is buffered (for example a decoder hardware ringbuffer that has
|
||||||
|
* to be drained before doing streamoff), allow scheduling without v4l2 buffers
|
||||||
|
* on that queue.
|
||||||
|
*
|
||||||
* There may also be additional, custom requirements. In such case the driver
|
* There may also be additional, custom requirements. In such case the driver
|
||||||
* should supply a custom callback (job_ready in v4l2_m2m_ops) that should
|
* should supply a custom callback (job_ready in v4l2_m2m_ops) that should
|
||||||
* return 1 if the instance is ready.
|
* return 1 if the instance is ready.
|
||||||
|
@ -224,7 +228,8 @@ static void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&m2m_ctx->out_q_ctx.rdy_spinlock, flags_out);
|
spin_lock_irqsave(&m2m_ctx->out_q_ctx.rdy_spinlock, flags_out);
|
||||||
if (list_empty(&m2m_ctx->out_q_ctx.rdy_queue)) {
|
if (list_empty(&m2m_ctx->out_q_ctx.rdy_queue)
|
||||||
|
&& !m2m_ctx->out_q_ctx.buffered) {
|
||||||
spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock,
|
spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock,
|
||||||
flags_out);
|
flags_out);
|
||||||
spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job);
|
spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job);
|
||||||
|
@ -232,7 +237,8 @@ static void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
spin_lock_irqsave(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags_cap);
|
spin_lock_irqsave(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags_cap);
|
||||||
if (list_empty(&m2m_ctx->cap_q_ctx.rdy_queue)) {
|
if (list_empty(&m2m_ctx->cap_q_ctx.rdy_queue)
|
||||||
|
&& !m2m_ctx->cap_q_ctx.buffered) {
|
||||||
spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock,
|
spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock,
|
||||||
flags_cap);
|
flags_cap);
|
||||||
spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock,
|
spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock,
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct v4l2_m2m_queue_ctx {
|
||||||
struct list_head rdy_queue;
|
struct list_head rdy_queue;
|
||||||
spinlock_t rdy_spinlock;
|
spinlock_t rdy_spinlock;
|
||||||
u8 num_rdy;
|
u8 num_rdy;
|
||||||
|
bool buffered;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct v4l2_m2m_ctx {
|
struct v4l2_m2m_ctx {
|
||||||
|
@ -134,6 +135,18 @@ struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,
|
||||||
void *drv_priv,
|
void *drv_priv,
|
||||||
int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq));
|
int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq));
|
||||||
|
|
||||||
|
static inline void v4l2_m2m_set_src_buffered(struct v4l2_m2m_ctx *m2m_ctx,
|
||||||
|
bool buffered)
|
||||||
|
{
|
||||||
|
m2m_ctx->out_q_ctx.buffered = buffered;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void v4l2_m2m_set_dst_buffered(struct v4l2_m2m_ctx *m2m_ctx,
|
||||||
|
bool buffered)
|
||||||
|
{
|
||||||
|
m2m_ctx->cap_q_ctx.buffered = buffered;
|
||||||
|
}
|
||||||
|
|
||||||
void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx);
|
void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx);
|
||||||
|
|
||||||
void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_buffer *vb);
|
void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_buffer *vb);
|
||||||
|
|
Loading…
Reference in New Issue