From patchwork Fri Jun 24 07:35:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16363 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 8D244BD808 for ; Fri, 24 Jun 2022 07:35:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B4566563A; Fri, 24 Jun 2022 09:35:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656056134; bh=oC1T9Bzvpbqx6SM/dzRwJZwUrQNjZdB+6cC84dChtKc=; 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=t9L+6Kt++7jJWl2abX1ikV2/BSyL4Cku19s0g2ZPhQdfmlRBSVe5Fy8zsw+mjJ5AP w9Xhr2aWubX+KQ6hmeIqcisVjQmgP5vn08ZvdP22SNWHaqvUw6Ska96D4RXtvtVFDd CJih06U2pATTMTQvnt9c7VSlkj2rcuXTuhcL+fmau1IUMI50dgk4+oM0SEP2+0BH98 rAd4o6mn5dSD/tgH/0OjEycvhcUp5hAhppcPksAXU+5e4Grg1R9imJgr5KJz+yEVxv EG2IOnx6lrh66ksRsYKDorPMhV/0tLzcEu5EqpOcDG7nea/OjeBEjNFmUUSzB10MtM a0N7dMc3YHU2Q== Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 915F565633 for ; Fri, 24 Jun 2022 09:35:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="iS9iEIt4"; dkim-atps=neutral Received: by mail-wr1-x42c.google.com with SMTP id e7so1899485wrc.13 for ; Fri, 24 Jun 2022 00:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TlD5JbWM88aNCrfmfL0dUsbi9Rk7oEjslHnb/ehI1TE=; b=iS9iEIt4FZ7N9kIW+WLgJmytNEuXHU3kXjyZZLt7AqDa9OcUclzibBjJ31dQHVQmsB q8mz9NyyuvooICDHzTQOx8urQFXGw8zfH2qCbiUGvUHvOll9rnBtfYcllWP8VlnpKeNJ XTv2mcc30sdSMaOBqKz4mLesKFiV3aDuNZJcVWAEBfTPUonEtBPFGx+VsHfE23OVLQX5 mnLwWM4r9mpHSumDvOcleGY15+5v1cC5AQV/HwUZxBjhgZY8lYft/5MTmKhWiTTH68xr sehWTuYm0Kbwjps0u2ToFpOAdRkcx2VgL+ALiRkYcU6jZIM8Nh1vIWzBvNf0XnWG7Wh1 u++w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TlD5JbWM88aNCrfmfL0dUsbi9Rk7oEjslHnb/ehI1TE=; b=SlFsM/fhcl0ilFlCQzFwrY9k/YYjVUc2BMYmTKYkARGIAtRmsRKnOXLqm7cWyDctAd Ii1v06RE0V2n/98G7lH0750otVPZ4t+acBpUHu2BeiQcv2DQGa+KcC4iGDYQuMJUOhFq FlnuoKATm9LRLrDa9ARTqeSvht/TAZf1D09dmXEHdmsd10hMpbdZXW+xk09OwQZptqPM 6fq42Ig4EVxAaykPGMuVayIz51rVMfL9Vs1OjWahHQwdjzFSzwjAZFa4lo4Is8UumErw nbutEMhyPDVbrYiiTHMT2o2XrLkMm6sBOoVwcvF9dmpk1JOdIDIdEMMx2ks624MTIsXZ m9NQ== X-Gm-Message-State: AJIora/Xj1Omh5lH+dxStPNntRVj89W3fNfGTj3su6DoD6CTSAURxQfa DRVkg43VfTQ0Mvro1WT1WlP3Pn4O9qV0jAxb X-Google-Smtp-Source: AGRyM1uZ64mMEPzeXb3wa46SWUb6DALXH0wVz0TNXtLHVamZDdMg411+GYadDseVwHVaUtcPrOThKA== X-Received: by 2002:adf:fb10:0:b0:207:af88:1eb9 with SMTP id c16-20020adffb10000000b00207af881eb9mr12222935wrr.238.1656056131051; Fri, 24 Jun 2022 00:35:31 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c154d00b0039ee391a024sm6695195wmg.14.2022.06.24.00.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 00:35:30 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Jun 2022 08:35:25 +0100 Message-Id: <20220624073528.26670-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624073528.26670-1-naush@raspberrypi.com> References: <20220624073528.26670-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/4] libcamera: controls: Add SensorTemperature control 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" Add a SensorTemperature control to return the temperature of the camera sensor in Celsius. This control will only be present in the Request metadata if a thermal sensor is available to the camera sensor. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Reviewed-by: David Plowman --- src/libcamera/control_ids.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index cd1d4512bf2e..ecab3ae97260 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -367,6 +367,16 @@ controls: size: [2] + - SensorTemperature: + type: float + description: | + Temperature measure from the camera sensor in Celsius. This is typically + obtained by a thermal sensor present on-die or in the camera module. The + range of reported temperatures is device dependent. + + The SensorTemperature control will only be returned in metadata if a + themal sensor is present. + - SensorTimestamp: type: int64_t description: | From patchwork Fri Jun 24 07:35:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16364 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 E6002BD808 for ; Fri, 24 Jun 2022 07:35:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8DE0165642; Fri, 24 Jun 2022 09:35:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656056136; bh=JnEWMYEe4ljQSpx/EsezHbYzmULN6aQP59WhNtfitPs=; 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=uy65H+0EX4dyIVkXTK2nIGwhTJQyXgG+b/0O6S/GI40JJHVZStXh8gccK54UZyJA1 FRtvPVlt1MwQo3YH4fXdWNNjDCjP70RmtZBBnv3ikIQUaYx8UT/rYdOj0TL0J/71SM J71lD9vy6LNzaMnze0sloL5XvqCbzFbCgSjeeIWl4Tgq7baOteG5rB/CqJ1pm/QCTO eC+f/5OC4i7ENFgNZWsKw1JnBCI9ZlHCWDaJLznvQcqkySunu8MyH6Ddbyf+OHznbm KsnAHjbFKRpHXiD5oKJRr8YalxHv0jk2MA4B5JfEaUt51GWeuHUDgVfXp9Mw19DhBo TRO2cEhE4wEOg== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A1C2665631 for ; Fri, 24 Jun 2022 09:35:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="en4gQ38i"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id e5so804335wma.0 for ; Fri, 24 Jun 2022 00:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TKXSDlXgMKHxKCr92d20eztm199M5cveMVtTrE2BYsA=; b=en4gQ38iGiQb9sIZ0/u9rXAidC5wPC3ivyxwMapzKkyPk2SIombamJSyclXE6fV2H2 q7D5lKAxw/zLXgD4/Pmlw32F5XggDBK47t2HXHAdwLLwh5AmZqCvbxNYvIV2xz2jOTm9 ARCiualzja16apyaB9hqbQeG7zZSxIKF/E4gAGusnZ+RVXfKhLMEIOZvxXxvi9THk189 aZtTYC8LIBmN6lOEpmiPENBpX5wRhm5t9KfAfpuDEa6W10qC9nVsjhHtQD8ajKYMpXWW njA0qP+R6xUalNfOkB9Vzd8CNJo0UCR9XVsZAQF6YbKZ7qif33J2n5++u1Qv79jV6UV+ 6dVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TKXSDlXgMKHxKCr92d20eztm199M5cveMVtTrE2BYsA=; b=vytZontXCNEd0mS0aJ3D2qKgjMHMdFwXRhNJckYTjW9RxjbcipE4rmJeYgNEPXvdlY 4pMFYUwKoOm7VWaCUdUwbuGUCjjTRILJaDZPLi5DHKU+OhN7aVi/harHcdEbJKi7lnS3 abrneyg+NMMEuClnQzCY5TGK2rDNpAo3ke6tmVAZ3Ba/OIDwWt7oxk7m3pieVmzfDNmj uXhfA9o2DSg5pB3Om8IghGAaOhPL7BL2MZ4IlOXO1dyTXZh6oODdWj7YC9HG5wdlsa0J aXvHmx70fZkbhCQ7IE5NpOUhuVNtZjeGKheRwyiwRypfdbkOY86JAzZXuiLonkXFcxo2 Y2zA== X-Gm-Message-State: AJIora/k+0uaFhNJGXSuQABZASYqpXTtAZ45L6Z0jIfDR1PvTtRBw32t q+NJZZfUrAAsh2I+YRwcFJTtnFbZZOQ9PIL6 X-Google-Smtp-Source: AGRyM1tUlDX64Qypgw3i7IzH2JEPPHN74KIKWK7YzyiGbmkBiOMdzVGbY3xGnZ/k5/74EtY6S4UXJA== X-Received: by 2002:a05:600c:354c:b0:39c:7e86:6ff5 with SMTP id i12-20020a05600c354c00b0039c7e866ff5mr2037678wmq.145.1656056131731; Fri, 24 Jun 2022 00:35:31 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c154d00b0039ee391a024sm6695195wmg.14.2022.06.24.00.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 00:35:31 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Jun 2022 08:35:26 +0100 Message-Id: <20220624073528.26670-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624073528.26670-1-naush@raspberrypi.com> References: <20220624073528.26670-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] ipa: raspberrypi: Add sensor temperature to DeviceStatus 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" Add an optional sensor_temperature field to the DeviceStatus structure. If a temperature measurement is available for a frame, the value is returned out through the SensorTemperature control in the Request metadata. Additionally, provide the sensor temperature value from the std::ostream &operator<< overload. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Reviewed-by: David Plowman --- src/ipa/raspberrypi/cam_helper.cpp | 8 +++++--- src/ipa/raspberrypi/controller/device_status.cpp | 3 +++ src/ipa/raspberrypi/controller/device_status.h | 3 +++ src/ipa/raspberrypi/raspberrypi.cpp | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 74179399e86a..3f81d4187d4d 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -185,9 +185,9 @@ void CamHelper::parseEmbeddedData(Span buffer, metadata.Merge(parsedMetadata); /* - * Overwrite the exposure/gain values in the existing DeviceStatus with - * values from the parsed embedded buffer. Fetch it first in case any - * other fields were set meaningfully. + * Overwrite the exposure/gain, 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. */ DeviceStatus deviceStatus, parsedDeviceStatus; if (metadata.Get("device.status", deviceStatus) || @@ -199,6 +199,8 @@ void CamHelper::parseEmbeddedData(Span buffer, deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed; deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain; deviceStatus.frame_length = parsedDeviceStatus.frame_length; + if (parsedDeviceStatus.sensor_temperature) + deviceStatus.sensor_temperature = parsedDeviceStatus.sensor_temperature; LOG(IPARPI, Debug) << "Metadata updated - " << deviceStatus; diff --git a/src/ipa/raspberrypi/controller/device_status.cpp b/src/ipa/raspberrypi/controller/device_status.cpp index f052ea8b7bed..05897fc15b50 100644 --- a/src/ipa/raspberrypi/controller/device_status.cpp +++ b/src/ipa/raspberrypi/controller/device_status.cpp @@ -17,5 +17,8 @@ std::ostream &operator<<(std::ostream &out, const DeviceStatus &d) << " Lens: " << d.lens_position << " Flash: " << d.flash_intensity; + if (d.sensor_temperature) + out << " Temperature: " << *d.sensor_temperature; + return out; } diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index c4a5d9c8e8c7..eca3bf4b042e 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include @@ -36,4 +37,6 @@ struct DeviceStatus { double aperture; /* proportional to brightness with 0 = no flash, 1 = maximum flash */ double flash_intensity; + /* Sensor reported temperature value (in degrees) */ + std::optional sensor_temperature; }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 3b126bb5175e..cb0025a17aff 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -491,6 +491,8 @@ void IPARPi::reportMetadata() libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogue_gain); libcameraMetadata_.set(controls::FrameDuration, helper_->Exposure(deviceStatus->frame_length).get()); + if (deviceStatus->sensor_temperature) + libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensor_temperature); } AgcStatus *agcStatus = rpiMetadata_.GetLocked("agc.status"); From patchwork Fri Jun 24 07:35:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16365 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 C3FBCBD808 for ; Fri, 24 Jun 2022 07:35:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 600CB6563D; Fri, 24 Jun 2022 09:35:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656056137; bh=aw/1NuVF+9SHjjIH3cFOZ7ydPEJYmnwxzpNmg/Cnowo=; 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=COV8hlAnwYTFNlZ7JbHHMZBP+aH7prFKZ1hSkP3hOOl75mQ2wbCfjmW2q1WRnIDiK jj9sbFlcoX9+gsVZ5ElYdTwo8A9FmUWoKOdDZjI+nMZCu8gaEuo9jXWJXQ8PVzU5xC oSfYExTzyy2Dke/LZSVJJLzn5YyEctVr96pViuoWCo118+wZOTiW+r12ZwS54rJTIE z5EjqtN4cmUT+u7MqfbuSzUWAM6BZror8kcnRKSMVqf6ony+NQ8IKfzNj5mLDs/O9C GfHGKUDshJxN6VPZ1L8v8febjNCqUhJNBUskLFOQ4wVG5Fw2mtgGFK9kz57qawT0a2 kaQRGLWJITjQQ== Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A69965633 for ; Fri, 24 Jun 2022 09:35:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="oOKPzor8"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id r81-20020a1c4454000000b003a0297a61ddso1368224wma.2 for ; Fri, 24 Jun 2022 00:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KJAuSaTd++kex691QD4SoGtyc7WqZ/kD/BSuFWZ8jMk=; b=oOKPzor80VfkdmMtxikvZ5oViBctb+7I58LEbxgg5Rp4zu2EXXAl1yOANZhuzqVUrN Gpa8efTdONjI4SUhAWwaGGLUrWPzKm2sjrlCJXYweHJu9X82GTzUzJ3g+mzJc8yIqFNF CKaZRhDnZPDFq9I+6yHmig5hCswM5ik0i6BJ8MolOxIHqzQ8nnngSmtp0tcCc43SPpBb yTFFCoLvg0lrLb1GFxGH40qmvuaGSl55SvYiJqsrFXN6kA8LUK9JUjTEvd0ZzB9DCJTj hFrUNLT88zeXvM1wCyjCRVaLAY9e8tvp1vr1w5uz0YXM1jCR4y9Y2jw12E3DfXtcgNtN mjtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KJAuSaTd++kex691QD4SoGtyc7WqZ/kD/BSuFWZ8jMk=; b=pk0hkCu34sIfXrvLD8jgt0xmIke89D4UTg3YrJLouHCo7vSF53rwfcfud35VsrF8AA wapLCrJCBBldvYyxs+cv76D4KxmAmH2ZRCbY2wNYyqhM6pGHvc6CplshyrEpLrp8PhoI 5DaO20qICs0fKFdvkMeCMaFqz1VtAFZwCmF/tEYg/e2u1dFEbOttWmy+B5U4JyMuBMPX qbGE2ZPWZn8VzRLzNcBUkTEEekgrE/taTbarGXj3eTPt+IQq4T/8szhvRhO5GnL7T2cK w3eq4grqgjFFeQP7LmNBuLYEbLUQUXKzzO9hxtTquTqEvz+wXQ2eABJziIJdvr61Py6h wMgw== X-Gm-Message-State: AJIora9eqA0y+Az3QPAUXN92KaEKmrohhHjFqtZS7+DS0yFkkN29g6lF PRS+KGX2ZGOW6bEGs4jfCJjimOZ31yG8mGBW X-Google-Smtp-Source: AGRyM1u7FV7mwUPKbveum89Q5+7WpZZDkf/SMbQ2/RK7TYqRkN8B/xF7Sh6jJ1mRcVw1r64RPPFd1Q== X-Received: by 2002:a05:600c:5021:b0:39c:6571:e0b0 with SMTP id n33-20020a05600c502100b0039c6571e0b0mr2083182wmr.177.1656056132729; Fri, 24 Jun 2022 00:35:32 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c154d00b0039ee391a024sm6695195wmg.14.2022.06.24.00.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 00:35:32 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Jun 2022 08:35:27 +0100 Message-Id: <20220624073528.26670-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624073528.26670-1-naush@raspberrypi.com> References: <20220624073528.26670-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/4] ipa: raspberrypi: imx477: Get sensor temperature from embedded data 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" Fetch the sensor temperature value from the embedded data buffer and add it to the DeviceStatus structure in CamHelperImx477::PopulateMetadata(). Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Reviewed-by: David Plowman --- src/ipa/raspberrypi/cam_helper_imx477.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 338fdc0c416a..0e1c0dbd142f 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -5,6 +5,7 @@ * cam_helper_imx477.cpp - camera helper for imx477 sensor */ +#include #include #include #include @@ -34,8 +35,9 @@ constexpr uint32_t gainHiReg = 0x0204; constexpr uint32_t gainLoReg = 0x0205; constexpr uint32_t frameLengthHiReg = 0x0340; constexpr uint32_t frameLengthLoReg = 0x0341; +constexpr uint32_t temperatureReg = 0x013a; constexpr std::initializer_list registerList = - { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg }; + { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg, temperatureReg }; class CamHelperImx477 : public CamHelper { @@ -171,6 +173,7 @@ void CamHelperImx477::PopulateMetadata(const MdParser::RegisterMap ®isters, deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); + deviceStatus.sensor_temperature = std::clamp(registers.at(temperatureReg), -20, 80); metadata.Set("device.status", deviceStatus); } From patchwork Fri Jun 24 07:35:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16366 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 DD513BD808 for ; Fri, 24 Jun 2022 07:35:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 498F46563F; Fri, 24 Jun 2022 09:35:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656056138; bh=sDyI8g97X48JdfiwaxJIL/+wnmJROB56cMLoq2m57ds=; 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=DpZ1oidmrhBCPWdH2Q+1rc4PEdmAXrCrR2jSmXj9P4Mv1i7udGouDfQDIiQwkyG21 fPbdhWStAy+GwDhCDCuV4xfMFaUv4KXba7HXEPtawi3pziIx9DPpFaan/IvtdAd9RP pnZmiMC6LriwerP7LqpjFTPANxE7cp/wucKxt514NxFA2bQo2Lxr6tKp+OGmzO4Zlr ouT5/Sf9XbuHWqfA8NGwuLLMLsjma+NJJ/sRZG4xvjIxfdd8FGLb5xpWwCrYzAFaVX WLT7WM5C6KL8A9m7nNQoLGaI+R+d2YGBzWe/CqpIFGVBnaaavYVPoVMh8XcBu1zHIX mgNkIrx4BGqVQ== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D72D6563D for ; Fri, 24 Jun 2022 09:35:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="iHnBBxLR"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id u12-20020a05600c210c00b003a02b16d2b8so1013970wml.2 for ; Fri, 24 Jun 2022 00:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HNrdXmmfeCNlElA1aGia+hElBRScKTSJx9yNux7DNGw=; b=iHnBBxLRDTDcx+Nj9dfk5oD7jql3ZS+1SjBYVVw7C/AL4hCYYWxZwnhQjDrR2QdeGC pEphLKW6b30wwsMuAk8GvYy2kShx85ZJ+22adeQbzyuyHv3TXecqlbLhlMNhw1IVPud6 2xOcCDOjAHPRuAsBZdlDHXZUoGdeNSL66RLTFGXZOhcnRSIcg80hLnzIH8Erd6xFZO/7 YXSFaak/WgN4E92wQqxI9fAcHyIKZMbPOxDPv4XqgL1mjS+IrE1knSx9pxEzDltR/EK/ WUpRhDdK/Npr8eOhmiEJhbcNrJP7/QBx7TFhKrw6L3VGuYs+ePx9JZE4D0E+i+V6IW6c Z75g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HNrdXmmfeCNlElA1aGia+hElBRScKTSJx9yNux7DNGw=; b=ZvTE0+WESr9dmy5Q7ezyqd/TJ+mikjBodh2yDxY+xxhXK2rMRalnPp4KKskZ3oj1Gw r9TaUjKbDYxNyoPqzuZcw0qc5MKF3sAqpQ/kxuRGIvMqTRV0Sgl1ewgwcFywscOXqdeT ln0xxGmNS3n+RQIdPLhKboa8bHoqnkvkhIZ45SvfuO/le5uUqMLAW/lIAMnPbKEkiUdK +DV7avPMI40Wdx2rSepNerHB11cQ4dOx/NqygA0V4WPZaJLDo5xY3nSLs2MHsA2kKN3H sNXV5hpbDrTgA8ssGmUT4e2QsMaz0XYLR81sDLvT1h9wsCTn96ONBCXxnmfJRDP0gePm tDOw== X-Gm-Message-State: AJIora+S0gB8JSyfUNwXLhgHq1VuMgMJNZRoo3u+eT5SWHYZYYpWtiTs dGJY6En2247eF+0d3mFhbWf0wT4DdOljeOPu X-Google-Smtp-Source: AGRyM1u8StVfx0AuyD9UNyTj7SgaNC1zzyd1nXOaHk6TLdTNoteHBMgr3sOYHsU4TqQ+N0LZ9FkjGA== X-Received: by 2002:a05:600c:4fd4:b0:3a0:334e:241e with SMTP id o20-20020a05600c4fd400b003a0334e241emr2237363wmq.73.1656056133542; Fri, 24 Jun 2022 00:35:33 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c154d00b0039ee391a024sm6695195wmg.14.2022.06.24.00.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 00:35:32 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Jun 2022 08:35:28 +0100 Message-Id: <20220624073528.26670-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624073528.26670-1-naush@raspberrypi.com> References: <20220624073528.26670-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/4] ipa: raspberrypi: Use std::optional in DeviceStatus 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" Switch the aperture, lens_position, and flash_intensity fields in the DeviceStatus structure to use std::optional instead of using invalid default values. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Reviewed-by: David Plowman --- src/ipa/raspberrypi/controller/device_status.cpp | 14 ++++++++++---- src/ipa/raspberrypi/controller/device_status.h | 9 ++++----- src/ipa/raspberrypi/controller/rpi/lux.cpp | 5 ++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/ipa/raspberrypi/controller/device_status.cpp b/src/ipa/raspberrypi/controller/device_status.cpp index 05897fc15b50..a389c40dafed 100644 --- a/src/ipa/raspberrypi/controller/device_status.cpp +++ b/src/ipa/raspberrypi/controller/device_status.cpp @@ -12,10 +12,16 @@ std::ostream &operator<<(std::ostream &out, const DeviceStatus &d) { out << "Exposure: " << d.shutter_speed << " Frame length: " << d.frame_length - << " Gain: " << d.analogue_gain - << " Aperture: " << d.aperture - << " Lens: " << d.lens_position - << " Flash: " << d.flash_intensity; + << " Gain: " << d.analogue_gain; + + if (d.aperture) + out << " Aperture: " << *d.aperture; + + if (d.lens_position) + out << " Lens: " << *d.lens_position; + + if (d.flash_intensity) + out << " Flash: " << *d.flash_intensity; if (d.sensor_temperature) out << " Temperature: " << *d.sensor_temperature; diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index eca3bf4b042e..b33f0d093ff3 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -19,8 +19,7 @@ struct DeviceStatus { DeviceStatus() : shutter_speed(std::chrono::seconds(0)), frame_length(0), - analogue_gain(0.0), lens_position(0.0), aperture(0.0), - flash_intensity(0.0) + analogue_gain(0.0) { } @@ -32,11 +31,11 @@ struct DeviceStatus { uint32_t frame_length; double analogue_gain; /* 1.0/distance-in-metres, or 0 if unknown */ - double lens_position; + std::optional lens_position; /* 1/f so that brightness quadruples when this doubles, or 0 if unknown */ - double aperture; + std::optional aperture; /* proportional to brightness with 0 = no flash, 1 = maximum flash */ - double flash_intensity; + std::optional flash_intensity; /* Sensor reported temperature value (in degrees) */ std::optional sensor_temperature; }; diff --git a/src/ipa/raspberrypi/controller/rpi/lux.cpp b/src/ipa/raspberrypi/controller/rpi/lux.cpp index f77e9140ac10..643fb8fbaac6 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -63,9 +63,8 @@ void Lux::Process(StatisticsPtr &stats, Metadata *image_metadata) DeviceStatus device_status; if (image_metadata->Get("device.status", device_status) == 0) { double current_gain = device_status.analogue_gain; - double current_aperture = device_status.aperture; - if (current_aperture == 0) - current_aperture = current_aperture_; + double current_aperture = device_status.aperture ? *device_status.aperture + : current_aperture_; uint64_t sum = 0; uint32_t num = 0; uint32_t *bin = stats->hist[0].g_hist;