kmscon: replace --fbdev/--dumb with --drm/--hwaccel
The old options were quite stupid and low-level. It doesn't make sense to require users to understand "--dumb" (besides, it sounds wrong). Therefore, two new options replace the old options: --drm: Enabled by default. If true, kmscon uses primary DRM devices and avoids primary fbdev devices. If false, kmscon uses no DRM devices at all but uses primary fbdev devices now. --hwaccel: Disabled by default. If true, kmscon tries to hardware-accelerate any rendering if available. This can also affect fbdev or other devices in the future. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
3e1f9f0c61
commit
3085b252ca
@ -36,6 +36,7 @@
|
||||
#include "kmscon_conf.h"
|
||||
#include "log.h"
|
||||
#include "shl_misc.h"
|
||||
#include "uterm.h"
|
||||
|
||||
static void print_help()
|
||||
{
|
||||
@ -119,9 +120,9 @@ static void print_help()
|
||||
"\t Create new terminal session\n"
|
||||
"\n"
|
||||
"Video Options:\n"
|
||||
"\t --fbdev [off] Use fbdev instead of DRM\n"
|
||||
"\t --dumb [off] Use dumb DRM instead of hardware-\n"
|
||||
"\t accelerated DRM devices\n"
|
||||
"\t --drm [on] Use DRM if available\n"
|
||||
"\t --hwaccel [off] Use 3D hardware-acceleration if\n"
|
||||
"\t available\n"
|
||||
"\t --primary-gpu-only [off] Use primary GPU only\n"
|
||||
"\t --all-gpus [off] Use all GPUs unconditionally\n"
|
||||
"\t --fps [50] Limit frame-rate\n"
|
||||
@ -396,6 +397,23 @@ static int copy_seats(struct conf_option *opt, const struct conf_option *src)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int aftercheck_drm(struct conf_option *opt, int argc, char **argv,
|
||||
int idx)
|
||||
{
|
||||
struct kmscon_conf_t *conf = KMSCON_CONF_FROM_FIELD(opt->mem, drm);
|
||||
|
||||
/* disable --drm if DRM runtime support is not available */
|
||||
if (conf->drm) {
|
||||
if (!uterm_video_available(UTERM_VIDEO_DRM) &&
|
||||
!uterm_video_available(UTERM_VIDEO_DUMB)) {
|
||||
log_info("no DRM runtime support available; disabling --drm");
|
||||
conf->drm = false;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Default Values
|
||||
* We use static default values to avoid allocating memory for these. This
|
||||
@ -482,8 +500,8 @@ int kmscon_conf_new(struct conf_ctx **out)
|
||||
CONF_OPTION_GRAB(0, "grab-terminal-new", &conf->grab_terminal_new, &def_grab_terminal_new),
|
||||
|
||||
/* Video Options */
|
||||
CONF_OPTION_BOOL(0, "fbdev", &conf->fbdev, false),
|
||||
CONF_OPTION_BOOL(0, "dumb", &conf->dumb, false),
|
||||
CONF_OPTION_BOOL_FULL(0, "drm", aftercheck_drm, NULL, NULL, &conf->drm, true),
|
||||
CONF_OPTION_BOOL(0, "hwaccel", &conf->hwaccel, false),
|
||||
CONF_OPTION_BOOL(0, "primary-gpu-only", &conf->primary_gpu_only, false),
|
||||
CONF_OPTION_BOOL(0, "all-gpus", &conf->all_gpus, false),
|
||||
CONF_OPTION_UINT(0, "fps", &conf->fps, 50),
|
||||
|
@ -109,10 +109,10 @@ struct kmscon_conf_t {
|
||||
struct conf_grab *grab_terminal_new;
|
||||
|
||||
/* Video Options */
|
||||
/* use framebuffers instead of DRM */
|
||||
bool fbdev;
|
||||
/* use dumb DRM devices */
|
||||
bool dumb;
|
||||
/* use DRM if available */
|
||||
bool drm;
|
||||
/* use 3D hardware-acceleration if available */
|
||||
bool hwaccel;
|
||||
/* use only primary GPU */
|
||||
bool primary_gpu_only;
|
||||
/* use all GPUs unconditionally */
|
||||
|
@ -200,6 +200,56 @@ static void app_seat_video_event(struct uterm_video *video,
|
||||
}
|
||||
}
|
||||
|
||||
static bool app_seat_is_ignored(struct app_seat *seat,
|
||||
unsigned int type,
|
||||
bool drm_backed,
|
||||
bool primary,
|
||||
bool aux,
|
||||
const char *node)
|
||||
{
|
||||
switch (type) {
|
||||
case UTERM_MONITOR_FBDEV:
|
||||
if (seat->conf->drm) {
|
||||
if (drm_backed) {
|
||||
log_info("ignoring video device %s on seat %s as it is a DRM-fbdev device",
|
||||
node, seat->name);
|
||||
return true;
|
||||
}
|
||||
if (primary) {
|
||||
log_info("ignoring video device %s on seat %s as it is a primary fbdev device",
|
||||
node, seat->name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UTERM_MONITOR_DRM:
|
||||
if (!seat->conf->drm) {
|
||||
log_info("ignoring video device %s on seat %s as it is a DRM device",
|
||||
node, seat->name);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log_info("ignoring unknown video device %s on seat %s",
|
||||
node, seat->name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (seat->conf->primary_gpu_only && !primary) {
|
||||
log_info("ignoring video device %s on seat %s as it is no primary GPU",
|
||||
node, seat->name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!seat->conf->all_gpus && !primary && !aux) {
|
||||
log_info("ignoring video device %s on seat %s as it is neither a primary nor auxiliary GPU",
|
||||
node, seat->name);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int app_seat_add_video(struct app_seat *seat,
|
||||
struct app_video **out,
|
||||
unsigned int type,
|
||||
@ -210,37 +260,12 @@ static int app_seat_add_video(struct app_seat *seat,
|
||||
unsigned int mode;
|
||||
struct app_video *vid;
|
||||
|
||||
if (seat->conf->fbdev) {
|
||||
if (type != UTERM_MONITOR_FBDEV) {
|
||||
log_info("ignoring video device %s on seat %s as it is not an fbdev device",
|
||||
node, seat->name);
|
||||
return -ERANGE;
|
||||
}
|
||||
} else if (type == UTERM_MONITOR_FBDEV) {
|
||||
if (flags & UTERM_MONITOR_DRM_BACKED) {
|
||||
log_info("ignoring video device %s on seat %s as it is a DRM-fbdev device",
|
||||
node, seat->name);
|
||||
return -ERANGE;
|
||||
}
|
||||
}
|
||||
|
||||
/* with --all-gpus we avoid any further filtering. With --fbdev we
|
||||
* already filtered all non-fbdev devices so there is currently no
|
||||
* reason to do further filtering, either.
|
||||
* TODO: We need to set PRIMARY flags to fbdev devices, too. Otherwise
|
||||
* we might end up with the same problems as DRM devices have. */
|
||||
if (!seat->conf->all_gpus && !seat->conf->fbdev) {
|
||||
if (seat->conf->primary_gpu_only && !(flags & UTERM_MONITOR_PRIMARY)) {
|
||||
log_info("ignoring video device %s on seat %s as it is no primary GPU",
|
||||
node, seat->name);
|
||||
return -ERANGE;
|
||||
}
|
||||
if (!(flags & (UTERM_MONITOR_PRIMARY | UTERM_MONITOR_AUX))) {
|
||||
log_info("ignoring video device %s on seat %s as it is neither a primary nor auxiliary GPU",
|
||||
node, seat->name);
|
||||
return -ERANGE;
|
||||
}
|
||||
}
|
||||
if (app_seat_is_ignored(seat, type,
|
||||
flags & UTERM_MONITOR_DRM_BACKED,
|
||||
flags & UTERM_MONITOR_PRIMARY,
|
||||
flags & UTERM_MONITOR_AUX,
|
||||
node))
|
||||
return -ERANGE;
|
||||
|
||||
log_debug("new video device %s on seat %s", node, seat->name);
|
||||
|
||||
@ -262,10 +287,10 @@ static int app_seat_add_video(struct app_seat *seat,
|
||||
}
|
||||
|
||||
if (type == UTERM_MONITOR_DRM) {
|
||||
if (seat->conf->dumb)
|
||||
mode = UTERM_VIDEO_DUMB;
|
||||
else
|
||||
if (seat->conf->hwaccel)
|
||||
mode = UTERM_VIDEO_DRM;
|
||||
else
|
||||
mode = UTERM_VIDEO_DUMB;
|
||||
} else {
|
||||
mode = UTERM_VIDEO_FBDEV;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user