From patchwork Wed Jun 29 08:57:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16422 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 3BBBABD808 for ; Wed, 29 Jun 2022 08:57:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E962165637; Wed, 29 Jun 2022 10:57:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656493051; bh=4plsZXo/pmMr32F305UKHNcVgdrmVM0bgCQIh+RE8CE=; 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=JIivAxaHvXWx79uxGT94fNQVee5JLnKcZ8KE/LyVhiiYpsRBhugdHU2r7e8gxtqwH OTTjGjtWGUQQDhtfQ3Uwy0hoJlWTh5o9SUwqQfcrr4Iovysvs0yfRCL/eLdxgvZO7m Npal9IptQepytR7UMXTv4ubWGjcKkGHpsINCXRqzjFgMCUJct9zjI/GnMUumHkDFMW rdEN7ks9aUrCMEfTyLXCXwxg/PU1kPJGsgLHtJnGCeqhCO+82o1J7HuRuowPbfqMJ/ PpVQCNdpYdNvSMabd3wTe/OXG9KU7p2hvADPVwa0lBD15k9jIN7vHYqS4v7i9q4fuw lIrjRJMYEuVfQ== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2870265631 for ; Wed, 29 Jun 2022 10:57:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="E9GVgGXG"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id i25so15854515wrc.13 for ; Wed, 29 Jun 2022 01:57:28 -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=60OOKIxJ9DCLBi3uWCPxOf3+BLNe7KbcuO/nm8UtQw0=; b=E9GVgGXG7H2ZX8oEhj7nPEs0npOEr+XaYCOkuJFOvXVKmt3Y9raWv6M7yiFs8x02GJ Od0+RZRZtydnVgd302ofM3liLTcU37mAV16Co3Li1zVFNaFB6tt41dYsmX63suaNnzUy /B9UxGqF/lsH8sDkYX3+evaLz8gEDTQ54IbYk/cVte8zTLn49giywhGzwe8cReg7Hrf+ 1CaFw4z73jmE3hHx9xaBySqFG3VucNtkFdKIyewGliBTdS6UOWLnnUMuKm0mTGdcPHRU CmCdheiGYVOkUUhP7T6W6025SV873xucOOvgDyFF2NXZhdqac3fyOPZNRwCNAqlqwPY8 zKWw== 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=60OOKIxJ9DCLBi3uWCPxOf3+BLNe7KbcuO/nm8UtQw0=; b=Rr+xQ+RIaVsMDFJV/sIZoyxgRq3l9TMmLBFVChQrkTfJ/DE2HSeFm91tZeZ/7HwMMR 5u9yjbzATyOpGZXcFnS9RzShm+Hl67XHVXYXVEfxPC4nlY29zpqYJoGSSrgvfOWOoeD8 Pdcga5s1Ea4awmuT27VTF7N0TtEBo1urdBb7ec+i+hgb5iQBD2C3iSrs9Ca4sVv30OZ6 dV1Lj1GYLvm4u9UP2QeJQzONEaerIRBwCeHNPqj4yU8EDfH3JediruZDn9K/5b+V52XL g9P9pf8dC4NKRZfnRFOOlOREjt0vZXK85+kqjQXInm1/1mN9mcxd/sRUpih2Nw05EamG /fyA== X-Gm-Message-State: AJIora8MavVHtr1zvrRKvroM1llR0hV6Rl+bKGELnnmaly9JWTCn6Qb0 rIWcbe373O2Qhzl8pi4LrXZAqX+3kNtRiGLO X-Google-Smtp-Source: AGRyM1tqVRNL/CeWLLtcY7jIYCs/F+sp35DfInWzA7UgCWmrGy5sXNyTVRVejs/SsrDD/LRo+cDIpA== X-Received: by 2002:adf:fb46:0:b0:210:2316:dd02 with SMTP id c6-20020adffb46000000b002102316dd02mr1977511wrs.557.1656493047552; Wed, 29 Jun 2022 01:57:27 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b003a032c88877sm2897102wmg.15.2022.06.29.01.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 01:57:27 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 29 Jun 2022 09:57:19 +0100 Message-Id: <20220629085722.11786-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220629085722.11786-1-naush@raspberrypi.com> References: <20220629085722.11786-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 Wed Jun 29 08:57:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16423 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 45FAEBD808 for ; Wed, 29 Jun 2022 08:57:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0771865640; Wed, 29 Jun 2022 10:57:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656493053; bh=cTDyvnhIURTW0R4V5fGA65Hb3TQoxTJ7BxIYsVxB5/k=; 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=E5zTKZWeD1BVGHhNvQuSsceapeG6Tu6+2hPE5mLHMl13kPMmSJykjlvMq8Vx2a6mB fToYGCC+vLSZC8QeqcN4TnFjXxNiHEXhifNMgEtfYE8+kO8my7qSLcFnHo2s8YDLkF nwzSobn1MqEVOwTxQpLLwD/++mxvuifxBFqp3YCEv80EbRsIEjjpKDm3zM6nLJPosJ vCPqRAMCOot8asTFx5oUWuFgAjS2A93k35GgcNifGJEQxdql4gKOvka5e1bMxYDkCT Efu+rzWYkD2lQ/r7sCy8ksk1fJ55cWQo9uP3zRPOqLA/85BQ9Mz8iuZF/j/LILSIK4 sTocnXNZET+CQ== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B8C565632 for ; Wed, 29 Jun 2022 10:57:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="G25mraLt"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id d17so15718855wrc.10 for ; Wed, 29 Jun 2022 01:57:29 -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=weQED+1mys2mhgHP4iQlmcHoTRJvWho5Ugz62KPfY20=; b=G25mraLtkeEEktCfQjyUp5t7uY3DDCdg9knRZkE7l1zpyJ3+9lLI8aW6ALJ9phGOwJ K4v+ZNbk89uDRCuPs0T0VxCvpYqV02Umh1OgoYBJE4sNjvnJxK3Wfb5o7dm9YDqN9nDl z/WWNrijfwrxqZt9g9usAV1gAyL0EFgJ7elFeoARJS56qsFmQmsaK8Ita5UrgdxAQTnw +Zax3sLtOpYaV7ONJPk1C2o2uSmvhQ7WlH+DkmffmbvKnGPPWNxRiDeUrVBQJs9UP/rD 8hHB6bC4De6VEcUk0qPfYbeycdg6BhqGqSm6Qq7kchr7viTf/GMpVk5k4ugWQ0tgYfmT 3VQw== 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=weQED+1mys2mhgHP4iQlmcHoTRJvWho5Ugz62KPfY20=; b=kc9VFdZzW5Ebp95GAnYmSDMJmcgnrRpw8yr4TfOpeM4lqCZKEyHWYlwxHEar8/w/LE RPIJ426LaTHty9iEI2STiHRMkminZOXzCmo5vXE2cuazAkwJ83bg/zz9p64hyRL5kToS djTJImHZP5NrDgnCzEo1vF26Xl5zxGDITNMu+qOnSgZX0RCljVMr1lbt3yWlG2Mqw8is CF2a7a8JG63gSX6D937WG1ga11kLdtGrPJLitugrwDM5v1d7OHTjJq4fRZX9TtnN91te dw945cnDAWQm1Opez5cMcu6jtrH/iC5K8BsN6KFHqsghZTZb4NwkzjWuao571F3/qcDq bEtA== X-Gm-Message-State: AJIora9aj6kPLdZIBrUJ8/6HLdm3qGMt2xZ4EzPaZJXXYOrcVCnBhnqI xq+gb9zegQT4GRGQiRz1yvkY7S+5r9GJgzB/ X-Google-Smtp-Source: AGRyM1sVMXQ37PcpZ3gSYSbHo9c23Cfn3hyLpLmcAGF7jg/P1R/7MfqcXw1fMifowayflAP3StxUWA== X-Received: by 2002:adf:e5d2:0:b0:21b:bfd5:cacd with SMTP id a18-20020adfe5d2000000b0021bbfd5cacdmr1955877wrn.474.1656493048482; Wed, 29 Jun 2022 01:57:28 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b003a032c88877sm2897102wmg.15.2022.06.29.01.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 01:57:27 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 29 Jun 2022 09:57:20 +0100 Message-Id: <20220629085722.11786-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220629085722.11786-1-naush@raspberrypi.com> References: <20220629085722.11786-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 Wed Jun 29 08:57:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16424 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 0D1B6BD808 for ; Wed, 29 Jun 2022 08:57:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B505A6563B; Wed, 29 Jun 2022 10:57:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656493053; bh=YTK5Noc2Q2lbhWo+rp4bSjy1UOV7qDRJES7u6OCqZJA=; 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=odmUpdFAxHoRaBeY4TYgQDaa77u8oUsdBbrJGDsoQ9WWl8oSn3GajKuEN73S6OTkP ExTXnvvFS/csSELl+KcKlXQz8n51RwDUlQR4CNFBxdy7i2pBVZXG2YM5YlX7vrgXA9 SLW8VHWuLcb2h4lJSRwcHFf4BzaTh4gMQU53AScRX840zfQi2jZUKUkkKiswKrZ3Gq Y8A5tX55UENmP5Q0frzso75l6Z2O5M3QlDrfVZMFBBfH1+YmqGCzOA22G+WkhBN5c7 yVhWkS7eNE4RiESIItedZxhrh2lUjVUZrYtalUT5cqdof7mJg1Pa16e5wICUGIPr3b bUTDxTY/S5zRw== Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2988760552 for ; Wed, 29 Jun 2022 10:57:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ApE8xHjB"; dkim-atps=neutral Received: by mail-wm1-x331.google.com with SMTP id l2-20020a05600c4f0200b0039c55c50482so11019812wmq.0 for ; Wed, 29 Jun 2022 01:57:30 -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=YqAxiP9TCv8odUus2VXRkdrejIzP2Ylpisi7DvbfMtc=; b=ApE8xHjBt6xqMMaqRfM4wLRC2WbeFrXaYdtu6d+Kwma/XQkfnu0lQ3UlJsF4m5c/2E 4k53uZtS7Yn1V/DmnF0/f9SsVhSamjD5f638JYncqpQgB9mwnOZ0DGK1KqzVs69EWzU0 cNugxS9ipeaGQzccl/yxYSoNAW5xFP17XRgl/USfQZRAOm3GSF9EowPcn12KOYcvBk+k Co5AuL17Os8pvee5cnSAl6YI7Za/HX6smYzHrjfOWezdQZ4QWtL4FQqhwrVHnImxbKtJ xbT9C44uTRjuHxy1jNSFT43CKcEjtPqEnsfIEUV3NxlKo2RlPg8029v4bVQCrpWRf1zs Pa3A== 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=YqAxiP9TCv8odUus2VXRkdrejIzP2Ylpisi7DvbfMtc=; b=UbrAP/soU6fc12+FMlbmIqLGE7afJ0iDvJp/kWQ4jIdhUnZIt5+rfG59X3OuR5Tp4a /D4OhY421xndDEo17osiUuF42z343yxwv0zgVjIMXfcOtTAuMabtaijhth+DeGjxgAE9 qyH8Iv0jr7mA0E7tW8VFSqPGdvGNecOWcnfStzVWiZJ989NdBGWGUHkz0r1OJpToLVQA I2icJkS7qocjH9nlWmx1+aNe0eFt2JyBFGtdtCktxN7ozXpEakygyAQOusovd2lm1/Uq qhwX2Leb06aU6KsD3unnTAiEsMME79alkoBrF/PqROUYNj2Bvy9H0uAVqF1SdEKpnSr3 OSLg== X-Gm-Message-State: AJIora+fYL2W22LyUFrOuPsCGBs1Gx+7ygkVDzuzW+HWxQ44hJIl73hi SNH6a3snqsyD2jhfuBjNORrUbaR1nBkhHCdK X-Google-Smtp-Source: AGRyM1s0fQviXlV1MbmGpdzRD1utZoJEVkLoOZPclN9kx0oHAEysU6F9VPmCidgt59Pa+gvHo2HSxw== X-Received: by 2002:a05:600c:4e54:b0:3a0:4e07:ce with SMTP id e20-20020a05600c4e5400b003a04e0700cemr2470555wmq.37.1656493049462; Wed, 29 Jun 2022 01:57:29 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b003a032c88877sm2897102wmg.15.2022.06.29.01.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 01:57:28 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 29 Jun 2022 09:57:21 +0100 Message-Id: <20220629085722.11786-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220629085722.11786-1-naush@raspberrypi.com> References: <20220629085722.11786-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 Wed Jun 29 08:57:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16425 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 2F346BD808 for ; Wed, 29 Jun 2022 08:57:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8DF1C65643; Wed, 29 Jun 2022 10:57:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656493054; bh=LKM41LkvdfqwKIuygN7sVv3WXuRUOjTdLGZvjQ9+rkk=; 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=2OleYZV3aDeSC7OFBOfhHsp1jjZqALrXq4fmQdbHq7oZ77UW5vkplU1hH1dvMVAc5 Q55hr1EnPAcBWE1RBxFPSmqqMuK6ezkRfv9jQRRRh+7tNuwD9YXVIFsI+QWZbZ2oCh xSvDybw0Yith7Z4z2QsjDfUZMSjubTj68k1FI94Ps1eWn6bq0cJ/Ze+/uytITj3/lP PaMJbE82fpR/m56erDX4IxXnR9ci3RtrBs8Oz0SWQPjUpJTDk6iB7A41sQeQnYxvhl gVB2cL7lGCcXfhggawAChqgnp2gkwdTnqAMDHTs3Tg8dh9a/NUs/7HyZr52ejKEWrq cg2kPCy2fDemg== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B9EA6563B for ; Wed, 29 Jun 2022 10:57:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="AE/0aNZc"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id i25so15854515wrc.13 for ; Wed, 29 Jun 2022 01:57: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=in89XHK+OhJp/bEi8fRq7qH5ZAnliJIX3PqoxwQ/GOA=; b=AE/0aNZc/P3Jtq+BKPFdeTGC82KaHbeC7FVKdz25WHbKkScg7SaTo6jcfyNbO1JiSH w0j0fBicMpS9wkwAwwYaINrAvZvbqW7GC53o8oCGiRvp3PVOJC18iIyfTvNArXPYWCyP bNLfrWwOhCgyLT8pQ4J1HzsWUpiFtkbJ+QjsxGIjIVWUWrqpZrNNqwUcxZt7su+DDHCc mA9qRDRUiJas7BxOXyHCaVbGahj6XkNvYMvgTObaY6y/hL631ne6qYsAr+An1P1Tykfo E7zPHzTA2rVKN8av2NA1indQmh6yCg20EUfUqiSnVrhktXkqIEu+sC1+vS/3ykukm94K lAJg== 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=in89XHK+OhJp/bEi8fRq7qH5ZAnliJIX3PqoxwQ/GOA=; b=Ztgh3o5ukdpKowkbpMH3s3BfO6zc6TNHE9p9jqsWP1ykY41uHIoyk05G8m8f3UH1OR TklcocYjcc8Y+VSZVAPy1vZlROxlu8G66ptsOVBPbGimNZhsaRSW6pqOv10nvD3QLskL WlRQTcu7CbIqbzGjGhFWSlqIwVwLngtx7qgyTvzhu15whkGC5Cesp2rn9YyP35z9lQ/K lUhty2P5OvgcLNNAKaPnhxxDVSuIZ7aehi8KznPNi0jl7bvX5UOaISROdFa1XuPHUXtK EcJr71TYr6TPcsa5GByT04OxaTbshKs3YG6ZASy55utlubYI2v2U/UwzMlg5BGkfBkhf RROw== X-Gm-Message-State: AJIora/jU4E+w9bB+N/qEBlZLbJc2Wa+JU2+1N4MU9XKmNcAg+zGHbYp OJUjNK6edPN/Ytq44JJeLeI5kYn/VIwlOLB2 X-Google-Smtp-Source: AGRyM1uuKMLm9/ZuS+pq3HAbj1XobfnXtQu6NHUzGTiXwI8EKG24ORz68EiIy6tjpFSldkwxGtdn8Q== X-Received: by 2002:adf:e8c7:0:b0:21d:1c7a:a45f with SMTP id k7-20020adfe8c7000000b0021d1c7aa45fmr1952696wrn.168.1656493050395; Wed, 29 Jun 2022 01:57:30 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b003a032c88877sm2897102wmg.15.2022.06.29.01.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 01:57:29 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 29 Jun 2022 09:57:22 +0100 Message-Id: <20220629085722.11786-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220629085722.11786-1-naush@raspberrypi.com> References: <20220629085722.11786-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 | 4 +--- 3 files changed, 15 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..4d145b6ff0e9 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -63,9 +63,7 @@ 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.value_or(current_aperture_); uint64_t sum = 0; uint32_t num = 0; uint32_t *bin = stats->hist[0].g_hist;