{"id":22203,"url":"https://patchwork.libcamera.org/api/patches/22203/?format=json","web_url":"https://patchwork.libcamera.org/patch/22203/","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":"<20241206101344.767170-12-stefan.klug@ideasonboard.com>","date":"2024-12-06T10:13:33","name":"[v3,11/17] libcamera: rkisp1: Refactor path validation","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1b7f93524a5fe5119c9e4e0bc12c862975840d23","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":{"id":17,"url":"https://patchwork.libcamera.org/api/users/17/?format=json","username":"epaul","first_name":"Paul","last_name":"Elder","email":"paul.elder@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/22203/mbox/","series":[{"id":4854,"url":"https://patchwork.libcamera.org/api/series/4854/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4854","date":"2024-12-06T10:13:22","name":"rkisp1: Fix aspect ratio and ScalerCrop","version":3,"mbox":"https://patchwork.libcamera.org/series/4854/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22203/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22203/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 D9B43BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Dec 2024 10:14:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5CC4766154;\n\tFri,  6 Dec 2024 11:14:24 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 21DE866150\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Dec 2024 11:14:20 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:3543:aebe:e043:ef86])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B41DF74C;\n\tFri,  6 Dec 2024 11:13:50 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"VnLWf9K9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1733480030;\n\tbh=yHnzyZRM5IV6dwy8fEaHRE2myWj0YapRWHx+OZjs6Dg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=VnLWf9K9nu+2HBaruLZAYzPTlnK5iTmxDE5ZYRXbAjxWc2VtLeY8GVLsn0gyMFWNo\n\tU2xyMqP/j34/KGYq7Ie0x7Ubh+C8DfCnYzANVLJZxDz5Jm6DxQX117Xd9bunHFfy5F\n\tk4wWTD2kOKF7vIBwvMZD/2G+ql+T6NrhYiPPC3Dw=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>","Subject":"[PATCH v3 11/17] libcamera: rkisp1: Refactor path validation","Date":"Fri,  6 Dec 2024 11:13:33 +0100","Message-ID":"<20241206101344.767170-12-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20241206101344.767170-1-stefan.klug@ideasonboard.com>","References":"<20241206101344.767170-1-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"Refactor validation code to prepare for extensions in the upcoming\npatches. Code duplication is reduced by moving parts of the validation\nlogic into a lambda function. This patch does not include any functional\nchanges.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\n---\nChanges in v3:\n- Added this patch\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 35 +++++++++++++-----------\n 1 file changed, 19 insertions(+), 16 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 098c560ca5c8..7f41092ee2d5 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -558,50 +558,53 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n \tif (config_.size() == 2 && fitsAllPaths(config_[0]))\n \t\tstd::reverse(order.begin(), order.end());\n \n+\tauto validateConfig = [&](StreamConfiguration &cfg, RkISP1Path *path,\n+\t\t\t\t  Stream *stream, Status expectedStatus) {\n+\t\tStreamConfiguration tryCfg = cfg;\n+\t\tif (path->validate(sensor, sensorConfig, &tryCfg) != expectedStatus)\n+\t\t\treturn false;\n+\n+\t\tcfg = tryCfg;\n+\t\tcfg.setStream(stream);\n+\t\treturn true;\n+\t};\n+\n \tbool mainPathAvailable = true;\n \tbool selfPathAvailable = data_->selfPath_;\n+\tRkISP1Path *mainPath = data_->mainPath_;\n+\tRkISP1Path *selfPath = data_->selfPath_;\n+\tStream *mainPathStream = const_cast<Stream *>(&data_->mainPathStream_);\n+\tStream *selfPathStream = const_cast<Stream *>(&data_->selfPathStream_);\n \tfor (unsigned int index : order) {\n \t\tStreamConfiguration &cfg = config_[index];\n \n \t\t/* Try to match stream without adjusting configuration. */\n \t\tif (mainPathAvailable) {\n-\t\t\tStreamConfiguration tryCfg = cfg;\n-\t\t\tif (data_->mainPath_->validate(sensor, sensorConfig, &tryCfg) == Valid) {\n+\t\t\tif (validateConfig(cfg, mainPath, mainPathStream, Valid)) {\n \t\t\t\tmainPathAvailable = false;\n-\t\t\t\tcfg = tryCfg;\n-\t\t\t\tcfg.setStream(const_cast<Stream *>(&data_->mainPathStream_));\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t}\n \n \t\tif (selfPathAvailable) {\n-\t\t\tStreamConfiguration tryCfg = cfg;\n-\t\t\tif (data_->selfPath_->validate(sensor, sensorConfig, &tryCfg) == Valid) {\n+\t\t\tif (validateConfig(cfg, selfPath, selfPathStream, Valid)) {\n \t\t\t\tselfPathAvailable = false;\n-\t\t\t\tcfg = tryCfg;\n-\t\t\t\tcfg.setStream(const_cast<Stream *>(&data_->selfPathStream_));\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t}\n \n \t\t/* Try to match stream allowing adjusting configuration. */\n \t\tif (mainPathAvailable) {\n-\t\t\tStreamConfiguration tryCfg = cfg;\n-\t\t\tif (data_->mainPath_->validate(sensor, sensorConfig, &tryCfg) == Adjusted) {\n+\t\t\tif (validateConfig(cfg, mainPath, mainPathStream, Adjusted)) {\n \t\t\t\tmainPathAvailable = false;\n-\t\t\t\tcfg = tryCfg;\n-\t\t\t\tcfg.setStream(const_cast<Stream *>(&data_->mainPathStream_));\n \t\t\t\tstatus = Adjusted;\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t}\n \n \t\tif (selfPathAvailable) {\n-\t\t\tStreamConfiguration tryCfg = cfg;\n-\t\t\tif (data_->selfPath_->validate(sensor, sensorConfig, &tryCfg) == Adjusted) {\n+\t\t\tif (validateConfig(cfg, selfPath, selfPathStream, Adjusted)) {\n \t\t\t\tselfPathAvailable = false;\n-\t\t\t\tcfg = tryCfg;\n-\t\t\t\tcfg.setStream(const_cast<Stream *>(&data_->selfPathStream_));\n \t\t\t\tstatus = Adjusted;\n \t\t\t\tcontinue;\n \t\t\t}\n","prefixes":["v3","11/17"]}