From patchwork Mon Nov 4 13:09: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: 11225779 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 151F7913 for ; Mon, 4 Nov 2019 13:09:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7B81222C1 for ; Mon, 4 Nov 2019 13:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572872998; bh=qET0go5fTgr+VAcDElsE61ngvrjcyMrCjUxKjlVEXPQ=; h=From:To:Cc:Subject:Date:List-ID:From; b=g59vd4CSKcWuxxM27mTcGM+m7yIO4S2YhjP2F09qlgozgdcV5leCQulBadn84ZhXl bRgLuNn7tmMAeXafvIe/UoPiLB278O84M0gw9fsK8nVqCy3vyoKHr72xL2d5duH9gs hECrOjlwWFQWRHxbB72qayRq0IIiJLP7kT0RygFM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729043AbfKDNJa (ORCPT ); Mon, 4 Nov 2019 08:09:30 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:45082 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727430AbfKDNJa (ORCPT ); Mon, 4 Nov 2019 08:09:30 -0500 Received: by mail-lj1-f195.google.com with SMTP id n21so3890632ljg.12; Mon, 04 Nov 2019 05:09:29 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=9P8rBv8FlOAdd5Kdu3vWsUKtcKK3jMnnUl9eTBCRCiQ=; b=RnTgQhOQ+YJWPEtNsSXE+8Rl3OSw/q1579PXm8Wt4uRGElZaQCa4T8fThPkXDozvau e+ZGVy3jFUQXMUF5OjkfrOI5/4fIKtSdvscuhkybPuMCNeL3ezbhO1uFoVLULiWpy8DX bVfE4nshiQJjp9TYhGn3rsTdiD3tNZRfIoOnvuoBB/Gouqqufat/Sm3ZejpLn7naGuoQ gj50wt1XwwHD+YnfQSkGW6YJTEHQ0X7iDYO3gr3VrJzeeqsiYg9zuNdyFtLgtuXWBytT sOWHqdWFIp0o0iAi+aXMRzl/5fgYhXYAIyc7VoSSsccUIBPu5H6KiAK4GpSzRT9FOEnt /XEg== X-Gm-Message-State: APjAAAX1TpA/NoKZUohJL3UoFN0TU+at09vXAqk4FWtOSwRKU6yQ1j1O BfbwzCoIjY1uNnr1Wkwbb4vtDJUn/qM= X-Google-Smtp-Source: APXvYqzcI44Lu+vcPgtgkIXtqYfzThKqoYRzsOByJ+efQrIZgoiFus2ESUgT0d0GIKWI+BjQT8VYbA== X-Received: by 2002:a2e:85c3:: with SMTP id h3mr5790400ljj.122.1572872968219; Mon, 04 Nov 2019 05:09:28 -0800 (PST) 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 q124sm985414ljq.93.2019.11.04.05.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 05:09:27 -0800 (PST) From: Ricardo Ribalda Delgado To: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v4 1/6] media: v4l2_ctrl: Add p_def to v4l2_ctrl_config Date: Mon, 4 Nov 2019 14:09:18 +0100 Message-Id: <20191104130923.22184-1-ribalda@kernel.org> X-Mailer: git-send-email 2.24.0.rc1 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This allows setting the default value on compound controls created via v4l2_ctrl_new_custom. Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/v4l2-core/v4l2-ctrls.c | 2 +- include/media/v4l2-ctrls.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index b4caf2d4d076..73d99c3561ce 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -2690,7 +2690,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, ptr_null, priv); + flags, qmenu, qmenu_int, cfg->p_def, priv); if (ctrl) ctrl->is_private = cfg->is_private; return ctrl; diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index e719d56fc024..78a97b10c89e 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -382,6 +382,7 @@ struct v4l2_ctrl_handler { * @max: The control's maximum value. * @step: The control's step value for non-menu controls. * @def: The control's default value. + * @p_def: The control's default value for compound controls. * @dims: The size of each dimension. * @elem_size: The size in bytes of the control. * @flags: The control's flags. @@ -410,6 +411,7 @@ struct v4l2_ctrl_config { s64 max; u64 step; s64 def; + union v4l2_ctrl_ptr p_def; u32 dims[V4L2_CTRL_MAX_DIMS]; u32 elem_size; u32 flags; From patchwork Mon Nov 4 13:09: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: 11225769 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 81EAB1515 for ; Mon, 4 Nov 2019 13:09:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 60C97222C1 for ; Mon, 4 Nov 2019 13:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572872974; bh=ZlvpnRLtbhTH6bL1jwzyKo1MZMsNDzVu4omY0MnxPvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZfF/OyTsJGc2H+HSGMV3qjczxlpiLREW0SOXiDerbV7AUhCxA7WTuzViLaVFRa//k PCrq9mXG2Bu0OaohO5WY/WcEcSoiKoPot1ftiEJ9GSyiv0fo69Stv2+wUQXvL8QTON u3NReT8kHgUgng03W4OnFcYZnhU/l4V0R/lKGMeU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729094AbfKDNJd (ORCPT ); Mon, 4 Nov 2019 08:09:33 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44992 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729089AbfKDNJc (ORCPT ); Mon, 4 Nov 2019 08:09:32 -0500 Received: by mail-lf1-f65.google.com with SMTP id v4so12190462lfd.11; Mon, 04 Nov 2019 05:09:31 -0800 (PST) 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=8kcIhL1Cm288cjerDWSwiT3z8kiQdheRmrevoTt/5WM=; b=NbT0jDzVjveQzXwDS1RpqYM/HFccFhB5BeRDnEXJSqEB+7Wm0UYdncTu3uxVZCZPJp 2L7Z4q8ye8yQlxyc1IhOmisqPyf2uJ+9wrH8zXxKotXFUcuvfAqFcHqfYxyynZGOmLjy /HNIt7XehK5dJo4B0UBNIaO8GdEZH6ejn59n2SVn6BK2NGIYsa2YWDefEhfqF6AB8eUf fySiXPTTRFPEWA1N7FqZ9TB3LIr6ihhCB20wTwHOD6d98APChPKkNLbBdOOOZegv47Ad 7zdK0GY2qHo6nUWGhtC0emAtQvh4q+1JZhchtxLG4ADhy6tW/UeqoDWYYcs8uRcTfGq2 jtMw== X-Gm-Message-State: APjAAAVt9k6aETOVmJwfAgX6XnmiJOmPbsv7SnERI4vF9Vk296ZLr9EG Z6eZA8FJuNX0KEYP1ol/oKzOyTi9Bac= X-Google-Smtp-Source: APXvYqxcRtuVs0OtY+hHr9NyWwTPx/Wd/rlX4fmZBhyGDxQBbqyePvHf4yQD5AVEK8qMKhIA2RzmFw== X-Received: by 2002:a19:4848:: with SMTP id v69mr16651712lfa.6.1572872970364; Mon, 04 Nov 2019 05:09:30 -0800 (PST) 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 q124sm985414ljq.93.2019.11.04.05.09.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 05:09:29 -0800 (PST) From: Ricardo Ribalda Delgado To: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v4 2/6] media: v4l2_ctrl: Add const pointer to ctrl_ptr Date: Mon, 4 Nov 2019 14:09:19 +0100 Message-Id: <20191104130923.22184-2-ribalda@kernel.org> X-Mailer: git-send-email 2.24.0.rc1 In-Reply-To: <20191104130923.22184-1-ribalda@kernel.org> References: <20191104130923.22184-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 pointer is used to point to data that is constant. Thanks to this we can avoid a lot of casting and we make more clear when the data is constant or variable. Suggested-by: Hans Verkuil Signed-off-by: Ricardo Ribalda Delgado --- include/media/v4l2-ctrls.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 78a97b10c89e..7db9e719a583 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -56,6 +56,7 @@ struct poll_table_struct; * @p_hevc_slice_params: Pointer to an HEVC slice parameters structure. * @p_area: Pointer to an area. * @p: Pointer to a compound value. + * @p_const: Pointer to a constant compound value. */ union v4l2_ctrl_ptr { s32 *p_s32; @@ -78,6 +79,7 @@ union v4l2_ctrl_ptr { struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params; struct v4l2_area *p_area; void *p; + const void *p_const; }; /** From patchwork Mon Nov 4 13:09: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: 11225771 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 656E813BD for ; Mon, 4 Nov 2019 13:09:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44B5621E6F for ; Mon, 4 Nov 2019 13:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572872977; bh=xPjTpdC1jm5gHOvOzgzz8OGDALqFZAuZcu4rCtV1hYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Y9ZNrFj7r9NPMxZJftEW0oPZ9fqEA/IN/ZZ1eLzmwN8DhnT26l1iEe6VVPnd7Dk+E etiUD1U8+8WsU3LXlY1bAH7WburWtNjgGFja9LRL6u5mWwGEPbnN/5UHiGVTpr6gxY Hs/adrSWiVZr8pcvmnhhVkz9zD0oIf2be6wlTHSI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729129AbfKDNJf (ORCPT ); Mon, 4 Nov 2019 08:09:35 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:36245 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729090AbfKDNJe (ORCPT ); Mon, 4 Nov 2019 08:09:34 -0500 Received: by mail-lf1-f67.google.com with SMTP id a6so8794970lfo.3; Mon, 04 Nov 2019 05:09:33 -0800 (PST) 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=D+ffK2Zkjlt7h/8BLS2fe/6Xm65ngdwZAR8g1pMusNs=; b=S9ae7lFpIdpFW6KBKJ1OAK2M7JrCNDt7cIl+mQnZ0CmR2u1YoJCsk0WB1JA9CUvHnm CeSvR0c8h4+SjuuUYniuQfY55wb740n3vQj1Ho/oeVYfEZ6FR6MjhCJzNH2zZ+PMZHqQ YGJjZZzVqeC9thZ/LoK8Hd1Sz7JLBB9WYacaM6qwHGX7+jF+hzcZeHw+HNEVhlAu3pSv J3ad1aTG+BuqkXafP6ACMfMRQNdl50dZMRZTkQkNx/vrdMSMR7u7XdfviqLWhOqkXfbD lBQoZoSlSnv2qWX7UjvjsJ34UipCzZURo608SjkJmOPjYIbPcdaD9yp3wr/7HJ9rzJKh hnJg== X-Gm-Message-State: APjAAAUYww7oY19Mj+bfVLlxZTsSuLfFOqErEceGMBSmaQAZkjqPxCMv kfQ/h84++Sbw/0HbrOFXsuk= X-Google-Smtp-Source: APXvYqwAPna3HlCtgfd+U1N3gbBMdK0foxIWoaCXbVaah9Ui2/Nu1dGdcFLg4ascmDU4/ORvXPfkKw== X-Received: by 2002:a19:d7:: with SMTP id 206mr16680328lfa.22.1572872972409; Mon, 04 Nov 2019 05:09:32 -0800 (PST) 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 q124sm985414ljq.93.2019.11.04.05.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 05:09:31 -0800 (PST) From: Ricardo Ribalda Delgado To: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v4 3/6] media: vivid: Add an area control Date: Mon, 4 Nov 2019 14:09:20 +0100 Message-Id: <20191104130923.22184-3-ribalda@kernel.org> X-Mailer: git-send-email 2.24.0.rc1 In-Reply-To: <20191104130923.22184-1-ribalda@kernel.org> References: <20191104130923.22184-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 represents a generic read/write area. Suggested-by: Hans Verkuil Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/platform/vivid/vivid-ctrls.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c index b250fc3764e2..68e8124c7973 100644 --- a/drivers/media/platform/vivid/vivid-ctrls.c +++ b/drivers/media/platform/vivid/vivid-ctrls.c @@ -32,6 +32,7 @@ #define VIVID_CID_U32_ARRAY (VIVID_CID_CUSTOM_BASE + 8) #define VIVID_CID_U16_MATRIX (VIVID_CID_CUSTOM_BASE + 9) #define VIVID_CID_U8_4D_ARRAY (VIVID_CID_CUSTOM_BASE + 10) +#define VIVID_CID_AREA (VIVID_CID_CUSTOM_BASE + 11) #define VIVID_CID_VIVID_BASE (0x00f00000 | 0xf000) #define VIVID_CID_VIVID_CLASS (0x00f00000 | 1) @@ -266,6 +267,18 @@ static const struct v4l2_ctrl_config vivid_ctrl_disconnect = { .type = V4L2_CTRL_TYPE_BUTTON, }; +static const struct v4l2_area area = { + .width = 1000, + .height = 2000, +}; + +static const struct v4l2_ctrl_config vivid_ctrl_area = { + .ops = &vivid_user_gen_ctrl_ops, + .id = VIVID_CID_AREA, + .name = "Area", + .type = V4L2_CTRL_TYPE_AREA, + .p_def.p_const = &area, +}; /* Framebuffer Controls */ @@ -1574,6 +1587,7 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap, dev->string = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_string, NULL); dev->bitmask = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_bitmask, NULL); dev->int_menu = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_int_menu, NULL); + v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_area, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_array, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u16_matrix, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u8_4d_array, NULL); From patchwork Mon Nov 4 13:09: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: 11225777 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 AC3D413BD for ; Mon, 4 Nov 2019 13:09:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80BB921E6F for ; Mon, 4 Nov 2019 13:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572872993; bh=bpLdGE8V/u9Pfk2EWnfMrE1PYLATaVTRs9lEUo93Jdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=y7BOJu2u8JVud5GS3GIyc1Dx5sOQp/aAGDASjb4yeCMTMhUB+gBlbpXtyjLZYKX8n tCwaQTUpAv9Sp3YFEYTMHTkNcK87+ALCwussqNKsVN47vhBEnuv3XKnoxQVN7u5YXY caHnA8ljmjOsefLWsOqKry8n0RQmtnrLqrdi/jNQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729153AbfKDNJh (ORCPT ); Mon, 4 Nov 2019 08:09:37 -0500 Received: from mail-lf1-f54.google.com ([209.85.167.54]:38739 "EHLO mail-lf1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729089AbfKDNJh (ORCPT ); Mon, 4 Nov 2019 08:09:37 -0500 Received: by mail-lf1-f54.google.com with SMTP id q28so12218831lfa.5; Mon, 04 Nov 2019 05:09:35 -0800 (PST) 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=0W10DXwaVM53AXBTDklaYFrwsbXNjvFaekrr8EZmqhM=; b=m4uLtIf2x9AhuMG+EJSSmi1DEOVtsDoHZoyZ8KshqYcBN/mhwcz4c+UZyprpbhsJGx EALb3coHk6D7WvIPaMEbSX9w70CWX5emG0cgrJklXMy0QOkhYfjVuuOEiCTPnOR6I3lz JDuMndMtKelH9DDW3/uSeDJ0C51ioBud0VIii00ZWUJ58CA+zbLmZ9l8nDWJofEAMfwk n9FFsjzpeW9wa8kk/svtFKhdcxzx2ZRJFoKri1XHdEQDC9vVAyRgqwBhyZhkHGv+8C4E n3tP99tdKOKZu0cQn3doL1BJ3eCwSIu0M3oZ2NKgsBv3N6c05nAwjLPzLDGjzDAv6Ua1 ylbg== X-Gm-Message-State: APjAAAVxVmivd3mnfm5nF7njQf28hdzrcatmXwY6bX9wWLdreeCD9mP2 +OEGiYMlSrC3NVUclHN5bk0IVaf5tmo= X-Google-Smtp-Source: APXvYqzABbvpVcFveZMqWs77oGlOEEVOFLAADl5rdqZu2wU5Wpn7jV5M4TZsLbgOog5eDCaF1WZDmw== X-Received: by 2002:a19:ab11:: with SMTP id u17mr1923139lfe.78.1572872974415; Mon, 04 Nov 2019 05:09:34 -0800 (PST) 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 q124sm985414ljq.93.2019.11.04.05.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 05:09:33 -0800 (PST) From: Ricardo Ribalda Delgado To: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v4 4/6] media: v4l2_core: Add p_area to struct v4l2_ext_control Date: Mon, 4 Nov 2019 14:09:21 +0100 Message-Id: <20191104130923.22184-4-ribalda@kernel.org> X-Mailer: git-send-email 2.24.0.rc1 In-Reply-To: <20191104130923.22184-1-ribalda@kernel.org> References: <20191104130923.22184-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 Allow accessing V4L2_CTRL_TYPE_AREA controls without any casting. Signed-off-by: Ricardo Ribalda Delgado --- include/uapi/linux/videodev2.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index f98bbcced8ff..04481c717fee 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1684,6 +1684,7 @@ struct v4l2_ext_control { __u8 __user *p_u8; __u16 __user *p_u16; __u32 __user *p_u32; + struct v4l2_area __user *p_area; void __user *ptr; }; } __attribute__ ((packed)); From patchwork Mon Nov 4 13:09:22 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: 11225775 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 AA8F513BD for ; Mon, 4 Nov 2019 13:09:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8636F222CA for ; Mon, 4 Nov 2019 13:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572872991; bh=dX6IpixzVBgSCMKI4SHYthEfbtWdSHK7QsJSPXjpaTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Ng006kHTwFdUMS6X4odbvU1aWwB8kCN4sPaHQQUlOYMiQZj9Y1bmg0JTG9FTmWaX5 x8m35p3/xgPOhbQU5Gf20O6EqU2zdSCTPIq2VJnJEQ/flK0V/CZ6FRRFZyeGZNb0+L KGWGzyQFLknPpZWjvuUIEFRLSIoI736APWCANUWk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728811AbfKDNJk (ORCPT ); Mon, 4 Nov 2019 08:09:40 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34663 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728807AbfKDNJi (ORCPT ); Mon, 4 Nov 2019 08:09:38 -0500 Received: by mail-lj1-f195.google.com with SMTP id 139so17562773ljf.1; Mon, 04 Nov 2019 05:09:37 -0800 (PST) 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=sjj30/458E859XQbnjLj4WwTf4kInVK2hNYmrjy4KYE=; b=LbP/PLJc7r6DKKlK2u6h3yg28y6C54o/XkbCEpvvKcZehQkXRBwa71E+Whf4YX0ogw s4uyiLMBMUf/1Yi+SGqWPPj7oJ5hHeH4rJfzC2NN2qIwRe4p24j6qP1BIUAbWCzitOyM Nj47uQStItOGpdxLw/tPMVJ9Z4drB8HXowc2i+8UY5rRU19NcrHghYIlnDJryVS46xQo YtiRoazDI9xMrHMcI4GHyCvxQw12WQ071pcLXIOzpzpzymwHIR0+PyV/J3+/wnP1Lqnt FLmWuAjwUZXAwmH6jsxT++HeiH4XMSvSjqZyA+KzJs23KI/CwkBTLelytajKCV5ay6QW 4h6w== X-Gm-Message-State: APjAAAWWxktVdDUY/Hy3diP1X3CMYzZFEcKUog/M5Kj9UW2z+YfzDHio dKbFEz9P1/KE7bHpTE4U+OOGRrTt+UY= X-Google-Smtp-Source: APXvYqzyxtz+Iwz3Yh3awlpBY2DgMBQeAfmt7kvGJbVgXdIYYcwbFPwPqQHT/OVrUCdTysAeLoyYmQ== X-Received: by 2002:a2e:914b:: with SMTP id q11mr4737209ljg.13.1572872976283; Mon, 04 Nov 2019 05:09:36 -0800 (PST) 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 q124sm985414ljq.93.2019.11.04.05.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 05:09:35 -0800 (PST) From: Ricardo Ribalda Delgado To: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v4 5/6] Documentation: v42l_core: v4l2_ext_control Date: Mon, 4 Nov 2019 14:09:22 +0100 Message-Id: <20191104130923.22184-5-ribalda@kernel.org> X-Mailer: git-send-email 2.24.0.rc1 In-Reply-To: <20191104130923.22184-1-ribalda@kernel.org> References: <20191104130923.22184-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 Describe p_area field from v4l2_ext_ctrl Signed-off-by: Ricardo Ribalda Delgado --- Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst b/Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst index 13dc1a986249..271cac18afbb 100644 --- a/Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst +++ b/Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst @@ -198,6 +198,11 @@ still cause this situation. - ``p_u32`` - A pointer to a matrix control of unsigned 32-bit values. Valid if this control is of type ``V4L2_CTRL_TYPE_U32``. + * - + - :c:type:`v4l2_area` * + - ``p_area`` + - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is + of type ``V4L2_CTRL_TYPE_AREA``. * - - void * - ``ptr`` From patchwork Mon Nov 4 13:09:23 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: 11225773 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 9ED82913 for ; Mon, 4 Nov 2019 13:09:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7DD3C21D81 for ; Mon, 4 Nov 2019 13:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572872989; bh=CNn1QMIMMKoxVbb00UzcVmYoCmWNy+sRB6kkJrpIRlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=liFAeXVIWAEE/UToak9dADcVOpGoYI+wLczvgUWH/5hWKxJZ3Qlxc89Dq26xJIw1+ Ds/u6KWcYX8py2Sy7Hn1iXLd2Ikx7pfzpQlpQ4OLq4ujzUeEOfOqOnz6Obsde4ij5n lJ+iPg0swSRZGW8wwuhpVl/CR7XKujNHj8wv+BWY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729006AbfKDNJk (ORCPT ); Mon, 4 Nov 2019 08:09:40 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:45007 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729090AbfKDNJk (ORCPT ); Mon, 4 Nov 2019 08:09:40 -0500 Received: by mail-lf1-f68.google.com with SMTP id v4so12190788lfd.11; Mon, 04 Nov 2019 05:09:39 -0800 (PST) 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=xyLLjGx5ZrVCZEiXYSVVcb3hHEr+G7AeV53GCDjOTy0=; b=VVw+7A3kpVe+rJlt79+B39uTcMCEtRFb58bnYTmeLe30Xg8ihB8/SA64rAfC8um3Jk GZ74tf4oAQHYzSYf8vviHyeYxW8lfeJNeslVm2FBB+RYMu3vBfG3ZxVjKkFSqYgvG+fA WghaXvSOrXWPI1TsM3t3Z3mdQao3BaTsMi3qL26lYEM/uUq7iFKwKHNp99ocXb8xreFS 3QHfWAnxnwo5djENUN6i66riusRWUe/2N01dwzK+ivXe/LEp3LjXeJ9ZTVQaT6SobC8a jLcjaYVmM8wVSnovtquUTPQlzm5nM1MB9wS1Xk8iyOthVtGRWG3NAnMXyhjvmszctCX4 EcbA== X-Gm-Message-State: APjAAAVlnzsbC5MCIKvzohwz8kX9ofBDgw8l8rdBcKOMhpo35Dn02EZb +50Xj52EHattt3ZRK2HTLpo= X-Google-Smtp-Source: APXvYqwvoqeUb29ZDHdgJFMuRgN/S//zAH64o/UdmhfHQknXt8Um5U9YmzrpFsDcmP+LsBJHPTcqeA== X-Received: by 2002:a19:746:: with SMTP id 67mr16747604lfh.42.1572872978354; Mon, 04 Nov 2019 05:09:38 -0800 (PST) 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 q124sm985414ljq.93.2019.11.04.05.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 05:09:37 -0800 (PST) From: Ricardo Ribalda Delgado To: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v4 6/6] media: v4l2-ctrl: Use p_const when possible Date: Mon, 4 Nov 2019 14:09:23 +0100 Message-Id: <20191104130923.22184-6-ribalda@kernel.org> X-Mailer: git-send-email 2.24.0.rc1 In-Reply-To: <20191104130923.22184-1-ribalda@kernel.org> References: <20191104130923.22184-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 After adding a const pointer to ctrl_ptr, lets use it where it make sense. Suggested-by: Hans Verkuil Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/v4l2-core/v4l2-ctrls.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 73d99c3561ce..a565ae3ba7e4 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1556,7 +1556,8 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, if (ctrl->is_int) return ptr1.p_s32[idx] == ptr2.p_s32[idx]; idx *= ctrl->elem_size; - return !memcmp(ptr1.p + idx, ptr2.p + idx, ctrl->elem_size); + return !memcmp(ptr1.p_const + idx, ptr2.p_const + idx, + ctrl->elem_size); } } @@ -1566,8 +1567,8 @@ 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; - if (ctrl->p_def.p) - memcpy(p, ctrl->p_def.p, ctrl->elem_size); + if (ctrl->p_def.p_const) + memcpy(p, ctrl->p_def.p_const, ctrl->elem_size); else memset(p, 0, ctrl->elem_size); @@ -1954,7 +1955,7 @@ static int ptr_to_user(struct v4l2_ext_control *c, u32 len; if (ctrl->is_ptr && !ctrl->is_string) - return copy_to_user(c->ptr, ptr.p, c->size) ? + return copy_to_user(c->ptr, ptr.p_const, c->size) ? -EFAULT : 0; switch (ctrl->type) { @@ -2069,7 +2070,7 @@ static void ptr_to_ptr(struct v4l2_ctrl *ctrl, { if (ctrl == NULL) return; - memcpy(to.p, from.p, ctrl->elems * ctrl->elem_size); + memcpy(to.p, from.p_const, ctrl->elems * ctrl->elem_size); } /* Copy the new value to the current value. */ @@ -2587,7 +2588,7 @@ 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) + if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p_const) sz_extra += elem_size; ctrl = kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); @@ -2634,9 +2635,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, ctrl->p_cur.p = &ctrl->cur.val; } - if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p) { + if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p_const) { ctrl->p_def.p = ctrl->p_cur.p + tot_ctrl_size; - memcpy(ctrl->p_def.p, p_def.p, elem_size); + memcpy(ctrl->p_def.p, p_def.p_const, elem_size); } for (idx = 0; idx < elems; idx++) {