From patchwork Fri Nov 22 17:20:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883429 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 D0DEBE69185 for ; Fri, 22 Nov 2024 17:20:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B16610EC23; Fri, 22 Nov 2024 17:20:29 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="CLo1lUIU"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6C98A10EC1D for ; Fri, 22 Nov 2024 17:20:22 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2FC1A1C0007; Fri, 22 Nov 2024 17:20:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eu7h5ilmMqLJECKzMclaLaNavWHuvKtTDIPmJsUemdk=; b=CLo1lUIUsiNvCpq9BgXZll0Q7QePH8QKNx4jd9MJomEQ3U5Tbl8anYsXL9ne9QopLf6/jN bDurQ+4TFH7jrL+3KbvS3PfGvvrFX/Rohk7R7hPBMcn+HnavXjwtJAdgUze1xFg2MKuEUa 0ZMcIL6w+8alLOHzcA4aF2Ma/Fb3oPbWXypELq/KK+f/pVphFNuH6pq8xFvSdDg8E+Q82m EPdzIU0vR9iwJpHxv3eUCTDxVN4HfKwpW4oQMrw072L1s3GqXHQGoRrjxwjVbv7ojIJA2H yrxakjbYBxKq6UwbMelKuN7gZzgDKlCEiYpof2XQxvko/u8SUKSx/6Ib9D90kw== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:05 +0100 Subject: [PATCH RFC v2 01/18] drm/vkms: Extract vkms_config header MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-1-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=8173; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=taBxjKE927SBRvVW38khWBgHEz1/XX80j/rtAWPpCuQ=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1MDnNrWxVEv6/B3PvsG0UOgenKVPTiTTKHb l3BE549KamJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TAAKCRAgrS7GWxAs 4tmJD/4t/4nVKMaZyL/1YsSkLQdb4ddgbJLBu4s+r3TC4oj1OfFDXw55/2rQ211DTE40zUK/f+U FpCuZXL3Wj9wVDRLK455mXHVNyugRUFc2OzpHCOpK8lZ1EExYTPMi441qoLycbp2Ggosm1e1EEH 5h3HOqBNzMn0U9d3VsiUhLmg644Ay3jxi1reAvr1q4XmgSqjWgZUequbZ5ZBubUOTQRtihe5T2j 8CfZrAZVAXX8xIEOQ82x9hLVb2AkQoRJwXvegcmY6BIKZikelPyPhUPOfxsWwLFId0drtLU1szH lhRUYkVV0yHpqkCf+i5zFLggb9Zz0fn0tav2dz2JtEkyytJmAZZQYu8bzz33ZvOr/9eF25tfJ0i t/ePUXI52Ta+sayZWlNCt2i3zWOidIe0Hp9aP81pbDBdGHTrPlZIPRXyGBqEKUMSAa8p+QLslGv dPz7sBIFZGH4CNskYH3WrJfKRFKiio6D7hqFH3C4RjBq/1oGrgA1fvb0p1cpoeqv4E3qmKoKmoI pa/kTZIsqsvKsmVMT178+XH6YqDKhAjeIJ85ZmChC/JQclZ9q7ppEWJuKHKzUwRfRv9dOdwDPKh oPe19qbpzwrty+OzYGlEGWp3Hgg6tz8wGB0iix7IvRlNcYiTLyHpGB/5rvcLrlXkWWg0d22WuYo alcCAdqoTp4dAnw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" Creating a new vkms_config structure will be more complex once we start adding more options. Extract the vkms_config structure to its own header and source files and add functions to create and delete a vkms_config and to initialize debugfs. Refactor, no functional changes. Signed-off-by: Louis Chauvet [Changes: Cherry picked and conflict solve] Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/Makefile | 3 ++- drivers/gpu/drm/vkms/vkms_config.c | 48 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 32 +++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_drv.c | 41 +++++++++----------------------- drivers/gpu/drm/vkms/vkms_drv.h | 15 +----------- drivers/gpu/drm/vkms/vkms_output.c | 1 + 6 files changed, 95 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index 8d3e46dde6350558a0aab4254df0dfe863f9c6ce..2b6db5870b977f6e5013982af89a48aec6c11983 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -6,7 +6,8 @@ vkms-y := \ vkms_formats.o \ vkms_crtc.o \ vkms_composer.o \ - vkms_writeback.o + vkms_writeback.o \ + vkms_config.o obj-$(CONFIG_DRM_VKMS) += vkms.o obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += tests/ diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c new file mode 100644 index 0000000000000000000000000000000000000000..76355174a6ca54b880218c2bd458c8339a3dabaa --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include + +#include "vkms_config.h" +#include "vkms_drv.h" + +struct vkms_config *vkms_config_create(void) +{ + struct vkms_config *config; + + config = kzalloc(sizeof(*config), GFP_KERNEL); + if (!config) + return ERR_PTR(-ENOMEM); + + return config; +} +EXPORT_SYMBOL_IF_KUNIT(vkms_config_create); + +void vkms_config_destroy(struct vkms_config *config) +{ + kfree(config); +} +EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy); + +static int vkms_config_show(struct seq_file *m, void *data) +{ + struct drm_debugfs_entry *entry = m->private; + struct drm_device *dev = entry->dev; + struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); + + seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); + seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor); + seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay); + + return 0; +} + +static const struct drm_debugfs_info vkms_config_debugfs_list[] = { + { "vkms_config", vkms_config_show, 0 }, +}; + +void vkms_config_register_debugfs(struct vkms_device *vkms_device) +{ + drm_debugfs_add_files(&vkms_device->drm, vkms_config_debugfs_list, + ARRAY_SIZE(vkms_config_debugfs_list)); +} diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h new file mode 100644 index 0000000000000000000000000000000000000000..b284831738743f6d7c452be03f917a7d3975d173 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_CONFIG_H +#define _VKMS_CONFIG_H + +#include +#include "vkms_drv.h" + +/** + * struct vkms_config - General configuration for VKMS driver + * + * @writeback: If true, a writeback buffer can be attached to the CRTC + * @cursor: If true, a cursor plane is created in the VKMS device + * @overlay: If true, NUM_OVERLAY_PLANES will be created for the VKMS device + * @dev: Used to store the current vkms device. Only set when the device is instancied. + */ +struct vkms_config { + bool writeback; + bool cursor; + bool overlay; + struct vkms_device *dev; +}; + +/** + * vkms_config_register_debugfs() - Register the debugfs file to display current configuration + */ +void vkms_config_register_debugfs(struct vkms_device *vkms_device); + +struct vkms_config *vkms_config_create(void); +void vkms_config_destroy(struct vkms_config *config); + +#endif //_VKMS_CONFIG_H diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index c54504e590a18ae8af07cc1cc48179c38c4e6c0f..e399566a5b5d6a6cf92a41c72910e857fc4e743f 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -28,6 +28,7 @@ #include #include "vkms_drv.h" +#include "vkms_config.h" #include #include @@ -82,22 +83,6 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) drm_atomic_helper_cleanup_planes(dev, old_state); } -static int vkms_config_show(struct seq_file *m, void *data) -{ - struct drm_debugfs_entry *entry = m->private; - struct drm_device *dev = entry->dev; - struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); - - seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); - seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor); - seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay); - - return 0; -} - -static const struct drm_debugfs_info vkms_config_debugfs_list[] = { - { "vkms_config", vkms_config_show, 0 }, -}; static const struct drm_driver vkms_driver = { .driver_features = DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM, @@ -210,8 +195,7 @@ static int vkms_create(struct vkms_config *config) if (ret) goto out_devres; - drm_debugfs_add_files(&vkms_device->drm, vkms_config_debugfs_list, - ARRAY_SIZE(vkms_config_debugfs_list)); + vkms_config_register_debugfs(vkms_device); ret = drm_dev_register(&vkms_device->drm, 0); if (ret) @@ -231,21 +215,18 @@ static int vkms_create(struct vkms_config *config) static int __init vkms_init(void) { int ret; - struct vkms_config *config; - - config = kmalloc(sizeof(*config), GFP_KERNEL); - if (!config) - return -ENOMEM; - default_config = config; + default_config = vkms_config_create(); + if (IS_ERR(default_config)) + return PTR_ERR(default_config); - config->cursor = enable_cursor; - config->writeback = enable_writeback; - config->overlay = enable_overlay; + default_config->cursor = enable_cursor; + default_config->writeback = enable_writeback; + default_config->overlay = enable_overlay; - ret = vkms_create(config); + ret = vkms_create(default_config); if (ret) - kfree(config); + vkms_config_destroy(default_config); return ret; } @@ -274,7 +255,7 @@ static void __exit vkms_exit(void) if (default_config->dev) vkms_destroy(default_config); - kfree(default_config); + vkms_config_destroy(default_config); } module_init(vkms_init); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index ddb6bf94514d9364521ff7c38a04d9aa69fc09dc..6dde780d0515394faf2a4763f9bb7447a28d1472 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -212,20 +212,7 @@ struct vkms_crtc { spinlock_t composer_lock; }; -/** - * struct vkms_config - General configuration for VKMS driver - * - * @writeback: If true, a writeback buffer can be attached to the CRTC - * @cursor: If true, a cursor plane is created in the VKMS device - * @overlay: If true, NUM_OVERLAY_PLANES will be created for the VKMS device - * @dev: Used to store the current VKMS device. Only set when the device is instantiated. - */ -struct vkms_config { - bool writeback; - bool cursor; - bool overlay; - struct vkms_device *dev; -}; +struct vkms_config; /** * struct vkms_device - Description of a VKMS device diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 1c6d41856e317eb7b9b79f56fdf7473d0a339250..34b6e761bce8a1f2153e1e47c795bad1a52a3454 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ #include "vkms_drv.h" +#include "vkms_config.h" #include #include #include From patchwork Fri Nov 22 17:20:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883427 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 F327AE69183 for ; Fri, 22 Nov 2024 17:20:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EEC1B10EC1F; Fri, 22 Nov 2024 17:20:24 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="i2yKyxRN"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A5A710EC1D for ; Fri, 22 Nov 2024 17:20:23 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 363CF1C0008; Fri, 22 Nov 2024 17:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LVbsawSCI+cNQQUSUvFQ3M/hXSyx3BQzl3u4EwEAYsM=; b=i2yKyxRNkA8zlgpt4Vx9R5HYP124E8d8qOwRY9DJj3oX4TBsdPQOQWuM5SZTtBEpVKWXCR DN5MAFz+KUCJM/mim1hb2C5EwABjyiy2mHwIaJlQd3BjAQURiJUGmilHnZxv1plyhG8qQD YmPwDPRolcBpaTwFvooSPrfCNSiNyxZjO78MyyOJaOstJRFFsgIvzoTwRJWy+YH1dx4Q2E 7ZHUFHokQWEQ1dvWuB7uobKoiK0cmw/Ghxypc76fJq1NvGL7FImUppPRKcGBYkAKMMGJ8T oyN1oVAkwNhvQSrBTZGvZqbx1K/EkLWWpC1MIWKD3VbcuQnJwrJBQX+yer2ZuQ== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:06 +0100 Subject: [PATCH RFC v2 02/18] drm/vkms: Add a validation function for vkms configuration MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-2-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1917; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=O3J5NrNzQvmEMPf1LtkrT4Rjj+8JjoV8IYUZ6CL3lbA=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1MnCxUSxlqHgS2+RV+OlFmTNtbD4x5DjcG2 CHAzu9HNz2JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TAAKCRAgrS7GWxAs 4sIcD/47MVc2OXG42yiTwonKS1y4FWPhPH2tqUeYs6tc9adNIDB6yxBSOAk3okR6Y351kiT6ftx ILcIrn0nsd1/LwCPusB6srTwSwR89iubAlka4IAkhkpSy3xYKYgB0H5vvkbjaPLcu0Ld3IQkr1E hQRakfEXiFWZxioqcOfxKnbxYzCc1jrS170TPwbFrCCFIGSKSHNAftA4TsD2n1kQCUt6qCoucKT jAGC8Xoi95FFJLeRzbuVJaWd3xG8SXco38vJ3JOieYkCKV/66F/ictu8m7GwYEv9LiC+LRSvIQy VPLTGX3ilRRkvhYjmpjFVfas3fHTV7jr6pGRQ+Id6x7VYOGlV3pQyCtbXybMHQkietb0HAJyU12 2hazC5R7qKzbVIUGAqtxAdbn517gSGvjGpmJ4yDzphT++4pVx8QjRsCKu+yiX5Ldtyjfyo7SwP8 OVnfBnNimOH1tvskjVpvnYVNpfVNiID6J8jPb79C0ll77mnnHcBb13o7Blj/zzP2BNc1uH8A9W3 FEVfJCQzW3hVRyLf3BDJolPGsok7bmS5VDu6RmdvzrjFIE8xGGEGNJzknAMotqoPgnqW4vFQUGk R23l8PqO/uF3F8TKmSUJtg7I4iFIjQxTDsk1WBoSKe+buaesLy9F2vFaGxjon4e28NWJ+C9QlIb Zuggc+RP2dS4Osg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" As the configuration will be used by userspace, add a validator to avoid creating a broken DRM device Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 6 ++++++ drivers/gpu/drm/vkms/vkms_config.h | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 76355174a6ca54b880218c2bd458c8339a3dabaa..8d5c1429e6e196ef46c95c6ae73330bc4be2be39 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -24,6 +24,12 @@ void vkms_config_destroy(struct vkms_config *config) } EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy); +bool vkms_config_is_valid(struct vkms_config *config) +{ + return true; +} +EXPORT_SYMBOL_IF_KUNIT(vkms_config_is_valid); + static int vkms_config_show(struct seq_file *m, void *data) { struct drm_debugfs_entry *entry = m->private; diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index b284831738743f6d7c452be03f917a7d3975d173..df571dd67352ca90fb47bd937fb9f11ceb95fcb2 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -29,4 +29,17 @@ void vkms_config_register_debugfs(struct vkms_device *vkms_device); struct vkms_config *vkms_config_create(void); void vkms_config_destroy(struct vkms_config *config); +/** + * vkms_config_is_valid() - Validate a configuration + * + * Check if all the property defined in the configuration are valids. This will return false for + * example if: + * - no or many primary planes are present; + * - the default rotation of a plane is not in its supported rotation; + * - a CRTC don't have any encoder... + * + * @vkms_config: Configuration to validate + */ +bool vkms_config_is_valid(struct vkms_config *vkms_config); + #endif //_VKMS_CONFIG_H From patchwork Fri Nov 22 17:20:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883428 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 A5ED5E69186 for ; Fri, 22 Nov 2024 17:20:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E13C410EC22; Fri, 22 Nov 2024 17:20:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="J8hPHHv2"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9116010EC1D for ; Fri, 22 Nov 2024 17:20:24 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 332ED1C0005; Fri, 22 Nov 2024 17:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5kG/+pvZVQrU54fb/iIcp/sowdPerCbadurT9JrGjEo=; b=J8hPHHv2KTgD7At/9PW72EHy4W2KxuOSmtj2eTV1Cf5iybRvhPB6As7Udif89kHXg2tnnW AY6+O0nWWcEi/VQvlQch9UioozU9uay0G/Fp9BShZP9PUOy2xlNtHplY6e+hXX1tYXoVb5 PIjVQ56YET4iIk1DUTUV5NmXa5FllCWp8Ta8M6CeXL3rmfNgzYlxTk+79bMImyKrGwhy4y pnPot5BhHEpzEzaoMJbwZ2D3bzrAkQpkir8qGUZysfMCVkZIpx8/bGsc0hLke4xuvVXO/B +W6ysNDUWSgskndC5Cgd+KsOFmji5SPHFzJd/M77h5t7/78RGvhsqhWOEmUJWg== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:07 +0100 Subject: [PATCH RFC v2 03/18] drm/vkms: Move default_config creation to its own function MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-3-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3035; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=ojS8il8nmfApHeXNw/AOz9r4p9aUJ0tSXXtnUxcQgW4=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1NHf9ewgg5+0TT9NMoI7EvMuFWOH6t9bBZ4 GjWXMHDefaJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TQAKCRAgrS7GWxAs 4nn3EACYKk2BDQwS+UJ+oGQysxZvh3S/a0zfpQqlmzEfzMMjmL4phgfPTaBIHt1l/8dA6usutdT gZCL2oIaY96KOkO+4plmZNUZ/odVJ7WP63BsZX5JC7rvwMY3hfm4nqW2s5XJS2dd3OV1dl7SZ87 CCQWCwdR8zEUnmSKf5x8q0zm/wzLPdUWFPRg/3TfgH5JzHhoLEgddhPJ1U4WbMUrAJnHQ/cHVlW R6pq2lL3avFpf/4XhU+3rnQujC4p10N9jYVjjF9u8qNVGivQmj6qmJNOZpFEvDTmr//nP+MYKgT p4G8QuyYHSg6DA9sfJFwIn0FW7+XDDRbQoHZxXbqc2H7CXEBb22BT64qkL4QSZtZtGNhtV8MKRi uDXM5Lr9VYffeU55WanN+ujihELTry/jCrye5jJJPC2n7Sh1HrDuV0uYxXa7EOgT4ss5Wt9YSek sg4Cvrjlo1iWuCsLTevppyDH7T+DGVCortj3YHH5LKSDneLVMOrv9MPxe/H/1tmir898k2VpEo/ jOp7B01EvGLTiB0l+aR8HsgO8qGChY71QYEwzJYWjRuq4ZEQnitZ2j7Te2EkqeDZ1Hrjfk2zkTC UGYo4ebImQjQn9ptohD6Au2YIGbdzQVG/bURKJpJd3p1kyOq3Cm3+wAFFpX+v2CiiN90shlmE9t p0hqt3k9iR2p9Fw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" Extract the initialization of the default configuration to a function. Refactor, no functional changes. Signed-off-by: Louis Chauvet [Changes: Cherry pick and solve conflicts] Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_config.c | 16 ++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 9 +++++++++ drivers/gpu/drm/vkms/vkms_drv.c | 7 +------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 8d5c1429e6e196ef46c95c6ae73330bc4be2be39..f7e0d39952ac73ea49c710b49becd391b5aaa66a 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -18,6 +18,22 @@ struct vkms_config *vkms_config_create(void) } EXPORT_SYMBOL_IF_KUNIT(vkms_config_create); +struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable_overlay, + bool enable_cursor) +{ + struct vkms_config *vkms_config = vkms_config_create(); + + if (IS_ERR(vkms_config)) + return vkms_config; + + vkms_config->writeback = enable_writeback; + vkms_config->overlay = enable_overlay; + vkms_config->cursor = enable_cursor; + + return vkms_config; +} + + void vkms_config_destroy(struct vkms_config *config) { kfree(config); diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index df571dd67352ca90fb47bd937fb9f11ceb95fcb2..2afb795586c6924a46dd4ba777bf22a4f51cddda 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -42,4 +42,13 @@ void vkms_config_destroy(struct vkms_config *config); */ bool vkms_config_is_valid(struct vkms_config *vkms_config); +/** + * vkms_config_alloc_default() - Allocate the configuration for the default device + * @enable_writeback: Enable the writeback connector for this configuration + * @enable_overlay: Create some overlay planes + * @enable_cursor: Create a cursor plane + */ +struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable_overlay, + bool enable_cursor); + #endif //_VKMS_CONFIG_H diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index e399566a5b5d6a6cf92a41c72910e857fc4e743f..61ae2986568093ab0df7174a0a4678a75f9aad0c 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -215,15 +215,10 @@ static int vkms_create(struct vkms_config *config) static int __init vkms_init(void) { int ret; - - default_config = vkms_config_create(); + default_config = vkms_config_alloc_default(enable_writeback, enable_overlay, enable_cursor); if (IS_ERR(default_config)) return PTR_ERR(default_config); - default_config->cursor = enable_cursor; - default_config->writeback = enable_writeback; - default_config->overlay = enable_overlay; - ret = vkms_create(default_config); if (ret) vkms_config_destroy(default_config); From patchwork Fri Nov 22 17:20:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883433 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 CD404E69186 for ; Fri, 22 Nov 2024 17:20:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7303710EC2C; Fri, 22 Nov 2024 17:20:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="HKojbZ1Q"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 889A310EC1D for ; Fri, 22 Nov 2024 17:20:25 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 534081C0009; Fri, 22 Nov 2024 17:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q4uWSFF1vQlPkiCyhhmIJ4bvL4MBs3Z0XPn9PAcZ8WI=; b=HKojbZ1QWf/KnE/6l5Kln+xGjRfARguRCBEvcbCenflKaQnIyuSi4gLXEaPElGIDz8ivTu /uUOYcka7Qwk63bWK8BLuBzKT9zU3oorUuqgpuTFsxWurq0HqksOxCQMUGAMml0mLCA/lV 40vgdbXS8s6Xfmqh44VNy/WUZNTbKT1nj2nfAY6cGbE3H9aPXYcV9Bhd6LogW24sfCmlZ+ ZArDZv7kU9B19nhK1nzQhRlb/XsN5HKOnHGl/eUp0Ip0tX8Jkh8/YT+jaL8odM3WRX/0Gf FqKKhUb24Mkty63UMSiSXgAG4oF8AqylKpw9dPxYaq+K1J6Do8OTQyCSshyS/g== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:08 +0100 Subject: [PATCH RFC v2 04/18] drm/vkms: Introduce config for plane MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-4-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=11425; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=cNXzkUxj+Faqm0VtcsIopVsGtGr/t4fXkIfe0jdPTG8=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1NPkXgElGgSTcZ6zgsxk1g6dkV8UCS6TKg3 J4J0vphTh+JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TQAKCRAgrS7GWxAs 4hbwEAC46bYAA7kpbD9bqUWBUqM290/A6KKNgsuN9SVwO5oelMxfJnYteIVnJviZ5TCLvojTC35 nwYWOpBElI0jAiHoI3dj/zipuaSt8hhysq8k6+lHLp1flcGVPPhIdS8e9Zc+VnNmrNSPGNuqXfq ap5750h6FUZB/JMpA1BaXmvxC4wMRl7WSTjw6E+SKK/JR/KO+FhoAikttoAfhUUZlQ0UQNtnvRN hKH7GvyDbGgr86lyIw7G9FXLBOuzMqT79RjC+9BqvGzkpOPr7nESqd1tHUw2f2hctkROgYJsepv /Z5l7ujq2vJqu9tN1Gx5M4cLAh6mxg6rBr2mv9XQ1Chg4Za0X91nkffy7RpKxVX6rPK9sa+lqMd uOPgh7P6V6ZlmmnhHzCDBz+0+SFLKSgrl9oGZMdNMe4b0rHbA69Uwcn7WutQC9bTg9P4N3G+ce0 pk/lpnsaiDfa4oecNHv/CfwhxhT1RB78QUel6l/93VSXRyauk9jE+IKwgiU/7Zpyh8Z4hsowas/ kCvBeti4epFPeF+eZKSLch35z2HE3F0U7kfNmZ1hCvHZc3z7YfUhh94BQyfAuS08NJMrxqKcizF DmQ5x8fe09vhvKWXguv11stx38aHmdvo1pkdsTOfvjuY4dZKoM71H6w1J/5ALZpUqhBmI4pLUwK xDp3zBXvFTf/scw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" The current vkms driver only allows the usage of one primary, eight overlays and one cursor plane. This new configuration structure aims to make the configuration more flexible. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 91 ++++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_config.h | 43 +++++++++++++++++- drivers/gpu/drm/vkms/vkms_drv.h | 3 +- drivers/gpu/drm/vkms/vkms_output.c | 37 +++++----------- drivers/gpu/drm/vkms/vkms_plane.c | 5 ++- 5 files changed, 144 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index f7e0d39952ac73ea49c710b49becd391b5aaa66a..31981dce2c2ed3ef8fc52e227e301d5f8d5338e6 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -14,6 +14,8 @@ struct vkms_config *vkms_config_create(void) if (!config) return ERR_PTR(-ENOMEM); + INIT_LIST_HEAD(&config->planes); + return config; } EXPORT_SYMBOL_IF_KUNIT(vkms_config_create); @@ -21,27 +23,105 @@ EXPORT_SYMBOL_IF_KUNIT(vkms_config_create); struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable_overlay, bool enable_cursor) { + struct vkms_config_plane *plane; struct vkms_config *vkms_config = vkms_config_create(); if (IS_ERR(vkms_config)) return vkms_config; vkms_config->writeback = enable_writeback; - vkms_config->overlay = enable_overlay; - vkms_config->cursor = enable_cursor; + plane = vkms_config_create_plane(vkms_config); + if (!plane) + goto err_alloc; + + plane->type = DRM_PLANE_TYPE_PRIMARY; + + if (enable_overlay) { + for (int i = 0; i < NUM_OVERLAY_PLANES; i++) { + plane = vkms_config_create_plane(vkms_config); + if (!plane) + goto err_alloc; + plane->type = DRM_PLANE_TYPE_OVERLAY; + } + } + if (enable_cursor) { + plane = vkms_config_create_plane(vkms_config); + if (!plane) + goto err_alloc; + plane->type = DRM_PLANE_TYPE_CURSOR; + } return vkms_config; + +err_alloc: + vkms_config_destroy(vkms_config); + return ERR_PTR(-ENOMEM); } +struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_config) +{ + if (!vkms_config) + return NULL; + + struct vkms_config_plane *vkms_config_overlay = kzalloc(sizeof(*vkms_config), + GFP_KERNEL); + + if (!vkms_config_overlay) + return NULL; + + vkms_config_overlay->type = DRM_PLANE_TYPE_OVERLAY; + + list_add(&vkms_config_overlay->link, &vkms_config->planes); + + return vkms_config_overlay; +} +EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_plane); + +void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_overlay) +{ + if (!vkms_config_overlay) + return; + list_del(&vkms_config_overlay->link); + kfree(vkms_config_overlay); +} void vkms_config_destroy(struct vkms_config *config) { + struct vkms_config_plane *vkms_config_plane, *tmp_plane; + + list_for_each_entry_safe(vkms_config_plane, tmp_plane, &config->planes, link) { + vkms_config_delete_plane(vkms_config_plane); + } + kfree(config); } EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy); bool vkms_config_is_valid(struct vkms_config *config) { + struct vkms_config_plane *config_plane; + + bool has_cursor = false; + bool has_primary = false; + + list_for_each_entry(config_plane, &config->planes, link) { + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { + // Multiple primary planes for only one CRTC + if (has_primary) + return false; + has_primary = true; + } + if (config_plane->type == DRM_PLANE_TYPE_CURSOR) { + // Multiple cursor planes for only one CRTC + if (has_cursor) + return false; + has_cursor = true; + } + } + + if (!has_primary) + return false; + return true; } EXPORT_SYMBOL_IF_KUNIT(vkms_config_is_valid); @@ -51,10 +131,13 @@ static int vkms_config_show(struct seq_file *m, void *data) struct drm_debugfs_entry *entry = m->private; struct drm_device *dev = entry->dev; struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); + struct vkms_config_plane *config_plane; seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); - seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor); - seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay); + list_for_each_entry(config_plane, &vkmsdev->config->planes, link) { + seq_puts(m, "plane:\n"); + seq_printf(m, "\ttype: %d\n", config_plane->type); + } return 0; } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 2afb795586c6924a46dd4ba777bf22a4f51cddda..ac99f1df6d9a17bd7040a1e7a6acce14cd8fd9d0 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -10,8 +10,8 @@ * struct vkms_config - General configuration for VKMS driver * * @writeback: If true, a writeback buffer can be attached to the CRTC - * @cursor: If true, a cursor plane is created in the VKMS device - * @overlay: If true, NUM_OVERLAY_PLANES will be created for the VKMS device + * @planes: List of planes configured for this device. They are created by the function + * vkms_config_create_plane(). * @dev: Used to store the current vkms device. Only set when the device is instancied. */ struct vkms_config { @@ -19,6 +19,27 @@ struct vkms_config { bool cursor; bool overlay; struct vkms_device *dev; + + struct list_head planes; +}; + +/** + * struct vkms_config_plane + * + * @link: Link to the others planes + * @type: Type of the plane. The creator of configuration needs to ensures that at least one + * plane is primary. + * @plane: Internal usage. This pointer should never be considered as valid. It can be used to + * store a temporary reference to a vkms plane during device creation. This pointer is + * not managed by the configuration and must be managed by other means. + */ +struct vkms_config_plane { + struct list_head link; + + enum drm_plane_type type; + + /* Internal usage */ + struct vkms_plane *plane; }; /** @@ -42,6 +63,24 @@ void vkms_config_destroy(struct vkms_config *config); */ bool vkms_config_is_valid(struct vkms_config *vkms_config); +/** + * vkms_config_create_plane() - Create a plane configuration + * + * This will allocate and add a new plane to @vkms_config. This plane will have by default the + * maximum supported values. + * @vkms_config: Configuration where to insert new plane + */ +struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_config); + +/** + * vkms_config_delete_plane() - Remove a plane configuration and frees its memory + * + * This will delete a plane configuration from the parent configuration. This will NOT + * cleanup and frees the vkms_plane that can be stored in @vkms_config_plane. + * @vkms_config_plane: Plane configuration to cleanup + */ +void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_plane); + /** * vkms_config_alloc_default() - Allocate the configuration for the default device * @enable_writeback: Enable the writeback connector for this configuration diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 6dde780d0515394faf2a4763f9bb7447a28d1472..acb0258d1ff18f97bde3630b3d2f3b8fcc511e67 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -213,6 +213,7 @@ struct vkms_crtc { }; struct vkms_config; +struct vkms_config_plane; /** * struct vkms_device - Description of a VKMS device @@ -269,7 +270,7 @@ int vkms_output_init(struct vkms_device *vkmsdev); * @type: type of plane to initialize */ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, - enum drm_plane_type type); + struct vkms_config_plane *config); /* CRC Support */ const char *const *vkms_get_crc_sources(struct drm_crtc *crtc, diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 34b6e761bce8a1f2153e1e47c795bad1a52a3454..20bd39f06f433b5b9cee2b0e4fa2176999ed85aa 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -31,30 +31,14 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { int vkms_output_init(struct vkms_device *vkmsdev) { + struct vkms_config_plane *config_plane; struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector; struct drm_encoder *encoder; struct vkms_crtc *vkms_crtc; - struct vkms_plane *primary, *overlay, *cursor = NULL; + struct vkms_plane *primary, *cursor = NULL; int ret; int writeback; - unsigned int n; - - /* - * Initialize used plane. One primary plane is required to perform the composition. - * - * The overlay and cursor planes are not mandatory, but can be used to perform complex - * composition. - */ - primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY); - if (IS_ERR(primary)) - return PTR_ERR(primary); - - if (vkmsdev->config->cursor) { - cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR); - if (IS_ERR(cursor)) - return PTR_ERR(cursor); - } vkms_crtc = vkms_crtc_init(dev, &primary->base, cursor ? &cursor->base : NULL); @@ -63,15 +47,16 @@ int vkms_output_init(struct vkms_device *vkmsdev) return PTR_ERR(vkms_crtc); } - if (vkmsdev->config->overlay) { - for (n = 0; n < NUM_OVERLAY_PLANES; n++) { - overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY); - if (IS_ERR(overlay)) { - DRM_DEV_ERROR(dev->dev, "Failed to init vkms plane\n"); - return PTR_ERR(overlay); - } - overlay->base.possible_crtcs = drm_crtc_mask(&vkms_crtc->base); + list_for_each_entry(config_plane, &vkmsdev->config->planes, link) { + config_plane->plane = vkms_plane_init(vkmsdev, config_plane); + if (IS_ERR(config_plane->plane)) { + ret = PTR_ERR(config_plane->plane); + return ret; } + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) + primary = config_plane->plane; + else if (config_plane->type == DRM_PLANE_TYPE_CURSOR) + cursor = config_plane->plane; } connector = drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 4ab0fab4dd09f4be14308afb2f52bc6465f6396d..3d742e47e0fcd647225251f53a73b6ac0e669868 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -11,6 +11,7 @@ #include "vkms_drv.h" #include "vkms_formats.h" +#include "vkms_config.h" static const u32 vkms_formats[] = { DRM_FORMAT_ARGB8888, @@ -219,7 +220,7 @@ static const struct drm_plane_helper_funcs vkms_plane_helper_funcs = { }; struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, - enum drm_plane_type type) + struct vkms_config_plane *config) { struct drm_device *dev = &vkmsdev->drm; struct vkms_plane *plane; @@ -227,7 +228,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 0, &vkms_plane_funcs, vkms_formats, ARRAY_SIZE(vkms_formats), - NULL, type, NULL); + NULL, config->type, NULL); if (IS_ERR(plane)) return plane; From patchwork Fri Nov 22 17:20:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883430 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 730C8E69183 for ; Fri, 22 Nov 2024 17:20:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7434810EC28; Fri, 22 Nov 2024 17:20:29 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="PJIxXipF"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 91D6210EC1D for ; Fri, 22 Nov 2024 17:20:26 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4E0C01C000A; Fri, 22 Nov 2024 17:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DA2OGgZp0KRoCQFiGaaZBrzWQDsoZVmLgth29AG0usc=; b=PJIxXipFF/6w6dHdZgfdRK5+QBAPOrnkSQj/AZmDRDEqhzfyv79DvL94ByonUg5T78ZPV5 zuWuGyISyZnuoOYili/yYGKyXHCO+fdOVLfyXNp6EpITKDX6s3ApBFMwlRr4J053jIMCCn FxlqbrNZI7mZ8l/uRioyO3DentWKHnj5Rvaq2EjUso5ULCxzWthDPY5iy+lSpumtGQd4jg OL76V+OBEzJ9EKzakwIhvEr45aGQGhZ9mSlNkpejWumx9JfcTz7VWX/UoZKkyQnT6YYSY7 BLCduqZ8TorUmt59Z1TvTwBD+cybQlfDzNlGMOowVuxPG/kqNaP3KJvNKWFIeQ== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:09 +0100 Subject: [PATCH RFC v2 05/18] drm/vkms: Introduce config for plane name MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-5-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3777; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=0JbmGZogKVTFANqtFMvuPkBSGo83j3o5kPyKHFU6Jm0=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1NnRJhpgQqiMXj5kja+fGJ8xWIB2KZGBC1o IXZq2ecThKJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TQAKCRAgrS7GWxAs 4vkbD/905iuEaC9VXbqglNpgridzRls/TWGXeRPlwOyFZRLFwEho+LzC1+p0FA9wtEXOzgmE3Xp Zl+jdzC3Kb7hCeqKK2Qil8bFEhA7jbpK5VbWuT7tbVdDvQciG3wMlbN4q/55iJjMqPcXG4TBrDc 5wsf0EdO3lovNokIXYioGsE7ZtVgHzAm5wEWDapg8tzwkWcoPWgHAZwo7m/PPcGUIHYkXgSSVpN diK386aZNmOl91EPOv+Sl4v5Q7I5/UmxLVOmF44qgTk2mWbsXAgR3a6tQe8HtH94TLPu/i4IBRy baVY9dznswVv6G53t+91DMLyXgsJoaAEMBfhiUyjUVc9+Qy9/131ZNAn/q+dP+5/niAX/skJl85 9LLtp/pLNRStebVrITmSWcZ6NIGfZtBN0rdf0XiA5wPjn0ju/5JU6ERZ2YC06Te3nz7tKUZZvXb ay2EJc+l5HT0TtWaKe+WTRXu07eRdyxMo0drBbvGn4fBCiuciMinrTMdm6Fk9Sfws34CmXtYEPo rHyk2Ug38amNbdc8Bv9ER092gWubPTQ8Iy9V/PtAer6DCfDr/ztuxmgHfEMahxWW+tfMrqiN9V6 p82DplG3tavKP0RsJOIME35VEkUMU2HdKPjI3VK3LXwbeZRmf9SbA6bOxVVBUS0OBEH4wBpnxMx LP+nIFN9lq7AjOg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" As a plane will be a folder in ConfigFS, add name configuration for plane so it will reflect the folder name. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 14 ++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 2 ++ drivers/gpu/drm/vkms/vkms_plane.c | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 31981dce2c2ed3ef8fc52e227e301d5f8d5338e6..8af7b80d1fea201102f45f8ee49fd88ce26733e3 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -36,6 +36,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable goto err_alloc; plane->type = DRM_PLANE_TYPE_PRIMARY; + plane->name = kzalloc(sizeof("primary"), GFP_KERNEL); + if (!plane->name) + goto err_alloc; + sprintf(plane->name, "primary"); if (enable_overlay) { for (int i = 0; i < NUM_OVERLAY_PLANES; i++) { @@ -43,6 +47,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (!plane) goto err_alloc; plane->type = DRM_PLANE_TYPE_OVERLAY; + plane->name = kzalloc(10, GFP_KERNEL); + if (!plane->name) + goto err_alloc; + snprintf(plane->name, 10, "plane-%d", i); } } if (enable_cursor) { @@ -50,6 +58,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (!plane) goto err_alloc; plane->type = DRM_PLANE_TYPE_CURSOR; + plane->name = kzalloc(sizeof("cursor"), GFP_KERNEL); + if (!plane->name) + goto err_alloc; + sprintf(plane->name, "cursor"); } return vkms_config; @@ -82,6 +94,7 @@ void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_overlay) if (!vkms_config_overlay) return; list_del(&vkms_config_overlay->link); + kfree(vkms_config_overlay->name); kfree(vkms_config_overlay); } @@ -136,6 +149,7 @@ static int vkms_config_show(struct seq_file *m, void *data) seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); list_for_each_entry(config_plane, &vkmsdev->config->planes, link) { seq_puts(m, "plane:\n"); + seq_printf(m, "\tname: %s\n", config_plane->name); seq_printf(m, "\ttype: %d\n", config_plane->type); } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index ac99f1df6d9a17bd7040a1e7a6acce14cd8fd9d0..3e70bce8d4f7b06f44ec79b3a3d8e6897f9a44c7 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -27,6 +27,7 @@ struct vkms_config { * struct vkms_config_plane * * @link: Link to the others planes + * @name: Name of the plane * @type: Type of the plane. The creator of configuration needs to ensures that at least one * plane is primary. * @plane: Internal usage. This pointer should never be considered as valid. It can be used to @@ -36,6 +37,7 @@ struct vkms_config { struct vkms_config_plane { struct list_head link; + char *name; enum drm_plane_type type; /* Internal usage */ diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 3d742e47e0fcd647225251f53a73b6ac0e669868..56725f243382d75668ab2bf23423a69c75cb366b 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -228,7 +228,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 0, &vkms_plane_funcs, vkms_formats, ARRAY_SIZE(vkms_formats), - NULL, config->type, NULL); + NULL, config->type, config->name); if (IS_ERR(plane)) return plane; From patchwork Fri Nov 22 17:20:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883435 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 1E6C5E69185 for ; Fri, 22 Nov 2024 17:20:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72B3910EC2F; Fri, 22 Nov 2024 17:20:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="oC82NXd8"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D44A10EC1D for ; Fri, 22 Nov 2024 17:20:27 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 503FD1C0006; Fri, 22 Nov 2024 17:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pBZIFQD7HtgRakJub3/6eX8TMYjNFlLaLh92/GPSFRs=; b=oC82NXd8veok57UZ19VecTSWSRZP4BKkBAFtrPc4dve27p8h3qRs7AV+2oPY9tz390kOl4 pndXo/eLG2D8UjduIc75b/ugsArB6rWoYcZ4NHFcN+aNGbzfYufEK9PXQ14wXtX8V1lmZ2 omjJM3+VPi7vqAha+Alog/Itcx+mX4gWMGXtelWpxHkvKTsuZkhvHp1JZkzzp9ZmbXjB1p 6whgL1G7VMHKJwSkVgYOaTxTatm91vRxc0BVQBgfTyRIZPOe14gxfiWAhpkCyYh+s0XZHS /T/tAnWk/o1pZrHccN3yK+axoYbaM6AquFrWsBKbgUOr36YHhOgz2WtUNKNQbg== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:10 +0100 Subject: [PATCH RFC v2 06/18] drm/vkms: Introduce config for plane rotation MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-6-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3904; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=ZF8/pyVrcBVVQ61iaXg6JYk5ufRwAGwyVd/mV0bBoCs=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1OIox1qOJnF5YSbYHa9W+bIw7Tk6QtlpHxh E87nh6JKQCJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TgAKCRAgrS7GWxAs 4gUoD/97Pd/OaENfT2DfMoKYzRWUFCrWIUddD5kQKvqldateYfNna3w1ASAdOMK5x/Y/eWv60xf 6QuKAaukCM9j0LA3/B5SeryLJeYSD7D9vHlgwHmJV3naJVgWb2tqwGH4AvSIMI3fKWvzzPmTiTa 44OvKI1G6C0rs6tiioM+sj70JIe3EWiRRtThG8qZjI0Es4DMjlzLjkzqnUvRextI1eRJk9Wr2tb 2z5zZ4bRZozO1mLdCheVxGX504rB7HNjv6v4ozqqf9kuCx9mw6mhdqaqBseJO+Goc+NrSsGd0/z y4SqEFsivw0T9xsoCtl04BiF9vlE4HOh/QUWZZVHh3xlvgLf1++hSQZLq6G3AXLkvK7JdTDUY3n 9xfHdAwQb6cAsIWSpebwoKlhZwujTdmncLkRshm9viTuAQvmvbnEN3UVFbADksuWhkq4U9cYZWo +NK6Mm8g59o6+FFLu7thyRPL8jfQ2lmWns8/leKIjRAHlvJMQlVlqQVuTyJcAIHLmxQ3zM+1lT5 RccJjr+aCN/ga2EWSNnFQ2MlhrbBmuic8UnxBaVgYj0WauONFOCVJBJn9mJuZFI9gt272jAvbme Rrzq5yxcoJWP92Bf9vOiSzPeeYB8SSZqHAY0QsgBvaXXp8EqjeSVAuF5VRS8HQKnYWTszLEcyJS vRJqb8V2PgECAjQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" VKMS driver supports all the rotation on planes, but for testing it can be useful to only advertise few of them. This new configuration interface will allow configuring the rotation per planes. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 9 +++++++++ drivers/gpu/drm/vkms/vkms_config.h | 4 ++++ drivers/gpu/drm/vkms/vkms_plane.c | 5 +++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 8af7b80d1fea201102f45f8ee49fd88ce26733e3..6a2e5f0c580a348effc12b474a7f87dcd4e36642 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -82,6 +82,8 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf return NULL; vkms_config_overlay->type = DRM_PLANE_TYPE_OVERLAY; + vkms_config_overlay->supported_rotations = DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK; + vkms_config_overlay->default_rotation = DRM_MODE_ROTATE_0; list_add(&vkms_config_overlay->link, &vkms_config->planes); @@ -118,6 +120,11 @@ bool vkms_config_is_valid(struct vkms_config *config) bool has_primary = false; list_for_each_entry(config_plane, &config->planes, link) { + // Default rotation not in supported rotations + if ((config_plane->default_rotation & config_plane->supported_rotations) != + config_plane->default_rotation) + return false; + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { // Multiple primary planes for only one CRTC if (has_primary) @@ -151,6 +158,8 @@ static int vkms_config_show(struct seq_file *m, void *data) seq_puts(m, "plane:\n"); seq_printf(m, "\tname: %s\n", config_plane->name); seq_printf(m, "\ttype: %d\n", config_plane->type); + seq_printf(m, "\tsupported rotations: 0x%x\n", config_plane->supported_rotations); + seq_printf(m, "\tdefault rotation: 0x%x\n", config_plane->default_rotation); } return 0; diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 3e70bce8d4f7b06f44ec79b3a3d8e6897f9a44c7..fd5e0df11647f145d53e71a1b6a244951af3ec0d 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -30,6 +30,8 @@ struct vkms_config { * @name: Name of the plane * @type: Type of the plane. The creator of configuration needs to ensures that at least one * plane is primary. + * @default_rotation: Default rotation that should be used by this plane + * @supported_rotation: Rotation that this plane will support * @plane: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms plane during device creation. This pointer is * not managed by the configuration and must be managed by other means. @@ -39,6 +41,8 @@ struct vkms_config_plane { char *name; enum drm_plane_type type; + unsigned int default_rotation; + unsigned int supported_rotations; /* Internal usage */ struct vkms_plane *plane; diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 56725f243382d75668ab2bf23423a69c75cb366b..306af498543cbc39b8af3e5b5879f8b3972d5a4a 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -234,8 +234,9 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, drm_plane_helper_add(&plane->base, &vkms_plane_helper_funcs); - drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, - DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK); + drm_plane_create_rotation_property(&plane->base, + config->default_rotation, + config->supported_rotations); drm_plane_create_color_properties(&plane->base, BIT(DRM_COLOR_YCBCR_BT601) | From patchwork Fri Nov 22 17:20:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883436 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 DC778E69187 for ; Fri, 22 Nov 2024 17:20:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A6D4910EC31; Fri, 22 Nov 2024 17:20:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="oMtAb9H/"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 908AE10EC28 for ; Fri, 22 Nov 2024 17:20:28 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4F2E61C0004; Fri, 22 Nov 2024 17:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ktawcOolQxrYmPaqwiDnraP2XPOZ45oKEBQAwhE213s=; b=oMtAb9H/2mSXg4pB/kN/CZe1IBf0mJQ2Y9rBPOMS1odtIZac57aixaETv1P7HBdetsX6Mr FxJqxi+y4FQdwzB6SYaurDM2w0AoIKk1FnG6okiXkVuuxNT9fb0sW9SGyMDDGq9XFbgJiE TER3Mg74kpJYBa8WOvVPm+/nb8Hh328iDymbXov5Ly2wakjkD0tnxOxHiow2tfmDZVFJlo CAF9qPTjvo9cl2yclVINnQcpmq3LMS94Tvcarb8M7ICyuK21/tTDdcE50x/53Xvs7Aqu5c i+zePwCXNBVIl285/lKvNPzPd/7+FmKlAQgyL3rCsFdwPPuL4MvbxdJjwV5x5A== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:11 +0100 Subject: [PATCH RFC v2 07/18] drm/vkms: Introduce config for plane color encoding MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-7-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4434; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=BF0yRjAMyDjPU9RolEhuXzgfCND9f1KlhkLeU6VUXIA=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1OpfzvGPhi5nbgVTIP6JnGt047EF7mfamOi pxenGUuXs6JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TgAKCRAgrS7GWxAs 4jn3D/9XTXmzSLdEBdnwiOtk+vlzWX4GjMEwjVySVgf6P1aTfE14F2h3zwVSfpEySyzf8oqZkwf dnPI6vWOo27Wgcr7d71tRugyArDcMAH5BA00ZrjvrhgG2ucssqDjdABMFZGKeHK9tfA4AmBFiQn bx7fHjyc4VUoCrr7SIMefcSY45kw2Z7smbAnqawcaISuEG4eofR895J3ONpQy1J7tMSYEG9RKJW 5HdJvtnY+50HEhApspf6OxGjaf+q/DjRigUVRxC3R1B+FzHYbEkOiVhfDMRmvZAfWTnIK8wTVJA 5hH3irC8CH/+RCSzl8L0uryzzGnLpw5npMQGIXeW/SMSeB4/in+ZiOF/Nf1vsHFSOvgL8DSx1oN UFOIUn77SOup0RscPxmScSAzSHJxaq5t2DYZuNcGvRsalP2hbgnt/DM1OOiTQhdxvbej/6AX5Qp k+YclDnR9D4zU6kVEa+CHhUffz7/zaWXV79WJwzCK7AjTcWV1ltJYy6DubrcpRJ4LQFudvg5nF1 aIonJ4z+RkhZOmYLeB22TUDLS7bYyGzsY9FYn9VmPpOIxRwB4qaZ1sj2JYs69pDI0BXo+i4Zv9k ljR6Bp6QLGksigmtAwkoIVO3q5nQR22c8BgkF/EpdF3fE+Hzw4n2P2sCQJ0Lh+1yjddt3lyKWdE vz9TpuJOfiMeOdQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" VKMS driver supports all the color encoding on planes, but for testing it can be useful to only advertise few of them. This new configuration interface will allow configuring the color encoding per planes. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 15 +++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 4 ++++ drivers/gpu/drm/vkms/vkms_plane.c | 6 ++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 6a2e5f0c580a348effc12b474a7f87dcd4e36642..9f9ebe674f6cbe03ac15e5380e4584c40a8bdea7 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -84,6 +84,11 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf vkms_config_overlay->type = DRM_PLANE_TYPE_OVERLAY; vkms_config_overlay->supported_rotations = DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK; vkms_config_overlay->default_rotation = DRM_MODE_ROTATE_0; + vkms_config_overlay->supported_color_encoding = BIT(DRM_COLOR_YCBCR_BT601) | + BIT(DRM_COLOR_YCBCR_BT709) | + BIT(DRM_COLOR_YCBCR_BT2020); + vkms_config_overlay->default_color_encoding = DRM_COLOR_YCBCR_BT601; + list_add(&vkms_config_overlay->link, &vkms_config->planes); @@ -125,6 +130,12 @@ bool vkms_config_is_valid(struct vkms_config *config) config_plane->default_rotation) return false; + // Default color range not in supported color range + if ((BIT(config_plane->default_color_encoding) & + config_plane->supported_color_encoding) != + BIT(config_plane->default_color_encoding)) + return false; + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { // Multiple primary planes for only one CRTC if (has_primary) @@ -160,6 +171,10 @@ static int vkms_config_show(struct seq_file *m, void *data) seq_printf(m, "\ttype: %d\n", config_plane->type); seq_printf(m, "\tsupported rotations: 0x%x\n", config_plane->supported_rotations); seq_printf(m, "\tdefault rotation: 0x%x\n", config_plane->default_rotation); + seq_printf(m, "\tsupported color encoding: 0x%x\n", + config_plane->supported_color_encoding); + seq_printf(m, "\tdefault color encoding: %d\n", + config_plane->default_color_encoding); } return 0; diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index fd5e0df11647f145d53e71a1b6a244951af3ec0d..6cc9b89a996fe26c04951981cfeff7b603c6aec4 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -32,6 +32,8 @@ struct vkms_config { * plane is primary. * @default_rotation: Default rotation that should be used by this plane * @supported_rotation: Rotation that this plane will support + * @default_color_encoding: Default color encoding that should be used by this plane + * @supported_color_encoding: Color encoding that this plane will support * @plane: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms plane during device creation. This pointer is * not managed by the configuration and must be managed by other means. @@ -43,6 +45,8 @@ struct vkms_config_plane { enum drm_plane_type type; unsigned int default_rotation; unsigned int supported_rotations; + enum drm_color_encoding default_color_encoding; + unsigned int supported_color_encoding; /* Internal usage */ struct vkms_plane *plane; diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 306af498543cbc39b8af3e5b5879f8b3972d5a4a..77704ee2d49d2ce1551f67cab6308dc69b329ef5 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -239,12 +239,10 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, config->supported_rotations); drm_plane_create_color_properties(&plane->base, - BIT(DRM_COLOR_YCBCR_BT601) | - BIT(DRM_COLOR_YCBCR_BT709) | - BIT(DRM_COLOR_YCBCR_BT2020), + config->supported_color_encoding, BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | BIT(DRM_COLOR_YCBCR_FULL_RANGE), - DRM_COLOR_YCBCR_BT601, + config->default_color_encoding, DRM_COLOR_YCBCR_FULL_RANGE); return plane; From patchwork Fri Nov 22 17:20:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883437 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 0B800E69186 for ; Fri, 22 Nov 2024 17:20:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 10F9310EC32; Fri, 22 Nov 2024 17:20:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="AZUhZny4"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8BF9610EC24 for ; Fri, 22 Nov 2024 17:20:29 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 550261C000B; Fri, 22 Nov 2024 17:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vJr0LT76hVInGCIa9UWQbQfIc6LUdemP9ljHnk7QCkU=; b=AZUhZny4jPoj+5MTy54eQhOyaX8FaIyBuBS88dbCqqppKp/TT5WbUDeDAws8pU6BNQeT46 /phxIuNLO8RwcI7lrd5B7l4riah3lsfD5KVZ/ulXbzuEsGVsb9otSx3j1J6snUX6Z5nxpp BenngTC0Wr+9n4zsfUAGqabfa6V57CN5LwyxpkehQkNoY1P9SIX5GU3Yv2huIBlrbjJBp/ w0hQ62UAjsIZVw/tBSYUGYPOHCQT/V4JG8fQWg6ubap/HrRnQPk2K9NVn9iXkWYLZXLbV2 j2DCoUyjw/eVsHMyqChRD4AUziiFnu/pZGOE+3wwGRkD1GpPuNUzZGdK14wFoA== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:12 +0100 Subject: [PATCH RFC v2 08/18] drm/vkms: Introduce config for plane color range MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-8-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4219; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=vs+lZLkIly2HZH9mqvWMTifBJurqNPj2JB/tyPp+AvY=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1OTUSQ5PhPXVMtoa7ZfKmjyShPNxoYUIXg7 HubchCd+6WJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TgAKCRAgrS7GWxAs 4oYlD/9fy7Xf7LdE41hwPzsGn8Td/8TFrxdZRDI4aqSjcV/eO5l60Yn1cvhWV95FCJWgX3eSCpS 1yxWZRy30e7U9ntLfFXWzGlYxXdRIlXPBpAJlvxPmD3HntR8/a5hIZ83oEdoRhqQzyYTNpnF97s 8fgjFYvQblbo6aCOLv3sHahOjKG03XUarsDcYt/7E7N2dEWnpIdXgumaPLnFuwONsiAEx+PWi1b 55J6+8wTqabOB6y5d6baZ9jyiqNudrw9ywa+ixOnMpEPnSGiYI/ZJ79vjZrl5hFyQU1wNC3JnfA UeQrEvyMuGGiwb5SpsB/jmB6YHb94zNVGhDQhrhN0ya1X9m3nmS81z3fiU1wauMVhO8up49088I wi9+b9Ac4CEotIAhvFV73LxcHpZ5lS7pV7BbYZvhUoYQy2CewzC9DkqloyvLhts/jNjntSDheGO NwH7k2DA/Z8sKWCJMBRa1sD3TQrMUFKN6gRUAsb8YJszXxIpCZVnh9mWcZhkIIIaIFmENVp7Yco +is2xCz3jyN4DjhoC3Ds7m+8wCKr3NEiUhmifIqjhJAXve6cCXSMjMBFi4YJ5TYZFKbJmNn4SWt AS1nHzQgOIOwMM4VqAF89cl4Z2cqgcWlnAfJSxGKovmNBg7sMwZCK+xX89ncL4/osMFClzLnkvM T3iWJ54mqcjiqOg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" VKMS driver supports all the color range on planes, but for testing it can be useful to only advertise few of them. This new configuration interface will allow configuring the color range per planes. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 14 +++++++++++++- drivers/gpu/drm/vkms/vkms_config.h | 4 ++++ drivers/gpu/drm/vkms/vkms_plane.c | 5 ++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 9f9ebe674f6cbe03ac15e5380e4584c40a8bdea7..10fef173fba921e9abacb5e6dfd292b396694815 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -88,7 +88,9 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf BIT(DRM_COLOR_YCBCR_BT709) | BIT(DRM_COLOR_YCBCR_BT2020); vkms_config_overlay->default_color_encoding = DRM_COLOR_YCBCR_BT601; - + vkms_config_overlay->supported_color_range = BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | + BIT(DRM_COLOR_YCBCR_FULL_RANGE); + vkms_config_overlay->default_color_range = DRM_COLOR_YCBCR_FULL_RANGE; list_add(&vkms_config_overlay->link, &vkms_config->planes); @@ -136,6 +138,12 @@ bool vkms_config_is_valid(struct vkms_config *config) BIT(config_plane->default_color_encoding)) return false; + // Default color range not in supported color range + if ((BIT(config_plane->default_color_range) & + config_plane->supported_color_range) != + BIT(config_plane->default_color_range)) + return false; + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { // Multiple primary planes for only one CRTC if (has_primary) @@ -175,6 +183,10 @@ static int vkms_config_show(struct seq_file *m, void *data) config_plane->supported_color_encoding); seq_printf(m, "\tdefault color encoding: %d\n", config_plane->default_color_encoding); + seq_printf(m, "\tsupported color range: 0x%x\n", + config_plane->supported_color_range); + seq_printf(m, "\tdefault color range: %d\n", + config_plane->default_color_range); } return 0; diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 6cc9b89a996fe26c04951981cfeff7b603c6aec4..8a58c633f9d4649308ce0c536acfcffb03c0617f 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -34,6 +34,8 @@ struct vkms_config { * @supported_rotation: Rotation that this plane will support * @default_color_encoding: Default color encoding that should be used by this plane * @supported_color_encoding: Color encoding that this plane will support + * @default_color_range: Default color range that should be used by this plane + * @supported_color_range: Color range that this plane will support * @plane: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms plane during device creation. This pointer is * not managed by the configuration and must be managed by other means. @@ -47,6 +49,8 @@ struct vkms_config_plane { unsigned int supported_rotations; enum drm_color_encoding default_color_encoding; unsigned int supported_color_encoding; + enum drm_color_range default_color_range; + unsigned int supported_color_range; /* Internal usage */ struct vkms_plane *plane; diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 77704ee2d49d2ce1551f67cab6308dc69b329ef5..90a5946481e47ab7cff9b9dc4942720b6bbcbe3f 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -240,10 +240,9 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, drm_plane_create_color_properties(&plane->base, config->supported_color_encoding, - BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | - BIT(DRM_COLOR_YCBCR_FULL_RANGE), + config->supported_color_range, config->default_color_encoding, - DRM_COLOR_YCBCR_FULL_RANGE); + config->default_color_range); return plane; } From patchwork Fri Nov 22 17:20:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883432 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 3E412E69185 for ; Fri, 22 Nov 2024 17:20:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B90D610EC1D; Fri, 22 Nov 2024 17:20:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="cL5HINAw"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B59210EC1D for ; Fri, 22 Nov 2024 17:20:30 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4F5C21C0005; Fri, 22 Nov 2024 17:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296029; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pn8Ka5N87FTKf2xTg6xH+39bGCxFQOZIHXERibjz27Q=; b=cL5HINAw2574tsUjKVNrvVaZg5hJ79aKjN9HZlVpVFLP3oWBdMbJKMrdID/w+e6bEUH00Y KiRileIz4+hziPFC8JvrL+UxWn/NfLuOr0Lqcv2gHRVNVwMR+9M3fY5Pwzo4eDP9pYv/pW qKapEXGZfpS7YE51LhCR7geb2I21QFE4sIt2wJLIVdczvpSxzO4tdZvlwP9YwGJYjCRKnz IN2upXo8042n9JN3FUUN3JHJ1w8JJxoNnLaTC7f0oN/DNHS15E41bK9bf9LSRK8l0C81Qt 8vpmgCEYBO03rsw85PhcGJdMXZcNXVrW4WgOMjpgdnUr8d0bPWuumZ41XmVEcA== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:13 +0100 Subject: [PATCH RFC v2 09/18] drm/vkms: Introduce config for CRTCs and encoders MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-9-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=25066; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=M/Tppt5qAS8MuTrKnQe5+o8gWpEAQYh6kupwHqBURqc=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1Pg0yzCXCBTjMyO3LP3J5NlI7bvPIxDbUXL FqF/0bT3miJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TwAKCRAgrS7GWxAs 4hJ7D/42BmHAsKRvMnh14rw/tcUq20j/Z8/oZzl1MBLxXgOJctYUSPLIF74tFsuyUq5u7fle7F3 SeSltAcf4CCUCCLvnWz2GYt6qlhiO6c+aLFVvHh6lXx2AQSt7cfNKKAcynZmqKd5PjMXG29Qese lVxDwF8t+NmIxXjMUpmfjVEmUon2/QI0P98oKQADJyePE0jmzFJ1OIcPkQB49h46Dgi6KGerI5T msobZXxDCedc9DRQ4TBmo9gmnYVg49uo42PRKJ2zWnuxXEFI7ql/T9uaIF5Asmd2c679bjfSprC Llut1O+o/krPz87yLy3P4A22LTlGCzi60vZbsbXbIcbegXKDfkFadxY5sin9XOb3+n9UwyTnHNv DiW302uIgjFNeiyuTPx5/MSimBgfMaWpCokPe+lbYM6olhnDmVg/DOeqWrZysPJ68HWDhJ+NHsV nEkf3L+b8m14BBVnP1B/oonmJBYJMBFIwUaIMk4JormFjWG5V/LjbB6DDYbdV+fNkCub6df3JC6 O1Y6e7Y/HIgXMO7QVjyFCAqEtCxlMPBJPWOt9LTBqBSe9Z/SK0mudex5zQcDtfSCULak/97dqN6 LcrQOlSLOkLWuENkbfUALUDdOWoHjUcCiaUJdt/N+eAEI+JYB+eHO8LlQSEqntBVqmgAI28Bhao REwXm5zExlC4gIg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" The current VKMS driver can only uses one CRTC and one encoder. This patch introduce in the same time CRTC and encoders as they are tighly linked. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 269 +++++++++++++++++++++++++++++++++---- drivers/gpu/drm/vkms/vkms_config.h | 104 +++++++++++++- drivers/gpu/drm/vkms/vkms_crtc.c | 14 +- drivers/gpu/drm/vkms/vkms_drv.h | 7 +- drivers/gpu/drm/vkms/vkms_output.c | 86 ++++++------ 5 files changed, 405 insertions(+), 75 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 10fef173fba921e9abacb5e6dfd292b396694815..e44ed904cefb97b8b6ab8fc27623e315397e0106 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -15,6 +15,8 @@ struct vkms_config *vkms_config_create(void) return ERR_PTR(-ENOMEM); INIT_LIST_HEAD(&config->planes); + INIT_LIST_HEAD(&config->crtcs); + INIT_LIST_HEAD(&config->encoders); return config; } @@ -24,12 +26,24 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable bool enable_cursor) { struct vkms_config_plane *plane; + struct vkms_config_encoder *encoder; + struct vkms_config_crtc *crtc; struct vkms_config *vkms_config = vkms_config_create(); if (IS_ERR(vkms_config)) return vkms_config; - vkms_config->writeback = enable_writeback; + crtc = vkms_config_create_crtc(vkms_config); + if (!crtc) + goto err_alloc; + crtc->writeback = enable_writeback; + + encoder = vkms_config_create_encoder(vkms_config); + if (!encoder) + goto err_alloc; + + if (vkms_config_encoder_attach_crtc(encoder, crtc)) + goto err_alloc; plane = vkms_config_create_plane(vkms_config); if (!plane) @@ -41,6 +55,9 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable goto err_alloc; sprintf(plane->name, "primary"); + if (vkms_config_plane_attach_crtc(plane, crtc)) + goto err_alloc; + if (enable_overlay) { for (int i = 0; i < NUM_OVERLAY_PLANES; i++) { plane = vkms_config_create_plane(vkms_config); @@ -51,6 +68,9 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (!plane->name) goto err_alloc; snprintf(plane->name, 10, "plane-%d", i); + + if (vkms_config_plane_attach_crtc(plane, crtc)) + goto err_alloc; } } if (enable_cursor) { @@ -62,6 +82,9 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (!plane->name) goto err_alloc; sprintf(plane->name, "cursor"); + + if (vkms_config_plane_attach_crtc(plane, crtc)) + goto err_alloc; } return vkms_config; @@ -91,6 +114,7 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf vkms_config_overlay->supported_color_range = BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | BIT(DRM_COLOR_YCBCR_FULL_RANGE); vkms_config_overlay->default_color_range = DRM_COLOR_YCBCR_FULL_RANGE; + xa_init_flags(&vkms_config_overlay->possible_crtcs, XA_FLAGS_ALLOC); list_add(&vkms_config_overlay->link, &vkms_config->planes); @@ -98,33 +122,195 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf } EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_plane); -void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_overlay) +struct vkms_config_crtc *vkms_config_create_crtc(struct vkms_config *vkms_config) { - if (!vkms_config_overlay) + if (!vkms_config) + return NULL; + + struct vkms_config_crtc *vkms_config_crtc = kzalloc(sizeof(*vkms_config_crtc), + GFP_KERNEL); + + if (!vkms_config_crtc) + return NULL; + + list_add(&vkms_config_crtc->link, &vkms_config->crtcs); + xa_init_flags(&vkms_config_crtc->possible_planes, XA_FLAGS_ALLOC); + xa_init_flags(&vkms_config_crtc->possible_encoders, XA_FLAGS_ALLOC); + + return vkms_config_crtc; +} +EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_crtc); + +struct vkms_config_encoder *vkms_config_create_encoder(struct vkms_config *vkms_config) +{ + if (!vkms_config) + return NULL; + + struct vkms_config_encoder *vkms_config_encoder = kzalloc(sizeof(*vkms_config_encoder), + GFP_KERNEL); + + if (!vkms_config_encoder) + return NULL; + + list_add(&vkms_config_encoder->link, &vkms_config->encoders); + xa_init_flags(&vkms_config_encoder->possible_crtcs, XA_FLAGS_ALLOC); + + return vkms_config_encoder; +} +EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_encoder); + +void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_plane, + struct vkms_config *vkms_config) +{ + struct vkms_config_crtc *crtc_config; + struct vkms_config_plane *plane; + + if (!vkms_config_plane) + return; + list_del(&vkms_config_plane->link); + xa_destroy(&vkms_config_plane->possible_crtcs); + + list_for_each_entry(crtc_config, &vkms_config->crtcs, link) { + unsigned long idx = 0; + + xa_for_each(&crtc_config->possible_planes, idx, plane) { + if (plane == vkms_config_plane) + xa_erase(&crtc_config->possible_planes, idx); + } + } + + kfree(vkms_config_plane->name); + kfree(vkms_config_plane); +} +EXPORT_SYMBOL_IF_KUNIT(vkms_config_delete_plane); + +void vkms_config_delete_crtc(struct vkms_config_crtc *vkms_config_crtc, + struct vkms_config *vkms_config) +{ + struct vkms_config_crtc *crtc_config; + struct vkms_config_plane *plane_config; + struct vkms_config_encoder *encoder_config; + + if (!vkms_config_crtc) + return; + list_del(&vkms_config_crtc->link); + xa_destroy(&vkms_config_crtc->possible_planes); + xa_destroy(&vkms_config_crtc->possible_encoders); + + list_for_each_entry(plane_config, &vkms_config->planes, link) { + unsigned long idx = 0; + + xa_for_each(&plane_config->possible_crtcs, idx, crtc_config) { + if (crtc_config == vkms_config_crtc) + xa_erase(&plane_config->possible_crtcs, idx); + } + } + + list_for_each_entry(encoder_config, &vkms_config->encoders, link) { + unsigned long idx = 0; + + xa_for_each(&encoder_config->possible_crtcs, idx, crtc_config) { + if (crtc_config == vkms_config_crtc) + xa_erase(&encoder_config->possible_crtcs, idx); + } + } + + kfree(vkms_config_crtc); +} + +void vkms_config_delete_encoder(struct vkms_config_encoder *vkms_config_encoder, + struct vkms_config *vkms_config) +{ + if (!vkms_config_encoder) return; - list_del(&vkms_config_overlay->link); - kfree(vkms_config_overlay->name); - kfree(vkms_config_overlay); + list_del(&vkms_config_encoder->link); + xa_destroy(&vkms_config_encoder->possible_crtcs); + + struct vkms_config_crtc *crtc_config; + struct vkms_config_encoder *encoder; + + list_for_each_entry(crtc_config, &vkms_config->crtcs, link) { + unsigned long idx = 0; + + xa_for_each(&crtc_config->possible_encoders, idx, encoder) { + if (encoder == vkms_config_encoder) + xa_erase(&crtc_config->possible_encoders, idx); + } + } + + kfree(vkms_config_encoder); } void vkms_config_destroy(struct vkms_config *config) { struct vkms_config_plane *vkms_config_plane, *tmp_plane; + struct vkms_config_encoder *vkms_config_encoder, *tmp_encoder; + struct vkms_config_crtc *vkms_config_crtc, *tmp_crtc; list_for_each_entry_safe(vkms_config_plane, tmp_plane, &config->planes, link) { - vkms_config_delete_plane(vkms_config_plane); + vkms_config_delete_plane(vkms_config_plane, config); + } + list_for_each_entry_safe(vkms_config_encoder, tmp_encoder, &config->encoders, link) { + vkms_config_delete_encoder(vkms_config_encoder, config); + } + list_for_each_entry_safe(vkms_config_crtc, tmp_crtc, &config->crtcs, link) { + vkms_config_delete_crtc(vkms_config_crtc, config); } kfree(config); } EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy); +int __must_check vkms_config_plane_attach_crtc(struct vkms_config_plane *vkms_config_plane, + struct vkms_config_crtc *vkms_config_crtc) +{ + u32 crtc_idx, encoder_idx; + int ret; + + ret = xa_alloc(&vkms_config_plane->possible_crtcs, &crtc_idx, vkms_config_crtc, + xa_limit_32b, GFP_KERNEL); + if (ret) + return ret; + + ret = xa_alloc(&vkms_config_crtc->possible_planes, &encoder_idx, vkms_config_plane, + xa_limit_32b, GFP_KERNEL); + if (ret) { + xa_erase(&vkms_config_plane->possible_crtcs, crtc_idx); + return ret; + } + + return ret; +} +EXPORT_SYMBOL_IF_KUNIT(vkms_config_plane_attach_crtc); + +int __must_check vkms_config_encoder_attach_crtc(struct vkms_config_encoder *vkms_config_encoder, + struct vkms_config_crtc *vkms_config_crtc) +{ + u32 crtc_idx, encoder_idx; + int ret; + + ret = xa_alloc(&vkms_config_encoder->possible_crtcs, &crtc_idx, vkms_config_crtc, + xa_limit_32b, GFP_KERNEL); + if (ret) + return ret; + + ret = xa_alloc(&vkms_config_crtc->possible_encoders, &encoder_idx, vkms_config_encoder, + xa_limit_32b, GFP_KERNEL); + if (ret) { + xa_erase(&vkms_config_encoder->possible_crtcs, crtc_idx); + return ret; + } + + return ret; +} +EXPORT_SYMBOL_IF_KUNIT(vkms_config_encoder_attach_crtc); + bool vkms_config_is_valid(struct vkms_config *config) { struct vkms_config_plane *config_plane; - bool has_cursor = false; - bool has_primary = false; + struct vkms_config_crtc *config_crtc; + struct vkms_config_encoder *config_encoder; list_for_each_entry(config_plane, &config->planes, link) { // Default rotation not in supported rotations @@ -144,22 +330,47 @@ bool vkms_config_is_valid(struct vkms_config *config) BIT(config_plane->default_color_range)) return false; - if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { - // Multiple primary planes for only one CRTC - if (has_primary) - return false; - has_primary = true; - } - if (config_plane->type == DRM_PLANE_TYPE_CURSOR) { - // Multiple cursor planes for only one CRTC - if (has_cursor) - return false; - has_cursor = true; - } + // No CRTC linked to this plane + if (xa_empty(&config_plane->possible_crtcs)) + return false; + } + + list_for_each_entry(config_encoder, &config->encoders, link) { + // No CRTC linked to this encoder + if (xa_empty(&config_encoder->possible_crtcs)) + return false; } - if (!has_primary) - return false; + list_for_each_entry(config_crtc, &config->crtcs, link) { + bool has_primary = false; + bool has_cursor = false; + unsigned long idx = 0; + + // No encoder attached to this CRTC + if (xa_empty(&config_crtc->possible_encoders)) + return false; + + xa_for_each(&config_crtc->possible_planes, idx, config_plane) { + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { + // Multiple primary planes for only one CRTC + if (has_primary) + return false; + + has_primary = true; + } + if (config_plane->type == DRM_PLANE_TYPE_CURSOR) { + // Multiple cursor planes for only one CRTC + if (has_cursor) + return false; + + has_cursor = true; + } + } + + // No primary plane for this CRTC + if (!has_primary) + return false; + } return true; } @@ -171,8 +382,9 @@ static int vkms_config_show(struct seq_file *m, void *data) struct drm_device *dev = entry->dev; struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); struct vkms_config_plane *config_plane; + struct vkms_config_crtc *config_crtc; + struct vkms_config_encoder *config_encoder; - seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); list_for_each_entry(config_plane, &vkmsdev->config->planes, link) { seq_puts(m, "plane:\n"); seq_printf(m, "\tname: %s\n", config_plane->name); @@ -189,6 +401,15 @@ static int vkms_config_show(struct seq_file *m, void *data) config_plane->default_color_range); } + list_for_each_entry(config_encoder, &vkmsdev->config->encoders, link) { + seq_puts(m, "encoder:\n"); + } + + list_for_each_entry(config_crtc, &vkmsdev->config->crtcs, link) { + seq_puts(m, "crtc:\n"); + seq_printf(m, "\twriteback: %d\n", config_crtc->writeback); + } + return 0; } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 8a58c633f9d4649308ce0c536acfcffb03c0617f..8f247fc09373fb2c8145e83be05c6afec1ffac1c 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -9,18 +9,59 @@ /** * struct vkms_config - General configuration for VKMS driver * - * @writeback: If true, a writeback buffer can be attached to the CRTC * @planes: List of planes configured for this device. They are created by the function * vkms_config_create_plane(). + * @crtcs: List of crtcs configured for this device. They are created by the function + * vkms_config_create_crtc(). + * @encoders: List of encoders configured for this device. They are created by the function + * vkms_config_create_encoder(). * @dev: Used to store the current vkms device. Only set when the device is instancied. */ struct vkms_config { - bool writeback; - bool cursor; - bool overlay; struct vkms_device *dev; struct list_head planes; + struct list_head crtcs; + struct list_head encoders; +}; + +/** + * struct vkms_config_crtc + * + * @link: Link to the others CRTCs + * @possible_planes: List of planes that can be used with this CRTC + * @possible_encoders: List of encoders that can be used with this CRTC + * @crtc: Internal usage. This pointer should never be considered as valid. It can be used to + * store a temporary reference to a vkms crtc during device creation. This pointer is + * not managed by the configuration and must be managed by other means. + */ +struct vkms_config_crtc { + struct list_head link; + + bool writeback; + struct xarray possible_planes; + struct xarray possible_encoders; + + /* Internal usage */ + struct vkms_crtc *crtc; +}; + +/** + * struct vkms_config_encoder + * + * @link: Link to the others encoders + * @possible_crtcs: List of CRTC that can be used with this encoder + * @encoder: Internal usage. This pointer should never be considered as valid. It can be used to + * store a temporary reference to a vkms encoder during device creation. This pointer is + * not managed by the configuration and must be managed by other means. + */ +struct vkms_config_encoder { + struct list_head link; + + struct xarray possible_crtcs; + + /* Internal usage */ + struct drm_encoder *encoder; }; /** @@ -36,6 +77,7 @@ struct vkms_config { * @supported_color_encoding: Color encoding that this plane will support * @default_color_range: Default color range that should be used by this plane * @supported_color_range: Color range that this plane will support + * @possible_crtcs: List of CRTC that can be used with this plane. * @plane: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms plane during device creation. This pointer is * not managed by the configuration and must be managed by other means. @@ -52,6 +94,7 @@ struct vkms_config_plane { enum drm_color_range default_color_range; unsigned int supported_color_range; + struct xarray possible_crtcs; /* Internal usage */ struct vkms_plane *plane; }; @@ -86,14 +129,63 @@ bool vkms_config_is_valid(struct vkms_config *vkms_config); */ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_config); +/** + * vkms_config_create_crtc() - Create a crtc configuration + * + * This will allocate and add a new crtc configuration to @vkms_config. + * @vkms_config: Configuration where to insert new crtc configuration + */ +struct vkms_config_crtc *vkms_config_create_crtc(struct vkms_config *vkms_config); + +/** + * vkms_config_create_encoder() - Create an encoder configuration + * + * This will allocate and add a new encoder configuration to @vkms_config. + * @vkms_config: Configuration where to insert new encoder configuration + */ +struct vkms_config_encoder *vkms_config_create_encoder(struct vkms_config *vkms_config); + +int __must_check vkms_config_plane_attach_crtc(struct vkms_config_plane *vkms_config_plane, + struct vkms_config_crtc *vkms_config_crtc); +int __must_check vkms_config_encoder_attach_crtc(struct vkms_config_encoder *vkms_config_encoder, + struct vkms_config_crtc *vkms_config_crtc); + /** * vkms_config_delete_plane() - Remove a plane configuration and frees its memory * * This will delete a plane configuration from the parent configuration. This will NOT - * cleanup and frees the vkms_plane that can be stored in @vkms_config_plane. + * cleanup and frees the vkms_plane that can be stored in @vkms_config_plane. It will also remove + * any reference to this plane in @vkms_config. + * * @vkms_config_plane: Plane configuration to cleanup + * @vkms_config: Parent configuration + */ +void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_plane, + struct vkms_config *vkms_config); +/** + * vkms_config_delete_crtc() - Remove a CRTC configuration and frees its memory + * + * This will delete a CRTC configuration from the parent configuration. This will NOT + * cleanup and frees the vkms_crtc that can be stored in @vkms_config_crtc. It will also remove + * any reference to this CRTC in @vkms_config. + * + * @vkms_config_crtc: Plane configuration to cleanup + * @vkms_config: Parent configuration + */ +void vkms_config_delete_crtc(struct vkms_config_crtc *vkms_config_crtc, + struct vkms_config *vkms_config); +/** + * vkms_config_delete_encoder() - Remove an encoder configuration and frees its memory + * + * This will delete an encoder configuration from the parent configuration. This will NOT + * cleanup and frees the vkms_encoder that can be stored in @vkms_config_encoder. It will also + * remove any reference to this CRTC in @vkms_config. + * + * @vkms_config_encoder: Plane configuration to cleanup + * @vkms_config: Parent configuration */ -void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_plane); +void vkms_config_delete_encoder(struct vkms_config_encoder *vkms_config_encoder, + struct vkms_config *vkms_config); /** * vkms_config_alloc_default() - Allocate the configuration for the default device diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 7851bcf335b7aa9a95848b3af8900812115b2189..3825fba57c012f84cbe67114e053dcd7fcfa283d 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -9,6 +9,7 @@ #include #include "vkms_drv.h" +#include "vkms_config.h" static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) { @@ -279,9 +280,12 @@ static void vkms_crtc_destroy_workqueue(struct drm_device *dev, destroy_workqueue(vkms_crtc->composer_workq); } -struct vkms_crtc *vkms_crtc_init(struct drm_device *dev, struct drm_plane *primary, - struct drm_plane *cursor) +struct vkms_crtc *vkms_crtc_init(struct vkms_device *vkms_device, + struct drm_plane *primary, + struct drm_plane *cursor, + struct vkms_config_crtc *config) { + struct drm_device *dev = &vkms_device->drm; struct vkms_crtc *vkms_crtc; struct drm_crtc *crtc; int ret; @@ -318,5 +322,11 @@ struct vkms_crtc *vkms_crtc_init(struct drm_device *dev, struct drm_plane *prima if (ret) return ERR_PTR(ret); + if (config->writeback) { + ret = vkms_enable_writeback_connector(vkms_device, vkms_crtc); + if (ret) + return ERR_PTR(ret); + } + return vkms_crtc; } diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index acb0258d1ff18f97bde3630b3d2f3b8fcc511e67..a772bf4168e11730c6ee2e3c79abce3a6351203f 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -214,6 +214,8 @@ struct vkms_crtc { struct vkms_config; struct vkms_config_plane; +struct vkms_config_crtc; +struct vkms_config_encoder; /** * struct vkms_device - Description of a VKMS device @@ -252,9 +254,10 @@ struct vkms_device { * @primary: primary plane to attach to the CRTC * @cursor: plane to attach to the CRTC */ -struct vkms_crtc *vkms_crtc_init(struct drm_device *dev, +struct vkms_crtc *vkms_crtc_init(struct vkms_device *vkms_device, struct drm_plane *primary, - struct drm_plane *cursor); + struct drm_plane *cursor, + struct vkms_config_crtc *config); /** * vkms_output_init() - Initialize all sub-components needed for a VKMS device. diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 20bd39f06f433b5b9cee2b0e4fa2176999ed85aa..03498a20d78dd8a66f9fc66b360c5ea57fc48d88 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -31,21 +31,13 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { int vkms_output_init(struct vkms_device *vkmsdev) { - struct vkms_config_plane *config_plane; + struct vkms_config_encoder *config_encoder; struct drm_device *dev = &vkmsdev->drm; + struct vkms_config_plane *config_plane; + struct vkms_config_crtc *config_crtc; struct drm_connector *connector; - struct drm_encoder *encoder; - struct vkms_crtc *vkms_crtc; - struct vkms_plane *primary, *cursor = NULL; + unsigned long idx; int ret; - int writeback; - - vkms_crtc = vkms_crtc_init(dev, &primary->base, - cursor ? &cursor->base : NULL); - if (IS_ERR(vkms_crtc)) { - DRM_ERROR("Failed to allocate CRTC\n"); - return PTR_ERR(vkms_crtc); - } list_for_each_entry(config_plane, &vkmsdev->config->planes, link) { config_plane->plane = vkms_plane_init(vkmsdev, config_plane); @@ -53,10 +45,30 @@ int vkms_output_init(struct vkms_device *vkmsdev) ret = PTR_ERR(config_plane->plane); return ret; } - if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) - primary = config_plane->plane; - else if (config_plane->type == DRM_PLANE_TYPE_CURSOR) - cursor = config_plane->plane; + } + + list_for_each_entry(config_crtc, &vkmsdev->config->crtcs, link) { + struct drm_plane *primary = NULL, *cursor = NULL; + + xa_for_each(&config_crtc->possible_planes, idx, config_plane) { + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) + primary = &config_plane->plane->base; + else if (config_plane->type == DRM_PLANE_TYPE_CURSOR) + cursor = &config_plane->plane->base; + } + + config_crtc->crtc = vkms_crtc_init(vkmsdev, primary, cursor, config_crtc); + + if (IS_ERR(config_crtc->crtc)) { + ret = PTR_ERR(config_crtc->crtc); + return ret; + } + } + + list_for_each_entry(config_crtc, &vkmsdev->config->crtcs, link) { + xa_for_each(&config_crtc->possible_planes, idx, config_plane) { + config_plane->plane->base.possible_crtcs |= drm_crtc_mask(&config_crtc->crtc->base); + } } connector = drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); @@ -74,33 +86,25 @@ int vkms_output_init(struct vkms_device *vkmsdev) drm_connector_helper_add(connector, &vkms_conn_helper_funcs); - encoder = drmm_kzalloc(dev, sizeof(*encoder), GFP_KERNEL); - if (!encoder) { - DRM_ERROR("Failed to allocate encoder\n"); - return -ENOMEM; - } - ret = drmm_encoder_init(dev, encoder, NULL, - DRM_MODE_ENCODER_VIRTUAL, NULL); - if (ret) { - DRM_ERROR("Failed to init encoder\n"); - return ret; - } - encoder->possible_crtcs = drm_crtc_mask(&vkms_crtc->base); - - /* Attach the encoder and the connector */ - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - DRM_ERROR("Failed to attach connector to encoder\n"); - return ret; - } - - /* Initialize the writeback component */ - if (vkmsdev->config->writeback) { - writeback = vkms_enable_writeback_connector(vkmsdev, vkms_crtc); - if (writeback) { - DRM_ERROR("Failed to init writeback connector\n"); + list_for_each_entry(config_encoder, &vkmsdev->config->encoders, link) { + config_encoder->encoder = drmm_kzalloc(dev, sizeof(*config_encoder->encoder), + GFP_KERNEL); + if (!config_encoder->encoder) + return -ENOMEM; + ret = drmm_encoder_init(dev, config_encoder->encoder, NULL, + DRM_MODE_ENCODER_VIRTUAL, NULL); + if (ret) { + DRM_ERROR("Failed to init encoder\n"); return ret; } + xa_for_each(&config_encoder->possible_crtcs, idx, config_crtc) { + config_encoder->encoder->possible_crtcs |= drm_crtc_mask(&config_crtc->crtc->base); + } + if (IS_ERR(config_encoder->encoder)) + return PTR_ERR(config_encoder->encoder); + ret = drm_connector_attach_encoder(connector, config_encoder->encoder); + if (ret) + return ret; } drm_mode_config_reset(dev); From patchwork Fri Nov 22 17:20:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883439 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 6E749E69188 for ; Fri, 22 Nov 2024 17:20:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 78AB510EC35; Fri, 22 Nov 2024 17:20:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="O1n8CCps"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 434C410EC1D for ; Fri, 22 Nov 2024 17:20:31 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 36CD31C0008; Fri, 22 Nov 2024 17:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aD7eOqd1AXVZgfGyfB+5KKxVBcCNLMv/mDAuDrDv5h4=; b=O1n8CCpspFjFEfbeszeFVOt7deQ9wVN6r06KBWJrys7m3VYBYXjk4TQxNd5v15h6o5WigE PyNkTflMwbnr+/u2UCxQBiJ78JxfpgroWPxMXNa756JOiwlm+iWxnz1DtSo7cbM0fg/t2j h1A7OGMigzeqC/+kFCqgVhvMKAwdq8SR2NKVMrCiaxvQn1vTzjohxnIDzUXbVC7o9lwy2U UwTh4PS86EoZLyh4+2Io3RaJKbtL4hT2g4xuZbPfCYIWxg5a13j+/D/JYBdKAn0aJSJGp2 CGTJchiTxC6wbSMhhxgXHYSm6nq+20QJSZ2VYZSzHIjF9lART+GiY3ENv/kXgQ== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:14 +0100 Subject: [PATCH RFC v2 10/18] drm/vkms: Introduce config for encoder name MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-10-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3130; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=lAxbX9FjGzHOgfioqpWzaGxl1qtPSft9cB6C9sfd15M=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1PdSWoGQkRuiGt7ExxbhNNACbrFuqmzTbzb lHdX7lFlhiJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TwAKCRAgrS7GWxAs 4g5LEACLYTUvph7FwFv95+ygxrr2rhQFgG0hKnQBJ4Tnx08RnOJyN58EnMkusHgWybjjj72/WSX Sdw5fDQgpawnaeQyRUeOtzdZBs6PXpWgsgzC+xwWvEa9M4siTiW65A9xg7+C5MRmCRRkPNxWCTn bMp6l1Wge44spaioLYBKRT2IF4Fshl9Lc49NbxsOS/hV3MfksLLvFmzQ9cLa40zE+vcf5YsI6gp C4VE/wUHRZUEeKSI7Jt+eAaDAmN59+viC6wztVMuyWK9P3cHXnMYtCO7xZEccLupN+HdLow7HoT 9bDYfuCsDOip3167BveUCPbvO/mJHQbxnQqKQCcpokH6JD9v+zRyrAenEP8Ob4ImatfRHfG850t QkFw+/yOzmjUhC7HNt30ml9OdBng6H/Zzi6zCdP1t1m5sGyrjjoUEVNjFp7AATNGc88DdrW997v ZEBJFdGPxDShidfCnuFgtGfjx6luuHpN34EnBYArbA5COYnuPBRlF2S8zDcD5PTpVaBWXtENrD6 WXQaw/nBDVjQfXIqSMAbyhxD2W+N3Ifh2w1Sf5ex3eR5b3a+iOFMFbvQYGRzOsAWRF3cf28jc7N JT5fEey9pvFDSr4GolWNmIBj4gBa5zt+ctsSKjOeP3Rk1UUvIKOulP+jpxAYuI0C3kxeE6MVdlA 59UnnhL7nsx+iAw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" As an encoder will be a directory in ConfigFS, add the configuration for encoder name so we will be able to reflect the configfs directory name in the drm name. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 6 ++++++ drivers/gpu/drm/vkms/vkms_config.h | 2 ++ drivers/gpu/drm/vkms/vkms_output.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index e44ed904cefb97b8b6ab8fc27623e315397e0106..a2539fb56b602569b75748fdf9c4784f104b0bff 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -41,6 +41,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable encoder = vkms_config_create_encoder(vkms_config); if (!encoder) goto err_alloc; + encoder->name = kzalloc(sizeof("Main Encoder"), GFP_KERNEL); + if (!encoder->name) + goto err_alloc; + sprintf(encoder->name, "Main Encoder"); if (vkms_config_encoder_attach_crtc(encoder, crtc)) goto err_alloc; @@ -238,6 +242,7 @@ void vkms_config_delete_encoder(struct vkms_config_encoder *vkms_config_encoder, } } + kfree(vkms_config_encoder->name); kfree(vkms_config_encoder); } @@ -403,6 +408,7 @@ static int vkms_config_show(struct seq_file *m, void *data) list_for_each_entry(config_encoder, &vkmsdev->config->encoders, link) { seq_puts(m, "encoder:\n"); + seq_printf(m, "\tname: %s\n", config_encoder->name); } list_for_each_entry(config_crtc, &vkmsdev->config->crtcs, link) { diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 8f247fc09373fb2c8145e83be05c6afec1ffac1c..4223edd94ec270915dd658c0b5efd489554d33a5 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -50,6 +50,7 @@ struct vkms_config_crtc { * struct vkms_config_encoder * * @link: Link to the others encoders + * @name: Name of the encoder * @possible_crtcs: List of CRTC that can be used with this encoder * @encoder: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms encoder during device creation. This pointer is @@ -58,6 +59,7 @@ struct vkms_config_crtc { struct vkms_config_encoder { struct list_head link; + char *name; struct xarray possible_crtcs; /* Internal usage */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 03498a20d78dd8a66f9fc66b360c5ea57fc48d88..6277ad72fdd476d1eff52ad037389bdb1a254f5e 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -92,7 +92,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) if (!config_encoder->encoder) return -ENOMEM; ret = drmm_encoder_init(dev, config_encoder->encoder, NULL, - DRM_MODE_ENCODER_VIRTUAL, NULL); + DRM_MODE_ENCODER_VIRTUAL, config_encoder->name); if (ret) { DRM_ERROR("Failed to init encoder\n"); return ret; From patchwork Fri Nov 22 17:20:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883431 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 35D50E69183 for ; Fri, 22 Nov 2024 17:20:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7329C10EC2E; Fri, 22 Nov 2024 17:20:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="guAscFtj"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B65510EC1D for ; Fri, 22 Nov 2024 17:20:32 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 26CB11C000C; Fri, 22 Nov 2024 17:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FPjoDbbnyRr8NB8CQTYsw04Lz1RI3/dvKXG1g5TXNeU=; b=guAscFtjUM5GWTCaMvjH05hO+2BPd06hoQ3+8ckboIHNlY2LvEyzyKH7C3+0NDzAQ9/zCt uLD4gLQmo1HcSODPFcZDsVavZ1NxeGhBCGr5wNGv4gfw2x44k4JTcoS/n9CLWmNwiZsdxg ajK0L6ON9e2ABBdnRB0tazulxjak8BoAZ6snqWRHouXQ4SriP0dtXrn9P+8yFwvXh6Co60 AU2Kml+rrJZwxeargv6oHabLKpG3PNpWuz4fipuVJTfy23Fy4kQUKgOysh1rXcuMfKjtms CUNM/RS3fjMXSfT4mdrlFb8tJcz4HtyzOgPt2LJtb39wWDC15cXBBh0ghWkmuw== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:15 +0100 Subject: [PATCH RFC v2 11/18] drm/vkms: Introduce config for CRTC name MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-11-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2727; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=XPH7g+AmIjMlHLLHQSbiTuo8nFUzQItzE3jlEy5xM9M=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1PdImx4wMcOGyY7gXf+uKLYlrrpEEym4oWq P349JzMu6OJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9TwAKCRAgrS7GWxAs 4rmBEACowjbfGf2hpsh6W6gtRuxg7jRi9OFoNB49utSwzHIu9NQeCdubJ5A+j9lDEPoGxEA/0Zv NIhMzd/6pY5OZeTZs0LkDFV/QzsmbRkcEoy9yr2emPy3xgcYEEoCjK3R2Mtv1UXt68O2S7RwaYe YlOkB51CjGzLY0s9eEFFQNKEE0TsGGymiLRxwqJ2XfDlC5yOmpCh901ZJ515S3nEsM0pEimMuj/ c1m43ptqyLLng0ekpSHN+GgW7jcp+/BBEz+FOrNxmw7/269Xjxcj3Bt1O01ZEAxKyfHOt/Z7tq9 DLtqZb9TJDaRRqJbGJyuwVDuvjOEoo32e4i3K8puhF4iL7T3IXQ9rOFNR73J0JvmeLLZrvezxXM cbqMP5LqfJ9QYQ0gOle46mP15NUb2OA8aE7rDzFxdh2yXlMJn6Dp5HR4AV3rWAVr62zrkAOsqD2 ne9nQ2Si/iTvD26SP1UZh7qteb9L866opG8eysqtSlqiYnqLl//w1BislyXhDQPXQXkW/AHnz7+ M6KIdEVqB142N7yb2VJBJlu56Pzo7lA9pN3zkEOZ5pRFSm2jo90zXG6Hp674qGj7Y3SJyUsvJwv 20XTQQL22fYZ6XvREZBS1eiD5w4OSatuDigDnUpnWA1TybGG0Us9y91v6aF+BQ56/VtGhAd3xU+ VClVQRKcvHk0OIA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" As a CRTC will be a directory in ConfigFS, add the name configuration for CRTC name so we will be able to reflect the configfs directory name in the drm name. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 5 +++++ drivers/gpu/drm/vkms/vkms_config.h | 2 ++ drivers/gpu/drm/vkms/vkms_crtc.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index a2539fb56b602569b75748fdf9c4784f104b0bff..3252f657ce515c0193a8c0e709bfe861feba0aca 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -37,6 +37,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (!crtc) goto err_alloc; crtc->writeback = enable_writeback; + crtc->name = kzalloc(sizeof("Main CRTC"), GFP_KERNEL); + if (!crtc->name) + goto err_alloc; + sprintf(crtc->name, "Main CRTC"); encoder = vkms_config_create_encoder(vkms_config); if (!encoder) @@ -219,6 +223,7 @@ void vkms_config_delete_crtc(struct vkms_config_crtc *vkms_config_crtc, } } + kfree(vkms_config_crtc->name); kfree(vkms_config_crtc); } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 4223edd94ec270915dd658c0b5efd489554d33a5..4a4c16dea7855cf36060986ef247be698974fafc 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -29,6 +29,7 @@ struct vkms_config { * struct vkms_config_crtc * * @link: Link to the others CRTCs + * @name: Name of the CRTC * @possible_planes: List of planes that can be used with this CRTC * @possible_encoders: List of encoders that can be used with this CRTC * @crtc: Internal usage. This pointer should never be considered as valid. It can be used to @@ -38,6 +39,7 @@ struct vkms_config { struct vkms_config_crtc { struct list_head link; + char *name; bool writeback; struct xarray possible_planes; struct xarray possible_encoders; diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 3825fba57c012f84cbe67114e053dcd7fcfa283d..25a3d97a362afd0d40f3e023d9cce985d447a880 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -292,7 +292,7 @@ struct vkms_crtc *vkms_crtc_init(struct vkms_device *vkms_device, vkms_crtc = drmm_crtc_alloc_with_planes(dev, struct vkms_crtc, base, primary, cursor, - &vkms_crtc_funcs, NULL); + &vkms_crtc_funcs, config->name); if (IS_ERR(vkms_crtc)) { DRM_DEV_ERROR(dev->dev, "Failed to init CRTC\n"); return vkms_crtc; From patchwork Fri Nov 22 17:20:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883438 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 A135DE69183 for ; Fri, 22 Nov 2024 17:20:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED95A10EC24; Fri, 22 Nov 2024 17:20:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="TW0wPuCv"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2FA3310EC1D for ; Fri, 22 Nov 2024 17:20:33 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 124F51C000F; Fri, 22 Nov 2024 17:20:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3pZcj0NZ2YBqvq/J6zcsQjddfQSR7x65pN9aBnV0Z70=; b=TW0wPuCvZtLUIvB5O8cXj9uyD7EojxDl5I/0Q3Dofj86gHyLnhKpAbX7W9JSjNSeXCjLYk LfkSgUiaVwWcIrM468zW7jJVZv3/0gOIC5imG/8IdYtZeIDHQm5oZe4Q19LOduVu8KDJlT dQobElcq+yUqf/ylZlpxXAELH65eL9C2pQt+PMAw0F5jlLjw/Woc3FX0x6iecmED9ULCFc dAL1ks4d+zkSHve0skstAIPuU+6PcX/pcjrTpIpzb+j/GzgDcZs3uVxAMsRgek+FkTXett g17UF7HNbxHlpWxaO7soz6S94rQ2xVOpYdGBC4MEuv9PlyRrtjmZqEyOp+takA== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:16 +0100 Subject: [PATCH RFC v2 12/18] drm/vkms: Add test for config structure MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-12-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=7146; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=oBmYPdGSswsqPrnaij5RkMl4T5hw1Ka1JTJFwGsUKVM=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1QFXRgp9FfoKX1rGti1LDTphZeiZUud6LF5 koAkx53Sp+JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9UAAKCRAgrS7GWxAs 4m7RD/99H8lhoNGL5h2CeYT8EfUFiQmDiffEHDEn1cmYZ86xgSNCEUYd2Ouy4uEBYAZa7Y8EPRG 8XA7X2JOUJNYTZvvi+hw6D/iEbc3IUNQT83qzs90KtwUvftvMea4pNSJ/bu1Jw0Ned0mkjxJdl3 t77KufmVq8vKfM5IAqMrPTPPWGjqHWXhnqA2FGVa1M8Qi+kzhjy2aTdxaJBBQUdghhG2XxruGn0 Md6UfFIPfsOhGPpRfTSXwcN2XQEPmu/r4evPvCrb5ASa5pjmzlrI44ooJDtehpV/4D1MSOPj90O PdgGpMIDvj/ezzPNLJuRFJTDfOFAjkL61yZjdxwVa0evFIYrx9Sdk0yelTB54LsOvCzVWGhqkb4 fDIfwEjpGxJ4e1A2xI8rZbLMse6L2bX+9ki8IUEbM1Mi9Mqin6orlpBb7MrIugityljs35c4R/z INv0qSTdRrUJnUExl2ENFi0IhjIDkhVHOjXdpm9ZnCxpdPlKQju+RjgS11CZGQQfoEh1vcSlSPx A6b+KHCsiQT5tpKHkZJb2QFdx3bcywFmWQV3XxgT2W/2gvwImUtwRVRb52dFIY0w/0xCJMTUb8r 1u3V+wTtHGMq3uM6WKBXJAXF6cZq8kg2IoESYLRGmZaHVZsCj4cY1htFI5Q9k1TT6OwYCoWjP9x iQKkMTBAi29kpQQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" The config structure is a bit complex in term of memory management. Add basic test to avoid breaking it in the future. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/tests/Makefile | 1 + drivers/gpu/drm/vkms/tests/vkms_config_test.c | 137 ++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) diff --git a/drivers/gpu/drm/vkms/tests/Makefile b/drivers/gpu/drm/vkms/tests/Makefile index 2d1df668569e4f243ed9a06c1e16e595c131c4f6..ec71b5fe7f9d957eeeabd233bb75c4c250789ff4 100644 --- a/drivers/gpu/drm/vkms/tests/Makefile +++ b/drivers/gpu/drm/vkms/tests/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += vkms_format_test.o +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += vkms_config_test.o diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c new file mode 100644 index 0000000000000000000000000000000000000000..12b845bc358aaa44434c6b66184cf17d19656596 --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "../vkms_config.h" + +MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING); + +static void vkms_config_test_basic_allocation(struct kunit *test) +{ + struct vkms_config *config = vkms_config_create(); + + KUNIT_EXPECT_TRUE_MSG(test, list_empty(&config->encoders), + "Encoder list is not empty after allocation"); + KUNIT_EXPECT_TRUE_MSG(test, list_empty(&config->crtcs), + "CRTC list is not empty after allocation"); + KUNIT_EXPECT_TRUE_MSG(test, list_empty(&config->planes), + "Plane list is not empty after allocation"); + + vkms_config_destroy(config); +} + +static void vkms_config_test_simple_config(struct kunit *test) +{ + struct vkms_config *config = vkms_config_create(); + + struct vkms_config_plane *plane_1 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_2 = vkms_config_create_plane(config); + struct vkms_config_crtc *crtc = vkms_config_create_crtc(config); + struct vkms_config_encoder *encoder = vkms_config_create_encoder(config); + + KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config)); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->planes), 2); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->crtcs), 1); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->encoders), 1); + + plane_1->type = DRM_PLANE_TYPE_PRIMARY; + plane_2->type = DRM_PLANE_TYPE_CURSOR; + + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_1, crtc), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_2, crtc), 0); + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder, crtc), 0); + + KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config)); + + vkms_config_delete_plane(plane_1, config); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->planes), 1); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->crtcs), 1); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->encoders), 1); + + KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config)); + + plane_2->type = DRM_PLANE_TYPE_PRIMARY; + + KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config)); + + vkms_config_destroy(config); +} + +static void vkms_config_test_complex_config(struct kunit *test) +{ + struct vkms_config *config = vkms_config_create(); + + struct vkms_config_plane *plane_1 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_2 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_3 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_4 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_5 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_6 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_7 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_8 = vkms_config_create_plane(config); + struct vkms_config_crtc *crtc_1 = vkms_config_create_crtc(config); + struct vkms_config_crtc *crtc_2 = vkms_config_create_crtc(config); + struct vkms_config_encoder *encoder_1 = vkms_config_create_encoder(config); + struct vkms_config_encoder *encoder_2 = vkms_config_create_encoder(config); + struct vkms_config_encoder *encoder_3 = vkms_config_create_encoder(config); + struct vkms_config_encoder *encoder_4 = vkms_config_create_encoder(config); + + KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config)); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->planes), 8); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->crtcs), 2); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->encoders), 4); + + plane_1->type = DRM_PLANE_TYPE_PRIMARY; + plane_2->type = DRM_PLANE_TYPE_CURSOR; + plane_3->type = DRM_PLANE_TYPE_OVERLAY; + plane_4->type = DRM_PLANE_TYPE_OVERLAY; + plane_5->type = DRM_PLANE_TYPE_PRIMARY; + plane_6->type = DRM_PLANE_TYPE_CURSOR; + plane_7->type = DRM_PLANE_TYPE_OVERLAY; + plane_8->type = DRM_PLANE_TYPE_OVERLAY; + + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_1, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_2, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_3, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_4, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_5, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_6, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_7, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_8, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_3, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_4, crtc_2), 0); + + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder_1, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder_2, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder_3, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder_3, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder_4, crtc_2), 0); + + KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config)); + + vkms_config_delete_plane(plane_4, config); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->planes), 7); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->crtcs), 2); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->encoders), 4); + + KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config)); + + vkms_config_destroy(config); +} + +static struct kunit_case vkms_config_test_cases[] = { + KUNIT_CASE(vkms_config_test_basic_allocation), + KUNIT_CASE(vkms_config_test_simple_config), + KUNIT_CASE(vkms_config_test_complex_config), + {} +}; + +static struct kunit_suite vkms_config_test_suite = { + .name = "vkms-config", + .test_cases = vkms_config_test_cases, +}; + +kunit_test_suite(vkms_config_test_suite); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Kunit test for vkms config utility"); From patchwork Fri Nov 22 17:20:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883442 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 1D327E69183 for ; Fri, 22 Nov 2024 17:20:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C88110EC25; Fri, 22 Nov 2024 17:20:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="b/V3VaIm"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A94410EC29 for ; Fri, 22 Nov 2024 17:20:33 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id E8B961C0007; Fri, 22 Nov 2024 17:20:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296032; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y2Cs9qpfJO1PfS7zmjOUPi9+YIlOxOIeMEzIvqex6gU=; b=b/V3VaImSrJW0pVNGfJvr1BBRMhOoKGfRv0SteNv7sXK8USjvpZPIEX6da04JrIzRmSspz w8IY34Jhu3dQvp58m6OtqoFN+2/MNdZqGBu98/l7j+Z9kdUhPcZoByoN9OysmhMI0XodSj cpoerOitoRROSwgXqsB9SpSoBWEyPhdS5YSCKXVjfBOkjKjaMyoeJ2UCnOWzDJdekNSLix PPAOhuO5STfZakUc92c+95Pc+crnLsQh1CV1ilYwSsdcqEvxfdOcAuVRCLYt4yxKs7Qphf zrFFYxokogjTC4KVhFq0OXuyRuL0O8+OLO6cgZKM/OcO8YMVVAJLoJLCwthQ4g== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:17 +0100 Subject: [PATCH RFC v2 13/18] drm/vkms: Introduce config for connector MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-13-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=10282; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=+nK9sQyp8wTHyJ2qDPlxWn+0DFyKKAaVT/iiUejAtIw=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1QUz0QhjkbR+jfIuCOLKCTz/NI2DdOH8esR oh+OJ3n9s+JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9UAAKCRAgrS7GWxAs 4sAGD/9qf1WZZmL8ct9G7d1QNLYFLfLqTgafs3fpzh0KnYRZbwJGdzj9qvQT1zk2YYe/ZIf0gt0 9fU9j3uP1S3p+gr7Kxd+5Wq2bo6cLSAeIRjQ7+BXS32h6wVXMYtizXwFjBToB/J9DQVaHxuowY7 GU/kIRng0WcnBUjpmfK/zPnNyFbj3Hgiy1FKaSKPdoq+YPIqYoqnvgcOU+OC8ktUpz3/RyhvZ7a pPbytjzCD8HAKulNoVLEvZfNE6PzpXPtSoJ/yxcG+bpj4K05lntV/aP2gZAlewLivKT2b6zct15 zfFZX+y8h2mIt55DmDA9shnqexaRFaMjtZOT+MavjatsgQ3BLgjqmwlTU/I2WquiSaexM0k9VXX 8sg5sbHt81a8Xd/L6/tw1LzNPuWp0GiccbHtKONK2tlzO33Iw7YpBnZpz6bL+/HH835/vIZto8J UOu6ERqyNInCUo4l1DQASa9jibBRUmOSOwdJrVyEI/DAIZ616nJYMHzXbTYupAhnAtVDNrQQyRj xz03Pp6dYdCWYC5BmA/MDbZBknv6b557hnDjy93QLS0nI/Uc4htHX9NH1H9ECRGzDefR2rL5cUt 7NBSgZiU/HaNcNeeiHTFxTSIduFknyg8VpAkGsf5n7BuxQaMMH+ELkwg5KWNkeznqZ7kEV0Xidz BldfMz2Pxnyd3fg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 62 +++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/vkms/vkms_config.h | 18 +++++++++-- drivers/gpu/drm/vkms/vkms_drv.c | 2 +- drivers/gpu/drm/vkms/vkms_output.c | 37 ++++++++++++----------- 4 files changed, 98 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 3252f657ce515c0193a8c0e709bfe861feba0aca..998bdc50405116507e9cefd72a7b472c4c17e36d 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -17,6 +17,7 @@ struct vkms_config *vkms_config_create(void) INIT_LIST_HEAD(&config->planes); INIT_LIST_HEAD(&config->crtcs); INIT_LIST_HEAD(&config->encoders); + INIT_LIST_HEAD(&config->connectors); return config; } @@ -28,6 +29,7 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable struct vkms_config_plane *plane; struct vkms_config_encoder *encoder; struct vkms_config_crtc *crtc; + struct vkms_config_connector *connector; struct vkms_config *vkms_config = vkms_config_create(); if (IS_ERR(vkms_config)) @@ -53,6 +55,12 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (vkms_config_encoder_attach_crtc(encoder, crtc)) goto err_alloc; + connector = vkms_config_create_connector(vkms_config); + if (!connector) + goto err_alloc; + if (vkms_config_connector_attach_encoder(connector, encoder)) + goto err_alloc; + plane = vkms_config_create_plane(vkms_config); if (!plane) goto err_alloc; @@ -130,6 +138,23 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf } EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_plane); +struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *vkms_config) +{ + if (!vkms_config) + return NULL; + + struct vkms_config_connector *vkms_config_connector = + kzalloc(sizeof(*vkms_config_connector), GFP_KERNEL); + + if (!vkms_config_connector) + return NULL; + + list_add(&vkms_config_connector->link, &vkms_config->connectors); + xa_init_flags(&vkms_config_connector->possible_encoders, XA_FLAGS_ALLOC); + + return vkms_config_connector; +} + struct vkms_config_crtc *vkms_config_create_crtc(struct vkms_config *vkms_config) { if (!vkms_config) @@ -227,6 +252,15 @@ void vkms_config_delete_crtc(struct vkms_config_crtc *vkms_config_crtc, kfree(vkms_config_crtc); } +void vkms_config_delete_connector(struct vkms_config_connector *vkms_config_conector) +{ + if (!vkms_config_conector) + return; + list_del(&vkms_config_conector->link); + + kfree(vkms_config_conector); +} + void vkms_config_delete_encoder(struct vkms_config_encoder *vkms_config_encoder, struct vkms_config *vkms_config) { @@ -247,6 +281,17 @@ void vkms_config_delete_encoder(struct vkms_config_encoder *vkms_config_encoder, } } + struct vkms_config_connector *connector_config; + + list_for_each_entry(connector_config, &vkms_config->connectors, link) { + unsigned long idx = 0; + + xa_for_each(&connector_config->possible_encoders, idx, encoder) { + if (encoder == vkms_config_encoder) + xa_erase(&connector_config->possible_encoders, idx); + } + } + kfree(vkms_config_encoder->name); kfree(vkms_config_encoder); } @@ -256,7 +301,7 @@ void vkms_config_destroy(struct vkms_config *config) struct vkms_config_plane *vkms_config_plane, *tmp_plane; struct vkms_config_encoder *vkms_config_encoder, *tmp_encoder; struct vkms_config_crtc *vkms_config_crtc, *tmp_crtc; - + struct vkms_config_connector *vkms_config_connector, *tmp_connector; list_for_each_entry_safe(vkms_config_plane, tmp_plane, &config->planes, link) { vkms_config_delete_plane(vkms_config_plane, config); } @@ -266,6 +311,9 @@ void vkms_config_destroy(struct vkms_config *config) list_for_each_entry_safe(vkms_config_crtc, tmp_crtc, &config->crtcs, link) { vkms_config_delete_crtc(vkms_config_crtc, config); } + list_for_each_entry_safe(vkms_config_connector, tmp_connector, &config->connectors, link) { + vkms_config_delete_connector(vkms_config_connector); + } kfree(config); } @@ -315,6 +363,18 @@ int __must_check vkms_config_encoder_attach_crtc(struct vkms_config_encoder *vkm } EXPORT_SYMBOL_IF_KUNIT(vkms_config_encoder_attach_crtc); +int __must_check +vkms_config_connector_attach_encoder(struct vkms_config_connector *vkms_config_connector, + struct vkms_config_encoder *vkms_config_encoder) +{ + u32 encoder_idx; + int ret; + + ret = xa_alloc(&vkms_config_connector->possible_encoders, &encoder_idx, vkms_config_encoder, + xa_limit_32b, GFP_KERNEL); + return ret; +} + bool vkms_config_is_valid(struct vkms_config *config) { struct vkms_config_plane *config_plane; diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 4a4c16dea7855cf36060986ef247be698974fafc..d64024e6682d217f7d9265f436ff2e6135860260 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -23,6 +23,7 @@ struct vkms_config { struct list_head planes; struct list_head crtcs; struct list_head encoders; + struct list_head connectors; }; /** @@ -103,6 +104,15 @@ struct vkms_config_plane { struct vkms_plane *plane; }; +struct vkms_config_connector { + struct list_head link; + + struct xarray possible_encoders; + + /* Internal usage */ + struct drm_connector *connector; +}; + /** * vkms_config_register_debugfs() - Register the debugfs file to display current configuration */ @@ -133,6 +143,8 @@ bool vkms_config_is_valid(struct vkms_config *vkms_config); */ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_config); +struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *vkms_config); + /** * vkms_config_create_crtc() - Create a crtc configuration * @@ -153,7 +165,9 @@ int __must_check vkms_config_plane_attach_crtc(struct vkms_config_plane *vkms_co struct vkms_config_crtc *vkms_config_crtc); int __must_check vkms_config_encoder_attach_crtc(struct vkms_config_encoder *vkms_config_encoder, struct vkms_config_crtc *vkms_config_crtc); - +int __must_check +vkms_config_connector_attach_encoder(struct vkms_config_connector *vkms_config_connector, + struct vkms_config_encoder *vkms_config_encoder); /** * vkms_config_delete_plane() - Remove a plane configuration and frees its memory * @@ -190,7 +204,7 @@ void vkms_config_delete_crtc(struct vkms_config_crtc *vkms_config_crtc, */ void vkms_config_delete_encoder(struct vkms_config_encoder *vkms_config_encoder, struct vkms_config *vkms_config); - +void vkms_config_delete_connector(struct vkms_config_connector *vkms_config_conector); /** * vkms_config_alloc_default() - Allocate the configuration for the default device * @enable_writeback: Enable the writeback connector for this configuration diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 61ae2986568093ab0df7174a0a4678a75f9aad0c..eb6fd570b4549639f6818ff63fb334f2a461b23d 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -185,7 +185,7 @@ static int vkms_create(struct vkms_config *config) goto out_devres; } - ret = drm_vblank_init(&vkms_device->drm, 1); + ret = drm_vblank_init(&vkms_device->drm, list_count_nodes(&config->crtcs)); if (ret) { DRM_ERROR("Failed to vblank\n"); goto out_devres; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 6277ad72fdd476d1eff52ad037389bdb1a254f5e..90c0fa8eba53bef4ca80c374b40d69b0de155144 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -35,7 +35,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) struct drm_device *dev = &vkmsdev->drm; struct vkms_config_plane *config_plane; struct vkms_config_crtc *config_crtc; - struct drm_connector *connector; + struct vkms_config_connector *config_connector; unsigned long idx; int ret; @@ -71,21 +71,6 @@ int vkms_output_init(struct vkms_device *vkmsdev) } } - connector = drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); - if (!connector) { - DRM_ERROR("Failed to allocate connector\n"); - return -ENOMEM; - } - - ret = drmm_connector_init(dev, connector, &vkms_connector_funcs, - DRM_MODE_CONNECTOR_VIRTUAL, NULL); - if (ret) { - DRM_ERROR("Failed to init connector\n"); - return ret; - } - - drm_connector_helper_add(connector, &vkms_conn_helper_funcs); - list_for_each_entry(config_encoder, &vkmsdev->config->encoders, link) { config_encoder->encoder = drmm_kzalloc(dev, sizeof(*config_encoder->encoder), GFP_KERNEL); @@ -97,14 +82,32 @@ int vkms_output_init(struct vkms_device *vkmsdev) DRM_ERROR("Failed to init encoder\n"); return ret; } + xa_for_each(&config_encoder->possible_crtcs, idx, config_crtc) { config_encoder->encoder->possible_crtcs |= drm_crtc_mask(&config_crtc->crtc->base); } if (IS_ERR(config_encoder->encoder)) return PTR_ERR(config_encoder->encoder); - ret = drm_connector_attach_encoder(connector, config_encoder->encoder); + } + + list_for_each_entry(config_connector, &vkmsdev->config->connectors, link) { + config_connector->connector = drmm_kzalloc(&vkmsdev->drm, + sizeof(*config_connector->connector), + GFP_KERNEL); + if (!config_connector->connector) + return -ENOMEM; + ret = drmm_connector_init(&vkmsdev->drm, config_connector->connector, + &vkms_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL, NULL); if (ret) return ret; + drm_connector_helper_add(config_connector->connector, &vkms_conn_helper_funcs); + + xa_for_each(&config_connector->possible_encoders, idx, config_encoder) { + ret = drm_connector_attach_encoder(config_connector->connector, + config_encoder->encoder); + if (ret) + return ret; + } } drm_mode_config_reset(dev); From patchwork Fri Nov 22 17:20:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883434 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 3F0B8E69183 for ; Fri, 22 Nov 2024 17:20:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7FE5910EC30; Fri, 22 Nov 2024 17:20:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="nam5ZBlB"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0167610EC25 for ; Fri, 22 Nov 2024 17:20:34 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id D50771C0004; Fri, 22 Nov 2024 17:20:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296033; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OagiUe3HQkEQnTAKyPtfCFjvpKrwiG5lJesDAbGKips=; b=nam5ZBlBu9x6QJVWFD7pv/e3fDvcDmeSGjXbqup52uhxIvAvwtf7Adp7QaYLPhceBb3zyA In3rKezJKCf+K2CKHhDJLh/Ov7r8gttdJdou/1kuuH7FoQyTlCq+rxYheZI2AogqYH2Sya IuudRhhp8ggvfF3CEUWQN2aid9pJQhBO7hn/Rzlp433K/LGXUhL393CO9AcefGcphF5NmX T75AtI/IH7m6bXNf/nn+XzBfij0W5JBT8Rw095Mk3BA6OXUnABwscPBnlvtIeXF+xPKRnH ePJvcTT15Xg4SOS6DoZudMrQbmVgQeo+/a/5O3KNg5MpoDrjd5rWZgRv6ROfxg== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:18 +0100 Subject: [PATCH RFC v2 14/18] drm/vkms: Introduce config for connector type MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-14-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2145; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=4AJ4w6rM+OS5dAB1iXM+yakMJb728HKc9lH7IWGkbyM=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1QrUbvw2eJYu9SVKJZjEJyrfnmhHUtfq/Ni UVC+DS86YSJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9UAAKCRAgrS7GWxAs 4ow0D/9PQENsHV2apPCplfO5JJtA5o8LYAwa2uy7sRHYkDF+uWDvsEsthJOzq3/r89OIqsYxw5m jPzVfuNZNc/K7KQFptV/XWaax7EOtIkO+WNxFdcyNZpjY4aDl6i0jLtPnYLJNwmpZBolGkewEy4 r4dHuVSaGVxyLKhxn4p4oQZy9h3bIzXkQ3Jjqz2hzSJ7vsPTHdSnJElkM69i+3YniCFNX6geAe2 TBh9QJ2+ZLfoAtK0PnisvjtXWW6Hc2hyaoF/A3KrjpQJZt3lZy2I6Zf+JuiaG/MsX1op+EOF5Va 5DWn5f4+iRAZRMHs6HVs3Zx7DrG84qYwOCQD9qTUaLyxoRRvVCnxnDDwFMKZUGUsgTu4NaoBte8 HnYvCSCoTpF9ktjgTJaNS7oWR5IvSLG/ew8Lu3qvWXriIY4lBD1oS0PqfMJJyKpoxwYN40uQQQa y7SBka1TZH2rIaf6pXp9I4dcLKaM8DBzGO8tJ/iwDRt+s/CIJWm0U4BhfShJHU7okgOjwXUrAmB uZxpQGIXgh3B8459rAOzQoq1JiJoXUqBZma1/tyZb5EGzxMTZINofd+A6fGtdokCgY0tTTQw9WE Ynv4R5l4ILrB6i+nx9ghc0yl4iWJWI3v+fbLfpTjViY2paRfCvoTL+4OzyDrh87Ekud1PmXgy5H YAAWU+zEkyb25Zw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" To allow emulation of different kind of connector, make the connector type configurable. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 1 + drivers/gpu/drm/vkms/vkms_config.h | 1 + drivers/gpu/drm/vkms/vkms_output.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 998bdc50405116507e9cefd72a7b472c4c17e36d..c3334d3d808e5fc8cd6d855e9e1395f94f157ffb 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -151,6 +151,7 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *v list_add(&vkms_config_connector->link, &vkms_config->connectors); xa_init_flags(&vkms_config_connector->possible_encoders, XA_FLAGS_ALLOC); + vkms_config_connector->type = DRM_MODE_CONNECTOR_VIRTUAL; return vkms_config_connector; } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index d64024e6682d217f7d9265f436ff2e6135860260..c44bcafc3b34e1997f29631fda42af05e1c0c2ba 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -108,6 +108,7 @@ struct vkms_config_connector { struct list_head link; struct xarray possible_encoders; + int type; /* Internal usage */ struct drm_connector *connector; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 90c0fa8eba53bef4ca80c374b40d69b0de155144..aea6366fd9a662483ed5a255d02d5025a30297f7 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -97,7 +97,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) if (!config_connector->connector) return -ENOMEM; ret = drmm_connector_init(&vkmsdev->drm, config_connector->connector, - &vkms_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL, NULL); + &vkms_connector_funcs, config_connector->type, NULL); if (ret) return ret; drm_connector_helper_add(config_connector->connector, &vkms_conn_helper_funcs); From patchwork Fri Nov 22 17:20:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883444 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 A84A5E69186 for ; Fri, 22 Nov 2024 17:20:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D226110EC3A; Fri, 22 Nov 2024 17:20:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="P3ZLUDtp"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0E46110EC25 for ; Fri, 22 Nov 2024 17:20:35 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id D0C801C0005; Fri, 22 Nov 2024 17:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b+uxkQn+mlEuDnQOdIypl/rm+OT/Ip+5g02ew8ECwUI=; b=P3ZLUDtpK71/FMHRiWTSM42HxBZ3/zu+mtEQt5aqbjpJFvRNgQLcsfKGVNa2Btq2XHOlWe wSVaFGcUH6c1c79oqV7hOyD1o2H+s0lAt0a/ARvonNvPM809WlJksmoFSSTVnXGRVSXd0y FIvXVSc2bEWaMIvZq6Ns8caSybJm6Zv0dmrxEChLlvXL+Av0LnqJtrHU4GKzz8tzMJfBuP h23SCPKBQqbsZ1RIkND/Pjk9/2lyKBJo7cb8/L9GSWxO1QD306NFMBAFtQAMduc+bwlPOe NPyy6p60P+842XbXnh/DA9W9va0dAJgoOXbF3FvJh5vgeJh4nZ70C/4ctNIm1g== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:19 +0100 Subject: [PATCH RFC v2 15/18] drm/vkms: Introduce config for plane format MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-15-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=8212; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=28S5sg0LuchLTdWq16JVNfGAMJbUl085tPc58du+djg=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1QgbqIU8MYbqIDkdSnOO9PX64/sCQg5uT83 NPsnFr0Dl2JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9UAAKCRAgrS7GWxAs 4ifwD/4t9SBVJW+AeCAlJIB9A9WhWpE+yAnLd/CBgm9s3FtBTmsTu6VWz25dAEBB4akem+CIftj FQBrkD3UMHRWYtQd+664fwPe9PEl1poUE74DzWOdJ2HXuYjDc6X+WUjS3VsLYfal5GcZTRIFyug vnerHoeggUQCB2BDDvHTWLmNOtWS3nyja7U7TfF+DxC6imEaSrKn0dyQYKDhHUa/qw3YdLTQlYj 6Sdi/ut9XLF+AGDl3uBTWb0qc+Iv3QnS2wjGJr/DkBNAPvVtR3Cx8zordWBvOZ+gK9hu0zgs9zO +JToJEAhtpCnG9GSxj/SGFmkR9nfZbUaiCBImPJ+a8054goEIjjpf4js1Oy4MVZbydu7aOiQIpH sJ7aKQ5Ve0rm0LigUUyA6Z1At0uz5VE8W0gfWibK+UZkSf900JCdu+BoRkN7c+9fq2Qr87q/P34 JEyc/mj/SyFK1fBy+ZwLvSN7GHv65+4BJPkBZuhN39aNv2NlWjozGyrbtGQY7al7gyLlyqCxv2Y tQY9S7ZynEcbXrYvy6mt6onDICr03M1qohiOfRqI9odVfQAbHsI0l4YFN744z0u+wD+DIjJxJfj u0FE9J7TUa3+OCZ026Rwy6Hy5RWLhdxKu8LmoFUdd9XjhhezpUA+3ptWl3Nx6H3PNoNNJeIH0sa x6vo7KlZbVMCNKA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 105 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 19 +++++++ drivers/gpu/drm/vkms/vkms_plane.c | 43 ++------------- 3 files changed, 127 insertions(+), 40 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index c3334d3d808e5fc8cd6d855e9e1395f94f157ffb..4726929c2b54b2e670f9ef53b05ec009ca495e08 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -6,6 +6,44 @@ #include "vkms_config.h" #include "vkms_drv.h" +static const u32 vkms_supported_plane_formats[] = { + DRM_FORMAT_ARGB8888, + DRM_FORMAT_ABGR8888, + DRM_FORMAT_BGRA8888, + DRM_FORMAT_RGBA8888, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_XBGR8888, + DRM_FORMAT_RGBX8888, + DRM_FORMAT_BGRX8888, + DRM_FORMAT_RGB888, + DRM_FORMAT_BGR888, + DRM_FORMAT_XRGB16161616, + DRM_FORMAT_XBGR16161616, + DRM_FORMAT_ARGB16161616, + DRM_FORMAT_ABGR16161616, + DRM_FORMAT_RGB565, + DRM_FORMAT_BGR565, + DRM_FORMAT_NV12, + DRM_FORMAT_NV16, + DRM_FORMAT_NV24, + DRM_FORMAT_NV21, + DRM_FORMAT_NV61, + DRM_FORMAT_NV42, + DRM_FORMAT_YUV420, + DRM_FORMAT_YUV422, + DRM_FORMAT_YUV444, + DRM_FORMAT_YVU420, + DRM_FORMAT_YVU422, + DRM_FORMAT_YVU444, + DRM_FORMAT_P010, + DRM_FORMAT_P012, + DRM_FORMAT_P016, + DRM_FORMAT_R1, + DRM_FORMAT_R2, + DRM_FORMAT_R4, + DRM_FORMAT_R8, +}; + struct vkms_config *vkms_config_create(void) { struct vkms_config *config; @@ -120,6 +158,13 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf if (!vkms_config_overlay) return NULL; + vkms_config_overlay->supported_formats = NULL; + + if (vkms_config_plane_add_all_formats(vkms_config_overlay)) { + kfree(vkms_config_overlay); + return NULL; + } + vkms_config_overlay->type = DRM_PLANE_TYPE_OVERLAY; vkms_config_overlay->supported_rotations = DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK; vkms_config_overlay->default_rotation = DRM_MODE_ROTATE_0; @@ -193,6 +238,65 @@ struct vkms_config_encoder *vkms_config_create_encoder(struct vkms_config *vkms_ } EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_encoder); +int __must_check vkms_config_plane_add_all_formats(struct vkms_config_plane *vkms_config_plane) +{ + u32 *ret = krealloc_array(vkms_config_plane->supported_formats, + ARRAY_SIZE(vkms_supported_plane_formats), + sizeof(uint32_t), GFP_KERNEL); + if (!ret) + return -ENOMEM; + vkms_config_plane->supported_formats = ret; + + memcpy(vkms_config_plane->supported_formats, vkms_supported_plane_formats, + sizeof(vkms_supported_plane_formats)); + vkms_config_plane->supported_formats_count = ARRAY_SIZE(vkms_supported_plane_formats); + return 0; +} + +int __must_check vkms_config_plane_add_format(struct vkms_config_plane *vkms_config_plane, + u32 drm_format) +{ + bool found = false; + + for (int i = 0; i < ARRAY_SIZE(vkms_supported_plane_formats); i++) { + if (vkms_supported_plane_formats[i] == drm_format) + found = true; + } + + if (!found) + return -EINVAL; + for (unsigned int i = 0; i < vkms_config_plane->supported_formats_count; i++) { + if (vkms_config_plane->supported_formats[i] == drm_format) + return 0; + } + u32 *new_ptr = krealloc_array(vkms_config_plane->supported_formats, + vkms_config_plane->supported_formats_count + 1, + sizeof(*vkms_config_plane->supported_formats), GFP_KERNEL); + if (!new_ptr) + return -ENOMEM; + + vkms_config_plane->supported_formats = new_ptr; + vkms_config_plane->supported_formats[vkms_config_plane->supported_formats_count] = drm_format; + vkms_config_plane->supported_formats_count++; + + return 0; +} + +void vkms_config_plane_remove_all_formats(struct vkms_config_plane *vkms_config_plane) +{ + vkms_config_plane->supported_formats_count = 0; +} + +void vkms_config_plane_remove_format(struct vkms_config_plane *vkms_config_plane, u32 drm_format) +{ + for (unsigned int i = 0; i < vkms_config_plane->supported_formats_count; i++) { + if (vkms_config_plane->supported_formats[i] == drm_format) { + vkms_config_plane->supported_formats[i] = vkms_config_plane->supported_formats[vkms_config_plane->supported_formats_count - 1]; + vkms_config_plane->supported_formats_count--; + } + } +} + void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_plane, struct vkms_config *vkms_config) { @@ -213,6 +317,7 @@ void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_plane, } } + kfree(vkms_config_plane->supported_formats); kfree(vkms_config_plane->name); kfree(vkms_config_plane); } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index c44bcafc3b34e1997f29631fda42af05e1c0c2ba..5487e0140da0e111c36f9a22d4e783a20c880a1d 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -98,6 +98,8 @@ struct vkms_config_plane { unsigned int supported_color_encoding; enum drm_color_range default_color_range; unsigned int supported_color_range; + u32 *supported_formats; + unsigned int supported_formats_count; struct xarray possible_crtcs; /* Internal usage */ @@ -144,6 +146,23 @@ bool vkms_config_is_valid(struct vkms_config *vkms_config); */ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_config); +/** vkms_config_plane_add_format - Add a format to the list of supported format of a plane + * + * The passed drm_format can already be present in the list. This may fail if the allocation of a + * bigger array fails. + * + * @vkms_config_plane: Plane to add the format to + * @drm_format: Format to add to this plane + * + * Returns: 0 on success, -ENOMEM if array allocation fails, -EINVAL if the format is not supported + * by VKMS + */ +int __must_check vkms_config_plane_add_format(struct vkms_config_plane *vkms_config_plane, + u32 drm_format); +int __must_check vkms_config_plane_add_all_formats(struct vkms_config_plane *vkms_config_plane); +void vkms_config_plane_remove_format(struct vkms_config_plane *vkms_config_plane, u32 drm_format); +void vkms_config_plane_remove_all_formats(struct vkms_config_plane *vkms_config_plane); + struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *vkms_config); /** diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 90a5946481e47ab7cff9b9dc4942720b6bbcbe3f..b858c8ba00d97e461d70b5cc274ab4e7a3e1bb78 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -13,44 +13,6 @@ #include "vkms_formats.h" #include "vkms_config.h" -static const u32 vkms_formats[] = { - DRM_FORMAT_ARGB8888, - DRM_FORMAT_ABGR8888, - DRM_FORMAT_BGRA8888, - DRM_FORMAT_RGBA8888, - DRM_FORMAT_XRGB8888, - DRM_FORMAT_XBGR8888, - DRM_FORMAT_RGBX8888, - DRM_FORMAT_BGRX8888, - DRM_FORMAT_RGB888, - DRM_FORMAT_BGR888, - DRM_FORMAT_XRGB16161616, - DRM_FORMAT_XBGR16161616, - DRM_FORMAT_ARGB16161616, - DRM_FORMAT_ABGR16161616, - DRM_FORMAT_RGB565, - DRM_FORMAT_BGR565, - DRM_FORMAT_NV12, - DRM_FORMAT_NV16, - DRM_FORMAT_NV24, - DRM_FORMAT_NV21, - DRM_FORMAT_NV61, - DRM_FORMAT_NV42, - DRM_FORMAT_YUV420, - DRM_FORMAT_YUV422, - DRM_FORMAT_YUV444, - DRM_FORMAT_YVU420, - DRM_FORMAT_YVU422, - DRM_FORMAT_YVU444, - DRM_FORMAT_P010, - DRM_FORMAT_P012, - DRM_FORMAT_P016, - DRM_FORMAT_R1, - DRM_FORMAT_R2, - DRM_FORMAT_R4, - DRM_FORMAT_R8, -}; - static struct drm_plane_state * vkms_plane_duplicate_state(struct drm_plane *plane) { @@ -227,8 +189,9 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 0, &vkms_plane_funcs, - vkms_formats, ARRAY_SIZE(vkms_formats), - NULL, config->type, config->name); + config->supported_formats, + config->supported_formats_count, NULL, config->type, + config->name); if (IS_ERR(plane)) return plane; From patchwork Fri Nov 22 17:20:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883441 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 CBD47E69185 for ; Fri, 22 Nov 2024 17:20:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4EECD10EC38; Fri, 22 Nov 2024 17:20:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="gf5W/Vtc"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1920910EC25 for ; Fri, 22 Nov 2024 17:20:36 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id C4B791C0008; Fri, 22 Nov 2024 17:20:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jzuSQ7XWNth9nLO58Lj8CZjuqIwgPyHE7wF5M+8a88E=; b=gf5W/Vtc8HqHlS1O+bD1C0QD130XNymKdl7yR4MGt67Fp49rg0u0p7Af8tVbA8xrfILeBf cFam/lthbqday4fm3KQbIoIjduaOj60tgjKFysXy7Wa9JcmuhxZ38j3+3sgf5zEvjSTUgT fUC5FB3rcIht4N4w4Q2xrGAv8BfxjPQag+Yzs9oLUs4LTZyY9MOc83cTjUjSa1qP9Owrue +8goZSNKSHS6fomyYgyugUqUPifnJ44kusOYENQSdV7cjUhX7ASWvPnqN+Y/U/d0stBPwG NKotWjtAPyeBFbdexGNLW5UCuVyKrwqB4PLi5s319729I9aXCAcZmDpfRQVI4w== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:20 +0100 Subject: [PATCH RFC v2 16/18] drm/vkms: Introduce config for connector status MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-16-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3589; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=bLnbWwXKLbazSIS/ctWB/cU2s2pysEf7G+KMJSRKhtE=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1RZc++KCbWtnju0RcA8/kxo/o/dtIsj7Qay ce2qVNzLKuJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9UQAKCRAgrS7GWxAs 4ngDD/wMrpUY/JjH/IEjiIkaPwViQ1no9IyNuGn4bXv5ELw0vXw4WnqKBR+UrUFOgYeEHMDM3uy TTht0dr/k4haU7nRyrROXs0RamiA6idrMR0THXy2OtCT6yvCQudWNaWc4/lxPr8fNZMHkfbNGwG QjO7rf7pt3/mUNitR5PDhuPGhWOLKBBpvW5Ezkum25+9M9kmcaMHBsss9629KNbv10OyFB45Pjg 8800k5e6m2o3D9+y8ktZDVM0KFxuh68ti33QfWyWRCcHDawuGfd+ZY7HY0J54i+2RzjvtgEJsOZ wpnK2E5eeYWtjl5SHL8k5gAc3fHATxd3kmtBun+dzYbzxVuWB+VHEYqSYmuT0UXdEeCd/RKf6Q0 CRJlGHCQYnosbniZatNlOvQb1HfQlczVX/rNWkWkKw7H5Vq1yKcYQAPac/6xPbe9sZS9zMLEX6/ 3uf8XcabJJZQUzKuxlVUi9ruGEU1w1TdZFRSDB6antAHu+An9SBiYrxFC/TRNmDX793IghLEWpB czYBe6wIe3s9XGL4T5sA6S4JjpXRektdWlY36tsPhsUxkjsNU9lcl6d7OFAWhf6j1+YXOiALPVG nHLkybe08vPs/ZWjx0f+QcrSCVJirJX8GogeLKozG1d4v96MggQJk3O26IOSyh7IhZ8ercKv0hj PA0MAe40oeL/COw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" Signed-off-by: José Expósito [adpated it for my implementation] Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 10 ++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 4 ++++ drivers/gpu/drm/vkms/vkms_output.c | 17 +++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 4726929c2b54b2e670f9ef53b05ec009ca495e08..ac1a9658c5075c118d59da965ca3392355ccb2b2 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -2,6 +2,7 @@ #include #include +#include #include "vkms_config.h" #include "vkms_drv.h" @@ -197,10 +198,19 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *v list_add(&vkms_config_connector->link, &vkms_config->connectors); xa_init_flags(&vkms_config_connector->possible_encoders, XA_FLAGS_ALLOC); vkms_config_connector->type = DRM_MODE_CONNECTOR_VIRTUAL; + vkms_config_connector->status = connector_status_unknown; return vkms_config_connector; } +void vkms_config_connector_update_status(struct vkms_config_connector *vkms_config_connector, + enum drm_connector_status status) +{ + vkms_config_connector->status = status; + if (vkms_config_connector->connector) + drm_kms_helper_hotplug_event(vkms_config_connector->connector->dev); +} + struct vkms_config_crtc *vkms_config_create_crtc(struct vkms_config *vkms_config) { if (!vkms_config) diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 5487e0140da0e111c36f9a22d4e783a20c880a1d..bba56c9d8aeceac97a4339ef42ab663c5dc54e65 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -111,11 +111,15 @@ struct vkms_config_connector { struct xarray possible_encoders; int type; + enum drm_connector_status status; /* Internal usage */ struct drm_connector *connector; }; +void vkms_config_connector_update_status(struct vkms_config_connector *vkms_config_connector, + enum drm_connector_status status); + /** * vkms_config_register_debugfs() - Register the debugfs file to display current configuration */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index aea6366fd9a662483ed5a255d02d5025a30297f7..fc6a0cdade0739b94820ed4e0924cf355137fe79 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -7,9 +7,26 @@ #include #include +static enum drm_connector_status vkms_connector_detect(struct drm_connector *connector, bool force) +{ + struct vkms_device *vkmsdev = drm_device_to_vkms_device(connector->dev); + enum drm_connector_status status = connector->status; + struct vkms_config_connector *connector_cfg; + + list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, link) { + if (connector_cfg->connector == connector) { + status = connector_cfg->status; + break; + } + } + + return status; +} + static const struct drm_connector_funcs vkms_connector_funcs = { .fill_modes = drm_helper_probe_single_connector_modes, .reset = drm_atomic_helper_connector_reset, + .detect = vkms_connector_detect, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; From patchwork Fri Nov 22 17:20:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883440 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 1DBEBE69185 for ; Fri, 22 Nov 2024 17:20:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 15BF610EC36; Fri, 22 Nov 2024 17:20:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="R1NabfzX"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0A73C10EC2F for ; Fri, 22 Nov 2024 17:20:37 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id D09E21C0009; Fri, 22 Nov 2024 17:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Ng8HIjJ5WKO/B/KgkTLuuX73lEr5Mvi5DID38i4cXk=; b=R1NabfzXe7vbzmDKMRhyUDjGH/oe0DQQvr3Pd6MTwx/yXFhXMXhIWvsjH/BkuKp7gPn7mK eF1ptn22OT/auilUHmb9ysMzM1hn4gJt5M4P1p5dOOgtq5MsmY924oXDBCeNvp5m2pIbnt 8/tswg0pED4gjG4/PfK+nBaPrKNUoPXVQO6UQG1Op/3W2NtZYXAIMqcRko4yOpSS9GbfIu AwDLIqy9LU5RJ1QALCpXWbARK+LVnTEv/fnblMe/n7A+cpOxb9YeEBMq9sxRBCng9TMW7A WDVKJ/03hxzjF+/wa6SrTxTM5LFjxRqNfQN8o5ZH8rmGHWpQKsaHotmTwysiPQ== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:21 +0100 Subject: [PATCH RFC v2 17/18] drm/vkms: Introduce config for connector EDID MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-17-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3463; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=WmeSrjtBmfwRHkFWb5YcawuoDv1h/e6bqt11lWh1plI=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1RH2ywbySfqdkYO6lLhI9Urdh663Fqn1Hge k19dC0SJJaJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9UQAKCRAgrS7GWxAs 4vf+EACKzvaNuROasKjIezksY9fhX0J4Nh/HDvR6m1UiygnBO4A1QVCri4N98YTe3JzdXJkzKg8 Dxryg26XXP1Gz6tRQJ8lQaKqIW1zDYifqA9wuds1UrxfpLJ+p79QCkk6ba93KFdOarBYw1ALNO6 rIl6wwjZfs+kB9fR+47PT1XPhurHjDa8pEKtDxqk4tZzxkUlEq4CLkr8NDVrxQyUGGaxz4ztY+F n/XUk15p++0/cCcBjuAyT0GuT7IOVbSnp7PiKehnd9W3IiR6m0X+3AvdG7OZYuYCOcusR6CaJdW Gt/tKGgRecx3F3X55umztzrjl9ha+ywV9B35fPAvV0Nq+z0qCTcspQ4OCCAeW29Q8lHu92feNCP mhve5HQGPED755XzHahwNGblktE94UAQ/cuJcmViut9i/LdSb2zSXVRlgvxgHwCXFbuOSRbT3Hv 4gz1uDC646AIUXbpenxP1dpdbJpl6fesKdeRgtSOZ+1KHTrEuGNM2Y+s+4RpTN2haHFpB6qYRzX LUjYtLjzHPEpMI8dBYT9nOBga/LjRA4faJUzcvGfVhmzTrMRP6GKHs3w34jC/j6OiRBjEkCN6my n2+A4A2tUmN7jsnggP++JEhLOoDXBV8TykRwcukRfngQhUW6da2HdJ7DahWCFuy2y7i0hDGiqJt DtnrNvG3eKiKMbA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" To properly test the EDID reading without using the DRM override, add an option to configure the EDID for a connector. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 1 + drivers/gpu/drm/vkms/vkms_config.h | 2 ++ drivers/gpu/drm/vkms/vkms_output.c | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index ac1a9658c5075c118d59da965ca3392355ccb2b2..1a1234d4f10fa8e5ea6bd649139ecc10c991f875 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -199,6 +199,7 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *v xa_init_flags(&vkms_config_connector->possible_encoders, XA_FLAGS_ALLOC); vkms_config_connector->type = DRM_MODE_CONNECTOR_VIRTUAL; vkms_config_connector->status = connector_status_unknown; + vkms_config_connector->edid_blob_len = 0; return vkms_config_connector; } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index bba56c9d8aeceac97a4339ef42ab663c5dc54e65..1220b16f6c98d1ebb0ae55d662a84fe25e1a6a02 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -112,6 +112,8 @@ struct vkms_config_connector { struct xarray possible_encoders; int type; enum drm_connector_status status; + char edid_blob[PAGE_SIZE]; + int edid_blob_len; /* Internal usage */ struct drm_connector *connector; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index fc6a0cdade0739b94820ed4e0924cf355137fe79..56590afb33d75465971d10a282040690840cdbee 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -31,13 +31,44 @@ static const struct drm_connector_funcs vkms_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; +static int vkms_connector_read_block(void *context, u8 *buf, unsigned int block, size_t len) +{ + struct vkms_config_connector *config = context; + + if (block * len + len > config->edid_blob_len) + return 1; + memcpy(buf, &config->edid_blob[block * len], len); + return 0; +} + static int vkms_conn_get_modes(struct drm_connector *connector) { + const struct drm_edid *drm_edid = NULL; int count; + struct vkms_config_connector *connector_cfg; + struct vkms_device *vkmsdev = drm_device_to_vkms_device(connector->dev); + struct vkms_config_connector *context = NULL; + + list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, link) { + if (connector_cfg->connector == connector) { + context = connector_cfg; + break; + } + } + if (context) + drm_edid = drm_edid_read_custom(connector, vkms_connector_read_block, context); + + /* + * Unconditionally update the connector. If the EDID was read + * successfully, fill in the connector information derived from the + * EDID. Otherwise, if the EDID is NULL, clear the connector + * information. + */ + drm_edid_connector_update(connector, drm_edid); + + count = drm_edid_connector_add_modes(connector); - /* Use the default modes list from DRM */ - count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX); - drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF); + drm_edid_free(drm_edid); return count; } From patchwork Fri Nov 22 17:20:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883443 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 60899E69187 for ; Fri, 22 Nov 2024 17:20:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D3C310EC3B; Fri, 22 Nov 2024 17:20:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="AlQpVBJj"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id E56A210EC2F for ; Fri, 22 Nov 2024 17:20:38 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id C14871C000B; Fri, 22 Nov 2024 17:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732296037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UAYdQPQtzh0gV8wVAo7qgs3QH7T2hO6Bm9p3RfcWbfs=; b=AlQpVBJj8b/EqgHli+UQ7eFaHxoDvFgf/s7CF08nV/g1hWoOCMJYRooE9E7aHaYxZHYmx0 8PCQpBwHiCPNVTAd12imQWPZ6JKrzXOxGA/WUkj+wajoKbQ9JQfggG94pes2alMCxMVPdo YRaRSZL2SWb90OsSl30JNE8MtJWT0vRVXqrlE8i33S4gkfhQf2S3SZ7ONh0iiYagLPhenI CsxcKQ1VuL9G0b7NDC7jTmKuP4UV+cCT7ftp3rkFXZS1bmrZ8hF94IUTlMio7gXCz43JLy yCjwNAIBKQ21rCVnkDbHdr7MY/Z0nd+eaVDSAy9FoxJkN2DmPMLrGBX0ho59Mw== From: Louis Chauvet Date: Fri, 22 Nov 2024 18:20:22 +0100 Subject: [PATCH RFC v2 18/18] drm/vkms: Introduce config for encoder type MIME-Version: 1.0 Message-Id: <20241122-google-remove-crtc-index-from-parameter-v2-18-81540742535a@bootlin.com> References: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> In-Reply-To: <20241122-google-remove-crtc-index-from-parameter-v2-0-81540742535a@bootlin.com> To: =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2487; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=M7OgKbAdZgFO249hi2gxd30GoPTFZoLXWvm7U1pXG+M=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQL1RktCDzrK7xLIUWST0RT3iZxjH/j5M6TjTU 8IQg2w3V4SJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0C9UQAKCRAgrS7GWxAs 4k40D/0X96OevF8YTgDp6mfrO1u3L+J0lO4dC5KgyLl50KzpiR3bdh2zjlKnOuky/jAoN0OmQZ8 joAtgkUCjOtQ4WHhNo59O33wPE3+6v14pugtyPfFFOdS4lu7kaVvcqZoSTYg+F35rCP4iXL+JQc jzlywI2OZ8m33jAC/wbk5a8hdz+YNxoITPbnRa1rPvKCLOxPD57On94LYPE9vEGcjWVRD5ds5oY /pNyMxMxMyK/zPsBbQV1FKRzMN+0fziu6j8Q8FtHk/3tKaZwfOBCSwxBy/m6sOseJbHldmvLVJL KK5oOeb1M4yD+ta1kRpqQ7s7EPssJObn+GYhM2RB290Us1PiIL6FbvVBg8QgqgqWkoMYluaLG90 XHsllHXZYncrf+ryAWKguPkRK8vFRl+ZR3x9s5dmAcn5LgJ5TCTt6qqVF8abeIIr/4HFcuhpTFO HP83sRBFH7WXn5fiOfq71ul9gzv0S9Uik5OjKH9kOptweTur83JsKuzjM5p1YEau5074ZXevEPV G8XvO+6mBwBxeIupunq54xlRIi7t8X8+g2DDypLPGyMuMGfzpq6SkXxxxqQ1DCw3Hl4WVTYOzJy fGN7ZijUWVrTlAJMjW+HnEKXIxQoch2vP6Ix8DzCEAbpeNJnJ8ni9VK5QMa9UAG09d1tAM6hLzp bQPltUJQ3dR3QBg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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" Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 1 + drivers/gpu/drm/vkms/vkms_config.h | 2 ++ drivers/gpu/drm/vkms/vkms_output.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 1a1234d4f10fa8e5ea6bd649139ecc10c991f875..26280ad223208a978c44ef9c6c6eaadf1756818d 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -242,6 +242,7 @@ struct vkms_config_encoder *vkms_config_create_encoder(struct vkms_config *vkms_ if (!vkms_config_encoder) return NULL; + vkms_config_encoder->type = DRM_MODE_ENCODER_VIRTUAL; list_add(&vkms_config_encoder->link, &vkms_config->encoders); xa_init_flags(&vkms_config_encoder->possible_crtcs, XA_FLAGS_ALLOC); diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 1220b16f6c98d1ebb0ae55d662a84fe25e1a6a02..c6fe0573abd899e4b44b5ad390ff72e12664973f 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -55,6 +55,7 @@ struct vkms_config_crtc { * @link: Link to the others encoders * @name: Name of the encoder * @possible_crtcs: List of CRTC that can be used with this encoder + * @type: Type of encoder, see drm_mode.h, DRM_MODE_ENCODER_* * @encoder: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms encoder during device creation. This pointer is * not managed by the configuration and must be managed by other means. @@ -64,6 +65,7 @@ struct vkms_config_encoder { char *name; struct xarray possible_crtcs; + char type; /* Internal usage */ struct drm_encoder *encoder; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 56590afb33d75465971d10a282040690840cdbee..7c87da5757529b9a8dae880cd32272be7dd46a27 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -125,7 +125,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) if (!config_encoder->encoder) return -ENOMEM; ret = drmm_encoder_init(dev, config_encoder->encoder, NULL, - DRM_MODE_ENCODER_VIRTUAL, config_encoder->name); + config_encoder->type, config_encoder->name); if (ret) { DRM_ERROR("Failed to init encoder\n"); return ret;