Patch Detail
Show a patch.
GET /api/patches/18743/?format=api
{ "id": 18743, "url": "https://patchwork.libcamera.org/api/patches/18743/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18743/", "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": "<20230615182044.95347-1-umang.jain@ideasonboard.com>", "date": "2023-06-15T18:20:44", "name": "[libcamera-devel] ipa: rpi: cam_helper: PDAF support for IMX519", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "1b794a0e3d2887a70f171630d8ced4767ffcdc37", "submitter": { "id": 86, "url": "https://patchwork.libcamera.org/api/people/86/?format=api", "name": "Umang Jain", "email": "umang.jain@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18743/mbox/", "series": [ { "id": 3926, "url": "https://patchwork.libcamera.org/api/series/3926/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3926", "date": "2023-06-15T18:20:44", "name": "[libcamera-devel] ipa: rpi: cam_helper: PDAF support for IMX519", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3926/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18743/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18743/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 702A7BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Jun 2023 18:20:53 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 87261628B5;\n\tThu, 15 Jun 2023 20:20:52 +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 39E93614FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Jun 2023 20:20:51 +0200 (CEST)", "from umang.jainideasonboard.com (unknown [103.251.226.67])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 70B15547;\n\tThu, 15 Jun 2023 20:20:18 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1686853252;\n\tbh=1l3fwkdhwaHy3NicUvZyjisQ41EvTRyMZdjbzuign+o=;\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=kOkFLREcRvsZzzt/9VwfkPBEF3nj1p1X7lRzghDsM+zHrJdE7KFQ12W7HBYy3vyfe\n\tvIkM5pl/ykJBElHxFUKxL3ejTrtl+FT4fcfkK3ONiC8Fv7uHQT23wClIHsvNYAy78X\n\tjwRh1x0T4eT/3FQQC7dZtlap+3Vn0rYhBPBwP4oVLL9+uAmAGxxPd53zriKsM7kQC4\n\txlzaYOl74YX9G02n3o9VjvYOnxutYFaT6olxH/xg5pDEHTpraucaxs+h/6O3zOXD0b\n\tOqULRquAV8nu/GDz3PgU6dL5emcYJdlGioRE6k9oNHClZFulAvG8yj2FJeBSkvPtjd\n\tyeGpE8Q2396zA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1686853219;\n\tbh=1l3fwkdhwaHy3NicUvZyjisQ41EvTRyMZdjbzuign+o=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=NniTov2Seb6e2rxrbY9I+qXUnSC7vPJ5butLRXIIiHqkheTBP8hD/r5XUC5Y+Ijb2\n\tu4l8LxkOP4k2Xfsq9jcJFbaXdXlHzTS7TyktI3djXWNCnOe7ftzF6nGuRrpc2MNP0k\n\txiJvRhojaOAnMHjXit+FyUDcP7jDWp+N22m6VrAw=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"NniTov2S\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 15 Jun 2023 23:50:44 +0530", "Message-Id": "<20230615182044.95347-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] 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": "sdfasdf <asdfasdfasdf@asdfasdf.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: sdfasdf <asdfasdfasdf@asdfasdf.com>\n\nAdds the PDAF support for IMX519 camera module by Arducam.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\nPatch originally not authored by me, but we are missing main author's \nfull-name and email.\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" ] }