From patchwork Sat Jul 30 15:48:36 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: 594592 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 BD5D6C04A68 for ; Sat, 30 Jul 2022 15:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234941AbiG3PtO (ORCPT ); Sat, 30 Jul 2022 11:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235124AbiG3PtK (ORCPT ); Sat, 30 Jul 2022 11:49:10 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2057.outbound.protection.outlook.com [40.107.21.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D1F615A0C; Sat, 30 Jul 2022 08:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PDczSK4cCAElRqHczeAtwq63OgzPoK01a1fmqu3hMkKp8waXwvZxpEtC4s0YZ6kKWfxjwtF4x2wsrlmYeiQ0ah1uVEFKUWKACUNhhUFoapT22/eDXpcwCZJA3RkH3WYL+bIL370uZsFlRmVa6GRp2HUl6oLJq3ViZKhdDYL9S4Qj1/iihmFuL3bfj0NNAGmwgrzvN08cW1DWYriNJL8l3kWH1Q1AbyoGgvn/VEy7HBxh+mbhCDPaojjW4q5lqozkHcORB4hVQ12bxF193xSvSHLKKSAmYlMN3eDF7/RFw5YCGL0BJU0/J38/Id33pG2MARZXeg6HqcpmEmZ/AdNV3g== 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=kZrAAryoVZCySzRib5onu8pfCpHApts8EFM/LK2Dq6zyrceBB7mc4Y6vL6T7+2f1iZ2l/TxlbNFlYDRwPgWkvwD+EVJyRB/I89HJ712IoQ6G3Coyqk94eNdFigZnvfqA7pOIzBFg7QtYjoD1B+k35qK79s96md2/N/CUwBYd3NR6yyq2IAAivx4vcy/s0XqYH96OIrasXNfGTs1cidL3VMBS3bMk24d8F4XZboQb7Xnxs2oCiJbzko83nWu4hbvqG8khngEck6RA0TMoTzbcvak1CzzQsEDjqyjaKIfN9qkd4gIeCTKAFQnPUkvdoX2lqoT4OQTB947XapH4fTedkg== 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=jwH2Gl62/oYWQufDQ0dJX1M7/umtW4NunUgaU8NSGKVC9UL+0FpebZ7H6T5qve/wT/9VHKA7sZOgIpSjTn2WDlGOgCr4Y7Aa0VKyQhrttAn/EkC8G2EvTXsW8IRRtieFb2F15mnKUPcBwCXNlE336gK7GrXs/C2g7mUB5FxMS30= 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 DB7PR04MB4875.eurprd04.prod.outlook.com (2603:10a6:10:1b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Sat, 30 Jul 2022 15:49:03 +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 15:49:03 +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 v10 1/8] v4l2-ctrls: optimize type_ops for arrays Date: Sat, 30 Jul 2022 17:48:36 +0200 Message-Id: <20220730154843.791378-2-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> References: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR3P189CA0082.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::27) 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: aa7afdf9-c9bf-45f0-439f-08da724306c9 X-MS-TrafficTypeDiagnostic: DB7PR04MB4875: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: b42EopFU6yuvHEQttBufMJy1OtWd8OeASHDirEzoZZh/C9KvCXQxR+4DP+qxg+TNuhMGAUa3+MeJYUcrUyFGNyPFZEALkQEdPw/JhSzo1Xow2zWfxDOcqPB0eBFY3swQ81BVFkuYZqIunuqBsp4aHt9qy6JslaGMFvtl52I7ljv+0kMTg2WQArfKvwjjx2AUxDFRy53XQaddqjvTlZk3LVUjfZLu2TCCFH+9RouuYHgCMGWixtTcM57f/YSaXP8LqR4Dbrkj/2geLqcDGzZSTpl//pTmpLPRTSzc2tLxC+z8fONhQTeJPiqEH17JU8e17g4U3w84vLkDVUuMxXm7mkSkk6ShpwsKdh+crPCrVpPT6J8dwKDrHjNdHsYTlq/+sBEUB0grJLLea3yi+N73TOXfEvdFCeZdKNFIWoRkmAS1bh00otIVLEm7a5qJHsR6PXHsRK83HaJOZvk9JoEyC6czMYu4XdHJyX/4N6Qdr4dooYlz/W/Ap/5fPA4ggSrxzCEc0qMnbypbta5ddWeWTei80eYJuilC9MX0wau+PcLWUZlAS1VETwmZLcgCtjeYUwYMlRRkeEdqQk/ycro/K0dm3kG3LKssVt5z4ygpjoyVTkz9zlr1cpf5BRl7I26Lq2XeZniNaKt6Ojjk2z+JrJ2wsT1s8hzzP3mbEbXj7rwIg2U/tun6KeInMPoYhMzaY/Hp2FoSPqK4gsw9iC07eztA0yn0tavf+P+NAbttAg/cljJRcz60lFVnxrJseLxM 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)(39850400004)(346002)(376002)(136003)(396003)(366004)(41300700001)(6666004)(478600001)(52116002)(66556008)(316002)(66476007)(66946007)(6486002)(6512007)(6506007)(83380400001)(38100700002)(186003)(2616005)(8936002)(1076003)(5660300002)(2906002)(8676002)(7416002)(44832011)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Gd9ginvMg1jbf5j/1gPwwMnQsiks22Orosd1BM1Ga/GAoxDDISn++Ih/xk11RcGMxwngXxmUjJlngdGOJoG7KlcKOGkPguo9pXTwl0rsNDXEZWgTTqD1sGb2xYvh809cCiWWqGMSnRmH7oVZig5pzpTEyB579S+R80QDhZ9+fn+bFTdDBPnRQ1R9bEcNZa7YKz3KjLPeqK/c/9QkvqXVJNkdrJNU+Q1H8hJfrJiSm/TQUBnfMlp79UDqP8Qm+0pixWV3noDoPwYlKWKAAQZvZKvNqJ2llawyD5eovik9Z2SD13LDlzHb6nsbb5FUr5Yvll6aZjs8RRtlqWTpi5k3BtHTNE1j9TD2kMINsoNVMyZ3Vzm+SIFb5CsjOcz2qN+XwbQeqy4xvElzvzmCWzsve5XAFMw8zfbW8GN7hnmuZkrhKFeZoObFksGegp4/6HD9QssL/I02GXPo9Tv3y2AKjKLIZG75zPFzZg94EHXwIBs03i/wEEW09C7FJF80ZWYQVe1AtWc+pw6wUWrsoMUKltqQAJ59ZgGTgwPmJEtYG9bH+siNJPUy7HHgo0AgFu/uujGJgwWMsCQLrOUfsLMefKE7WUl3NOOCOLPOpcFN4MY4zU2BLsGivUKIuLPLtSY6MFnOwpiAT9pRz+C/st9xvgwyqIOivX1G6N3hS3S3Oe+PM4PyVbI9naLff3CmEpLNpCYjOF4MhV8EinEq40YvE+FZroYh0nlqd1F2HqoCCeZcswzByBki1mAyJMWS9MFRycqxn5Sf1NCXz1dNNGl2iBEq6zl0HrXRXKyS1hKyeZk2fL1Z39k0JCqKMtQIl47+oIVUtWxx/xUaO/55c/nD+IHxSoBgCd7NWvozvI7l9zyRLC+XK6barv7GjOvEaQu3MURStNBVMVr80nZk6Bv5hj3d6Ng/cvs9wd8Q1MmTceFKF+UszYjc2mWW234CvyUgCbxG/86WASux8Nva51ZtWY6zQc9xKXBvP+zSdcg4ieuFKWfq7ZL33iOgtJcxmkdE9b/GdlrN+cR9Xsgo/5ZPmd76Y4WGJbKFsoxy3SUsugK8AI8661Bf66MIGOKz/WLCSGsm42cmCM3KQKTiMKcyN6IO47NSrOUjXjLle088KxXfKSGseFf00mbWPLerLNNGMr0NwR+OtInX/Bu6/ORIQt2jHHE5FVuO9iTq9vVFu55JDj4Xqtm83whSTmY7oDQrCgt4JY6VT6R3d8AqAVJ9uXdAFtz2aS/RXVQd4kazIKys2vJNY/5tvzDS8r2T4FB8rHZDt+lNaW7wKyN4pHYB4O8c+Xf8eTSsC5T4k8aDVuXZTVtPm2LzqWLoru12mnvcBBtJHRykoEdjaZiIB0Bz/oArIQdZzss7uz6rMgJp1EzGGD1xANZjljOEKHCkztQWnKbZXrZPP+/yarVuAGLdEYA4nTlXaJgvqTCLN3yc2biuSuz+e+JiqT7NjvXRLa51jVran36oRxv8txmTnmKOz1rdLNvXPrW5jKHj6TfX9OjX93CpUfvCf9W5oRIZAoE51qicHFoJ+e88gaTre1J2wjkv1iHCYS6G09CC7fPIoRtGvrnpRUBxOwEyJnIVkoPLb+terhPWRwchhk6nH/+CuorVUWuxEiVvRUewyY87KpmgEINK4UDSjdA4AZPnghJ5CrTtRmoPIqdMIbhd29s/sA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa7afdf9-c9bf-45f0-439f-08da724306c9 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 15:49:03.0137 (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: bBzdsaQndGTfhXyHC21kZVKv0ns5Ec4RvM1EQE/mDAxcvQIr481rVB1D0SPXJYdRFz5ARLbiNgySG5WtXbV7KA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4875 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 15:48:37 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: 595731 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 BBBC8C3F6B0 for ; Sat, 30 Jul 2022 15:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235191AbiG3PtP (ORCPT ); Sat, 30 Jul 2022 11:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235131AbiG3PtK (ORCPT ); Sat, 30 Jul 2022 11:49:10 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2083.outbound.protection.outlook.com [40.107.21.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ACC915A1D; Sat, 30 Jul 2022 08:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hRN3QsL2wRXfV2tVS6h5Ic1lsFhzngBGwDFCpXeNn1NsA0awUU04NSUgb7CNVoFfFBHcTZqhvlkQGfKQ65jsrOiMwxbqzep4WGMFzelqxxYTsPwjcdxEagnVq+O89ImE2yWKRt4DpbjLdMQFCG+Faofnqs0PyCainD/wky3Wza+SXq+ZjXM8Ie81n5FwNFVLYoDDIp9EGBCt+LJO503YX/OeOL6nKciMmh/61Q/jWkgGS/yDfNr1tRfKpTeeO5bWtNI98iBfOTyGNlaq4cX04cylfPWrd9TyhWCCPBGdn8GzlExJ7idYGsjCSjmigYGedamWFN6ONbaHjEVGVd9cPg== 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=LBFBZGfgltc8v8d3YZpeCaczEMG/0URWZnQHO31bnUyw6JspPbHrpufwvd/lLGns+tds3ypTn4MKbYUac38xyBZ2AzlEFVgGEaNgp07b53dl+LzJYRKkX/zLFhgSe0j2JKKvQXmWtwUXTBlC9Cflu0nr1CFOAeWzakDYA28beXOnmq1RSkWtWrkH8O+qdUzT5gD8kNkuwJEWLJtEFG9d1J0YGGYiYIQQs9qJvIT/W44vBc003VmuqoxADtkl91p4JSLMC0eBq+uiViC2EsDuneu0rFEq97LrqYG7V5mWSBfYCiQWzemOO1iodTo85X4FodiMXCId9GyDgE4irXsAFA== 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=ByKowVEPKTI1zxFFonDL2mjTx/uONIo/yCw+sxnBMf1cdbyV2zKU3m3p2FIs0SAf6f4DDRUcNpTa+pEXUVHFIID4jMFZTvD+y4Yg+il/eAmWuo8VjaiP8EUMVimDml0ijiBBFjt96hBvxn1wnNBB9XFOouw8c1aUtDzlJAxgsBw= 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 DB7PR04MB4875.eurprd04.prod.outlook.com (2603:10a6:10:1b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Sat, 30 Jul 2022 15:49:03 +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 15:49:03 +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 v10 2/8] v4l2-ctrls: Export default v4l2_ctrl_type_ops callbacks Date: Sat, 30 Jul 2022 17:48:37 +0200 Message-Id: <20220730154843.791378-3-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> References: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR3P189CA0082.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::27) 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: b233ed5c-2c69-439c-5248-08da7243071a X-MS-TrafficTypeDiagnostic: DB7PR04MB4875: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: +zXzPjzEOer8Wv6ghcJmxDEP+ZUjFrdjiXB3EdX0qotC7NPpsGY3fw17h0SritpjunBBAVwLJKAwF5giF0wJEz55DAUgqzRzwZ4Cr3p6TJ+Am785qnzXl1T3FsjExkqZTW+Qyv7kRdzNask4mBn8moFyEEqw94HMh8D1qVr2XMH0iRs2S5T0gjMWD9ppyUvaCj+uj7nVwqEChfHAe3/LuUr40oM13doI/9p2YZSoI64tsYiJSwtu1K/q5e+1mZwpJSzxJEj2SDy8lY/DfXC7qLZx9Bdk5F/y/c7BjcWR05R45xuxqhPgqrzgEizoLvYAtZtqRY77ZT7rO+1YHHhc1hEb9VUL4QEDUQWxieGICqvlM3AA29zfwGnFasGj+01/2i5wM6D7BKyqlMvIU6ZUwHA8Kj5/yuKoaoWVOZNLPsgAUwFlx5Dz5YZcdNB5psbEFD6/+d8t/bwNHb15bnwfd57DOCZoj5Fb3HJMaozD8lkwwwDHYEGFFlTW5nXMbhbIKI/qM/bSMS7zn5DDvr/hGBHRgpw0vAKIbWKUh2ubd9AyfYWa8mwxALoneCUJ6wB8ZciPlMDKPMXIoh0ngRhUxzOClJMLwoEfqGQEqqLZZthbHzpOR10Zjnmne+2ekWzW5jFPxsj94+3kQG306x8ipxVoIMVq0cL77rn3irHZF99r5NunOyZW+FhCsI/bAHJk9TOT3fU04Kax9XUGfIOws8JHdOj6Vj99wDRJUl+kw28lrAw2XY2/ecEnq18kehjq 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)(39850400004)(346002)(376002)(136003)(396003)(366004)(41300700001)(6666004)(478600001)(52116002)(66556008)(316002)(66476007)(66946007)(6486002)(6512007)(6506007)(83380400001)(38100700002)(186003)(2616005)(8936002)(1076003)(5660300002)(2906002)(8676002)(7416002)(44832011)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z+MbchgH6kqNhyeyWC86BkgMbIaRDsZHSPs/mw1awqw14Nxs6BtpZsPeZOgtjZH1ZdIEiJBkMgLvGTwHu2XcZ6pIQoPmAAQwUmu7bKBeOBUelrit+uTys+aBXgrF4umOU22PVkPA4GCNINUKikGT8vFIUl31lLAu64C8m03onoZUQMw5iEaZh+YZJm5ERsDHyg6MctF8OtJiQnkbg25x+/r+7iTsONRq33UheufhmlMXAf+NoN85pN2vPfCnKevFxI3vaF6/ppg+f4rMKXss+FnlGCFeu9kGho5da+pYjR61OASvF2iJ356RjnS5jkA0RzxTs95dqXYc/Ztf5uq8slZcyQq6VmnnreH/UU4R3BPoSPJwhD0XD2Ba/fNYj7/L4UmUfLbp6oylgPcCwvih++NkNfYlHGqDPegNajK70O3yjZ2GGg9MT/APMxV3STfozaZCy8PA4eUXrU4Pu0sjoWwg02yvIXC28/tNIc03xMbGy+YIX0+RBqsD5UkrS9cLAS0IGsI26CzL2aOOdDcZNG4dz2TUfmztt/W88vgic+XeLJCLTP/y8YGdU8t9LVXgFYz+KIucTd2914hb86eCTaYrqf/bkhShC3fBG9buOTXD0lfx5s7jriqL9Wb0Hp3t19tVGairBXqqBCNpBu3w6+IYGnloLkyuttsS7QS3WbfL3CZX71OTwTCBcfq6UxSx1/h+l3kbVoIMP3ngy5E5g+FpK4xb2EZu6YEoVmK6srSoHoSas1R8v+1EALSqhfTqkxGWvkhvFJgYe+SxsRtgtyaAerN+sycVZfsDskGjG/Vk//z252KPiA/1TuVPMspWffcQN8RKih/AkfOtSh2ygRn3LP50H+hYuQU2Qo9QTfuetPB3ZYAiQVHLOg51jAA2U4fQzekrgQfBaToxs3Mc5yGb8ZyDgf+M4uuO/+bROz9m8Fo+5B0QUgATQO14Axo3ypefGNGiz5d5dfY22JeSn8Wm7U7k6CyfIqq9btkgbD/EeAwkJta93z+ESxBuy1t+XqsLmAB0s+npVqArdlg5HWfVQ2tiUEZgU3D2XRtg8A6jC+pkCK+00vrwALtlIGS1frOwX4sxjXqtUmo+EKfLxzv9vsIwDprsh76BMFbZmeEmkgVJuFLg7GSIfFbfDxPGSIuG9Bkl8sDftIunULj3pkIcR3KzKClY1ZPrErz/sPqPedaQuEWHz3j3i1y53C77tyjiNXeZRsOzgyZMkw86UtZ4oWDt+V4HjhsaCqhCiHm7Smk/1N7yybFZsP/bADquok7K6v2dY/AvbC68vRruErY5JXBg+wztOWSu5HyYHMW5p4k7wSHCvFiTlakx5Dq6r6xr0ci8MGSdxB3oXFWR5w0egRTJhISPS0Tde8vHRr7h0bbMBgWSh0YezUtC7ibhs+EIKq3RuCG5HeNBBI/gCseo8GyTDATscuMwvZ75QZGNUPYI1R1m2E7fzVB8pS5wEpfZ7eXGSuzpdHw02Vh1ng3GfVB9aijjSqvpZQmefoE2m+ku22bdsNYsgIwRkV46Jmp5NO1zRhGA1A1qxZs52sccFu2BCLqYRJ7CpQz8ED4HTGCHODMnu4Nx2pwqUn7On5n4tw/3eWYWWAxd9bWrQ2S6Vj7mG9wjWoOEwoME9q9NsZwzCiA9emdNF0b/rp6/NgJKF1OdUCQsG1rHBVi/2Q== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b233ed5c-2c69-439c-5248-08da7243071a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 15:49:03.5136 (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: mIGiG7d7W3XYeFpv6La9ZjKRgXL/KK5+v7r6/6x0DmOKvUjdMs8Z9wS8C4wzBj9htRC88U7K+JCL9hwt5zndug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4875 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 15:48:38 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: 594591 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 89A60C19F2A for ; Sat, 30 Jul 2022 15:49:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235221AbiG3PtQ (ORCPT ); Sat, 30 Jul 2022 11:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234814AbiG3PtL (ORCPT ); Sat, 30 Jul 2022 11:49:11 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2057.outbound.protection.outlook.com [40.107.21.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 630F115A3D; Sat, 30 Jul 2022 08:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L39TZiEHvbVgQ8Vao2iP5hKuvH4fke9Cj94U7cq1X9l7qLij8UWL2XYcuY5h1jPLpAN22wWtKD/it+hWooT3s52AeNmvzBygn/ESQdTC0e5vMumNuPcoxgnenwtD7zlopUCURVJvQYdQRvI1znXHrKnFpMZ2gpP87VYUQ2blUHC5Bup4tSjvTR0OwzZDJ+tyEaLD4km1U96QS7nw70HIxBR8niHG2sMob7zC1zHP3j0GtKqH2Vd+Aqqr+Ba8fvi8Wah+/gZcKb5CClFOMzvSsXLNFPX/Oxo2NifmQ4JHeI+YOxVIrccAdn87jWmukX8WNeM1nZ8pgtpBr67rqYKMCA== 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=VDKFDKxkXVVb4Z7aHLZZhrEXLRSMgmkJIJLPqvxTpltqCN1TR+kPOjKlQDX8AEGgKRReDpIIa/1WtYU8XsU+Pm5m5E58TWbcY/ISQd//esl9/h10rvMduzWFQbKLDekwt6Bfc2p43BBHIwNvlma1B3ACGyrFvfH2M1DFhRLguLssCw7YYHmi/8xDc2Cx4HnQviuklBwU3pMyqpOTJdo5uxy6NCjYwrZjpHaf4q0dSF2HvG7DfBsaCQvAymd2bd5knqHU1IGkaqcQZzkwz0XIf1xfkzfkialtACWdGn3JPMA11GGbs+/jf6hP9n3IMyKkJqHPewds3AWDRJ7NFMIR5g== 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=CUZumkoOUoItCMGfOd3ge93FpnjGvza5MqGStoaCt7atr/knrOd8IOaJidNaor5Q0D3R2PYeJ57nt4vrmK/fVTTSewVAr7829Za1XzK/1txv0vzfm1LvbRvvOPFKtnAAxwIDL5pQj+c901PPOg4J2sgRrKGfxz/HZm1fJXM33Rs= 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 DB7PR04MB4875.eurprd04.prod.outlook.com (2603:10a6:10:1b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Sat, 30 Jul 2022 15:49:04 +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 15:49:04 +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 v10 3/8] media: Documentation: dw100: Add user documentation for the DW100 driver Date: Sat, 30 Jul 2022 17:48:38 +0200 Message-Id: <20220730154843.791378-4-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> References: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR3P189CA0082.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::27) 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: fbbb9258-e92b-449d-9b1d-08da72430766 X-MS-TrafficTypeDiagnostic: DB7PR04MB4875: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: ZK9CweoP68cMKZUzs0rj7EU66/r+hkEp5JuEWPVkK7XcWdUa+Z6dHHktSbt/4e+cYvNzvrHFgeAz1IGW87MZKv6R/XPz9njdl1jhqTx/6Vy0DGzGJqGmiGRvR0ulNajMxW6hC6oodDBngBpnZCJEoK4nDwemWkOD76fVgtvnicUiVBcMIheXFgi1OXQcJvpH95wq+TTPKlDXCeYV1fFwGs71t3BwXPQ4AMUWkkh4sN3GY+JtgePuvVqGs9r6t3nmJ8ZW3RVyLdPO5yn9N7FcJg8zXM1oETp69SVIa8WVU+tKOrNiyR45pNZVqerYsUIUcvxxRLrNMIeXXMnYLkwri7u4lXPff89hZvj08wadBt0M0h8vV0WyyqZGl/mUkW3q/smoAlFoDagJZeOt9wU/O6J9jbUe5DoUoiGSTuxNG++Q1x87HB2hebfSkI/fK8Ih5CXLsT3dqghKwh6U+A+x4w/kQDaxfuV7Qo/1pedGW7GkrPxN+arTFbVBNLZLG9fRHUCTOtLpKW1EXx2N4zztJBpdoExi0Hn9hj1vUJKysUFfXjCypBkACq2kyPPAKowYQMRmM9NSEkkvvHDWdj0pZfa17meXYNXXoBfQ+NxohYSkG+LLpvjE7QU2cemq0iHo5F63RSxF4BceyhehtyiIXBRRlUwT+O77xMAjYv0C3ftc7P77DnVieZiLvWQtHJU1XAM3Z+IEVsBrLiCy3O8tSmB9pkBW/O5Ncw9WA4acKROp2Fa4U2VhraPe9hujGl+NsuQmZlfWb+qRVumWwQYCmg== 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)(39850400004)(346002)(376002)(136003)(396003)(366004)(41300700001)(6666004)(478600001)(52116002)(66556008)(316002)(66476007)(66946007)(6486002)(6512007)(6506007)(83380400001)(38100700002)(186003)(2616005)(8936002)(1076003)(5660300002)(2906002)(966005)(8676002)(7416002)(44832011)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tKjSMhuEktmDAWQt4W3thW5P3cM4Mtv0juWpojVh8xnCDQdlv7l0QDVo86H8obuIzd0blCiZmYMruK4BcH+ftm6amrVdZlQdzeobSWAZyEkeChG9thdAvxAdP4Zbym5fgpicwlPClFbQ1CZPzRztaiueZN0Zp5Py3PF6dV5F3UZb1OHnYUfh/8Gamcl9g98hqblY97Kk2QOSO1msV6TqaXs8RRvBs4pHcWI2ANQhsoNotUJfXnAJFUbcj4N77eWsAidz+AtO1p4Efkk5jMg9Wk5nOICaX7+9rnzeqCRR4ACrhDLhT7CEC7OSbEgWMf9Jdtvb7b8Put5WhfextecEf+SQNA+gOgRngjxkUeRLKvcwKB7bBAqWapKuMGbWLn/79nxMNXOT+sWbfPELZdM+/YaT9vwEuH46ghjGu6j4+4tuWa87kwlCOx2gmuZ7E+anV4WFiyRbWCOTHSWr5KVFJpH1jyi4MyVyrmd2SKBAPMMnGnWgR53j4DU2OWPM8KNqIemuvpsa0Puz5+FqpgSbM/dYICrLQ21DNFQgNgtMrvQq3uqnZkwna034qdCXO6w6lv8Sdj6bfQlA8/4V/OGAcV3LNua0IDvZWYTMLedHduA+42WCoQZxkY006lLkuwz+8FffkWB/UQfnPSs/6yZd0jUo3IbAQxP0tJa770seIAeijh5tLTmybcQKaYugwiIJxcnkSIPPkon+Y08EOVPRpegCuIjtJIaLn/RMs8FGKgTgWIpcQD4aVtjwr2x9m4tq0KHz3q0MtbJfVVDSVDrc2DsuHBW55JQ3mp9axTkKnggbsrSmUazDRvhWma66/s6Yj+rTClC8ggeT1xLy5kW1j0nHaZZk5fQlvPJJwAIGLhfBgNKIHAyNK3ke9laIZIHsYaixrHUEf87unWTsOE4KYP1qIXTOtirFfiLMTy9VDmPLxzty1Su7fIwqHGLRWSPu56aN6d6i+NY8Eo7hn2Wfck/ZHN7BRDbOmk78/OYp1JUZRDxmvmuj7kXAM2Q0ivVEEOq9NVuajpgYxkgHeleCcsBvLru/HGA5GgPfe5epu1CgsUvVh3yxnX6RjyGAEqc+ldCWG9OtzYVYYbHJpoZQrTyax4X3LXub+MqatMqdpZH0HL8MrNKlOT2sAxM1M99yDRNm53MlrSjbKM8rX1V8AbOt1rxU3wiZUkNYUBQ9dC+CY16iQ6d/J2BiLbr6K53S42fThYEJKugw9udSMuev9W7iQP8b4JmBPs8+4DQDijDiEBv9YTl964sd2JlfDlywYqy1g/qdCO6EF1h81k79qVRuvICUTi0EPDfUhhfALWWdspvaXnbXr9nU0QBcO6T5A6wkMH/e04AbK3BoQQ1LlY6t+KygB3zmbDTKN1O5zKidCktUHV3QnuDxyp4GcN1wt5gVm5hEiX4TerM++OINbdrMyuJrAnTvBeZnHumX1qZWC3hY4L+afgQWw9FrUUdk5xLUOxCzJHmonBOJ39aCBvrNpA/7JLWjGxWyc66o5P+zIgMONEILoaNlEhLMdqSFIkrq8vouKaedbK5hPowJTyajkuvzoOhluUYYa1FzUC9c/7h3E71D22lzIoPbIcaf6O0nbfX9je1p/PAc8S+GD4Rb5pxvhXQgv+r3eKAjeXwBO4jblhUO54r+fYi+vpO2xi8F9DcuW1NHejBEbOKbpg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbbb9258-e92b-449d-9b1d-08da72430766 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 15:49:03.9979 (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: avaeWvCxU8fu/A/5O1ixaTwCOzvFvYOWGLERavqr4SF32A5j1v6nay/mVwIeZtgDaTvdEKjShkhEcQA+LFsD0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4875 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 15:48:39 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: 595730 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 C8469C19F2B for ; Sat, 30 Jul 2022 15:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235230AbiG3PtR (ORCPT ); Sat, 30 Jul 2022 11:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235142AbiG3PtL (ORCPT ); Sat, 30 Jul 2022 11:49:11 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2083.outbound.protection.outlook.com [40.107.21.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA69F15A15; Sat, 30 Jul 2022 08:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a4YhMXg9fVUnsmwiApklZTFut+WOG3A4+/sZ7n8vKR49xCkRSZa9a4EiHGkPCHfsjpcesWTpqA40mdM6o+9K96FJyF2vIQpvOKwwKjegTfQQlxI2gVg/ga0VPWelYo8e4Z3PF60aPAxEuHTxkj4/UebBOqYosqTMOuyliJolECW6ShQwJ3lM+aRWgZZPdsNgoI/utV6/WZaAWE1FAC9D0DnqZvLHG3YgXplbP/hW5bJF7WXEkExy3TNIFk11ThY5+FdESF1qK4xi4g+4JwFm+G8apGFCdedvYWGe9AGCJ3/T8xhE7XrGj2kT7/RTK/ZfzDMzgPtoYPJyhOr+zrOv9A== 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=f8IlF6nzxGrP5Ajf1qaw7X5ZdBLJPqNgzZVI/PnTZ00MMsxqu7ZZPIT9zuPPFmU1Ul7aXHlAPgugP2LpVVL4hJGl+vnPyursaHwbp/cFcS4l5JfZZnLCAqLb9eD7bFjO0W4LOsZd5386riCP4z7poxgUV7GYBjIkhwsEMU5V+WkOv/oEwZkD0owpq7KefatQumVRdZBXOS5G9h/puebWCzvnISBPAGx7Hag2QrupnO8CWqtLcRTOinDqNqfbvqr/X4KdbnNzPjmWvkPZUmMdwf7uVGvlWDHEEJoYK8XtL8pdPFnXNnQeClLPvQ1rcTa31jCp/rOs8OMAVyvoXY/R/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=F7f7zGHNQZv1eqEk4Rfa0A2wNlhS3QAzboYDRYMbrLo=; b=hi3BNVjsos9wky2HZbPk7cZgv5tT3zQ+N/TR1J61sk+ilPBIE7igPRSw/IBbm4qfgBpUouSZvvKiWyV5eZ+Q2CicR/JOxhv6nL1jB4nEMx6pmxcPhxgONaOkCfKsLO3GPSpliKk9C2tj2NXhY3b9wIK72Oi3BZ2GT1zndS7OhQI= 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 DB7PR04MB4875.eurprd04.prod.outlook.com (2603:10a6:10:1b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Sat, 30 Jul 2022 15:49:04 +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 15:49:04 +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 v10 4/8] media: v4l: uapi: Add user control base for DW100 controls Date: Sat, 30 Jul 2022 17:48:39 +0200 Message-Id: <20220730154843.791378-5-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> References: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR3P189CA0082.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::27) 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: a15f5a7f-5c20-4b7b-7c78-08da724307b0 X-MS-TrafficTypeDiagnostic: DB7PR04MB4875: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: 9Hs9V5vfGfdhfRn50pSH6hqB3e+PU3++XrxeNkWqTIqIsPeJJVK2TaqGpZtyKq4LAWOsUbFfumWLKP6CQTp4UauOStB8E7CyOfmzcCMV5GYA77O29pqRoZTxiHlzQkm9PLASV2mLckUiG8+fEPmCE4kOHs1SkTbq1e4eVAsQRBZ6secfS0ytVRtFSS8pbmhQkgi7d7HyXIjLGXsVmfvzzVkKD3GvGMMvjE1/BUYtS12WFrR6f5f0Laz6+F/sYC4cY9wMJV2tHxFcST5ekvL6WqzcuiSBWhwHqOeCZB/+bUT8fBukV6ZCYJTVQ2Lv363eV/Z70QUjVxX47FDUcsknOX1zhRyawZQqVvlseoznEWUpuPihpGD/9vjnkilCFqWK4vSkocbGFg595WjQcoIbnvv48F/h+fM4sk2kLndIT7sAGH2sLkCXV6LU713UOIxn/4ucZKLe5FRUAG77nb3fTecc2RFoW4F22A+GPIsebi57eH9gmdSG1yqvjV4UJlGELVmWJ3H8YDdveLCRjeQkzBkpWK0OJYBYUV+jLgnCI2FYjRXwaGJqqjreeyqb8dwjxGSRYjMIz7P1blsXXFbjZlGk1LenpG5RdLKP/9ILWu2eLi6R7aJf+9GizykYVDr9RrEpxqTxWlYsfjMLQlz6/M7V/TQk8WhwjdhntaksYzKxKfpgZL+Usi86GXfcZZ0nuUCMC6AhFESlBjIHwOJgVKf0uwrxw7eRd8ElxKRa4J9B0r/TsPDpOndUjCxRUFNf 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)(39850400004)(346002)(376002)(136003)(396003)(366004)(41300700001)(6666004)(478600001)(52116002)(66556008)(316002)(66476007)(66946007)(6486002)(6512007)(6506007)(38100700002)(186003)(2616005)(8936002)(1076003)(5660300002)(2906002)(8676002)(7416002)(4744005)(44832011)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1sUBe+JFMdX1pYaLLF4Rp7sW4gPdJ/fSTA751vSOGhgz+lwE4CveIdtYlPeA1Fe2ZTKNFd70AGJwx3COXNNF99M4F4je+2LlqxdWfYY1qFVCUOLPsl98YIKqmKB5W1h0uSAnlpDJCFHtnJAJIrIgblm/cYftvB8vEyIjmwIHskFgHoJ1za9/Nh3Rsy2k3i8irExuNKtXED7qI3s/L2e5YWKdDdygCR4ZdcAFhH5jcHZAoA4sqA4ThvqWbF3HlaHIiUsSCPLGOLylpXYwSaxGrsIcnaHYZ+2kDGTmgkFWCx3HscuGi8tKvwfIsA32fJoZV2QlkpiErqUcenYFU99IyxUhbn8my+QHoFa7NANuoTN/jgThyC56EYS+J3TadnsTWY3g9SvBozxjFneWg1KMB+qRfy7Cd6DpzHUusu0tAiJfpzGO+iYSvo5PxF0g9Y7QhqsAtxo57XqyXdS+REC0pkZx366ZDE9gOUat2ERkY4TDaDKHk6p97P8Ef4JZ1bRfEX0RPj/9VSpVw/pwzU9yR9L3MXDLciGtZAY3jxQCz4vxjeHc9mGQCD2XCI84R60Bf7skW4JzHeNTPCIEFlgUv3hG+LoWHTF3Nzaio5WftBLB5HH13exZ88F+GqZulGtw1xWCMdnnf6M6mrWub3NaP0XJIuOv1ffPYEdbmkIq1RCubmf30E+1jHofcDBKuxnNI2Ih0N2MKZHMxYYq831BOQYVWsDJdGICWsGcLDMeEAT+jz1NKHhMD0XfbNpTsE75Fl568fe32rDfOS4a52fO4rTnMwZtPqA0eQ430+FOdDLVH40B9vIUq9/hSMqe70JjU3xAiCncUwE/KT5Rz9JKdJaeJgXUfRCMHAJRXYdJ2mUDTq0K40mwnfHBhrSXyJubf3DtGcu7xjSbJUYu7cDRFeFouUshtzf5cI4ee4ECQ+t9lD9FxSjenchoTOsoMDZ5/Dy0wD0HrqqdiZ0ZYQIf1OiUWUjzDlzfmvZ0jz9SDLlJ4vUKZTGHLWx1BSdXrtVGjD7C9ZouuZ3E0Smh3Ae8l+YZBre1mPd7rqkB1q0wqctGRMpdUP936seq0IKdm9gOn+MuVcQQoHvLs4lQtNZ4ShUT4eL6ZQytYxacqyJEpaD5jG5oiBD/sp0y6Pf9mpYfLMXIJWRt9ePk0g1fVMQUsgXCCr0gB20VhHy1Y4DnlSD+R7A8qaZOtmrxsKAdZ7KqPs/KcQGLH4JilSIsi/9X1djZY0EA4O3FuEsG7RCyp3tivRoLJO8eOvte5yyQFHSe+hOXGwdad4DJbxsXEgLMgwktDfM14egkfqDuNf8MY2g9SxAmdMRokPRxYFrfpxZbZMg3iwzoDRhbtGCnJ24CqKzsXTLJP/mtNK7/+ciTYDrV0IoiAgZ2BGhB97vZfln7G+XwvEwx0mBWRMtnyvkV0muRKj8bIsFGs1/nbOkaLPWVxvTIZoVLDxNsNaEdzCf8lw0qH0U8fPe7oh51IFGj2dTn3BlGSYdWLkd7qxmdX9CL1qo3vNYPkxuHLwTDrnBoTqZzNvzlDReGDypbKJaWmudjGyd8SlbhtLJ/qhM7lGXufn5ZcxJG/rB6wH0y4hyl8FPhx5jGBLs19eBEZBaizaJkP7brbvbzIgQ9DIn/vcJoqpXAwX/sgETDsBicEtJXuw8YaSpOqQ98iqesQwvMDg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a15f5a7f-5c20-4b7b-7c78-08da724307b0 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 15:49:04.4822 (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: z3eCZN0veyMG0rhIXchthBjrMMCJCxkhCfTofZ074JZsStKSsj/d5gaUgB8Oi1rPs8Z7ubvNtRGiR6afOr4vFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4875 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 15:48:40 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: 594590 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 51288C19F29 for ; Sat, 30 Jul 2022 15:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234814AbiG3PtS (ORCPT ); Sat, 30 Jul 2022 11:49:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235137AbiG3PtM (ORCPT ); Sat, 30 Jul 2022 11:49:12 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2057.outbound.protection.outlook.com [40.107.21.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 916C315A04; Sat, 30 Jul 2022 08:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MM/9hCDsgnwgmCsbbEGx26pVjrjrVyj3Iqw+3eHJL2v0haVgZSW1eIuUe25p4JgutaM3s+DsOOgDQZuDOERgyJ/88TNqPMfXLG2bTsAKFmCg1nzXXPfIb3yHHS14TO24CY1aLeCkP8KxBpeJjqa0QDbfqBmiGvjBG6XSHIZ4RHKAZsvBI/lg4do8lzsbhH5SqGfRKQ283woR0CAYZ5nL9tsaO2bsc9cFd8q74btP+g0UegmiYQGmicGqPUAe7qMZML3cG1AsL5bNFVxeDntcFLPKkwk7id9E6h9q3J4si9GVbcx8hTQ+VRWEefXdsEAYhAmHYdijnqE/fSq1HXfyBA== 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=BqVUtl3M4B4po7M4MzXHhFCAFQcQ8AdjTygM6eyFeQxGBaVIwbFZpZwW8bfeWVYQdo/sVh9LG5KE1v2Iu3zJhzg5v/2lWSvRLdAJsX0LPo9rpBnItAvkTwA5glHAtCFyaAy19U+tSUoqI9um+sWtR1H9g7bqGouJHlJj3C0xmE9Ac5oFvKiyVT1Yh7ZI33Oip1EAMVD4M84w8DAUZ8VH9lxDMpjdzupmtBjMQW/eI2UT7QM9L7tOq5bkjfbYyLMtliwSp1OboIrrd8X/IeVwf/OyJId3c/h+MY1vWsEPgHSaGCVRvF7zm8JSSrC9GBxoiPTNFZ65LemDm9BBvGahYw== 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=gdMtHBhpZ61lHgSMsUKZu4+23LNhnkFmuf5I8icVJfPsi/lZ8j5X1CBigj7ImLnmLfDpDLlon909cCHMj0WPsp2iMdb0hvmUkxJtcywJ49/57GpvQ7U6pWD5Z/qEOe8v3H5g1/oI8DmX8fr7GNUOXIq3aMIrgjXYDVHVJKc091U= 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 DB7PR04MB4875.eurprd04.prod.outlook.com (2603:10a6:10:1b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Sat, 30 Jul 2022 15:49:05 +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 15:49:05 +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 v10 5/8] media: uapi: Add a control for DW100 driver Date: Sat, 30 Jul 2022 17:48:40 +0200 Message-Id: <20220730154843.791378-6-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> References: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR3P189CA0082.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::27) 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: aac941ed-902e-4271-990b-08da724307fa X-MS-TrafficTypeDiagnostic: DB7PR04MB4875: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: FVl3AjuO4P+vhXzN8kgjI5kQRXKUKlggtaoJdPmroOJ2kswDyMnfy6XxVwQT1D/gwNxz1bwcz/lnt7ikjFMuOWRM2/cXbGCusJE1mFTsF6T2xf3ChFVRGHwJIF5ecUmRtQfStmtPqR2DWrmvqCKym17GKnJXtN3qm6IBDYn16Az+mgrgYLlZe+gpgRn7GBdM+EKOcS5SyVS/jM6GMA7WU+cOhdiHwyfdPilJpdnmGLZL1wm/1gH1MJF6VAYefV5+x8xvlqV1OqpNpfCM64DTLFWQjW1yp3hFab6OumSg0mWIjmX9RAWeTsGMrsrRZgctILi15edLBnQzm75bfxhS/MTWHMMngJD/EGw7LAaK43Ag2HHqrOfxwX0rKI6ldnbWyxzQj9QvyOg/tWBHQXyS2Y/bLiALzaLT8aSPdeHm+ca78Wx+B6343L7x/qJPcHFz0Duu2aIDQNEiVy1rsW0KiXvU13EoPCUL3weOgQnKjdPwPAtZl8982UV4Tyq2kLJs7ilaj9cg9+TZKygsKxBqiUH9v0Dx7cIcmKmG/Zn5D5Uc8CxM6AhdkekZyDN+9NCt6mph2pQkCNf0ZCFc4OZKs+A1K+XlAHo4ORfilJqkgRUTtj70i99CsKfZuNeIVzi08Vx45uDVuZfiMn+1wvdQCgEBpbSAeBL+f4VbiC3ehpFuW6joyV+qZzFT2cfRlrXmauf+hNkZY0vDOocK+8JhNHvPDLcEcFwm0FcA/Wv/7RHBMV2MXFcYgfIJ0+WSYHQojLgZlA3p3aza1/aUuoxZJA== 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)(39850400004)(346002)(376002)(136003)(396003)(366004)(41300700001)(6666004)(478600001)(52116002)(66556008)(316002)(66476007)(66946007)(6486002)(6512007)(6506007)(83380400001)(38100700002)(186003)(2616005)(8936002)(1076003)(5660300002)(2906002)(966005)(8676002)(7416002)(44832011)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: toYpqnjNgRVDUuH8RAPH5Luiai4OfDge+cQmULSPi+Vks8XSJ6MykQhdlvfwJwpXfPzd8JxjNLFFGQfSQlBlzBy97FjEmsVqBM4tkgaTlCOzyKOTX7m6fnfqrB6ARYAgYMmCbjkzrYXoV84/YZFxPMK0BKHol0xizX1SkK2cqcG29y4ul17IhnuzNtTfakrQbZai9rAE/s5DIgM0RbUrrmWhNfnWIBqebm+oYu62Gv2xdovIEXpC7c9HGWBWNiXhqsl1ElptFleL8eAxdQuMtaGPfoASJW6sNuUH+oxbPTCcqRvyVyMlPrxgBDl0p2HlmI444Vz0brcY0RnCfTI3OnpS6XNM9C3+NqJl6qpJcWSRlwU4hvoiKM08BRfEEvej+yUR7hkUH0r2lGiH5Bm/lxiWJD1zJNVNh0PJQw0+Y7/3sHm7UePftlufPKWdgxiIwn8qT1nu5jOOukjWsWenEh4GgFZ7gQzGjf9aHH+3I3KifObV7neYDHRFCLYDDREEi0f4XYFDi2p+DFTCGZcIFU+Zk/pmRJbzACN7KK2X3EdWDVoZkpVyl5LlSgvT3MSLvE9XYMRd6UGsCsXoHQ0BWTVq4c2mXNILQX4UgAwdytd5WBCojAKcSl2UPt9hgjGcCZMm3brSF64JpiaE6tmY8XmVT6XZUM54B7JAESHzT/PZblzjtq9ynTBtADgQ+RkMqdNGaJPBWwMIjkWqBVmQhZRHF3n0e7y5Qbo72RK6zr3FpnG0kultry7f3S1bF0RThazMCMBBasqt31MzKmsjaj8upKzt3Yhjjii+HF6LBGoEs/bbkgf0J3qqzoZUZ9scc6SPolhuFpAxBDo96bB8qJTLDi1NH4/OOpMXojZwYSrlG80rke3T6qkj9xlJrOUTBL8SKW7DPZUVlsJqpVVUn61FtmDT4mopBMNNLCTST0bSrC5hP8vJscv6+t4mTjdO5N+3gAhBGvO1Wzr3cADty8H1cw5G6xUR6dxtblXjxFQUXRHsw/BelBhc0szC6LtVrs3CgEYI20vnlbsO4AHzBbRCeLh7L+rBLWbBdL+ZE5560aHsq99BoMzVHiKsANa75vHK/5omzHqXuBsNtBPq7oJfjhyeguWYxkmKh5BEUeB2/zp4FH/5d0R/kuUkBsl0w7Qf6RkglwqpKWASl6VsR/zzO2c3SF9CGRjoaNjT814y29iGUFeGLzjOJ2n6+8mtRpb6rkPx2DGsUoenEJ+tl47ugFMBblCtsvkmMWLJYFgHFpiDS/MOA2DuHov6kom6rwx8kWRKAofHS3oQA9mGarnQr+kKY8hoBvMDDblhMfQnqsjE62RmJVnJUuy8LooeC+2joMIrliGlZEVj1ETSHIZtjLEAHe3ZsHOjBYAe/iCTjAxVd3QsXmiJn7DrNpCeUrV/3/9ahGxUvxc58RcsCa4zUgRlEC9d573LeBukdJ9GcmdNJodq5mSzIYm2fgsP0EOjkZdUl+hWCWArwaiWgl576s3Ne8M5TB52PaJ4Xe/RMhe0qaRwtFiKaXAxO4Ok9wYMVpq/3rs3DEQZlP/uFNzrmQY9hgg0q37+Oe9V9eLnumsxAg0uHZaYhj1FyQwl6prS+sQFx2iCqwj71FJrqftrfZM/8dadMyUBlsJEZGtA52tw8Fa+8JKYYbPotInxOOk0oB6TCPgwWyoL8kCwPg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aac941ed-902e-4271-990b-08da724307fa X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 15:49:04.9679 (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: 9egBGRDOmpnsI5pf7mK7uShtDt34sad2nucXNu/Aado/J2CkoUpuR3+WpZrmV+utp2sW5n28Li2jHZ3AJnTt5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4875 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 15:48:41 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: 595729 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 94FA5C3F6B0 for ; Sat, 30 Jul 2022 15:49:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235249AbiG3PtU (ORCPT ); Sat, 30 Jul 2022 11:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235170AbiG3PtM (ORCPT ); Sat, 30 Jul 2022 11:49:12 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2083.outbound.protection.outlook.com [40.107.21.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDF5715A0C; Sat, 30 Jul 2022 08:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VtGRhNHKgk4NAaPhIwJlEvKGEuDhwUGYiJfJuVJVoF+J+NL25K+GmfnDFQGCL+t9WHJ3dLBGpUr6eO/Ql2U7prZApLABC8CPX0fgOvyxgDy0IRUvdKcWNvyCDdPOnLECb0/hXa2q+iM8W4m73drCMaG52bn3bEs0lF3b48j09fyutI4CumH9aZz/OMxCs+MgBJVkqx77pxunKgM0hgQbMmjXs4ovnI5TsnvpQ1jV/tjnHmUNVB93mbdmWMdmTDL2qlTIIsFVm3mjqF9apyw1//7JOEQDJGf6WBBJtk1BkMfVpMQnvdUEuuZvNbIPvMX3OGOTkkJzD6wa1pNuiwLe9Q== 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=RXVl7Bvc+XC9sjvu0E6oTGW8LjwAAkNEcnF9VhNC3t1EKnRKaumg0Tp5Chfn8FezeRTsofJ14ym+7YU8rRw//ppStvtWM9UVusYcc0fkDPJ4QjyDAi4emtybSATiMVKoIzsc0g6R/8Ta3HKgqFv0S+h5XjUkErBB0Ye289Leo6BkV5eJZgcFXohI5P1KEaRU2Z8Cy8s5cSh27b9DpHE0o0tQyQOFX44sf0GnJ2MNw2/3DBAY64DZrYFO8B4XUWppwCd0dJLH4AhqGSr43xBwtcKBhhRflmXSLfUW4lgVruGgsWaLKLL6estieotRx5PDYcyiURhrfYeyxVk/zVvolw== 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=dhdJ3qgvaurkP0KxFsVhHdLd9Rq/4PW/2vbAMVL2nV+6mkdgfjPsXguclOpBZLX3wjV2efCbPR8H6tRvoDUMITgUVQmo3uIS0zNnwQIfQCWiudkeJso25jW+uYOdDw3GDGyvIaJKD+nG5dpvsfxd9daF3FWvMza87z7rscYfGfQ= 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 DB7PR04MB4875.eurprd04.prod.outlook.com (2603:10a6:10:1b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Sat, 30 Jul 2022 15:49:05 +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 15:49:05 +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 v10 6/8] media: dt-bindings: media: Add i.MX8MP DW100 binding Date: Sat, 30 Jul 2022 17:48:41 +0200 Message-Id: <20220730154843.791378-7-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> References: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR3P189CA0082.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::27) 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: f72f6dba-5b4f-4667-e083-08da72430846 X-MS-TrafficTypeDiagnostic: DB7PR04MB4875: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: gZeJ0Uqp39oKOw0fFRHf1fLpAKdpcH/y5KQ3QZ/0fP7b33OA6InKXRrCtp2GziULXA2JyDyRM9XmBArWst9nYVvqggdt1rjLEmKtytiVo5korf6UfAj47d73vtm+ooR/YPlyuVzJpQR6fyvy0tR5oO2P0Pw1bnthOtdzX/ditNWInVr2MMpZjcSgElk6/FQU0wOY2ARaa3M4OO7esj603cuZlknYq1p2G6BpIpuBkMnjZ1tPIweMxvv4YEBmBNIJu9bc/FxVWBMnldQoO7XgND0sGDeAOz8qRa3u8CZol/0AH0cAM4jexGi4R0BRSwfPPouPlulQU8XEkn/c5E014wXbQfFxFlY1WeXLCHn82eoUhwxwQh0c8Pjy7WpyPixUADoNu2DhwMMOcTyJBwWGpadPle6R1b7fjlDX1stgEMuiucNLNOZPBrMAqmMpkArrj7UOWj7m2RVCXmBwz2hCLBNPqQujWc/1/ZA/eo1Pu9CcTw0IXCiSTUeDKIjg9Uip8lU44zQEinBySjjDRVR+1kBD22hr0zPFvwiMQt46QsFUWINiUGyBvkZHujXo2b8KIEwzWgqAsXIFSGluSyo1eyzR4iyeR+6uyfCCLp2mCzJeUrsc24IuXN/1LmVsBgzjDWnb+0EElNiLQpMO072QhDMW1/AtGPwA5nwqHGqRlD4mpHOp6EYUjK0PtZFuEtxOyE6Aakl7u1IxRqH1u7fg59T6qUBu3j08fYpnVnAdzx8NtYgURIIr7F4GoEEd3pgeu68ZKCH8vkiXeuQiHgnJsgR6o96SguCHGE6oHR05Lua6aJlQjvs0Eke/2EOrSwof 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)(39850400004)(346002)(376002)(136003)(396003)(366004)(41300700001)(6666004)(478600001)(52116002)(66556008)(316002)(66476007)(66946007)(6486002)(6512007)(54906003)(6506007)(83380400001)(38100700002)(186003)(2616005)(8936002)(1076003)(5660300002)(2906002)(966005)(8676002)(7416002)(44832011)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HPs5x5BTHiEzlt2hXLSujHVNAZ2BArpxNa8Q1uLfRXlyIMVgjqcMp1okaoa7qNcmyTjv/tH1YI2LvCS4cC5KAT4zgEt6aac8+PoDCfZ2FNcgA15qkIzjqmIl2rx/1jv6B1Pjo/Rcn+Jebw7NNxZzwMU5kyTZ0r52w1/jaNLYW/uP3AV3XMMJIybg01DV+5QnY04liiWOwPgonM58EE+H8Ufk5JDEEFwa3XOQSD3EbEhUw7EYaj5HaA8tHYEC5shai/2QK0WbTm5JBBMM1TNUeNcSla47/nKUy/ilw9Cvkj0P5GtEzcsxSJvHFEPtS1DBzJHHY0P1lSNt+0VjKFTooezT47Rr9w1D6zNN06dok4/BddpJ1zgbrOnDAJcJdI3BVXytD1dn7tWE29QU+MQRsMVYZeDVtkG4Cs6Uyco25YhZUCFi4Q7VDm3Y0n19U961y8qOB7x08kWag4596YogzwlRvaTKrVgW8o+novr4xxF0sq6tLpRiY0J991grQiE9ELdQNpCK/NbwzbCfeGX/pG0cKuNLRAYy/gf8eKMgguq6DxixCfqTnkhFj6cbRXhXsBPngG2iU80QwbhfzHW1S06qm28SW92wstANcbx0Gz5aV0dS9aMOFne/g3I8Pr1HI6w34S1id4/zpeNCn1tx1OAmImoMAtTh8OgUUU5O3k6vQ3QxkAslr6GMlFvf1APYAyOl1zGacgdAUVbGbt8JqyEBikVTlCEXFFB+FqTMWt7WXGq9Bcrx0sRl0dfxFT7Swf8q+tpJyQK8I/8ut6RxZcsz/hzNH5KiskPfEJ+wCR5F6J8KXh0omJ5EmLl9zOrnegtb0lREr7s1ykr13k0utdXmavca/dGqVpCtdPSSHtdcTeGlmMNvl7DP5Lx7gXAL3/rH84lc1UOUcSkZZ4xDYYvCguquKAqU209jfRWshr+KLmn2nuqY8vphpOav//ghs5yZ7N9Ic5K/yY5zMjgn8DD7WYbzjtJnJoHtx1QF625US5y4D6Yb45dyAJR4Cj5IYzub3L7kNBiKzj2Krg5u0pfL23NW3ygWfdB6BNO8ZTypB5iI+5xOwph5n0a97yMh600LbF5j6JMtjgczVwFcaPQGZciZ1RmyKg96K+X+RuJaYeNZa+RjOvbeakdMmxkJyOUTVduF21rYMFDPfGaZN5vMku6NgEzEsLyM8QIROQzIFjlsyQIyXPzJZnXsbBDPQQKtXx2rXSsbI5vwkr+mnEFa/crYmMShTAjTyBpaSZAUj03SiWI8uFvR9Tqw6nq3sRRgq1qQri2zG4NamzY8n3lxwuhjSSiWxNTsyE9ZZHRdDy0vEK/p4ZVhivwpw56H3IXSUxttiFr+ep5yG+GIUq28aCYKoUb5wfjsGikhVRXqYaervRYss/5H5KBqV+WZBf1EE4gifnnpYsd6tzHUOjKeGPxVJo5BrdGZaHN9fOJTiLVvUoXOHb53pQXWQE3U5qaQQyuLnCfc0PaQtOAuK6lEtcuVTLjAqUMLqV+7Eb3HkrlNHTccZQHFejbyCoNUWlX2QOjUugTBcWqunBDs5oxCVLute1edBSe3AF5262KkYx1t8Hn0OBhIunHv22/Wac5Elv1awtgNOHaniS0FCqN4/SNCyr5CE3NBhLVUl0PFaFccFvhjqnG5FhHgizyoZ1UT0XAcg6JlEut+GObccA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f72f6dba-5b4f-4667-e083-08da72430846 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 15:49:05.5135 (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: h8HBZQO3lLUUJjPGGItrJXe3GHKXn3UthSVTaotG2W2jjhkMPODlrgn5dziRSe9tqGqz9C0k7eeTtB6t/Gng9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4875 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 15:48:42 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: 595728 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 31A7BC19F2A for ; Sat, 30 Jul 2022 15:49:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235170AbiG3PtZ (ORCPT ); Sat, 30 Jul 2022 11:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235219AbiG3PtQ (ORCPT ); Sat, 30 Jul 2022 11:49:16 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2083.outbound.protection.outlook.com [40.107.21.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16FC515A15; Sat, 30 Jul 2022 08:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AdJQ3zqDxbcOJWRO7/Ns7YMJmQXcttFJfCMIgpz36MCGXPQFg+tKkoHs7atYKwCnWaM88V/L84xFb7LMrDydbumrSNgFPNH53A8R80WzXR2z5UxF92WHTp8qJB5nx0iKAi0yGkU2iQyEu1ZYMJozJL/NJSAXZ4D3iL0L7Fmk4orL8qIBh0HXi0rVTA+GF7uzic5uolGeYzwUv3CJWXdlyKlnboPo67pHl/KhXVWkR+kdujQ9LgRTrxIXbqrfulhlVvvnByYdhYlGtnYpObZG9ucSu9l/nln+qX/98sZE2tI3ymGC6KJDsqySBYAj4pkLeVGD0Oe+slhkrQa/6dYAsQ== 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=Wr/4GTPAPGO/4IB029UeVJsZBBDVO3a+k+14TY/RpVc=; b=ZFJXyjtMkDXebZgrGXt4YRloz12bzyav8BBq3L767lZr7bs/RVJLZBLQZ6fkcdEIKcz6kpBYjQHnjgeY2gwIwZoibRqD78AUxCv9I9wjMMe6RTM1+b80zDjarbfok8Wr3GI3HFTth8v8l90uPUXNjk9QSMvEJ0oL6A8N8dXBg88+Dx9D8S2DIxirdiJSm2GWAScgqcBIElo78XkU3kHjGjJdzt/1YgQG+yszkNA5NBHVDr2CD8iWMh38TAUgqm2Y7M3NK5XhklO+HmLKIoDiprJLksdNoJOovTBhEb3OiafWYk2gsL8MCdGzRLqHZOSwdrq11ams6cMusjoJp3HelQ== 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=Wr/4GTPAPGO/4IB029UeVJsZBBDVO3a+k+14TY/RpVc=; b=ksX7HnrbF5rN0wtFvl4HcsLtcEWnIIi1lsYlKbD0QEtT+StudE1FJdW3N9ZUvBqYk3Jh/xfrKa8XbsNxz67AAoTOlxJcrOz/FlXF1nnojAOSxo37UznxBubAJRHE4BNhsKp1V284NPPXL42xisya74Wj495LRBtsYDfTPecjfy8= 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 DB7PR04MB4875.eurprd04.prod.outlook.com (2603:10a6:10:1b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Sat, 30 Jul 2022 15:49:06 +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 15:49:06 +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 v10 7/8] media: dw100: Add i.MX8MP dw100 dewarper driver Date: Sat, 30 Jul 2022 17:48:42 +0200 Message-Id: <20220730154843.791378-8-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> References: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR3P189CA0082.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::27) 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: 8ee42ac3-9e0e-44e0-c1f9-08da72430897 X-MS-TrafficTypeDiagnostic: DB7PR04MB4875: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: huqeIhraTbI0xiq+P4YYWPs3Beetac3nXAzitjZSVBjQ5jdZ6Rb1UE8G4tvMgS3aLZVSmRZQ5qU0oxXVH1cuoIz4M40CGXgWts9eonsTaxrc2ZHESV2Xgr7ZlCx+Ce7P7gNH7NYFeg+/0sZl6Zqw0obO/cOpKkGJyOcG3qwC2PkBiTyYpft6r6bSV8kGqewsaxbLWGpkOwKpFgMt0Se8AB+EfCWGqa0WQ/gWrvAEiva13qqskPsq/EP/2pgBjhcJS/GGmXUkHTa73vOTyEp/if2YXTZQ/wOBHz3xYPRyGWQMh40naP/68Uq+EcIb3W9Ez7c7iQ9jT7PlTEUWGjU/l4IEw9a96rsHYN3FatfgL0UpFenbW3AAxdNOyLq7n/z6lFmBakDdkiDlwf10cGbz5zltLgtMQbFpH0DZFDHYkIZzn2Nxc0K6GT76fMV+Q4Wimwf9ZoymCjtyzrR8nWo6skgF2P3n0bKosc8f62h2Xk8+BgUnK2xyTKzYFZvj2qw5nt9YDN7Y9HgMJNJUCBeiVxSG0eFxE3nGcsnw5nVISBYS2sShYZDUY2YcTOeo2tD8jAyh/rCIEbhK9b3u/nRjutNI9edkh05dfafejU69HY/fbtl1QENvXfBosNDvQuwey2aHAcl70PhBFr1l1OvsRJLYnY672Zc/0vAChhRGIrRKOnbyCBbYiz8v5lJ3htr3vSNcKPKz6y+MuJ1CnR6Qs5nNY17R1otn2ezlWw+VsnfmSHhRGG76S91pQey037R+ 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)(39850400004)(346002)(376002)(136003)(396003)(366004)(41300700001)(6666004)(478600001)(52116002)(66556008)(316002)(66476007)(66946007)(6486002)(6512007)(6506007)(83380400001)(38100700002)(186003)(2616005)(8936002)(1076003)(5660300002)(2906002)(8676002)(7416002)(44832011)(30864003)(4326008)(86362001)(559001)(579004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z8rgS5mXQCYtGE9oxNODc0nVoTP0e/zs2ZB3i/QKQYglgQw+AEKwqym+Kc6ExcRl59id+R4oG8sQJUzoMX55DzphGpHUuWLNehV1l+T/T5g9LxMgYOm0u5I8JiyP+DG4NkjySvblz3jU3fbt/HuERJfnC2DrITeUtGcAIDdynlCrlJZS39Q8L6wDEuodF8Eu4vvIFLOFjpkLBf0rzpBej+keZS6QQZBtwkQYoA9TB6Fcix56/a9et4bRW8EW/2ooMGaEanLDtCqcBxBuQtTfHuytgf58h6olgs5xETkzLNbGoZdWS+yLw/ZUCTnAJUGv+OlNdApg2v5ds7sicZhlXw92yEwQVPnM0kC3/V0dOu7b6nvF1MkiQ/F7draz874bwalg8Z1cZqVryIyCwyMpMr/2oboXgaxscenBgLVIW0RSwkgDo7i48MK+6nwSpx2AhxM2LnM7VSQ17RTvmG4hcAqEhgSsRqKhiyhHRv3+6kKkZtIWfOy7IRElekxMqiWztNhfcK7P9zXwwPbzVRdLEBOs56lqN4ykzKvz3eAxBQmoY64X1looGlPK1w5b9vapfYZPh+ZbFbV4tsA3GuMug/sSGb09oNUtJrH6A6o/4cXzN+GPwucGqA3OEWgSYBF3Z9EjJSeNg8+ahxbBe3BdlHsOYXcMIy2g0a80e41HzsrEFQt/Wd8HbgMMc/VUmTcBmUdLkElskuh3H4rVHIJiDVS9NJvibWlux39+jacWTmprwp4QcpMkkS6ClmOMnqirF+Yf7hzzQAUGntG/NjYc0BfVMvURh06UbUD6NGeulEI9nahNHep+I8Dh6nqlELj8sxY9gNcxexGHtcXDT6wbsDn4dsKGGtmFhIpPGA3b5lRdJ57M4Hn1bhgDFKfT4S9nlTvfLR4ITQ6SDpm4EvIF8YHB0HRQcjGvbG+ZhxOMS4lw87GwZKVRaxDZQDiF5u06WooFMlOeqFlpYajfSVV9KeSrAzWo8YwzKAjhxEDeT5sehIm0YSyxTAbxMlPS48X4lPD9sd8pXaurKgl3IEcs9BAsBqTmVa7PeCmc09X1chzsMHMV8DtlDPdQhtA2bhUc7L+4rMEMNWRm8Ah/g5PH27UFfz0Gcb481SHd3gaQhOBPdiacfYXYw5yTwuzc8N39KI5yfijhn/+WvTgHf/SNuDqvME1TJL3oJkpew0cVze+EF4x4ZxK3QpaSmUCU0hOWqEhK9qKNORQBCG9+n8JFi5f4TnEQn8aKlLYvUj0Dv49aUBPbVbzW6v1i6Wi0qt+0vUWEKlqwNcbuc/RITyscf3i5Rsc1+YkKMtbmQ9MssZZMDYg6Fv1kBqC05pH04hRBQTuIRIhfV0TVBVN1UqXm6PlDQUc10KGEUQoYhhu1V1BbPWqKNSlyhbdR7oTMJ7N5o7bDPA6npsnzmB8Z/BPt2l1NOcwboTHSxt7UjgwqtH4pw+UtG5EJS00x4jXxMkDyjyFQw8k11IEYqylqhe+tFPQBpWNdKgSY9yUZ7o60d/JffBqLsdUy7LVOr9Mb6hLx4CGAs4Lq/uzufyFqN3ZM/1juALML9vf+Ud75zTOEFtP7j579WqkSM9UihUoKVJbRyt/MQTfafDsWjNka6LiRnA31i47KQhwPVVVe1wfWKuH8tMlT7zl9beSU4bVp4ZrVXU9rvlIZkFVsM/F/9TS9dA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ee42ac3-9e0e-44e0-c1f9-08da72430897 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 15:49:06.0759 (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: 8cOgK6suucvZGwe5Zjel8hiy9yS9UOBohdFK0/Au5VKHp5uIB9TR1XSSQa+u2eHGATDhM4LneHTnlpz5ESCeGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4875 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 | 1708 +++++++++++++++++ drivers/media/platform/nxp/dw100/dw100_regs.h | 117 ++ 6 files changed, 1847 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..651622f8ac8c4 --- /dev/null +++ b/drivers/media/platform/nxp/dw100/dw100.c @@ -0,0 +1,1708 @@ +// 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, idx; + 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 = ctrl->dims[0]; + mh = ctrl->dims[1]; + + 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 (idx = from_idx; idx < elems; idx++) { + qy = min_t(u32, (idx / mw) * qdy, qsh); + qx = min_t(u32, (idx % mw) * qdx, qsw); + map[idx] = 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 15:48:43 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: 594589 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 180D0C19F29 for ; Sat, 30 Jul 2022 15:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235265AbiG3PtX (ORCPT ); Sat, 30 Jul 2022 11:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235181AbiG3PtN (ORCPT ); Sat, 30 Jul 2022 11:49:13 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2057.outbound.protection.outlook.com [40.107.21.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C15C11583B; Sat, 30 Jul 2022 08:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JDzV833n6CwbRtI18sW0i5+lKLoNJ3CN3jkq0ZlrNZcy8nu3CYjHnsD+aJ8bMfUToToyBwlq/H1lRzscUiEUYKlnwb9rwHmYdR5us3yT+eR2Q9RU9WV+N+Yoe4trq34OQoq8xtTToCK2RvE4mnxKvEehmOKtiZs2uOlzEGS4n6CEk74LxREAIvWnh6j0pGnoDoOhr7bZ9qM8I0aDfruGbnl2hQsoz9+xCvMqgNhwRNv0FSayjxD0wYQF3jBT4YFB0U84kfOBI6N9Y7MymbibKs+jneA6SJep8AsBipxtQStHQOePOf3DqbtJrA57g+2jgug0hFRQL3VL5PBLELn2cQ== 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=Cmzap3McBzrl9JYIAz4bbeyugAdTJO1q0gDcYlaoPdk7wrbldliyEQrt/2DNnDRNXS7wLQ+7XZx/6/ONHNfcW2Ajlg8D3rX1sTs8h7mAXomKakz+tTZIkmtbtSeXbGDPzMDmxAGHwC1HqXkfPsM7PRaxrmuV28MZK9p/afkNvvStxBLiTNa84Md7iANfqVOSA/9kS4N2P6mIcEix1eqSLHAqqcBqPDJwSQSLxEfG/A0wCKrBr7mCfB8qg5IC9+GVfclXR+LGKd7KXIndWV8aiSuV/8/AlTG5AVku6Gltd9KMtkngh02b8VtyfoEBUNrj+oRtgLOehQshy37nZLxFJQ== 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=QuULYWHoiwjAEm3MTpsAl2no4bnLCxijfeQiEJQj3EReVzaUtyPHcI63Tj+wx3ni9UHTMpbd5lqYEOWhRMz8+Sn5mrLWo9WvpC6ZaE86fsLlSzL8LFFc0mOraib0moWdezYnL8bmjCFkCmTvdsqxX6ll5fdsBK/AuMhOjryeHhI= 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 DB7PR04MB4875.eurprd04.prod.outlook.com (2603:10a6:10:1b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Sat, 30 Jul 2022 15:49:06 +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 15:49:06 +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 v10 8/8] media: MAINTAINERS: add entry for i.MX8MP DW100 v4l2 mem2mem driver Date: Sat, 30 Jul 2022 17:48:43 +0200 Message-Id: <20220730154843.791378-9-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> References: <20220730154843.791378-1-xavier.roumegue@oss.nxp.com> X-ClientProxiedBy: PR3P189CA0082.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::27) 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: 1498d21f-7688-41c4-cc51-08da724308e8 X-MS-TrafficTypeDiagnostic: DB7PR04MB4875: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: v8o2xVaeLNZ3AJpln9enRaIuIAofuo39TFJbTQXmwUVbT2tjPUSt/QXFAcbgS36ScxPBGPYFkuy6vryKE5tf/fumP4YIfjvX2CzaSHY2RoDoA5KY53nQ7CpXxUDoolaRR1QfqXL0oJCjVGaD9Bpvv7umB33+/KUok04pFCHYtbXsfvaj2kguQEJGI+GWhwmc/7Ds/+xCh7KkbXR9VKf86bIKMQI5Q5Qadr1fNwJJb2ynfVfRBDRHTZ4zDeO9hkcfz1lp2wuAJi/I2iaE2w5lCwizZaSanAeA4aQFmuTeLtD4wtIS4KVoDAF83MP92acg4BZy1L+7b+Qz/I+l0NeqGu8biRyzpRFMfSTV6kAYtzdIcdV711W27+ZJmd5rN+TUmElMP2chP/9rGqV7H1VxM6nTWKhl+geXPvm/hr+W9JSqdSDT9dHGp8IiinD79OlNpdcDOJZ+pGcIrhxOzB8wH6bkqqfVsQkf72tevpSOI9yAdPXGy0wnNvmhsUStCpkAExLKvOQS8jlQBfTMBePhGHvxQnrhZU9XtiZfe1VGRNIcfVAX3Dj1jj+UzKCXBhbrDfUNUYwPihB4x+D4gvcqPVCipSDRTf+i7ThYZ35QzhHiPyoVpChJYrarxkex/L9Xu+R+OTdUG7rLOJ++mskEVfZQZTSrexZtrPzImzkLPPxFFpJvhE+42ZXFFRaMk3LXgvEhxrPyKuRQVc3voDWRWFC7CzgAJI6MEZnMXukkMX/Ynbm6HyDptaexgGQ+c67m 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)(39850400004)(346002)(376002)(136003)(396003)(366004)(41300700001)(6666004)(478600001)(52116002)(66556008)(316002)(66476007)(66946007)(6486002)(6512007)(6506007)(38100700002)(186003)(2616005)(8936002)(1076003)(5660300002)(2906002)(8676002)(7416002)(4744005)(44832011)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: O6qW9OiHkWbFpIYNsDISCGBRueIGaZLOqsNm4hV8c9R9qM7P5ovfIqzX2eaNgghrcPpwCwQnAmMhau+SG16NrtmVhvVRt9aUBIkWAI+j/AD6VM24XDLrBAtg5NNmkHUsKH7YdLPas9VguvPw00/BPTA+CAmbGKUPmGxF5K7H6XIcfCLzovA/IxwVVCxwY5/60GUsVy3/tEULLa47HB6OSRb4b75Rh/noR12mSugHyp2Id8wc+isIDA0te4xM0O5prjqW5BXjiVPp1C88nKa3WESEvKfsc8d5VkD5J7v1NQEkHHq6RZA4EmM9NscMkmhdLtLZpleW/IxClNQN6MJka0yXfM23o7Tw/kVU1tPnrX8eqh9xI/xl1ZRstnqF59U1gHtDU/YfvoJ+Ey61GMWIlj9KCNyFPxu85f/KSdwQU2KUXJNfpJMBj9zdoQD1V4pUVKP85D4fZeL5L98VW/iB313oSGmNo6e4UTVZeoZDW4EZAcolUodJsz2XbL+k14U7JurTgFStNGtkxoHmYScUzcWGmeDOrlVILcwwGhqeopEIik+hi7u8Gnd/mp3LS5jacGOlKlMukFBgvEbFslggItpw8YqbweQStGrznFQ7sFmud9rKl6sMTP9hBbIwCq4TjYSsEEhNNYyMZMecPcLURoRbFsTReC4t48Fe9V9tqtCjvjjBEH3Vc/Uf9Pr+G6iA9BM3EzKMOqYtuqPNoODbyt9YSD+6kM8I2PHhbVpXEao04aY4ySVWfZEqblqI4HTMgDK1yi1BV4ZgprpUhsdCDMIIuNLAytjagEmuVc66dTB4abdFeHVrGTTR5+OkRpxPLOTSq0CuyhT8eAxgxCGkxfSvH/UUs0ibNJqwmErWh2+JG8MMjOI8Oj+BskKXGSRPOcHlcArOS6BkxydXw0jfmbp7B3AsOmFr4WUzGjczflE2ijrKm/eLWmy2gtVigoj9cAl6EVyjGMnuSLMs7pe1/OUtJq3Bh8UFEB0raYRd1UX6x5NdPMdvxB4Kcf1IqgSQC+yPW478ULLwalFmNc8PNBAgk3uW6TJkTrzJ6l8bZurD4I1xz/a6jCdPnnhyutseYqaeLrDHlEH+mjzZUUquwkIZzTNDjlCeyFAtqhDhH+7ya5G1QwUGilRhjF1DxL8MpP3CXAcwKH8tpwM9c4fIvGD9t4GVpB5hT7GwiyZrTN5jqfKH0JYJkPZR+jDEx3pI63DzW9LR9D96Oq4VURGi1apfgcCRZfqz/MQaIJb+WqLabFMQE8elhev3LF7xbOlD+HUIGAw/baI7NajQSBH7BvUnQQTwnPr7f90FvBuJhwcuuOaYXS3PN+Gg2o+X5C8CzS80pe5mIVzUqouCod/rLWcAoQFT8vq7Oa5W397d02x8Duq8L79vqczKGSwf2nl+w/BHe2ofpZy10sfP3LJ6hLpU5dI8leqn7Ah1CbAdpOoM1/ezutFIrr2aBOu82ZE+vnyLDwruKXWrhMNP9FACfqoc1RmGZRZf00IW3FEbzS1q3gYEdExN1mzGEfak9W/Xag640zlrph2ZpL60T2ahcYMAPLDmdciZvY1GO3f0hXgDk1ztZgcnsGI3j4xD/T8pXQ5deWbkV5vjJFWKORd9MFvbXRbkEUXhrlZqNye8vBkQRmJ3RUUSSdCMqPu2GlHePrrbHbLsngqMHTJJV0Cuxw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1498d21f-7688-41c4-cc51-08da724308e8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 15:49:06.5602 (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: 0qTyoYuctjeZCm7csO1ifcrcMw3rB4a0QuH26OPy4E57Zyc2nQQtkIDTQJmRQqtQ8gJj+nZBBEIbi2nifmcN9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4875 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