media: rp1: cfe: Fix width & height in cfe_start_channel()
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Wed, 27 Sep 2023 13:00:39 +0000 (16:00 +0300)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:35:02 +0000 (11:35 +0000)
commit5f177695a4e20500faa5501200b7cbc2c5d2f235
tree574b6ad1af0eb42d3d8e99317c8e20f6bf7642a1
parentd777b4518d357f2e4941aca667ee6b7a1d4d3269
media: rp1: cfe: Fix width & height in cfe_start_channel()

The logic for handling width & height in cfe_start_channel() is somewhat
odd and, afaics, broken. The code reads:

bool start_fe = is_fe_enabled(cfe) &&
                test_all_nodes(cfe, NODE_ENABLED, NODE_STREAMING);

if (start_fe || is_image_output_node(node)) {
        width = node->fmt.fmt.pix.width;
        height = node->fmt.fmt.pix.height;
}

cfe_start_channel() is called for all video nodes that will be used. So
this means that if, say, fe_stats is enabled as the last node, start_fe
will be true, and width and height will be taken from fe_stats' node.
The width and height will thus contain garbage, which then gets
programmed to the csi2 registers.

It seems that this often still works fine, though, probably if the width
& height are large enough.

Drop the above code, and instead get the width & height from the csi2
subdev's sink pad for the csi2 channel that is used. For metadata the
width & height will be 0 as before.

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