From owner-freebsd-mobile Tue Apr 29 03:18:12 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id DAA09035 for mobile-outgoing; Tue, 29 Apr 1997 03:18:12 -0700 (PDT) Received: from hot.ee.lbl.gov (hot.ee.lbl.gov [131.243.1.42]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id DAA09030 for ; Tue, 29 Apr 1997 03:18:10 -0700 (PDT) Received: by hot.ee.lbl.gov (8.8.5/1.43r) id DAA13110; Tue, 29 Apr 1997 03:18:09 -0700 (PDT) Message-Id: <199704291018.DAA13110@hot.ee.lbl.gov> To: freebsd-mobile@freebsd.org Subject: blacklight blanking syscons module for the Butterfly Date: Tue, 29 Apr 1997 03:18:09 PDT From: Craig Leres Sender: owner-mobile@freebsd.org X-Loop: FreeBSD.org Precedence: bulk -----BEGIN PGP SIGNED MESSAGE----- Ever since I switched my IBM 701 to FreeBSD, it's annoyed me that the "green" screen saver didn't turn off the backlight. I took a look at this tonight and found some code I wrote for BSD/OS once upon a time. It was easily adapted as the appended loadable kernel module and works great! It will probably work with any Chips & Technologies 65545/65540 based notebook/laptop (and falls back to the normal "green" behavior when using something else). The easiest way to build it is to unpack the appended sharchive in /sys/syscons/lcd, build and install it (in /lkm) and change /etc/sysconfig to use saver=lcd (and set blanktime to some non-zero number of seconds). (It would be really cool if this got picked up and incorporated back into the official source tree.) Craig - ------ #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # lcd_saver.c # Makefile # This archive created: Tue Apr 29 03:08:48 1997 export PATH; PATH=/bin:$PATH echo shar: extracting "'lcd_saver.c'" '(4192 characters)' if test -f 'lcd_saver.c' then echo shar: will not over-write existing file "'lcd_saver.c'" else sed 's/^X//' << \SHAR_EOF > 'lcd_saver.c' X/*- X * Copyright (c) 1995, 1997 Sxren Schmidt X * All rights reserved. X * X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer X * in this position and unchanged. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. The name of the author may not be used to endorse or promote products X * derived from this software withough specific prior written permission X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X * X * CT65545 backlight hacks by Craig Leres X * Network Research Group, Lawrence Berkeley National Laboratory, April 1997 X * X * @(#) $Header: lcd_saver.c,v 1.1 97/04/29 03:02:14 leres Exp $ (LBL) X */ X X#include X#include X#include X#include X#include X#include X#include X#include X X/* Chips & Technologies 65545 extension registers */ X#define CT_XRI 0x3d6 /* extension index */ X#define CT_XRD 0x3d7 /* extension data */ X X#define XR_CHPVER 0x00 /* (XR00) chip version */ X#define XR_CHPVER_MSK 0x07 /* chip version mask */ X#define XR_CHPVER_545 0xd8 /* 65545 version base */ X#define XR_CHPVER_540 0xd0 /* 65540 version base */ X#define XR_PWRCTL 0x52 /* (XR52) power down control */ X#define XR_PWRCTL_PANOFF 0x08 /* panel off mode */ X#ifdef notdef X#define XR_TMRCTL 0x5c /* (XR5C) activity timer ctl */ X#define XR_TMRCTL_MSK 0x1f /* activity timer count mask */ X#define XR_TMRCTL_ENA 0x80 /* enable activity timer */ X#endif X XMOD_MISC(lcd_saver); X Xvoid (*current_saver)(int blank); Xvoid (*old_saver)(int blank); X Xstatic void Xlcd_saver(int blank) X{ X u_char val; X register u_int chipver; X X if (blank) { X scrn_blanked = 1; X X /* Special panel backlight blanking for the CT 65545/65540 */ X outb(CT_XRI, XR_CHPVER); X chipver = inb(CT_XRD); X chipver &= ~XR_CHPVER_MSK; X if (chipver == XR_CHPVER_545 || chipver == XR_CHPVER_540) { X outb(CT_XRI, XR_PWRCTL); X outb(CT_XRD, inb(CT_XRD) | XR_PWRCTL_PANOFF); X } else { X /* blank stuff */ X outb(TSIDX, 0x01); val = inb(TSREG); X outb(TSIDX, 0x01); outb(TSREG, val | 0x20); X X /* green stuff */ X outb(crtc_addr, 0x17); val = inb(crtc_addr + 1); X outb(crtc_addr + 1, val & ~0x80); X } X } X else { X outb(CT_XRI, XR_CHPVER); X chipver = inb(CT_XRD); X chipver &= ~XR_CHPVER_MSK; X if (chipver == XR_CHPVER_545 || chipver == XR_CHPVER_540) { X outb(CT_XRI, XR_PWRCTL); X outb(CT_XRD, inb(CT_XRD) & ~XR_PWRCTL_PANOFF); X } else { X /* blank stuff */ X outb(TSIDX, 0x01); val = inb(TSREG); X outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); X X /* green stuff */ X outb(crtc_addr, 0x17); val = inb(crtc_addr + 1); X outb(crtc_addr + 1, val | 0x80); X } X X scrn_blanked = 0; X } X} X Xstatic int Xlcd_saver_load(struct lkm_table *lkmtp, int cmd) X{ X (*current_saver)(0); X old_saver = current_saver; X current_saver = lcd_saver; X return 0; X} X Xstatic int Xlcd_saver_unload(struct lkm_table *lkmtp, int cmd) X{ X (*current_saver)(0); X current_saver = old_saver; X return 0; X} X Xint Xlcd_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) X{ X DISPATCH(lkmtp, cmd, ver, lcd_saver_load, lcd_saver_unload, X lkm_nullcmd); X} SHAR_EOF if test 4192 -ne "`wc -c < 'lcd_saver.c'`" then echo shar: error transmitting "'lcd_saver.c'" '(should have been 4192 characters)' fi fi # end of overwriting check echo shar: extracting "'Makefile'" '(196 characters)' if test -f 'Makefile' then echo shar: will not over-write existing file "'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' X# @(#) $Header: Makefile,v 1.1 97/04/29 03:08:08 leres Exp $ (LBL) X XKMOD= lcd_saver_mod XSRCS= lcd_saver.c X XNOMAN= XCFLAGS+= -DLKM -I${.CURDIR}/.. -I${.CURDIR}/../../../sys X X.include SHAR_EOF if test 196 -ne "`wc -c < 'Makefile'`" then echo shar: error transmitting "'Makefile'" '(should have been 196 characters)' fi fi # end of overwriting check # End of shell archive exit 0 -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBM2XKur2JLbUEFcrxAQE+CwQAkvp8gwpTLZnB+HnXxOm86NdGrIcRZFar AkQ3dwbzl2moi0zlC1r4of1OUMdCiStR+n7tIgtfVERSiRdLH8WRWOvNh3oAHHZk kr/lxFy+zk3KguADR8Niz/DSkk30lDJ4NHjbaM7OhIOBmY7eKznuubh8jDNZeeYK GdnogZi5d7k= =9hK4 -----END PGP SIGNATURE-----