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
impl DmaBufManager
Sourcepub fn new() -> Self
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.
Sourcepub fn get_supported_formats(&self) -> &[DmaBufFormat]
pub fn get_supported_formats(&self) -> &[DmaBufFormat]
Get the list of supported format + modifier combinations.
Sourcepub fn add_supported_format(&mut self, format: DmaBufFormat)
pub fn add_supported_format(&mut self, format: DmaBufFormat)
Add a supported format + modifier combination.
Sourcepub fn is_format_supported(&self, fourcc: u32, modifier: u64) -> bool
pub fn is_format_supported(&self, fourcc: u32, modifier: u64) -> bool
Check whether a specific fourcc + modifier combination is supported.
Sourcepub fn create_params(&mut self) -> u32
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.
Sourcepub fn add_plane(
&mut self,
params_id: u32,
plane: DmaBufPlane,
) -> Result<(), KernelError>
pub fn add_plane( &mut self, params_id: u32, plane: DmaBufPlane, ) -> Result<(), KernelError>
Add a plane to an in-progress params builder.
Sourcepub fn create_buffer(
&mut self,
params_id: u32,
width: u32,
height: u32,
format: u32,
flags: u32,
) -> Result<u32, KernelError>
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.
Sourcepub fn destroy_buffer(&mut self, buffer_id: u32) -> Result<(), KernelError>
pub fn destroy_buffer(&mut self, buffer_id: u32) -> Result<(), KernelError>
Destroy an imported buffer.
Sourcepub fn import_from_virtio_gpu(
&mut self,
resource_id: u32,
width: u32,
height: u32,
format: u32,
) -> Result<u32, KernelError>
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.
Sourcepub fn get_buffer(&self, buffer_id: u32) -> Option<&DmaBufBuffer>
pub fn get_buffer(&self, buffer_id: u32) -> Option<&DmaBufBuffer>
Get a reference to an imported buffer.
Sourcepub fn get_buffer_mut(&mut self, buffer_id: u32) -> Option<&mut DmaBufBuffer>
pub fn get_buffer_mut(&mut self, buffer_id: u32) -> Option<&mut DmaBufBuffer>
Get a mutable reference to an imported buffer.
Sourcepub fn destroy_params(&mut self, params_id: u32) -> Result<(), KernelError>
pub fn destroy_params(&mut self, params_id: u32) -> Result<(), KernelError>
Cancel an in-progress params builder without creating a buffer.
Sourcepub fn buffer_count(&self) -> usize
pub fn buffer_count(&self) -> usize
Number of imported buffers.
Sourcepub fn params_count(&self) -> usize
pub fn params_count(&self) -> usize
Number of in-progress params builders.