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: 8055961 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 6D2D89F440 for ; Mon, 18 Jan 2016 16:18:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D22D420397 for ; Mon, 18 Jan 2016 16:18:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E9596204AD for ; Mon, 18 Jan 2016 16:18:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755837AbcARQSH (ORCPT ); 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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 | 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