[{"id":18108,"web_url":"https://patchwork.libcamera.org/comment/18108/","msgid":"<981e7175-ca38-dc81-7dbe-f9fd583e1b2a@ideasonboard.com>","date":"2021-07-12T12:51:02","subject":"Re: [libcamera-devel] [PATCH v7 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 12/07/2021 11:02, 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> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> ---\n>  src/ipa/raspberrypi/cam_helper.cpp            |  5 +----\n>  .../raspberrypi/controller/device_status.cpp  | 20 +++++++++++++++++++\n>  .../raspberrypi/controller/device_status.h    |  4 ++++\n>  src/ipa/raspberrypi/meson.build               |  1 +\n>  src/ipa/raspberrypi/raspberrypi.cpp           |  5 +----\n>  5 files changed, 27 insertions(+), 8 deletions(-)\n>  create mode 100644 src/ipa/raspberrypi/controller/device_status.cpp\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.cpp b/src/ipa/raspberrypi/controller/device_status.cpp\n> new file mode 100644\n> index 000000000000..7b8218ca67d5\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/controller/device_status.cpp\n> @@ -0,0 +1,20 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> + *\n> + * device_status.cpp - device (image sensor) status\n> + */\n> +#include \"device_status.h\"\n> +\n> +using namespace libcamera; /* for the Duration operator<< overload */\n> +\n> +std::ostream &operator<<(std::ostream &out, const DeviceStatus &d)\n> +{\n> +\tout << \"Exposure: \" << d.shutter_speed\n> +\t    << \" Gain: \" << d.analogue_gain\n> +\t    << \" Aperture: \" << d.aperture\n> +\t    << \" Lens: \" << d.lens_position\n> +\t    << \" Flash: \" << d.flash_intensity;\n> +\n> +\treturn out;\n> +}\n> diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h\n> index 73df7ce228dd..ec4bbe738b35 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,8 @@ struct DeviceStatus {\n>  \t{\n>  \t}\n>  \n> +\tfriend std::ostream &operator<<(std::ostream &out, const DeviceStatus &d);\n> +\n>  \t/* time shutter is open */\n>  \tlibcamera::utils::Duration shutter_speed;\n>  \tdouble analogue_gain;\n> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> index c98550180d7b..1af31e4aa021 100644\n> --- a/src/ipa/raspberrypi/meson.build\n> +++ b/src/ipa/raspberrypi/meson.build\n> @@ -40,6 +40,7 @@ rpi_ipa_sources = files([\n>      'controller/rpi/contrast.cpp',\n>      'controller/rpi/sdn.cpp',\n>      'controller/pwl.cpp',\n> +    'controller/device_status.cpp',\n>  ])\n>  \n>  mod = shared_module(ipa_name,\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 8CAEBC3224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Jul 2021 12:51:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C4DE868526;\n\tMon, 12 Jul 2021 14:51:05 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A65A268513\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Jul 2021 14:51: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 21DB5CC;\n\tMon, 12 Jul 2021 14:51:04 +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=\"uC1Y/jSs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626094264;\n\tbh=iF/E1dvKGUPGnIk57lwwFSVk89Q3L5rJQGf3vI4jZsU=;\n\th=To:References:From:Subject:Date:In-Reply-To:From;\n\tb=uC1Y/jSss+kd/6FVZ0OZQlDNKA1LSiODwSzBdmsyM5NJTQuero2MIOnTrOhx/391m\n\tglMzkbcqdfFVfsSbE3696JA9hFcbfubWLLnawC4yDlgxtnwzA7DtsrCRRurcz3ECTI\n\tzLWxU/jHst2vipzSV2sMB4C35SLzGsJtmISQxw6U=","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210712100209.447893-1-naush@raspberrypi.com>\n\t<20210712100209.447893-4-naush@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<981e7175-ca38-dc81-7dbe-f9fd583e1b2a@ideasonboard.com>","Date":"Mon, 12 Jul 2021 13:51:02 +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":"<20210712100209.447893-4-naush@raspberrypi.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v7 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>"}},{"id":18109,"web_url":"https://patchwork.libcamera.org/comment/18109/","msgid":"<YOw7izBz27ZoZVpE@pendragon.ideasonboard.com>","date":"2021-07-12T12:54:35","subject":"Re: [libcamera-devel] [PATCH v7 3/8] ipa: raspberrypi: Add an\n\toperator<< to struct DeviceStatus","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Mon, Jul 12, 2021 at 11:02:04AM +0100, 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> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/ipa/raspberrypi/cam_helper.cpp            |  5 +----\n>  .../raspberrypi/controller/device_status.cpp  | 20 +++++++++++++++++++\n>  .../raspberrypi/controller/device_status.h    |  4 ++++\n>  src/ipa/raspberrypi/meson.build               |  1 +\n>  src/ipa/raspberrypi/raspberrypi.cpp           |  5 +----\n>  5 files changed, 27 insertions(+), 8 deletions(-)\n>  create mode 100644 src/ipa/raspberrypi/controller/device_status.cpp\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.cpp b/src/ipa/raspberrypi/controller/device_status.cpp\n> new file mode 100644\n> index 000000000000..7b8218ca67d5\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/controller/device_status.cpp\n> @@ -0,0 +1,20 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> + *\n> + * device_status.cpp - device (image sensor) status\n> + */\n> +#include \"device_status.h\"\n> +\n> +using namespace libcamera; /* for the Duration operator<< overload */\n> +\n> +std::ostream &operator<<(std::ostream &out, const DeviceStatus &d)\n> +{\n> +\tout << \"Exposure: \" << d.shutter_speed\n> +\t    << \" Gain: \" << d.analogue_gain\n> +\t    << \" Aperture: \" << d.aperture\n> +\t    << \" Lens: \" << d.lens_position\n> +\t    << \" Flash: \" << d.flash_intensity;\n> +\n> +\treturn out;\n> +}\n> diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h\n> index 73df7ce228dd..ec4bbe738b35 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,8 @@ struct DeviceStatus {\n>  \t{\n>  \t}\n>  \n> +\tfriend std::ostream &operator<<(std::ostream &out, const DeviceStatus &d);\n> +\n>  \t/* time shutter is open */\n>  \tlibcamera::utils::Duration shutter_speed;\n>  \tdouble analogue_gain;\n> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> index c98550180d7b..1af31e4aa021 100644\n> --- a/src/ipa/raspberrypi/meson.build\n> +++ b/src/ipa/raspberrypi/meson.build\n> @@ -40,6 +40,7 @@ rpi_ipa_sources = files([\n>      'controller/rpi/contrast.cpp',\n>      'controller/rpi/sdn.cpp',\n>      'controller/pwl.cpp',\n> +    'controller/device_status.cpp',\n\nWhen you get a chance, sorting this alphabetically would be nice.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  ])\n>  \n>  mod = shared_module(ipa_name,\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>  }","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 68BCBC3225\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Jul 2021 12:55:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D9D4B68524;\n\tMon, 12 Jul 2021 14:55:22 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1A00168513\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Jul 2021 14:55:22 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 92527CC;\n\tMon, 12 Jul 2021 14:55:21 +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=\"fVNnBN5j\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626094521;\n\tbh=DQvThGZDPwsY3hiI9XxWWqGDOAfUnGTvaVcTSqC/VYE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=fVNnBN5j2kmQeHzr8N5j5qpPZNV9uKznoyZPR2ccsiR88a4BwwbB2FwSWErvZwMao\n\t9IYyNC0u+DiOt12KNk5h8R0MtcRGkP6apRUVTwg1CiGTj/0Yax8H4IstxK1kmjMq7W\n\tFSjeFOx+O+Gzk7IO/plJd8bPFJbN6G2HcPKjJgFY=","Date":"Mon, 12 Jul 2021 15:54:35 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YOw7izBz27ZoZVpE@pendragon.ideasonboard.com>","References":"<20210712100209.447893-1-naush@raspberrypi.com>\n\t<20210712100209.447893-4-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210712100209.447893-4-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v7 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]