From patchwork Mon Jun 17 09:17:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 2732161 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7CBFDC0AB1 for ; Mon, 17 Jun 2013 09:18:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3AF9520276 for ; Mon, 17 Jun 2013 09:18:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EAA6A20277 for ; Mon, 17 Jun 2013 09:18:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755817Ab3FQJSH (ORCPT ); Mon, 17 Jun 2013 05:18:07 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:25943 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751533Ab3FQJSG (ORCPT ); Mon, 17 Jun 2013 05:18:06 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MOJ00CTO5U0OQE0@mailout2.samsung.com> for linux-media@vger.kernel.org; Mon, 17 Jun 2013 18:18:04 +0900 (KST) X-AuditID: cbfee61a-b7f3b6d000006edd-a7-51bed44c7ce9 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 94.69.28381.C44DEB15; Mon, 17 Jun 2013 18:18:04 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MOJ004PE5TPNQ30@mmp1.samsung.com>; Mon, 17 Jun 2013 18:18:04 +0900 (KST) From: Sylwester Nawrocki To: arun.kk@samsung.com Cc: linux-media@vger.kernel.org, Sylwester Nawrocki Subject: [PATCH] V4L: Add support for integer menu controls with standard menu items Date: Mon, 17 Jun 2013 11:17:35 +0200 Message-id: <1371460655-25531-1-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: References: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAJMWRmVeSWpSXmKPExsVy+t9jAV2fK/sCDV5NkbL4eOo2q0XPhq2s FofftLM6MHv0bVnF6PF5k1wAUxSXTUpqTmZZapG+XQJXxoRFP1kLLspXfGh8yt7A+Fmyi5GT Q0LARGLi1kYmCFtM4sK99WxdjFwcQgKLGCUOn+hghHA6mCQeX37KClLFJmAo0Xu0jxHEFhEQ l1jYuxQszizgI/Gv+weYLSwQJvFv1nMwm0VAVeLp14nsIDavgJvE2U0NQDYH0DYFiTmTbEDC nALBEkvPfwcrERIIkPg3/TzrBEbeBYwMqxhFUwuSC4qT0nMN9YoTc4tL89L1kvNzNzGCw+GZ 1A7GlQ0WhxgFOBiVeHg3VO8LFGJNLCuuzD3EKMHBrCTCGzsRKMSbklhZlVqUH19UmpNafIhR moNFSZz3QKt1oJBAemJJanZqakFqEUyWiYNTqoHRRDd3TduMsg+/2WocxHfLyp16+uhXTkhi ueHnZM1dQfvePdyWdXv/5nl1jQ1nOpzf1oYqHP89IWbLtm7TaRevXL1/bds6yxAtF3b+2TJO zn+b3XZOP8kU4iNTlBp04uL++9U2349WmUYx7Pj95fKnZ1lzpx3JZzfh2KKe8HPP/1KRslBN YcFoJZbijERDLeai4kQASp0pwwMCAAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.0 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 Signed-off-by: Sylwester Nawrocki --- Hi Arun, Perhaps you find this patch useful for your VP8 controls works. It's not complete and I didn't test it, except ensuring it compiles. Thanks, Sylwester --- Documentation/video4linux/v4l2-controls.txt | 21 ++++++++++---------- drivers/media/v4l2-core/v4l2-ctrls.c | 28 ++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt index 676f873..fd11d0b 100644 --- a/Documentation/video4linux/v4l2-controls.txt +++ b/Documentation/video4linux/v4l2-controls.txt @@ -124,26 +124,27 @@ You add non-menu controls by calling v4l2_ctrl_new_std: const struct v4l2_ctrl_ops *ops, u32 id, s32 min, s32 max, u32 step, s32 def); -Menu controls are added by calling v4l2_ctrl_new_std_menu: +Menu and integer menu controls are added by calling v4l2_ctrl_new_std_menu: struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops, u32 id, s32 max, s32 skip_mask, s32 def); -Or alternatively for integer menu controls, by calling v4l2_ctrl_new_int_menu: +Menu controls with a driver specific menu are added by calling +v4l2_ctrl_new_std_menu_items: + + struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items( + struct v4l2_ctrl_handler *hdl, + const struct v4l2_ctrl_ops *ops, u32 id, s32 max, + s32 skip_mask, s32 def, const char * const *qmenu); + +Integer menu controls with driver specific menu can be added by calling +v4l2_ctrl_new_int_menu: struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops, u32 id, s32 max, s32 def, const s64 *qmenu_int); -Standard menu controls with a driver specific menu are added by calling -v4l2_ctrl_new_std_menu_items: - - struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items( - struct v4l2_ctrl_handler *hdl, - const struct v4l2_ctrl_ops *ops, u32 id, s32 max, - s32 skip_mask, s32 def, const char * const *qmenu); - These functions are typically called right after the v4l2_ctrl_handler_init: static const s64 exp_bias_qmenu[] = { diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index ebb8e48..c230b96 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -552,6 +552,20 @@ const char * const *v4l2_ctrl_get_menu(u32 id) } EXPORT_SYMBOL(v4l2_ctrl_get_menu); +/* + * Returns NULL or an s64 type array containing the menu for given + * control ID. The total number of the menu items is returned in @len. + */ +const s64 const *v4l2_ctrl_get_int_menu(u32 id, u32 *len) +{ + + switch (id) { + default: + return NULL; + } +} +EXPORT_SYMBOL(v4l2_ctrl_get_int_menu); + /* Return the control name. */ const char *v4l2_ctrl_get_name(u32 id) { @@ -1712,20 +1726,28 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops, u32 id, s32 max, s32 mask, s32 def) { - const char * const *qmenu = v4l2_ctrl_get_menu(id); + const char * const *qmenu = NULL; + const s64 *qmenu_int = NULL; const char *name; enum v4l2_ctrl_type type; + unsigned int qmenu_int_len; s32 min; s32 step; u32 flags; v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags); - if (type != V4L2_CTRL_TYPE_MENU) { + + if (type == V4L2_CTRL_TYPE_MENU) + qmenu = v4l2_ctrl_get_menu(id); + else if (type == V4L2_CTRL_TYPE_INTEGER_MENU) + qmenu_int = v4l2_ctrl_get_int_menu(id, &qmenu_int_len); + + if ((!qmenu && !qmenu_int) || (qmenu_int && max > qmenu_int_len)) { handler_set_err(hdl, -EINVAL); return NULL; } return v4l2_ctrl_new(hdl, ops, id, name, type, - 0, max, mask, def, flags, qmenu, NULL, NULL); + 0, max, mask, def, flags, qmenu, qmenu_int, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std_menu);