{"id":15101,"url":"https://patchwork.libcamera.org/api/patches/15101/?format=json","web_url":"https://patchwork.libcamera.org/patch/15101/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211209133252.2234668-2-naush@raspberrypi.com>","date":"2021-12-09T13:32:51","name":"[libcamera-devel,v3,1/2] pipeline: raspberrypi: Move sensor entity detection out of registerCamera()","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"36450bd158321de60381eab163eaabf7e81cd383","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15101/mbox/","series":[{"id":2832,"url":"https://patchwork.libcamera.org/api/series/2832/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2832","date":"2021-12-09T13:32:50","name":"Raspberry Pi: Add video mux and bridge support","version":3,"mbox":"https://patchwork.libcamera.org/series/2832/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15101/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15101/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id EFC70BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Dec 2021 13:33:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B06B060890;\n\tThu,  9 Dec 2021 14:32:59 +0100 (CET)","from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com\n\t[IPv6:2a00:1450:4864:20::32f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 235CD6086A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Dec 2021 14:32:57 +0100 (CET)","by mail-wm1-x32f.google.com with SMTP id\n\to19-20020a1c7513000000b0033a93202467so4088365wmc.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 09 Dec 2021 05:32:57 -0800 (PST)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:a3bd:8799:8317:6d3f])\n\tby smtp.gmail.com with ESMTPSA id\n\tr15sm8449244wmh.13.2021.12.09.05.32.55\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 09 Dec 2021 05:32:56 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"cnQ0RPb8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=nJnkmgQAsgdErldvbjoJq1Zg/UvxAKQrj2jHEwu8eT0=;\n\tb=cnQ0RPb8In0cnqTpOntQS1pQV1d8GjZiWD/654Siwn325l+MfKeqsQiGvsk3imu8IE\n\tCghP+yWJwrfUEGMuGf8Oor20VEYx02LEcUU8zOpMFY3cUEaXGpkdxJRQPAyegNDPs2b2\n\tqKwYn2jELjFjDtq7qM0E8CxvaW7stuQoBpZzwSsulmnsMrTui0zmQBM+thL5Pu7v37bg\n\tNWA/YzK5M7ybLPQFbiswIGHrSsPBPk9qXWEd5ah+P1qrBiIj2bZWH8mg/4eRRFALR439\n\tqaTktJ462K6Nu+vghk4yWiinAd4xQkyxRbbKA02O33vNXLujhsZVNt2kXb7R+tFziD0+\n\t8Qaw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=nJnkmgQAsgdErldvbjoJq1Zg/UvxAKQrj2jHEwu8eT0=;\n\tb=51wNWr+fjgF1099E6Ek83ojdQBUh11fciaAQzcdcAA6a6fpE2/Ck/CiqMaUalFciNv\n\tBgIGyEBknWwQUe7WDIdaNEcZnc6UvTRZiI+75FrwubdxRHWttdCb8upBl3QmhjhT0IJj\n\tWiZgApjtx4W1t4SxjUYIW6zNBO0toGleEAbB8z1VWNnYdvRf0LAKVVVv+Kr44svQNVaj\n\tJWUYF6RGfnfl6gIzsDH+Au+v0lkvhV3LCEBlUQdiPBnbW9xeuKDAEeguU0SadNxrHFS4\n\tThwCVzG6i9SKpnJYv6CfCrxF12IO7viunR+7UMEyIJbsEoDx+VXPfetg6BaJvWLIImf9\n\ttt2Q==","X-Gm-Message-State":"AOAM531psP+oRx3nDfR1e3aTMTIqYKMOeQWYZjiO4E5g+REySYTu7djE\n\tUmDaNHzfVdAKogvasSV/Md2yEggOppLvJXgP","X-Google-Smtp-Source":"ABdhPJxW2pc3ItQvRGfUN1u8Mo5OL14lwNo8GMNnrQYooZxZRJR05UVCQ3vdnekQtTNb/97P82meYQ==","X-Received":"by 2002:a05:600c:3658:: with SMTP id\n\ty24mr7242621wmq.161.1639056776530; \n\tThu, 09 Dec 2021 05:32:56 -0800 (PST)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  9 Dec 2021 13:32:51 +0000","Message-Id":"<20211209133252.2234668-2-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20211209133252.2234668-1-naush@raspberrypi.com>","References":"<20211209133252.2234668-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 1/2] pipeline: raspberrypi: Move sensor\n\tentity detection out of registerCamera()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Enumerate the sensor device entities in PipelineHandlerRPi::match() and loop\nover PipelineHandlerRPi::registerCamera() for each sensor found. This will\nallow the pipeline handler to register multiple cameras attached to a single\nUnicam instance with a Video Mux device.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 35 +++++++++++--------\n 1 file changed, 20 insertions(+), 15 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 86851ac467ad..2a2fb5273eb8 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -310,7 +310,7 @@ private:\n \t\treturn static_cast<RPiCameraData *>(camera->_d());\n \t}\n \n-\tint registerCamera(MediaDevice *unicam, MediaDevice *isp);\n+\tint registerCamera(MediaDevice *unicam, MediaDevice *isp, MediaEntity *sensorEntity);\n \tint queueAllBuffers(Camera *camera);\n \tint prepareBuffers(Camera *camera);\n \tvoid freeBuffers(Camera *camera);\n@@ -1029,16 +1029,28 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \t}\n \n-\tint ret = registerCamera(unicamDevice, ispDevice);\n-\tif (ret) {\n-\t\tLOG(RPI, Error) << \"Failed to register camera: \" << ret;\n-\t\treturn false;\n+\t/*\n+\t * The loop below is used to register multiple cameras behind one or more\n+\t * video mux devices that are attached to a particular Unicam instance.\n+\t * Obviously these cameras cannot be used simultaneously.\n+\t */\n+\tunsigned int numCameras = 0;\n+\tfor (MediaEntity *entity : unicamDevice->entities()) {\n+\t\tif (entity->function() != MEDIA_ENT_F_CAM_SENSOR)\n+\t\t\tcontinue;\n+\n+\t\tint ret = registerCamera(unicamDevice, ispDevice, entity);\n+\t\tif (ret)\n+\t\t\tLOG(RPI, Error) << \"Failed to register camera \"\n+\t\t\t\t\t<< entity->name() << \": \" << ret;\n+\t\telse\n+\t\t\tnumCameras++;\n \t}\n \n-\treturn true;\n+\treturn !!numCameras;\n }\n \n-int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp)\n+int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, MediaEntity *sensorEntity)\n {\n \tstd::unique_ptr<RPiCameraData> data = std::make_unique<RPiCameraData>(this);\n \n@@ -1079,14 +1091,7 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp)\n \tdata->isp_[Isp::Output1].dev()->bufferReady.connect(data.get(), &RPiCameraData::ispOutputDequeue);\n \tdata->isp_[Isp::Stats].dev()->bufferReady.connect(data.get(), &RPiCameraData::ispOutputDequeue);\n \n-\t/* Identify the sensor. */\n-\tfor (MediaEntity *entity : unicam->entities()) {\n-\t\tif (entity->function() == MEDIA_ENT_F_CAM_SENSOR) {\n-\t\t\tdata->sensor_ = std::make_unique<CameraSensor>(entity);\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\n+\tdata->sensor_ = std::make_unique<CameraSensor>(sensorEntity);\n \tif (!data->sensor_)\n \t\treturn -EINVAL;\n \n","prefixes":["libcamera-devel","v3","1/2"]}