[{"id":18047,"web_url":"https://patchwork.libcamera.org/comment/18047/","msgid":"<dc5649e2-b77d-5c4e-d061-cf6b6f8cf591@ideasonboard.com>","date":"2021-07-09T13:13:01","subject":"Re: [libcamera-devel] [PATCH v5 3/8] ipa: raspberrypi: Add an\n\toperator<< to struct DeviceStatus","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Naush,\n\nOn 09/07/2021 10:56, Naushir Patuck wrote:\n> Add an operator<< overload to log all fields in DeviceStatus, and remove the\n> manual logging statements in the IPA and CamHelper.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/cam_helper.cpp             |  5 +----\n>  src/ipa/raspberrypi/controller/device_status.h | 15 +++++++++++++++\n>  src/ipa/raspberrypi/raspberrypi.cpp            |  5 +----\n>  3 files changed, 17 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp\n> index e6d2258c66d7..1ec3f03e1aa3 100644\n> --- a/src/ipa/raspberrypi/cam_helper.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper.cpp\n> @@ -188,10 +188,7 @@ void CamHelper::parseEmbeddedData(Span<const uint8_t> buffer,\n>  \tdeviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed;\n>  \tdeviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain;\n>  \n> -\tLOG(IPARPI, Debug) << \"Metadata updated - Exposure : \"\n> -\t\t\t   << deviceStatus.shutter_speed\n> -\t\t\t   << \" Gain : \"\n> -\t\t\t   << deviceStatus.analogue_gain;\n> +\tLOG(IPARPI, Debug) << \"Metadata updated - \" << deviceStatus;\n>  \n>  \tmetadata.Set(\"device.status\", deviceStatus);\n>  }\n> diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h\n> index 73df7ce228dd..e2511d19b96d 100644\n> --- a/src/ipa/raspberrypi/controller/device_status.h\n> +++ b/src/ipa/raspberrypi/controller/device_status.h\n> @@ -6,6 +6,8 @@\n>   */\n>  #pragma once\n>  \n> +#include <iostream>\n> +\n>  #include <libcamera/base/utils.h>\n>  \n>  /*\n> @@ -20,6 +22,19 @@ struct DeviceStatus {\n>  \t{\n>  \t}\n>  \n> +\tfriend std::ostream &operator<<(std::ostream &out, const DeviceStatus &d)\n> +\t{\n> +\t\tusing namespace libcamera; /* for the Duration operator<< overload */\n> +\n\nGenerally in libcamera we try not to modify or extend the standard\nlibrary namespace, which this does.\n\nThat's why we have used the toString() pattern instead of operator<<\noverloads..\n\nHowever, given that this code is in src/ipa/raspberrypi and separated\nfrom the main libcamera code base - I think this is probably something\nthat can apply as an exception.\n\n\n\n> +\t\tout << \"Exposure: \" << d.shutter_speed\n> +\t\t    << \" Gain: \" << d.analogue_gain\n> +\t\t    << \" Aperture: \" << d.aperture\n> +\t\t    << \" Lens: \" << d.lens_position\n> +\t\t    << \" Flash: \" << d.flash_intensity;\n> +\n> +\t\treturn out;\n> +\t}\n> +\n>  \t/* time shutter is open */\n>  \tlibcamera::utils::Duration shutter_speed;\n>  \tdouble analogue_gain;\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index 4d09a84f6532..f51c970befb5 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -1019,10 +1019,7 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls)\n>  \tdeviceStatus.shutter_speed = helper_->Exposure(exposureLines);\n>  \tdeviceStatus.analogue_gain = helper_->Gain(gainCode);\n>  \n> -\tLOG(IPARPI, Debug) << \"Metadata - Exposure : \"\n> -\t\t\t   << deviceStatus.shutter_speed\n> -\t\t\t   << \" Gain : \"\n> -\t\t\t   << deviceStatus.analogue_gain;\n> +\tLOG(IPARPI, Debug) << \"Metadata - \" << deviceStatus;\n>  \n>  \trpiMetadata_.Set(\"device.status\", deviceStatus);\n>  }\n>","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 5AF79BD794\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  9 Jul 2021 13:13:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C8847684E7;\n\tFri,  9 Jul 2021 15:13:05 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 83D00605AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  9 Jul 2021 15:13:04 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 044AAE7;\n\tFri,  9 Jul 2021 15:13:03 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"fi46p+7H\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1625836384;\n\tbh=oBgfU7esLBIO5eipTB0odYXnqHFtAww2bxfw43nYb4U=;\n\th=To:References:From:Subject:Date:In-Reply-To:From;\n\tb=fi46p+7HTEdcrHrtPTzbggJgj7MEplLhyGD/Hiauu7Ku6oHqE4ni3sjjS/j7f2mEp\n\tA7VMGDXA/YBOBcJuFAuh7l0GoVJkdWDJ2v3N49hVOtXs0Sf1faht3GeBD+bS8D3yT6\n\tjj1z9ByCbGKZm7ym5BcQ/s+dvJJpo9v53RlmxPCs=","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210709095638.2801713-1-naush@raspberrypi.com>\n\t<20210709095638.2801713-3-naush@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<dc5649e2-b77d-5c4e-d061-cf6b6f8cf591@ideasonboard.com>","Date":"Fri, 9 Jul 2021 14:13:01 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210709095638.2801713-3-naush@raspberrypi.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v5 3/8] ipa: raspberrypi: Add an\n\toperator<< to struct DeviceStatus","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]