Patch Detail
Show a patch.
GET /api/patches/10669/?format=api
{ "id": 10669, "url": "https://patchwork.libcamera.org/api/patches/10669/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10669/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20201215101633.21546-2-naush@raspberrypi.com>", "date": "2020-12-15T10:16:33", "name": "[libcamera-devel,2/2] ipa: raspberrypi: Only validate ISP and sensor control during configure", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "ce469b44a81eafdf733e9a7836a003d926e18db2", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/10669/mbox/", "series": [ { "id": 1534, "url": "https://patchwork.libcamera.org/api/series/1534/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1534", "date": "2020-12-15T10:16:32", "name": "[libcamera-devel,1/2] ipa: raspberrypi: Rename unicamCtrls_ to sensorCtrls_", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1534/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10669/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10669/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 DD8D8BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 15 Dec 2020 10:16:40 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EE1C461594;\n\tTue, 15 Dec 2020 11:16:39 +0100 (CET)", "from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4B694600FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Dec 2020 11:16:38 +0100 (CET)", "by mail-wm1-x32b.google.com with SMTP id q75so17938857wme.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Dec 2020 02:16:38 -0800 (PST)", "from localhost.localdomain ([2a00:1098:3142:14:a00:27ff:fe4d:f6a2])\n\tby smtp.gmail.com with ESMTPSA id\n\ts63sm39801117wms.18.2020.12.15.02.16.36\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 15 Dec 2020 02:16:36 -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=\"mRQYluoY\"; 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=lXMmv1RSkTY6TxW3gM14i/0ixKRskwN7lmq08a9CYME=;\n\tb=mRQYluoYckrz29as1PSYgXBNB+0Dvz799xe8FBSjO77vYDNY1oDKNEXPNWGL7kcNOm\n\t4ZgVdwJrCouxJi174cJ5TM5awhMvKhWlG1X9nOLQSuW3fPhgJjnHW2t1odDjHNrm561E\n\tT6Onixv6/Jy1qXlD/stWGcWVu19TFESz8zKUBCLreKfRRaSHF5mvKq830VZuef330TFV\n\tPhTQMISznQrqiTwTqny6K4AVXL3hO8N3r5/ADDU6jtl/mB5QNFTYQquAPskl5B6nGvD9\n\tpnjr1Hg+f9TuO2cRKbJkA2xOeN9mUs2AxurhJIVI8EbsBgTDllr88N787iLKtGX7f4rv\n\tG9JA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\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=lXMmv1RSkTY6TxW3gM14i/0ixKRskwN7lmq08a9CYME=;\n\tb=AaP/1iCN/VUQyndwV0DqjrgToxnj16RO4kgpQLAz9c1pueuNLX+uepAXJ8ttDGo/Du\n\tCb+3CqbWSc71DGIxJ27LZlTANVN567WeA7NeBK89AG9fPSmEbapT56BzTJYp94Aq5ynr\n\tgAYhU5R+ddYsdVSPv4mXVikCpRobGoQexmEYNoc8cMLulgw9VG6wDSpRRA77yKofJEU3\n\t8YEL/Ptovsx3IhJYjfw85HkcgWk7WNffwcjo48cRcciGIHu+mUQmnVYOX6Y173BZV1NE\n\t8V6QkDnIxM0f/Q+lWWTAPXCZFEr7IhxOfpULVN9yX/V7c4zuGAUV2Ef1CtfKrT4Vl1Bd\n\tcdeg==", "X-Gm-Message-State": "AOAM530eJeScx30uXMlRrLotlE5JXPXpD2lCTmGtu9vfi8vlY50Sed+E\n\txn0FchToTr21bfP9IqJwoE7/joVzD2i10Q==", "X-Google-Smtp-Source": "ABdhPJyoSbY2jnNr4811021060pdQzO4fdbh5k0FQnDoiWv2Ehe/q6lo5Y1rQBy4w/lZKG5GWC/WTg==", "X-Received": "by 2002:a7b:c24d:: with SMTP id\n\tb13mr25442973wmj.151.1608027397669; \n\tTue, 15 Dec 2020 02:16:37 -0800 (PST)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 15 Dec 2020 10:16:33 +0000", "Message-Id": "<20201215101633.21546-2-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20201215101633.21546-1-naush@raspberrypi.com>", "References": "<20201215101633.21546-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Only validate ISP\n\tand sensor control during configure", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "There is no need to validate all the ISP and sensor V4L2 control on\nevery use. Simply validate them once during the IPA configuration, and\nfail if a required control is not available.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/raspberrypi.cpp | 133 ++++++++++++++--------------\n 1 file changed, 66 insertions(+), 67 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 5f2e07fd..bf544553 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -92,6 +92,8 @@ public:\n \n private:\n \tvoid setMode(const CameraSensorInfo &sensorInfo);\n+\tbool validateSensorControls();\n+\tbool validateIspControls();\n \tvoid queueRequest(const ControlList &controls);\n \tvoid returnEmbeddedBuffer(unsigned int bufferId);\n \tvoid prepareISP(unsigned int bufferId);\n@@ -290,6 +292,18 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \tsensorCtrls_ = entityControls.at(0);\n \tispCtrls_ = entityControls.at(1);\n \n+\tif (!validateSensorControls()) {\n+\t\tLOG(IPARPI, Error) << \"Sensor control validation failed.\";\n+\t\tresult->operation = RPi::IPA_CONFIG_FAILED;\n+\t\treturn;\n+\t}\n+\n+\tif (!validateIspControls()) {\n+\t\tLOG(IPARPI, Error) << \"ISP control validation failed.\";\n+\t\tresult->operation = RPi::IPA_CONFIG_FAILED;\n+\t\treturn;\n+\t}\n+\n \t/* Setup a metadata ControlList to output metadata. */\n \tlibcameraMetadata_ = ControlList(controls::controls);\n \n@@ -506,6 +520,51 @@ void IPARPi::reportMetadata()\n \t}\n }\n \n+bool IPARPi::validateSensorControls()\n+{\n+\tstatic const uint32_t ctrls[] = {\n+\t\tV4L2_CID_ANALOGUE_GAIN,\n+\t\tV4L2_CID_EXPOSURE\n+\t};\n+\n+\tfor (auto c : ctrls) {\n+\t\tif (sensorCtrls_.find(c) == sensorCtrls_.end()) {\n+\t\t\tLOG(IPARPI, Error) << \"Unable to find Unicam control \"\n+\t\t\t\t\t << utils::hex(c);\n+\t\t\treturn false;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+\n+bool IPARPi::validateIspControls()\n+{\n+\tstatic const uint32_t ctrls[] = {\n+\t\tV4L2_CID_RED_BALANCE,\n+\t\tV4L2_CID_BLUE_BALANCE,\n+\t\tV4L2_CID_DIGITAL_GAIN,\n+\t\tV4L2_CID_USER_BCM2835_ISP_CC_MATRIX,\n+\t\tV4L2_CID_USER_BCM2835_ISP_GAMMA,\n+\t\tV4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL,\n+\t\tV4L2_CID_USER_BCM2835_ISP_GEQ,\n+\t\tV4L2_CID_USER_BCM2835_ISP_DENOISE,\n+\t\tV4L2_CID_USER_BCM2835_ISP_SHARPEN,\n+\t\tV4L2_CID_USER_BCM2835_ISP_DPC,\n+\t\tV4L2_CID_USER_BCM2835_ISP_LENS_SHADING\n+\t};\n+\n+\tfor (auto c : ctrls) {\n+\t\tif (ispCtrls_.find(c) == ispCtrls_.end()) {\n+\t\t\tLOG(IPARPI, Error) << \"Unable to find ISP control \"\n+\t\t\t\t\t << utils::hex(c);\n+\t\t\treturn false;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+\n /*\n * Converting between enums (used in the libcamera API) and the names that\n * we use to identify different modes. Unfortunately, the conversion tables\n@@ -891,18 +950,6 @@ void IPARPi::processStats(unsigned int bufferId)\n \n void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)\n {\n-\tconst auto gainR = ispCtrls_.find(V4L2_CID_RED_BALANCE);\n-\tif (gainR == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find red gain control\";\n-\t\treturn;\n-\t}\n-\n-\tconst auto gainB = ispCtrls_.find(V4L2_CID_BLUE_BALANCE);\n-\tif (gainB == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find blue gain control\";\n-\t\treturn;\n-\t}\n-\n \tLOG(IPARPI, Debug) << \"Applying WB R: \" << awbStatus->gain_r << \" B: \"\n \t\t\t << awbStatus->gain_b;\n \n@@ -917,16 +964,6 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)\n \tint32_t gainCode = helper_->GainCode(agcStatus->analogue_gain);\n \tint32_t exposureLines = helper_->ExposureLines(agcStatus->shutter_time);\n \n-\tif (sensorCtrls_.find(V4L2_CID_ANALOGUE_GAIN) == sensorCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find analogue gain control\";\n-\t\treturn;\n-\t}\n-\n-\tif (sensorCtrls_.find(V4L2_CID_EXPOSURE) == sensorCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find exposure control\";\n-\t\treturn;\n-\t}\n-\n \tLOG(IPARPI, Debug) << \"Applying AGC Exposure: \" << agcStatus->shutter_time\n \t\t\t << \" (Shutter lines: \" << exposureLines << \") Gain: \"\n \t\t\t << agcStatus->analogue_gain << \" (Gain Code: \"\n@@ -938,23 +975,14 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)\n \n void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls)\n {\n-\tif (ispCtrls_.find(V4L2_CID_DIGITAL_GAIN) == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find digital gain control\";\n-\t\treturn;\n-\t}\n-\n \tctrls.set(V4L2_CID_DIGITAL_GAIN,\n \t\t static_cast<int32_t>(dgStatus->digital_gain * 1000));\n }\n \n void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls)\n {\n-\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_CC_MATRIX) == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find CCM control\";\n-\t\treturn;\n-\t}\n-\n \tbcm2835_isp_custom_ccm ccm;\n+\n \tfor (int i = 0; i < 9; i++) {\n \t\tccm.ccm.ccm[i / 3][i % 3].den = 1000;\n \t\tccm.ccm.ccm[i / 3][i % 3].num = 1000 * ccmStatus->matrix[i];\n@@ -970,12 +998,8 @@ void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls)\n \n void IPARPi::applyGamma(const struct ContrastStatus *contrastStatus, ControlList &ctrls)\n {\n-\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_GAMMA) == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find Gamma control\";\n-\t\treturn;\n-\t}\n-\n \tstruct bcm2835_isp_gamma gamma;\n+\n \tgamma.enabled = 1;\n \tfor (int i = 0; i < CONTRAST_NUM_POINTS; i++) {\n \t\tgamma.x[i] = contrastStatus->points[i].x;\n@@ -989,12 +1013,8 @@ void IPARPi::applyGamma(const struct ContrastStatus *contrastStatus, ControlList\n \n void IPARPi::applyBlackLevel(const struct BlackLevelStatus *blackLevelStatus, ControlList &ctrls)\n {\n-\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL) == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find black level control\";\n-\t\treturn;\n-\t}\n-\n \tbcm2835_isp_black_level blackLevel;\n+\n \tblackLevel.enabled = 1;\n \tblackLevel.black_level_r = blackLevelStatus->black_level_r;\n \tblackLevel.black_level_g = blackLevelStatus->black_level_g;\n@@ -1007,12 +1027,8 @@ void IPARPi::applyBlackLevel(const struct BlackLevelStatus *blackLevelStatus, Co\n \n void IPARPi::applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls)\n {\n-\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_GEQ) == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find geq control\";\n-\t\treturn;\n-\t}\n-\n \tbcm2835_isp_geq geq;\n+\n \tgeq.enabled = 1;\n \tgeq.offset = geqStatus->offset;\n \tgeq.slope.den = 1000;\n@@ -1025,12 +1041,8 @@ void IPARPi::applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls)\n \n void IPARPi::applyDenoise(const struct SdnStatus *denoiseStatus, ControlList &ctrls)\n {\n-\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_DENOISE) == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find denoise control\";\n-\t\treturn;\n-\t}\n-\n \tbcm2835_isp_denoise denoise;\n+\n \tdenoise.enabled = 1;\n \tdenoise.constant = denoiseStatus->noise_constant;\n \tdenoise.slope.num = 1000 * denoiseStatus->noise_slope;\n@@ -1045,12 +1057,8 @@ void IPARPi::applyDenoise(const struct SdnStatus *denoiseStatus, ControlList &ct\n \n void IPARPi::applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls)\n {\n-\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_SHARPEN) == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find sharpen control\";\n-\t\treturn;\n-\t}\n-\n \tbcm2835_isp_sharpen sharpen;\n+\n \tsharpen.enabled = 1;\n \tsharpen.threshold.num = 1000 * sharpenStatus->threshold;\n \tsharpen.threshold.den = 1000;\n@@ -1066,12 +1074,8 @@ void IPARPi::applySharpen(const struct SharpenStatus *sharpenStatus, ControlList\n \n void IPARPi::applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls)\n {\n-\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_DPC) == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find DPC control\";\n-\t\treturn;\n-\t}\n-\n \tbcm2835_isp_dpc dpc;\n+\n \tdpc.enabled = 1;\n \tdpc.strength = dpcStatus->strength;\n \n@@ -1082,11 +1086,6 @@ void IPARPi::applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls)\n \n void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls)\n {\n-\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING) == ispCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find LS control\";\n-\t\treturn;\n-\t}\n-\n \t/*\n \t * Program lens shading tables into pipeline.\n \t * Choose smallest cell size that won't exceed 63x48 cells.\n", "prefixes": [ "libcamera-devel", "2/2" ] }