Message ID | 1476282922-11544-2-git-send-email-j.anaszewski@samsung.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Sakari Ailus |
Headers |
Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from <linux-media-owner@vger.kernel.org>) id 1buKnr-0001P1-Hy; Wed, 12 Oct 2016 14:46:43 +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.84_2/mailfrontend-5) with esmtp id 1buKnp-0005MT-6c; Wed, 12 Oct 2016 16:46:43 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933631AbcJLOqi (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Wed, 12 Oct 2016 10:46:38 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:43867 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933677AbcJLOqg (ORCPT <rfc822;linux-media@vger.kernel.org>); Wed, 12 Oct 2016 10:46:36 -0400 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OEX023V7V77YQ70@mailout2.samsung.com> for linux-media@vger.kernel.org; Wed, 12 Oct 2016 23:35:34 +0900 (KST) X-AuditID: cbfee61b-f79b66d000002d5f-41-57fe4a360096 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id B0.92.11615.63A4EF75; Wed, 12 Oct 2016 23:35:34 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OEX00HXUV70WM50@mmp1.samsung.com>; Wed, 12 Oct 2016 23:35:34 +0900 (KST) From: Jacek Anaszewski <j.anaszewski@samsung.com> To: linux-media@vger.kernel.org Cc: sakari.ailus@linux.intel.com, hverkuil@xs4all.nl, mchehab@kernel.org, m.szyprowski@samsung.com, s.nawrocki@samsung.com, Jacek Anaszewski <j.anaszewski@samsung.com> Subject: [PATCH v4l-utils v7 1/7] mediactl: Add support for v4l2-ctrl-binding config Date: Wed, 12 Oct 2016 16:35:16 +0200 Message-id: <1476282922-11544-2-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1476282922-11544-1-git-send-email-j.anaszewski@samsung.com> References: <1476282922-11544-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRmVeSWpSXmKPExsVy+t9jAV0zr3/hBjPfC1qcmvyMyaL36nNG i54NW1kt1h65y26xbNMfJovDb9pZLT5t+cbkwO6xaVUnm8e8k4EefVtWMXp83iTncerrZ/YA 1ig3m4zUxJTUIoXUvOT8lMy8dFul0BA3XQslhbzE3FRbpQhd35AgJYWyxJxSIM/IAA04OAe4 Byvp2yW4Zbxc+JK14LZExfIHN5kbGDeKdDFyckgImEj83nmWDcIWk7hwbz2QzcUhJLCUUaLj +nZ2COcno8SVJX1MIFVsAoYSP1+8BrNFBOQlnvTeAOtmFljNKHFxWQqILSwQJvFl7iQWEJtF QFXicdtvRhCbV8BD4s6dgywQ2+QkTh6bzApicwp4Snz6/BJsjhBQzZl9h1gnMPIuYGRYxSiR WpBcUJyUnmuUl1quV5yYW1yal66XnJ+7iREc0s+kdzAe3uV+iFGAg1GJh9fg099wIdbEsuLK 3EOMEhzMSiK8wW7/woV4UxIrq1KL8uOLSnNSiw8xmgIdNpFZSjQ5HxhveSXxhibmJubGBhbm lpYmRkrivI2zn4ULCaQnlqRmp6YWpBbB9DFxcEo1MGZ3NMU9/Wri/PqBfvtls5tF/ybWzXzL fnfr3Ls39r0SOVnlU2N/V06FO2vB9uWfDVYJGH8Rd8ozqjy6w2Oq/knj++cbwjb/7pRhk+s7 stz6TmvdTf2TJ0WXTbqsqm6nIeT82uyeb0CJTG3tja4HJpZ8biKbpsztvsFTyin/9/2m39r/ tibvMldiKc5INNRiLipOBABrl5xyfwIAAA== X-MTR: 20000000000000000@CPGS Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.10.12.143916 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, IN_REP_TO 0, LEGITIMATE_NEGATE 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, REFERENCES 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __CP_URI_IN_BODY 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 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 , __URI_WITH_PATH 0' |
Commit Message
Jacek Anaszewski
Oct. 12, 2016, 2:35 p.m. UTC
Make struct v4l2_subdev capable of aggregating v4l2-ctrl-bindings - media device configuration entries. Added are also functions for validating support for the control on given media entity and checking whether a v4l2-ctrl-binding has been defined for a media entity. Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> --- utils/media-ctl/libv4l2subdev.c | 32 ++++++++++++++++++++++++++++++++ utils/media-ctl/v4l2subdev.h | 19 +++++++++++++++++++ 2 files changed, 51 insertions(+)
Comments
Hi Jacek, On Wed, Oct 12, 2016 at 04:35:16PM +0200, Jacek Anaszewski wrote: > Make struct v4l2_subdev capable of aggregating v4l2-ctrl-bindings - > media device configuration entries. Added are also functions for > validating support for the control on given media entity and checking > whether a v4l2-ctrl-binding has been defined for a media entity. I still don't think this belongs here. I think I told you about the generic pipeline configuration library I worked on years ago; unfortunately it was left on prototype stage. Still, what I realised was that something very similar is needed in that library --- associating information to the representation of the media entities (or the V4L2 sub-devices) in user space that has got nothing to do with the devices themselves. We could have e.g. a list of key--value pairs where the key is a pointer provided by the user (i.e. application, another library) that could be associated with the value. That would avoid having explicit information on that in the struct media_entity itself. An quicker alternative would be to manage a list of controls e.g. in the plugin itself and store the media entity where they're implemented in that list, with the control value. Cc Laurent as well. > > Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> > Acked-by: Kyungmin Park <kyungmin.park@samsung.com> > --- > utils/media-ctl/libv4l2subdev.c | 32 ++++++++++++++++++++++++++++++++ > utils/media-ctl/v4l2subdev.h | 19 +++++++++++++++++++ > 2 files changed, 51 insertions(+) > > diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c > index c3439d7..4f8ee7f 100644 > --- a/utils/media-ctl/libv4l2subdev.c > +++ b/utils/media-ctl/libv4l2subdev.c > @@ -50,7 +50,15 @@ int v4l2_subdev_create(struct media_entity *entity) > > entity->sd->fd = -1; > > + entity->sd->v4l2_ctrl_bindings = malloc(sizeof(__u32)); > + if (entity->sd->v4l2_ctrl_bindings == NULL) > + goto err_v4l2_ctrl_bindings_alloc; > + > return 0; > + > +err_v4l2_ctrl_bindings_alloc: > + free(entity->sd); > + return -ENOMEM; > } > > int v4l2_subdev_create_opened(struct media_entity *entity, int fd) > @@ -102,6 +110,7 @@ void v4l2_subdev_close(struct media_entity *entity) > if (entity->sd->fd_owner) > close(entity->sd->fd); > > + free(entity->sd->v4l2_ctrl_bindings); > free(entity->sd); > } > > @@ -884,3 +893,26 @@ const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list(unsigned int *length) > > return mbus_codes; > } > + > +int v4l2_subdev_supports_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; > +} > diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h > index 011fab1..4dee6b1 100644 > --- a/utils/media-ctl/v4l2subdev.h > +++ b/utils/media-ctl/v4l2subdev.h > @@ -26,10 +26,14 @@ > > struct media_device; > struct media_entity; > +struct media_device; > > struct v4l2_subdev { > int fd; > unsigned int fd_owner:1; > + > + __u32 *v4l2_ctrl_bindings; > + unsigned int num_v4l2_ctrl_bindings; > }; > > /** > @@ -314,4 +318,19 @@ enum v4l2_field v4l2_subdev_string_to_field(const char *string); > const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list( > unsigned int *length); > > +/** > + * @brief Check if sub-device supports given v4l2 control > + * @param media - media device. > + * @param entity - media entity. > + * @param ctrl_id - id of the v4l2 control to check. > + * > + * Verify if the sub-device associated with given media entity > + * supports v4l2-control with given ctrl_id. > + * > + * @return 1 if the control is supported, 0 otherwise. > + */ > +int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device, > + struct media_entity *entity, > + __u32 ctrl_id); > + > #endif
Hi Sakari, On 11/24/2016 03:23 PM, Sakari Ailus wrote: > Hi Jacek, > > On Wed, Oct 12, 2016 at 04:35:16PM +0200, Jacek Anaszewski wrote: >> Make struct v4l2_subdev capable of aggregating v4l2-ctrl-bindings - >> media device configuration entries. Added are also functions for >> validating support for the control on given media entity and checking >> whether a v4l2-ctrl-binding has been defined for a media entity. > > I still don't think this belongs here. > > I think I told you about the generic pipeline configuration library I worked > on years ago; unfortunately it was left on prototype stage. Still, what I > realised was that something very similar is needed in that library --- > associating information to the representation of the media entities (or the > V4L2 sub-devices) in user space that has got nothing to do with the devices > themselves. > > We could have e.g. a list of key--value pairs where the key is a pointer > provided by the user (i.e. application, another library) that could be > associated with the value. That would avoid having explicit information on > that in the struct media_entity itself. > > An quicker alternative would be to manage a list of controls e.g. in the > plugin itself and store the media entity where they're implemented in that > list, with the control value. We are not interested in media entity -> control value relation but but media entity -> control id. The value is an arbitrary choice of userspace. Binding's task is to route the ctrl ioctl to a desired pipeline entity if more than one supports same control. Effectively we'd need a list of controls as a keys and entities as values. The list should be allocated dynamically as it would make no sense to keep keys for all v4l2 controls if only few bindings are defined. Best regards, Jacek Anaszewski > Cc Laurent as well. > >> >> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> >> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> >> --- >> utils/media-ctl/libv4l2subdev.c | 32 ++++++++++++++++++++++++++++++++ >> utils/media-ctl/v4l2subdev.h | 19 +++++++++++++++++++ >> 2 files changed, 51 insertions(+) >> >> diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c >> index c3439d7..4f8ee7f 100644 >> --- a/utils/media-ctl/libv4l2subdev.c >> +++ b/utils/media-ctl/libv4l2subdev.c >> @@ -50,7 +50,15 @@ int v4l2_subdev_create(struct media_entity *entity) >> >> entity->sd->fd = -1; >> >> + entity->sd->v4l2_ctrl_bindings = malloc(sizeof(__u32)); >> + if (entity->sd->v4l2_ctrl_bindings == NULL) >> + goto err_v4l2_ctrl_bindings_alloc; >> + >> return 0; >> + >> +err_v4l2_ctrl_bindings_alloc: >> + free(entity->sd); >> + return -ENOMEM; >> } >> >> int v4l2_subdev_create_opened(struct media_entity *entity, int fd) >> @@ -102,6 +110,7 @@ void v4l2_subdev_close(struct media_entity *entity) >> if (entity->sd->fd_owner) >> close(entity->sd->fd); >> >> + free(entity->sd->v4l2_ctrl_bindings); >> free(entity->sd); >> } >> >> @@ -884,3 +893,26 @@ const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list(unsigned int *length) >> >> return mbus_codes; >> } >> + >> +int v4l2_subdev_supports_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; >> +} >> diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h >> index 011fab1..4dee6b1 100644 >> --- a/utils/media-ctl/v4l2subdev.h >> +++ b/utils/media-ctl/v4l2subdev.h >> @@ -26,10 +26,14 @@ >> >> struct media_device; >> struct media_entity; >> +struct media_device; >> >> struct v4l2_subdev { >> int fd; >> unsigned int fd_owner:1; >> + >> + __u32 *v4l2_ctrl_bindings; >> + unsigned int num_v4l2_ctrl_bindings; >> }; >> >> /** >> @@ -314,4 +318,19 @@ enum v4l2_field v4l2_subdev_string_to_field(const char *string); >> const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list( >> unsigned int *length); >> >> +/** >> + * @brief Check if sub-device supports given v4l2 control >> + * @param media - media device. >> + * @param entity - media entity. >> + * @param ctrl_id - id of the v4l2 control to check. >> + * >> + * Verify if the sub-device associated with given media entity >> + * supports v4l2-control with given ctrl_id. >> + * >> + * @return 1 if the control is supported, 0 otherwise. >> + */ >> +int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device, >> + struct media_entity *entity, >> + __u32 ctrl_id); >> + >> #endif > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Jacek, On Mon, Nov 28, 2016 at 10:32:43PM +0100, Jacek Anaszewski wrote: > Hi Sakari, > > On 11/24/2016 03:23 PM, Sakari Ailus wrote: > >Hi Jacek, > > > >On Wed, Oct 12, 2016 at 04:35:16PM +0200, Jacek Anaszewski wrote: > >>Make struct v4l2_subdev capable of aggregating v4l2-ctrl-bindings - > >>media device configuration entries. Added are also functions for > >>validating support for the control on given media entity and checking > >>whether a v4l2-ctrl-binding has been defined for a media entity. > > > >I still don't think this belongs here. > > > >I think I told you about the generic pipeline configuration library I worked > >on years ago; unfortunately it was left on prototype stage. Still, what I > >realised was that something very similar is needed in that library --- > >associating information to the representation of the media entities (or the > >V4L2 sub-devices) in user space that has got nothing to do with the devices > >themselves. > > > >We could have e.g. a list of key--value pairs where the key is a pointer > >provided by the user (i.e. application, another library) that could be > >associated with the value. That would avoid having explicit information on > >that in the struct media_entity itself. > > > >An quicker alternative would be to manage a list of controls e.g. in the > >plugin itself and store the media entity where they're implemented in that > >list, with the control value. s/value/id/ > > We are not interested in media entity -> control value relation but > but media entity -> control id. The value is an arbitrary choice of > userspace. Binding's task is to route the ctrl ioctl to a desired > pipeline entity if more than one supports same control. Correct. But even that's more efficient if you don't need to iterate over all the entities. > > Effectively we'd need a list of controls as a keys and entities > as values. The list should be allocated dynamically as it would > make no sense to keep keys for all v4l2 controls if only few bindings > are defined. > > Best regards, > Jacek Anaszewski > > >Cc Laurent as well. > > > >> > >>Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> > >>Acked-by: Kyungmin Park <kyungmin.park@samsung.com> > >>--- > >> utils/media-ctl/libv4l2subdev.c | 32 ++++++++++++++++++++++++++++++++ > >> utils/media-ctl/v4l2subdev.h | 19 +++++++++++++++++++ > >> 2 files changed, 51 insertions(+) > >> > >>diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c > >>index c3439d7..4f8ee7f 100644 > >>--- a/utils/media-ctl/libv4l2subdev.c > >>+++ b/utils/media-ctl/libv4l2subdev.c > >>@@ -50,7 +50,15 @@ int v4l2_subdev_create(struct media_entity *entity) > >> > >> entity->sd->fd = -1; > >> > >>+ entity->sd->v4l2_ctrl_bindings = malloc(sizeof(__u32)); > >>+ if (entity->sd->v4l2_ctrl_bindings == NULL) > >>+ goto err_v4l2_ctrl_bindings_alloc; > >>+ > >> return 0; > >>+ > >>+err_v4l2_ctrl_bindings_alloc: > >>+ free(entity->sd); > >>+ return -ENOMEM; > >> } > >> > >> int v4l2_subdev_create_opened(struct media_entity *entity, int fd) > >>@@ -102,6 +110,7 @@ void v4l2_subdev_close(struct media_entity *entity) > >> if (entity->sd->fd_owner) > >> close(entity->sd->fd); > >> > >>+ free(entity->sd->v4l2_ctrl_bindings); > >> free(entity->sd); > >> } > >> > >>@@ -884,3 +893,26 @@ const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list(unsigned int *length) > >> > >> return mbus_codes; > >> } > >>+ > >>+int v4l2_subdev_supports_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; > >>+} > >>diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h > >>index 011fab1..4dee6b1 100644 > >>--- a/utils/media-ctl/v4l2subdev.h > >>+++ b/utils/media-ctl/v4l2subdev.h > >>@@ -26,10 +26,14 @@ > >> > >> struct media_device; > >> struct media_entity; > >>+struct media_device; > >> > >> struct v4l2_subdev { > >> int fd; > >> unsigned int fd_owner:1; > >>+ > >>+ __u32 *v4l2_ctrl_bindings; > >>+ unsigned int num_v4l2_ctrl_bindings; > >> }; > >> > >> /** > >>@@ -314,4 +318,19 @@ enum v4l2_field v4l2_subdev_string_to_field(const char *string); > >> const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list( > >> unsigned int *length); > >> > >>+/** > >>+ * @brief Check if sub-device supports given v4l2 control > >>+ * @param media - media device. > >>+ * @param entity - media entity. > >>+ * @param ctrl_id - id of the v4l2 control to check. > >>+ * > >>+ * Verify if the sub-device associated with given media entity > >>+ * supports v4l2-control with given ctrl_id. > >>+ * > >>+ * @return 1 if the control is supported, 0 otherwise. > >>+ */ > >>+int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device, > >>+ struct media_entity *entity, > >>+ __u32 ctrl_id); > >>+ > >> #endif > >
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index c3439d7..4f8ee7f 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -50,7 +50,15 @@ int v4l2_subdev_create(struct media_entity *entity) entity->sd->fd = -1; + entity->sd->v4l2_ctrl_bindings = malloc(sizeof(__u32)); + if (entity->sd->v4l2_ctrl_bindings == NULL) + goto err_v4l2_ctrl_bindings_alloc; + return 0; + +err_v4l2_ctrl_bindings_alloc: + free(entity->sd); + return -ENOMEM; } int v4l2_subdev_create_opened(struct media_entity *entity, int fd) @@ -102,6 +110,7 @@ void v4l2_subdev_close(struct media_entity *entity) if (entity->sd->fd_owner) close(entity->sd->fd); + free(entity->sd->v4l2_ctrl_bindings); free(entity->sd); } @@ -884,3 +893,26 @@ const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list(unsigned int *length) return mbus_codes; } + +int v4l2_subdev_supports_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; +} diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index 011fab1..4dee6b1 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -26,10 +26,14 @@ struct media_device; struct media_entity; +struct media_device; struct v4l2_subdev { int fd; unsigned int fd_owner:1; + + __u32 *v4l2_ctrl_bindings; + unsigned int num_v4l2_ctrl_bindings; }; /** @@ -314,4 +318,19 @@ enum v4l2_field v4l2_subdev_string_to_field(const char *string); const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list( unsigned int *length); +/** + * @brief Check if sub-device supports given v4l2 control + * @param media - media device. + * @param entity - media entity. + * @param ctrl_id - id of the v4l2 control to check. + * + * Verify if the sub-device associated with given media entity + * supports v4l2-control with given ctrl_id. + * + * @return 1 if the control is supported, 0 otherwise. + */ +int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device, + struct media_entity *entity, + __u32 ctrl_id); + #endif