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:
| Mode | Value | Description |
|---|---|---|
| Sdr | 0 | Fixed SDR output. |
| AppleEdr | 1 | Apple EDR, extended according to headroom. |
| ExtendedLinear | 2 | Extended-linear output (the Android / Linux scRGB path). |
| Auto | 3 | Selected 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:
| Reason | Value | Description |
|---|---|---|
| None | 0 | No fallback. |
| DisplayHdrUnsupported | 1 | The display does not support HDR. |
| HybridCompositionRequired | 2 | Hybrid composition is required. |
| WgpuBackendNotVulkan | 3 | The wgpu backend is not Vulkan. |
| Rgba16FloatSurfaceFormatUnavailable | 4 | The surface does not support RGBA16F. |
| NativeWindowDataSpaceApiUnavailable | 5 | The native window lacks the data space API. |
| ScrgbDataSpaceVerificationFailed | 6 | scRGB data space verification failed. |
| SurfaceConfigureFailed | 7 | Surface configuration failed. |
| LegacyAppleEdrUnsupported | 8 | The 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統計#
| Field | Description |
|---|---|
| hdr_source_frames | Number of frames of HDR source content. |
| hdr10_output_frames | Number of frames output as HDR10 PQ. |
| sdr_tonemap_frames | Number of frames from HDR sources tone mapped to SDR output. |
| hdr10_metadata_updates | Number of HDR10 metadata updates. |
| hdr10_metadata_failures | Number of metadata generation failures. |
| hdr10_output_failures | Number of HDR10 output failures. |
| hdr10_output_active | Whether 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.