xref: /linux/drivers/gpu/drm/tyr/gem.rs (revision 4b99990cdf9560e8a071640baf19f312e6ae02f4)
1 // SPDX-License-Identifier: GPL-2.0 or MIT
2 //! GEM buffer object management for the Tyr driver.
3 //!
4 //! This module provides buffer object (BO) management functionality using
5 //! DRM's GEM subsystem with shmem backing.
6 
7 use kernel::{
8     drm::{
9         gem,
10         DeviceContext, //
11     },
12     prelude::*, //
13 };
14 
15 use crate::driver::{
16     TyrDrmDevice,
17     TyrDrmDriver, //
18 };
19 
20 /// Tyr's DriverObject type for GEM objects.
21 #[pin_data]
22 pub(crate) struct BoData {
23     flags: u32,
24 }
25 
26 /// Provides a way to pass arguments when creating BoData
27 /// as required by the gem::DriverObject trait.
28 pub(crate) struct BoCreateArgs {
29     flags: u32,
30 }
31 
32 impl gem::DriverObject for BoData {
33     type Driver = TyrDrmDriver;
34     type Args = BoCreateArgs;
35 
36     fn new<Ctx: DeviceContext>(
37         _dev: &TyrDrmDevice<Ctx>,
38         _size: usize,
39         args: BoCreateArgs,
40     ) -> impl PinInit<Self, Error> {
41         try_pin_init!(Self { flags: args.flags })
42     }
43 }
44