Show a patch.

GET /api/patches/10623/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 10623,
    "url": "https://patchwork.libcamera.org/api/patches/10623/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10623/",
    "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": "<20201209095339.4107-1-naush@raspberrypi.com>",
    "date": "2020-12-09T09:53:39",
    "name": "[libcamera-devel] ipa: raspberrypi: Only validate ISP and Unicam controls during configure",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "cd73b59f70dcd791d36523b613d6843e6d316c5f",
    "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/10623/mbox/",
    "series": [
        {
            "id": 1518,
            "url": "https://patchwork.libcamera.org/api/series/1518/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1518",
            "date": "2020-12-09T09:53:39",
            "name": "[libcamera-devel] ipa: raspberrypi: Only validate ISP and Unicam controls during configure",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1518/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10623/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10623/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 BA9F7BDE19\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Dec 2020 09:53:46 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2052067E4D;\n\tWed,  9 Dec 2020 10:53:46 +0100 (CET)",
            "from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 27A4D635C4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Dec 2020 10:53:45 +0100 (CET)",
            "by mail-wr1-x42b.google.com with SMTP id r7so1022198wrc.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 09 Dec 2020 01:53:45 -0800 (PST)",
            "from naushir-VirtualBox.pitowers.org\n\t([2a00:1098:3142:14:a00:27ff:fe4d:f6a2])\n\tby smtp.gmail.com with ESMTPSA id\n\tw12sm2635015wre.57.2020.12.09.01.53.43\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 09 Dec 2020 01:53:43 -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=\"rgp0yHy9\"; 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:mime-version\n\t:content-transfer-encoding;\n\tbh=qWoZ5CpjT3w9n26TV/VtaSkHi37FTRfo/PrryIzxKfk=;\n\tb=rgp0yHy92rmvzgdOL6A+fd1EDYOPPk/qRw2s5lm4Vn3KzOhdjdfkFeKL1tWWl+Y+yq\n\tZfxidbQBZ8RyrNaIBGIhQBhOOwCc56zM6qxu/aswjQO/kPlEqB77FWWWsd4LXMU2m/4W\n\tKmaqCHcXkpLgyTDTnBJ16+wWShsIV6dIk1Fz1vF1MbEh7bXF1EckjWyW8q/4hbwZKJQR\n\tr2PJkf/n0PkbHFUfRWu3FmbKjkmvaThQYkK71dIPlO6xjPxGw6HQ+rlcuNlaIMgzlKcD\n\tjcEcSjZH1h6mddTlQJE+fMwyQd6S2JIm4d8d6CJbt9WDcPGi6cUVKb89mtNkjOphr1Q2\n\t1TWQ==",
        "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:mime-version\n\t:content-transfer-encoding;\n\tbh=qWoZ5CpjT3w9n26TV/VtaSkHi37FTRfo/PrryIzxKfk=;\n\tb=Hs1QISA6G1MtNVrqv8V0i6wxd0dbM3+46rbE/xORsB2BKeN5vX3pTDyW3aEwKmxIf9\n\tpOdINPkDnWX4vsA3Y0UVmG4lceaQcbF1+DBnXtLbwbY1MpBHIstrbW8C6dcuTDvnGxfd\n\tJLHoKsMZflPQern6xCCZLE+XkZVd2tuq9aMzMKIoarLit5pSqItmZqYs2OuKt8nf2Kmc\n\t/4LjmmcAyFI+X6YJs2XU3yJYEzVW+2satwk2TU3iF8iaonRJus/OLcy+H5I/dX7m1rXF\n\tQYjYOov8W1TWpQQrmTJLfSc/qdbhZkJKNF+jIFO0WrrM+3P9ia4IAO0wdbG8GF+BYSNW\n\tqaKw==",
        "X-Gm-Message-State": "AOAM531O+aarHBGrVmWghxj9sMBs68JrEaQgmjEnmQYO9fOOTE0QOzUw\n\td3Fhw13gjeA4wxF5VWhQ2lOw5GVg/4FOKg==",
        "X-Google-Smtp-Source": "ABdhPJxJjC+3ITwMngu7eahrVBotTOQr/rC0uwzoMpu/owtlIC7+l4nADNA3hUa9jYuaagji/ccf3A==",
        "X-Received": "by 2002:a5d:6386:: with SMTP id p6mr1723970wru.261.1607507624398;\n\tWed, 09 Dec 2020 01:53:44 -0800 (PST)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  9 Dec 2020 09:53:39 +0000",
        "Message-Id": "<20201209095339.4107-1-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH] ipa: raspberrypi: Only validate ISP and\n\tUnicam controls 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 Unicam V4L2 controls on\nevery frame. Simply validate them once during the IPA configuration, and\nfail if a required control is not available.\n\nAlso add some whitespace for readability.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/raspberrypi.cpp | 131 ++++++++++++++--------------\n 1 file changed, 64 insertions(+), 67 deletions(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 60cfdc27..e5d2b41e 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 validateUnicamControls();\n+\tbool validateIspControls();\n \tvoid queueRequest(const ControlList &controls);\n \tvoid returnEmbeddedBuffer(unsigned int bufferId);\n \tvoid prepareISP(unsigned int bufferId);\n@@ -238,6 +240,16 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \tunicamCtrls_ = entityControls.at(0);\n \tispCtrls_ = entityControls.at(1);\n \n+\tif (!validateUnicamControls()) {\n+\t\tLOG(IPARPI, Error) << \"Unicam control validation failed.\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (!validateIspControls()) {\n+\t\tLOG(IPARPI, Error) << \"ISP control validation failed.\";\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Setup a metadata ControlList to output metadata. */\n \tlibcameraMetadata_ = ControlList(controls::controls);\n \n@@ -473,6 +485,51 @@ void IPARPi::reportMetadata()\n \t}\n }\n \n+bool IPARPi::validateUnicamControls()\n+{\n+\tconst 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 (unicamCtrls_.find(c) == unicamCtrls_.end()) {\n+\t\t\tLOG(IPARPI, Error) << \"Unable to find Unicam control \"\n+\t\t\t\t\t   << c;\n+\t\t\treturn false;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+\n+bool IPARPi::validateIspControls()\n+{\n+\tconst 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   << 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@@ -858,18 +915,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@@ -884,16 +929,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 (unicamCtrls_.find(V4L2_CID_ANALOGUE_GAIN) == unicamCtrls_.end()) {\n-\t\tLOG(IPARPI, Error) << \"Can't find analogue gain control\";\n-\t\treturn;\n-\t}\n-\n-\tif (unicamCtrls_.find(V4L2_CID_EXPOSURE) == unicamCtrls_.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@@ -905,23 +940,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@@ -937,12 +963,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@@ -956,12 +978,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@@ -974,12 +992,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@@ -992,12 +1006,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@@ -1012,12 +1022,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@@ -1033,12 +1039,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@@ -1049,11 +1051,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"
    ]
}