89fac78738aa2baa93b5e5ec329c24cfe2611deb
[openwrt/staging/rmilecki.git] /
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
5 unless streaming
6
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.
10
11 Check that the queue is streaming before sending buffers to the VPU.
12
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
14 ---
15 .../bcm2835-codec/bcm2835-v4l2-codec.c | 64 +++++++++++--------
16 1 file changed, 38 insertions(+), 26 deletions(-)
17
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)
21
22 v4l2_dbg(3, debug, &ctx->dev->v4l2_dev, "%s: off we go\n", __func__);
23
24 - src_buf = v4l2_m2m_buf_remove(&ctx->fh.m2m_ctx->out_q_ctx);
25 - if (src_buf) {
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);
29 -
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);
36 - if (ret)
37 - v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed submitting ip buffer\n",
38 - __func__);
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);
41 + if (src_buf) {
42 + m2m = container_of(src_buf, struct v4l2_m2m_buffer, vb);
43 + src_m2m_buf = container_of(m2m, struct m2m_mmal_buffer,
44 + m2m);
45 + vb2_to_mmal_buffer(src_m2m_buf, src_buf);
46 +
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);
55 + if (ret)
56 + v4l2_err(&ctx->dev->v4l2_dev,
57 + "%s: Failed submitting ip buffer\n",
58 + __func__);
59 + }
60 }
61
62 - dst_buf = v4l2_m2m_buf_remove(&ctx->fh.m2m_ctx->cap_q_ctx);
63 - if (dst_buf) {
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);
67 -
68 - ret = vchiq_mmal_submit_buffer(dev->instance,
69 - &ctx->component->output[0],
70 - &dst_m2m_buf->mmal);
71 - if (ret)
72 - v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed submitting op buffer\n",
73 - __func__);
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);
76 + if (dst_buf) {
77 + m2m = container_of(dst_buf, struct v4l2_m2m_buffer, vb);
78 + dst_m2m_buf = container_of(m2m, struct m2m_mmal_buffer,
79 + m2m);
80 + vb2_to_mmal_buffer(dst_m2m_buf, dst_buf);
81 +
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);
87 + if (ret)
88 + v4l2_err(&ctx->dev->v4l2_dev,
89 + "%s: Failed submitting op buffer\n",
90 + __func__);
91 + }
92 }
93
94 v4l2_dbg(3, debug, &ctx->dev->v4l2_dev, "%s: Submitted src %p, dst %p\n",