The DRM/KMS subsystem from a
newbie’s point of view
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com
1/49
Boris Brezillon
Embedded Linux engineer and trainer at Free Electrons
Embedded Linux development: kernel and driver
development, system integration, boot time and power
consumption optimization, consulting, etc.
Embedded Linux training, Linux driver development training
and Android system development training, with materials
freely available under a Creative Commons license.
http://free-electrons.com
Contributions
Kernel support for the AT91 SoCs ARM SoCs from Atmel
Kernel support for the sunXi SoCs ARM SoCs from
Allwinner
Living in Toulouse, south west of France
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com
2/49
Agenda
Context description
What is this talk about ?
How to display things in Linux ?
DRM/KMS overview
Global architecture
Partial description of the components
Sharing my experience
Tips on developing a DRM/KMS driver
Integration with userland graphic stacks
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com
3/49
Context: What is this talk about ?
Sharing my understanding of the DRM/KMS subsytem
learned while working on the Atmel HLCDC driver
Explaining some key aspects (from my point of view) of the
DRM/KMS subsystem
Explaining some common concepts in the video/graphic world
and showing how they are implemented in DRM/KMS
Sharing some tips on how to develop a KMS driver based on
my experience
This talk is not:
A detailed description of the DRM/KMS subsystem
A description on how to use a DRM device (user-space API)
And most importantly: this talk is not given by an expert
Don’t hesitate to correct me if you think I’m wrong ;-)
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com
4/49
Context: How to display things in the Linux world
Different solutions, provided by different subsystems:
FBDEV: Framebuffer Device
DRM/KMS: Direct Rendering Manager / Kernel Mode Setting
V4L2: Video For Linux 2
How to choose one: it depends on your needs
Each subsytem provides its own set of features
Different levels of complexity
Different levels of activity
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com
5/49
Context: Why choosing DRM/KMS ?
Actively maintained
Provides fine grained control on the display pipeline
Widely used by user-space graphic stacks
Provides a full set of advanced features
Why not FBDEV ?
Less actively maintained
Does not provides all the features we needed (overlays, hw
cursor, ...)
Developers are now encouraged to move to DRM/KMS
Why not V4L2 ?
Well suited for video capture and specific video output devices
but not for ”complex” display controllers
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com
6/49
DRM/KMS: Definition
DRM stands for Direct Rendering Manager and was
introduced to deal with graphic cards embedding GPUs
KMS stands for Kernel Mode Setting and is a sub-part of the
DRM API
Though rendering and mode setting are now splitted in two
different APIs (accessible through /dev/dri/renderX and
/dev/dri/controlDX)
KMS provide a way to configure the display pipeline of a
graphic card (or an embedded system)
KMS is what we’re interested in when looking for an FBDEV
alternative
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com
7/49
DRM/KMS: Architecture
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com
8/49