From patchwork Mon Oct 7 11:34:55 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: 11177243 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 092A117EE for ; Mon, 7 Oct 2019 11:35:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CFE5A21721 for ; Mon, 7 Oct 2019 11:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570448111; bh=E9NmJKhv42+mB1ZMBt8iKwzh9l6hyWMUl5rZ2Ywgwl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Atq2laEL9J2fLjy5BdnYvlzFEJvJwsFBgGBJMrDHiYLsHrqtvszg+TWWcWsawWfwT qilyayWYe94nBCSvwpf0dAJTouTAjmbRt6H0vb4pSAjuarxFFN3hp2fJAtq5UsWqJD uum51ZaCfAX6k9JHj/ukVjM5HxPPoaWcGdDxMij4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727769AbfJGLfL (ORCPT ); Mon, 7 Oct 2019 07:35:11 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:41651 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727376AbfJGLfK (ORCPT ); Mon, 7 Oct 2019 07:35:10 -0400 Received: by mail-lf1-f68.google.com with SMTP id r2so8995203lfn.8; Mon, 07 Oct 2019 04:35:08 -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=daSOpf+9Er9QChSZPCNIv7cT4tavsYE8z9zUYmU9DH4FGBPNNZYw9OwSuEu5GUesh7 5ia5ozJS4QMD6RyqAr5GJWspQ7/WtrcF18lPXDIFSkDXehERofj6nHVaaznJAx6ietgV 4nvqpgbpvVV99dp7q5H/jP5S9X1rEpLr7IFuQ6GtWvx0uMy53UGqQU2s62msTAri7P1n SjixgAFX+yKu8bUdFn//82TEr3Z2LqJSRRQWtoUnCCyzq3gyG3JPk45OydYXhumNnNnv 4128kdV05+N6pG7RXnM02zpbcgBGBucMQDYD+ukpY5CHy3x1ZU7eGBp+gzqgXOXGvdxZ H2eg== X-Gm-Message-State: APjAAAU40G4GTpweMhbwAwujkRHa3C6ywpszsIzpklSuU19Chdkud0K3 Hq8WIm1KLfXW5dI6+uV/ztoeQpLR+3I= X-Google-Smtp-Source: APXvYqxu3HzaHgEvZNmhXODgLc8v8DcZXVf1/B/m+8s5ruoXItL1DKCnv8cdOtrupUl40cnt/FFnSA== X-Received: by 2002:a19:ac45:: with SMTP id r5mr16431488lfc.6.1570448107198; Mon, 07 Oct 2019 04:35:07 -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 b25sm3666047ljj.36.2019.10.07.04.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 04:35:05 -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 v10 1/8] media: v4l2-core: Implement v4l2_ctrl_new_std_compound Date: Mon, 7 Oct 2019 13:34:55 +0200 Message-Id: <20191007113502.11746-2-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007113502.11746-1-ribalda@kernel.org> References: <20191007113502.11746-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 11:34:56 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: 11177257 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 E0AC51599 for ; Mon, 7 Oct 2019 11:35:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF3B721D7D for ; Mon, 7 Oct 2019 11:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570448142; bh=WMCQd2GDPxepzdcS7GcjwsjWqqxgbpSwzeQjk3Onw74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=LeIk5EHHxhuHpzPx0w0xM71CyP7l5p2n28huSDNoSJnlOpzHLnExdbnCa/T7Jwioc 0Q9qcRn/T5vIlcj7HpSnak2MVdky29oqCxH+3myBzs78xMmYri9R6dJzy9fjfTAXBq Voi6LlbS/ow4vbpMizSbx2SZD3lq91DuTp8QzGi4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727799AbfJGLfj (ORCPT ); Mon, 7 Oct 2019 07:35:39 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35645 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727757AbfJGLfL (ORCPT ); Mon, 7 Oct 2019 07:35:11 -0400 Received: by mail-lf1-f66.google.com with SMTP id w6so9010430lfl.2; Mon, 07 Oct 2019 04:35:09 -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=QJNGZIpScWEOpBiUuR5ogk8EeSrxf1DIU3G2z0VagZr8pkWfPq18XB+4JPgD3xaQD/ ZfdfWChvTTZV3o7TbXKuRM7qqTfe87O5SsYR3i3NDvFQvUKTis2Kd80xJ+1hOnOkqIP4 SHLJoBMchklgCpaJOY2O3VDXt5+N9VYsXJGIliJtDEMR7L0gQiw/oL0YaHsKuAOPu3hW k9+CyWaYb+3/1FPLevRZdD39NOt903bWVmmOPAVJm8yc1V3ABm/NXXFV74qg7FmCUF1u e1oZdqYbaVwltnQblyShyffncaB39lgwbHbWKldxbhNaPIg6NbJ1Q0mVngXl+Wf+7zrN pzoQ== X-Gm-Message-State: APjAAAXf7aLalpSjZE0Qp58lqwbu6rMZhx9fWB5C2v+LP7DbjzJZWs1C FTA0v4Wi1N7q2QZUExQAMyPHQNrzkik= X-Google-Smtp-Source: APXvYqwQBw9XPD6p+WtacfDJ/7xNyoIqolTB5wKw/wcK1/uTSQnIYGe+xUlAzIIsCv6vaMQMqIU9HA== X-Received: by 2002:ac2:551d:: with SMTP id j29mr16052554lfk.7.1570448108835; Mon, 07 Oct 2019 04:35:08 -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 b25sm3666047ljj.36.2019.10.07.04.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 04:35:07 -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 v10 2/8] Documentation: v4l2_ctrl_new_std_compound Date: Mon, 7 Oct 2019 13:34:56 +0200 Message-Id: <20191007113502.11746-3-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007113502.11746-1-ribalda@kernel.org> References: <20191007113502.11746-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 11:34:57 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: 11177255 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 644E81599 for ; Mon, 7 Oct 2019 11:35:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 387DE20867 for ; Mon, 7 Oct 2019 11:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570448137; bh=i6rbzyjQQRlkROdhTWdTfJS8BbejsXG1x7e7k9LtUqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dqP4vb4bnd33jO3LVooe7lBi6OlUWB0yd/mBYZbed+6qvi2QcXVHC73nLyH43s8HA V5V61wwLyCMsK+4X8LlXAVKwjkc3x1DUC+Ar7vEZK4pJN49stOVP70W/L0KMgPiBp1 /WfWtS+3byhZo3+eT/+NpWrCTDqRRKbbVRy2cRuQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727793AbfJGLfN (ORCPT ); Mon, 7 Oct 2019 07:35:13 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:36028 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727490AbfJGLfN (ORCPT ); Mon, 7 Oct 2019 07:35:13 -0400 Received: by mail-lf1-f67.google.com with SMTP id x80so9024463lff.3; Mon, 07 Oct 2019 04:35:10 -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=W49nxA+XyuKhKxKsn46DIB5suU6vzX2JO9Odb3T+9cs=; b=BOjaXlw+qaEcDY0RGbqU00OvdlMo2Tc5u9yvITYLpXFw3Hrq6705pYdkt9DJ6uXKFZ yk96AUtwJwhJ4OkiGYT5eIxvimhcxvoV+4ifGrro0Np50SxZKYkb1mkaBrhkY9AOrspO y2nSUQHAQG/RGvfEOCeSC6nwkXVLZlzN1HOG6W2rwWtXQhnq7HRa8vWWtT2MzxTXl7Nd Z6deZwgfjgl7PmhP9igARCkMQt/azMGI/oCZDDoySrJ52rKD7hSJt73hPxy0UuQ3/DG1 t11hGzBG7zZVflpuKX4n2bu0mL+7iZxi+RYsB9k+Pf1GqIv1ibxyra2jsygaIU2W04TL m15Q== X-Gm-Message-State: APjAAAX1SU/CrXB7PuJM87jqkuRyZufUXehDG9+vzl26sM4fOH6Z6Y6V 3vMrgYCMJJW+2dD5L9eBL2E= X-Google-Smtp-Source: APXvYqyTSzTeg1ZRRu9XKHCa6WMHgrufbnmqgoT6RZ6Ah+nJxLxdW5OZXbMANgSSVuRpcOge77ngBg== X-Received: by 2002:ac2:4884:: with SMTP id x4mr1388763lfc.45.1570448110107; Mon, 07 Oct 2019 04:35:10 -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 b25sm3666047ljj.36.2019.10.07.04.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 04:35:09 -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 v10 3/8] media: add V4L2_CTRL_TYPE_AREA control type Date: Mon, 7 Oct 2019 13:34:57 +0200 Message-Id: <20191007113502.11746-4-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007113502.11746-1-ribalda@kernel.org> References: <20191007113502.11746-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..c42f164e2c9e 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. + * @s: 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 11:34:58 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: 11177253 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 235B317EE for ; Mon, 7 Oct 2019 11:35:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EBBB720867 for ; Mon, 7 Oct 2019 11:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570448135; bh=qNrcMr/8SbxkQYJjYnj/mVx36Bmtf1e3S6sEoTqgqMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EXaF42W+9UcBcTvyYrDEfxa9uVBK41lK9IxK0VP+virRBs5cxYTSNgxPazNsjFN5c /4YPOxQ7GXi5LSnEaFrZPiBR5xEFhE1F85RD7yXnsP4q1mLo5m0r15dxmEgVlFD2x7 JvgmNCThTUnTEobxYtyQ3MvLx7OmK9UjT6dFyoME= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727826AbfJGLfP (ORCPT ); Mon, 7 Oct 2019 07:35:15 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:33282 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727791AbfJGLfP (ORCPT ); Mon, 7 Oct 2019 07:35:15 -0400 Received: by mail-lf1-f66.google.com with SMTP id y127so9038890lfc.0; Mon, 07 Oct 2019 04:35:12 -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=KOQK/iTDEM2OOwuKD12eKM8a+YD1YCYg9jIBY8YMxOA=; b=CVvcI+QKQsUo5D025+b9xDs1bRrdppU6aObBZNL0n2CzbmNjSLSq4v45FsrN2oZm/D /NnQuRJot+jd0MwX2xIQoJeY1NmFeaIVy6G5vMNi/Ndc8KyPAfzoOIVQibg6SdZzVHfb yWfSwSmTRfNaivSozNMKczaEdVJpEx/CwjzwwAIZpvCOOcFnk23q9DyGSrOGhn4nQNRm VxlWR3lVIj5hwo7aX5ujWpZrxOpLLwgQg7cUg8Byd/wmGfSDxXqu1eLMMmjtZEGoRD4v R9Vmvp6Dgg6skQD4+vHyciWlToDUpUU1ZKQ4Ox/7iXOIlg86Ld596yQ0cg0k747idFi9 +Uuw== X-Gm-Message-State: APjAAAUoyMUqokWSYMCDdgtAjaNdeVOnhmGcPxNDKNchiy1jvkMsr6k7 8OPSFryHL3/cOcValCvPoTA= X-Google-Smtp-Source: APXvYqztCCaBxWPgOIMQhen2P198wIgh5SWv69czRq6l9HsoFpdENlYEQN4JpGoSwHxUr9wv2/9PsA== X-Received: by 2002:a19:2314:: with SMTP id j20mr16513006lfj.22.1570448111484; Mon, 07 Oct 2019 04:35:11 -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 b25sm3666047ljj.36.2019.10.07.04.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 04:35:10 -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 v10 4/8] Documentation: media: Document V4L2_CTRL_TYPE_AREA Date: Mon, 7 Oct 2019 13:34:58 +0200 Message-Id: <20191007113502.11746-5-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007113502.11746-1-ribalda@kernel.org> References: <20191007113502.11746-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 ++++++ 1 file changed, 6 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 From patchwork Mon Oct 7 11:34:59 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: 11177251 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 D1AF91599 for ; Mon, 7 Oct 2019 11:35:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0D3021D6C for ; Mon, 7 Oct 2019 11:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570448134; bh=EInH/vgdsDUyVee6E6f5mXVy6rfJLICDUbdSSURr+hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GkWTg3CIlVrZzHhIF89mSK4z/ooPasDOdofsr/rkpI5uTsWaAe+CWA2Gwvny2WAHG BVdZM2avkvp7eGGrmYOMXLqEyh9em/wWTzCq9FoUZNtzkA08/j3hmtLfYMCuicqM/v oqEO6FEYdO4y9cV9VWo1Ra8M6OLUquo4L6zWluHY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727861AbfJGLfa (ORCPT ); Mon, 7 Oct 2019 07:35:30 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:42823 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727799AbfJGLfP (ORCPT ); Mon, 7 Oct 2019 07:35:15 -0400 Received: by mail-lj1-f194.google.com with SMTP id y23so13215460lje.9; Mon, 07 Oct 2019 04:35:14 -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=RLzs3p/fLRAbLFx0P7dce2696f+CqikL0Qa3r/ho2TjNyeBbjWH10KyKgvOGqJ04sZ cpkPdnLLFCrxEpUbzJGWSjFuDomqZd7rqRNfXdWH7DC5O0QeruoJB3VExo23QqBAqR9u rSM2kS90dH1xgB0KTattAdeAHKGrkn61HJw7bc/LGZoO3LCz4T/soBzZ9sy1IfEcp+mS 18KiQyxF3ivUzfB/gwlEauiCULeO3fm343Hc5dU9uU2Ugg6cXvVdwPPmqomFs0lHexz4 AtBxVlYIp0FXrdaMRFO1XeHVF1vY3ub0dJQpaoI/nJrWpmqu7asHDE7/H7ryFiL+si65 R2iw== X-Gm-Message-State: APjAAAWGum/NgBMO/uPrvLRIT46/DymgHieokylMtU04dDiDpsL3qFRy dKJ3v35FwGvqSdBhSJsOtIE= X-Google-Smtp-Source: APXvYqxriWcuCywlzFNFeFfqlrM/bXbs+7FKl8JMpSjGSlHrJBW2KHo36FL2ZqBnDKiaCPLqOkPvxA== X-Received: by 2002:a05:651c:1132:: with SMTP id e18mr18303142ljo.33.1570448112821; Mon, 07 Oct 2019 04:35:12 -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 b25sm3666047ljj.36.2019.10.07.04.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 04:35:11 -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 v10 5/8] media: add V4L2_CID_UNIT_CELL_SIZE control Date: Mon, 7 Oct 2019 13:34:59 +0200 Message-Id: <20191007113502.11746-6-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007113502.11746-1-ribalda@kernel.org> References: <20191007113502.11746-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 11:35:00 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: 11177245 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 64A8C17EE for ; Mon, 7 Oct 2019 11:35:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F1EC222C1 for ; Mon, 7 Oct 2019 11:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570448118; bh=WbRs1XeKYyn96UqhzWPssEr/6fw1+7MeH8u9fZxIbKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=A9dkmZVMxM7V7tzzfZnN/SxP9lHrPpJn75Ruup5fWEbgnncrxGCIn05de/QoG0bJY kqAHV/unxLZNdC5qsFFSCHKVKilBeqvj1P3FsqRl+nfDPQdLMAbwfZGZ/aRVZtAGWc gXMsDGt9JGh9RUDhKiXI+tahGuayiG3LsjV9od6c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727850AbfJGLfR (ORCPT ); Mon, 7 Oct 2019 07:35:17 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42492 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727490AbfJGLfQ (ORCPT ); Mon, 7 Oct 2019 07:35:16 -0400 Received: by mail-lf1-f65.google.com with SMTP id c195so9005900lfg.9; Mon, 07 Oct 2019 04:35:14 -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=70x3tCLN15pVZABiv+sJGfjAbt3B67/xHyirI0wzx58=; b=EaSeURKIkRqGCykuhny4XBag4Y5NiCyerPTwd8qwa1AQQnQjdgOhOSgNcfbd8cXhOZ g1aTgFDG3FsUfH1m9wA7m9hX9316XhSX5CmrQU6G1bBRqEXg7emcvuhOXqdSQLOLWmJh +TA0mOGvoePi0Ql+v6U7uUNNY8Z/868W/Pm0PbqdlFHrMjivsxbNqsrO2N6N+xxgyvD/ wG75MSU2d5EUxdygvcE1K6t/NFb2S6+ySnhg7aA+LxfZ1O5WKFHL2oMmXc5ZeZ9ubY2t n0QxwBh+b6Ovs5kWpJS9IZapc+mXhnpuxVyVEZ4ZaeQbn/fYp+uqrkYN1cu6vtJ5sjsv uy7Q== X-Gm-Message-State: APjAAAU2oih/L+kCtp1CfLXPG5XWIUqmsNnGx5mzXiDz6xsiB49XuLbB KOmcaIZIYdOUnQDOCfmq8AY= X-Google-Smtp-Source: APXvYqzEs8wmTTWmN7yGseypLKH8UDpB02czRsmtX90rJG0hsVqNV0Rn5O5UdeYrV9fkZcUB4o2mGQ== X-Received: by 2002:a05:6512:304:: with SMTP id t4mr17226147lfp.15.1570448114103; Mon, 07 Oct 2019 04:35:14 -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 b25sm3666047ljj.36.2019.10.07.04.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 04:35:13 -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 v10 6/8] Documentation: media: Describe V4L2_CID_UNIT_CELL_SIZE Date: Mon, 7 Oct 2019 13:35:00 +0200 Message-Id: <20191007113502.11746-7-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007113502.11746-1-ribalda@kernel.org> References: <20191007113502.11746-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 --- Documentation/media/uapi/v4l/ext-ctrls-image-source.rst | 9 +++++++++ 1 file changed, 9 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..6388668855d0 100644 --- a/Documentation/media/uapi/v4l/ext-ctrls-image-source.rst +++ b/Documentation/media/uapi/v4l/ext-ctrls-image-source.rst @@ -55,3 +55,12 @@ 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 and/or 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 11:35:01 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: 11177247 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 3B05E1862 for ; Mon, 7 Oct 2019 11:35:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0CA84222BE for ; Mon, 7 Oct 2019 11:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570448120; bh=uL/jxlJhBOzt2phJWd3CpcwUQzx2t8TEYELIK3/mTbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0W0Qaclx+hFyu63dTvRmCoIzsxEXjQ+figB/LmXVydAyXZiVEUJzCTiOo0NmSO8vo jZnO4wMZlcu21VgcOHTqeMQqXHEfaAzuR4AMi1v9kuqtFKsGPREhNa7RvUED5u57mQ o2eANx8Krstj5P3Zs81g7K6li+mC2bw43lTGh0Dc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727880AbfJGLfT (ORCPT ); Mon, 7 Oct 2019 07:35:19 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:39150 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727791AbfJGLfS (ORCPT ); Mon, 7 Oct 2019 07:35:18 -0400 Received: by mail-lj1-f195.google.com with SMTP id y3so13246559ljj.6; Mon, 07 Oct 2019 04:35:16 -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=5A36dry6P/XdWhWibfmP9iwvjj4WogIUlnkb+TsrNII=; b=FwNoEqIw/r2Nr4gGC7gfGAcXXie9FPQ7oa//R1wTWj56g3CbBPZo7HnBRmfkOwYwOT Ljrd2s1hYwqKHqTIhXwfCo7+pFetQqMJatSDUTwBWKLzixpO42ANkHwc9y8MBFg9KbF/ 54hJ+zWodDuGxQ1bczBPOHYqM69f5zQbADd3rjW09Tt3pbduCCfNbzmpp15aF34GAmAf CnjsUqZWBTp3nJwKaiXIiRnWunjDVHGQWbwmFy9gswCBpYK++aMgVbSy/RWFv4Tm62S0 fIfVxRkbxfeNOdHCoq1G9gTt9AF+Kg3HO2l+GrSPiG+POrgLBmudoKjXN3lp6I6/J7n0 4yRQ== X-Gm-Message-State: APjAAAV204tkcnpQIQKvqwxD/jKJckJtRe30PGkSBGkYiG7K61OdH0sl eUQJYiNKfYxkW9z7tnxoVvI= X-Google-Smtp-Source: APXvYqy26ApRN+6kygYoXsM9KJd/z4ze7tUjYgazXxqNEql/N97IuAAEZfr73kLG61uP1Wb0iVBz2A== X-Received: by 2002:a2e:9753:: with SMTP id f19mr18040020ljj.197.1570448115457; Mon, 07 Oct 2019 04:35:15 -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 b25sm3666047ljj.36.2019.10.07.04.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 04:35:14 -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 v10 7/8] media: v4l2-ctrl: Add new helper v4l2_ctrl_ptr_create Date: Mon, 7 Oct 2019 13:35:01 +0200 Message-Id: <20191007113502.11746-8-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007113502.11746-1-ribalda@kernel.org> References: <20191007113502.11746-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 c42f164e2c9e..0bfedd3d70a6 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 11:35:02 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: 11177249 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 6B78D1599 for ; Mon, 7 Oct 2019 11:35:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 48891218AC for ; Mon, 7 Oct 2019 11:35:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570448128; bh=pK20S9w9jPx4oDEOoBNNwlgSdse6dCqOTIYN8MTHsOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=yalkb/bQIFSLJjmjr35xdllT2K90BV7LBdZHHpLURaNNR2TxkXr8l/JwPjrEEqM0G 28z8mYjm1VD9o9UhAEJ3uFipH6jI+tCqw69WZ236zW+moZZ6IVdxVJOY8GGZ/9OsRT QMZXNgW2kdj7j1Y2Uqvs4xpPejiyTkPIDeHtizzc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727905AbfJGLfY (ORCPT ); Mon, 7 Oct 2019 07:35:24 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42497 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727861AbfJGLfT (ORCPT ); Mon, 7 Oct 2019 07:35:19 -0400 Received: by mail-lf1-f65.google.com with SMTP id c195so9006000lfg.9; Mon, 07 Oct 2019 04:35:17 -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=hZU5BIigDKrW3EbZX/srO/Xz3nHbo3ImZokKfx48aUdKpTGjL6CP+4ORzzsufI/N/i 6Gec15jpJMUE2EppJ3+Ai0s//8aQfCzBupOtna58ZsrqmTFHnMIYG3tNieW4YcvPB6ix HFb87XSsqChGb5e2/rjy19V7d6LIHonqDFfWVQTzCInUh+3oX/22FI0PYVaaTNURBR7B dph2E30s+s2mMAFtKNAsNWZyNlOIYOOGqBaD7OVAZ7smvzOeqOtQq/WF8uro0V//i8WH /VHY9q1o6ZBwbLtRhdEavsXbRe80Z5d9eoxVRZp1aUJ1LgoW/SL3v2bEycRC1IegT96t Lvow== X-Gm-Message-State: APjAAAXOcXzxndoE3oTLYLAG/aTXv+eiSUTNhWqX40CabJmOZCRfZTnT rkv5HwYFtk4fesDNTqyjFYo= X-Google-Smtp-Source: APXvYqy9XxrNLq2MEaMQGnjZ56QD7dlDtRgKrb3Pgk4e1h2O/nZiZfcSvqfBKoTTk7Seo5suBxbXhg== X-Received: by 2002:ac2:44a3:: with SMTP id c3mr15246729lfm.17.1570448116812; Mon, 07 Oct 2019 04:35:16 -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 b25sm3666047ljj.36.2019.10.07.04.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 04:35:15 -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 v10 8/8] media: imx214: Add new control with V4L2_CID_UNIT_CELL_SIZE Date: Mon, 7 Oct 2019 13:35:02 +0200 Message-Id: <20191007113502.11746-9-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007113502.11746-1-ribalda@kernel.org> References: <20191007113502.11746-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",