[PATCH 1/2] fbdev: allow multiple concurrent visible consoles

From: Florian Tobias Schandinat
Date: Fri Sep 02 2011 - 21:11:28 EST


This patch allows having multiple visible consoles that receive
display updates. For example one can have running "top" to monitor
the system on fb0 and at the same time work on a shell on fb1.
At the moment that works only with consoles, not with console and
graphical application nor with two graphical applications.

Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@xxxxxx>
---
drivers/video/console/fbcon.c | 34 ++++++++++++++++++++++++++++++----
drivers/video/console/fbcon.h | 1 +
2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 8745637..ce9a686 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -94,6 +94,7 @@ enum {
};

static struct display fb_display[MAX_NR_CONSOLES];
+static struct vc_data *dummy_fg;

static signed char con2fb_map[MAX_NR_CONSOLES];
static signed char con2fb_map_boot[MAX_NR_CONSOLES];
@@ -816,7 +817,8 @@ static int set_con2fb_map(int unit, int newidx, int user)
int oldidx = con2fb_map[unit];
struct fb_info *info = registered_fb[newidx];
struct fb_info *oldinfo = NULL;
- int found, err = 0;
+ struct fbcon_ops *ops;
+ int found, err = 0, visible = vc && CON_IS_VISIBLE(vc);

if (oldidx == newidx)
return 0;
@@ -839,6 +841,15 @@ static int set_con2fb_map(int unit, int newidx, int user)
if (!err && !found)
err = con2fb_acquire_newinfo(vc, info, unit, oldidx);

+ if (!err && vc && oldinfo && oldinfo->fbcon_par) {
+ ops = oldinfo->fbcon_par;
+ if (vc->vc_display_fg == &ops->vc_fg) {
+ if (CON_IS_VISIBLE(vc))
+ ops->vc_fg = NULL;
+
+ vc->vc_display_fg = &dummy_fg;
+ }
+ }

/*
* If old fb is not mapped to any of the consoles,
@@ -852,6 +863,13 @@ static int set_con2fb_map(int unit, int newidx, int user)
int show_logo = (fg_console == 0 && !user &&
logo_shown != FBCON_LOGO_DONTSHOW);

+ ops = info->fbcon_par;
+ if (!ops->vc_fg || visible)
+ ops->vc_fg = vc;
+
+ if (vc && vc->vc_display_fg == &dummy_fg)
+ vc->vc_display_fg = &ops->vc_fg;
+
if (!found)
fbcon_add_cursor_timer(info);
con2fb_map_boot[unit] = newidx;
@@ -1023,8 +1041,10 @@ static void fbcon_init(struct vc_data *vc, int init)
int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
int cap, ret;

- if (info_idx == -1 || info == NULL)
- return;
+ if (info_idx == -1 || info == NULL) {
+ vc->vc_display_fg = &dummy_fg;
+ return;
+ }

cap = info->flags;

@@ -1089,6 +1109,10 @@ static void fbcon_init(struct vc_data *vc, int init)
con_copy_unimap(vc, svc);

ops = info->fbcon_par;
+ if (!ops->vc_fg)
+ ops->vc_fg = vc;
+
+ vc->vc_display_fg = &ops->vc_fg;
p->con_rotate = initial_rotation;
set_blitting_type(vc, info);

@@ -1184,8 +1208,10 @@ static void fbcon_deinit(struct vc_data *vc)
if (!ops)
goto finished;

- if (CON_IS_VISIBLE(vc))
+ if (CON_IS_VISIBLE(vc)) {
fbcon_del_cursor_timer(info);
+ ops->vc_fg = NULL;
+ }

ops->flags &= ~FBCON_FLAGS_INIT;
finished:
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
index 6bd2e0c..adc7316 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/console/fbcon.h
@@ -69,6 +69,7 @@ struct fbcon_ops {
struct timer_list cursor_timer; /* Cursor timer */
struct fb_cursor cursor_state;
struct display *p;
+ struct vc_data *vc_fg;
int currcon; /* Current VC. */
int cursor_flash;
int cursor_reset;
--
1.6.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/