]> git.pld-linux.org Git - packages/kernel.git/blob - 2.6.1-all-in-1.patch
- enable cluster config on ppc,sparc,amd64,ia64
[packages/kernel.git] / 2.6.1-all-in-1.patch
1 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/arch/i386/Kconfig linux-2.6.1-gentoo-test/arch/i386/Kconfig
2 --- linux-2.6.1-gentoo/arch/i386/Kconfig        2004-01-09 23:40:12.000000000 +0000
3 +++ linux-2.6.1-gentoo-test/arch/i386/Kconfig   2004-01-09 22:33:09.000000000 +0000
4 @@ -586,6 +586,9 @@
5           Say Y if you intend to run this kernel on a Dell Inspiron 8000.
6           Say N otherwise.
7  
8 +config OMNIBOOK
9 +       tristate "HP Omnibook Support"
10 +
11  config MICROCODE
12         tristate "/dev/cpu/microcode - Intel IA32 CPU microcode support"
13         ---help---
14 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/arch/i386/kernel/cpu/cpufreq/powernow-k7.c linux-2.6.1-gentoo-test/arch/i386/kernel/cpu/cpufreq/powernow-k7.c
15 --- linux-2.6.1-gentoo/arch/i386/kernel/cpu/cpufreq/powernow-k7.c       2004-01-09 23:40:12.000000000 +0000
16 +++ linux-2.6.1-gentoo-test/arch/i386/kernel/cpu/cpufreq/powernow-k7.c  2004-01-09 22:32:23.000000000 +0000
17 @@ -279,6 +279,8 @@
18         etuple &= 0xf00;
19         etuple |= (c->x86_model<<4)|(c->x86_mask);
20  
21 +       if (etuple == 0x7a0) { etuple = 0x781; }
22 +
23         for (i=0xC0000; i < 0xffff0 ; i+=16) {
24  
25                 p = phys_to_virt(i);
26 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/Makefile linux-2.6.1-gentoo-test/drivers/char/Makefile
27 --- linux-2.6.1-gentoo/drivers/char/Makefile    2004-01-09 23:40:12.000000000 +0000
28 +++ linux-2.6.1-gentoo-test/drivers/char/Makefile       2004-01-09 22:33:09.000000000 +0000
29 @@ -61,6 +61,7 @@
30  endif
31  obj-$(CONFIG_TOSHIBA) += toshiba.o
32  obj-$(CONFIG_I8K) += i8k.o
33 +obj-$(CONFIG_OMNIBOOK) += omnibook/
34  obj-$(CONFIG_DS1620) += ds1620.o
35  obj-$(CONFIG_HW_RANDOM) += hw_random.o
36  obj-$(CONFIG_QIC02_TAPE) += tpqic02.o
37 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/drm/radeon_cp.c linux-2.6.1-gentoo-test/drivers/char/drm/radeon_cp.c
38 --- linux-2.6.1-gentoo/drivers/char/drm/radeon_cp.c     2004-01-09 23:40:12.000000000 +0000
39 +++ linux-2.6.1-gentoo-test/drivers/char/drm/radeon_cp.c        2004-01-09 23:33:45.000000000 +0000
40 @@ -855,7 +855,8 @@
41  
42         /* Initialize the memory controller */
43         RADEON_WRITE( RADEON_MC_FB_LOCATION,
44 -                     (dev_priv->gart_vm_start - 1) & 0xffff0000 );
45 +                     ((dev_priv->gart_vm_start - 1) & 0xffff0000 ) |
46 +                     (dev_priv->fb_base >> 16));
47  
48  #if __REALLY_HAVE_AGP
49         if ( !dev_priv->is_pci ) {
50 @@ -1071,13 +1072,6 @@
51         dev_priv->depth_offset  = init->depth_offset;
52         dev_priv->depth_pitch   = init->depth_pitch;
53  
54 -       dev_priv->front_pitch_offset = (((dev_priv->front_pitch/64) << 22) |
55 -                                       (dev_priv->front_offset >> 10));
56 -       dev_priv->back_pitch_offset = (((dev_priv->back_pitch/64) << 22) |
57 -                                      (dev_priv->back_offset >> 10));
58 -       dev_priv->depth_pitch_offset = (((dev_priv->depth_pitch/64) << 22) |
59 -                                       (dev_priv->depth_offset >> 10));
60 -
61         /* Hardware state for depth clears.  Remove this if/when we no
62          * longer clear the depth buffer with a 3D rectangle.  Hard-code
63          * all values to prevent unwanted 3D state from slipping through
64 @@ -1204,9 +1198,17 @@
65                            dev_priv->buffers->handle );
66         }
67  
68 +       dev_priv->fb_base = (RADEON_READ( RADEON_MC_FB_LOCATION ) & 0xffff) << 16;
69 +        dev_priv->front_pitch_offset = (((dev_priv->front_pitch/64) << 22) |
70 +                                       ((dev_priv->front_offset+dev_priv->fb_base) >> 10));
71 +        dev_priv->back_pitch_offset = (((dev_priv->back_pitch/64) << 22) |
72 +                                      ((dev_priv->back_offset+dev_priv->fb_base) >> 10));
73 +        dev_priv->depth_pitch_offset = (((dev_priv->depth_pitch/64) << 22) |
74 +                                       ((dev_priv->depth_offset+dev_priv->fb_base) >> 10));
75  
76         dev_priv->gart_size = init->gart_size;
77 -       dev_priv->gart_vm_start = RADEON_READ( RADEON_CONFIG_APER_SIZE );
78 +       dev_priv->gart_vm_start = RADEON_READ( RADEON_CONFIG_APER_SIZE ) + dev_priv->fb_base;
79 +
80  #if __REALLY_HAVE_AGP
81         if ( !dev_priv->is_pci )
82                 dev_priv->gart_buffers_offset = (dev_priv->buffers->offset
83 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/drm/radeon_drv.h linux-2.6.1-gentoo-test/drivers/char/drm/radeon_drv.h
84 --- linux-2.6.1-gentoo/drivers/char/drm/radeon_drv.h    2004-01-09 23:40:12.000000000 +0000
85 +++ linux-2.6.1-gentoo-test/drivers/char/drm/radeon_drv.h       2004-01-09 22:32:40.000000000 +0000
86 @@ -125,6 +125,7 @@
87  
88         drm_radeon_depth_clear_t depth_clear;
89         
90 +       unsigned long fb_base;
91         unsigned long fb_offset;
92         unsigned long mmio_offset;
93         unsigned long ring_offset;
94 @@ -146,7 +147,6 @@
95         /* SW interrupt */
96         wait_queue_head_t swi_queue;
97         atomic_t swi_emitted;
98 -
99  } drm_radeon_private_t;
100  
101  typedef struct drm_radeon_buf_priv {
102 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/drm/radeon_state.c linux-2.6.1-gentoo-test/drivers/char/drm/radeon_state.c
103 --- linux-2.6.1-gentoo/drivers/char/drm/radeon_state.c  2004-01-09 23:40:12.000000000 +0000
104 +++ linux-2.6.1-gentoo-test/drivers/char/drm/radeon_state.c     2004-01-09 22:32:40.000000000 +0000
105 @@ -153,7 +153,7 @@
106                 OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_0, 5 ) );
107                 OUT_RING( tex[0].pp_txfilter );
108                 OUT_RING( tex[0].pp_txformat );
109 -               OUT_RING( tex[0].pp_txoffset );
110 +               OUT_RING( tex[0].pp_txoffset + dev_priv->fb_base);
111                 OUT_RING( tex[0].pp_txcblend );
112                 OUT_RING( tex[0].pp_txablend );
113                 OUT_RING( tex[0].pp_tfactor );
114 @@ -167,7 +167,7 @@
115                 OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_1, 5 ) );
116                 OUT_RING( tex[1].pp_txfilter );
117                 OUT_RING( tex[1].pp_txformat );
118 -               OUT_RING( tex[1].pp_txoffset );
119 +               OUT_RING( tex[1].pp_txoffset + dev_priv->fb_base);
120                 OUT_RING( tex[1].pp_txcblend );
121                 OUT_RING( tex[1].pp_txablend );
122                 OUT_RING( tex[1].pp_tfactor );
123 @@ -181,7 +181,7 @@
124                 OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_2, 5 ) );
125                 OUT_RING( tex[2].pp_txfilter );
126                 OUT_RING( tex[2].pp_txformat );
127 -               OUT_RING( tex[2].pp_txoffset );
128 +               OUT_RING( tex[2].pp_txoffset + dev_priv->fb_base);
129                 OUT_RING( tex[2].pp_txcblend );
130                 OUT_RING( tex[2].pp_txablend );
131                 OUT_RING( tex[2].pp_tfactor );
132 @@ -1178,7 +1178,7 @@
133                              RADEON_GMC_CLR_CMP_CNTL_DIS |
134                              RADEON_GMC_WR_MSK_DIS);
135                 
136 -               buffer[2] = (tex->pitch << 22) | (tex->offset >> 10);
137 +               buffer[2] = (tex->pitch << 22) | ((tex->offset + dev_priv->fb_base) >> 10);
138                 buffer[3] = 0xffffffff;
139                 buffer[4] = 0xffffffff;
140                 buffer[5] = (image->y << 16) | image->x;
141 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/Makefile linux-2.6.1-gentoo-test/drivers/char/omnibook/Makefile
142 --- linux-2.6.1-gentoo/drivers/char/omnibook/Makefile   1970-01-01 01:00:00.000000000 +0100
143 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/Makefile      2004-01-09 22:33:10.000000000 +0000
144 @@ -0,0 +1,37 @@
145 +#
146 +# Makefile -- makefile for the HP OmniBook support module
147 +#
148 +# This program is free software; you can redistribute it and/or modify it
149 +# under the terms of the GNU General Public License as published by the
150 +# Free Software Foundation; either version 2, or (at your option) any
151 +# later version.
152 +#
153 +# This program is distributed in the hope that it will be useful, but
154 +# WITHOUT ANY WARRANTY; without even the implied warranty of
155 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
156 +# General Public License for more details.
157 +#
158 +# Written by Soós Péter <sp@osb.hu>, 2002,2003
159 +#
160 +# Note! Dependencies are done automagically by 'make dep', which also
161 +# removes any old dependencies. DON'T put your own dependencies here
162 +# unless it's something special (ie not a .c file).
163 +#
164 +# Note 2! The CFLAGS definitions are now in the main makefile...
165 +
166 +#export-objs := ac.o battery.o blank.o display.o dmi.o dock.o fan.o \
167 +               fan_policy.o init.o lcd.o onetouch.o polling.o temperature.o \
168 +               touchpad.o
169 +
170 +#O_TARGET := omnibook.o
171 +
172 +#obj-y   := ac.o apmemu.o battery.o blank.o dmi.o display.o dock.o ec.o \
173 +           fan.o fan_policy.o init.o lcd.o onetouch.o polling.o \
174 +           temperature.o touchpad.o util.o
175 +#obj-m   := $(O_TARGET)
176 +
177 +#include $(TOPDIR)/Rules.make
178 +
179 +obj-$(CONFIG_OMNIBOOK) += omnibook.o
180 +
181 +omnibook-objs := ac.o apmemu.o battery.o blank.o dmi.o display.o dock.o ec.o fan.o fan_policy.o init.o lcd.o onetouch.o temperature.o touchpad.o util.o
182 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/ac.c linux-2.6.1-gentoo-test/drivers/char/omnibook/ac.c
183 --- linux-2.6.1-gentoo/drivers/char/omnibook/ac.c       1970-01-01 01:00:00.000000000 +0100
184 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/ac.c  2004-01-09 22:33:49.000000000 +0000
185 @@ -0,0 +1,134 @@
186 +/*
187 + * ac.c -- AC adapter related functions
188 + * 
189 + * This program is free software; you can redistribute it and/or modify it
190 + * under the terms of the GNU General Public License as published by the
191 + * Free Software Foundation; either version 2, or (at your option) any
192 + * later version.
193 + * 
194 + * This program is distributed in the hope that it will be useful, but
195 + * WITHOUT ANY WARRANTY; without even the implied warranty of
196 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
197 + * General Public License for more details.
198 + *
199 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
200 + */
201 +
202 +
203 +#include <linux/config.h>
204 +#include <linux/module.h>
205 +#include <linux/version.h>
206 +#include <linux/types.h>
207 +#include <linux/init.h>
208 +#include <linux/proc_fs.h>
209 +
210 +#include <asm/system.h>
211 +#include <asm/errno.h>
212 +#include <asm/io.h>
213 +#include <asm/uaccess.h>
214 +
215 +#ifdef OMNIBOOK_STANDALONE
216 +#include "omnibook.h"
217 +#else
218 +#include <linux/omnibook.h>
219 +#endif
220 +
221 +#include "ec.h"
222 +#include "util.h"
223 +
224 +static struct proc_dir_entry *proc_ac;
225 +
226 +int omnibook_get_ac(void)
227 +{
228 +       u8 ac;
229 +       int retval;
230 +
231 +       switch (omnibook_ectype) {
232 +       case XE3GF:
233 +               if ((retval = omnibook_ec_read(XE3GF_ADP, &ac)))
234 +                       return retval;
235 +               retval = (ac & XE3GF_ADP_MASK) ? 1 : 0;
236 +               break;
237 +       case XE3GC:
238 +               if ((retval = omnibook_ec_read(XE3GC_STA1, &ac)))
239 +                       return retval;
240 +               retval = (ac & XE3GC_ADP_MASK) ? 1 : 0;
241 +               break;
242 +       case OB500:
243 +       case OB510:
244 +       case OB6000:
245 +       case OB6100:
246 +       case XE4500:
247 +               if ((retval = omnibook_ec_read(OB500_STA2, &ac)))
248 +                       return retval;
249 +               retval = (ac & OB500_ADP_MASK) ? 1 : 0;
250 +               break;
251 +       case OB4150:
252 +               if ((retval = omnibook_ec_read(OB4150_ADP, &ac)))
253 +                       return retval;
254 +               retval = (ac & OB4150_ADP_MASK) ? 1 : 0;
255 +               break;
256 +       case XE2:
257 +               if ((retval = omnibook_ec_read(XE2_STA1, &ac)))
258 +                       return retval;
259 +               retval = (ac & XE2_ADP_MASK) ? 1 : 0;
260 +               break;
261 +       default:
262 +               printk(KERN_INFO "%s: AC adapter status monitoring is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
263 +               retval = -ENODEV;
264 +       }
265 +       return retval;
266 +}
267 +
268 +static int omnibook_proc_ac(char *buffer, char **start, off_t off, int count, int *eof, void *data)
269 +{
270 +       char *b = buffer;
271 +       int ac;
272 +
273 +       ac = omnibook_get_ac();
274 +       if (ac < 0)
275 +               return ac;
276 +
277 +       b += sprintf(b, "AC %s\n", (ac) ? "on-line" : "off-line");
278 +       
279 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
280 +}
281 +
282 +int __init omnibook_ac_init(void)
283 +{
284 +       mode_t pmode;
285 +
286 +       switch (omnibook_ectype) {
287 +       case XE3GF:
288 +       case XE3GC:
289 +       case OB500:
290 +       case OB510:
291 +       case OB6000:
292 +       case OB6100:
293 +       case XE4500:
294 +       case OB4150:
295 +       case XE2:
296 +               pmode = S_IFREG | S_IRUGO;
297 +               proc_ac = create_proc_read_entry("ac", pmode, omnibook_proc_root, omnibook_proc_ac, NULL);
298 +               break;
299 +       default:
300 +               printk(KERN_INFO "%s: AC adapter status monitoring is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
301 +               return 0;
302 +       }
303 +       if (! proc_ac) {
304 +               printk(KERN_ERR "%s: Unable to create /proc/%s/ac.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
305 +               return -ENOENT;
306 +       }
307 +       printk(KERN_INFO "%s: AC adapter status monitoring is enabled.\n", OMNIBOOK_MODULE_NAME);
308 +       return 0;
309 +}
310 +
311 +void __exit omnibook_ac_cleanup(void)
312 +{
313 +       if (proc_ac)
314 +               remove_proc_entry("ac", omnibook_proc_root);
315 +}
316 +
317 +EXPORT_SYMBOL(omnibook_get_ac);
318 +
319 +/* End of file */
320 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/apmemu.c linux-2.6.1-gentoo-test/drivers/char/omnibook/apmemu.c
321 --- linux-2.6.1-gentoo/drivers/char/omnibook/apmemu.c   1970-01-01 01:00:00.000000000 +0100
322 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/apmemu.c      2004-01-09 22:33:49.000000000 +0000
323 @@ -0,0 +1,187 @@
324 +/*
325 + * apmemu.c -- /proc/apm emulation
326 + * 
327 + * This program is free software; you can redistribute it and/or modify it
328 + * under the terms of the GNU General Public License as published by the
329 + * Free Software Foundation; either version 2, or (at your option) any
330 + * later version.
331 + * 
332 + * This program is distributed in the hope that it will be useful, but
333 + * WITHOUT ANY WARRANTY; without even the implied warranty of
334 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
335 + * General Public License for more details.
336 + *
337 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
338 + */
339 +
340 +
341 +#include <linux/config.h>
342 +#include <linux/module.h>
343 +#include <linux/version.h>
344 +#include <linux/types.h>
345 +#include <linux/init.h>
346 +#include <linux/proc_fs.h>
347 +
348 +#ifdef CONFIG_APM
349 +#include <linux/apm_bios.h>
350 +#endif
351 +
352 +#include <asm/system.h>
353 +#include <asm/errno.h>
354 +#include <asm/io.h>
355 +#include <asm/uaccess.h>
356 +
357 +#ifdef OMNIBOOK_STANDALONE
358 +#include "omnibook.h"
359 +#else
360 +#include <linux/omnibook.h>
361 +#endif
362 +
363 +#include "apmemu.h"
364 +#include "util.h"
365 +
366 +static struct proc_dir_entry *proc_apmemu;
367 +
368 +/* Arguments, with symbols from linux/apm_bios.h.  Information is
369 +   from the Get Power Status (0x0a) call unless otherwise noted.
370 +   0) Linux driver version (this will change if format changes)
371 +   1) APM BIOS Version.  Usually 1.0, 1.1 or 1.2.
372 +   2) APM flags from APM Installation Check (0x00):
373 +      bit 0: APM_16_BIT_SUPPORT
374 +      bit 1: APM_32_BIT_SUPPORT
375 +      bit 2: APM_IDLE_SLOWS_CLOCK
376 +      bit 3: APM_BIOS_DISABLED
377 +      bit 4: APM_BIOS_DISENGAGED
378 +   3) AC line status
379 +      0x00: Off-line
380 +      0x01: On-line
381 +      0x02: On backup power (BIOS >= 1.1 only)
382 +      0xff: Unknown
383 +   4) Battery status
384 +      0x00: High
385 +      0x01: Low
386 +      0x02: Critical
387 +      0x03: Charging
388 +      0x04: Selected battery not present (BIOS >= 1.2 only)
389 +      0xff: Unknown
390 +   5) Battery flag
391 +      bit 0: High
392 +      bit 1: Low
393 +      bit 2: Critical
394 +      bit 3: Charging
395 +      bit 7: No system battery
396 +      0xff: Unknown
397 +   6) Remaining battery life (percentage of charge):
398 +      0-100: valid
399 +      -1: Unknown
400 +   7) Remaining battery life (time units):
401 +      Number of remaining minutes or seconds
402 +      -1: Unknown
403 +   8) min = minutes; sec = seconds */
404 +
405 +static int omnibook_proc_apmemu(char *buffer, char **start, off_t off, int count)
406 +{
407 +       int retval;
408 +       char *b = buffer;
409 +
410 +       int ac;
411 +       struct omnibook_battery_status battstat;
412 +       
413 +       struct apm_features {
414 +               char *drvver;
415 +               char *apmver;
416 +               u8 apmflags;
417 +               u8 ac;
418 +               u8 battstat;
419 +               u8 battflags;
420 +               u8 gauge;
421 +               int time;
422 +               char *units;
423 +       };
424 +
425 +       struct apm_features apm = {
426 +               APMEMU_DRIVER_VERSION,
427 +               APMEMU_APM_VERSION,
428 +               APMEMU_32_BIT_SUPPORT | APMEMU_BIOS_DISABLED,
429 +               APMEMU_AC_UNKNOWN,
430 +               APMEMU_BATTSTAT_UNKN,
431 +               0x00,
432 +               APMEMU_BATTLIFE_UNKN,
433 +               APMEMU_BATTLIFE_UNKN,
434 +               "?"
435 +       };
436 +
437 +       ac = omnibook_get_ac();
438 +       apm.ac = (ac) ? APMEMU_AC_ONLINE : APMEMU_AC_OFFLINE;
439 +       /* Asking for Battery 0 as APM does */
440 +       retval = omnibook_get_battery_status(0, &battstat);
441 +       if (retval == 0)
442 +               apm.gauge = battstat.gauge;
443 +       if (apm.gauge >= APMEMU_BATTERY_LOW) {
444 +               apm.battflags = apm.battflags | APMEMU_BATTFLAG_HIGH;
445 +               apm.battstat = APMEMU_BATTSTAT_HIGH;
446 +       } else {
447 +               apm.battflags = apm.battflags | APMEMU_BATTFLAG_LOW;
448 +               apm.battstat = APMEMU_BATTSTAT_LOW;
449 +       }
450 +       if (battstat.status == OMNIBOOK_BATTSTAT_CHARGING) {
451 +               apm.battflags = apm.battflags | APMEMU_BATTFLAG_CHR;
452 +               apm.battstat = APMEMU_BATTSTAT_CHR;
453 +       }
454 +       if (battstat.status == OMNIBOOK_BATTSTAT_CRITICAL) {
455 +               apm.battflags = apm.battflags | APMEMU_BATTFLAG_CRIT;
456 +               apm.battstat = APMEMU_BATTSTAT_CRIT;
457 +       }
458 +
459 +       b += sprintf(b, "%s %s 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
460 +                       apm.drvver,
461 +                       apm.apmver,
462 +                       apm.apmflags,
463 +                       apm.ac,
464 +                       apm.battstat,
465 +                       apm.battflags,
466 +                       apm.gauge,
467 +                       apm.time,
468 +                       apm.units
469 +       );
470 +
471 +       return b - buffer;
472 +}
473 +
474 +int __init omnibook_apmemu_init(void)
475 +{
476 +       mode_t pmode;
477 +
478 +       switch (omnibook_ectype) {
479 +       case XE3GF:
480 +       case XE3GC:
481 +#ifdef CONFIG_APM
482 +               if (! apm_info.disabled) {
483 +                       printk(KERN_NOTICE "%s: Real APM support is present, emulation is not necessary.\n", OMNIBOOK_MODULE_NAME);
484 +                       return 0;
485 +               }
486 +#endif
487 +               pmode = S_IFREG | S_IRUGO;
488 +               proc_apmemu = create_proc_info_entry("apm", pmode, NULL, omnibook_proc_apmemu);
489 +               break;
490 +       default:
491 +               printk(KERN_INFO "%s: /proc/apm emulation is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
492 +               return 0;
493 +       }
494 +       if (! proc_apmemu) {
495 +               printk(KERN_ERR "%s: Unable to create /proc/apm.\n", OMNIBOOK_MODULE_NAME);
496 +               return -ENOENT;
497 +       }
498 +       printk(KERN_INFO "%s: /proc/apm emulation enabled.\n", OMNIBOOK_MODULE_NAME);
499 +       return 0;
500 +}
501 +
502 +void __exit omnibook_apmemu_cleanup(void)
503 +{
504 +       if (proc_apmemu) {
505 +               remove_proc_entry("apm", NULL);
506 +               printk(KERN_INFO "%s: /proc/apm emulation disabled.\n", OMNIBOOK_MODULE_NAME);
507 +       }
508 +}
509 +
510 +/* End of file */
511 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/apmemu.h linux-2.6.1-gentoo-test/drivers/char/omnibook/apmemu.h
512 --- linux-2.6.1-gentoo/drivers/char/omnibook/apmemu.h   1970-01-01 01:00:00.000000000 +0100
513 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/apmemu.h      2004-01-09 22:33:49.000000000 +0000
514 @@ -0,0 +1,48 @@
515 +/*
516 + * apmemu.c -- code to emulate /proc/apm
517 + * 
518 + * This program is free software; you can redistribute it and/or modify it
519 + * under the terms of the GNU General Public License as published by the
520 + * Free Software Foundation; either version 2, or (at your option) any
521 + * later version.
522 + * 
523 + * This program is distributed in the hope that it will be useful, but
524 + * WITHOUT ANY WARRANTY; without even the implied warranty of
525 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
526 + * General Public License for more details.
527 + *
528 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
529 + */
530 +
531 +
532 +#define APMEMU_DRIVER_VERSION  "1.16"
533 +#define APMEMU_APM_VERSION     "1.2"
534 +
535 +#define APMEMU_BATTERY_LOW     30      /* Battery low threshold */
536 +
537 +#define APMEMU_16_BIT_SUPPORT  0x01    /* 16 bit APM BIOS */
538 +#define APMEMU_32_BIT_SUPPORT  0x02    /* 32 bit APM BIOS */
539 +#define APMEMU_IDLE_SLOWS_CLOCK        0x04
540 +#define APMEMU_BIOS_DISABLED   0x08    /* APM BIOS disabled */
541 +#define APMEMU_BIOS_DISENGAGED 0x10    /* APM BIOS disengaged */
542 +
543 +#define APMEMU_AC_OFFLINE      0x00    /* AC offline */
544 +#define APMEMU_AC_ONLINE       0x01    /* AC online */
545 +#define APMEMU_AC_BACKUP       0x02    /* On backup power */
546 +#define APMEMU_AC_UNKNOWN      0xFF    /* Unkonwn status */
547 +
548 +#define APMEMU_BATTSTAT_HIGH   0x00    /* Remaining battery capacity is high */
549 +#define APMEMU_BATTSTAT_LOW    0x01    /* Remaining battery capacity is low */
550 +#define APMEMU_BATTSTAT_CRIT   0x02    /* Battery status is critical */
551 +#define APMEMU_BATTSTAT_CHR    0x03    /* Battery is charging */
552 +#define APMEMU_BATTSTAT_MISS   0x04    /* Battery is not present */
553 +
554 +#define APMEMU_BATTFLAG_HIGH   0x01    /* Remaining battery capacity is high bit */
555 +#define APMEMU_BATTFLAG_LOW    0x02    /* Remaining battery capacity is low bit */
556 +#define APMEMU_BATTFLAG_CRIT   0x04    /* Battery status is critical bit */
557 +#define APMEMU_BATTFLAG_CHR    0x08    /* Battery is charging bit */
558 +#define APMEMU_BATTFLAG_MISS   0x80    /* Battery is not present bit */
559 +
560 +#define APMEMU_BATTSTAT_UNKN   0xff    /* Status is unknown */
561 +
562 +#define APMEMU_BATTLIFE_UNKN   -1      /* Remaining battery capacity is unknown */
563 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/battery.c linux-2.6.1-gentoo-test/drivers/char/omnibook/battery.c
564 --- linux-2.6.1-gentoo/drivers/char/omnibook/battery.c  1970-01-01 01:00:00.000000000 +0100
565 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/battery.c     2004-01-09 22:33:49.000000000 +0000
566 @@ -0,0 +1,426 @@
567 +/*
568 + * battery.c -- battery related functions
569 + * 
570 + * This program is free software; you can redistribute it and/or modify it
571 + * under the terms of the GNU General Public License as published by the
572 + * Free Software Foundation; either version 2, or (at your option) any
573 + * later version.
574 + * 
575 + * This program is distributed in the hope that it will be useful, but
576 + * WITHOUT ANY WARRANTY; without even the implied warranty of
577 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
578 + * General Public License for more details.
579 + *
580 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
581 + */
582 +
583 +
584 +#include <linux/config.h>
585 +#include <linux/module.h>
586 +#include <linux/version.h>
587 +#include <linux/types.h>
588 +#include <linux/init.h>
589 +#include <linux/proc_fs.h>
590 +
591 +#include <asm/system.h>
592 +#include <asm/errno.h>
593 +#include <asm/io.h>
594 +#include <asm/uaccess.h>
595 +
596 +#ifdef OMNIBOOK_STANDALONE
597 +#include "omnibook.h"
598 +#else
599 +#include <linux/omnibook.h>
600 +#endif
601 +
602 +#include "ec.h"
603 +#include "util.h"
604 +
605 +static struct proc_dir_entry *proc_battery;
606 +
607 +int omnibook_battery_present(int num)
608 +{
609 +       int retval;
610 +       int i;
611 +       u8 bat;
612 +       u8 mask = 0;
613 +
614 +       switch (omnibook_ectype) {
615 +       case XE3GF:
616 +               if (num >= 2)
617 +                       return -EINVAL;
618 +               if ((retval = omnibook_ec_read(XE3GF_BAL, &bat)))
619 +                       return retval;
620 +               mask = XE3GF_BAL0_MASK;
621 +               for (i = 0; i < num; i++)
622 +                       mask = mask << 1;
623 +               break;
624 +       case XE3GC:
625 +               if (num >= 2)
626 +                       return -EINVAL;
627 +               if ((retval = omnibook_ec_read(XE3GC_BAT, &bat)))
628 +                       return retval;
629 +               mask = XE3GC_BAT0_MASK;
630 +               for (i = 0; i < num; i++)
631 +                       mask = mask << 1;
632 +               break;
633 +       }
634 +       return (bat & mask) ? 1 : 0;
635 +}
636 +
637 +/*
638 + * Get static battery information
639 + * All info have to be reread every time because battery sould be cahnged
640 + * when laptop is on AC power 
641 + * return values:
642 + *  < 0 - ERROR
643 + *    0 - OK
644 + *    1 - Battery is not present
645 + *    2 - Not supported
646 + */
647 +int omnibook_get_battery_info(int num, struct omnibook_battery_info *battinfo)
648 +{
649 +       int retval;
650 +       u32 offset;
651 +
652 +       switch (omnibook_ectype) {
653 +       case XE3GF:
654 +               offset = 0x10;
655 +               retval = omnibook_battery_present(num);
656 +               if (retval < 0)
657 +                       return retval;
658 +               if (retval) {
659 +                       if ((retval = omnibook_ec_read(XE3GF_BTY0 + (offset * num), &(*battinfo).type)))
660 +                               return retval;
661 +                       if ((retval = omnibook_ec_read16(XE3GF_BSN0 + (offset * num), &(*battinfo).sn)))
662 +                               return retval;
663 +                       if ((retval = omnibook_ec_read16(XE3GF_BDV0 + (offset * num), &(*battinfo).dv)))
664 +                               return retval;
665 +                       if ((retval = omnibook_ec_read16(XE3GF_BDC0 + (offset * num), &(*battinfo).dc)))
666 +                               return retval;
667 +
668 +                       (*battinfo).type = ((*battinfo).type & XE3GF_BTY_MASK) ? 1 : 0;
669 +               } else
670 +                       return 1;
671 +               break;
672 +       case XE3GC:
673 +               offset = 0x10;
674 +               retval = omnibook_battery_present(num);
675 +               if (retval < 0)
676 +                       return retval;
677 +               if (retval) {
678 +                       if ((retval = omnibook_ec_read16(XE3GC_BDV0 + (offset * num), &(*battinfo).dv)))
679 +                               return retval;
680 +                       if ((retval = omnibook_ec_read16(XE3GC_BDC0 + (offset * num), &(*battinfo).dc)))
681 +                               return retval;
682 +                       if ((retval = omnibook_ec_read(XE3GC_BTY0 + (offset * num), &(*battinfo).type)))
683 +                               return retval;
684 +
685 +                       (*battinfo).type = ((*battinfo).type & XE3GC_BTY_MASK) ? 1 : 0;
686 +                       (*battinfo).sn = 0; /* Unknown */
687 +               } else
688 +                       return 1;
689 +               break;
690 +       /* FIXME */
691 +       case OB500:
692 +       case OB510:
693 +               switch (num) {
694 +               case 0:
695 +                       break;
696 +               case 1:
697 +                       break;
698 +               case 2:
699 +                       break;
700 +               default:
701 +                       return -EINVAL;
702 +               }
703 +               break;
704 +       case OB6000:
705 +       case OB6100:
706 +       case XE4500:
707 +               switch (num) {
708 +               case 0:
709 +                       break;
710 +               case 1:
711 +                       break;
712 +               default:
713 +                       return -EINVAL;
714 +               }
715 +               break;
716 +       default:
717 +               return 2;
718 +       }
719 +       return 0;
720 +}
721 +
722 +/*
723 + * Get battery status
724 + * return values:
725 + *  < 0 - ERROR
726 + *    0 - OK
727 + *    1 - Battery is not present
728 + *    2 - Not supported
729 + */
730 +int omnibook_get_battery_status(int num, struct omnibook_battery_status *battstat)
731 +{
732 +       int retval;
733 +       u8 status;
734 +       u16 dc;
735 +       int gauge;
736 +       u8 offset;
737 +
738 +       switch (omnibook_ectype) {
739 +       case XE3GF:
740 +               offset = 0x10;
741 +               retval = omnibook_battery_present(num);
742 +               if (retval < 0)
743 +                       return retval;
744 +               if (retval) {
745 +                       if ((retval = omnibook_ec_read(XE3GF_BST0 + (offset * num), &status)))
746 +                               return retval;
747 +                       if ((retval = omnibook_ec_read16(XE3GF_BRC0 + (offset * num), &(*battstat).rc)))
748 +                               return retval;
749 +                       if ((retval = omnibook_ec_read16(XE3GF_BPV0 + (offset * num), &(*battstat).pv)))
750 +                               return retval;
751 +                       if ((retval = omnibook_ec_read16(XE3GF_BFC0 + (offset * num), &(*battstat).lc)))
752 +                               return retval;
753 +                       if ((retval = omnibook_ec_read(XE3GF_GAU0 + (offset * num), &(*battstat).gauge)))
754 +                               return retval;
755 +
756 +                       if (status & XE3GF_BST_MASK_CRT)
757 +                               (*battstat).status = OMNIBOOK_BATTSTAT_CRITICAL;
758 +                       else if (status & XE3GF_BST_MASK_CHR)
759 +                               (*battstat).status = OMNIBOOK_BATTSTAT_CHARGING;
760 +                       else if (status & XE3GF_BST_MASK_DSC)
761 +                               (*battstat).status = OMNIBOOK_BATTSTAT_DISCHARGING;
762 +                       else if (status & (XE3GF_BST_MASK_CHR | XE3GF_BST_MASK_DSC))
763 +                               (*battstat).status = OMNIBOOK_BATTSTAT_UNKNOWN;
764 +                       else {
765 +                               (*battstat).status = OMNIBOOK_BATTSTAT_CHARGED;
766 +                       }
767 +               } else
768 +                       return 1;
769 +               break;
770 +       case XE3GC:
771 +               offset = 0x10;
772 +               retval = omnibook_battery_present(num);
773 +               if (retval < 0)
774 +                       return retval;
775 +               if (retval) {
776 +                       if ((retval = omnibook_ec_read(XE3GC_BST0 + (offset * num), &status)))
777 +                               return retval;
778 +                       if ((retval = omnibook_ec_read16(XE3GC_BRC0 + (offset * num), &(*battstat).rc)))
779 +                               return retval;
780 +                       if ((retval = omnibook_ec_read16(XE3GC_BPV0 + (offset * num), &(*battstat).pv)))
781 +                               return retval;
782 +                       if ((retval = omnibook_ec_read16(XE3GC_BDC0 + (offset * num), &dc)))
783 +                               return retval;
784 +
785 +                       if (status & XE3GC_BST_MASK_CRT)
786 +                               (*battstat).status = OMNIBOOK_BATTSTAT_CRITICAL;
787 +                       else if (status & XE3GC_BST_MASK_CHR)
788 +                               (*battstat).status = OMNIBOOK_BATTSTAT_CHARGING;
789 +                       else if (status & XE3GC_BST_MASK_DSC)
790 +                               (*battstat).status = OMNIBOOK_BATTSTAT_DISCHARGING;
791 +                       else if (status & (XE3GC_BST_MASK_CHR | XE3GC_BST_MASK_DSC))
792 +                               (*battstat).status = OMNIBOOK_BATTSTAT_UNKNOWN;
793 +                       else {
794 +                               (*battstat).status = OMNIBOOK_BATTSTAT_CHARGED;
795 +                       }
796 +                       gauge = ((*battstat).rc * 100) / dc;
797 +                       (*battstat).gauge = gauge;
798 +                       (*battstat).lc = 0; /* Unknown */
799 +               } else
800 +                       return 1;
801 +       case OB500:
802 +       case OB510:
803 +               switch (num) {
804 +               case 0:
805 +                       if ((retval = omnibook_ec_read(OB500_BT1S, &status)))
806 +                               return retval;
807 +                       if ((retval = omnibook_ec_read16(OB500_BT1C, &(*battstat).rc)))
808 +                               return retval;
809 +                       if ((retval = omnibook_ec_read16(OB500_BT1V, &(*battstat).pv)))
810 +                               return retval;
811 +                       break;
812 +               case 1:
813 +                       if ((retval = omnibook_ec_read(OB500_BT2S, &status)))
814 +                               return retval;
815 +                       if ((retval = omnibook_ec_read16(OB500_BT2C, &(*battstat).rc)))
816 +                               return retval;
817 +                       if ((retval = omnibook_ec_read16(OB500_BT2V, &(*battstat).pv)))
818 +                               return retval;
819 +                       break;
820 +               case 2:
821 +                       if ((retval = omnibook_ec_read(OB500_BT3S, &status)))
822 +                               return retval;
823 +                       if ((retval = omnibook_ec_read16(OB500_BT3C, &(*battstat).rc)))
824 +                               return retval;
825 +                       if ((retval = omnibook_ec_read16(OB500_BT3V, &(*battstat).pv)))
826 +                               return retval;
827 +                       break;
828 +               default:
829 +                       return -EINVAL;
830 +               }
831 +               if (status & OB500_BST_MASK_CRT)
832 +                       (*battstat).status = OMNIBOOK_BATTSTAT_CRITICAL;
833 +               else if (status & OB500_BST_MASK_CHR)
834 +                       (*battstat).status = OMNIBOOK_BATTSTAT_CHARGING;
835 +               else if (status & OB500_BST_MASK_DSC)
836 +                       (*battstat).status = OMNIBOOK_BATTSTAT_DISCHARGING;
837 +               else if (status & (OB500_BST_MASK_CHR | OB500_BST_MASK_DSC))
838 +                       (*battstat).status = OMNIBOOK_BATTSTAT_UNKNOWN;
839 +               else {
840 +                       (*battstat).status = OMNIBOOK_BATTSTAT_CHARGED;
841 +               }
842 +               break;
843 +       case OB6000:
844 +       case OB6100:
845 +       case XE4500:
846 +               switch (num) {
847 +               case 0:
848 +                       if ((retval = omnibook_ec_read(OB500_BT1S, &status)))
849 +                               return retval;
850 +                       if ((retval = omnibook_ec_read16(OB500_BT1C, &(*battstat).rc)))
851 +                               return retval;
852 +                       if ((retval = omnibook_ec_read16(OB500_BT1V, &(*battstat).pv)))
853 +                               return retval;
854 +                       break;
855 +               case 1:
856 +                       if ((retval = omnibook_ec_read(OB500_BT3S, &status)))
857 +                               return retval;
858 +                       if ((retval = omnibook_ec_read16(OB500_BT3C, &(*battstat).rc)))
859 +                               return retval;
860 +                       if ((retval = omnibook_ec_read16(OB500_BT3V, &(*battstat).pv)))
861 +                               return retval;
862 +                       break;
863 +               default:
864 +                       return -EINVAL;
865 +               }
866 +               if (status & OB500_BST_MASK_CRT)
867 +                       (*battstat).status = OMNIBOOK_BATTSTAT_CRITICAL;
868 +               else if (status & OB500_BST_MASK_CHR)
869 +                       (*battstat).status = OMNIBOOK_BATTSTAT_CHARGING;
870 +               else if (status & OB500_BST_MASK_DSC)
871 +                       (*battstat).status = OMNIBOOK_BATTSTAT_DISCHARGING;
872 +               else if (status & (OB500_BST_MASK_CHR | OB500_BST_MASK_DSC))
873 +                       (*battstat).status = OMNIBOOK_BATTSTAT_UNKNOWN;
874 +               else {
875 +                       (*battstat).status = OMNIBOOK_BATTSTAT_CHARGED;
876 +               }
877 +               break;
878 +       default:
879 +               return 2;
880 +       }
881 +       return 0;
882 +}
883 +
884 +static int omnibook_proc_battery(char *buffer, char **start, off_t off, int count, int *eof, void *data)
885 +{
886 +       char *statustr;
887 +       char *typestr;
888 +       int max = 0;
889 +       int num = 0; 
890 +       int retval;
891 +       char *b = buffer;
892 +       int i;
893 +       struct omnibook_battery_info battinfo;
894 +       struct omnibook_battery_status battstat;
895 +
896 +       switch (omnibook_ectype) {
897 +       case XE3GF:
898 +       case XE3GC:
899 +       case OB6000:
900 +       case OB6100:
901 +       case XE4500:
902 +               max = 2;
903 +               break;
904 +       case OB500:
905 +       case OB510:
906 +               max = 3;
907 +               break;
908 +       }
909 +       
910 +       for (i = 0; i < max; i++) {
911 +               retval = omnibook_get_battery_info(i, &battinfo);
912 +               if (retval == 0) {
913 +                       num++;
914 +                       omnibook_get_battery_status(i, &battstat);
915 +                       typestr = (battinfo.type) ? "Li-Ion" : "NiMH";
916 +                       switch (battstat.status) {
917 +                       case OMNIBOOK_BATTSTAT_CHARGED:
918 +                               statustr = "charged";
919 +                               break;
920 +                       case OMNIBOOK_BATTSTAT_DISCHARGING:
921 +                               statustr = "discharging";
922 +                               break;
923 +                       case OMNIBOOK_BATTSTAT_CHARGING:
924 +                               statustr = "charging";
925 +                               break;
926 +                       case OMNIBOOK_BATTSTAT_CRITICAL:
927 +                               statustr = "critical";
928 +                               break;
929 +                       default:
930 +                               statustr = "unknown";
931 +                       }
932 +
933 +                       b += sprintf(b, "Battery:            %11d\n", i);
934 +                       b += sprintf(b, "Type:               %11s\n", typestr);
935 +                       if (battinfo.sn)
936 +                               b += sprintf(b, "Serial Number:      %11d\n", battinfo.sn);
937 +                       b += sprintf(b, "Present Voltage:    %11d mV\n", battstat.pv);
938 +                       b += sprintf(b, "Design Voltage:     %11d mV\n", battinfo.dv);
939 +                       b += sprintf(b, "Remaining Capacity: %11d mAh\n", battstat.rc);
940 +                       if (battstat.lc)
941 +                               b += sprintf(b, "Last Full Capacity: %11d mAh\n", battstat.lc);
942 +                       b += sprintf(b, "Design Capacity:    %11d mAh\n", battinfo.dc);
943 +                       b += sprintf(b, "Gauge:              %11d %%\n", battstat.gauge);
944 +                       b += sprintf(b, "Status:             %11s\n", statustr);
945 +                       b += sprintf(b, "\n");
946 +               }
947 +       }
948 +       if (num == 0)
949 +               b += sprintf(b, "No battery present\n");
950 +
951 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
952 +}
953 +
954 +int __init omnibook_battery_init(void)
955 +{
956 +       mode_t pmode;
957 +
958 +       switch (omnibook_ectype) {
959 +       case XE3GF:
960 +       case XE3GC:
961 +       /* FIXME */
962 +//     case OB500:
963 +//     case OB510:
964 +//     case OB6000:
965 +//     case OB6100:
966 +//     case XE4500:
967 +               pmode = S_IFREG | S_IRUGO;
968 +               proc_battery = create_proc_read_entry("battery", pmode, omnibook_proc_root, omnibook_proc_battery, NULL);
969 +               break;
970 +       default:
971 +               printk(KERN_INFO "%s: Battery status monitoring is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
972 +               return 0;
973 +       }
974 +       if (! proc_battery) {
975 +               printk(KERN_ERR "%s: Unable to create /proc/%s/battery.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
976 +               return -ENOENT;
977 +       }
978 +       printk(KERN_INFO "%s: Battery status monitoring is enabled.\n", OMNIBOOK_MODULE_NAME);
979 +       return 0;
980 +}
981 +
982 +void __exit omnibook_battery_cleanup(void)
983 +{
984 +       if (proc_battery)
985 +               remove_proc_entry("battery", omnibook_proc_root);
986 +}
987 +
988 +EXPORT_SYMBOL(omnibook_battery_present);
989 +EXPORT_SYMBOL(omnibook_get_battery_info);
990 +EXPORT_SYMBOL(omnibook_get_battery_status);
991 +
992 +/* End of file */
993 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/blank.c linux-2.6.1-gentoo-test/drivers/char/omnibook/blank.c
994 --- linux-2.6.1-gentoo/drivers/char/omnibook/blank.c    1970-01-01 01:00:00.000000000 +0100
995 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/blank.c       2004-01-09 22:33:49.000000000 +0000
996 @@ -0,0 +1,208 @@
997 +/*
998 + * blank.c -- blanking lcd console
999 + * 
1000 + * This program is free software; you can redistribute it and/or modify it
1001 + * under the terms of the GNU General Public License as published by the
1002 + * Free Software Foundation; either version 2, or (at your option) any
1003 + * later version.
1004 + * 
1005 + * This program is distributed in the hope that it will be useful, but
1006 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1007 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1008 + * General Public License for more details.
1009 + *
1010 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
1011 + */
1012 +
1013 +
1014 +#include <linux/config.h>
1015 +#include <linux/module.h>
1016 +#include <linux/version.h>
1017 +#include <linux/types.h>
1018 +#include <linux/init.h>
1019 +#include <linux/pm.h>
1020 +#include <linux/proc_fs.h>
1021 +
1022 +#include <asm/system.h>
1023 +#include <asm/errno.h>
1024 +#include <asm/io.h>
1025 +#include <asm/uaccess.h>
1026 +
1027 +#ifdef OMNIBOOK_STANDALONE
1028 +#include "omnibook.h"
1029 +#else
1030 +#include <linux/omnibook.h>
1031 +#endif
1032 +
1033 +#include "ec.h"
1034 +#include "util.h"
1035 +
1036 +static struct proc_dir_entry *proc_blank;
1037 +int omnibook_console_blank_enabled = 0;
1038 +
1039 +extern int (*console_blank_hook)(int);
1040 +
1041 +/*
1042 + * Turn LCD display off at console blanking if APM does not do it
1043 + * (e.g. using ACPI).
1044 + */
1045 +
1046 +int omnibook_lcd_blank(int blank)
1047 +{
1048 +       int retval = 0;
1049 +#ifdef CONFIG_VT
1050 +       u8 cmd;
1051 +       
1052 +       switch (omnibook_ectype) {
1053 +       case XE3GF:
1054 +       case XE3GC:
1055 +               cmd = blank ? OMNIBOOK_KBC_CMD_LCD_OFF : OMNIBOOK_KBC_CMD_LCD_ON;
1056 +               if ((retval = omnibook_kbc_command(OMNIBOOK_KBC_CONTROL_CMD, cmd)))
1057 +                       return retval;
1058 +               break;
1059 +       case OB500:
1060 +       case OB6000:
1061 +       case XE2:
1062 +               if ((retval = omnibook_io_read(OB500_GPO1, &cmd)))
1063 +                       return retval;
1064 +               cmd = blank ? cmd & ~OB500_BKLT_MASK : cmd | OB500_BKLT_MASK;
1065 +               if ((retval = omnibook_io_write(OB500_GPO1, cmd)))
1066 +                       return retval;
1067 +               break;
1068 +       case OB510:
1069 +       case OB6100:
1070 +               if ((retval = omnibook_io_read(OB510_GPO2, &cmd)))
1071 +                       return retval;
1072 +               cmd = blank ? cmd & ~OB510_BKLT_MASK : cmd | OB510_BKLT_MASK;
1073 +               if ((retval = omnibook_io_write(OB510_GPO2, cmd)))
1074 +                       return retval;
1075 +               break;
1076 +       default:
1077 +               printk(KERN_INFO "%s: LCD console blanking is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
1078 +               retval = -ENODEV;
1079 +       }
1080 +#endif
1081 +       return retval;
1082 +}
1083 +
1084 +int omnibook_console_blank_enable(void)
1085 +{
1086 +#ifdef CONFIG_VT
1087 +       if (omnibook_console_blank_enabled == 0) {
1088 +               if (console_blank_hook == NULL) {
1089 +                       console_blank_hook = omnibook_lcd_blank;
1090 +                       printk(KERN_INFO "%s: LCD display turn off at console blanking enabled.\n", OMNIBOOK_MODULE_NAME);
1091 +                       omnibook_console_blank_enabled = 1;
1092 +               } else {
1093 +                       printk(KERN_INFO "%s: There is a console blanking solution already registered.\n", OMNIBOOK_MODULE_NAME);
1094 +               }
1095 +       }
1096 +#endif
1097 +       return 0;
1098 +}
1099 +       
1100 +int omnibook_console_blank_disable(void)
1101 +{
1102 +#ifdef CONFIG_VT
1103 +       if (console_blank_hook == omnibook_lcd_blank) {
1104 +               console_blank_hook = NULL;
1105 +               printk(KERN_INFO "%s: LCD display turn off at console blanking disabled.\n", OMNIBOOK_MODULE_NAME);
1106 +               omnibook_console_blank_enabled = 0;
1107 +       } else if (console_blank_hook) {
1108 +               printk(KERN_WARNING "%s: You can not disable another console blanking solution.\n", OMNIBOOK_MODULE_NAME);
1109 +               return -EBUSY;
1110 +       } else {
1111 +               printk(KERN_INFO "%s: Console blanking already disabled.\n", OMNIBOOK_MODULE_NAME);
1112 +               return 0;
1113 +       }
1114 +#endif
1115 +       return 0;
1116 +}
1117 +
1118 +static int omnibook_console_blank_status(char *buffer, char **start, off_t off, int count, int *eof, void *data)
1119 +{
1120 +       char *b = buffer;
1121 +
1122 +       b += sprintf(b, "LCD console blanking is %s\n", (omnibook_console_blank_enabled) ? "enabled" : "disabled");
1123 +
1124 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
1125 +}
1126 +
1127 +static int omnibook_console_blank_set(struct file *file, const char *buffer, unsigned long count, void *data)
1128 +{
1129 +       char status[1] = {'\0'};
1130 +       int retval;
1131 +
1132 +       if ((retval = copy_from_user(status, buffer, 1)))
1133 +               return retval;
1134 +       switch (*status) {
1135 +       case '0':
1136 +               if ((retval = omnibook_console_blank_disable()))
1137 +                       return retval;
1138 +               break;
1139 +       case '1':
1140 +               if ((retval = omnibook_console_blank_enable()))
1141 +                       return retval;
1142 +               break;
1143 +       default:
1144 +               count = -EINVAL;
1145 +       }
1146 +       return count;
1147 +}
1148 +
1149 +int __init omnibook_console_blank_init(void)
1150 +{
1151 +#ifdef CONFIG_VT
1152 +       mode_t pmode;
1153 +       int retval;
1154 +
1155 +       switch (omnibook_ectype) {
1156 +       case XE3GF:
1157 +       case XE3GC:
1158 +       case OB500:
1159 +       case OB510:
1160 +       case OB6000:
1161 +       case OB6100:
1162 +       case XE2:
1163 +               if ((retval = omnibook_console_blank_enable()))
1164 +                       return retval;
1165 +               pmode = S_IFREG | S_IWUSR | S_IRUGO;
1166 +               if (omnibook_userset)
1167 +                       pmode = pmode | S_IWUGO;
1168 +               proc_blank = create_proc_entry("blank", pmode, omnibook_proc_root);
1169 +               break;
1170 +       default:
1171 +               printk(KERN_INFO "%s: LCD console blanking is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
1172 +               return 0;
1173 +       }
1174 +       
1175 +       if (proc_blank) {
1176 +               proc_blank->read_proc = omnibook_console_blank_status;
1177 +               proc_blank->write_proc = omnibook_console_blank_set;
1178 +       } else {
1179 +               printk(KERN_ERR "%s: Unable to create /proc/%s/blank.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
1180 +               return -ENOENT;
1181 +       }
1182 +       return 0;
1183 +#else
1184 +       printk(KERN_ERR "%s: Virtual terminal support is not compiled into your kernel.\n", OMNIBOOK_MODULE_NAME);
1185 +       return -ENODEV;
1186 +#endif
1187 +}
1188 +
1189 +void __exit omnibook_console_blank_cleanup(void)
1190 +{
1191 +#ifdef CONFIG_VT
1192 +       if (proc_blank) {
1193 +               remove_proc_entry("blank", omnibook_proc_root);
1194 +               omnibook_console_blank_disable();
1195 +       }
1196 +#endif
1197 +}
1198 +
1199 +EXPORT_SYMBOL(omnibook_console_blank_enabled);
1200 +EXPORT_SYMBOL(omnibook_lcd_blank);
1201 +EXPORT_SYMBOL(omnibook_console_blank_enable);
1202 +EXPORT_SYMBOL(omnibook_console_blank_disable);
1203 +
1204 +/* End of file */
1205 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/display.c linux-2.6.1-gentoo-test/drivers/char/omnibook/display.c
1206 --- linux-2.6.1-gentoo/drivers/char/omnibook/display.c  1970-01-01 01:00:00.000000000 +0100
1207 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/display.c     2004-01-09 22:33:49.000000000 +0000
1208 @@ -0,0 +1,137 @@
1209 +/*
1210 + * display.c -- external display related functions
1211 + * 
1212 + * This program is free software; you can redistribute it and/or modify it
1213 + * under the terms of the GNU General Public License as published by the
1214 + * Free Software Foundation; either version 2, or (at your option) any
1215 + * later version.
1216 + * 
1217 + * This program is distributed in the hope that it will be useful, but
1218 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1219 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1220 + * General Public License for more details.
1221 + *
1222 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
1223 + */
1224 +
1225 +
1226 +#include <linux/config.h>
1227 +#include <linux/module.h>
1228 +#include <linux/version.h>
1229 +#include <linux/types.h>
1230 +#include <linux/init.h>
1231 +#include <linux/proc_fs.h>
1232 +
1233 +#include <asm/system.h>
1234 +#include <asm/errno.h>
1235 +#include <asm/io.h>
1236 +#include <asm/uaccess.h>
1237 +
1238 +#ifdef OMNIBOOK_STANDALONE
1239 +#include "omnibook.h"
1240 +#else
1241 +#include <linux/omnibook.h>
1242 +#endif
1243 +
1244 +#include "ec.h"
1245 +#include "util.h"
1246 +
1247 +static struct proc_dir_entry *proc_display;
1248 +
1249 +int omnibook_get_display(void)
1250 +{
1251 +       int retval = 0;
1252 +#ifdef CONFIG_VT
1253 +       u8 sta;
1254 +       
1255 +       switch (omnibook_ectype) {
1256 +       case XE3GF:
1257 +               if ((retval = omnibook_ec_read(XE3GF_STA1, &sta)))
1258 +                       return retval;
1259 +               retval = (sta & XE3GF_SHDD_MASK) ? 1 : 0;
1260 +               break;
1261 +       case XE3GC:
1262 +               if ((retval = omnibook_ec_read(XE3GC_STA1, &sta)))
1263 +                       return retval;
1264 +               retval = (sta & XE3GC_CRTI_MASK) ? 1 : 0;
1265 +               break;
1266 +       case OB500:
1267 +       case OB510:
1268 +       case OB6000:
1269 +       case OB6100:
1270 +       case XE4500:
1271 +               if ((retval = omnibook_ec_read(OB500_STA1, &sta)))
1272 +                       return retval;
1273 +               retval = (sta & OB500_CRTS_MASK) ? 1 : 0;
1274 +               break;
1275 +       case OB4150:
1276 +               if ((retval = omnibook_ec_read(OB4150_STA2, &sta)))
1277 +                       return retval;
1278 +               retval = (sta & OB4150_CRST_MASK) ? 1 : 0;
1279 +               break;
1280 +       default:
1281 +               printk(KERN_INFO "%s: External display status monitoring is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
1282 +               retval = -ENODEV;
1283 +       }
1284 +#endif
1285 +       return retval;
1286 +}
1287 +
1288 +static int omnibook_proc_display(char *buffer, char **start, off_t off, int count, int *eof, void *data)
1289 +{
1290 +       char *b = buffer;
1291 +       int display;
1292 +
1293 +       display = omnibook_get_display();
1294 +       if (display < 0)
1295 +               return display;
1296 +
1297 +       b += sprintf(b, "External display is %s\n", (display) ? "present" : "not present");
1298 +       
1299 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
1300 +}
1301 +
1302 +int __init omnibook_display_init(void)
1303 +{
1304 +#ifdef CONFIG_VT
1305 +       mode_t pmode;
1306 +
1307 +       switch (omnibook_ectype) {
1308 +       case XE3GF:
1309 +       case XE3GC:
1310 +       case OB500:
1311 +       case OB510:
1312 +       case OB6000:
1313 +       case OB6100:
1314 +       case XE4500:
1315 +       case OB4150:
1316 +               pmode = S_IFREG | S_IRUGO;
1317 +               proc_display = create_proc_read_entry("display", pmode, omnibook_proc_root, omnibook_proc_display, NULL);
1318 +               break;
1319 +       default:
1320 +               printk(KERN_INFO "%s: External display status monitoring is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
1321 +               return 0;
1322 +       }
1323 +       if (! proc_display) {
1324 +               printk(KERN_ERR "%s: Unable to create /proc/%s/display.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
1325 +               return -ENOENT;
1326 +       }
1327 +       printk(KERN_INFO "%s: External display status monitoring is enabled.\n", OMNIBOOK_MODULE_NAME);
1328 +       return 0;
1329 +#else
1330 +       printk(KERN_ERR "%s: Virtual terminal support is not compiled into your kernel.\n", OMNIBOOK_MODULE_NAME);
1331 +       return -ENODEV;
1332 +#endif
1333 +}
1334 +
1335 +void __exit omnibook_display_cleanup(void)
1336 +{
1337 +#ifdef CONFIG_VT
1338 +       if (proc_display)
1339 +               remove_proc_entry("display", omnibook_proc_root);
1340 +#endif
1341 +}
1342 +
1343 +EXPORT_SYMBOL(omnibook_get_display);
1344 +
1345 +/* End of file */
1346 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/dmi.c linux-2.6.1-gentoo-test/drivers/char/omnibook/dmi.c
1347 --- linux-2.6.1-gentoo/drivers/char/omnibook/dmi.c      1970-01-01 01:00:00.000000000 +0100
1348 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/dmi.c 2004-01-09 22:33:49.000000000 +0000
1349 @@ -0,0 +1,205 @@
1350 +/*
1351 + * dmi.c -- to get DMI information
1352 + *
1353 + * This code originally came from file arch/i386/kernel/dmi_scan.c from 
1354 + * Linux kernel version 2.4.18
1355 + * 
1356 + * This program is free software; you can redistribute it and/or modify it
1357 + * under the terms of the GNU General Public License as published by the
1358 + * Free Software Foundation; either version 2, or (at your option) any
1359 + * later version.
1360 + * 
1361 + * This program is distributed in the hope that it will be useful, but
1362 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1363 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1364 + * General Public License for more details.
1365 + */
1366 +
1367 +
1368 +#include <linux/config.h>
1369 +#include <linux/module.h>
1370 +#include <linux/version.h>
1371 +#include <linux/types.h>
1372 +#include <linux/kernel.h>
1373 +#include <linux/string.h>
1374 +#include <linux/init.h>
1375 +#include <linux/apm_bios.h>
1376 +#include <linux/slab.h>
1377 +
1378 +#include <asm/io.h>
1379 +#include <asm/system.h>
1380 +
1381 +#ifdef OMNIBOOK_STANDALONE
1382 +#include "omnibook.h"
1383 +#else
1384 +#include <linux/omnibook.h>
1385 +#endif
1386 +
1387 +#include "dmi.h"
1388 +
1389 +struct dmi_header
1390 +{
1391 +       u8      type;
1392 +       u8      length;
1393 +       u16     handle;
1394 +};
1395 +
1396 +static char * __init dmi_string(struct dmi_header *dm, u8 s)
1397 +{
1398 +       u8 *bp=(u8 *)dm;
1399 +       bp+=dm->length;
1400 +       if(!s)
1401 +               return "";
1402 +       s--;
1403 +       while(s>0 && *bp)
1404 +       {
1405 +               bp+=strlen(bp);
1406 +               bp++;
1407 +               s--;
1408 +       }
1409 +       return bp;
1410 +}
1411 +
1412 +/*
1413 + *     We have to be cautious here. We have seen BIOSes with DMI pointers
1414 + *     pointing to completely the wrong place for example
1415 + */
1416
1417 +static int __init dmi_table(u32 base, int len, int num, void (*decode)(struct dmi_header *))
1418 +{
1419 +       u8 *buf;
1420 +       struct dmi_header *dm;
1421 +       u8 *data;
1422 +       int i=0;
1423 +               
1424 +       buf = ioremap(base, len);
1425 +       if(buf==NULL)
1426 +               return -1;
1427 +
1428 +       data = buf;
1429 +
1430 +       /*
1431 +        *      Stop when we see all the items the table claimed to have
1432 +        *      OR we run off the end of the table (also happens)
1433 +        */
1434
1435 +       while(i<num && data-buf+sizeof(struct dmi_header)<=len)
1436 +       {
1437 +               dm=(struct dmi_header *)data;
1438 +               /*
1439 +                *  We want to know the total length (formated area and strings)
1440 +                *  before decoding to make sure we won't run off the table in
1441 +                *  dmi_decode or dmi_string
1442 +                */
1443 +               data+=dm->length;
1444 +               while(data-buf<len-1 && (data[0] || data[1]))
1445 +                       data++;
1446 +               if(data-buf<len-1)
1447 +                       decode(dm);
1448 +               data+=2;
1449 +               i++;
1450 +       }
1451 +       iounmap(buf);
1452 +       return 0;
1453 +}
1454 +
1455 +inline static int __init dmi_checksum(u8 *buf)
1456 +{
1457 +       u8 sum=0;
1458 +       int a;
1459 +
1460 +       for(a=0; a<15; a++)
1461 +               sum+=buf[a];
1462 +       return (sum==0);
1463 +}
1464 +
1465 +static int __init dmi_iterate(void (*decode)(struct dmi_header *))
1466 +{
1467 +       u8 buf[15];
1468 +       u32 fp=0xF0000;
1469 +
1470 +#ifdef CONFIG_SIMNOW
1471 +       /*
1472 +        *      Skip on x86/64 with simnow. Will eventually go away
1473 +        *      If you see this ifdef in 2.6pre mail me !
1474 +        */
1475 +       return -1;
1476 +#endif
1477 +
1478 +       while( fp < 0xFFFFF)
1479 +       {
1480 +               isa_memcpy_fromio(buf, fp, 15);
1481 +               if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf))
1482 +               {
1483 +                       u16 num=buf[13]<<8|buf[12];
1484 +                       u16 len=buf[7]<<8|buf[6];
1485 +                       u32 base=buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8];
1486 +
1487 +                       if(dmi_table(base,len,num,decode)==0)
1488 +                               return 0;
1489 +               }
1490 +               fp+=16;
1491 +       }
1492 +       return -1;
1493 +}
1494 +
1495 +char *omnibook_dmi_ident[OMNIBOOK_STRING_MAX];
1496 +
1497 +/*
1498 + *     Save a DMI string
1499 + */
1500
1501 +static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string)
1502 +{
1503 +       char *d = (char*)dm;
1504 +       char *p = dmi_string(dm, d[string]);
1505 +       if(p==NULL || *p == 0)
1506 +               return;
1507 +       if (omnibook_dmi_ident[slot])
1508 +               return;
1509 +       omnibook_dmi_ident[slot] = kmalloc(strlen(p)+1, GFP_KERNEL);
1510 +       if(omnibook_dmi_ident[slot])
1511 +               strcpy(omnibook_dmi_ident[slot], p);
1512 +       else
1513 +               printk(KERN_ERR "%s: dmi_save_ident: out of memory.\n", OMNIBOOK_MODULE_NAME);
1514 +}
1515 +
1516 +/*
1517 + *     Process a DMI table entry. Right now all we care about are the BIOS
1518 + *     and machine entries. For 2.5 we should pull the smbus controller info
1519 + *     out of here.
1520 + */
1521 +
1522 +static void __init dmi_decode(struct dmi_header *dm)
1523 +{
1524 +       switch(dm->type)
1525 +       {
1526 +               case  0:
1527 +                       dmi_save_ident(dm, OMNIBOOK_BIOS_VENDOR, 4);
1528 +                       dmi_save_ident(dm, OMNIBOOK_BIOS_VERSION, 5);
1529 +                       dmi_save_ident(dm, OMNIBOOK_BIOS_DATE, 8);
1530 +                       break;
1531 +                       
1532 +               case 1:
1533 +                       dmi_save_ident(dm, OMNIBOOK_SYS_VENDOR, 4);
1534 +                       dmi_save_ident(dm, OMNIBOOK_PRODUCT_NAME, 5);
1535 +                       dmi_save_ident(dm, OMNIBOOK_PRODUCT_VERSION, 6);
1536 +                       dmi_save_ident(dm, OMNIBOOK_SERIAL_NUMBER, 7);
1537 +                       break;
1538 +               case 2:
1539 +                       dmi_save_ident(dm, OMNIBOOK_BOARD_VENDOR, 4);
1540 +                       dmi_save_ident(dm, OMNIBOOK_BOARD_NAME, 5);
1541 +                       dmi_save_ident(dm, OMNIBOOK_BOARD_VERSION, 6);
1542 +                       break;
1543 +       }
1544 +}
1545 +
1546 +int __init omnibook_dmi_scan_machine(void)
1547 +{
1548 +       int err = dmi_iterate(dmi_decode);
1549 +       return err;
1550 +}
1551 +
1552 +EXPORT_SYMBOL(omnibook_dmi_ident);
1553 +
1554 +/* End of file */
1555 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/dmi.h linux-2.6.1-gentoo-test/drivers/char/omnibook/dmi.h
1556 --- linux-2.6.1-gentoo/drivers/char/omnibook/dmi.h      1970-01-01 01:00:00.000000000 +0100
1557 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/dmi.h 2004-01-09 22:33:49.000000000 +0000
1558 @@ -0,0 +1,37 @@
1559 +/*
1560 + * dmi.h -- code to get DMI information
1561 + *
1562 + * This code originally came from file arch/i386/kernel/dmi_scan.c from 
1563 + * Linux kernel version 2.4.18
1564 + *
1565 + * This program is free software; you can redistribute it and/or modify it
1566 + * under the terms of the GNU General Public License as published by the
1567 + * Free Software Foundation; either version 2, or (at your option) any
1568 + * later version.
1569 + * 
1570 + * This program is distributed in the hope that it will be useful, but
1571 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1572 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1573 + * General Public License for more details.
1574 + */
1575 +
1576 +enum
1577 +{
1578 +       OMNIBOOK_BIOS_VENDOR,
1579 +       OMNIBOOK_BIOS_VERSION,
1580 +       OMNIBOOK_BIOS_DATE,
1581 +       OMNIBOOK_SYS_VENDOR,
1582 +       OMNIBOOK_PRODUCT_NAME,
1583 +       OMNIBOOK_PRODUCT_VERSION,
1584 +       OMNIBOOK_SERIAL_NUMBER,
1585 +       OMNIBOOK_BOARD_VENDOR,
1586 +       OMNIBOOK_BOARD_NAME,
1587 +       OMNIBOOK_BOARD_VERSION,
1588 +       OMNIBOOK_STRING_MAX
1589 +};
1590 +
1591 +extern char *omnibook_dmi_ident[OMNIBOOK_STRING_MAX];
1592 +
1593 +extern int __init omnibook_dmi_scan_machine(void);
1594 +
1595 +/* End of file */
1596 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/dock.c linux-2.6.1-gentoo-test/drivers/char/omnibook/dock.c
1597 --- linux-2.6.1-gentoo/drivers/char/omnibook/dock.c     1970-01-01 01:00:00.000000000 +0100
1598 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/dock.c        2004-01-09 22:33:49.000000000 +0000
1599 @@ -0,0 +1,123 @@
1600 +/*
1601 + * dock.c -- docking station/port replicator support
1602 + * 
1603 + * This program is free software; you can redistribute it and/or modify it
1604 + * under the terms of the GNU General Public License as published by the
1605 + * Free Software Foundation; either version 2, or (at your option) any
1606 + * later version.
1607 + * 
1608 + * This program is distributed in the hope that it will be useful, but
1609 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1610 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1611 + * General Public License for more details.
1612 + *
1613 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
1614 + */
1615 +
1616 +
1617 +#include <linux/config.h>
1618 +#include <linux/module.h>
1619 +#include <linux/version.h>
1620 +#include <linux/types.h>
1621 +#include <linux/init.h>
1622 +#include <linux/pm.h>
1623 +#include <linux/proc_fs.h>
1624 +
1625 +#include <asm/system.h>
1626 +#include <asm/errno.h>
1627 +#include <asm/io.h>
1628 +#include <asm/uaccess.h>
1629 +
1630 +#ifdef OMNIBOOK_STANDALONE
1631 +#include "omnibook.h"
1632 +#else
1633 +#include <linux/omnibook.h>
1634 +#endif
1635 +
1636 +#include "ec.h"
1637 +#include "util.h"
1638 +
1639 +static struct proc_dir_entry *proc_dock;
1640 +
1641 +int omnibook_get_dock(void)
1642 +{
1643 +       u8 dock;
1644 +       int retval;
1645 +       
1646 +       switch (omnibook_ectype) {
1647 +       case XE3GF:
1648 +               if ((retval = omnibook_ec_read(XE3GF_CSPR, &dock)))
1649 +                       return retval;
1650 +               retval = (dock & XE3GF_CSPR_MASK) ? 1 : 0;
1651 +               break;
1652 +       case OB500:
1653 +       case OB510:
1654 +       case OB6000:
1655 +       case OB6100:
1656 +               if ((retval = omnibook_ec_read(OB500_STA1, &dock)))
1657 +                       return retval;
1658 +               retval = (dock & OB500_DCKS_MASK) ? 1 : 0;
1659 +               break;
1660 +       case OB4150:
1661 +               if ((retval = omnibook_ec_read(OB4150_DCID, &dock)))
1662 +                       return retval;
1663 +               retval = (dock) ? 1 : 0;
1664 +               break;
1665 +       default:
1666 +               printk(KERN_INFO "%s: Docking station handling is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
1667 +               retval = -ENODEV;
1668 +       }
1669 +
1670 +       return retval;
1671 +}
1672 +       
1673 +static int omnibook_dock_status(char *buffer, char **start, off_t off, int count, int *eof, void *data)
1674 +{
1675 +       char *b = buffer;
1676 +       int dock;
1677 +
1678 +       dock = omnibook_get_dock();
1679 +       if (dock < 0)
1680 +               return dock;
1681 +
1682 +       b += sprintf(b, "Laptop is %s\n", (dock) ? "docked" : "undocked");
1683 +
1684 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
1685 +}
1686 +
1687 +int __init omnibook_dock_init(void)
1688 +{
1689 +       mode_t pmode;
1690 +
1691 +       switch (omnibook_ectype) {
1692 +       case XE3GF:
1693 +       case OB500:
1694 +       case OB510:
1695 +       case OB6000:
1696 +       case OB6100:
1697 +       case OB4150:
1698 +               pmode = S_IFREG | S_IRUGO;
1699 +               proc_dock = create_proc_read_entry("dock", pmode, omnibook_proc_root, omnibook_dock_status, NULL);
1700 +               break;
1701 +       default:
1702 +               printk(KERN_INFO "%s: Docking station status monitoring is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
1703 +               return 0;
1704 +       }
1705 +       
1706 +       if (! proc_dock) {
1707 +               printk(KERN_ERR "%s: Unable to create /proc/%s/dock.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
1708 +               return -ENOENT;
1709 +       }
1710 +       printk(KERN_INFO "%s: Docking station status monitoring is enabled.\n", OMNIBOOK_MODULE_NAME);
1711 +       return 0;
1712 +}
1713 +
1714 +void __exit omnibook_dock_cleanup(void)
1715 +{
1716 +       if (proc_dock)
1717 +               remove_proc_entry("dock", omnibook_proc_root);
1718 +}
1719 +
1720 +EXPORT_SYMBOL(omnibook_get_dock);
1721 +
1722 +/* End of file */
1723 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/ec.c linux-2.6.1-gentoo-test/drivers/char/omnibook/ec.c
1724 --- linux-2.6.1-gentoo/drivers/char/omnibook/ec.c       1970-01-01 01:00:00.000000000 +0100
1725 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/ec.c  2004-01-09 22:33:49.000000000 +0000
1726 @@ -0,0 +1,341 @@
1727 +/*
1728 + * ec.c -- low level functions to access Embedded Conrtroller,
1729 + *         Keyboard Controller and system I/O ports or memory
1730 + * 
1731 + * This program is free software; you can redistribute it and/or modify it
1732 + * under the terms of the GNU General Public License as published by the
1733 + * Free Software Foundation; either version 2, or (at your option) any
1734 + * later version.
1735 + * 
1736 + * This program is distributed in the hope that it will be useful, but
1737 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1738 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1739 + * General Public License for more details.
1740 + *
1741 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
1742 + */
1743 +
1744 +
1745 +#include <linux/config.h>
1746 +#include <linux/types.h>
1747 +#include <linux/delay.h>
1748 +#include <linux/sched.h>
1749 +
1750 +#ifdef CONFIG_ACPI_EC
1751 +#include <linux/acpi.h>
1752 +#ifdef ACPI_CA_VERSION
1753 +#if ACPI_CA_VERSION > 0x20021121
1754 +#define USE_ACPI_EC
1755 +#endif
1756 +#endif
1757 +#endif
1758 +
1759 +#include <asm/io.h>
1760 +
1761 +#include "ec.h"
1762 +
1763 +/*
1764 + *     Interrupt control
1765 + */
1766 +
1767 +#ifdef CONFIG_SMP /* Are you ready for SMP laptops? Coming soon... ;) */
1768 +static spinlock_t omnibook_ec_lock = SPIN_LOCK_UNLOCKED;
1769 +#include <linux/spinlock.h>
1770 +#define omnibook_save_flags(x)         spin_lock_irqsave(&omnibook_ec_lock, x)
1771 +#define omnibook_restore_flags(x)      spin_unlock_irqrestore(&omnibook_ec_lock, x)
1772 +#else
1773 +#include <linux/version.h>
1774 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,28))
1775 +#define omnibook_save_flags(x)         do { save_flags(x); cli(); } while (0)
1776 +#define omnibook_restore_flags(x)      restore_flags(x)
1777 +#else
1778 +#define omnibook_save_flags(x)         local_irq_save(x)
1779 +#define omnibook_restore_flags(x)      local_irq_restore(x)
1780 +#endif
1781 +#endif /* CONFIG_SMP */
1782 +
1783 +/*
1784 + * Timeout in ms for sending to controller
1785 + */
1786 +
1787 +#define OMNIBOOK_TIMEOUT               250
1788 +
1789 +/*
1790 + * Registers of the embedded controller
1791 + */
1792 +
1793 +#define OMNIBOOK_EC_DATA               0x62
1794 +#define OMNIBOOK_EC_SC                 0x66
1795 +
1796 +/*
1797 + * Embedded controller status register bits
1798 + */
1799 +
1800 +#define OMNIBOOK_EC_STAT_OBF           0x01    /* Output buffer full */
1801 +#define OMNIBOOK_EC_STAT_IBF           0x02    /* Input buffer full */
1802 +#define OMNIBOOK_EC_STAT_CMD           0x08    /* Last write was a command write (0=data) */
1803 +
1804 +/*
1805 + * Embedded controller commands
1806 + */
1807 +
1808 +#define OMNIBOOK_EC_CMD_READ           0x80
1809 +#define OMNIBOOK_EC_CMD_WRITE          0x81
1810 +#define OMNIBOOK_EC_CMD_QUERY          0x84
1811 +
1812 +/*
1813 + * Wait for embedded controller buffer
1814 + */
1815 +
1816 +static int omnibook_ec_wait(u8 event)
1817 +{
1818 +       int timeout = OMNIBOOK_TIMEOUT;
1819 +
1820 +       switch (event) {
1821 +       case OMNIBOOK_EC_STAT_OBF:
1822 +               while (!(inb(OMNIBOOK_EC_SC) & event) && timeout--)
1823 +                       mdelay(1);
1824 +               break;
1825 +       case OMNIBOOK_EC_STAT_IBF:
1826 +               while ((inb(OMNIBOOK_EC_SC) & event) && timeout--)
1827 +                       mdelay(1);
1828 +               break;
1829 +       default:
1830 +               return -EINVAL;
1831 +       }
1832 +       if (timeout>0)
1833 +               return 0;
1834 +       return -ETIME;
1835 +}
1836 +
1837 +/*
1838 + * Read from the embedded controller
1839 + */
1840 +
1841 +int omnibook_ec_read(u8 addr, u8 *data)
1842 +{
1843 +       unsigned long flags;
1844 +       int retval;
1845 +       
1846 +#ifdef USE_ACPI_EC
1847 +       retval = ec_read(addr, data);
1848 +       if (!retval)
1849 +               return retval;
1850 +#endif
1851 +       omnibook_save_flags(flags);
1852 +       retval = omnibook_ec_wait(OMNIBOOK_EC_STAT_IBF);
1853 +       if (retval)
1854 +               goto end;
1855 +       outb(OMNIBOOK_EC_CMD_READ, OMNIBOOK_EC_SC);
1856 +       retval = omnibook_ec_wait(OMNIBOOK_EC_STAT_IBF);
1857 +       if (retval)
1858 +               goto end;
1859 +       outb(addr, OMNIBOOK_EC_DATA);
1860 +       retval = omnibook_ec_wait(OMNIBOOK_EC_STAT_OBF);
1861 +       if (retval)
1862 +               goto end;
1863 +       *data = inb(OMNIBOOK_EC_DATA);
1864 +end:
1865 +       omnibook_restore_flags(flags);
1866 +       return retval;
1867 +}
1868 +
1869 +/*
1870 + * Write to the embedded controller
1871 + */
1872 +
1873 +int omnibook_ec_write(u8 addr, u8 data)
1874 +{
1875 +
1876 +       unsigned long flags;
1877 +       int retval;
1878 +       
1879 +#ifdef USE_ACPI_EC
1880 +       retval = ec_write(addr, data);
1881 +       if (!retval)
1882 +               return retval;
1883 +#endif
1884 +       omnibook_save_flags(flags);
1885 +       retval = omnibook_ec_wait(OMNIBOOK_EC_STAT_IBF);
1886 +       if (retval)
1887 +               goto end;
1888 +       outb(OMNIBOOK_EC_CMD_WRITE, OMNIBOOK_EC_SC);
1889 +       retval = omnibook_ec_wait(OMNIBOOK_EC_STAT_IBF);
1890 +       if (retval)
1891 +               goto end;
1892 +       outb(addr, OMNIBOOK_EC_DATA);
1893 +       retval = omnibook_ec_wait(OMNIBOOK_EC_STAT_IBF);
1894 +       if (retval)
1895 +               goto end;
1896 +       outb(data, OMNIBOOK_EC_DATA);
1897 +end:
1898 +       omnibook_restore_flags(flags);
1899 +       return retval;
1900 +}
1901 +
1902 +int omnibook_ec_read16(u8 addr, u16 *data)
1903 +{
1904 +       int retval;
1905 +       u8 high;
1906 +       u8 low;
1907 +       u16 result;
1908 +
1909 +       retval = omnibook_ec_read(addr, &low);
1910 +       if (retval)
1911 +               return retval;
1912 +       retval = omnibook_ec_read(addr + 0x01, &high);
1913 +       result = ((high << 8) + low);
1914 +       *data = result;
1915 +       return retval;
1916 +}
1917 +
1918 +/*
1919 + * Registers of the keyboard controller
1920 + */
1921 +
1922 +#define OMNIBOOK_KBC_DATA              0x60
1923 +#define OMNIBOOK_KBC_SC                        0x64
1924 +
1925 +/*
1926 + * Keyboard controller status register bits
1927 + */
1928 +
1929 +#define OMNIBOOK_KBC_STAT_OBF          0x01    /* Output buffer full */
1930 +#define OMNIBOOK_KBC_STAT_IBF          0x02    /* Input buffer full */
1931 +#define OMNIBOOK_KBC_STAT_CMD          0x08    /* Last write was a command write (0=data) */
1932 +
1933 +/*
1934 + * Wait for keyboard buffer
1935 + */
1936 +
1937 +static int omnibook_kbc_wait(u8 event)
1938 +{
1939 +       int timeout = OMNIBOOK_TIMEOUT;
1940 +
1941 +       switch (event) {
1942 +       case OMNIBOOK_KBC_STAT_OBF:
1943 +               while (!(inb(OMNIBOOK_KBC_SC) & event) && timeout--)
1944 +                       mdelay(1);
1945 +               break;
1946 +       case OMNIBOOK_KBC_STAT_IBF:
1947 +               while ((inb(OMNIBOOK_KBC_SC) & event) && timeout--)
1948 +                       mdelay(1);
1949 +               break;
1950 +       default:
1951 +               return -EINVAL;
1952 +       }
1953 +       if (timeout>0)
1954 +               return 0;
1955 +       return -ETIME;
1956 +}
1957 +
1958 +/*
1959 + * Write to the keyboard command register
1960 + */
1961 +
1962 +static int omnibook_kbc_write_command(u8 cmd)
1963 +{
1964 +       unsigned long flags;
1965 +       int retval;
1966 +       
1967 +       omnibook_save_flags(flags);
1968 +       retval = omnibook_kbc_wait(OMNIBOOK_KBC_STAT_IBF);
1969 +       if (retval)
1970 +               goto end;
1971 +       outb(cmd, OMNIBOOK_KBC_SC);
1972 +       retval = omnibook_kbc_wait(OMNIBOOK_KBC_STAT_IBF);
1973 +end:
1974 +       omnibook_restore_flags(flags);
1975 +       return retval;
1976 +}
1977 +
1978 +/*
1979 + * Write to the keyboard data register
1980 + */
1981 +
1982 +static int omnibook_kbc_write_data(u8 data)
1983 +{
1984 +       unsigned long flags;
1985 +       int retval;
1986 +       
1987 +       omnibook_save_flags(flags);
1988 +       retval = omnibook_kbc_wait(OMNIBOOK_KBC_STAT_IBF);
1989 +       if (retval)
1990 +               goto end;;
1991 +       outb(data, OMNIBOOK_KBC_DATA);
1992 +       retval = omnibook_kbc_wait(OMNIBOOK_KBC_STAT_IBF);
1993 +end:
1994 +       omnibook_restore_flags(flags);
1995 +       return retval;
1996 +}
1997 +
1998 +/*
1999 + * Send a command to keyboard controller
2000 + */
2001 +
2002 +int omnibook_kbc_command(u8 cmd, u8 data)
2003 +{
2004 +       int retval;
2005 +       
2006 +       retval = omnibook_kbc_write_command(cmd);
2007 +       if (retval)
2008 +               return retval;
2009 +       retval = omnibook_kbc_write_data(data);
2010 +       return retval;
2011 +}
2012 +
2013 +/*
2014 + * Read a value from a system I/O address
2015 + */
2016 +
2017 +int omnibook_io_read(u32 addr, u8 *data)
2018 +{
2019 +       unsigned long flags;
2020 +
2021 +       omnibook_save_flags(flags);
2022 +       *data = inb(addr);
2023 +       omnibook_restore_flags(flags);
2024 +       return 0;
2025 +}
2026 +
2027 +/*
2028 + * Write a value to a system I/O address
2029 + */
2030 +
2031 +int omnibook_io_write(u32 addr, u8 data)
2032 +{
2033 +       unsigned long flags;
2034 +
2035 +       omnibook_save_flags(flags);
2036 +       outb(data, addr);
2037 +       omnibook_restore_flags(flags);
2038 +       return 0;
2039 +}
2040 +
2041 +/*
2042 + * Read a value from a system memory address
2043 + */
2044 +
2045 +int omnibook_mem_read(u32 addr, u8 *data)
2046 +{
2047 +       char *base = ioremap(addr, 1);
2048 +
2049 +       *data = readb(base);
2050 +       iounmap(base);
2051 +       return 0;
2052 +}
2053 +
2054 +/*
2055 + * Write a value to a system memory address
2056 + */
2057 +
2058 +int omnibook_mem_write(u32 addr, u8 data)
2059 +{
2060 +       char *base = ioremap(addr, 1);
2061 +
2062 +       writeb(data, base);
2063 +       iounmap(base);
2064 +       return 0;
2065 +}
2066 +
2067 +/* End of file */
2068 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/ec.h linux-2.6.1-gentoo-test/drivers/char/omnibook/ec.h
2069 --- linux-2.6.1-gentoo/drivers/char/omnibook/ec.h       1970-01-01 01:00:00.000000000 +0100
2070 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/ec.h  2004-01-09 22:33:49.000000000 +0000
2071 @@ -0,0 +1,269 @@
2072 +/*
2073 + * ec.h -- low level definitions to access Embedded Conrtroller
2074 + *         and Keyboard Controller and system I/O ports or memory
2075 + * 
2076 + * This program is free software; you can redistribute it and/or modify it
2077 + * under the terms of the GNU General Public License as published by the
2078 + * Free Software Foundation; either version 2, or (at your option) any
2079 + * later version.
2080 + * 
2081 + * This program is distributed in the hope that it will be useful, but
2082 + * WITHOUT ANY WARRANTY; without even the implied warranty of
2083 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2084 + * General Public License for more details.
2085 + *
2086 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
2087 + */
2088 +
2089 +extern int omnibook_ec_read(u8 addr, u8 *data);
2090 +extern int omnibook_ec_read16(u8 addr, u16 *data);
2091 +extern int omnibook_ec_write(u8 addr, u8 data);
2092 +extern int omnibook_kbc_command(u8 cmd, u8 data);
2093 +extern int omnibook_io_read(u32 addr, u8 *data);
2094 +extern int omnibook_io_write(u32 addr, u8 data);
2095 +extern int omnibook_mem_read(u32 addr, u8 *data);
2096 +extern int omnibook_mem_write(u32 addr, u8 data);
2097 +
2098 +/*
2099 + *     Embedded controller adresses
2100 + */
2101 +
2102 +#define XE3GF_CHGM                             0x90    /* , 16 bit */
2103 +#define XE3GF_CHGS                             0x92    /* , 16 bit */
2104 +#define XE3GF_CHGC                             0x94    /* Current charge of board, 16 bit */
2105 +#define XE3GF_CHGV                             0x96    /* Current voltage, 16 bit */
2106 +#define XE3GF_CHGA                             0x98    /* Current intensity, 16 bit */
2107 +#define XE3GF_BAL                              0x9A    /* Battery present status */
2108 +#define XE3GF_STA1                             0x9C    /* Various status bits*/
2109 +#define XE3GF_CSPR                             0xA1    /* Port replicator status, 1 bit */
2110 +#define XE3GF_ADP                              0xA3    /* AC acapter status, 1 bit */
2111 +#define XE3GF_FOT                              0xA5    /* Fan off temperature, 8 bit */
2112 +#define XE3GF_FSD1                             0xA6    /* Fan on temperature, 8 bit */
2113 +#define XE3GF_FSD2                             0xA7    /* Fan level 2 temperature, 8 bit */
2114 +#define XE3GF_FSD3                             0xA8    /* Fan level 3 temperature, 8 bit */
2115 +#define XE3GF_FSD4                             0xA9    /* Fan level 4 temperature, 8 bit */
2116 +#define XE3GF_FSD5                             0xAA    /* Fan level 5 temperature, 8 bit */
2117 +#define XE3GF_FSD6                             0xAB    /* Fan level 6 temperature, 8 bit */
2118 +#define XE3GF_FSD7                             0xAC    /* Fan level 7 temperature, 8 bit */
2119 +#define XE3GF_FSRD                             0xAD    /* Fan status, 8 bit */
2120 +#define XE3GF_CTMP                             0xB0    /* CPU tempetature, 8 bit */
2121 +#define XE3GF_BRTS                             0xB9    /* LCD brightness, 4 bit */
2122 +#define XE3GF_BTY0                             0xC0    /* Battery 0 type, 1 bit */
2123 +#define XE3GF_BST0                             0xC1    /* Battery 0 status, 3 bit */
2124 +#define XE3GF_BRC0                             0xC2    /* Battery 0 remaining capacity, 16 bit */
2125 +#define XE3GF_BSN0                             0xC4    /* Battery 0 serial number 16 bit */
2126 +#define XE3GF_BPV0                             0xC6    /* Battery 0 present voltage, 16 bit */
2127 +#define XE3GF_BDV0                             0xC8    /* Battery 0 design voltage 16 bit */
2128 +#define XE3GF_BDC0                             0xCA    /* Battery 0 design capacity 16 bit */
2129 +#define XE3GF_BFC0                             0xCC    /* Battery 0 last full capacity 16 bit */
2130 +#define XE3GF_GAU0                             0xCE    /* Battery 0 gauge, 8 bit */
2131 +#define XE3GF_BTY1                             0xD0    /* Battery 1 type, 1 bit */
2132 +#define XE3GF_BST1                             0xD1    /* Battery 1 status, 3 bit */
2133 +#define XE3GF_BRC1                             0xD2    /* Battery 1 remaining capacity, 16 bit */
2134 +#define XE3GF_BSN1                             0xD4    /* Battery 1 serial number, 16 bit */
2135 +#define XE3GF_BPV1                             0xD6    /* Battery 1 present voltage, 16 bit */
2136 +#define XE3GF_BDV1                             0xD8    /* Battery 1 design voltage 16 bit */
2137 +#define XE3GF_BDC1                             0xDA    /* Battery 1 design capacity 16 bit */
2138 +#define XE3GF_BFC1                             0xDC    /* Battery 1 last full capacity 16 bit */
2139 +#define XE3GF_GAU1                             0xDE    /* Battery 1 gauge, 8 bit */
2140 +
2141 +/*
2142 + * Bitmasks for sub byte values
2143 + */
2144 +
2145 +#define XE3GF_SHDD_MASK                                0x40    /* External display status */
2146 +#define XE3GF_CSPR_MASK                                0x01    /* Port replicator status */
2147 +#define XE3GF_ADP_MASK                         0x20    /* AC acapter status */
2148 +#define XE3GF_BAL0_MASK                                0x01    /* Battery 0 present */
2149 +#define XE3GF_BAL1_MASK                                0x02    /* Battery 1 present */
2150 +#define XE3GF_BMF_MASK                         0x70    /* Model code */
2151 +#define XE3GF_BTY_MASK                         0x80    /* Type: Ni-MH or Li-Ion */
2152 +#define XE3GF_BST_MASK_DSC                     0x01    /* Discarging */
2153 +#define XE3GF_BST_MASK_CHR                     0x02    /* Charging */
2154 +#define XE3GF_BST_MASK_CRT                     0x04    /* Critical */
2155 +#define XE3GF_FSRD_MASK_S1                     0x01    /* Fan level 1 */
2156 +#define XE3GF_FSRD_MASK_S2                     0x02    /* Fan level 2 */
2157 +#define XE3GF_FSRD_MASK_S3                     0x04    /* Fan level 3 */
2158 +#define XE3GF_FSRD_MASK_S4                     0x08    /* Fan level 4 */
2159 +#define XE3GF_FSRD_MASK_S5                     0x10    /* Fan level 5 */
2160 +#define XE3GF_FSRD_MASK_S6                     0x20    /* Fan level 6 */
2161 +#define XE3GF_FSRD_MASK_S7                     0x40    /* Fan level 7 */
2162 +#define XE3GF_BRTS_MASK                                0x0F    /* LCD brightness */
2163 +
2164 +#define XE3GF_FAN_ON_MASK                      0x02    /* Fan on */
2165 +
2166 +/*
2167 + * OmniBook XE3 GC values
2168 + */
2169 +
2170 +#define XE3GC_CTMP                             0x28    /* CPU tempetature, 8 bit */
2171 +#define XE3GC_STA1                             0x30    /* Various status bits */
2172 +#define XE3GC_Q0A                              0x31    /* Various status bits */
2173 +#define XE3GC_CCUR                             0x38    /* Current charge of board, 16 bit ? */
2174 +#define XE3GC_CVOL                             0x3A    /* Current voltage, 16 bit ? */
2175 +#define XE3GC_CARM                             0x3C    /* Current intensity, 16 bit ? */
2176 +#define XE3GC_BAT                              0x3E    /* Battery present status */
2177 +#define XE3GC_BST0                             0x40    /* Battery 0 status, 3 bit */
2178 +#define XE3GC_BPR0                             0x41    /* Battery 0 present rate, 16 bit ? */
2179 +#define XE3GC_BRC0                             0x43    /* Battery 0 remaining capacity, 16 bit */
2180 +#define XE3GC_BPV0                             0x45    /* Battery 0 present voltage, 16 bit */
2181 +#define XE3GC_BDV0                             0x47    /* Battery 0 design voltage 16 bit */
2182 +#define XE3GC_BDC0                             0x49    /* Battery 0 design capacity 16 bit */
2183 +#define XE3GC_BTY0                             0x4A    /* Battery 0 type, 1 bit ?*/
2184 +#define XE3GC_BTP0                             0x4B    /* Battery 0 ?, 1 bit */
2185 +#define XE3GC_BSN0                             0x4C    /* Battery 0 serial number, 8 bit ?*/
2186 +#define XE3GC_BMF0                             0x4D    /* Battery 0 ?,8 bit */
2187 +#define XE3GC_BST1                             0x50    /* Battery 0 status, 3 bit */
2188 +#define XE3GC_BPR1                             0x51    /* Battery 0 present rate, 16 bit ? */
2189 +#define XE3GC_BRC1                             0x53    /* Battery 0 remaining capacity, 16 bit */
2190 +#define XE3GC_BPV1                             0x55    /* Battery 0 present voltage, 16 bit */
2191 +#define XE3GC_BDV1                             0x57    /* Battery 0 design voltage 16 bit */
2192 +#define XE3GC_BDC1                             0x59    /* Battery 0 design capacity 16 bit */
2193 +#define XE3GC_BTY1                             0x5A    /* Battery 0 type, 1 bit ?*/
2194 +#define XE3GC_BTP1                             0x5B    /* Battery 0 ?, 1 bit */
2195 +#define XE3GC_BSN1                             0x5C    /* Battery 0 serial number, 8 bit ?*/
2196 +#define XE3GC_BMF1                             0x5D    /* Battery 0 ?,8 bit */
2197 +#define XE3GC_STA2                             0x61    /* Various status bits */
2198 +#define XE3GC_BTVL                             0x6A    /* LCD brightness, 4 bit */
2199 +
2200 +/*
2201 + * Bitmasks for sub byte values
2202 + */
2203 +
2204 +#define XE3GC_ADP_MASK                         0x40    /* AC acapter status */
2205 +#define XE3GC_BAT0_MASK                                0x01    /* Battery 0 present */
2206 +#define XE3GC_BAT1_MASK                                0x02    /* Battery 1 present */
2207 +#define XE3GC_BTY_MASK                         0x01    /* Type: Ni-MH or Li-Ion */
2208 +#define XE3GC_BST_MASK_DSC                     0x01    /* Discarging */
2209 +#define XE3GC_BST_MASK_CHR                     0x02    /* Charging */
2210 +#define XE3GC_BST_MASK_CRT                     0x04    /* Critical */
2211 +#define XE3GC_CRTI_MASK                                0x04    /* External display status */
2212 +#define XE3GC_SLPB_MASK                                0x01    /* Sleep button pressed */
2213 +#define XE3GC_F5_MASK                          0x02    /* Fn-F5 - LCD/CRT switch pressed */
2214 +#define XE3GC_VOLD_MASK                                0x04    /* Fn-down arrow or Volume down pressed */
2215 +#define XE3GC_VOLU_MASK                                0x08    /* Fn-up arrow or Volume up pressed */
2216 +#define XE3GC_MUTE_MASK                                0x10    /* Fn+F7 - Volume mute pressed */
2217 +#define XE3GC_CNTR_MASK                                0x20    /* Fn+F3/Fn+F4 - Contrast up or down pressed */
2218 +#define XE3GC_BRGT_MASK                                0x40    /* Fn+F1/Fn+F2 - Brightness up or down pressed */
2219 +#define XE3GC_BTVL_MASK                                0x0F    /* LCD brightness */
2220 +
2221 +/*
2222 + * Emulated scancodes
2223 + */
2224 +
2225 +#define XE3GC_VOLD_SCAN                                0x2E    /* Volume down button scancode */
2226 +#define XE3GC_VOLU_SCAN                                0x30    /* Volume up button scancode */
2227 +#define XE3GC_MUTE_SCAN                                0x20    /* Volume up button scancode */
2228 +
2229 +/*
2230 + * OmniBook 500, 510, 6000, 6100, XE2 values
2231 + */
2232 +
2233 +#define OB500_STA1                             0x44    /* Various status bits */
2234 +#define OB500_STA2                             0x50    /* Various status bits */
2235 +#define OB500_CTMP                             0x55    /* CPU tempetature, 8 bit */
2236 +#define OB500_BT1I                             0x58    /* Battery 1 ? 16 bit */
2237 +#define OB500_BT1C                             0x5A    /* Battery 1 remaining capacity 16 bit ? */
2238 +#define OB500_BT1V                             0x5C    /* Battery 1 present voltage 16 bit ? */
2239 +#define OB500_BT1S                             0x5E    /* Battery 1 status 3 bit ? */
2240 +#define OB500_BT2I                             0x6A    /* Battery 2 ? 16 bit */
2241 +#define OB500_BT2C                             0x6C    /* Battery 2 remaining capacity 16 bit ? */
2242 +#define OB500_BT2V                             0x6E    /* Battery 2 present voltage 16 bit ? */
2243 +#define OB500_BT2S                             0x70    /* Battery 2 status 3 bit ? */
2244 +#define OB500_BT3I                             0x5F    /* Battery 3 ? 16 bit */
2245 +#define OB500_BT3C                             0x61    /* Battery 3 remaining capacity 16 bit ? */
2246 +#define OB500_BT3V                             0x63    /* Battery 3 present voltage 16 bit ? */
2247 +#define OB500_BT3S                             0x65    /* Battery 3 status 3 bit ? */
2248 +
2249 +#define OB6000_STA1                            0x77    /* Various status bits */
2250 +
2251 +#define XE2_STA1                               0x50    /* Various status bits */
2252 +
2253 +/*
2254 + * Bitmasks for sub byte values
2255 + */
2256 +
2257 +#define OB500_LIDS_MASK                                0x01    /* LID status */
2258 +#define OB500_CRTS_MASK                                0x20    /* External display status */
2259 +#define OB500_SLPS_MASK                                0x40    /* Sleep button status */
2260 +#define OB500_DCKS_MASK                                0x80    /* Docking status */
2261 +#define OB500_ADP_MASK                         0x02    /* AC acapter status */
2262 +#define OB500_BST_MASK_DSC                     0x01    /* Discarging */
2263 +#define OB500_BST_MASK_CHR                     0x02    /* Charging */
2264 +#define OB500_BST_MASK_CRT                     0x04    /* Critical */
2265 +
2266 +#define OB6000_FAN_MASK                                0x10    /* Fan status */
2267 +
2268 +#define XE2_ADP_MASK                           0x02    /* AC acapter status */
2269 +
2270 +/*
2271 + * OmniBook 4150
2272 + */
2273 +
2274 +#define OB4150_TMP                             0x28    /* CPU tempetature, 8 bit */
2275 +#define OB4150_STA1                            0x2E    /* Various status bits */
2276 +#define OB4150_STA2                            0x2F    /* Various status bits */
2277 +#define OB4150_ADP                             0x30    /* AC acapter status, 1 bit */
2278 +#define OB4150_DCID                            0x2C    /* Port replicator */
2279 +
2280 +/*
2281 + * Bitmasks for sub byte values
2282 + */
2283 +
2284 +#define OB4150_FAN_MASK                                0x01    /* Fan status */
2285 +#define OB4150_ADP_MASK                                0x40    /* AC acapter status */
2286 +#define OB4150_CRST_MASK                       0x20    /* External display status */
2287 +
2288 +/*
2289 + *     Keyboard controller command for some laptop functions
2290 + */
2291 +
2292 +#define OMNIBOOK_KBC_CONTROL_CMD               0x59
2293 +
2294 +/*
2295 + *     Keyboard controller command parameters for functions available via kbc
2296 + */
2297 +
2298 +#define OMNIBOOK_KBC_CMD_ONETOUCH_ENABLE       0x90    /* Enables OneTouch buttons */
2299 +#define OMNIBOOK_KBC_CMD_ONETOUCH_DISABLE      0x91    /* Disables OneTouch buttons */
2300 +#define OMNIBOOK_KBC_CMD_TOUCHPAD_ENABLE       0xAA    /* Enables toucpad */
2301 +#define OMNIBOOK_KBC_CMD_TOUCHPAD_DISABLE      0xA9    /* Disables toucpad */
2302 +#define OMNIBOOK_KBC_CMD_LCD_ON                        0xE1    /* Turns LCD display on */
2303 +#define OMNIBOOK_KBC_CMD_LCD_OFF               0xE2    /* Turns LCD display off */
2304 +#define OMNIBOOK_KBC_CMD_AC_POWER_ENABLE       0xC2    /* Enable AC power */
2305 +#define OMNIBOOK_KBC_CMD_AC_POWER_DISABLE      0xC1    /* Disable AC power */
2306 +
2307 +/*
2308 + * Other I/O ports
2309 + */
2310 +
2311 +#define ACL00_AC_STAT                          0x11B9  /* AC adapter status on ACL00 */
2312 +#define ACL00_AC_MASK                          0x04    /* Bitmask for AC adapter status on ACL00 */
2313 +#define TOSH3K_AC_STAT                         0x102D  /* AC adapter status on Toshiba 3000 */
2314 +#define TOSH3K_AC_MASK                         0x08    /* Bitmask for AC adapter status on Toshiba 3000 */
2315 +#define XE3GF_AC_STAT                          0x11B9  /* AC adapter status on XE3 GF */
2316 +#define XE3GF_AC_MASK                          0x04    /* Bitmask for AC adapter status on XE3 GF */
2317 +#define XE3GF_LID_STAT                         0x11AD  /* LID switch status on XE3 GF */
2318 +#define XE3GF_LID_MASK                         0x20    /* Bitmask for LID switch status on XE3 GF */
2319 +#define XE3GC_SMIC                             0xFE00
2320 +
2321 +#define OB500_GPO1                             0x8034  /* Fan control */
2322 +#define OB510_GPO2                             0x11B9  /* LCD backlight */
2323 +#define OB510_GPIO                             0x118F  /* Fan control */
2324 +
2325 +#define OB500_FAN_ON_MASK                      0x0A    /* Turn fan on with zero bits */
2326 +#define OB500_FAN_OFF_MASK                     0x08    /* Fan status/off */
2327 +#define OB500_BKLT_MASK                                0x40    /* LCD backlight */
2328 +#define OB510_FAN_ON_MASK                      0x18    /* Turn fan on with zero bits */
2329 +#define OB510_FAN_OFF_MASK                     0x10    /* Turn fan on */
2330 +#define OB510_BKLT_MASK                                0x01    /* LCD backlight */
2331 +
2332 +#define XE2_FAN_MASK                           0x02    /* Turn fan on with zero bit */
2333 +
2334 +/*
2335 + * Memory adresses
2336 + */
2337 +
2338 +#define XE3GC_BCMD                             0xFFFFEBC
2339 +
2340 +/* End of file */
2341 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/fan.c linux-2.6.1-gentoo-test/drivers/char/omnibook/fan.c
2342 --- linux-2.6.1-gentoo/drivers/char/omnibook/fan.c      1970-01-01 01:00:00.000000000 +0100
2343 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/fan.c 2004-01-09 22:33:49.000000000 +0000
2344 @@ -0,0 +1,290 @@
2345 +/*
2346 + * fan.c -- fan status/control
2347 + * 
2348 + * This program is free software; you can redistribute it and/or modify it
2349 + * under the terms of the GNU General Public License as published by the
2350 + * Free Software Foundation; either version 2, or (at your option) any
2351 + * later version.
2352 + * 
2353 + * This program is distributed in the hope that it will be useful, but
2354 + * WITHOUT ANY WARRANTY; without even the implied warranty of
2355 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2356 + * General Public License for more details.
2357 + *
2358 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
2359 + */
2360 +
2361 +
2362 +#include <linux/config.h>
2363 +#include <linux/module.h>
2364 +#include <linux/version.h>
2365 +#include <linux/types.h>
2366 +#include <linux/init.h>
2367 +#include <linux/delay.h>
2368 +#include <linux/pm.h>
2369 +#include <linux/proc_fs.h>
2370 +
2371 +#include <asm/system.h>
2372 +#include <asm/errno.h>
2373 +#include <asm/io.h>
2374 +#include <asm/uaccess.h>
2375 +
2376 +#ifdef OMNIBOOK_STANDALONE
2377 +#include "omnibook.h"
2378 +#else
2379 +#include <linux/omnibook.h>
2380 +#endif
2381 +
2382 +#include "ec.h"
2383 +#include "util.h"
2384 +
2385 +static struct proc_dir_entry *proc_fan;
2386 +
2387 +int omnibook_get_fan(void)
2388 +{
2389 +       u8 fan;
2390 +       int retval;
2391 +       
2392 +       switch (omnibook_ectype) {
2393 +       case XE3GF:
2394 +               if ((retval = omnibook_ec_read(XE3GF_FSRD, &fan)))
2395 +                       return retval;
2396 +               retval = fan;
2397 +               break;
2398 +       case OB500:
2399 +               if ((retval = omnibook_io_read(OB500_GPO1, &fan)))
2400 +                       return retval;
2401 +               retval = (fan & OB500_FAN_OFF_MASK) ? 0 : 1;
2402 +               break;
2403 +       case OB510:
2404 +               if ((retval = omnibook_io_read(OB510_GPIO, &fan)))
2405 +                       return retval;
2406 +               retval = (fan & OB510_FAN_OFF_MASK) ? 0 : 1;
2407 +               break;
2408 +       case OB6000:
2409 +       case OB6100:
2410 +               if ((retval = omnibook_ec_read(OB6000_STA1, &fan)))
2411 +                       return retval;
2412 +               retval = (fan & OB6000_FAN_MASK) ? 1 : 0;
2413 +               break;
2414 +       case OB4150:
2415 +               if ((retval = omnibook_ec_read(OB4150_STA1, &fan)))
2416 +                       return retval;
2417 +               retval = (fan & OB4150_FAN_MASK) ? 1 : 0;
2418 +               break;
2419 +       case XE2:
2420 +               if ((retval = omnibook_io_read(OB500_GPO1, &fan)))
2421 +                       return retval;
2422 +               retval = (fan & XE2_FAN_MASK) ? 0 : 1;
2423 +               break;
2424 +       default:
2425 +               printk(KERN_INFO "%s: Fan status monitoring is unsupported on this machie.\n", OMNIBOOK_MODULE_NAME);
2426 +               retval = -ENODEV;
2427 +       }
2428 +
2429 +       return retval;
2430 +}
2431 +       
2432 +int omnibook_fan_on(void)
2433 +{
2434 +       u8 fan;
2435 +       int retval;
2436 +
2437 +       switch (omnibook_ectype) {
2438 +       case XE3GF:
2439 +               if ((retval = omnibook_ec_read(XE3GF_FSRD, &fan)))
2440 +                       return retval;
2441 +               if ((retval = omnibook_ec_write(XE3GF_FSRD, fan | XE3GF_FAN_ON_MASK)))
2442 +                       return retval;
2443 +               break;
2444 +       case OB500:
2445 +               if ((retval = omnibook_io_read(OB500_GPO1, &fan)))
2446 +                       return retval;
2447 +               if ((retval = omnibook_io_write(OB500_GPO1, fan & ~OB500_FAN_ON_MASK)))
2448 +                       return retval;
2449 +               break;
2450 +       case OB510:
2451 +               if ((retval = omnibook_io_read(OB510_GPIO, &fan)))
2452 +                       return retval;
2453 +               if ((retval = omnibook_io_write(OB510_GPIO, fan & ~OB510_FAN_ON_MASK)))
2454 +                       return retval;
2455 +               break;
2456 +       case OB6000:
2457 +       case OB6100:
2458 +               if ((retval = omnibook_ec_read(OB6000_STA1, &fan)))
2459 +                       return retval;
2460 +               if ((retval = omnibook_ec_write(OB6000_STA1, fan | OB6000_FAN_MASK)))
2461 +                       return retval;
2462 +               break;
2463 +       case OB4150:
2464 +               if ((retval = omnibook_ec_read(OB4150_STA1, &fan)))
2465 +                       return retval;
2466 +               if ((retval = omnibook_ec_write(OB4150_STA1, fan | OB4150_FAN_MASK)))
2467 +                       return retval;
2468 +               break;
2469 +       case XE2:
2470 +               if ((retval = omnibook_io_read(OB500_GPO1, &fan)))
2471 +                       return retval;
2472 +               if ((retval = omnibook_io_write(OB500_GPO1, fan & ~XE2_FAN_MASK)))
2473 +                       return retval;
2474 +               break;
2475 +       default:
2476 +               printk(KERN_INFO "%s: Direct fan control is unsupported on this machie.\n", OMNIBOOK_MODULE_NAME);
2477 +               retval = -ENODEV;
2478 +       }
2479 +
2480 +       return retval;
2481 +}
2482 +
2483 +int omnibook_fan_off(void)
2484 +{
2485 +       u8 fan;
2486 +       int retval;
2487 +
2488 +       switch (omnibook_ectype) {
2489 +       case XE3GF:
2490 +               {
2491 +                       u8 fot, temp;
2492 +                       if ((retval = omnibook_ec_read(XE3GF_FSRD, &fan)))
2493 +                               return retval;
2494 +
2495 +                       /* fan is already off */
2496 +                       if (!fan)
2497 +                               return 0;
2498 +
2499 +                       /* now we set FOT to current temp, then reset to initial value */
2500 +                       if ((retval = omnibook_ec_read(XE3GF_FOT, &fot)))
2501 +                               return retval;
2502 +                       if ((retval = omnibook_ec_read(XE3GF_CTMP, &temp)))
2503 +                               return retval;
2504 +                       
2505 +                       do {
2506 +                               omnibook_ec_write(XE3GF_FOT, temp);
2507 +                               mdelay(1);
2508 +                       } while (omnibook_get_fan() != 0);
2509 +
2510 +                       omnibook_ec_write(XE3GF_FOT, fot);
2511 +               }
2512 +               break;
2513 +       case OB500:
2514 +               if ((retval = omnibook_io_read(OB500_GPO1, &fan)))
2515 +                       return retval;
2516 +               if ((retval = omnibook_io_write(OB500_GPO1, fan | OB500_FAN_OFF_MASK)))
2517 +                       return retval;
2518 +               break;
2519 +       case OB510:
2520 +               if ((retval = omnibook_io_read(OB510_GPIO, &fan)))
2521 +                       return retval;
2522 +               if ((retval = omnibook_io_write(OB510_GPIO, fan | OB510_FAN_OFF_MASK)))
2523 +                       return retval;
2524 +               break;
2525 +       case OB6000:
2526 +       case OB6100:
2527 +               if ((retval = omnibook_ec_read(OB6000_STA1, &fan)))
2528 +                       return retval;
2529 +               if ((retval = omnibook_ec_write(OB6000_STA1, fan & ~OB6000_FAN_MASK)))
2530 +                       return retval;
2531 +               break;
2532 +       case OB4150:
2533 +               if ((retval = omnibook_ec_read(OB4150_STA1, &fan)))
2534 +                       return retval;
2535 +               if ((retval = omnibook_ec_write(OB4150_STA1, fan & ~OB4150_FAN_MASK)))
2536 +                       return retval;
2537 +               break;
2538 +       case XE2:
2539 +               if ((retval = omnibook_io_read(OB500_GPO1, &fan)))
2540 +                       return retval;
2541 +               if ((retval = omnibook_io_write(OB500_GPO1, fan | XE2_FAN_MASK)))
2542 +                       return retval;
2543 +               break;
2544 +       default:
2545 +               printk(KERN_INFO "%s: Direct fan control is unsupported on this machie.\n", OMNIBOOK_MODULE_NAME);
2546 +               retval = -ENODEV;
2547 +       }
2548 +
2549 +       return retval;
2550 +}
2551 +
2552 +static int omnibook_fan_status(char *buffer, char **start, off_t off, int count, int *eof, void *data)
2553 +{
2554 +       int fan;
2555 +       char *b = buffer;
2556 +       char *str;
2557 +
2558 +       fan = omnibook_get_fan();
2559 +       if (fan < 0)
2560 +               return fan;
2561 +       str = (fan) ? "on" : "off";
2562 +
2563 +       if (fan > 1)
2564 +               b += sprintf(b, "Fan is %s (level %d)\n", str, fan);
2565 +       else
2566 +               b += sprintf(b, "Fan is %s\n", str);
2567 +
2568 +       return omnibook_proc_len(buffer, start, off, count, eof, b);;
2569 +}
2570 +
2571 +static int omnibook_fan_set(struct file *file, const char *buffer, unsigned long count, void *data)
2572 +{
2573 +       char status[1] = {'\0'};
2574 +
2575 +       if (copy_from_user(status, buffer, 1))
2576 +               return -EFAULT;
2577 +       switch (*status) {
2578 +       case '0':
2579 +               omnibook_fan_off();
2580 +               break;
2581 +       case '1':
2582 +               omnibook_fan_on();
2583 +               break;
2584 +       default:
2585 +               count = -EINVAL;
2586 +       }
2587 +       
2588 +       return count;
2589 +}
2590 +
2591 +int __init omnibook_fan_init(void)
2592 +{
2593 +       mode_t pmode;
2594 +
2595 +       switch (omnibook_ectype) {
2596 +       case XE3GF:
2597 +       case OB500:
2598 +       case OB510:
2599 +       case OB6000:
2600 +       case OB6100:
2601 +       case OB4150:
2602 +       case XE2:
2603 +               pmode = S_IFREG | S_IWUSR | S_IRUGO;
2604 +               if (omnibook_userset)
2605 +                       pmode = pmode | S_IWUGO;
2606 +               proc_fan = create_proc_entry("fan", pmode, omnibook_proc_root);
2607 +               break;
2608 +       default:
2609 +               printk(KERN_INFO "%s: Fan status monitor and control is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
2610 +               return 0;
2611 +       }
2612 +       
2613 +       if (proc_fan) {
2614 +               proc_fan->read_proc = omnibook_fan_status;
2615 +               proc_fan->write_proc = omnibook_fan_set;
2616 +       } else {
2617 +               printk(KERN_ERR "%s: Unable to create /proc/%s/fan.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
2618 +               return -ENOENT;
2619 +       }
2620 +       printk(KERN_INFO "%s: Fan status monitor and control is enabled.\n", OMNIBOOK_MODULE_NAME);
2621 +       return 0;
2622 +}
2623 +
2624 +void __exit omnibook_fan_cleanup(void)
2625 +{
2626 +       if (proc_fan)
2627 +               remove_proc_entry("fan", omnibook_proc_root);
2628 +}
2629 +
2630 +EXPORT_SYMBOL(omnibook_get_fan);
2631 +EXPORT_SYMBOL(omnibook_fan_on);
2632 +EXPORT_SYMBOL(omnibook_fan_off);
2633 +
2634 +/* End of file */
2635 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/fan_policy.c linux-2.6.1-gentoo-test/drivers/char/omnibook/fan_policy.c
2636 --- linux-2.6.1-gentoo/drivers/char/omnibook/fan_policy.c       1970-01-01 01:00:00.000000000 +0100
2637 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/fan_policy.c  2004-01-09 22:33:49.000000000 +0000
2638 @@ -0,0 +1,227 @@
2639 +/*
2640 + * fan_policy.c -- fan policy support
2641 + * 
2642 + * This program is free software; you can redistribute it and/or modify it
2643 + * under the terms of the GNU General Public License as published by the
2644 + * Free Software Foundation; either version 2, or (at your option) any
2645 + * later version.
2646 + * 
2647 + * This program is distributed in the hope that it will be useful, but
2648 + * WITHOUT ANY WARRANTY; without even the implied warranty of
2649 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2650 + * General Public License for more details.
2651 + *
2652 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
2653 + */
2654 +
2655 +
2656 +#include <linux/config.h>
2657 +#include <linux/module.h>
2658 +#include <linux/version.h>
2659 +#include <linux/types.h>
2660 +#include <linux/init.h>
2661 +#include <linux/proc_fs.h>
2662 +
2663 +#include <asm/system.h>
2664 +#include <asm/errno.h>
2665 +#include <asm/io.h>
2666 +#include <asm/uaccess.h>
2667 +
2668 +#ifdef OMNIBOOK_STANDALONE
2669 +#include "omnibook.h"
2670 +#else
2671 +#include <linux/omnibook.h>
2672 +#endif
2673 +
2674 +#include "ec.h"
2675 +#include "util.h"
2676 +
2677 +static struct proc_dir_entry *proc_fan_policy;
2678 +
2679 +u8 omnibook_fan_policy[OMNIBOOK_FAN_LEVELS];
2680 +
2681 +int omnibook_get_fan_policy(void)
2682 +{
2683 +       int retval = 0;
2684 +       int i;
2685 +       u8 tmp;
2686 +       
2687 +       switch (omnibook_ectype) {
2688 +       case XE3GF:
2689 +               for (i = 0; i <= OMNIBOOK_FAN_LEVELS; i++) {
2690 +                       if ((retval = omnibook_ec_read(XE3GF_FOT + i, &tmp)))
2691 +                               return retval;
2692 +                       omnibook_fan_policy[i] = tmp;
2693 +               }
2694 +               break;
2695 +       default:
2696 +               printk(KERN_INFO "%s: Fan policy is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
2697 +               retval = -ENODEV;
2698 +       }
2699 +
2700 +       return retval;
2701 +}
2702 +
2703 +int omnibook_set_fan_policy(void)
2704 +{
2705 +       int retval;
2706 +       int i;
2707 +       
2708 +       switch (omnibook_ectype) {
2709 +       case XE3GF:
2710 +               if (omnibook_fan_policy[0] > OMNIBOOK_FOT_MAX)
2711 +                       return -EINVAL;
2712 +               for (i = 0; i < OMNIBOOK_FAN_LEVELS; i++) {
2713 +                       if ((omnibook_fan_policy[i] > omnibook_fan_policy[i + 1]) || (omnibook_fan_policy[i] < OMNIBOOK_FAN_MIN) || (omnibook_fan_policy[i] > OMNIBOOK_FAN_MAX))
2714 +                               return -EINVAL;
2715 +                       if (omnibook_fan_policy[i + 1] > OMNIBOOK_FAN_MAX)
2716 +                               return -EINVAL;
2717 +               }
2718 +               for (i = 0; i <= OMNIBOOK_FAN_LEVELS; i++) {
2719 +                       if ((retval = omnibook_ec_write(XE3GF_FOT + i, omnibook_fan_policy[i])))
2720 +                               return retval;
2721 +               }
2722 +               break;
2723 +       default:
2724 +               printk(KERN_INFO "%s: Fan policy is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
2725 +               retval = -ENODEV;
2726 +       }
2727 +
2728 +       return retval;
2729 +}
2730 +
2731 +int omnibook_set_fan_policy_defaults(void)
2732 +{
2733 +       int retval;
2734 +       int i;
2735 +       u8 fan_defaults[] = {
2736 +               OMNIBOOK_FOT_DEFAULT,
2737 +               OMNIBOOK_FAN1_DEFAULT,
2738 +               OMNIBOOK_FAN2_DEFAULT,
2739 +               OMNIBOOK_FAN3_DEFAULT,
2740 +               OMNIBOOK_FAN4_DEFAULT,
2741 +               OMNIBOOK_FAN5_DEFAULT,
2742 +               OMNIBOOK_FAN6_DEFAULT,
2743 +               OMNIBOOK_FAN7_DEFAULT,
2744 +       };
2745 +
2746 +       switch (omnibook_ectype) {
2747 +       case XE3GF:
2748 +               for (i = 0; i <= OMNIBOOK_FAN_LEVELS; i++) {
2749 +                       if ((retval = omnibook_ec_write(XE3GF_FOT + i, fan_defaults[i])))
2750 +                               return retval;
2751 +               }
2752 +               break;
2753 +       default:
2754 +               printk(KERN_INFO "%s: Fan policy is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
2755 +               retval = -ENODEV;
2756 +       }
2757 +
2758 +       return retval;
2759 +}
2760 +
2761 +static int omnibook_proc_fan_policy_status(char *buffer, char **start, off_t off, int count, int *eof, void *data)
2762 +{
2763 +       int retval;
2764 +       char *b = buffer;
2765 +       u8 i;
2766 +       
2767 +       if ((retval = omnibook_get_fan_policy()))
2768 +               return retval;
2769 +
2770 +       b += sprintf(b, "Fan off temperature:        %2d C\n", omnibook_fan_policy[0]);
2771 +       b += sprintf(b, "Fan on temperature:         %2d C\n", omnibook_fan_policy[1]);
2772 +       for (i = 2; i <= OMNIBOOK_FAN_LEVELS; i++) {
2773 +               b += sprintf(b, "Fan level %1d temperature:    %2d C\n", i, omnibook_fan_policy[i]);
2774 +       }
2775 +       b += sprintf(b, "Minimal temperature to set: %2d C\n", OMNIBOOK_FAN_MIN);
2776 +       b += sprintf(b, "Maximal temperature to set: %2d C\n", OMNIBOOK_FAN_MAX);
2777 +
2778 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
2779 +}
2780 +
2781 +static int omnibook_proc_fan_policy_set(struct file *file, const char *buffer, unsigned long count, void *data)
2782 +{
2783 +       unsigned int len = (count < OMNIBOOK_FAN_POLICY_STRING) ? count : OMNIBOOK_FAN_POLICY_STRING;
2784 +       char status[OMNIBOOK_FAN_POLICY_STRING] = {'\0'};
2785 +       char *b;
2786 +       char *prev;
2787 +       u8 n;
2788 +       u8 c;
2789 +       int retval;
2790 +
2791 +       if ((retval = omnibook_get_fan_policy()))
2792 +               return retval;
2793 +
2794 +       if (copy_from_user(status, buffer, len))
2795 +               return -EFAULT;
2796 +       status[len] = 0;
2797 +       b = status;
2798 +       n = 0;
2799 +       c = 0;
2800 +       prev = NULL;
2801 +       do {
2802 +               printk(KERN_INFO "%s: c=%d\n", OMNIBOOK_MODULE_NAME, c);
2803 +               if (n > OMNIBOOK_FAN_LEVELS)
2804 +                       return -EINVAL;
2805 +               if (*b >= '0' && *b <= '9')
2806 +                       c = c * 10 + (*b - '0');
2807 +               else if (((*b == ' ') || (*b == '\0') || (*b == '\n')) && (*prev >= '0') && (*prev <= '9')) {
2808 +                       omnibook_fan_policy[n] = c;
2809 +                       n++;
2810 +                       c = 0;
2811 +               } else {
2812 +                       return -EINVAL;
2813 +               }
2814 +               prev = b;
2815 +               b++;
2816 +       } while ((*prev != '\n') && (*prev != '\0'));
2817 +
2818 +       /* A zero value set the defaults */ 
2819 +       if ((omnibook_fan_policy[0] == 0) && (n == 1)) {
2820 +               if ((retval = omnibook_set_fan_policy_defaults()))
2821 +                       return retval;
2822 +       } else
2823 +               omnibook_set_fan_policy();
2824 +
2825 +       return count;
2826 +}
2827 +
2828 +int __init omnibook_fan_policy_init(void)
2829 +{
2830 +       mode_t pmode;
2831 +
2832 +       switch (omnibook_ectype) {
2833 +       case XE3GF:
2834 +               pmode = S_IFREG | S_IWUSR | S_IRUGO;
2835 +               if (omnibook_userset)
2836 +                       pmode = pmode | S_IWUGO;
2837 +               proc_fan_policy = create_proc_entry("fan_policy", pmode, omnibook_proc_root);
2838 +               break;
2839 +       default:
2840 +               printk(KERN_INFO "%s: Fan policy is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
2841 +               return 0;
2842 +       }
2843 +       if (proc_fan_policy) {
2844 +                       proc_fan_policy->read_proc = omnibook_proc_fan_policy_status;
2845 +                       proc_fan_policy->write_proc = omnibook_proc_fan_policy_set;
2846 +       } else {
2847 +               printk(KERN_ERR "%s: Unable to create /proc/%s/fan_policy.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
2848 +               return -ENOENT;
2849 +       }
2850 +       printk(KERN_INFO "%s: Fan policy setting is enabled.\n", OMNIBOOK_MODULE_NAME);
2851 +       return 0;
2852 +}
2853 +
2854 +void __exit omnibook_fan_policy_cleanup(void)
2855 +{
2856 +       if (proc_fan_policy)
2857 +               remove_proc_entry("fan_policy", omnibook_proc_root);
2858 +}
2859 +
2860 +EXPORT_SYMBOL(omnibook_fan_policy);
2861 +EXPORT_SYMBOL(omnibook_get_fan_policy);
2862 +EXPORT_SYMBOL(omnibook_set_fan_policy);
2863 +EXPORT_SYMBOL(omnibook_set_fan_policy_defaults);
2864 +
2865 +/* End of file */
2866 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/init.c linux-2.6.1-gentoo-test/drivers/char/omnibook/init.c
2867 --- linux-2.6.1-gentoo/drivers/char/omnibook/init.c     1970-01-01 01:00:00.000000000 +0100
2868 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/init.c        2004-01-09 22:33:49.000000000 +0000
2869 @@ -0,0 +1,492 @@
2870 +/*
2871 + * init.c -- module initialization code
2872 + * 
2873 + * This program is free software; you can redistribute it and/or modify it
2874 + * under the terms of the GNU General Public License as published by the
2875 + * Free Software Foundation; either version 2, or (at your option) any
2876 + * later version.
2877 + * 
2878 + * This program is distributed in the hope that it will be useful, but
2879 + * WITHOUT ANY WARRANTY; without even the implied warranty of
2880 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2881 + * General Public License for more details.
2882 + *
2883 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
2884 + */
2885 +
2886 +
2887 +#include <linux/config.h>
2888 +#include <linux/module.h>
2889 +#include <linux/version.h>
2890 +#include <linux/types.h>
2891 +#include <linux/init.h>
2892 +#include <linux/pm.h>
2893 +#include <linux/proc_fs.h>
2894 +
2895 +#include <asm/system.h>
2896 +#include <asm/errno.h>
2897 +#include <asm/io.h>
2898 +#include <asm/uaccess.h>
2899 +
2900 +#ifdef OMNIBOOK_STANDALONE
2901 +#include "omnibook.h"
2902 +#else
2903 +#include <linux/omnibook.h>
2904 +#endif
2905 +
2906 +#include "dmi.h"
2907 +#include "init.h"
2908 +#include "util.h"
2909 +
2910 +int omnibook_ectype;
2911 +int omnibook_userset;
2912 +
2913 +struct proc_dir_entry *omnibook_proc_root __initdata = NULL;
2914 +static struct proc_dir_entry *proc_version;
2915 +static struct proc_dir_entry *proc_dmi;
2916 +
2917 +/*
2918 + * Module parameters
2919 + *  0 disables the feature
2920 + * >1 enables the feature
2921 + * All feature enabled by default
2922 + */
2923 +
2924 +static int ectype __initdata = NONE;
2925 +static int ac __initdata = 1;
2926 +static int battery __initdata = 1;
2927 +static int blank __initdata = 1;
2928 +static int display __initdata = 1;
2929 +static int dmi __initdata = 1;
2930 +static int fan __initdata = 1;
2931 +static int fan_policy __initdata = 1;
2932 +static int onetouch __initdata = 1;
2933 +static int lcd __initdata = 1;
2934 +static int temperature __initdata = 1;
2935 +static int touchpad __initdata = 1;
2936 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
2937 +static int key_polling __initdata = 1;
2938 +#endif
2939 +
2940 +static int apmemu __initdata = 0;
2941 +static int dock __initdata = 0;
2942 +static int user __initdata = 0;
2943 +
2944 +static int omnibook_proc_version(char *buffer, char **start, off_t off, int count, int *eof, void *data)
2945 +{
2946 +       char *b = buffer;
2947 +
2948 +       b += sprintf(b, "%s\n", OMNIBOOK_MODULE_VERSION);
2949 +
2950 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
2951 +}
2952 +
2953 +static int omnibook_proc_dmi(char *buffer, char **start, off_t off, int count, int *eof, void *data)
2954 +{
2955 +       char *b = buffer;
2956 +
2957 +       b += sprintf(b, "BIOS Vendor:   %s\n", omnibook_dmi_ident[OMNIBOOK_BIOS_VENDOR]);
2958 +       b += sprintf(b, "BIOS Version:  %s\n", omnibook_dmi_ident[OMNIBOOK_BIOS_VERSION]);
2959 +       b += sprintf(b, "BIOS Release:  %s\n", omnibook_dmi_ident[OMNIBOOK_BIOS_DATE]);
2960 +       b += sprintf(b, "System Vendor: %s\n", omnibook_dmi_ident[OMNIBOOK_SYS_VENDOR]);
2961 +       b += sprintf(b, "Product Name:  %s\n", omnibook_dmi_ident[OMNIBOOK_PRODUCT_NAME]);
2962 +       b += sprintf(b, "Version:       %s\n", omnibook_dmi_ident[OMNIBOOK_PRODUCT_VERSION]);
2963 +       b += sprintf(b, "Serial Number: %s\n", omnibook_dmi_ident[OMNIBOOK_SERIAL_NUMBER]);
2964 +       b += sprintf(b, "Board Vendor:  %s\n", omnibook_dmi_ident[OMNIBOOK_BOARD_VENDOR]);
2965 +       b += sprintf(b, "Board Name:    %s\n", omnibook_dmi_ident[OMNIBOOK_BOARD_NAME]);
2966 +       b += sprintf(b, "Board Version: %s\n", omnibook_dmi_ident[OMNIBOOK_BOARD_VERSION]);
2967 +
2968 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
2969 +}
2970 +
2971 +#define HP_SIGNATURE   "Hewlett-Packard"
2972 +
2973 +struct omnibook_models_t {
2974 +       /* DMI field matchers (table inputs) */
2975 +       char    *sys_vendor;
2976 +       char    *product_name;
2977 +       char    *product_version;
2978 +       char    *board_name;
2979 +
2980 +       /* Table outputs */
2981 +       char    *syslog_name;           /* Name which will appear in the syslog */
2982 +       int     ectype;                 /* Type of the embedded controller firmware, see omnibook.h and README */
2983 +};
2984 +
2985 +static struct omnibook_models_t omnibook_models[] __initdata = {
2986 +  /* sys_vendor product_name                 product_version                   board_name syslog_name                  ectype */
2987 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook XE3 GF*",            NULL,    NULL,                          XE3GF },
2988 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook XT1000*",            NULL,    NULL,                          XE3GF },
2989 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook XE2 DC*",            NULL,    NULL,                          XE2 },
2990 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook XE3 GC*",            NULL,    NULL,                          XE3GC },
2991 +  /* HP Pavilion N5430 */
2992 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook XE3 GD*",            NULL,    NULL,                          XE3GC },
2993 +  /* HP Pavilion N5415 */
2994 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook XE3 GE*",            NULL,    NULL,                          XE3GC },
2995 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook 500 FA*",            NULL,    NULL,                          OB500 },
2996 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook 510 FB*",            NULL,    NULL,                          OB510 },
2997 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook 4150*",              NULL,    NULL,                          OB4150 },
2998 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook 900 B*",             NULL,    NULL,                          OB4150 },
2999 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook 6000 EA*",           NULL,    NULL,                          OB6000 },
3000 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook 6100 EB*",           NULL,    NULL,                          OB6100 },
3001 +  /* HP OmniBook xe4100 */
3002 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook xe4000*",            NULL,    NULL,                          XE4500 },
3003 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook xe4400*",            NULL,    NULL,                          XE4500 },
3004 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook xe4500*",            NULL,    NULL,                          XE4500 },
3005 +  /* HP OmniBook vt6200 and xt6200 */
3006 +  { NULL,       "HP OmniBook PC*",           "HP OmniBook 6200 EG*",           NULL,    NULL,                          XE4500 },
3007 +  /* HP Pavilion ze4125 */
3008 +  { NULL,       "HP NoteBook PC*",           "HP NoteBook ze4000*",            NULL,    NULL,                          XE4500 },
3009 +  /* There are no model specific strings of some HP Pavilion xt155 and some HP Pavilion ze4100 */
3010 +  { NULL,       "HP NoteBook PC*",           "HP NoteBook PC*",                NULL,    NULL,                          XE4500 },
3011 +  /* HP Pavilion ZU1155 and ZU1175 */
3012 +  { NULL,       "HP Pavilion Notebook PC*",  "HP Pavilion ZU1000 FA*",         NULL,    NULL,                          OB500 },
3013 +  /* HP Pavilion N5290 */
3014 +  { NULL,       "HP Pavilion Notebook PC*",  "HP Pavilion Notebook XE3 GC*",   NULL,    NULL,                          XE3GC },
3015 +  /* HP Pavilion N5441 */
3016 +  { NULL,       "HP Pavilion Notebook PC*",  "HP Pavilion Notebook Model GD*", NULL,    NULL,                          XE3GC },
3017 +  /* HP Pavilion XH545 */
3018 +  { NULL,       "HP Pavilion Notebook PC*",  "HP Pavilion Notebook Model GE*", NULL,    NULL,                          XE3GC },
3019 +  /* HP Pavilion ZT1141 */
3020 +  { NULL,       "HP Pavilion Notebook PC*",  "HP Pavilion Notebook ZT1000*",   NULL,    NULL,                          XE3GF },
3021 +  /* There are no model specific strings of some HP Pavilion ZT1175 and ZT1195 notebooks */
3022 +  { NULL,       "HP Pavilion Notebook PC*",  "HP Pavilion Notebook*",          NULL,    NULL,                          XE3GF },
3023 +  { NULL,       "Pavilion ze4200*",          NULL,                             NULL,    "HP Pavilion ze4200 series",   XE4500 },
3024 +  /* Compaq nx9000 */
3025 +  { NULL,       "HP nx9000*",                NULL,                             NULL,    "HP/Compaq nx9000",            XE4500 },
3026 +  /* Compaq nx9005 */
3027 +  { NULL,       "HP nx9005*",                NULL,                             NULL,    "HP/Compaq nx9005",            XE4500 },
3028 +  /* Compaq nx9010 */
3029 +  { NULL,       "HP nx9010*",                NULL,                             NULL,    "HP/Compaq nx9010",            XE4500 },
3030 +  { "TOSHIBA",  "S1000*",                    NULL,                             NULL,    "Toshiba Satellite 1000",      XE3GF },
3031 +  { "TOSHIBA",  "S1005*",                    NULL,                             NULL,    "Toshiba Satellite 1005",      XE3GF },
3032 +  { "TOSHIBA",  "S1110*",                    NULL,                             NULL,    "Toshiba Satellite 1110",      XE3GF },
3033 +  { "TOSHIBA",  "S1115*",                    NULL,                             NULL,    "Toshiba Satellite 1115",      XE3GF },
3034 +  { "TOSHIBA",  "S1900*",                    NULL,                             NULL,    "Toshiba Satellite 1900",      XE3GF },
3035 +  { "TOSHIBA",  "S1905*",                    NULL,                             NULL,    "Toshiba Satellite 1905",      XE3GF },
3036 +  { "TOSHIBA",  "S1950*",                    NULL,                             NULL,    "Toshiba Satellite 1950",      XE3GF },
3037 +  { "TOSHIBA",  "S2430*",                    NULL,                             NULL,    "Toshiba Satellite 2430",      XE3GF },
3038 +  { "TOSHIBA",  "S3000*",                    NULL,                             NULL,    "Toshiba Satellite 3000",      XE3GF },
3039 +  { "TOSHIBA",  "S3005*",                    NULL,                             NULL,    "Toshiba Satellite 3005",      XE3GF },
3040 +  { "TOSHIBA",  "Satellite 1000*",           NULL,                             NULL,    "Toshiba Satellite 1000",      XE3GF },
3041 +  { "TOSHIBA",  "Satellite 1005*",           NULL,                             NULL,    "Toshiba Satellite 1005",      XE3GF },
3042 +  { "TOSHIBA",  "Satellite 1110*",           NULL,                             NULL,    "Toshiba Satellite 1110",      XE3GF },
3043 +  { "TOSHIBA",  "Satellite 1115*",           NULL,                             NULL,    "Toshiba Satellite 1115",      XE3GF },
3044 +  { "TOSHIBA",  "Satellite 1900*",           NULL,                             NULL,    "Toshiba Satellite 1900",      XE3GF },
3045 +  { "TOSHIBA",  "Satellite 1905*",           NULL,                             NULL,    "Toshiba Satellite 1905",      XE3GF },
3046 +  { "TOSHIBA",  "Satellite 1950*",           NULL,                             NULL,    "Toshiba Satellite 1950",      XE3GF },
3047 +  { "TOSHIBA",  "Satellite 2430*",           NULL,                             NULL,    "Toshiba Satellite 2430",      XE3GF },
3048 +  { "TOSHIBA",  "Satellite 3000*",           NULL,                             NULL,    "Toshiba Satellite 3000",      XE3GF },
3049 +  { "TOSHIBA",  "Satellite 3005*",           NULL,                             NULL,    "Toshiba Satellite 3005",      XE3GF },
3050 +  { "COMPAL",   NULL,                        NULL,                             "ACL00", "Compal ACL00",                XE3GF },
3051 +  { "Acer",     "Aspire 1400 series*",       NULL,                             NULL,    "Acer Aspire 1400 series",     XE3GF },
3052 +  /* This sentinel at the end catches all unsupported models */
3053 +  { NULL, NULL, NULL, NULL, NONE }
3054 +};
3055 +
3056 +struct omnibook_tc_t {
3057 +       char    *tc;
3058 +       int     ectype;
3059 +};
3060 +
3061 +/* HP technology codes */
3062 +static struct omnibook_tc_t omnibook_tc[] __initdata = {
3063 +  /* technology code           ectype */
3064 +       { "CI.",                OB4150 },
3065 +       { "CL.",                OB4150 },
3066 +       { "DC.",                XE2 },
3067 +       { "EA.",                OB6000 },
3068 +       { "EB.",                OB6100 },
3069 +       { "EG.",                XE4500 },
3070 +       { "FA.",                OB500 },
3071 +       { "FB.",                OB510 },
3072 +       { "GC.",                XE3GC },
3073 +       { "GD.",                XE3GC },
3074 +       { "GE.",                XE3GC },
3075 +       { "GF.",                XE3GF },
3076 +       { "IB.",                XE3GF },
3077 +       { "IC.",                XE3GF },
3078 +       { "ID.",                XE3GF },
3079 +       { "KA.",                XE4500 },
3080 +       { "KB.",                XE4500 },
3081 +       { "KC.",                XE4500 },
3082 +       { "KD.",                XE4500 },
3083 +       { "KE.",                XE4500 },
3084 +       { NULL,                 NONE }
3085 +};
3086 +
3087 +/*
3088 + * Compare the saved DMI info at "index" with a string.
3089 + * A '*' at the end of the string will match anything.
3090 + * Returns 0 for a match.
3091 + * 
3092 + * This preserves the semantics of the old omnibook_features[]
3093 + * table.  I don't know if its generally useful or not.
3094 + */
3095 +static int __init cmp_with_glob(int index, char *str)
3096 +{
3097 +       int retval = 0;
3098 +       char *glob;
3099 +       unsigned int len;
3100 +
3101 +       if (str) {
3102 +               glob = strchr(str, '*');
3103 +               len = glob ? glob - str : strlen(str);
3104 +               retval = strncmp(omnibook_dmi_ident[index], str, len);
3105 +       }
3106 +
3107 +       return retval;
3108 +}
3109 +
3110 +static int __init omnibook_ident(void)
3111 +{
3112 +       struct omnibook_models_t *mp;
3113 +
3114 +       for (mp = omnibook_models; mp->ectype != NONE; ++mp) {
3115 +               /* Check all fields for a match */
3116 +               if (cmp_with_glob(OMNIBOOK_SYS_VENDOR, mp->sys_vendor))
3117 +                       continue;
3118 +               if (cmp_with_glob(OMNIBOOK_PRODUCT_NAME, mp->product_name))
3119 +                       continue;
3120 +               if (cmp_with_glob(OMNIBOOK_PRODUCT_VERSION, mp->product_version))
3121 +                       continue;
3122 +               if (cmp_with_glob(OMNIBOOK_BOARD_NAME, mp->board_name))
3123 +                       continue;
3124 +
3125 +               /* All required fields matched */
3126 +               break;
3127 +       }
3128 +
3129 +       return (mp - omnibook_models);
3130 +}
3131 +
3132 +static int __init omnibook_get_tc(void)
3133 +{      
3134 +       struct omnibook_tc_t *tc;
3135 +
3136 +       for (tc = omnibook_tc; tc->ectype != NONE; ++tc) {
3137 +               /*
3138 +                * Technology code appears in the first two chracters of BIOS version string
3139 +                * ended by a dot, but it prefixed a space character on some models and BIOS
3140 +                * versions.
3141 +                * The new HP/Compaq models use different codes, this is not supported yet.
3142 +                */
3143 +               if (strstr(omnibook_dmi_ident[OMNIBOOK_BIOS_VERSION], tc->tc))
3144 +                       break;
3145 +       }
3146 +
3147 +       return (tc - omnibook_tc);
3148 +}
3149 +
3150 +static int __init omnibook_init(void)
3151 +{
3152 +       int retval;
3153 +       int model = 0;
3154 +       int tc = 0;
3155 +       char *syslog_name;
3156 +       char *glob;
3157 +       mode_t pmode;
3158 +
3159 +       omnibook_userset = user;
3160 +
3161 +#ifdef MODULE
3162 +       printk(KERN_INFO "%s: module version %s.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_VERSION);
3163 +#else
3164 +       printk(KERN_INFO "%s: driver version %s.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_VERSION);
3165 +#endif
3166 +
3167 +       /* saving DMI information */
3168 +       if (omnibook_dmi_scan_machine() != 0)
3169 +               return  -ENODEV;
3170 +
3171 +       if (ectype != NONE)
3172 +               printk(KERN_WARNING "%s: Forced load with EC firmware type %d.\n", OMNIBOOK_MODULE_NAME, ectype);
3173 +       else {
3174 +               model = omnibook_ident();
3175 +               if (omnibook_models[model].ectype != NONE) {
3176 +                       ectype = omnibook_models[model].ectype;
3177 +                       syslog_name = omnibook_models[model].syslog_name;
3178 +                       if (!syslog_name) {
3179 +                               syslog_name = omnibook_models[model].product_version;
3180 +                               glob = strchr(syslog_name, '*');
3181 +                               if (glob)
3182 +                                       *glob = '\0';
3183 +                       }
3184 +                       printk(KERN_INFO "%s: %s detected.\n", OMNIBOOK_MODULE_NAME, syslog_name);
3185 +               } else {
3186 +                       /* Without explicite informations try chechking for technology code of HP laptops */
3187 +                       tc = omnibook_get_tc();
3188 +                       if ((strncmp(omnibook_dmi_ident[OMNIBOOK_SYS_VENDOR], HP_SIGNATURE, strlen(HP_SIGNATURE)) == 0) &&
3189 +                               (omnibook_tc[tc].ectype != NONE)) {
3190 +                               ectype = omnibook_tc[tc].ectype;
3191 +                               printk(KERN_INFO "%s: HP tecnology code %s detected.\n", OMNIBOOK_MODULE_NAME, omnibook_tc[tc].tc);
3192 +                       } else {
3193 +                               printk(KERN_INFO "%s: Unknown model detected.\n", OMNIBOOK_MODULE_NAME);
3194 +                               ac = 0;
3195 +                               apmemu = 0;
3196 +                               battery = 0;
3197 +                               blank = 0;
3198 +                               display = 0;
3199 +                               dock = 0;
3200 +                               fan = 0;
3201 +                               fan_policy = 0;
3202 +                               lcd = 0;
3203 +                               onetouch = 0;
3204 +                               temperature = 0;
3205 +                               touchpad = 0;
3206 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
3207 +                               key_polling = 0;
3208 +#endif
3209 +                       }
3210 +               }
3211 +       }
3212 +       omnibook_ectype = ectype;
3213 +
3214 +       omnibook_proc_root = proc_mkdir(OMNIBOOK_MODULE_NAME, NULL);
3215 +       if (! omnibook_proc_root) {
3216 +               printk(KERN_ERR "%s: Unable to create /proc/%s.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
3217 +               return -ENOENT;
3218 +       }
3219 +
3220 +       pmode = S_IFREG | S_IRUGO;
3221 +       proc_version = create_proc_read_entry("version", pmode, omnibook_proc_root, omnibook_proc_version, NULL);
3222 +       if (! proc_version) {
3223 +               printk(KERN_ERR "%s: Unable to create /proc/%s/version.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
3224 +               return -ENOENT;
3225 +       }
3226 +
3227 +       if (dmi) {
3228 +               pmode = S_IFREG | S_IRUGO;
3229 +               proc_dmi = create_proc_read_entry("dmi", pmode, omnibook_proc_root, omnibook_proc_dmi, NULL);
3230 +               if (! proc_dmi) {
3231 +                       printk(KERN_ERR "%s: Unable to create /proc/%s/dmi.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
3232 +                       return -ENOENT;
3233 +               }
3234 +       }
3235 +
3236 +       if ((retval = (ac ? omnibook_ac_init() : 0)))
3237 +               return retval;
3238 +       ac = retval;
3239 +
3240 +       if ((retval = (battery ? omnibook_battery_init() : 0)))
3241 +               return retval;
3242 +       battery = retval;
3243 +
3244 +       /* /proc/apm emulation needs to read battery and AC adapter status */
3245 +       if ((ac == 0) && (battery == 0) && apmemu) {
3246 +               if ((retval = omnibook_apmemu_init()))
3247 +                       return retval;
3248 +       }
3249 +
3250 +       if ((retval = (blank ? omnibook_console_blank_init() : 0)))
3251 +               return retval;
3252 +
3253 +       if ((retval = (display ? omnibook_display_init() : 0)))
3254 +               return retval;
3255 +
3256 +       if ((retval = (dock ? omnibook_dock_init() : 0)))
3257 +               return retval;
3258 +
3259 +       if ((retval = (fan ? omnibook_fan_init() : 0)))
3260 +               return retval;
3261 +
3262 +       if ((retval = (fan_policy ? omnibook_fan_policy_init() : 0)))
3263 +               return retval;
3264 +
3265 +       if ((retval = (lcd ? omnibook_brightness_init() : 0)))
3266 +               return retval;
3267 +
3268 +       if ((retval = (onetouch ? omnibook_onetouch_init() : 0)))
3269 +               return retval;
3270 +
3271 +       if ((retval = (temperature ? omnibook_temperature_init() : 0)))
3272 +               return retval;
3273 +
3274 +       if ((retval = (touchpad ? omnibook_touchpad_init() : 0)))
3275 +               return retval;
3276 +
3277 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
3278 +       if ((retval = (key_polling ? omnibook_key_polling_init() : 0)))
3279 +               return retval;
3280 +
3281 +       printk(KERN_WARNING "%s: module unloading does not work yet on 2.6 kernel.\n", OMNIBOOK_MODULE_NAME);
3282 +#endif
3283 +
3284 +       return 0;
3285 +}
3286 +
3287 +static void __exit omnibook_cleanup(void)
3288 +{
3289 +       omnibook_ac_cleanup();
3290 +       omnibook_apmemu_cleanup();
3291 +       omnibook_battery_cleanup();
3292 +       omnibook_brightness_cleanup();
3293 +       omnibook_console_blank_cleanup();
3294 +       omnibook_display_cleanup();
3295 +       omnibook_dock_cleanup();
3296 +       omnibook_fan_cleanup();
3297 +       omnibook_fan_policy_cleanup();
3298 +       omnibook_onetouch_cleanup();
3299 +       omnibook_temperature_cleanup();
3300 +       omnibook_touchpad_cleanup();
3301 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
3302 +       omnibook_key_polling_cleanup();
3303 +#endif
3304 +       if (proc_version)
3305 +               remove_proc_entry("version", omnibook_proc_root);
3306 +       if (proc_dmi)
3307 +               remove_proc_entry("dmi", omnibook_proc_root);
3308 +       if (omnibook_proc_root)
3309 +               remove_proc_entry("omnibook", NULL);
3310 +       printk(KERN_INFO "%s: module is unloaded.\n", OMNIBOOK_MODULE_NAME);
3311 +}
3312 +
3313 +module_init(omnibook_init);
3314 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
3315 +module_exit(omnibook_cleanup);
3316 +#endif
3317 +
3318 +EXPORT_SYMBOL(omnibook_ectype);
3319 +EXPORT_SYMBOL(omnibook_proc_root);
3320 +
3321 +MODULE_AUTHOR("Soós Péter <sp@osb.hu>");
3322 +MODULE_DESCRIPTION("Kernel interface for HP OmniBook, HP Pavilion, Toshiba Satellite, Acer Aspire and Compal ACL00 laptops");
3323 +MODULE_LICENSE("GPL");
3324 +MODULE_PARM(ectype, "i");
3325 +MODULE_PARM(ac, "i");
3326 +MODULE_PARM(apmemu, "i");
3327 +MODULE_PARM(battery, "i");
3328 +MODULE_PARM(blank, "i");
3329 +MODULE_PARM(display, "i");
3330 +MODULE_PARM(dock, "i");
3331 +MODULE_PARM(dmi, "i");
3332 +MODULE_PARM(fan, "i");
3333 +MODULE_PARM(fan_policy, "i");
3334 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
3335 +MODULE_PARM(key_polling, "i");
3336 +#endif
3337 +MODULE_PARM(lcd, "i");
3338 +MODULE_PARM(onetouch, "i");
3339 +MODULE_PARM(temperature, "i");
3340 +MODULE_PARM(touchpad, "i");
3341 +MODULE_PARM(user, "i");
3342 +MODULE_PARM_DESC(ectype, "Type of embedded controller firmware");
3343 +MODULE_PARM_DESC(ac, "Use 0 to disable, 1 to enable AC adapter status monitoring");
3344 +MODULE_PARM_DESC(apmemu, "Use 0 to disable, 1 to enable /proc/apm emulation");
3345 +MODULE_PARM_DESC(battery, "Use 0 to disable, 1 to enable battery status monitoring");
3346 +MODULE_PARM_DESC(blank, "Use 0 to disable, 1 to enable lcd console blanking");
3347 +MODULE_PARM_DESC(display, "Use 0 to disable, 1 to enable display status handling");
3348 +MODULE_PARM_DESC(dock, "Use 0 to disable, 1 to enable docking station support");
3349 +MODULE_PARM_DESC(dmi, "Use 0 to disable, 1 to enable /proc/omnibook/dmi");
3350 +MODULE_PARM_DESC(fan, "Use 0 to disable, 1 to enable fan status monitor and control");
3351 +MODULE_PARM_DESC(fan_policy, "Use 0 to disable, 1 to enable fan control policy support");
3352 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
3353 +MODULE_PARM_DESC(key_polling, "Use 0 to disable, 1 to enable to scancode emulation for volume keys");
3354 +#endif
3355 +MODULE_PARM_DESC(lcd, "Use 0 to disable, 1 to enable to LCD brightness support");
3356 +MODULE_PARM_DESC(onetouch, "Use 0 to disable, 1 to enable onetouch handling");
3357 +MODULE_PARM_DESC(temperature, "Use 0 to disable, 1 to enable thermal status and policy support");
3358 +MODULE_PARM_DESC(touchpad, "Use 0 to disable, 1 to enable touchpad handling");
3359 +MODULE_PARM_DESC(user, "Use 0 to disable, 1 to enable users to set parameters");
3360 +
3361 +/* End of file */
3362 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/init.h linux-2.6.1-gentoo-test/drivers/char/omnibook/init.h
3363 --- linux-2.6.1-gentoo/drivers/char/omnibook/init.h     1970-01-01 01:00:00.000000000 +0100
3364 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/init.h        2004-01-09 22:33:49.000000000 +0000
3365 @@ -0,0 +1,44 @@
3366 +/*
3367 + * init.h -- initialization and cleanup functions
3368 + * 
3369 + * This program is free software; you can redistribute it and/or modify it
3370 + * under the terms of the GNU General Public License as published by the
3371 + * Free Software Foundation; either version 2, or (at your option) any
3372 + * later version.
3373 + * 
3374 + * This program is distributed in the hope that it will be useful, but
3375 + * WITHOUT ANY WARRANTY; without even the implied warranty of
3376 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3377 + * General Public License for more details.
3378 + *
3379 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
3380 + */
3381 +
3382 +extern int __init omnibook_ac_init(void);
3383 +extern void __exit omnibook_ac_cleanup(void);
3384 +extern int __init omnibook_apmemu_init(void);
3385 +extern void __exit omnibook_apmemu_cleanup(void);
3386 +extern int __init omnibook_battery_init(void);
3387 +extern void __exit omnibook_battery_cleanup(void);
3388 +extern int __init omnibook_console_blank_init(void);
3389 +extern void __exit omnibook_console_blank_cleanup(void);
3390 +extern int __init omnibook_display_init(void);
3391 +extern void __exit omnibook_display_cleanup(void);
3392 +extern int __init omnibook_dock_init(void);
3393 +extern void __exit omnibook_dock_cleanup(void);
3394 +extern int __init omnibook_fan_init(void);
3395 +extern void __exit omnibook_fan_cleanup(void);
3396 +extern int __init omnibook_fan_policy_init(void);
3397 +extern void __exit omnibook_fan_policy_cleanup(void);
3398 +extern int __init omnibook_onetouch_init(void);
3399 +extern void __exit omnibook_onetouch_cleanup(void);
3400 +extern int __init omnibook_key_polling_init(void);
3401 +extern void __exit omnibook_key_polling_cleanup(void);
3402 +extern int __init omnibook_touchpad_init(void);
3403 +extern void __exit omnibook_touchpad_cleanup(void);
3404 +extern int __init omnibook_temperature_init(void);
3405 +extern void __exit omnibook_temperature_cleanup(void);
3406 +extern int __init omnibook_brightness_init(void);
3407 +extern void __exit omnibook_brightness_cleanup(void);
3408 +
3409 +/* End of file */
3410 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/lcd.c linux-2.6.1-gentoo-test/drivers/char/omnibook/lcd.c
3411 --- linux-2.6.1-gentoo/drivers/char/omnibook/lcd.c      1970-01-01 01:00:00.000000000 +0100
3412 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/lcd.c 2004-01-09 22:33:49.000000000 +0000
3413 @@ -0,0 +1,183 @@
3414 +/*
3415 + * lcd.c -- LCD brightness and on/off
3416 + * 
3417 + * This program is free software; you can redistribute it and/or modify it
3418 + * under the terms of the GNU General Public License as published by the
3419 + * Free Software Foundation; either version 2, or (at your option) any
3420 + * later version.
3421 + * 
3422 + * This program is distributed in the hope that it will be useful, but
3423 + * WITHOUT ANY WARRANTY; without even the implied warranty of
3424 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3425 + * General Public License for more details.
3426 + *
3427 + * Written by Maciek Górniak <mago@acn.waw.pl>, 2002
3428 + * Modified by Soós Péter <sp@osb.hu>, 2002-2003
3429 + */
3430 +
3431 +#include <linux/config.h>
3432 +#include <linux/module.h>
3433 +#include <linux/version.h>
3434 +#include <linux/types.h>
3435 +#include <linux/init.h>
3436 +#include <linux/proc_fs.h>
3437 +
3438 +#include <asm/system.h>
3439 +#include <asm/errno.h>
3440 +#include <asm/io.h>
3441 +#include <asm/uaccess.h>
3442 +
3443 +#ifdef OMNIBOOK_STANDALONE
3444 +#include "omnibook.h"
3445 +#else
3446 +#include <linux/omnibook.h>
3447 +#endif
3448 +
3449 +#include "ec.h"
3450 +#include "util.h"
3451 +
3452 +static struct proc_dir_entry *proc_brightness;
3453 +
3454 +int omnibook_get_lcd_brightness(void)
3455 +{
3456 +       int retval = 0;
3457 +       u8 brgt;
3458 +#ifdef CONFIG_VT
3459 +
3460 +       switch (omnibook_ectype) {
3461 +       case XE3GF:
3462 +               if ((retval = omnibook_ec_read(XE3GF_BRTS, &brgt)))
3463 +                       return retval;
3464 +               retval = brgt &= XE3GF_BRTS_MASK;
3465 +               break;
3466 +       case XE3GC:
3467 +               if ((retval = omnibook_ec_read(XE3GC_BTVL, &brgt)))
3468 +                       return retval;
3469 +               retval = brgt &= XE3GC_BTVL_MASK;
3470 +               break;
3471 +       default:
3472 +               printk(KERN_INFO "%s: LCD brightness handling is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
3473 +               retval = -ENODEV;
3474 +       }
3475 +
3476 +#endif
3477 +       return retval;
3478 +}
3479 +
3480 +int omnibook_set_lcd_brightness(u8 brgt)
3481 +{
3482 +       int retval = 0;
3483 +#ifdef CONFIG_VT
3484 +       
3485 +       brgt = (brgt > 10) ? 10 : brgt;
3486 +
3487 +       switch (omnibook_ectype) {
3488 +       case XE3GF:
3489 +               if ((retval = omnibook_ec_write(XE3GF_BRTS, brgt)))
3490 +                       return retval;
3491 +               break;
3492 +       case XE3GC:
3493 +               if ((retval = omnibook_ec_write(XE3GC_BTVL, brgt)))
3494 +                       return retval;
3495 +               break;
3496 +       default:
3497 +               printk(KERN_INFO "%s: LCD brightness handling is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
3498 +               retval = -ENODEV;
3499 +       }
3500 +#endif
3501 +       return retval;  
3502 +}
3503 +
3504 +static int omnibook_proc_brightness_status(char *buffer, char **start, off_t off, int count, int *eof, void *data)
3505 +{
3506 +       char *b = buffer;
3507 +       int brgt;
3508 +
3509 +       brgt = omnibook_get_lcd_brightness();
3510 +       if (brgt < 0)
3511 +               return brgt;
3512 +
3513 +       b += sprintf(b, "LCD brightness: %2d\n", brgt);
3514 +       
3515 +       return omnibook_proc_len(buffer, start, off, count, eof, b);;
3516 +}
3517 +
3518 +static int omnibook_proc_brightness_set(struct file *file, const char *buffer, unsigned long count, void *data)
3519 +{
3520 +       char value[4+1];
3521 +       int brgt = 0;
3522 +       int i;
3523 +       unsigned int len;
3524 +       
3525 +       len = sizeof(value) - 1;
3526 +       if (count < len)
3527 +               len = count;
3528 +       if (copy_from_user(value, buffer, len))
3529 +               return -EFAULT;
3530 +       value[len] = 0;
3531 +
3532 +       if (strcmp(value, "off\n") == 0)
3533 +               omnibook_lcd_blank(1);
3534 +       else if (strcmp(value, "on\n") == 0)
3535 +               omnibook_lcd_blank(0);
3536 +       else
3537 +       {
3538 +               for (i = 0; (value[i] != '\0') && (value[i] != '\n'); i++)
3539 +                       if ((value[i] >= '0') && (value[i] <= '9'))
3540 +                               brgt = brgt * 10 + value[i] - '0';
3541 +                       else
3542 +                               return -EINVAL;
3543 +
3544 +               if ((brgt >= 0) && (brgt <= 10))
3545 +                       omnibook_set_lcd_brightness(brgt);
3546 +               else
3547 +                       return -EINVAL;
3548 +       }
3549 +
3550 +       return count;
3551 +}
3552 +
3553 +int __init omnibook_brightness_init(void)
3554 +{
3555 +#ifdef CONFIG_VT
3556 +       mode_t pmode;
3557 +
3558 +       switch (omnibook_ectype) {
3559 +       case XE3GF:
3560 +       case XE3GC:
3561 +               pmode = S_IFREG | S_IWUSR | S_IRUGO;
3562 +               if (omnibook_userset)
3563 +                       pmode = pmode | S_IWUGO;
3564 +               proc_brightness = create_proc_entry("lcd", pmode, omnibook_proc_root);
3565 +               break;
3566 +       default:
3567 +               printk(KERN_INFO "%s: LCD brightness handling is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
3568 +               return 0;
3569 +       }
3570 +       if (! proc_brightness) {
3571 +               printk(KERN_ERR "%s: Unable to create /proc/%s/lcd.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
3572 +               return -ENOENT;
3573 +       } else {
3574 +               proc_brightness->read_proc = omnibook_proc_brightness_status;
3575 +               proc_brightness->write_proc = omnibook_proc_brightness_set;
3576 +       }
3577 +       printk(KERN_INFO "%s: LCD brightness handling is enabled.\n", OMNIBOOK_MODULE_NAME);
3578 +       return 0;
3579 +#else
3580 +       printk(KERN_ERR "%s: Virtual terminal support is not compiled into your kernel.\n", OMNIBOOK_MODULE_NAME);
3581 +       return -ENODEV;
3582 +#endif
3583 +}
3584 +
3585 +void __exit omnibook_brightness_cleanup(void)
3586 +{
3587 +#ifdef CONFIG_VT
3588 +       if (proc_brightness)
3589 +               remove_proc_entry("lcd", omnibook_proc_root);
3590 +#endif
3591 +}
3592 +
3593 +EXPORT_SYMBOL(omnibook_get_lcd_brightness);
3594 +EXPORT_SYMBOL(omnibook_set_lcd_brightness);
3595 +
3596 +/* End of file */
3597 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/omnibook.h linux-2.6.1-gentoo-test/drivers/char/omnibook/omnibook.h
3598 --- linux-2.6.1-gentoo/drivers/char/omnibook/omnibook.h 1970-01-01 01:00:00.000000000 +0100
3599 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/omnibook.h    2004-01-09 22:33:49.000000000 +0000
3600 @@ -0,0 +1,131 @@
3601 +/*
3602 + * omnibook.h -- High level data structures and functions of omnibook
3603 + *               support code
3604 + * 
3605 + * This program is free software; you can redistribute it and/or modify it
3606 + * under the terms of the GNU General Public License as published by the
3607 + * Free Software Foundation; either version 2, or (at your option) any
3608 + * later version.
3609 + * 
3610 + * This program is distributed in the hope that it will be useful, but
3611 + * WITHOUT ANY WARRANTY; without even the implied warranty of
3612 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3613 + * General Public License for more details.
3614 + *
3615 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
3616 + */
3617 +
3618 +/*
3619 + * Module informations
3620 + */
3621 +
3622 +#define OMNIBOOK_MODULE_NAME           "omnibook"
3623 +#define OMNIBOOK_MODULE_VERSION                "2003-12-08"
3624 +
3625 +/*
3626 + * EC types
3627 + */
3628 +
3629 +extern int omnibook_ectype;
3630 +enum {
3631 +       NONE,
3632 +       XE3GF,  /* HP OmniBook XE3 GF, most Toshiba Satellites and more*/
3633 +       XE3GC,  /* HP OmniBook XE3 GC, GD, GE and compatible */
3634 +       OB500,  /* HP OmniBook 500 and compatible */
3635 +       OB510,  /* HP OmniBook 510 */
3636 +       OB6000, /* HP OmniBook 6000 */
3637 +       OB6100, /* HP OmniBook 6100 */
3638 +       XE4500, /* HP OmniBook xe4500 and compatible */
3639 +       OB4150, /* HP OmniBook 4150 */
3640 +       XE2     /* HP OmniBook XE2 */
3641 +};
3642 +
3643 +extern struct __init proc_dir_entry *omnibook_proc_root;
3644 +extern int omnibook_userset;
3645 +
3646 +extern int omnibook_get_ac(void);
3647 +
3648 +struct omnibook_battery_info {
3649 +       u8 type;        /* 1 - Li-Ion, 2 NiMH */
3650 +       u16 sn;         /* Serial number */
3651 +       u16 dv;         /* Design Voltage */
3652 +       u16 dc;         /* Design Capacity */
3653 +};
3654 +struct omnibook_battery_status {
3655 +       u16 pv;         /* Present Voltage */
3656 +       u16 rc;         /* Remaining Capacity */
3657 +       u16 lc;         /* Last Full Capacity */
3658 +       u8 gauge;       /* Gauge in % */
3659 +       u8 status;      /* 0 - unknown, 1 - charged, 2 - discharging, 3 - charging, 4 - critical) */
3660 +};
3661 +enum {
3662 +       OMNIBOOK_BATTSTAT_UNKNOWN,
3663 +       OMNIBOOK_BATTSTAT_CHARGED,
3664 +       OMNIBOOK_BATTSTAT_DISCHARGING,
3665 +       OMNIBOOK_BATTSTAT_CHARGING,
3666 +       OMNIBOOK_BATTSTAT_CRITICAL
3667 +};
3668 +
3669 +extern int omnibook_battery_present(int num);
3670 +extern int omnibook_get_battery_info(int num, struct omnibook_battery_info *battinfo);
3671 +extern int omnibook_get_battery_status(int num, struct omnibook_battery_status *battstat);
3672 +
3673 +extern int omnibook_console_blank_enabled;
3674 +extern int omnibook_lcd_blank(int blank);
3675 +extern int omnibook_console_blank_enable(void);
3676 +extern int omnibook_console_blank_disable(void);
3677 +
3678 +extern int omnibook_get_display(void);
3679 +
3680 +extern int omnibook_get_dock(void);
3681 +
3682 +extern int omnibook_get_fan(void);
3683 +extern int omnibook_fan_on(void);
3684 +extern int omnibook_fan_off(void);
3685 +
3686 +/*
3687 + * Default temperature limits.
3688 + * Danger! You may overheat your CPU!
3689 + * Do not change these values unless you exactly know what you do.
3690 + */
3691 +
3692 +#define OMNIBOOK_FAN_LEVELS                    7
3693 +#define OMNIBOOK_FAN_MIN                       25      /* Minimal value of fan off temperature */
3694 +#define OMNIBOOK_FOT_MAX                       75      /* Maximal value of fan off temperature */
3695 +#define OMNIBOOK_FAN_MAX                       95      /* Maximal value of fan on temperature */
3696 +#define OMNIBOOK_FOT_DEFAULT                   60      /* Default value of fan off temperature */
3697 +#define OMNIBOOK_FAN1_DEFAULT                  75      /* Default value of fan on temperature */
3698 +#define OMNIBOOK_FAN2_DEFAULT                  85      /* Default value of fan level 2 temperature */
3699 +#define OMNIBOOK_FAN3_DEFAULT                  90      /* Default value of fan level 3 temperature */
3700 +#define OMNIBOOK_FAN4_DEFAULT                  95      /* Default value of fan level 4 temperature */
3701 +#define OMNIBOOK_FAN5_DEFAULT                  95      /* Default value of fan level 5 temperature */
3702 +#define OMNIBOOK_FAN6_DEFAULT                  95      /* Default value of fan level 6 temperature */
3703 +#define OMNIBOOK_FAN7_DEFAULT                  95      /* Default value of fan level 7 temperature */
3704 +#define OMNIBOOK_FAN_POLICY_STRING             32      /* Maximal length of temperature policy control string */
3705 +
3706 +extern u8 omnibook_fan_policy[OMNIBOOK_FAN_LEVELS];
3707 +
3708 +extern int omnibook_get_fan_policy(void);
3709 +extern int omnibook_set_fan_policy(void);
3710 +extern int omnibook_set_fan_policy_defaults(void);
3711 +
3712 +extern int omnibook_get_lcd_brightness(void);
3713 +extern int omnibook_set_lcd_brightness(u8 brgt);
3714 +
3715 +extern int omnibook_onetouch_enabled;
3716 +extern int omnibook_onetouch_enable(void);
3717 +extern int omnibook_onetouch_disable(void);
3718 +
3719 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
3720 +extern int omnibook_key_polling_enabled;
3721 +extern int omnibook_key_polling_enable(void);
3722 +extern int omnibook_key_polling_disable(void);
3723 +#endif
3724 +
3725 +extern int omnibook_get_cpu_temp(void);
3726 +
3727 +extern int omnibook_touchpad_enabled;
3728 +extern int omnibook_touchpad_enable(void);
3729 +extern int omnibook_touchpad_disable(void);
3730 +
3731 +/* End of file */
3732 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/onetouch.c linux-2.6.1-gentoo-test/drivers/char/omnibook/onetouch.c
3733 --- linux-2.6.1-gentoo/drivers/char/omnibook/onetouch.c 1970-01-01 01:00:00.000000000 +0100
3734 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/onetouch.c    2004-01-09 22:33:49.000000000 +0000
3735 @@ -0,0 +1,239 @@
3736 +/*
3737 + * onetouch.c -- code to handling OneTouch buttons
3738 + * 
3739 + * This program is free software; you can redistribute it and/or modify it
3740 + * under the terms of the GNU General Public License as published by the
3741 + * Free Software Foundation; either version 2, or (at your option) any
3742 + * later version.
3743 + * 
3744 + * This program is distributed in the hope that it will be useful, but
3745 + * WITHOUT ANY WARRANTY; without even the implied warranty of
3746 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3747 + * General Public License for more details.
3748 + *
3749 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
3750 + */
3751 +
3752 +
3753 +#include <linux/config.h>
3754 +#include <linux/module.h>
3755 +#include <linux/version.h>
3756 +#include <linux/types.h>
3757 +#include <linux/init.h>
3758 +#include <linux/pm.h>
3759 +#include <linux/proc_fs.h>
3760 +
3761 +#include <asm/system.h>
3762 +#include <asm/errno.h>
3763 +#include <asm/io.h>
3764 +#include <asm/uaccess.h>
3765 +
3766 +#ifdef OMNIBOOK_STANDALONE
3767 +#include "omnibook.h"
3768 +#else
3769 +#include <linux/omnibook.h>
3770 +#endif
3771 +
3772 +#include "ec.h"
3773 +#include "util.h"
3774 +
3775 +static struct pm_dev *pm_onetouch;
3776 +static pm_callback pm_onetouch_callback = NULL;
3777 +
3778 +static struct proc_dir_entry *proc_onetouch;
3779 +
3780 +/* There is no information about reading OneTouch status */
3781 +int omnibook_onetouch_enabled = 0;
3782 +
3783 +static int omnibook_onetouch_on(void)
3784 +{
3785 +       if (omnibook_kbc_command(OMNIBOOK_KBC_CONTROL_CMD, OMNIBOOK_KBC_CMD_ONETOUCH_ENABLE)) {
3786 +               printk(KERN_ERR "%s: failed OneTouch enable command.\n", OMNIBOOK_MODULE_NAME);
3787 +               return -EIO;
3788 +       }
3789 +       return 0;
3790 +}
3791 +
3792 +static int omnibook_onetouch_off(void)
3793 +{
3794 +       if (omnibook_kbc_command(OMNIBOOK_KBC_CONTROL_CMD, OMNIBOOK_KBC_CMD_ONETOUCH_DISABLE)) {
3795 +               printk(KERN_ERR "%s: failed OneTouch disable command.\n", OMNIBOOK_MODULE_NAME);
3796 +               return -EIO;
3797 +       }
3798 +       return 0;
3799 +}
3800 +
3801 +/*
3802 + * Power management handler: on resume it reenables the OneTouch buttons it they were enabled previously
3803 + */
3804 +
3805 +static int pm_onetouch_handler(struct pm_dev *dev, pm_request_t rqst, void *data)
3806 +{
3807 +       switch (rqst) {
3808 +       case PM_RESUME:
3809 +               if (omnibook_onetouch_enabled)
3810 +                       return omnibook_onetouch_on();
3811 +               break;
3812 +       case PM_SUSPEND:
3813 +               if (omnibook_onetouch_enabled)
3814 +                       return omnibook_onetouch_off();
3815 +               break;
3816 +       }
3817 +       return 0;
3818 +}
3819 +
3820 +static int omnibook_onetouch_register(void)
3821 +{
3822 +               pm_onetouch_callback = pm_onetouch_handler;
3823 +               pm_onetouch = pm_register(PM_SYS_DEV, PM_SYS_KBC, pm_onetouch_callback);
3824 +               return (pm_onetouch ? 0 : -EFAULT);
3825 +}
3826 +
3827 +static void omnibook_onetouch_unregister(void)
3828 +{
3829 +               pm_onetouch_callback = NULL;
3830 +               pm_unregister(pm_onetouch);
3831 +}
3832 +
3833 +int omnibook_onetouch_enable(void)
3834 +{
3835 +#ifdef CONFIG_VT
3836 +       switch (omnibook_ectype) {
3837 +       case XE3GF:
3838 +       case XE3GC:
3839 +       case OB500:
3840 +       case OB510:
3841 +       case OB6000:
3842 +       case OB6100:
3843 +       case XE4500:
3844 +               if (! omnibook_onetouch_enabled) {
3845 +                       if (omnibook_onetouch_on())
3846 +                               return -EIO;
3847 +                       omnibook_onetouch_enabled = 1;
3848 +                       printk(KERN_INFO "%s: OneTouch buttons are enabled.\n", OMNIBOOK_MODULE_NAME);
3849 +               }
3850 +               break;
3851 +       default:
3852 +               omnibook_onetouch_enabled = 0;
3853 +               return -ENODEV;
3854 +       }
3855 +#endif
3856 +       return 0;
3857 +}
3858 +
3859 +int omnibook_onetouch_disable(void)
3860 +{
3861 +#ifdef CONFIG_VT
3862 +       switch (omnibook_ectype) {
3863 +       case XE3GF:
3864 +       case XE3GC:
3865 +       case OB500:
3866 +       case OB510:
3867 +       case OB6000:
3868 +       case OB6100:
3869 +       case XE4500:
3870 +               if (omnibook_onetouch_enabled) {
3871 +                       if (omnibook_onetouch_off()) {
3872 +                               return -EIO;
3873 +                       }
3874 +                       omnibook_onetouch_enabled = 0;
3875 +                       printk(KERN_INFO "%s: OneTouch buttons are disabled.\n", OMNIBOOK_MODULE_NAME);
3876 +               }
3877 +               break;
3878 +       default:
3879 +               omnibook_onetouch_enabled = 0;
3880 +               return -ENODEV;
3881 +       }
3882 +#endif
3883 +       return 0;
3884 +}
3885 +
3886 +static int omnibook_onetouch_status(char *buffer, char **start, off_t off, int count, int *eof, void *data)
3887 +{
3888 +       char *b = buffer;
3889 +
3890 +       b += sprintf(b, "OneTouch buttons are %s\n", (omnibook_onetouch_enabled) ? "enabled" : "disabled");
3891 +
3892 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
3893 +}
3894 +
3895 +static int omnibook_onetouch_set(struct file *file, const char *buffer, unsigned long count, void *data)
3896 +{
3897 +       char status[1] = {'\0'};
3898 +
3899 +       if (copy_from_user(status, buffer, 1))
3900 +               return -EFAULT;
3901 +       switch (*status) {
3902 +       case '0':
3903 +               omnibook_onetouch_disable();
3904 +               break;
3905 +       case '1':
3906 +               omnibook_onetouch_enable();
3907 +               break;
3908 +       default:
3909 +               count = -EINVAL;
3910 +       }
3911 +       return count;
3912 +}
3913 +
3914 +int __init omnibook_onetouch_init(void)
3915 +{
3916 +#ifdef CONFIG_VT
3917 +       int retval;
3918 +       mode_t pmode;
3919 +
3920 +       switch (omnibook_ectype) {
3921 +       case XE3GF:
3922 +       case XE3GC:
3923 +       case OB500:
3924 +       case OB510:
3925 +       case OB6000:
3926 +       case OB6100:
3927 +       case XE4500:
3928 +               pmode = S_IFREG | S_IWUSR | S_IRUGO;
3929 +               if (omnibook_userset)
3930 +                       pmode = pmode | S_IWUGO;
3931 +               proc_onetouch = create_proc_entry("onetouch", pmode, omnibook_proc_root);
3932 +               break;
3933 +       default:
3934 +               printk(KERN_INFO "%s: OneTouch button handling is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
3935 +               omnibook_onetouch_enabled = 0;
3936 +               return 0;
3937 +       }
3938 +       if (proc_onetouch) {
3939 +               proc_onetouch->read_proc = omnibook_onetouch_status;
3940 +               proc_onetouch->write_proc = omnibook_onetouch_set;
3941 +       } else {
3942 +               printk(KERN_ERR "%s: Unable to create /proc/%s/onetouch.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
3943 +               return -ENOENT;
3944 +       }
3945 +       if ((retval = omnibook_onetouch_register()))
3946 +               return retval;
3947 +       if ((retval = omnibook_onetouch_enable()))
3948 +               return retval;
3949 +
3950 +       return 0;
3951 +#else
3952 +       printk(KERN_ERR "%s: Virtual terminal support is not compiled into your kernel.\n", OMNIBOOK_MODULE_NAME);
3953 +//     return -ENODEV;
3954 +       return 0;
3955 +#endif
3956 +}
3957 +
3958 +void __exit omnibook_onetouch_cleanup(void)
3959 +{
3960 +#ifdef CONFIG_VT
3961 +       if (proc_onetouch)
3962 +               remove_proc_entry("onetouch", omnibook_proc_root);
3963 +       if (pm_onetouch)
3964 +               omnibook_onetouch_unregister();
3965 +       
3966 +       omnibook_onetouch_disable();
3967 +#endif
3968 +}
3969 +
3970 +EXPORT_SYMBOL(omnibook_onetouch_enabled);
3971 +EXPORT_SYMBOL(omnibook_onetouch_enable);
3972 +EXPORT_SYMBOL(omnibook_onetouch_disable);
3973 +
3974 +/* End of file */
3975 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/polling.c linux-2.6.1-gentoo-test/drivers/char/omnibook/polling.c
3976 --- linux-2.6.1-gentoo/drivers/char/omnibook/polling.c  1970-01-01 01:00:00.000000000 +0100
3977 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/polling.c     2004-01-09 22:33:49.000000000 +0000
3978 @@ -0,0 +1,268 @@
3979 +/*
3980 + * polling.c -- scancode emulation for volume buttons on certain models
3981 + * 
3982 + * This program is free software; you can redistribute it and/or modify it
3983 + * under the terms of the GNU General Public License as published by the
3984 + * Free Software Foundation; either version 2, or (at your option) any
3985 + * later version.
3986 + * 
3987 + * This program is distributed in the hope that it will be useful, but
3988 + * WITHOUT ANY WARRANTY; without even the implied warranty of
3989 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3990 + * General Public License for more details.
3991 + *
3992 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
3993 + */
3994 +
3995 +
3996 +#include <linux/config.h>
3997 +#include <linux/module.h>
3998 +#include <linux/version.h>
3999 +#include <linux/types.h>
4000 +#include <linux/init.h>
4001 +#include <linux/pm.h>
4002 +#include <linux/proc_fs.h>
4003 +#include <linux/version.h>
4004 +#include <linux/timer.h>
4005 +#include <linux/kbd_ll.h>
4006 +
4007 +#include <asm/system.h>
4008 +#include <asm/errno.h>
4009 +#include <asm/io.h>
4010 +#include <asm/uaccess.h>
4011 +
4012 +#ifdef OMNIBOOK_STANDALONE
4013 +#include "omnibook.h"
4014 +#else
4015 +#include <linux/omnibook.h>
4016 +#endif
4017 +
4018 +#include "ec.h"
4019 +#include "util.h"
4020 +
4021 +/*
4022 + * Pollong interval for keys (50 ms)
4023 + */
4024 +
4025 +#define OMNIBOOK_POLL                   50 * HZ / 1000
4026 +
4027 +
4028 +
4029 +static struct pm_dev *pm_key_polling;
4030 +static pm_callback pm_key_polling_callback = NULL;
4031 +
4032 +static struct proc_dir_entry *proc_key_polling;
4033 +
4034 +static struct timer_list omnibook_key_timer;
4035 +
4036 +int omnibook_key_polling_enabled = 0;
4037 +static int pm_omnibook_key_polling_enabled;
4038 +
4039 +static void omnibook_key_poller(unsigned long data)
4040 +{
4041 +       u8 q0a;
4042 +
4043 +       switch (omnibook_ectype) {
4044 +       case XE3GC:
4045 +               omnibook_ec_read(XE3GC_Q0A, &q0a);
4046 +               omnibook_ec_write(XE3GC_Q0A, 0);
4047 +
4048 +//             if (q0a & XE3GC_SLPB_MASK)
4049 +//                     printk(KERN_INFO "%s: Sleep button pressed.\n", OMNIBOOK_MODULE_NAME);
4050 +//             if (q0a & XE3GC_F5_MASK)
4051 +//                     printk(KERN_INFO "%s: Fn-F5 - LCD/CRT switch pressed.\n", OMNIBOOK_MODULE_NAME);
4052 +               /*
4053 +                * Volume button scancode emulaton
4054 +                * It emulates a key press and a release without repeat as other OneTouch buttons do.
4055 +                */
4056 +               if (q0a & XE3GC_VOLD_MASK) {
4057 +                       printk(KERN_INFO "%s: Fn-down arrow or Volume down pressed.\n", OMNIBOOK_MODULE_NAME);
4058 +                       handle_scancode(0xe0, 1);
4059 +                       handle_scancode(XE3GC_VOLD_SCAN, 1);
4060 +                       handle_scancode(0xe0, 0);
4061 +                       handle_scancode(XE3GC_VOLD_SCAN, 0);
4062 +               }
4063 +               if (q0a & XE3GC_VOLU_MASK) {
4064 +                       printk(KERN_INFO "%s: Fn-up arrow or Volume up pressed.\n", OMNIBOOK_MODULE_NAME);
4065 +                       handle_scancode(0xe0, 1);
4066 +                       handle_scancode(XE3GC_VOLU_SCAN, 1);
4067 +                       handle_scancode(0xe0, 0);
4068 +                       handle_scancode(XE3GC_VOLU_SCAN, 0);
4069 +               }
4070 +               if (q0a & XE3GC_MUTE_MASK) {
4071 +                       printk(KERN_INFO "%s: Fn+F7 - Volume mute pressed.\n", OMNIBOOK_MODULE_NAME);
4072 +                       handle_scancode(0xe0, 1);
4073 +                       handle_scancode(XE3GC_MUTE_SCAN, 1);
4074 +                       handle_scancode(0xe0, 0);
4075 +                       handle_scancode(XE3GC_MUTE_SCAN, 0);
4076 +               }
4077 +//             if (q0a & XE3GC_CNTR_MASK)
4078 +//                     printk(KERN_INFO "%s: Fn+F3/Fn+F4 - Contrast up or down pressed.\n", OMNIBOOK_MODULE_NAME);
4079 +//             if (q0a & XE3GC_BRGT_MASK)
4080 +//                     printk(KERN_INFO "%s: Fn+F1/Fn+F2 - Brightness up or down pressed.\n", OMNIBOOK_MODULE_NAME);
4081 +               break;
4082 +       }
4083 +
4084 +       mod_timer(&omnibook_key_timer, jiffies + OMNIBOOK_POLL);
4085 +}
4086 +
4087 +int omnibook_key_polling_enable(void)
4088 +{
4089 +#ifdef CONFIG_VT
4090 +       switch (omnibook_ectype) {
4091 +       case XE3GC:
4092 +               printk(KERN_INFO "%s: Volume buttons do not generate scancodes on this model.\n", OMNIBOOK_MODULE_NAME);
4093 +               init_timer(&omnibook_key_timer);
4094 +               omnibook_key_timer.data = 0;
4095 +               omnibook_key_timer.function = omnibook_key_poller;
4096 +               omnibook_key_timer.expires = jiffies + OMNIBOOK_POLL;
4097 +               add_timer(&omnibook_key_timer);
4098 +               omnibook_key_polling_enabled = 1;
4099 +               printk(KERN_INFO "%s: Scancode emulation for volume buttons enabled.\n", OMNIBOOK_MODULE_NAME);
4100 +               break;
4101 +       default:
4102 +               omnibook_key_polling_enabled = 0;
4103 +               return -ENODEV;
4104 +       }
4105 +#endif
4106 +       return 0;
4107 +}
4108 +       
4109 +int omnibook_key_polling_disable(void)
4110 +{
4111 +#ifdef CONFIG_VT
4112 +       switch (omnibook_ectype) {
4113 +       case XE3GC:
4114 +               if (&omnibook_key_timer) {
4115 +                       del_timer(&omnibook_key_timer);
4116 +                       printk(KERN_INFO "%s: Scancode emulation for volume buttons disabled.\n", OMNIBOOK_MODULE_NAME);
4117 +               }
4118 +               omnibook_key_polling_enabled = 0;
4119 +               break;
4120 +       default:
4121 +               omnibook_key_polling_enabled = 0;
4122 +               return -ENODEV;
4123 +       }
4124 +#endif
4125 +       return 0;
4126 +}
4127 +
4128 +/*
4129 + * Power management handler: on resume it reenables key polling if it was enabled previously
4130 + */
4131 +
4132 +static int pm_key_polling_handler(struct pm_dev *dev, pm_request_t rqst, void *data)
4133 +{
4134 +
4135 +       switch (rqst) {
4136 +       case PM_RESUME:
4137 +               if (pm_omnibook_key_polling_enabled)
4138 +                       return omnibook_key_polling_enable();
4139 +               break;
4140 +       case PM_SUSPEND:
4141 +               if (omnibook_key_polling_enabled)
4142 +                       pm_omnibook_key_polling_enabled = omnibook_key_polling_enabled;
4143 +                       return omnibook_key_polling_disable();
4144 +               break;
4145 +       }
4146 +       return 0;
4147 +}
4148 +
4149 +static int omnibook_key_polling_register(void)
4150 +{
4151 +               pm_key_polling_callback = pm_key_polling_handler;
4152 +               pm_key_polling = pm_register(PM_SYS_DEV, PM_SYS_KBC, pm_key_polling_callback);
4153 +               return (pm_key_polling ? 0 : -EFAULT);
4154 +}
4155 +
4156 +static void omnibook_key_polling_unregister(void)
4157 +{
4158 +               pm_key_polling_callback = NULL;
4159 +               pm_unregister(pm_key_polling);
4160 +}
4161 +
4162 +static int omnibook_key_polling_status(char *buffer, char **start, off_t off, int count, int *eof, void *data)
4163 +{
4164 +       char *b = buffer;
4165 +
4166 +       b += sprintf(b, "Volume buttons handling is %s\n", (omnibook_key_polling_enabled) ? "enabled" : "disabled");
4167 +
4168 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
4169 +}
4170 +
4171 +static int omnibook_key_polling_set(struct file *file, const char *buffer, unsigned long count, void *data)
4172 +{
4173 +       char status[1] = {'\0'};
4174 +
4175 +       if (copy_from_user(status, buffer, 1))
4176 +               return -EFAULT;
4177 +       switch (*status) {
4178 +       case '0':
4179 +               omnibook_key_polling_disable();
4180 +               break;
4181 +       case '1':
4182 +               omnibook_key_polling_enable();
4183 +               break;
4184 +       default:
4185 +               count = -EINVAL;
4186 +       }
4187 +       return count;
4188 +}
4189 +
4190 +
4191 +int __init omnibook_key_polling_init(void)
4192 +{
4193 +#ifdef CONFIG_VT
4194 +
4195 +       int retval;
4196 +       mode_t pmode;
4197 +
4198 +       switch (omnibook_ectype) {
4199 +       case XE3GC:
4200 +               pmode = S_IFREG | S_IWUSR | S_IRUGO;
4201 +               if (omnibook_userset)
4202 +                       pmode = pmode | S_IWUGO;
4203 +               proc_key_polling = create_proc_entry("key_polling", pmode, omnibook_proc_root);
4204 +               break;
4205 +       default:
4206 +               printk(KERN_INFO "%s: Key polling is unnecessary on this machine.\n", OMNIBOOK_MODULE_NAME);
4207 +               omnibook_key_polling_enabled = 0;
4208 +               return 0;
4209 +       }
4210 +       if (proc_key_polling) {
4211 +               proc_key_polling->read_proc = omnibook_key_polling_status;
4212 +               proc_key_polling->write_proc = omnibook_key_polling_set;
4213 +       } else {
4214 +               printk(KERN_ERR "%s: Unable to create /proc/%s/key_polling.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
4215 +               return -ENOENT;
4216 +       }
4217 +       if ((retval = omnibook_key_polling_register()))
4218 +               return retval;
4219 +//     if ((retval = omnibook_key_polling_enable()))
4220 +//             return retval;
4221 +
4222 +       printk(KERN_INFO "%s: Key polling is enabled.\n", OMNIBOOK_MODULE_NAME);
4223 +       return 0;
4224 +#else
4225 +       printk(KERN_ERR "%s: Virtual terminal support is not compiled into your kernel.\n", OMNIBOOK_MODULE_NAME);
4226 +       return -ENODEV;
4227 +#endif
4228 +}
4229 +
4230 +void __exit omnibook_key_polling_cleanup(void)
4231 +{
4232 +#ifdef CONFIG_VT
4233 +       if (proc_key_polling)
4234 +               remove_proc_entry("key_polling", omnibook_proc_root);
4235 +       if (pm_key_polling)
4236 +               omnibook_key_polling_unregister();
4237 +       
4238 +       omnibook_key_polling_disable();
4239 +#endif
4240 +}
4241 +
4242 +EXPORT_SYMBOL(omnibook_key_polling_enabled);
4243 +EXPORT_SYMBOL(omnibook_key_polling_enable);
4244 +EXPORT_SYMBOL(omnibook_key_polling_disable);
4245 +
4246 +/* End of file */
4247 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/temperature.c linux-2.6.1-gentoo-test/drivers/char/omnibook/temperature.c
4248 --- linux-2.6.1-gentoo/drivers/char/omnibook/temperature.c      1970-01-01 01:00:00.000000000 +0100
4249 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/temperature.c 2004-01-09 22:33:49.000000000 +0000
4250 @@ -0,0 +1,130 @@
4251 +/*
4252 + * temperature.c -- CPU temprature monitoring
4253 + * 
4254 + * This program is free software; you can redistribute it and/or modify it
4255 + * under the terms of the GNU General Public License as published by the
4256 + * Free Software Foundation; either version 2, or (at your option) any
4257 + * later version.
4258 + * 
4259 + * This program is distributed in the hope that it will be useful, but
4260 + * WITHOUT ANY WARRANTY; without even the implied warranty of
4261 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4262 + * General Public License for more details.
4263 + *
4264 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
4265 + */
4266 +
4267 +
4268 +#include <linux/config.h>
4269 +#include <linux/module.h>
4270 +#include <linux/version.h>
4271 +#include <linux/types.h>
4272 +#include <linux/init.h>
4273 +#include <linux/proc_fs.h>
4274 +
4275 +#include <asm/system.h>
4276 +#include <asm/errno.h>
4277 +#include <asm/io.h>
4278 +#include <asm/uaccess.h>
4279 +
4280 +#ifdef OMNIBOOK_STANDALONE
4281 +#include "omnibook.h"
4282 +#else
4283 +#include <linux/omnibook.h>
4284 +#endif
4285 +
4286 +#include "ec.h"
4287 +#include "util.h"
4288 +
4289 +static struct proc_dir_entry *proc_temperature;
4290 +
4291 +int omnibook_get_cpu_temp(void)
4292 +{
4293 +       u8 temp = 0;
4294 +       int retval;
4295 +
4296 +       switch (omnibook_ectype) {
4297 +       case XE3GF:
4298 +               if ((retval = omnibook_ec_read(XE3GF_CTMP, &temp)))
4299 +                       return retval;
4300 +               retval = temp;
4301 +               break;
4302 +       case XE3GC:
4303 +               if ((retval = omnibook_ec_read(XE3GC_CTMP, &temp)))
4304 +                       return retval;
4305 +               retval = temp;
4306 +               break;
4307 +       case OB500:
4308 +       case OB510:
4309 +       case OB6000:
4310 +       case OB6100:
4311 +       case XE4500:
4312 +       case XE2:
4313 +               if ((retval = omnibook_ec_read(OB500_CTMP, &temp)))
4314 +                       return retval;
4315 +               retval = temp;
4316 +               break;
4317 +       case OB4150:
4318 +               if ((retval = omnibook_ec_read(OB4150_TMP, &temp)))
4319 +                       return retval;
4320 +               retval = temp;
4321 +               break;
4322 +       default:
4323 +               printk(KERN_INFO "%s: Temperature monitoring is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
4324 +               retval = -ENODEV ;
4325 +       }
4326 +       return retval;
4327 +}
4328 +
4329 +static int omnibook_proc_temperature(char *buffer, char **start, off_t off, int count, int *eof, void *data)
4330 +{
4331 +       char *b = buffer;
4332 +       int cpu_temp;
4333 +
4334 +       cpu_temp = omnibook_get_cpu_temp();
4335 +       if (cpu_temp < 0)
4336 +               return cpu_temp;
4337 +
4338 +       b += sprintf(b, "CPU temperature:            %2d C\n", cpu_temp);
4339 +
4340 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
4341 +}
4342 +
4343 +int __init omnibook_temperature_init(void)
4344 +{
4345 +       mode_t pmode;
4346 +
4347 +       switch (omnibook_ectype) {
4348 +       case XE3GF:
4349 +       case XE3GC:
4350 +       case OB500:
4351 +       case OB510:
4352 +       case OB6000:
4353 +       case OB6100:
4354 +       case XE4500:
4355 +       case OB4150:
4356 +       case XE2:
4357 +               pmode = S_IFREG | S_IRUGO;
4358 +               proc_temperature = create_proc_read_entry("temperature", pmode, omnibook_proc_root, omnibook_proc_temperature, NULL);
4359 +               break;
4360 +       default:
4361 +               printk(KERN_INFO "%s: Temperature monitoring is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
4362 +               return 0;
4363 +       }
4364 +       if (! proc_temperature) {
4365 +               printk(KERN_ERR "%s: Unable to create /proc/%s/temperature.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
4366 +               return -ENOENT;
4367 +       }
4368 +       printk(KERN_INFO "%s: Temperature monitoring is enabled.\n", OMNIBOOK_MODULE_NAME);
4369 +       return 0;
4370 +}
4371 +
4372 +void __exit omnibook_temperature_cleanup(void)
4373 +{
4374 +       if (proc_temperature)
4375 +               remove_proc_entry("temperature", omnibook_proc_root);
4376 +}
4377 +
4378 +EXPORT_SYMBOL(omnibook_get_cpu_temp);
4379 +
4380 +/* End of file */
4381 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/touchpad.c linux-2.6.1-gentoo-test/drivers/char/omnibook/touchpad.c
4382 --- linux-2.6.1-gentoo/drivers/char/omnibook/touchpad.c 1970-01-01 01:00:00.000000000 +0100
4383 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/touchpad.c    2004-01-09 22:33:49.000000000 +0000
4384 @@ -0,0 +1,239 @@
4385 +/*
4386 + * touchpad.c -- enable/disable touchpad
4387 + * 
4388 + * This program is free software; you can redistribute it and/or modify it
4389 + * under the terms of the GNU General Public License as published by the
4390 + * Free Software Foundation; either version 2, or (at your option) any
4391 + * later version.
4392 + * 
4393 + * This program is distributed in the hope that it will be useful, but
4394 + * WITHOUT ANY WARRANTY; without even the implied warranty of
4395 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4396 + * General Public License for more details.
4397 + *
4398 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
4399 + */
4400 +
4401 +
4402 +#include <linux/config.h>
4403 +#include <linux/module.h>
4404 +#include <linux/version.h>
4405 +#include <linux/types.h>
4406 +#include <linux/init.h>
4407 +#include <linux/pm.h>
4408 +#include <linux/proc_fs.h>
4409 +
4410 +#include <asm/system.h>
4411 +#include <asm/errno.h>
4412 +#include <asm/io.h>
4413 +#include <asm/uaccess.h>
4414 +
4415 +#ifdef OMNIBOOK_STANDALONE
4416 +#include "omnibook.h"
4417 +#else
4418 +#include <linux/omnibook.h>
4419 +#endif
4420 +
4421 +#include "ec.h"
4422 +#include "util.h"
4423 +
4424 +static struct pm_dev *pm_touchpad;
4425 +static pm_callback pm_touchpad_callback = NULL;
4426 +
4427 +static struct proc_dir_entry *proc_touchpad;
4428 +
4429 +#ifdef CONFIG_MOUSE_PS2
4430 +#define OMNIBOOK_TOUCHPAD
4431 +#endif
4432 +
4433 +#ifdef CONFIG_PSMOUSE
4434 +#define OMNIBOOK_TOUCHPAD
4435 +#endif
4436 +
4437 +#ifdef OMNIBOOK_TOUCHPAD
4438 +/* Touchpad is enabled by default */
4439 +int omnibook_touchpad_enabled = 1;
4440 +#else
4441 +int omnibook_touchpad_enabled = 0;
4442 +#endif
4443 +
4444 +static int omnibook_touchpad_on(void)
4445 +{
4446 +       if (omnibook_kbc_command(OMNIBOOK_KBC_CONTROL_CMD, OMNIBOOK_KBC_CMD_TOUCHPAD_ENABLE)) {
4447 +               printk(KERN_ERR "%s: failed touchpad enable command.\n", OMNIBOOK_MODULE_NAME);
4448 +               return -EIO;
4449 +       }
4450 +       return 0;
4451 +}
4452 +
4453 +static int omnibook_touchpad_off(void)
4454 +{
4455 +       if (omnibook_kbc_command(OMNIBOOK_KBC_CONTROL_CMD, OMNIBOOK_KBC_CMD_TOUCHPAD_DISABLE)) {
4456 +               printk(KERN_ERR "%s: failed touchpad disable command.\n", OMNIBOOK_MODULE_NAME);
4457 +               return -EIO;
4458 +       }
4459 +       return 0;
4460 +}
4461 +
4462 +/*
4463 + * Power management handler: on resume it redisables the touchpad if it was disabled previously
4464 + */
4465 +
4466 +static int pm_touchpad_handler(struct pm_dev *dev, pm_request_t rqst, void *data)
4467 +{
4468 +       switch (rqst) {
4469 +       case PM_RESUME:
4470 +               if (! omnibook_touchpad_enabled)
4471 +                       return omnibook_touchpad_off();
4472 +               break;
4473 +       }
4474 +       return 0;
4475 +}
4476 +
4477 +static int omnibook_touchpad_register(void)
4478 +{
4479 +               pm_touchpad_callback = pm_touchpad_handler;
4480 +               pm_touchpad = pm_register(PM_SYS_DEV, PM_SYS_KBC, pm_touchpad_callback);
4481 +               return (pm_touchpad ? 0 : -EFAULT);
4482 +}
4483 +
4484 +static void omnibook_touchpad_unregister(void)
4485 +{
4486 +               pm_touchpad_callback = NULL;
4487 +               pm_unregister(pm_touchpad);
4488 +}
4489 +
4490 +int omnibook_touchpad_enable(void)
4491 +{
4492 +#ifdef OMNIBOOK_TOUCHPAD
4493 +       switch (omnibook_ectype) {
4494 +       case XE3GF:
4495 +       case XE3GC:
4496 +               if (! omnibook_touchpad_enabled) {
4497 +                       if (omnibook_touchpad_on())
4498 +                               return -EIO;
4499 +                       omnibook_touchpad_enabled = 1;
4500 +                       printk(KERN_INFO "%s: Touchpad is enabled.\n", OMNIBOOK_MODULE_NAME);
4501 +               }
4502 +               break;
4503 +       case OB500:
4504 +       case OB510:
4505 +               omnibook_touchpad_enabled = 0;
4506 +               return -ENODEV;
4507 +               break;
4508 +       default:
4509 +               omnibook_touchpad_enabled = 1;
4510 +               return -ENODEV;
4511 +       }
4512 +#endif
4513 +       return 0;
4514 +}
4515 +
4516 +int omnibook_touchpad_disable(void)
4517 +{
4518 +#ifdef OMNIBOOK_TOUCHPAD
4519 +       switch (omnibook_ectype) {
4520 +       case XE3GF:
4521 +       case XE3GC:
4522 +               if (omnibook_touchpad_enabled) {
4523 +                       if (omnibook_touchpad_off()) {
4524 +                               return -EIO;
4525 +                       }
4526 +                       omnibook_touchpad_enabled = 0;
4527 +                       printk(KERN_INFO "%s: Touchpad is disabled.\n", OMNIBOOK_MODULE_NAME);
4528 +               }
4529 +               break;
4530 +       case OB500:
4531 +       case OB510:
4532 +               omnibook_touchpad_enabled = 0;
4533 +               return -ENODEV;
4534 +               break;
4535 +       default:
4536 +               omnibook_touchpad_enabled = 1;
4537 +               return -ENODEV;
4538 +       }
4539 +#endif
4540 +       return 0;
4541 +}
4542 +
4543 +static int omnibook_touchpad_status(char *buffer, char **start, off_t off, int count, int *eof, void *data)
4544 +{
4545 +       char *b = buffer;
4546 +
4547 +        b += sprintf(b, "Touchpad is %s\n", (omnibook_touchpad_enabled) ? "enabled" : "disabled");
4548 +       
4549 +       return omnibook_proc_len(buffer, start, off, count, eof, b);
4550 +}
4551 +
4552 +static int omnibook_touchpad_set(struct file *file, const char *buffer, unsigned long count, void *data)
4553 +{
4554 +       char status[1] = {'\0'};
4555 +
4556 +       if (copy_from_user(status, buffer, 1))
4557 +               return -EFAULT;
4558 +       switch (*status) {
4559 +       case '0':
4560 +               omnibook_touchpad_disable();
4561 +               break;
4562 +       case '1':
4563 +               omnibook_touchpad_enable();
4564 +               break;
4565 +       default:
4566 +               count = -EINVAL;
4567 +       }
4568 +       return count;
4569 +}
4570 +
4571 +int __init omnibook_touchpad_init(void)
4572 +{
4573 +#ifdef OMNIBOOK_TOUCHPAD
4574 +       int retval;
4575 +       mode_t pmode;
4576 +       
4577 +       switch (omnibook_ectype) {
4578 +       case XE3GF:
4579 +       case XE3GC:
4580 +               pmode = S_IFREG | S_IWUSR | S_IRUGO;
4581 +               if (omnibook_userset)
4582 +                       pmode = pmode | S_IWUGO;
4583 +               proc_touchpad = create_proc_entry("touchpad", pmode, omnibook_proc_root);
4584 +               break;
4585 +       default:
4586 +               printk(KERN_INFO "%s: Touchpad handling is unsupported on this machine.\n", OMNIBOOK_MODULE_NAME);
4587 +               omnibook_touchpad_enabled = 1;
4588 +               return 0;
4589 +       }
4590 +       if (proc_touchpad) {
4591 +               proc_touchpad->read_proc = omnibook_touchpad_status;
4592 +               proc_touchpad->write_proc = omnibook_touchpad_set;
4593 +       } else {
4594 +               printk(KERN_ERR "%s: Unable to create /proc/%s/touchpad.\n", OMNIBOOK_MODULE_NAME, OMNIBOOK_MODULE_NAME);
4595 +               return -ENOENT;
4596 +       }
4597 +       if ((retval = omnibook_touchpad_register()))
4598 +               return retval;
4599 +
4600 +       return 0;
4601 +#else
4602 +       printk(KERN_ERR "%s: PS/2 mouse support is not compiled into your kernel.\n", OMNIBOOK_MODULE_NAME);
4603 +//     return -ENODEV;
4604 +       return 0;
4605 +#endif
4606 +}
4607 +
4608 +void __exit omnibook_touchpad_cleanup(void)
4609 +{
4610 +#ifdef OMNIBOOK_TOUCHPAD
4611 +       if (proc_touchpad)
4612 +               remove_proc_entry("touchpad", omnibook_proc_root);
4613 +       if (pm_touchpad)
4614 +               omnibook_touchpad_unregister();
4615 +       omnibook_touchpad_enable();
4616 +#endif
4617 +}
4618 +
4619 +EXPORT_SYMBOL(omnibook_touchpad_enabled);
4620 +EXPORT_SYMBOL(omnibook_touchpad_enable);
4621 +EXPORT_SYMBOL(omnibook_touchpad_disable);
4622 +
4623 +/* End of file */
4624 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/util.c linux-2.6.1-gentoo-test/drivers/char/omnibook/util.c
4625 --- linux-2.6.1-gentoo/drivers/char/omnibook/util.c     1970-01-01 01:00:00.000000000 +0100
4626 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/util.c        2004-01-09 22:33:49.000000000 +0000
4627 @@ -0,0 +1,35 @@
4628 +/*
4629 + * util.c -- utility functions
4630 + * 
4631 + * This program is free software; you can redistribute it and/or modify it
4632 + * under the terms of the GNU General Public License as published by the
4633 + * Free Software Foundation; either version 2, or (at your option) any
4634 + * later version.
4635 + * 
4636 + * This program is distributed in the hope that it will be useful, but
4637 + * WITHOUT ANY WARRANTY; without even the implied warranty of
4638 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4639 + * General Public License for more details.
4640 + *
4641 + * Written by Soós Péter <sp@osb.hu>, 2003
4642 + */
4643 +
4644 +#include <linux/types.h>
4645 +
4646 +int omnibook_proc_len(char *buffer, char **start, off_t off, int count, int *eof, char *b)
4647 +{
4648 +       unsigned int len;
4649 +
4650 +       len = b - buffer;
4651 +       if (len < off + count)
4652 +               *eof = 1;
4653 +       *start = buffer + off;
4654 +               len -= off;
4655 +       if (len > count)
4656 +               len = count;
4657 +       if (len < 0)
4658 +               len = 0;
4659 +       return len;
4660 +}
4661 +
4662 +/* End of file */
4663 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/char/omnibook/util.h linux-2.6.1-gentoo-test/drivers/char/omnibook/util.h
4664 --- linux-2.6.1-gentoo/drivers/char/omnibook/util.h     1970-01-01 01:00:00.000000000 +0100
4665 +++ linux-2.6.1-gentoo-test/drivers/char/omnibook/util.h        2004-01-09 22:33:49.000000000 +0000
4666 @@ -0,0 +1,19 @@
4667 +/*
4668 + * util.h -- Utility declarations
4669 + * 
4670 + * This program is free software; you can redistribute it and/or modify it
4671 + * under the terms of the GNU General Public License as published by the
4672 + * Free Software Foundation; either version 2, or (at your option) any
4673 + * later version.
4674 + * 
4675 + * This program is distributed in the hope that it will be useful, but
4676 + * WITHOUT ANY WARRANTY; without even the implied warranty of
4677 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4678 + * General Public License for more details.
4679 + *
4680 + * Written by Soós Péter <sp@osb.hu>, 2003
4681 + */
4682 +
4683 +extern int omnibook_proc_len(char *buffer, char **start, off_t off, int count, int *eof, char *b);
4684 +
4685 +/* End of file */
4686 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/drivers/input/keyboard/atkbd.c linux-2.6.1-gentoo-test/drivers/input/keyboard/atkbd.c
4687 --- linux-2.6.1-gentoo/drivers/input/keyboard/atkbd.c   2004-01-09 23:40:12.000000000 +0000
4688 +++ linux-2.6.1-gentoo-test/drivers/input/keyboard/atkbd.c      2004-01-09 23:32:25.000000000 +0000
4689 @@ -59,11 +59,11 @@
4690          82, 83, 80, 76, 77, 72,  1, 69, 87, 78, 81, 74, 55, 73, 70, 99,
4691  
4692           0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
4693 -       217,100,255,  0, 97,165,  0,  0,156,  0,  0,  0,  0,  0,  0,125,
4694 +       217,100,255,118, 97,165,  0,  0,156,117,  0,  0,  0,  0,  0,125,
4695         173,114,  0,113,  0,  0,  0,126,128,  0,  0,140,  0,  0,  0,127,
4696         159,  0,115,  0,164,  0,  0,116,158,  0,150,166,  0,  0,  0,142,
4697         157,  0,  0,  0,  0,  0,  0,  0,155,  0, 98,  0,  0,163,  0,  0,
4698 -       226,  0,  0,  0,  0,  0,  0,  0,  0,255, 96,  0,  0,  0,143,  0,
4699 +       226,116,  0,  0,  0,  0,  0,  0,  0,255, 96,  0,  0,  0,143,  0,
4700           0,  0,  0,  0,  0,  0,  0,  0,  0,107,  0,105,102,  0,  0,112,
4701         110,111,108,112,106,103,  0,119,  0,118,109,  0, 99,104,119,  0,
4702  
4703 diff -Naur --exclude '*.orig' --exclude '*.rej' linux-2.6.1-gentoo/include/linux/omnibook.h linux-2.6.1-gentoo-test/include/linux/omnibook.h
4704 --- linux-2.6.1-gentoo/include/linux/omnibook.h 1970-01-01 01:00:00.000000000 +0100
4705 +++ linux-2.6.1-gentoo-test/include/linux/omnibook.h    2004-01-09 22:34:17.000000000 +0000
4706 @@ -0,0 +1,131 @@
4707 +/*
4708 + * omnibook.h -- High level data structures and functions of omnibook
4709 + *               support code
4710 + * 
4711 + * This program is free software; you can redistribute it and/or modify it
4712 + * under the terms of the GNU General Public License as published by the
4713 + * Free Software Foundation; either version 2, or (at your option) any
4714 + * later version.
4715 + * 
4716 + * This program is distributed in the hope that it will be useful, but
4717 + * WITHOUT ANY WARRANTY; without even the implied warranty of
4718 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4719 + * General Public License for more details.
4720 + *
4721 + * Written by Soós Péter <sp@osb.hu>, 2002-2003
4722 + */
4723 +
4724 +/*
4725 + * Module informations
4726 + */
4727 +
4728 +#define OMNIBOOK_MODULE_NAME           "omnibook"
4729 +#define OMNIBOOK_MODULE_VERSION                "2003-12-08"
4730 +
4731 +/*
4732 + * EC types
4733 + */
4734 +
4735 +extern int omnibook_ectype;
4736 +enum {
4737 +       NONE,
4738 +       XE3GF,  /* HP OmniBook XE3 GF, most Toshiba Satellites and more*/
4739 +       XE3GC,  /* HP OmniBook XE3 GC, GD, GE and compatible */
4740 +       OB500,  /* HP OmniBook 500 and compatible */
4741 +       OB510,  /* HP OmniBook 510 */
4742 +       OB6000, /* HP OmniBook 6000 */
4743 +       OB6100, /* HP OmniBook 6100 */
4744 +       XE4500, /* HP OmniBook xe4500 and compatible */
4745 +       OB4150, /* HP OmniBook 4150 */
4746 +       XE2     /* HP OmniBook XE2 */
4747 +};
4748 +
4749 +extern struct __init proc_dir_entry *omnibook_proc_root;
4750 +extern int omnibook_userset;
4751 +
4752 +extern int omnibook_get_ac(void);
4753 +
4754 +struct omnibook_battery_info {
4755 +       u8 type;        /* 1 - Li-Ion, 2 NiMH */
4756 +       u16 sn;         /* Serial number */
4757 +       u16 dv;         /* Design Voltage */
4758 +       u16 dc;         /* Design Capacity */
4759 +};
4760 +struct omnibook_battery_status {
4761 +       u16 pv;         /* Present Voltage */
4762 +       u16 rc;         /* Remaining Capacity */
4763 +       u16 lc;         /* Last Full Capacity */
4764 +       u8 gauge;       /* Gauge in % */
4765 +       u8 status;      /* 0 - unknown, 1 - charged, 2 - discharging, 3 - charging, 4 - critical) */
4766 +};
4767 +enum {
4768 +       OMNIBOOK_BATTSTAT_UNKNOWN,
4769 +       OMNIBOOK_BATTSTAT_CHARGED,
4770 +       OMNIBOOK_BATTSTAT_DISCHARGING,
4771 +       OMNIBOOK_BATTSTAT_CHARGING,
4772 +       OMNIBOOK_BATTSTAT_CRITICAL
4773 +};
4774 +
4775 +extern int omnibook_battery_present(int num);
4776 +extern int omnibook_get_battery_info(int num, struct omnibook_battery_info *battinfo);
4777 +extern int omnibook_get_battery_status(int num, struct omnibook_battery_status *battstat);
4778 +
4779 +extern int omnibook_console_blank_enabled;
4780 +extern int omnibook_lcd_blank(int blank);
4781 +extern int omnibook_console_blank_enable(void);
4782 +extern int omnibook_console_blank_disable(void);
4783 +
4784 +extern int omnibook_get_display(void);
4785 +
4786 +extern int omnibook_get_dock(void);
4787 +
4788 +extern int omnibook_get_fan(void);
4789 +extern int omnibook_fan_on(void);
4790 +extern int omnibook_fan_off(void);
4791 +
4792 +/*
4793 + * Default temperature limits.
4794 + * Danger! You may overheat your CPU!
4795 + * Do not change these values unless you exactly know what you do.
4796 + */
4797 +
4798 +#define OMNIBOOK_FAN_LEVELS                    7
4799 +#define OMNIBOOK_FAN_MIN                       25      /* Minimal value of fan off temperature */
4800 +#define OMNIBOOK_FOT_MAX                       75      /* Maximal value of fan off temperature */
4801 +#define OMNIBOOK_FAN_MAX                       95      /* Maximal value of fan on temperature */
4802 +#define OMNIBOOK_FOT_DEFAULT                   60      /* Default value of fan off temperature */
4803 +#define OMNIBOOK_FAN1_DEFAULT                  75      /* Default value of fan on temperature */
4804 +#define OMNIBOOK_FAN2_DEFAULT                  85      /* Default value of fan level 2 temperature */
4805 +#define OMNIBOOK_FAN3_DEFAULT                  90      /* Default value of fan level 3 temperature */
4806 +#define OMNIBOOK_FAN4_DEFAULT                  95      /* Default value of fan level 4 temperature */
4807 +#define OMNIBOOK_FAN5_DEFAULT                  95      /* Default value of fan level 5 temperature */
4808 +#define OMNIBOOK_FAN6_DEFAULT                  95      /* Default value of fan level 6 temperature */
4809 +#define OMNIBOOK_FAN7_DEFAULT                  95      /* Default value of fan level 7 temperature */
4810 +#define OMNIBOOK_FAN_POLICY_STRING             32      /* Maximal length of temperature policy control string */
4811 +
4812 +extern u8 omnibook_fan_policy[OMNIBOOK_FAN_LEVELS];
4813 +
4814 +extern int omnibook_get_fan_policy(void);
4815 +extern int omnibook_set_fan_policy(void);
4816 +extern int omnibook_set_fan_policy_defaults(void);
4817 +
4818 +extern int omnibook_get_lcd_brightness(void);
4819 +extern int omnibook_set_lcd_brightness(u8 brgt);
4820 +
4821 +extern int omnibook_onetouch_enabled;
4822 +extern int omnibook_onetouch_enable(void);
4823 +extern int omnibook_onetouch_disable(void);
4824 +
4825 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
4826 +extern int omnibook_key_polling_enabled;
4827 +extern int omnibook_key_polling_enable(void);
4828 +extern int omnibook_key_polling_disable(void);
4829 +#endif
4830 +
4831 +extern int omnibook_get_cpu_temp(void);
4832 +
4833 +extern int omnibook_touchpad_enabled;
4834 +extern int omnibook_touchpad_enable(void);
4835 +extern int omnibook_touchpad_disable(void);
4836 +
4837 +/* End of file */
This page took 0.430727 seconds and 3 git commands to generate.