1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! This module implements the bindgen C FFI bindings for use within this crate
// The bindings are generated from vendored C headers; their doc comments carry
// bare URLs and other rustdoc-unfriendly markup. Don't lint generated docs.
include!;
use OnceLock;
/// The dlopen'd libva symbol table, resolved once on first use. The result is
/// cached (success or failure) so a missing libva is probed at most once.
static VA: = new;
/// Loads libva (via `libva-drm.so.2`) on first call and returns the symbol table.
///
/// `libva-drm.so.2` is linked against `libva.so.2`, so a single dlopen exposes
/// both `vaGetDisplayDRM` and the core `va*` symbols (dlsym on the handle searches
/// its dependencies). Returns `Err` if the library is absent, so a caller on a
/// libva-less host can fall back to another encoder instead of aborting.
pub
/// Accessor for the loaded libva symbols.
///
/// Panics if libva has not loaded. Every entry point that reaches libva goes
/// through a [`crate::Display`], whose constructor calls [`load`] and bails out on
/// failure, so by the time any other `va*` call runs the library is present.
pub