{"id":12585,"url":"https://patchwork.libcamera.org/api/patches/12585/?format=json","web_url":"https://patchwork.libcamera.org/patch/12585/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210614095340.3051816-5-naush@raspberrypi.com>","date":"2021-06-14T09:53:38","name":"[libcamera-devel,4/6] ipa: raspberrypi: Non-functional formatting fixes to md_parser_smia.cpp","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"bff18214944a8ca117f0ca94f14fb087181b7b05","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12585/mbox/","series":[{"id":2128,"url":"https://patchwork.libcamera.org/api/series/2128/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2128","date":"2021-06-14T09:53:34","name":"Raspberry Pi: Metadata parsing improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/2128/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12585/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12585/checks/","tags":{},"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 BAEA2C3218\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 14 Jun 2021 09:53:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 439936892E;\n\tMon, 14 Jun 2021 11:53:57 +0200 (CEST)","from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n\t[IPv6:2a00:1450:4864:20::335])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C6F2B6892E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Jun 2021 11:53:48 +0200 (CEST)","by mail-wm1-x335.google.com with SMTP id\n\tv206-20020a1cded70000b02901a586d3fa23so12410517wmg.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Jun 2021 02:53:48 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:fd93:d554:2dff:83ca])\n\tby smtp.gmail.com with ESMTPSA id\n\tc2sm19834891wmf.24.2021.06.14.02.53.47\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 14 Jun 2021 02:53:47 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"Tiivs/dr\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=34le5w+WAQXu2pLv13o0Ik/41cbpR/8uQ+Df8ylFK58=;\n\tb=Tiivs/drImWpcYRokGpJMJh+ASHdnFPi1HxVAet8eZU3uJxeqKcFuvsfMZZZzG+NcZ\n\tFGugGmyDnYqo3F68QBuNULrqHNFwHI2fhRmwMLub5teqAAAcmTHD4iamXaQZcReagEqG\n\tSlMBFhhRNlTod4hnqF+0IoLwgrgU6wway5z/ZRN8NexAuWhK6BdoC5hL8by51eJfQ7KV\n\tQcOdZ+Por3VJq/dAdyS5CmR8q/V9hLMYbPrKzI7ip1uVG387KAAxRZh4kRq0AG+/8zPi\n\t9vpkPYWnD+Gbonm0L/h5L480hhkfV341Vgz+omwVsUIx2yvNpSJT4FYrsUgKPl3YJkTY\n\tec7A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=34le5w+WAQXu2pLv13o0Ik/41cbpR/8uQ+Df8ylFK58=;\n\tb=pU7huVarDAR6Jia8GPEEWx5YUKFTysBHTp6Pi1AB8A4iyE95jyyjSaVqHKsVcTXmol\n\tyfJHOH8RATl+sd5O+ga3arjYAKASEeib53J1UKfpOm2g4a5XlLhtrm2WJnHQ4fXbeUJO\n\tf4vCCIXQCyILGsMKcf4Agl0S83ARG1RvatT7qZa7YZ74bDR7+xcMwa7sVTJgJIN3IxOF\n\tNG294XQYEv6m5Z38ciG6jVyJ1YSRZf5Agk2csMn74el04Q634NETEqbZOC3jpHhEM4sK\n\tA3pua4kxUrK3MKTtll+2vswJChGsFydWokMCQPcQB3bRKDmxT1/4ICdcxmHsrAZyBL3p\n\tuMaA==","X-Gm-Message-State":"AOAM530pXX/xmqu31xbeajA+J/5/mTP2zDJnboRCH/8plo956Pcx/6zp\n\tc16nVjN4JP0hkpeO2MxRCnecW9UMdEj0vg==","X-Google-Smtp-Source":"ABdhPJxtnlmAVvKnLbl5hwZQkx5H7iA14U9ghDCQXjfbl30BBpKmX6u7SH7T0APCrisFPTko0I5RxA==","X-Received":"by 2002:a1c:7918:: with SMTP id\n\tl24mr12625115wme.126.1623664428036; \n\tMon, 14 Jun 2021 02:53:48 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 14 Jun 2021 10:53:38 +0100","Message-Id":"<20210614095340.3051816-5-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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 4/6] ipa: raspberrypi: Non-functional\n\tformatting fixes to md_parser_smia.cpp","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>"},"content":"Adjust source formatting to closer match libcamera guidelines:\n\n- Switch to C style comments.\n- Adjust whitespace for readability.\n- Remove retcode local variable usage.\n\nThere are no functional changes in this commit.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/md_parser_smia.cpp | 70 ++++++++++++++------------\n 1 file changed, 38 insertions(+), 32 deletions(-)","diff":"diff --git a/src/ipa/raspberrypi/md_parser_smia.cpp b/src/ipa/raspberrypi/md_parser_smia.cpp\nindex 852a1d347d11..65ffbe00c76e 100644\n--- a/src/ipa/raspberrypi/md_parser_smia.cpp\n+++ b/src/ipa/raspberrypi/md_parser_smia.cpp\n@@ -1,31 +1,32 @@\n /* SPDX-License-Identifier: BSD-2-Clause */\n /*\n- * Copyright (C) 2019, Raspberry Pi (Trading) Limited\n+ * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited\n  *\n- * md_parser.cpp - image sensor metadata parsers\n+ * md_parser_smia.cpp - SMIA specification based embedded data parser\n  */\n-\n #include <assert.h>\n #include <map>\n-#include <string.h>\n+#include <string>\n \n #include \"md_parser.hpp\"\n \n using namespace RPiController;\n \n-// This function goes through the embedded data to find the offsets (not\n-// values!), in the data block, where the values of the given registers can\n-// subsequently be found.\n-\n-// Embedded data tag bytes, from Sony IMX219 datasheet but general to all SMIA\n-// sensors, I think.\n+/*\n+ * This function goes through the embedded data to find the offsets (not\n+ * values!), in the data block, where the values of the given registers can\n+ * subsequently be found.\n+ *\n+ * Embedded data tag bytes, from Sony IMX219 datasheet but general to all SMIA\n+ * sensors, I think.\n+ */\n \n-#define LINE_START 0x0a\n-#define LINE_END_TAG 0x07\n-#define REG_HI_BITS 0xaa\n-#define REG_LOW_BITS 0xa5\n-#define REG_VALUE 0x5a\n-#define REG_SKIP 0x55\n+constexpr unsigned int LINE_START = 0x0a;\n+constexpr unsigned int LINE_END_TAG = 0x07;\n+constexpr unsigned int REG_HI_BITS = 0xaa;\n+constexpr unsigned int REG_LOW_BITS = 0xa5;\n+constexpr unsigned int REG_VALUE = 0x5a;\n+constexpr unsigned int REG_SKIP = 0x55;\n \n MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t> buffer,\n \t\t\t\t\t\t uint32_t regs[], int offsets[],\n@@ -36,12 +37,13 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t>\n \tif (buffer[0] != LINE_START)\n \t\treturn NO_LINE_START;\n \n-\tunsigned int current_offset = 1; // after the LINE_START\n+\tunsigned int current_offset = 1; /* after the LINE_START */\n \tunsigned int current_line_start = 0, current_line = 0;\n \tunsigned int reg_num = 0, first_reg = 0;\n-\tParseStatus retcode = PARSE_OK;\n+\n \twhile (1) {\n \t\tint tag = buffer[current_offset++];\n+\n \t\tif ((bits_per_pixel_ == 10 &&\n \t\t     (current_offset + 1 - current_line_start) % 5 == 0) ||\n \t\t    (bits_per_pixel_ == 12 &&\n@@ -49,34 +51,38 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t>\n \t\t\tif (buffer[current_offset++] != REG_SKIP)\n \t\t\t\treturn BAD_DUMMY;\n \t\t}\n+\n \t\tint data_byte = buffer[current_offset++];\n-\t\t//printf(\"Offset %u, tag 0x%02x data_byte 0x%02x\\n\", current_offset-1, tag, data_byte);\n+\n \t\tif (tag == LINE_END_TAG) {\n \t\t\tif (data_byte != LINE_END_TAG)\n \t\t\t\treturn BAD_LINE_END;\n+\n \t\t\tif (num_lines_ && ++current_line == num_lines_)\n \t\t\t\treturn MISSING_REGS;\n+\n \t\t\tif (line_length_bytes_) {\n-\t\t\t\tcurrent_offset =\n-\t\t\t\t\tcurrent_line_start + line_length_bytes_;\n-\t\t\t\t// Require whole line to be in the buffer (if buffer size set).\n+\t\t\t\tcurrent_offset = current_line_start + line_length_bytes_;\n+\n+\t\t\t\t/* Require whole line to be in the buffer (if buffer size set). */\n \t\t\t\tif (buffer.size() &&\n-\t\t\t\t    current_offset + line_length_bytes_ >\n-\t\t\t\t\t    buffer.size())\n+\t\t\t\t    current_offset + line_length_bytes_ > buffer.size())\n \t\t\t\t\treturn MISSING_REGS;\n+\n \t\t\t\tif (buffer[current_offset] != LINE_START)\n \t\t\t\t\treturn NO_LINE_START;\n \t\t\t} else {\n-\t\t\t\t// allow a zero line length to mean \"hunt for the next line\"\n+\t\t\t\t/* allow a zero line length to mean \"hunt for the next line\" */\n \t\t\t\twhile (buffer[current_offset] != LINE_START &&\n \t\t\t\t       current_offset < buffer.size())\n \t\t\t\t\tcurrent_offset++;\n+\n \t\t\t\tif (current_offset == buffer.size())\n \t\t\t\t\treturn NO_LINE_START;\n \t\t\t}\n-\t\t\t// inc current_offset to after LINE_START\n-\t\t\tcurrent_line_start =\n-\t\t\t\tcurrent_offset++;\n+\n+\t\t\t/* inc current_offset to after LINE_START */\n+\t\t\tcurrent_line_start = current_offset++;\n \t\t} else {\n \t\t\tif (tag == REG_HI_BITS)\n \t\t\t\treg_num = (reg_num & 0xff) | (data_byte << 8);\n@@ -86,13 +92,13 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t>\n \t\t\t\treg_num++;\n \t\t\telse if (tag == REG_VALUE) {\n \t\t\t\twhile (reg_num >=\n-\t\t\t\t       // assumes registers are in order...\n+\t\t\t\t       /* assumes registers are in order... */\n \t\t\t\t       regs[first_reg]) {\n \t\t\t\t\tif (reg_num == regs[first_reg])\n-\t\t\t\t\t\toffsets[first_reg] =\n-\t\t\t\t\t\t\tcurrent_offset - 1;\n+\t\t\t\t\t\toffsets[first_reg] = current_offset - 1;\n+\n \t\t\t\t\tif (++first_reg == num_regs)\n-\t\t\t\t\t\treturn retcode;\n+\t\t\t\t\t\treturn PARSE_OK;\n \t\t\t\t}\n \t\t\t\treg_num++;\n \t\t\t} else\n","prefixes":["libcamera-devel","4/6"]}