From patchwork Mon Jan 18 16:17:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 32653 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.84) (envelope-from ) id 1aLCVP-0005Il-3C; Mon, 18 Jan 2016 16:18:11 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-8) with esmtp id 1aLCVN-0002t3-jM; Mon, 18 Jan 2016 17:18:10 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755837AbcARQSH (ORCPT + 1 other); Mon, 18 Jan 2016 11:18:07 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:43251 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755832AbcARQSG (ORCPT ); Mon, 18 Jan 2016 11:18:06 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O1500V0KPA4UN20@mailout3.samsung.com> for linux-media@vger.kernel.org; Tue, 19 Jan 2016 01:18:05 +0900 (KST) X-AuditID: cbfee61b-f793c6d00000236c-95-569d103cb8ca Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 77.59.09068.C301D965; Tue, 19 Jan 2016 01:18:04 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O15003TLP9I9Y00@mmp2.samsung.com>; Tue, 19 Jan 2016 01:18:04 +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, hverkuil@xs4all.nl, Jacek Anaszewski Subject: [PATCH 02/15] mediactl: Add support for v4l2-ctrl-redir config Date: Mon, 18 Jan 2016 17:17:27 +0100 Message-id: <1453133860-21571-3-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1453133860-21571-1-git-send-email-j.anaszewski@samsung.com> References: <1453133860-21571-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrALMWRmVeSWpSXmKPExsVy+t9jQV0bgblhBnsbrC2mT5nFaPHm+HQm i1OTnzFZ9F59zmjROXEJu0XPhq2sFp+2fGNyYPd4OmEyu8fsjpmsHvNOBnq833eVzaNvyypG j8+b5DxOff3MHsAexWWTkpqTWZZapG+XwJXxbc5lloLV8hUnbj9hbGA8JdnFyMkhIWAi0Xxr GhOELSZx4d56ti5GLg4hgVmMEtP697NDOD8ZJU4svsIOUsUmYCjx88VrsA4RAXmJJ703wDqY BbYwSty9swisSFjAXeJgx2dWEJtFQFVicvMvsDivgIfEkZOTgBo4gNYpSMyZZAMS5hTwlHhz cz8biC0EVHLg7lbmCYy8CxgZVjFKpBYkFxQnpeca5aWW6xUn5haX5qXrJefnbmIEh9sz6R2M h3e5H2IU4GBU4uF1ODs7TIg1say4MvcQowQHs5II7yGOuWFCvCmJlVWpRfnxRaU5qcWHGKU5 WJTEefddigwTEkhPLEnNTk0tSC2CyTJxcEo1MNp56Rdmmz6Sb52+SvV2BYfHa+5vZmGbDJyN PM6/ZzWf1PzWXoZN+tHS9uJtsXNKl22YXD1h3b1720pYI7fM3HAh6+nZy6tau16uFD/FHMRZ owgM95eLnJOP6yxazpEQwp3Ue8eXqcwmcl7wosMS11IDFxk76/V92vl7mfwhz7dbZDr9/9ds VmIpzkg01GIuKk4EAOvE0U8zAgAA 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: 2016.1.18.160917 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, NO_URI_HTTPS 0, REFERENCES 0, SINGLE_URI_IN_BODY 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, __SINGLE_URI_TEXT 0, __STOCK_PHRASE_7 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_IN_BODY 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 | 30 ++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 3977ce5..069ded6 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) @@ -870,3 +877,43 @@ enum v4l2_field v4l2_subdev_string_to_field(const char *string, return fields[i].field; } + +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 ba9b8c4..f395065 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -23,12 +23,17 @@ #define __SUBDEV_H__ #include +#include struct media_device; struct media_entity; +struct media_device; struct v4l2_subdev { int fd; + + __u32 *v4l2_control_redir; + unsigned int v4l2_control_redir_num; }; /** @@ -316,5 +321,30 @@ const char *v4l2_subdev_field_to_string(enum v4l2_field field); */ enum v4l2_field v4l2_subdev_string_to_field(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