From patchwork Thu Feb 26 15:59:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5894531 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A19489F37F for ; Thu, 26 Feb 2015 16:01:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2F56203AB for ; Thu, 26 Feb 2015 16:01:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D82720274 for ; Thu, 26 Feb 2015 16:01:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754518AbbBZQAK (ORCPT ); Thu, 26 Feb 2015 11:00:10 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:54683 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754359AbbBZQAI (ORCPT ); Thu, 26 Feb 2015 11:00:08 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NKD00E64Z46UDC0@mailout3.samsung.com> for linux-media@vger.kernel.org; Fri, 27 Feb 2015 01:00:06 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-d3-54ef43063862 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 5B.F4.09430.6034FE45; Fri, 27 Feb 2015 01:00:06 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NKD00448Z32VO60@mmp2.samsung.com>; Fri, 27 Feb 2015 01:00:06 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, gjasny@googlemail.com, hdegoede@redhat.com, kyungmin.park@samsung.com, Jacek Anaszewski Subject: [v4l-utils PATCH/RFC v5 02/14] mediactl: Add support for v4l2-ctrl-redir config Date: Thu, 26 Feb 2015 16:59:12 +0100 Message-id: <1424966364-3647-3-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1424966364-3647-1-git-send-email-j.anaszewski@samsung.com> References: <1424966364-3647-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBLMWRmVeSWpSXmKPExsVy+t9jQV025/chBqsmyVhMnzKL0eLN8elM Fr1XnzNanG16w27ROXEJu0XPhq2sFp+2fGNyYPd4OmEyu8fsjpmsHvNOBnq833eVzaNvyypG j8+b5ALYorhsUlJzMstSi/TtErgynm4/zVRwTL7i8NLlTA2MzyW7GDk5JARMJNrPn2SEsMUk Ltxbz9bFyMUhJDCdUeLL/hYWCKedSeJUy1V2kCo2AUOJny9eM4HYIgLyEk96b4B1MAvsZpR4 tnwPK0hCWCBK4v+zOcwgNouAqsSpuVvYQGxeAXeJR+snAw3iAFqnIDFnkg1ImFPAQ2Lql09g VwgBlXx9t5xtAiPvAkaGVYyiqQXJBcVJ6blGesWJucWleel6yfm5mxjB4fVMegfjqgaLQ4wC HIxKPLwzjd6HCLEmlhVX5h5ilOBgVhLh1bcGCvGmJFZWpRblxxeV5qQWH2KU5mBREudVsm8L ERJITyxJzU5NLUgtgskycXBKNTA6flC1rUkPFToo9DZTb+3lQ/+5Hmj02afN4p90vXZXsZ7r DOtTC1q2VUmwt8if+xrDdWSTkMLRk4KzVfx5TH9YdfO/1eb4p2cmlMKxX3rCTcYQO7kVh36G cdc4PXVsSXetePN/T7NZndaR1f+TDfWKT+0z5Czaky8/RyqkXJLP4KLBVN59n5RYijMSDbWY i4oTAaH7UEYrAgAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make struct v4l2_subdev capable of aggregating v4l2-ctrl-redir media device configuration entries. Added are also functions for validating the config and checking whether a v4l2 sub-device expects to receive ioctls related to the v4l2-control with given id. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libv4l2subdev.c | 49 ++++++++++++++++++++++++++++++++++++++- utils/media-ctl/v4l2subdev.h | 33 ++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 68404d4..5b9d908 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -50,7 +49,15 @@ int v4l2_subdev_create(struct media_entity *entity) entity->sd->fd = -1; + entity->sd->v4l2_control_redir = malloc(sizeof(__u32)); + if (entity->sd->v4l2_control_redir == NULL) + goto err_v4l2_control_redir_alloc; + return 0; + +err_v4l2_control_redir_alloc: + free(entity->sd); + return -ENOMEM; } int v4l2_subdev_create_with_fd(struct media_entity *entity, int fd) @@ -803,3 +810,43 @@ enum v4l2_mbus_pixelcode v4l2_subdev_string_to_pixelcode(const char *string, return mbus_formats[i].code; } + +int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media, + struct media_entity *entity, + __u32 ctrl_id) +{ + struct v4l2_queryctrl queryctrl = {}; + int ret; + + ret = v4l2_subdev_open(entity); + if (ret < 0) + return ret; + + queryctrl.id = ctrl_id; + + ret = ioctl(entity->sd->fd, VIDIOC_QUERYCTRL, &queryctrl); + if (ret < 0) + return ret; + + media_dbg(media, "Validated control \"%s\" (0x%8.8x) on entity %s\n", + queryctrl.name, queryctrl.id, entity->info.name); + + return 0; +} + +bool v4l2_subdev_has_v4l2_control_redir(struct media_device *media, + struct media_entity *entity, + int ctrl_id) +{ + struct v4l2_subdev *sd = entity->sd; + int i; + + if (!sd) + return false; + + for (i = 0; i < sd->v4l2_control_redir_num; ++i) + if (sd->v4l2_control_redir[i] == ctrl_id) + return true; + + return false; +} diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index b386294..07f9697 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -23,11 +23,16 @@ #define __SUBDEV_H__ #include +#include struct media_entity; +struct media_device; struct v4l2_subdev { int fd; + + __u32 *v4l2_control_redir; + unsigned int v4l2_control_redir_num; }; /** @@ -293,4 +298,32 @@ const char *v4l2_subdev_pixelcode_to_string(enum v4l2_mbus_pixelcode code); */ enum v4l2_mbus_pixelcode v4l2_subdev_string_to_pixelcode(const char *string, unsigned int length); + +/** + * @brief Validate v4l2 control for a sub-device + * @param media - media device. + * @param entity - subdev-device media entity. + * @param ctrl_id - id of the v4l2 control to validate. + * + * Verify if the entity supports v4l2-control with given ctrl_id. + * + * @return 1 if the control is supported, 0 otherwise. + */ +int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media, + struct media_entity *entity, + __u32 ctrl_id); + +/** + * @brief Check if there was a v4l2_control redirection defined for the entity + * @param media - media device. + * @param entity - subdev-device media entity. + * @param ctrl_id - v4l2 control identifier. + * + * Check if there was a v4l2-ctrl-redir entry defined for the entity. + * + * @return true if the entry exists, false otherwise + */ +bool v4l2_subdev_has_v4l2_control_redir(struct media_device *media, + struct media_entity *entity, int ctrl_id); + #endif