1 /*-
2  * Copyright (c) 2002 Sean Bullington <seanATstalker.org>
3  *               2003-2008 Anish Mistry <amistry@am-productions.biz>
4  *               2004 Mark Santcroos <marks@ripe.net>
5  * All Rights Reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD: head/sys/dev/acpi_support/acpi_fujitsu.c 246128 2013-01-30 18:01:20Z sbz $
29  */
30 
31 #include "opt_acpi.h"
32 #include <sys/param.h>
33 #include <sys/kernel.h>
34 #include <sys/bus.h>
35 #include <sys/module.h>
36 #include <sys/sysctl.h>
37 
38 #include "acpi.h"
39 #include "accommon.h"
40 
41 #include <dev/acpica/acpivar.h>
42 
43 /* Hooks for the ACPICA debugging infrastructure */
44 #define _COMPONENT	ACPI_OEM
45 ACPI_MODULE_NAME("Fujitsu")
46 
47 /* Change and update bits for the hotkeys */
48 #define VOLUME_MUTE_BIT		0x40000000
49 
50 /* Values of settings */
51 #define GENERAL_SETTING_BITS	0x0fffffff
52 #define MOUSE_SETTING_BITS	GENERAL_SETTING_BITS
53 #define VOLUME_SETTING_BITS	GENERAL_SETTING_BITS
54 #define BRIGHTNESS_SETTING_BITS	GENERAL_SETTING_BITS
55 
56 /* Possible state changes */
57 /*
58  * These are NOT arbitrary values.  They are the
59  * GHKS return value from the device that says which
60  * hotkey is active.  They should match up with a bit
61  * from the GSIF bitmask.
62  */
63 #define BRIGHT_CHANGED	0x01
64 #define VOLUME_CHANGED	0x04
65 #define MOUSE_CHANGED	0x08
66 /*
67  * It is unknown which hotkey this bit is supposed to indicate, but
68  * according to values from GSIF this is a valid flag.
69  */
70 #define UNKNOWN_CHANGED	0x10
71 
72 /* sysctl values */
73 #define FN_MUTE			0
74 #define FN_POINTER_ENABLE	1
75 #define FN_LCD_BRIGHTNESS	2
76 #define FN_VOLUME		3
77 
78 /* Methods */
79 #define METHOD_GBLL	1
80 #define METHOD_GMOU	2
81 #define METHOD_GVOL	3
82 #define METHOD_MUTE	4
83 #define METHOD_RBLL	5
84 #define METHOD_RVOL	6
85 #define METHOD_GSIF	7
86 #define METHOD_GHKS	8
87 #define METHOD_GBLS	9
88 
89 /* Notify event */
90 #define	ACPI_NOTIFY_STATUS_CHANGED	0x80
91 
92 /*
93  * Holds a control method name and its associated integer value.
94  * Only used for no-argument control methods which return a value.
95  */
96 struct int_nameval {
97 	char	*name;
98 	int	value;
99 	int	exists;
100 };
101 
102 /*
103  * Driver extension for the FUJITSU ACPI driver.
104  */
105 struct acpi_fujitsu_softc {
106 	device_t	dev;
107 	ACPI_HANDLE	handle;
108 
109 	/* Control methods */
110 	struct int_nameval	_sta,	/* unused */
111 				gbll,	/* brightness */
112 				gbls,	/* get brightness state */
113 				ghks,	/* hotkey selector */
114 				gbuf,	/* unused (buffer?) */
115 				gmou,	/* mouse */
116 				gsif,	/* function key bitmask */
117 				gvol,	/* volume */
118 				rbll,	/* number of brightness levels (radix) */
119 				rvol;	/* number of volume levels (radix) */
120 
121 	/* State variables */
122 	uint8_t		bIsMuted;	/* Is volume muted */
123 	uint8_t		bIntPtrEnabled;	/* Is internal ptr enabled */
124 	uint32_t	lastValChanged;	/* The last value updated */
125 
126 	/* sysctl tree */
127 	struct sysctl_ctx_list	sysctl_ctx;
128 	struct sysctl_oid	*sysctl_tree;
129 };
130 
131 /* Driver entry point forward declarations. */
132 static int	acpi_fujitsu_probe(device_t dev);
133 static int	acpi_fujitsu_attach(device_t dev);
134 static int	acpi_fujitsu_detach(device_t dev);
135 static int	acpi_fujitsu_suspend(device_t dev);
136 static int	acpi_fujitsu_resume(device_t dev);
137 
138 static void	acpi_fujitsu_notify_status_changed(void *arg);
139 static void	acpi_fujitsu_notify_handler(ACPI_HANDLE h, uint32_t notify, void *context);
140 static int	acpi_fujitsu_sysctl(SYSCTL_HANDLER_ARGS);
141 
142 /* Utility function declarations */
143 static uint8_t acpi_fujitsu_update(struct acpi_fujitsu_softc *sc);
144 static uint8_t acpi_fujitsu_init(struct acpi_fujitsu_softc *sc);
145 static uint8_t acpi_fujitsu_check_hardware(struct acpi_fujitsu_softc *sc);
146 
147 /* Driver/Module specific structure definitions. */
148 static device_method_t acpi_fujitsu_methods[] = {
149 	/* Device interface */
150 	DEVMETHOD(device_probe,		acpi_fujitsu_probe),
151 	DEVMETHOD(device_attach,	acpi_fujitsu_attach),
152 	DEVMETHOD(device_detach,	acpi_fujitsu_detach),
153 	DEVMETHOD(device_suspend,	acpi_fujitsu_suspend),
154 	DEVMETHOD(device_resume,	acpi_fujitsu_resume),
155 	DEVMETHOD_END
156 };
157 
158 static driver_t acpi_fujitsu_driver = {
159 	"acpi_fujitsu",
160 	acpi_fujitsu_methods,
161 	sizeof(struct acpi_fujitsu_softc),
162 };
163 
164 /* Prototype for function hotkeys for getting/setting a value. */
165 static int acpi_fujitsu_method_get(struct acpi_fujitsu_softc *sc, int method);
166 static int acpi_fujitsu_method_set(struct acpi_fujitsu_softc *sc, int method, int value);
167 
168 static char *fujitsu_ids[] = { "FUJ02B1", NULL };
169 
170 ACPI_SERIAL_DECL(fujitsu, "Fujitsu Function Hotkeys");
171 
172 /* sysctl names and function calls */
173 static struct {
174 	char		*name;
175 	int		method;
176 	char		*description;
177 } sysctl_table[] = {
178 	{
179 		.name		= "mute",
180 		.method		= METHOD_MUTE,
181 		.description	= "Speakers/headphones mute status"
182 	},
183 	{
184 		.name		= "pointer_enable",
185 		.method		= METHOD_GMOU,
186 		.description	= "Enable and disable the internal pointer"
187 	},
188 	{
189 		.name		= "lcd_brightness",
190 		.method		= METHOD_GBLL,
191 		.description	= "Brightness level of the LCD panel"
192 	},
193 	{
194 		.name		= "lcd_brightness",
195 		.method		= METHOD_GBLS,
196 		.description	= "Brightness level of the LCD panel"
197 	},
198 	{
199 		.name		= "volume",
200 		.method		= METHOD_GVOL,
201 		.description	= "Speakers/headphones volume level"
202 	},
203 	{
204 		.name		= "volume_radix",
205 		.method		= METHOD_RVOL,
206 		.description	= "Number of volume level steps"
207 	},
208 	{
209 		.name		= "lcd_brightness_radix",
210 		.method		= METHOD_RBLL,
211 		.description	= "Number of brightness level steps"
212 	},
213 
214 	{ NULL, 0, NULL }
215 };
216 
217 static devclass_t acpi_fujitsu_devclass;
218 DRIVER_MODULE(acpi_fujitsu, acpi, acpi_fujitsu_driver,
219     acpi_fujitsu_devclass, 0, 0);
220 MODULE_DEPEND(acpi_fujitsu, acpi, 1, 1, 1);
221 MODULE_VERSION(acpi_fujitsu, 1);
222 
223 static int
224 acpi_fujitsu_probe(device_t dev)
225 {
226 	char *name;
227 	char buffer[64];
228 
229 	name = ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids);
230 	if (acpi_disabled("fujitsu") || name == NULL ||
231 	    device_get_unit(dev) > 1)
232 		return (ENXIO);
233 
234 	ksprintf(buffer, "Fujitsu Function Hotkeys %s", name);
235 	device_set_desc_copy(dev, buffer);
236 
237 	return (0);
238 }
239 
240 static int
241 acpi_fujitsu_attach(device_t dev)
242 {
243 	struct acpi_fujitsu_softc *sc;
244 
245 	ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
246 
247 	sc = device_get_softc(dev);
248 	sc->dev = dev;
249 	sc->handle = acpi_get_handle(dev);
250 
251 	/* Install notification handler */
252 	AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
253 	    acpi_fujitsu_notify_handler, sc);
254 
255 	/* Snag our default values for the hotkeys / hotkey states. */
256 	ACPI_SERIAL_BEGIN(fujitsu);
257 	if (!acpi_fujitsu_init(sc))
258 		device_printf(dev, "Couldn't initialize hotkey states!\n");
259 	ACPI_SERIAL_END(fujitsu);
260 
261 	return (0);
262 }
263 
264 /*
265  * Called when the system is being suspended, simply
266  * set an event to be signalled when we wake up.
267  */
268 static int
269 acpi_fujitsu_suspend(device_t dev)
270 {
271 
272 	return (0);
273 }
274 
275 static int
276 acpi_fujitsu_resume(device_t dev)
277 {
278 	struct acpi_fujitsu_softc   *sc;
279 	ACPI_STATUS		    status;
280 
281 	sc = device_get_softc(dev);
282 
283 	/*
284 	 * The pointer needs to be re-enabled for
285 	 * some revisions of the P series (2120).
286 	 */
287 	ACPI_SERIAL_BEGIN(fujitsu);
288 
289 	if(sc->gmou.exists) {
290 		status = acpi_SetInteger(sc->handle, "SMOU", 1);
291 		if (ACPI_FAILURE(status))
292 			device_printf(sc->dev, "Couldn't enable pointer\n");
293 	}
294 	ACPI_SERIAL_END(fujitsu);
295 
296 	return (0);
297 }
298 
299 static void
300 acpi_fujitsu_notify_status_changed(void *arg)
301 {
302 	struct acpi_fujitsu_softc *sc;
303 
304 	ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
305 
306 	sc = (struct acpi_fujitsu_softc *)arg;
307 
308 	/*
309 	 * Since our notify function is called, we know something has
310 	 * happened.  So the only reason for acpi_fujitsu_update to fail
311 	 * is if we can't find what has changed or an error occurs.
312 	 */
313 	ACPI_SERIAL_BEGIN(fujitsu);
314 	acpi_fujitsu_update(sc);
315 	ACPI_SERIAL_END(fujitsu);
316 }
317 
318 
319 static void
320 acpi_fujitsu_notify_handler(ACPI_HANDLE h, uint32_t notify, void *context)
321 {
322 	struct acpi_fujitsu_softc *sc;
323 
324 	ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, notify);
325 
326 	sc = (struct acpi_fujitsu_softc *)context;
327 
328 	switch (notify) {
329 	case ACPI_NOTIFY_STATUS_CHANGED:
330 		AcpiOsExecute(OSL_NOTIFY_HANDLER,
331 		    acpi_fujitsu_notify_status_changed, sc);
332 		break;
333 	default:
334 		/* unknown notification value */
335 		break;
336 	}
337 }
338 
339 static int
340 acpi_fujitsu_detach(device_t dev)
341 {
342 	struct acpi_fujitsu_softc *sc;
343 
344 	sc = device_get_softc(dev);
345 	AcpiRemoveNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
346 	   acpi_fujitsu_notify_handler);
347 
348 	sysctl_ctx_free(&sc->sysctl_ctx);
349 
350 	return (0);
351 }
352 
353 /*
354  * Initializes the names of the ACPI control methods and grabs
355  * the current state of all of the ACPI hotkeys into the softc.
356  */
357 static uint8_t
358 acpi_fujitsu_init(struct acpi_fujitsu_softc *sc)
359 {
360 	struct acpi_softc *acpi_sc;
361 	int i, exists;
362 
363 	ACPI_SERIAL_ASSERT(fujitsu);
364 
365 	/* Setup all of the names for each control method */
366 	sc->_sta.name = "_STA";
367 	sc->gbll.name = "GBLL";
368 	sc->gbls.name = "GBLS";
369 	sc->ghks.name = "GHKS";
370 	sc->gmou.name = "GMOU";
371 	sc->gsif.name = "GSIF";
372 	sc->gvol.name = "GVOL";
373 	sc->ghks.name = "GHKS";
374 	sc->gsif.name = "GSIF";
375 	sc->rbll.name = "RBLL";
376 	sc->rvol.name = "RVOL";
377 
378 	/* Determine what hardware functionality is available */
379 	acpi_fujitsu_check_hardware(sc);
380 
381 	/* Build the sysctl tree */
382 	acpi_sc = acpi_device_get_parent_softc(sc->dev);
383 	sysctl_ctx_init(&sc->sysctl_ctx);
384 	sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx,
385 	    SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree),
386 	    OID_AUTO, "fujitsu", CTLFLAG_RD, 0, "");
387 
388 	for (i = 0; sysctl_table[i].name != NULL; i++) {
389 		switch(sysctl_table[i].method) {
390 			case METHOD_GMOU:
391 				exists = sc->gmou.exists;
392 				break;
393 			case METHOD_GBLL:
394 				exists = sc->gbll.exists;
395 				break;
396 			case METHOD_GBLS:
397 				exists = sc->gbls.exists;
398 				break;
399 			case METHOD_GVOL:
400 			case METHOD_MUTE:
401 				exists = sc->gvol.exists;
402 				break;
403 			case METHOD_RVOL:
404 				exists = sc->rvol.exists;
405 				break;
406 			case METHOD_RBLL:
407 				exists = sc->rbll.exists;
408 				break;
409 			default:
410 				/* Allow by default */
411 				exists = 1;
412 				break;
413 		}
414 		if(!exists)
415 			continue;
416 		SYSCTL_ADD_PROC(&sc->sysctl_ctx,
417 		    SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
418 		    sysctl_table[i].name,
419 		    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY,
420 		    sc, i, acpi_fujitsu_sysctl, "I",
421 		    sysctl_table[i].description);
422 	}
423 
424 
425 	/* Set the hotkeys to their initial states */
426 	if (!acpi_fujitsu_update(sc)) {
427 		device_printf(sc->dev, "Couldn't init hotkey states\n");
428 		return (FALSE);
429 	}
430 
431 	return (TRUE);
432 }
433 
434 static int
435 acpi_fujitsu_sysctl(SYSCTL_HANDLER_ARGS)
436 {
437 	struct acpi_fujitsu_softc	*sc;
438 	int				method;
439 	int				arg;
440 	int				function_num, error = 0;
441 
442 	sc = (struct acpi_fujitsu_softc *)oidp->oid_arg1;
443 	function_num = oidp->oid_arg2;
444 	method = sysctl_table[function_num].method;
445 
446 	ACPI_SERIAL_BEGIN(fujitsu);
447 
448 	/* Get the current value */
449 	arg = acpi_fujitsu_method_get(sc, method);
450 	error = sysctl_handle_int(oidp, &arg, 0, req);
451 
452 	if (error != 0 || req->newptr == NULL)
453 		goto out;
454 
455 	/* Update the value */
456 	error = acpi_fujitsu_method_set(sc, method, arg);
457 
458 out:
459 	ACPI_SERIAL_END(fujitsu);
460 	return (error);
461 }
462 
463 static int
464 acpi_fujitsu_method_get(struct acpi_fujitsu_softc *sc, int method)
465 {
466 	struct int_nameval	nv;
467 	ACPI_STATUS		status;
468 
469 	ACPI_SERIAL_ASSERT(fujitsu);
470 
471 	switch (method) {
472 		case METHOD_GBLL:
473 			nv = sc->gbll;
474 			break;
475 		case METHOD_GBLS:
476 			nv = sc->gbls;
477 			break;
478 		case METHOD_GMOU:
479 			nv = sc->gmou;
480 			break;
481 		case METHOD_GVOL:
482 		case METHOD_MUTE:
483 			nv = sc->gvol;
484 			break;
485 		case METHOD_GHKS:
486 			nv = sc->ghks;
487 			break;
488 		case METHOD_GSIF:
489 			nv = sc->gsif;
490 			break;
491 		case METHOD_RBLL:
492 			nv = sc->rbll;
493 			break;
494 		case METHOD_RVOL:
495 			nv = sc->rvol;
496 			break;
497 		default:
498 			return (FALSE);
499 	}
500 
501 	if(!nv.exists)
502 		return (EINVAL);
503 
504 	status = acpi_GetInteger(sc->handle, nv.name, &nv.value);
505 	if (ACPI_FAILURE(status)) {
506 		device_printf(sc->dev, "Couldn't query method (%s)\n", nv.name);
507 		return (FALSE);
508 	}
509 
510 	if (method == METHOD_MUTE) {
511 		sc->bIsMuted = (uint8_t)((nv.value & VOLUME_MUTE_BIT) != 0);
512 		return (sc->bIsMuted);
513 	}
514 
515 	nv.value &= GENERAL_SETTING_BITS;
516 	return (nv.value);
517 }
518 
519 static int
520 acpi_fujitsu_method_set(struct acpi_fujitsu_softc *sc, int method, int value)
521 {
522 	struct int_nameval	nv;
523 	ACPI_STATUS		status;
524 	char			*control;
525 	int			changed;
526 
527 	ACPI_SERIAL_ASSERT(fujitsu);
528 
529 	switch (method) {
530 		case METHOD_GBLL:
531 			changed = BRIGHT_CHANGED;
532 			control = "SBLL";
533 			nv = sc->gbll;
534 			break;
535 		case METHOD_GBLS:
536 			changed = BRIGHT_CHANGED;
537 			control = "SBL2";
538 			nv = sc->gbls;
539 			break;
540 		case METHOD_GMOU:
541 			changed = MOUSE_CHANGED;
542 			control = "SMOU";
543 			nv = sc->gmou;
544 			break;
545 		case METHOD_GVOL:
546 		case METHOD_MUTE:
547 			changed = VOLUME_CHANGED;
548 			control = "SVOL";
549 			nv = sc->gvol;
550 			break;
551 		default:
552 			return (EINVAL);
553 	}
554 
555 	if(!nv.exists)
556 		return (EINVAL);
557 
558 	if (method == METHOD_MUTE) {
559 		if (value == 1)
560 			value = nv.value | VOLUME_MUTE_BIT;
561 		else if (value == 0)
562 			value = nv.value & ~VOLUME_MUTE_BIT;
563 		else
564 			return (EINVAL);
565 	}
566 
567 	status = acpi_SetInteger(sc->handle, control, value);
568 	if (ACPI_FAILURE(status)) {
569 		device_printf(sc->dev, "Couldn't update %s\n", control);
570 		return (FALSE);
571 	}
572 
573 	sc->lastValChanged = changed;
574 	return (0);
575 }
576 
577 /*
578  * Query the get methods to determine what functionality is available
579  * from the hardware function hotkeys.
580  */
581 static uint8_t
582 acpi_fujitsu_check_hardware(struct acpi_fujitsu_softc *sc)
583 {
584 	int val;
585 
586 	ACPI_SERIAL_ASSERT(fujitsu);
587 	/* save the hotkey bitmask */
588 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
589 	sc->gsif.name, &(sc->gsif.value)))) {
590 		sc->gsif.exists = 0;
591 		device_printf(sc->dev, "Couldn't query bitmask value\n");
592 	} else {
593 		sc->gsif.exists = 1;
594 	}
595 
596 	/* System Volume Level */
597 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
598 	    sc->gvol.name, &val))) {
599 		sc->gvol.exists = 0;
600 	} else {
601 		sc->gvol.exists = 1;
602 	}
603 
604 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
605 		sc->gbls.name, &val))) {
606 		sc->gbls.exists = 0;
607 	} else {
608 		sc->gbls.exists = 1;
609 	}
610 
611 	/* don't add if we can use the new method */
612 	if (sc->gbls.exists || ACPI_FAILURE(acpi_GetInteger(sc->handle,
613 	    sc->gbll.name, &val))) {
614 		sc->gbll.exists = 0;
615 	} else {
616 		sc->gbll.exists = 1;
617 	}
618 
619 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
620 	    sc->ghks.name, &val))) {
621 		sc->ghks.exists = 0;
622 	} else {
623 		sc->ghks.exists = 1;
624 	}
625 
626 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
627 	    sc->gmou.name, &val))) {
628 		sc->gmou.exists = 0;
629 	} else {
630 		sc->gmou.exists = 1;
631 	}
632 
633 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
634 	    sc->rbll.name, &val))) {
635 		sc->rbll.exists = 0;
636 	} else {
637 		sc->rbll.exists = 1;
638 	}
639 
640 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
641 	    sc->rvol.name, &val))) {
642 		sc->rvol.exists = 0;
643 	} else {
644 		sc->rvol.exists = 1;
645 	}
646 
647 	return (TRUE);
648 }
649 
650 /*
651  * Query each of the ACPI control methods that contain information we're
652  * interested in. We check the return values from the control methods and
653  * adjust any state variables if they should be adjusted.
654  */
655 static uint8_t
656 acpi_fujitsu_update(struct acpi_fujitsu_softc *sc)
657 {
658 	int changed;
659 	struct acpi_softc *acpi_sc;
660 
661 	acpi_sc = acpi_device_get_parent_softc(sc->dev);
662 
663 	ACPI_SERIAL_ASSERT(fujitsu);
664 	if(sc->gsif.exists)
665 		changed = sc->gsif.value & acpi_fujitsu_method_get(sc,METHOD_GHKS);
666 	else
667 		changed = 0;
668 
669 	/* System Volume Level */
670 	if(sc->gvol.exists) {
671 		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
672 		sc->gvol.name, &(sc->gvol.value)))) {
673 			device_printf(sc->dev, "Couldn't query volume level\n");
674 			return (FALSE);
675 		}
676 
677 		if (changed & VOLUME_CHANGED) {
678 			sc->bIsMuted =
679 			(uint8_t)((sc->gvol.value & VOLUME_MUTE_BIT) != 0);
680 
681 			/* Clear the modification bit */
682 			sc->gvol.value &= VOLUME_SETTING_BITS;
683 
684 			if (sc->bIsMuted) {
685 				acpi_UserNotify("FUJITSU", sc->handle, FN_MUTE);
686 				ACPI_VPRINT(sc->dev, acpi_sc, "Volume is now mute\n");
687 			} else
688 				ACPI_VPRINT(sc->dev, acpi_sc, "Volume is now %d\n",
689 				sc->gvol.value);
690 
691 			acpi_UserNotify("FUJITSU", sc->handle, FN_VOLUME);
692 		}
693 	}
694 
695 	/* Internal mouse pointer (eraserhead) */
696 	if(sc->gmou.exists) {
697 		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
698 		sc->gmou.name, &(sc->gmou.value)))) {
699 			device_printf(sc->dev, "Couldn't query pointer state\n");
700 			return (FALSE);
701 		}
702 
703 		if (changed & MOUSE_CHANGED) {
704 			sc->bIntPtrEnabled = (uint8_t)(sc->gmou.value & 0x1);
705 
706 			/* Clear the modification bit */
707 			sc->gmou.value &= MOUSE_SETTING_BITS;
708 
709 			/* Set the value in case it is not hardware controlled */
710 			acpi_fujitsu_method_set(sc, METHOD_GMOU, sc->gmou.value);
711 
712 			acpi_UserNotify("FUJITSU", sc->handle, FN_POINTER_ENABLE);
713 
714 			ACPI_VPRINT(sc->dev, acpi_sc, "Internal pointer is now %s\n",
715 			(sc->bIntPtrEnabled) ? "enabled" : "disabled");
716 		}
717 	}
718 
719 	/* Screen Brightness Level P8XXX */
720 	if(sc->gbls.exists) {
721 		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
722                 sc->gbls.name, &(sc->gbls.value)))) {
723                         device_printf(sc->dev, "Couldn't query P8XXX brightness level\n");
724                         return (FALSE);
725                 }
726 		if (changed & BRIGHT_CHANGED) {
727 			/* No state to record here. */
728 
729 			/* Clear the modification bit */
730 			sc->gbls.value &= BRIGHTNESS_SETTING_BITS;
731 
732 			/* Set the value in case it is not hardware controlled */
733 			acpi_fujitsu_method_set(sc, METHOD_GBLS, sc->gbls.value);
734 
735 			acpi_UserNotify("FUJITSU", sc->handle, FN_LCD_BRIGHTNESS);
736 
737 			ACPI_VPRINT(sc->dev, acpi_sc, "P8XXX Brightness level is now %d\n",
738 			sc->gbls.value);
739                 }
740 	}
741 
742 	/* Screen Brightness Level */
743 	if(sc->gbll.exists) {
744 		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
745 		sc->gbll.name, &(sc->gbll.value)))) {
746 			device_printf(sc->dev, "Couldn't query brightness level\n");
747 			return (FALSE);
748 		}
749 
750 		if (changed & BRIGHT_CHANGED) {
751 			/* No state to record here. */
752 
753 			/* Clear the modification bit */
754 			sc->gbll.value &= BRIGHTNESS_SETTING_BITS;
755 
756 			acpi_UserNotify("FUJITSU", sc->handle, FN_LCD_BRIGHTNESS);
757 
758 			ACPI_VPRINT(sc->dev, acpi_sc, "Brightness level is now %d\n",
759 			sc->gbll.value);
760 		}
761 	}
762 
763 	sc->lastValChanged = changed;
764 	return (TRUE);
765 }
766