Home/docs/kernel/High dynamic range

High dynamic range

HDR / EDR Output

liberika negotiates the output encoding per platform: Apple EDR, Windows HDR10 PQ, and extended-linear scRGB on Android and Linux. When negotiation fails, it falls back to SDR. The fallback reason and count are reported through ErikaOutputStatus; the kernel never degrades silently.

Output modes#

When it creates a Presenter, the host declares its request through ErikaPresenterConfig.output_mode:

ModeValueDescription
Sdr0Fixed SDR output.
AppleEdr1Apple EDR, extended according to headroom.
ExtendedLinear2Extended-linear output (the Android / Linux scRGB path).
Auto3Selected automatically based on the content and the surface's capabilities.

The encoding actually in effect is recorded in ErikaOutputStatus.active_encoding: SdrSrgb, AppleEdr, AndroidExtendedLinearScRgb, Hdr10Pq, and LinuxExtendedLinearScRgb. The requested mode and the active encoding can differ, and that difference is the fallback.

Headroom negotiation#

The EDR and scRGB paths negotiate dynamic range based on the display's peak brightness. The host calls set_output_headroom to provide the headroom it wants along with a flag saying whether that value is known, and the renderer converges to a usable value based on the surface's actual capabilities.

Status fields during negotiation:

  • requested_headroom — The value the host requested.
  • active_headroom / active_headroom_known — The value currently in effect, and whether it is valid.
  • headroom_updates — Number of times the effective value changed.
  • extended_linear_frames — Number of frames output with extended-linear encoding.

Fallback#

The ErikaOutputFallbackReason enumeration has 9 values, including None (no fallback occurred); the other 8 are actual fallback reasons:

ReasonValueDescription
None0No fallback.
DisplayHdrUnsupported1The display does not support HDR.
HybridCompositionRequired2Hybrid composition is required.
WgpuBackendNotVulkan3The wgpu backend is not Vulkan.
Rgba16FloatSurfaceFormatUnavailable4The surface does not support RGBA16F.
NativeWindowDataSpaceApiUnavailable5The native window lacks the data space API.
ScrgbDataSpaceVerificationFailed6scRGB data space verification failed.
SurfaceConfigureFailed7Surface configuration failed.
LegacyAppleEdrUnsupported8The legacy Apple EDR path is unavailable.

fallback_count is the cumulative number of fallbacks, and data_space_failures separately counts failed data space negotiations. A host can use these two values to judge whether HDR support on the target device is stable.

Android scRGB requires Vulkan, an RGBA16F surface, and the correct native window data space. Linux scRGB requires an FP16 extended-linear WSI. A regular SDR surface uses tone-mapped output.

HDR statistics#

FieldDescription
hdr_source_framesNumber of frames of HDR source content.
hdr10_output_framesNumber of frames output as HDR10 PQ.
sdr_tonemap_framesNumber of frames from HDR sources tone mapped to SDR output.
hdr10_metadata_updatesNumber of HDR10 metadata updates.
hdr10_metadata_failuresNumber of metadata generation failures.
hdr10_output_failuresNumber of HDR10 output failures.
hdr10_output_activeWhether the current output is HDR10.

Tone mapping and output transforms for HDR content happen inside the rendering pipeline; see Rendering pipeline.

Tone mapping and Dolby Vision#

Since 0.2.0, BT.2390 EETF is the default, and peak compression is done in the IPT color space. You can optionally choose operators such as spline, BT.2446a, ST 2094, Mobius, Reinhard, and clip. The black point and target contrast also take part in the mapping.

Dolby Vision RPU support covers piecewise / MMR reshaping and nonlinear matrix transforms, and Profile 5 / 8 is processed as BT.2020 / PQ. Profile 7 uses the base layer and its mapping; enhancement layer residuals do not yet take part in compositing. The kernel performs the rendering conversion itself rather than passing the Dolby Vision signal through to the display.

For HDR10 software frames, the peak can be adjusted using per-frame brightness statistics. The perceptual gamut mapping LUT is built on the CPU in the background and cached across frames. Apple EDR output updates with the display's headroom, and P010 uploads preserve 10-bit precision.

liberika v0.3.8 Section Kernel License MPL-2.0