From: Mathieu Bérard Date: Mon, 26 Jun 2006 15:35:00 +0000 (+0000) Subject: -Add muteled featuere and suport for HP XE4500 X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=2f045feb288df2dd09cdbb931257bd32d456bc53;p=omnibook.git -Add muteled featuere and suport for HP XE4500 -Nuke watch feature -New ELF section powered features enumeration: array of all features not needed anymore -Reorganize code in init.c and (nuked) init.h: create laptop.h and compat.h -More use of Kbuild in Makefile --- diff --git a/Makefile b/Makefile index 888239e..772cfcd 100644 --- a/Makefile +++ b/Makefile @@ -41,35 +41,35 @@ RM = rm -f FIND = find endif -DEBUG = # -D OMNIBOOK_DEBUG -g -O0 -# Used by 2.6 stuff, so let's be consistant. +DEBUG = #-D DEBUG -g -O0 EXTRA_CFLAGS += -D OMNIBOOK_STANDALONE $(DEBUG) +EXTRA_LDFLAGS += $(src)/sections.lds + OBJS = ac.o battery.o blank.o display.o dock.o \ ec.o fan.o fan_policy.o init.o lcd.o onetouch.o \ - temperature.o touchpad.o dump.o info.o watch.o \ - apmemu.o + temperature.o touchpad.o dump.o info.o \ + apmemu.o muteled.o # All extra flags delt with automagically + obj-m += $(MODULE_NAME).o omnibook-objs := $(OBJS) all: $(MODULE_NAME).ko clean: - $(RM) .*.cmd *.map *.mod.c *.o *.ko *~ "#*#" - $(RM) -r .tmp_versions + make -C $(KSRC) M=$(PWD) clean + $(RM) *~ "#*#" .swp $(RM) -r debian/omnibook-source *-stamp $(RM) -r Modules.symvers (cd misc/obtest; $(RM) obtest *.o) + install: all # Removing module from old location - $(RM) $(MODDIR)/char/$(MODULE_NAME).ko - $(RM) $(MODDIR)/misc/$(MODULE_NAME).ko - $(MKDIR) $(INSTDIR) - $(INSTALL) $(MODULE_NAME).ko $(INSTDIR) - $(DEPMOD) + $(RM) $(VMODDIR)/kernel/drivers/char/$(MODULE_NAME).ko + make -C $(KSRC) M=$(PWD) modules_install unload: $(RMMOD) $(MODULE_NAME) || : diff --git a/ac.c b/ac.c index a1c2e01..6689d82 100644 --- a/ac.c +++ b/ac.c @@ -94,7 +94,7 @@ static int omnibook_ac_read(char *buffer) return len; } -struct omnibook_feature ac_feature = { +static struct omnibook_feature __declared_feature ac_feature = { .name = "ac", .enabled = 1, .read = omnibook_ac_read, diff --git a/apmemu.c b/apmemu.c index c0c86cb..c8d4b46 100644 --- a/apmemu.c +++ b/apmemu.c @@ -147,7 +147,7 @@ static int omnibook_apmemu_init(void) return 0; } -struct omnibook_feature apmemu_feature = { +static struct omnibook_feature __declared_feature apmemu_feature = { .name = "apmemu", .proc_entry = "apm", /* create /proc/apm */ #ifdef CONFIG_OMNIBOOK_APMEMU diff --git a/battery.c b/battery.c index 7443e8d..4b2e00e 100644 --- a/battery.c +++ b/battery.c @@ -552,7 +552,7 @@ static int omnibook_battery_read(char *buffer) return len; } -struct omnibook_feature battery_feature = { +static struct omnibook_feature __declared_feature battery_feature = { .name = "battery", .enabled = 1, .read = omnibook_battery_read, diff --git a/blank.c b/blank.c index 1bf24c4..8659ee2 100644 --- a/blank.c +++ b/blank.c @@ -162,7 +162,7 @@ static void omnibook_console_blank_cleanup(void) omnibook_console_blank_disable(); } -struct omnibook_feature blank_feature = { +static struct omnibook_feature __declared_feature blank_feature = { .name = "blank", .enabled = 1, .read = omnibook_console_blank_read, diff --git a/init.h b/compat.h similarity index 68% rename from init.h rename to compat.h index b915c69..fdb1805 100644 --- a/init.h +++ b/compat.h @@ -1,5 +1,5 @@ /* - * init.h -- Interfaces functions with omnibook features + * compat.h -- Older kernel (=> 2.6.8) support * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * - * Written by Soós Péter , 2002-2004 + * Written by Mathieu Bérard , 2006 */ /* @@ -76,25 +76,4 @@ void inline *kzalloc(size_t size, int flags) } #endif -struct omnibook_feature; - -static int __init omnibook_init(struct omnibook_feature *feature); - -extern struct omnibook_feature ac_feature; -extern struct omnibook_feature apmemu_feature; -extern struct omnibook_feature battery_feature; -extern struct omnibook_feature blank_feature; -extern struct omnibook_feature display_feature; -extern struct omnibook_feature dock_feature; -extern struct omnibook_feature dump_feature; -extern struct omnibook_feature fan_feature; -extern struct omnibook_feature fan_policy_feature; -extern struct omnibook_feature dmi_feature; -extern struct omnibook_feature lcd_feature; -extern struct omnibook_feature onetouch_feature; -extern struct omnibook_feature temperature_feature; -extern struct omnibook_feature touchpad_feature; -extern struct omnibook_feature version_feature; -extern struct omnibook_feature watch_feature; - /* End of file */ diff --git a/display.c b/display.c index 652c78d..725afc2 100644 --- a/display.c +++ b/display.c @@ -90,7 +90,7 @@ static int omnibook_display_read(char *buffer) return len; } -struct omnibook_feature display_feature = { +static struct omnibook_feature __declared_feature display_feature = { .name = "display", .enabled = 1, .read = omnibook_display_read, diff --git a/doc/ChangeLog b/doc/ChangeLog index 924c7b2..5103711 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,6 +1,8 @@ Changelog file for omnibook package: ------------------------------------ + + 2006-XX-XX Mathieu Bérard * Make the module linux 2.6 only kernel versions from 2.6.8 to a least 2.6.17-rc1 are supported @@ -37,6 +39,9 @@ Changelog file for omnibook package: conditions They are both disabled by default +2006-05-15 Thomas Perl +* Added support for xe4500's "audio mute" led + 2006-01-26 Soós Péter * Added support for kernels >= 2.6.15 (pm_legacy.h) * Added Toshiba Satellite M30X diff --git a/doc/README-Windows-Driver b/doc/README-Windows-Driver new file mode 100644 index 0000000..2dc31e3 --- /dev/null +++ b/doc/README-Windows-Driver @@ -0,0 +1,10 @@ +hp's onetouch windows utility +----------------------------- + +When installing hp's onetouch utility in Windows, you can find a ONETOUCH.CFG +file in the installation folder which seems to contain EC Controller commands +for some special features of the embedded controller (like mute led, etc..). + +It looks like the Windows DLL that sends commands to the EC controller is +LgKCUtl.DLL, also found in the onetouch installation folder. Maybe this is +useful to somebody someday :) diff --git a/doc/TODO b/doc/TODO index c3121fd..b5b2559 100644 --- a/doc/TODO +++ b/doc/TODO @@ -7,3 +7,4 @@ TODO * Adding more features of embedded controller * Support more machines * See if/how key polling can be ported to 2.6 +* LED API support diff --git a/dock.c b/dock.c index 9987017..3412b0e 100644 --- a/dock.c +++ b/dock.c @@ -76,7 +76,7 @@ static int omnibook_dock_read(char *buffer) return len; } -struct omnibook_feature dock_feature = { +static struct omnibook_feature __declared_feature dock_feature = { .name = "dock", .enabled = 0, .read = omnibook_dock_read, diff --git a/dump.c b/dump.c index 55f9e0d..142cb44 100644 --- a/dump.c +++ b/dump.c @@ -84,7 +84,7 @@ static int ecdump_write(char *buffer) return 0; } -struct omnibook_feature dump_feature = { +static struct omnibook_feature __declared_feature dump_feature = { .name = "dump", .enabled = 0, .read = ecdump_read, diff --git a/ec.c b/ec.c index f14ba20..e31a7e2 100644 --- a/ec.c +++ b/ec.c @@ -285,13 +285,9 @@ int omnibook_kbc_command(u8 cmd, u8 data) * Read a value from a system I/O address */ -int omnibook_io_read(u32 addr, u8 * data) +int inline omnibook_io_read(u32 addr, u8 * data) { - unsigned long flags; - - spin_lock_irqsave(&omnibook_ec_lock, flags); *data = inb(addr); - spin_unlock_irqrestore(&omnibook_ec_lock, flags); return 0; } @@ -299,13 +295,9 @@ int omnibook_io_read(u32 addr, u8 * data) * Write a value to a system I/O address */ -int omnibook_io_write(u32 addr, u8 data) +int inline omnibook_io_write(u32 addr, u8 data) { - unsigned long flags; - - spin_lock_irqsave(&omnibook_ec_lock, flags); outb(data, addr); - spin_unlock_irqrestore(&omnibook_ec_lock, flags); return 0; } diff --git a/ec.h b/ec.h index d728420..67ef19f 100644 --- a/ec.h +++ b/ec.h @@ -268,6 +268,8 @@ extern int omnibook_mem_write(u32 addr, u8 data); #define OMNIBOOK_KBC_CMD_TOUCHPAD_DISABLE 0xA9 /* Disables touchpad */ #define OMNIBOOK_KBC_CMD_LCD_ON 0xE1 /* Turns LCD display on */ #define OMNIBOOK_KBC_CMD_LCD_OFF 0xE2 /* Turns LCD display off */ +#define OMNIBOOK_KBC_CMD_MUTELED_ON 0x94 /* Turns (xe4500) Mute LED on */ +#define OMNIBOOK_KBC_CMD_MUTELED_OFF 0x95 /* Turns (xe4500) Mute LED off */ #define OMNIBOOK_KBC_CMD_AC_POWER_ENABLE 0xC2 /* Enable AC power */ #define OMNIBOOK_KBC_CMD_AC_POWER_DISABLE 0xC1 /* Disable AC power */ diff --git a/fan.c b/fan.c index 04c031f..340f4f4 100644 --- a/fan.c +++ b/fan.c @@ -279,7 +279,7 @@ static int omnibook_fan_write(char *buffer) return 0; } -struct omnibook_feature fan_feature; +static struct omnibook_feature fan_feature; static int omnibook_fan_init(void) { @@ -294,7 +294,7 @@ static int omnibook_fan_init(void) return 0; } -struct omnibook_feature fan_feature = { +static struct omnibook_feature __declared_feature fan_feature = { .name = "fan", .enabled = 1, .read = omnibook_fan_read, diff --git a/fan_policy.c b/fan_policy.c index 64f3aa4..415f81f 100644 --- a/fan_policy.c +++ b/fan_policy.c @@ -187,9 +187,9 @@ static int omnibook_fan_policy_write(char *buffer) b = buffer; do { -#ifdef OMNIBOOK_DEBUG - printk("n=[%i] b=[%s]\n", n, b); -#endif + + pr_debug("n=[%i] b=[%s]\n", n, b); + if (n > OMNIBOOK_FAN_LEVELS) return -EINVAL; if (!isspace(*b)) { @@ -212,7 +212,7 @@ static int omnibook_fan_policy_write(char *buffer) return 0; } -struct omnibook_feature fan_policy_feature = { +static struct omnibook_feature __declared_feature fan_policy_feature = { .name = "fan_policy", .enabled = 1, .read = omnibook_fan_policy_read, diff --git a/info.c b/info.c index 31b721e..642319e 100644 --- a/info.c +++ b/info.c @@ -69,13 +69,13 @@ static int omnibook_dmi_read(char *buffer) return len; } -struct omnibook_feature version_feature = { +static struct omnibook_feature __declared_feature version_feature = { .name = "version", .enabled = 1, .read = omnibook_version_read, }; -struct omnibook_feature dmi_feature = { +static struct omnibook_feature __declared_feature dmi_feature = { .name = "dmi", .enabled = 1, .read = omnibook_dmi_read, diff --git a/init.c b/init.c index a9eb4a1..a95252f 100644 --- a/init.c +++ b/init.c @@ -31,9 +31,9 @@ #include #endif - #include "ec.h" -#include "init.h" +#include "laptop.h" +#include "compat.h" static struct proc_dir_entry *omnibook_proc_root = NULL; @@ -84,165 +84,11 @@ static struct platform_device omnibook_device = { /* Linked list of all enabled features */ static struct omnibook_feature *omnibook_available_feature; -/* - * Array of all the features provided by this module - */ -static struct omnibook_feature *omnibook_features[] __initdata = { - &ac_feature, - &apmemu_feature, - &battery_feature, - &blank_feature, - &display_feature, - &dock_feature, - &dump_feature, - &fan_feature, - &fan_policy_feature, - &dmi_feature, - &lcd_feature, - &onetouch_feature, - &temperature_feature, - &touchpad_feature, - &version_feature, - &watch_feature -}; - -#define HP_SIGNATURE "Hewlett-Packard" - -struct omnibook_models_t { - /* DMI field matchers (table inputs) */ - char *sys_vendor; - char *product_name; - char *product_version; - char *board_name; - /* Table outputs */ - char *syslog_name; /* Name which will appear in the syslog */ - int ectype; /* Type of the embedded controller firmware, see omnibook.h and README */ -}; -static struct omnibook_models_t omnibook_models[] __initdata = { - /* sys_vendor product_name product_version board_name syslog_name ectype */ - { NULL, "HP OmniBook PC*", "HP OmniBook XE3 GF*", NULL, NULL, XE3GF }, - { NULL, "HP OmniBook PC*", "HP OmniBook XT1000*", NULL, NULL, XE3GF }, - { NULL, "HP OmniBook PC*", "HP OmniBook XE2 DC*", NULL, NULL, XE2 }, - { NULL, "HP OmniBook PC*", "HP OmniBook XE3 GC*", NULL, NULL, XE3GC }, - /* HP Pavilion N5430 */ - { NULL, "HP OmniBook PC*", "HP OmniBook XE3 GD*", NULL, NULL, XE3GC }, - /* HP Pavilion N5415 */ - { NULL, "HP OmniBook PC*", "HP OmniBook XE3 GE*", NULL, NULL, XE3GC }, - { NULL, "HP OmniBook PC*", "HP OmniBook 500 FA*", NULL, NULL, OB500 }, - { NULL, "HP OmniBook PC*", "HP OmniBook 510 FB*", NULL, NULL, OB510 }, - { NULL, "HP OmniBook PC*", "HP OmniBook 4150*", NULL, NULL, OB4150 }, - { NULL, "HP OmniBook PC*", "HP OmniBook 900 B*", NULL, NULL, OB4150 }, - { NULL, "HP OmniBook PC*", "HP OmniBook 6000 EA*", NULL, NULL, OB6000 }, - { NULL, "HP OmniBook PC*", "HP OmniBook 6100 EB*", NULL, NULL, OB6100 }, - /* HP OmniBook xe4100 */ - { NULL, "HP OmniBook PC*", "HP OmniBook xe4000*", NULL, NULL, XE4500 }, - { NULL, "HP OmniBook PC*", "HP OmniBook xe4400*", NULL, NULL, XE4500 }, - { NULL, "HP OmniBook PC*", "HP OmniBook xe4500*", NULL, NULL, XE4500 }, - /* HP OmniBook vt6200 and xt6200 */ - { NULL, "HP OmniBook PC*", "HP OmniBook 6200 EG*", NULL, NULL, XE4500 }, - /* There are no model specific strings of some HP OmniBook XT1500 */ - { NULL, "HP OmniBook PC*", "HP OmniBook*", NULL, NULL, XE3GF }, - /* HP Pavilion ze4125 */ - { NULL, "HP NoteBook PC*", "HP NoteBook ze4000*", NULL, NULL, XE4500 }, - /* There are no model specific strings of some HP Pavilion xt155 and some HP Pavilion ze4100 */ - { NULL, "HP NoteBook PC*", "HP NoteBook PC*", NULL, NULL, XE4500 }, - /* There are no model specific strings of some HP nx9000 */ - { NULL, "HP Notebook PC*", "HP Notebook PC*", NULL, NULL, XE4500 }, - /* HP Pavilion ZU1155 and ZU1175 */ - { NULL, "HP Pavilion Notebook PC*", "HP Pavilion ZU1000 FA*", NULL, NULL, OB500 }, - /* HP Pavilion N5290 */ - { NULL, "HP Pavilion Notebook PC*", "HP Pavilion Notebook XE3 GC*", NULL, NULL, XE3GC }, - /* HP Pavilion N5441 */ - { NULL, "HP Pavilion Notebook PC*", "HP Pavilion Notebook Model GD*", NULL, NULL, XE3GC }, - /* HP Pavilion XH545 */ - { NULL, "HP Pavilion Notebook PC*", "HP Pavilion Notebook Model GE*", NULL, NULL, XE3GC }, - /* HP Pavilion ZT1141 */ - { NULL, "HP Pavilion Notebook PC*", "HP Pavilion Notebook ZT1000*", NULL, NULL, XE3GF }, - /* There are no model specific strings of some HP Pavilion ZT1175 and ZT1195 notebooks */ - { NULL, "HP Pavilion Notebook PC*", "HP Pavilion Notebook*", NULL, NULL, XE3GF }, - { NULL, "Pavilion ze4200*", NULL, NULL, "HP Pavilion ze4200 series", XE4500 }, - { NULL, "Pavilion ze4300*", NULL, NULL, "HP Pavilion ze4300 series", XE4500 }, - { NULL, "Pavilion ze8500*", NULL, NULL, "HP Pavilion ze8500 series", XE4500 }, - /* Compaq nx9000 */ - { NULL, "HP nx9000*", NULL, NULL, "HP Compaq nx9000", XE4500 }, - /* Compaq nx9005 */ - { NULL, "HP nx9005*", NULL, NULL, "HP Compaq nx9005", XE4500 }, - /* Compaq nx9010 */ - { NULL, "HP nx9010*", NULL, NULL, "HP Compaq nx9010", XE4500 }, - { "TOSHIBA", "S1000*", NULL, NULL, "Toshiba Satellite 1000", XE3GF }, - { "TOSHIBA", "S1005*", NULL, NULL, "Toshiba Satellite 1005", XE3GF }, - { "TOSHIBA", "S1110*", NULL, NULL, "Toshiba Satellite 1110", XE3GF }, - { "TOSHIBA", "S1115*", NULL, NULL, "Toshiba Satellite 1115", XE3GF }, - { "TOSHIBA", "S1900*", NULL, NULL, "Toshiba Satellite 1900", XE3GF }, - { "TOSHIBA", "S1905*", NULL, NULL, "Toshiba Satellite 1905", XE3GF }, - { "TOSHIBA", "S1950*", NULL, NULL, "Toshiba Satellite 1950", XE3GF }, - { "TOSHIBA", "S1955*", NULL, NULL, "Toshiba Satellite 1955", XE3GF }, - { "TOSHIBA", "S2430*", NULL, NULL, "Toshiba Satellite 2430", XE3GF }, - { "TOSHIBA", "S2435*", NULL, NULL, "Toshiba Satellite 2435", XE3GF }, - { "TOSHIBA", "S3000*", NULL, NULL, "Toshiba Satellite 3000", XE3GF }, - { "TOSHIBA", "S3005*", NULL, NULL, "Toshiba Satellite 3005", XE3GF }, - { "TOSHIBA", "Satellite 1000*", NULL, NULL, "Toshiba Satellite 1000", XE3GF }, - { "TOSHIBA", "Satellite 1005*", NULL, NULL, "Toshiba Satellite 1005", XE3GF }, - { "TOSHIBA", "Satellite 1110*", NULL, NULL, "Toshiba Satellite 1110", XE3GF }, - { "TOSHIBA", "Satellite 1115*", NULL, NULL, "Toshiba Satellite 1115", XE3GF }, - { "TOSHIBA", "Toshiba 1115*", NULL, NULL, "Toshiba Satellite 1115", XE3GF }, - { "TOSHIBA", "Satellite 1900*", NULL, NULL, "Toshiba Satellite 1900", XE3GF }, - { "TOSHIBA", "Satellite 1905*", NULL, NULL, "Toshiba Satellite 1905", XE3GF }, - { "TOSHIBA", "Satellite 1950*", NULL, NULL, "Toshiba Satellite 1950", XE3GF }, - { "TOSHIBA", "Satellite 1955*", NULL, NULL, "Toshiba Satellite 1955", XE3GF }, - { "TOSHIBA", "Satellite 2430*", NULL, NULL, "Toshiba Satellite 2430", XE3GF }, - { "TOSHIBA", "Satellite 2435*", NULL, NULL, "Toshiba Satellite 2435", XE3GF }, - { "TOSHIBA", "Satellite 3000*", NULL, NULL, "Toshiba Satellite 3000", XE3GF }, - { "TOSHIBA", "Satellite 3005*", NULL, NULL, "Toshiba Satellite 3005", XE3GF }, - { "TOSHIBA", "Satellite P10*", NULL, NULL, "Toshiba Satellite P10", TSP10 }, - { "TOSHIBA", "Satellite P15*", NULL, NULL, "Toshiba Satellite P15", TSP10 }, - { "TOSHIBA", "Satellite P20*", NULL, NULL, "Toshiba Satellite P20", TSP10 }, - { "TOSHIBA", "Satellite M30X*", NULL, NULL, "Toshiba Satellite M30X", TSM30X }, - { "TOSHIBA", "Satellite M35X*", NULL, NULL, "Toshiba Satellite M35X", TSM30X }, - { "TOSHIBA", "Satellite M70*", NULL, NULL, "Toshiba Satellite M70", TSM30X }, - { "TOSHIBA", "Satellite M40*", NULL, NULL, "Toshiba Satellite M40", TSM40 }, - { "COMPAL", NULL, NULL, "ACL00", "Compal ACL00", XE3GF }, - { "COMPAL", NULL, NULL, "ACL10", "Compal ACL10", XE3GF }, - { "Acer", "Aspire 1400 series*", NULL, NULL, "Acer Aspire 1400 series", XE3GF }, - { "Acer", "Aspire 1350*", NULL, NULL, "Acer Aspire 1350", XE4500 }, - { "FUJITSU SIEMENS", "Amilo D-Series*", NULL, NULL, "Fujitsu-Siemens Amilo D series", AMILOD }, - /* This sentinel at the end catches all unsupported models */ - { NULL, NULL, NULL, NULL, NULL, NONE } -}; +/* Delimiters of the .features section wich holds all the omnibook_feature structs */ +extern struct omnibook_feature _features_start[]; +extern struct omnibook_feature _features_end[]; -struct omnibook_tc_t { - char *tc; - int ectype; -}; - -/* HP technology codes */ -static struct omnibook_tc_t omnibook_tc[] __initdata = { - /* technology code ectype */ - {"CI.", OB4150}, - {"CL.", OB4150}, - {"DC.", XE2}, - {"EA.", OB6000}, - {"EB.", OB6100}, - {"EG.", XE4500}, - {"FA.", OB500}, - {"FB.", OB510}, - {"GC.", XE3GC}, - {"GD.", XE3GC}, - {"GE.", XE3GC}, - {"GF.", XE3GF}, - {"IB.", XE3GF}, - {"IC.", XE3GF}, - {"ID.", XE3GF}, - {"KA.", XE4500}, - {"KB.", XE4500}, - {"KC.", XE4500}, - {"KD.", XE4500}, - {"KE.", XE4500}, - {"KE_KG.", XE4500}, - {"KF_KH.", XE4500}, - {NULL, NONE} -}; /* * Compare the saved DMI info at "index" with a string. @@ -360,10 +206,7 @@ static int procfile_write_dispatch(struct file *file, /* Make sure the string is \0 terminated */ kernbuf[count] = '\0'; -#ifdef OMNIBOOK_DEBUG - printk("Input string length is %u and is: [%s]\n", (unsigned int)count, - kernbuf); -#endif + retval = feature->write(kernbuf); if (retval == 0) retval = count; @@ -373,40 +216,6 @@ static int procfile_write_dispatch(struct file *file, return retval; } -/* - * Callback function for driver registering : - * Initialize the linked list of enabled features and call omnibook_init to populate it - */ -static int __init omnibook_probe(struct platform_device *dev) -{ - int i; - struct list_head *p; - struct omnibook_feature *feature; - - omnibook_available_feature = - kzalloc(sizeof(struct omnibook_feature), GFP_KERNEL); - if (!omnibook_available_feature) - return -ENOMEM; - INIT_LIST_HEAD(&omnibook_available_feature->list); - - for (i = 0; i < ARRAY_SIZE(omnibook_features); i++) { - if (!omnibook_features[i]->enabled) - continue; - if ((omnibook_ectype & omnibook_features[i]->ectypes) || (!omnibook_features[i]->ectypes)) - omnibook_init(omnibook_features[i]); - } - - printk(KERN_INFO "%s: Enabled features:",OMNIBOOK_MODULE_NAME); - list_for_each(p, &omnibook_available_feature->list) { - feature = list_entry(p, struct omnibook_feature, list); - if (feature->name) - printk(" %s", feature->name); - } - printk(".\n"); - - return 0; -} - /* * Initialise a feature and add it to the linked list of active features */ @@ -455,12 +264,60 @@ static int __init omnibook_init(struct omnibook_feature *feature) if (feature->write) proc_entry->write_proc = &procfile_write_dispatch; + proc_entry->owner = THIS_MODULE; } } list_add_tail(&feature->list, &omnibook_available_feature->list); return 0; } + +/* + * Callback function for driver registering : + * Initialize the linked list of enabled features and call omnibook_init to populate it + */ +static int __init omnibook_probe(struct platform_device *dev) +{ + int i; + struct list_head *p; + struct omnibook_feature *feature; + + + omnibook_available_feature = + kzalloc(sizeof(struct omnibook_feature), GFP_KERNEL); + if (!omnibook_available_feature) + return -ENOMEM; + INIT_LIST_HEAD(&omnibook_available_feature->list); + + for (i=0; i < _features_end - _features_start; i++ ) { + + feature = &_features_start[i]; + + if (!feature->enabled) + continue; + + if ((omnibook_ectype & feature->ectypes) || (!feature->ectypes)) { +/* printk("cursor is at: %p\n", (void*) feature); + if(feature->name) + printk("trying to init:%s\n",feature->name); + else + printk("trying to init nameless feature\n"); */ + + omnibook_init(feature); + } + } + + printk(KERN_INFO "%s: Enabled features:",OMNIBOOK_MODULE_NAME); + list_for_each(p, &omnibook_available_feature->list) { + feature = list_entry(p, struct omnibook_feature, list); + if (feature->name) + printk(" %s", feature->name); + } + printk(".\n"); + + return 0; +} + /* * Callback function for driver removal */ diff --git a/laptop.h b/laptop.h new file mode 100644 index 0000000..acc745f --- /dev/null +++ b/laptop.h @@ -0,0 +1,155 @@ +/* + * laptop.h -- Various structures about supported hardware + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * Written by Soós Péter , 2002-2004 + * Written by Mathieu Bérard , 2006 + */ + + +#define HP_SIGNATURE "Hewlett-Packard" + +struct omnibook_models_t { + /* DMI field matchers (table inputs) */ + char *sys_vendor; + char *product_name; + char *product_version; + char *board_name; + /* Table outputs */ + char *syslog_name; /* Name which will appear in the syslog */ + int ectype; /* Type of the embedded controller firmware, see omnibook.h and README */ +}; + +static struct omnibook_models_t omnibook_models[] __initdata = { + /* sys_vendor product_name product_version board_name syslog_name ectype */ + { NULL, "HP OmniBook PC*", "HP OmniBook XE3 GF*", NULL, NULL, XE3GF }, + { NULL, "HP OmniBook PC*", "HP OmniBook XT1000*", NULL, NULL, XE3GF }, + { NULL, "HP OmniBook PC*", "HP OmniBook XE2 DC*", NULL, NULL, XE2 }, + { NULL, "HP OmniBook PC*", "HP OmniBook XE3 GC*", NULL, NULL, XE3GC }, + /* HP Pavilion N5430 */ + { NULL, "HP OmniBook PC*", "HP OmniBook XE3 GD*", NULL, NULL, XE3GC }, + /* HP Pavilion N5415 */ + { NULL, "HP OmniBook PC*", "HP OmniBook XE3 GE*", NULL, NULL, XE3GC }, + { NULL, "HP OmniBook PC*", "HP OmniBook 500 FA*", NULL, NULL, OB500 }, + { NULL, "HP OmniBook PC*", "HP OmniBook 510 FB*", NULL, NULL, OB510 }, + { NULL, "HP OmniBook PC*", "HP OmniBook 4150*", NULL, NULL, OB4150 }, + { NULL, "HP OmniBook PC*", "HP OmniBook 900 B*", NULL, NULL, OB4150 }, + { NULL, "HP OmniBook PC*", "HP OmniBook 6000 EA*", NULL, NULL, OB6000 }, + { NULL, "HP OmniBook PC*", "HP OmniBook 6100 EB*", NULL, NULL, OB6100 }, + /* HP OmniBook xe4100 */ + { NULL, "HP OmniBook PC*", "HP OmniBook xe4000*", NULL, NULL, XE4500 }, + { NULL, "HP OmniBook PC*", "HP OmniBook xe4400*", NULL, NULL, XE4500 }, + { NULL, "HP OmniBook PC*", "HP OmniBook xe4500*", NULL, NULL, XE4500 }, + /* HP OmniBook vt6200 and xt6200 */ + { NULL, "HP OmniBook PC*", "HP OmniBook 6200 EG*", NULL, NULL, XE4500 }, + /* There are no model specific strings of some HP OmniBook XT1500 */ + { NULL, "HP OmniBook PC*", "HP OmniBook*", NULL, NULL, XE3GF }, + /* HP Pavilion ze4125 */ + { NULL, "HP NoteBook PC*", "HP NoteBook ze4000*", NULL, NULL, XE4500 }, + /* There are no model specific strings of some HP Pavilion xt155 and some HP Pavilion ze4100 */ + { NULL, "HP NoteBook PC*", "HP NoteBook PC*", NULL, NULL, XE4500 }, + /* There are no model specific strings of some HP nx9000 */ + { NULL, "HP Notebook PC*", "HP Notebook PC*", NULL, NULL, XE4500 }, + /* HP Pavilion ZU1155 and ZU1175 */ + { NULL, "HP Pavilion Notebook PC*", "HP Pavilion ZU1000 FA*", NULL, NULL, OB500 }, + /* HP Pavilion N5290 */ + { NULL, "HP Pavilion Notebook PC*", "HP Pavilion Notebook XE3 GC*", NULL, NULL, XE3GC }, + /* HP Pavilion N5441 */ + { NULL, "HP Pavilion Notebook PC*", "HP Pavilion Notebook Model GD*", NULL, NULL, XE3GC }, + /* HP Pavilion XH545 */ + { NULL, "HP Pavilion Notebook PC*", "HP Pavilion Notebook Model GE*", NULL, NULL, XE3GC }, + /* HP Pavilion ZT1141 */ + { NULL, "HP Pavilion Notebook PC*", "HP Pavilion Notebook ZT1000*", NULL, NULL, XE3GF }, + /* There are no model specific strings of some HP Pavilion ZT1175 and ZT1195 notebooks */ + { NULL, "HP Pavilion Notebook PC*", "HP Pavilion Notebook*", NULL, NULL, XE3GF }, + { NULL, "Pavilion ze4200*", NULL, NULL, "HP Pavilion ze4200 series", XE4500 }, + { NULL, "Pavilion ze4300*", NULL, NULL, "HP Pavilion ze4300 series", XE4500 }, + { NULL, "Pavilion ze8500*", NULL, NULL, "HP Pavilion ze8500 series", XE4500 }, + /* Compaq nx9000 */ + { NULL, "HP nx9000*", NULL, NULL, "HP Compaq nx9000", XE4500 }, + /* Compaq nx9005 */ + { NULL, "HP nx9005*", NULL, NULL, "HP Compaq nx9005", XE4500 }, + /* Compaq nx9010 */ + { NULL, "HP nx9010*", NULL, NULL, "HP Compaq nx9010", XE4500 }, + { "TOSHIBA", "S1000*", NULL, NULL, "Toshiba Satellite 1000", XE3GF }, + { "TOSHIBA", "S1005*", NULL, NULL, "Toshiba Satellite 1005", XE3GF }, + { "TOSHIBA", "S1110*", NULL, NULL, "Toshiba Satellite 1110", XE3GF }, + { "TOSHIBA", "S1115*", NULL, NULL, "Toshiba Satellite 1115", XE3GF }, + { "TOSHIBA", "S1900*", NULL, NULL, "Toshiba Satellite 1900", XE3GF }, + { "TOSHIBA", "S1905*", NULL, NULL, "Toshiba Satellite 1905", XE3GF }, + { "TOSHIBA", "S1950*", NULL, NULL, "Toshiba Satellite 1950", XE3GF }, + { "TOSHIBA", "S1955*", NULL, NULL, "Toshiba Satellite 1955", XE3GF }, + { "TOSHIBA", "S2430*", NULL, NULL, "Toshiba Satellite 2430", XE3GF }, + { "TOSHIBA", "S2435*", NULL, NULL, "Toshiba Satellite 2435", XE3GF }, + { "TOSHIBA", "S3000*", NULL, NULL, "Toshiba Satellite 3000", XE3GF }, + { "TOSHIBA", "S3005*", NULL, NULL, "Toshiba Satellite 3005", XE3GF }, + { "TOSHIBA", "Satellite 1000*", NULL, NULL, "Toshiba Satellite 1000", XE3GF }, + { "TOSHIBA", "Satellite 1005*", NULL, NULL, "Toshiba Satellite 1005", XE3GF }, + { "TOSHIBA", "Satellite 1110*", NULL, NULL, "Toshiba Satellite 1110", XE3GF }, + { "TOSHIBA", "Satellite 1115*", NULL, NULL, "Toshiba Satellite 1115", XE3GF }, + { "TOSHIBA", "Toshiba 1115*", NULL, NULL, "Toshiba Satellite 1115", XE3GF }, + { "TOSHIBA", "Satellite 1900*", NULL, NULL, "Toshiba Satellite 1900", XE3GF }, + { "TOSHIBA", "Satellite 1905*", NULL, NULL, "Toshiba Satellite 1905", XE3GF }, + { "TOSHIBA", "Satellite 1950*", NULL, NULL, "Toshiba Satellite 1950", XE3GF }, + { "TOSHIBA", "Satellite 1955*", NULL, NULL, "Toshiba Satellite 1955", XE3GF }, + { "TOSHIBA", "Satellite 2430*", NULL, NULL, "Toshiba Satellite 2430", XE3GF }, + { "TOSHIBA", "Satellite 2435*", NULL, NULL, "Toshiba Satellite 2435", XE3GF }, + { "TOSHIBA", "Satellite 3000*", NULL, NULL, "Toshiba Satellite 3000", XE3GF }, + { "TOSHIBA", "Satellite 3005*", NULL, NULL, "Toshiba Satellite 3005", XE3GF }, + { "TOSHIBA", "Satellite P10*", NULL, NULL, "Toshiba Satellite P10", TSP10 }, + { "TOSHIBA", "Satellite P15*", NULL, NULL, "Toshiba Satellite P15", TSP10 }, + { "TOSHIBA", "Satellite P20*", NULL, NULL, "Toshiba Satellite P20", TSP10 }, + { "TOSHIBA", "Satellite M30X*", NULL, NULL, "Toshiba Satellite M30X", TSM30X }, + { "TOSHIBA", "Satellite M35X*", NULL, NULL, "Toshiba Satellite M35X", TSM30X }, + { "TOSHIBA", "Satellite M70*", NULL, NULL, "Toshiba Satellite M70", TSM30X }, + { "TOSHIBA", "Satellite M40*", NULL, NULL, "Toshiba Satellite M40", TSM40 }, + { "COMPAL", NULL, NULL, "ACL00", "Compal ACL00", XE3GF }, + { "COMPAL", NULL, NULL, "ACL10", "Compal ACL10", XE3GF }, + { "Acer", "Aspire 1400 series*", NULL, NULL, "Acer Aspire 1400 series", XE3GF }, + { "Acer", "Aspire 1350*", NULL, NULL, "Acer Aspire 1350", XE4500 }, + { "FUJITSU SIEMENS", "Amilo D-Series*", NULL, NULL, "Fujitsu-Siemens Amilo D series", AMILOD }, + /* This sentinel at the end catches all unsupported models */ + { NULL, NULL, NULL, NULL, NULL, NONE } +}; + +struct omnibook_tc_t { + char *tc; + int ectype; +}; + +/* HP technology codes */ +static struct omnibook_tc_t omnibook_tc[] __initdata = { + /* technology code ectype */ + {"CI.", OB4150}, + {"CL.", OB4150}, + {"DC.", XE2}, + {"EA.", OB6000}, + {"EB.", OB6100}, + {"EG.", XE4500}, + {"FA.", OB500}, + {"FB.", OB510}, + {"GC.", XE3GC}, + {"GD.", XE3GC}, + {"GE.", XE3GC}, + {"GF.", XE3GF}, + {"IB.", XE3GF}, + {"IC.", XE3GF}, + {"ID.", XE3GF}, + {"KA.", XE4500}, + {"KB.", XE4500}, + {"KC.", XE4500}, + {"KD.", XE4500}, + {"KE.", XE4500}, + {"KE_KG.", XE4500}, + {"KF_KH.", XE4500}, + {NULL, NONE} +}; diff --git a/lcd.c b/lcd.c index 5a60913..aa09c15 100644 --- a/lcd.c +++ b/lcd.c @@ -36,12 +36,12 @@ static int omnibook_max_brightness; static struct backlight_device *omnibook_backlight_device; int omnibook_get_backlight(struct backlight_device *bd); -int omnibook_set_backlight(struct backlight_device *bd, int brgt); +int omnibook_set_backlight(struct backlight_device *bd); static struct backlight_properties omnibookbl_data = { .owner = THIS_MODULE, .get_brightness = omnibook_get_backlight, - .set_brightness = omnibook_set_backlight, + .update_status = omnibook_set_backlight, }; #endif @@ -130,9 +130,10 @@ int omnibook_get_backlight(struct backlight_device *bd) return omnibook_get_lcd_brightness(); } -int omnibook_set_backlight(struct backlight_device *bd, int brgt) +int omnibook_set_backlight(struct backlight_device *bd) { - return omnibook_set_lcd_brightness(brgt); + int intensity = bd->props->brightness; + return omnibook_set_lcd_brightness(intensity); } #endif @@ -208,7 +209,7 @@ static void omnibook_brightness_cleanup(void) #endif } -struct omnibook_feature lcd_feature = { +static struct omnibook_feature __declared_feature lcd_feature = { .name = "lcd", .enabled = 1, .read = omnibook_brightness_read, diff --git a/muteled.c b/muteled.c new file mode 100644 index 0000000..5938a62 --- /dev/null +++ b/muteled.c @@ -0,0 +1,100 @@ +/* + * mutled.c -- MUTE LED control + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * Written by Thomas Perl , 2006 + */ + +#ifdef OMNIBOOK_STANDALONE +#include "omnibook.h" +#else +#include +#endif + +#include "ec.h" + +/* There is no information about reading MUTE LED status */ +static int omnibook_muteled_enabled = 0; + +static int omnibook_muteled_on(void) +{ + if (omnibook_kbc_command(OMNIBOOK_KBC_CONTROL_CMD, OMNIBOOK_KBC_CMD_MUTELED_ON)) { + printk(KERN_ERR "%s: failed muteled on command.\n", OMNIBOOK_MODULE_NAME); + return -EIO; + } + omnibook_muteled_enabled = 1; + return 0; +} + +static int omnibook_muteled_off(void) +{ + if (omnibook_kbc_command(OMNIBOOK_KBC_CONTROL_CMD, OMNIBOOK_KBC_CMD_MUTELED_OFF)) { + printk(KERN_ERR "%s: failed muteled off command.\n", OMNIBOOK_MODULE_NAME); + return -EIO; + } + omnibook_muteled_enabled = 0; + return 0; +} + + +static int omnibook_muteled_disable(void) +{ + omnibook_muteled_off(); + return 0; +} + +static int omnibook_muteled_enable(void) +{ + omnibook_muteled_on(); + return 0; +} + +static int omnibook_muteled_read(char *buffer) +{ + int len = 0; + + len += sprintf(buffer+len, "The mute LED is %s\n", (omnibook_muteled_enabled) ? "on" : "off"); + + return len; +} + +static int omnibook_muteled_write(char *buffer) +{ + int retval; + + switch (*buffer) { + case '0': + if ((retval = omnibook_muteled_disable())); + return retval; + break; + case '1': + if ((retval = omnibook_muteled_enable())); + return retval; + break; + default: + return -EINVAL; + } + return 0; +} + + +static struct omnibook_feature __declared_feature muteled_feature = { + .name = "muteled", + .enabled = 1, + .read = omnibook_muteled_read, + .write = omnibook_muteled_write, + .ectypes = XE4500, +}; + +module_param_named(muteled, muteled_feature.enabled, int, S_IRUGO); +MODULE_PARM_DESC(muteled, "Use 0 to disable, 1 to enable 'Audo Mute' LED control"); + diff --git a/omnibook.h b/omnibook.h index 711ceba..9f9d9b5 100644 --- a/omnibook.h +++ b/omnibook.h @@ -17,6 +17,8 @@ #include #include +#include +#include /* * Module informations @@ -52,7 +54,6 @@ extern int omnibook_ectype; */ struct omnibook_feature { - struct list_head list; char *name; /* Name */ char *proc_entry; /* Specify proc entry relative to /proc (will be omnibook/name otherwise) */ int enabled; /* Set from module parameter */ @@ -63,6 +64,7 @@ struct omnibook_feature { int (*suspend) (void); /* PM Suspend function */ int (*resume) (void); /* PM Resume function */ int ectypes; /* Type(s) of EC we support for this feature (bitmask) */ + struct list_head list; }; struct omnibook_battery_info { @@ -92,14 +94,18 @@ extern int omnibook_get_ac(void); extern int omnibook_get_battery_status(int num, struct omnibook_battery_state *battstat); extern int set_omnibook_param(const char *val, struct kernel_param *kp); + +#define __declared_feature __attribute__ (( __section__(".features"), __aligned__(__alignof__ (struct omnibook_feature)))) __attribute_used__ + + /* * Configuration for standalone compilation: - * -Register as backlight depends on kernel config + * -Register as backlight depends on kernel config (requires 2.6.17+ interface) * -APM emulation is disabled by default */ #ifdef OMNIBOOK_STANDALONE -#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE +#if defined(CONFIG_BACKLIGHT_DEVICE) && (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)) #define CONFIG_OMNIBOOK_BACKLIGHT #else #undef CONFIG_OMNIBOOK_BACKLIGHT diff --git a/onetouch.c b/onetouch.c index 0241a3a..1cc147b 100644 --- a/onetouch.c +++ b/onetouch.c @@ -23,7 +23,7 @@ #include "ec.h" /* There is no information about reading OneTouch status */ -int omnibook_onetouch_enabled = 0; +static int omnibook_onetouch_enabled = 0; static int omnibook_onetouch_on(void) { @@ -165,7 +165,7 @@ static void omnibook_onetouch_cleanup(void) omnibook_onetouch_disable(); } -struct omnibook_feature onetouch_feature = { +static struct omnibook_feature __declared_feature onetouch_feature = { .name = "onetouch", .enabled = 1, .read = omnibook_onetouch_read, diff --git a/sections.lds b/sections.lds new file mode 100644 index 0000000..c06ae7e --- /dev/null +++ b/sections.lds @@ -0,0 +1,8 @@ +SECTIONS{ + .features : + { + _features_start = .; + *(.features) + _features_end = .; + } +} diff --git a/temperature.c b/temperature.c index 6572867..5a72268 100644 --- a/temperature.c +++ b/temperature.c @@ -88,7 +88,7 @@ int omnibook_temperature_read(char *buffer) return len; } -struct omnibook_feature temperature_feature = { +static struct omnibook_feature __declared_feature temperature_feature = { .name = "temperature", .enabled = 1, .read = omnibook_temperature_read, diff --git a/touchpad.c b/touchpad.c index 8c37c48..e4f2d3b 100644 --- a/touchpad.c +++ b/touchpad.c @@ -151,7 +151,7 @@ static void omnibook_touchpad_cleanup(void) omnibook_touchpad_enable(); } -struct omnibook_feature touchpad_feature = { +static struct omnibook_feature __declared_feature touchpad_feature = { .name = "touchpad", .enabled = 1, .read = omnibook_touchpad_read, diff --git a/watch.c b/watch.c deleted file mode 100644 index f34b558..0000000 --- a/watch.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * watch.c - Watch a specific ioport/iomem/ec register - * - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * Written by Mathieu Bérard , 2006 - */ - -#ifdef OMNIBOOK_STANDALONE -#include "omnibook.h" -#else -#include -#endif - -#include "ec.h" - -enum { - BAD, - EC, - PIO, - MMIO, -}; - -static u32 addr = 0; -static int addr_type = BAD; - -static int watch_read(char *buffer) -{ - int len = 0; - u8 v; - - switch (addr_type) { - case BAD: - len += sprintf(buffer + len, "Please first write to this file and address to watch\n"); - len += sprintf(buffer + len, "ex: 'TYPE 0x2f' where TYPE={EC,PIO,MMIO}\n"); - return len; - case EC: - omnibook_ec_read((u8) addr, &v); - break; - case PIO: - omnibook_io_read(addr, &v); - break; - case MMIO: - omnibook_mem_read(addr, &v); - break; - } - len += sprintf(buffer + len, "%02x\n",v ); - - return len; -} - -static int watch_write(char *buffer) -{ - int retval; - u32 value; - char type[5]; - - retval = sscanf(buffer, "%4s%x", type, &value); - - if (retval != 2) - return -EINVAL; - - if (strncmp(type,"EC",2) == 0) - addr_type = EC; - else if (strncmp(type,"PIO",3) == 0) - addr_type = PIO; - else if (strncmp(type,"MMIO",4) == 0) - addr_type = MMIO; - else - return -EINVAL; - - if ((value > 0xff) && (addr_type == EC)) - return -EINVAL; - else if ((value > 0xffff) && (addr_type == PIO)) - return -EINVAL; - else - addr = value; - - return 0; -} - -struct omnibook_feature watch_feature = { - .name = "watch", - .enabled = 0, - .read = watch_read, - .write = watch_write, -}; - - -module_param_named(watch, watch_feature.enabled, int, S_IRUGO); -MODULE_PARM_DESC(watch, "Use 0 to disable, 1 to enable register watching (DANGEROUS)"); - -/* End of file */