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 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD$");
32
33#include "opt_acpi.h"
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/bus.h>
37#include <sys/module.h>
38#include <sys/sysctl.h>
39
40#include <contrib/dev/acpica/include/acpi.h>
41#include <contrib/dev/acpica/include/accommon.h>
42
43#include <dev/acpica/acpivar.h>
44
45/* Hooks for the ACPI CA debugging infrastructure */
46#define _COMPONENT	ACPI_OEM
47ACPI_MODULE_NAME("Fujitsu")
48
49/* Change and update bits for the hotkeys */
50#define VOLUME_MUTE_BIT		0x40000000
51
52/* Values of settings */
53#define GENERAL_SETTING_BITS	0x0fffffff
54#define MOUSE_SETTING_BITS	GENERAL_SETTING_BITS
55#define VOLUME_SETTING_BITS	GENERAL_SETTING_BITS
56#define BRIGHTNESS_SETTING_BITS	GENERAL_SETTING_BITS
57
58/* Possible state changes */
59/*
60 * These are NOT arbitrary values.  They are the
61 * GHKS return value from the device that says which
62 * hotkey is active.  They should match up with a bit
63 * from the GSIF bitmask.
64 */
65#define BRIGHT_CHANGED	0x01
66#define VOLUME_CHANGED	0x04
67#define MOUSE_CHANGED	0x08
68/*
69 * It is unknown which hotkey this bit is supposed to indicate, but
70 * according to values from GSIF this is a valid flag.
71 */
72#define UNKNOWN_CHANGED	0x10
73
74/* sysctl values */
75#define FN_MUTE			0
76#define FN_POINTER_ENABLE	1
77#define FN_LCD_BRIGHTNESS	2
78#define FN_VOLUME		3
79
80/* Methods */
81#define METHOD_GBLL	1
82#define METHOD_GMOU	2
83#define METHOD_GVOL	3
84#define METHOD_MUTE	4
85#define METHOD_RBLL	5
86#define METHOD_RVOL	6
87#define METHOD_GSIF	7
88#define METHOD_GHKS	8
89#define METHOD_GBLS	9
90
91/* Notify event */
92#define	ACPI_NOTIFY_STATUS_CHANGED	0x80
93
94/*
95 * Holds a control method name and its associated integer value.
96 * Only used for no-argument control methods which return a value.
97 */
98struct int_nameval {
99	char	*name;
100	int	value;
101	int	exists;
102};
103
104/*
105 * Driver extension for the FUJITSU ACPI driver.
106 */
107struct acpi_fujitsu_softc {
108	device_t	dev;
109	ACPI_HANDLE	handle;
110
111	/* Control methods */
112	struct int_nameval	_sta,	/* unused */
113				gbll,	/* brightness */
114				gbls,	/* get brightness state */
115				ghks,	/* hotkey selector */
116				gbuf,	/* unused (buffer?) */
117				gmou,	/* mouse */
118				gsif,	/* function key bitmask */
119				gvol,	/* volume */
120				rbll,	/* number of brightness levels (radix) */
121				rvol;	/* number of volume levels (radix) */
122
123	/* State variables */
124	uint8_t		bIsMuted;	/* Is volume muted */
125	uint8_t		bIntPtrEnabled;	/* Is internal ptr enabled */
126	uint32_t	lastValChanged;	/* The last value updated */
127
128	/* sysctl tree */
129	struct sysctl_ctx_list	sysctl_ctx;
130	struct sysctl_oid	*sysctl_tree;
131};
132
133/* Driver entry point forward declarations. */
134static int	acpi_fujitsu_probe(device_t dev);
135static int	acpi_fujitsu_attach(device_t dev);
136static int	acpi_fujitsu_detach(device_t dev);
137static int	acpi_fujitsu_suspend(device_t dev);
138static int	acpi_fujitsu_resume(device_t dev);
139
140static void	acpi_fujitsu_notify_status_changed(void *arg);
141static void	acpi_fujitsu_notify_handler(ACPI_HANDLE h, uint32_t notify, void *context);
142static int	acpi_fujitsu_sysctl(SYSCTL_HANDLER_ARGS);
143
144/* Utility function declarations */
145static uint8_t acpi_fujitsu_update(struct acpi_fujitsu_softc *sc);
146static uint8_t acpi_fujitsu_init(struct acpi_fujitsu_softc *sc);
147static uint8_t acpi_fujitsu_check_hardware(struct acpi_fujitsu_softc *sc);
148
149/* Driver/Module specific structure definitions. */
150static device_method_t acpi_fujitsu_methods[] = {
151	/* Device interface */
152	DEVMETHOD(device_probe,		acpi_fujitsu_probe),
153	DEVMETHOD(device_attach,	acpi_fujitsu_attach),
154	DEVMETHOD(device_detach,	acpi_fujitsu_detach),
155	DEVMETHOD(device_suspend,	acpi_fujitsu_suspend),
156	DEVMETHOD(device_resume,	acpi_fujitsu_resume),
157
158	DEVMETHOD_END
159};
160
161static driver_t acpi_fujitsu_driver = {
162	"acpi_fujitsu",
163	acpi_fujitsu_methods,
164	sizeof(struct acpi_fujitsu_softc),
165};
166
167/* Prototype for function hotkeys for getting/setting a value. */
168static int acpi_fujitsu_method_get(struct acpi_fujitsu_softc *sc, int method);
169static int acpi_fujitsu_method_set(struct acpi_fujitsu_softc *sc, int method, int value);
170
171static char *fujitsu_ids[] = { "FUJ02B1", NULL };
172
173ACPI_SERIAL_DECL(fujitsu, "Fujitsu Function Hotkeys");
174
175/* sysctl names and function calls */
176static struct {
177	char		*name;
178	int		method;
179	char		*description;
180} sysctl_table[] = {
181	{
182		.name		= "mute",
183		.method		= METHOD_MUTE,
184		.description	= "Speakers/headphones mute status"
185	},
186	{
187		.name		= "pointer_enable",
188		.method		= METHOD_GMOU,
189		.description	= "Enable and disable the internal pointer"
190	},
191	{
192		.name		= "lcd_brightness",
193		.method		= METHOD_GBLL,
194		.description	= "Brightness level of the LCD panel"
195	},
196	{
197		.name		= "lcd_brightness",
198		.method		= METHOD_GBLS,
199		.description	= "Brightness level of the LCD panel"
200	},
201	{
202		.name		= "volume",
203		.method		= METHOD_GVOL,
204		.description	= "Speakers/headphones volume level"
205	},
206	{
207		.name		= "volume_radix",
208		.method		= METHOD_RVOL,
209		.description	= "Number of volume level steps"
210	},
211	{
212		.name		= "lcd_brightness_radix",
213		.method		= METHOD_RBLL,
214		.description	= "Number of brightness level steps"
215	},
216	{ NULL, 0, NULL }
217};
218
219static devclass_t acpi_fujitsu_devclass;
220DRIVER_MODULE(acpi_fujitsu, acpi, acpi_fujitsu_driver,
221    acpi_fujitsu_devclass, 0, 0);
222MODULE_DEPEND(acpi_fujitsu, acpi, 1, 1, 1);
223MODULE_VERSION(acpi_fujitsu, 1);
224
225static int
226acpi_fujitsu_probe(device_t dev)
227{
228	char *name;
229	char buffer[64];
230	int rv;
231
232	rv =  ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids, &name);
233	if (acpi_disabled("fujitsu") || rv > 0 || device_get_unit(dev) > 1)
234		return (ENXIO);
235	sprintf(buffer, "Fujitsu Function Hotkeys %s", name);
236	device_set_desc_copy(dev, buffer);
237
238	return (rv);
239}
240
241static int
242acpi_fujitsu_attach(device_t dev)
243{
244	struct acpi_fujitsu_softc *sc;
245
246	ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
247
248	sc = device_get_softc(dev);
249	sc->dev = dev;
250	sc->handle = acpi_get_handle(dev);
251
252	/* Install notification handler */
253	AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
254	    acpi_fujitsu_notify_handler, sc);
255
256	/* Snag our default values for the hotkeys / hotkey states. */
257	ACPI_SERIAL_BEGIN(fujitsu);
258	if (!acpi_fujitsu_init(sc))
259		device_printf(dev, "Couldn't initialize hotkey states!\n");
260	ACPI_SERIAL_END(fujitsu);
261
262	return (0);
263}
264
265/*
266 * Called when the system is being suspended, simply
267 * set an event to be signalled when we wake up.
268 */
269static int
270acpi_fujitsu_suspend(device_t dev)
271{
272
273	return (0);
274}
275
276static int
277acpi_fujitsu_resume(device_t dev)
278{
279	struct acpi_fujitsu_softc   *sc;
280	ACPI_STATUS		    status;
281
282	sc = device_get_softc(dev);
283
284	/*
285	 * The pointer needs to be re-enabled for
286	 * some revisions of the P series (2120).
287	 */
288	ACPI_SERIAL_BEGIN(fujitsu);
289
290	if(sc->gmou.exists) {
291		status = acpi_SetInteger(sc->handle, "SMOU", 1);
292		if (ACPI_FAILURE(status))
293			device_printf(sc->dev, "Couldn't enable pointer\n");
294	}
295	ACPI_SERIAL_END(fujitsu);
296
297	return (0);
298}
299
300static void
301acpi_fujitsu_notify_status_changed(void *arg)
302{
303	struct acpi_fujitsu_softc *sc;
304
305	ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
306
307	sc = (struct acpi_fujitsu_softc *)arg;
308
309	/*
310	 * Since our notify function is called, we know something has
311	 * happened.  So the only reason for acpi_fujitsu_update to fail
312	 * is if we can't find what has changed or an error occurs.
313	 */
314	ACPI_SERIAL_BEGIN(fujitsu);
315	acpi_fujitsu_update(sc);
316	ACPI_SERIAL_END(fujitsu);
317}
318
319static void
320acpi_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
339static int
340acpi_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 */
357static uint8_t
358acpi_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 | CTLFLAG_MPSAFE, 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		    CTLFLAG_NEEDGIANT, sc, i, acpi_fujitsu_sysctl, "I",
421		    sysctl_table[i].description);
422	}
423
424	/* Set the hotkeys to their initial states */
425	if (!acpi_fujitsu_update(sc)) {
426		device_printf(sc->dev, "Couldn't init hotkey states\n");
427		return (FALSE);
428	}
429
430	return (TRUE);
431}
432
433static int
434acpi_fujitsu_sysctl(SYSCTL_HANDLER_ARGS)
435{
436	struct acpi_fujitsu_softc	*sc;
437	int				method;
438	int				arg;
439	int				function_num, error = 0;
440
441	sc = (struct acpi_fujitsu_softc *)oidp->oid_arg1;
442	function_num = oidp->oid_arg2;
443	method = sysctl_table[function_num].method;
444
445	ACPI_SERIAL_BEGIN(fujitsu);
446
447	/* Get the current value */
448	arg = acpi_fujitsu_method_get(sc, method);
449	error = sysctl_handle_int(oidp, &arg, 0, req);
450
451	if (error != 0 || req->newptr == NULL)
452		goto out;
453
454	/* Update the value */
455	error = acpi_fujitsu_method_set(sc, method, arg);
456
457out:
458	ACPI_SERIAL_END(fujitsu);
459	return (error);
460}
461
462static int
463acpi_fujitsu_method_get(struct acpi_fujitsu_softc *sc, int method)
464{
465	struct int_nameval	nv;
466	ACPI_STATUS		status;
467
468	ACPI_SERIAL_ASSERT(fujitsu);
469
470	switch (method) {
471		case METHOD_GBLL:
472			nv = sc->gbll;
473			break;
474		case METHOD_GBLS:
475			nv = sc->gbls;
476			break;
477		case METHOD_GMOU:
478			nv = sc->gmou;
479			break;
480		case METHOD_GVOL:
481		case METHOD_MUTE:
482			nv = sc->gvol;
483			break;
484		case METHOD_GHKS:
485			nv = sc->ghks;
486			break;
487		case METHOD_GSIF:
488			nv = sc->gsif;
489			break;
490		case METHOD_RBLL:
491			nv = sc->rbll;
492			break;
493		case METHOD_RVOL:
494			nv = sc->rvol;
495			break;
496		default:
497			return (FALSE);
498	}
499
500	if(!nv.exists)
501		return (EINVAL);
502
503	status = acpi_GetInteger(sc->handle, nv.name, &nv.value);
504	if (ACPI_FAILURE(status)) {
505		device_printf(sc->dev, "Couldn't query method (%s)\n", nv.name);
506		return (FALSE);
507	}
508
509	if (method == METHOD_MUTE) {
510		sc->bIsMuted = (uint8_t)((nv.value & VOLUME_MUTE_BIT) != 0);
511		return (sc->bIsMuted);
512	}
513
514	nv.value &= GENERAL_SETTING_BITS;
515	return (nv.value);
516}
517
518static int
519acpi_fujitsu_method_set(struct acpi_fujitsu_softc *sc, int method, int value)
520{
521	struct int_nameval	nv;
522	ACPI_STATUS		status;
523	char			*control;
524	int			changed;
525
526	ACPI_SERIAL_ASSERT(fujitsu);
527
528	switch (method) {
529		case METHOD_GBLL:
530			changed = BRIGHT_CHANGED;
531			control = "SBLL";
532			nv = sc->gbll;
533			break;
534		case METHOD_GBLS:
535			changed = BRIGHT_CHANGED;
536			control = "SBL2";
537			nv = sc->gbls;
538			break;
539		case METHOD_GMOU:
540			changed = MOUSE_CHANGED;
541			control = "SMOU";
542			nv = sc->gmou;
543			break;
544		case METHOD_GVOL:
545		case METHOD_MUTE:
546			changed = VOLUME_CHANGED;
547			control = "SVOL";
548			nv = sc->gvol;
549			break;
550		default:
551			return (EINVAL);
552	}
553
554	if(!nv.exists)
555		return (EINVAL);
556
557	if (method == METHOD_MUTE) {
558		if (value == 1)
559			value = nv.value | VOLUME_MUTE_BIT;
560		else if (value == 0)
561			value = nv.value & ~VOLUME_MUTE_BIT;
562		else
563			return (EINVAL);
564	}
565
566	status = acpi_SetInteger(sc->handle, control, value);
567	if (ACPI_FAILURE(status)) {
568		device_printf(sc->dev, "Couldn't update %s\n", control);
569		return (FALSE);
570	}
571
572	sc->lastValChanged = changed;
573	return (0);
574}
575
576/*
577 * Query the get methods to determine what functionality is available
578 * from the hardware function hotkeys.
579 */
580static uint8_t
581acpi_fujitsu_check_hardware(struct acpi_fujitsu_softc *sc)
582{
583	int val;
584
585	ACPI_SERIAL_ASSERT(fujitsu);
586	/* save the hotkey bitmask */
587	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
588	sc->gsif.name, &(sc->gsif.value)))) {
589		sc->gsif.exists = 0;
590		device_printf(sc->dev, "Couldn't query bitmask value\n");
591	} else {
592		sc->gsif.exists = 1;
593	}
594
595	/* System Volume Level */
596	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
597	    sc->gvol.name, &val))) {
598		sc->gvol.exists = 0;
599	} else {
600		sc->gvol.exists = 1;
601	}
602
603	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
604		sc->gbls.name, &val))) {
605		sc->gbls.exists = 0;
606	} else {
607		sc->gbls.exists = 1;
608	}
609
610	// don't add if we can use the new method
611	if (sc->gbls.exists || ACPI_FAILURE(acpi_GetInteger(sc->handle,
612	    sc->gbll.name, &val))) {
613		sc->gbll.exists = 0;
614	} else {
615		sc->gbll.exists = 1;
616	}
617
618	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
619	    sc->ghks.name, &val))) {
620		sc->ghks.exists = 0;
621	} else {
622		sc->ghks.exists = 1;
623	}
624
625	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
626	    sc->gmou.name, &val))) {
627		sc->gmou.exists = 0;
628	} else {
629		sc->gmou.exists = 1;
630	}
631
632	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
633	    sc->rbll.name, &val))) {
634		sc->rbll.exists = 0;
635	} else {
636		sc->rbll.exists = 1;
637	}
638
639	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
640	    sc->rvol.name, &val))) {
641		sc->rvol.exists = 0;
642	} else {
643		sc->rvol.exists = 1;
644	}
645
646	return (TRUE);
647}
648
649/*
650 * Query each of the ACPI control methods that contain information we're
651 * interested in. We check the return values from the control methods and
652 * adjust any state variables if they should be adjusted.
653 */
654static uint8_t
655acpi_fujitsu_update(struct acpi_fujitsu_softc *sc)
656{
657	int changed;
658	struct acpi_softc *acpi_sc;
659
660	acpi_sc = acpi_device_get_parent_softc(sc->dev);
661
662	ACPI_SERIAL_ASSERT(fujitsu);
663	if(sc->gsif.exists)
664		changed = sc->gsif.value & acpi_fujitsu_method_get(sc,METHOD_GHKS);
665	else
666		changed = 0;
667
668	/* System Volume Level */
669	if(sc->gvol.exists) {
670		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
671		sc->gvol.name, &(sc->gvol.value)))) {
672			device_printf(sc->dev, "Couldn't query volume level\n");
673			return (FALSE);
674		}
675
676		if (changed & VOLUME_CHANGED) {
677			sc->bIsMuted =
678			(uint8_t)((sc->gvol.value & VOLUME_MUTE_BIT) != 0);
679
680			/* Clear the modification bit */
681			sc->gvol.value &= VOLUME_SETTING_BITS;
682
683			if (sc->bIsMuted) {
684				acpi_UserNotify("FUJITSU", sc->handle, FN_MUTE);
685				ACPI_VPRINT(sc->dev, acpi_sc, "Volume is now mute\n");
686			} else
687				ACPI_VPRINT(sc->dev, acpi_sc, "Volume is now %d\n",
688				sc->gvol.value);
689
690			acpi_UserNotify("FUJITSU", sc->handle, FN_VOLUME);
691		}
692	}
693
694	/* Internal mouse pointer (eraserhead) */
695	if(sc->gmou.exists) {
696		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
697		sc->gmou.name, &(sc->gmou.value)))) {
698			device_printf(sc->dev, "Couldn't query pointer state\n");
699			return (FALSE);
700		}
701
702		if (changed & MOUSE_CHANGED) {
703			sc->bIntPtrEnabled = (uint8_t)(sc->gmou.value & 0x1);
704
705			/* Clear the modification bit */
706			sc->gmou.value &= MOUSE_SETTING_BITS;
707
708			/* Set the value in case it is not hardware controlled */
709                        acpi_fujitsu_method_set(sc, METHOD_GMOU, sc->gmou.value);
710
711			acpi_UserNotify("FUJITSU", sc->handle, FN_POINTER_ENABLE);
712
713			ACPI_VPRINT(sc->dev, acpi_sc, "Internal pointer is now %s\n",
714			(sc->bIntPtrEnabled) ? "enabled" : "disabled");
715		}
716	}
717
718	/* Screen Brightness Level P8XXX */
719	if(sc->gbls.exists) {
720		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
721                sc->gbls.name, &(sc->gbls.value)))) {
722                        device_printf(sc->dev, "Couldn't query P8XXX brightness level\n");
723                        return (FALSE);
724                }
725		if (changed & BRIGHT_CHANGED) {
726			/* No state to record here. */
727
728			/* Clear the modification bit */
729			sc->gbls.value &= BRIGHTNESS_SETTING_BITS;
730
731			/* Set the value in case it is not hardware controlled */
732			acpi_fujitsu_method_set(sc, METHOD_GBLS, sc->gbls.value);
733
734			acpi_UserNotify("FUJITSU", sc->handle, FN_LCD_BRIGHTNESS);
735
736			ACPI_VPRINT(sc->dev, acpi_sc, "P8XXX Brightness level is now %d\n",
737			sc->gbls.value);
738                }
739	}
740
741	/* Screen Brightness Level */
742	if(sc->gbll.exists) {
743		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
744		sc->gbll.name, &(sc->gbll.value)))) {
745			device_printf(sc->dev, "Couldn't query brightness level\n");
746			return (FALSE);
747		}
748
749		if (changed & BRIGHT_CHANGED) {
750			/* No state to record here. */
751
752			/* Clear the modification bit */
753			sc->gbll.value &= BRIGHTNESS_SETTING_BITS;
754
755			acpi_UserNotify("FUJITSU", sc->handle, FN_LCD_BRIGHTNESS);
756
757			ACPI_VPRINT(sc->dev, acpi_sc, "Brightness level is now %d\n",
758			sc->gbll.value);
759		}
760	}
761
762	sc->lastValChanged = changed;
763	return (TRUE);
764}
765