From patchwork Mon Jun 14 09:53:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12585 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 BAEA2C3218 for ; Mon, 14 Jun 2021 09:53:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 439936892E; Mon, 14 Jun 2021 11:53:57 +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="Tiivs/dr"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C6F2B6892E for ; Mon, 14 Jun 2021 11:53:48 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id v206-20020a1cded70000b02901a586d3fa23so12410517wmg.4 for ; Mon, 14 Jun 2021 02:53:48 -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=34le5w+WAQXu2pLv13o0Ik/41cbpR/8uQ+Df8ylFK58=; b=Tiivs/drImWpcYRokGpJMJh+ASHdnFPi1HxVAet8eZU3uJxeqKcFuvsfMZZZzG+NcZ FGugGmyDnYqo3F68QBuNULrqHNFwHI2fhRmwMLub5teqAAAcmTHD4iamXaQZcReagEqG SlMBFhhRNlTod4hnqF+0IoLwgrgU6wway5z/ZRN8NexAuWhK6BdoC5hL8by51eJfQ7KV QcOdZ+Por3VJq/dAdyS5CmR8q/V9hLMYbPrKzI7ip1uVG387KAAxRZh4kRq0AG+/8zPi 9vpkPYWnD+Gbonm0L/h5L480hhkfV341Vgz+omwVsUIx2yvNpSJT4FYrsUgKPl3YJkTY ec7A== 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=34le5w+WAQXu2pLv13o0Ik/41cbpR/8uQ+Df8ylFK58=; b=pU7huVarDAR6Jia8GPEEWx5YUKFTysBHTp6Pi1AB8A4iyE95jyyjSaVqHKsVcTXmol yfJHOH8RATl+sd5O+ga3arjYAKASEeib53J1UKfpOm2g4a5XlLhtrm2WJnHQ4fXbeUJO f4vCCIXQCyILGsMKcf4Agl0S83ARG1RvatT7qZa7YZ74bDR7+xcMwa7sVTJgJIN3IxOF NG294XQYEv6m5Z38ciG6jVyJ1YSRZf5Agk2csMn74el04Q634NETEqbZOC3jpHhEM4sK A3pua4kxUrK3MKTtll+2vswJChGsFydWokMCQPcQB3bRKDmxT1/4ICdcxmHsrAZyBL3p uMaA== X-Gm-Message-State: AOAM530pXX/xmqu31xbeajA+J/5/mTP2zDJnboRCH/8plo956Pcx/6zp c16nVjN4JP0hkpeO2MxRCnecW9UMdEj0vg== X-Google-Smtp-Source: ABdhPJxtnlmAVvKnLbl5hwZQkx5H7iA14U9ghDCQXjfbl30BBpKmX6u7SH7T0APCrisFPTko0I5RxA== X-Received: by 2002:a1c:7918:: with SMTP id l24mr12625115wme.126.1623664428036; Mon, 14 Jun 2021 02:53:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 02:53:47 -0700 (PDT) From: Naushir Patuck 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 Subject: [libcamera-devel] [PATCH 4/6] ipa: raspberrypi: Non-functional formatting fixes to md_parser_smia.cpp 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: - Switch to C style comments. - Adjust whitespace for readability. - Remove retcode local variable usage. 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_smia.cpp | 70 ++++++++++++++------------ 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/src/ipa/raspberrypi/md_parser_smia.cpp b/src/ipa/raspberrypi/md_parser_smia.cpp index 852a1d347d11..65ffbe00c76e 100644 --- a/src/ipa/raspberrypi/md_parser_smia.cpp +++ b/src/ipa/raspberrypi/md_parser_smia.cpp @@ -1,31 +1,32 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited * - * md_parser.cpp - image sensor metadata parsers + * md_parser_smia.cpp - SMIA specification based embedded data parser */ - #include #include -#include +#include #include "md_parser.hpp" using namespace RPiController; -// This function goes through the embedded data to find the offsets (not -// values!), in the data block, where the values of the given registers can -// subsequently be found. - -// Embedded data tag bytes, from Sony IMX219 datasheet but general to all SMIA -// sensors, I think. +/* + * This function goes through the embedded data to find the offsets (not + * values!), in the data block, where the values of the given registers can + * subsequently be found. + * + * Embedded data tag bytes, from Sony IMX219 datasheet but general to all SMIA + * sensors, I think. + */ -#define LINE_START 0x0a -#define LINE_END_TAG 0x07 -#define REG_HI_BITS 0xaa -#define REG_LOW_BITS 0xa5 -#define REG_VALUE 0x5a -#define REG_SKIP 0x55 +constexpr unsigned int LINE_START = 0x0a; +constexpr unsigned int LINE_END_TAG = 0x07; +constexpr unsigned int REG_HI_BITS = 0xaa; +constexpr unsigned int REG_LOW_BITS = 0xa5; +constexpr unsigned int REG_VALUE = 0x5a; +constexpr unsigned int REG_SKIP = 0x55; MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span buffer, uint32_t regs[], int offsets[], @@ -36,12 +37,13 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span if (buffer[0] != LINE_START) return NO_LINE_START; - unsigned int current_offset = 1; // after the LINE_START + unsigned int current_offset = 1; /* after the LINE_START */ unsigned int current_line_start = 0, current_line = 0; unsigned int reg_num = 0, first_reg = 0; - ParseStatus retcode = PARSE_OK; + while (1) { int tag = buffer[current_offset++]; + if ((bits_per_pixel_ == 10 && (current_offset + 1 - current_line_start) % 5 == 0) || (bits_per_pixel_ == 12 && @@ -49,34 +51,38 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span if (buffer[current_offset++] != REG_SKIP) return BAD_DUMMY; } + int data_byte = buffer[current_offset++]; - //printf("Offset %u, tag 0x%02x data_byte 0x%02x\n", current_offset-1, tag, data_byte); + if (tag == LINE_END_TAG) { if (data_byte != LINE_END_TAG) return BAD_LINE_END; + if (num_lines_ && ++current_line == num_lines_) return MISSING_REGS; + if (line_length_bytes_) { - current_offset = - current_line_start + line_length_bytes_; - // Require whole line to be in the buffer (if buffer size set). + current_offset = current_line_start + line_length_bytes_; + + /* Require whole line to be in the buffer (if buffer size set). */ if (buffer.size() && - current_offset + line_length_bytes_ > - buffer.size()) + current_offset + line_length_bytes_ > buffer.size()) return MISSING_REGS; + if (buffer[current_offset] != LINE_START) return NO_LINE_START; } else { - // allow a zero line length to mean "hunt for the next line" + /* allow a zero line length to mean "hunt for the next line" */ while (buffer[current_offset] != LINE_START && current_offset < buffer.size()) current_offset++; + if (current_offset == buffer.size()) return NO_LINE_START; } - // inc current_offset to after LINE_START - current_line_start = - current_offset++; + + /* inc current_offset to after LINE_START */ + current_line_start = current_offset++; } else { if (tag == REG_HI_BITS) reg_num = (reg_num & 0xff) | (data_byte << 8); @@ -86,13 +92,13 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span reg_num++; else if (tag == REG_VALUE) { while (reg_num >= - // assumes registers are in order... + /* assumes registers are in order... */ regs[first_reg]) { if (reg_num == regs[first_reg]) - offsets[first_reg] = - current_offset - 1; + offsets[first_reg] = current_offset - 1; + if (++first_reg == num_regs) - return retcode; + return PARSE_OK; } reg_num++; } else