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: 28426 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1YR0sh-0005RH-5u; Thu, 26 Feb 2015 17:01:43 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-5) with esmtp id 1YR0se-0001e0-7D; Thu, 26 Feb 2015 17:01:42 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754518AbbBZQAK (ORCPT + 1 other); 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-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.2.26.155119 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_4000_4999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __REFERENCES 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' 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