[Midnightbsd-cvs] src: dev/acpi_support: merge changes.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Nov 23 11:18:43 EST 2008


Log Message:
-----------
merge changes.  support newer hardware

Modified Files:
--------------
    src/sys/dev/acpi_support:
        acpi_asus.c (r1.1.1.1 -> r1.2)
        acpi_fujitsu.c (r1.1.1.1 -> r1.2)
        acpi_ibm.c (r1.1.1.1 -> r1.2)
        acpi_panasonic.c (r1.1.1.1 -> r1.2)
        acpi_sony.c (r1.1.1.1 -> r1.2)
        acpi_toshiba.c (r1.1.1.1 -> r1.2)

Added Files:
-----------
    src/sys/dev/acpi_support:
        acpi_aiboost.c (r1.1)

-------------- next part --------------
Index: acpi_ibm.c
===================================================================
RCS file: /home/cvs/src/sys/dev/acpi_support/acpi_ibm.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sys/dev/acpi_support/acpi_ibm.c -L sys/dev/acpi_support/acpi_ibm.c -u -r1.1.1.1 -r1.2
--- sys/dev/acpi_support/acpi_ibm.c
+++ sys/dev/acpi_support/acpi_ibm.c
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_ibm.c,v 1.7.2.2 2005/11/10 11:22:11 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_ibm.c,v 1.14.2.1 2007/11/02 18:54:09 jhb Exp $");
 
 /*
  * Driver for extra ACPI-controlled gadgets found on IBM ThinkPad laptops.
@@ -64,8 +64,9 @@
 #define ACPI_IBM_METHOD_BLUETOOTH	8
 #define ACPI_IBM_METHOD_WLAN		9
 #define ACPI_IBM_METHOD_FANSPEED	10
-#define ACPI_IBM_METHOD_FANSTATUS	11
-#define ACPI_IBM_METHOD_THERMAL		12
+#define ACPI_IBM_METHOD_FANLEVEL	11
+#define ACPI_IBM_METHOD_FANSTATUS	12
+#define ACPI_IBM_METHOD_THERMAL		13
 
 /* Hotkeys/Buttons */
 #define IBM_RTC_HOTKEY1			0x64
@@ -94,6 +95,8 @@
 #define   IBM_EC_MASK_VOL		0xf
 #define   IBM_EC_MASK_MUTE		(1 << 6)
 #define IBM_EC_FANSTATUS		0x2F
+#define   IBM_EC_MASK_FANLEVEL		0x3f
+#define   IBM_EC_MASK_FANDISENGAGED	(1 << 6)
 #define   IBM_EC_MASK_FANSTATUS		(1 << 7)
 #define IBM_EC_FANSPEED			0x84
 
@@ -229,10 +232,16 @@
 		.access		= CTLTYPE_INT | CTLFLAG_RD
 	},
 	{
+		.name		= "fan_level",
+		.method		= ACPI_IBM_METHOD_FANLEVEL,
+		.description	= "Fan level",
+		.access		= CTLTYPE_INT | CTLFLAG_RW
+	},
+	{
 		.name		= "fan",
 		.method		= ACPI_IBM_METHOD_FANSTATUS,
 		.description	= "Fan enable",
-		.access		= CTLTYPE_INT | CTLFLAG_RD
+		.access		= CTLTYPE_INT | CTLFLAG_RW
 	},
 
 	{ NULL, 0, NULL, 0 }
@@ -276,7 +285,7 @@
 DRIVER_MODULE(acpi_ibm, acpi, acpi_ibm_driver, acpi_ibm_devclass,
 	      0, 0);
 MODULE_DEPEND(acpi_ibm, acpi, 1, 1, 1);
-static char    *ibm_ids[] = {"IBM0057", "IBM0068", NULL};
+static char    *ibm_ids[] = {"IBM0068", NULL};
 
 static void
 ibm_led(void *softc, int onoff)
@@ -291,8 +300,7 @@
 	sc->led_busy = 1;
 	sc->led_state = onoff;
 
-	AcpiOsQueueForExecution(OSD_PRIORITY_LO,
-	    (void *)ibm_led_task, sc);
+	AcpiOsExecute(OSL_NOTIFY_HANDLER, (void *)ibm_led_task, sc);
 }
 
 static void
@@ -404,7 +412,7 @@
 
 	/* Hook up light to led(4) */
 	if (sc->light_set_supported)
-		sc->led_dev = led_create(ibm_led, sc, "thinklight");
+		sc->led_dev = led_create_state(ibm_led, sc, "thinklight", sc->light_val);
 
 	return (0);
 }
@@ -590,6 +598,22 @@
 		}
 		break;
 
+	case ACPI_IBM_METHOD_FANLEVEL:
+		/*
+		 * The IBM_EC_FANSTATUS register works as follows:
+		 * Bit 0-5 indicate the level at which the fan operates. Only
+		 *       values between 0 and 7 have an effect. Everything
+		 *       above 7 is treated the same as level 7
+		 * Bit 6 overrides the fan speed limit if set to 1
+		 * Bit 7 indicates at which mode the fan operates:
+		 *       manual (0) or automatic (1)
+		 */
+		if (!sc->fan_handle) {
+			ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
+			val = val_ec & IBM_EC_MASK_FANLEVEL;
+		}
+		break;
+
 	case ACPI_IBM_METHOD_FANSTATUS:
 		if (!sc->fan_handle) {
 			ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
@@ -731,6 +755,32 @@
 		val = (arg == 1) ? sc->wlan_bt_flags | IBM_NAME_MASK_BT : sc->wlan_bt_flags & (~IBM_NAME_MASK_BT);
 		return acpi_SetInteger(sc->handle, IBM_NAME_WLAN_BT_SET, val);
 		break;
+
+	case ACPI_IBM_METHOD_FANLEVEL:
+		if (arg < 0 || arg > 7)
+			return (EINVAL);
+
+		if (!sc->fan_handle) {
+			/* Read the current fanstatus */
+			ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
+			val = val_ec & (~IBM_EC_MASK_FANLEVEL);
+
+			return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_FANSTATUS, val | arg, 1);
+		}
+		break;
+
+	case ACPI_IBM_METHOD_FANSTATUS:
+		if (arg < 0 || arg > 1)
+			return (EINVAL);
+
+		if (!sc->fan_handle) {
+			/* Read the current fanstatus */
+			ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
+
+			return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_FANSTATUS,
+				(arg == 1) ? (val_ec | IBM_EC_MASK_FANSTATUS) : (val_ec & (~IBM_EC_MASK_FANSTATUS)), 1);
+		}
+		break;
 	}
 
 	return (0);
@@ -760,7 +810,8 @@
 
 	case ACPI_IBM_METHOD_THINKLIGHT:
 		sc->cmos_handle = NULL;
-		sc->light_get_supported = ACPI_SUCCESS(acpi_GetInteger(sc->ec_handle, IBM_NAME_KEYLIGHT, &dummy));
+		sc->light_get_supported = ACPI_SUCCESS(acpi_GetInteger(
+		    sc->ec_handle, IBM_NAME_KEYLIGHT, &sc->light_val));
 
 		if ((ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\UCMS", &sc->light_handle)) ||
 		     ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\CMOS", &sc->light_handle)) ||
@@ -781,12 +832,15 @@
 		sc->light_set_supported = (sc->light_handle &&
 		    ACPI_FAILURE(AcpiGetHandle(sc->ec_handle, "LEDB", &ledb_handle)));
 
-		if (sc->light_get_supported || sc->light_set_supported) {
+		if (sc->light_get_supported)
+			return (TRUE);
+
+		if (sc->light_set_supported) {
 			sc->light_val = 0;
 			return (TRUE);
 		}
-		else
-			return (FALSE);
+
+		return (FALSE);
 
 	case ACPI_IBM_METHOD_BLUETOOTH:
 	case ACPI_IBM_METHOD_WLAN:
@@ -804,6 +858,7 @@
 		     ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\FSPD", &sc->fan_handle)));
 		return (TRUE);
 
+	case ACPI_IBM_METHOD_FANLEVEL:
 	case ACPI_IBM_METHOD_FANSTATUS:
 		/* 
 		 * Fan status is only supported on those models,
@@ -867,9 +922,8 @@
 
 	ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, notify);
 
-	printf("IBM:NOTIFY:%x\n", notify);
 	if (notify != 0x80)
-		printf("Unknown notify\n");
+		device_printf(dev, "Unknown notify\n");
 
 	for (;;) {
 		acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_EVENTS_GET, &event);
@@ -877,14 +931,13 @@
 		if (event == 0)
 			break;
 
-		printf("notify:%x\n", event);
 
 		type = (event >> 12) & 0xf;
 		arg = event & 0xfff;
 		switch (type) {
 		case 1:
 			if (!(sc->events_availmask & (1 << (arg - 1)))) {
-				printf("Unknown key %d\n", arg);
+				device_printf(dev, "Unknown key %d\n", arg);
 				break;
 			}
 
Index: acpi_asus.c
===================================================================
RCS file: /home/cvs/src/sys/dev/acpi_support/acpi_asus.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sys/dev/acpi_support/acpi_asus.c -L sys/dev/acpi_support/acpi_asus.c -u -r1.1.1.1 -r1.2
--- sys/dev/acpi_support/acpi_asus.c
+++ sys/dev/acpi_support/acpi_asus.c
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_asus.c,v 1.24.2.1 2005/11/10 11:22:11 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_asus.c,v 1.30 2007/06/02 21:10:00 philip Exp $");
 
 /*
  * Driver for extra ACPI-controlled gadgets (hotkeys, leds, etc) found on
@@ -146,6 +146,42 @@
 		.disp_set	= "SDSP"
 	},
 	{
+		.name           = "A3N",
+		.mled_set       = "MLED",
+		.bled_set       = "BLED",
+		.wled_set       = "WLED",
+		.lcd_get        = NULL,
+		.lcd_set        = "\\_SB.PCI0.SBRG.EC0._Q10",
+		.brn_set        = "SPLV",
+		.brn_get        = "SDSP",
+		.disp_set       = "SDSP",
+		.disp_get       = "\\_SB.PCI0.P0P3.VGA.GETD"
+	},
+	{
+		.name		= "A4D",
+		.mled_set	= "MLED",
+		.brn_up		= "\\_SB_.PCI0.SBRG.EC0._Q0E",
+		.brn_dn		= "\\_SB_.PCI0.SBRG.EC0._Q0F",
+		.brn_get	= "GPLV",
+		.brn_set	= "SPLV",
+#ifdef notyet
+		.disp_get	= "\\_SB_.PCI0.SBRG.EC0._Q10",
+		.disp_set	= "\\_SB_.PCI0.SBRG.EC0._Q11"
+#endif
+	},
+	{
+		.name		= "A6V",
+		.bled_set	= "BLED",
+		.mled_set	= "MLED",
+		.wled_set	= "WLED",
+		.lcd_get	= NULL,
+		.lcd_set	= "\\_SB.PCI0.SBRG.EC0._Q10",
+		.brn_get	= "GPLV",
+		.brn_set	= "SPLV",
+		.disp_get	= "\\_SB.PCI0.P0P3.VGA.GETD",
+		.disp_set	= "SDSP"
+	},
+	{
 		.name		= "D1x",
 		.mled_set	= "MLED",
 		.lcd_get	= "\\GP11",
@@ -287,6 +323,16 @@
 		.disp_get	= "\\_SB.PCI0.P0P1.VGA.GETD",
 		.disp_set	= "SDSP"
 	},
+	{
+		.name		= "W5A",
+		.bled_set	= "BLED",
+		.lcd_get	= "\\BKLT",
+		.lcd_set	= "\\_SB.PCI0.SBRG.EC0._Q10",
+		.brn_get	= "GPLV",
+		.brn_set	= "SPLV",
+		.disp_get	= "\\_SB.PCI0.P0P2.VGA.GETD",
+		.disp_set	= "SDSP"
+	},
 
 	{ .name = NULL }
 };
@@ -409,7 +455,7 @@
 		ACPI_STATUS		status;
 		ACPI_TABLE_HEADER	th;
 
-		status = AcpiGetTableHeader(ACPI_TABLE_DSDT, 1, &th);
+		status = AcpiGetTableHeader(ACPI_SIG_DSDT, 0, &th);
 		if (ACPI_FAILURE(status)) {
 			device_printf(dev, "Unsupported (Samsung?) laptop\n");
 			AcpiOsFree(Buf.Pointer);
@@ -686,8 +732,7 @@
 	led->busy = 1;
 	led->state = state;
 
-	AcpiOsQueueForExecution(OSD_PRIORITY_LO,
-	    (void *)acpi_asus_led_task, led);
+	AcpiOsExecute(OSL_NOTIFY_HANDLER, (void *)acpi_asus_led_task, led);
 }
 
 static int
Index: acpi_panasonic.c
===================================================================
RCS file: /home/cvs/src/sys/dev/acpi_support/acpi_panasonic.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sys/dev/acpi_support/acpi_panasonic.c -L sys/dev/acpi_support/acpi_panasonic.c -u -r1.1.1.1 -r1.2
--- sys/dev/acpi_support/acpi_panasonic.c
+++ sys/dev/acpi_support/acpi_panasonic.c
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_panasonic.c,v 1.8.2.1 2005/11/10 11:22:11 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_panasonic.c,v 1.13 2007/06/17 04:40:33 mjacob Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -79,6 +79,7 @@
 static int	acpi_panasonic_probe(device_t dev);
 static int	acpi_panasonic_attach(device_t dev);
 static int	acpi_panasonic_detach(device_t dev);
+static void	acpi_panasonic_shutdown(device_t dev);
 static int	acpi_panasonic_sysctl(SYSCTL_HANDLER_ARGS);
 static ACPI_INTEGER acpi_panasonic_sinf(ACPI_HANDLE h, ACPI_INTEGER index);
 static void	acpi_panasonic_sset(ACPI_HANDLE h, ACPI_INTEGER index,
@@ -114,6 +115,7 @@
 	DEVMETHOD(device_probe,		acpi_panasonic_probe),
 	DEVMETHOD(device_attach,	acpi_panasonic_attach),
 	DEVMETHOD(device_detach,	acpi_panasonic_detach),
+	DEVMETHOD(device_shutdown,	acpi_panasonic_shutdown),
 
 	{0, 0}
 };
@@ -181,7 +183,7 @@
 	}
 #endif
 
-        /* Handle notifies */
+	/* Handle notifies */
 	status = AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
 	    acpi_panasonic_notify, sc);
 	if (ACPI_FAILURE(status)) {
@@ -218,6 +220,18 @@
 	return (0);
 }
 
+static void
+acpi_panasonic_shutdown(device_t dev)
+{
+	struct acpi_panasonic_softc *sc;
+	int mute;
+
+	/* Mute the main audio during reboot to prevent static burst to speaker. */
+	sc = device_get_softc(dev);
+	mute = 1;
+	hkey_sound_mute(sc->handle, HKEY_SET, &mute);
+}
+
 static int
 acpi_panasonic_sysctl(SYSCTL_HANDLER_ARGS)
 {
@@ -230,7 +244,7 @@
 	function = oidp->oid_arg2;
 	handler = sysctl_table[function].handler;
 
-        /* Get the current value from the appropriate function. */
+	/* Get the current value from the appropriate function. */
 	ACPI_SERIAL_BEGIN(panasonic);
 	error = handler(sc->handle, HKEY_GET, &arg);
 	if (error != 0)
@@ -413,8 +427,11 @@
 acpi_panasonic_hkey_action(struct acpi_panasonic_softc *sc, ACPI_HANDLE h,
     UINT32 key)
 {
+	struct acpi_softc *acpi_sc;
 	int arg, max, min;
 
+	acpi_sc = acpi_device_get_parent_softc(sc->dev);
+
 	ACPI_SERIAL_ASSERT(panasonic);
 	switch (key) {
 	case 1:
@@ -450,6 +467,10 @@
 			arg = 1;
 		hkey_sound_mute(h, HKEY_SET, &arg);
 		break;
+	case 7:
+		/* Suspend. */
+		acpi_event_sleep_button_sleep(acpi_sc);
+		break;
 	}
 }
 
@@ -457,7 +478,7 @@
 acpi_panasonic_notify(ACPI_HANDLE h, UINT32 notify, void *context)
 {
 	struct acpi_panasonic_softc *sc;
-	UINT32 key;
+	UINT32 key = 0;
 
 	sc = (struct acpi_panasonic_softc *)context;
 
Index: acpi_sony.c
===================================================================
RCS file: /home/cvs/src/sys/dev/acpi_support/acpi_sony.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sys/dev/acpi_support/acpi_sony.c -L sys/dev/acpi_support/acpi_sony.c -u -r1.1.1.1 -r1.2
--- sys/dev/acpi_support/acpi_sony.c
+++ sys/dev/acpi_support/acpi_sony.c
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_sony.c,v 1.8.2.1 2005/11/10 11:22:11 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_sony.c,v 1.10 2006/11/01 03:45:24 kevlo Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -67,8 +67,8 @@
 	{ "cmi", "GCMI", "SCMI", "????"},
 #endif
 	{ "wdp", "GWDP", NULL, "?????"},
-	{ "cdp", "GCDP", "CDPW", "??????"},  /*shares [\GL03]&0x8 flag*/
-	{NULL, NULL,NULL}
+	{ "cdp", "GCDP", "CDPW", "CD Power"},  /*shares [\GL03]&0x8 flag*/
+	{ NULL, NULL, NULL }
 };
 
 static int	acpi_sony_probe(device_t dev);
Index: acpi_fujitsu.c
===================================================================
RCS file: /home/cvs/src/sys/dev/acpi_support/acpi_fujitsu.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sys/dev/acpi_support/acpi_fujitsu.c -L sys/dev/acpi_support/acpi_fujitsu.c -u -r1.1.1.1 -r1.2
--- sys/dev/acpi_support/acpi_fujitsu.c
+++ sys/dev/acpi_support/acpi_fujitsu.c
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2002 Sean Bullington <seanATstalker.org>
- *               2003-2005 Anish Mistry <amistry at am-productions.biz>
+ *               2003-2006 Anish Mistry <amistry at am-productions.biz>
  *               2004 Mark Santcroos <marks at ripe.net>
  * All Rights Reserved.
  *
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_fujitsu.c,v 1.2.2.1 2005/11/10 11:22:11 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_fujitsu.c,v 1.5 2007/03/22 18:16:39 jkim Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -44,11 +44,8 @@
 #define _COMPONENT	ACPI_OEM
 ACPI_MODULE_NAME("Fujitsu")
 
-/* Change and update bits for the buttons */
-#define MOUSE_UPDATED_BIT	0x80000000
+/* Change and update bits for the hotkeys */
 #define VOLUME_MUTE_BIT		0x40000000
-#define VOLUME_CHANGE_BIT	0x80000000
-#define BRIGHTNESS_CHANGE_BIT	0x80000000
 
 /* Values of settings */
 #define GENERAL_SETTING_BITS	0x0fffffff
@@ -57,9 +54,20 @@
 #define BRIGHTNESS_SETTING_BITS	GENERAL_SETTING_BITS
 
 /* Possible state changes */
-#define VOLUME_CHANGED	1
-#define BRIGHT_CHANGED	2
-#define MOUSE_CHANGED	3
+/*
+ * These are NOT arbitrary values.  They are the
+ * GHKS return value from the device that says which
+ * hotkey is active.  They should match up with a bit
+ * from the GSIF bitmask.
+ */
+#define BRIGHT_CHANGED	0x01
+#define VOLUME_CHANGED	0x04
+#define MOUSE_CHANGED	0x08
+/*
+ * It is unknown which hotkey this bit is supposed to indicate, but
+ * according to values from GSIF this is a valid flag.
+ */
+#define UNKNOWN_CHANGED	0x10
 
 /* sysctl values */
 #define FN_MUTE			0
@@ -72,6 +80,10 @@
 #define METHOD_GMOU	2
 #define METHOD_GVOL	3
 #define METHOD_MUTE	4
+#define METHOD_RBLL	5
+#define METHOD_RVOL	6
+#define METHOD_GSIF	7
+#define METHOD_GHKS	8
 
 /* Notify event */
 #define	ACPI_NOTIFY_STATUS_CHANGED	0x80
@@ -83,6 +95,7 @@
 struct int_nameval {
 	char	*name;
 	int	value;
+	int	exists;
 };
 
 /*
@@ -95,12 +108,13 @@
 	/* Control methods */
 	struct int_nameval	_sta,	/* unused */
 				gbll,	/* brightness */
-				ghks,	/* unused */
+				ghks,	/* hotkey selector */
+				gbuf,	/* unused (buffer?) */
 				gmou,	/* mouse */
-				gsif,	/* unused */
+				gsif,	/* function key bitmask */
 				gvol,	/* volume */
-				rbll,	/* unused */
-				rvol;	/* unused */
+				rbll,	/* number of brightness levels (radix) */
+				rvol;	/* number of volume levels (radix) */
 
 	/* State variables */
 	uint8_t		bIsMuted;	/* Is volume muted */
@@ -126,6 +140,7 @@
 /* Utility function declarations */
 static uint8_t acpi_fujitsu_update(struct acpi_fujitsu_softc *sc);
 static uint8_t acpi_fujitsu_init(struct acpi_fujitsu_softc *sc);
+static uint8_t acpi_fujitsu_check_hardware(struct acpi_fujitsu_softc *sc);
 
 /* Driver/Module specific structure definitions. */
 static device_method_t acpi_fujitsu_methods[] = {
@@ -144,13 +159,13 @@
 	sizeof(struct acpi_fujitsu_softc),
 };
 
-/* Prototype for function buttons for getting/setting a value. */
+/* Prototype for function hotkeys for getting/setting a value. */
 static int acpi_fujitsu_method_get(struct acpi_fujitsu_softc *sc, int method);
 static int acpi_fujitsu_method_set(struct acpi_fujitsu_softc *sc, int method, int value);
 
 static char *fujitsu_ids[] = { "FUJ02B1", NULL };
 
-ACPI_SERIAL_DECL(fujitsu, "Fujitsu Function Buttons");
+ACPI_SERIAL_DECL(fujitsu, "Fujitsu Function Hotkeys");
 
 /* sysctl names and function calls */
 static struct {
@@ -178,6 +193,16 @@
 		.method		= METHOD_GVOL,
 		.description	= "Speakers/headphones volume level"
 	},
+	{
+		.name		= "volume_radix",
+		.method		= METHOD_RVOL,
+		.description	= "Number of volume level steps"
+	},
+	{
+		.name		= "lcd_brightness_radix",
+		.method		= METHOD_RBLL,
+		.description	= "Number of brightness level steps"
+	},
 
 	{ NULL, 0, NULL }
 };
@@ -191,13 +216,16 @@
 static int
 acpi_fujitsu_probe(device_t dev)
 {
+	char *name;
+	char buffer[64];
 
-	if (acpi_disabled("fujitsu") ||
-	    ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids) == NULL ||
-	    device_get_unit(dev) != 0)
+	name = ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids);
+	if (acpi_disabled("fujitsu") || name == NULL ||
+	    device_get_unit(dev) > 1)
 		return (ENXIO);
 
-	device_set_desc(dev, "Fujitsu Function Buttons");
+	sprintf(buffer, "Fujitsu Function Hotkeys %s", name);
+	device_set_desc_copy(dev, buffer);
 
 	return (0);
 }
@@ -217,10 +245,10 @@
 	AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
 	    acpi_fujitsu_notify_handler, sc);
 
-	/* Snag our default values for the buttons / button states. */
+	/* Snag our default values for the hotkys / hotkey states. */
 	ACPI_SERIAL_BEGIN(fujitsu);
 	if (!acpi_fujitsu_init(sc))
-		device_printf(dev, "Couldn't initialize button states!\n");
+		device_printf(dev, "Couldn't initialize hotkey states!\n");
 	ACPI_SERIAL_END(fujitsu);
 
 	return (0);
@@ -251,10 +279,11 @@
 	 */
 	ACPI_SERIAL_BEGIN(fujitsu);
 
-	status = acpi_SetInteger(sc->handle, "SMOU", 1);
-	if (ACPI_FAILURE(status))
-		device_printf(sc->dev, "Couldn't enable pointer\n");
-
+	if(sc->gmou.exists) {
+		status = acpi_SetInteger(sc->handle, "SMOU", 1);
+		if (ACPI_FAILURE(status))
+			device_printf(sc->dev, "Couldn't enable pointer\n");
+	}
 	ACPI_SERIAL_END(fujitsu);
 
 	return (0);
@@ -291,7 +320,7 @@
 
 	switch (notify) {
 	case ACPI_NOTIFY_STATUS_CHANGED:
-		AcpiOsQueueForExecution(OSD_PRIORITY_LO,
+		AcpiOsExecute(OSL_NOTIFY_HANDLER,
 		    acpi_fujitsu_notify_status_changed, sc);
 		break;
 	default:
@@ -316,13 +345,13 @@
 
 /*
  * Initializes the names of the ACPI control methods and grabs
- * the current state of all of the ACPI buttons into the softc.
+ * the current state of all of the ACPI hotkeys into the softc.
  */
 static uint8_t
 acpi_fujitsu_init(struct acpi_fujitsu_softc *sc)
 {
 	struct acpi_softc *acpi_sc;
-	int i;
+	int i, exists;
 
 	ACPI_SERIAL_ASSERT(fujitsu);
 
@@ -333,9 +362,14 @@
 	sc->gmou.name = "GMOU";
 	sc->gsif.name = "GSIF";
 	sc->gvol.name = "GVOL";
+	sc->ghks.name = "GHKS";
+	sc->gsif.name = "GSIF";
 	sc->rbll.name = "RBLL";
 	sc->rvol.name = "RVOL";
 
+	/* Determine what hardware functionality is available */
+	acpi_fujitsu_check_hardware(sc);
+
 	/* Build the sysctl tree */
 	acpi_sc = acpi_device_get_parent_softc(sc->dev);
 	sysctl_ctx_init(&sc->sysctl_ctx);
@@ -344,6 +378,31 @@
 	    OID_AUTO, "fujitsu", CTLFLAG_RD, 0, "");
 
 	for (i = 0; sysctl_table[i].name != NULL; i++) {
+		exists = 0;
+		switch(sysctl_table[i].method) {
+			case METHOD_GMOU:
+				exists = sc->gmou.exists;
+				break;
+			case METHOD_GBLL:
+				exists = sc->gbll.exists;
+				break;
+			case METHOD_GVOL:
+			case METHOD_MUTE:
+				exists = sc->gvol.exists;
+				break;
+			case METHOD_RVOL:
+				exists = sc->rvol.exists;
+				break;
+			case METHOD_RBLL:
+				exists = sc->rbll.exists;
+				break;
+			default:
+				/* Allow by default */
+				exists = 1;
+				break;
+		}
+		if(!exists)
+			continue;
 		SYSCTL_ADD_PROC(&sc->sysctl_ctx,
 		    SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
 		    sysctl_table[i].name,
@@ -352,9 +411,10 @@
 		    sysctl_table[i].description);
 	}
 
-	/* Set the buttons to their initial states */
+
+	/* Set the hotkeys to their initial states */
 	if (!acpi_fujitsu_update(sc)) {
-		device_printf(sc->dev, "Couldn't init button states\n");
+		device_printf(sc->dev, "Couldn't init hotkey states\n");
 		return (FALSE);
 	}
 
@@ -409,13 +469,28 @@
 		case METHOD_MUTE:
 			nv = sc->gvol;
 			break;
+		case METHOD_GHKS:
+			nv = sc->ghks;
+			break;
+		case METHOD_GSIF:
+			nv = sc->gsif;
+			break;
+		case METHOD_RBLL:
+			nv = sc->rbll;
+			break;
+		case METHOD_RVOL:
+			nv = sc->rvol;
+			break;
 		default:
 			return (FALSE);
 	}
 
+	if(!nv.exists)
+		return (EINVAL);
+
 	status = acpi_GetInteger(sc->handle, nv.name, &nv.value);
 	if (ACPI_FAILURE(status)) {
-		device_printf(sc->dev, "Couldn't query method\n");
+		device_printf(sc->dev, "Couldn't query method (%s)\n", nv.name);
 		return (FALSE);
 	}
 
@@ -459,6 +534,9 @@
 			return (EINVAL);
 	}
 
+	if(!nv.exists)
+		return (EINVAL);
+
 	if (method == METHOD_MUTE) {
 		if (value == 1)
 			value = nv.value | VOLUME_MUTE_BIT;
@@ -471,7 +549,7 @@
 	status = acpi_SetInteger(sc->handle, control, value);
 	if (ACPI_FAILURE(status)) {
 		device_printf(sc->dev, "Couldn't update %s\n", control);
-		return (EINVAL);
+		return (FALSE);
 	}
 
 	sc->lastValChanged = changed;
@@ -479,86 +557,160 @@
 }
 
 /*
- * Query each of the ACPI control methods that contain information we're
- * interested in. We check the return values from the control methods and
- * adjust any state variables if they should be adjusted.
+ * Query the get methods to determine what functionality is available
+ * from the hardware function hotkeys.
  */
 static uint8_t
-acpi_fujitsu_update(struct acpi_fujitsu_softc *sc)
+acpi_fujitsu_check_hardware(struct acpi_fujitsu_softc *sc)
 {
+	int val;
 	struct acpi_softc *acpi_sc;
 
 	acpi_sc = acpi_device_get_parent_softc(sc->dev);
 
 	ACPI_SERIAL_ASSERT(fujitsu);
+	/* save the hotkey bitmask */
+	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
+	sc->gsif.name, &(sc->gsif.value)))) {
+		sc->gsif.exists = 0;
+		device_printf(sc->dev, "Couldn't query bitmask value\n");
+	} else {
+		sc->gsif.exists = 1;
+	}
 
 	/* System Volume Level */
 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
-	    sc->gvol.name, &(sc->gvol.value)))) {
-		device_printf(sc->dev, "Couldn't query volume level\n");
-		return (FALSE);
+	    sc->gvol.name, &val))) {
+		sc->gvol.exists = 0;
+	} else {
+		sc->gvol.exists = 1;
 	}
 
-	if (sc->gvol.value & VOLUME_CHANGE_BIT) {
-		sc->bIsMuted =
-		    (uint8_t)((sc->gvol.value & VOLUME_MUTE_BIT) != 0);
-
-		/* Clear the modification bit */
-		sc->gvol.value &= VOLUME_SETTING_BITS;
-
-		if (sc->bIsMuted) {
-			acpi_UserNotify("FUJITSU", sc->handle, FN_MUTE);
-			ACPI_VPRINT(sc->dev, acpi_sc, "Volume is now mute\n");
-		} else
-			ACPI_VPRINT(sc->dev, acpi_sc, "Volume is now %d\n",
-			    sc->gvol.value);
-
-		acpi_UserNotify("FUJITSU", sc->handle, FN_VOLUME);
-
-		sc->lastValChanged = VOLUME_CHANGED;
+	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
+	    sc->gbll.name, &val))) {
+		sc->gbll.exists = 0;
+	} else {
+		sc->gbll.exists = 1;
 	}
 
-	/* Internal mouse pointer (eraserhead) */
 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
-	    sc->gmou.name, &(sc->gmou.value)))) {
-		device_printf(sc->dev, "Couldn't query pointer state\n");
-		return (FALSE);
+	    sc->ghks.name, &val))) {
+		sc->ghks.exists = 0;
+	} else {
+		sc->ghks.exists = 1;
 	}
 
-	if (sc->gmou.value & MOUSE_UPDATED_BIT) {
-		sc->bIntPtrEnabled = (uint8_t)(sc->gmou.value & 0x1);
-
-		/* Clear the modification bit */
-		sc->gmou.value &= MOUSE_SETTING_BITS;
-		
-		acpi_UserNotify("FUJITSU", sc->handle, FN_POINTER_ENABLE);
-
-		ACPI_VPRINT(sc->dev, acpi_sc, "Internal pointer is now %s\n",
-		    (sc->bIntPtrEnabled) ? "enabled" : "disabled");
+	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
+	    sc->gmou.name, &val))) {
+		sc->gmou.exists = 0;
+	} else {
+		sc->gmou.exists = 1;
+	}
 
-		sc->lastValChanged = MOUSE_CHANGED;
+	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
+	    sc->rbll.name, &val))) {
+		sc->rbll.exists = 0;
+	} else {
+		sc->rbll.exists = 1;
 	}
 
-	/* Screen Brightness Level */
 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
-	    sc->gbll.name, &(sc->gbll.value)))) {
-		device_printf(sc->dev, "Couldn't query brightness level\n");
-		return (FALSE);
+	    sc->rvol.name, &val))) {
+		sc->rvol.exists = 0;
+	} else {
+		sc->rvol.exists = 1;
 	}
 
-	if (sc->gbll.value & BRIGHTNESS_CHANGE_BIT) {
-		/* No state to record here. */
+	return (TRUE);
+}
 
-		/* Clear the modification bit */
-		sc->gbll.value &= BRIGHTNESS_SETTING_BITS;
+/*
+ * Query each of the ACPI control methods that contain information we're
+ * interested in. We check the return values from the control methods and
+ * adjust any state variables if they should be adjusted.
+ */
+static uint8_t
+acpi_fujitsu_update(struct acpi_fujitsu_softc *sc)
+{
+	int changed;
+	struct acpi_softc *acpi_sc;
+
+	acpi_sc = acpi_device_get_parent_softc(sc->dev);
+
+	ACPI_SERIAL_ASSERT(fujitsu);
+	if(sc->gsif.exists)
+		changed = sc->gsif.value & acpi_fujitsu_method_get(sc,METHOD_GHKS);
+	else
+		changed = 0;
 
-		acpi_UserNotify("FUJITSU", sc->handle, FN_LCD_BRIGHTNESS);
+	/* System Volume Level */
+	if(sc->gvol.exists) {
+		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
+		sc->gvol.name, &(sc->gvol.value)))) {
+			device_printf(sc->dev, "Couldn't query volume level\n");
+			return (FALSE);
+		}
+	
+		if (changed & VOLUME_CHANGED) {
+			sc->bIsMuted =
+			(uint8_t)((sc->gvol.value & VOLUME_MUTE_BIT) != 0);
+	
+			/* Clear the modification bit */
+			sc->gvol.value &= VOLUME_SETTING_BITS;
+	
+			if (sc->bIsMuted) {
+				acpi_UserNotify("FUJITSU", sc->handle, FN_MUTE);
+				ACPI_VPRINT(sc->dev, acpi_sc, "Volume is now mute\n");
+			} else
+				ACPI_VPRINT(sc->dev, acpi_sc, "Volume is now %d\n",
+				sc->gvol.value);
+	
+			acpi_UserNotify("FUJITSU", sc->handle, FN_VOLUME);
+		}
+	}
 
-		ACPI_VPRINT(sc->dev, acpi_sc, "Brightness level is now %d\n",
-		    sc->gbll.value);
+	/* Internal mouse pointer (eraserhead) */
+	if(sc->gmou.exists) {
+		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
+		sc->gmou.name, &(sc->gmou.value)))) {
+			device_printf(sc->dev, "Couldn't query pointer state\n");
+			return (FALSE);
+		}
+	
+		if (changed & MOUSE_CHANGED) {
+			sc->bIntPtrEnabled = (uint8_t)(sc->gmou.value & 0x1);
+	
+			/* Clear the modification bit */
+			sc->gmou.value &= MOUSE_SETTING_BITS;
+			
+			acpi_UserNotify("FUJITSU", sc->handle, FN_POINTER_ENABLE);
+	
+			ACPI_VPRINT(sc->dev, acpi_sc, "Internal pointer is now %s\n",
+			(sc->bIntPtrEnabled) ? "enabled" : "disabled");
+		}
+	}
 
-		sc->lastValChanged = BRIGHT_CHANGED;
+	/* Screen Brightness Level */
+	if(sc->gbll.exists) {
+		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
+		sc->gbll.name, &(sc->gbll.value)))) {
+			device_printf(sc->dev, "Couldn't query brightness level\n");
+			return (FALSE);
+		}
+	
+		if (changed & BRIGHT_CHANGED) {
+			/* No state to record here. */
+	
+			/* Clear the modification bit */
+			sc->gbll.value &= BRIGHTNESS_SETTING_BITS;
+	
+			acpi_UserNotify("FUJITSU", sc->handle, FN_LCD_BRIGHTNESS);
+	
+			ACPI_VPRINT(sc->dev, acpi_sc, "Brightness level is now %d\n",
+			sc->gbll.value);
+		}
 	}
 
+	sc->lastValChanged = changed;
 	return (TRUE);
 }
Index: acpi_toshiba.c
===================================================================
RCS file: /home/cvs/src/sys/dev/acpi_support/acpi_toshiba.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sys/dev/acpi_support/acpi_toshiba.c -L sys/dev/acpi_support/acpi_toshiba.c -u -r1.1.1.1 -r1.2
--- sys/dev/acpi_support/acpi_toshiba.c
+++ sys/dev/acpi_support/acpi_toshiba.c
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_toshiba.c,v 1.16.2.1 2005/11/10 11:22:11 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_toshiba.c,v 1.17 2005/09/11 18:39:01 obrien Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
--- /dev/null
+++ sys/dev/acpi_support/acpi_aiboost.c
@@ -0,0 +1,338 @@
+/*-
+ * Copyright (c) 2006 Takanori Watanabe
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/sys/dev/acpi_support/acpi_aiboost.c,v 1.3 2006/11/06 12:14:27 takawata Exp $");
+
+#include "opt_acpi.h"
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <contrib/dev/acpica/acpi.h>
+#include "acpi_if.h"
+#include <sys/module.h>
+#include <dev/acpica/acpivar.h>
+#include <sys/sysctl.h>
+#include <sys/malloc.h>
+#include <sys/sysctl.h>
+
+#define _COMPONENT	ACPI_OEM
+ACPI_MODULE_NAME("AIBOOST")
+
+#define DESCSTRLEN 32
+struct acpi_aiboost_element{
+	ACPI_HANDLE h;
+	uint32_t id;
+	char desc[DESCSTRLEN];
+};
+ACPI_SERIAL_DECL(aiboost, "ACPI AIBOOST");
+/**/
+struct acpi_aiboost_component{
+	unsigned int num;
+	struct acpi_aiboost_element elem[1];
+};
+
+struct acpi_aiboost_softc {
+	int pid;
+	struct acpi_aiboost_component *temp;
+	struct acpi_aiboost_component *volt;
+	struct acpi_aiboost_component *fan;
+};
+
+static int	acpi_aiboost_probe(device_t dev);
+static int	acpi_aiboost_attach(device_t dev);
+static int 	acpi_aiboost_detach(device_t dev);
+
+static device_method_t acpi_aiboost_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe, acpi_aiboost_probe),
+	DEVMETHOD(device_attach, acpi_aiboost_attach),
+	DEVMETHOD(device_detach, acpi_aiboost_detach),
+
+	{0, 0}
+};
+
+static driver_t	acpi_aiboost_driver = {
+	"acpi_aiboost",
+	acpi_aiboost_methods,
+	sizeof(struct acpi_aiboost_softc),
+};
+
+static devclass_t acpi_aiboost_devclass;
+
+DRIVER_MODULE(acpi_aiboost, acpi, acpi_aiboost_driver, acpi_aiboost_devclass,
+	      0, 0);
+MODULE_DEPEND(acpi_aiboost, acpi, 1, 1, 1);
+static char    *abs_id[] = {"ATK0110", NULL};
+
+/*VSIF, RVLT, SVLT,  TSIF, RTMP, STMP FSIF, RFAN, SFAN */
+
+static ACPI_STATUS acpi_aiboost_getcomponent(device_t dev, char *name, struct  acpi_aiboost_component **comp)
+{
+	ACPI_BUFFER		buf, buf2;
+	ACPI_OBJECT            *o,*elem,*subobj;
+	ACPI_STATUS status;
+	struct acpi_aiboost_component *c = NULL;
+
+	int i;
+
+	buf.Pointer = NULL;
+	buf.Length = ACPI_ALLOCATE_BUFFER;
+	buf2.Pointer = NULL;
+
+	status = AcpiEvaluateObject(acpi_get_handle(dev), name, NULL, &buf);
+	
+	if(ACPI_FAILURE(status))
+		return status;
+	
+	o = buf.Pointer;
+	if(o->Type != ACPI_TYPE_PACKAGE)
+		goto error;
+	
+	elem = o->Package.Elements;
+	if(elem->Type != ACPI_TYPE_INTEGER)
+		goto error;
+
+	c = malloc(sizeof(struct acpi_aiboost_component)
+		   + sizeof(struct acpi_aiboost_element)
+		   * (elem->Integer.Value -1),
+		   M_DEVBUF, M_ZERO|M_WAITOK);
+	*comp = c;
+	c->num = elem->Integer.Value;
+	
+	for(i = 1 ; i < o->Package.Count; i++){
+		elem = &o->Package.Elements[i];
+		if(elem->Type != ACPI_TYPE_ANY){
+			printf("NOREF\n");
+			goto error;
+		}
+		c->elem[ i - 1].h = elem->Reference.Handle;
+
+		buf2.Pointer = NULL;
+		buf2.Length = ACPI_ALLOCATE_BUFFER;
+		
+		status = AcpiEvaluateObject(c->elem[i - 1].h, NULL, NULL,
+					    &buf2);
+		if(ACPI_FAILURE(status)){
+			printf("FETCH OBJECT\n");
+			goto error;
+		}
+		subobj = buf2.Pointer;
+		if(ACPI_FAILURE(acpi_PkgInt32(subobj,0, &c->elem[i -1].id))){
+			printf("ID FAILED\n");
+			goto error;
+		}
+		status = acpi_PkgStr(subobj, 1, c->elem[i - 1].desc, 
+				     sizeof(c->elem[i - 1].desc));
+		if(ACPI_FAILURE(status)){
+			if(status == E2BIG){
+				c->elem[i-1].desc[DESCSTRLEN-1] = 0;
+			}else{
+				printf("DESC FAILED %d\n", i-1);
+				goto error;
+			}
+		}
+		
+		if(buf2.Pointer)
+		  AcpiOsFree(buf2.Pointer);
+	}
+
+	if(buf.Pointer)
+		AcpiOsFree(buf.Pointer);
+
+	return 0;
+
+ error:
+	printf("BAD DATA\n");
+	if(buf.Pointer)
+		AcpiOsFree(buf.Pointer);
+	if(buf2.Pointer)
+		AcpiOsFree(buf2.Pointer);
+	if(c)
+		free(c, M_DEVBUF);
+	return AE_BAD_DATA;
+}
+
+static int 
+acpi_aiboost_get_value(ACPI_HANDLE handle, char *path, UINT32 number)
+{
+	ACPI_OBJECT arg1, *ret;
+	ACPI_OBJECT_LIST args;
+	ACPI_BUFFER buf;
+	buf.Length = ACPI_ALLOCATE_BUFFER;
+	buf.Pointer = 0;
+	int val;
+
+	arg1.Type = ACPI_TYPE_INTEGER;
+	arg1.Integer.Value = number;
+	args.Count = 1;
+	args.Pointer = &arg1;
+
+	if(ACPI_FAILURE(AcpiEvaluateObject(handle, path, &args, &buf))){
+		return -1;
+	}
+
+	ret = buf.Pointer;
+	val = (ret->Type == ACPI_TYPE_INTEGER)? ret->Integer.Value : -1;
+
+	AcpiOsFree(buf.Pointer);
+	return val;
+}
+
+
+static int acpi_aiboost_temp_sysctl(SYSCTL_HANDLER_ARGS)
+{
+	device_t dev = arg1;
+	int function = oidp->oid_arg2;
+	int error = 0, val;
+	ACPI_SERIAL_BEGIN(aiboost);
+	val = acpi_aiboost_get_value(acpi_get_handle(dev), "RTMP",function );
+	error = sysctl_handle_int(oidp, &val, 0 , req);
+	ACPI_SERIAL_END(aiboost);
+	
+	return 0;
+}
+
+static int acpi_aiboost_volt_sysctl(SYSCTL_HANDLER_ARGS)
+{
+	device_t dev = arg1;
+	int function = oidp->oid_arg2;
+	int error = 0, val;
+	ACPI_SERIAL_BEGIN(aiboost);
+	val = acpi_aiboost_get_value(acpi_get_handle(dev), "RVLT", function);
+	error = sysctl_handle_int(oidp, &val, 0 , req);
+	ACPI_SERIAL_END(aiboost);
+	
+	return 0;
+}
+
+static int acpi_aiboost_fan_sysctl(SYSCTL_HANDLER_ARGS)
+{
+	device_t dev = arg1;
+	int function = oidp->oid_arg2;
+	int error = 0, val;
+	ACPI_SERIAL_BEGIN(aiboost);
+	val = acpi_aiboost_get_value(acpi_get_handle(dev), "RFAN", function);
+	error = sysctl_handle_int(oidp, &val, 0 , req);
+	ACPI_SERIAL_END(aiboost);
+	
+	return 0;
+}
+
+static int
+acpi_aiboost_probe(device_t dev)
+{
+	int		ret = ENXIO;
+
+	if (ACPI_ID_PROBE(device_get_parent(dev), dev, abs_id)) {
+		device_set_desc(dev, "ASUStek AIBOOSTER");
+		ret = 0;
+	}
+	return (ret);
+}
+
+static int
+acpi_aiboost_attach(device_t dev)
+{
+	struct acpi_aiboost_softc *sc;
+	char nambuf[]="tempXXX";
+	int i;
+
+	sc = device_get_softc(dev);
+	if(ACPI_FAILURE(acpi_aiboost_getcomponent(dev, "TSIF", &sc->temp)))
+		goto error;
+	for(i= 0; i < sc->temp->num; i++){
+		sprintf(nambuf,"temp%d", i);
+		SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
+				SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+				OID_AUTO, nambuf,
+				CTLTYPE_INT|CTLFLAG_RD, dev, 
+				sc->temp->elem[i].id,
+				acpi_aiboost_temp_sysctl,
+				"I", sc->temp->elem[i].desc);
+	}
+	if(ACPI_FAILURE(acpi_aiboost_getcomponent(dev, "VSIF", &sc->volt)))
+		goto error;
+
+	for(i= 0; i < sc->volt->num; i++){
+		sprintf(nambuf,"volt%d", i);
+		SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
+				SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+				OID_AUTO, nambuf,
+				CTLTYPE_INT|CTLFLAG_RD, dev, 
+				sc->volt->elem[i].id,
+				acpi_aiboost_volt_sysctl,
+				"I", sc->volt->elem[i].desc);
+	}
+
+	if(ACPI_FAILURE(acpi_aiboost_getcomponent(dev, "FSIF", &sc->fan)))
+		goto error;
+
+	for(i= 0; i < sc->fan->num; i++){
+		sprintf(nambuf,"fan%d", i);
+		SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
+				SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+				OID_AUTO, nambuf,
+				CTLTYPE_INT|CTLFLAG_RD, dev, 
+				sc->fan->elem[i].id,
+				acpi_aiboost_fan_sysctl,
+				"I", sc->fan->elem[i].desc);
+	}
+
+	
+	return (0);
+ error:
+	return EINVAL;
+}
+
+static int 
+acpi_aiboost_detach(device_t dev)
+{
+	struct acpi_aiboost_softc *sc = device_get_softc(dev);
+
+	if(sc->temp)
+		free(sc->temp, M_DEVBUF);
+	if(sc->volt)
+		free(sc->volt, M_DEVBUF);
+	if(sc->fan)
+		free(sc->fan, M_DEVBUF);
+	return (0);
+}
+
+#if 0
+static int
+acpi_aiboost_suspend(device_t dev)
+{
+	struct acpi_aiboost_softc *sc = device_get_softc(dev);
+	return (0);
+}
+
+static int
+acpi_aiboost_resume(device_t dev)
+{
+	return (0);
+}
+#endif


More information about the Midnightbsd-cvs mailing list