Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Smithay/drm-rs/llms.txt

Use this file to discover all available pages before exploring further.

An encoder is the bridge between a CRTC and a connector. It converts raw pixel data from the CRTC into the electrical signal that a particular connector technology can carry — TMDS for HDMI and DVI-D, DAC for VGA, LVDS for embedded panels, and so on. On most modern discrete and integrated GPUs the encoder logic is embedded inside the display engine and not directly user-configurable. The DRM API still exposes encoder objects so that user-space can determine which CRTCs and connectors can be wired together. Not every CRTC can drive every connector; the encoder’s possible_crtcs bitmask encodes these hardware constraints. Encoders are enumerated through Device::resource_handles() and inspected with Device::get_encoder().

encoder::Handle

An opaque, copy-cheap handle to an encoder resource. Internally a NonZeroU32 wrapped with repr(transparent). Implements ResourceHandle with FFI_TYPE = DRM_MODE_OBJECT_ENCODER.
let res = card.resource_handles().unwrap();
let encoder_handles: &[encoder::Handle] = res.encoders();

encoder::Info

Returned by Device::get_encoder(). Describes the type and current attachment of an encoder.
MethodReturn typeDescription
handle()HandleThe encoder’s own handle
kind()KindTechnology type of this encoder
crtc()Option<crtc::Handle>The CRTC this encoder is currently feeding, or None if unused
possible_crtcs()CrtcListFilterBitmask of CRTCs that can drive this encoder; use with ResourceHandles::filter_crtcs
Info also implements Display, formatting as "Encoder <id>".
possible_clones() is defined in the source but is currently unimplemented!(). Do not call it.

encoder::Kind

The signal encoding technology. Maps to the kernel’s DRM_MODE_ENCODER_* constants.
VariantDescription
NoneNo encoder / unspecified
DACDigital-to-Analogue Converter — drives VGA and TV outputs
TMDSTransition-Minimised Differential Signalling — HDMI and DVI-D
LVDSLow-Voltage Differential Signalling — internal laptop panels
TVDACTV-specific DAC encoder
VirtualVirtual/software encoder (used with Virtual connectors)
DSIMIPI Display Serial Interface — mobile and embedded panels
DPMSTDisplayPort Multi-Stream Transport hub
DPIDisplay Parallel Interface
Kind implements From<u32> and From<Kind> for u32 for FFI conversion.

Looking Up Encoders from a Connector

When setting up a display, traverse the connectors compatible encoders to find an available CRTC:
use drm::control::Device as ControlDevice;

let res = card.resource_handles().unwrap();
let con_info = card.get_connector(con_handle, false).unwrap();

for &enc_handle in con_info.encoders() {
    let enc_info = card.get_encoder(enc_handle).unwrap();
    println!(
        "Encoder {:?}: kind={:?}",
        enc_handle,
        enc_info.kind(),
    );

    // Find a compatible CRTC
    let compatible = res.filter_crtcs(enc_info.possible_crtcs());
    if let Some(crtc_handle) = compatible.first() {
        println!("  -> can use CRTC {:?}", crtc_handle);
    }
}
encoder::Info::crtc() returns the encoder’s current CRTC attachment. If you are setting up a new output, prefer selecting from possible_crtcs() filtered by ResourceHandles::filter_crtcs to find an available one rather than relying on the current state.

Build docs developers (and LLMs) love