From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1AF3392802 for ; Wed, 22 Apr 2026 16:49:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776876578; cv=none; b=EsNawMkrNr6JrBMmnysRZNUNGs4/U5LP5kld6Ziz7n87Zh9ne84Vd5ixf1mW/Bv5FbSvFU3ycck+QPXljTxBu/oLQe7YRbfnPRjZv7+DWA3JW228gjzoY7PRgGX7j46Ih5hu5+NpJocD8YXuH0324aijRLDWXz9Q/jRiGjXlU4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776876578; c=relaxed/simple; bh=obOecvEE8MY3zx5RwUnOUApWZU1fObAUiclO3cPqTQ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I5YHHAzqW5aIQB+raL5JR3kjlMV82W4Bvmt8UOOUj+yMzeoWCSIkCW152RYVkxTTwqs8EJXfjejEDmJRrUfHIm7K8GnZiLICAKLTpDMKW3LLCrslX1IE0sZEQb8I6yFiGo02MIRRPWNQMNo/XUdV7J6nE9CDeby+7rAa6sjLcQA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=WsnEWZEQ; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="WsnEWZEQ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 6A33A1A33AA; Wed, 22 Apr 2026 16:49:35 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 37DE65FA8F; Wed, 22 Apr 2026 16:49:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 013AA10460C14; Wed, 22 Apr 2026 18:49:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1776876574; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=yQbSHJ1pCmjkng+T8IWPSefSvSRH9WZoqqcDYcajovI=; b=WsnEWZEQ2f3oVm4ZZlEqQfkeVK5qGxkP6ZKBePWh+zbJwA7gghphVu0iStEX0e0iz4sP5V bjJFnCHfIPIqQz7gK3pXbJjernTBSj7Qnk+JoCheqMVJr5fjXkSilK1fShTd54UpPL736c U663umRUve+H6XzxkgJmR3dVRB3YeTp80g/X8k1PSltMpy3l7kk5RGzq+Z7xI5sb11vYFm 4VSgve1NpFbo41tiOnXVGe8d/XcmkWxJaZb+ZhQei7CzioyTr1ToTTVbOTqPXWbOtQEuCo IR1O53h8yRGmly/Qm5PKQyLbrmiRtTmy5hDkw2eiKRb1xugf2CCvYqWXqNPyAA== From: Louis Chauvet Date: Wed, 22 Apr 2026 18:48:13 +0200 Subject: [PATCH v4 16/37] drm/vkms: Introduce configfs for plane rotation Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260422-vkms-all-config-v4-16-dbb52e9aadc3@bootlin.com> References: <20260422-vkms-all-config-v4-0-dbb52e9aadc3@bootlin.com> In-Reply-To: <20260422-vkms-all-config-v4-0-dbb52e9aadc3@bootlin.com> To: Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , jose.exposito89@gmail.com, Jonathan Corbet , Shuah Khan , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: victoria@system76.com, sebastian.wick@redhat.com, victoria@system76.com, airlied@gmail.com, thomas.petazzoni@bootlin.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Louis Chauvet , llvm@lists.linux.dev X-Mailer: b4 0.16-dev X-Last-TLS-Session-Version: TLSv1.3 To allows the userspace to test many hardware configurations, introduce a new interface to configure the available rotation per planes. VKMS supports any rotation and reflection, so the userspace can choose any combination. The supported rotations are configured by writing a rotation bitmask to the file `supported_rotations` and the default rotation is chosen by writing a rotation bitmask to `default_rotation`. Signed-off-by: Louis Chauvet --- Documentation/ABI/testing/configfs-vkms | 15 ++++++ Documentation/gpu/vkms.rst | 7 ++- drivers/gpu/drm/vkms/vkms_configfs.c | 82 +++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms index 642d0dad8cca..55472f4e721d 100644 --- a/Documentation/ABI/testing/configfs-vkms +++ b/Documentation/ABI/testing/configfs-vkms @@ -109,6 +109,21 @@ Contact: dri-devel@lists.freedesktop.org Description: Name of the plane. +What: /sys/kernel/config/vkms//planes//supported_rotations +Date: Nov 2025 +Contact: dri-devel@lists.freedesktop.org +Description: + Available rotations for the plane, as a bitmask: + 0x01 - no rotation, 0x02 - rotate 90°, 0x04 - rotate 180°, + 0x08 - rotate 270°, 0x10 - reflect x, 0x20 - reflect y. + +What: /sys/kernel/config/vkms//planes//default_rotation +Date: Nov 2025 +Contact: dri-devel@lists.freedesktop.org +Description: + Default rotation presented to userspace, same values as + possible_rotations. + What: /sys/kernel/config/vkms//planes//possible_crtcs Date: Nov 2025 Contact: dri-devel@lists.freedesktop.org diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index 79f1185d8645..034565eb43ad 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -87,11 +87,16 @@ Start by creating one or more planes:: sudo mkdir /config/vkms/my-vkms/planes/plane0 -Planes have 2 configurable attributes: +Planes have 4 configurable attributes: - type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those exposed by the "type" property of a plane) - name: Name of the plane. Allowed characters are [A-Za-z1-9_-] +- supported_rotations: Available rotation for a plane, as a bitmask: 0x01 no rotation, + 0x02 rotate 90°, 0x04 rotate 180°, 0x08 rotate 270°, 0x10 reflect x, 0x20 reflect y + (same values as those exposed by the "rotation" property of a plane) +- default_rotation: Default rotation presented to the userspace, same values as + supported_rotations. Continue by creating one or more CRTCs:: diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c index e8d5792b0873..5ed6a7fa6046 100644 --- a/drivers/gpu/drm/vkms/vkms_configfs.c +++ b/drivers/gpu/drm/vkms/vkms_configfs.c @@ -384,12 +384,94 @@ static ssize_t plane_name_store(struct config_item *item, const char *page, return (ssize_t)count; } +static ssize_t plane_supported_rotations_show(struct config_item *item, char *page) +{ + struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item); + unsigned int plane_supported_rotations; + + scoped_guard(mutex, &plane->dev->lock) + plane_supported_rotations = vkms_config_plane_get_supported_rotations(plane->config); + + return sprintf(page, "%u", plane_supported_rotations); +} + +static ssize_t plane_supported_rotations_store(struct config_item *item, + const char *page, size_t count) +{ + struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item); + int ret, val = 0; + + ret = kstrtouint(page, 0, &val); + if (ret) + return ret; + + /* Should be a supported value */ + if (val & ~(DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK)) + return -EINVAL; + /* Should at least provide one rotation */ + if (!(val & DRM_MODE_ROTATE_MASK)) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->lock) { + if (plane->dev->enabled) + return -EBUSY; + + vkms_config_plane_set_supported_rotations(plane->config, val); + } + + return count; +} + +static ssize_t plane_default_rotation_show(struct config_item *item, char *page) +{ + struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item); + unsigned int plane_default_rotation; + + scoped_guard(mutex, &plane->dev->lock) { + plane_default_rotation = vkms_config_plane_get_default_rotation(plane->config); + } + + return sprintf(page, "%u", plane_default_rotation); +} + +static ssize_t plane_default_rotation_store(struct config_item *item, + const char *page, size_t count) +{ + struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item); + int ret, val = 0; + + ret = kstrtouint(page, 10, &val); + if (ret) + return ret; + + /* Should be a supported value */ + if (val & ~(DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK)) + return -EINVAL; + + /* Should contain exactly one rotation */ + if (!is_power_of_2(val & DRM_MODE_ROTATE_MASK)) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->lock) { + if (plane->dev->enabled) + return -EBUSY; + + vkms_config_plane_set_default_rotation(plane->config, val); + } + + return count; +} + CONFIGFS_ATTR(plane_, type); CONFIGFS_ATTR(plane_, name); +CONFIGFS_ATTR(plane_, supported_rotations); +CONFIGFS_ATTR(plane_, default_rotation); static struct configfs_attribute *plane_item_attrs[] = { &plane_attr_type, &plane_attr_name, + &plane_attr_supported_rotations, + &plane_attr_default_rotation, NULL, }; -- 2.54.0