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
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
12 Iterate through the sensor pads to find the relevant source pads.
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
16 drivers/media/platform/raspberrypi/rp1_cfe/cfe.c | 15 ++++++++++++---
17 1 file changed, 12 insertions(+), 3 deletions(-)
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
23 static int cfe_link_node_pads(struct cfe_device *cfe)
26 + unsigned int i, source_pad = 0;
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))
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))
41 + if (source_pad < cfe->sensor->entity.num_pads) {
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);
51 + /* Dealt with that source_pad, look at the next one next time */
55 /* CSI2 channel # -> /dev/video# */