1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

terminal: add grdev DRM backend

The grdev-drm backend manages DRM cards for grdev. Any DRM card with
DUMB_BUFFER support can be used. So far, our policy is to configure all
available connectors, but keep pipes inactive as long as users don't
enable the displays on top.

We hard-code double-buffering so far, but can easily support
single-buffering or n-buffering. We also require XRGB8888 as format as
this is required to be supported by all DRM drivers and it is what VTs
use. This allows us to switch from VTs to grdev via page-flips instead of
deep modesets.

There is still a lot room for improvements in this backend, but it works
smoothly so far so more enhanced features can be added later.
This commit is contained in:
David Herrmann 2014-09-19 14:13:06 +02:00
parent 650c544427
commit f22e0bce37
5 changed files with 3036 additions and 0 deletions

View File

@ -3008,6 +3008,7 @@ libsystemd_terminal_la_SOURCES = \
src/libsystemd-terminal/grdev.h \
src/libsystemd-terminal/grdev-internal.h \
src/libsystemd-terminal/grdev.c \
src/libsystemd-terminal/grdev-drm.c \
src/libsystemd-terminal/idev.h \
src/libsystemd-terminal/idev-internal.h \
src/libsystemd-terminal/idev.c \

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,7 @@
#pragma once
#include <inttypes.h>
#include <libudev.h>
#include <stdbool.h>
#include <stdlib.h>
#include <systemd/sd-bus.h>
@ -39,6 +40,14 @@ typedef struct grdev_pipe grdev_pipe;
typedef struct grdev_card_vtable grdev_card_vtable;
typedef struct grdev_card grdev_card;
/*
* DRM cards
*/
bool grdev_is_drm_card(grdev_card *card);
grdev_card *grdev_find_drm_card(grdev_session *session, dev_t devnum);
int grdev_drm_card_new(grdev_card **out, grdev_session *session, struct udev_device *ud);
/*
* Displays
*/

View File

@ -20,6 +20,7 @@
***/
#include <inttypes.h>
#include <libudev.h>
#include <stdbool.h>
#include <stdlib.h>
#include <systemd/sd-bus.h>
@ -30,6 +31,7 @@
#include "hashmap.h"
#include "login-shared.h"
#include "macro.h"
#include "udev-util.h"
#include "util.h"
static void pipe_enable(grdev_pipe *pipe);
@ -1083,6 +1085,68 @@ void grdev_session_restore(grdev_session *session) {
card->vtable->restore(card);
}
void grdev_session_add_drm(grdev_session *session, struct udev_device *ud) {
grdev_card *card;
dev_t devnum;
int r;
assert(session);
assert(ud);
devnum = udev_device_get_devnum(ud);
if (devnum == 0)
return;
card = grdev_find_drm_card(session, devnum);
if (card)
return;
r = grdev_drm_card_new(&card, session, ud);
if (r < 0) {
log_debug("grdev: %s: cannot add DRM device for %s: %s",
session->name, udev_device_get_syspath(ud), strerror(-r));
return;
}
session_add_card(session, card);
}
void grdev_session_remove_drm(grdev_session *session, struct udev_device *ud) {
grdev_card *card;
dev_t devnum;
assert(session);
assert(ud);
devnum = udev_device_get_devnum(ud);
if (devnum == 0)
return;
card = grdev_find_drm_card(session, devnum);
if (!card)
return;
session_remove_card(session, card);
}
void grdev_session_hotplug_drm(grdev_session *session, struct udev_device *ud) {
grdev_card *card;
dev_t devnum;
assert(session);
assert(ud);
devnum = udev_device_get_devnum(ud);
if (devnum == 0)
return;
card = grdev_find_drm_card(session, devnum);
if (!card)
return;
/* TODO: hotplug card */
}
static void session_configure(grdev_session *session) {
grdev_display *display;
grdev_tile *tile;

View File

@ -55,6 +55,7 @@
#include <drm_fourcc.h>
#include <inttypes.h>
#include <libudev.h>
#include <stdbool.h>
#include <stdlib.h>
#include <systemd/sd-bus.h>
@ -171,6 +172,10 @@ void grdev_session_disable(grdev_session *session);
void grdev_session_commit(grdev_session *session);
void grdev_session_restore(grdev_session *session);
void grdev_session_add_drm(grdev_session *session, struct udev_device *ud);
void grdev_session_remove_drm(grdev_session *session, struct udev_device *ud);
void grdev_session_hotplug_drm(grdev_session *session, struct udev_device *ud);
/*
* Contexts
*/