From patchwork Mon Jun 24 07:10:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Spintzyk?= X-Patchwork-Id: 13709107 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 77682C2D0D1 for ; Mon, 24 Jun 2024 07:23:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A682210E388; Mon, 24 Jun 2024 07:23:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=synaptics.com header.i=@synaptics.com header.b="YWTR11jg"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2093.outbound.protection.outlook.com [40.107.237.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8BB8A10E370 for ; Mon, 24 Jun 2024 07:11:19 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a3yrpWsSe67AFnd61MPQMN+PSoJG+8d2x1BCof1R2zTSJOGiXTzhWZ5gpzrPgfa7AePMNYleRdxDp/6gAvbCun1okGgzn1/YDM+h6P6Ph0iQbr2QOT8KIqEk4/Naj/NAMaMZm5IyWecFUtTBghAFjYZDh697tMznfJwS+NHaIb8jScrbl+YLVs7qcgtGGc8RSmS3SEkPqIxyqT0Wuni6p8L91ORR20nc/O9/hvdLnXVq6G36aVWzN8Xo8sVtZHA6iVU9ux/QneWkHESOjKu6PNWpUUAB+I/rLHHHNHxaLmFPXjc/dUKUAtYLpFy5XaaEjHrJH8OWm0CHNpBlq0s6Vw== 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=WqRhWxs1wW8N3JeAaUzbhnYoPdQEVTtyEJhNFGBjDk8=; b=fASkQstEdRo8eFSZoG/6olOVXrkyq0x60JTXkMARvnYaeeMOM0KxGjD36opfpd9JPs0jm+vf1twzJycpqIfRvx/3duz+TZtyvf+cZmKG1m7XP6jHyWWcu069BSVtbTrPY5wB0KQyaAtCoWr4T4dh8TSE+c3FfMZ+0Ct9aKA13mf7fO7wsDhEkzhzdtWY6KnXauV2Cn1QZDYFdTGCK6zsqgieYSLg8JtIlW5gXFXo2apYhRnW73COqdCAN5VKcP1Y+vuhCKEuUdSYNBEpzgQWqV1iSBSTUlKPii7Ul3YRTJCaWUwPSVt0pFJoXLB1N4YamSuhFfm1j6vi0y8tOein+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synaptics.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WqRhWxs1wW8N3JeAaUzbhnYoPdQEVTtyEJhNFGBjDk8=; b=YWTR11jgf9E4+5vZp9b6UOps0uMeIg+7ielqG0RefoKAM1/RnZv2ZslB0SFcXpfP9uqx1HjcKAwavbk0R8A2Q74lwB3sSosb8u+O7n38u4VGIvPRjUxXr4iMWGQjhVXmTvVjpnF/qkvNMazxyArqBujQ3p6h8Oe4IoscZcN7g2k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=synaptics.com; Received: from BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) by BY5PR03MB5063.namprd03.prod.outlook.com (2603:10b6:a03:1e4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.29; Mon, 24 Jun 2024 07:11:17 +0000 Received: from BN9PR03MB6188.namprd03.prod.outlook.com ([fe80::7b19:7f50:4645:3990]) by BN9PR03MB6188.namprd03.prod.outlook.com ([fe80::7b19:7f50:4645:3990%4]) with mapi id 15.20.7698.025; Mon, 24 Jun 2024 07:11:17 +0000 From: lukasz.spintzyk@synaptics.com To: dri-devel@lists.freedesktop.org Cc: Dave Airlie , Sean Paul , Thomas Zimmermann , Douglas Anderson , Haixia Shi , Ross Zwisler , Guenter Roeck , =?utf-8?q?=C5=81ukasz_Spintzyk?= Subject: [PATCH 1/4] drm/udl: Port CrOS cursor blending on primary plane in usb transfer Date: Mon, 24 Jun 2024 09:10:38 +0200 Message-Id: <20240624071041.5087-2-lukasz.spintzyk@synaptics.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624071041.5087-1-lukasz.spintzyk@synaptics.com> References: <20240624071041.5087-1-lukasz.spintzyk@synaptics.com> X-ClientProxiedBy: LO4P265CA0209.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:33a::16) To BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN9PR03MB6188:EE_|BY5PR03MB5063:EE_ X-MS-Office365-Filtering-Correlation-Id: d645fe1b-47e3-4d85-d605-08dc941cd732 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|376011|1800799021|52116011|366013|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?SRYuDQhDGZTEyZcPNUt2WwvnFsydESO?= =?utf-8?q?3gBjtKe/he6+aNMLJw92fn51DujPOKGtUuul2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epU8zDRe+IOQZK+9NDdSzB7i7cgD3HWPaZ0lRgMJ?= =?utf-8?q?xQjqay8RUmgcmU31+EM3BKRISYmSrZVs6fLubw/dCBg+UE4W8cCNYj41D6uls98O2?= =?utf-8?q?vbXLAm9vFL5iRSDAL0T/nbi8vv2F6Q/ekC6EXR8APcahEJbwGmk6LHUaCa/PrF9Am?= =?utf-8?q?Gb11rdW5VqwquWLhudQEemsa9SrMVjMj4oRx1U4Mh56kK05JFLnKMxyqWKysLWRvA?= =?utf-8?q?q7lDKh09Th5KRKYieHLp4SJn1YqIyo6aM/AuasUfgYUDYIGL3Fxx38+EViJT0wXfp?= =?utf-8?q?UVVK3vEpy5ZuYo+qqA+p3DeoP7bukgC8FwaJvMtwpd61ul14nmSZI3CaMt8nvfCt3?= =?utf-8?q?XXH6vQqM1CJOx?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR03MB6188.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230037)(376011)(1800799021)(52116011)(366013)(38350700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?DPm89Z+U9+jjmZ3ax8hyQDHMTWR6?= =?utf-8?q?hiKeleKkxUZTGC8l/W98Yd4QcXRLd6OuIPWmeH76iO40FE9XUCYMd4Io2fFgRhUZi?= =?utf-8?q?8a7EaoFPHF8nLdjBYti+rPuCK2JDUrs1NFBEMoSZz/6yFFe9qQMJnJbkNkugQhGg7?= =?utf-8?q?ruYh6tNC6KnnNw2+yE2Me2B+8a7b3m0SVUGYxdgGFR/jNK7ugsNUtYS+tCBnrW867?= =?utf-8?q?isuhADjhvrGbGZN0O4ioXSsnDavOZTVljF78lKvLAp1veGyncZdb/FCIiOlkoZ4TD?= =?utf-8?q?st7aX67ldiTg/HCcJ4DI0IrQaiVyPTZSrcWa8uqk9IjhT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H9Nc2z1pb6PyXZg/dRVw+TAq4JJ88J?= =?utf-8?q?v8q2i8LKGXPymPwBMxTKZ6COSjfFIIdQx8aTRwZnGiXt3A2v/AHYRu1r3GShOQOdm?= =?utf-8?q?3n3IvMbGc2VKT/dVYi0gad5XQINtedKH2hO8OQ96KCi8JF+Db46MSJFwflel2T5zm?= =?utf-8?q?SAAPH+GfqdX3PwTPrr4na57WvNQdTrhe9LiOo6GkA04mLv8FnIU8B8lVdeSnPH95n?= =?utf-8?q?YjtN0SS7PQSrFEnbHLmOAg5K4P7Hl9k2tudD9m5xcHRogHy33fhP0gJDtGDwjyKPV?= =?utf-8?q?gQHPr4ciLgx9mdIs1V5eNZuX+9kyZq/YW0AdXMbCVBqJ3nSiQzFxpfTb1/apoOdpv?= =?utf-8?q?NYWQlXiufSO8?= X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: d645fe1b-47e3-4d85-d605-08dc941cd732 X-MS-Exchange-CrossTenant-AuthSource: BN9PR03MB6188.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 07:11:17.2698 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RKGN90jz+wS4LMReHuetAu5Ms484alQDa9EAO+2Lm3oEx95bV4qoJ5gfRMgO8Sl0cFxktQZIP1kJBJINdiY6+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR03MB5063 X-Mailman-Approved-At: Mon, 24 Jun 2024 07:22:58 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Douglas Anderson Port applicable parts of CrOS udl cursor implementation from 5.4 CrOS kernel fork. - removed legacy non-atomic udl_cursor_move, udl_cursor_set ioctl's implementation - modified udl_cursor_download to copy cursor content to the buffer from iosys_map - removed unnecessary cursor copy in udl_handle_damage - simplify code by making struct udl_cursor public Cursor was tested on ChromeOS and Ubuntu 22.04 with gnome-wayland. (cherry picked from commit efb4c23afa3e1de185a1a4f8ff5b7ec412aec0fe) ChromiumOS fork at https://chromium.googlesource.com/chromiumos/third_party/kernel) Signed-off-by: Haixia Shi Signed-off-by: Ross Zwisler Signed-off-by: Douglas Anderson Signed-off-by: Guenter Roeck Signed-off-by: Łukasz Spintzyk --- drivers/gpu/drm/udl/Makefile | 2 +- drivers/gpu/drm/udl/udl_cursor.c | 78 ++++++++++++++++++++++++++++++ drivers/gpu/drm/udl/udl_cursor.h | 47 ++++++++++++++++++ drivers/gpu/drm/udl/udl_drv.h | 6 ++- drivers/gpu/drm/udl/udl_modeset.c | 9 +++- drivers/gpu/drm/udl/udl_transfer.c | 36 +++++++++++++- 6 files changed, 173 insertions(+), 5 deletions(-) create mode 100644 drivers/gpu/drm/udl/udl_cursor.c create mode 100644 drivers/gpu/drm/udl/udl_cursor.h diff --git a/drivers/gpu/drm/udl/Makefile b/drivers/gpu/drm/udl/Makefile index 3f6db179455d..0abd04b0e829 100644 --- a/drivers/gpu/drm/udl/Makefile +++ b/drivers/gpu/drm/udl/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -udl-y := udl_drv.o udl_modeset.o udl_main.o udl_transfer.o +udl-y := udl_drv.o udl_modeset.o udl_main.o udl_transfer.o udl_cursor.o obj-$(CONFIG_DRM_UDL) := udl.o diff --git a/drivers/gpu/drm/udl/udl_cursor.c b/drivers/gpu/drm/udl/udl_cursor.c new file mode 100644 index 000000000000..594bb3b6b056 --- /dev/null +++ b/drivers/gpu/drm/udl/udl_cursor.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * udl_cursor.c + * + * Copyright (c) 2015 The Chromium OS Authors + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include + +#include "udl_cursor.h" +#include "udl_drv.h" + +void udl_cursor_get_hline(struct udl_cursor *cursor, int x, int y, + struct udl_cursor_hline *hline) +{ + if (!cursor || !cursor->enabled || + x >= cursor->x + UDL_CURSOR_W || + y < cursor->y || y >= cursor->y + UDL_CURSOR_H) { + hline->buffer = NULL; + return; + } + + hline->buffer = &cursor->buffer[UDL_CURSOR_W * (y - cursor->y)]; + hline->width = UDL_CURSOR_W; + hline->offset = x - cursor->x; +} + +/* + * Return pre-computed cursor blend value defined as: + * R: 5 bits (bit 0:4) + * G: 6 bits (bit 5:10) + * B: 5 bits (bit 11:15) + * A: 7 bits (bit 16:22) + */ +static uint32_t cursor_blend_val32(uint32_t pix) +{ + /* range of alpha_scaled is 0..64 */ + uint32_t alpha_scaled = ((pix >> 24) * 65) >> 8; + + return ((pix >> 3) & 0x1f) | + ((pix >> 5) & 0x7e0) | + ((pix >> 8) & 0xf800) | + (alpha_scaled << 16); +} + +int udl_cursor_download(struct udl_cursor *cursor, + const struct iosys_map *map) +{ + uint32_t *src_ptr, *dst_ptr; + size_t i; + + src_ptr = map->vaddr; + dst_ptr = cursor->buffer; + for (i = 0; i < UDL_CURSOR_BUF; ++i) + dst_ptr[i] = cursor_blend_val32(le32_to_cpu(src_ptr[i])); + return 0; +} + + +int udl_cursor_move(struct udl_cursor *cursor, int x, int y) +{ + cursor->x = x; + cursor->y = y; + return 0; +} diff --git a/drivers/gpu/drm/udl/udl_cursor.h b/drivers/gpu/drm/udl/udl_cursor.h new file mode 100644 index 000000000000..6a848accc106 --- /dev/null +++ b/drivers/gpu/drm/udl/udl_cursor.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * udl_cursor.h + * + * Copyright (c) 2015 The Chromium OS Authors + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _UDL_CURSOR_H_ +#define _UDL_CURSOR_H_ + +#include +#include + +#define UDL_CURSOR_W 64 +#define UDL_CURSOR_H 64 +#define UDL_CURSOR_BUF (UDL_CURSOR_W * UDL_CURSOR_H) +struct udl_cursor { + uint32_t buffer[UDL_CURSOR_BUF]; + bool enabled; + int x; + int y; +}; +struct udl_cursor_hline { + uint32_t *buffer; + int width; + int offset; +}; + +extern void udl_cursor_get_hline(struct udl_cursor *cursor, int x, int y, + struct udl_cursor_hline *hline); +extern int udl_cursor_move(struct udl_cursor *cursor, int x, int y); +extern int udl_cursor_download(struct udl_cursor *cursor, const struct iosys_map *map); + +#endif diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h index 282ebd6c02fd..ccd813bec1a9 100644 --- a/drivers/gpu/drm/udl/udl_drv.h +++ b/drivers/gpu/drm/udl/udl_drv.h @@ -21,6 +21,7 @@ #include #include #include +#include "udl_cursor.h" struct drm_mode_create_dumb; @@ -60,6 +61,7 @@ static inline struct udl_connector *to_udl_connector(struct drm_connector *conne return container_of(connector, struct udl_connector, connector); } +struct udl_cursor_hline; struct udl_device { struct drm_device drm; struct device *dev; @@ -74,6 +76,7 @@ struct udl_device { int sku_pixel_limit; struct urb_list urbs; + struct udl_cursor cursor; }; #define to_udl(x) container_of(x, struct udl_device, drm) @@ -97,7 +100,8 @@ int udl_init(struct udl_device *udl); int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr, const char *front, char **urb_buf_ptr, - u32 byte_offset, u32 device_byte_offset, u32 byte_width); + u32 byte_offset, u32 device_byte_offset, u32 byte_width, + struct udl_cursor_hline *cursor_hline); int udl_drop_usb(struct drm_device *dev); int udl_select_std_channel(struct udl_device *udl); diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c index 7702359c90c2..21594144fec5 100644 --- a/drivers/gpu/drm/udl/udl_modeset.c +++ b/drivers/gpu/drm/udl/udl_modeset.c @@ -26,6 +26,9 @@ #include "udl_drv.h" #include "udl_proto.h" +#include "udl_cursor.h" + +#define UDL_COLOR_DEPTH_16BPP 0 /* * All DisplayLink bulk operations start with 0xaf (UDL_MSG_BULK), followed by @@ -204,6 +207,7 @@ static int udl_handle_damage(struct drm_framebuffer *fb, const struct drm_rect *clip) { struct drm_device *dev = fb->dev; + struct udl_device *udl = to_udl(dev); void *vaddr = map->vaddr; /* TODO: Use mapping abstraction properly */ int i, ret; char *cmd; @@ -225,9 +229,12 @@ static int udl_handle_damage(struct drm_framebuffer *fb, const int byte_offset = line_offset + (clip->x1 << log_bpp); const int dev_byte_offset = (fb->width * i + clip->x1) << log_bpp; const int byte_width = drm_rect_width(clip) << log_bpp; + struct udl_cursor_hline cursor_hline; + + udl_cursor_get_hline(&udl->cursor, clip->x1, i, &cursor_hline); ret = udl_render_hline(dev, log_bpp, &urb, (char *)vaddr, &cmd, byte_offset, dev_byte_offset, - byte_width); + byte_width, &cursor_hline); if (ret) return ret; } diff --git a/drivers/gpu/drm/udl/udl_transfer.c b/drivers/gpu/drm/udl/udl_transfer.c index 5ff1037a3453..ba3a3ae08943 100644 --- a/drivers/gpu/drm/udl/udl_transfer.c +++ b/drivers/gpu/drm/udl/udl_transfer.c @@ -11,6 +11,7 @@ #include "udl_drv.h" #include "udl_proto.h" +#include "udl_cursor.h" #define MAX_CMD_PIXELS 255 @@ -43,6 +44,19 @@ static inline u16 get_pixel_val16(const uint8_t *pixel, int log_bpp) return pixel_val16; } +static inline u16 blend_alpha(const uint16_t pixel_val16, uint32_t blend_val32) +{ + uint32_t alpha = (blend_val32 >> 16); + uint32_t alpha_inv = 64 - alpha; + + return (((pixel_val16 & 0x1f) * alpha_inv + + (blend_val32 & 0x1f) * alpha) >> 6) | + ((((pixel_val16 & 0x7e0) * alpha_inv + + (blend_val32 & 0x7e0) * alpha) >> 6) & 0x7e0) | + ((((pixel_val16 & 0xf800) * alpha_inv + + (blend_val32 & 0xf800) * alpha) >> 6) & 0xf800); +} + /* * Render a command stream for an encoded horizontal line segment of pixels. * @@ -74,6 +88,7 @@ static void udl_compress_hline16( const u8 **pixel_start_ptr, const u8 *const pixel_end, uint32_t *device_address_ptr, + struct udl_cursor_hline *cursor_hline, uint8_t **command_buffer_ptr, const uint8_t *const cmd_buffer_end, int log_bpp) { @@ -81,6 +96,9 @@ static void udl_compress_hline16( const u8 *pixel = *pixel_start_ptr; uint32_t dev_addr = *device_address_ptr; uint8_t *cmd = *command_buffer_ptr; + const uint32_t *cursor_buf = cursor_hline ? cursor_hline->buffer : NULL; + int cursor_pos = cursor_buf ? cursor_hline->offset : 0; + int cursor_width = cursor_buf ? cursor_hline->width : 0; while ((pixel_end > pixel) && (cmd_buffer_end - MIN_RLX_CMD_BYTES > cmd)) { @@ -107,6 +125,11 @@ static void udl_compress_hline16( (unsigned long)(cmd_buffer_end - 1 - cmd) / 2) << log_bpp); pixel_val16 = get_pixel_val16(pixel, log_bpp); + if (cursor_buf && cursor_pos >= 0 && + cursor_pos < cursor_width) { + pixel_val16 = blend_alpha(pixel_val16, + cursor_buf[cursor_pos]); + } while (pixel < cmd_pixel_end) { const u8 *const start = pixel; @@ -116,12 +139,19 @@ static void udl_compress_hline16( cmd += 2; pixel += bpp; + cursor_pos++; while (pixel < cmd_pixel_end) { pixel_val16 = get_pixel_val16(pixel, log_bpp); + if (cursor_buf && cursor_pos >= 0 && + cursor_pos < cursor_width) { + pixel_val16 = blend_alpha(pixel_val16, + cursor_buf[cursor_pos]); + } if (pixel_val16 != repeating_pixel_val16) break; pixel += bpp; + cursor_pos++; } if (unlikely(pixel > start + bpp)) { @@ -160,6 +190,8 @@ static void udl_compress_hline16( *command_buffer_ptr = cmd; *pixel_start_ptr = pixel; *device_address_ptr = dev_addr; + if (cursor_buf) + cursor_hline->offset = cursor_pos; return; } @@ -173,7 +205,7 @@ static void udl_compress_hline16( int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr, const char *front, char **urb_buf_ptr, u32 byte_offset, u32 device_byte_offset, - u32 byte_width) + u32 byte_width, struct udl_cursor_hline *cursor_hline) { const u8 *line_start, *line_end, *next_pixel; u32 base16 = 0 + (device_byte_offset >> log_bpp) * 2; @@ -194,7 +226,7 @@ int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr, while (next_pixel < line_end) { udl_compress_hline16(&next_pixel, - line_end, &base16, + line_end, &base16, cursor_hline, (u8 **) &cmd, (u8 *) cmd_end, log_bpp); if (cmd >= cmd_end) { From patchwork Mon Jun 24 07:10:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Spintzyk?= X-Patchwork-Id: 13709099 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 2A3C6C2BD05 for ; Mon, 24 Jun 2024 07:23:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 32EF810E380; Mon, 24 Jun 2024 07:23:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=synaptics.com header.i=@synaptics.com header.b="Er09ZNeF"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2109.outbound.protection.outlook.com [40.107.237.109]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8FBEF10E370 for ; Mon, 24 Jun 2024 07:11:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W9xil4iKrk1r8eOc7bvr7gH7Tvm3Lvg8cyWK8D3Qt7QU7RMcZAkk70wEKCpk2niIccIVZjpTTo8eqHKIz60P3tGChlsBQxwI5V9nAK81UHkcdABcrvIsisey1qsWDEwgi8GtfCRkcCo1C2DNRrNGGmQtsivz2PiON6vb2R863ZF5RVvqrAo76fM94IfPe3cFqM9NFzTabNmPyb1We6UmhDgb1QkMpmQVragZmqTW6vq5AssHv9j8DxTulD18GsMKadmUOWdVRASdaFq5DgTTUiV0LxtRvB1JtWNprpfYXSgmoz+PcYdS5PefzG1BXGzByCYH/NnEsDPdS3f2xT0xcA== 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=P1qsqQxyeIkVl4m1ralVr8fCs/KQZ0LDaQY4i3NVcAw=; b=e9VTI5M17o1YxTnoVKlCmf2uiI+gDA85XOAWVtJJRkYeUGZ5jZFfM4S2zPbRtLzqpUdqsBc79j8TGE+Qt/r4APmz9wPGMMDjp6B9CPR1R1cPMPNq7U9F4Ez7SYrZCdGSkEmdrapflMoeBVb4CLPIA+JFrM5NLwQ+XQwwZZ+SnGSg6ErkDkwgxdF+UxNpu9RtDoginFLoq74YRXjYPhRO+6iipUbtaom/0bcY0O0GWdONLP8/EtlgfysquUxHvK/88IbjS0rL19d0tyDQM/AdFG0XVp7j/0lG3nQh5lJftu6iW83FdWdrjbn+XVwmRa/Stc1adVAa74qb5FI//V17Pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synaptics.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P1qsqQxyeIkVl4m1ralVr8fCs/KQZ0LDaQY4i3NVcAw=; b=Er09ZNeFJ4MfvB0dW1mHTDpPRVVBH9cQIl8pEJDtPCJEloPxaqS4G3wAREy0DIGV2xnOsKcHUZLczmNSRMFgto0m1HI3mm/9oSSgcHnRxkqb954AruFeO96e9iER2D0J9u24jzGi3wvpZcS3FpGrhSQvdl2Kx9SrwgBwdXurj20= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=synaptics.com; Received: from BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) by BY5PR03MB5063.namprd03.prod.outlook.com (2603:10b6:a03:1e4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.29; Mon, 24 Jun 2024 07:11:22 +0000 Received: from BN9PR03MB6188.namprd03.prod.outlook.com ([fe80::7b19:7f50:4645:3990]) by BN9PR03MB6188.namprd03.prod.outlook.com ([fe80::7b19:7f50:4645:3990%4]) with mapi id 15.20.7698.025; Mon, 24 Jun 2024 07:11:22 +0000 From: lukasz.spintzyk@synaptics.com To: dri-devel@lists.freedesktop.org Cc: Dave Airlie , Sean Paul , Thomas Zimmermann , =?utf-8?q?=C5=81ukasz_Spintzyk?= Subject: [PATCH 2/4] drm/udl: Add cursor drm_plane support Date: Mon, 24 Jun 2024 09:10:39 +0200 Message-Id: <20240624071041.5087-3-lukasz.spintzyk@synaptics.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624071041.5087-1-lukasz.spintzyk@synaptics.com> References: <20240624071041.5087-1-lukasz.spintzyk@synaptics.com> X-ClientProxiedBy: LO4P265CA0209.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:33a::16) To BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN9PR03MB6188:EE_|BY5PR03MB5063:EE_ X-MS-Office365-Filtering-Correlation-Id: 60bd867f-f574-4986-d535-08dc941cda2a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|376011|1800799021|52116011|366013|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?2Zs25kk+C+6OcVlfvdqtrvcSfztews0?= =?utf-8?q?m2QMOZVolQfXXDpTaGE0mBmeHfqvZKWjZtQ8Tciy99kqvTvFf3d2HaZtdXpX7GRrV?= =?utf-8?q?y1uNqjPenpWmFWZcOHYgwzXh8BmjHIKmS7Z46ME9T+HZ71xbHeJ7ddFv11vfs0Thf?= =?utf-8?q?HpdHC5/OGioe9R1S77NKyWivkl+gtnfv24qU3yQif39+2QNX/K7SeLIj/rCkA2c3F?= =?utf-8?q?SCMhtW0uvZpg8TThGBgvFnmXxVF9jW6aMDUMe6WJSgbQDEJoDnjdB+KJXPt/l5BPu?= =?utf-8?q?gaW3cmzVZctITJgQnLrHtntWACC0Md1+b2ApQwxVbZsWY7NNP3rjvVUZt7damUFk6?= =?utf-8?q?N5aKstFerNw13tXmpKYQv2LVERXIhV3f6rIIPvX9B1/npUopTadOyxERBDxiNhJrV?= =?utf-8?q?uT6wtVnjOA/8pUJbc04vhk41vhnyCqy92a+1ftxknx/5jug1ZN04oYlYO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LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR03MB6188.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230037)(376011)(1800799021)(52116011)(366013)(38350700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?wEVNsBpl3Aog+87w5h3Et+xdBom2?= =?utf-8?q?pYA00wQfrF2XDkLQHItSTnwklwScORKx4sRwcMbn3xvf/+0xoHtfM8AO0UvVSI1Bg?= =?utf-8?q?1+tXqM6QR96cg3elwhw3acDIqEopy4qzottCndVRKQZdkGb7ujhQLUJhc/UlLKAQP?= =?utf-8?q?E6mQ3TCKIQKrgoPB8YkbEWpagfMTKv0cgPm8CJiO+ekx8ENVy/6XbuQvyhn9kozC0?= =?utf-8?q?Am899fPoIN2TeqZrNcFZfSTzD8EMe7zF3xzr1by+gKV3IpXLY3eTXJIrB7QDdYlHX?= =?utf-8?q?v9EPZOVhHBf6/nNiIWJA4Svj2CWip4Hcv4rsrxsWGI6oREjs1eCNHFhYD9GGDTTY4?= =?utf-8?q?xHxh6YunNln7ELlNM0Z4T4wAEvAtzM6t2vm9MLM6ckouRb2p3KH1iWgSkTbWToYhl?= =?utf-8?q?7ND3VaLxOzjqa+y83E/jiqDJil2q6Pm5uIHMOyAqzmbtrxQRdXPCd+4tz7gd1LCER?= =?utf-8?q?yMob/nHyCXqRPwBuQurfIbG+q9S/ePkQEzlHPHt5dEJh2Ykk8fLxaf39d5J94O5xL?= =?utf-8?q?DGUOfmWLT/OB/45WCG10gyLPK1Gb+wo6JL6eo+zeI4oPF0Fo9dYfqN4ANvGwnqfpd?= =?utf-8?q?6B5YzRTdNjOmyldeLfEnzbQRFyjylRzMC92y3ADvaZRaP7GKDuvBo1mvclIzCyNl+?= =?utf-8?q?Zt08851FnHJ7KMY4Lkaut9UUaF9DXeoNyVYi8G7hw1qO1siCkgY1HYJi5PxJM+9Dx?= =?utf-8?q?qXY6rEFgO0/mpTiUyNGTWDpnZztbWWBhMeZUol0b9NSnPKukza0m76KoYgHr02P9I?= =?utf-8?q?IPY8dBOYFggoYZIq7svIzqhe0bWZ+s/1nSgBnHfru3axNlp1cJzHpmKJD9fMwg2SU?= =?utf-8?q?hoKsJWfmIgiV5+n1xOW4tqtwHiY7cZ1q6+i6dfZW6sSmvy7IDnJDuF1gknCYHVTu/?= =?utf-8?q?QapwAEjTCgtt5zl17jBNu9HckAK4GqUS01J+k2LnZq8sy+dPf767n9JbFMv6B/jLT?= =?utf-8?q?EryoDDoQAfc3iA7jbov5Skbsm61yxVeHH5x6TVYOJYXl9qz5SniHhRiRduDH7anrY?= =?utf-8?q?KkMNkU9oqouOYWAxbWnF6roiHj5XIbNgDeZNA+QoBOpsfpvu5rwflxN4YzEZtZcIb?= =?utf-8?q?cDcrO72zX7OvtcvjL33xm+mJNojacAVHNeB4yJyG6LO+ZtdPTkF183b3gQOV0EUai?= =?utf-8?q?GeDKTbOjQ9RxRIpzZ0sIUX2ztg6osHGl8O/J9uotzInARB95F8f24TY/qF8s7oLk6?= =?utf-8?q?KlSMtns07wD8SvvNXnOjwulXvXL2FFR7vTXcM1Du49oDsNsvWV4ZnRJQcA6yrH4vK?= =?utf-8?q?Bs6RNqnVM0ALQrZ+cipV0zYR+DJ9rzUDbeyqP+ypqGtDO0po31mP4a6jZOd/6WfgB?= =?utf-8?q?oND5XQfTA90BzYPwUZ1A2wW7HZJXvSjXcnEJaXQE68YxkAybz8lFWccT9EsxSHv0h?= =?utf-8?q?eTOeRxmyEqZyjgrMboUHGBGMleUeScTwQ3zLHAwvnQbnnpEnAEF7BtO2blwPmH+XC?= =?utf-8?q?KJM1G7diHEN/d8bG/iqmgHJFdJCyWtjxcTurscnLhsJZWoVZvNFHgus6rRVQw7N87?= =?utf-8?q?n1ExReB82vys?= X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60bd867f-f574-4986-d535-08dc941cda2a X-MS-Exchange-CrossTenant-AuthSource: BN9PR03MB6188.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 07:11:22.2126 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jtNcinXNI6q1LV3Rx7Z0UST7sNYWGbqhFqedb0GPN1RZds64Qj8gfmngLCYxsgLoCAsWBcfHYaW2RJQZA44Mag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR03MB5063 X-Mailman-Approved-At: Mon, 24 Jun 2024 07:22:58 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Łukasz Spintzyk Atomic support for cursor plane was inspired by evdi drm driver that is maintained on github.com/displaylink/evdi. Also added ARGB8888 plane format as it is used by cursor plane. Signed-off-by: Łukasz Spintzyk --- drivers/gpu/drm/udl/udl_cursor.c | 32 +++++++- drivers/gpu/drm/udl/udl_cursor.h | 8 ++ drivers/gpu/drm/udl/udl_drv.h | 1 + drivers/gpu/drm/udl/udl_modeset.c | 129 +++++++++++++++++++++++++----- 4 files changed, 150 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_cursor.c b/drivers/gpu/drm/udl/udl_cursor.c index 594bb3b6b056..d60eccb704f4 100644 --- a/drivers/gpu/drm/udl/udl_cursor.c +++ b/drivers/gpu/drm/udl/udl_cursor.c @@ -3,6 +3,7 @@ * udl_cursor.c * * Copyright (c) 2015 The Chromium OS Authors + * Copyright (c) 2024 Synaptics Incorporated. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -69,10 +70,39 @@ int udl_cursor_download(struct udl_cursor *cursor, return 0; } - int udl_cursor_move(struct udl_cursor *cursor, int x, int y) { cursor->x = x; cursor->y = y; return 0; } + +void udl_cursor_damage_clear(struct udl_cursor *cursor) +{ + cursor->damage.x1 = INT_MAX; + cursor->damage.y1 = INT_MAX; + cursor->damage.x2 = 0; + cursor->damage.y2 = 0; +} + +void udl_rect_merge(struct drm_rect *rect, struct drm_rect *rect2) +{ + rect->x1 = min(rect->x1, rect2->x1); + rect->y1 = min(rect->y1, rect2->y1); + rect->x2 = max(rect->x2, rect2->x2); + rect->y2 = max(rect->y2, rect2->y2); +} + +void udl_cursor_mark_damage_from_plane(struct udl_cursor *cursor, struct drm_plane_state *state) +{ + struct drm_rect rect; + + rect.x1 = (state->crtc_x < 0) ? 0 : state->crtc_x; + rect.y1 = (state->crtc_y < 0) ? 0 : state->crtc_y; + rect.x2 = state->crtc_x + state->crtc_w; + rect.y2 = state->crtc_y + state->crtc_h; + + udl_rect_merge(&cursor->damage, &rect); +} + + diff --git a/drivers/gpu/drm/udl/udl_cursor.h b/drivers/gpu/drm/udl/udl_cursor.h index 6a848accc106..2375323bae55 100644 --- a/drivers/gpu/drm/udl/udl_cursor.h +++ b/drivers/gpu/drm/udl/udl_cursor.h @@ -3,6 +3,7 @@ * udl_cursor.h * * Copyright (c) 2015 The Chromium OS Authors + * Copyright (c) 2024 Synaptics Incorporated. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -27,12 +28,15 @@ #define UDL_CURSOR_W 64 #define UDL_CURSOR_H 64 #define UDL_CURSOR_BUF (UDL_CURSOR_W * UDL_CURSOR_H) + struct udl_cursor { uint32_t buffer[UDL_CURSOR_BUF]; + struct drm_rect damage; // damage on primary bool enabled; int x; int y; }; + struct udl_cursor_hline { uint32_t *buffer; int width; @@ -43,5 +47,9 @@ extern void udl_cursor_get_hline(struct udl_cursor *cursor, int x, int y, struct udl_cursor_hline *hline); extern int udl_cursor_move(struct udl_cursor *cursor, int x, int y); extern int udl_cursor_download(struct udl_cursor *cursor, const struct iosys_map *map); +void udl_cursor_damage_clear(struct udl_cursor *cursor); +void udl_rect_merge(struct drm_rect *rect, struct drm_rect *rect2); +void udl_cursor_mark_damage_from_plane(struct udl_cursor *cursor, + struct drm_plane_state *state); #endif diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h index ccd813bec1a9..935bcabcd593 100644 --- a/drivers/gpu/drm/udl/udl_drv.h +++ b/drivers/gpu/drm/udl/udl_drv.h @@ -68,6 +68,7 @@ struct udl_device { struct device *dmadev; struct drm_plane primary_plane; + struct drm_plane cursor_plane; struct drm_crtc crtc; struct drm_encoder encoder; diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c index 21594144fec5..0bd4e2f02dcf 100644 --- a/drivers/gpu/drm/udl/udl_modeset.c +++ b/drivers/gpu/drm/udl/udl_modeset.c @@ -6,6 +6,7 @@ * Copyright (C) 2009 Roberto De Ioris * Copyright (C) 2009 Jaya Kumar * Copyright (C) 2009 Bernie Thompson + * Copyright (c) 2024 Synaptics Incorporated. All Rights Reserved. */ #include @@ -202,6 +203,23 @@ static long udl_log_cpp(unsigned int cpp) return __ffs(cpp); } +static void udl_trim_rect_to_framebuffer( + const struct drm_framebuffer *fb, + struct drm_rect *clip) +{ + if (clip->x1 > fb->width) + clip->x1 = fb->width; + + if (clip->y1 > fb->height) + clip->y1 = fb->height; + + if (clip->x2 > fb->width) + clip->x2 = fb->width; + + if (clip->y2 > fb->height) + clip->y2 = fb->height; +} + static int udl_handle_damage(struct drm_framebuffer *fb, const struct iosys_map *map, const struct drm_rect *clip) @@ -254,20 +272,21 @@ static int udl_handle_damage(struct drm_framebuffer *fb, } /* - * Primary plane + * Primary and cursor planes */ -static const uint32_t udl_primary_plane_formats[] = { +static const uint32_t udl_plane_formats[] = { DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888, + DRM_FORMAT_ARGB8888, }; -static const uint64_t udl_primary_plane_fmtmods[] = { +static const uint64_t udl_plane_fmtmods[] = { DRM_FORMAT_MOD_LINEAR, DRM_FORMAT_MOD_INVALID }; -static int udl_primary_plane_helper_atomic_check(struct drm_plane *plane, +static int udl_plane_helper_atomic_check(struct drm_plane *plane, struct drm_atomic_state *state) { struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); @@ -280,7 +299,36 @@ static int udl_primary_plane_helper_atomic_check(struct drm_plane *plane, return drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state, DRM_PLANE_NO_SCALING, DRM_PLANE_NO_SCALING, - false, false); + plane->type == DRM_PLANE_TYPE_CURSOR, false); +} + +static void +udl_cursor_plane_helper_atomic_update(struct drm_plane *plane, + struct drm_atomic_state *state) +{ + struct drm_device *dev = plane->dev; + struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane); + struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); + struct drm_framebuffer *fb = plane_state->fb; + struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane); + struct udl_device *udl = to_udl(dev); + struct udl_cursor *cursor = &udl->cursor; + + WARN_ON(old_plane_state->plane->type != DRM_PLANE_TYPE_CURSOR); + + udl_cursor_move(cursor, plane_state->crtc_x, plane_state->crtc_y); + cursor->enabled = fb != NULL; + + udl_cursor_mark_damage_from_plane(&udl->cursor, old_plane_state); + udl_cursor_mark_damage_from_plane(&udl->cursor, plane_state); + + if (!fb) + return; + + if (plane_state->fb == old_plane_state->fb) + return; + + udl_cursor_download(cursor, &shadow_plane_state->data[0]); } static void udl_primary_plane_helper_atomic_update(struct drm_plane *plane, @@ -291,6 +339,7 @@ static void udl_primary_plane_helper_atomic_update(struct drm_plane *plane, struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); struct drm_framebuffer *fb = plane_state->fb; struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane); + struct udl_device *udl = to_udl(dev); struct drm_atomic_helper_damage_iter iter; struct drm_rect damage; int ret, idx; @@ -305,24 +354,39 @@ static void udl_primary_plane_helper_atomic_update(struct drm_plane *plane, if (!drm_dev_enter(dev, &idx)) goto out_drm_gem_fb_end_cpu_access; - drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state); - drm_atomic_for_each_plane_damage(&iter, &damage) { - udl_handle_damage(fb, &shadow_plane_state->data[0], &damage); + if (plane_state->fb != old_plane_state->fb) { + drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state); + drm_atomic_for_each_plane_damage(&iter, &damage) + udl_handle_damage(fb, &shadow_plane_state->data[0], &damage); } + udl_trim_rect_to_framebuffer(fb, &udl->cursor.damage); + udl_handle_damage(fb, &shadow_plane_state->data[0], &udl->cursor.damage); + udl_cursor_damage_clear(&udl->cursor); + drm_dev_exit(idx); out_drm_gem_fb_end_cpu_access: drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE); } -static const struct drm_plane_helper_funcs udl_primary_plane_helper_funcs = { +static void +udl_plane_helper_atomic_update(struct drm_plane *plane, + struct drm_atomic_state *state) +{ + if (plane->type == DRM_PLANE_TYPE_CURSOR) + udl_cursor_plane_helper_atomic_update(plane, state); + else + udl_primary_plane_helper_atomic_update(plane, state); +} + +static const struct drm_plane_helper_funcs udl_plane_helper_funcs = { DRM_GEM_SHADOW_PLANE_HELPER_FUNCS, - .atomic_check = udl_primary_plane_helper_atomic_check, - .atomic_update = udl_primary_plane_helper_atomic_update, + .atomic_check = udl_plane_helper_atomic_check, + .atomic_update = udl_plane_helper_atomic_update, }; -static const struct drm_plane_funcs udl_primary_plane_funcs = { +static const struct drm_plane_funcs udl_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, .destroy = drm_plane_cleanup, @@ -393,8 +457,20 @@ static void udl_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct drm_ato drm_dev_exit(idx); } +static int udl_crtc_helper_atomic_check(struct drm_crtc *crtc, + struct drm_atomic_state *state) +{ + int ret; + + ret = drm_crtc_helper_atomic_check(crtc, state); + if (ret) + return ret; + + return drm_atomic_add_affected_planes(state, crtc); +} + static const struct drm_crtc_helper_funcs udl_crtc_helper_funcs = { - .atomic_check = drm_crtc_helper_atomic_check, + .atomic_check = udl_crtc_helper_atomic_check, .atomic_enable = udl_crtc_helper_atomic_enable, .atomic_disable = udl_crtc_helper_atomic_disable, }; @@ -573,6 +649,7 @@ int udl_modeset_init(struct drm_device *dev) { struct udl_device *udl = to_udl(dev); struct drm_plane *primary_plane; + struct drm_plane *cursor_plane; struct drm_crtc *crtc; struct drm_encoder *encoder; struct drm_connector *connector; @@ -589,20 +666,34 @@ int udl_modeset_init(struct drm_device *dev) dev->mode_config.preferred_depth = 16; dev->mode_config.funcs = &udl_mode_config_funcs; + cursor_plane = &udl->cursor_plane; + // Add cursor plane first as this is an order of plane atomic_update calls + // That allows to gather cursor damage before primary plane update + ret = drm_universal_plane_init(dev, cursor_plane, 0, + &udl_plane_funcs, + udl_plane_formats, + ARRAY_SIZE(udl_plane_formats), + udl_plane_fmtmods, + DRM_PLANE_TYPE_CURSOR, NULL); + if (ret) + return ret; + drm_plane_helper_add(cursor_plane, &udl_plane_helper_funcs); + primary_plane = &udl->primary_plane; ret = drm_universal_plane_init(dev, primary_plane, 0, - &udl_primary_plane_funcs, - udl_primary_plane_formats, - ARRAY_SIZE(udl_primary_plane_formats), - udl_primary_plane_fmtmods, + &udl_plane_funcs, + udl_plane_formats, + ARRAY_SIZE(udl_plane_formats), + udl_plane_fmtmods, DRM_PLANE_TYPE_PRIMARY, NULL); if (ret) return ret; - drm_plane_helper_add(primary_plane, &udl_primary_plane_helper_funcs); + drm_plane_helper_add(primary_plane, &udl_plane_helper_funcs); drm_plane_enable_fb_damage_clips(primary_plane); + crtc = &udl->crtc; - ret = drm_crtc_init_with_planes(dev, crtc, primary_plane, NULL, + ret = drm_crtc_init_with_planes(dev, crtc, primary_plane, cursor_plane, &udl_crtc_funcs, NULL); if (ret) return ret; From patchwork Mon Jun 24 07:10:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Spintzyk?= X-Patchwork-Id: 13709101 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 B5F2EC2BD09 for ; Mon, 24 Jun 2024 07:23:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08D8E10E384; Mon, 24 Jun 2024 07:23:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=synaptics.com header.i=@synaptics.com header.b="sEztR52A"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2109.outbound.protection.outlook.com [40.107.237.109]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26D6A10E373 for ; Mon, 24 Jun 2024 07:11:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dFDebIR4cVl34e90GrDLQ1PfQ/ZKJVYHItb68RhJi3gBtalNH+g+plEWFN4cWtFSw46m5N8gn1+E2yNVFlsB3lbtLXWp2ss9YQFPjJZOuubgvdMfwlQ+qHxPaImt6hyimQsA0UV5cFM3UdBm4nUTBcX7xMDS7pBeNB6fJtKnlKgEkTsQHMj4R7lS8aWTR1kqcG9saZAlrQLqAGUDbVX3XQFgDpOXFCJlAbGpT1q6BZOlGW/cKIBBUTGsLEg/U+hPoDs7oGqKT8e0phkiIhc0zFwq1i1DKwhxLh6+wJyDawoLG0HatsegAZT3LA4g7sh44Ku9iMH3L57Q8x7uyqFEEA== 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=onylsF04H65p4cNS9Gq/jVFb4QEKUi6xIP+DEei472c=; b=I3fAVAeX+iN/e/QSR2mLvTe2rJbMt8QHgl1INAzgiK/gEygZ5QkEKQ5NZB+I00WjEAU5mGVMfGfW4zzV3hwkrKOc+iu8YoxLTsJx9TCUjoyaSVUaHwl6l/ANxPKK+c1QYYX5jgOXOvbHooxRI8LEdfNwrU9Mks+WBGxNIhf/BLfILxcmVgsWS8UUPUZUnE9+PI6QQOMxqxNR3266TAWzm0gIXdHTfWoHMHr4jUnYS/mxjwQhTl144GR0YSFhzAn0OSrVI/bAGpXniQLKNxnGNvhZj1/4Kzf1FG1U5BRlcDBcE1xpn94eo82BQ/D9fC0dXoACAthmLFa8JLa86yu8BQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synaptics.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=onylsF04H65p4cNS9Gq/jVFb4QEKUi6xIP+DEei472c=; b=sEztR52AkMRWkB+s+gku2Q51RBxti5n6NEbny3MT4dCq1qn95KHmHNRwmoJ2uTRhGNru1ObAPrvaHYGPF2IxxH4S4Q7PpnHKMmP5Mif2soePdc+vYKrId+Ge4YTkPSZuXvGEewsSPX1IS6cp+etUQ6JEjOSirW2MHsqOOYCFoLg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=synaptics.com; Received: from BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) by BY5PR03MB5063.namprd03.prod.outlook.com (2603:10b6:a03:1e4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.29; Mon, 24 Jun 2024 07:11:23 +0000 Received: from BN9PR03MB6188.namprd03.prod.outlook.com ([fe80::7b19:7f50:4645:3990]) by BN9PR03MB6188.namprd03.prod.outlook.com ([fe80::7b19:7f50:4645:3990%4]) with mapi id 15.20.7698.025; Mon, 24 Jun 2024 07:11:23 +0000 From: lukasz.spintzyk@synaptics.com To: dri-devel@lists.freedesktop.org Cc: Dave Airlie , Sean Paul , Thomas Zimmermann , =?utf-8?q?=C5=81ukasz_Spintzyk?= Subject: [PATCH 3/4] drm/udl: Allow smaller plane sizes to allow cursor plane Date: Mon, 24 Jun 2024 09:10:40 +0200 Message-Id: <20240624071041.5087-4-lukasz.spintzyk@synaptics.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624071041.5087-1-lukasz.spintzyk@synaptics.com> References: <20240624071041.5087-1-lukasz.spintzyk@synaptics.com> X-ClientProxiedBy: LO4P265CA0209.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:33a::16) To BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN9PR03MB6188:EE_|BY5PR03MB5063:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a8bdbc5-98a8-4faf-5557-08dc941cdb1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|376011|1800799021|52116011|366013|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?rl2JZCVq5o1twxBvgtjMtloGjD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V/7whDHAUpK?= =?utf-8?q?dtjDYBB2DZ2IuXwqznrjcLKBx+MxEHQo2rakuQZBNDSPsCgZhTQRTYppMamChqDSh?= =?utf-8?q?fzIbexBamtmT0HRi3mwYc/p0KGhQvoTtUihXYwPmnXctNBlVXrEo6oDAzGbgv4e56?= =?utf-8?q?QeMilD+h4kmHcP9k8MWSJ0Ge7Pe/KmuL0EkXPHx+9ltfnmoxDngosPSq6lQTX1Jt5?= =?utf-8?q?46jZrCUBBOreDEWDZP+dTuyco1B7YwA5oclHo8HHVt4mYnzPU+rxakswk24YLQwEW?= =?utf-8?q?ruynECjBUqeED0ixsh4+HP0b0EK+onpEVw4Dqmy7IbocM9cZ3qQX+GHBI2Co+DWlD?= =?utf-8?q?Mwaw6+zlCElAQRCoSssJCbnGxKnkke0rmlBZCe4aSgZr6RfTgEiBZhqORKwZrEefI?= =?utf-8?q?5RZiTmfJOThxIt15kMkZ3Rk2x5NzkWXEtEXS5rNSliixsUXZ0szYfqKs=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR03MB6188.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230037)(376011)(1800799021)(52116011)(366013)(38350700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?mAiJXjrJPjVBVEcPQiurhSmLVyKd?= =?utf-8?q?QPB7P3UHXDlS/zF2XFYfppK/LnAki6ROyOXFGF3domZY507ImksGiLZJEjKViaXax?= =?utf-8?q?YHLdSheDrINKjp7WKu+JLquo9mK8oPydG7bJYKC97hca5iNcMn/mUN7KQHlLNcweK?= =?utf-8?q?AxRtZhAl/1kBY6X9dyb0H/Q2Shw9yyPkM0l0ev3ZqqKvY5+5nS1nJ7VZoNeOxPvsA?= =?utf-8?q?GxYKyeZoHWALCy6bldF/R43eBuJlNevb1XxKUUrY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5v21JdDgYAUQHrv9P6nEweqA?= =?utf-8?q?yLPSkfyf2xRXBoQHJ6WE0Y6LEIwje5/RCMqQEoONLvZAtlTlD8qkLr6+mLqadqpUm?= =?utf-8?q?CCb35oRayEg9icrqhlxJO+L45Pi/g9k6v4EOVP+Jo2J7xPf32OAtyXx8Uf1jhTE+v?= =?utf-8?q?mNUF53ZS+YlZrIYEMo2g3N1YYt9rs1m9ieEaYknz8A0nLZQX5LqiEHfzAfR69C/Kv?= =?utf-8?q?RdgrgVt1NhFtXbEyhO2v/LTt25+LS0VrgGNZ11AWR6/R5/SaFwdI4EO9qC8raCaUM?= =?utf-8?q?9/GaiVuCYio7J2pSD5Ab6ryMeIQxc7X+NL1fdsIrAZUZRq4s8Dk/9x6eH/Oc2/0/k?= =?utf-8?q?6mB66Ri3U7DqY07M+yGYAWIFcY43bOlAlg1YnAafzFsMP4y98vMdKWHW98QfdX0fO?= =?utf-8?q?wUnJjs6dsYBY?= X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a8bdbc5-98a8-4faf-5557-08dc941cdb1a X-MS-Exchange-CrossTenant-AuthSource: BN9PR03MB6188.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 07:11:23.7828 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1zP0iJK5ddmtJO6APPScMukhc9qNtJo7gvIEHdwKc0yinZ5wfpG9qr4YOGl/kg7FanKGtj+Kx3YGl4jTbQz+Uw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR03MB5063 X-Mailman-Approved-At: Mon, 24 Jun 2024 07:22:58 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Łukasz Spintzyk Signed-off-by: Łukasz Spintzyk --- drivers/gpu/drm/udl/udl_modeset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c index 0bd4e2f02dcf..28b7c269e913 100644 --- a/drivers/gpu/drm/udl/udl_modeset.c +++ b/drivers/gpu/drm/udl/udl_modeset.c @@ -659,8 +659,8 @@ int udl_modeset_init(struct drm_device *dev) if (ret) return ret; - dev->mode_config.min_width = 640; - dev->mode_config.min_height = 480; + dev->mode_config.min_width = UDL_CURSOR_W; + dev->mode_config.min_height = UDL_CURSOR_H; dev->mode_config.max_width = 2048; dev->mode_config.max_height = 2048; dev->mode_config.preferred_depth = 16; From patchwork Mon Jun 24 07:10:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Spintzyk?= X-Patchwork-Id: 13709102 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 D7A35C30653 for ; Mon, 24 Jun 2024 07:23:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0ADD610E385; Mon, 24 Jun 2024 07:23:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=synaptics.com header.i=@synaptics.com header.b="IYGJF+iM"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2091.outbound.protection.outlook.com [40.107.237.91]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A02710E370 for ; Mon, 24 Jun 2024 07:11:27 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lgncJYpnUZW57epdWm23x+xLlLVhQlqxMrr3CdrYsWdRgvI8rizNUPcEGlqKAJBWG5A2T+gHCQzSUvXxADMTeqVhHAiOO8GzgBxripRzIHxq+1tYN7xNSTZ7T+4Im0UBH/+75AStg71/B/eOsAdCwgj7fDu4TfsNSZUeebp+Hj/Y8vNPDqgx/m7bxOJAWLOoi4ZtRGifleEKTDQ/52r+xDi9y1D/5EvGRadqP6/L1R9hw2NCyXR2/C3kIZqQ1e9HU1MFf5wWazqFAEKgrfSJRLK8oxJuFdoGUDEaXIZQfYaJRCqJll2nLWRrhNt7RqA7dA3+/WK2Ibu8M1TlseTRHw== 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=ZzjPdwKz9ljC2BwYLgVlAcJVpgG2p4+yBnna8imPKo4=; b=kmCE1PeOsPnjqUBCkvI4jvzFhRZIM4jw/294xIzz7WW1EFYRerbRrCWDdWy4Rf+Lq4cHqxpM9aJlJOmsDBPnigqkipgpH3jijwbVTMKosP/X0ERn3kNl/TWaYLmi5ZaUByx5Fr2iCvbrGNoIEmHRPsq8exLadGL3d44WlxT719OXkmfvQOdeuUeF4/EU3pWk3w58wJc3lARGp5Zh8ibRzdZU6OyfiarUnVSqWGGCwcNKnhNdWY1n0a20KXCefl0vzFLPYOdjhm5WVbJ9Fkl+Q0fXdRPmt1Xte9Ir1gQDPZfrk/cSj105W98nLOkhdretcaNToF60+XELBU1rvRMoWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synaptics.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZzjPdwKz9ljC2BwYLgVlAcJVpgG2p4+yBnna8imPKo4=; b=IYGJF+iMPDCrQGg9eO0Yk7n5h9mOlD2BPiqPxh3Lhjks3ISSPlUCHXjaWK4AQHp7zUI4qTBy0YhLi0+18QR8BM0X9+Vths6aLGq2UTZVA524SVV5hX5Elwt0SdyyeoZRHkbLJgC7RFaADSLhwhgACrhHUZ9djPRR9na2zZoIwuU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=synaptics.com; Received: from BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) by BY5PR03MB5063.namprd03.prod.outlook.com (2603:10b6:a03:1e4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.29; Mon, 24 Jun 2024 07:11:25 +0000 Received: from BN9PR03MB6188.namprd03.prod.outlook.com ([fe80::7b19:7f50:4645:3990]) by BN9PR03MB6188.namprd03.prod.outlook.com ([fe80::7b19:7f50:4645:3990%4]) with mapi id 15.20.7698.025; Mon, 24 Jun 2024 07:11:25 +0000 From: lukasz.spintzyk@synaptics.com To: dri-devel@lists.freedesktop.org Cc: Dave Airlie , Sean Paul , Thomas Zimmermann , =?utf-8?q?=C5=81ukasz_Spintzyk?= Subject: [PATCH 4/4] drm/udl: Shutdown all CRTCs on usb disconnect Date: Mon, 24 Jun 2024 09:10:41 +0200 Message-Id: <20240624071041.5087-5-lukasz.spintzyk@synaptics.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624071041.5087-1-lukasz.spintzyk@synaptics.com> References: <20240624071041.5087-1-lukasz.spintzyk@synaptics.com> X-ClientProxiedBy: LO4P265CA0209.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:33a::16) To BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN9PR03MB6188:EE_|BY5PR03MB5063:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e7ae828-3fc1-4218-5342-08dc941cdc09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|376011|1800799021|52116011|366013|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?g6S85PZNPKT2qJ3s14N6hfu+fKpucxg?= =?utf-8?q?gtoVmdGk6owoH1DrV4QvVq7DiTaUelyYDIoQVbIQ1scVKh6JoXkQwcAq1lGW32vc5?= =?utf-8?q?5YR0MHZAUD+2drijH/o9yAqD8Y0avBx7H6WVTBV5XfwV5di06Kp+B1PlBs7c0uXed?= =?utf-8?q?yZfN0iA95W9SeRWfjZD/awo/jFzg4N5NJ8bj2BuMSWD3QIUIEWIvc9DpClbW0Bs2P?= =?utf-8?q?2pUYkAoI6nU3TvBjLZMhQ4aKTdLT7kvspXrSEk+T44jPKoOALvov97hbFhZ9U8zpE?= =?utf-8?q?M4pJf7la016aGyIi2O9JcyylfNh118iz3diZai6fwl5zYhYE+Lcn3nXEgXF851hkA?= =?utf-8?q?qoTawd85HROmTU4fsukOqa7JSWP+x4x+rbmkpqjFCwBPSWmrcvCohGIFU3EK6vriB?= =?utf-8?q?rzFeIWx3s/6UCbcAmDLSPVw0nHcTeVYvCdnr6ijQJobPX83N20H/gNZTOVQ64OTH4?= =?utf-8?q?+TLiAN07Yb+g/D/o2a1aA/8K/bghauoUizAnK3UrGUND6kxqVjXitmbK9K9qb1rnP?= =?utf-8?q?aPhhdD9eMfomhalJy6EhJv1evi2W5gDYSZ0ccuGJ+c//CbedqUC4XPIwKlZCqzwm9?= =?utf-8?q?TDLLg9x0j4PUD4DcTccLe7um0zCq4CdSj8pMvaQL15a4qkhVkNNkHp7VZX5JAMcWC?= =?utf-8?q?iYRZuxsKRisx2WK8zjAk2bV6sJVTFCEBNdCLRNhyFOzQEwNorwehDcPP/Pvrz5Txp?= =?utf-8?q?xmoHs+nU5y9OVdO+M8IqdeuHOBpB7/PuS8vm3IhlncVJvUzAaXhXKyfVgDgGvXgA7?= =?utf-8?q?AeYO6Tas9beuCj3c7c6JLklQCwycyzMX8A4MyUNPCcSSYGg4+vNGk0CS4oaW36oXt?= =?utf-8?q?IcH7CdBMLktJ2b++5mOHAVTC+RY1kxlHn+a5zed63wYb/IM48/LAtXKLGz8EZcgt9?= =?utf-8?q?kHl3OUZ7GBXnpRLnS66pGdlgcViEdjdUKnbFa/ksAGBl4MPsj4F7WhILnQXlRG8oS?= =?utf-8?q?wFezQXJPACHZ33fsvXAQg8hjuzTAg4xBYuLszG6+YeyfJ6OsRGCTPM7ywHVRpfJSM?= =?utf-8?q?bLhcs1SV1n+TdDZDzdebYL7hxCGaU+whcw9hfR212ETN/DX4xmHcROZBz8YmcWf3U?= =?utf-8?q?YS3TCo8UVvjE/uE+6iFwvQc9F7KwujxXp+Q7pParbbJV+8Yzgey4ktjJSdgKO8vAC?= =?utf-8?q?Z5hMLuc5pJEf/aQjKTFL7U4jJeqO21O2910X7IYMzapcV5jjbw0vfQjEq2yk8WrMk?= =?utf-8?q?+DdMUC0vo51Ab9N9bwMt8283QRPTTg9HDTSo89LYhVZvhNIji8BzeUoG4ulvEsxxD?= =?utf-8?q?YHI43cjq+uyzMWox0kVZsAj2fMsYAvhGbWZ8vxskuLCbhZx/34aTEuVI=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR03MB6188.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230037)(376011)(1800799021)(52116011)(366013)(38350700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?mnwzbzkR9TBIHgOQXlc/7A/MVcpy?= =?utf-8?q?heNxJkYclknxBzg408zAgVeOEG645kil/4moxtI3FZ6WsvspOe0JpOAubxXignOYC?= =?utf-8?q?a3W0ZsrG0zk96sQcYsLQmWyyNZbxgyhcmhNniL/JfHtvfMc5ZzLIPayI04mLS1IpD?= =?utf-8?q?rZKwQhe1gLswU4V47+qo+opsyrJAkaa07oxfpnRCiwD1PUAomKKmWnYXW1/C84CtK?= =?utf-8?q?3O3clizTwtRmY1aB77rB7nlB/6VpvhrcSK2JUqHJiMZzJuTAf9L7eFusJ7JrPOuu4?= =?utf-8?q?2C0EGpFfObgFa6dda/JXtJeQLIjuNXKyDxeRVIUQHOayczeDyzF1mEz8/2YIK5wZT?= =?utf-8?q?K/VKPZVN1nUh5rYbUJ00gXZ4JbdTh/gfyzLlPfCqJvfsLQXMOU5XGjr06jsvwCsqg?= =?utf-8?q?ro3a0O8spT+sXHIjIxRAItzaN2M7bQXWMxbgZOtfHAURizeuQFVbmy/o28Fli3vUg?= =?utf-8?q?t7a7Q/WZan/S2C8gqd/26p+opRCrawyU894V6cKhH5lFWefmkcwtbEp151i0rPgbj?= =?utf-8?q?picnNi11xEWiR4FjUtpBdAnLfi7vVxsTw1sECc+G/fKHLVYSeMiBDA1bHdBYByJrP?= =?utf-8?q?gUcBwaKNSa6TRyrHQTEq5yETZttG4heZa0AWUkZR6fJN2g7GUNpXWDjIHslry5XyI?= =?utf-8?q?hA6hwsogJvs6jCMJ+xMhk2HM9BzDh8XHxKqb96jCn0Z6cedgri2pGgVTfVY4XmkSU?= =?utf-8?q?zxrqC/949FCVJCs1fabffg8NxZfI21+gx2d+XcLPNx6pAzFyiPp8y2Ex+za8jfqKx?= =?utf-8?q?uuMzdfQPzlFVY7Cn8UCjjdwEnvMVFfxpTuHZd2zS7uIEtQGTOxPsfvsGmhkREGCin?= =?utf-8?q?+aEx0TAoUMULbbcuCJCXjQtbznrJ1bZwyML7YJXHmCsgFDKBwsK1P6cUx1fu51zbU?= =?utf-8?q?86tt6fTKgEVcPT/n83zJK+B0xBi1O9nq/+WAd8YNI/vJbF2PMN7K0cPMBJuZeF7Qo?= =?utf-8?q?UUplDppMU2AGb1aBFlI36/dVVo0SvAawnmKGkSrT/E7ouI+u5uTITNdN9DOdAmLiU?= =?utf-8?q?rn0OaZ9k8nDQpn9LOH9YqSd+kt8aD24vt7brN1NrJZlbftmKdm/pzH/9+w3RnhOpO?= =?utf-8?q?XIEGS7YI1uWo6iNWEmNq1nUFMpHdUYaQs67g/vDPWQ4jAmwLmQMxa0SC3SoRtpSr9?= =?utf-8?q?PkPZjyc9DylTJ67gSKD9NPSwk9x0vlz2wJj1SwUs/2Rz9RwNvUSvRS94cm30RS1A8?= =?utf-8?q?NBu7artmf9G7HsP6eonkh8zhxS/hnapn7fPuPCYxTQqXt4XHCeHg+fs7/fOgUqHH1?= =?utf-8?q?d/02/YbboNfFpj2yNceF42fSTbn901C+HzfqMONsJ61fa19Gat+kXeuS/N+FKAuHv?= =?utf-8?q?Jkig1qpr4eB5TxcDG1fc4GcQc/VAlPYOPET7TRjyqAoKeGlZUo/OdZdE3wAuF14fn?= =?utf-8?q?SWOGP3EWOo2ghhDoj0TnL4E1rEEu7N3SwRZrQB4/xrwwqj0qS4KIvB/N5pykBSO+x?= =?utf-8?q?ugMKJfRVymDs7LCqu7uR18DzovJEBcFqPwbQ9kxLkoeh9cdyH9enEetS6Srax3DlJ?= =?utf-8?q?qt6++pPJuRxB?= X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e7ae828-3fc1-4218-5342-08dc941cdc09 X-MS-Exchange-CrossTenant-AuthSource: BN9PR03MB6188.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 07:11:25.3380 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: o060mj9cvK7ENgOHgrxUnC09fRPriNsLdLiwwofIM7OEff7y/2wswmYsWSh9l4G281qaWgowdMjPLB5EsPLeXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR03MB5063 X-Mailman-Approved-At: Mon, 24 Jun 2024 07:22:58 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Łukasz Spintzyk This is fixing some kernel panics on device unplug, that started to be more visible after implementing cursor plane support. Signed-off-by: Łukasz Spintzyk --- drivers/gpu/drm/udl/udl_drv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c index 1506094a8009..adaa7703c118 100644 --- a/drivers/gpu/drm/udl/udl_drv.c +++ b/drivers/gpu/drm/udl/udl_drv.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2012 Red Hat + * Copyright (c) 2024 Synaptics Incorporated. All Rights Reserved. */ #include @@ -14,6 +15,7 @@ #include #include #include +#include #include "udl_drv.h" @@ -129,6 +131,7 @@ static void udl_usb_disconnect(struct usb_interface *interface) drm_kms_helper_poll_fini(dev); udl_drop_usb(dev); drm_dev_unplug(dev); + drm_atomic_helper_shutdown(dev); } /*