From patchwork Fri Aug 30 15:27:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 21114 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 AC570C32D8 for ; Fri, 30 Aug 2024 15:28:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 030FC634EC; Fri, 30 Aug 2024 17:28:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="aUG9jLyE"; 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 7E1876345A for ; Fri, 30 Aug 2024 17:27:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725031668; 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=M9bfMi4VqzY/pQXJHFXwQBnXfGeaU/HCwM+kT8xn3Z0=; b=aUG9jLyE1IJZcef6LLRhZ2UA/OMCmNjMiDRxx5hYKPPuK5WFsbCQBia8RrHui5HDopav3F Gf/YXicuegf0FEsE0QLPFl2rfzdoLZ8UKNuB7qBU66NUhbwujaLxkyjoTU0zXqqnLZSEAs jqieMej8ZD00zytjaRcca/FLZslVWu8= Received: from mx-prod-mc-05.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-468-BnoPLefROkCWudutq6yXwg-1; Fri, 30 Aug 2024 11:27:47 -0400 X-MC-Unique: BnoPLefROkCWudutq6yXwg-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6AE9C1955F65 for ; Fri, 30 Aug 2024 15:27:46 +0000 (UTC) Received: from nuthatch.redhat.com (unknown [10.45.225.65]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 10D501956048; Fri, 30 Aug 2024 15:27:44 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [PATCH v2 11/20] libcamera: v4l2: Formatting improvements Date: Fri, 30 Aug 2024 17:27:08 +0200 Message-ID: <20240830152721.1420313-12-mzamazal@redhat.com> In-Reply-To: <20240830152721.1420313-1-mzamazal@redhat.com> References: <20240830152721.1420313-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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/v4l2_device.cpp | 17 ++++++------ src/libcamera/v4l2_subdevice.cpp | 4 +-- src/libcamera/v4l2_videodevice.cpp | 36 ++++++++++++------------- src/v4l2/v4l2_camera_proxy.cpp | 43 ++++++++++++++---------------- src/v4l2/v4l2_compat.cpp | 19 +++++++------ src/v4l2/v4l2_compat_manager.cpp | 4 +-- 6 files changed, 60 insertions(+), 63 deletions(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 68add4f2..0da1c5ae 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -424,11 +424,12 @@ int V4L2Device::setFrameStartEnabled(bool enable) if (frameStartEnabled_ == enable) return 0; - struct v4l2_event_subscription event{}; + struct v4l2_event_subscription event { + }; event.type = V4L2_EVENT_FRAME_SYNC; unsigned long request = enable ? VIDIOC_SUBSCRIBE_EVENT - : VIDIOC_UNSUBSCRIBE_EVENT; + : VIDIOC_UNSUBSCRIBE_EVENT; int ret = ioctl(request, &event); if (enable && ret) return ret; @@ -744,7 +745,8 @@ void V4L2Device::updateControls(ControlList *ctrls, */ void V4L2Device::eventAvailable() { - struct v4l2_event event{}; + struct v4l2_event event { + }; int ret = ioctl(VIDIOC_DQEVENT, &event); if (ret < 0) { LOG(V4L2, Error) @@ -766,11 +768,10 @@ void V4L2Device::eventAvailable() static const std::map v4l2ToColorSpace = { { V4L2_COLORSPACE_RAW, ColorSpace::Raw }, - { V4L2_COLORSPACE_SRGB, { - ColorSpace::Primaries::Rec709, - ColorSpace::TransferFunction::Srgb, - ColorSpace::YcbcrEncoding::Rec601, - ColorSpace::Range::Limited } }, + { V4L2_COLORSPACE_SRGB, + { ColorSpace::Primaries::Rec709, + ColorSpace::TransferFunction::Srgb, + ColorSpace::YcbcrEncoding::Rec601, ColorSpace::Range::Limited } }, { V4L2_COLORSPACE_JPEG, ColorSpace::Sycc }, { V4L2_COLORSPACE_SMPTE170M, ColorSpace::Smpte170m }, { V4L2_COLORSPACE_REC709, ColorSpace::Rec709 }, diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 6eaa8f01..9f2ec479 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -17,11 +17,11 @@ #include #include -#include - #include #include +#include + #include "libcamera/internal/formats.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/media_object.h" diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 76742e18..1e913c88 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -606,13 +606,13 @@ int V4L2VideoDevice::open() if (caps_.isVideoCapture()) { notifierType = EventNotifier::Read; bufferType_ = caps_.isMultiplanar() - ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE - : V4L2_BUF_TYPE_VIDEO_CAPTURE; + ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE + : V4L2_BUF_TYPE_VIDEO_CAPTURE; } else if (caps_.isVideoOutput()) { notifierType = EventNotifier::Write; bufferType_ = caps_.isMultiplanar() - ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE - : V4L2_BUF_TYPE_VIDEO_OUTPUT; + ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE + : V4L2_BUF_TYPE_VIDEO_OUTPUT; } else if (caps_.isMetaCapture()) { notifierType = EventNotifier::Read; bufferType_ = V4L2_BUF_TYPE_META_CAPTURE; @@ -699,14 +699,14 @@ int V4L2VideoDevice::open(SharedFD handle, enum v4l2_buf_type type) case V4L2_BUF_TYPE_VIDEO_OUTPUT: notifierType = EventNotifier::Write; bufferType_ = caps_.isMultiplanar() - ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE - : V4L2_BUF_TYPE_VIDEO_OUTPUT; + ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE + : V4L2_BUF_TYPE_VIDEO_OUTPUT; break; case V4L2_BUF_TYPE_VIDEO_CAPTURE: notifierType = EventNotifier::Read; bufferType_ = caps_.isMultiplanar() - ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE - : V4L2_BUF_TYPE_VIDEO_CAPTURE; + ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE + : V4L2_BUF_TYPE_VIDEO_CAPTURE; break; default: LOG(V4L2, Error) << "Unsupported buffer type"; @@ -792,7 +792,7 @@ void V4L2VideoDevice::close() std::string V4L2VideoDevice::logPrefix() const { return deviceNode() + "[" + std::to_string(fd()) + - (V4L2_TYPE_IS_OUTPUT(bufferType_) ? ":out]" : ":cap]"); + (V4L2_TYPE_IS_OUTPUT(bufferType_) ? ":out]" : ":cap]"); } /** @@ -1133,7 +1133,7 @@ std::vector V4L2VideoDevice::enumPixelformats(uint32_t code) return {}; } - for (unsigned int index = 0; ; index++) { + for (unsigned int index = 0;; index++) { struct v4l2_fmtdesc pixelformatEnum = {}; pixelformatEnum.index = index; pixelformatEnum.type = bufferType_; @@ -1472,9 +1472,9 @@ std::unique_ptr V4L2VideoDevice::createBuffer(unsigned int index) * account, which is equal to the bytesPerGroup ratio of * the planes. */ - unsigned int stride = format_.planes[0].bpl - * formatInfo_->planes[i].bytesPerGroup - / formatInfo_->planes[0].bytesPerGroup; + unsigned int stride = + format_.planes[0].bpl * formatInfo_->planes[i].bytesPerGroup / + formatInfo_->planes[0].bytesPerGroup; plane.fd = fd; plane.offset = offset; @@ -1827,11 +1827,11 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() FrameMetadata &metadata = buffer->_d()->metadata(); metadata.status = buf.flags & V4L2_BUF_FLAG_ERROR - ? FrameMetadata::FrameError - : FrameMetadata::FrameSuccess; + ? FrameMetadata::FrameError + : FrameMetadata::FrameSuccess; metadata.sequence = buf.sequence; - metadata.timestamp = buf.timestamp.tv_sec * 1000000000ULL - + buf.timestamp.tv_usec * 1000ULL; + metadata.timestamp = + buf.timestamp.tv_sec * 1000000000ULL + buf.timestamp.tv_usec * 1000ULL; if (V4L2_TYPE_IS_OUTPUT(buf.type)) return buffer; @@ -1875,7 +1875,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() * API. */ unsigned int bytesused = multiPlanar ? planes[0].bytesused - : buf.bytesused; + : buf.bytesused; unsigned int remaining = bytesused; for (auto [i, plane] : utils::enumerate(buffer->planes())) { diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index a020a2b0..56c557b5 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -179,17 +179,17 @@ void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig) { const Size &size = streamConfig.size; - v4l2PixFormat_.width = size.width; - v4l2PixFormat_.height = size.height; - v4l2PixFormat_.pixelformat = V4L2PixelFormat::fromPixelFormat(streamConfig.pixelFormat)[0]; - v4l2PixFormat_.field = V4L2_FIELD_NONE; + v4l2PixFormat_.width = size.width; + v4l2PixFormat_.height = size.height; + v4l2PixFormat_.pixelformat = V4L2PixelFormat::fromPixelFormat(streamConfig.pixelFormat)[0]; + v4l2PixFormat_.field = V4L2_FIELD_NONE; v4l2PixFormat_.bytesperline = streamConfig.stride; - v4l2PixFormat_.sizeimage = streamConfig.frameSize; - v4l2PixFormat_.colorspace = V4L2_COLORSPACE_SRGB; - v4l2PixFormat_.priv = V4L2_PIX_FMT_PRIV_MAGIC; - v4l2PixFormat_.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + v4l2PixFormat_.sizeimage = streamConfig.frameSize; + v4l2PixFormat_.colorspace = V4L2_COLORSPACE_SRGB; + v4l2PixFormat_.priv = V4L2_PIX_FMT_PRIV_MAGIC; + v4l2PixFormat_.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; v4l2PixFormat_.quantization = V4L2_QUANTIZATION_DEFAULT; - v4l2PixFormat_.xfer_func = V4L2_XFER_FUNC_DEFAULT; + v4l2PixFormat_.xfer_func = V4L2_XFER_FUNC_DEFAULT; sizeimage_ = streamConfig.frameSize; } @@ -207,11 +207,8 @@ void V4L2CameraProxy::querycap(std::shared_ptr camera) sizeof(capabilities_.bus_info)); /* \todo Put this in a header/config somewhere. */ capabilities_.version = KERNEL_VERSION(5, 2, 0); - capabilities_.device_caps = V4L2_CAP_VIDEO_CAPTURE - | V4L2_CAP_STREAMING - | V4L2_CAP_EXT_PIX_FORMAT; - capabilities_.capabilities = capabilities_.device_caps - | V4L2_CAP_DEVICE_CAPS; + capabilities_.device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_EXT_PIX_FORMAT; + capabilities_.capabilities = capabilities_.device_caps | V4L2_CAP_DEVICE_CAPS; memset(capabilities_.reserved, 0, sizeof(capabilities_.reserved)); } @@ -330,17 +327,17 @@ int V4L2CameraProxy::tryFormat(struct v4l2_format *arg) return -EINVAL; } - arg->fmt.pix.width = config.size.width; - arg->fmt.pix.height = config.size.height; - arg->fmt.pix.pixelformat = V4L2PixelFormat::fromPixelFormat(config.pixelFormat)[0]; - arg->fmt.pix.field = V4L2_FIELD_NONE; + arg->fmt.pix.width = config.size.width; + arg->fmt.pix.height = config.size.height; + arg->fmt.pix.pixelformat = V4L2PixelFormat::fromPixelFormat(config.pixelFormat)[0]; + arg->fmt.pix.field = V4L2_FIELD_NONE; arg->fmt.pix.bytesperline = config.stride; - arg->fmt.pix.sizeimage = config.frameSize; - arg->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; - arg->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; - arg->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + arg->fmt.pix.sizeimage = config.frameSize; + arg->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; + arg->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; + arg->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; arg->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT; - arg->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; + arg->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; return 0; } diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp index ff833f57..a18d6cc9 100644 --- a/src/v4l2/v4l2_compat.cpp +++ b/src/v4l2/v4l2_compat.cpp @@ -5,8 +5,6 @@ * V4L2 compatibility layer */ -#include "v4l2_compat_manager.h" - #include #include #include @@ -18,17 +16,19 @@ #include +#include "v4l2_compat_manager.h" + #define LIBCAMERA_PUBLIC __attribute__((visibility("default"))) using namespace libcamera; -#define extract_va_arg(type, arg, last) \ -{ \ - va_list ap; \ - va_start(ap, last); \ - arg = va_arg(ap, type); \ - va_end(ap); \ -} +#define extract_va_arg(type, arg, last) \ + { \ + va_list ap; \ + va_start(ap, last); \ + arg = va_arg(ap, type); \ + va_end(ap); \ + } namespace { @@ -164,5 +164,4 @@ LIBCAMERA_PUBLIC int ioctl(int fd, unsigned long request, ...) return V4L2CompatManager::instance()->ioctl(fd, request, arg); } - } diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp index f53fb300..54aba540 100644 --- a/src/v4l2/v4l2_compat_manager.cpp +++ b/src/v4l2/v4l2_compat_manager.cpp @@ -171,8 +171,8 @@ int V4L2CompatManager::openat(int dirfd, const char *path, int oflag, mode_t mod fops_.close(fd); int efd = eventfd(0, EFD_SEMAPHORE | - ((oflag & O_CLOEXEC) ? EFD_CLOEXEC : 0) | - ((oflag & O_NONBLOCK) ? EFD_NONBLOCK : 0)); + ((oflag & O_CLOEXEC) ? EFD_CLOEXEC : 0) | + ((oflag & O_NONBLOCK) ? EFD_NONBLOCK : 0)); if (efd < 0) return efd;