bcm27xx: update 6.1 patches to latest version
[openwrt/staging/svanheule.git] / target / linux / bcm27xx / patches-6.1 / 950-1207-media-rp1-cfe-Add-is_image_node.patch
1 From 2b6570e66f2769110311593f52f88dba3271a278 Mon Sep 17 00:00:00 2001
2 From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
3 Date: Fri, 22 Sep 2023 13:47:10 +0300
4 Subject: [PATCH] media: rp1: cfe: Add is_image_node()
5
6 The hardware supports streaming from memory (in addition to streaming
7 from the CSI-2 RX), but the driver does not support this at the moment.
8
9 There are multiple places in the driver which uses
10 is_image_output_node(), even if the "output" part is not relevant. Thus,
11 in a minor preparation for the possible support for streaming from
12 memory, and to make it more obvious that the pieces of code are not
13 about the "output", add is_image_node() which will return true for both
14 input and output video nodes.
15
16 While at it, reformat also the metadata related macros to fit inside 80
17 columns.
18
19 Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
20 ---
21 .../media/platform/raspberrypi/rp1_cfe/cfe.c | 28 +++++++++++--------
22 1 file changed, 17 insertions(+), 11 deletions(-)
23
24 --- a/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
25 +++ b/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
26 @@ -199,13 +199,20 @@ static const struct node_description nod
27
28 #define is_fe_node(node) (((node)->id) >= FE_OUT0)
29 #define is_csi2_node(node) (!is_fe_node(node))
30 -#define is_image_output_node(node) \
31 +
32 +#define is_image_output_node(node) \
33 (node_desc[(node)->id].buf_type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
34 -#define is_meta_output_node(node) \
35 +#define is_image_input_node(node) \
36 + (node_desc[(node)->id].buf_type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
37 +#define is_image_node(node) \
38 + (is_image_output_node(node) || is_image_input_node(node))
39 +
40 +#define is_meta_output_node(node) \
41 (node_desc[(node)->id].buf_type == V4L2_BUF_TYPE_META_CAPTURE)
42 -#define is_meta_input_node(node) \
43 +#define is_meta_input_node(node) \
44 (node_desc[(node)->id].buf_type == V4L2_BUF_TYPE_META_OUTPUT)
45 -#define is_meta_node(node) (is_meta_output_node(node) || is_meta_input_node(node))
46 +#define is_meta_node(node) \
47 + (is_meta_output_node(node) || is_meta_input_node(node))
48
49 /* To track state across all nodes. */
50 #define NUM_STATES 5
51 @@ -426,7 +433,7 @@ static int format_show(struct seq_file *
52 seq_printf(s, "\nNode %u (%s) state: 0x%lx\n", i,
53 node_desc[i].name, state);
54
55 - if (is_image_output_node(node))
56 + if (is_image_node(node))
57 seq_printf(s, "format: " V4L2_FOURCC_CONV " 0x%x\n"
58 "resolution: %ux%u\nbpl: %u\nsize: %u\n",
59 V4L2_FOURCC_CONV_ARGS(node->fmt.fmt.pix.pixelformat),
60 @@ -940,9 +947,8 @@ static int cfe_queue_setup(struct vb2_qu
61 {
62 struct cfe_node *node = vb2_get_drv_priv(vq);
63 struct cfe_device *cfe = node->cfe;
64 - unsigned int size = is_image_output_node(node) ?
65 - node->fmt.fmt.pix.sizeimage :
66 - node->fmt.fmt.meta.buffersize;
67 + unsigned int size = is_image_node(node) ? node->fmt.fmt.pix.sizeimage :
68 + node->fmt.fmt.meta.buffersize;
69
70 cfe_dbg("%s: [%s]\n", __func__, node_desc[node->id].name);
71
72 @@ -973,8 +979,8 @@ static int cfe_buffer_prepare(struct vb2
73 cfe_dbg_verbose("%s: [%s] buffer:%p\n", __func__,
74 node_desc[node->id].name, vb);
75
76 - size = is_image_output_node(node) ? node->fmt.fmt.pix.sizeimage :
77 - node->fmt.fmt.meta.buffersize;
78 + size = is_image_node(node) ? node->fmt.fmt.pix.sizeimage :
79 + node->fmt.fmt.meta.buffersize;
80 if (vb2_plane_size(vb, 0) < size) {
81 cfe_err("data will not fit into plane (%lu < %lu)\n",
82 vb2_plane_size(vb, 0), size);
83 @@ -1757,7 +1763,7 @@ static int cfe_register_node(struct cfe_
84 node->cfe = cfe;
85 node->id = id;
86
87 - if (is_image_output_node(node)) {
88 + if (is_image_node(node)) {
89 fmt = find_format_by_code(cfe_default_format.code);
90 if (!fmt) {
91 cfe_err("Failed to find format code\n");