From patchwork Mon Oct 3 08:39:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17496 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7BBD7C3288 for ; Mon, 3 Oct 2022 08:40:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0AEF462CFA; Mon, 3 Oct 2022 10:40:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786410; bh=AaC6lAuRrIb0QPhH2liWi7eEXXWDnFn2WPH3DcoZBRk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xt1TX/h9YNHL83sKzxUBsfw/CB7YpWTB6eF/ykSZt0U0TnIiuElq3ndKEfmtFeDMY BuJUJU7MViViiKGKOfEkawtBrYLiT/jSchUo+3y0sKecFD12uWGp46WKjlCySDPOqe AYU1lWHz2M0S715NJ6Bm/gp7uHZRE3KcFh8zyyRQPdB35o/9DXcB5/wJJ2PBR73HKW Z67mKDWt6UkQ5/b/4JobTCRTCGjh7ez/3R2D+WaV5QZZuW8Sv03CLFtab6wUIDILKP GfrqzYvyRsydQ8PmQoUreq3TO+x/+ZZekfmQJYiT4d9QwRioIE7wm13aTK9VCkjIUj BIbYEC/ZKND6Q== Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B36362CEA for ; Mon, 3 Oct 2022 10:40:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="aemwqF3u"; dkim-atps=neutral Received: by mail-wm1-x332.google.com with SMTP id r3-20020a05600c35c300b003b4b5f6c6bdso5415976wmq.2 for ; Mon, 03 Oct 2022 01:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ymnK8vfNa3P0z8WJVisbeR9rTR8rDaZY2QIaaCwwkRY=; b=aemwqF3ug8hns24q4V7K5ziC6rX/4XT1ct/Ypymgw+OlM5hTzGEIoIL6tpI+i7q3CB FJpv07ss+vCZyJUNDRRECScR5NHnqp4H6WKn00H6MtVEGlnVXnRUd00E770oWs9OySHd zIy9Abf21TyRlifp2WWtBzRVFU530fc+tUhfq7TveiH1W7swovmq1GIZP4yeGgUPjdbC rJham2vMZmLtLUhvhzQ2xxhKeXZ5RphN45Uo2FBjyada7BtbQc5vOU6VV+9T3eNxnShF v4doupGq+nrOzvtu8qQ+GjgcMbPEoklaq+Y9Ke5QjcQC05dL/CDAujgx8NOXELI+N2+G oABg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ymnK8vfNa3P0z8WJVisbeR9rTR8rDaZY2QIaaCwwkRY=; b=JBbjvL+kI/yj560HQQvh+jUpmA33GtAyB61ncUUOtl4aBjXlR900CUEzUv7Nnzarla ufKXRJjD1YYK5XiGQC/HLNDNauIhUlOpwBZ7hv+Ze/LcLHedVEWpwcY75NAvGFugyT6b Vaof6clB1TNVGaG6jUedLPyjTNJ+ZNT1tO8UV55Hu1jRZjiZGg6yd0rzmJOmHmDu9TlC U/3tFTNpao9+LUYls8SUvFPrg5EZWtIUlDGpJmjX7LTZ4HbaK2TgtznLU/ZAwgLFj76Z I0qjg3aOk4pfrKlwdArU9aAdOxPmelD5RLBxyLF3/J0hsUic6YaHmKduhgT7j+sDZ2IX AdKQ== X-Gm-Message-State: ACrzQf3ChqIEBO8UGNQMZINra9uz49IwFFcCCHG+ByQLyo+8fSPe5jmH oZF1iZsTyLwn7067+jCVGGTxT6Aimpb2Bg== X-Google-Smtp-Source: AMsMyM5i7NLKbjZ3p4bVR7uhJ7ND9ON7zqlps2L9QFumN9CPUw8MbxaTsz6lE4cl9oEZqEWEex7l2Q== X-Received: by 2002:a05:600c:4f46:b0:3b4:fed8:331e with SMTP id m6-20020a05600c4f4600b003b4fed8331emr6227992wmq.198.1664786403660; Mon, 03 Oct 2022 01:40:03 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:40:03 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:35 +0100 Message-Id: <20221003083934.31629-10-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 9/9] ipa: raspberrypi: Extract line length from the embedded data parser X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Update the imx219, imx477 and imx519 parsers to extract the line length values from the embedded data stream and use these values in the deviceStatus metadata, replacing the DelayedControls provided values. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper.cpp | 3 ++- src/ipa/raspberrypi/cam_helper_imx219.cpp | 9 +++++++-- src/ipa/raspberrypi/cam_helper_imx477.cpp | 9 +++++++-- src/ipa/raspberrypi/cam_helper_imx519.cpp | 9 +++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index f5f034ece711..1811d231ad40 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -228,7 +228,7 @@ void CamHelper::parseEmbeddedData(Span buffer, metadata.merge(parsedMetadata); /* - * Overwrite the exposure/gain, frame length and sensor temperature values + * Overwrite the exposure/gain, line/frame length and sensor temperature values * in the existing DeviceStatus with values from the parsed embedded buffer. * Fetch it first in case any other fields were set meaningfully. */ @@ -242,6 +242,7 @@ void CamHelper::parseEmbeddedData(Span buffer, deviceStatus.shutterSpeed = parsedDeviceStatus.shutterSpeed; deviceStatus.analogueGain = parsedDeviceStatus.analogueGain; deviceStatus.frameLength = parsedDeviceStatus.frameLength; + deviceStatus.lineLength = parsedDeviceStatus.lineLength; if (parsedDeviceStatus.sensorTemperature) deviceStatus.sensorTemperature = parsedDeviceStatus.sensorTemperature; diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp index 98a3b31956ec..c3337ed08466 100644 --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp @@ -32,8 +32,11 @@ constexpr uint32_t expHiReg = 0x15a; constexpr uint32_t expLoReg = 0x15b; constexpr uint32_t frameLengthHiReg = 0x160; constexpr uint32_t frameLengthLoReg = 0x161; +constexpr uint32_t lineLengthHiReg = 0x162; +constexpr uint32_t lineLengthLoReg = 0x163; constexpr std::initializer_list registerList [[maybe_unused]] - = { expHiReg, expLoReg, gainReg, frameLengthHiReg, frameLengthLoReg }; + = { expHiReg, expLoReg, gainReg, frameLengthHiReg, frameLengthLoReg, + lineLengthHiReg, lineLengthLoReg }; class CamHelperImx219 : public CamHelper { @@ -94,8 +97,10 @@ void CamHelperImx219::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; + deviceStatus.lineLength = lineLengthPckToDuration(registers.at(lineLengthHiReg) * 256 + + registers.at(lineLengthLoReg)); deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), - mode_.minLineLength); + deviceStatus.lineLength); deviceStatus.analogueGain = gain(registers.at(gainReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 19a5e471c27e..bc769ca75baa 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -35,9 +35,12 @@ constexpr uint32_t gainHiReg = 0x0204; constexpr uint32_t gainLoReg = 0x0205; constexpr uint32_t frameLengthHiReg = 0x0340; constexpr uint32_t frameLengthLoReg = 0x0341; +constexpr uint32_t lineLengthHiReg = 0x0342; +constexpr uint32_t lineLengthLoReg = 0x0343; constexpr uint32_t temperatureReg = 0x013a; constexpr std::initializer_list registerList = - { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg, temperatureReg }; + { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg, + lineLengthHiReg, lineLengthLoReg, temperatureReg }; class CamHelperImx477 : public CamHelper { @@ -175,8 +178,10 @@ void CamHelperImx477::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; + deviceStatus.lineLength = lineLengthPckToDuration(registers.at(lineLengthHiReg) * 256 + + registers.at(lineLengthLoReg)); deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), - mode_.minLineLength); + deviceStatus.lineLength); deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); deviceStatus.sensorTemperature = std::clamp(registers.at(temperatureReg), -20, 80); diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp index d2eb171912da..c7262aa0b6e6 100644 --- a/src/ipa/raspberrypi/cam_helper_imx519.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp @@ -36,8 +36,11 @@ constexpr uint32_t gainHiReg = 0x0204; constexpr uint32_t gainLoReg = 0x0205; constexpr uint32_t frameLengthHiReg = 0x0340; constexpr uint32_t frameLengthLoReg = 0x0341; +constexpr uint32_t lineLengthHiReg = 0x0342; +constexpr uint32_t lineLengthLoReg = 0x0343; constexpr std::initializer_list registerList = - { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg }; + { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg, + lineLengthHiReg, lineLengthLoReg }; class CamHelperImx519 : public CamHelper { @@ -175,8 +178,10 @@ void CamHelperImx519::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; + deviceStatus.lineLength = lineLengthPckToDuration(registers.at(lineLengthHiReg) * 256 + + registers.at(lineLengthLoReg)); deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), - mode_.minLineLength); + deviceStatus.lineLength); deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg);