From patchwork Fri Aug 30 13:18:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 21099 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 71107C32DA for ; Fri, 30 Aug 2024 13:20:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 940DF634F1; Fri, 30 Aug 2024 15:20:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="IRz/F0On"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 492BC634E0 for ; Fri, 30 Aug 2024 15:19:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725023987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=23M2hfhy+zNZHg/JuWmM6lqOiuQNPh2eIHg+QDYwtBA=; b=IRz/F0OnJfFoTGW8LnAYgM5G4YFBwnce8u102CFK/R9+t3xPzl5HV9D9c87TudqWIhMVmG I5tV+11jokxmewYkgzSv4K0hFmnGb8hu371DnCVpUUWcsEMPTqwDbH0Lz4itwgHGreOc/J DUDMzCIKVd6swlGu1kCC1/22tDUVY3I= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-nxML2X06MuipLRrVTRzDIg-1; Fri, 30 Aug 2024 09:19:45 -0400 X-MC-Unique: nxML2X06MuipLRrVTRzDIg-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0E7201955BED for ; Fri, 30 Aug 2024 13:19:45 +0000 (UTC) Received: from nuthatch.redhat.com (unknown [10.45.225.65]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 912511955F45; Fri, 30 Aug 2024 13:19:43 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [PATCH 16/19] libcamera: libcamera: Formatting improvements Date: Fri, 30 Aug 2024 15:18:53 +0200 Message-ID: <20240830131904.1090330-17-mzamazal@redhat.com> In-Reply-To: <20240830131904.1090330-1-mzamazal@redhat.com> References: <20240830131904.1090330-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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" The LSP autoformatter doesn't like some of the current formatting, let's make it happy. Signed-off-by: Milan Zamazal --- src/libcamera/base/event_dispatcher_poll.cpp | 3 +- src/libcamera/camera.cpp | 4 +- src/libcamera/controls.cpp | 31 +++---- src/libcamera/ipa_data_serializer.cpp | 95 ++++++++++---------- src/libcamera/ipa_module.cpp | 15 ++-- src/libcamera/orientation.cpp | 16 ++-- src/libcamera/pipeline_handler.cpp | 5 +- src/libcamera/process.cpp | 7 +- src/libcamera/sensor/camera_sensor.cpp | 6 +- src/libcamera/shared_mem_object.cpp | 4 +- src/libcamera/stream.cpp | 6 +- 11 files changed, 97 insertions(+), 95 deletions(-) diff --git a/src/libcamera/base/event_dispatcher_poll.cpp b/src/libcamera/base/event_dispatcher_poll.cpp index 86a26f36..288246ff 100644 --- a/src/libcamera/base/event_dispatcher_poll.cpp +++ b/src/libcamera/base/event_dispatcher_poll.cpp @@ -5,8 +5,6 @@ * Poll-based event dispatcher */ -#include - #include #include #include @@ -15,6 +13,7 @@ #include #include +#include #include #include #include diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 88210ff3..69e54439 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -5,7 +5,7 @@ * Camera device */ -#include +#include "libcamera/internal/camera.h" #include #include @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include -#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_controls.h" #include "libcamera/internal/pipeline_handler.h" #include "libcamera/internal/request.h" diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 67400797..603e2672 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -5,15 +5,15 @@ * Control handling */ -#include - #include -#include #include +#include #include #include +#include + #include "libcamera/internal/control_validator.h" /** @@ -51,15 +51,15 @@ LOG_DEFINE_CATEGORY(Controls) namespace { static constexpr size_t ControlValueSize[] = { - [ControlTypeNone] = 0, - [ControlTypeBool] = sizeof(bool), - [ControlTypeByte] = sizeof(uint8_t), - [ControlTypeInteger32] = sizeof(int32_t), - [ControlTypeInteger64] = sizeof(int64_t), - [ControlTypeFloat] = sizeof(float), - [ControlTypeString] = sizeof(char), - [ControlTypeRectangle] = sizeof(Rectangle), - [ControlTypeSize] = sizeof(Size), + [ControlTypeNone] = 0, + [ControlTypeBool] = sizeof(bool), + [ControlTypeByte] = sizeof(uint8_t), + [ControlTypeInteger32] = sizeof(int32_t), + [ControlTypeInteger64] = sizeof(int64_t), + [ControlTypeFloat] = sizeof(float), + [ControlTypeString] = sizeof(char), + [ControlTypeRectangle] = sizeof(Rectangle), + [ControlTypeSize] = sizeof(Size), }; } /* namespace */ @@ -186,8 +186,8 @@ Span ControlValue::data() const { std::size_t size = numElements_ * ControlValueSize[type_]; const uint8_t *data = size > sizeof(value_) - ? reinterpret_cast(storage_) - : reinterpret_cast(&value_); + ? reinterpret_cast(storage_) + : reinterpret_cast(&value_); return { data, size }; } @@ -700,7 +700,8 @@ bool ControlInfoMap::validate() * values. */ ControlType rangeType = id->type() == ControlTypeString - ? ControlTypeInteger32 : id->type(); + ? ControlTypeInteger32 + : id->type(); const ControlInfo &info = ctrl.second; if (info.min().type() != rangeType) { diff --git a/src/libcamera/ipa_data_serializer.cpp b/src/libcamera/ipa_data_serializer.cpp index f6dd7e6f..67a5726a 100644 --- a/src/libcamera/ipa_data_serializer.cpp +++ b/src/libcamera/ipa_data_serializer.cpp @@ -188,52 +188,52 @@ namespace { #ifndef __DOXYGEN__ -#define DEFINE_POD_SERIALIZER(type) \ - \ -template<> \ -std::tuple, std::vector> \ -IPADataSerializer::serialize(const type &data, \ - [[maybe_unused]] ControlSerializer *cs) \ -{ \ - std::vector dataVec; \ - dataVec.reserve(sizeof(type)); \ - appendPOD(dataVec, data); \ - \ - return { dataVec, {} }; \ -} \ - \ -template<> \ -type IPADataSerializer::deserialize(std::vector::const_iterator dataBegin, \ - std::vector::const_iterator dataEnd, \ - [[maybe_unused]] ControlSerializer *cs) \ -{ \ - return readPOD(dataBegin, 0, dataEnd); \ -} \ - \ -template<> \ -type IPADataSerializer::deserialize(const std::vector &data, \ - ControlSerializer *cs) \ -{ \ - return deserialize(data.cbegin(), data.end(), cs); \ -} \ - \ -template<> \ -type IPADataSerializer::deserialize(const std::vector &data, \ - [[maybe_unused]] const std::vector &fds, \ - ControlSerializer *cs) \ -{ \ - return deserialize(data.cbegin(), data.end(), cs); \ -} \ - \ -template<> \ -type IPADataSerializer::deserialize(std::vector::const_iterator dataBegin, \ - std::vector::const_iterator dataEnd, \ - [[maybe_unused]] std::vector::const_iterator fdsBegin, \ - [[maybe_unused]] std::vector::const_iterator fdsEnd, \ - ControlSerializer *cs) \ -{ \ - return deserialize(dataBegin, dataEnd, cs); \ -} +#define DEFINE_POD_SERIALIZER(type) \ + \ + template<> \ + std::tuple, std::vector> \ + IPADataSerializer::serialize(const type &data, \ + [[maybe_unused]] ControlSerializer *cs) \ + { \ + std::vector dataVec; \ + dataVec.reserve(sizeof(type)); \ + appendPOD(dataVec, data); \ + \ + return { dataVec, {} }; \ + } \ + \ + template<> \ + type IPADataSerializer::deserialize(std::vector::const_iterator dataBegin, \ + std::vector::const_iterator dataEnd, \ + [[maybe_unused]] ControlSerializer *cs) \ + { \ + return readPOD(dataBegin, 0, dataEnd); \ + } \ + \ + template<> \ + type IPADataSerializer::deserialize(const std::vector &data, \ + ControlSerializer *cs) \ + { \ + return deserialize(data.cbegin(), data.end(), cs); \ + } \ + \ + template<> \ + type IPADataSerializer::deserialize(const std::vector &data, \ + [[maybe_unused]] const std::vector &fds, \ + ControlSerializer *cs) \ + { \ + return deserialize(data.cbegin(), data.end(), cs); \ + } \ + \ + template<> \ + type IPADataSerializer::deserialize(std::vector::const_iterator dataBegin, \ + std::vector::const_iterator dataEnd, \ + [[maybe_unused]] std::vector::const_iterator fdsBegin, \ + [[maybe_unused]] std::vector::const_iterator fdsEnd, \ + ControlSerializer *cs) \ + { \ + return deserialize(dataBegin, dataEnd, cs); \ + } DEFINE_POD_SERIALIZER(bool) DEFINE_POD_SERIALIZER(uint8_t) @@ -539,7 +539,6 @@ IPADataSerializer::serialize(const SharedFD &data, if (data.isValid()) fdVec.push_back(data); - return { dataVec, fdVec }; } @@ -606,7 +605,7 @@ IPADataSerializer::deserialize(std::vector::const_i FrameBuffer::Plane ret; ret.fd = IPADataSerializer::deserialize(dataBegin, dataBegin + 4, - fdsBegin, fdsBegin + 1); + fdsBegin, fdsBegin + 1); ret.offset = readPOD(dataBegin, 4, dataEnd); ret.length = readPOD(dataBegin, 8, dataEnd); diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index 86d88a86..b8b2eb6c 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -50,8 +50,8 @@ typename std::remove_extent_t *elfPointer(Span elf, if (size > elf.size() || size < objSize) return nullptr; - return reinterpret_cast *> - (reinterpret_cast(elf.data()) + offset); + return reinterpret_cast *>( + reinterpret_cast(elf.data()) + offset); } template @@ -80,21 +80,22 @@ int elfVerifyIdent(Span elf) int a = 1; unsigned char endianness = *reinterpret_cast(&a) == 1 - ? ELFDATA2LSB : ELFDATA2MSB; + ? ELFDATA2LSB + : ELFDATA2MSB; if (e_ident[EI_DATA] != endianness) return -ENOEXEC; return 0; } -const ElfW(Shdr) *elfSection(Span elf, const ElfW(Ehdr) *eHdr, - ElfW(Half) idx) +const ElfW(Shdr) * elfSection(Span elf, const ElfW(Ehdr) * eHdr, + ElfW(Half) idx) { if (idx >= eHdr->e_shnum) return nullptr; - off_t offset = eHdr->e_shoff + idx * - static_cast(eHdr->e_shentsize); + off_t offset = + eHdr->e_shoff + idx * static_cast(eHdr->e_shentsize); return elfPointer(elf, offset); } diff --git a/src/libcamera/orientation.cpp b/src/libcamera/orientation.cpp index bf960249..80dea459 100644 --- a/src/libcamera/orientation.cpp +++ b/src/libcamera/orientation.cpp @@ -5,10 +5,10 @@ * Image orientation */ -#include - #include +#include + /** * \file orientation.h * \brief Image orientation definition @@ -101,10 +101,14 @@ std::ostream &operator<<(std::ostream &out, const Orientation &orientation) { constexpr std::array orientationNames = { "", /* Orientation starts counting from 1. */ - "Rotate0", "Rotate0Mirror", - "Rotate180", "Rotate180Mirror", - "Rotate90Mirror", "Rotate270", - "Rotate270Mirror", "Rotate90", + "Rotate0", + "Rotate0Mirror", + "Rotate180", + "Rotate180Mirror", + "Rotate90Mirror", + "Rotate270", + "Rotate270Mirror", + "Rotate90", }; out << orientationNames[static_cast(orientation)]; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index a63d3503..981c2e64 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -577,8 +577,9 @@ std::string PipelineHandler::configurationFile(const std::string &subdir, << confPath << "'"; } else { /* Else look in the system locations. */ - confPath = std::string(LIBCAMERA_DATA_DIR) - + "/pipeline/" + subdir + '/' + name; + confPath = + std::string(LIBCAMERA_DATA_DIR) + + "/pipeline/" + subdir + '/' + name; } ret = stat(confPath.c_str(), &statbuf); diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index c0f4d49f..68fad327 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -75,7 +75,7 @@ void ProcessManager::sighandler() return; } - for (auto it = processes_.begin(); it != processes_.end(); ) { + for (auto it = processes_.begin(); it != processes_.end();) { Process *process = *it; int wstatus; @@ -188,7 +188,6 @@ const struct sigaction &ProcessManager::oldsa() const return oldsa_; } - /** * \class Process * \brief Process object @@ -270,8 +269,8 @@ int Process::start(const std::string &path, unsigned int len = args.size(); argv[0] = path.c_str(); for (unsigned int i = 0; i < len; i++) - argv[i+1] = args[i].c_str(); - argv[len+1] = nullptr; + argv[i + 1] = args[i].c_str(); + argv[len + 1] = nullptr; execv(path.c_str(), (char **)argv); diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp index 1382081a..4a990bb9 100644 --- a/src/libcamera/sensor/camera_sensor.cpp +++ b/src/libcamera/sensor/camera_sensor.cpp @@ -6,7 +6,6 @@ */ #include "libcamera/internal/camera_sensor.h" -#include "libcamera/internal/media_device.h" #include #include @@ -14,15 +13,16 @@ #include #include +#include + #include #include #include -#include - #include "libcamera/internal/bayer_format.h" #include "libcamera/internal/camera_lens.h" #include "libcamera/internal/camera_sensor_properties.h" +#include "libcamera/internal/media_device.h" #include "libcamera/internal/sysfs.h" /** diff --git a/src/libcamera/shared_mem_object.cpp b/src/libcamera/shared_mem_object.cpp index 65b53919..d9b61d37 100644 --- a/src/libcamera/shared_mem_object.cpp +++ b/src/libcamera/shared_mem_object.cpp @@ -57,8 +57,8 @@ SharedMem::SharedMem() = default; */ SharedMem::SharedMem(const std::string &name, std::size_t size) { - UniqueFD memfd = MemFd::create(name.c_str(), size, MemFd::Seal::Shrink | - MemFd::Seal::Grow); + UniqueFD memfd = MemFd::create(name.c_str(), size, + MemFd::Seal::Shrink | MemFd::Seal::Grow); if (!memfd.isValid()) return; diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index e70688f6..00b15608 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -5,17 +5,15 @@ * Video stream for a Camera */ -#include - #include #include #include -#include - #include #include +#include +#include /** * \file stream.h