From patchwork Fri Jun 19 05:41:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 4086 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 0879D603BF for ; Fri, 19 Jun 2020 07:41:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="s9tUmBdp"; dkim-atps=neutral Received: from jade.flets-east.jp (unknown [IPv6:2400:4051:61:600:e972:d773:e99a:4f79]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E2139556; Fri, 19 Jun 2020 07:41:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1592545308; bh=USR0E8AUhRg8JcikxWau5HbGH0xOr85PKz/bM+2Dn54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s9tUmBdpg0W4AoJjY84p/5PzzsgnzSJMSFMtY/nurkVuzHOgsOFCNs9FsjgxWlp4A 41HvIBk1ABlh9LBEIENEgsMkB97hpE4Y9BQeQggnibFXzKahd/vAf9SRvgJG8vtgUt SRkJeaaIqgxKfYVE2cZmK6nH1otm8Rk7harZUZMU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Fri, 19 Jun 2020 14:41:12 +0900 Message-Id: <20200619054123.19052-7-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619054123.19052-1-paul.elder@ideasonboard.com> References: <20200619054123.19052-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 06/17] 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: Fri, 19 Jun 2020 05:41:49 -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 --- Changes in v2: - use V4L2CameraFile instead of fd - remove arg == nullptr check as it has been moved away to the main ioctl handler --- src/v4l2/v4l2_camera_proxy.cpp | 48 ++++++++++++++++++++++++++++++++++ src/v4l2/v4l2_camera_proxy.h | 3 +++ 2 files changed, 51 insertions(+) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 3e95645..3ac9068 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -376,6 +376,42 @@ int V4L2CameraProxy::vidioc_s_priority(V4L2CameraFile *cf, enum v4l2_priority *a return 0; } +int V4L2CameraProxy::vidioc_enuminput(V4L2CameraFile *cf, struct v4l2_input *arg) +{ + LOG(V4L2Compat, Debug) << "Servicing vidioc_enuminput fd = " << cf->efd(); + + 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(V4L2CameraFile *cf, int *arg) +{ + LOG(V4L2Compat, Debug) << "Servicing vidioc_g_input fd = " << cf->efd(); + + *arg = 0; + + return 0; +} + +int V4L2CameraProxy::vidioc_s_input(V4L2CameraFile *cf, int *arg) +{ + LOG(V4L2Compat, Debug) << "Servicing vidioc_s_input fd = " << cf->efd(); + + if (*arg != 0) + return -EINVAL; + + return 0; +} + int V4L2CameraProxy::freeBuffers() { LOG(V4L2Compat, Debug) << "Freeing libcamera bufs"; @@ -594,6 +630,9 @@ std::set V4L2CameraProxy::supportedIoctls_ = { VIDIOC_TRY_FMT, VIDIOC_G_PRIORITY, VIDIOC_S_PRIORITY, + VIDIOC_ENUMINPUT, + VIDIOC_G_INPUT, + VIDIOC_S_INPUT, VIDIOC_REQBUFS, VIDIOC_QUERYBUF, VIDIOC_QBUF, @@ -637,6 +676,15 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *cf, unsigned long request, void *arg) case VIDIOC_S_PRIORITY: ret = vidioc_s_priority(cf, static_cast(arg)); break; + case VIDIOC_ENUMINPUT: + ret = vidioc_enuminput(cf, static_cast(arg)); + break; + case VIDIOC_G_INPUT: + ret = vidioc_g_input(cf, static_cast(arg)); + break; + case VIDIOC_S_INPUT: + ret = vidioc_s_input(cf, static_cast(arg)); + break; case VIDIOC_REQBUFS: ret = vidioc_reqbufs(cf, static_cast(arg)); break; diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h index 3260eec..46573e7 100644 --- a/src/v4l2/v4l2_camera_proxy.h +++ b/src/v4l2/v4l2_camera_proxy.h @@ -53,6 +53,9 @@ private: int vidioc_try_fmt(V4L2CameraFile *cf, struct v4l2_format *arg); int vidioc_g_priority(V4L2CameraFile *cf, enum v4l2_priority *arg); int vidioc_s_priority(V4L2CameraFile *cf, enum v4l2_priority *arg); + int vidioc_enuminput(V4L2CameraFile *cf, struct v4l2_input *arg); + int vidioc_g_input(V4L2CameraFile *cf, int *arg); + int vidioc_s_input(V4L2CameraFile *cf, int *arg); int vidioc_reqbufs(V4L2CameraFile *cf, struct v4l2_requestbuffers *arg); int vidioc_querybuf(V4L2CameraFile *cf, struct v4l2_buffer *arg); int vidioc_qbuf(V4L2CameraFile *cf, struct v4l2_buffer *arg);