From patchwork Mon Jun 14 09:53:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12581 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 B2658C3218 for ; Mon, 14 Jun 2021 09:53:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EAFF46893A; Mon, 14 Jun 2021 11:53:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="OAPPAdz5"; dkim-atps=neutral Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 04A3D6892E for ; Mon, 14 Jun 2021 11:53:47 +0200 (CEST) Received: by mail-wm1-x32f.google.com with SMTP id g204so11746411wmf.5 for ; Mon, 14 Jun 2021 02:53:47 -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=kPuFk49pii5/tLsd+X1YpO60JWW5UTyY5zkbwfO6vXY=; b=OAPPAdz5P3/NNhMuA9iK/tzwOZ7p/i5nY6U++e8AxFzRxZg57gUuWyd6x3SQyz58kg Bw+rdbo7Q9F9/0WJ/5F2GDCNX7bdgGoNRFg2R0Bd3gQ0IySl9WeKfFhkHH1Wn+MBjR7z +9/31gOwdQk930n087Mz+uUYeJxkSF9cxYFVZfYdVPddjQpfvQRRJiAFvnNlMkcOqYpP K3xWofuUILDkiWXi2HX8HitQ1gDPLIuFNJYdKUFxu0rLK/VZb6qXAPQ13a1Ss2s26GSc wlNIez3205H4O8KiMQgSrcfnO5c3Qw7lEe1sF0WZWGyHxkHXBALeOWHVL7H5q4Dvxtyj JYRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kPuFk49pii5/tLsd+X1YpO60JWW5UTyY5zkbwfO6vXY=; b=V/BNthgHBnoZnnsCoYKbDwg3KgKqLZa/gVyfVXyeRhTOvYeznqmNGiLqb4srSELzGM u0lELBrYKzhO1RjrglpDs+o8MNqErbwsU07BE1nN+/8Ufj8i0kkbYrqShDOF06CkXspo HooXoevV2fRvcchCbAqbP1tpwHjtPqK/czmDtYAsolJpgd15EEBbYFDbbDLUMdZWfAy8 zCFQ2nNiG3n3dYotj42HXtBOh7s5kpnyhSl2A9Bj97vrSEIAZ9JpfJRihL50BAgBtsg+ h+TocUCMQqKQGMnYYta73bdsdjeI6gBaUamakrruHoMU4tsgewVGHGCeyhBj2SRDsUiF OTrQ== X-Gm-Message-State: AOAM532nptT2X+ocRVHov1oeJiLle6gJqArdQVuOqOWx6yY0d03qu7XD VLKEOcMkrrusb7HOKuHF/KoJ+tmpd9sL5A== X-Google-Smtp-Source: ABdhPJzj0+4a2MQHE9wPcwVMuRyThPkLT4y5H1fZyb7tHQEQdiRySytjCFDl0CCtpdZgpTAazNQrCw== X-Received: by 2002:a7b:c7c5:: with SMTP id z5mr15247797wmk.77.1623664426310; Mon, 14 Jun 2021 02:53:46 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:fd93:d554:2dff:83ca]) by smtp.gmail.com with ESMTPSA id c2sm19834891wmf.24.2021.06.14.02.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 02:53:45 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 14 Jun 2021 10:53:35 +0100 Message-Id: <20210614095340.3051816-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614095340.3051816-1-naush@raspberrypi.com> References: <20210614095340.3051816-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/6] ipa: raspberrypi: Non-functional formatting fixes to md_parser.hpp 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Adjust source formatting to closer match libcamera guidelines: - Remove unused header files. - Switch to C style comments. - Add whitespace for readability. There are no functional changes in this commit. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/md_parser.hpp | 144 ++++++++++++++++++------------ 1 file changed, 85 insertions(+), 59 deletions(-) diff --git a/src/ipa/raspberrypi/md_parser.hpp b/src/ipa/raspberrypi/md_parser.hpp index 8e22b1d7ca43..86e0577614e0 100644 --- a/src/ipa/raspberrypi/md_parser.hpp +++ b/src/ipa/raspberrypi/md_parser.hpp @@ -6,75 +6,94 @@ */ #pragma once -#include - #include /* Camera metadata parser class. Usage as shown below. - -Setup: - -Usually the metadata parser will be made as part of the CamHelper class so -application code doesn't have to worry which to kind to instantiate. But for -the sake of example let's suppose we're parsing imx219 metadata. - -MdParser *parser = new MdParserImx219(); // for example -parser->SetBitsPerPixel(bpp); -parser->SetLineLengthBytes(pitch); -parser->SetNumLines(2); - -Note 1: if you don't know how many lines there are, the size of the input -buffer is used as a limit instead. - -Note 2: if you don't know the line length, you can leave the line length unset -(or set to zero) and the parser will hunt for the line start instead. - -Then on every frame: - -if (parser->Parse(buffer) != MdParser::OK) - much badness; -unsigned int exposure_lines, gain_code -if (parser->GetExposureLines(exposure_lines) != MdParser::OK) - exposure was not found; -if (parser->GetGainCode(parser, gain_code) != MdParser::OK) - gain code was not found; - -(Note that the CamHelper class converts to/from exposure lines and time, -and gain_code / actual gain.) - -If you suspect your embedded data may have changed its layout, change any line -lengths, number of lines, bits per pixel etc. that are different, and -then: - -parser->Reset(); - -before calling Parse again. */ + * + * Setup: + * + * Usually the metadata parser will be made as part of the CamHelper class so + * application code doesn't have to worry which to kind to instantiate. But for + * the sake of example let's suppose we're parsing imx219 metadata. + * + * MdParser *parser = new MdParserImx219(); // for example + * parser->SetBitsPerPixel(bpp); + * parser->SetLineLengthBytes(pitch); + * parser->SetNumLines(2); + * + * Note 1: if you don't know how many lines there are, the size of the input + * buffer is used as a limit instead. + * + * Note 2: if you don't know the line length, you can leave the line length unset + * (or set to zero) and the parser will hunt for the line start instead. + * + * Then on every frame: + * + * if (parser->Parse(buffer) != MdParser::OK) + * much badness; + * unsigned int exposure_lines, gain_code + * if (parser->GetExposureLines(exposure_lines) != MdParser::OK) + * exposure was not found; + * if (parser->GetGainCode(parser, gain_code) != MdParser::OK) + * gain code was not found; + * + * (Note that the CamHelper class converts to/from exposure lines and time, + * and gain_code / actual gain.) + * + * If you suspect your embedded data may have changed its layout, change any line + * lengths, number of lines, bits per pixel etc. that are different, and + * then: + * + * parser->Reset(); + * + * before calling Parse again. + */ namespace RPiController { -// Abstract base class from which other metadata parsers are derived. +/* Abstract base class from which other metadata parsers are derived. */ class MdParser { public: - // Parser status codes: - // OK - success - // NOTFOUND - value such as exposure or gain was not found - // ERROR - all other errors + /* + * Parser status codes: + * OK - success + * NOTFOUND - value such as exposure or gain was not found + * ERROR - all other errors + */ enum Status { OK = 0, NOTFOUND = 1, ERROR = 2 }; - MdParser() : reset_(true) {} + + MdParser() : reset_(true) + { + } + virtual ~MdParser() = default; - void Reset() { reset_ = true; } - void SetBitsPerPixel(int bpp) { bits_per_pixel_ = bpp; } - void SetNumLines(unsigned int num_lines) { num_lines_ = num_lines; } + + void Reset() + { + reset_ = true; + } + + void SetBitsPerPixel(int bpp) + { + bits_per_pixel_ = bpp; + } + + void SetNumLines(unsigned int num_lines) + { + num_lines_ = num_lines; + } + void SetLineLengthBytes(unsigned int num_bytes) { line_length_bytes_ = num_bytes; } + virtual Status Parse(libcamera::Span buffer) = 0; virtual Status GetExposureLines(unsigned int &lines) = 0; virtual Status GetGainCode(unsigned int &gain_code) = 0; @@ -87,22 +106,28 @@ protected: unsigned int buffer_size_bytes_; }; -// This isn't a full implementation of a metadata parser for SMIA sensors, -// however, it does provide the findRegs method which will prove useful and make -// it easier to implement parsers for other SMIA-like sensors (see -// md_parser_imx219.cpp for an example). +/* + * This isn't a full implementation of a metadata parser for SMIA sensors, + * however, it does provide the findRegs method which will prove useful and make + * it easier to implement parsers for other SMIA-like sensors (see + * md_parser_imx219.cpp for an example). + */ class MdParserSmia : public MdParser { public: - MdParserSmia() : MdParser() {} + MdParserSmia() : MdParser() + { + } protected: - // Note that error codes > 0 are regarded as non-fatal; codes < 0 - // indicate a bad data buffer. Status codes are: - // PARSE_OK - found all registers, much happiness - // MISSING_REGS - some registers found; should this be a hard error? - // The remaining codes are all hard errors. + /* + * Note that error codes > 0 are regarded as non-fatal; codes < 0 + * indicate a bad data buffer. Status codes are: + * PARSE_OK - found all registers, much happiness + * MISSING_REGS - some registers found; should this be a hard error? + * The remaining codes are all hard errors. + */ enum ParseStatus { PARSE_OK = 0, MISSING_REGS = 1, @@ -112,6 +137,7 @@ protected: BAD_LINE_END = -4, BAD_PADDING = -5 }; + ParseStatus findRegs(libcamera::Span buffer, uint32_t regs[], int offsets[], unsigned int num_regs); };