From patchwork Tue Oct 1 11:24:14 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: 11168507 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 B89371709 for ; Tue, 1 Oct 2019 11:25:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D48121A4C for ; Tue, 1 Oct 2019 11:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569929103; bh=E9NmJKhv42+mB1ZMBt8iKwzh9l6hyWMUl5rZ2Ywgwl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=u7/c2mj20Bx/192D61cCZrfIz/EVvegu81jMamf4njaYQcRkVJcH+C3TUXKF9X6er yZlKWKu6J7xgdixkcFBtEl3M/esUz6Wye2JnLtGaTCIy+wrjixxRV0bZzmuekEgwa0 LIgUtdIr9vPC0F0aPh4653vLla0dmADPq1Vtjzo4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731705AbfJALY3 (ORCPT ); Tue, 1 Oct 2019 07:24:29 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:38857 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731083AbfJALY3 (ORCPT ); Tue, 1 Oct 2019 07:24:29 -0400 Received: by mail-lf1-f68.google.com with SMTP id u28so9571350lfc.5; Tue, 01 Oct 2019 04:24:27 -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=g/sR+8O/Q7WX+k56ugi7B4jPwXugNyfEpaYIjk8ijOQ/9b55wlHn0gz2Kzb4Fxp966 VszUd3nliT+hneUbga5aKsJ4VVAbC9tIoe1v+QMQJKnv+TkyjmGWpTAvHRINN8DMYkGE S/FWO6ne8A7QfLu+nY4yenD59rwBta+Cg5SJVlyadak+iDpT8Cxqm9UiI+qkLYJFmwAW yp9QfakD62huEsJFeBRgWVSjt6AB6bkj7IH4a+VIqM9fZT+AxRTjTAGjJ3su4xLeUF3D amCqsIguXdcjX2in9w9euk5qWDkprD5DI3ddo/CjdI1MhfMxwOzkFQtoJ9BfmWg7v8PV Rs3A== X-Gm-Message-State: APjAAAVuZB4iV8YU0EKfmg+4a0E0KO8C5u/9yWTzpblWJBnZW/KOXZzB z6wxCVTOv4wVaVqrtDlcegY= X-Google-Smtp-Source: APXvYqwbgsVV5L/LzUaI9/Y/jE+arxquU0Y0kuCLZyBphoivXXWfXskIOjYKyHqAPaMnj+2ieOB7jg== X-Received: by 2002:ac2:5091:: with SMTP id f17mr14725978lfm.107.1569929067010; Tue, 01 Oct 2019 04:24:27 -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 3sm3853894ljs.20.2019.10.01.04.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 04:24:25 -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 v9 1/8] media: v4l2-core: Implement v4l2_ctrl_new_std_compound Date: Tue, 1 Oct 2019 13:24:14 +0200 Message-Id: <20191001112421.2778-2-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191001112421.2778-1-ribalda@kernel.org> References: <20191001112421.2778-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 Tue Oct 1 11:24:15 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: 11168505 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 8BC621709 for ; Tue, 1 Oct 2019 11:25:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6760521906 for ; Tue, 1 Oct 2019 11:25:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569929101; bh=WMCQd2GDPxepzdcS7GcjwsjWqqxgbpSwzeQjk3Onw74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SCLfs+taVq6vzoTSNB+bVq5VA0kRvzZigSt6Ik4xqDpH9O+IkJ0iT5xR+1Vs6cFzU wBNnHLhdit+No07wjuVqknJdLHsIhzRk3VVLc7bGuRrqCw7Z9tlaLA+mj+N9jvo8lW 0ozgpJB1qcbCfbAYx+KiOQG6T3djpo/aQk0B9LBc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731972AbfJALYc (ORCPT ); Tue, 1 Oct 2019 07:24:32 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46985 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726847AbfJALYb (ORCPT ); Tue, 1 Oct 2019 07:24:31 -0400 Received: by mail-lj1-f194.google.com with SMTP id d1so12895046ljl.13; Tue, 01 Oct 2019 04:24:29 -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=WZGq39LcAqM2RyI8xaKcVy7beWCGsioVFTfkSZ7K3dUyocGqFyTLVTG78iwR3Y0brn b5TmIGbB2V6UAP6hx/m5VVBR4QkdZuQaZqRlM+SzFwEd7IXudLlz1zw7ivkmjf9M3rni vEscO6uECveAp3xN9LdK3gqsEEf8TaEtk8s3/KC/eihFxlIG28j9KBJyRjHQ+BYfO2tK 9C1zQ3IO/thvxQsqINj2HzWF7Xvov4XmEftQDhNoRpcXLkAWhxa1JPJ0LmH7PkmGu5dq TBIlUtLXXbdOcj4Eu70wUzs12ahx6LXbKLczZ/lEctSLFTaDpbPEcPKeFGa0MVVZk/MT IDUQ== X-Gm-Message-State: APjAAAWI0FFOsG8S7+pksGIDF0syfZMytz1LKB1CAp45+tsfPXheW4od CsWUGwbrCGZfslskYhbQKnlxsUe3E3A= X-Google-Smtp-Source: APXvYqzP0LwvTal7yo+imIWg6vXdKi/4l+CeZPZLwf5Jhf0C7sMyFUpppOjQ6tRDPHx0XWC7NzRAaw== X-Received: by 2002:a2e:4704:: with SMTP id u4mr15232561lja.203.1569929068899; Tue, 01 Oct 2019 04:24:28 -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 3sm3853894ljs.20.2019.10.01.04.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 04:24:27 -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 v9 2/8] Documentation: v4l2_ctrl_new_std_compound Date: Tue, 1 Oct 2019 13:24:15 +0200 Message-Id: <20191001112421.2778-3-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191001112421.2778-1-ribalda@kernel.org> References: <20191001112421.2778-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 Tue Oct 1 11:24:16 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: 11168503 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 C99DA13BD for ; Tue, 1 Oct 2019 11:24:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A01F321D71 for ; Tue, 1 Oct 2019 11:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569929099; bh=gYx5qO7De33HryEb5Q/vL4u7pggJWB0T3CFMj3AqQQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BBzGo2xElcMPS2Yb0dPuLkhNXl/xSGGATqwwgMLh917NY1/7lHuBvd10wAUdNqwmx t4gf3OB0pw7ToBoxr0mkTjJF+BqPr5rT4MX/yBhZt52jEEF0olVNqMGnh7QbWuOlc4 5PqTQx/dwlw5XuWIKPE+g6QtULYlPDAOI+1Oc4aM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732045AbfJALYd (ORCPT ); Tue, 1 Oct 2019 07:24:33 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42445 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731083AbfJALYc (ORCPT ); Tue, 1 Oct 2019 07:24:32 -0400 Received: by mail-lj1-f196.google.com with SMTP id y23so12898907lje.9; Tue, 01 Oct 2019 04:24:31 -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=oitGYrLz+M7x37417nx+E0ZUEysZsMYgL9DwRrCYv3c=; b=JUz+aEsASLJfqKdUs6qXteGAKTJjpgGPgH3I6A33JEpNphHrRHjDphixhKFrLH2YfX vkA1TVEKeYDgSvRVxdhp40L05Yq7Ti7qSDeuqxXQyyhVlFxSHeXf20Pwj/OwPoXQtPoY gwjFRkuM5VjRPLP+Cm52j9IZWq4TUIh9WxdFTHMTO8gvKm90QlcNuaEjAunP33Ut2q2q ngeVhjI7vnqEfmvhej7g5bViOWFfoQNvSqZqzac7DXnFg8ba781HImU/qaZAwGYBMNE6 qeaf44Uu+mMr0XpK1RaWJXdnQbiddIwCURunNLaOZxykYhjJuzQ82F3xn3jzW9qFQkyU 1sZw== X-Gm-Message-State: APjAAAW5Ee6F8zPTM/wKZua9kPOCbtXtRrVGlSM4T7isbKNfpVxSn5Dg dcNXGA2ZIROlcYwgF4FZmJQ= X-Google-Smtp-Source: APXvYqyUOqInyfuVS08BNKRO6qoar/NMuE9CrRTA7c/NVUZeaI1dXscKWvrqaxvbVjdI/rFHb3Yksw== X-Received: by 2002:a2e:2d5:: with SMTP id y82mr16212524lje.230.1569929070704; Tue, 01 Oct 2019 04:24:30 -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 3sm3853894ljs.20.2019.10.01.04.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 04:24:29 -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 v9 3/8] media: add V4L2_CTRL_TYPE_AREA control type Date: Tue, 1 Oct 2019 13:24:16 +0200 Message-Id: <20191001112421.2778-4-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191001112421.2778-1-ribalda@kernel.org> References: <20191001112421.2778-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..b9a46f536406 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1678,6 +1678,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; void *p = ptr.p + idx * ctrl->elem_size; + struct v4l2_area *area; switch ((u32)ctrl->type) { case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: @@ -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); + memcpy(ctrl->p_new.p_area, area, sizeof(*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 Tue Oct 1 11:24:17 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: 11168493 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 9132F1709 for ; Tue, 1 Oct 2019 11:24:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6FC3321D79 for ; Tue, 1 Oct 2019 11:24:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569929077; bh=qNrcMr/8SbxkQYJjYnj/mVx36Bmtf1e3S6sEoTqgqMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=l90lW9dx01zU++zF6ApQnF14197F+ZqzU3FVm1eeuGCWUF0+uaGk15H/aeC6BZDbZ z/539Bo5WLvc3RKvGeXmj+ZyPPZkNIJBusRUtoihPoL+TOStP3skO2GY79pu7hcW8S QCLq0L5AnTS4hWYY96Trmd1+HJrY6dKwxnHUol2c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732160AbfJALYf (ORCPT ); Tue, 1 Oct 2019 07:24:35 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43249 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732034AbfJALYf (ORCPT ); Tue, 1 Oct 2019 07:24:35 -0400 Received: by mail-lf1-f65.google.com with SMTP id u3so9563118lfl.10; Tue, 01 Oct 2019 04:24:33 -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=r+F0Qdwp5fdvEXlBMioZZEu81T91BgZQd+z2sCuT/bacnRrRN19YhXalsHZZYaho8B qnx8pFCPJ6OZGPZBivK5lljNHiF4Upswadgn/a85wCZKNANOUuULUoSIVki46PlkPrVl iSamxjeDXeIVfh5yoM6wF6kYXoskkwbHW/2BNVapvIc/R43fse9zHXsIFy1fVHgUWjVr CAL03U4Qd/0oKw6hUjg/b6tJ/2dPXfALymY0TWwHXEZf8PNeSr++xkZwzs0e0hnzzAGq AL/QtRt+k/fp9XIcAnD9NZJgfLa7nUOOCj57ROJgtiPp9XVl/fkwkdB0yhQ7AFPDNSIj C/tQ== X-Gm-Message-State: APjAAAUR+R+cvDc6pSKNLJmK/YTO/BjTcbNUGBjNftVEmCtmHBT8hi1P 3KlBvwnrbCIJMTrd55/vXjA= X-Google-Smtp-Source: APXvYqxc6S0IaCmirBB5H4KQ2LvQnvSMn/jfM8x+RS6F8Hv5i2ejRs+M69AKtV02a7fPk1cxl48ctA== X-Received: by 2002:ac2:50c5:: with SMTP id h5mr14451515lfm.105.1569929072691; Tue, 01 Oct 2019 04:24:32 -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 3sm3853894ljs.20.2019.10.01.04.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 04:24:30 -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 v9 4/8] Documentation: media: Document V4L2_CTRL_TYPE_AREA Date: Tue, 1 Oct 2019 13:24:17 +0200 Message-Id: <20191001112421.2778-5-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191001112421.2778-1-ribalda@kernel.org> References: <20191001112421.2778-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 Tue Oct 1 11:24:18 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: 11168501 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 7AED413BD for ; Tue, 1 Oct 2019 11:24:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5977321924 for ; Tue, 1 Oct 2019 11:24:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569929096; bh=qMDToGj5VuZFZgy2BFaEjk6oXNuX2W7PgD53NHdQzdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gD5bs6K2dSPsmgbed4gP/KGnrNZ1BzVu8DOJMEKGG6w0haFu3dewxSxXtgBrWH7AS Dekr1ZjUV3pj012Cd9Aiiwxa/d/opF2HjWgWr6LBwIIkw9ALemnDFGRvhju7OOfwlw 5a4eclcw6kFzBjCFiRxGR8Kn6atHXt9IGt8oUbgY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732267AbfJALYi (ORCPT ); Tue, 1 Oct 2019 07:24:38 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37160 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731083AbfJALYg (ORCPT ); Tue, 1 Oct 2019 07:24:36 -0400 Received: by mail-lf1-f66.google.com with SMTP id w67so9564442lff.4; Tue, 01 Oct 2019 04:24:35 -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=Ktnq7xkHoJ1ZWnUKlDDdlNDPJ4T3Et1IvqzPSJZiEIM=; b=SQDYcU03lc94lf/u0gZ4AaSB9Ya28ltup62esWcYb/gvEeWLIpT/aTWmU1E1kKx/yh 7uxNG796QW4+9RYqNhd/GnmhalrQwA6v/7rL3hMIZ3Ku7vJ0JkJxvIVf2AW1zVfHol1X nV8z/83xwJiVS9yr/FcZOX9wcXvDPDcC0lbZlBdVryfmMjMPwEVEePifuc20Jzo4Gt91 so4ckOJ7Lco2r5pMcpp6MKUwVP5RBAXPz7NlNEFEYah1uCAEhqCmJq0lPF+RVSFsPAdW kRgvRkWhjcocIVN8svwjV1qico6iML3t2wtLt9J1p06uwZEcZSiABcwqN9aQ5MzYg2+I VNpg== X-Gm-Message-State: APjAAAVd9/PRPVqoTEEq2di2ApKpjUqScV+z3UOe4OkRk8BAjDoQ1bYt lyfa6iuEQ36wdX5LZwvR0Pw= X-Google-Smtp-Source: APXvYqzgl3LEcM43wWSK+ZlrpXzboRC5f4P66NW1PduPSP+AArCBfWoLtFvvShJXMrTrNtnNUCc1Ww== X-Received: by 2002:a19:810:: with SMTP id 16mr14302480lfi.110.1569929074241; Tue, 01 Oct 2019 04:24:34 -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 3sm3853894ljs.20.2019.10.01.04.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 04:24:32 -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 v9 5/8] media: add V4L2_CID_UNIT_CELL_SIZE control Date: Tue, 1 Oct 2019 13:24:18 +0200 Message-Id: <20191001112421.2778-6-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191001112421.2778-1-ribalda@kernel.org> References: <20191001112421.2778-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 b9a46f536406..f626f9983408 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 Tue Oct 1 11:24:19 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: 11168499 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 CD1D01709 for ; Tue, 1 Oct 2019 11:24:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A488A21D71 for ; Tue, 1 Oct 2019 11:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569929094; bh=/khlmvyIF7dnAYuyK6pcvtYPvxWsRxXD/3cTxwU/l58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pv7MlL9poUJvLxJO4nLzhrNludHgbgwy7ev24K6IeH3ID50PWYK/b8CmfRCG6qm1g DovW+9uwIisSV9NBKx0yRHleTaLJL32VkLGOy2dBe4s3tRavQgehlAxptSbIW9b/dO a458bzQif2ZuYObEmc1AW/SDNTPk7IaVecpLUdFg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732286AbfJALYi (ORCPT ); Tue, 1 Oct 2019 07:24:38 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:42829 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732215AbfJALYi (ORCPT ); Tue, 1 Oct 2019 07:24:38 -0400 Received: by mail-lf1-f66.google.com with SMTP id c195so9564739lfg.9; Tue, 01 Oct 2019 04:24:36 -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=6p4YV1zw75GWQJusYr45Q284S6H3/JdTSqt0G1D+1gg=; b=EJSX0n34DsU6oRkDnNORzhh0VjPNCy7NzeaFpaD7tArU4Nt7QtNsaCTpQM7+J/mHfA LvygwPtYJr6JpKeODL14o+ehp+5CZU+qDjUlVGJwhgugVUZ/ZaOMbj6LJZxThMzRNZWX XYY0PqNP2bjcrVwFyRIdfLQRz8mmohxpqWIBcr2jzEh7BpTQiQUM+N5KH/3Gc2FJkd8W T/bRSdSnadAPwEDCtjvDAw2ieU20DOHSqFFTxp/a4oomwLw1c87btjBmxaCP1ZvWbsNX xumihsF7xQkpONbQRKK9G76sW4cdpqFrhKqTEjGGhujEdEsVEF/eJfxbYrmzz7wKXsLQ 59hw== X-Gm-Message-State: APjAAAVlvXFBiU+I0Hp/c77yhk3PMmbAsBB0ygchmnnxozouyb0THvsB jBVgXRJD1TqFKeU9T6+Ry9c= X-Google-Smtp-Source: APXvYqxuuHGmYJw9Go+LXkMmgo5Wf6LKyGqIajb3dXZTvMvU2ZME6oKYjkhfQA/AxFrWBMKVeiLhrg== X-Received: by 2002:ac2:4196:: with SMTP id z22mr5218720lfh.54.1569929076043; Tue, 01 Oct 2019 04:24:36 -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 3sm3853894ljs.20.2019.10.01.04.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 04:24:34 -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 v9 6/8] Documentation: media: Describe V4L2_CID_UNIT_CELL_SIZE Date: Tue, 1 Oct 2019 13:24:19 +0200 Message-Id: <20191001112421.2778-7-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191001112421.2778-1-ribalda@kernel.org> References: <20191001112421.2778-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..033672dcb43d 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 nanometres. The struct + :c:type:`v4l2_area` provides the width and the height in separated + 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 sensors/cameras. From patchwork Tue Oct 1 11:24:20 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: 11168497 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 E8AC91709 for ; Tue, 1 Oct 2019 11:24:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C76C621D71 for ; Tue, 1 Oct 2019 11:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569929093; bh=cur87b/shjG3V7yxSuCJDxCpWW/l1Ebp1gsAdE68BQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BCGM1ZHuq5BFSffyw6o4OaCaep2vfc6kZnbIj1bjoGIApdX9jo7rhVFtc22k8V0H2 l9Jh+64diV63xmoSfYJMaZ1xXFJWqbY9agJNeOQfX7BUNHQNmNR2Ffn+7IomkDEgkV YCkIXozHA+CI5LrnCs58lAsWnfjUu65NVBZ34B9E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732396AbfJALYt (ORCPT ); Tue, 1 Oct 2019 07:24:49 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:43258 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732298AbfJALYk (ORCPT ); Tue, 1 Oct 2019 07:24:40 -0400 Received: by mail-lf1-f68.google.com with SMTP id u3so9563280lfl.10; Tue, 01 Oct 2019 04:24:38 -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=k/QNAeiB1uteASJ99iJIBlS83CywKDXvhSpbUiVCPnQ=; b=CtKYI3ZSH+tGpLHlY3DYT8yqdl7H+g7Fqf6dbeMSdtLT3qq9MWDTXcNBB0atyCzoy9 q0gTmp0QO/I+KgX87ocq97v5+1N7wBgYvYsePpFH74BNrv9uphBOb/OEMg9zucVwi0Jd 3eoNDZghUc8twJdjnCF5FrYCCDd/tbQrgq4Z2g/TDYFOaeYcIs/97pBi9ApDaxbElcHS xZu/oevVwtMKRWRPRC9vu4oC1s3RugZ15wZty074nZScv9ToeibQtedboMJojvN38f4v iTzA2XyzBd4asUZh2kXnWkTDB5F1wdSZ40/P2iAhjKaG6ODY9pjpOwJobwgXXsVaIZ7M b9Jg== X-Gm-Message-State: APjAAAWdvVG0nDpo8qz9u4WWvay2UYoK/A+q0gdiS3aJsOo3zQFQ46pu vmcO5zabvo2X+h9IkDVu9Hs= X-Google-Smtp-Source: APXvYqwp/KteKI5hiLXC1BfiX20hhffjdr+xZD9L09iHmlSZaJ4dNDFBLVH+DszLFFMkp7hOZn/E7Q== X-Received: by 2002:ac2:4adb:: with SMTP id m27mr14475596lfp.1.1569929077345; Tue, 01 Oct 2019 04:24:37 -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 3sm3853894ljs.20.2019.10.01.04.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 04:24:36 -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 v9 7/8] media: v4l2-ctrl: Add new helper v4l2_ctrl_ptr_create Date: Tue, 1 Oct 2019 13:24:20 +0200 Message-Id: <20191001112421.2778-8-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191001112421.2778-1-ribalda@kernel.org> References: <20191001112421.2778-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..51d74fa7c7e2 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 Tue Oct 1 11:24:21 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: 11168495 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 1C26D13BD for ; Tue, 1 Oct 2019 11:24:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EFF9021924 for ; Tue, 1 Oct 2019 11:24:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569929083; bh=pK20S9w9jPx4oDEOoBNNwlgSdse6dCqOTIYN8MTHsOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=O0omGqDrlgSL8900ugw3rpsvhRMpCW0fWn4R7SDQzqejWzHSnB8lVvQvgsqOJGWzV Hs6fwQzw7XGIdG/K7d3uJNMxtVRK2FF7xWG99W6AAm6c3QFnePFt7NywFTvi4H0LXE irMOjTf7w06yjo2uOLMqFBl3X274b5n2yPbjvTRI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732346AbfJALYl (ORCPT ); Tue, 1 Oct 2019 07:24:41 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:41806 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732303AbfJALYl (ORCPT ); Tue, 1 Oct 2019 07:24:41 -0400 Received: by mail-lf1-f67.google.com with SMTP id r2so9544554lfn.8; Tue, 01 Oct 2019 04:24:39 -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=tcXxZ7mUE0A1PytGsA9lB1vgzJCr3yKYBOgGOYburmc6WX2ASQN8SskUB4XTwouldG ETsvsX2HNWCF0hpC2H3lBdaE/JfKIrwCETE+ROCICn6sgNvtW0yDklo5ClQq9JEwdXX9 puAYycFyVa2lnqNIW8lMzDQsp7i2A3YaYdL2n9DBfPgeQK3DPbscJiET3RsjULYcNrjh g1bCb0h/I6wf5nIcFWqGk5ACnvIGVQvq7dSlO/dS1LY+2X/cRC3iaGai2HVzJoayg4wL xPrMiG7QIUwiGcHdr6sQth7YhJd73iQfKPwgnstaIQ/UGayBsLFxJuW0LlQYu3vgXrKi +L9Q== X-Gm-Message-State: APjAAAVuKKdEcbApmQG5GqSGNg1j0Kq/FTj8T3oN1bPjBxTs+kJC2sEu HvQHvWYuey6jKB+jhYKLiRM= X-Google-Smtp-Source: APXvYqxuRI13v85jwQ2c1377ih1pB77hgw7oauFXbhh4t6dcq/+Ubf2Bz5eZgLNkvg/mSDtvqXzdGw== X-Received: by 2002:a05:6512:251:: with SMTP id b17mr15426465lfo.35.1569929078781; Tue, 01 Oct 2019 04:24:38 -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 3sm3853894ljs.20.2019.10.01.04.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 04:24:37 -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 v9 8/8] media: imx214: Add new control with V4L2_CID_UNIT_CELL_SIZE Date: Tue, 1 Oct 2019 13:24:21 +0200 Message-Id: <20191001112421.2778-9-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191001112421.2778-1-ribalda@kernel.org> References: <20191001112421.2778-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",