media: rp1: cfe: Add is_image_node()
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Fri, 22 Sep 2023 10:47:10 +0000 (13:47 +0300)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:35:21 +0000 (11:35 +0000)
The hardware supports streaming from memory (in addition to streaming
from the CSI-2 RX), but the driver does not support this at the moment.

There are multiple places in the driver which uses
is_image_output_node(), even if the "output" part is not relevant. Thus,
in a minor preparation for the possible support for streaming from
memory, and to make it more obvious that the pieces of code are not
about the "output", add is_image_node() which will return true for both
input and output video nodes.

While at it, reformat also the metadata related macros to fit inside 80
columns.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
drivers/media/platform/raspberrypi/rp1_cfe/cfe.c

index cecc6fa..fe0ec1c 100644 (file)
@@ -199,13 +199,20 @@ static const struct node_description node_desc[NUM_NODES] = {
 
 #define is_fe_node(node) (((node)->id) >= FE_OUT0)
 #define is_csi2_node(node) (!is_fe_node(node))
-#define is_image_output_node(node)                                               \
+
+#define is_image_output_node(node) \
        (node_desc[(node)->id].buf_type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
-#define is_meta_output_node(node)                                                \
+#define is_image_input_node(node) \
+       (node_desc[(node)->id].buf_type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+#define is_image_node(node) \
+       (is_image_output_node(node) || is_image_input_node(node))
+
+#define is_meta_output_node(node) \
        (node_desc[(node)->id].buf_type == V4L2_BUF_TYPE_META_CAPTURE)
-#define is_meta_input_node(node)                                                 \
+#define is_meta_input_node(node) \
        (node_desc[(node)->id].buf_type == V4L2_BUF_TYPE_META_OUTPUT)
-#define is_meta_node(node) (is_meta_output_node(node) || is_meta_input_node(node))
+#define is_meta_node(node) \
+       (is_meta_output_node(node) || is_meta_input_node(node))
 
 /* To track state across all nodes. */
 #define NUM_STATES             5
@@ -426,7 +433,7 @@ static int format_show(struct seq_file *s, void *data)
                seq_printf(s, "\nNode %u (%s) state: 0x%lx\n", i,
                           node_desc[i].name, state);
 
-               if (is_image_output_node(node))
+               if (is_image_node(node))
                        seq_printf(s, "format: " V4L2_FOURCC_CONV " 0x%x\n"
                                      "resolution: %ux%u\nbpl: %u\nsize: %u\n",
                                   V4L2_FOURCC_CONV_ARGS(node->fmt.fmt.pix.pixelformat),
@@ -940,9 +947,8 @@ static int cfe_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
 {
        struct cfe_node *node = vb2_get_drv_priv(vq);
        struct cfe_device *cfe = node->cfe;
-       unsigned int size = is_image_output_node(node) ?
-                                         node->fmt.fmt.pix.sizeimage :
-                                         node->fmt.fmt.meta.buffersize;
+       unsigned int size = is_image_node(node) ? node->fmt.fmt.pix.sizeimage :
+                                                 node->fmt.fmt.meta.buffersize;
 
        cfe_dbg("%s: [%s]\n", __func__, node_desc[node->id].name);
 
@@ -973,8 +979,8 @@ static int cfe_buffer_prepare(struct vb2_buffer *vb)
        cfe_dbg_verbose("%s: [%s] buffer:%p\n", __func__,
                        node_desc[node->id].name, vb);
 
-       size = is_image_output_node(node) ? node->fmt.fmt.pix.sizeimage :
-                                           node->fmt.fmt.meta.buffersize;
+       size = is_image_node(node) ? node->fmt.fmt.pix.sizeimage :
+                                    node->fmt.fmt.meta.buffersize;
        if (vb2_plane_size(vb, 0) < size) {
                cfe_err("data will not fit into plane (%lu < %lu)\n",
                        vb2_plane_size(vb, 0), size);
@@ -1757,7 +1763,7 @@ static int cfe_register_node(struct cfe_device *cfe, int id)
        node->cfe = cfe;
        node->id = id;
 
-       if (is_image_output_node(node)) {
+       if (is_image_node(node)) {
                fmt = find_format_by_code(cfe_default_format.code);
                if (!fmt) {
                        cfe_err("Failed to find format code\n");