mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
Now that we have the ability to represent the context in which a DRM device is in at compile-time, we can start carrying around this context with GEM object types in order to allow a driver to safely create GEM objects before a DRM device has registered with userspace. Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Link: https://patch.msgid.link/20260507220044.3204919-4-lyude@redhat.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
44 lines
949 B
Rust
44 lines
949 B
Rust
// SPDX-License-Identifier: GPL-2.0 or MIT
|
|
//! GEM buffer object management for the Tyr driver.
|
|
//!
|
|
//! This module provides buffer object (BO) management functionality using
|
|
//! DRM's GEM subsystem with shmem backing.
|
|
|
|
use kernel::{
|
|
drm::{
|
|
gem,
|
|
DeviceContext, //
|
|
},
|
|
prelude::*, //
|
|
};
|
|
|
|
use crate::driver::{
|
|
TyrDrmDevice,
|
|
TyrDrmDriver, //
|
|
};
|
|
|
|
/// Tyr's DriverObject type for GEM objects.
|
|
#[pin_data]
|
|
pub(crate) struct BoData {
|
|
flags: u32,
|
|
}
|
|
|
|
/// Provides a way to pass arguments when creating BoData
|
|
/// as required by the gem::DriverObject trait.
|
|
pub(crate) struct BoCreateArgs {
|
|
flags: u32,
|
|
}
|
|
|
|
impl gem::DriverObject for BoData {
|
|
type Driver = TyrDrmDriver;
|
|
type Args = BoCreateArgs;
|
|
|
|
fn new<Ctx: DeviceContext>(
|
|
_dev: &TyrDrmDevice<Ctx>,
|
|
_size: usize,
|
|
args: BoCreateArgs,
|
|
) -> impl PinInit<Self, Error> {
|
|
try_pin_init!(Self { flags: args.flags })
|
|
}
|
|
}
|