bcm27xx: update 6.1 patches to latest version
[openwrt/staging/dangole.git] / target / linux / bcm27xx / patches-6.1 / 950-1172-drivers-media-cfe-Find-the-source-pads-on-the-sensor.patch
1 From 76b1bbf3ec3be0afdc768863ab7e9bbd2734b97b Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 24 Nov 2023 14:29:57 +0000
4 Subject: [PATCH] drivers: media: cfe: Find the source pads on the sensor
5 entity
6
7 The driver was assuming that pad 0 on the sensor entity was the
8 appropriate source pad, but this isn't necessarily the case.
9 With video-mux, it has the sink pads first, and then the source
10 pad as the last one.
11
12 Iterate through the sensor pads to find the relevant source pads.
13
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 ---
16 drivers/media/platform/raspberrypi/rp1_cfe/cfe.c | 15 ++++++++++++---
17 1 file changed, 12 insertions(+), 3 deletions(-)
18
19 --- a/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
20 +++ b/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
21 @@ -1826,7 +1826,7 @@ static void cfe_unregister_nodes(struct
22
23 static int cfe_link_node_pads(struct cfe_device *cfe)
24 {
25 - unsigned int i;
26 + unsigned int i, source_pad = 0;
27 int ret;
28
29 for (i = 0; i < CSI2_NUM_CHANNELS; i++) {
30 @@ -1835,14 +1835,23 @@ static int cfe_link_node_pads(struct cfe
31 if (!check_state(cfe, NODE_REGISTERED, i))
32 continue;
33
34 - if (i < cfe->sensor->entity.num_pads) {
35 + /* Find next source pad */
36 + while (source_pad < cfe->sensor->entity.num_pads &&
37 + !(cfe->sensor->entity.pads[source_pad].flags &
38 + MEDIA_PAD_FL_SOURCE))
39 + source_pad++;
40 +
41 + if (source_pad < cfe->sensor->entity.num_pads) {
42 /* Sensor -> CSI2 */
43 - ret = media_create_pad_link(&cfe->sensor->entity, i,
44 + ret = media_create_pad_link(&cfe->sensor->entity, source_pad,
45 &cfe->csi2.sd.entity, i,
46 MEDIA_LNK_FL_IMMUTABLE |
47 MEDIA_LNK_FL_ENABLED);
48 if (ret)
49 return ret;
50 +
51 + /* Dealt with that source_pad, look at the next one next time */
52 + source_pad++;
53 }
54
55 /* CSI2 channel # -> /dev/video# */