Show a patch.

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

{
    "id": 18756,
    "url": "https://patchwork.libcamera.org/api/patches/18756/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18756/",
    "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": "<20230621123712.7787-1-naush@raspberrypi.com>",
    "date": "2023-06-21T12:37:12",
    "name": "[libcamera-devel] ipa: rpi: imx296: Enable embedded data",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "e91f809c3e8812e2fab217268d260fb19e2e6016",
    "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/18756/mbox/",
    "series": [
        {
            "id": 3933,
            "url": "https://patchwork.libcamera.org/api/series/3933/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3933",
            "date": "2023-06-21T12:37:12",
            "name": "[libcamera-devel] ipa: rpi: imx296: Enable embedded data",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3933/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18756/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18756/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 20B7CBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Jun 2023 12:37:24 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 34643628C0;\n\tWed, 21 Jun 2023 14:37:23 +0200 (CEST)",
            "from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 47DBA61E41\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Jun 2023 14:37:21 +0200 (CEST)",
            "by mail-wm1-x32b.google.com with SMTP id\n\t5b1f17b1804b1-3f901f87195so37551325e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Jun 2023 05:37:21 -0700 (PDT)",
            "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ts10-20020a1cf20a000000b003f9b0cfbe30sm4868011wmc.36.2023.06.21.05.37.20\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 21 Jun 2023 05:37:20 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1687351043;\n\tbh=GCpAKYKVRCKRJL6HdWe2Tj29uLV0jpW2p1Tn2+x5Ib8=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=r2vjlAPoAy6tW+Itue1LRT5INKHqmoonKT3MEupGgnEn1HDajs4GyQgXeePfJ53ge\n\tO0Qq2Gx4XUDpk2FNt1vxJze1/s+DsmhMEcKPjIflBYNdN2p2YUbpg0UwbUL0PhAef5\n\tRFQDDa8g67n0tsKsqIss4x5L+QfJbWQVuMbFP53KmIJ+81Rr8GtjZ3GeWtmrdyBOnX\n\tcBUt2bpSDa+8l46R/cgEk+aiV5UWkZz6oDWMUdVgNQyUPi4a7U9M9jCE19lOyqr9jI\n\tUCOFQ+Lkt0jfYtqyd8W0TUmSKGjZ2rSRAetdn8luy3atdCs0JHMZySQi/ipoYp4902\n\tp16o+EQUClfDg==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1687351040; x=1689943040;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=YKI3ZckpxYyi6v/yb1y8SshgwKDM0rJrEComuJNIimI=;\n\tb=hG9npHECea8gusYtD6PwDNzTEel4FKgYEIfAr97Q56SRhhaeHTW059iq9zUSLqtDff\n\t9wjLpDUW51mXtTok9j6S8GDCpubuZawxlvqY5zRfDzbQZPMcGQKVjpBnzHkfnmIh3qn8\n\t+VJXlsKac2GMQcH2h9bWS/Yv2dH1pmCv9fDngWE267g/ka6/BCp58FpFCBUUcVhmFCsI\n\t5vEbLfQRcimx02mHy8WVz9ktXa/FTQDQMX7ZIPheijG7aCfW0vQ8zbGc/wJZYjm3lGbf\n\tiTaysZrz2kdC94wzUR9an9fOTM7c0TLtEIbXpBod5XVu+bPSH5ajWQQb4f7iq89sRW+Y\n\tVrLg=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"hG9npHEC\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1687351040; x=1689943040;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=YKI3ZckpxYyi6v/yb1y8SshgwKDM0rJrEComuJNIimI=;\n\tb=UlaAtwrBmav2FEfiETcUHFl/604vl6EH57+U/nma+2WtaU4juCUOwuRMCUFX6zXlRI\n\tnrNYW7Lk9a42CSUbbafJtQxFkfYZ5SANYgxq34nHyGh89omADhlQsXiEOMbP9a3r90VD\n\tnhnic9KKief+6sy62oGFvPK01i6kJ6G5WPm7HKYOanOR3yW2KzpiBeSu0IMbp0zPdXGx\n\tsv2SADaya+MD0M4mNb+A1JsfW/SOmiigDq7FhsJj/Ku6fohvOBiS0M7U3yak7yi5EStT\n\tZPUysCI2A8WfIbqagGqiBa3RbbzdI0Fy0vkCTrjP330zBIDZzcRlZSpGznsAuGSr4dmx\n\t3KaA==",
        "X-Gm-Message-State": "AC+VfDzoarGZ02F87MBeSMjwxMUFqC6TlNEKE+asWD1DhvurbQoIbc81\n\t3/K5AVn0bylyieKXW4A77D8WflfPXb7ki1FXOOqX4A==",
        "X-Google-Smtp-Source": "ACHHUZ5pP43A8QMSEZP+5wGjcBSmRQPL6d6WwVe5ftjRDaFpgsFZpKTq7/zj5M20h4WmPewJFztPrg==",
        "X-Received": "by 2002:a1c:f616:0:b0:3f6:d90:3db with SMTP id\n\tw22-20020a1cf616000000b003f60d9003dbmr13351892wmc.3.1687351040548; \n\tWed, 21 Jun 2023 05:37:20 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 21 Jun 2023 13:37:12 +0100",
        "Message-Id": "<20230621123712.7787-1-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] ipa: rpi: imx296: Enable embedded data",
        "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": "Enable embedded data parising for the imx296 sensor.\n\nHowever, the imx296 has a quirk where the embedded data is ahead by a\nsingle frame, i.e. embedded data in frame N corresponds to the image\ndata in frame N+1. So make a copy of the embedded data buffer stored in\nthe camera helper state, and use that copy in the next frame.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/cam_helper/cam_helper_imx296.cpp | 61 +++++++++++++++++++-\n 1 file changed, 60 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx296.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx296.cpp\nindex ecb845e76e12..8f06981b500e 100644\n--- a/src/ipa/rpi/cam_helper/cam_helper_imx296.cpp\n+++ b/src/ipa/rpi/cam_helper/cam_helper_imx296.cpp\n@@ -7,6 +7,7 @@\n \n #include <algorithm>\n #include <cmath>\n+#include <string.h>\n #include <stddef.h>\n \n #include \"cam_helper.h\"\n@@ -15,6 +16,17 @@ using namespace RPiController;\n using libcamera::utils::Duration;\n using namespace std::literals::chrono_literals;\n \n+constexpr uint32_t gainReg = 0x41ba;\n+constexpr uint32_t shsLoReg = 0x41b4;\n+constexpr uint32_t shsMidReg = 0x41b5;\n+constexpr uint32_t shsHiReg = 0x41b6;\n+constexpr uint32_t vmaxLoReg = 0x41cc;\n+constexpr uint32_t vmaxMidReg = 0x41cd;\n+constexpr uint32_t vmaxHiReg = 0x41ce;\n+constexpr uint32_t tempReg = 0x41da;\n+constexpr std::initializer_list<uint32_t> registerList =\n+\t{ gainReg, shsLoReg, shsMidReg, shsHiReg, vmaxLoReg, vmaxMidReg, vmaxHiReg, tempReg };\n+\n class CamHelperImx296 : public CamHelper\n {\n public:\n@@ -23,8 +35,12 @@ public:\n \tdouble gain(uint32_t gainCode) const override;\n \tuint32_t exposureLines(const Duration exposure, const Duration lineLength) const override;\n \tDuration exposure(uint32_t exposureLines, const Duration lineLength) const override;\n+\tvoid prepare(libcamera::Span<const uint8_t> buffer, Metadata &metadata) override;\n \tvoid getDelays(int &exposureDelay, int &gainDelay,\n \t\t       int &vblankDelay, int &hblankDelay) const override;\n+\tbool sensorEmbeddedDataPresent() const override;\n+\tvoid populateMetadata(const MdParser::RegisterMap &registers,\n+\t\t\t      Metadata &metadata) const override;\n \n private:\n \tstatic constexpr uint32_t minExposureLines = 1;\n@@ -36,10 +52,13 @@ private:\n \t * in units of lines.\n \t */\n \tstatic constexpr int frameIntegrationDiff = 4;\n+\n+\tstd::unique_ptr<uint8_t[]> lastEmbeddedBuffer_;\n+\tlibcamera::Span<uint8_t> embeddedBufferSpan_;\n };\n \n CamHelperImx296::CamHelperImx296()\n-\t: CamHelper(nullptr, frameIntegrationDiff)\n+\t: CamHelper(std::make_unique<MdParserSmia>(registerList), frameIntegrationDiff)\n {\n }\n \n@@ -66,6 +85,24 @@ Duration CamHelperImx296::exposure(uint32_t exposureLines,\n \treturn std::max<uint32_t>(minExposureLines, exposureLines) * timePerLine + 14.26us;\n }\n \n+void CamHelperImx296::prepare(libcamera::Span<const uint8_t> buffer, Metadata &metadata)\n+{\n+\t/*\n+\t * The imx296 embedded data is ahead by a single frame, i.e. embedded\n+\t * data in frame N corresponds to the image data in frame N+1. So make\n+\t * a copy of the embedded data buffer and use it as normal for the next\n+\t * frame.\n+\t */\n+\tCamHelper::prepare(embeddedBufferSpan_, metadata);\n+\n+\tif (embeddedBufferSpan_.size() != buffer.size()) {\n+\t\tlastEmbeddedBuffer_ = std::make_unique<uint8_t[]>(buffer.size());\n+\t\tembeddedBufferSpan_ = libcamera::Span(lastEmbeddedBuffer_.get(), buffer.size());\n+\t}\n+\n+\tmemcpy(embeddedBufferSpan_.data(), buffer.data(), embeddedBufferSpan_.size());\n+}\n+\n void CamHelperImx296::getDelays(int &exposureDelay, int &gainDelay,\n \t\t\t\tint &vblankDelay, int &hblankDelay) const\n {\n@@ -75,6 +112,28 @@ void CamHelperImx296::getDelays(int &exposureDelay, int &gainDelay,\n \thblankDelay = 2;\n }\n \n+bool CamHelperImx296::sensorEmbeddedDataPresent() const\n+{\n+\treturn true;\n+}\n+\n+void CamHelperImx296::populateMetadata(const MdParser::RegisterMap &registers,\n+\t\t\t\t       Metadata &metadata) const\n+{\n+\tuint32_t shs = registers.at(shsLoReg) + (registers.at(shsMidReg) << 8) +\n+\t\t       (registers.at(shsHiReg) << 16);\n+\tuint32_t vmax = registers.at(vmaxLoReg) + (registers.at(vmaxMidReg) << 8) +\n+\t\t\t(registers.at(vmaxHiReg) << 16);\n+\n+\tDeviceStatus deviceStatus;\n+\tdeviceStatus.lineLength = timePerLine;\n+\tdeviceStatus.frameLength = vmax;\n+\tdeviceStatus.shutterSpeed = exposure(vmax - shs, timePerLine);\n+\tdeviceStatus.analogueGain = gain(registers.at(gainReg));\n+\n+\tmetadata.set(\"device.status\", deviceStatus);\n+}\n+\n static CamHelper *create()\n {\n \treturn new CamHelperImx296();\n",
    "prefixes": [
        "libcamera-devel"
    ]
}