From patchwork Thu Jun 10 07:50:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12533 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 93ECEBD78E for ; Thu, 10 Jun 2021 07:50:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 076A368931; Thu, 10 Jun 2021 09:50:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="GEYkRIBw"; dkim-atps=neutral Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 99837602C5 for ; Thu, 10 Jun 2021 09:50:35 +0200 (CEST) Received: by mail-pg1-x534.google.com with SMTP id y11so13785529pgp.11 for ; Thu, 10 Jun 2021 00:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yMF5taR7KEjEMX6xq1ja7QRGY9EdPLS9COVFA1Q84Ys=; b=GEYkRIBwAXP5ReoC9lwZwQqxYOgCSRkljzFbiNcPLc4KGwRxAFGibG9mJBIBgiHLlZ 8pV1gnAp9XGEFg5oAY1YSjMCJuvpX8forJn1eruPvr7Z/NMYXaTx4Pln5E3yi+IpQ5Yv /7kt3hf7ruCBdzvmTMK4llSfhqOFEK7ZencOU= 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:mime-version :content-transfer-encoding; bh=yMF5taR7KEjEMX6xq1ja7QRGY9EdPLS9COVFA1Q84Ys=; b=pZrdEMJiokyu4uj6yvOd0TE3TchY/bXVATfwkCaNENBwmIaya25lLA6f0LrEnzXUHM 1vvdeOJQTUwFG3Ajdp4RRK4hHPpR0Z2Thj7ymmXTnDEQiHOrpHhvq5Gbr/vw89INdURz M7We93EnGwJXy7eQqiVp/VLsHWeAjSph2r+I0XEnrV2bXry46bdEjfCSeCMiQdhMOLpv AAbHWzVr10EtUH2SQMdCbcInnerCryHbPHyxY9PX35vZQDBS4lLWjsp7YY+0sC0EXhxg nhWb33oL3BesvslpuRRHNnHGYps58V7GkUpdbDRiTy6ZsQrHDYnSNpH7DyZoiWlD/wgv ZY5A== X-Gm-Message-State: AOAM530Oqdx92S0CRE7Z0J83ohQY+un0H5lMTsecPB0Fh2gXzc8Kfbrl 7HsptItri0Zgk2x5dDANpeWi2yQWMriPog== X-Google-Smtp-Source: ABdhPJz6IZrOZmeuPHRpCpBtj0FhhiODkGp3L5hGrcEEahASyuTo2ClW9zDpuBBIaMo7IWK9xdNqoA== X-Received: by 2002:a62:1c48:0:b029:2ea:1c13:e229 with SMTP id c69-20020a621c480000b02902ea1c13e229mr1776129pfc.17.1623311433415; Thu, 10 Jun 2021 00:50:33 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:98e0:b356:1c8a:25d4]) by smtp.gmail.com with ESMTPSA id d66sm1565161pfa.32.2021.06.10.00.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 00:50:32 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 10 Jun 2021 16:50:17 +0900 Message-Id: <20210610075027.523672-1-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 00/10] Introduce ScopedFD 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" This series introduces ScopedFD that is a file descriptor wrapper that owns a file descriptor and acts like unique_ptr. It enables to not only reduce close() manually, but also clarify an ownership of a file descriptor. Change in v2 - Address Lauren'ts comments to v1 Hirokazu Honda (10): libcamera: ScopedFD: Introduce ScopedFD libcamera: EventDispatcherPoll: Manage fd by ScopedFD libcamera: File: Manage fd by ScopedFD libcamera: Process: Manage pipe fds by ScopedFD libcamera: MediaDevice: Manage fd by ScopedFD libcamera: V4L2Device: Use ScopedFD for a file descriptor libcamera: V4L2VideoDevice: Use fd for a file descriptor libcamera: IPCUnixSocket: Use ScopedFD for a file descriptor libcamera: pipeline: raspberrypi: DmaHeaps: Use ScopedFD for a file descriptor v4l2: V4L2Camera: Return int in getBufferFd() include/libcamera/file_descriptor.h | 3 + .../internal/event_dispatcher_poll.h | 4 +- include/libcamera/internal/file.h | 5 +- include/libcamera/internal/ipc_unixsocket.h | 5 +- include/libcamera/internal/media_device.h | 3 +- include/libcamera/internal/process.h | 4 +- include/libcamera/internal/v4l2_device.h | 9 +- include/libcamera/internal/v4l2_videodevice.h | 4 +- include/libcamera/meson.build | 1 + include/libcamera/scoped_fd.h | 36 +++++ src/libcamera/event_dispatcher_poll.cpp | 11 +- src/libcamera/file.cpp | 25 ++-- src/libcamera/file_descriptor.cpp | 20 +++ src/libcamera/ipc_pipe_unixsocket.cpp | 8 +- src/libcamera/ipc_unixsocket.cpp | 40 +++--- src/libcamera/media_device.cpp | 39 +++--- src/libcamera/meson.build | 1 + .../pipeline/raspberrypi/dma_heaps.cpp | 23 ++-- .../pipeline/raspberrypi/dma_heaps.h | 10 +- .../pipeline/raspberrypi/raspberrypi.cpp | 7 +- src/libcamera/process.cpp | 16 ++- src/libcamera/scoped_fd.cpp | 129 ++++++++++++++++++ src/libcamera/v4l2_device.cpp | 26 ++-- src/libcamera/v4l2_videodevice.cpp | 48 +++---- src/v4l2/v4l2_camera.cpp | 6 +- src/v4l2/v4l2_camera.h | 2 +- src/v4l2/v4l2_camera_proxy.cpp | 6 +- test/ipc/unixsocket.cpp | 6 +- 28 files changed, 339 insertions(+), 158 deletions(-) create mode 100644 include/libcamera/scoped_fd.h create mode 100644 src/libcamera/scoped_fd.cpp --- 2.32.0.rc1.229.g3e70b5a671-goog