From aa749f7cd42a4e70472139b96801c5408bed1d3d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 26 Jun 2024 00:56:52 +0200 Subject: [PATCH] MediaControl: Dymically set mainline IVSC media-entity src-pad index Since mainline kernel commit 48f5fd8967f8 ("media: ivsc: csi: Swap SINK and SOURCE pads") the src-pad on the mainline ivsc mc-entity is pad 1, where as on older versions it is pad 0. When updating the sensor link to point to the IVSC instead, link.srcPad was left at pad-0 inherited from the original sensor link. Since with newer kernels this now needs to be pad-1, also update link.srcPad and do so dynamically, so that it works with all mainline IVSC driver versions. This fixes ipu6-camera-hal / icamerasrc not working on laptops with an IVSC chip running kernels using the mainline IVSC driver with the mentioned commit. Signed-off-by: Hans de Goede --- src/v4l2/MediaControl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/v4l2/MediaControl.cpp b/src/v4l2/MediaControl.cpp index a371e544..6145225e 100644 --- a/src/v4l2/MediaControl.cpp +++ b/src/v4l2/MediaControl.cpp @@ -886,6 +886,15 @@ int MediaControl::mediaCtlSetup(int cameraId, MediaCtlConf* mc, int width, int h ivscName.c_str(), link.sinkEntityName.c_str()); link.srcEntity = ivsc->info.id; link.srcEntityName = ivscName; + /* + * Since mainline kernel commit 48f5fd8967f8 ("media: + * ivsc: csi: Swap SINK and SOURCE pads") the src-pad + * on the mainline ivsc mc-entity is pad 1, where on + * older versions it is pad 0, so this needs to be set + * dynamically. + * The src-pad is the other pad of the found ivsc sink. + */ + link.srcPad = !ivsc->links[i].sink->index; break; } }