From patchwork Fri Aug 4 13:02:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Riesch X-Patchwork-Id: 13341792 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 995D0C04E69 for ; Fri, 4 Aug 2023 13:02:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 76CFA10E6F4; Fri, 4 Aug 2023 13:02:53 +0000 (UTC) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2052.outbound.protection.outlook.com [40.107.247.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6CFB10E0B9 for ; Fri, 4 Aug 2023 13:02:46 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SIJBGjJ6fvrZlrxYk+rx8//0rJSQRQu0blypwbcBaA4Q5H72iGar6aacPYAf6IkhZz3AjvS4vU2laTKj+NUkva/MpD5RrV6p0zxzXCUBSh/aS4QCcoNRJHVbDaZ/2Fu4fw2/YeQjAFoq1rv5Xjfjf0Dp+CBsXS/2rED7UJdmnbAi8k1D3mihFyGqYpq2bwAZr99WZ6gP3EgZkhhZzHu9YPW8CsXQgjIvlw8fSjKbZ4geH7ZgTLkPMSPLRgpFY4FMP3rEwLF2KpGl+2a9lbWO5/DSCu8NGbPoQQyVp1Ix8cRS6lT0XFddIDx9UTsU6jM8fKUfBdkd7DEd85i34AVgfw== 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=ac5f6Oxahs92G9BhJ5ffEeT3JoNdmuQaXl2k1ppr2BE=; b=oMgiqd+jtxkGA6b5pmatc/xN0DLGA8ZXUTH6HgJsM6T0V48+iBH4Q4q+1zP6O9cdhmcYfZtG8kRvYn7PCeBwAq7RqHPPslZHcnbLuItW/kXWPMyGFMCmD+1Tys0KqQuIcAnYkN1ia9rvjrEzy3Z/jeTGm5KqDO3X70mpxlsvUiFg3n+HsyySNB1C82s+xUa4ROjo7EgpzPkCbHj7sPQ3QVq4eErvNLBAm1Mr7XtSUVPVvR9XYZJ6B2YuEcn591WOhPrQIWVXOC+gSNRICmgKedXIlVDl0iNxjnkpf1AqY9kX5OggG64JBGiB8O9w1KYIIyusEpODQ5ZJhKfzi0NgDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ac5f6Oxahs92G9BhJ5ffEeT3JoNdmuQaXl2k1ppr2BE=; b=I1CdbpaGDTObP8QAZYz311fqZvgNT87qQmg7hFXHqRmcO5wDrhT8x06LZ4oavMNjDCUvpGaDnF3oNR+cIj9/yPsbA+bKLn3WPcX/gvj2/96yWiQLUly6B5DaQrbeImuR7V/iFSR3YGt27GqrskrCBZzjUadXCZq1Md/Qpbkj+98= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from DU0PR08MB9155.eurprd08.prod.outlook.com (2603:10a6:10:416::5) by AM0PR08MB5348.eurprd08.prod.outlook.com (2603:10a6:208:189::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.21; Fri, 4 Aug 2023 13:02:43 +0000 Received: from DU0PR08MB9155.eurprd08.prod.outlook.com ([fe80::9d1a:4539:a8f8:dd60]) by DU0PR08MB9155.eurprd08.prod.outlook.com ([fe80::9d1a:4539:a8f8:dd60%7]) with mapi id 15.20.6631.046; Fri, 4 Aug 2023 13:02:43 +0000 From: Michael Riesch Date: Fri, 04 Aug 2023 15:02:34 +0200 Subject: [PATCH v2 3/4] drm/panel: sitronix-st7789v: add support for partial mode Message-Id: <20230718-feature-lcd-panel-v2-3-2485ca07b49d@wolfvision.net> References: <20230718-feature-lcd-panel-v2-0-2485ca07b49d@wolfvision.net> In-Reply-To: <20230718-feature-lcd-panel-v2-0-2485ca07b49d@wolfvision.net> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , David Airlie , Daniel Vetter , Maxime Ripard , Miquel Raynal , Sebastian Reichel , Gerald Loacker X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1691154158; l=3358; i=michael.riesch@wolfvision.net; s=20230425; h=from:subject:message-id; bh=ERJqwsd6TIo7l2Xda5AeUy5M5qXLm/Xs9Pw5gkTdYyM=; b=BMpuow4bAQ075j/GfP1eaSmmbD/fciXGPyZ2qc5mqLHkxj2BJ6IffNKcp7OnJU0q9t6FaGqMP jdiCQDVWOaiD2+veOQq49+EbY4jJtkjUsRDZbFt/FhgSNRFsJsdsZ91 X-Developer-Key: i=michael.riesch@wolfvision.net; a=ed25519; pk=1QQdXA2QbwdxaQn/VQK0hz04C8IBYhDowbK0hlNU4Ng= X-ClientProxiedBy: VI1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::36) To DU0PR08MB9155.eurprd08.prod.outlook.com (2603:10a6:10:416::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR08MB9155:EE_|AM0PR08MB5348:EE_ X-MS-Office365-Filtering-Correlation-Id: ffea3589-37f0-4ade-7056-08db94eb170f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MMfnHwBZIMh/X1/zt6e0J314nRIFz5FMgXiGQU/LV92RjVeTNy8lJCOzt2Cj3PRjdeUKajF4hShR8ExJ72M6oT7z1Eyl1FBEObr4EH0IF8rALZ2heCKWtlbW3FAUW244Hd6DYqyVgkU4qeyboZd+Ag9eLj8BBKENDq5Vbu9PCJEMVCbb0YFo9DR/YE2Mj+lFKVmsJ9pPnWuDRAwLAxu3DxmI+LJ95uzzQmtgDAYhNfJ6VDXeetriCHVK/tIQjSaM9vs3xr/5zjtrE4A6ukedDjusvTINmaErRF1VARe3T+zfdU2fNXFLCu6khCWDpgF5zaq5CowB2HW9tXr7NuAutrAxDg8MNKFlowwZc8UmMeKc7Q9iB4C4R+KrtrZVESySyPsvcsWyYA00xwwValR1qB/PFiARwsAkls1mB/KrhNE2O349gyeQGwOqNl7fA+2uz4VT40vz25AR69OZ3t9+CwQnZ+5mdS+CIc0QKAApSBljFfcQK7BcTFGAFaKMxcW9udZaU3JO4rgo+mkvS0gvJfH8PCs/MvxEi3ijfPxTL/1fxKJXtvqC+VC+SuytEiuZ79cGh18DBGOFD24Eb0kW8OC2uwriCIgwLXM2ccdWO0ViPPyHrXItVVvbgOEgtNhhlrCLOmh8La2sHrIXjKonCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR08MB9155.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(366004)(376002)(346002)(39840400004)(451199021)(186006)(1800799003)(6486002)(52116002)(6666004)(6512007)(86362001)(26005)(6506007)(107886003)(36756003)(2616005)(83380400001)(38100700002)(921005)(38350700002)(66556008)(66476007)(66946007)(4326008)(2906002)(316002)(6636002)(5660300002)(7416002)(44832011)(41300700001)(8936002)(8676002)(478600001)(110136005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?kTp8CR7VyQiZeKVXUCrXa+1cCFIq?= =?utf-8?q?4jgXOQQZe5/OHN6Cn7NoQuiNg3qIjjixnYTC3KtM4TI3kDVnm/JXBEYLfcVuqS9Mp?= =?utf-8?q?iWWU8JH2isdMcGber6M2XvtjFkHF8NV2AN1bbEPFWuG0diGmHM+Siughgg/DAFr4m?= =?utf-8?q?BrBc6e7LkhLh64IdFOscvYMV5/Lw47ZwXIwmdOGJa0kAF1DG0cxx14eSFUomxKX6k?= =?utf-8?q?97QvkI24xd99mfZal3p9QlKVielC1haTrwt6e6B9YPPFqU7C9ewRQgme21x3a+UDJ?= =?utf-8?q?Lf56FbDU7VG60jD4UL0tXLAidxHP50/oO5xmSKjaKR1FIkDmvWaMQJrYUsW/ybc92?= =?utf-8?q?q4T0DIAqYHQ/F/SrS9uUCoePRemmxxQUniB5UHvuTmksRbthgrtp+LA8tilH2+Ki2?= =?utf-8?q?fbGJzLOor1YEQVJIDswwJfK/M3HbU4QJjxXYagtvNSwxykiKoUhyqJmobJbUycS3o?= =?utf-8?q?s8NoOUZGB5LhzwmezQB/91ZkvmLeRUNugogqDF9IJQoZtHRfp94lBSifaCJQO8XgC?= =?utf-8?q?fyZ0joaS6oiY0lyCjT0TdFjs3G7gMZiDU8F+rdrF4NPY3wHL36BUGII8zMNw7/iwd?= =?utf-8?q?ANw/Nfmxrmw6fJMjbnIBQryMg7j9RBc+cVVzpak6omXMMfMiZUet1oRsIzEHMR3O9?= =?utf-8?q?sWPRjDT0nQDkv1JRr3YBWW6RgKHh4MSTeNyA3waXcce2vc2LkSud4L+NiW3MH+I1P?= =?utf-8?q?6aKXRd/T8xy+l+6I8GEYYMCHTOFqSCE5nObZQ2rQWEVDmaY8gEDacGOnP8jf0txoy?= =?utf-8?q?SkMtALhCQKV1OaFhWdgq1KWg+MPinOWCSbqyiRnbSIWh3NYmHCTi5G+vLt2QcNwBw?= =?utf-8?q?J4PglKd7Kc609HTi+9oI0iZ09DivijWDrTfUJ2uJIo+Z09ToOlQjfN3Pi25rl5XXe?= =?utf-8?q?eWgKwjWJBnEauRC0PilU5TDAV1L1C8Z1Y9wmst9gnXwUGnkktihCzSk86YIuIhoM0?= =?utf-8?q?HPfPYIEa554ffPMSAiTpEqfMPlivrWt4iOkQC6FVbTOU6/Upwqxw74Xrb7jT5FWaP?= =?utf-8?q?FlBif0eH8WcEPwxTxWagPVxSEEaLKpDHbs1ByH249p54guTkJwjXzVWpQMq0oIP9u?= =?utf-8?q?CatFef0RLZswvOuloSi46eQOCiOnWeCO39WEkQDVLVQoTFg2ZGNsSreY6P+ZFJe0O?= =?utf-8?q?yJazGOBHOOlx4+mT0EzqXenG7pgqB9+9SPNA0gYQr3xWE+VjGOR55R+TpXLmgqURY?= =?utf-8?q?/AFscVQGV1DC5zmhtaywF6Wc9lKuFnWIcMHYpb1RYnVD18GlljLz+MLAig+eVxIsx?= =?utf-8?q?Wgm0vxy2EDm9OLr5Yxfwigb5fv0PFS8SWIzG5/nwycMg8FJHYHvEcxVCSa6fHpH+2?= =?utf-8?q?wZvPM6/diyri8Xogzk+NjHzwQAVzNNC8ip+379wQTCTBfA7o49+eCgsu1ihm7+pT/?= =?utf-8?q?i3D2x80PdJEn6X47l+AQ+L3d4jkjOT/qXXV9mqo0ArGROxYNM1A7SW5te6wrz+W9B?= =?utf-8?q?wZt7TDl1K+Zl+Az09n1ER9V8RlMPngZixlVUrgOC2zB6fbf/NKTlTXOeXYLMdEBHK?= =?utf-8?q?CMkZSShK0HxrAat48rb8dCfFwZU7nR3HoA=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: ffea3589-37f0-4ade-7056-08db94eb170f X-MS-Exchange-CrossTenant-AuthSource: DU0PR08MB9155.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2023 13:02:42.9213 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Z0MBVvs/xHNvQ4ib5vCqPsK3y2rbHmqBQBT0JIJOdV9meKvG/j+an2tNQ1XvYe3tOYXJXzZe/Uz1+lp4VgP3bUWdR9kXthfpVisCJcXESnM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5348 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Michael Riesch Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The ST7789V controller features support for the partial mode. Here, the area to be displayed can be restricted in one direction (by default, in vertical direction). This is useful for panels that are partially occluded by design. Add support for the partial mode. Signed-off-by: Michael Riesch Reviewed-by: Neil Armstrong --- drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 43 ++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 0ded72ed2fcd..ebc9a3bd6db3 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -118,6 +118,9 @@ struct st7789_panel_info { u32 bus_format; u32 bus_flags; bool invert_mode; + bool partial_mode; + u16 partial_start; + u16 partial_end; }; struct st7789v { @@ -345,9 +348,14 @@ static enum drm_panel_orientation st7789v_get_orientation(struct drm_panel *p) static int st7789v_prepare(struct drm_panel *panel) { struct st7789v *ctx = panel_to_st7789v(panel); - u8 pixel_fmt, polarity; + u8 mode, pixel_fmt, polarity; int ret; + if (!ctx->info->partial_mode) + mode = ST7789V_RGBCTRL_WO; + else + mode = 0; + switch (ctx->info->bus_format) { case MEDIA_BUS_FMT_RGB666_1X18: pixel_fmt = MIPI_DCS_PIXEL_FMT_18BIT; @@ -487,6 +495,37 @@ static int st7789v_prepare(struct drm_panel *panel) MIPI_DCS_EXIT_INVERT_MODE)); } + if (ctx->info->partial_mode) { + u8 area_data[4] = { + (ctx->info->partial_start >> 8) & 0xff, + (ctx->info->partial_start >> 0) & 0xff, + ((ctx->info->partial_end - 1) >> 8) & 0xff, + ((ctx->info->partial_end - 1) >> 0) & 0xff, + }; + + /* Caution: if userspace ever pushes a mode different from the + * expected one (i.e., the one advertised by get_modes), we'll + * add margins. + */ + + ST7789V_TEST(ret, st7789v_write_command( + ctx, MIPI_DCS_ENTER_PARTIAL_MODE)); + + ST7789V_TEST(ret, st7789v_write_command( + ctx, MIPI_DCS_SET_PAGE_ADDRESS)); + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[0])); + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[1])); + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[2])); + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[3])); + + ST7789V_TEST(ret, st7789v_write_command( + ctx, MIPI_DCS_SET_PARTIAL_ROWS)); + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[0])); + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[1])); + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[2])); + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[3])); + } + ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_RAMCTRL_CMD)); ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RAMCTRL_DM_RGB | ST7789V_RAMCTRL_RM_RGB)); @@ -494,7 +533,7 @@ static int st7789v_prepare(struct drm_panel *panel) ST7789V_RAMCTRL_MAGIC)); ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_RGBCTRL_CMD)); - ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_WO | + ST7789V_TEST(ret, st7789v_write_data(ctx, mode | ST7789V_RGBCTRL_RCM(2) | polarity)); ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_VBP(8)));