From patchwork Thu Mar 30 16:02:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helen Mae Koike Fornazier X-Patchwork-Id: 9654751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8CF3060350 for ; Thu, 30 Mar 2017 16:02:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F21628583 for ; Thu, 30 Mar 2017 16:02:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 735A7285AD; Thu, 30 Mar 2017 16:02:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB52E2859E for ; Thu, 30 Mar 2017 16:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934261AbdC3QCg (ORCPT ); Thu, 30 Mar 2017 12:02:36 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:39523 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934333AbdC3QCe (ORCPT ); Thu, 30 Mar 2017 12:02:34 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id CFCAA2659CC From: Helen Koike To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, jgebben@codeaurora.org, Laurent Pinchart Subject: [PATCH RFC 1/2] [media] v4l2: add V4L2_INPUT_TYPE_DEFAULT Date: Thu, 30 Mar 2017 13:02:17 -0300 Message-Id: <1490889738-30009-1-git-send-email-helen.koike@collabora.com> X-Mailer: git-send-email 2.7.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add V4L2_INPUT_TYPE_DEFAULT and helpers functions for input ioctls to be used when no inputs are available in the device Signed-off-by: Helen Koike --- drivers/media/v4l2-core/v4l2-ioctl.c | 27 +++++++++++++++++++++++++++ include/media/v4l2-ioctl.h | 26 ++++++++++++++++++++++++++ include/uapi/linux/videodev2.h | 1 + 3 files changed, 54 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 0c3f238..ccaf04b 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -2573,6 +2573,33 @@ struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned cmd) return vdev->lock; } +int v4l2_ioctl_enum_input_default(struct file *file, void *priv, + struct v4l2_input *i) +{ + if (i->index > 0) + return -EINVAL; + + memset(i, 0, sizeof(*i)); + i->type = V4L2_INPUT_TYPE_DEFAULT; + strlcpy(i->name, "Default", sizeof(i->name)); + + return 0; +} +EXPORT_SYMBOL(v4l2_ioctl_enum_input_default); + +int v4l2_ioctl_g_input_default(struct file *file, void *priv, unsigned int *i) +{ + *i = 0; + return 0; +} +EXPORT_SYMBOL(v4l2_ioctl_g_input_default); + +int v4l2_ioctl_s_input_default(struct file *file, void *priv, unsigned int i) +{ + return i ? -EINVAL : 0; +} +EXPORT_SYMBOL(v4l2_ioctl_s_input_default); + /* Common ioctl debug function. This function can be used by external ioctl messages as well as internal V4L ioctl */ void v4l_printk_ioctl(const char *prefix, unsigned int cmd) diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index 6cd94e5..accc470 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -652,6 +652,32 @@ struct video_device; */ struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned int cmd); + +/** + * v4l2_ioctl_enum_input_default - v4l2 ioctl helper for VIDIOC_ENUM_INPUT ioctl + * + * Plug this function in vidioc_enum_input field of the struct v4l2_ioctl_ops to + * enumerate a single input as V4L2_INPUT_TYPE_DEFAULT + */ +int v4l2_ioctl_enum_input_default(struct file *file, void *priv, + struct v4l2_input *i); + +/** + * v4l2_ioctl_g_input_default - v4l2 ioctl helper for VIDIOC_G_INPUT ioctl + * + * Plug this function in vidioc_g_input field of the struct v4l2_ioctl_ops + * when using v4l2_ioctl_enum_input_default + */ +int v4l2_ioctl_g_input_default(struct file *file, void *priv, unsigned int *i); + +/** + * v4l2_ioctl_s_input_default - v4l2 ioctl helper for VIDIOC_S_INPUT ioctl + * + * Plug this function in vidioc_s_input field of the struct v4l2_ioctl_ops + * when using v4l2_ioctl_enum_input_default + */ +int v4l2_ioctl_s_input_default(struct file *file, void *priv, unsigned int i); + /* names for fancy debug output */ extern const char *v4l2_field_names[]; extern const char *v4l2_type_names[]; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 316be62..c10bbde 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1477,6 +1477,7 @@ struct v4l2_input { }; /* Values for the 'type' field */ +#define V4L2_INPUT_TYPE_DEFAULT 0 #define V4L2_INPUT_TYPE_TUNER 1 #define V4L2_INPUT_TYPE_CAMERA 2 #define V4L2_INPUT_TYPE_TOUCH 3