From patchwork Thu Jun 10 07:50:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12543 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 E30D0C3214 for ; Thu, 10 Jun 2021 07:50:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 96C8C6892F; Thu, 10 Jun 2021 09:50:51 +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="nQqrcFxf"; dkim-atps=neutral Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6587F6892F for ; Thu, 10 Jun 2021 09:50:50 +0200 (CEST) Received: by mail-pf1-x42e.google.com with SMTP id c12so924385pfl.3 for ; Thu, 10 Jun 2021 00:50:50 -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=dOwdZ1a4Xmkt8I8dXzLynSQEvGuaDTE1Jt4nfltN2pE=; b=nQqrcFxfoOHPHxbM8u8GSBKmZ5SfYC32sYkITLiztcdepDzVXXk2MNb5gTNCFFeUzd HONn2mAEgzMuMkTXgkxwWWsqWXOSppQsQ9PTdsvcF4ln5anjAEBIxu+/kEaIBhcEGZTg pLDbYXDTUYRD14r773u07aFtmvs8EDSSr+qKI= 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=dOwdZ1a4Xmkt8I8dXzLynSQEvGuaDTE1Jt4nfltN2pE=; b=cmQ7w89/1rHDKa4mAIaPpznIWGdO1UshKFeLVNZ8Am3WQsHPbZnsigey2yQCYZfmmX jDhzVpllAjxyGlNciV+OPom2XNf2Leb1pBLHD07D0uhJV4oOO2XjLYHoGFqTBQ4cowXY BefNP85WHc2SrXi5AMlcuLtzEcroiM2y/4p/JhXPdpxYZgpieOm0vC4LKrxsGziuEaiR m/+7vmX4ehaZwd/Q+RmRLhYvyDS9YYB1wzRQmxjgmxjO+8A6Df4uJ16VqZmL7d+wMAUM ewWEZRZlMqUMnuPy5tCmb9dEI/eK7vRfJSeU6V0VUxeNuNfvSuqOjGE9QW6Ow+TzB3NU aJwg== X-Gm-Message-State: AOAM533mEv9fUR+EHlIVR3ZManKiMz7KqmGo8QV8HP+vhwHZFU47r6Jo wCHbXG3J8Xi3aPe42d6ZMfBpHONraIltlQ== X-Google-Smtp-Source: ABdhPJzBG00XUt7lVVSY46TK3mWroMT/loNmweLQsnFkpFxrubc88ehJcJb/EDD9LL7S7EUA2ZkYcA== X-Received: by 2002:a63:bc19:: with SMTP id q25mr3758086pge.211.1623311448772; Thu, 10 Jun 2021 00:50:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 00:50:48 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 10 Jun 2021 16:50:27 +0900 Message-Id: <20210610075027.523672-11-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog In-Reply-To: <20210610075027.523672-1-hiroh@chromium.org> References: <20210610075027.523672-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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;