From patchwork Thu Jun 23 14:44:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16336 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 42C01BE173 for ; Thu, 23 Jun 2022 14:44:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ED17265640; Thu, 23 Jun 2022 16:44:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655995471; bh=03a2ANdsxrFRWD+2YAbQ23SGmxqYgsIsFuZ86YP/8cI=; 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=I34OIA1c9+ew7Goxmh8zVOM8zEbezKuIjAtGh66GYNiqQjwM6RWWuVS17jZzOqt4m G95DpIrd6I9bNCiutSELKtEdgQV0CDnjjt5MagnX1gVQsqEscV1cHRgBMq1PeklLFC NUuxF/CUluLcYS8/oXUFLsPPJ5QzIBKpWPSUQVqBdgPFXqWtPXk/d0njpX3iQRZiSV pJuNjx8DWD9YwpWxVnlsy88nHn48/g0GAxC8s7wQdtZyj/WQRKdmTCUUzY8q2OoyKS 5gu2XTcJsysIgxmg5jjtaRQi3PY6T6ixPg95UvFqjDBsvcb0nZFVECLoT5DkBl7i8O efRJf4o7U/kjg== Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ECF8A6563A for ; Thu, 23 Jun 2022 16:44:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="OdPY7SAh"; dkim-atps=neutral Received: by mail-wr1-x42a.google.com with SMTP id r20so7864595wra.1 for ; Thu, 23 Jun 2022 07:44:26 -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=E86bYylqH36xxjXjHLA0Hj3cU2ciiltp7NwZLTqDbMI=; b=OdPY7SAhlDlrssi1T/GjJoXZcd03ROMd7MccBviNSmmbrwtft23YkN2Q/DCOG34PLz dlE/o0igMQX+AdqSgAl3/LoOmWlHqAYPqZu3CqFtdVJv2VNQiQIPoeypBFCt3N2Iqhhe HiFj7iW/M1dI62o01G97uOljcJJYp46nI/zLBakReGMKyB027XKdkRQpM2l3qNXVf4ZJ 1u4VNJRIK0t97fv7rIx8l0nhXzmojvsrKNsoUk6oP0PXq6s9Y/tPej5MLxTCXj3U1PvQ anefIpIFSe19hTlJurn9AQVOfsPSXJ8FaM/0xYaqaQPtKCzQN5sGNLWXePkBf3hbmMC2 JC7Q== 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=E86bYylqH36xxjXjHLA0Hj3cU2ciiltp7NwZLTqDbMI=; b=fplSZ6xEHEhN6sVm2/gTq/5BZWU6HtnnOV5xpYLgmAqKS+CTLtPY7H4rk9YBpVwD8x 432f0RR0OPU9N2NzaVqes5tK2+NbhOcclw+l136mQctiO2DXx4Md4uXTMtsTCN58e9tb R3mqRloy29LF3PPNQ9lNgE05qj2EiIiafYK7kODMjqIfDVSOiCwTLo/50EDU6VUk3k0E ycPhJFBjbbKW2oFG51lR7CvErAKdZAYhOd052z1NZ/RWXTerUSNnjCZvzYFWQl/93Jv/ L7OmFdt1Am9dErubM2lhH3CHuXa4jVLVdG6NqG1wjF8Eck+P3Pgagcp1mVwLvhJw17fN o0LA== X-Gm-Message-State: AJIora87LOM4zmCemYM2RmUn62UqPv7EqNEQGjki7trS7Z3mDPpGkp8a /MnCQcH3LK67x/g7qDzCPJcdu5x0jrWsq8Mc X-Google-Smtp-Source: AGRyM1sbocVh5BUuQyz1jsD9/cXx18hoB6RygQzqrB1tgyTO6CBBe/bGFpF4BQHCUH9t/3YuPGAHGA== X-Received: by 2002:adf:d1ed:0:b0:215:98d7:2a93 with SMTP id g13-20020adfd1ed000000b0021598d72a93mr8807420wrd.637.1655995466319; Thu, 23 Jun 2022 07:44:26 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id v21-20020a05600c15d500b0039c96b97359sm3178578wmf.37.2022.06.23.07.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 07:44:25 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 23 Jun 2022 15:44:09 +0100 Message-Id: <20220623144410.20725-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220623144410.20725-1-naush@raspberrypi.com> References: <20220623144410.20725-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] 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 a sensor_temperature field to the DeviceStatus structure. The default value of -300.0 indicates a temperature measurement is unavilable. 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 --- src/ipa/raspberrypi/cam_helper.cpp | 7 ++++--- src/ipa/raspberrypi/controller/device_status.cpp | 3 +++ src/ipa/raspberrypi/controller/device_status.h | 4 +++- src/ipa/raspberrypi/raspberrypi.cpp | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 74179399e86a..046428de8545 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,7 @@ void CamHelper::parseEmbeddedData(Span buffer, deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed; deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain; deviceStatus.frame_length = parsedDeviceStatus.frame_length; + 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..1a376eecb1c3 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 != -300) + 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..53cfeedc2956 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -19,7 +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) + flash_intensity(0.0), sensor_temperature(-300.0) { } @@ -36,4 +36,6 @@ struct DeviceStatus { double aperture; /* proportional to brightness with 0 = no flash, 1 = maximum flash */ double flash_intensity; + /* Sensor reported temperature value (in degrees) */ + double sensor_temperature; }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 3b126bb5175e..fb91c8d11f6c 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 != -300) + libcameraMetadata_.set(controls::SensorTemperature, deviceStatus->sensor_temperature); } AgcStatus *agcStatus = rpiMetadata_.GetLocked("agc.status");