From acba8f0177ba942887e455a1612df92147304f82 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Mon, 15 Oct 2012 14:25:59 +0200 Subject: [PATCH] uterm: video: fbdev: fix setting current-mode on activation We must not recreate a video-mode if we re-activate an fbdev display after wake-up. Otherwise, the "current" pointer changes and users might get confused. We guarantee that the "current" pointer stays the same during operation as we currently do not support changing display size without reactiating the display. Signed-off-by: David Herrmann --- src/uterm_video_fbdev.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/uterm_video_fbdev.c b/src/uterm_video_fbdev.c index 94672b3..36e139c 100644 --- a/src/uterm_video_fbdev.c +++ b/src/uterm_video_fbdev.c @@ -274,14 +274,16 @@ static int display_activate_force(struct uterm_display *disp, /* TODO: make dithering configurable */ disp->flags |= DISPLAY_DITHERING; - ret = mode_new(&disp->modes, &fbdev_mode_ops); - if (ret) { - munmap(disp->fbdev.map, disp->fbdev.len); - return ret; + if (!disp->current_mode) { + ret = mode_new(&disp->modes, &fbdev_mode_ops); + if (ret) { + munmap(disp->fbdev.map, disp->fbdev.len); + return ret; + } + disp->modes->fbdev.width = disp->fbdev.xres; + disp->modes->fbdev.height = disp->fbdev.yres; + disp->current_mode = disp->modes; } - disp->modes->fbdev.width = disp->fbdev.xres; - disp->modes->fbdev.height = disp->fbdev.yres; - disp->current_mode = disp->modes; disp->flags |= DISPLAY_ONLINE; return 0; @@ -298,7 +300,9 @@ static void display_deactivate_force(struct uterm_display *disp, bool force) return; log_info("deactivating device %s", disp->fbdev.node); - uterm_mode_unref(disp->modes); + + if (!force) + uterm_mode_unref(disp->current_mode); disp->modes = NULL; disp->current_mode = NULL; munmap(disp->fbdev.map, disp->fbdev.len);