1 From def9aa1e5f2e29d29b493c22fd98e1c0af018d99 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 15 Sep 2021 17:44:19 +0100
4 Subject: [PATCH] staging/bcm2835-codec: Do not send buffers to the VPU
7 With video decode we now enable both input and output ports on
8 the component. This means that buffers will get passed to the VPU
9 earlier than desired if they are queued befoer STREAMON.
11 Check that the queue is streaming before sending buffers to the VPU.
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 .../bcm2835-codec/bcm2835-v4l2-codec.c | 64 +++++++++++--------
16 1 file changed, 38 insertions(+), 26 deletions(-)
18 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
19 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
20 @@ -1244,35 +1244,47 @@ static void device_run(void *priv)
22 v4l2_dbg(3, debug, &ctx->dev->v4l2_dev, "%s: off we go\n", __func__);
24 - src_buf = v4l2_m2m_buf_remove(&ctx->fh.m2m_ctx->out_q_ctx);
26 - m2m = container_of(src_buf, struct v4l2_m2m_buffer, vb);
27 - src_m2m_buf = container_of(m2m, struct m2m_mmal_buffer, m2m);
28 - vb2_to_mmal_buffer(src_m2m_buf, src_buf);
30 - ret = vchiq_mmal_submit_buffer(dev->instance,
31 - &ctx->component->input[0],
32 - &src_m2m_buf->mmal);
33 - v4l2_dbg(3, debug, &ctx->dev->v4l2_dev, "%s: Submitted ip buffer len %lu, pts %llu, flags %04x\n",
34 - __func__, src_m2m_buf->mmal.length,
35 - src_m2m_buf->mmal.pts, src_m2m_buf->mmal.mmal_flags);
37 - v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed submitting ip buffer\n",
39 + if (ctx->fh.m2m_ctx->out_q_ctx.q.streaming) {
40 + src_buf = v4l2_m2m_buf_remove(&ctx->fh.m2m_ctx->out_q_ctx);
42 + m2m = container_of(src_buf, struct v4l2_m2m_buffer, vb);
43 + src_m2m_buf = container_of(m2m, struct m2m_mmal_buffer,
45 + vb2_to_mmal_buffer(src_m2m_buf, src_buf);
47 + ret = vchiq_mmal_submit_buffer(dev->instance,
48 + &ctx->component->input[0],
49 + &src_m2m_buf->mmal);
50 + v4l2_dbg(3, debug, &ctx->dev->v4l2_dev,
51 + "%s: Submitted ip buffer len %lu, pts %llu, flags %04x\n",
52 + __func__, src_m2m_buf->mmal.length,
53 + src_m2m_buf->mmal.pts,
54 + src_m2m_buf->mmal.mmal_flags);
56 + v4l2_err(&ctx->dev->v4l2_dev,
57 + "%s: Failed submitting ip buffer\n",
62 - dst_buf = v4l2_m2m_buf_remove(&ctx->fh.m2m_ctx->cap_q_ctx);
64 - m2m = container_of(dst_buf, struct v4l2_m2m_buffer, vb);
65 - dst_m2m_buf = container_of(m2m, struct m2m_mmal_buffer, m2m);
66 - vb2_to_mmal_buffer(dst_m2m_buf, dst_buf);
68 - ret = vchiq_mmal_submit_buffer(dev->instance,
69 - &ctx->component->output[0],
70 - &dst_m2m_buf->mmal);
72 - v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed submitting op buffer\n",
74 + if (ctx->fh.m2m_ctx->cap_q_ctx.q.streaming) {
75 + dst_buf = v4l2_m2m_buf_remove(&ctx->fh.m2m_ctx->cap_q_ctx);
77 + m2m = container_of(dst_buf, struct v4l2_m2m_buffer, vb);
78 + dst_m2m_buf = container_of(m2m, struct m2m_mmal_buffer,
80 + vb2_to_mmal_buffer(dst_m2m_buf, dst_buf);
82 + v4l2_dbg(3, debug, &ctx->dev->v4l2_dev,
83 + "%s: Submitted op buffer\n", __func__);
84 + ret = vchiq_mmal_submit_buffer(dev->instance,
85 + &ctx->component->output[0],
86 + &dst_m2m_buf->mmal);
88 + v4l2_err(&ctx->dev->v4l2_dev,
89 + "%s: Failed submitting op buffer\n",
94 v4l2_dbg(3, debug, &ctx->dev->v4l2_dev, "%s: Submitted src %p, dst %p\n",