mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
rust: drm: add FEAT_RENDER flag for render node support
Add FEAT_RENDER bool constant to the Driver trait to control render node support. When enabled, the driver exposes /dev/dri/renderDXX render nodes to userspace. The flag defaults to false, drivers can opt in by setting it to true in their Driver implementation. This is then enabled in the Tyr driver, while it's left disabled for Nova for the time being. Co-developed-by: Daniel Almeida <daniel.almeida@collabora.com> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Laura Nao <laura.nao@collabora.com> Link: https://patch.msgid.link/20260507080914.95478-2-laura.nao@collabora.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
committed by
Danilo Krummrich
parent
e2b773fb7b
commit
9c81596851
@@ -186,6 +186,7 @@ impl drm::Driver for TyrDrmDriver {
|
||||
type Object = drm::gem::shmem::Object<BoData>;
|
||||
|
||||
const INFO: drm::DriverInfo = INFO;
|
||||
const FEAT_RENDER: bool = true;
|
||||
|
||||
kernel::declare_drm_ioctls! {
|
||||
(PANTHOR_DEV_QUERY, drm_panthor_dev_query, ioctl::RENDER_ALLOW, TyrDrmFileData::dev_query),
|
||||
|
||||
@@ -80,6 +80,16 @@ pub struct Device<T: drm::Driver> {
|
||||
}
|
||||
|
||||
impl<T: drm::Driver> Device<T> {
|
||||
const fn compute_features() -> u32 {
|
||||
let mut features = drm::driver::FEAT_GEM;
|
||||
|
||||
if T::FEAT_RENDER {
|
||||
features |= drm::driver::FEAT_RENDER;
|
||||
}
|
||||
|
||||
features
|
||||
}
|
||||
|
||||
const VTABLE: bindings::drm_driver = drm_legacy_fields! {
|
||||
load: None,
|
||||
open: Some(drm::File::<T::File>::open_callback),
|
||||
@@ -105,7 +115,7 @@ impl<T: drm::Driver> Device<T> {
|
||||
name: crate::str::as_char_ptr_in_const_context(T::INFO.name).cast_mut(),
|
||||
desc: crate::str::as_char_ptr_in_const_context(T::INFO.desc).cast_mut(),
|
||||
|
||||
driver_features: drm::driver::FEAT_GEM,
|
||||
driver_features: Self::compute_features(),
|
||||
ioctls: T::IOCTLS.as_ptr(),
|
||||
num_ioctls: T::IOCTLS.len() as i32,
|
||||
fops: &Self::GEM_FOPS,
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
/// Driver use the GEM memory manager. This should be set for all modern drivers.
|
||||
pub(crate) const FEAT_GEM: u32 = bindings::drm_driver_feature_DRIVER_GEM;
|
||||
/// Driver supports render nodes, i.e.: /dev/dri/renderDXX devices.
|
||||
pub(crate) const FEAT_RENDER: u32 = bindings::drm_driver_feature_DRIVER_RENDER;
|
||||
|
||||
/// Information data for a DRM Driver.
|
||||
pub struct DriverInfo {
|
||||
@@ -115,6 +117,16 @@ pub trait Driver {
|
||||
|
||||
/// IOCTL list. See `kernel::drm::ioctl::declare_drm_ioctls!{}`.
|
||||
const IOCTLS: &'static [drm::ioctl::DrmIoctlDescriptor];
|
||||
|
||||
/// Sets the `DRIVER_RENDER` feature for this driver.
|
||||
///
|
||||
/// When enabled, the driver exposes `/dev/dri/renderDXX` render nodes to
|
||||
/// userspace. The render node is an alternate low-priviledge way to access
|
||||
/// the driver, which is enforced on a per-ioctl level. Userspace processes
|
||||
/// that open the render node can only invoke ioctls explicitly listed as
|
||||
/// usable from the render node (i.e. marked DRM_RENDER_ALLOW), whereas
|
||||
/// userspace processes using the master node can invoke any ioctl.
|
||||
const FEAT_RENDER: bool = false;
|
||||
}
|
||||
|
||||
/// The registration type of a `drm::Device`.
|
||||
|
||||
Reference in New Issue
Block a user