Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 288089
Collapse All | Expand All

(-)a/drivers/video/console/fbcon.c (-22 / +150 lines)
Lines 80-85 Link Here
80
#include <asm/system.h>
80
#include <asm/system.h>
81
81
82
#include "fbcon.h"
82
#include "fbcon.h"
83
#include "fbcondecor.h"
83
84
84
#ifdef FBCONDEBUG
85
#ifdef FBCONDEBUG
85
#  define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
86
#  define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
Lines 95-101 enum { Link Here
95
96
96
static struct display fb_display[MAX_NR_CONSOLES];
97
static struct display fb_display[MAX_NR_CONSOLES];
97
98
98
static signed char con2fb_map[MAX_NR_CONSOLES];
99
signed char con2fb_map[MAX_NR_CONSOLES];
99
static signed char con2fb_map_boot[MAX_NR_CONSOLES];
100
static signed char con2fb_map_boot[MAX_NR_CONSOLES];
100
101
101
static int logo_lines;
102
static int logo_lines;
Lines 286-292 static inline int fbcon_is_inactive(stru Link Here
286
		vc->vc_mode != KD_TEXT || ops->graphics);
287
		vc->vc_mode != KD_TEXT || ops->graphics);
287
}
288
}
288
289
289
static inline int get_color(struct vc_data *vc, struct fb_info *info,
290
inline int get_color(struct vc_data *vc, struct fb_info *info,
290
	      u16 c, int is_fg)
291
	      u16 c, int is_fg)
291
{
292
{
292
	int depth = fb_get_color_depth(&info->var, &info->fix);
293
	int depth = fb_get_color_depth(&info->var, &info->fix);
Lines 391-396 static void fb_flashcursor(struct work_s Link Here
391
		CM_ERASE : CM_DRAW;
392
		CM_ERASE : CM_DRAW;
392
	ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
393
	ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
393
		    get_color(vc, info, c, 0));
394
		    get_color(vc, info, c, 0));
395
	
394
	release_console_sem();
396
	release_console_sem();
395
}
397
}
396
398
Lines 527-532 static int search_for_mapped_con(void) Link Here
527
static int fbcon_takeover(int show_logo)
529
static int fbcon_takeover(int show_logo)
528
{
530
{
529
	int err, i;
531
	int err, i;
532
	struct fb_info *info;
530
533
531
	if (!num_registered_fb)
534
	if (!num_registered_fb)
532
		return -ENODEV;
535
		return -ENODEV;
Lines 540-545 static int fbcon_takeover(int show_logo) Link Here
540
	err = take_over_console(&fb_con, first_fb_vc, last_fb_vc,
543
	err = take_over_console(&fb_con, first_fb_vc, last_fb_vc,
541
				fbcon_is_default);
544
				fbcon_is_default);
542
545
546
    info = registered_fb[info_idx];
547
543
	if (err) {
548
	if (err) {
544
		for (i = first_fb_vc; i <= last_fb_vc; i++) {
549
		for (i = first_fb_vc; i <= last_fb_vc; i++) {
545
			con2fb_map[i] = -1;
550
			con2fb_map[i] = -1;
Lines 547-552 static int fbcon_takeover(int show_logo) Link Here
547
		info_idx = -1;
552
		info_idx = -1;
548
	} else {
553
	} else {
549
		fbcon_has_console_bind = 1;
554
		fbcon_has_console_bind = 1;
555
		unlock_fb_info(info);
556
		fbcon_decor_init();
557
		lock_fb_info(info);
550
	}
558
	}
551
559
552
	return err;
560
	return err;
Lines 988-993 static const char *fbcon_startup(void) Link Here
988
	rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
996
	rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
989
	cols /= vc->vc_font.width;
997
	cols /= vc->vc_font.width;
990
	rows /= vc->vc_font.height;
998
	rows /= vc->vc_font.height;
999
1000
	if (fbcon_decor_active(info, vc)) {
1001
		cols = vc->vc_decor.twidth / vc->vc_font.width;
1002
		rows = vc->vc_decor.theight / vc->vc_font.height;
1003
	}
1004
991
	vc_resize(vc, cols, rows);
1005
	vc_resize(vc, cols, rows);
992
1006
993
	DPRINTK("mode:   %s\n", info->fix.id);
1007
	DPRINTK("mode:   %s\n", info->fix.id);
Lines 1017-1023 static void fbcon_init(struct vc_data *v Link Here
1017
	cap = info->flags;
1031
	cap = info->flags;
1018
1032
1019
	if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1033
	if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1020
	    (info->fix.type == FB_TYPE_TEXT))
1034
	    (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
1021
		logo = 0;
1035
		logo = 0;
1022
1036
1023
	if (var_to_display(p, &info->var, info))
1037
	if (var_to_display(p, &info->var, info))
Lines 1219-1224 static void fbcon_clear(struct vc_data * Link Here
1219
	if (sy < vc->vc_top && vc->vc_top == logo_lines)
1233
	if (sy < vc->vc_top && vc->vc_top == logo_lines)
1220
		vc->vc_top = 0;
1234
		vc->vc_top = 0;
1221
1235
1236
 	if (fbcon_decor_active(info, vc)) {
1237
 		fbcon_decor_clear(vc, info, sy, sx, height, width);
1238
 		return;
1239
 	}
1240
 	
1222
	/* Split blits that cross physical y_wrap boundary */
1241
	/* Split blits that cross physical y_wrap boundary */
1223
1242
1224
	y_break = p->vrows - p->yscroll;
1243
	y_break = p->vrows - p->yscroll;
Lines 1238-1247 static void fbcon_putcs(struct vc_data * Link Here
1238
	struct display *p = &fb_display[vc->vc_num];
1257
	struct display *p = &fb_display[vc->vc_num];
1239
	struct fbcon_ops *ops = info->fbcon_par;
1258
	struct fbcon_ops *ops = info->fbcon_par;
1240
1259
1241
	if (!fbcon_is_inactive(vc, info))
1260
	if (!fbcon_is_inactive(vc, info)) {
1242
		ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1261
		
1243
			   get_color(vc, info, scr_readw(s), 1),
1262
		if (fbcon_decor_active(info, vc))
1244
			   get_color(vc, info, scr_readw(s), 0));
1263
			fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
1264
		else
1265
			ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1266
				   get_color(vc, info, scr_readw(s), 1),
1267
				   get_color(vc, info, scr_readw(s), 0));
1268
	}
1245
}
1269
}
1246
1270
1247
static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
1271
static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
Lines 1257-1264 static void fbcon_clear_margins(struct v Link Here
1257
	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1281
	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1258
	struct fbcon_ops *ops = info->fbcon_par;
1282
	struct fbcon_ops *ops = info->fbcon_par;
1259
1283
1260
	if (!fbcon_is_inactive(vc, info))
1284
	if (!fbcon_is_inactive(vc, info)) {
1261
		ops->clear_margins(vc, info, bottom_only);
1285
	 	if (fbcon_decor_active(info, vc)) {
1286
	 		fbcon_decor_clear_margins(vc, info, bottom_only);
1287
 		} else {
1288
			ops->clear_margins(vc, info, bottom_only);
1289
		}
1290
	}
1262
}
1291
}
1263
1292
1264
static void fbcon_cursor(struct vc_data *vc, int mode)
1293
static void fbcon_cursor(struct vc_data *vc, int mode)
Lines 1778-1784 static int fbcon_scroll(struct vc_data * Link Here
1778
			count = vc->vc_rows;
1807
			count = vc->vc_rows;
1779
		if (softback_top)
1808
		if (softback_top)
1780
			fbcon_softback_note(vc, t, count);
1809
			fbcon_softback_note(vc, t, count);
1781
		if (logo_shown >= 0)
1810
		if (logo_shown >= 0 || fbcon_decor_active(info, vc))
1782
			goto redraw_up;
1811
			goto redraw_up;
1783
		switch (p->scrollmode) {
1812
		switch (p->scrollmode) {
1784
		case SCROLL_MOVE:
1813
		case SCROLL_MOVE:
Lines 1871-1876 static int fbcon_scroll(struct vc_data * Link Here
1871
			count = vc->vc_rows;
1900
			count = vc->vc_rows;
1872
		if (logo_shown >= 0)
1901
		if (logo_shown >= 0)
1873
			goto redraw_down;
1902
			goto redraw_down;
1903
		if (fbcon_decor_active(info, vc))
1904
			goto redraw_down;
1874
		switch (p->scrollmode) {
1905
		switch (p->scrollmode) {
1875
		case SCROLL_MOVE:
1906
		case SCROLL_MOVE:
1876
			fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1907
			fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
Lines 2019-2024 static void fbcon_bmove_rec(struct vc_da Link Here
2019
		}
2050
		}
2020
		return;
2051
		return;
2021
	}
2052
	}
2053
2054
	if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
2055
 		/* must use slower redraw bmove to keep background pic intact */
2056
 		fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
2057
 		return;
2058
 	}
2059
	
2022
	ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
2060
	ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
2023
		   height, width);
2061
		   height, width);
2024
}
2062
}
Lines 2089-2096 static int fbcon_resize(struct vc_data * Link Here
2089
	var.yres = virt_h * virt_fh;
2127
	var.yres = virt_h * virt_fh;
2090
	x_diff = info->var.xres - var.xres;
2128
	x_diff = info->var.xres - var.xres;
2091
	y_diff = info->var.yres - var.yres;
2129
	y_diff = info->var.yres - var.yres;
2092
	if (x_diff < 0 || x_diff > virt_fw ||
2130
	if ((x_diff < 0 || x_diff > virt_fw ||
2093
	    y_diff < 0 || y_diff > virt_fh) {
2131
		y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
2094
		const struct fb_videomode *mode;
2132
		const struct fb_videomode *mode;
2095
2133
2096
		DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
2134
		DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
Lines 2126-2131 static int fbcon_switch(struct vc_data * Link Here
2126
2164
2127
	info = registered_fb[con2fb_map[vc->vc_num]];
2165
	info = registered_fb[con2fb_map[vc->vc_num]];
2128
	ops = info->fbcon_par;
2166
	ops = info->fbcon_par;
2167
	prev_console = ops->currcon;
2168
	if (prev_console != -1)
2169
		old_info = registered_fb[con2fb_map[prev_console]];
2170
2171
	if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
2172
		struct vc_data *vc_curr = vc_cons[prev_console].d;
2173
		if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
2174
			/* Clear the screen to avoid displaying funky colors during
2175
			 * palette updates. */
2176
			memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
2177
			       0, info->var.yres * info->fix.line_length);
2178
		}
2179
	}
2129
2180
2130
	if (softback_top) {
2181
	if (softback_top) {
2131
		if (softback_lines)
2182
		if (softback_lines)
Lines 2144-2152 static int fbcon_switch(struct vc_data * Link Here
2144
		logo_shown = FBCON_LOGO_CANSHOW;
2195
		logo_shown = FBCON_LOGO_CANSHOW;
2145
	}
2196
	}
2146
2197
2147
	prev_console = ops->currcon;
2148
	if (prev_console != -1)
2149
		old_info = registered_fb[con2fb_map[prev_console]];
2150
	/*
2198
	/*
2151
	 * FIXME: If we have multiple fbdev's loaded, we need to
2199
	 * FIXME: If we have multiple fbdev's loaded, we need to
2152
	 * update all info->currcon.  Perhaps, we can place this
2200
	 * update all info->currcon.  Perhaps, we can place this
Lines 2184-2189 static int fbcon_switch(struct vc_data * Link Here
2184
			fbcon_del_cursor_timer(old_info);
2232
			fbcon_del_cursor_timer(old_info);
2185
	}
2233
	}
2186
2234
2235
	if (fbcon_decor_active_vc(vc)) {
2236
		struct vc_data *vc_curr = vc_cons[prev_console].d;
2237
2238
		if (!vc_curr->vc_decor.theme ||
2239
			strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
2240
			(fbcon_decor_active_nores(info, vc_curr) &&
2241
			 !fbcon_decor_active(info, vc_curr))) {
2242
			if (fbcon_decor_call_helper("modechange", vc->vc_num))
2243
				fbcon_decor_disable(vc, 0);
2244
		}
2245
	}
2246
2187
	if (fbcon_is_inactive(vc, info) ||
2247
	if (fbcon_is_inactive(vc, info) ||
2188
	    ops->blank_state != FB_BLANK_UNBLANK)
2248
	    ops->blank_state != FB_BLANK_UNBLANK)
2189
		fbcon_del_cursor_timer(info);
2249
		fbcon_del_cursor_timer(info);
Lines 2295-2309 static int fbcon_blank(struct vc_data *v Link Here
2295
			info->fbops->fb_restore_state(info);
2355
			info->fbops->fb_restore_state(info);
2296
	}
2356
	}
2297
2357
2298
 	if (!fbcon_is_inactive(vc, info)) {
2358
	if (!fbcon_is_inactive(vc, info)) {
2299
		if (ops->blank_state != blank) {
2359
		if (ops->blank_state != blank) {
2300
			ops->blank_state = blank;
2360
			ops->blank_state = blank;
2301
			fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
2361
			fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
2302
			ops->cursor_flash = (!blank);
2362
			ops->cursor_flash = (!blank);
2303
2363
2304
			if (!(info->flags & FBINFO_MISC_USEREVENT))
2364
			if (!(info->flags & FBINFO_MISC_USEREVENT)) {
2305
				if (fb_blank(info, blank))
2365
				if (fb_blank(info, blank)) {
2306
					fbcon_generic_blank(vc, info, blank);
2366
					if (fbcon_decor_active(info, vc))
2367
						fbcon_decor_blank(vc, info, blank);
2368
					else
2369
						fbcon_generic_blank(vc, info, blank);
2370
				}
2371
			}
2307
		}
2372
		}
2308
2373
2309
		if (!blank)
2374
		if (!blank)
Lines 2454-2466 static int fbcon_do_set_font(struct vc_d Link Here
2454
	}
2519
	}
2455
2520
2456
	if (resize) {
2521
	if (resize) {
2522
		/* reset wrap/pan */
2457
		int cols, rows;
2523
		int cols, rows;
2458
2524
2459
		cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2525
		cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2460
		rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2526
		rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2527
2528
 		info->var.xoffset = info->var.yoffset = p->yscroll = 0;
2529
		if (fbcon_decor_active(info, vc)) {
2530
			cols = vc->vc_decor.twidth;
2531
			rows = vc->vc_decor.theight;
2532
		}
2461
		cols /= w;
2533
		cols /= w;
2462
		rows /= h;
2534
		rows /= h;
2535
2463
		vc_resize(vc, cols, rows);
2536
		vc_resize(vc, cols, rows);
2537
2464
		if (CON_IS_VISIBLE(vc) && softback_buf)
2538
		if (CON_IS_VISIBLE(vc) && softback_buf)
2465
			fbcon_update_softback(vc);
2539
			fbcon_update_softback(vc);
2466
	} else if (CON_IS_VISIBLE(vc)
2540
	} else if (CON_IS_VISIBLE(vc)
Lines 2589-2595 static int fbcon_set_palette(struct vc_d Link Here
2589
	int i, j, k, depth;
2663
	int i, j, k, depth;
2590
	u8 val;
2664
	u8 val;
2591
2665
2592
	if (fbcon_is_inactive(vc, info))
2666
	if (fbcon_is_inactive(vc, info) || vc->vc_num != fg_console)
2593
		return -EINVAL;
2667
		return -EINVAL;
2594
2668
2595
	if (!CON_IS_VISIBLE(vc))
2669
	if (!CON_IS_VISIBLE(vc))
Lines 2615-2621 static int fbcon_set_palette(struct vc_d Link Here
2615
	} else
2689
	} else
2616
		fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
2690
		fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
2617
2691
2618
	return fb_set_cmap(&palette_cmap, info);
2692
	if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
2693
	    info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
2694
2695
		u16 *red, *green, *blue;
2696
		int minlen = min(min(info->var.red.length, info->var.green.length), 
2697
				     info->var.blue.length);
2698
		int h;
2699
2700
		struct fb_cmap cmap = {
2701
			.start = 0,
2702
			.len = (1 << minlen),
2703
			.red = NULL,
2704
			.green = NULL,
2705
			.blue = NULL,
2706
			.transp = NULL
2707
		};
2708
2709
		red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
2710
	
2711
		if (!red)
2712
			goto out;		
2713
	
2714
		green = red + 256;
2715
		blue = green + 256;
2716
		cmap.red = red;
2717
		cmap.green = green;
2718
		cmap.blue = blue;
2719
		
2720
		for (i = 0; i < cmap.len; i++) {
2721
			red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
2722
		}
2723
2724
		h = fb_set_cmap(&cmap, info);
2725
		fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
2726
		kfree(red);
2727
		
2728
		return h;
2729
		
2730
	} else if (fbcon_decor_active(info, vc_cons[fg_console].d) && 
2731
		   info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL) 
2732
		fb_set_cmap(&info->bgdecor.cmap, info);
2733
		
2734
out:	return fb_set_cmap(&palette_cmap, info);
2619
}
2735
}
2620
2736
2621
static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
2737
static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
Lines 2841-2847 static void fbcon_modechanged(struct fb_ Link Here
2841
		rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2957
		rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2842
		cols /= vc->vc_font.width;
2958
		cols /= vc->vc_font.width;
2843
		rows /= vc->vc_font.height;
2959
		rows /= vc->vc_font.height;
2844
		vc_resize(vc, cols, rows);
2960
2961
		if (!fbcon_decor_active_nores(info, vc)) {
2962
			vc_resize(vc, cols, rows);
2963
		} else {
2964
			/* HACK: Do this properly at some point.. */
2965
			unlock_fb_info(info);
2966
			int res = fbcon_decor_call_helper("modechange", vc->vc_num);
2967
			lock_fb_info(info);
2968
			if (res)
2969
				fbcon_decor_disable(vc, 0);
2970
		}
2971
2845
		updatescrollmode(p, info, vc);
2972
		updatescrollmode(p, info, vc);
2846
		scrollback_max = 0;
2973
		scrollback_max = 0;
2847
		scrollback_current = 0;
2974
		scrollback_current = 0;
Lines 3475-3480 static void fbcon_exit(void) Link Here
3475
		}
3602
		}
3476
	}
3603
	}
3477
3604
3605
	fbcon_decor_exit();
3478
	fbcon_has_exited = 1;
3606
	fbcon_has_exited = 1;
3479
}
3607
}
3480
3608

Return to bug 288089