From patchwork Thu Apr 15 08:38:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11946 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 B013CBD224 for ; Thu, 15 Apr 2021 08:39:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 67FD568820; Thu, 15 Apr 2021 10:39:04 +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="UszF879V"; dkim-atps=neutral Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C1046881C for ; Thu, 15 Apr 2021 10:39:03 +0200 (CEST) Received: by mail-pg1-x52d.google.com with SMTP id w10so16430180pgh.5 for ; Thu, 15 Apr 2021 01:39:03 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=DSsxcSmsNI9tDWl/QmgciTOfqlHw1LrlygyIrWs5bYw=; b=UszF879VhFcbEnqHkvQJ34hIscVtI9CHlD0kqhgOmzJoUUMQwUlmuyPDS8HYA1VciJ KCYxTabv5/fYUlg0il08GzYJ+RQIJvxW0iWTrycYpgAAcDHmIRPO5hML1oc5y2hyOhUs k/f89NPo4Ng9DfHK3dwq/7PySNr0ufP6dUeqU= 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=DSsxcSmsNI9tDWl/QmgciTOfqlHw1LrlygyIrWs5bYw=; b=C+zXhR4DLRK8W2whysUJtXVd7iYgo/SzIBzM75rbpZYlmaUxo/Fd4kCuQpKe5t2rzH vcHOFQ6BfZahfMM5bMyNxN/18LQU1rwKztXMJokiSIj4QB4o7e4dgUZtUaogXfCJUrOQ cuwqGkB2UwMRqibSBHJM07iRRQPxUzSqRqOTqegALNUWKxBFmSLM6G0mojdEp6uX1d7C ZHsGUZkyFsj+GwQ5UB9bJZdOLXPOuSC+JY3G+sQVyz86XOUNHBXlghKcpLJSRWly8WQ1 3mkg1ZMzyrz4LfS6y6MM63hvy4Lskiu/TpJUAn9BszPsdSPsSzSMMxJTZAyNio4REWg2 dioA== X-Gm-Message-State: AOAM531j8QXYkLSw/aFNcC3XIYdLXKOqEQSIedXG3O1Kgta8uInvm5I9 GRTeqY79s58wnxIOdvAnjxa2cfF1jXtODA== X-Google-Smtp-Source: ABdhPJwYB8ZCYkI41AySZLE23mkwwfUC5gud5+oOglGczMt33plvLktIeG9I1mjK3eUFup/EdC5H9Q== X-Received: by 2002:a63:dc03:: with SMTP id s3mr2409558pgg.426.1618475941835; Thu, 15 Apr 2021 01:39:01 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:84f5:7981:dfbe:8f02]) by smtp.gmail.com with ESMTPSA id 205sm1520258pfc.201.2021.04.15.01.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 01:39:01 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 15 Apr 2021 17:38:43 +0900 Message-Id: <20210415083843.3399502-10-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210415083843.3399502-1-hiroh@chromium.org> References: <20210415083843.3399502-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 10/10] v4l2: V4L2Camera: Return int in getBufferFd() 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" V4L2Camera::getBufferFd() returns FileDescriptor. However, the file descriptor is still owned by V4L2Camera. It should rather return an integer to represent V4L2Camera doesn't have the ownership of the file descriptor. Signed-off-by: Hirokazu Honda --- src/v4l2/v4l2_camera.cpp | 6 +++--- src/v4l2/v4l2_camera.h | 2 +- src/v4l2/v4l2_camera_proxy.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp index 97825c71..cccc6749 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -186,16 +186,16 @@ void V4L2Camera::freeBuffers() bufferAllocator_->free(stream); } -FileDescriptor V4L2Camera::getBufferFd(unsigned int index) +int V4L2Camera::getBufferFd(unsigned int index) { Stream *stream = config_->at(0).stream(); const std::vector> &buffers = bufferAllocator_->buffers(stream); if (buffers.size() <= index) - return FileDescriptor(); + return -1; - return buffers[index]->planes()[0].fd; + return buffers[index]->planes()[0].fd.fd(); } int V4L2Camera::streamOn() diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h index d2380462..8efe1642 100644 --- a/src/v4l2/v4l2_camera.h +++ b/src/v4l2/v4l2_camera.h @@ -53,7 +53,7 @@ public: int allocBuffers(unsigned int count); void freeBuffers(); - FileDescriptor getBufferFd(unsigned int index); + int getBufferFd(unsigned int index); int streamOn(); int streamOff(); diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index f8bfe595..8f417421 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -112,14 +112,14 @@ void *V4L2CameraProxy::mmap(void *addr, size_t length, int prot, int flags, return MAP_FAILED; } - FileDescriptor fd = vcam_->getBufferFd(index); - if (!fd.isValid()) { + int fd = vcam_->getBufferFd(index); + if (fd < 0) { errno = EINVAL; return MAP_FAILED; } void *map = V4L2CompatManager::instance()->fops().mmap(addr, length, prot, - flags, fd.fd(), 0); + flags, fd, 0); if (map == MAP_FAILED) return map;