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