Configuring the pipelineΒΆ

At this stage we already know enough things to detect a connected video display and to allocate generic buffers and frames. We just need to learn how to connect entities to build a pipeline and finally display something on the screen.

The whole source code can be found here.

We first need to find a primary plane and check the pixel formats it supports. Then we need a Controller that can work with the plane (obtained with planePossibleControllers). Finally we need to build the pipeline with code similar to the following one:

assertLogShowErrorE "Config" <| withModeBlob card mode \modeBlobID ->
   configureGraphics card Commit EnableVSync EnableFullModeset do
      setConnectorSource conn ctrlID -- connector  <-> controller
      setPlaneTarget plane ctrlID    -- controller <-> plane
      setPlaneSource plane frame     -- plane      <-> frame
      -- sizes and mode
      setPlaneSize plane (frameWidth frame) (frameHeight frame)
      setPlaneSourceSize plane (frameWidth frame) (frameHeight frame)
      setMode ctrlID modeBlobID
      -- enable the controller
      enableController ctrlID True

We allocate a Mode blob on the graphic card with withModeBlob. Then we use configureGraphics to send a batch of commands to the chipset: the commands will either all succeed or none of them will be applied (atomicity).

To test that a batch of commands is valid, you can pass TestOnly instead of Commit and check for errors.

You can allow or disallow a full mode-setting with EnableFullModeset and DisableFullModeset. A full mode-setting is costly so avoid it if you can afford to run in a degraded mode for some time.

You can enable or disable vertical synchronization (VSYNC). It is recommended to enable it to avoid tearing and because some drivers seem to require it.

The example code should display the following pattern on the screen: