[{"id":17955,"web_url":"https://patchwork.libcamera.org/comment/17955/","msgid":"<CAHW6GY+1oC1cXK1xrrph4GWpxKgswKNe-7WZXUy67=xe5Y-k2g@mail.gmail.com>","date":"2021-07-02T15:51:31","subject":"Re: [libcamera-devel] [PATCH v3 3/8] ipa: raspberrypi: Add an\n\toperator<< to struct DeviceStatus","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Naush\n\nThanks for this patch, it is indeed much tidier now.\n\nOn Fri, 2 Jul 2021 at 16:09, Naushir Patuck <naush@raspberrypi.com> wrote:\n>\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\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks!\nDavid\n\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>         deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed;\n>         deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain;\n>\n> -       LOG(IPARPI, Debug) << \"Metadata updated - Exposure : \"\n> -                          << deviceStatus.shutter_speed\n> -                          << \" Gain : \"\n> -                          << deviceStatus.analogue_gain;\n> +       LOG(IPARPI, Debug) << \"Metadata updated - \" << deviceStatus;\n>\n>         metadata.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>         {\n>         }\n>\n> +       friend std::ostream &operator<<(std::ostream &out, const DeviceStatus &d)\n> +       {\n> +               using namespace libcamera; /* for the Duration operator<< overload */\n> +\n> +               out << \"Exposure: \" << d.shutter_speed\n> +                   << \" Gain: \" << d.analogue_gain\n> +                   << \" Aperture: \" << d.aperture\n> +                   << \" Lens: \" << d.lens_position\n> +                   << \" Flash: \" << d.flash_intensity;\n> +\n> +               return out;\n> +       }\n> +\n>         /* time shutter is open */\n>         libcamera::utils::Duration shutter_speed;\n>         double 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>         deviceStatus.shutter_speed = helper_->Exposure(exposureLines);\n>         deviceStatus.analogue_gain = helper_->Gain(gainCode);\n>\n> -       LOG(IPARPI, Debug) << \"Metadata - Exposure : \"\n> -                          << deviceStatus.shutter_speed\n> -                          << \" Gain : \"\n> -                          << deviceStatus.analogue_gain;\n> +       LOG(IPARPI, Debug) << \"Metadata - \" << deviceStatus;\n>\n>         rpiMetadata_.Set(\"device.status\", deviceStatus);\n>  }\n> --\n> 2.25.1\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 6A0DEC0100\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Jul 2021 15:51:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E196F684E6;\n\tFri,  2 Jul 2021 17:51:44 +0200 (CEST)","from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7265F684E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Jul 2021 17:51:43 +0200 (CEST)","by mail-wr1-x42b.google.com with SMTP id g7so12987509wri.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 02 Jul 2021 08:51:43 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"POIEQuBl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=5pIPvFI/UinR5rvouSAhOE1bBPZP53+qdS1QMrsy7LA=;\n\tb=POIEQuBlr5kmEcYz22FwOfBKhwJgwhr8vCusaDWm0LYrwkwxDH2EGp0YMvPPIt5wnr\n\tiefzRXc/NBLbOxi6HujJ3gXFyN0n3Klr2J/s9IJ338z5waEQ1e0lPeawMExdm0UuNILS\n\toLgOkjwVPG1sLGGQ95mXr0BaWQ4vcuO1gEXw2ozN3ZPmnSJTkAh3Fh2BuElQl4oStSkZ\n\ta9Jpu0RK9xV/TPcAQEev3rIiBRnqx2mJkLveqYsEPYvsHMpj18j+JI0E1sZTbq0fLv/b\n\t/znOEziRYG0mnN5f3rGZbdXHbAgW7jYneLSZN3bfNHF5qwZmyyD4YznUtTPlvjl4YFaH\n\tayJA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=5pIPvFI/UinR5rvouSAhOE1bBPZP53+qdS1QMrsy7LA=;\n\tb=BJvChjY2KcZqiH+BZBPEw3iPoN1mQMtHnvhfsP7xoY8uI0/UHXSASqLkwPYwPirCQa\n\tAuEat1SC6ONuu1VZ6ATmGSOfl80IVZJyd9OZbIzSgGXI7APHfSe80VDt0J4cX8n/EYN4\n\tBAZlpW6gU4Ezck7PfOFG4on3QGltM6BtudRuJtTlS7M3LlLSSjljJNqUfDOmmQ9TlVki\n\tzaqi/iQfMsUHXEDodTLNhZiOkJmLotjKg/ocb3LOAs5LH11qB3qXtn2Zfkob/i7vI9f+\n\t7GcmHcPHEsoche9kfNHw88jFaXOBZ6GmyLaxH2R/fx8y5FUdsthOsqJoV3cUw0zgXSmE\n\tCoFw==","X-Gm-Message-State":"AOAM533ogrilyAPsWvo34TCfinR8mz9xPAhVxtn3UEUuC9C4+ME70JhI\n\tayJcuD9iomCi+/88vUAoHgyeCFpyGiVLJYtlTnqaVQ==","X-Google-Smtp-Source":"ABdhPJzGKspq2nbsU4Q/Pbs45Rjr0+HBlgEbWdYQEMfMhCpbu+bkDTgL8khNMRL3mC3OYzYnLSR3i4QjAtXMgIeKYhk=","X-Received":"by 2002:a5d:4bca:: with SMTP id l10mr349134wrt.236.1625241103157;\n\tFri, 02 Jul 2021 08:51:43 -0700 (PDT)","MIME-Version":"1.0","References":"<20210702150940.226941-1-naush@raspberrypi.com>\n\t<20210702150940.226941-4-naush@raspberrypi.com>","In-Reply-To":"<20210702150940.226941-4-naush@raspberrypi.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Fri, 2 Jul 2021 16:51:31 +0100","Message-ID":"<CAHW6GY+1oC1cXK1xrrph4GWpxKgswKNe-7WZXUy67=xe5Y-k2g@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v3 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 <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]