From patchwork Mon Oct 7 15:06:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 11177679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7AC16112B for ; Mon, 7 Oct 2019 15:07:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5041C21655 for ; Mon, 7 Oct 2019 15:07:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570460836; bh=E9NmJKhv42+mB1ZMBt8iKwzh9l6hyWMUl5rZ2Ywgwl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wUgJVgnQ8lsDXo+PbcIBOyFPKQlbR4+H3rN5ZKo0vOTB/zWjKyrmSXIw3Mfl0cWbe zxrjtku1L8qWz43Kvj2mu1XIPMkuEyA8Ro3jdqpulVyF8/7idr+zGesxREWJo1SLXK zusTZTgUwVp6oeOdF2AN/0Y+3kD4GXjGeXQUcEJU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728189AbfJGPGo (ORCPT ); Mon, 7 Oct 2019 11:06:44 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:44729 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbfJGPGn (ORCPT ); Mon, 7 Oct 2019 11:06:43 -0400 Received: by mail-lj1-f196.google.com with SMTP id m13so14018534ljj.11; Mon, 07 Oct 2019 08:06:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xHNPcA4Js+ERaMLNDY6RAwwdozVmuU2ADKCjFEFxwwM=; b=XeVQPdl4PXTIk8/DiZNrx9rpsLWWdeCcm+CpQy6BjKy4vhjn5bxTnED8U+9gMBmBfV OAKxKWEd6uPM9ynWKvU2xNrF5Qa9r3yegriXelb2svbJJIjbCbrz70zMvf4Q91kj0dYy umpw0Zhew+rXMEoPGILfPX7ySzzupnJvimQmgolfdbbT0W906oxRJenTodr232kf6QTR W0+bN9kgnhFzuNtcsK5XS6qCTfyUyOn70soBYUSlK5kZxpgMeXJCaMcnhMWp42FudiyM HaZ/N/wD6tlM8Oc0V98FZTNzfXFGR66Qg1MXb3w96LD/zUVf6Iis1rWIfgOaZeHNn1LH NiTA== X-Gm-Message-State: APjAAAXgPuMopSVEItXZRRPsblDsUxgE0sjqeU9g7Hg3ce4ORtuJtF4R SpphxUpaewH7ZqLa++hy30c= X-Google-Smtp-Source: APXvYqw7OFp6EeY875YNbDZPWRb0A0wYcpaLpm3U7ySVZRxw/RdTpVf9oz5e/34VQJSrTfsOmYk7fA== X-Received: by 2002:a2e:9014:: with SMTP id h20mr18657179ljg.154.1570460801163; Mon, 07 Oct 2019 08:06:41 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id n2sm3145517ljj.30.2019.10.07.08.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:06:39 -0700 (PDT) From: Ricardo Ribalda Delgado To: Philipp Zabel , Hans Verkuil , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado , Hans Verkuil , Ricardo Ribalda Delgado Subject: [PATCH v12 1/8] media: v4l2-core: Implement v4l2_ctrl_new_std_compound Date: Mon, 7 Oct 2019 17:06:29 +0200 Message-Id: <20191007150636.16458-2-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007150636.16458-1-ribalda@kernel.org> References: <20191007150636.16458-1-ribalda@kernel.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Ricardo Ribalda Delgado Currently compound controls do not have a simple way of initializing its values. This results in ofuscated code with type_ops init. This patch introduces a new field on the control with the default value for the compound control that can be set with the brand new v4l2_ctrl_new_std_compound function Suggested-by: Hans Verkuil Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/v4l2-core/v4l2-ctrls.c | 50 ++++++++++++++++++++++++---- include/media/v4l2-ctrls.h | 21 ++++++++++++ 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 1d8f38824631..219d8aeefa20 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -29,6 +29,8 @@ #define call_op(master, op) \ (has_op(master, op) ? master->ops->op(master) : 0) +static const union v4l2_ctrl_ptr ptr_null; + /* Internal temporary helper struct, one for each v4l2_ext_control */ struct v4l2_ctrl_helper { /* Pointer to the control reference of the master control */ @@ -1530,7 +1532,10 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; void *p = ptr.p + idx * ctrl->elem_size; - memset(p, 0, ctrl->elem_size); + if (ctrl->p_def.p) + memcpy(p, ctrl->p_def.p, ctrl->elem_size); + else + memset(p, 0, ctrl->elem_size); /* * The cast is needed to get rid of a gcc warning complaining that @@ -2354,7 +2359,8 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, s64 min, s64 max, u64 step, s64 def, const u32 dims[V4L2_CTRL_MAX_DIMS], u32 elem_size, u32 flags, const char * const *qmenu, - const s64 *qmenu_int, void *priv) + const s64 *qmenu_int, const union v4l2_ctrl_ptr p_def, + void *priv) { struct v4l2_ctrl *ctrl; unsigned sz_extra; @@ -2460,6 +2466,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, is_array) sz_extra += 2 * tot_ctrl_size; + if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p) + sz_extra += elem_size; + ctrl = kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); if (ctrl == NULL) { handler_set_err(hdl, -ENOMEM); @@ -2503,6 +2512,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, ctrl->p_new.p = &ctrl->val; ctrl->p_cur.p = &ctrl->cur.val; } + + if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p) { + ctrl->p_def.p = ctrl->p_cur.p + tot_ctrl_size; + memcpy(ctrl->p_def.p, p_def.p, elem_size); + } + for (idx = 0; idx < elems; idx++) { ctrl->type_ops->init(ctrl, idx, ctrl->p_cur); ctrl->type_ops->init(ctrl, idx, ctrl->p_new); @@ -2554,7 +2569,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, type, min, max, is_menu ? cfg->menu_skip_mask : step, def, cfg->dims, cfg->elem_size, - flags, qmenu, qmenu_int, priv); + flags, qmenu, qmenu_int, ptr_null, priv); if (ctrl) ctrl->is_private = cfg->is_private; return ctrl; @@ -2579,7 +2594,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, min, max, step, def, NULL, 0, - flags, NULL, NULL, NULL); + flags, NULL, NULL, ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std); @@ -2612,7 +2627,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, mask, def, NULL, 0, - flags, qmenu, qmenu_int, NULL); + flags, qmenu, qmenu_int, ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std_menu); @@ -2644,11 +2659,32 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, mask, def, NULL, 0, - flags, qmenu, NULL, NULL); + flags, qmenu, NULL, ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); +/* Helper function for standard compound controls */ +struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, + const struct v4l2_ctrl_ops *ops, u32 id, + const union v4l2_ctrl_ptr p_def) +{ + const char *name; + enum v4l2_ctrl_type type; + u32 flags; + s64 min, max, step, def; + + v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags); + if (type < V4L2_CTRL_COMPOUND_TYPES) { + handler_set_err(hdl, -EINVAL); + return NULL; + } + return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, + min, max, step, def, NULL, 0, + flags, NULL, NULL, p_def, NULL); +} +EXPORT_SYMBOL(v4l2_ctrl_new_std_compound); + /* Helper function for standard integer menu controls */ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops, @@ -2669,7 +2705,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, 0, def, NULL, 0, - flags, NULL, qmenu_int, NULL); + flags, NULL, qmenu_int, ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_int_menu); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 570ff4b0205a..90a8ee48c2f3 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -200,6 +200,9 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); * not freed when the control is deleted. Should this be needed * then a new internal bitfield can be added to tell the framework * to free this pointer. + * @p_def: The control's default value represented via a union which + * provides a standard way of accessing control types + * through a pointer (for compound controls only). * @p_cur: The control's current value represented via a union which * provides a standard way of accessing control types * through a pointer. @@ -254,6 +257,7 @@ struct v4l2_ctrl { s32 val; } cur; + union v4l2_ctrl_ptr p_def; union v4l2_ctrl_ptr p_new; union v4l2_ctrl_ptr p_cur; }; @@ -646,6 +650,23 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, u64 mask, u8 def, const char * const *qmenu); +/** + * v4l2_ctrl_new_std_compound() - Allocate and initialize a new standard V4L2 + * compound control. + * + * @hdl: The control handler. + * @ops: The control ops. + * @id: The control ID. + * @p_def: The control's default value. + * + * Sames as v4l2_ctrl_new_std(), but with support to compound controls, thanks + * to the @p_def field. + * + */ +struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, + const struct v4l2_ctrl_ops *ops, u32 id, + const union v4l2_ctrl_ptr p_def); + /** * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control. * From patchwork Mon Oct 7 15:06:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 11177675 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D03EC13BD for ; Mon, 7 Oct 2019 15:07:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AFC1121479 for ; Mon, 7 Oct 2019 15:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570460833; bh=WMCQd2GDPxepzdcS7GcjwsjWqqxgbpSwzeQjk3Onw74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aIIJQ3RXNdTHwWfqlw22vH50MuuDKQdaaJEcf3jiBQheWFDcI5XeALYT6f7TfY4io x3EZSo3BkddRL/nKZq3zSvsadNyb+yvrtGMl1c8Zk2L2Zd7LpzgfmHbNkAEeY7aV0m 8NG4Y/gcjKyPOZSxrzYOx56pAzmigIOQe76r+T0s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728462AbfJGPGr (ORCPT ); Mon, 7 Oct 2019 11:06:47 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33931 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbfJGPGq (ORCPT ); Mon, 7 Oct 2019 11:06:46 -0400 Received: by mail-lj1-f195.google.com with SMTP id j19so14066686lja.1; Mon, 07 Oct 2019 08:06:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m6p9TCl1q4PmCyDnNVWS8vM5CeKoKD3/SoQWgI0Yo4g=; b=Jvb3r9przn80NoTG9vxZv4zyHFUhcovsRIVQS3FmkXc89WcP+PW8+fqwB1vhb3lEjx GyhAMrlcpdPfkWpicbub1yWTL9VY61Ce+xDhwkoDQ1i2eGFDmnxeiYyuPtg4xjd8BzZU uSnPa8tbGnC4GyAjOGUZBTAFNHJabaq9jzWX4xU+dZ5WDvJeW3OcJGTWtPrET+b7K19J RI479C8Pyb+8Y/l36reAZ6pnxAFPNOs0w96DCYyWuvpEI66KUFvoBjrMz9nXb11qFEwY 0aFVNSaFOyuiXwwZ013VNn4QR45H/LbY09jW7Lmb74XVgLstZ4RzkRsSn/Uj7OzuCH+f aqsw== X-Gm-Message-State: APjAAAXalZTny+pAZipGOg+g7ibL9ZxRNRoE+fox/trjBiR3m24IazoF CdgmkD32MhD8zWhwqLwdxjxSTwQtZkf/tw== X-Google-Smtp-Source: APXvYqzQ62/7eOw3kCCHPcQR4PUxvoHH6rTrHMPNU7g2TKMmU2i6hbmiKbEaCpklhgYl4Nli2V42PA== X-Received: by 2002:a2e:88cd:: with SMTP id a13mr16353954ljk.102.1570460802827; Mon, 07 Oct 2019 08:06:42 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id n2sm3145517ljj.30.2019.10.07.08.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:06:41 -0700 (PDT) From: Ricardo Ribalda Delgado To: Philipp Zabel , Hans Verkuil , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado , Hans Verkuil , Ricardo Ribalda Delgado Subject: [PATCH v12 2/8] Documentation: v4l2_ctrl_new_std_compound Date: Mon, 7 Oct 2019 17:06:30 +0200 Message-Id: <20191007150636.16458-3-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007150636.16458-1-ribalda@kernel.org> References: <20191007150636.16458-1-ribalda@kernel.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Ricardo Ribalda Delgado Function for initializing compound controls with a default value. Suggested-by: Hans Verkuil Reviewed-by: Jacopo Mondi Signed-off-by: Ricardo Ribalda Delgado --- Documentation/media/kapi/v4l2-controls.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/media/kapi/v4l2-controls.rst b/Documentation/media/kapi/v4l2-controls.rst index ebe2a55908be..b20800cae3f2 100644 --- a/Documentation/media/kapi/v4l2-controls.rst +++ b/Documentation/media/kapi/v4l2-controls.rst @@ -140,6 +140,15 @@ Menu controls with a driver specific menu are added by calling const struct v4l2_ctrl_ops *ops, u32 id, s32 max, s32 skip_mask, s32 def, const char * const *qmenu); +Standard compound controls can be added by calling +:c:func:`v4l2_ctrl_new_std_compound`: + +.. code-block:: c + + struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, + const struct v4l2_ctrl_ops *ops, u32 id, + const union v4l2_ctrl_ptr p_def); + Integer menu controls with a driver specific menu can be added by calling :c:func:`v4l2_ctrl_new_int_menu`: From patchwork Mon Oct 7 15:06:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 11177677 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3680413BD for ; Mon, 7 Oct 2019 15:07:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C3EA21924 for ; Mon, 7 Oct 2019 15:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570460835; bh=4OVks1qICsaLCu5WjeOllnyV2fHWA9nPOZC4RiFcHdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2VbBsZEHryMDYtP2FnMe8ekF1ArSpmaakTPyQoi1KoBHxztSgtxv9opBeo9nsZ1Uq tlmUKSCwOOTCAb1AP1ugTWTwNrd1Iwn9KiCcvK3kTpgwVGMsar8dF2veb5+D4SZeHY hx/aHlET7TF4/48uE+gxEG8jnYgOAHx9lhPY3lqw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728444AbfJGPGr (ORCPT ); Mon, 7 Oct 2019 11:06:47 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:42834 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728408AbfJGPGq (ORCPT ); Mon, 7 Oct 2019 11:06:46 -0400 Received: by mail-lj1-f193.google.com with SMTP id y23so14031978lje.9; Mon, 07 Oct 2019 08:06:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ML/wsP7A5QplLapYjf/StovSlxFIsIaJ+3SqwgITJm0=; b=j+uASFkmZDTiRKJEmYb8URv87Ze7AMMeYYdVjS2xpn8GjDyP25IZgruUS3TRV0FZlw GI2tkF5u+suVb7xM/hZuUZqww55YOdlVcfwWkpXqX9EPE+l+H1/wTQLVrXfxQYO6olxc YgsIPbPbE3LoZoALbI0neLuj6zXiBz9U3xpdJWmHH9gMVF3HoDLe5f7f5zrH699RZxih mxYd+ZQx7P2cr/WNq49aLkggN77jvF9Ztzcqof5E/p5S2OBkBgGxm5jtDBhjvRe238F6 0lGEWd4btq831OO8Y/Jp5vLcqNDhQHNysLboMM8yiwKEOXb8w9jApZv1Po6sthBddATR HxVg== X-Gm-Message-State: APjAAAUuNdW9mHok3obMuDN/lEy/AGFsStlRBtSFYKFCACdjijmE3HzY Ow5gpvwiOO0OzE7Qd4WT4/8YAFaMN0Ss8A== X-Google-Smtp-Source: APXvYqzeevIs3KPGUIftK1VkMEqoikZcB0FgrSU1wqS3ACsmUDOUwecEroCIamZwi4VP9PiydlqY3g== X-Received: by 2002:a2e:91c7:: with SMTP id u7mr18738640ljg.146.1570460804391; Mon, 07 Oct 2019 08:06:44 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id n2sm3145517ljj.30.2019.10.07.08.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:06:43 -0700 (PDT) From: Ricardo Ribalda Delgado To: Philipp Zabel , Hans Verkuil , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado , Ricardo Ribalda Delgado Subject: [PATCH v12 3/8] media: add V4L2_CTRL_TYPE_AREA control type Date: Mon, 7 Oct 2019 17:06:31 +0200 Message-Id: <20191007150636.16458-4-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007150636.16458-1-ribalda@kernel.org> References: <20191007150636.16458-1-ribalda@kernel.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Ricardo Ribalda Delgado This type contains the width and the height of a rectangular area. Reviewed-by: Jacopo Mondi Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/v4l2-core/v4l2-ctrls.c | 21 ++++++++++++++ include/media/v4l2-ctrls.h | 42 ++++++++++++++++++++++++++++ include/uapi/linux/videodev2.h | 6 ++++ 3 files changed, 69 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 219d8aeefa20..96cab2e173d3 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1677,6 +1677,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, { struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; + struct v4l2_area *area; void *p = ptr.p + idx * ctrl->elem_size; switch ((u32)ctrl->type) { @@ -1753,6 +1754,11 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, zero_padding(p_vp8_frame_header->entropy_header); zero_padding(p_vp8_frame_header->coder_state); break; + case V4L2_CTRL_TYPE_AREA: + area = p; + if (!area->width || !area->height) + return -EINVAL; + break; default: return -EINVAL; } @@ -2427,6 +2433,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_VP8_FRAME_HEADER: elem_size = sizeof(struct v4l2_ctrl_vp8_frame_header); break; + case V4L2_CTRL_TYPE_AREA: + elem_size = sizeof(struct v4l2_area); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size = sizeof(s32); @@ -4116,6 +4125,18 @@ int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) } EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_string); +int __v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl, + const struct v4l2_area *area) +{ + lockdep_assert_held(ctrl->handler->lock); + + /* It's a driver bug if this happens. */ + WARN_ON(ctrl->type != V4L2_CTRL_TYPE_AREA); + *ctrl->p_new.p_area = *area; + return set_ctrl(NULL, ctrl, 0); +} +EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_area); + void v4l2_ctrl_request_complete(struct media_request *req, struct v4l2_ctrl_handler *main_hdl) { diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 90a8ee48c2f3..5331cf6c8517 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -50,6 +50,7 @@ struct poll_table_struct; * @p_h264_slice_params: Pointer to a struct v4l2_ctrl_h264_slice_params. * @p_h264_decode_params: Pointer to a struct v4l2_ctrl_h264_decode_params. * @p_vp8_frame_header: Pointer to a VP8 frame header structure. + * @p_area: Pointer to an area. * @p: Pointer to a compound value. */ union v4l2_ctrl_ptr { @@ -68,6 +69,7 @@ union v4l2_ctrl_ptr { struct v4l2_ctrl_h264_slice_params *p_h264_slice_params; struct v4l2_ctrl_h264_decode_params *p_h264_decode_params; struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; + struct v4l2_area *p_area; void *p; }; @@ -1086,6 +1088,46 @@ static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) return rval; } +/** + * __v4l2_ctrl_s_ctrl_area() - Unlocked variant of v4l2_ctrl_s_ctrl_area(). + * + * @ctrl: The control. + * @area: The new area. + * + * This sets the control's new area safely by going through the control + * framework. This function assumes the control's handler is already locked, + * allowing it to be used from within the &v4l2_ctrl_ops functions. + * + * This function is for area type controls only. + */ +int __v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl, + const struct v4l2_area *area); + +/** + * v4l2_ctrl_s_ctrl_area() - Helper function to set a control's area value + * from within a driver. + * + * @ctrl: The control. + * @area: The new area. + * + * This sets the control's new area safely by going through the control + * framework. This function will lock the control's handler, so it cannot be + * used from within the &v4l2_ctrl_ops functions. + * + * This function is for area type controls only. + */ +static inline int v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl, + const struct v4l2_area *area) +{ + int rval; + + v4l2_ctrl_lock(ctrl); + rval = __v4l2_ctrl_s_ctrl_area(ctrl, area); + v4l2_ctrl_unlock(ctrl); + + return rval; +} + /* Internal helper functions that deal with control events. */ extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 530638dffd93..b3c0961b62a0 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -422,6 +422,11 @@ struct v4l2_fract { __u32 denominator; }; +struct v4l2_area { + __u32 width; + __u32 height; +}; + /** * struct v4l2_capability - Describes V4L2 device caps returned by VIDIOC_QUERYCAP * @@ -1720,6 +1725,7 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_U8 = 0x0100, V4L2_CTRL_TYPE_U16 = 0x0101, V4L2_CTRL_TYPE_U32 = 0x0102, + V4L2_CTRL_TYPE_AREA = 0x0106, }; /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ From patchwork Mon Oct 7 15:06:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 11177673 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D30B112B for ; Mon, 7 Oct 2019 15:07:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7BCBA21BE5 for ; Mon, 7 Oct 2019 15:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570460832; bh=CuQE8xZV2J0srgp8LnnZ0RWs8PiNVms2wpi9b7Xh1mE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EaBg0DbS6XPuiCUCqQ9mVzIc3pyD4KGOP7DCYWC4wvoltV93j5bCSupENZBgOpJJ3 rJoOvfEsmKbLfmafoMcm/L6dxo28e9ubDgY7Tacem5aEwzLCVIcRDf+kZqs9m2mARG +ftx89urZiSZJEhKRLoVSzBfVYQY5AWLq23R8JS4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728359AbfJGPHI (ORCPT ); Mon, 7 Oct 2019 11:07:08 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:37211 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728417AbfJGPGs (ORCPT ); Mon, 7 Oct 2019 11:06:48 -0400 Received: by mail-lj1-f193.google.com with SMTP id l21so14066674lje.4; Mon, 07 Oct 2019 08:06:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E9NkjYUFveZggVHspgGbGz7WkNJuc9jbm/jcHnFp4sA=; b=FeWKGqa+4LroVvwErh+/kzWj73kWaqOpRa/ao9Mz/np5LgzS7xuycrDc+RzogSNgZC gKV/2ZZAq5jz5LjuROEUtW/N/WRGubZ65th23OoCyQn5cSgebao41QxQ1CoQHjTfMT2C pgtXFSfTrdrUiCF6BiCpHWcwewzZGOjj+dL8tcMvnvInCEdbk+oTlH5/s0tKKV7bvx4b ocAmwfoCHyiPIFfdxDGcnzovQloKnW+N4uOAH1OmiVR4VDEO6eR005KwiPbDJ4yEJFQ/ ZLGvqKfa0sIjOzvJqmEvv6+B6+U+esVIQuQ6VRCN4g0CNfLQNsHKeBI1uMS8BUAYMEEv EUvA== X-Gm-Message-State: APjAAAWC0x5JWk1+Qc/0fO81puoSazZe8wbC5ipk4z/r6x5uH/vvRpou ZgX5IvconIX8YPCtDXSa2aA= X-Google-Smtp-Source: APXvYqz7fHa19siM3LdVAaGAJWVvjm0LdRVSdomXrfIjxqDIzeJthpsOcBnqOx2z8YpI2+/iY302Bw== X-Received: by 2002:a2e:3610:: with SMTP id d16mr16365371lja.254.1570460806236; Mon, 07 Oct 2019 08:06:46 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id n2sm3145517ljj.30.2019.10.07.08.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:06:44 -0700 (PDT) From: Ricardo Ribalda Delgado To: Philipp Zabel , Hans Verkuil , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v12 4/8] Documentation: media: Document V4L2_CTRL_TYPE_AREA Date: Mon, 7 Oct 2019 17:06:32 +0200 Message-Id: <20191007150636.16458-5-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007150636.16458-1-ribalda@kernel.org> References: <20191007150636.16458-1-ribalda@kernel.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org A struct v4l2_area containing the width and the height of a rectangular area. Reviewed-by: Jacopo Mondi Reviewed-by: Philipp Zabel Signed-off-by: Ricardo Ribalda Delgado --- Documentation/media/uapi/v4l/vidioc-queryctrl.rst | 6 ++++++ Documentation/media/videodev2.h.rst.exceptions | 1 + 2 files changed, 7 insertions(+) diff --git a/Documentation/media/uapi/v4l/vidioc-queryctrl.rst b/Documentation/media/uapi/v4l/vidioc-queryctrl.rst index a3d56ffbf4cc..33aff21b7d11 100644 --- a/Documentation/media/uapi/v4l/vidioc-queryctrl.rst +++ b/Documentation/media/uapi/v4l/vidioc-queryctrl.rst @@ -443,6 +443,12 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_ctrl_mpeg2_quantization`, containing MPEG-2 quantization matrices for stateless video decoders. + * - ``V4L2_CTRL_TYPE_AREA`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_area`, containing the width and the height + of a rectangular area. Units depend on the use case. * - ``V4L2_CTRL_TYPE_H264_SPS`` - n/a - n/a diff --git a/Documentation/media/videodev2.h.rst.exceptions b/Documentation/media/videodev2.h.rst.exceptions index adeb6b7a15cb..b58e381bdf7b 100644 --- a/Documentation/media/videodev2.h.rst.exceptions +++ b/Documentation/media/videodev2.h.rst.exceptions @@ -141,6 +141,7 @@ replace symbol V4L2_CTRL_TYPE_H264_PPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_H264_SCALING_MATRIX :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_H264_SLICE_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_H264_DECODE_PARAMS :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type` # V4L2 capability defines replace define V4L2_CAP_VIDEO_CAPTURE device-capabilities From patchwork Mon Oct 7 15:06:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 11177665 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1ED9D112B for ; Mon, 7 Oct 2019 15:06:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F14C121655 for ; Mon, 7 Oct 2019 15:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570460813; bh=EInH/vgdsDUyVee6E6f5mXVy6rfJLICDUbdSSURr+hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OkXeNs/GJEJYd+AKsNxSZtYUY7PcVBJ/tL7Z8zu1UB61z8jBYbAyouE6GHaxByWw4 rn2bufr4hgnG5TQEfltMb84NB2g9exSaTIGnO1y1JXMPmGK0mRnIB4SqxUeNqDpjfw HoNeGA0eAVrEFkd/NM+xDqNrQuFq976bXk5LtQlU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728543AbfJGPGw (ORCPT ); Mon, 7 Oct 2019 11:06:52 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45386 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728519AbfJGPGv (ORCPT ); Mon, 7 Oct 2019 11:06:51 -0400 Received: by mail-lj1-f194.google.com with SMTP id q64so14045037ljb.12; Mon, 07 Oct 2019 08:06:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gfi7av1677y2cplYp6Mr+tclh8Fz7p32JQ7/mzFpucw=; b=RWaY8RqEZ0599sEuHzvg9OTGxjLgQkq9JbQOSuhu3xMblCmna/7ZURhsKs6oxHJwGj /WD3FY+YxLZfMlIu+6XQNiG8smSUKjKDHBmcBjTHDUlRElpWo4R2l88LVuWI02SMDFvU noFw28wl792Ku2CM6pTPb5Cly6uWUTOmTolELYa8Hu9jXFhDkq6JOauBgMwwVHryIgLk hjIufNNEyiwrcQ29KbxzKovVKnBQUjj2VaarzptNsEf456of3tRiVQalW8tPckjww/8p uefnTz2PwEVJlay70BuGLKhr3tldLlINAegsmOTbqLDA+BvjYYJk4MdnWGCu6C3j9TP0 nQVA== X-Gm-Message-State: APjAAAV2/II14spSd1ybheUnar2DyI6gi/zqI5PIGTfZFHYeJeeYPs+M qHqud55lfW9CfuRKhvy1zlU= X-Google-Smtp-Source: APXvYqyPsG5090CjynIvArYXAwdV3E2WdTZxCpahkG1ual+vcI2ezIm9V4joRwiwqjauKlEP5SXNEg== X-Received: by 2002:a2e:5456:: with SMTP id y22mr18551560ljd.60.1570460807771; Mon, 07 Oct 2019 08:06:47 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id n2sm3145517ljj.30.2019.10.07.08.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:06:46 -0700 (PDT) From: Ricardo Ribalda Delgado To: Philipp Zabel , Hans Verkuil , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v12 5/8] media: add V4L2_CID_UNIT_CELL_SIZE control Date: Mon, 7 Oct 2019 17:06:33 +0200 Message-Id: <20191007150636.16458-6-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007150636.16458-1-ribalda@kernel.org> References: <20191007150636.16458-1-ribalda@kernel.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This control returns the unit cell size in nanometres. The struct provides the width and the height in separated fields to take into consideration asymmetric pixels and/or hardware binning. This control is required for automatic calibration of sensors/cameras. Reviewed-by: Philipp Zabel Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/v4l2-core/v4l2-ctrls.c | 5 +++++ include/uapi/linux/v4l2-controls.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 96cab2e173d3..bf50d37ef6c1 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -996,6 +996,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_AUTO_FOCUS_RANGE: return "Auto Focus, Range"; case V4L2_CID_PAN_SPEED: return "Pan, Speed"; case V4L2_CID_TILT_SPEED: return "Tilt, Speed"; + case V4L2_CID_UNIT_CELL_SIZE: return "Unit Cell Size"; /* FM Radio Modulator controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ @@ -1377,6 +1378,10 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER: *type = V4L2_CTRL_TYPE_VP8_FRAME_HEADER; break; + case V4L2_CID_UNIT_CELL_SIZE: + *type = V4L2_CTRL_TYPE_AREA; + *flags |= V4L2_CTRL_FLAG_READ_ONLY; + break; default: *type = V4L2_CTRL_TYPE_INTEGER; break; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index a2669b79b294..5a7bedee2b0e 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1034,6 +1034,7 @@ enum v4l2_jpeg_chroma_subsampling { #define V4L2_CID_TEST_PATTERN_GREENR (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 5) #define V4L2_CID_TEST_PATTERN_BLUE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 6) #define V4L2_CID_TEST_PATTERN_GREENB (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 7) +#define V4L2_CID_UNIT_CELL_SIZE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 8) /* Image processing controls */ From patchwork Mon Oct 7 15:06:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 11177671 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7837C112B for ; Mon, 7 Oct 2019 15:07:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5763C218AC for ; Mon, 7 Oct 2019 15:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570460827; bh=dTgHTwxcPVAY75bpwe5bI35sEPUYww67ozMuUmKVYS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vKljKY7LnT8HRzEOg65Ph49/3oNKnpsdt4SwUYCAqh/sy8lpaP7QO/1uDX45pWusY p0FRQseExLkI0I36j1ZgD1mIVppCaDlUFUfX4t3tPC/QUqnDuk0nt3LCKpMXI4VaQT M4W9NLL0FvZvmCpRG6bVzr1Hvby1Y1vebS4LRm94= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728575AbfJGPGw (ORCPT ); Mon, 7 Oct 2019 11:06:52 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:33946 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbfJGPGv (ORCPT ); Mon, 7 Oct 2019 11:06:51 -0400 Received: by mail-lf1-f68.google.com with SMTP id r22so9560210lfm.1; Mon, 07 Oct 2019 08:06:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UMcbJXVkLFQKjwiek+1XAltyAJgo9tN49kR+LoXfqHI=; b=fu+4SED9YvnUO1io+EKdFzrjz9Hwe9zWH5BgCcUYWxV0qtCKLK2A41ImJRlWQMpLWW xENCM5Bq6bjE9ckOZF0ileHhFWMwhqId5O3jjDTCC4WeNZjzCHTr/e/cHYd1hlHCid19 I30Y8JGfOPVl85SsXnV8Cdwj9aBebMp7tfOX8Eq9jZvzwGtXW+yshSW1ZrnZ3R3N90ps KvghPpMbFBjmWoirdmvF+24zt1YzCv6Z5c+fjPTV3jMm5hqjuHVqwtjLIT5GPAAGSIDX pIScTogpcolyrSsbZUBeIY2Pl8Flw93OCNdD1D3wbB5ub0wENrx1Z7NVAOeEdytN5JbJ CDbQ== X-Gm-Message-State: APjAAAWhp50a/UR3mRgssM9RmFDW6D6cLvWY9rRiIE/byLSXODxRKwnK k4mvJ6AYkRIRW5Ap4sOq1bY= X-Google-Smtp-Source: APXvYqx5faEgTg3018IJ3rcho1KK2DYnWj69WhoQSYeEUUoHR/LagEO+wokNxxsjt3emWmMrhP/1BA== X-Received: by 2002:ac2:5090:: with SMTP id f16mr17700746lfm.66.1570460809299; Mon, 07 Oct 2019 08:06:49 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id n2sm3145517ljj.30.2019.10.07.08.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:06:48 -0700 (PDT) From: Ricardo Ribalda Delgado To: Philipp Zabel , Hans Verkuil , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v12 6/8] Documentation: media: Describe V4L2_CID_UNIT_CELL_SIZE Date: Mon, 7 Oct 2019 17:06:34 +0200 Message-Id: <20191007150636.16458-7-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007150636.16458-1-ribalda@kernel.org> References: <20191007150636.16458-1-ribalda@kernel.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org New control to pass to userspace the width/height of a pixel. Which is needed for calibration and lens selection. Reviewed-by: Philipp Zabel Signed-off-by: Ricardo Ribalda Delgado --- .../media/uapi/v4l/ext-ctrls-image-source.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/media/uapi/v4l/ext-ctrls-image-source.rst b/Documentation/media/uapi/v4l/ext-ctrls-image-source.rst index 2c3ab5796d76..2d3e2b83d6dd 100644 --- a/Documentation/media/uapi/v4l/ext-ctrls-image-source.rst +++ b/Documentation/media/uapi/v4l/ext-ctrls-image-source.rst @@ -55,3 +55,13 @@ Image Source Control IDs ``V4L2_CID_TEST_PATTERN_GREENB (integer)`` Test pattern green (next to blue) colour component. + +``V4L2_CID_UNIT_CELL_SIZE (struct)`` + This control returns the unit cell size in nanometers. The struct + :c:type:`v4l2_area` provides the width and the height in separate + fields to take into consideration asymmetric pixels. + This control does not take into consideration any possible hardware + binning. + The unit cell consists of the whole area of the pixel, sensitive and + non-sensitive. + This control is required for automatic calibration of sensors/cameras. From patchwork Mon Oct 7 15:06:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 11177669 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CF7B112B for ; Mon, 7 Oct 2019 15:07:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31D1821929 for ; Mon, 7 Oct 2019 15:07:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570460826; bh=nhpPUhT8ZiWCN4xt+1Ptl7iUd8tl8OWdmX75qUGDcRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uqU88lFziuFaTTPGrwkmF7aOCm8dWWc0G1dO5EkxiP0Fbqe/45mh6r2bMNKkGg0b1 r2KaDPU1ZReuFcNk0QB+mGg6+l1qD9PONCE64Waaum4oOFqEot0LYolVycllVS/Od1 UZTLbj+k2FS9RBBgfwUjj9DScFRYvXpfEh/sldW0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728598AbfJGPGw (ORCPT ); Mon, 7 Oct 2019 11:06:52 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:38142 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728533AbfJGPGw (ORCPT ); Mon, 7 Oct 2019 11:06:52 -0400 Received: by mail-lf1-f68.google.com with SMTP id u28so9527482lfc.5; Mon, 07 Oct 2019 08:06:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=emfiFOeFAAxgXit83uDIdAuAU1rO2ypqLYWuaCBBiAI=; b=RQGfBXiT4eZiil9ZQUX0fBf/QKSRccv5KTUgbVbjc2HIzN7can8Fovgc6pq7kKVnNy xI4yqiOavemoRY32GLuNMOWnp6NQIThNa6YqLPGtmv0TWISLV5VtvMKeNvCbamo0pPgU KUS0AvwyQOvsJ/L+eDR81hcg/7Rn/Oaf7DIcsoODWjphuTNWfQuKUJstNT3Nkr/PlOC/ htBTGLqafTml6jCGzPQvA8GX+mntCYKlGBylNsWN6Xg41kSaA95d8trPbBiFxxGtYllM xZ3ynzMq4J8HdndcvOaFpaTylHJb9Mf0jtDGqpDdQYbOEfoT23eB2zy4S1j+ojQq2o39 ErJw== X-Gm-Message-State: APjAAAXYQ9HKfCtqb7LveWELAHIHuzgvXDZLLsyZuuuZfKngRVe9/x07 R5Zrfue1VO538vk/pPlJrYA= X-Google-Smtp-Source: APXvYqz+IJjl2HjzlrutbMg0+HcDbH5hZL+hMTpy7bS3Hnnh6LfE72wgQzIB9yjjE+RdZW1+6Zt71Q== X-Received: by 2002:a05:6512:419:: with SMTP id u25mr16510375lfk.165.1570460810724; Mon, 07 Oct 2019 08:06:50 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id n2sm3145517ljj.30.2019.10.07.08.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:06:49 -0700 (PDT) From: Ricardo Ribalda Delgado To: Philipp Zabel , Hans Verkuil , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado , Hans Verkuil Subject: [PATCH v12 7/8] media: v4l2-ctrl: Add new helper v4l2_ctrl_ptr_create Date: Mon, 7 Oct 2019 17:06:35 +0200 Message-Id: <20191007150636.16458-8-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007150636.16458-1-ribalda@kernel.org> References: <20191007150636.16458-1-ribalda@kernel.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This helper function simplifies the code by not needing a union v4l2_ctrl_ptr and an assignment every time we need to use a ctrl_ptr. Suggested-by: Hans Verkuil Signed-off-by: Ricardo Ribalda Delgado --- include/media/v4l2-ctrls.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 5331cf6c8517..d4e1b1902044 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -73,6 +73,18 @@ union v4l2_ctrl_ptr { void *p; }; +/** + * v4l2_ctrl_ptr_create() - Helper function to return a v4l2_ctrl_ptr from a + * void pointer + * @ptr: The void pointer + */ +static inline union v4l2_ctrl_ptr v4l2_ctrl_ptr_create(void *ptr) +{ + union v4l2_ctrl_ptr p = { .p = ptr }; + + return p; +} + /** * struct v4l2_ctrl_ops - The control operations that the driver has to provide. * From patchwork Mon Oct 7 15:06:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 11177667 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E74413BD for ; Mon, 7 Oct 2019 15:07:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D24C21A4A for ; Mon, 7 Oct 2019 15:07:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570460824; bh=pK20S9w9jPx4oDEOoBNNwlgSdse6dCqOTIYN8MTHsOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=17DfSiFvp6JsVbfFPo0JQWVrwb8jk5S67ScFjG8KveLMh0Sxyg8JWLDfaK+pd+KYA wgJPhaJBKKF7l+wTEAbylYsxu44i1jKdfZdgDzPpu226JYmg2HHAspwGZ0BzpyaFc/ 1LSkYZvanEGkCdsOGJsOwjpA/mbqLxzl8Pt8EsIg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728641AbfJGPGz (ORCPT ); Mon, 7 Oct 2019 11:06:55 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40161 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728603AbfJGPGy (ORCPT ); Mon, 7 Oct 2019 11:06:54 -0400 Received: by mail-lj1-f195.google.com with SMTP id 7so14063598ljw.7; Mon, 07 Oct 2019 08:06:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pmVOhqPV32NcE6/VgCf74tZc8Nj51x40T3jhqugB4as=; b=TRWYkwkpgSPiRjKPy7XOhSTGN33f5oXhUOsnZkIejWwy/7/X81vvcWeo+GKHZsSUnp E3GHUBRYro6UKk8LrXrpqN0+qd86i6RKf4dAUYkIc07/3E4gCbZShiNrNCzjuhOJa0M6 MON8JdgQg4qJ1LQqrKbpOAk1ZjD7nok8Eu2IS2lB5+AAr4YJM1F19YqS8YXiLDJHj9S9 xsTyW2h2UXIlVs0iQ3G1Jbd7C4q2x4J2NTf0m8oP1pNctsPR9nBX++Dm5Njvdkd0dcNI fwG8ck28eRgmWZkTeg+jty5X1pqS7+YHBIZTq2DKnMwRyTn9mcRs6bhADHkiPF06fzAv +h7A== X-Gm-Message-State: APjAAAVV4cmWImA+r2gtittKyQFZiLTddQ0g5XUbcEGHO3jKX2srFikh fUKAzvtbToD6MLkhjFJm4jc= X-Google-Smtp-Source: APXvYqwK7DNQQdsfY9M8U1S6wADiMibc8D0R/IKBzbxZdTUIZvO0h2ZdKVAPY1QBihaCvYiJN5ndAA== X-Received: by 2002:a05:651c:154:: with SMTP id c20mr18307067ljd.83.1570460812200; Mon, 07 Oct 2019 08:06:52 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id n2sm3145517ljj.30.2019.10.07.08.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:06:50 -0700 (PDT) From: Ricardo Ribalda Delgado To: Philipp Zabel , Hans Verkuil , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v12 8/8] media: imx214: Add new control with V4L2_CID_UNIT_CELL_SIZE Date: Mon, 7 Oct 2019 17:06:36 +0200 Message-Id: <20191007150636.16458-9-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007150636.16458-1-ribalda@kernel.org> References: <20191007150636.16458-1-ribalda@kernel.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org According to the product brief, the unit cell size is 1120 nanometers^2. https://www.sony-semicon.co.jp/products_en/IS/sensor1/img/products/ProductBrief_IMX214_20150428.pdf Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/i2c/imx214.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 159a3a604f0e..adcaaa8c86d1 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -47,6 +47,7 @@ struct imx214 { struct v4l2_ctrl *pixel_rate; struct v4l2_ctrl *link_freq; struct v4l2_ctrl *exposure; + struct v4l2_ctrl *unit_size; struct regulator_bulk_data supplies[IMX214_NUM_SUPPLIES]; @@ -948,6 +949,10 @@ static int imx214_probe(struct i2c_client *client) static const s64 link_freq[] = { IMX214_DEFAULT_LINK_FREQ, }; + static const struct v4l2_area unit_size = { + .width = 1120, + .height = 1120, + }; int ret; ret = imx214_parse_fwnode(dev); @@ -1029,6 +1034,10 @@ static int imx214_probe(struct i2c_client *client) V4L2_CID_EXPOSURE, 0, 3184, 1, 0x0c70); + imx214->unit_size = v4l2_ctrl_new_std_compound(&imx214->ctrls, + NULL, + V4L2_CID_UNIT_CELL_SIZE, + v4l2_ctrl_ptr_create((void *)&unit_size)); ret = imx214->ctrls.error; if (ret) { dev_err(&client->dev, "%s control init failed (%d)\n",