From patchwork Tue Jun 16 13:12:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 4049 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E2C75603C1 for ; Tue, 16 Jun 2020 15:13:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rPuq2sbi"; dkim-atps=neutral Received: from jade.flets-east.jp (unknown [IPv6:2400:4051:61:600:2807:bdfa:f6a:8e53]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5A332F9; Tue, 16 Jun 2020 15:13:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1592313189; bh=y/vOLRN6xRrkRkkvDb1TKpC5d0iLmLjQLru3wnFYy5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rPuq2sbiCTaMNYTB/cOQH8Sv81i2IGhjsKyA89LZ8+theEXo1G716CVm6CF55imLK UU6HWd5Ol4REt8IbS9GKq3X6Ec3g/M/aCMb3DyR65N308pIHNQsXTMC31VYqFgMfcv oN9w5Tfa0mpwx26ZI8Ocf5ogZnxAXmqeoeOPv5BE= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Jun 2020 22:12:34 +0900 Message-Id: <20200616131244.70308-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616131244.70308-1-paul.elder@ideasonboard.com> References: <20200616131244.70308-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 05/15] v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUMINPUT, VIDIOC_G/S_INPUT 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: , X-List-Received-Date: Tue, 16 Jun 2020 13:13:10 -0000 Implement VIDIOC_ENUMINPUT, VIDIOC_G_INPUT, and VIDIOC_S_INPUT. Only the zeroth input device is supported, and the info returned by enuminput is hardcoded and basic. This is sufficient to pass v4l2-compliance. Signed-off-by: Paul Elder Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/v4l2/v4l2_camera_proxy.cpp | 54 ++++++++++++++++++++++++++++++++++ src/v4l2/v4l2_camera_proxy.h | 3 ++ 2 files changed, 57 insertions(+) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index f268f7a..6c0dacc 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -397,6 +397,51 @@ int V4L2CameraProxy::vidioc_s_priority(int fd, enum v4l2_priority *arg) return 0; } +int V4L2CameraProxy::vidioc_enuminput(int fd, struct v4l2_input *arg) +{ + LOG(V4L2Compat, Debug) << "Servicing vidioc_enuminput fd = " << fd; + + if (arg == nullptr) + return -EFAULT; + + if (arg->index != 0) + return -EINVAL; + + memset(arg, 0, sizeof(*arg)); + + utils::strlcpy(reinterpret_cast(arg->name), + reinterpret_cast(capabilities_.card), + sizeof(arg->name)); + arg->type = V4L2_INPUT_TYPE_CAMERA; + + return 0; +} + +int V4L2CameraProxy::vidioc_g_input(int fd, int *arg) +{ + LOG(V4L2Compat, Debug) << "Servicing vidioc_g_input fd = " << fd; + + if (arg == nullptr) + return -EFAULT; + + *arg = 0; + + return 0; +} + +int V4L2CameraProxy::vidioc_s_input(int fd, int *arg) +{ + LOG(V4L2Compat, Debug) << "Servicing vidioc_s_input fd = " << fd; + + if (arg == nullptr) + return -EFAULT; + + if (*arg != 0) + return -EINVAL; + + return 0; +} + int V4L2CameraProxy::freeBuffers() { LOG(V4L2Compat, Debug) << "Freeing libcamera bufs"; @@ -649,6 +694,15 @@ int V4L2CameraProxy::ioctl(int fd, unsigned long request, void *arg) case VIDIOC_S_PRIORITY: ret = vidioc_s_priority(fd, static_cast(arg)); break; + case VIDIOC_ENUMINPUT: + ret = vidioc_enuminput(fd, static_cast(arg)); + break; + case VIDIOC_G_INPUT: + ret = vidioc_g_input(fd, static_cast(arg)); + break; + case VIDIOC_S_INPUT: + ret = vidioc_s_input(fd, static_cast(arg)); + break; case VIDIOC_REQBUFS: ret = vidioc_reqbufs(fd, static_cast(arg)); break; diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h index a0c373d..2e90bfd 100644 --- a/src/v4l2/v4l2_camera_proxy.h +++ b/src/v4l2/v4l2_camera_proxy.h @@ -51,6 +51,9 @@ private: int vidioc_try_fmt(int fd, struct v4l2_format *arg); int vidioc_g_priority(int fd, enum v4l2_priority *arg); int vidioc_s_priority(int fd, enum v4l2_priority *arg); + int vidioc_enuminput(int fd, struct v4l2_input *arg); + int vidioc_g_input(int fd, int *arg); + int vidioc_s_input(int fd, int *arg); int vidioc_reqbufs(int fd, struct v4l2_requestbuffers *arg); int vidioc_querybuf(int fd, struct v4l2_buffer *arg); int vidioc_qbuf(int fd, struct v4l2_buffer *arg);