From patchwork Sat Jul 30 10:24:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xavier Roumegue \(OSS\)" X-Patchwork-Id: 595736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE74FC19F29 for ; Sat, 30 Jul 2022 10:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232286AbiG3KZG (ORCPT ); Sat, 30 Jul 2022 06:25:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231143AbiG3KZE (ORCPT ); Sat, 30 Jul 2022 06:25:04 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2085.outbound.protection.outlook.com [40.107.21.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF9FA2BB2F; Sat, 30 Jul 2022 03:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XmEUo1uX28V9/8kRvbg45gb1q12o0/j3rv2kejSWthx4u4k7MTW/QYldMF3g7KqM8dNzZayguX/oiSPpDHaUnKD7UUJn0wnQ2S6Ms/TrDNlUC5gHJ+bPbamiGm+VC3motnFQ8EnMA5n+paAXGKWBkafIOPCYIP7nESPJzeTlN+xOv0LsCrS0htDQYy2ESbpYHUNnDLI1TN4kAYQ5B3/x9wP1Szp1bRC5LU8ani0JObye4dycDsbU1/A2iGND5QYGNvDw+d1DxL3e/ITdPgVdnlV5LOP+xRsFD7ueJyM7I2jYunQbUoO82RmpgPuxoqOdwrqVSd/jSx0J+JLmDmF8ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vGMq/W2/ac8V0jfSl0o8R/flkvjAyw1EZ8JJ38UbspQ=; b=lqAZXUq8h+yhjzXs7+3A19iINbLTsT7sfntwguB5DpYZe/WVTQjUWBOtk841TGVF+tn35sebtOkNNedqeaP/LarTPjv9NlA15NjQIMb2ddZp5GNMqH5X9sXqRIioAN0gQMgQ5c6WzJniUz5hgPBhwMwasrBU4S+Uf/0v5SjOM3IZfIUFVNJXGp0JonVhgIYE6OP7X0CLj+wGpojCHUzEafGB7CT4zsTnkG2/oOiQZ6buMxMvn6GC+s3REyefwoNTUtryq/k3R0QLTIMftCpaIzUKbx0fkNuE7MtU1Bxh9u/dxzxChQaxzWXMzlrl/vj+FtO5r8C9ClStIAVt601zQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vGMq/W2/ac8V0jfSl0o8R/flkvjAyw1EZ8JJ38UbspQ=; b=UT/7JlUNaxN1t+quHxDkhq+L8aYfZRDcrMjYNpSDG8aj8dQokf5IhyoRzvD9kYs98NtBfVrmni5XOL/BaC+2X6Urp7sOj+IsKRoV9SCa7Zhh9Lk15jIedU/ldUfAUA3rt0Lgiz5wZxgoizCpyeSLwjfikfW8BLMkeByj4GXJKIM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) by PAXPR04MB8621.eurprd04.prod.outlook.com (2603:10a6:102:218::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Sat, 30 Jul 2022 10:25:00 +0000 Received: from PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f]) by PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f%9]) with mapi id 15.20.5482.014; Sat, 30 Jul 2022 10:25:00 +0000 From: Xavier Roumegue To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, stanimir.varbanov@linaro.org, laurent.pinchart@ideasonboard.com, tomi.valkeinen@ideasonboard.com, robh+dt@kernel.org, nicolas@ndufresne.ca, alexander.stein@ew.tq-group.com, ezequiel@vanguardiasur.com.ar Cc: Hans Verkuil , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v9 1/8] v4l2-ctrls: optimize type_ops for arrays Date: Sat, 30 Jul 2022 12:24:06 +0200 Message-Id: <20220730102413.547698-2-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> References: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR1P264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2cc::9) To PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10870c48-ecfa-41a8-611d-08da7215c085 X-MS-TrafficTypeDiagnostic: PAXPR04MB8621:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wOxhLqx9bxaxpJREIizxTOjwlD7q/rEMO2pApQxAd9ArzMK4AyUlgNN6jOfGUOqfkMoWFwSS0WZtAe5dI0rMzneyyk/clcdtp6OGsu9PRO14rZhTIZHuIq2ujAcFaNBez7IuHq70TTjdqwQK9TYXvxMS/+nD1wGSz/xIV15+GV+3FENlXq8KE+7y+zb1z1AbUxtlXfD1B1UgVIwep8wjUbwaNPmFyB8d4GaRNwYhukLRYjdJeT8nn2Yyfwjx8bFaac/YgBpmzUWzP7r0SgpUwobzq16mfNSgG0opTeJ6RwEajxbpZEoE/4ZV1Jfxbp3VwMG48mM1SlcoQJK9SrfN4/2VskBL9eN6DeSoXv1hsS/chaIoctJcAPBkDjLNrEY1uHfBykYMyem+Ih/yKNENB0aeDkEBEnYnFgPM+alR1Z5QnYQQZ+8/3J1SeZK9rQC+eX42dD5zf9re1wH7ulLRgVVgf+lmBLF8CVfVKdg70QGcos5gnuXiJJtQ/8AUfh8FtusM9tOJtCRk+1EZeJm3sL9vKVtrQxnWjKP96bNC4he2LVd369Q1PvARXvgRkg4Oc3s005XgYqZSEihocl2A0eRlXgMGo4w2ALewY7ZP4IkGHTTBl82aSfbHY9BbUsn7IVcJln8aj3+ztohPcEj4B357sXG3+i2Ut7nI29+y7J09ZUouPAIg5sE7mgPemftqv5EeBy79OK/RRAz1cKoEOwjbRUsul7kl1ECAOvMLem3OhuYHUgQH3dFPMzKE60Xg X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8703.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(366004)(39860400002)(136003)(396003)(346002)(7416002)(6512007)(4326008)(8676002)(44832011)(186003)(83380400001)(52116002)(66556008)(6506007)(38100700002)(66476007)(66946007)(2906002)(86362001)(8936002)(41300700001)(5660300002)(478600001)(1076003)(6486002)(2616005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uzzsqMrOaze2x8qf8cDtaC3uI20sdqAYhi+ktRT7c8S5RWX89OCWqyMavuzSS4w5ofpLD8haa8/p262/uOdBu6HkqTnNBXsLBC0OxvQZteSp355sdKTRo4Tie/GXdoBYLlALk0y18mBXoPkdUAcOIAqKfWoAqLt6oKEaKGBeD8yW3l2ykwflSRTqSGQve5CmZytTgXbPLEX4XaVr0cvw+cv0pwISUQEHZkTc4lyn87sU7xaZ2TB48+ZnI0EXkUHQqVKLl/e9VV2X/+YmMbjeOKw9xPwNQYFc2C7SmRO/Ym5ykvgI06yyjjed1N34fAFh5P0lTljMgO+QkGUnO1SYmt2DdPr1VygBFGhdMZkbNKaTTfC7uQIhY3FCKWRGXdzUVpbHmGCgi0eRlKPtxBWTRTec/82uGw1BXneiJZWfasCOT7x+CSopJ+YDTDq0qwbDLotAV/wN/DE326lXX5newEcUo0M1NqYC7jAhkTTRmvBpQjsptibmypA95ucsIAYe9XhJIQ8AWRVDk+mB4ZrqWeGgtZMujWnMKPusctCjPrU/UnCPIAqdoTlo+MVSWf2oj/hli/z/hyCDHr8RjPC6nntmVxdH+NyeCmnezEY+NkfCZ07raiv61ae+A4YC07K1jbl/a3Gk8rfngVCZ5cgb53Vk4unZA88X3V+slMunHJC5ecUsONnJNlvdxW0hitNF/FQwxqUZEl/HJwiEp3fCu4Pj+DGzASm0R0USomGSsf0pN7UDu785vvvzCGjJwjnwfdCpI6/9BVQW75LVLzD2FD+zcE+B2KEwtyvIzmLRudpC4KE+HoHbI6k6qMjy3mxQk921ilufKeuli/UMxQ7iiapPQIpQC4es9XDPUEwYayOFILju+emokZ6NAj9yj2FVwfaLa4sKL5MxwceHqlvwWMre1qBjeemmikp6P76m8d1FcbN+6sV8Ff/dVD+PDCqhiD4erdU9UFjG6Mp76yYPWbJrpaZ8aOItFALtnyCpjwH9eioev3yqJDV/xVmprjNBSK1L1RJJppygMDObE48ocO+u9IhABPugHdhtI4NWOSWPm4veqa5Z02wcKG8k9OrAaD8WA23m3iZUeS3z5rYflXrlGeZelJZJzxG6J8JmMXfqiZecqg9dZGm3e4zfXo1Bi8FvofMqf7nO3qvA0OunSsVUHLhQap4AulihYl4iBzlvMCNflbRpQ7tu8dOFEqamBXA7N/aatLQG0S2ZMXSvX+9JTc1r8pDTktz3FtSiQSvVGVlJK5iflU+bFpkzZt11TdJWE7ZSDI+AkTOw7tUHQ4uICVwmBhrxDhFMJgsNL4ZXPQenPeMLQu1rsfQekgiM3fO18T8qPSbnEZ+NK+l2ZOtLxCXuDIR+R0hdChrilLdsEP7A3Gq5MtbCzTgBQOTyhBXGnu5g1Uxe7MqR0iWsUIhQ/vdmLTUjbkJOURzOiRdsJIyiT+oGH9CDCUQs+9vv/npK/i8bzbPkzT4RrusHBcqIwPuWbgHjTh3EAhL/D3syjAcWVSbYyr+WzwoSW83uHEkmwqNJrl2WXOqZLMdAGILnXP66FQbpx+W/XGV6eFhHdJDidBlxNQf5tWvjsT7IhmdpTjnIJjakz/E4USffcYtBAiVGx/CoMgeQAQO8LNnSAGTPd8nGoPG7XsPu34IQ+uLDAzedVFEROmZDA8GDzg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10870c48-ecfa-41a8-611d-08da7215c085 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 10:25:00.0118 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3SM32HLp7ewgZqweKLEtFSbCOCljOAC01u0U6+J1av03OVr17P2AVCXDYG7T871vUEt+QZIZujGxsQUoQGwciQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8621 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Hans Verkuil Initializing arrays and validating or checking for equality of arrays is suboptimal since it does this per element. Change the ops to operate on the whole payload to speed up array operations. Signed-off-by: Hans Verkuil --- drivers/media/v4l2-core/v4l2-ctrls-api.c | 19 +--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 129 +++++++++++++++------- include/media/v4l2-ctrls.h | 6 +- 3 files changed, 96 insertions(+), 58 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls-api.c b/drivers/media/v4l2-core/v4l2-ctrls-api.c index 67fbdccda2d83..a8c354ad3d234 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-api.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-api.c @@ -89,10 +89,7 @@ static int req_to_user(struct v4l2_ext_control *c, /* Helper function: copy the initial control value back to the caller */ static int def_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) { - int idx; - - for (idx = 0; idx < ctrl->elems; idx++) - ctrl->type_ops->init(ctrl, idx, ctrl->p_new); + ctrl->type_ops->init(ctrl, 0, ctrl->elems, ctrl->p_new); return ptr_to_user(c, ctrl, ctrl->p_new); } @@ -122,7 +119,6 @@ static int user_to_new(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) if (ctrl->is_ptr && !ctrl->is_string) { unsigned int elems = c->size / ctrl->elem_size; - unsigned int idx; if (copy_from_user(ctrl->p_new.p, c->ptr, c->size)) return -EFAULT; @@ -130,8 +126,7 @@ static int user_to_new(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) if (ctrl->is_dyn_array) ctrl->new_elems = elems; else if (ctrl->is_array) - for (idx = elems; idx < ctrl->elems; idx++) - ctrl->type_ops->init(ctrl, idx, ctrl->p_new); + ctrl->type_ops->init(ctrl, elems, ctrl->elems, ctrl->p_new); return 0; } @@ -499,12 +494,7 @@ EXPORT_SYMBOL(v4l2_g_ext_ctrls); /* Validate a new control */ static int validate_new(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr p_new) { - unsigned int idx; - int err = 0; - - for (idx = 0; !err && idx < ctrl->new_elems; idx++) - err = ctrl->type_ops->validate(ctrl, idx, p_new); - return err; + return ctrl->type_ops->validate(ctrl, ctrl->new_elems, p_new); } /* Validate controls. */ @@ -1017,8 +1007,7 @@ int __v4l2_ctrl_modify_dimensions(struct v4l2_ctrl *ctrl, ctrl->p_cur.p = p_array + elems * ctrl->elem_size; for (i = 0; i < ctrl->nr_of_dims; i++) ctrl->dims[i] = dims[i]; - for (i = 0; i < elems; i++) - ctrl->type_ops->init(ctrl, i, ctrl->p_cur); + ctrl->type_ops->init(ctrl, 0, elems, ctrl->p_cur); cur_to_new(ctrl); send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_VALUE | V4L2_EVENT_CTRL_CH_DIMENSIONS); diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c index 38030a7cb2338..4faba8ffe426a 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -65,31 +65,27 @@ void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes) v4l2_event_queue_fh(sev->fh, &ev); } -static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, +static bool std_equal(const struct v4l2_ctrl *ctrl, u32 elems, union v4l2_ctrl_ptr ptr1, union v4l2_ctrl_ptr ptr2) { + unsigned int i; + switch (ctrl->type) { case V4L2_CTRL_TYPE_BUTTON: return false; case V4L2_CTRL_TYPE_STRING: - idx *= ctrl->elem_size; - /* strings are always 0-terminated */ - return !strcmp(ptr1.p_char + idx, ptr2.p_char + idx); - case V4L2_CTRL_TYPE_INTEGER64: - return ptr1.p_s64[idx] == ptr2.p_s64[idx]; - case V4L2_CTRL_TYPE_U8: - return ptr1.p_u8[idx] == ptr2.p_u8[idx]; - case V4L2_CTRL_TYPE_U16: - return ptr1.p_u16[idx] == ptr2.p_u16[idx]; - case V4L2_CTRL_TYPE_U32: - return ptr1.p_u32[idx] == ptr2.p_u32[idx]; + for (i = 0; i < elems; i++) { + unsigned int idx = i * ctrl->elem_size; + + /* strings are always 0-terminated */ + if (strcmp(ptr1.p_char + idx, ptr2.p_char + idx)) + return false; + } + return true; default: - if (ctrl->is_int) - return ptr1.p_s32[idx] == ptr2.p_s32[idx]; - idx *= ctrl->elem_size; - return !memcmp(ptr1.p_const + idx, ptr2.p_const + idx, - ctrl->elem_size); + return !memcmp(ptr1.p_const, ptr2.p_const, + elems * ctrl->elem_size); } } @@ -181,40 +177,66 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, } } -static void std_init(const struct v4l2_ctrl *ctrl, u32 idx, +static void std_init(const struct v4l2_ctrl *ctrl, u32 from_idx, u32 elems, union v4l2_ctrl_ptr ptr) { + unsigned int i; + switch (ctrl->type) { case V4L2_CTRL_TYPE_STRING: - idx *= ctrl->elem_size; - memset(ptr.p_char + idx, ' ', ctrl->minimum); - ptr.p_char[idx + ctrl->minimum] = '\0'; + for (i = from_idx; i < elems; i++) { + unsigned int offset = i * ctrl->elem_size; + + memset(ptr.p_char + offset, ' ', ctrl->minimum); + ptr.p_char[offset + ctrl->minimum] = '\0'; + } break; case V4L2_CTRL_TYPE_INTEGER64: - ptr.p_s64[idx] = ctrl->default_value; + if (ctrl->default_value) { + for (i = from_idx; i < elems; i++) + ptr.p_s64[i] = ctrl->default_value; + } else { + memset(ptr.p_s64 + from_idx, 0, elems * sizeof(s64)); + } break; case V4L2_CTRL_TYPE_INTEGER: case V4L2_CTRL_TYPE_INTEGER_MENU: case V4L2_CTRL_TYPE_MENU: case V4L2_CTRL_TYPE_BITMASK: case V4L2_CTRL_TYPE_BOOLEAN: - ptr.p_s32[idx] = ctrl->default_value; + if (ctrl->default_value) { + for (i = from_idx; i < elems; i++) + ptr.p_s32[i] = ctrl->default_value; + } else { + memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32)); + } break; case V4L2_CTRL_TYPE_BUTTON: case V4L2_CTRL_TYPE_CTRL_CLASS: - ptr.p_s32[idx] = 0; + memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32)); break; case V4L2_CTRL_TYPE_U8: - ptr.p_u8[idx] = ctrl->default_value; + memset(ptr.p_u8 + from_idx, ctrl->default_value, elems); break; case V4L2_CTRL_TYPE_U16: - ptr.p_u16[idx] = ctrl->default_value; + if (ctrl->default_value) { + for (i = from_idx; i < elems; i++) + ptr.p_u16[i] = ctrl->default_value; + } else { + memset(ptr.p_u16 + from_idx, 0, elems * sizeof(u16)); + } break; case V4L2_CTRL_TYPE_U32: - ptr.p_u32[idx] = ctrl->default_value; + if (ctrl->default_value) { + for (i = from_idx; i < elems; i++) + ptr.p_u32[i] = ctrl->default_value; + } else { + memset(ptr.p_u32 + from_idx, 0, elems * sizeof(u32)); + } break; default: - std_init_compound(ctrl, idx, ptr); + for (i = from_idx; i < elems; i++) + std_init_compound(ctrl, i, ptr); break; } } @@ -895,8 +917,8 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, return 0; } -static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, - union v4l2_ctrl_ptr ptr) +static int std_validate_elem(const struct v4l2_ctrl *ctrl, u32 idx, + union v4l2_ctrl_ptr ptr) { size_t len; u64 offset; @@ -964,6 +986,38 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, default: return std_validate_compound(ctrl, idx, ptr); } + +} + +static int std_validate(const struct v4l2_ctrl *ctrl, u32 elems, + union v4l2_ctrl_ptr ptr) +{ + unsigned int i; + int ret = 0; + + switch ((u32)ctrl->type) { + case V4L2_CTRL_TYPE_U8: + if (ctrl->maximum == 0xff && ctrl->minimum == 0 && ctrl->step == 1) + return 0; + break; + case V4L2_CTRL_TYPE_U16: + if (ctrl->maximum == 0xffff && ctrl->minimum == 0 && ctrl->step == 1) + return 0; + break; + case V4L2_CTRL_TYPE_U32: + if (ctrl->maximum == 0xffffffff && ctrl->minimum == 0 && ctrl->step == 1) + return 0; + break; + + case V4L2_CTRL_TYPE_BUTTON: + case V4L2_CTRL_TYPE_CTRL_CLASS: + memset(ptr.p_s32, 0, elems * sizeof(s32)); + return 0; + } + + for (i = 0; !ret && i < elems; i++) + ret = std_validate_elem(ctrl, i, ptr); + return ret; } static const struct v4l2_ctrl_type_ops std_type_ops = { @@ -1449,7 +1503,6 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, unsigned elems = 1; bool is_array; unsigned tot_ctrl_size; - unsigned idx; void *data; int err; @@ -1664,10 +1717,8 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, memcpy(ctrl->p_def.p, p_def.p_const, 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); - } + ctrl->type_ops->init(ctrl, 0, elems, ctrl->p_cur); + cur_to_new(ctrl); if (handler_new_ref(hdl, ctrl, NULL, false, false)) { kvfree(ctrl->p_array); @@ -1984,7 +2035,6 @@ void update_from_auto_cluster(struct v4l2_ctrl *master) static int cluster_changed(struct v4l2_ctrl *master) { bool changed = false; - unsigned int idx; int i; for (i = 0; i < master->ncontrols; i++) { @@ -2010,10 +2060,9 @@ static int cluster_changed(struct v4l2_ctrl *master) if (ctrl->elems != ctrl->new_elems) ctrl_changed = true; - - for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++) - ctrl_changed = !ctrl->type_ops->equal(ctrl, idx, - ctrl->p_cur, ctrl->p_new); + if (!ctrl_changed) + ctrl_changed = !ctrl->type_ops->equal(ctrl, + ctrl->elems, ctrl->p_cur, ctrl->p_new); ctrl->has_changed = ctrl_changed; changed |= ctrl->has_changed; } diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 683e9903a6ea6..62052e1874bdf 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -134,13 +134,13 @@ struct v4l2_ctrl_ops { * otherwise. */ struct v4l2_ctrl_type_ops { - bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx, + bool (*equal)(const struct v4l2_ctrl *ctrl, u32 elems, union v4l2_ctrl_ptr ptr1, union v4l2_ctrl_ptr ptr2); - void (*init)(const struct v4l2_ctrl *ctrl, u32 idx, + void (*init)(const struct v4l2_ctrl *ctrl, u32 from_idx, u32 elems, union v4l2_ctrl_ptr ptr); void (*log)(const struct v4l2_ctrl *ctrl); - int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx, + int (*validate)(const struct v4l2_ctrl *ctrl, u32 elems, union v4l2_ctrl_ptr ptr); }; From patchwork Sat Jul 30 10:24:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xavier Roumegue \(OSS\)" X-Patchwork-Id: 594597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BA07C04A68 for ; Sat, 30 Jul 2022 10:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232749AbiG3KZH (ORCPT ); Sat, 30 Jul 2022 06:25:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231687AbiG3KZG (ORCPT ); Sat, 30 Jul 2022 06:25:06 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2085.outbound.protection.outlook.com [40.107.21.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACBB02C119; Sat, 30 Jul 2022 03:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qvm7cyjCw/4y4Wkh2RHrQV/gYQ4SJC1yDga98LfZHdPeSI6BgXwGHABEHqdEvpd1d0gV3XGXxB7Uwi6+2BY80RiV0e72F1lSPQCefrrw16DP7YuJ9Tt8bhM5xwKCciqWrZkXQf8CMUcmO+luFsbgpSvF86YAA2Q+mIIUUJaDgxIKl4ZmVfBo7m2uahRH6KEE7jagST2tO3J280b9DiTcUSs1LA5UrA1UvUpahKGuGtub0IgMnVIZz40rUWXtP1wG21JMqcOfmhHxM+TsDgZxEKBJ31SjyC0aPZycJZQQbvpinPjv1SO8BfG5dCOKQnPgH4bXsoeZn6wDIjBhvdWLEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sJySvM2RzQ8yfyLYrCcr+UHM3X0MJ5/VdC5P5rgGc7E=; b=miOe4xtPka0+rY7UWWdN2VAqpZALsNzElzv4zPKfXWPW1MnGP5DnzEIZVT4UCli/RjEeXTUiCO7+ZsPQWx4iYQqPivqg3GJiWPrKqgt+HHLIaN99S4KLGrRS8UtTPi3mvas87kIKyPP9DfCDHaprMjM2VeTU3MQQVKeK5HkmBCmbWgdUr71un1Z15MmlONTzJ4DHAZjz5KxVXrcNF0XfwCxEUl4Dh47zqTzJwmPfALOmqMp+X7IycOVwJ4ZumqcKE9vTuJAPU0e8h4ZXT5IEh7rnr8f1ZnBwGAxeznLQ6Dhbpc5mXaxidAzY6uq+bL9g6es9nM8vJ5s6QaKmw5W5vQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sJySvM2RzQ8yfyLYrCcr+UHM3X0MJ5/VdC5P5rgGc7E=; b=Cclxo9qRDeePnQWheGaPFCF6w9gFuVmG0boeXlPRb/UHAzEmb5HDX/HCSldb9WjYWGUfTyruEgiaIwiK6vbAK/pr43G+21/gsN8jm5Eb+tig38Sjq7mnWy5ajkp+LevKJr6rxcLEyNULaDva0AT3wjnJNf3sk1GPZiep4OG1uS8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) by PAXPR04MB8621.eurprd04.prod.outlook.com (2603:10a6:102:218::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Sat, 30 Jul 2022 10:25:01 +0000 Received: from PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f]) by PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f%9]) with mapi id 15.20.5482.014; Sat, 30 Jul 2022 10:25:01 +0000 From: Xavier Roumegue To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, stanimir.varbanov@linaro.org, laurent.pinchart@ideasonboard.com, tomi.valkeinen@ideasonboard.com, robh+dt@kernel.org, nicolas@ndufresne.ca, alexander.stein@ew.tq-group.com, ezequiel@vanguardiasur.com.ar Cc: Xavier Roumegue , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v9 2/8] v4l2-ctrls: Export default v4l2_ctrl_type_ops callbacks Date: Sat, 30 Jul 2022 12:24:07 +0200 Message-Id: <20220730102413.547698-3-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> References: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR1P264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2cc::9) To PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4052ba4-a990-4d35-d8e7-08da7215c288 X-MS-TrafficTypeDiagnostic: PAXPR04MB8621:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zxfc9jxisnl6nc6XC789ITVm6pnFSI8tZ7LvXPDdjuCsLmC4RMKiakC3moUqqBhLehB0fpZoha1gnwr8csZBBPs/RqJPc5rEJm1xcRcSbmCGdmhkBx28RCs/gz0Etgu+5Na5yLh61ui3IAwk0v/NgLajji7pWEF3BuOdqW6GivQRYCl8jsq1GV4LIxNsHgRYZwBd3JwY9gRTOZiPfppMvb39oBm30bJeNZG0aPgenwxuet503jqVE2e5bVqexf89/4OocXMqetqpD25yLbzLYLsI6jq0f1oBvrsKsz6oqNwGB4ni33o7CIzRQO/Ze88pdlCOqSDjoyei3A3hopoMT7qWaN18p9vAf67/lBD8UQ5cHHUL6kH67u4eIwQoYYoT2LeWGYvkP3pbV7X8zm/fV6gZBx76VJ++DYjJEqQnvCIR+7VN8uEGUHtFngECxZNMlvOkhSGVn4v0c+K73EXyTmbbmpd9ezCHt2rSi+lnGhL1UFNUMzlXXwKKNGZjbUwhtjAatGJ9h3lyRLxYJopbv8LoGy1qZyqXmg+Es6rOMYJNseQk/ViMTzVC7vPaUjxzq46JVuP/f0qyArAONrTZCaHaV9cV38mfoiGQlYipXMRZ539k/T9Shs57DEwnN6iV8MaqsvAI/wjuuT2/lJ4KFOPg57NwHU1YrKF5usB51OWWcoe+zCMlp+/WYEk/o7j96Oddl8lyAH9k3iKUb61E1ellbTmQyf/JvPW2o49rcV93MKLuE6SS2Hz1B95EfZDB X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8703.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(366004)(39860400002)(136003)(396003)(346002)(7416002)(6512007)(4326008)(8676002)(44832011)(186003)(83380400001)(52116002)(66556008)(6506007)(38100700002)(66476007)(66946007)(2906002)(86362001)(8936002)(41300700001)(5660300002)(478600001)(1076003)(6486002)(2616005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Dv7iky23mJkUDe3+biYTWCjauI5WWdsmxH+QAYrjz5TLUslFZpz+1zploFLZxr7VcFdZVXaozfwWPwajXkbPO8go3FMzycZqiFkeLOVhr+IJY0GA3hsE26WARMP+zb1YU1R56QGFUKrDURmJcUSWXXLqRyfJ4QF7Ob+B41JC8O3wKmggw7PjRwPDy1U9Vkx5CbiP8mU9irbaexcs4NLCmtg0Q1jpsq9KRDUWE/vBPfT6s2jMywTqRPR7+ajUO+KtUFsap/68CBxDrHfayD23KZVDLaXCihiBViPLxiK7YsEwziroZqpf0766e/YEN5fFswrfHFkB8IOz44oeyEyuHWJzdkgs8f6tqw7JMMzp2BfzKHHhC2HSdq4zJFI/BHastRK4wbjQJBbZ+rvxULNSEZVwM5SrYxYGnj97AZZvC9F1/7mq0aB+oIMUMKk9uFnrAZC4fu7GFX79wJ+UbqPkACkzJvRpGaizAvjxLH6Y8f7aFbbwRK9/XhFcQ3zCCaKjGEtj3S8v4rgViS9rN7n18cpMODY3+ipvQJPXgQRuI6bGeoFREcui54yzytv4INP1d1CmiXeEzqklO8iuSwxV2qUN8gGkH/ctQcx4eiF5hLjScbUCMlMGtv5LyxkZvwyNxWAgNC8MIrXzGeTf33/ldNAFvf1tgi61aXmMu3zzglRIi8izNnoz7euhdOZxSZcMMNpkrd4arZ/z7Agrx3txJ6bS57K1HctEOqkEYfu0W87kXSTXR1c7vNJuM/gjZrsqjmE6FjqdAyjbt1fDrsiGmX9ExCRovuxu+AqYJGWtSz5MO8nqyrQ8dRR0AVXA17Qe2O2dR/C7lboSYi3fOJ3P9LTDR37a1ji+PpfvhNONIIpa8xFm26Llj+/GUr//rfIJhJofrzjNC6v6XCEhHBwbZMOM6PqGBX6yxINJ9yDEDGe0eMw/ogxZ/UXUEQC2rF7EekIcsqu9ANXt8Fw8aIv6AfBkn1r4aLdZVLWuuYbc1RQLtyoletXbvUtdlJOddQ3NU8IfXaERWzD8wIlEzWY860iMiwEOhl2yOrdC+7s9alByKO7rH20dWatSXgEw8duyW0DJDjL8kvSj0EIKlvfDcsZlw2HxydKyosuDmvLSygmk5AtVw9mEA2U5ANpxNapBYc3rpirgbRr7l4ixOSr8Xbr8oBh8cCCYkJrvy9ZUGb+tZMCyB91m/HZ4RuR6etP68ju7JMt+Vki1evBP5WJQyrQptxvgJb0wG2T2GaWKI4OqoZS2ZZtkCnNX6tQIHT7jZarQtaPc1yiqTBn/G03kBzRyOaKwnNlEgP07oaZS5t9cVZ6Pbjkxdz8dtrbXVElpNUIz25mlUoMkWJ4JIunkkxyhbnsIckZ80Y6qEVrQt6BWZO7fkH9XbscrrmDsAVyaTWaNnuNC7R1j7oR7/BrA3XNHFQU1/hJ/zpmbz+6jZu74lA6GUMirJicU0IZfVCH0yWbatGDPfftq1FkN5IpjIBtQQ/PH7Y5cxxNXP0+Nu25CZVGOTfGdp3OtRk0L8MeQfMKcIrN1HqSbkquhTYNuyF8/sPPvt0E/Euh790IlzoRrA/zPOI6d6tNZXh1i+dpZiA4kwTHjPktEwke10COIVhtdwF4Wk5vxR5n3IzxQWb+XmDML8lBMzMgTvOFZBNBUa0n0ljIxC0SGcGEcZC+BPw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4052ba4-a990-4d35-d8e7-08da7215c288 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 10:25:01.1536 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EZO8BIu9CVRXdTyQew97lYDUnNibsfo1BAf3Xfl4KfDXSq0OqAXOyBRXWdhKCADXoqXHUs9uX8Q8HijjOAiFSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8621 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Export the callback functions of the default v4l2 control type operations such as a driver defining its own operations could reuse some of them. Signed-off-by: Xavier Roumegue --- drivers/media/v4l2-core/v4l2-ctrls-core.c | 30 ++++++++------ include/media/v4l2-ctrls.h | 48 +++++++++++++++++++++++ 2 files changed, 65 insertions(+), 13 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c index 4faba8ffe426a..ead5159f39c77 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -65,9 +65,8 @@ void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes) v4l2_event_queue_fh(sev->fh, &ev); } -static bool std_equal(const struct v4l2_ctrl *ctrl, u32 elems, - union v4l2_ctrl_ptr ptr1, - union v4l2_ctrl_ptr ptr2) +bool v4l2_ctrl_type_op_equal(const struct v4l2_ctrl *ctrl, u32 elems, + union v4l2_ctrl_ptr ptr1, union v4l2_ctrl_ptr ptr2) { unsigned int i; @@ -88,6 +87,7 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 elems, elems * ctrl->elem_size); } } +EXPORT_SYMBOL(v4l2_ctrl_type_op_equal); /* Default intra MPEG-2 quantisation coefficients, from the specification. */ static const u8 mpeg2_intra_quant_matrix[64] = { @@ -177,8 +177,8 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, } } -static void std_init(const struct v4l2_ctrl *ctrl, u32 from_idx, u32 elems, - union v4l2_ctrl_ptr ptr) +void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, + u32 elems, union v4l2_ctrl_ptr ptr) { unsigned int i; @@ -240,8 +240,9 @@ static void std_init(const struct v4l2_ctrl *ctrl, u32 from_idx, u32 elems, break; } } +EXPORT_SYMBOL(v4l2_ctrl_type_op_init); -static void std_log(const struct v4l2_ctrl *ctrl) +void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl) { union v4l2_ctrl_ptr ptr = ctrl->p_cur; @@ -334,6 +335,7 @@ static void std_log(const struct v4l2_ctrl *ctrl) break; } } +EXPORT_SYMBOL(v4l2_ctrl_type_op_log); /* * Round towards the closest legal value. Be careful when we are @@ -527,7 +529,8 @@ validate_vp9_frame(struct v4l2_ctrl_vp9_frame *frame) /* * Compound controls validation requires setting unused fields/flags to zero - * in order to properly detect unchanged controls with std_equal's memcmp. + * in order to properly detect unchanged controls with v4l2_ctrl_type_op_equal's + * memcmp. */ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, union v4l2_ctrl_ptr ptr) @@ -989,8 +992,8 @@ static int std_validate_elem(const struct v4l2_ctrl *ctrl, u32 idx, } -static int std_validate(const struct v4l2_ctrl *ctrl, u32 elems, - union v4l2_ctrl_ptr ptr) +int v4l2_ctrl_type_op_validate(const struct v4l2_ctrl *ctrl, u32 elems, + union v4l2_ctrl_ptr ptr) { unsigned int i; int ret = 0; @@ -1019,12 +1022,13 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 elems, ret = std_validate_elem(ctrl, i, ptr); return ret; } +EXPORT_SYMBOL(v4l2_ctrl_type_op_validate); static const struct v4l2_ctrl_type_ops std_type_ops = { - .equal = std_equal, - .init = std_init, - .log = std_log, - .validate = std_validate, + .equal = v4l2_ctrl_type_op_equal, + .init = v4l2_ctrl_type_op_init, + .log = v4l2_ctrl_type_op_log, + .validate = v4l2_ctrl_type_op_validate, }; void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv) diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 62052e1874bdf..121ea19d3da8c 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -1544,4 +1544,52 @@ int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd); int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ctrl_ops, const struct v4l2_fwnode_device_properties *p); + +/** + * v4l2_ctrl_type_op_equal - Default v4l2_ctrl_type_ops equal callback. + * + * @ctrl: The v4l2_ctrl pointer. + * @elems: The number of elements to compare. + * @ptr1: A v4l2 control value. + * @ptr2: A v4l2 control value. + * + * Return: true if values are equal, otherwise false. + */ +bool v4l2_ctrl_type_op_equal(const struct v4l2_ctrl *ctrl, u32 elems, + union v4l2_ctrl_ptr ptr1, union v4l2_ctrl_ptr ptr2); + +/** + * v4l2_ctrl_type_op_init - Default v4l2_ctrl_type_ops init callback. + * + * @ctrl: The v4l2_ctrl pointer. + * @from_idx: Starting element index. + * @elems: The number of elements to initialize. + * @ptr: The v4l2 control value. + * + * Return: void + */ +void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, + u32 elems, union v4l2_ctrl_ptr ptr); + +/** + * v4l2_ctrl_type_op_log - Default v4l2_ctrl_type_ops log callback. + * + * @ctrl: The v4l2_ctrl pointer. + * + * Return: void + */ +void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl); + +/** + * v4l2_ctrl_type_op_validate - Default v4l2_ctrl_type_ops validate callback. + * + * @ctrl: The v4l2_ctrl pointer. + * @elems: The number of elements in the control. + * @ptr: The v4l2 control value. + * + * Return: 0 on success, a negative error code on failure. + */ +int v4l2_ctrl_type_op_validate(const struct v4l2_ctrl *ctrl, u32 elems, + union v4l2_ctrl_ptr ptr); + #endif From patchwork Sat Jul 30 10:24:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xavier Roumegue \(OSS\)" X-Patchwork-Id: 595735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFC33C19F2D for ; Sat, 30 Jul 2022 10:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232866AbiG3KZI (ORCPT ); Sat, 30 Jul 2022 06:25:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232658AbiG3KZH (ORCPT ); Sat, 30 Jul 2022 06:25:07 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2085.outbound.protection.outlook.com [40.107.21.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FE4417A83; Sat, 30 Jul 2022 03:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SewoZVbcer3hlHR0+oowYMGq7RvH9Sj3Ct3Sj17D4Y1jUb3TPkJpC5eS5hXb94aiOqdhB/gx37t/kydFEkG3wvF3z6xkHu1VUZ2Uklu5WM7wRWPGw0lBqD293zCglI9u+l7BjrtZ39H9KC70d1XTyN21GoutUBXfnuRtLxbV041dEP57C1iiTNNnMUplF5p4lO9qMik4kg5kecBFXoxvf77f/xp5l62cK3cB796iW/y7+9WoR6zmS6mPYOgZSSc92qJBG3ouSDoLHAtPlKNj/fGmnIV4GtUm1J1HK3VcFo0EFeWwJi76IzLKVkeEN7l+3zLwUZyrYw3au49TUVeVPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c3JN9o4QcbBTMt4mLQUCzo+2bIrsNzcVwdzFt4RFoLI=; b=d/k/Q7hGHitm02Hme6CVAqpjEyUOgddejh/VFuoEwvuQvgrXUDTe7AVA1BQdExNK4Nkft3BqeeA7axanlH+HeAjzIDSp7J3GkU273XTesK05nwZPnyg58GTk1++zpowOtjKALXXmXFK9Acb9oabNOTS5yQdUM+jMm6AxdIn5mL2+b8FCmzJ3U8FaKX0LcNdbiyhUJtJwb1myi49beUK4kCcjRucKbMbvio4OO/yOX6LxCpwgt+GKCf5tXA8fhGGEWN33gdD9iDVC26EBdYtBQuITDILUsfrCgLmX9dRrbgmB7HUOaGAblSGEhHfEUpevu6Z2x5hs2XN+bjELVdLqYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c3JN9o4QcbBTMt4mLQUCzo+2bIrsNzcVwdzFt4RFoLI=; b=ktgsxXuwYsneyIMClrHeCcrKaavCucgZmrwtLrLmRDrnayaYa8yrnDN1RnXJFkz3wzh3I4h6uF8Obi2pH2g8nVRRsFNycI8RcGYUy+xDGypBUCgnf+t+IlsAM33/lA3pURPd93tsUsa3bIUecbErUidOhlxLoFIkQF5sQaDtGIc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) by PAXPR04MB8621.eurprd04.prod.outlook.com (2603:10a6:102:218::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Sat, 30 Jul 2022 10:25:02 +0000 Received: from PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f]) by PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f%9]) with mapi id 15.20.5482.014; Sat, 30 Jul 2022 10:25:02 +0000 From: Xavier Roumegue To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, stanimir.varbanov@linaro.org, laurent.pinchart@ideasonboard.com, tomi.valkeinen@ideasonboard.com, robh+dt@kernel.org, nicolas@ndufresne.ca, alexander.stein@ew.tq-group.com, ezequiel@vanguardiasur.com.ar Cc: Xavier Roumegue , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v9 3/8] media: Documentation: dw100: Add user documentation for the DW100 driver Date: Sat, 30 Jul 2022 12:24:08 +0200 Message-Id: <20220730102413.547698-4-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> References: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR1P264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2cc::9) To PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7a3ec279-a8e9-48cf-55e4-08da7215c30e X-MS-TrafficTypeDiagnostic: PAXPR04MB8621:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DyR5KuaAxkj8QxBjoFepPvpPo/57ywXu2rd65BqOty41dW2KRFuAnRrTzL191/1driNBqh5OKJgzdjwQmdRwfdNo7M1R/n7FxuQJzoJEXlKAab7VSRGino951t4pv0KcFrgSxTNTfc6wCF3PQmJ04HftrX8wXqVCKBpA377TMgBb/SInELWEWdwSiGje4eAJdu8VRKwgqxEQWXBsX2Jdw+JOsmqqMIMrj6awIw1hAGnFdYwQprkXIPkzAWyVdH4Ka/l0EI4FM3upKcniRnE5AHpHiOag/eTUFJPBh4x01VKIyLhHyN+ucjUM+jy7ceuYtJRpVh23KPk4wDJmggn4x+sEX5VbYX3KfViA6jGMhcroNdRLHJg7LH2pDkGdc1chE84FIaPt/XaItzMovKZXQn99d+ck7+djy4AZEzkYRbDY3q5p3NSoZFL1eiX4a2BbqLohDMBYe/hOgK+J5FQEMxfUmjHsmIpVrHHefpfHNdPSnjlra4n/+BQMjCMjvJJoTTiYhk43AajJhESpDoOuUzgCjojZU1xw5RwdsofeCXVMRaw3vTWvqS323zD/PBRXvWOmob4VgcK603rMcSdM8TVbsMlls54ktBrEAVW1m6W/DmtpnP2yBV6PcNxf3r+cUhotC5VN4C9lQlM+Y660kYti0jvGyyTJ/YsfmY+73ezsSCPtQKCOJ9ybi4T/3hL6g3dsuGfclPjCvXLqLRNG1yTFo7Zmoh7Y2+FAUoc1NRrVt81tEyJI/uekOPuo1+jq70J0xJvtX7Kh9ZAXqn3aZg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8703.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(366004)(39860400002)(136003)(396003)(346002)(7416002)(6512007)(4326008)(8676002)(44832011)(186003)(83380400001)(52116002)(66556008)(6506007)(38100700002)(66476007)(66946007)(2906002)(86362001)(8936002)(41300700001)(5660300002)(478600001)(1076003)(966005)(6486002)(2616005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: V/gYn5jNMi4djXAU8duQANOS7lyNIowGhFDaxUKj/hFKUfZOg5/zkQnJW063OwPmkhtA7qV8vJg6+oyaTb4qmGOdtjYfbU+skxxwg6y/LGu7M2v6N/qKl3Gg2BUr4Xo0WcXdcu4FbPfNh9gCDpI+jrPZr+mqRbiimr6xLA8LMfbcAvKxYrsGEB75Jc5SlYfDl1U/+5nB5tWBbPX+ASgohPH1vOt5aQcNBZG+ZSGsBu9gKU9bVLhkZoGlA9+k5p52RptNv+eRAchc4CgZAyDpF3TEY48nOT8PD/yDdHnvi0/qKcDDFCv2i32W8+K1xjhvh85NtB7ypoMaYGFZpAYPDm9Vz0mv0a1tVuSGOTcE5j8Jzw16sygUCBf+y7LzNTn/TBiJ4EiFyshpMHarh/qBM6zv21cycuVAJ4KGVT07IIvWYKi1c/QtC4G/p8sPyvmyhmr2nMgwYeDrwywlStsJlcOttupvU7jTAliDr8i6xch+TFlRCTZSfqpLVdccfKGWpVbPYsuBcMWF0x8JEqoIeYiE3TN2cnxD2yYoq3ZbKe2UxHvyqtZv9mmnQZcIDE0qfZ7T2ifwuqyQvjhusKT8nNQSN4lHXWe4Db8a88wDpjeMXu7/9nGtJe7u/yePpkuzBAZ5KiuXoqgiUTMTjBreX87RkINuZtKJxr8D12Hq+UefVGJxVE0/bQshkoDU9BIr64JGluZThIUhL6pf20Jm2vHJfSNm2oJDqs12y3g8H0UZTPE/PSSXYtSAAcQ8kub2B8nzV5p9YOAfo8rF9D0bBVB54KWEhoQ7mdOfU4fFqVYQ7yeR8V8UHkZkmw5fsecF7vjD6ZS1Cm5qLrTPuPZ47V2DL80Bwgb/XE5ilNFSUcWyMxigMnb3xov8zpRYl0APX0NaFoOiZ2hjSoy3MIfdAbkjniV917oy55fFvFVQokcrsqrp517esOcZaPOrxRQV0Clo4m8I1QAH0a8O0S3pcrBQdCe+wv6cwA2KLa0Ta50DcJ1ITUjqAlE4KxVx2QgIWBgTwS3XxPegqF5YBwdyRZTpSL+uwLxBSPzy32yMt1m/r4OvOjQ/oMoMw6Gcm28s1ABq0KuTSKrK+ORW43cBw7X+tB5qMNXa5ecE3IF0Qt6m+LqiL9aeJcSQdwS/SZzVug1BGMeLS6mvmdQzM34HVPkDc1MUzgoCwmBQXXBb09Mn5k9o6Uhamm+hXj+1PUjjbaR/mtH8NzLXmh8EeKp3+WGhuykafkFVRMUq0/SUd/S7ejHqQk78PrywOQQoyd9yBPL/cHoYVbTdPvwxxfAi6668G3vI0m/hOIskWgHUA/kHRT3dQFPpA4AHzqiypuAw517tUxblJM4DR3O/mzDfjDu19QnTrET3JffRrF3lo84nyimdgxbdcqWABGg6mzyzLvCfeeulwQWJ6zjBDhaAac5jzcWnhd5Nlvbx/Pp1Epu+0jwPexC5Q74k0xc/Hddhgwg23QnMKEPexxGg2RcJIfepmXp6iY5GZJg+50opMD6M+GaK/tAKdj1bIViOq4wMowNdiyH20h6Et/Ndd6Iq718oHx/z1biK3dDeymrb7GaZ8dn2s2cDNjKFG4zNvhmE3DVYDV2EYYzGMBpF0+Rdj3FSJ7e9n8tP+WIy0hPfTaRfjNzilYGco80qkTFsby4PA6tW/EoOUJO+hq9DK3/DGA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a3ec279-a8e9-48cf-55e4-08da7215c30e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 10:25:01.9972 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: P+rBZKCTHY19Ze2DECeGUxPXewqvvPXoavbW+Eo+6g9TPCOBlcpN1CNkUER6EM9PWacVfLoQaZ495yFnmslEtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8621 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add user documentation for the DW100 driver. while at it, replace spaces with tab on drivers list. Signed-off-by: Xavier Roumegue Reviewed-by: Laurent Pinchart --- .../userspace-api/media/drivers/dw100.rst | 69 +++++++++++++++++++ .../userspace-api/media/drivers/index.rst | 3 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 Documentation/userspace-api/media/drivers/dw100.rst diff --git a/Documentation/userspace-api/media/drivers/dw100.rst b/Documentation/userspace-api/media/drivers/dw100.rst new file mode 100644 index 0000000000000..1ca6fa55f539e --- /dev/null +++ b/Documentation/userspace-api/media/drivers/dw100.rst @@ -0,0 +1,69 @@ +.. SPDX-License-Identifier: GPL-2.0 + +DW100 dewarp driver +=================== + +The Vivante DW100 Dewarp Processor IP core found on i.MX8MP SoC applies a +programmable geometrical transformation on the input image to correct distortion +introduced by lenses. + +The transformation function is exposed by the hardware as a grid map with 16x16 +pixel macroblocks indexed using X, Y vertex coordinates. +:: + + Image width + <---------------------------------------> + + ^ .-------.-------.-------.-------.-------. + | | 16x16 | | | | | + I | | pixel | | | | | + m | | block | | | | | + a | .-------.-------.-------.-------.-------. + g | | | | | | | + e | | | | | | | + | | | | | | | + h | .-------.-------.-------.-------.-------. + e | | | | | | | + i | | | | | | | + g | | | | | | | + h | .-------.-------.-------.-------.-------. + t | | | | | | | + | | | | | | | + | | | | | | | + v '-------'-------'-------'-------'-------' + + Grid of Image Blocks for Dewarping Map + + +Each x, y coordinate register uses 16 bits to record the coordinate address in +an unsigned 12.4 fixed point format (UQ12.4). +:: + + .----------------------.--------..----------------------.--------. + | 31~20 | 19~16 || 15~4 | 3~0 | + | (integer) | (frac) || (integer) | (frac) | + '----------------------'--------''----------------------'--------' + <-------------------------------><-------------------------------> + Y coordinate X coordinate + + Remap Register Layout + +The dewarping map is set from applications using the +V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP control. The control contains +an array of u32 values storing (x, y) destination coordinates for each +vertex of the grid. The x coordinate is stored in the 16 LSBs and the y +coordinate in the 16 MSBs. + +The number of elements in the array must match the image size: + +.. code-block:: C + + elems = (DIV_ROUND_UP(width, 16) + 1) * (DIV_ROUND_UP(height, 16) + 1); + +If the control has not been set by the application, the driver uses an identity +map. + +More details on the DW100 hardware operations can be found in +*chapter 13.15 DeWarp* of IMX8MP_ reference manual. + +.. _IMX8MP: https://www.nxp.com/webapp/Download?colCode=IMX8MPRM diff --git a/Documentation/userspace-api/media/drivers/index.rst b/Documentation/userspace-api/media/drivers/index.rst index 12e3c512d7185..0c720ca1a27d2 100644 --- a/Documentation/userspace-api/media/drivers/index.rst +++ b/Documentation/userspace-api/media/drivers/index.rst @@ -33,7 +33,8 @@ For more details see the file COPYING in the source distribution of Linux. ccs cx2341x-uapi - hantro + dw100 + hantro imx-uapi max2175 meye-uapi From patchwork Sat Jul 30 10:24:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xavier Roumegue \(OSS\)" X-Patchwork-Id: 594596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDC7EC3F6B0 for ; Sat, 30 Jul 2022 10:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233313AbiG3KZO (ORCPT ); Sat, 30 Jul 2022 06:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232922AbiG3KZM (ORCPT ); Sat, 30 Jul 2022 06:25:12 -0400 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50071.outbound.protection.outlook.com [40.107.5.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 672F42182; Sat, 30 Jul 2022 03:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xv9jp3HLCo+2b4BMxx3RmzmIoNCCcO3PFPASib2JR8nt+YcufUAKV3Bup+r+OgL5nK6qqOgA2jceiUcP8LOgWk1KwJ5r72bBP32UqBr6wIfIY1VixumJ3ZuGjNJjYVgp3Otei9TTnb6is8Wrb4PCXjHcb0TxcRVKVDU31oPLuKt4MB54Ok8pMBlip76/dvvl3/z6yPHuHfN7YFQeSGOQaIdeeCbHyZBYQu5FWXP+01Sq6E6HQY4lsDyClKMZUe/mFkeG7StS7LooQ+U8N3FU+Jh5F4lgsbWLDb87046mFvsK6Int4r3hzTf9xQW0UThMWflb1Oaxp7QVYSQcKiHWjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F7f7zGHNQZv1eqEk4Rfa0A2wNlhS3QAzboYDRYMbrLo=; b=KeHrqcfQ2apR+Wy6ObJKf6rK8DERSxHZk58qudinrdO6q1sLbszboJj6oY9IkZ+oLcmKVxm/YkjMjvpxKZmEGjvKLdQul/F1980Sz2IJiRir2VD9er5PBlD+USECs9A7GgDCkWm3omr+WQLEoOfQfeuYg1h9qBe9AiJfp1C44E9lLVbpDT+cGY4Ck/JovGn56Sd3CfzSV48dare4xiYbZB9mOkQ15O+lHGbKcB1/b6i/Onl/+cRB3fqZq0RI3pjbdY81wLhBbeZ0VIyTBP5k8F6FfyuBbfiIEwV6bcDLxeWUeQtpXckB16upi9YEI6dVC75Eow8YzyWwvIvn1B6j3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F7f7zGHNQZv1eqEk4Rfa0A2wNlhS3QAzboYDRYMbrLo=; b=BadO5HzRL2TjBQay6tVC8xCr664lkFQiRmIefuzxgtqJmZ9gHjuloHIdXdm+EiMBdATKqZZW178A9Fz6oe9c1AoXB8Qr3XR5efTV1rXDbM58DHkSmsty0tE0zywnTfKvsZmfLaqfOPlh58mqMzFQe47LazxyvLNrCRFY+PS4rTk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) by PAXPR04MB8621.eurprd04.prod.outlook.com (2603:10a6:102:218::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Sat, 30 Jul 2022 10:25:08 +0000 Received: from PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f]) by PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f%9]) with mapi id 15.20.5482.014; Sat, 30 Jul 2022 10:25:08 +0000 From: Xavier Roumegue To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, stanimir.varbanov@linaro.org, laurent.pinchart@ideasonboard.com, tomi.valkeinen@ideasonboard.com, robh+dt@kernel.org, nicolas@ndufresne.ca, alexander.stein@ew.tq-group.com, ezequiel@vanguardiasur.com.ar Cc: Xavier Roumegue , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v9 4/8] media: v4l: uapi: Add user control base for DW100 controls Date: Sat, 30 Jul 2022 12:24:09 +0200 Message-Id: <20220730102413.547698-5-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> References: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR1P264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2cc::9) To PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf3dcb50-1632-4c54-3f95-08da7215c3a7 X-MS-TrafficTypeDiagnostic: PAXPR04MB8621:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xAgkXwaG5qxMEVE6WzkhGO+eCGpIvHOGw2ssc/6RbBRzlR2UrEKgPBxQHD2IY6WfU2LvkXAD7iHHLlIO+Ld8Yxmr86vylp4IyT+PxheJX+Ojf4TttIpsyKlfbCums1fQkJnxv8MbRYrREBDK6bxGORMyqUzjIqlByrfM8zyayiJJOfM6PqDlNo5B0lZx/4w9pbxNxLDYpTIhuUvlOI7P6uYoNA+e1KM2S1bWOcNE8xzJe3nASJj0pjZfVdT/1HDaQrPSM+i8rZWWt6tBsLPridFoLX8nvSZWL690hwQIcb30rOoVD2QwhtGHMgFZ1Gn2v2xiIM2mhi6P/XvPUGaYzuAw/NkV6atu4DEb+UTzGxNt4jSDZjAptbEDIW2S+1jlv8qbMAXdEpaDCF+CuWlsxNDhtpDWgweP6zbBRJcXCWhyaJgGRb6rDhrUC1IYeHFLyuvE2ADCTfNEGKndu987e9aH/+Iz1RaoXjVcdmltA9oT5uV0+WilHq0Qqsi7Z7bZ53OIl7ojlbvBhvdskeXfZoKaBJUaubVj57DpxNBHIovnW0KTLHFlf3Z6cLv12ALfKVasnplcrmUEJVN5aYCpLf+twAmkN2KQm74IrBh2G+msdCLYf4DbzP4V+V6rlHAXhdPXNzI6iIJPaiBbZnFCpZIiT9VO+CCSPbS7EQH+Lvvdr1C/PIv/efpRkxPx8mhsrDoQ8ob79eMzLXuf4ZEO3QqTPZAcB9Z1xkzyen5ffBHWZwdhEhlyEqH+rFXfgENT X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8703.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(366004)(39860400002)(136003)(396003)(346002)(7416002)(6512007)(4326008)(8676002)(44832011)(186003)(4744005)(52116002)(66556008)(6506007)(38100700002)(66476007)(66946007)(2906002)(86362001)(8936002)(41300700001)(5660300002)(478600001)(1076003)(6486002)(2616005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SnxBYf0q15qZfqb09F+4jUokxG/Y4mmXnyRhgU74eQcyY+eCd04BwoG/dVUezV4rGoqp7dBWFh6sV+kg/gAmNb7gsmtug0Z5g68I19NvupopHZiE2K309J6G7+pO9Oib61w8iJWYSKR56vQYlhXbhT99IW+Hw/s5Q9oewKhFNBYxT/BCIidpz+o9bBIeHTZSoN4RpRXFRZ5ULSi2mumSA5IDqVHF5JRYgiT6+mamYK8CNCz2UFzjGymirOaSsWpiFz4+TDT/t/q/zGdvSbJEiYSlPlEt9YAQm1qeZvCkcZvp2SHOMHBgBkhf8+8R800BQ4v7OQ2tD5D9po5Wt8hTKx3tvasleMWsB4Rv5hIQX2jrFL3zsZeYVdVJF3TUXRl8bmvBwz+4xrilW2gKhJjczTFweitxYSNFpyWwya+1kC/gWqPu3zLQHkV2DOw69PHWtpG55KSsphyNX4GsdGwvNtYNxmyo3sRV0O2vJnszbSIlMllbrMBhCBmAt10el7K0tRJJdu2SqVWITSnyix7f/69GbxP/nm9dR2CvlmGxYRy8gJBwfQat0fDpHV4ggQDV+4CSvp7zq6Gkzw1x0zrI04Gluk4BJ0dR5y4iK/0JLjuU77sh76xnmRayWPMRa+aKSZS8Lpw4c9cwiSwY8LhJXY0Xo2WbV2EgZEDyJ/lQvoUkhPQudSRZZVN9u5HyKvUBYRGs2D3wU3c/53wL8mNgKShdnuZs6G5PFIe4IiF3rgBwqcuQ1t/ODP5qJl+y1ivlvNBNwvZjEt9dMMQ78Rt41YGUU/ac0JBgoJngE8Vtwgna4h8xCkmnFzqD1MSzYXYkKYXZ2fgTETbOnOkf1lo4oNO1vGodRUV8wig6S+Tr5RCwLJ0LQi1D7id4Nvk1YiZnOEy+Kv946ENQgLBifzb78oiunAiF2ptjSRcK41QqRB6lPb5EliErXkPJVxND9CWBmJDRWmfUgSEZBqNw6hbUYXADjoFSkbbxw0VOJddCNK3bcyG7Oe+qAS/gSZfHw1Iw9PxGzWUANsQ2RalEOWQ8qWkFBWeJ1b22eZeCg8JlBCc9NG39F3jNc6rvSrLsbGIR6Qu+GxWKFxthKsVyeNeSQaakX6lbYIDMRbZcdtnRq4LM/A8P0o6+dLBBlT/cljUdphB7NymuhlIUNL99GbxnlRLsMf0kafrAqs1U+4AJVoClcovuI5go461hfS8eMw6YWiv5Rum3KLqXr96wfEPvb/9JC+cTfIpkSZYqeR2eAWopXwBxCU3E8dWCFd3C4vBc/QzVjNuOLt8gKwJOevIK4oUf1le3MCdJ8e6elimhlBW7RrecFoX1ORfiKphxjXSeUKhQF/N9y7e1brVy5oGPEJHIZEDMu6ztk+X+fSoeDUq+vhdhtAW0JmNQolpRc0k2OAEX831yhtfNddsbKBAttk5o1P/T+BgwAQQ5MYfkGZ/Po7fJ+4iH2ylglQkwR1P3v6P13dEaf1hIo6noPUUPa0VilQylQBm+agVhFOS697+moh7/vVslN7teND1WSsAecruw5IJp5ZRrIUM0gjgu6toCj/GyYkYISSHo0J8SzK740LQj1TxQrqYLJYq3TkEdzWREM2FCaUahb9Z50UMbrWjHwyXXzWTdu+wLApqWv4/o0IaxGIJBt4Waz9SxGT0+to/tQjsGgnmmDy31EtyfNw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf3dcb50-1632-4c54-3f95-08da7215c3a7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 10:25:03.0150 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GKmc5kYFRvkh3mKp8apl9c/jcHc6C8R/OU+eltiYVa4CNFOsVprX88WuoYbHR+Sl+4D/PwGsbU54PDmRt3AKFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8621 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a control base for DW100 driver controls, and reserve 16 controls. Signed-off-by: Xavier Roumegue Reviewed-by: Laurent Pinchart --- include/uapi/linux/v4l2-controls.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index dfff69ed88f71..0b26ebd6ca78f 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -225,6 +225,12 @@ enum v4l2_colorfx { */ #define V4L2_CID_USER_ISL7998X_BASE (V4L2_CID_USER_BASE + 0x1180) +/* + * The base for DW100 driver controls. + * We reserve 16 controls for this driver. + */ +#define V4L2_CID_USER_DW100_BASE (V4L2_CID_USER_BASE + 0x1190) + /* MPEG-class control IDs */ /* The MPEG controls are applicable to all codec controls * and the 'MPEG' part of the define is historical */ From patchwork Sat Jul 30 10:24:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xavier Roumegue \(OSS\)" X-Patchwork-Id: 595734 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1309CC19F29 for ; Sat, 30 Jul 2022 10:25:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232428AbiG3KZX (ORCPT ); Sat, 30 Jul 2022 06:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233332AbiG3KZV (ORCPT ); Sat, 30 Jul 2022 06:25:21 -0400 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50044.outbound.protection.outlook.com [40.107.5.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9730E0EB; Sat, 30 Jul 2022 03:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dx4Xw4RsJNg6+DgSpuuUwuFK7ia+ymh6kUZj6bN+gZdA9WNtycf1SMrYcN+i+XgiT17clUgYY+FP+2dMQ3I6IUk8EVry8tHil4eX8MWY9y8CDQAixzMmThlkrkKXaHe5mLm673QyDapHlyMoiCMmBB14LZoJrjryZXoSw/9A0Jhx9ypmJROtFJMM6WfMhGQcJ94KeVJseMY00x1nSS+TaTP42J5JIW14DQGlPCtiiej9Gsu6+l9kpxbOVCjRxlj5ohgo/pd2rHvgWtJVKyKTruSPbecaDRmUIHwNmyp5cotYHtFLvDwLzjaZhKG0o40VMiUahtbBaNa1hSMY0A+/Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TA35iNsFgg6Bh38FSsqTx/VG1RcGEYb11t6EST8qKK0=; b=UHORgtLuZFk1Vlp92Fl24b2TDFJkiADUs2T4gPslBqFY3ih8IJ38IcFHP2NwubAFQnSqQtz5h9EYD/Ywm39stdytL/SZdyA0Lk7JHKnBaNlgHwz4sdJ1Jdi9jLIa8UJ29e0Ss64blZtD9YswsdvthrlG8Z1/FrzsI44JOS46tcWJkFnnq8kkZhv22kYe0ZmwNE9ukNN/BomCB0JIrWT8a5MOSVzSQHZSH6bObVOh2qYjt+WQ3fHWbzTZ4gQHTgHpNf+m6nuWHsl8C4w2e7gy8B23wg2g96g5VcwIxh2UsLhEi3hI01sVGUuobUFwKld/1IFlNM57EdOZusTdcXj5/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TA35iNsFgg6Bh38FSsqTx/VG1RcGEYb11t6EST8qKK0=; b=mFMYg8DklA8jaR9boXDqKiCMVKj/5R2ShkFqNAnJHh7yOWKfsFMkVNmOMX8zQYTVVB8o8JVzzirJ07lFusy1FIrQYpkNK3T2sf3JKASVjbNtgD1iHcJBXJlG0XoFlCEFXCg3ANMq6GRzRrnj10ZX4OEztrf7gZwwDjnrjxOFFzc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) by PAXPR04MB8621.eurprd04.prod.outlook.com (2603:10a6:102:218::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Sat, 30 Jul 2022 10:25:17 +0000 Received: from PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f]) by PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f%9]) with mapi id 15.20.5482.014; Sat, 30 Jul 2022 10:25:16 +0000 From: Xavier Roumegue To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, stanimir.varbanov@linaro.org, laurent.pinchart@ideasonboard.com, tomi.valkeinen@ideasonboard.com, robh+dt@kernel.org, nicolas@ndufresne.ca, alexander.stein@ew.tq-group.com, ezequiel@vanguardiasur.com.ar Cc: Xavier Roumegue , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v9 5/8] media: uapi: Add a control for DW100 driver Date: Sat, 30 Jul 2022 12:24:10 +0200 Message-Id: <20220730102413.547698-6-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> References: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR1P264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2cc::9) To PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a8ce2a5f-618d-4654-8cf8-08da7215c736 X-MS-TrafficTypeDiagnostic: PAXPR04MB8621:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NidusxkLkrQHWkprdzl88sta4QhYK7AXhLum0uKFA6Vjw9FNQKgVf0mKL/qBHFK6ga7dL3XYn8ikYRpQrIazV8ogxi+luyHyz+GZKewtTjoFh4IKRmUFNOkLymRwDaI4TYJZmHEE4hq+tbjHf5aRH6S4Li06G9TnDCHBdSuejX1Mw60IPb10jnGA5El7f5Wq6+Uw+USeTzfOc70NyR2Mt4Mjk2MhJBpZCUJ7O8edNuaR7HmVpJbz7QJtfdFIf4i34pIEMxmX05LYSwf3JKU/QKGWCNkSJqbzSGnwbpqeRtrT+q0CBYRKbqj3k2F16YefZtoLxxthbe5LG/tW2ZhFHRMIpiydIV5IL1nt/qnCvPtUAawo/0s64h/TVE+MDAbunEcEbBrAmy3yVGXqa/Ui+dm+8QFxSNFHNcpYeuprwXXp5IC/ltFLkWDQ0tSn2Y/0QT/disYwj3NU9m3pXft2YxVq/Yyw9JYikfIvRLS2xq8yWq1I7YhxD4u9xoB0Sm5mUf5PIvZ4Yl41zPXsVxFAxeAeMayHkTG/kmk1Zgv0YUya+VJ1bqAp+7A3NI3wSGneUgLcQFEllUqkNMFjrpID0DUx89l4UC3kiK5B9B744f8Go/njENJeSGvNOx8MWpiUNgg9/k/FGFnyQxtBFw/tKPe1WdK8eEjimWqX5Q+pPCUK8r9hSsECOK/PDQ1NZTJwloMCpqaLwvITA/RPxVdOJA4YJqaSV+/LjVg1y0Xhu2CGuEHaEpocGP5oscbxvdNGuhHfi0wNn7iNxOMEIXFrPQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8703.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(366004)(39860400002)(136003)(396003)(346002)(7416002)(6512007)(4326008)(8676002)(44832011)(186003)(83380400001)(52116002)(66556008)(6506007)(38100700002)(6666004)(66476007)(66946007)(2906002)(86362001)(8936002)(41300700001)(5660300002)(478600001)(1076003)(966005)(6486002)(2616005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gLEn/XGEgreJo4RvbxZJXJK7qxlSywmyT9EsDJit9OMTronU6laMagxJGujzyTSoH9LARJn/Ug86acNKvmlB3kg64sqpAEgsna9gbdrgZxxIa++gyiflBhrMOnrkwIMwBwDILABPIdSZ41Rk1W/lXCh3AKw6w73a/1EmJNOdrhxOTrzG+DeryUU4J9uhwPBs0BhocayaGPMW+amGRufkr2zDFCGzHQGyaCvdxlJMDF2BJtBMGipbHbNOAwKQeFtfrETXkWTDjp5PGWcLHGL4AJl842f9ZeLOQVVD1VBFV/t8o9B3eP9SzjOeBNGm6gGDJGrijRqGPlwhpA7aea2m4CYD6vfKzMxUpd4apnFyN5qEllHpv2Z0hbtE+7H8yJLplgPOmAF7Zt/hqaV30Z+LS+QY/WrJ5VVorHQAgOlKk4LPbIIed1bopeZS0sysI+z98xSUQzttYCchj3zJW73Y8uxd6dm7nL4l9xle3rIxhrGoTXzxz4q5dsPXLsrZI7YwfiDyCbdrETZ5VIPKbTWZzkMMEPbrV2OiVJHZSK9m/5Bwb46S/8VLNFdX5v9TFgNC2nYscEu8thUClj6ctJH5PLj9J6rHPXSLVrapXSumrD+ipvL9SDxhTbF0WvJg0HsRzLeSUffRpduITFkwysSGny5s0ID0NfmdtSemF3N5yQqPHNpGH4eslTyVvfgcOTTqOmAg/BEox8DHJ+zEeoC4PqZEw58oaRdxc0hwkcZvVa5ablpy4MktT3tKvBpkwbLnRrFDaB5Cu+E44IquNBKzzmYCwYUhvBw9A6oz6+QqR6dJW1ydtim5qXhtXuXg9ID1LMC8ItSC3SBmSipuF+ukOXkpgP554W+fy9a0fQ0VRdWYQUH8hD0Sikoo93ZNTDwmZa0Zbq0AYEvVCOL2AZyquwQxAlc9SlYYOE5MLy5GnqjyxWrTmuHeRWyEH1cRzWuFVSlXr9y6bSWq8U6TgOqhw+RmY4fz8jdAO1i/DHqkB1HV8GP7Lhr5SaR0lxqVILNfElLTKof9UfljOkuvBLWc3boOdZ9dFEC9MZvpeCFOKNenL+6/X3h3ujTBtXpoNxpbRzASgf21JJ7057fFZzeDPI33HfyOsD7l1dHNqBo3QmXvvFx4xvbP36NOPdTis1HhQXr34Bfi+Wus7Uepdx0+N1m06j1X6ywepuQ79kUm7h/Q/o9TIM6U9B1wvBh7GivfAy1NVvK7ptl4/KNnMXZUmEgUjH+Gx/BOM7GEyKlUbxvJ2N/6ABq2Ogws4XUPmaD8NJZFJxP+g0VtRXIzQ5E6TVcEieWDs4obcybERUZUpaXwWi5GooyjXFYGY30ACdyec+1TM/JMMzE4Pbou7saBzewvRITC1bxfSb0PugUYMTHdVWUDgkkz1fudPLPxTc6ROvBlvuFkWP9xcsgI+Z/rMy493FR2Jf61vWlDzTtpP0gHu57BFV7rkbqE/qJzW6it1HfP0MYMrRL/Xt9Xa6n74Qg0YRqBmsZZeFSzCsCs2F2NqLuhzYFNyzRXK1sICiFIDqDTG+rRE79/q3f0i7f/jsgyhBN8enoInF0Krw9gfuL8wjo3S6x/W+Tq1gH1IgvZP04k0wW6FO/zHy0b8Y87YDvGezGjgyNz6nMzqYx8XYA8FzthJj5r4h+RdH/I7xSjPKhkjxEVBZrdfzv2izbzdg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8ce2a5f-618d-4654-8cf8-08da7215c736 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 10:25:08.9560 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +8MmZJa5m01B2+PiCZdW14CI5Vu2TSG/voVox/xgusxn+A1b67IVfa+kI5KkYQYroGxehM5bPu6kiqp7L7KHQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8621 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The DW100 driver gets the dewarping mapping as a binary blob from the userspace application through a custom control. The blob format is hardware specific so create a dedicated control for this purpose. Signed-off-by: Xavier Roumegue Reviewed-by: Laurent Pinchart --- .../userspace-api/media/drivers/dw100.rst | 15 +++++++++++++++ include/uapi/linux/dw100.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 include/uapi/linux/dw100.h diff --git a/Documentation/userspace-api/media/drivers/dw100.rst b/Documentation/userspace-api/media/drivers/dw100.rst index 1ca6fa55f539e..fceea6ece6221 100644 --- a/Documentation/userspace-api/media/drivers/dw100.rst +++ b/Documentation/userspace-api/media/drivers/dw100.rst @@ -66,4 +66,19 @@ map. More details on the DW100 hardware operations can be found in *chapter 13.15 DeWarp* of IMX8MP_ reference manual. +The Vivante DW100 m2m driver implements the following driver-specific control: + +``V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP (__u32 array)`` + Specifies to DW100 driver its dewarping map (aka LUT) blob as described in + *chapter 13.15.2.3 Dewarping Remap* of IMX8MP_ reference manual as an U32 + dynamic array. The image is divided into many small 16x16 blocks. If the + width/height of the image is not divisible by 16, the size of the + rightmost/bottommost block is the remainder. The dewarping map only saves + the vertex coordinates of the block. The dewarping grid map is comprised of + vertex coordinates for x and y. Each x, y coordinate register uses 16 bits + (UQ12.4) to record the coordinate address, with the Y coordinate in the + upper bits and X in the lower bits. The driver modifies the dimensions of + this control when the sink format is changed, to reflect the new input + resolution. + .. _IMX8MP: https://www.nxp.com/webapp/Download?colCode=IMX8MPRM diff --git a/include/uapi/linux/dw100.h b/include/uapi/linux/dw100.h new file mode 100644 index 0000000000000..3356496edd6b0 --- /dev/null +++ b/include/uapi/linux/dw100.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* Copyright 2022 NXP */ + +#ifndef __UAPI_DW100_H__ +#define __UAPI_DW100_H__ + +#include + +/* + * Check Documentation/userspace-api/media/drivers/dw100.rst for control details. + */ +#define V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP (V4L2_CID_USER_DW100_BASE + 1) + +#endif From patchwork Sat Jul 30 10:24:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xavier Roumegue \(OSS\)" X-Patchwork-Id: 594595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAAF8C19F29 for ; Sat, 30 Jul 2022 10:25:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233543AbiG3KZn (ORCPT ); Sat, 30 Jul 2022 06:25:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232979AbiG3KZa (ORCPT ); Sat, 30 Jul 2022 06:25:30 -0400 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50049.outbound.protection.outlook.com [40.107.5.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2F2A15A33; Sat, 30 Jul 2022 03:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HbnqQpvn82FAKHNAjLsN/HLhRTNK3mUVFU1eaC6lojnWDL8BhONuBde6Igg6G/ub+PvGQUe/rkQNyBi2SNCtdjkR9lMs5C9PyIrdmULUnLqNUCK2mrZxEoUI+h1WG+XkdoCN3AGDa+XJTy80zLiqEGab2LK0SKRKrcBKrrOD0fWzZ1DYQGapPjq/G/Thzp7V60RZ4gU4VOXeg0HSyDcMRKdwYkv2Jxvwy3dP+nGwtTUNMcDABd7xj4v2azrn3vG1PzzqF/U/NrIwwPYk+dQZGYjSkDeDsNbqkqo02Y6NsEHe0OA29hBUo3t27N1BcOI/pyyNaAc0QQI9BPgYU6rPhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+FnXg9WgfK6jD46+KNdYNCPgkVYf5pSHdRNAeKQzj+A=; b=fRzlkv5JM/EbU9AZ0mM95g17oEsnboVkTwLWl9LdUqAE+ZpmriaLxU6ay9e9p5pSfRNoLKEeYi4pFWHYXkF479vLV2SkEo6DC026NTDNWwVZr94wAi0iy9St+C0hM2YOvNk0dFu+yCqUZaa98qH+dEYZsoUfX5ZTAK2ZawVGrrCjrNJvas3P3X1pPMRqplK9CUMXYVPLCWTZ3npi6dG0rA9DnAzmqEPuF6nZVpvxaoWvVtbgK1YqI5gXcHeIhOpXUs3W/p370eoza0JBQ8tmzdNPp9KixxAIbb1nIsoImVidhL45c99be67zt9BUlieGmqgUPnffg1JfBrGPbZUhSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+FnXg9WgfK6jD46+KNdYNCPgkVYf5pSHdRNAeKQzj+A=; b=YIvtYlqOWWh5DVIGuYhOrvThYdLP34GunBogMeZ+gaHonj6gfK5RFdAMqNhalxMkY40y1c11UKSJ0Bm/tH1JNx3fmYlnrpJHA21HUlRNU7SA4heQrBGrzykFCu3+jYOcCWu6g9ta7xAoCW0mxWyJuSoCVFmSJ81zYsaglvLidi4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) by PAXPR04MB8621.eurprd04.prod.outlook.com (2603:10a6:102:218::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Sat, 30 Jul 2022 10:25:26 +0000 Received: from PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f]) by PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f%9]) with mapi id 15.20.5482.014; Sat, 30 Jul 2022 10:25:25 +0000 From: Xavier Roumegue To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, stanimir.varbanov@linaro.org, laurent.pinchart@ideasonboard.com, tomi.valkeinen@ideasonboard.com, robh+dt@kernel.org, nicolas@ndufresne.ca, alexander.stein@ew.tq-group.com, ezequiel@vanguardiasur.com.ar Cc: Xavier Roumegue , linux-media@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring Subject: [PATCH v9 6/8] media: dt-bindings: media: Add i.MX8MP DW100 binding Date: Sat, 30 Jul 2022 12:24:11 +0200 Message-Id: <20220730102413.547698-7-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> References: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR1P264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2cc::9) To PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 80e7a6b7-139c-4e53-715b-08da7215cacc X-MS-TrafficTypeDiagnostic: PAXPR04MB8621:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /nTF9LL7gZgDQCTzoLHiMWncV9KbDPN0l43JcIoS85GGwO4fy1YP/3pY65+E4z5aLC4/kpCS3CdjXdrw+UNmnTIfZvF0LPC8sNQd6WUtlnmki2XQX6KdPiqERIYVZqc9Tffz4rIwY3bOy2JBMQjHMyLlmBRHYfmmzPqsooomIXaaD/DbXvQCaoIZ2L92NYkR62C6+HDXU516wrBs/5iBHSQePqi4IzGiLp0BhXe6eTzYgdxjvXcochurQcb4FuBmd45YSvAfM/H5d25bgmRJF+r5txEtRtg4++vuvrf11vH3EI6RxfPIVYoAJZs/YfKX4OAEE/sWSVTgKzcMiUEYWjj1eiBhLw12+2RC8ymOUy33qixwoIvqZ4NEEhQWV5hd9vajSbUQ/gBuc6mCQiuOA6lUINd1TYrq2BYsoFLhONzEa4Vf7a5vNe7qYwxdHplhXAkVumrS89g8XbZe6IflCCeJYJ44n5Mzi7goo/wcRmi/JzX5d/38aq4JKCU7HYjJyRQx6ejsXYt/2aDE8i77k1pRmqw160mmVd8rJqRKEasEOrcBASsz7X6esM80xwUbdpE0aaJB8KyNYruNHyxf2N3BcvW9wLSQjl5ddtB5k+Mu3IUHu6DPBKX6TaqoKIWvqZpCfrC35gEgO7rDUnP9MIRqTPo7RSdwpHYn4KOnjSZrwkYG4wV+PgQq4tKKpvPhN/qnK/jwFgVk3pb1hi/Z2KphIRVR9CJvOYuwUcZOOEyVAH9cEAW9hXt2jMoqTwvlossy8pbcDvATXqx8NuGKs/WJR8fKK4Mi+Ul2Lt36loE9VMJKFOk1ufjQKaBm+KUW X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8703.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(366004)(39860400002)(136003)(396003)(346002)(7416002)(6512007)(4326008)(8676002)(44832011)(186003)(83380400001)(52116002)(66556008)(6506007)(38100700002)(6666004)(66476007)(66946007)(2906002)(86362001)(54906003)(8936002)(41300700001)(5660300002)(478600001)(1076003)(966005)(6486002)(2616005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UTXeRzewbFEacrBvpIWg5pXVAjUJawY43+YmGooymBlJIjpi2eYRlwcgE+Z0cjYJu7jP+NziuW6VeVWkMZYhUNfG2qYarhpm2nq9P3VLrtT2I8sIc854LS62YlJwAc5DvTRuuesSo/7felDci3gSDEJQ9qKZGhkFHlc/Pku80nT/a/yQR5+6odqw8kfo2zWDeBCcdb8EhISsmUFevhAYmrGqylj3q7AwaGHTg10QY5hY5R0rFGvZnfrjcPV+EqPjbL2cCqXfTA7HJlZJkKeelJAYvP0aWIpw3qVqLnEijrO7vKRuhg5YSfAvZjan3LaorwHehWYuf4PGOPRYkp7oS5Ux0Ts6C8NMtd8H5K6U/EUOO41rDEkTt0+Y3az/oC8TePwU32iEySMu+4k5+o6+NntkKAo68Xikvfr3qiFYaizsSF+H4Jgra1TwSvgwQXDVkawWpBKZGNk4sQ1O0f894eYi9oqqXGk12NnzRvTD8G/HFBO7x/i8BG3CXPMfEsmP1hPmWLjQ/OsQmhMdnii4P6e58MjtNkvO3pcAKGdymugG6Qv8wtCdQi8xFLI4r6S/AVqyMn0PgIcH3p/pA+xBHFeSbYgAwR27MK26t54auuuA4mRTjeWXwFJEl5JtQewE2ksXNN80+kk2sSNrOi2yiILbq9laBx2WiMV2M7kodfvulrZPfK9KW6yYkYYtXl4nUFhYz3wRbz1kAngVP0Q0+vxq7BHHrFr5OlRSrAY8qtxmBg9++S6Kf628Som6pMOdJ4aKZ4tEIHO2GFZ3H9k/lK2qwP1iVG7bvptiAdM8L1FsygC0jLVTkLnAZ8N2O++7GDxbsDgkOhFKHAjFsjokN8zAtt2jW7ls/LbOyZuokqoG4a7vorRfuzzIEHV+MK9mrxc9ec8F5qDrwNiQ9eA4OM8tUy1E4/yZ6WETonvRbZ5MRw1HGThb9ztKlDnBz/X7M1wX6lkzGRJjFLm+4L1phdrO32pYvtl7bKYYo4rizVwY0x5oeqU6ziL0dKWpzoVBI/1kraQKW2hh/HQ2i9gmJTEsrkdPUReH2WWEnMuCscp3Ygtds0iHrGpDrz58Wy3pdcbqDUfDBrIirP7bTgAjW1yxDWkJl9HddFx+CTY1IU6Ik7kNQcQL4pcCdSxX1KBLc5CSrTXqtjYJT/+xxk9LR/+foYMyHFvftV8/QF1+tJJHXGjzRBVtZn0bSjWn0U9/JZsvoAZcXSmVLD+8W9+cb9TkCnoppzXuJLXNK90FCIx/pOiCpfJ2DKcstq20vzEXPPQkJ8Lg3vOKI2yS+vhTs0KqMMxLvYk7neOTSpclz57V3YnG1Z6JxFyzIhYih1+86bH92lv/rj1xweDYRYbqqyxPagLEmdJazDvqF19IVu7oD9sHOFx6w77Y6QHYC0hieooBYLTSyd9d6NdX7Qax7mcw4qeeLaGelpQdxM1phDFdFmO/uWJy8glvRpXhrycUT0FqYZ6fqG2x2eyRt84ArOj0nqQJ1lQclB54PMaI7re/mo5pkbc27T0msZZ0adurgcq1V5orHadEkoZv3IA59B2tN2j4oejL2gMYeLvlHN8fiIuGgpvWIdtQ/zjUxKFmK4aV6Bv+ePzM1/61BGgBp0YKo6jkaUPaA2YFd2jMiEAdAcuEfoPI6VZKL5Fon5/Lfi47QtNLfbviLyIwW8PJiA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80e7a6b7-139c-4e53-715b-08da7215cacc X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 10:25:15.0496 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UvseqEmXWriuRSxyaDg3uDbnPlRGbLZ+f8QNnOSAiBVND6OxeYc0U+pICRAal4+SkZ/95tAQ2hd2gyU26mbq8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8621 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add DT binding documentation for the Vivante DW100 dewarper engine found on NXP i.MX8MP SoC Signed-off-by: Xavier Roumegue Reviewed-by: Laurent Pinchart Reviewed-by: Rob Herring --- .../devicetree/bindings/media/nxp,dw100.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/nxp,dw100.yaml diff --git a/Documentation/devicetree/bindings/media/nxp,dw100.yaml b/Documentation/devicetree/bindings/media/nxp,dw100.yaml new file mode 100644 index 0000000000000..21910ff0e1c37 --- /dev/null +++ b/Documentation/devicetree/bindings/media/nxp,dw100.yaml @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/nxp,dw100.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP i.MX8MP DW100 Dewarper core + +maintainers: + - Xavier Roumegue + +description: |- + The Dewarp Engine provides high-performance dewarp processing for the + correction of the distortion that is introduced in images produced by fisheye + and wide angle lenses. It is implemented with a line/tile-cache based + architecture. With configurable address mapping look up tables and per tile + processing, it successfully generates a corrected output image. + The engine can be used to perform scaling, cropping and pixel format + conversion. + +properties: + compatible: + enum: + - nxp,imx8mp-dw100 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: The AXI clock + - description: The AHB clock + + clock-names: + items: + - const: axi + - const: ahb + + power-domains: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - power-domains + +additionalProperties: false + +examples: + - | + #include + #include + #include + + dewarp: dwe@32e30000 { + compatible = "nxp,imx8mp-dw100"; + reg = <0x32e30000 0x10000>; + interrupts = ; + clocks = <&clk IMX8MP_CLK_MEDIA_AXI_ROOT>, + <&clk IMX8MP_CLK_MEDIA_APB_ROOT>; + clock-names = "axi", "ahb"; + power-domains = <&media_blk_ctrl IMX8MP_MEDIABLK_PD_DWE>; + }; From patchwork Sat Jul 30 10:24:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xavier Roumegue \(OSS\)" X-Patchwork-Id: 595733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6134C19F29 for ; Sat, 30 Jul 2022 10:25:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233332AbiG3KZs (ORCPT ); Sat, 30 Jul 2022 06:25:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233344AbiG3KZn (ORCPT ); Sat, 30 Jul 2022 06:25:43 -0400 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50060.outbound.protection.outlook.com [40.107.5.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB8DB167CF; Sat, 30 Jul 2022 03:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lmPBpWKMeR/8VhRURb2UFbN0hvyGisEEc2ZTeuHHRT+LwyWndMy7cZ2CzJHTLYn5pdoL4fYZ0ac/HTIfp87mRBjJ1DwHYqmEKuHHezIx3WH9szFgNzxWa//UG6QaYCzd5OqgkNvWozeavKBPzUtGAlGyQcG1sDGsZIwiasuPOK9jhz8UVh/Y6xWajRzY/7uJsdqb/4SscNI0xMPFsHxhBSZaWmiQuyiODX884xjJ9scprxyqk6ToOcAA/WCrcR+UpiRdHMxSmGWAXZhS/JTEElCUNYJ0IAmaYgUprGUIRBGiyrz8NYsBIUzkU6199lH1IRkObkzFtr1uTE++vxxavA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MUFuhrAlijvOw9x36u1yrzhWeVUXGrNVj7PR1J/JVYk=; b=BB9nR/x/B4Z+aIil0z2opaidoW8l16NmaI2nfZZW8hp7fEw31oak1x7WPNp+c4Bg/ci5A8d1gz0jciYhihGiiIl9XOaCI2YZ2aS8Piirzl1GxJwXe4iTSL3IlHodJN0ouM3xR7g/jigGxdF8Hjzl/Yei3VE/WTmBrgajdw5quymv/TMt82vb+YikM1DT5T8A9FQQXl51a8U/mIVrNpWlRgRrvZH2+8DpQxN3GmSC/31eWtZ8w9NMAla7XJliurqXJFJ5f9gXvMhOGLdxKlhaeCC0THrclb8PGbdMrCE3FmUfyN8TFjM+RNSbAabOIhS+TFYH9kwu6pn5PNFeotHs7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MUFuhrAlijvOw9x36u1yrzhWeVUXGrNVj7PR1J/JVYk=; b=JjDSC9OSGqtuz0B1LcoqQkgIU7QC04Vbcm4uSyJGgwPvNpixpyvDPZXYPe9fOlpfhE+VTuSSrc8+pqQz2gaq4RTxe5R1Rr0joyBi0tiTo6k0M8KPF4q01KJdgI3JaiRywesBmalNGE9Rm042KugZLHF07u53TWPyiT5u3BWdzXo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) by PAXPR04MB8621.eurprd04.prod.outlook.com (2603:10a6:102:218::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Sat, 30 Jul 2022 10:25:35 +0000 Received: from PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f]) by PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f%9]) with mapi id 15.20.5482.014; Sat, 30 Jul 2022 10:25:35 +0000 From: Xavier Roumegue To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, stanimir.varbanov@linaro.org, laurent.pinchart@ideasonboard.com, tomi.valkeinen@ideasonboard.com, robh+dt@kernel.org, nicolas@ndufresne.ca, alexander.stein@ew.tq-group.com, ezequiel@vanguardiasur.com.ar Cc: Xavier Roumegue , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v9 7/8] media: dw100: Add i.MX8MP dw100 dewarper driver Date: Sat, 30 Jul 2022 12:24:12 +0200 Message-Id: <20220730102413.547698-8-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> References: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR1P264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2cc::9) To PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 07497a56-e4fe-46df-9e47-08da7215ceb4 X-MS-TrafficTypeDiagnostic: PAXPR04MB8621:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yGxTzFvHhX9tfOUddWEuqa7uqiYwN4JBNx0omr6Nt2ksn88phjAz0BP7ueqECt2NAtsVsjZUQiiRCn22wrrBuNzhdgd4b4Y/EOCl52i5w2HAmkRkae3fedB01PZAAGgsMd0aYroSmO/TTFlDARXoH6ywZn1F5asvbvmhbwD9Sh+WHXIcss6NnBVG+BXItDSeHLJLkXJ4+xgvl0dMkkDtxjrHj1Do1PNYUWclDzkzMSRa4uJizyB4MrvYpzmFFU1Kfbo0Dm+Y/AiJVXeI+Jl/bHUP7pTCzA2FTbK68EPv98R0+QrS69g8jkLUVNnVoX6DZ4kdguQjRULWJDioeGVradnsq2A4KiFjaJWp8H6jEuZJA+kv0JSZhsMv14sGUAw/x14ZjsXhGYFDikOUHOu8wZm+fEpECpjFlyTuTv8r+nwp75QfrcYvSujhRZh9ib0eKrivSOaYrlG/XO6H3QTAj4y1gTk3GVTpXL7Ay8DN0fjF0RcdKKat7IYFOON9WUkGvL+xQnPVwAX/40DGRy3At3Ps0Y2/hC88pYQYd4DrvsnxRpInC7Ci1X1bFRKju+Ga6tTmN1HdrvsfcJSmjyAcKyLqI+iYPnCkTnT565/vkad9ItqJC6AA/WrrRb1HZ+QUghjTPip//u5WIbdm37hjEpfYftc3UdpTZKmMI2StJYC/QdFgvSetYRabjsJ4z+9krokup7aUnyadpyhMwen201MS+gg/RE6HzuAnzxCgOqjje68bO6y0Y3djs0Rn565d X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8703.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(366004)(39860400002)(136003)(396003)(346002)(7416002)(6512007)(4326008)(8676002)(44832011)(186003)(83380400001)(30864003)(52116002)(66556008)(6506007)(38100700002)(6666004)(66476007)(66946007)(2906002)(86362001)(8936002)(41300700001)(5660300002)(478600001)(1076003)(6486002)(2616005)(316002)(579004)(559001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: R2dAYA+GzkemqXF0DiB2VedDNouP4ZYtaOdYcrWyT2uYwaxudRz2Y+mXbiTi/V1MXKeKvfOY9gpRgUn8HGW4QK0YMlgh25Im6nckizOv8Gf69nVNJjE44yji+ApLBvD6ws84SU7j4866SrUfLqBkLJKdM8Yx0M/AibWpaDXdBrMwa1/f2gsDO6AGeTdvEDv9Mh4fC8I1dV6YTWxR1ZEIbinDeB1Hi3kOAYih6CHbrsKRD5462fxj+5GRrjd/mc2bQuUz7i9oanybzBLDjAuMFoDgbzT7gymCxiH0snDCn9N0lBCJl+mtJkOjgsEej+dcfcreP/ptlnh0ezh8zYtJKLqlt3A8OgF/ay+Wo1J8jdPIQn8bNcK48Oy8IExENY75a1fc+XxOHxQcFwE1On6TYSc1Lhe7RQLAKMn76VrcRrB8HQl6M7bVx4InFy1glAtUXpl7ZyDWynW0auH3XPindDcAAUQlUK9a0z+XLsiedeZVBYk2pGMI0ZkmAqbNcEq8nM++RFOc8uv4Zi55Ebdk50IXwu560lASXMM00jEjuXsupMiSr27O3UG3CDBjlmRMPmvFzYtGrSySjJ0Gj5bfg6lrX/C7sWl7SAro1qkHuowQa+PR0FS7fUTKBmjVzCe90LEcsVd2j5lFdxnf4SwSDVvcPHUB/6ywXRT3uX8EzNVimomRShchG90S1wAkJxSJKc0CVeX2GD+r7z02i9lYzhgRObuZJ1hMot4rOq1gTLCOEx0GKJR/eugPVsdxLO2lu+u9PJfybYZK+WDzU0NEN/H4lap5xGQvV28sljPakn+WSrav7/B9e5j4GuaE7YIUqUxZlSsMvU8OG6Axm1yiaZQ+V+kJVFVv5lGzNUOQqI01EyxLTuRAaqr3ltJegFutOmPNxU/3gPn8tWue4NeYAvqynlfyFQbQvLBWpQyWlQsUXGoAZT8IoUAvutD4KjEZ8+w6KmBWyN3fq1qeCMZ+97U5nYnktAwN9dDDcUa92PeJ0F+2poJEJj1Os5zW/zC0z6DPsWncMS6OpH89c0w4Rtk5xXWXE7iD/uN9NYlc178QSbYZMNGjyd1CbeZrr4VGLNkjHVmqz/k7MIgn57umtkqYFOKoajDLy/1jxfq6wQviXSsZkVKUJlhNtzs7mzl4wnDpjGNCIAW9xHiEkawSZFl2i8yqtWQhrgrwapSsCXkN3erynnxMsuMf5zFpPOxJ0htQG3RdDpmkPdIS6oz3HnQh2xWN+3CR7RXipAJEuNIZuvHZu2xbbypkcqHBqiuebFiYhMByYvypb0XJM93AOFHy66Xs3x3QpLqTp26nPmiaTmmDfHzLXeCJ8ZmxtWWIlmD5XifzvCcDEdoE9Ym8oOoU2eLeG7QZNWLTUggNsyimPN5ZPgwrIgZ6KiyyMsXU20oCPTd9oa3ZPXKMXLsN6QiAhlg5sGYt6o6s6CdrmxsKeFoovlWYqOyZ1YE67eNAIEanQqP6dEPbwP+XTeo4usG/fHWpmlPiZ2tbcTEb6YwYMcyKNvdkkXwEpbGSdMosFeKCNZHmNU3h/MKsLXtkrXLi3PtZAhP5NsfQfacfn9Xk1a+/qgJ16qblpCgIiPXcrJil8Boa5X4jMmX4YRQl545/U7bpESuYjY8VcCn9QzWRc5BUvIyGY4vKOlfV+COmQ5AJTOk6ihnSWisImGyUJA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07497a56-e4fe-46df-9e47-08da7215ceb4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 10:25:21.6200 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8xDqvSsS5bXAoMRn/Zcp+U6d86xtkQlU2yHgc52FJiFNEB7ndzZmROkbVLnLzyi0atd/Y8hrD0oEZnw9Z5h3Vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8621 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a V4L2 mem-to-mem driver for the Vivante DW100 Dewarp Processor IP core found on i.MX8MP SoC. The processor core applies a programmable geometrical transformation on input images to correct distorsion introduced by lenses. The transformation function is exposed as a grid map with 16x16 pixel macroblocks indexed using X, Y vertex coordinates. The dewarping map can be set from application through a dedicated v4l2 control. If not set or invalid, the driver computes an identity map prior to starting the processing engine. The driver supports scaling, cropping and pixel format conversion. Signed-off-by: Xavier Roumegue Reviewed-by: Ezequiel Garcia Reviewed-by: Laurent Pinchart --- drivers/media/platform/nxp/Kconfig | 1 + drivers/media/platform/nxp/Makefile | 1 + drivers/media/platform/nxp/dw100/Kconfig | 17 + drivers/media/platform/nxp/dw100/Makefile | 3 + drivers/media/platform/nxp/dw100/dw100.c | 1712 +++++++++++++++++ drivers/media/platform/nxp/dw100/dw100_regs.h | 117 ++ 6 files changed, 1851 insertions(+) create mode 100644 drivers/media/platform/nxp/dw100/Kconfig create mode 100644 drivers/media/platform/nxp/dw100/Makefile create mode 100644 drivers/media/platform/nxp/dw100/dw100.c create mode 100644 drivers/media/platform/nxp/dw100/dw100_regs.h diff --git a/drivers/media/platform/nxp/Kconfig b/drivers/media/platform/nxp/Kconfig index 1ac0a6e911111..4c76656e353ea 100644 --- a/drivers/media/platform/nxp/Kconfig +++ b/drivers/media/platform/nxp/Kconfig @@ -51,4 +51,5 @@ config VIDEO_MX2_EMMAPRP memory to memory. Operations include resizing and format conversion. +source "drivers/media/platform/nxp/dw100/Kconfig" source "drivers/media/platform/nxp/imx-jpeg/Kconfig" diff --git a/drivers/media/platform/nxp/Makefile b/drivers/media/platform/nxp/Makefile index efc38c6578ce5..22ba28ac6d633 100644 --- a/drivers/media/platform/nxp/Makefile +++ b/drivers/media/platform/nxp/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-y += dw100/ obj-y += imx-jpeg/ obj-$(CONFIG_VIDEO_IMX_MIPI_CSIS) += imx-mipi-csis.o diff --git a/drivers/media/platform/nxp/dw100/Kconfig b/drivers/media/platform/nxp/dw100/Kconfig new file mode 100644 index 0000000000000..45e01baf3b27b --- /dev/null +++ b/drivers/media/platform/nxp/dw100/Kconfig @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config VIDEO_DW100 + tristate "NXP i.MX DW100 dewarper" + depends on V4L_MEM2MEM_DRIVERS + depends on VIDEO_DEV + depends on ARCH_MXC || COMPILE_TEST + select MEDIA_CONTROLLER + select V4L2_MEM2MEM_DEV + select VIDEOBUF2_DMA_CONTIG + help + DW100 is a memory-to-memory engine performing geometrical + transformation on source images through a programmable dewarping map. + + To compile this driver as a module, choose M here: the module + will be called dw100. + diff --git a/drivers/media/platform/nxp/dw100/Makefile b/drivers/media/platform/nxp/dw100/Makefile new file mode 100644 index 0000000000000..49db80589e9a6 --- /dev/null +++ b/drivers/media/platform/nxp/dw100/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_VIDEO_DW100) += dw100.o diff --git a/drivers/media/platform/nxp/dw100/dw100.c b/drivers/media/platform/nxp/dw100/dw100.c new file mode 100644 index 0000000000000..e5cac8c257684 --- /dev/null +++ b/drivers/media/platform/nxp/dw100/dw100.c @@ -0,0 +1,1712 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * DW100 Hardware dewarper + * + * Copyright 2022 NXP + * Author: Xavier Roumegue (xavier.roumegue@oss.nxp.com) + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include "dw100_regs.h" + +#define DRV_NAME "dw100" + +#define DW100_MIN_W 176u +#define DW100_MIN_H 144u +#define DW100_MAX_W 4096u +#define DW100_MAX_H 3072u +#define DW100_ALIGN_W 3 +#define DW100_ALIGN_H 3 + +#define DW100_BLOCK_SIZE 16 + +#define DW100_DEF_W 640u +#define DW100_DEF_H 480u +#define DW100_DEF_LUT_W (DIV_ROUND_UP(DW100_DEF_W, DW100_BLOCK_SIZE) + 1) +#define DW100_DEF_LUT_H (DIV_ROUND_UP(DW100_DEF_H, DW100_BLOCK_SIZE) + 1) + +/* + * 16 controls have been reserved for this driver for future extension, but + * let's limit the related driver allocation to the effective number of controls + * in use. + */ +#define DW100_MAX_CTRLS 1 +#define DW100_CTRL_DEWARPING_MAP 0 + +enum { + DW100_QUEUE_SRC = 0, + DW100_QUEUE_DST = 1, +}; + +enum { + DW100_FMT_CAPTURE = BIT(0), + DW100_FMT_OUTPUT = BIT(1), +}; + +struct dw100_device { + struct platform_device *pdev; + struct v4l2_m2m_dev *m2m_dev; + struct v4l2_device v4l2_dev; + struct video_device vfd; + struct media_device mdev; + /* Video device lock */ + struct mutex vfd_mutex; + void __iomem *mmio; + struct clk_bulk_data *clks; + int num_clks; + struct dentry *debugfs_root; +}; + +struct dw100_q_data { + struct v4l2_pix_format_mplane pix_fmt; + unsigned int sequence; + const struct dw100_fmt *fmt; + struct v4l2_rect crop; +}; + +struct dw100_ctx { + struct v4l2_fh fh; + struct dw100_device *dw_dev; + struct v4l2_ctrl_handler hdl; + struct v4l2_ctrl *ctrls[DW100_MAX_CTRLS]; + /* per context m2m queue lock */ + struct mutex vq_mutex; + + /* Look Up Table for pixel remapping */ + unsigned int *map; + dma_addr_t map_dma; + size_t map_size; + unsigned int map_width; + unsigned int map_height; + bool user_map_is_set; + + /* Source and destination queue data */ + struct dw100_q_data q_data[2]; +}; + +static const struct v4l2_frmsize_stepwise dw100_frmsize_stepwise = { + .min_width = DW100_MIN_W, + .min_height = DW100_MIN_H, + .max_width = DW100_MAX_W, + .max_height = DW100_MAX_H, + .step_width = 1UL << DW100_ALIGN_W, + .step_height = 1UL << DW100_ALIGN_H, +}; + +static const struct dw100_fmt { + u32 fourcc; + u32 types; + u32 reg_format; + bool reg_swap_uv; +} formats[] = { + { + .fourcc = V4L2_PIX_FMT_NV16, + .types = DW100_FMT_OUTPUT | DW100_FMT_CAPTURE, + .reg_format = DW100_DEWARP_CTRL_FORMAT_YUV422_SP, + .reg_swap_uv = false, + }, { + .fourcc = V4L2_PIX_FMT_NV16M, + .types = DW100_FMT_OUTPUT | DW100_FMT_CAPTURE, + .reg_format = DW100_DEWARP_CTRL_FORMAT_YUV422_SP, + .reg_swap_uv = false, + }, { + .fourcc = V4L2_PIX_FMT_NV61, + .types = DW100_FMT_CAPTURE, + .reg_format = DW100_DEWARP_CTRL_FORMAT_YUV422_SP, + .reg_swap_uv = true, + }, { + .fourcc = V4L2_PIX_FMT_NV61M, + .types = DW100_FMT_CAPTURE, + .reg_format = DW100_DEWARP_CTRL_FORMAT_YUV422_SP, + .reg_swap_uv = true, + }, { + .fourcc = V4L2_PIX_FMT_YUYV, + .types = DW100_FMT_OUTPUT | DW100_FMT_CAPTURE, + .reg_format = DW100_DEWARP_CTRL_FORMAT_YUV422_PACKED, + .reg_swap_uv = false, + }, { + .fourcc = V4L2_PIX_FMT_UYVY, + .types = DW100_FMT_OUTPUT | DW100_FMT_CAPTURE, + .reg_format = DW100_DEWARP_CTRL_FORMAT_YUV422_PACKED, + .reg_swap_uv = true, + }, { + .fourcc = V4L2_PIX_FMT_NV12, + .types = DW100_FMT_OUTPUT | DW100_FMT_CAPTURE, + .reg_format = DW100_DEWARP_CTRL_FORMAT_YUV420_SP, + .reg_swap_uv = false, + }, { + .fourcc = V4L2_PIX_FMT_NV12M, + .types = DW100_FMT_OUTPUT | DW100_FMT_CAPTURE, + .reg_format = DW100_DEWARP_CTRL_FORMAT_YUV420_SP, + .reg_swap_uv = false, + }, { + .fourcc = V4L2_PIX_FMT_NV21, + .types = DW100_FMT_CAPTURE, + .reg_format = DW100_DEWARP_CTRL_FORMAT_YUV420_SP, + .reg_swap_uv = true, + }, { + .fourcc = V4L2_PIX_FMT_NV21M, + .types = DW100_FMT_CAPTURE, + .reg_format = DW100_DEWARP_CTRL_FORMAT_YUV420_SP, + .reg_swap_uv = true, + }, +}; + +static inline int to_dw100_fmt_type(enum v4l2_buf_type type) +{ + if (V4L2_TYPE_IS_OUTPUT(type)) + return DW100_FMT_OUTPUT; + else + return DW100_FMT_CAPTURE; +} + +static const struct dw100_fmt *dw100_find_pixel_format(u32 pixel_format, + int fmt_type) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(formats); i++) { + const struct dw100_fmt *fmt = &formats[i]; + + if (fmt->fourcc == pixel_format && fmt->types & fmt_type) + return fmt; + } + + return NULL; +} + +static const struct dw100_fmt *dw100_find_format(struct v4l2_format *f) +{ + return dw100_find_pixel_format(f->fmt.pix_mp.pixelformat, + to_dw100_fmt_type(f->type)); +} + +static inline u32 dw100_read(struct dw100_device *dw_dev, u32 reg) +{ + return readl(dw_dev->mmio + reg); +} + +static inline void dw100_write(struct dw100_device *dw_dev, u32 reg, u32 val) +{ + writel(val, dw_dev->mmio + reg); +} + +static inline int dw100_dump_regs(struct seq_file *m) +{ + struct dw100_device *dw_dev = m->private; +#define __DECLARE_REG(x) { #x, x } + unsigned int i; + static const struct reg_desc { + const char * const name; + unsigned int addr; + } dw100_regs[] = { + __DECLARE_REG(DW100_DEWARP_ID), + __DECLARE_REG(DW100_DEWARP_CTRL), + __DECLARE_REG(DW100_MAP_LUT_ADDR), + __DECLARE_REG(DW100_MAP_LUT_SIZE), + __DECLARE_REG(DW100_MAP_LUT_ADDR2), + __DECLARE_REG(DW100_MAP_LUT_SIZE2), + __DECLARE_REG(DW100_SRC_IMG_Y_BASE), + __DECLARE_REG(DW100_SRC_IMG_UV_BASE), + __DECLARE_REG(DW100_SRC_IMG_SIZE), + __DECLARE_REG(DW100_SRC_IMG_STRIDE), + __DECLARE_REG(DW100_DST_IMG_Y_BASE), + __DECLARE_REG(DW100_DST_IMG_UV_BASE), + __DECLARE_REG(DW100_DST_IMG_SIZE), + __DECLARE_REG(DW100_DST_IMG_STRIDE), + __DECLARE_REG(DW100_DST_IMG_Y_SIZE1), + __DECLARE_REG(DW100_DST_IMG_UV_SIZE1), + __DECLARE_REG(DW100_SRC_IMG_Y_BASE2), + __DECLARE_REG(DW100_SRC_IMG_UV_BASE2), + __DECLARE_REG(DW100_SRC_IMG_SIZE2), + __DECLARE_REG(DW100_SRC_IMG_STRIDE2), + __DECLARE_REG(DW100_DST_IMG_Y_BASE2), + __DECLARE_REG(DW100_DST_IMG_UV_BASE2), + __DECLARE_REG(DW100_DST_IMG_SIZE2), + __DECLARE_REG(DW100_DST_IMG_STRIDE2), + __DECLARE_REG(DW100_DST_IMG_Y_SIZE2), + __DECLARE_REG(DW100_DST_IMG_UV_SIZE2), + __DECLARE_REG(DW100_SWAP_CONTROL), + __DECLARE_REG(DW100_VERTICAL_SPLIT_LINE), + __DECLARE_REG(DW100_HORIZON_SPLIT_LINE), + __DECLARE_REG(DW100_SCALE_FACTOR), + __DECLARE_REG(DW100_ROI_START), + __DECLARE_REG(DW100_BOUNDARY_PIXEL), + __DECLARE_REG(DW100_INTERRUPT_STATUS), + __DECLARE_REG(DW100_BUS_CTRL), + __DECLARE_REG(DW100_BUS_CTRL1), + __DECLARE_REG(DW100_BUS_TIME_OUT_CYCLE), + }; + + for (i = 0; i < ARRAY_SIZE(dw100_regs); i++) + seq_printf(m, "%s: %#x\n", dw100_regs[i].name, + dw100_read(dw_dev, dw100_regs[i].addr)); + + return 0; +} + +static inline struct dw100_ctx *dw100_file2ctx(struct file *file) +{ + return container_of(file->private_data, struct dw100_ctx, fh); +} + +static struct dw100_q_data *dw100_get_q_data(struct dw100_ctx *ctx, + enum v4l2_buf_type type) +{ + if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + return &ctx->q_data[DW100_QUEUE_SRC]; + else + return &ctx->q_data[DW100_QUEUE_DST]; +} + +static u32 dw100_get_n_vertices_from_length(u32 length) +{ + return DIV_ROUND_UP(length, DW100_BLOCK_SIZE) + 1; +} + +static u16 dw100_map_convert_to_uq12_4(u32 a) +{ + return (u16)((a & 0xfff) << 4); +} + +static u32 dw100_map_format_coordinates(u16 xq, u16 yq) +{ + return (u32)((yq << 16) | xq); +} + +static u32 *dw100_get_user_map(struct dw100_ctx *ctx) +{ + struct v4l2_ctrl *ctrl = ctx->ctrls[DW100_CTRL_DEWARPING_MAP]; + + return ctrl->p_cur.p_u32; +} + +/* + * Create the dewarp map used by the hardware from the V4L2 control values which + * have been initialized with an identity map or set by the application. + */ +static int dw100_create_mapping(struct dw100_ctx *ctx) +{ + u32 *user_map; + + if (ctx->map) + dma_free_coherent(&ctx->dw_dev->pdev->dev, ctx->map_size, + ctx->map, ctx->map_dma); + + ctx->map = dma_alloc_coherent(&ctx->dw_dev->pdev->dev, ctx->map_size, + &ctx->map_dma, GFP_KERNEL); + + if (!ctx->map) + return -ENOMEM; + + user_map = dw100_get_user_map(ctx); + memcpy(ctx->map, user_map, ctx->map_size); + + dev_dbg(&ctx->dw_dev->pdev->dev, + "%ux%u %s mapping created (d:%pad-c:%p) for stream %ux%u->%ux%u\n", + ctx->map_width, ctx->map_height, + ctx->user_map_is_set ? "user" : "identity", + &ctx->map_dma, ctx->map, + ctx->q_data[DW100_QUEUE_SRC].pix_fmt.width, + ctx->q_data[DW100_QUEUE_DST].pix_fmt.height, + ctx->q_data[DW100_QUEUE_SRC].pix_fmt.width, + ctx->q_data[DW100_QUEUE_DST].pix_fmt.height); + + return 0; +} + +static void dw100_destroy_mapping(struct dw100_ctx *ctx) +{ + if (ctx->map) { + dma_free_coherent(&ctx->dw_dev->pdev->dev, ctx->map_size, + ctx->map, ctx->map_dma); + ctx->map = NULL; + } +} + +static int dw100_s_ctrl(struct v4l2_ctrl *ctrl) +{ + struct dw100_ctx *ctx = + container_of(ctrl->handler, struct dw100_ctx, hdl); + + switch (ctrl->id) { + case V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP: + ctx->user_map_is_set = true; + break; + } + + return 0; +} + +static const struct v4l2_ctrl_ops dw100_ctrl_ops = { + .s_ctrl = dw100_s_ctrl, +}; + +/* + * Initialize the dewarping map with an identity mapping. + * + * A 16 pixels cell size grid is mapped on the destination image. + * The last cells width/height might be lesser than 16 if the destination image + * width/height is not divisible by 16. This dewarping grid map specifies the + * source image pixel location (x, y) on each grid intersection point. + * Bilinear interpolation is used to compute inner cell points locations. + * + * The coordinates are saved in UQ12.4 fixed point format. + */ +static void dw100_ctrl_dewarping_map_init(const struct v4l2_ctrl *ctrl, + u32 from_idx, u32 elems, + union v4l2_ctrl_ptr ptr) +{ + struct dw100_ctx *ctx = + container_of(ctrl->handler, struct dw100_ctx, hdl); + + u32 sw, sh, dw, dh, mw, mh, i, j; + u16 qx, qy, qdx, qdy, qsh, qsw; + u32 *map = ctrl->p_cur.p_u32; + + sw = ctx->q_data[DW100_QUEUE_SRC].pix_fmt.width; + dw = ctx->q_data[DW100_QUEUE_DST].pix_fmt.width; + sh = ctx->q_data[DW100_QUEUE_SRC].pix_fmt.height; + dh = ctx->q_data[DW100_QUEUE_DST].pix_fmt.height; + + mw = dw100_get_n_vertices_from_length(dw); + mh = dw100_get_n_vertices_from_length(dh); + + qsw = dw100_map_convert_to_uq12_4(sw); + qsh = dw100_map_convert_to_uq12_4(sh); + qdx = qsw / (mw - 1); + qdy = qsh / (mh - 1); + + ctx->map_width = mw; + ctx->map_height = mh; + ctx->map_size = mh * mw * sizeof(u32); + + for (i = 0, qy = 0; i < mh; i++, qy += qdy) { + if (qy > qsh) + qy = qsh; + for (j = 0, qx = 0; j < mw; j++, qx += qdx) { + if (qx > qsw) + qx = qsw; + *map++ = dw100_map_format_coordinates(qx, qy); + } + } + + ctx->user_map_is_set = false; +} + +static const struct v4l2_ctrl_type_ops dw100_ctrl_type_ops = { + .init = dw100_ctrl_dewarping_map_init, + .validate = v4l2_ctrl_type_op_validate, + .log = v4l2_ctrl_type_op_log, + .equal = v4l2_ctrl_type_op_equal, +}; + +static const struct v4l2_ctrl_config controls[] = { + [DW100_CTRL_DEWARPING_MAP] = { + .ops = &dw100_ctrl_ops, + .type_ops = &dw100_ctrl_type_ops, + .id = V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP, + .name = "Dewarping Vertex Map", + .type = V4L2_CTRL_TYPE_U32, + .min = 0x00000000, + .max = 0xffffffff, + .step = 1, + .def = 0, + .dims = { DW100_DEF_LUT_W, DW100_DEF_LUT_H }, + }, +}; + +static int dw100_queue_setup(struct vb2_queue *vq, + unsigned int *nbuffers, unsigned int *nplanes, + unsigned int sizes[], struct device *alloc_devs[]) +{ + struct dw100_ctx *ctx = vb2_get_drv_priv(vq); + const struct v4l2_pix_format_mplane *format; + unsigned int i; + + format = &dw100_get_q_data(ctx, vq->type)->pix_fmt; + + if (*nplanes) { + if (*nplanes != format->num_planes) + return -EINVAL; + + for (i = 0; i < *nplanes; ++i) { + if (sizes[i] < format->plane_fmt[i].sizeimage) + return -EINVAL; + } + + return 0; + } + + *nplanes = format->num_planes; + + for (i = 0; i < format->num_planes; ++i) + sizes[i] = format->plane_fmt[i].sizeimage; + + return 0; +} + +static int dw100_buf_prepare(struct vb2_buffer *vb) +{ + unsigned int i; + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct dw100_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); + struct dw100_device *dw_dev = ctx->dw_dev; + const struct v4l2_pix_format_mplane *pix_fmt = + &dw100_get_q_data(ctx, vb->vb2_queue->type)->pix_fmt; + + if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) { + if (vbuf->field != V4L2_FIELD_NONE) { + dev_dbg(&dw_dev->pdev->dev, "%x field isn't supported\n", + vbuf->field); + return -EINVAL; + } + } + + for (i = 0; i < pix_fmt->num_planes; i++) { + unsigned long size = pix_fmt->plane_fmt[i].sizeimage; + + if (vb2_plane_size(vb, i) < size) { + dev_dbg(&dw_dev->pdev->dev, + "User buffer too small (%lu < %lu)\n", + vb2_plane_size(vb, i), size); + return -EINVAL; + } + + vb2_set_plane_payload(vb, i, size); + } + + return 0; +} + +static void dw100_buf_queue(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct dw100_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); + + v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); +} + +static void dw100_return_all_buffers(struct vb2_queue *q, + enum vb2_buffer_state state) +{ + struct dw100_ctx *ctx = vb2_get_drv_priv(q); + struct vb2_v4l2_buffer *vbuf; + + for (;;) { + if (V4L2_TYPE_IS_OUTPUT(q->type)) + vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); + else + vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); + if (!vbuf) + return; + v4l2_m2m_buf_done(vbuf, state); + } +} + +static int dw100_start_streaming(struct vb2_queue *q, unsigned int count) +{ + struct dw100_ctx *ctx = vb2_get_drv_priv(q); + struct dw100_q_data *q_data = dw100_get_q_data(ctx, q->type); + int ret; + + q_data->sequence = 0; + + ret = dw100_create_mapping(ctx); + if (ret) + goto err; + + ret = pm_runtime_resume_and_get(&ctx->dw_dev->pdev->dev); + if (ret) { + dw100_destroy_mapping(ctx); + goto err; + } + + return 0; +err: + dw100_return_all_buffers(q, VB2_BUF_STATE_QUEUED); + return ret; +} + +static void dw100_stop_streaming(struct vb2_queue *q) +{ + struct dw100_ctx *ctx = vb2_get_drv_priv(q); + + dw100_return_all_buffers(q, VB2_BUF_STATE_ERROR); + + pm_runtime_put_sync(&ctx->dw_dev->pdev->dev); + + dw100_destroy_mapping(ctx); +} + +static const struct vb2_ops dw100_qops = { + .queue_setup = dw100_queue_setup, + .buf_prepare = dw100_buf_prepare, + .buf_queue = dw100_buf_queue, + .start_streaming = dw100_start_streaming, + .stop_streaming = dw100_stop_streaming, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, +}; + +static int dw100_m2m_queue_init(void *priv, struct vb2_queue *src_vq, + struct vb2_queue *dst_vq) +{ + struct dw100_ctx *ctx = priv; + int ret; + + src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + src_vq->io_modes = VB2_MMAP | VB2_DMABUF; + src_vq->drv_priv = ctx; + src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); + src_vq->ops = &dw100_qops; + src_vq->mem_ops = &vb2_dma_contig_memops; + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; + src_vq->lock = &ctx->vq_mutex; + src_vq->dev = ctx->dw_dev->v4l2_dev.dev; + + ret = vb2_queue_init(src_vq); + if (ret) + return ret; + + dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + dst_vq->io_modes = VB2_MMAP | VB2_DMABUF; + dst_vq->drv_priv = ctx; + dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); + dst_vq->ops = &dw100_qops; + dst_vq->mem_ops = &vb2_dma_contig_memops; + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; + dst_vq->lock = &ctx->vq_mutex; + dst_vq->dev = ctx->dw_dev->v4l2_dev.dev; + + return vb2_queue_init(dst_vq); +} + +static int dw100_open(struct file *file) +{ + struct dw100_device *dw_dev = video_drvdata(file); + struct dw100_ctx *ctx; + struct v4l2_ctrl_handler *hdl; + struct v4l2_pix_format_mplane *pix_fmt; + int ret, i; + + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + mutex_init(&ctx->vq_mutex); + v4l2_fh_init(&ctx->fh, video_devdata(file)); + file->private_data = &ctx->fh; + ctx->dw_dev = dw_dev; + + ctx->q_data[DW100_QUEUE_SRC].fmt = &formats[0]; + + pix_fmt = &ctx->q_data[DW100_QUEUE_SRC].pix_fmt; + pix_fmt->field = V4L2_FIELD_NONE; + pix_fmt->colorspace = V4L2_COLORSPACE_REC709; + pix_fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(pix_fmt->colorspace); + pix_fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(pix_fmt->colorspace); + pix_fmt->quantization = + V4L2_MAP_QUANTIZATION_DEFAULT(false, pix_fmt->colorspace, + pix_fmt->ycbcr_enc); + + v4l2_fill_pixfmt_mp(pix_fmt, formats[0].fourcc, DW100_DEF_W, DW100_DEF_H); + + ctx->q_data[DW100_QUEUE_SRC].crop.top = 0; + ctx->q_data[DW100_QUEUE_SRC].crop.left = 0; + ctx->q_data[DW100_QUEUE_SRC].crop.width = DW100_DEF_W; + ctx->q_data[DW100_QUEUE_SRC].crop.height = DW100_DEF_H; + + ctx->q_data[DW100_QUEUE_DST] = ctx->q_data[DW100_QUEUE_SRC]; + + hdl = &ctx->hdl; + v4l2_ctrl_handler_init(hdl, ARRAY_SIZE(controls)); + for (i = 0; i < ARRAY_SIZE(controls); i++) { + ctx->ctrls[i] = v4l2_ctrl_new_custom(hdl, &controls[i], NULL); + if (hdl->error) { + dev_err(&ctx->dw_dev->pdev->dev, + "Adding control (%d) failed\n", i); + ret = hdl->error; + goto err; + } + } + ctx->fh.ctrl_handler = hdl; + + ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dw_dev->m2m_dev, + ctx, &dw100_m2m_queue_init); + + if (IS_ERR(ctx->fh.m2m_ctx)) { + ret = PTR_ERR(ctx->fh.m2m_ctx); + goto err; + } + + v4l2_fh_add(&ctx->fh); + + return 0; + +err: + v4l2_ctrl_handler_free(hdl); + v4l2_fh_exit(&ctx->fh); + mutex_destroy(&ctx->vq_mutex); + kfree(ctx); + + return ret; +} + +static int dw100_release(struct file *file) +{ + struct dw100_ctx *ctx = dw100_file2ctx(file); + + v4l2_fh_del(&ctx->fh); + v4l2_fh_exit(&ctx->fh); + v4l2_ctrl_handler_free(&ctx->hdl); + v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); + mutex_destroy(&ctx->vq_mutex); + kfree(ctx); + + return 0; +} + +static const struct v4l2_file_operations dw100_fops = { + .owner = THIS_MODULE, + .open = dw100_open, + .release = dw100_release, + .poll = v4l2_m2m_fop_poll, + .unlocked_ioctl = video_ioctl2, + .mmap = v4l2_m2m_fop_mmap, +}; + +static int dw100_querycap(struct file *file, void *priv, + struct v4l2_capability *cap) +{ + strscpy(cap->driver, DRV_NAME, sizeof(cap->driver)); + strscpy(cap->card, "DW100 dewarper", sizeof(cap->card)); + + return 0; +} + +static int dw100_enum_fmt_vid(struct file *file, void *priv, + struct v4l2_fmtdesc *f) +{ + int i, num = 0; + + for (i = 0; i < ARRAY_SIZE(formats); i++) { + if (formats[i].types & to_dw100_fmt_type(f->type)) { + if (num == f->index) { + f->pixelformat = formats[i].fourcc; + return 0; + } + ++num; + } + } + + return -EINVAL; +} + +static int dw100_enum_framesizes(struct file *file, void *priv, + struct v4l2_frmsizeenum *fsize) +{ + const struct dw100_fmt *fmt; + + if (fsize->index) + return -EINVAL; + + fmt = dw100_find_pixel_format(fsize->pixel_format, + DW100_FMT_OUTPUT | DW100_FMT_CAPTURE); + if (!fmt) + return -EINVAL; + + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; + fsize->stepwise = dw100_frmsize_stepwise; + + return 0; +} + +static int dw100_g_fmt_vid(struct file *file, void *priv, struct v4l2_format *f) +{ + struct dw100_ctx *ctx = dw100_file2ctx(file); + struct vb2_queue *vq; + struct dw100_q_data *q_data; + + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); + if (!vq) + return -EINVAL; + + q_data = dw100_get_q_data(ctx, f->type); + + f->fmt.pix_mp = q_data->pix_fmt; + + return 0; +} + +static int dw100_try_fmt(struct file *file, struct v4l2_format *f) +{ + struct dw100_ctx *ctx = dw100_file2ctx(file); + struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp; + const struct dw100_fmt *fmt; + + fmt = dw100_find_format(f); + if (!fmt) { + fmt = &formats[0]; + pix->pixelformat = fmt->fourcc; + } + + v4l2_apply_frmsize_constraints(&pix->width, &pix->height, + &dw100_frmsize_stepwise); + + v4l2_fill_pixfmt_mp(pix, fmt->fourcc, pix->width, pix->height); + + pix->field = V4L2_FIELD_NONE; + + if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + if (pix->colorspace == V4L2_COLORSPACE_DEFAULT) + pix->colorspace = V4L2_COLORSPACE_REC709; + if (pix->xfer_func == V4L2_XFER_FUNC_DEFAULT) + pix->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(pix->colorspace); + if (pix->ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT) + pix->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(pix->colorspace); + if (pix->quantization == V4L2_QUANTIZATION_DEFAULT) + pix->quantization = + V4L2_MAP_QUANTIZATION_DEFAULT(false, + pix->colorspace, + pix->ycbcr_enc); + } else { + /* + * The DW100 can't perform colorspace conversion, the colorspace + * on the capture queue must be identical to the output queue. + */ + const struct dw100_q_data *q_data = + dw100_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + + pix->colorspace = q_data->pix_fmt.colorspace; + pix->xfer_func = q_data->pix_fmt.xfer_func; + pix->ycbcr_enc = q_data->pix_fmt.ycbcr_enc; + pix->quantization = q_data->pix_fmt.quantization; + } + + return 0; +} + +static int dw100_s_fmt(struct dw100_ctx *ctx, struct v4l2_format *f) +{ + struct dw100_q_data *q_data; + struct vb2_queue *vq; + + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); + if (!vq) + return -EINVAL; + + q_data = dw100_get_q_data(ctx, f->type); + if (!q_data) + return -EINVAL; + + if (vb2_is_busy(vq)) { + dev_dbg(&ctx->dw_dev->pdev->dev, "%s queue busy\n", __func__); + return -EBUSY; + } + + q_data->fmt = dw100_find_format(f); + q_data->pix_fmt = f->fmt.pix_mp; + q_data->crop.top = 0; + q_data->crop.left = 0; + q_data->crop.width = f->fmt.pix_mp.width; + q_data->crop.height = f->fmt.pix_mp.height; + + /* Propagate buffers encoding */ + + if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + struct dw100_q_data *dst_q_data = + dw100_get_q_data(ctx, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + + dst_q_data->pix_fmt.colorspace = q_data->pix_fmt.colorspace; + dst_q_data->pix_fmt.ycbcr_enc = q_data->pix_fmt.ycbcr_enc; + dst_q_data->pix_fmt.quantization = q_data->pix_fmt.quantization; + dst_q_data->pix_fmt.xfer_func = q_data->pix_fmt.xfer_func; + } + + dev_dbg(&ctx->dw_dev->pdev->dev, + "Setting format for type %u, wxh: %ux%u, fmt: %p4cc\n", + f->type, q_data->pix_fmt.width, q_data->pix_fmt.height, + &q_data->pix_fmt.pixelformat); + + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + int ret; + u32 dims[V4L2_CTRL_MAX_DIMS] = {}; + struct v4l2_ctrl *ctrl = ctx->ctrls[DW100_CTRL_DEWARPING_MAP]; + + dims[0] = dw100_get_n_vertices_from_length(q_data->pix_fmt.width); + dims[1] = dw100_get_n_vertices_from_length(q_data->pix_fmt.height); + + ret = v4l2_ctrl_modify_dimensions(ctrl, dims); + + if (ret) { + dev_err(&ctx->dw_dev->pdev->dev, + "Modifying LUT dimensions failed with error %d\n", + ret); + return ret; + } + } + + return 0; +} + +static int dw100_try_fmt_vid_cap(struct file *file, void *priv, + struct v4l2_format *f) +{ + if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + return -EINVAL; + + return dw100_try_fmt(file, f); +} + +static int dw100_s_fmt_vid_cap(struct file *file, void *priv, + struct v4l2_format *f) +{ + struct dw100_ctx *ctx = dw100_file2ctx(file); + int ret; + + ret = dw100_try_fmt_vid_cap(file, priv, f); + if (ret) + return ret; + + ret = dw100_s_fmt(ctx, f); + if (ret) + return ret; + + return 0; +} + +static int dw100_try_fmt_vid_out(struct file *file, void *priv, + struct v4l2_format *f) +{ + if (f->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + return -EINVAL; + + return dw100_try_fmt(file, f); +} + +static int dw100_s_fmt_vid_out(struct file *file, void *priv, + struct v4l2_format *f) +{ + struct dw100_ctx *ctx = dw100_file2ctx(file); + int ret; + + ret = dw100_try_fmt_vid_out(file, priv, f); + if (ret) + return ret; + + ret = dw100_s_fmt(ctx, f); + if (ret) + return ret; + + return 0; +} + +static int dw100_g_selection(struct file *file, void *fh, + struct v4l2_selection *sel) +{ + struct dw100_ctx *ctx = dw100_file2ctx(file); + struct dw100_q_data *src_q_data; + + if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) + return -EINVAL; + + src_q_data = dw100_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + + switch (sel->target) { + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = src_q_data->pix_fmt.width; + sel->r.height = src_q_data->pix_fmt.height; + break; + case V4L2_SEL_TGT_CROP: + sel->r.top = src_q_data->crop.top; + sel->r.left = src_q_data->crop.left; + sel->r.width = src_q_data->crop.width; + sel->r.height = src_q_data->crop.height; + break; + default: + return -EINVAL; + } + + return 0; +} + +static int dw100_s_selection(struct file *file, void *fh, + struct v4l2_selection *sel) +{ + struct dw100_ctx *ctx = dw100_file2ctx(file); + struct dw100_q_data *src_q_data; + u32 qscalex, qscaley, qscale; + int x, y, w, h; + unsigned int wframe, hframe; + + if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) + return -EINVAL; + + src_q_data = dw100_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + + dev_dbg(&ctx->dw_dev->pdev->dev, + ">>> Buffer Type: %u Target: %u Rect: %ux%u@%d.%d\n", + sel->type, sel->target, + sel->r.width, sel->r.height, sel->r.left, sel->r.top); + + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + wframe = src_q_data->pix_fmt.width; + hframe = src_q_data->pix_fmt.height; + + sel->r.top = clamp_t(int, sel->r.top, 0, hframe - DW100_MIN_H); + sel->r.left = clamp_t(int, sel->r.left, 0, wframe - DW100_MIN_W); + sel->r.height = + clamp(sel->r.height, DW100_MIN_H, hframe - sel->r.top); + sel->r.width = + clamp(sel->r.width, DW100_MIN_W, wframe - sel->r.left); + + /* UQ16.16 for float operations */ + qscalex = (sel->r.width << 16) / wframe; + qscaley = (sel->r.height << 16) / hframe; + y = sel->r.top; + x = sel->r.left; + if (qscalex == qscaley) { + qscale = qscalex; + } else { + switch (sel->flags) { + case 0: + qscale = (qscalex + qscaley) / 2; + break; + case V4L2_SEL_FLAG_GE: + qscale = max(qscaley, qscalex); + break; + case V4L2_SEL_FLAG_LE: + qscale = min(qscaley, qscalex); + break; + case V4L2_SEL_FLAG_LE | V4L2_SEL_FLAG_GE: + return -ERANGE; + default: + return -EINVAL; + } + } + + w = (u32)((((u64)wframe << 16) * qscale) >> 32); + h = (u32)((((u64)hframe << 16) * qscale) >> 32); + x = x + (sel->r.width - w) / 2; + y = y + (sel->r.height - h) / 2; + x = min(wframe - w, (unsigned int)max(0, x)); + y = min(hframe - h, (unsigned int)max(0, y)); + + sel->r.top = y; + sel->r.left = x; + sel->r.width = w; + sel->r.height = h; + + src_q_data->crop.top = sel->r.top; + src_q_data->crop.left = sel->r.left; + src_q_data->crop.width = sel->r.width; + src_q_data->crop.height = sel->r.height; + break; + + default: + return -EINVAL; + } + + dev_dbg(&ctx->dw_dev->pdev->dev, + "<<< Buffer Type: %u Target: %u Rect: %ux%u@%d.%d\n", + sel->type, sel->target, + sel->r.width, sel->r.height, sel->r.left, sel->r.top); + + return 0; +} + +static const struct v4l2_ioctl_ops dw100_ioctl_ops = { + .vidioc_querycap = dw100_querycap, + + .vidioc_enum_fmt_vid_cap = dw100_enum_fmt_vid, + .vidioc_enum_framesizes = dw100_enum_framesizes, + .vidioc_g_fmt_vid_cap_mplane = dw100_g_fmt_vid, + .vidioc_try_fmt_vid_cap_mplane = dw100_try_fmt_vid_cap, + .vidioc_s_fmt_vid_cap_mplane = dw100_s_fmt_vid_cap, + + .vidioc_enum_fmt_vid_out = dw100_enum_fmt_vid, + .vidioc_g_fmt_vid_out_mplane = dw100_g_fmt_vid, + .vidioc_try_fmt_vid_out_mplane = dw100_try_fmt_vid_out, + .vidioc_s_fmt_vid_out_mplane = dw100_s_fmt_vid_out, + + .vidioc_g_selection = dw100_g_selection, + .vidioc_s_selection = dw100_s_selection, + .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, + .vidioc_querybuf = v4l2_m2m_ioctl_querybuf, + .vidioc_qbuf = v4l2_m2m_ioctl_qbuf, + .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, + .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, + .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, + .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, + + .vidioc_streamon = v4l2_m2m_ioctl_streamon, + .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, + + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, +}; + +static void dw100_job_finish(struct dw100_device *dw_dev, bool with_error) +{ + struct dw100_ctx *curr_ctx; + struct vb2_v4l2_buffer *src_vb, *dst_vb; + enum vb2_buffer_state buf_state; + + curr_ctx = v4l2_m2m_get_curr_priv(dw_dev->m2m_dev); + + if (!curr_ctx) { + dev_err(&dw_dev->pdev->dev, + "Instance released before the end of transaction\n"); + return; + } + + src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx); + dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx); + + if (likely(!with_error)) + buf_state = VB2_BUF_STATE_DONE; + else + buf_state = VB2_BUF_STATE_ERROR; + + v4l2_m2m_buf_done(src_vb, buf_state); + v4l2_m2m_buf_done(dst_vb, buf_state); + + dev_dbg(&dw_dev->pdev->dev, "Finishing transaction with%s error(s)\n", + with_error ? "" : "out"); + + v4l2_m2m_job_finish(dw_dev->m2m_dev, curr_ctx->fh.m2m_ctx); +} + +static void dw100_hw_reset(struct dw100_device *dw_dev) +{ + u32 val; + + val = dw100_read(dw_dev, DW100_DEWARP_CTRL); + val |= DW100_DEWARP_CTRL_ENABLE; + val |= DW100_DEWARP_CTRL_SOFT_RESET; + dw100_write(dw_dev, DW100_DEWARP_CTRL, val); + val &= ~DW100_DEWARP_CTRL_SOFT_RESET; + dw100_write(dw_dev, DW100_DEWARP_CTRL, val); +} + +static void _dw100_hw_set_master_bus_enable(struct dw100_device *dw_dev, + unsigned int enable) +{ + u32 val; + + dev_dbg(&dw_dev->pdev->dev, "%sable master bus\n", + enable ? "En" : "Dis"); + + val = dw100_read(dw_dev, DW100_BUS_CTRL); + + if (enable) + val |= DW100_BUS_CTRL_AXI_MASTER_ENABLE; + else + val &= ~DW100_BUS_CTRL_AXI_MASTER_ENABLE; + + dw100_write(dw_dev, DW100_BUS_CTRL, val); +} + +static void dw100_hw_master_bus_enable(struct dw100_device *dw_dev) +{ + _dw100_hw_set_master_bus_enable(dw_dev, 1); +} + +static void dw100_hw_master_bus_disable(struct dw100_device *dw_dev) +{ + _dw100_hw_set_master_bus_enable(dw_dev, 0); +} + +static void dw100_hw_dewarp_start(struct dw100_device *dw_dev) +{ + u32 val; + + val = dw100_read(dw_dev, DW100_DEWARP_CTRL); + + dev_dbg(&dw_dev->pdev->dev, "Starting Hardware CTRL:0x%08x\n", val); + dw100_write(dw_dev, DW100_DEWARP_CTRL, val | DW100_DEWARP_CTRL_START); + dw100_write(dw_dev, DW100_DEWARP_CTRL, val); +} + +static void dw100_hw_init_ctrl(struct dw100_device *dw_dev) +{ + u32 val; + /* + * Input format YUV422_SP + * Output format YUV422_SP + * No hardware handshake (SW) + * No automatic double src buffering (Single) + * No automatic double dst buffering (Single) + * No Black Line + * Prefetch image pixel traversal + */ + + val = DW100_DEWARP_CTRL_ENABLE + /* Valid only for auto prefetch mode*/ + | DW100_DEWARP_CTRL_PREFETCH_THRESHOLD(32); + + /* + * Calculation mode required to support any scaling factor, + * but x4 slower than traversal mode. + * + * DW100_DEWARP_CTRL_PREFETCH_MODE_TRAVERSAL + * DW100_DEWARP_CTRL_PREFETCH_MODE_CALCULATION + * DW100_DEWARP_CTRL_PREFETCH_MODE_AUTO + * + * TODO: Find heuristics requiring calculation mode + */ + val |= DW100_DEWARP_CTRL_PREFETCH_MODE_CALCULATION; + + dw100_write(dw_dev, DW100_DEWARP_CTRL, val); +} + +static void dw100_hw_set_pixel_boundary(struct dw100_device *dw_dev) +{ + u32 val; + + val = DW100_BOUNDARY_PIXEL_V(128) + | DW100_BOUNDARY_PIXEL_U(128) + | DW100_BOUNDARY_PIXEL_Y(0); + + dw100_write(dw_dev, DW100_BOUNDARY_PIXEL, val); +} + +static void dw100_hw_set_scale(struct dw100_device *dw_dev, u8 scale) +{ + dev_dbg(&dw_dev->pdev->dev, "Setting scale factor to %u\n", scale); + + dw100_write(dw_dev, DW100_SCALE_FACTOR, scale); +} + +static void dw100_hw_set_roi(struct dw100_device *dw_dev, u32 x, u32 y) +{ + u32 val; + + dev_dbg(&dw_dev->pdev->dev, "Setting ROI region to %u.%u\n", x, y); + + val = DW100_ROI_START_X(x) | DW100_ROI_START_Y(y); + + dw100_write(dw_dev, DW100_ROI_START, val); +} + +static void dw100_hw_set_src_crop(struct dw100_device *dw_dev, + const struct dw100_q_data *src_q_data, + const struct dw100_q_data *dst_q_data) +{ + const struct v4l2_rect *rect = &src_q_data->crop; + u32 src_scale, qscale, left_scale, top_scale; + + /* HW Scale is UQ1.7 encoded */ + src_scale = (rect->width << 7) / src_q_data->pix_fmt.width; + dw100_hw_set_scale(dw_dev, src_scale); + + qscale = (dst_q_data->pix_fmt.width << 7) / src_q_data->pix_fmt.width; + + left_scale = ((rect->left << 7) * qscale) >> 14; + top_scale = ((rect->top << 7) * qscale) >> 14; + + dw100_hw_set_roi(dw_dev, left_scale, top_scale); +} + +static void dw100_hw_set_source(struct dw100_device *dw_dev, + const struct dw100_q_data *q_data, + struct vb2_buffer *buffer) +{ + u32 width, height, stride, fourcc, val; + const struct dw100_fmt *fmt = q_data->fmt; + dma_addr_t addr_y = vb2_dma_contig_plane_dma_addr(buffer, 0); + dma_addr_t addr_uv; + + width = q_data->pix_fmt.width; + height = q_data->pix_fmt.height; + stride = q_data->pix_fmt.plane_fmt[0].bytesperline; + fourcc = q_data->fmt->fourcc; + + if (q_data->pix_fmt.num_planes == 2) + addr_uv = vb2_dma_contig_plane_dma_addr(buffer, 1); + else + addr_uv = addr_y + (stride * height); + + dev_dbg(&dw_dev->pdev->dev, + "Set HW source registers for %ux%u - stride %u, pixfmt: %p4cc, dma:%pad\n", + width, height, stride, &fourcc, &addr_y); + + /* Pixel Format */ + val = dw100_read(dw_dev, DW100_DEWARP_CTRL); + + val &= ~DW100_DEWARP_CTRL_INPUT_FORMAT_MASK; + val |= DW100_DEWARP_CTRL_INPUT_FORMAT(fmt->reg_format); + + dw100_write(dw_dev, DW100_DEWARP_CTRL, val); + + /* Swap */ + val = dw100_read(dw_dev, DW100_SWAP_CONTROL); + + val &= ~DW100_SWAP_CONTROL_SRC_MASK; + /* + * Data swapping is performed only on Y plane for source image. + */ + if (fmt->reg_swap_uv && + fmt->reg_format == DW100_DEWARP_CTRL_FORMAT_YUV422_PACKED) + val |= DW100_SWAP_CONTROL_SRC(DW100_SWAP_CONTROL_Y + (DW100_SWAP_CONTROL_BYTE)); + + dw100_write(dw_dev, DW100_SWAP_CONTROL, val); + + /* Image resolution */ + dw100_write(dw_dev, DW100_SRC_IMG_SIZE, + DW100_IMG_SIZE_WIDTH(width) | DW100_IMG_SIZE_HEIGHT(height)); + + dw100_write(dw_dev, DW100_SRC_IMG_STRIDE, stride); + + /* Buffers */ + dw100_write(dw_dev, DW100_SRC_IMG_Y_BASE, DW100_IMG_Y_BASE(addr_y)); + dw100_write(dw_dev, DW100_SRC_IMG_UV_BASE, DW100_IMG_UV_BASE(addr_uv)); +} + +static void dw100_hw_set_destination(struct dw100_device *dw_dev, + const struct dw100_q_data *q_data, + const struct dw100_fmt *ifmt, + struct vb2_buffer *buffer) +{ + u32 width, height, stride, fourcc, val, size_y, size_uv; + const struct dw100_fmt *fmt = q_data->fmt; + dma_addr_t addr_y, addr_uv; + + width = q_data->pix_fmt.width; + height = q_data->pix_fmt.height; + stride = q_data->pix_fmt.plane_fmt[0].bytesperline; + fourcc = fmt->fourcc; + + addr_y = vb2_dma_contig_plane_dma_addr(buffer, 0); + size_y = q_data->pix_fmt.plane_fmt[0].sizeimage; + + if (q_data->pix_fmt.num_planes == 2) { + addr_uv = vb2_dma_contig_plane_dma_addr(buffer, 1); + size_uv = q_data->pix_fmt.plane_fmt[1].sizeimage; + } else { + addr_uv = addr_y + ALIGN(stride * height, 16); + size_uv = size_y; + if (fmt->reg_format == DW100_DEWARP_CTRL_FORMAT_YUV420_SP) + size_uv /= 2; + } + + dev_dbg(&dw_dev->pdev->dev, + "Set HW source registers for %ux%u - stride %u, pixfmt: %p4cc, dma:%pad\n", + width, height, stride, &fourcc, &addr_y); + + /* Pixel Format */ + val = dw100_read(dw_dev, DW100_DEWARP_CTRL); + + val &= ~DW100_DEWARP_CTRL_OUTPUT_FORMAT_MASK; + val |= DW100_DEWARP_CTRL_OUTPUT_FORMAT(fmt->reg_format); + + dw100_write(dw_dev, DW100_DEWARP_CTRL, val); + + /* Swap */ + val = dw100_read(dw_dev, DW100_SWAP_CONTROL); + + val &= ~DW100_SWAP_CONTROL_DST_MASK; + + /* + * Avoid to swap twice + */ + if (fmt->reg_swap_uv ^ + (ifmt->reg_swap_uv && ifmt->reg_format != + DW100_DEWARP_CTRL_FORMAT_YUV422_PACKED)) { + if (fmt->reg_format == DW100_DEWARP_CTRL_FORMAT_YUV422_PACKED) + val |= DW100_SWAP_CONTROL_DST(DW100_SWAP_CONTROL_Y + (DW100_SWAP_CONTROL_BYTE)); + else + val |= DW100_SWAP_CONTROL_DST(DW100_SWAP_CONTROL_UV + (DW100_SWAP_CONTROL_BYTE)); + } + + dw100_write(dw_dev, DW100_SWAP_CONTROL, val); + + /* Image resolution */ + dw100_write(dw_dev, DW100_DST_IMG_SIZE, + DW100_IMG_SIZE_WIDTH(width) | DW100_IMG_SIZE_HEIGHT(height)); + dw100_write(dw_dev, DW100_DST_IMG_STRIDE, stride); + dw100_write(dw_dev, DW100_DST_IMG_Y_BASE, DW100_IMG_Y_BASE(addr_y)); + dw100_write(dw_dev, DW100_DST_IMG_UV_BASE, DW100_IMG_UV_BASE(addr_uv)); + dw100_write(dw_dev, DW100_DST_IMG_Y_SIZE1, DW100_DST_IMG_Y_SIZE(size_y)); + dw100_write(dw_dev, DW100_DST_IMG_UV_SIZE1, + DW100_DST_IMG_UV_SIZE(size_uv)); +} + +static void dw100_hw_set_mapping(struct dw100_device *dw_dev, dma_addr_t addr, + u32 width, u32 height) +{ + dev_dbg(&dw_dev->pdev->dev, + "Set HW mapping registers for %ux%u addr:%pad", + width, height, &addr); + + dw100_write(dw_dev, DW100_MAP_LUT_ADDR, DW100_MAP_LUT_ADDR_ADDR(addr)); + dw100_write(dw_dev, DW100_MAP_LUT_SIZE, DW100_MAP_LUT_SIZE_WIDTH(width) + | DW100_MAP_LUT_SIZE_HEIGHT(height)); +} + +static void dw100_hw_clear_irq(struct dw100_device *dw_dev, unsigned int irq) +{ + dw100_write(dw_dev, DW100_INTERRUPT_STATUS, + DW100_INTERRUPT_STATUS_INT_CLEAR(irq)); +} + +static void dw100_hw_enable_irq(struct dw100_device *dw_dev) +{ + dw100_write(dw_dev, DW100_INTERRUPT_STATUS, + DW100_INTERRUPT_STATUS_INT_ENABLE_MASK); +} + +static void dw100_hw_disable_irq(struct dw100_device *dw_dev) +{ + dw100_write(dw_dev, DW100_INTERRUPT_STATUS, 0); +} + +static u32 dw_hw_get_pending_irqs(struct dw100_device *dw_dev) +{ + u32 val; + + val = dw100_read(dw_dev, DW100_INTERRUPT_STATUS); + + return DW100_INTERRUPT_STATUS_INT_STATUS(val); +} + +static irqreturn_t dw100_irq_handler(int irq, void *dev_id) +{ + struct dw100_device *dw_dev = dev_id; + u32 pending_irqs, err_irqs, frame_done_irq; + bool with_error = true; + + pending_irqs = dw_hw_get_pending_irqs(dw_dev); + frame_done_irq = pending_irqs & DW100_INTERRUPT_STATUS_INT_FRAME_DONE; + err_irqs = DW100_INTERRUPT_STATUS_INT_ERR_STATUS(pending_irqs); + + if (frame_done_irq) { + dev_dbg(&dw_dev->pdev->dev, "Frame done interrupt\n"); + with_error = false; + err_irqs &= ~DW100_INTERRUPT_STATUS_INT_ERR_STATUS + (DW100_INTERRUPT_STATUS_INT_ERR_FRAME_DONE); + } + + if (err_irqs) + dev_err(&dw_dev->pdev->dev, "Interrupt error: %#x\n", err_irqs); + + dw100_hw_disable_irq(dw_dev); + dw100_hw_master_bus_disable(dw_dev); + dw100_hw_clear_irq(dw_dev, pending_irqs | + DW100_INTERRUPT_STATUS_INT_ERR_TIME_OUT); + + dw100_job_finish(dw_dev, with_error); + + return IRQ_HANDLED; +} + +static void dw100_start(struct dw100_ctx *ctx, struct vb2_v4l2_buffer *in_vb, + struct vb2_v4l2_buffer *out_vb) +{ + struct dw100_device *dw_dev = ctx->dw_dev; + + out_vb->sequence = + dw100_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)->sequence++; + in_vb->sequence = + dw100_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)->sequence++; + + dev_dbg(&ctx->dw_dev->pdev->dev, + "Starting queues %p->%p, sequence %u->%u\n", + v4l2_m2m_get_vq(ctx->fh.m2m_ctx, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE), + v4l2_m2m_get_vq(ctx->fh.m2m_ctx, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE), + in_vb->sequence, out_vb->sequence); + + v4l2_m2m_buf_copy_metadata(in_vb, out_vb, true); + + /* Now, let's deal with hardware ... */ + dw100_hw_master_bus_disable(dw_dev); + dw100_hw_init_ctrl(dw_dev); + dw100_hw_set_pixel_boundary(dw_dev); + dw100_hw_set_src_crop(dw_dev, &ctx->q_data[DW100_QUEUE_SRC], + &ctx->q_data[DW100_QUEUE_DST]); + dw100_hw_set_source(dw_dev, &ctx->q_data[DW100_QUEUE_SRC], + &in_vb->vb2_buf); + dw100_hw_set_destination(dw_dev, &ctx->q_data[DW100_QUEUE_DST], + ctx->q_data[DW100_QUEUE_SRC].fmt, + &out_vb->vb2_buf); + dw100_hw_set_mapping(dw_dev, ctx->map_dma, + ctx->map_width, ctx->map_height); + dw100_hw_enable_irq(dw_dev); + dw100_hw_dewarp_start(dw_dev); + + /* Enable Bus */ + dw100_hw_master_bus_enable(dw_dev); +} + +static void dw100_device_run(void *priv) +{ + struct dw100_ctx *ctx = priv; + struct vb2_v4l2_buffer *src_buf, *dst_buf; + + src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); + dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); + + dw100_start(ctx, src_buf, dst_buf); +} + +static const struct v4l2_m2m_ops dw100_m2m_ops = { + .device_run = dw100_device_run, +}; + +static struct video_device *dw100_init_video_device(struct dw100_device *dw_dev) +{ + struct video_device *vfd = &dw_dev->vfd; + + vfd->vfl_dir = VFL_DIR_M2M; + vfd->fops = &dw100_fops; + vfd->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; + vfd->ioctl_ops = &dw100_ioctl_ops; + vfd->minor = -1; + vfd->release = video_device_release_empty; + vfd->v4l2_dev = &dw_dev->v4l2_dev; + vfd->lock = &dw_dev->vfd_mutex; + + strscpy(vfd->name, DRV_NAME, sizeof(vfd->name)); + mutex_init(vfd->lock); + video_set_drvdata(vfd, dw_dev); + + return vfd; +} + +static int dw100_dump_regs_show(struct seq_file *m, void *private) +{ + struct dw100_device *dw_dev = m->private; + int ret; + + ret = pm_runtime_resume_and_get(&dw_dev->pdev->dev); + if (ret < 0) + return ret; + + ret = dw100_dump_regs(m); + + pm_runtime_put_sync(&dw_dev->pdev->dev); + + return ret; +} +DEFINE_SHOW_ATTRIBUTE(dw100_dump_regs); + +static void dw100_debugfs_init(struct dw100_device *dw_dev) +{ + dw_dev->debugfs_root = + debugfs_create_dir(dev_name(&dw_dev->pdev->dev), NULL); + + debugfs_create_file("dump_regs", 0600, dw_dev->debugfs_root, dw_dev, + &dw100_dump_regs_fops); +} + +static void dw100_debugfs_exit(struct dw100_device *dw_dev) +{ + debugfs_remove_recursive(dw_dev->debugfs_root); +} + +static int dw100_probe(struct platform_device *pdev) +{ + struct dw100_device *dw_dev; + struct video_device *vfd; + struct resource *res; + int ret, irq; + + dw_dev = devm_kzalloc(&pdev->dev, sizeof(*dw_dev), GFP_KERNEL); + if (!dw_dev) + return -ENOMEM; + dw_dev->pdev = pdev; + + ret = devm_clk_bulk_get_all(&pdev->dev, &dw_dev->clks); + if (ret < 0) { + dev_err(&pdev->dev, "Unable to get clocks: %d\n", ret); + return ret; + } + dw_dev->num_clks = ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + dw_dev->mmio = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(dw_dev->mmio)) + return PTR_ERR(dw_dev->mmio); + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + platform_set_drvdata(pdev, dw_dev); + + pm_runtime_enable(&pdev->dev); + ret = pm_runtime_resume_and_get(&pdev->dev); + if (ret < 0) { + dev_err(&pdev->dev, "Unable to resume the device: %d\n", ret); + goto err_pm; + } + + pm_runtime_put_sync(&pdev->dev); + + ret = devm_request_irq(&pdev->dev, irq, dw100_irq_handler, IRQF_ONESHOT, + dev_name(&pdev->dev), dw_dev); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to request irq: %d\n", ret); + return ret; + } + + ret = v4l2_device_register(&pdev->dev, &dw_dev->v4l2_dev); + if (ret) + goto err_pm; + + vfd = dw100_init_video_device(dw_dev); + + dw_dev->m2m_dev = v4l2_m2m_init(&dw100_m2m_ops); + if (IS_ERR(dw_dev->m2m_dev)) { + dev_err(&pdev->dev, "Failed to init mem2mem device\n"); + ret = PTR_ERR(dw_dev->m2m_dev); + goto err_v4l2; + } + + dw_dev->mdev.dev = &pdev->dev; + strscpy(dw_dev->mdev.model, "dw100", sizeof(dw_dev->mdev.model)); + media_device_init(&dw_dev->mdev); + dw_dev->v4l2_dev.mdev = &dw_dev->mdev; + + ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1); + if (ret) { + dev_err(&pdev->dev, "Failed to register video device\n"); + goto err_m2m; + } + + ret = v4l2_m2m_register_media_controller(dw_dev->m2m_dev, vfd, + MEDIA_ENT_F_PROC_VIDEO_SCALER); + if (ret) { + dev_err(&pdev->dev, "Failed to init mem2mem media controller\n"); + goto error_v4l2; + } + + ret = media_device_register(&dw_dev->mdev); + if (ret) { + dev_err(&pdev->dev, "Failed to register mem2mem media device\n"); + goto error_m2m_mc; + } + + dw100_debugfs_init(dw_dev); + + dev_info(&pdev->dev, + "dw100 v4l2 m2m registered as /dev/video%u\n", vfd->num); + + return 0; + +error_m2m_mc: + v4l2_m2m_unregister_media_controller(dw_dev->m2m_dev); +error_v4l2: + video_unregister_device(vfd); +err_m2m: + v4l2_m2m_release(dw_dev->m2m_dev); +err_v4l2: + v4l2_device_unregister(&dw_dev->v4l2_dev); +err_pm: + pm_runtime_disable(&pdev->dev); + + return ret; +} + +static int dw100_remove(struct platform_device *pdev) +{ + struct dw100_device *dw_dev = platform_get_drvdata(pdev); + + dw100_debugfs_exit(dw_dev); + + pm_runtime_disable(&pdev->dev); + + media_device_unregister(&dw_dev->mdev); + v4l2_m2m_unregister_media_controller(dw_dev->m2m_dev); + media_device_cleanup(&dw_dev->mdev); + + video_unregister_device(&dw_dev->vfd); + mutex_destroy(dw_dev->vfd.lock); + v4l2_m2m_release(dw_dev->m2m_dev); + v4l2_device_unregister(&dw_dev->v4l2_dev); + + return 0; +} + +static int __maybe_unused dw100_runtime_suspend(struct device *dev) +{ + struct dw100_device *dw_dev = dev_get_drvdata(dev); + + clk_bulk_disable_unprepare(dw_dev->num_clks, dw_dev->clks); + + return 0; +} + +static int __maybe_unused dw100_runtime_resume(struct device *dev) +{ + int ret; + struct dw100_device *dw_dev = dev_get_drvdata(dev); + + ret = clk_bulk_prepare_enable(dw_dev->num_clks, dw_dev->clks); + + if (ret) + return ret; + + dw100_hw_reset(dw_dev); + + return 0; +} + +static const struct dev_pm_ops dw100_pm = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(dw100_runtime_suspend, + dw100_runtime_resume, NULL) +}; + +static const struct of_device_id dw100_dt_ids[] = { + { .compatible = "nxp,imx8mp-dw100", .data = NULL }, + { }, +}; +MODULE_DEVICE_TABLE(of, dw100_dt_ids); + +static struct platform_driver dw100_driver = { + .probe = dw100_probe, + .remove = dw100_remove, + .driver = { + .name = DRV_NAME, + .pm = &dw100_pm, + .of_match_table = dw100_dt_ids, + }, +}; + +module_platform_driver(dw100_driver); + +MODULE_DESCRIPTION("DW100 Hardware dewarper"); +MODULE_AUTHOR("Xavier Roumegue "); +MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/nxp/dw100/dw100_regs.h b/drivers/media/platform/nxp/dw100/dw100_regs.h new file mode 100644 index 0000000000000..e85dfeff90568 --- /dev/null +++ b/drivers/media/platform/nxp/dw100/dw100_regs.h @@ -0,0 +1,117 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * DW100 Hardware dewarper + * + * Copyright 2022 NXP + * Author: Xavier Roumegue (xavier.roumegue@oss.nxp.com) + */ + +#ifndef _DW100_REGS_H_ +#define _DW100_REGS_H_ + +/* AHB register offset */ +#define DW100_DEWARP_ID 0x00 +#define DW100_DEWARP_CTRL 0x04 +#define DW100_DEWARP_CTRL_ENABLE BIT(0) +#define DW100_DEWARP_CTRL_START BIT(1) +#define DW100_DEWARP_CTRL_SOFT_RESET BIT(2) +#define DW100_DEWARP_CTRL_FORMAT_YUV422_SP 0UL +#define DW100_DEWARP_CTRL_FORMAT_YUV422_PACKED 1UL +#define DW100_DEWARP_CTRL_FORMAT_YUV420_SP 2UL +#define DW100_DEWARP_CTRL_INPUT_FORMAT_MASK GENMASK(5, 4) +#define DW100_DEWARP_CTRL_INPUT_FORMAT(x) ((x) << 4) +#define DW100_DEWARP_CTRL_OUTPUT_FORMAT(x) ((x) << 6) +#define DW100_DEWARP_CTRL_OUTPUT_FORMAT_MASK GENMASK(7, 6) +#define DW100_DEWARP_CTRL_SRC_AUTO_SHADOW BIT(8) +#define DW100_DEWARP_CTRL_HW_HANDSHAKE BIT(9) +#define DW100_DEWARP_CTRL_DST_AUTO_SHADOW BIT(10) +#define DW100_DEWARP_CTRL_SPLIT_LINE BIT(11) +#define DW100_DEWARP_CTRL_PREFETCH_MODE_MASK GENMASK(17, 16) +#define DW100_DEWARP_CTRL_PREFETCH_MODE_TRAVERSAL (0UL << 16) +#define DW100_DEWARP_CTRL_PREFETCH_MODE_CALCULATION (1UL << 16) +#define DW100_DEWARP_CTRL_PREFETCH_MODE_AUTO (2UL << 16) +#define DW100_DEWARP_CTRL_PREFETCH_THRESHOLD_MASK GENMASK(24, 18) +#define DW100_DEWARP_CTRL_PREFETCH_THRESHOLD(x) ((x) << 18) + +#define DW100_MAP_LUT_ADDR 0x08 +#define DW100_MAP_LUT_ADDR_ADDR(addr) (((addr) >> 4) & GENMASK(29, 0)) +#define DW100_MAP_LUT_SIZE 0x0c +#define DW100_MAP_LUT_SIZE_WIDTH(w) (((w) & GENMASK(10, 0)) << 0) +#define DW100_MAP_LUT_SIZE_HEIGHT(h) (((h) & GENMASK(10, 0)) << 16) +#define DW100_SRC_IMG_Y_BASE 0x10 +#define DW100_IMG_Y_BASE(base) (((base) >> 4) & GENMASK(29, 0)) +#define DW100_SRC_IMG_UV_BASE 0x14 +#define DW100_IMG_UV_BASE(base) (((base) >> 4) & GENMASK(29, 0)) +#define DW100_SRC_IMG_SIZE 0x18 +#define DW100_IMG_SIZE_WIDTH(w) (((w) & GENMASK(12, 0)) << 0) +#define DW100_IMG_SIZE_HEIGHT(h) (((h) & GENMASK(12, 0)) << 16) + +#define DW100_SRC_IMG_STRIDE 0x1c +#define DW100_MAP_LUT_ADDR2 0x20 +#define DW100_MAP_LUT_SIZE2 0x24 +#define DW100_SRC_IMG_Y_BASE2 0x28 +#define DW100_SRC_IMG_UV_BASE2 0x2c +#define DW100_SRC_IMG_SIZE2 0x30 +#define DW100_SRC_IMG_STRIDE2 0x34 +#define DW100_DST_IMG_Y_BASE 0x38 +#define DW100_DST_IMG_UV_BASE 0x3c +#define DW100_DST_IMG_SIZE 0x40 +#define DW100_DST_IMG_STRIDE 0x44 +#define DW100_DST_IMG_Y_BASE2 0x48 +#define DW100_DST_IMG_UV_BASE2 0x4c +#define DW100_DST_IMG_SIZE2 0x50 +#define DW100_DST_IMG_STRIDE2 0x54 +#define DW100_SWAP_CONTROL 0x58 +#define DW100_SWAP_CONTROL_BYTE BIT(0) +#define DW100_SWAP_CONTROL_SHORT BIT(1) +#define DW100_SWAP_CONTROL_WORD BIT(2) +#define DW100_SWAP_CONTROL_LONG BIT(3) +#define DW100_SWAP_CONTROL_Y(x) (((x) & GENMASK(3, 0)) << 0) +#define DW100_SWAP_CONTROL_UV(x) (((x) & GENMASK(3, 0)) << 4) +#define DW100_SWAP_CONTROL_SRC(x) (((x) & GENMASK(7, 0)) << 0) +#define DW100_SWAP_CONTROL_DST(x) (((x) & GENMASK(7, 0)) << 8) +#define DW100_SWAP_CONTROL_SRC2(x) (((x) & GENMASK(7, 0)) << 16) +#define DW100_SWAP_CONTROL_DST2(x) (((x) & GENMASK(7, 0)) << 24) +#define DW100_SWAP_CONTROL_SRC_MASK GENMASK(7, 0) +#define DW100_SWAP_CONTROL_DST_MASK GENMASK(15, 8) +#define DW100_SWAP_CONTROL_SRC2_MASK GENMASK(23, 16) +#define DW100_SWAP_CONTROL_DST2_MASK GENMASK(31, 24) +#define DW100_VERTICAL_SPLIT_LINE 0x5c +#define DW100_HORIZON_SPLIT_LINE 0x60 +#define DW100_SCALE_FACTOR 0x64 +#define DW100_ROI_START 0x68 +#define DW100_ROI_START_X(x) (((x) & GENMASK(12, 0)) << 0) +#define DW100_ROI_START_Y(y) (((y) & GENMASK(12, 0)) << 16) +#define DW100_BOUNDARY_PIXEL 0x6c +#define DW100_BOUNDARY_PIXEL_V(v) (((v) & GENMASK(7, 0)) << 0) +#define DW100_BOUNDARY_PIXEL_U(u) (((u) & GENMASK(7, 0)) << 8) +#define DW100_BOUNDARY_PIXEL_Y(y) (((y) & GENMASK(7, 0)) << 16) + +#define DW100_INTERRUPT_STATUS 0x70 +#define DW100_INTERRUPT_STATUS_INT_FRAME_DONE BIT(0) +#define DW100_INTERRUPT_STATUS_INT_ERR_TIME_OUT BIT(1) +#define DW100_INTERRUPT_STATUS_INT_ERR_AXI_RESP BIT(2) +#define DW100_INTERRUPT_STATUS_INT_ERR_X BIT(3) +#define DW100_INTERRUPT_STATUS_INT_ERR_MB_FETCH BIT(4) +#define DW100_INTERRUPT_STATUS_INT_ERR_FRAME2 BIT(5) +#define DW100_INTERRUPT_STATUS_INT_ERR_FRAME3 BIT(6) +#define DW100_INTERRUPT_STATUS_INT_ERR_FRAME_DONE BIT(7) +#define DW100_INTERRUPT_STATUS_INT_ERR_STATUS(x) (((x) >> 1) & 0x7f) +#define DW100_INTERRUPT_STATUS_INT_STATUS(x) ((x) & 0xff) + +#define DW100_INTERRUPT_STATUS_INT_ENABLE_MASK GENMASK(15, 8) +#define DW100_INTERRUPT_STATUS_INT_ENABLE(x) (((x) & GENMASK(7, 0)) << 8) +#define DW100_INTERRUPT_STATUS_FRAME_BUSY BIT(16) +#define DW100_INTERRUPT_STATUS_INT_CLEAR(x) (((x) & GENMASK(7, 0)) << 24) +#define DW100_BUS_CTRL 0x74 +#define DW100_BUS_CTRL_AXI_MASTER_ENABLE BIT(31) +#define DW100_BUS_CTRL1 0x78 +#define DW100_BUS_TIME_OUT_CYCLE 0x7c +#define DW100_DST_IMG_Y_SIZE1 0x80 +#define DW100_DST_IMG_Y_SIZE(sz) (((sz) >> 4) & GENMASK(29, 0)) +#define DW100_DST_IMG_UV_SIZE(sz) (((sz) >> 4) & GENMASK(29, 0)) +#define DW100_DST_IMG_UV_SIZE1 0x84 +#define DW100_DST_IMG_Y_SIZE2 0x88 +#define DW100_DST_IMG_UV_SIZE2 0x8c + +#endif /* _DW100_REGS_H_ */ From patchwork Sat Jul 30 10:24:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xavier Roumegue \(OSS\)" X-Patchwork-Id: 594594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97C18C04A68 for ; Sat, 30 Jul 2022 10:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233428AbiG3KZv (ORCPT ); Sat, 30 Jul 2022 06:25:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232979AbiG3KZq (ORCPT ); Sat, 30 Jul 2022 06:25:46 -0400 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50060.outbound.protection.outlook.com [40.107.5.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F91F2C12B; Sat, 30 Jul 2022 03:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WegUmCFlEhjPG4NSxVlEIt/iYfYm5bPdU+nUA1AWyb/+mBmFeVsLLnkylpupm+saspdb4dLE+4d1DT3sWiVs7jYthScf9Jk1fF7/jDhUqDgedrRNgITyqOin/TIsf8zY9qIxxnlXtCGJnLhmNfrqt7xdiDXuhXAIm44nn65UDmfXroMR1hS/Ooq5PSA3zm9DLPzzTW42JPhaVKCoNBYzjCPLvGya1iqu4qpBTsC52jWV+TtNrTSBa6ddXEIhrCYARoZJ5Jz2Nog+Fx+nYhD2KzDTsIcQhnQsRvZyC0b1c8jI3RtWEYx7fTpaiqyP91WWojUnul3bnHNCIGWWXr151Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mzPTxSpBvCED02QSOs2bcDzT8pYf2J9JntNxfaawM0o=; b=AqPmnq6F+0xRtIx1xDyThFtEf+Z7BCdPszeTDSuDQLOj0J/oNsdNUbFQshW4TJrIU9zNRxedsYWAjOrKpi104WwxnR/WZO+R5JnYRX2a/2f7EJ7c7tm7z1mlbmgvO8oJi84AMAhbVq5LwVfst/T1c/Y1S3aL+DK3iav3IhHpsnRgcvx8AXcJXnzhMpFSsOYqbLfF8Pg+ovR6CqRx/jZm+feVyVE99v4dY8LlKHgmcmsLQE60u1LPfBb++lko3+4V4DQ2Wf6hYagVtz5TsdUAH3nC6/PH7PQdLaG0ROZDOmwXAk/57oPcRaVFh7XkclUvq+FrUWhPHmi9ZXNUQc7G+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mzPTxSpBvCED02QSOs2bcDzT8pYf2J9JntNxfaawM0o=; b=e9QRaGZ+fSCAuGgWHpJ+4yiOoiZG2nyH8Od47bmIsSzg9f1xhyZp1QbBWH6i5Wx4LonFkM7KrCSsps5vv4O2bmiPX111Mg7kR6U8FwQ0voaBCIbY7PXdb06tKAK1lch/bwtCGCdrjRZYWxxEEkYilj490uq+EWnkpWYkKkOi0RA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) by PAXPR04MB8621.eurprd04.prod.outlook.com (2603:10a6:102:218::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Sat, 30 Jul 2022 10:25:39 +0000 Received: from PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f]) by PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::9d8:f571:6ec7:521f%9]) with mapi id 15.20.5482.014; Sat, 30 Jul 2022 10:25:39 +0000 From: Xavier Roumegue To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, stanimir.varbanov@linaro.org, laurent.pinchart@ideasonboard.com, tomi.valkeinen@ideasonboard.com, robh+dt@kernel.org, nicolas@ndufresne.ca, alexander.stein@ew.tq-group.com, ezequiel@vanguardiasur.com.ar Cc: Xavier Roumegue , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v9 8/8] media: MAINTAINERS: add entry for i.MX8MP DW100 v4l2 mem2mem driver Date: Sat, 30 Jul 2022 12:24:13 +0200 Message-Id: <20220730102413.547698-9-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> References: <20220730102413.547698-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR1P264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2cc::9) To PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9bc0eaa9-803a-4df6-d996-08da7215d3ee X-MS-TrafficTypeDiagnostic: PAXPR04MB8621:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZLGsZHXZuBFaUmDHM3QrDZlfS9ueTTXu/fNiOkPI5UHfIRQeFJDVNTZJEFur/a5DjkobvTAUJMTl1+fsYeh/0N587OZvjcF4NK/uTBoTXQ3QsTFkZzPCpIkE9lu3lspbY/B6pmMTkmx1SfLMlnFlRp+/VRo2fXST38nUY7JgrSHFlr+vuKp1nY8jyxbwlEiKSXDvPkS4XcUef1+ahHvhj0YI7hKXKUIFy4z7oT0WAD13wcFeOasHhTd0H7UbpfXOs5NhpFlzaaSJZ31MDmUZp20VnbDwbp4GiA9uNB0IU4JGY7H67m2qP56+vQndOE/B738OmpdS9D95PVId5SmIWKrxKWqT13J8UIue6CRAZx7LRfcfQjW2ftGciFqUctVkrjY1mLQplQ+/jdVyxCI3tXHSkghPrZR0puhqzQsPprG+D0rLMy2HVmNskG7a+RBZ00cDEoSjrjaiQgFNfW22zR/VwvszciP2KLpIvrSCLIbbg54Y1C1LiJHYmouAxN2G2cAOHlSAqKN8V5nexo4p5KnJjk9PKvj+egSeZq/pDiedNmqzxSUyjyDkuqkrHTVu4nIgECuhaGwdHjj15vNq4QFTlOR/AeCjfQzQVkVojGQLyzg6tPglNsBRyFp9LiZ51rCZm1BoaI7Vewy5BFBJqnCb4mpKAQkeWZcjvG9zpI0319h6fQL0hLJsC7ABqXfe/M9+FDXFKj/Yt3F01iYnD9GBhqfF/LLq6qdYenSxUvswUMHtRR5cQTYl0PUmGVeM X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8703.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(366004)(39860400002)(136003)(396003)(346002)(7416002)(6512007)(4326008)(8676002)(44832011)(186003)(4744005)(52116002)(66556008)(6506007)(38100700002)(6666004)(66476007)(66946007)(2906002)(86362001)(8936002)(41300700001)(5660300002)(478600001)(1076003)(6486002)(2616005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2J6uT8QVLwZwm0fujuNmzVt4slQkLWqBbMGb7V+hr0rCsV+JLvM9VRbXUO0NF3th7zlhypVWhB7XuyVaEZW7YvcrQbXejCoyKoN6+sTgtd0N7aTHrjm9uu3td+NUiacQmF6jIUrYSky/eRPQwOZKbR8jThdflhK5NtskNvFFiqyHaaPCyG53H96byjqhz+W3rru1FjxuqXBJzodFQjrYKB8AjoIMZpCrK9gtWOerTUAFZr/TpxvF0VkOSxCZvZJmPtGzN/ik8POj/7hozXukSXqYv7xGLinZG/52p6iTMCEsBvkSx5xIry7NrP4ITwkAPPZy6PKMIDQvuwBJSkvAqFAN44p/uJE035U/2XKEfwv1eheSX+/wydSU5G/v4jUPMR8StBXY/IpDzLv8FR+2TllUxGApBiskH52G3uUtgpSMhJ/HgRoTNE6rtEUZWU01MebBX29zN26pDCjNP6vNAi4llqzeQdaM76fpdqb9oMuXaNecnnHv+auWQdoCN9q7qw4pFlKI8V+c3Noekb9xUdVAAaVXZghaiqlr9J4Nkhpr4oh8xmTCQ60BCgRI8CF+F9q7zYCVgL7lOUNj29VllBpvJy/8oM9uOyVIDOg6oCcJHHiIH1K7mRiX7PScz/5PKwWR6yfJm5Q1rxgekhInBViYLNjVYkH6+dILe4iUZZZI73pW1zJ4JDNFXlPlH7GBvMln9/QuePDgi7tHRiVV02FYafuyj47jS3gPggZosb9AQUr5JWU8+uRReMMzekne2nJLt3Kzo/0wKHL3Qu7H/cw6igY50IirRJr9UcBPUMSLL8225cKBFymMFF9tW7K5UmZNuF//7yDZDkR1rKmhFbdPGPspqx66m3UzT7pgy4D0sCFE9EBrpwMMve0/rNROYnsEr42NKxdq33Er+AWUqIvNMyrap1i2Gj4B82HkUDGQnm8TpaG6MQfksCRzsr+/6Sae/Go4+6/MIDHHlPeE74EYAyZsZkUYMD2eUKrkBl1M3/fqZTgwheQ+OzJmqP3mzOdJ9S/HVEOs0Wt2ya7q6lHOhH2GVdw+iupfjt68fXi3jfhzjPIg/p7aqcMVI7y98vBM96msNU1yXT9tqB3Qh//bf7jf3vJFBH3xAbD0A93HqGX2DsNXFXp9nlPmkg70uxj0Bdl+Os0FnjxCuBl4SbfiMQo6ZDeiUbNbzqjC1+0ggB36m52cLzwRSmMD7noPv7Qsa8sPCtmHNo33fjoGkmlIT5DFeuLXHk1RUtWJm2jnIgRUjhfQa3ChkUjksY9z+RLiryG1BI3QUtnEvZhdHT6ckZCxWQ4BxhJfNgAAELBoW6BfRVZl5VYZ4gJ9k4unQzZkFcB/zy3Tk87iH55ZDrVxjxt54oosBrb4TaoAx+/XEeW0xN7KzCbBDEf3kfBjsbzMq0hc/Tob9W7vP0h6pPVat04FuzsDmpaDrxzxZ7hwEPHnmM4BOkF2AOOEnerbn0cqTEIkKpfRNliZl9yqe1bpLlInlKRetfC3J5PEBX9Y/d3FU3b+v9paHcDJ5lv+ZjYZHYYYKmIlKeuUQO/mbMjOM41psc/OWKQKW7b8AwNi7BMtg5KqwFSIIbQwuEoHWEOXIPHRrn/AtfCzjKb5l5AM5xB12IW8s41NtEkz3PBoz1CVrxfEcwMMdStCw2eDS7C1JDrQUCC7KeG3iF59LA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bc0eaa9-803a-4df6-d996-08da7215d3ee X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 10:25:30.3268 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FZcmbFJX++F/SYPxMMhHnoWm3gK7RNRjQtjUY7I1CzwUCkpp3wyudPF7+L96PYYy2aB0GaWaYHHXdMRiUcbAqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8621 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add myself as maintainer of the dw100 driver which offers hardware accelerated dewarping operations through a v4l2 mem2mem interface. Signed-off-by: Xavier Roumegue Reviewed-by: Laurent Pinchart --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1fc9ead83d2aa..a2e1174bc0bee 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14355,6 +14355,15 @@ S: Supported F: Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml F: drivers/nfc/nxp-nci +NXP i.MX 8MP DW100 V4L2 DRIVER +M: Xavier Roumegue +L: linux-media@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/media/nxp,dw100.yaml +F: Documentation/userspace-api/media/drivers/dw100.rst +F: drivers/media/platform/nxp/dw100/ +F: include/uapi/linux/dw100.h + NXP i.MX 8QXP/8QM JPEG V4L2 DRIVER M: Mirela Rabulea R: NXP Linux Team