⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

DmaBufManager

Struct DmaBufManager 

Source
pub struct DmaBufManager { /* private fields */ }
Expand description

DMA-BUF manager.

Tracks supported formats, in-progress params builders, and imported buffers. Provides the server-side implementation of zwp_linux_dmabuf_v1.

Implementations§

Source§

impl DmaBufManager

Source

pub fn new() -> Self

Create a new DMA-BUF manager with default supported formats.

By default, supports ARGB8888 and XRGB8888 with the LINEAR modifier. These are universally supported by software renderers and virtio-gpu.

Source

pub fn get_supported_formats(&self) -> &[DmaBufFormat]

Get the list of supported format + modifier combinations.

Source

pub fn add_supported_format(&mut self, format: DmaBufFormat)

Add a supported format + modifier combination.

Source

pub fn is_format_supported(&self, fourcc: u32, modifier: u64) -> bool

Check whether a specific fourcc + modifier combination is supported.

Source

pub fn create_params(&mut self) -> u32

Create a new params builder. Returns the params object ID.

The client should subsequently call add_plane() for each buffer plane, then create_buffer() to finalize.

Source

pub fn add_plane( &mut self, params_id: u32, plane: DmaBufPlane, ) -> Result<(), KernelError>

Add a plane to an in-progress params builder.

Source

pub fn create_buffer( &mut self, params_id: u32, width: u32, height: u32, format: u32, flags: u32, ) -> Result<u32, KernelError>

Finalize a params builder and create an imported DMA-BUF buffer.

Validates that at least one plane was added and that the format is supported. Returns the buffer ID on success.

Source

pub fn destroy_buffer(&mut self, buffer_id: u32) -> Result<(), KernelError>

Destroy an imported buffer.

Source

pub fn import_from_virtio_gpu( &mut self, resource_id: u32, width: u32, height: u32, format: u32, ) -> Result<u32, KernelError>

Convenience wrapper: import a single-plane buffer from a virtio-gpu resource with the LINEAR modifier.

This is the common case for software-rendered content shared via virtio-gpu. The stride is computed as width * bpp.

Source

pub fn get_buffer(&self, buffer_id: u32) -> Option<&DmaBufBuffer>

Get a reference to an imported buffer.

Source

pub fn get_buffer_mut(&mut self, buffer_id: u32) -> Option<&mut DmaBufBuffer>

Get a mutable reference to an imported buffer.

Source

pub fn destroy_params(&mut self, params_id: u32) -> Result<(), KernelError>

Cancel an in-progress params builder without creating a buffer.

Source

pub fn buffer_count(&self) -> usize

Number of imported buffers.

Source

pub fn params_count(&self) -> usize

Number of in-progress params builders.

Trait Implementations§

Source§

impl Default for DmaBufManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for DmaBufManager

§

impl RefUnwindSafe for DmaBufManager

§

impl Send for DmaBufManager

§

impl Sync for DmaBufManager

§

impl Unpin for DmaBufManager

§

impl UnwindSafe for DmaBufManager

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.