Patch Detail
Show a patch.
GET /api/1.1/patches/18758/?format=api
{ "id": 18758, "url": "https://patchwork.libcamera.org/api/1.1/patches/18758/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18758/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20230622150015.45888-1-umang.jain@ideasonboard.com>", "date": "2023-06-22T15:00:15", "name": "[libcamera-devel,v3] ipa: rpi: cam_helper: PDAF support for IMX519", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "1b794a0e3d2887a70f171630d8ced4767ffcdc37", "submitter": { "id": 86, "url": "https://patchwork.libcamera.org/api/1.1/people/86/?format=api", "name": "Umang Jain", "email": "umang.jain@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18758/mbox/", "series": [ { "id": 3935, "url": "https://patchwork.libcamera.org/api/1.1/series/3935/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3935", "date": "2023-06-22T15:00:15", "name": "[libcamera-devel,v3] ipa: rpi: cam_helper: PDAF support for IMX519", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3935/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18758/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18758/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 A6ABDC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Jun 2023 15:00:26 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E51A261E40;\n\tThu, 22 Jun 2023 17:00:25 +0200 (CEST)", "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 37ACD6002B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Jun 2023 17:00:24 +0200 (CEST)", "from umang.jainideasonboard.com (unknown [103.95.123.182])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E60D4DE;\n\tThu, 22 Jun 2023 16:59:46 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1687446025;\n\tbh=Gt8hRRf0GwbtN9l75y8QWn9T+BUARiLInQzIIEvmLmI=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=btCe082hjvpOZ4sHQOJQFq0JePATDXIfHUm5D7099ccCPRih5GQYnaEW6SkA876Wf\n\tm2x+VtiDXfbOV7HHKrwj2oT1Ul3xrAFi6HDW9WQA/3d51DNpSDwNijQu4rdoa91Y04\n\tb+BiR3WpbdPX4WrpAk7GJps3iSkLr9y8xuI6rZQOPNm4NVv2KdW9UDGTGv99Gerlf1\n\tksbGCfzVS3tX4LLBQAfMiqN/Mr0YfkqOoKglC924gTRHjrzLg0n3rhVUEqa+nlLXhf\n\tH1gF6WHcRaO41wY7dlmlBk/v6RIcxP3xgbH9cdZbEVIl1vyhesRQO4bG8Q/anSN5bl\n\t+6FTCoZWaQy7g==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1687445987;\n\tbh=Gt8hRRf0GwbtN9l75y8QWn9T+BUARiLInQzIIEvmLmI=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=ddVDverMSixHgpRv3JdMBckBzP9zJOOmDjZJbgt6FEMqmn5yPkMd5Vo5DtrtKwMB1\n\tXRqD9kXZNKUfNP1rNugBcjUaeynNNN0Ot9GbnOul5sTlEL383iOgguic/xjIaYyekU\n\tW6W43vYroLQw4c2kwYV8p7bqWPVg+LHXv9NafvBY=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ddVDverM\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 22 Jun 2023 20:30:15 +0530", "Message-Id": "<20230622150015.45888-1-umang.jain@ideasonboard.com>", "X-Mailer": "git-send-email 2.39.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3] ipa: rpi: cam_helper: PDAF support for\n\tIMX519", "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": "Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Umang Jain <umang.jain@ideasonboard.com>", "Cc": "Lee Jackson <lee.jackson@arducam.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Lee Jackson <lee.jackson@arducam.com>\n\nAdds the PDAF support for IMX519 camera module by Arducam.\n\nTested-by: Umang Jain <umang.jain@ideasonboard.com>\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\nSigned-off-by: Lee Jackson <lee.jackson@arducam.com>\n---\nChanges in v3:\n- Collect author's S-o-B from v2.\n\n---\n src/ipa/rpi/cam_helper/cam_helper_imx519.cpp | 50 ++++++++++++++++++++\n src/ipa/rpi/vc4/data/imx519.json | 40 ++++++++++++++++\n 2 files changed, 90 insertions(+)", "diff": "diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx519.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx519.cpp\nindex c7262aa0..6d032082 100644\n--- a/src/ipa/rpi/cam_helper/cam_helper_imx519.cpp\n+++ b/src/ipa/rpi/cam_helper/cam_helper_imx519.cpp\n@@ -15,9 +15,13 @@\n \n #include <libcamera/base/log.h>\n \n+#include \"controller/pdaf_data.h\"\n+\n #include \"cam_helper.h\"\n #include \"md_parser.h\"\n \n+#define ALIGN_UP(x, a) (((x) + (a)-1) & ~(a - 1))\n+\n using namespace RPiController;\n using namespace libcamera;\n using libcamera::utils::Duration;\n@@ -66,8 +70,13 @@ private:\n \t/* Largest long exposure scale factor given as a left shift on the frame length. */\n \tstatic constexpr int longExposureShiftMax = 7;\n \n+\tstatic constexpr int pdafStatsRows = 12;\n+\tstatic constexpr int pdafStatsCols = 16;\n+\n \tvoid populateMetadata(const MdParser::RegisterMap ®isters,\n \t\t\t Metadata &metadata) const override;\n+\tstatic bool parsePdafData(const uint8_t *ptr, size_t len, unsigned bpp,\n+\t\t\t\t PdafRegions &pdaf);\n };\n \n CamHelperImx519::CamHelperImx519()\n@@ -90,6 +99,11 @@ void CamHelperImx519::prepare(libcamera::Span<const uint8_t> buffer, Metadata &m\n \tMdParser::RegisterMap registers;\n \tDeviceStatus deviceStatus;\n \n+\tLOG(IPARPI, Debug) << \"Embedded buffer size: \" << buffer.size();\n+\n+\tsize_t bytesPerLine = (mode_.width * mode_.bitdepth) >> 3;\n+\tbytesPerLine = ALIGN_UP(bytesPerLine, 16);\n+\n \tif (metadata.get(\"device.status\", deviceStatus)) {\n \t\tLOG(IPARPI, Error) << \"DeviceStatus not found from DelayedControls\";\n \t\treturn;\n@@ -97,6 +111,14 @@ void CamHelperImx519::prepare(libcamera::Span<const uint8_t> buffer, Metadata &m\n \n \tparseEmbeddedData(buffer, metadata);\n \n+\tif (buffer.size() > 2 * bytesPerLine) {\n+\t\tPdafRegions pdaf;\n+\t\tparsePdafData(&buffer[2 * bytesPerLine],\n+\t\t\t buffer.size() - 2 * bytesPerLine,\n+\t\t\t mode_.bitdepth, pdaf);\n+\t\tmetadata.set(\"pdaf.data\", pdaf);\n+\t}\n+\n \t/*\n \t * The DeviceStatus struct is first populated with values obtained from\n \t * DelayedControls. If this reports frame length is > frameLengthMax,\n@@ -188,6 +210,34 @@ void CamHelperImx519::populateMetadata(const MdParser::RegisterMap ®isters,\n \tmetadata.set(\"device.status\", deviceStatus);\n }\n \n+bool CamHelperImx519::parsePdafData(const uint8_t *ptr, size_t len,\n+\t\t\t\t unsigned bpp, PdafRegions &pdaf)\n+{\n+\tsize_t step = bpp >> 1; /* bytes per PDAF grid entry */\n+\n+\tif (bpp < 10 || bpp > 12 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) {\n+\t\tLOG(IPARPI, Error) << \"PDAF data in unsupported format\";\n+\t\treturn false;\n+\t}\n+\n+\tpdaf.init({ pdafStatsCols, pdafStatsRows });\n+\n+\tptr += 2 * step;\n+\tfor (unsigned i = 0; i < pdafStatsRows; ++i) {\n+\t\tfor (unsigned j = 0; j < pdafStatsCols; ++j) {\n+\t\t\tunsigned c = (ptr[0] << 3) | (ptr[1] >> 5);\n+\t\t\tint p = (((ptr[1] & 0x0F) - (ptr[1] & 0x10)) << 6) | (ptr[2] >> 2);\n+\t\t\tPdafData pdafData;\n+\t\t\tpdafData.conf = c;\n+\t\t\tpdafData.phase = c ? p : 0;\n+\t\t\tpdaf.set(libcamera::Point(j, i), { pdafData, 1, 0 });\n+\t\t\tptr += step;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+\n static CamHelper *create()\n {\n \treturn new CamHelperImx519();\ndiff --git a/src/ipa/rpi/vc4/data/imx519.json b/src/ipa/rpi/vc4/data/imx519.json\nindex 1b0a7747..0733d97e 100644\n--- a/src/ipa/rpi/vc4/data/imx519.json\n+++ b/src/ipa/rpi/vc4/data/imx519.json\n@@ -350,6 +350,46 @@\n ]\n }\n },\n+ {\n+ \"rpi.af\":\n+ {\n+ \"ranges\":\n+ {\n+ \"normal\":\n+ {\n+ \"min\": 0.0,\n+ \"max\": 12.0,\n+ \"default\": 1.0\n+ },\n+ \"macro\":\n+ {\n+ \"min\": 3.0,\n+ \"max\": 15.0,\n+ \"default\": 4.0\n+ }\n+ },\n+ \"speeds\":\n+ {\n+ \"normal\":\n+ {\n+ \"step_coarse\": 1.0,\n+ \"step_fine\": 0.25,\n+ \"contrast_ratio\": 0.75,\n+ \"pdaf_gain\": -0.02,\n+ \"pdaf_squelch\": 0.125,\n+ \"max_slew\": 2.0,\n+ \"pdaf_frames\": 20,\n+ \"dropout_frames\": 6,\n+ \"step_frames\": 4\n+ }\n+ },\n+ \"conf_epsilon\": 8,\n+ \"conf_thresh\": 16,\n+ \"conf_clip\": 512,\n+ \"skip_frames\": 5,\n+ \"map\": [ 0.0, 0.0, 15.0, 4095 ]\n+ }\n+ },\n {\n \"rpi.ccm\":\n {\n", "prefixes": [ "libcamera-devel", "v3" ] }