Code Analysis of Linux DRM architecture __linux

Source: Internet
Author: User

An article on the Linux display-driven DRM architecture is reviewed here in some order:

1 I connect the monitor to the DVI output of the video card, this connection is abstracted into Connector

2 on the DVI Connector driver will assign the DVI signal Encoder, if not allocated, Connector resources will find all available encoders

3 encoder is for Image scanning field CRTC service, the driver may assign CRTC to encoder, or can find the available from encoder POSSIBLE_CRTC

4 CRTC scan site to configure the physical memory area of the display image FB

5 FB-> CRTC-> encoder-> Connector After this relationship is bound, the drawing work has already started, you can write any painting on FB and get the display immediately.

6 in order to avoid image tearing, however, multiple FB (buffering) can be established to refresh the drawing by Pageflip operation.

7 Of course there are plane for video refresh, plane also bind to CRTC to work.

Two summary + DRM API usage:

API uses reference to David Herrmann <dh.herrmann@googlemail.com> Drm-howto and Weston and DRM-led modetest programs


The DRM API core configuration is to bind a CRTC relationship FB-> CRTC-> encoder-> Connector

We look at the "one" review, I was in reverse order. Haha in fact, this is only natural, how to use the API, look down:

1 First, open the DRM Drive module, and then get all the resources

FD = open ("/dev/dri/card0", O_RDWR | O_CLOEXEC);

Drmmoderes res = drmmodegetresources (FD);

What's in res, Res tells a few connector, a few encoder, a few CRTC, and their IDs, and they're completely out of complete sets.

2 starting from connector, the clues

Get CONNECOTR's specific resources first

Drmmodeconnector * conn = Drmmodegetconnector (FD, res->connectors[i]);

Conn resources are important in two parts, part is through the cable read out the display of "modes" such as 1920x1080@60, of course, you have to choose a favorite

The other part is encoder to start looking for encoder (see Drmmodeconnector definition) in the 2 order of a chapter:p

3 Find the right CRTC for encoder

Find CRTC in 3 order in one chapter

4 Create FB for CRTC

DRM example modetest written in detail, ARGB can be directly DRMMODEADDFB, multi-plane FB can be used drmModeAddFB2

5 binding

Core Four group < FB, CRTC, conn, mode >


int DRMMODESETCRTC (int fd, uint32_t crtcid, uint32_t Bufferid,

uint32_t x, uint32_t y, uint32_t *connectors, int count,

Drmmodemodeinfoptr mode);


6 Pageflip

extern int Drmmodepageflip (int fd, uint32_t crtc_id, uint32_t fb_id,
uint32_t flags, void *user_data);

This is a good game to write down,

First of all, poll (DRM_FD) can receive the Pollin message of the DRM, the message is that there are only two kinds of vblank, one is pageflip complete

Second, after receiving the message must call Drmhandleevent (DRM_FD, &evctx); To process the message, remember that you have to fill in the Evctx with your pageflip handler function.

What to do in the Pageflip processing function, pageflip a frame to end, of course, to pageflip the next frame.


7 plane

Plane's play did not understand, tried, using multiple buffering drmmodesetplane to change the page to achieve video playback, but encountered two problems:

One is the timing of setplane, and how to wait for a monitor's field to sync. See the Vblank code feel Vblank is for a video card synchronization, but I have more than one monitor.

The second is the Setplane run time, my i3 CPU to perform a use of ~ ms, inexplicably.

Ben thought of the plane YUV channel can save resources, there are two major problems in the inability to do, Pageflip FB can only be the same color space with the monitor, and is usually ARGB!!



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.