From 4fb2f85f67bc067749a20e94aeaa047681bee6e7 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 24 Jun 2012 11:01:25 +0200 Subject: [PATCH] main: use --fbdev options to switch between DRM/fbdev The new --fbdev option allows runtime switching between the two backends. That is, we only use fbdev devices when --fbdev is given. Otherwise, DRM is used. Technically, it would also be possible to use both. However, almost every DRM device does also register an fbdev device for backwards compatibility. Therefore, we must avoid using both, the DRM and fbdev device of the same display at the same time. As this would also mean dealing with failures in one backend and then switching to the other, we avoid this for complexity reasons. Who needs fbdev and drm simultaneously, anyway? Signed-off-by: David Herrmann --- src/conf.c | 4 ++++ src/conf.h | 2 ++ src/main.c | 21 ++++++++++++++++----- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/conf.c b/src/conf.c index edc6163..c17999c 100644 --- a/src/conf.c +++ b/src/conf.c @@ -67,6 +67,9 @@ static void print_help() "\t-t, --term Value of the TERM environment variable\n" "\t for the child process\n" "\n" + "Video Options:\n" + "\t --fbdev Use fbdev instead of DRM\n" + "\n" "Input Device Options:\n" "\t --xkb-layout Set XkbLayout for input devices\n" "\t --xkb-variant Set XkbVariant for input devices\n" @@ -84,6 +87,7 @@ int conf_parse_argv(int argc, char **argv) { "debug", no_argument, &conf_global.debug, 1 }, { "silent", no_argument, &conf_global.silent, 1 }, { "switchvt", no_argument, NULL, 's' }, + { "fbdev", no_argument, &conf_global.use_fbdev, 1 }, { "xkb-layout", required_argument, NULL, 1001 }, { "xkb-variant", required_argument, NULL, 1002 }, { "xkb-options", required_argument, NULL, 1003 }, diff --git a/src/conf.h b/src/conf.h index 871ecbd..e477937 100644 --- a/src/conf.h +++ b/src/conf.h @@ -53,6 +53,8 @@ struct conf_obj { int silent; /* enter new VT directly */ int switchvt; + /* use framebuffers instead of DRM */ + int use_fbdev; /* input KBD layout */ const char *xkb_layout; diff --git a/src/main.c b/src/main.c index 92fc170..ce23d3a 100644 --- a/src/main.c +++ b/src/main.c @@ -151,15 +151,23 @@ static void seat_free(struct kmscon_seat *seat) static void seat_add_video(struct kmscon_seat *seat, struct uterm_monitor_dev *dev, + unsigned int type, const char *node) { int ret; + unsigned int mode; if (seat->video) return; + if ((type == UTERM_MONITOR_FBDEV) != !!conf_global.use_fbdev) + return; - ret = uterm_video_new(&seat->video, seat->app->eloop, UTERM_VIDEO_DRM, - node); + if (conf_global.use_fbdev) + mode = UTERM_VIDEO_FBDEV; + else + mode = UTERM_VIDEO_DRM; + + ret = uterm_video_new(&seat->video, seat->app->eloop, mode, node); if (ret) return; @@ -211,8 +219,10 @@ static void monitor_event(struct uterm_monitor *mon, seat = ev->seat_data; if (!seat) break; - if (ev->dev_type == UTERM_MONITOR_DRM) - seat_add_video(seat, ev->dev, ev->dev_node); + if (ev->dev_type == UTERM_MONITOR_DRM || + ev->dev_type == UTERM_MONITOR_FBDEV) + seat_add_video(seat, ev->dev, ev->dev_type, + ev->dev_node); else if (ev->dev_type == UTERM_MONITOR_INPUT) uterm_input_add_dev(seat->input, ev->dev_node); break; @@ -220,7 +230,8 @@ static void monitor_event(struct uterm_monitor *mon, seat = ev->seat_data; if (!seat) break; - if (ev->dev_type == UTERM_MONITOR_DRM) + if (ev->dev_type == UTERM_MONITOR_DRM || + ev->dev_type == UTERM_MONITOR_FBDEV) seat_rm_video(seat, ev->dev); else if (ev->dev_type == UTERM_MONITOR_INPUT) uterm_input_remove_dev(seat->input, ev->dev_node);