bcm27xx: update 6.1 patches to latest version
[openwrt/staging/dangole.git] / target / linux / bcm27xx / patches-6.1 / 950-1033-drivers-media-rp1_cfe-Fix-link-validate-test-for-pix.patch
1 From c14550658832026e82111f2a89b3f7bf567afc1c Mon Sep 17 00:00:00 2001
2 From: Naushir Patuck <naush@raspberrypi.com>
3 Date: Tue, 17 Oct 2023 09:35:44 +0100
4 Subject: [PATCH] drivers: media: rp1_cfe: Fix link validate test for pixel
5 format
6
7 Now that we have removed unique PISP media bus codes, the cfe format
8 table has multiple entries with the same media bus code for 16-bit
9 formats. The test in cfe_video_link_validate() did not account for this.
10 Fix it by testing the media bus code and the V4L2 pixelformat 4cc
11 together.
12
13 As a drive-by, ensure we have a valid CSI2 datatype id when programming
14 the hardware block.
15
16 Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
17 ---
18 .../media/platform/raspberrypi/rp1_cfe/cfe.c | 19 ++++++++++++++++---
19 1 file changed, 16 insertions(+), 3 deletions(-)
20
21 --- a/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
22 +++ b/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
23 @@ -786,6 +786,9 @@ static void cfe_start_channel(struct cfe
24 width = source_fmt->width;
25 height = source_fmt->height;
26
27 + /* Must have a valid CSI2 datatype. */
28 + WARN_ON(!fmt->csi_dt);
29 +
30 /*
31 * Start the associated CSI2 Channel as well.
32 *
33 @@ -809,6 +812,9 @@ static void cfe_start_channel(struct cfe
34 node_desc[node->id].link_pad - CSI2_NUM_CHANNELS);
35 fmt = find_format_by_code(source_fmt->code);
36
37 + /* Must have a valid CSI2 datatype. */
38 + WARN_ON(!fmt->csi_dt);
39 +
40 if (is_image_output_node(node)) {
41 width = source_fmt->width;
42 height = source_fmt->height;
43 @@ -1504,7 +1510,8 @@ static int cfe_video_link_validate(struc
44
45 if (is_image_output_node(node)) {
46 struct v4l2_pix_format *pix_fmt = &node->fmt.fmt.pix;
47 - const struct cfe_fmt *fmt;
48 + const struct cfe_fmt *fmt = NULL;
49 + unsigned int i;
50
51 if (source_fmt->width != pix_fmt->width ||
52 source_fmt->height != pix_fmt->height) {
53 @@ -1516,8 +1523,14 @@ static int cfe_video_link_validate(struc
54 goto out;
55 }
56
57 - fmt = find_format_by_code(source_fmt->code);
58 - if (!fmt || fmt->fourcc != pix_fmt->pixelformat) {
59 + for (i = 0; i < ARRAY_SIZE(formats); i++) {
60 + if (formats[i].code == source_fmt->code &&
61 + formats[i].fourcc == pix_fmt->pixelformat) {
62 + fmt = &formats[i];
63 + break;
64 + }
65 + }
66 + if (!fmt) {
67 cfe_err("Format mismatch!\n");
68 ret = -EINVAL;
69 goto out;