console bacground color and blanking

Mika Raento (mikie@calvin.rutgers.edu)
Wed, 13 Mar 1996 21:49:07 +0200 (EET)


Noticing that the newer kernels support my video card better I switched
from 80x25 to 132x44 as my console text mode. The smaller letters are
a bit harder on the eyes so I wrote a short c prog (I can mail it if
someone wants me to) to change the console background color and used it
to change the color to a more peaceful dark blue.

To my dismay I noticed that now the console blanking didn't switch to a
black screen anymore, but to a blue screen (serves me right for changing
the bg color by using a ioctl :-). I think it might be a more acceptable
behaviour if blanking the console would change the background to black as
well.

The blanking is implemented in drivers/char/console.c . I made a small
patch to implement the changing of bg color to black and changing it back
to the one in use when un_blanking. I guess this might count as
unnecessary bloat, but it should add only a little to memory usage as the
kernel size only grew ~100 bytes and the routine only permanently
allocates 3 bytes of memory.

Here's my patch (against 1.3.72) for anyone to try out, I'd be very
grateful for any comments/input on the subject. Oh, and you should
#define BLACK_BLANK for example in drivers/char/kd_kern.h for this to
take effect. And I'd more than grateful to here if there already existed
a way to do this. (by no means is patch graceful, it's just a quick
implementation of my concept but should be a working example of what I
had in mind)

blank_patch.1.3.72 :

*** drivers/char/console.c.original Wed Mar 13 18:37:58 1996
--- drivers/char/console.c Wed Mar 13 20:14:31 1996
***************
*** 187,192 ****
--- 187,196 ----

struct vc vc_cons [MAX_NR_CONSOLES];

+ #ifdef BLACK_BLANK
+ unsigned char orig_bg_color[3]= {0,0,0}; /* used to hold original bg colour
+ while blanking screen to black */
+ #endif /* BLACK_BLANK */

#ifdef CONFIG_SERIAL_ECHO

***************
*** 2105,2110 ****
--- 2109,2140 ----
return kmem_start;
}

+ /*
+ * Load palette into the EGA/VGA DAC registers. arg points to a colour
+ * map, 3 bytes per colour, 16 colours, range from 0 to 255.
+ */
+
+ int con_set_cmap (unsigned char *arg)
+ {
+ return set_get_cmap (arg,1);
+ }
+
+ int con_get_cmap (unsigned char *arg)
+ {
+ return set_get_cmap (arg,0);
+ }
+
+ void reset_palette (int currcons)
+ {
+ int j, k ;
+ for (j=k=0; j<16; j++) {
+ palette[k++] = default_red[j];
+ palette[k++] = default_grn[j];
+ palette[k++] = default_blu[j];
+ }
+ set_palette() ;
+ }
+
void vesa_powerdown_screen(void)
{
timer_active &= ~(1<<BLANK_TIMER);
***************
*** 2117,2122 ****
--- 2147,2156 ----
{
int currcons;

+ #ifdef BLACK_BLANK
+ unsigned char i,temp_cmap[16][3];
+ #endif /* BLACK_BLANK */
+
#ifdef CONFIG_APM
if (apm_display_blank())
return;
***************
*** 2135,2140 ****
--- 2169,2184 ----
}

/* try not to lose information by blanking, and not to waste memory */
+
+ #ifdef BLACK_BLANK
+ con_get_cmap (temp_cmap);
+ for ( i=0; i<3 ; i++) {
+ orig_bg_color[i]=temp_cmap[0][i];
+ temp_cmap[0][i]=0;
+ }
+ con_set_cmap (temp_cmap);
+ #endif /* BLACK_BLANK */
+
currcons = fg_console;
has_scrolled = 0;
blank__origin = __origin;
***************
*** 2157,2162 ****
--- 2201,2210 ----
int resetorg;
long offset;

+ #ifdef BLACK_BLANK
+ unsigned char i,temp_cmap[16][3];
+ #endif /* BLACK_BLANK */
+
#ifdef CONFIG_APM
if (apm_display_unblank())
return;
***************
*** 2187,2192 ****
--- 2235,2247 ----
}

console_blanked = 0;
+
+ #ifdef BLACK_BLANK
+ con_get_cmap (temp_cmap);
+ for ( i=0; i<3 ; i++) temp_cmap[0][i]=orig_bg_color[i];
+ con_set_cmap (temp_cmap);
+ #endif /* BLACK_BLANK */
+
set_scrmem(fg_console, offset);
set_origin(fg_console);
set_cursor(fg_console);
***************
*** 2264,2294 ****
}


- /*
- * Load palette into the EGA/VGA DAC registers. arg points to a colour
- * map, 3 bytes per colour, 16 colours, range from 0 to 255.
- */
-
- int con_set_cmap (unsigned char *arg)
- {
- return set_get_cmap (arg,1);
- }
-
- int con_get_cmap (unsigned char *arg)
- {
- return set_get_cmap (arg,0);
- }
-
- void reset_palette (int currcons)
- {
- int j, k ;
- for (j=k=0; j<16; j++) {
- palette[k++] = default_red[j];
- palette[k++] = default_grn[j];
- palette[k++] = default_blu[j];
- }
- set_palette() ;
- }

/*
* Load font into the EGA/VGA character generator. arg points to a 8192
--- 2319,2324 ----

Mika Raento mailto:mikpera@cc.jyu.fi http://www.jyu.fi/~mikpera
-- "You can't *ADD* things and come out with *LESS* than you started with!"
-- "I can do that! It's a free country! I've got my rights!"
Have a look at Jukola '97 orienteering relay homepage at ~mikpera/jukola-97/