Show a patch.

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

{
    "id": 18702,
    "url": "https://patchwork.libcamera.org/api/patches/18702/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18702/",
    "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": "<20230605082605.9993-3-naush@raspberrypi.com>",
    "date": "2023-06-05T08:26:05",
    "name": "[libcamera-devel,v3,2/2] ipa: rpi: Handle controls for mono variant sensors",
    "commit_ref": "a0271e72a86da5796891795565f43f20f7024a8d",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "890a730a7fcc8bb55f3bc89b3d4fb2d5e8ada76a",
    "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/18702/mbox/",
    "series": [
        {
            "id": 3906,
            "url": "https://patchwork.libcamera.org/api/series/3906/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3906",
            "date": "2023-06-05T08:26:03",
            "name": "Mono sensor improvements",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/3906/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18702/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18702/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 AA0D8C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  5 Jun 2023 08:26:14 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 216C36288C;\n\tMon,  5 Jun 2023 10:26:14 +0200 (CEST)",
            "from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com\n\t[IPv6:2a00:1450:4864:20::12c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AB83D62887\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  5 Jun 2023 10:26:12 +0200 (CEST)",
            "by mail-lf1-x12c.google.com with SMTP id\n\t2adb3069b0e04-4f611ac39c5so3702588e87.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 05 Jun 2023 01:26:12 -0700 (PDT)",
            "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\t12-20020a05600c020c00b003f080b2f9f4sm13520686wmi.27.2023.06.05.01.26.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 05 Jun 2023 01:26:10 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1685953574;\n\tbh=rLfQ7RAKOhmYuA3lXFrxyksvQqSiaXEF1+w4XeTiCw0=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=oWUmphUfK7SqoJFE/kOxY0FKN5ALflkcqHT9RnKsab+QLFlkdp4RwRXaQXqDp3RVh\n\tBjtvpgJG+MO7pCIx7fsKnDCijqF0a/lDJY7QdD4l1fd5KPXGrgMuo3k+Zu67zHBcPc\n\tRfI/EDJ6P/U0Onr6IyBEXzybrCqngYJLvaC4CMFXG+jXaHVPjpwJvJCacn9IFjOMlz\n\tVobxKnQMiyKBcWmQ1V18l3V98W51e28u4caGEEfd8re1VJEQ5Kb3YliPTa4x4RUWdD\n\tvThio/laG2nFFWPLgaaQHPpmQusTZFSgN84qgvJFa0L2oYunEaPTaKd5ZfGSYuGAO1\n\tQ970bsgJoTIYA==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1685953571; x=1688545571;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=TYgdHBr0Gu7BZvR7BXYzmgmJeMThU6C/kNNpwP8vUB4=;\n\tb=DPZNk+5edPrsvG2PEQI6MUNAoX5uSaGm8E+0YcERMp6lKgbLnboYmbkAV1rJomqxs8\n\tJZNSsv7SOq3HAVivsDRXecjR+mf58sL2Mqe45DMEl9090BVA99Doicya41DJul0IhiTT\n\tK2r50rcBViny4QsZaFhojsZqL2T878+fT4TxvhrZXAqCJUu0ENhxqIAbddKkDV2fZQCp\n\t70AqBPZdp1MmPwEe1iSelh93jFm3EKvZuWyJajBHRBG8TZBrxuqdW/3VccdIWQ+SGdM0\n\turbeFK7496h+vXhqno7ImZW0s2ShAwGNgnMgBMjL7zE6WOLlmG4QFmTrkaMPNQBgY9vr\n\t09Rw=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"DPZNk+5e\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1685953571; x=1688545571;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=TYgdHBr0Gu7BZvR7BXYzmgmJeMThU6C/kNNpwP8vUB4=;\n\tb=Lw072GHyovkvdeKbq5AYXGfw3wR3U6JPGxyTdtkJL3JNmYi64IAzQY3Uc77g8ih+lX\n\thhfeRDZFL7mOA7E1NjLcpxiJHuhNd4U4MizQt9YYU63cShhwfh+oCG3KDjH+OdiNBHoH\n\t99h+cNVbMc2FylIDQCaRj2EP8BztyA9rkFRykAdb6axYmhVd+U/6c4evioesjt7DXnBq\n\turlHnvcqgp+uqfyBa76ugiprNQvqHfUiOVm2hQt+/vK2p2kL7AYbRX83HRmhOkheSSUc\n\tziEd6Lq8l9d8rYKe9znsVaq8I/CBKshP3EQtVZWMSPCbfFzas1e4zwYBJLsC0H+Os5IH\n\tOiuA==",
        "X-Gm-Message-State": "AC+VfDw92hopG3lbOynLFLq103BmNZwoMT8/lif9W7Aq32sKvSmqSAwO\n\tEUzS2wVKc2omMDwIP7Jp1tcTIGHeb/uHBgr+OAIjhw==",
        "X-Google-Smtp-Source": "ACHHUZ5e7tRMnSdTxWEi+mOatv3XWBVMFNSmhIk1ibYoh5KRC9Om++ctygiG8g/zdwZ3Y0FnNCrOWA==",
        "X-Received": "by 2002:a05:6512:40a:b0:4f3:8143:765 with SMTP id\n\tu10-20020a056512040a00b004f381430765mr4048582lfk.27.1685953571452; \n\tMon, 05 Jun 2023 01:26:11 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon,  5 Jun 2023 09:26:05 +0100",
        "Message-Id": "<20230605082605.9993-3-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20230605082605.9993-1-naush@raspberrypi.com>",
        "References": "<20230605082605.9993-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 2/2] ipa: rpi: Handle controls for mono\n\tvariant sensors",
        "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>",
        "From": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Naushir Patuck <naush@raspberrypi.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Do not advertise colour related controls (i.e. [A]WB, colour saturation)\nin the ControlInfoMap of available controls returned out to the\napplication.\n\nSilently ignore these controls in the control handler in case applications\ndon't use the advertised ControlInfoMap to validate controls.\n\nAs a drive-by, don't advertise controls::ColourCorrectionMatrix in the\nControlInfoMap as it is not handled by the IPA.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/ipa/raspberrypi.mojom       |  1 +\n src/ipa/rpi/common/ipa_base.cpp               | 39 ++++++++++++++++---\n src/ipa/rpi/common/ipa_base.h                 |  1 +\n .../pipeline/rpi/common/pipeline_base.cpp     | 10 ++++-\n 4 files changed, 45 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\nindex ba786e647ca1..1ea51f99e2bb 100644\n--- a/include/libcamera/ipa/raspberrypi.mojom\n+++ b/include/libcamera/ipa/raspberrypi.mojom\n@@ -21,6 +21,7 @@ struct SensorConfig {\n \n struct InitParams {\n \tbool lensPresent;\n+\tlibcamera.IPACameraSensorInfo sensorInfo;\n };\n \n struct InitResult {\ndiff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\nindex db7a0eb3a1ca..7fe8ee738e01 100644\n--- a/src/ipa/rpi/common/ipa_base.cpp\n+++ b/src/ipa/rpi/common/ipa_base.cpp\n@@ -12,6 +12,7 @@\n #include <libcamera/base/log.h>\n #include <libcamera/base/span.h>\n #include <libcamera/control_ids.h>\n+#include <libcamera/property_ids.h>\n \n #include \"controller/af_algorithm.h\"\n #include \"controller/af_status.h\"\n@@ -60,19 +61,22 @@ const ControlInfoMap::Map ipaControls{\n \t{ &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) },\n \t{ &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) },\n \t{ &controls::ExposureValue, ControlInfo(-8.0f, 8.0f, 0.0f) },\n-\t{ &controls::AwbEnable, ControlInfo(false, true) },\n-\t{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\n-\t{ &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\n \t{ &controls::Brightness, ControlInfo(-1.0f, 1.0f, 0.0f) },\n \t{ &controls::Contrast, ControlInfo(0.0f, 32.0f, 1.0f) },\n-\t{ &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) },\n \t{ &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },\n-\t{ &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) },\n \t{ &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) },\n \t{ &controls::FrameDurationLimits, ControlInfo(INT64_C(33333), INT64_C(120000)) },\n \t{ &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }\n };\n \n+/* IPA controls handled conditionally, if the sensor is not mono */\n+const ControlInfoMap::Map ipaColourControls{\n+\t{ &controls::AwbEnable, ControlInfo(false, true) },\n+\t{ &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\n+\t{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\n+\t{ &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) },\n+};\n+\n /* IPA controls handled conditionally, if the lens has a focus control */\n const ControlInfoMap::Map ipaAfControls{\n \t{ &controls::AfMode, ControlInfo(controls::AfModeValues) },\n@@ -146,6 +150,11 @@ int32_t IpaBase::init(const IPASettings &settings, const InitParams &params, Ini\n \tControlInfoMap::Map ctrlMap = ipaControls;\n \tif (lensPresent_)\n \t\tctrlMap.merge(ControlInfoMap::Map(ipaAfControls));\n+\n+\tmonoSensor_ = params.sensorInfo.cfaPattern == properties::draft::ColorFilterArrangementEnum::MONO;\n+\tif (!monoSensor_)\n+\t\tctrlMap.merge(ControlInfoMap::Map(ipaColourControls));\n+\n \tresult->controlInfo = ControlInfoMap(std::move(ctrlMap), controls::controls);\n \n \treturn platformInit(params, result);\n@@ -220,6 +229,10 @@ int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa\n \t\tControlInfo(static_cast<int32_t>(mode_.minShutter.get<std::micro>()),\n \t\t\t    static_cast<int32_t>(mode_.maxShutter.get<std::micro>()));\n \n+\t/* Declare colour processing related controls for non-mono sensors. */\n+\tif (!monoSensor_)\n+\t\tctrlMap.merge(ControlInfoMap::Map(ipaColourControls));\n+\n \t/* Declare Autofocus controls, only if we have a controllable lens */\n \tif (lensPresent_)\n \t\tctrlMap.merge(ControlInfoMap::Map(ipaAfControls));\n@@ -780,6 +793,10 @@ void IpaBase::applyControls(const ControlList &controls)\n \t\t}\n \n \t\tcase controls::AWB_ENABLE: {\n+\t\t\t/* Silently ignore this control for a mono sensor. */\n+\t\t\tif (monoSensor_)\n+\t\t\t\tbreak;\n+\n \t\t\tRPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n \t\t\t\tcontroller_.getAlgorithm(\"awb\"));\n \t\t\tif (!awb) {\n@@ -799,6 +816,10 @@ void IpaBase::applyControls(const ControlList &controls)\n \t\t}\n \n \t\tcase controls::AWB_MODE: {\n+\t\t\t/* Silently ignore this control for a mono sensor. */\n+\t\t\tif (monoSensor_)\n+\t\t\t\tbreak;\n+\n \t\t\tRPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n \t\t\t\tcontroller_.getAlgorithm(\"awb\"));\n \t\t\tif (!awb) {\n@@ -819,6 +840,10 @@ void IpaBase::applyControls(const ControlList &controls)\n \t\t}\n \n \t\tcase controls::COLOUR_GAINS: {\n+\t\t\t/* Silently ignore this control for a mono sensor. */\n+\t\t\tif (monoSensor_)\n+\t\t\t\tbreak;\n+\n \t\t\tauto gains = ctrl.second.get<Span<const float>>();\n \t\t\tRPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n \t\t\t\tcontroller_.getAlgorithm(\"awb\"));\n@@ -867,6 +892,10 @@ void IpaBase::applyControls(const ControlList &controls)\n \t\t}\n \n \t\tcase controls::SATURATION: {\n+\t\t\t/* Silently ignore this control for a mono sensor. */\n+\t\t\tif (monoSensor_)\n+\t\t\t\tbreak;\n+\n \t\t\tRPiController::CcmAlgorithm *ccm = dynamic_cast<RPiController::CcmAlgorithm *>(\n \t\t\t\tcontroller_.getAlgorithm(\"ccm\"));\n \t\t\tif (!ccm) {\ndiff --git a/src/ipa/rpi/common/ipa_base.h b/src/ipa/rpi/common/ipa_base.h\nindex 6f9c46bb16b1..39d00760d012 100644\n--- a/src/ipa/rpi/common/ipa_base.h\n+++ b/src/ipa/rpi/common/ipa_base.h\n@@ -87,6 +87,7 @@ private:\n \tstd::map<unsigned int, MappedFrameBuffer> buffers_;\n \n \tbool lensPresent_;\n+\tbool monoSensor_;\n \tControlList libcameraMetadata_;\n \n \tstd::array<RPiController::Metadata, numMetadataContexts> rpiMetadata_;\ndiff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex 3bb5ec531e4f..3aef1f43d697 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -1130,6 +1130,8 @@ int CameraData::loadPipelineConfiguration()\n \n int CameraData::loadIPA(ipa::RPi::InitResult *result)\n {\n+\tint ret;\n+\n \tipa_ = IPAManager::createIPA<ipa::RPi::IPAProxyRPi>(pipe(), 1, 1);\n \n \tif (!ipa_)\n@@ -1153,8 +1155,14 @@ int CameraData::loadIPA(ipa::RPi::InitResult *result)\n \tIPASettings settings(configurationFile, sensor_->model());\n \tipa::RPi::InitParams params;\n \n+\tret = sensor_->sensorInfo(&params.sensorInfo);\n+\tif (ret) {\n+\t\tLOG(RPI, Error) << \"Failed to retrieve camera sensor info\";\n+\t\treturn ret;\n+\t}\n+\n \tparams.lensPresent = !!sensor_->focusLens();\n-\tint ret = platformInitIpa(params);\n+\tret = platformInitIpa(params);\n \tif (ret)\n \t\treturn ret;\n \n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "2/2"
    ]
}