Show a patch.

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

{
    "id": 15464,
    "url": "https://patchwork.libcamera.org/api/patches/15464/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15464/",
    "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": "<20220317091937.168527-2-jeanmichel.hautbois@ideasonboard.com>",
    "date": "2022-03-17T09:19:38",
    "name": "[libcamera-devel,v2,2/2] ipa: raspberrypi: Control the lens position",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "9dd4b66af0adc8600d1c709b84e17335a27843f0",
    "submitter": {
        "id": 75,
        "url": "https://patchwork.libcamera.org/api/people/75/?format=api",
        "name": "Jean-Michel Hautbois",
        "email": "jeanmichel.hautbois@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15464/mbox/",
    "series": [
        {
            "id": 2969,
            "url": "https://patchwork.libcamera.org/api/series/2969/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2969",
            "date": "2022-03-17T09:19:37",
            "name": "[libcamera-devel,v2,1/2] libcamera: raspberrypi: Control the lens from pipeline",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2969/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15464/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15464/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\r\n\t[92.243.16.209])\r\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 99F4FC3262\r\n\tfor <parsemail@patchwork.libcamera.org>;\r\n\tThu, 17 Mar 2022 09:20:41 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 849FD6118A;\r\n\tThu, 17 Mar 2022 10:20:40 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\r\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D9765604DB\r\n\tfor <libcamera-devel@lists.libcamera.org>;\r\n\tThu, 17 Mar 2022 10:20:38 +0100 (CET)",
            "from tatooine.ideasonboard.com (unknown\r\n\t[IPv6:2a01:e0a:169:7140:2f87:7946:75e2:1cf1])\r\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9FE7E493;\r\n\tThu, 17 Mar 2022 10:20:38 +0100 (CET)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\r\n\ts=mail; t=1647508840;\r\n\tbh=bdgDfuPJ1ozz5TXBn7Aby1v5pkCWt/fZPD98PuF8clk=;\r\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\r\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\r\n\tFrom;\r\n\tb=Z6001+cEib7Xc1tPNIYIYVmNt69GhSUKYzUqkisrTkBATvNYan3BaQbUEvkU5P6L0\r\n\t8ag0rya2TRTkUoE6BM/qNT3Ja1X3t3bjOTglZdvpHcVDCZXT7Tc+cmos9ge/+p2Pez\r\n\tNN2+6AqQKuGdJyeZ4oZnuhLEx3wi+QWbJL7bOebpLOBiKsaM+894KvqOOZFi5vpUhm\r\n\tMtBtmsv2Tp2i4vKiD8KkshgAW5COlj+XaMJN/JVJaLYrpyhsOb7wrSw8be5hw4AjtF\r\n\tR0Z1AvL1yRvv10DpNe44E5TF7bfJwu06J4m02pxif3p3grU0l7CnwDUR4ycHJJEcZa\r\n\thRa/ZWGngS0ng==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\r\n\ts=mail; t=1647508838;\r\n\tbh=bdgDfuPJ1ozz5TXBn7Aby1v5pkCWt/fZPD98PuF8clk=;\r\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\r\n\tb=HEckDv1aFh0bNlN8dliagiMbQKJOJ+JMo5K3xKkRV9FRRECHiOBn/yXzlLSkQwArH\r\n\tH0cLQig+7WM/b75gXAk+oQ2Se6UWL4Ks/8kTOXjLd3aZ4q7UIZS6MJz/QOhXvn3oE6\r\n\t1pDtqpyAMeL4Mi8m1ofWy7rce/jrJi9dE6zo84Ls="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \r\n\tunprotected) header.d=ideasonboard.com\r\n\theader.i=@ideasonboard.com\r\n\theader.b=\"HEckDv1a\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 17 Mar 2022 10:19:38 +0100",
        "Message-Id": "<20220317091937.168527-2-jeanmichel.hautbois@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.32.0",
        "In-Reply-To": "<20220317091937.168527-1-jeanmichel.hautbois@ideasonboard.com>",
        "References": "<20220317091937.168527-1-jeanmichel.hautbois@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 2/2] ipa: raspberrypi: Control the lens\r\n\tposition",
        "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>,\r\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>,\r\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "From": "Jean-Michel Hautbois via libcamera-devel\r\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Now that the ancillary links are configured, we can use the CameraLens\nclass and control the VCM through the IPA.\nFor now, force a default value for the lens position, until the AF\nalgorithm is introduced.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/raspberrypi/raspberrypi.cpp | 41 ++++++++++++++++++++++++++++-\n 1 file changed, 40 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\r\nindex fd8fecb0..9e66f8fd 100644\r\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\r\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\r\n@@ -108,6 +108,7 @@ private:\r\n \tvoid setMode(const IPACameraSensorInfo &sensorInfo);\r\n \tbool validateSensorControls();\r\n \tbool validateIspControls();\r\n+\tbool validateLensControls();\r\n \tvoid queueRequest(const ControlList &controls);\r\n \tvoid returnEmbeddedBuffer(unsigned int bufferId);\r\n \tvoid prepareISP(const ipa::RPi::ISPConfig &data);\r\n@@ -132,6 +133,7 @@ private:\r\n \r\n \tControlInfoMap sensorCtrls_;\r\n \tControlInfoMap ispCtrls_;\r\n+\tControlInfoMap lensCtrls_;\r\n \tControlList libcameraMetadata_;\r\n \r\n \t/* Camera sensor params. */\r\n@@ -342,7 +344,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,\r\n \t\t      const ipa::RPi::IPAConfig &ipaConfig,\r\n \t\t      ControlList *controls)\r\n {\r\n-\tif (entityControls.size() != 2) {\r\n+\tif (entityControls.size() < 2) {\r\n \t\tLOG(IPARPI, Error) << \"No ISP or sensor controls found.\";\r\n \t\treturn -1;\r\n \t}\r\n@@ -360,6 +362,14 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,\r\n \t\treturn -1;\r\n \t}\r\n \r\n+\t/* Lens may not be present, don't make it an hard assumption. */\r\n+\tauto lensControl = entityControls.find(2);\r\n+\tif (lensControl != entityControls.end()) {\r\n+\t\tlensCtrls_ = lensControl->second;\r\n+\t\tif (!validateLensControls())\r\n+\t\t\tLOG(IPARPI, Error) << \"Lens control validation failed.\";\r\n+\t}\r\n+\r\n \tmaxSensorGainCode_ = sensorCtrls_.at(V4L2_CID_ANALOGUE_GAIN).max().get<int32_t>();\r\n \r\n \t/* Setup a metadata ControlList to output metadata. */\r\n@@ -578,6 +588,23 @@ bool IPARPi::validateIspControls()\r\n \treturn true;\r\n }\r\n \r\n+bool IPARPi::validateLensControls()\r\n+{\r\n+\tstatic const uint32_t ctrls[] = {\r\n+\t\tV4L2_CID_FOCUS_ABSOLUTE,\r\n+\t};\r\n+\r\n+\tfor (auto c : ctrls) {\r\n+\t\tif (lensCtrls_.find(c) == lensCtrls_.end()) {\r\n+\t\t\tLOG(IPARPI, Error) << \"Unable to find lens control \"\r\n+\t\t\t\t\t   << utils::hex(c);\r\n+\t\t\treturn false;\r\n+\t\t}\r\n+\t}\r\n+\r\n+\treturn true;\r\n+}\r\n+\r\n /*\r\n  * Converting between enums (used in the libcamera API) and the names that\r\n  * we use to identify different modes. Unfortunately, the conversion tables\r\n@@ -1066,6 +1093,18 @@ void IPARPi::processStats(unsigned int bufferId)\r\n \r\n \t\tsetDelayedControls.emit(ctrls);\r\n \t}\r\n+\r\n+\t/*\r\n+\t * Set the focus position\r\n+\t * \\todo Use an AF algorithm and replace the arbitrary value\r\n+\t */\r\n+\tstruct FocusStatus focusStatus;\r\n+\tif (rpiMetadata_.Get(\"focus.status\", focusStatus) == 0) {\r\n+\t\tControlList lensCtrls(lensCtrls_);\r\n+\t\tlensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, static_cast<int32_t>(123));\r\n+\t\tsetLensControls.emit(lensCtrls);\r\n+\t}\r\n+\r\n }\r\n \r\n void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "2/2"
    ]
}