Struct cros_libva::Display
source · pub struct Display { /* private fields */ }
Expand description
A VADisplay opened over DRM.
A Display is the starting point to using libva. This struct is essentially a safe wrapper over
VADisplay
, from which Surface
s and Context
s can be allocated in order to perform
actual work using Display::create_surfaces
and Display::create_context
, respectively.
Although libva offers several ways to create a display, this struct currently only supports opening through DRM. It may be extended to support other display types (X11, Wayland) in the future.
Implementations§
source§impl Display
impl Display
sourcepub fn open_drm_display<P: AsRef<Path>>(
path: P
) -> Result<Rc<Self>, OpenDrmDisplayError>
pub fn open_drm_display<P: AsRef<Path>>( path: P ) -> Result<Rc<Self>, OpenDrmDisplayError>
Opens and initializes a specific DRM Display
.
path
is the path to a DRM device that supports VAAPI, e.g. /dev/dri/renderD128
.
sourcepub fn open() -> Option<Rc<Self>>
pub fn open() -> Option<Rc<Self>>
Opens the first device that succeeds and returns its Display
.
If an error occurs on a given device, it is ignored and the next one is tried until one succeeds or we reach the end of the iterator.
sourcepub fn query_config_profiles(&self) -> Result<Vec<Type>, VaError>
pub fn query_config_profiles(&self) -> Result<Vec<Type>, VaError>
Queries supported profiles by this display by wrapping vaQueryConfigProfiles
.
sourcepub fn query_vendor_string(&self) -> Result<String, &'static str>
pub fn query_vendor_string(&self) -> Result<String, &'static str>
Returns a string describing some aspects of the VA implemenation on the specific hardware
accelerator used by this display. Wrapper over vaQueryVendorString
.
The format of the returned string is vendor specific and at the discretion of the
implementer. e.g. for the Intel GMA500 implementation, an example would be: Intel GMA500 - 2.0.0.32L.0005
.
sourcepub fn query_config_entrypoints(
&self,
profile: Type
) -> Result<Vec<Type>, VaError>
pub fn query_config_entrypoints( &self, profile: Type ) -> Result<Vec<Type>, VaError>
Query supported entrypoints for a given profile by wrapping vaQueryConfigEntrypoints
.
sourcepub fn get_config_attributes(
&self,
profile: Type,
entrypoint: Type,
attributes: &mut [VAConfigAttrib]
) -> Result<(), VaError>
pub fn get_config_attributes( &self, profile: Type, entrypoint: Type, attributes: &mut [VAConfigAttrib] ) -> Result<(), VaError>
Writes attributes for a given profile
/entrypoint
pair into attributes
. Wrapper over
vaGetConfigAttributes
.
Entries of attributes
must have their type_
member initialized to the desired attribute
to retrieve.
sourcepub fn create_surfaces<D: SurfaceMemoryDescriptor>(
self: &Rc<Self>,
rt_format: u32,
va_fourcc: Option<u32>,
width: u32,
height: u32,
usage_hint: Option<UsageHint>,
descriptors: Vec<D>
) -> Result<Vec<Surface<D>>, VaError>
pub fn create_surfaces<D: SurfaceMemoryDescriptor>( self: &Rc<Self>, rt_format: u32, va_fourcc: Option<u32>, width: u32, height: u32, usage_hint: Option<UsageHint>, descriptors: Vec<D> ) -> Result<Vec<Surface<D>>, VaError>
Creates Surface
s by wrapping around a vaCreateSurfaces
call.
The number of surfaces created will be equal to the length of descriptors
.
Arguments
rt_format
- The desired surface format. SeeVA_RT_FORMAT_*
va_fourcc
- The desired pixel format (optional). SeeVA_FOURCC_*
width
- Width for the create surfacesheight
- Height for the created surfacesusage_hint
- Optional hint of intended usage to optimize allocation (e.g. tiling)num_surfaces
- Number of surfaces to createdescriptors
- Memory descriptors used as surface memory backing.
Return value
Returns as many surfaces as the length of descriptors
.
Note that the descriptors
’s ownership is irrevocably given to the surfaces, and that in
case of error the descriptors
will be destroyed. Make sure to duplicate the descriptors
if you need something outside of libva to access them.
sourcepub fn create_context<D: SurfaceMemoryDescriptor>(
self: &Rc<Self>,
config: &Config,
coded_width: u32,
coded_height: u32,
surfaces: Option<&Vec<Surface<D>>>,
progressive: bool
) -> Result<Rc<Context>, VaError>
pub fn create_context<D: SurfaceMemoryDescriptor>( self: &Rc<Self>, config: &Config, coded_width: u32, coded_height: u32, surfaces: Option<&Vec<Surface<D>>>, progressive: bool ) -> Result<Rc<Context>, VaError>
Creates a Context
by wrapping around a vaCreateContext
call.
Arguments
config
- The configuration for the contextcoded_width
- The coded picture widthcoded_height
- The coded picture heightsurfaces
- Optional hint for the amount of surfaces tied to the contextprogressive
- Whether only progressive frame pictures are present in the sequence
sourcepub fn create_config(
self: &Rc<Self>,
attrs: Vec<VAConfigAttrib>,
profile: Type,
entrypoint: Type
) -> Result<Config, VaError>
pub fn create_config( self: &Rc<Self>, attrs: Vec<VAConfigAttrib>, profile: Type, entrypoint: Type ) -> Result<Config, VaError>
Creates a Config
by wrapping around the vaCreateConfig
call.
attrs
describe the attributes to set for this config. A list of the supported attributes
for a given profile/entrypoint pair can be retrieved using
Display::get_config_attributes
. Other attributes will take their default values, and
attrs
can be empty in order to obtain a default configuration.
sourcepub fn query_image_formats(&self) -> Result<Vec<VAImageFormat>, VaError>
pub fn query_image_formats(&self) -> Result<Vec<VAImageFormat>, VaError>
Returns available image formats for this display by wrapping around vaQueryImageFormats
.