From 63912i@cfi.waseda.ac.jp Thu Apr 14 12:29:26 EDT 1994 Article: 7800 of comp.os.linux.development Path: bigblue.oit.unc.edu!concert!news.duke.edu!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!agate!darkstar.UCSC.EDU!news.hal.COM!olivea!koriel!sh.wide!wnoc-tyo-news!waseda-mail!wsdnws!63912i From: 63912i@cfi.waseda.ac.jp ("Alexander During") Newsgroups: comp.os.linux.development Subject: Kernel patch for console.c (Laptop Backlight) Date: 14 Apr 1994 06:56:55 GMT Organization: Centre for Informatics, WASEDA University Lines: 182 Distribution: world Message-ID: <2oipfn$5ve@wsdnws.cfi.waseda.ac.jp> NNTP-Posting-Host: suzuka.cfi.waseda.ac.jp Hello Fello Linuxers! This is the patch onto drivers/char/console.c that I announced some three weeks ago, just before I left for holiday, so here are my apologies for sending the actual code rather late. Again, here is what I know about the computer: It may be called Notebook 3500 by some manufacturers, in Germany it is sold by Computer Revolution and Vobis as 386 or 486 versions. You have dark blue writings on some keys, notably the following: Esc: PopUp Enter: Stand By CsrUp: Norm CsrDn: Sleep F5: A-M F6: Bold F7: L/C The key marked Fn is between left Crtl and left Alt. The driver that comes for DOS is called note3500.sys. There has been some discussion following my posting, so I feel the thing is no really state-of-the-art as far as sophistication goes. The change I would like to see is to see blankscreen() called by a blanking routine, not hardcoded as one. These changes, however, go directly into blank_screen() and unblank_screen(). I do not feel very much like having user-installable blanking routines, for a simple reason: When I work with virtual consoles instead of X, I do this to have my RAM free for computations, compiles, &c. It seems rather baroque to me to add too much functionality to a bare metal interface. But this is my personal opinion. About this division thing; I will see if it comes out in the next kernel release, because I strongly feel that both, the routine to blank the screen and the one to perform hardware specific twiddling should be visible for user programs and neither do I know what to do to make a function externally callable, nor do I want to meddle with the ways of Linus. Now for the patch. Obviously it just toggles one bit. I add a test program to check out beforehand whether this works. Try the program, if it goes well, apply the patch. The computer in question has alot more features, most prominently switching between internal (=LCD) and external screen, en-/disabling colour and so on. I have been asked to implement these as well and I am working on it, but while the backlight twiddling is done within a loadable driver, all the rest involves the VGA-BIOS and this is somewhat larger, read: harder to see through than the driver code. As a matter of fact, the interfacing looks like all the things that couldn't be squeezed into the BIOS have been put into the driver and so the division of functionality is less than well structured. Next thing is, I don't have an external monitor here in Japan... As we are at it, instead of wading through the source listing, if somebody could point me to something that enables me to debug along the 16h interrupt, perhaps using a Linux box via a serial line, I guess it would speed up things. =============================== Patch =================================== 1556,1566d1555 < < /* Now comes the addition to switch off backlight of my LCD screen*/ < if (((jiffies-timer_table[BLANK_TIMER].expires) & ~3L)==0L) { < /* call this only if due to timeout, not if called by X */ < /* the & allows 3 jiffies to go by before the call reaches us */ < outb(0x84, 0x3c4); /* EGA sequencer index*/ < outb(inb(0x3c5) & 0xbf, 0x3c5); /* turn off backlight bit */ < outb(0x00, 0x3da); /* VGA feature contr.: acknowledge */ < } < /* End of LCD insertions. Alex heisei 6/03/17 */ < 1580,1586d1568 < < /* switch LCD back on */ < outb(0x84, 0x3c4); /* EGA sequencer index*/ < outb(inb(0x3c5) | 0x40, 0x3c5); /* turn on backlight bit */ < outb(0x00, 0x3da); /* VGA feature contr.: acknowledge */ < /* End of LCD insertions. Alex heisei 6/03/17 */ < =============================== End of patch ============================ =============================== Test program ============================ /* setscreen.c Compile this with gcc -o setscreen -O2 setscreen.c */ #include #include #include #define EGASEQU 0x3c4 #define EGAPORT 0x3c5 #define VGAPORT 0x3da typedef struct _attribute { char *name; char ormask; char andmask; } attribute; attribute capability[] = { { "backlit", 0x40, 0xff}, { "nolight", 0x00, 0xbf}, { NULL, 0x00, 0xbf} }; void usage(char *name) { int i; printf("Usage: %s options\n", name); printf("Available options are:"); for (i=0; capability[i].name; i++) printf(" %s", capability[i].name); printf(".\n"); } int main(int argc, char **argv) { int j,i,p; if (argc<2) { usage(argv[0]); return -1; } if (ioperm(EGASEQU, 1L, 1) || ioperm(EGAPORT, 1L, 1) || ioperm(VGAPORT, 1L, 1)) { printf("This program must be run with root permissions.\n"); return -2; }; for(i=1; i