Skip to content

Commit

Permalink
drivers: media: cfe: Find the source pads on the sensor entity
Browse files Browse the repository at this point in the history
The driver was assuming that pad 0 on the sensor entity was the
appropriate source pad, but this isn't necessarily the case.
With video-mux, it has the sink pads first, and then the source
pad as the last one.

Iterate through the sensor pads to find the relevant source pads.

Signed-off-by: Dave Stevenson <[email protected]>
  • Loading branch information
6by9 authored and naushir committed Nov 27, 2023
1 parent 057e09b commit 76b1bbf
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ static void cfe_unregister_nodes(struct cfe_device *cfe)

static int cfe_link_node_pads(struct cfe_device *cfe)
{
unsigned int i;
unsigned int i, source_pad = 0;
int ret;

for (i = 0; i < CSI2_NUM_CHANNELS; i++) {
Expand All @@ -1835,14 +1835,23 @@ static int cfe_link_node_pads(struct cfe_device *cfe)
if (!check_state(cfe, NODE_REGISTERED, i))
continue;

if (i < cfe->sensor->entity.num_pads) {
/* Find next source pad */
while (source_pad < cfe->sensor->entity.num_pads &&
!(cfe->sensor->entity.pads[source_pad].flags &
MEDIA_PAD_FL_SOURCE))
source_pad++;

if (source_pad < cfe->sensor->entity.num_pads) {
/* Sensor -> CSI2 */
ret = media_create_pad_link(&cfe->sensor->entity, i,
ret = media_create_pad_link(&cfe->sensor->entity, source_pad,
&cfe->csi2.sd.entity, i,
MEDIA_LNK_FL_IMMUTABLE |
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;

/* Dealt with that source_pad, look at the next one next time */
source_pad++;
}

/* CSI2 channel # -> /dev/video# */
Expand Down

0 comments on commit 76b1bbf

Please sign in to comment.