From patchwork Mon Sep 30 10: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: 11166345 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 B4E6813BD for ; Mon, 30 Sep 2019 10:07:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A1CD21920 for ; Mon, 30 Sep 2019 10:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569838041; bh=PeppCgHLwlt7g0XaxiQaOikDA7Ffj7hltJB4xHtjfmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=x/uNap+XtynxDhvBLYe85tSQxlJ7/ESJjb1x1AxtUPrAhEko9V4yaQ1IyRVdUXj8/ jKooN/H2z39YiSZflt61+7p58JJgN1BQXQjH/R93vu2T8hyLqJm2ym6pAREgIvDkBf qY8iBIrkTgBnfglcSM6YuQSZB3Z/Zg8y/1O5pTYY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730541AbfI3KGr (ORCPT ); Mon, 30 Sep 2019 06:06:47 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:46255 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbfI3KGr (ORCPT ); Mon, 30 Sep 2019 06:06:47 -0400 Received: by mail-lj1-f196.google.com with SMTP id d1so8758851ljl.13; Mon, 30 Sep 2019 03: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=mdjrew/YOfxvbSjo9g2n1pZ81Dy63rnFiLTfk2eLY1c=; b=GBPDmpH8bl0E5tf48EyQIMns1mab6COK8lk1xX7XluxXYL3Lapc1La1o097b/Hkk0y j3dalXuPBOJaxBD7+oxn9uDNIP9ECXuqMgtruHL7gWbuUn3/Hp69qJ2Z2jl8wUN+FPPu vlLsX5f0NzlswQkNF06IWKWuOmTc8lUjrYeWyiP7Hte4chTr3Ik/jr2vLv1SPpSjLc8V RVvfEtT7K/NB6BninV1LkyBBefa5VaAB+WLCoqzQpBTx7ruh5+fbKBZZDw+WQVcqzSQG OzjL++RsflU2mXaMgz1MeUW6PQv13pKsoROOHR+G6L7ArN4mGo4GiFol5L7qcYlCVe6x wS2w== X-Gm-Message-State: APjAAAVrnAm8dfrhnIt/uR7gq/ofn0lVb+qRSZ7iC6qVRu554LSA3oP3 lA/IK1NZNhjl6uYQNyisyDg= X-Google-Smtp-Source: APXvYqwdYeGQjM5yrogvELofjq2hhb0iAHvPKMpdPG2ZqOG1d19qx5J0xuLYa2Cc422nuy4kqwEWhw== X-Received: by 2002:a2e:8054:: with SMTP id p20mr11727512ljg.36.1569838002654; Mon, 30 Sep 2019 03: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 z72sm3091580ljb.98.2019.09.30.03.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 03: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 v7 1/8] media: v4l2-core: Implement v4l2_ctrl_new_std_compound Date: Mon, 30 Sep 2019 12:06:29 +0200 Message-Id: <20190930100636.18318-2-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190930100636.18318-1-ribalda@kernel.org> References: <20190930100636.18318-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 Sep 30 10: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: 11166339 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 CB5E213B1 for ; Mon, 30 Sep 2019 10:07:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A8BE621920 for ; Mon, 30 Sep 2019 10:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569838031; bh=zPoc85WEtDPb/QzHX6JINlNAeJRn86+iWB+uo6ST3Wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mTLBjJd79pUxjmsrM5o72R63Fxl92shVyInySY/WXuz7whxzMk7/zPSmKHqRUrMHi 8G0oM2dENMW9ptLnhrrmfCuxtV7EDdhThVfB3ZpqnOIdQocVkdxT/5h963FSWhwgiZ tCP+qE/DBB5ArlO5MartWXaF8oziar9u/KdMD9hs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730605AbfI3KGs (ORCPT ); Mon, 30 Sep 2019 06:06:48 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38227 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730485AbfI3KGr (ORCPT ); Mon, 30 Sep 2019 06:06:47 -0400 Received: by mail-lj1-f193.google.com with SMTP id b20so8795211ljj.5; Mon, 30 Sep 2019 03:06:44 -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=mt9PJojqcUM4cqVHa79FQdY7MJpX4LpkJTQluT5lFmg=; b=dlvPJMv3ufK7dNUBgrYCIQ9lvRxWi0miO9Lsf4e4PMS0JyKspenBiS7qAMQwbXndx4 uwCOSFvWBNGqLKVAaQ2ZhH4UsAKP7xmPFORlTNYOCR7CBq95MysTcQjBpvi60g4fYlDz 10A9hSt3X5hp1qophdLTFGJGkh4LQJR+nFkpdYOE6gSzv5l31BbcRKsHIphhI8d4RlOc rcC+7XXNBTDpAVybrme3E0C3NFD/j0A+R433r2oT7/vDU4gqVKJfkD2XbZnC0kZY5qpf w35wcMJeA2MA++Nuj/Ci/Y0DyUOTPmBJDUTLMs3cp5ULoBMpeuY6VaxjetVeBjDyKVg8 jp5A== X-Gm-Message-State: APjAAAXyohygPK0Ic0GVgvofM0SJ+shNR+NeeT7UH92YaCy6OgcrV06t UONqfcQMSKXXtkkyUJ8daTk= X-Google-Smtp-Source: APXvYqx8kYRfIeqLb+n4G9xETjEBllXw6uWSapy/kW5H9ck7P7s3SkYk1UPU1wy08xlI/sMcUDozEg== X-Received: by 2002:a2e:654a:: with SMTP id z71mr11743727ljb.37.1569838003980; Mon, 30 Sep 2019 03:06:43 -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 z72sm3091580ljb.98.2019.09.30.03.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 03:06:42 -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 v7 2/8] Documentation: v4l2_ctrl_new_std_compound Date: Mon, 30 Sep 2019 12:06:30 +0200 Message-Id: <20190930100636.18318-3-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190930100636.18318-1-ribalda@kernel.org> References: <20190930100636.18318-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 Sep 30 10: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: 11166341 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 C0ED613B1 for ; Mon, 30 Sep 2019 10:07:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97DF521D71 for ; Mon, 30 Sep 2019 10:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569838035; bh=68QKLdXhy8lytMX5DSoBlN+q1SOZ8vylblFmhTRe4hE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Mtw8wO3Nu4AumleL2nrQFPwsv+EwntUqXL8RZmoH+D11cOQVRlipmZOzfm6oPHyTN P9j9TjpeLlkZgrzxNnDk98w6h9qKHmhaI2PidwhIoAvN423b94lS6/qQ9LkT5kf3cq D3c/jRDtb2RJ6PD4ec9vTTKqdu4KuhclWabe67Qw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730703AbfI3KHL (ORCPT ); Mon, 30 Sep 2019 06:07:11 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34992 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730455AbfI3KGs (ORCPT ); Mon, 30 Sep 2019 06:06:48 -0400 Received: by mail-lj1-f193.google.com with SMTP id m7so8813903lji.2; Mon, 30 Sep 2019 03:06:46 -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=wDCoIm/OerPX0IV20jJXfyDcK7NqvyTie8mVd32s0jk=; b=MyfVu4Nvg3fkZhqrshJfSniO4BZHmaGT//eUnQf1dDRrFttGZuwe/Eilg1zk9i4DLg gopCefyWHNxpqU+vxIRHKlrP6W0X6LOttAW4umKIBxQ39pCz/4cbQaA6U5sGT85CQeIO Bsj/rkjwr0d1qhCCFvVZ1Z14E8YIa2vhQ6nJYWgh+DFMbeMXFQf1IV1EhmzLHFxD61oU 0CqbynVY4ob89K4h3vPR6iqBPVc1ZA8wMa05ovHd6cInstoZp+utgYbc3QPKb2YM5LXc 8z+CEwxoAsGvM9SqXjT0M2Jez4yQVz3rgjVWj6buqEB1Eydu2efRQ9W0iDgj7GCzEn5i HHjQ== X-Gm-Message-State: APjAAAXUn0KcCtUII/lzp8+6CQHPX5yX5cMKQjS1Ivtt3jrKH6+L3DLg f9wvd/nYWLTRWtRiPYjivUA= X-Google-Smtp-Source: APXvYqxAiSzw+rn4EYLd/jH74NAk/Vp1/kUld2GXHmjqGbE/7iD8DZtPf9o/SZHTM2PApQ+8wDG3/A== X-Received: by 2002:a2e:9610:: with SMTP id v16mr11868630ljh.21.1569838005340; Mon, 30 Sep 2019 03:06:45 -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 z72sm3091580ljb.98.2019.09.30.03.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 03: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 , Ricardo Ribalda Delgado Subject: [PATCH v7 3/8] media: add V4L2_CTRL_TYPE_AREA control type Date: Mon, 30 Sep 2019 12:06:31 +0200 Message-Id: <20190930100636.18318-4-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190930100636.18318-1-ribalda@kernel.org> References: <20190930100636.18318-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 Mon Sep 30 10: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: 11166343 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 E5C0413BD for ; Mon, 30 Sep 2019 10:07:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C37EF2190F for ; Mon, 30 Sep 2019 10:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569838040; bh=qNrcMr/8SbxkQYJjYnj/mVx36Bmtf1e3S6sEoTqgqMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=udddVKm9xAxTaPEupft7+DbP0dRPVuznonRyF7kL967tLj9EAXCzNMmUlqEVNNv+O d35eRjJ626maIlgOLGNzX0YB2i8rxzeX7+RgsmW5eXObup9NoAZeuDKaIjZTn3qOR3 9Z19iTO6q6DgOvMKUiXmq2RIuPkX73a4d5EW11u8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730716AbfI3KHQ (ORCPT ); Mon, 30 Sep 2019 06:07:16 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:37601 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730487AbfI3KGs (ORCPT ); Mon, 30 Sep 2019 06:06:48 -0400 Received: by mail-lj1-f196.google.com with SMTP id l21so8803160lje.4; Mon, 30 Sep 2019 03: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=KOQK/iTDEM2OOwuKD12eKM8a+YD1YCYg9jIBY8YMxOA=; b=spHvLnMMnX0VkxN40/72gF9rW+YRioRaS1PVsyszTLHuGLHFMP0IlRIECcWxvyKBMg m+pV4T29WXUMzgfVqChut14+TY/qhDk94XErHxf7Yu3fWzNTCT3Jmib5A/L+ruVLwJ4x DCeXk97GoxI0XaUE4wHJNvGfK46YSeqaOlevWqaJke97brSs39C0/YLY5RhvP2XKsRIx +NRt7Wp9Un1LWwOCYAMuEFmu7dwEpNtHe/kVORYKZ0JZp81QCQzFr/6bHcgWtM1IT9rX Y8+Zseyh3fJ7iY95NtAKmshJ+MrhokWpqTJAgwGP+wPgoeyc/j0xc8eyGeVDKPiiG5ob Xo1w== X-Gm-Message-State: APjAAAXTbipKQ3POzu7VA8iucoFQ82X56S1Xxu3xO4oD+o7cNjksO58f hMp5n81a9Zq5J2TYINJ2UnU= X-Google-Smtp-Source: APXvYqybt31i8zFAslAiL2G4nrSBLQqDRC8Mselga5NNQP7J6ahsWpWA0p4qWgfrbTNJ6Oo3Yn9TdA== X-Received: by 2002:a2e:63da:: with SMTP id s87mr11231250lje.79.1569838006572; Mon, 30 Sep 2019 03: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 z72sm3091580ljb.98.2019.09.30.03.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 03:06:45 -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 v7 4/8] Documentation: media: Document V4L2_CTRL_TYPE_AREA Date: Mon, 30 Sep 2019 12:06:32 +0200 Message-Id: <20190930100636.18318-5-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190930100636.18318-1-ribalda@kernel.org> References: <20190930100636.18318-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 Sep 30 10: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: 11166331 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 76E8213B1 for ; Mon, 30 Sep 2019 10:06:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 557D821855 for ; Mon, 30 Sep 2019 10:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569838012; bh=qMDToGj5VuZFZgy2BFaEjk6oXNuX2W7PgD53NHdQzdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mQ9diz7jsbuhdW9QzYj9+rWgEeNh/b/bTON8/1DSBcfckZiJb80U/iZCTHGkUAalR JL99da/0ziYKXodGu5WQd2gKHPVxowfNcooc7CieY/9lA+iMwmN1GqiZp5m939LAYJ FM+ur+ChKsvhKqG9ZCI3NWudPGnYDCFerlB5HVeg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730639AbfI3KGu (ORCPT ); Mon, 30 Sep 2019 06:06:50 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:43129 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbfI3KGu (ORCPT ); Mon, 30 Sep 2019 06:06:50 -0400 Received: by mail-lj1-f195.google.com with SMTP id n14so8758691ljj.10; Mon, 30 Sep 2019 03: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=Ktnq7xkHoJ1ZWnUKlDDdlNDPJ4T3Et1IvqzPSJZiEIM=; b=NaJHW3d7iLAQh+cPcW+r7jEPEZKgugQ3x0IwgB1Sg4ebZ3f/Z305H4hT/TIaUe59Hn 3AhHzzmNo1l1P76nbzy23lLd4EynxlXORkaZkTv6jeEF66Q9sp5t3ep9ttPwcuKq2HuS wGL1pI2jcFRo3ZSvw6ba0buHj33uVqtlocVuXF5jUMl5KShx0z0CmxHBOwz3Bzgcvims o/TGHZd3XGAroelqAqM2wKs4cjlxGfVARwfq5ljxSxDomyDiCsS/mnBg11V6ExUMG93j FjMguHQ2sqaCqg/sWS18ieGySw0u0tMy1Tx7tSoE5zoQiJaIXO1+GphkIHX7IuYjgekL 1f1Q== X-Gm-Message-State: APjAAAVXt5TPhqHd8fYGg48NR053AwnS2UUKYM0lGhvzBx+fytuaF6FM oPlvYZeB5jIZbyCRsTIDY7c= X-Google-Smtp-Source: APXvYqx5er287eVPmhJgbMadOEazef529ZrcpOhPYb5YPbBtXjwF8CgAuH4l3VyRjUClNZ+Ppbr2TQ== X-Received: by 2002:a2e:9943:: with SMTP id r3mr11885352ljj.171.1569838007896; Mon, 30 Sep 2019 03: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 z72sm3091580ljb.98.2019.09.30.03.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 03: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 v7 5/8] media: add V4L2_CID_UNIT_CELL_SIZE control Date: Mon, 30 Sep 2019 12:06:33 +0200 Message-Id: <20190930100636.18318-6-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190930100636.18318-1-ribalda@kernel.org> References: <20190930100636.18318-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 Mon Sep 30 10: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: 11166333 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 DE42413B1 for ; Mon, 30 Sep 2019 10:06:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCBB421A4C for ; Mon, 30 Sep 2019 10:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569838015; bh=/khlmvyIF7dnAYuyK6pcvtYPvxWsRxXD/3cTxwU/l58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=I2ohPOxv41Xw+zQdiDNS9QegQMkN9v6V5aPI1L9Y/l7uqPf61tzWhOEK7NHzBWFXL uEwSS3AtoB6FF0zlnDi0Fg65GYeNdy7BVxjSLAJtix9neLZ8s7nbQVu8MjhuCDzbzg ZB+Uz4fD5cUIIJSHhvQqHz75oeFq3c9RfFuqtv/4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730548AbfI3KGy (ORCPT ); Mon, 30 Sep 2019 06:06:54 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:44099 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730646AbfI3KGx (ORCPT ); Mon, 30 Sep 2019 06:06:53 -0400 Received: by mail-lf1-f67.google.com with SMTP id q11so6537100lfc.11; Mon, 30 Sep 2019 03: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=6p4YV1zw75GWQJusYr45Q284S6H3/JdTSqt0G1D+1gg=; b=BjonJ9ILw6RRwjTiFrMIaj31RuzaZ7miY3RaFcljK9HcLoJvFct7uD95kaaQExRYAI SjGl2MjoY78TR7LvDTHkHvHn+H14nTWCAovboJGNcrWyTeVRrj65OqZUG0eMSF20BgCC xbAy5yPoLrZuPr8GiyoMsoxwR54U3zSBk/0BEUrlxCpnKSp/kJ7xRyS/ukxay4UPoUlK OyE2YCkQer8X1/doOMTVIW/Bt8oXE8r7gAV+ZwtY0co51uQ/NY4CSTibXbDGxxeyI8qH i2dVe8xKrIgi/kFrZtqbghCCscM7Kj44sFA2piMkL/Rap53zC6x3igXOJQzTft1WWYUv s/Hw== X-Gm-Message-State: APjAAAUj9xli6OB72l+227CwJwdBTbn9/g2oq76XQehB6onNSOCjL9k3 OWoe7VXbTTA7Oh9PovyYa8g= X-Google-Smtp-Source: APXvYqw8zda0A2oGUqGRrQwHDEkBvqQbk1BCAQE49t7Bs4nPMb0eS+4MQGxGU8w7NDRgi4KJJG/5+g== X-Received: by 2002:ac2:4c2b:: with SMTP id u11mr10400224lfq.179.1569838009497; Mon, 30 Sep 2019 03: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 z72sm3091580ljb.98.2019.09.30.03.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 03: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 v7 6/8] Documentation: media: Describe V4L2_CID_UNIT_CELL_SIZE Date: Mon, 30 Sep 2019 12:06:34 +0200 Message-Id: <20190930100636.18318-7-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190930100636.18318-1-ribalda@kernel.org> References: <20190930100636.18318-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 Mon Sep 30 10: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: 11166335 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 95BFE13BD for ; Mon, 30 Sep 2019 10:07:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7444521920 for ; Mon, 30 Sep 2019 10:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569838027; bh=F7PU0XTzulJyYozp4p3TKjIBYzu0jmLbK1kiwEtvVSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vh30ax749pq6y4ih02uzcPNpLwLY8//vTW1lJz0xaZh9h4oJgJ5g2V9vcALRwpKkt 4cwqo++dwbg3Z2Hvalt/JgJWlaE5wrCS+RdiirLDpw5tFQOfxHPq6Cr/i2Chg6qYi4 xhf3f6a/82IyZWF5mYqm0czysnwTGqLy1Saas9GQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730679AbfI3KHA (ORCPT ); Mon, 30 Sep 2019 06:07:00 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:37485 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730654AbfI3KGx (ORCPT ); Mon, 30 Sep 2019 06:06:53 -0400 Received: by mail-lf1-f68.google.com with SMTP id w67so6551997lff.4; Mon, 30 Sep 2019 03: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=u6PH07eWhP9yLzHtDWmI6SB0uTSpZSpElPRT+7mhohA=; b=I5kSGWKl5uvi11jzWNbvyGAwY22JtnD+UbPNRDIcCvtQGB9cZvxMbgkVX0Nyff9Jb+ Ek5EFkxaMHktstBAxh5bC2reLysY4lHBIDiqAxzpWFrlwUMZraPrgPzxgLT6DlsYGBZw 3GP/9GJNUUwazWRBwOsgSnN+uFmjwFZhtFCunRwPs9fBL4HmUWuseKZyoz5Afo138pXT AmB6jEYL/8zFQvzXPY2SsJ74KQLAn/r5GAY6GGrw6GVOvE0cxP87jth32EsdGAMvraYQ x4HdY7BbXToMw0KAjbKOmF6I8JAOfkitXQi2pWnzATnhad4qfrSYHRTJfX4/70I9T2if GkyA== X-Gm-Message-State: APjAAAXJ9Ni6nbi3wvqKFXO8L0iFPGNo41rd0DDJV+xddSWsjUvMvVUg wJmdxOtEklrN5bwBLsOCFhg= X-Google-Smtp-Source: APXvYqypY2QkKQ5WMOWTdcrWUY3bxFzsaKGZx2iwIq/euM6byPcQHqviu/TZGZMEgyMVwcBTrGiMJg== X-Received: by 2002:ac2:5dd0:: with SMTP id x16mr11009575lfq.38.1569838011426; Mon, 30 Sep 2019 03:06:51 -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 z72sm3091580ljb.98.2019.09.30.03.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 03: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 , Hans Verkuil Subject: [PATCH v7 7/8] media: v4l2-ctrl: Add new helper v4l2_ctrl_ptr_from_void Date: Mon, 30 Sep 2019 12:06:35 +0200 Message-Id: <20190930100636.18318-8-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190930100636.18318-1-ribalda@kernel.org> References: <20190930100636.18318-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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index c42f164e2c9e..d69cfdffd41d 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -73,6 +73,17 @@ union v4l2_ctrl_ptr { void *p; }; +/** + * v4l2_ctrl_ptr() - 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_from_void(void *ptr) +{ + BUILD_BUG_ON(sizeof(union v4l2_ctrl_ptr) != sizeof(void *)); + return (union v4l2_ctrl_ptr) ptr; +} + /** * struct v4l2_ctrl_ops - The control operations that the driver has to provide. * From patchwork Mon Sep 30 10: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: 11166337 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 D1FBA15AB for ; Mon, 30 Sep 2019 10:07:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B1C8721927 for ; Mon, 30 Sep 2019 10:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569838027; bh=SdcLzt1NMV5HtC9jlXslHJgHvj8quEha2dL9Fzs+U+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xyldkDy2BPZzynuFbjQ63Gil1w+CS7l2/50i8Be4wV0XVLwRwz4EQmnxNAN+ZnD49 zptHkLmOCTYxtq9mhQIzlqNbB1JjwtgJrHdX3vlxJw9qBCb9Fdqsp/wck581WPV0bw /n+LGsU+KrDs14CoeC4h5ixPgFQX5iNWOre1LQos= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730672AbfI3KG7 (ORCPT ); Mon, 30 Sep 2019 06:06:59 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:41055 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbfI3KGy (ORCPT ); Mon, 30 Sep 2019 06:06:54 -0400 Received: by mail-lf1-f66.google.com with SMTP id r2so6535991lfn.8; Mon, 30 Sep 2019 03:06:53 -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=b2dEZ5VveeCRyXH+CovRffyZBiPh0RcTQuJCALACFyo=; b=USnb21lLGcxxi7sMxBUvqaT0mG2c6IZTH8m8YWUST4l8Y7Gch8wCwioZAFe/gCXF7R i4jX+8czmB4aVV5VezTeQrxCQOhmfnYqFFFswxOgxAdlAjrAovd+0VLKXa/JglLJh04d Tpn+J8sxMsu2ECN6fIp5fsT8kZv2F1ybjUSGUgTJGTY4WULtExhasUCra5cUZZRSSCOA llUZIpUngW7EVPJCc41gRA4nVnnCB+UpvMK25mJNrG+e9TL2NKe0Jkp3dAaVFYB8ziMa p/T1q8QHACKgn1YQFfeVNqV/EhAVks8P6PLW5QaJZmpFrNfNWZ6b/tHHhm6p5zR9aEn1 vbYQ== X-Gm-Message-State: APjAAAWoFp2q25xzMqJlZIwFHklD1k07mMBL941Jiy1eI4/kpNOxy76o uTyIkFuzsEaaXF8yklO0GyM= X-Google-Smtp-Source: APXvYqzGJJ+ZwN/HRp10IThFkho3TT0C0+ycqJo+yYCne7gcqlwwyGtmdZaN1zlJqWsj5tH/1O60Gg== X-Received: by 2002:a05:6512:75:: with SMTP id i21mr10789844lfo.95.1569838012486; Mon, 30 Sep 2019 03: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 z72sm3091580ljb.98.2019.09.30.03.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 03:06:51 -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 v7 8/8] media: imx214: Add new control with V4L2_CID_UNIT_CELL_SIZE Date: Mon, 30 Sep 2019 12:06:36 +0200 Message-Id: <20190930100636.18318-9-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190930100636.18318-1-ribalda@kernel.org> References: <20190930100636.18318-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..4d9879f60dfb 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_from_void((void *)&unit_size)); ret = imx214->ctrls.error; if (ret) { dev_err(&client->dev, "%s control init failed (%d)\n",