To select an encoder, CRTC, and connector

  1. Open a DRM device file using drmOpen.
  2. Obtain DRM-KMS resources using drmModeGetResources.
  3. (Optional) Get plane info using drmModeGetPlane and drmModeGetPlaneResources.
  4. Query the desired connector using drmModeGetConnector.

    All valid modes for a connector can be retrieved with a call to drmModeGetConnector. Select the mode to be used and save it. The first mode in the list is the default mode with the highest resolution possible and often a suitable choice

  5. If there is already an encoder attached to the connector, choose it using drmModeGetEncoder.

    If the attached encoder is incompatible with CRTC/plane find another one by iterating over all available encoders.

  6. Select a suitable CRTC.
    • For each connector, find a CRTC to drive this connector. To find a suitable CRTC, iterate over the list of encoders that are available for each connector. Each encoder contains a list of CRTCs that it can work with and select one of these CRTCs.
    • Query info for CRTC, drmModeGetCrtc.
  7. If necessary, set the mode using drmModeSetCrtc. Obtain the layer for the plane/CRTC.

    Use CRTC to drive the selected connector with a call to drmModeSetCrtc.

  8. If a plane must be used, set it using drmModeSetPlane.