Documentation
¶
Overview ¶
Package kms lights every output of every DRM card on two linear XRGB8888 dumb buffers and flips frames to them with atomic commits, one per vblank, copying only what changed. It follows cards appearing and disappearing through kernel uevents, from a firmware framebuffer to the native driver.
Index ¶
Constants ¶
const BytesPerPixel = 4
BytesPerPixel is the size of a Frame's pixel.
Variables ¶
var SystemPaths = Paths{Dev: "/dev/dri", Sysfs: "/sys/class/drm"}
SystemPaths are the kernel's: /dev/dri and /sys/class/drm.
Functions ¶
Types ¶
type Card ¶
type Card struct {
// contains filtered or unexported fields
}
Card is one open DRM card and the outputs lit on it. The loop owns outputs, what it draws on, and the commit in req. Whatever probes or allocates, and with it crtcs, planes, built and retired, belongs to the card's worker: built are the outputs it holds buffers for and retired those the loop still has to stop drawing on.
func (*Card) Deactivate ¶
Deactivate drops DRM master and stops committing, leaving the last frame on screen for the next master.
func (*Card) Reactivate ¶
Reactivate takes DRM master back and shows the splash again with a modeset, since the master in between may have changed the mode.
type Damage ¶
type Damage struct {
// contains filtered or unexported fields
}
Damage is the rectangles of a frame that changed, kept apart so that what lies between them is neither copied nor reported to the kernel. Rectangles never overlap; past the capacity the two that grow the least are merged.
type Display ¶
type Display struct {
// contains filtered or unexported fields
}
Display is every DRM card's outputs. It is not safe for concurrent use: one goroutine opens it, handles its events and draws, while a worker per card does whatever could keep that goroutine waiting.
func Open ¶
Open opens every card under paths and lights its outputs, then follows cards appearing and disappearing. A card that fails to open is logged and left out, unless another process is master of it, when it is tried again for a while; with none at all, Outputs is empty and the splash has no graphical output.
func (*Display) Close ¶
Close releases every card and stops following uevents. With retain, the frames on screen stay there after the process exits (see Card.Release).
func (*Display) Deactivate ¶
Deactivate drops DRM master on every card, leaving the frames on screen; cards that appear meanwhile are opened deactivated.
func (*Display) Handle ¶
Handle applies e and says whether Outputs changed: a flip lets its output show the next frame, a card that disappears is dropped at once, and what takes time, a card appearing or a hotplug, goes to the card's worker, whose result is another Event.
func (*Display) Outputs ¶
Outputs are every lit output, ordered by card and connector. The list is built once per change, and a change gives a new list.
func (*Display) Reactivate ¶
Reactivate takes DRM master back on every card and shows the splash again.
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is something that happened to the display: a card's page flip, a uevent, something failing off the loop, or a card worker's result. Display.Handle applies it.
type FlipError ¶
FlipError is a frame of Output that did not reach the display. The output keeps it, and its next Present sends it.
type Frame ¶
Frame is 32-bit pixels in rows: little-endian ARGB8888 or XRGB8888, whose bytes are blue, green, red and alpha or padding.
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
Output is one connector lit on a CRTC and its primary plane, drawn into an upright frame in memory and copied, turned, into two scanout buffers.
func (*Output) Frame ¶
Frame is the upright frame to draw into, kept between frames so that a redraw only touches what changed. Present shows it.
func (*Output) Present ¶
Present shows the frame, of which only damage changed since the last Present. A frame presented while the previous one still waits for its vblank goes out on that vblank's flip event, so frames flip at most once per vblank.
type Paths ¶
Paths are where the display finds card nodes and their sysfs entries.
func (Paths) ClientsMustCloseBeforeRemoval ¶
type Rotation ¶
type Rotation uint8
Rotation is how a frame is turned on its way to a panel, so that a panel mounted sideways or upside down shows it upright.
The rotations, following the connector's "panel orientation" as plymouth maps it: "Upside Down" turns the frame half way, "Left Side Up" counter clockwise and "Right Side Up" clockwise.
type Scaler ¶
type Scaler struct {
// contains filtered or unexported fields
}
Scaler chooses each output's scale as plymouth does, except that once a firmware framebuffer forced a guess, the native driver's outputs keep the guessed value even when their mode differs, so the picture does not jump.
type Uevent ¶
Uevent is a kernel uevent about a device.
func ParseUevent ¶
ParseUevent reads one message from a NETLINK_KOBJECT_UEVENT socket: "ACTION@DEVPATH", then NUL-separated KEY=VALUE pairs. It fails on a message udev rebroadcasts, on a missing header and on an ACTION or DEVPATH pair that contradicts the header.