bcm27xx: update to latest patches from RPi foundation
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0496-media-v4l2-mem2mem-add-new_frame-detection.patch
1 From 1d55acac432983ad8301f5430c42ac549b4b4c6f Mon Sep 17 00:00:00 2001
2 From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 Date: Fri, 11 Oct 2019 06:32:44 -0300
4 Subject: [PATCH] media: v4l2-mem2mem: add new_frame detection
5
6 Commit f07602ac388723233e9e3c5a05b54baf34e0a3e9 upstream.
7
8 Drivers that support VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF
9 typically want to know if a new frame is started (i.e. the first
10 slice is about to be processed). Add a new_frame bool to v4l2_m2m_ctx
11 and set it accordingly.
12
13 Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
14 Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
15 ---
16 drivers/media/v4l2-core/v4l2-mem2mem.c | 11 +++++++++--
17 include/media/v4l2-mem2mem.h | 7 +++++++
18 2 files changed, 16 insertions(+), 2 deletions(-)
19
20 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c
21 +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
22 @@ -319,8 +319,10 @@ static void __v4l2_m2m_try_queue(struct
23 goto job_unlock;
24 }
25
26 - if (src && dst &&
27 - dst->is_held && dst->vb2_buf.copied_timestamp &&
28 + m2m_ctx->new_frame = true;
29 +
30 + if (src && dst && dst->is_held &&
31 + dst->vb2_buf.copied_timestamp &&
32 dst->vb2_buf.timestamp != src->vb2_buf.timestamp) {
33 dst->is_held = false;
34 v4l2_m2m_dst_buf_remove(m2m_ctx);
35 @@ -333,6 +335,11 @@ static void __v4l2_m2m_try_queue(struct
36 }
37 }
38
39 + if (src && dst && (m2m_ctx->cap_q_ctx.q.subsystem_flags &
40 + VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF))
41 + m2m_ctx->new_frame = !dst->vb2_buf.copied_timestamp ||
42 + dst->vb2_buf.timestamp != src->vb2_buf.timestamp;
43 +
44 if (m2m_dev->m2m_ops->job_ready
45 && (!m2m_dev->m2m_ops->job_ready(m2m_ctx->priv))) {
46 dprintk("Driver not ready\n");
47 --- a/include/media/v4l2-mem2mem.h
48 +++ b/include/media/v4l2-mem2mem.h
49 @@ -75,6 +75,11 @@ struct v4l2_m2m_queue_ctx {
50 * struct v4l2_m2m_ctx - Memory to memory context structure
51 *
52 * @q_lock: struct &mutex lock
53 + * @new_frame: valid in the device_run callback: if true, then this
54 + * starts a new frame; if false, then this is a new slice
55 + * for an existing frame. This is always true unless
56 + * V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF is set, which
57 + * indicates slicing support.
58 * @m2m_dev: opaque pointer to the internal data to handle M2M context
59 * @cap_q_ctx: Capture (output to memory) queue context
60 * @out_q_ctx: Output (input from memory) queue context
61 @@ -91,6 +96,8 @@ struct v4l2_m2m_ctx {
62 /* optional cap/out vb2 queues lock */
63 struct mutex *q_lock;
64
65 + bool new_frame;
66 +
67 /* internal use only */
68 struct v4l2_m2m_dev *m2m_dev;
69