kernel: Use DEVMETHOD_END in the drivers.
[dragonfly.git] / sys / dev / acpica / acpi_fujitsu / acpi_fujitsu.c
1 /*-
2  * Copyright (c) 2002 Sean Bullington <seanATstalker.org>
3  *               2003-2006 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: src/sys/dev/acpi_support/acpi_fujitsu.c,v 1.7 2009/06/05 18:44:36 jkim
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 ACPI CA 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
88 /* Notify event */
89 #define ACPI_NOTIFY_STATUS_CHANGED      0x80
90
91 /*
92  * Holds a control method name and its associated integer value.
93  * Only used for no-argument control methods which return a value.
94  */
95 struct int_nameval {
96         char    *name;
97         int     value;
98         int     exists;
99 };
100
101 /*
102  * Driver extension for the FUJITSU ACPI driver.
103  */
104 struct acpi_fujitsu_softc {
105         device_t        dev;
106         ACPI_HANDLE     handle;
107
108         /* Control methods */
109         struct int_nameval      _sta,   /* unused */
110                                 gbll,   /* brightness */
111                                 ghks,   /* hotkey selector */
112                                 gbuf,   /* unused (buffer?) */
113                                 gmou,   /* mouse */
114                                 gsif,   /* function key bitmask */
115                                 gvol,   /* volume */
116                                 rbll,   /* number of brightness levels (radix) */
117                                 rvol;   /* number of volume levels (radix) */
118
119         /* State variables */
120         uint8_t         bIsMuted;       /* Is volume muted */
121         uint8_t         bIntPtrEnabled; /* Is internal ptr enabled */
122         uint32_t        lastValChanged; /* The last value updated */
123
124         /* sysctl tree */
125         struct sysctl_ctx_list  sysctl_ctx;
126         struct sysctl_oid       *sysctl_tree;
127 };
128
129 /* Driver entry point forward declarations. */
130 static int      acpi_fujitsu_probe(device_t dev);
131 static int      acpi_fujitsu_attach(device_t dev);
132 static int      acpi_fujitsu_detach(device_t dev);
133 static int      acpi_fujitsu_suspend(device_t dev);
134 static int      acpi_fujitsu_resume(device_t dev);
135
136 static void     acpi_fujitsu_notify_status_changed(void *arg);
137 static void     acpi_fujitsu_notify_handler(ACPI_HANDLE h, uint32_t notify, void *context);
138 static int      acpi_fujitsu_sysctl(SYSCTL_HANDLER_ARGS);
139
140 /* Utility function declarations */
141 static uint8_t acpi_fujitsu_update(struct acpi_fujitsu_softc *sc);
142 static uint8_t acpi_fujitsu_init(struct acpi_fujitsu_softc *sc);
143 static uint8_t acpi_fujitsu_check_hardware(struct acpi_fujitsu_softc *sc);
144
145 /* Driver/Module specific structure definitions. */
146 static device_method_t acpi_fujitsu_methods[] = {
147         /* Device interface */
148         DEVMETHOD(device_probe,         acpi_fujitsu_probe),
149         DEVMETHOD(device_attach,        acpi_fujitsu_attach),
150         DEVMETHOD(device_detach,        acpi_fujitsu_detach),
151         DEVMETHOD(device_suspend,       acpi_fujitsu_suspend),
152         DEVMETHOD(device_resume,        acpi_fujitsu_resume),
153         DEVMETHOD_END
154 };
155
156 static driver_t acpi_fujitsu_driver = {
157         "acpi_fujitsu",
158         acpi_fujitsu_methods,
159         sizeof(struct acpi_fujitsu_softc),
160 };
161
162 /* Prototype for function hotkeys for getting/setting a value. */
163 static int acpi_fujitsu_method_get(struct acpi_fujitsu_softc *sc, int method);
164 static int acpi_fujitsu_method_set(struct acpi_fujitsu_softc *sc, int method, int value);
165
166 static char *fujitsu_ids[] = { "FUJ02B1", NULL };
167
168 ACPI_SERIAL_DECL(fujitsu, "Fujitsu Function Hotkeys");
169
170 /* sysctl names and function calls */
171 static struct {
172         char            *name;
173         int             method;
174         char            *description;
175 } sysctl_table[] = {
176         {
177                 .name           = "mute",
178                 .method         = METHOD_MUTE,
179                 .description    = "Speakers/headphones mute status"
180         },
181         {
182                 .name           = "pointer_enable",
183                 .method         = METHOD_GMOU,
184                 .description    = "Enable and disable the internal pointer"
185         },
186         {
187                 .name           = "lcd_brightness",
188                 .method         = METHOD_GBLL,
189                 .description    = "Brightness level of the LCD panel"
190         },
191         {
192                 .name           = "volume",
193                 .method         = METHOD_GVOL,
194                 .description    = "Speakers/headphones volume level"
195         },
196         {
197                 .name           = "volume_radix",
198                 .method         = METHOD_RVOL,
199                 .description    = "Number of volume level steps"
200         },
201         {
202                 .name           = "lcd_brightness_radix",
203                 .method         = METHOD_RBLL,
204                 .description    = "Number of brightness level steps"
205         },
206
207         { NULL, 0, NULL }
208 };
209
210 static devclass_t acpi_fujitsu_devclass;
211 DRIVER_MODULE(acpi_fujitsu, acpi, acpi_fujitsu_driver,
212     acpi_fujitsu_devclass, 0, 0);
213 MODULE_DEPEND(acpi_fujitsu, acpi, 1, 1, 1);
214 MODULE_VERSION(acpi_fujitsu, 1);
215
216 static int
217 acpi_fujitsu_probe(device_t dev)
218 {
219         char *name;
220         char buffer[64];
221
222         name = ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids);
223         if (acpi_disabled("fujitsu") || name == NULL ||
224             device_get_unit(dev) > 1)
225                 return (ENXIO);
226
227         ksprintf(buffer, "Fujitsu Function Hotkeys %s", name);
228         device_set_desc_copy(dev, buffer);
229
230         return (0);
231 }
232
233 static int
234 acpi_fujitsu_attach(device_t dev)
235 {
236         struct acpi_fujitsu_softc *sc;
237
238         ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
239
240         sc = device_get_softc(dev);
241         sc->dev = dev;
242         sc->handle = acpi_get_handle(dev);
243
244         /* Install notification handler */
245         AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
246             acpi_fujitsu_notify_handler, sc);
247
248         /* Snag our default values for the hotkeys / hotkey states. */
249         ACPI_SERIAL_BEGIN(fujitsu);
250         if (!acpi_fujitsu_init(sc))
251                 device_printf(dev, "Couldn't initialize hotkey states!\n");
252         ACPI_SERIAL_END(fujitsu);
253
254         return (0);
255 }
256
257 /*
258  * Called when the system is being suspended, simply
259  * set an event to be signalled when we wake up.
260  */
261 static int
262 acpi_fujitsu_suspend(device_t dev)
263 {
264
265         return (0);
266 }
267
268 static int
269 acpi_fujitsu_resume(device_t dev)
270 {
271         struct acpi_fujitsu_softc   *sc;
272         ACPI_STATUS                 status;
273
274         sc = device_get_softc(dev);
275
276         /*
277          * The pointer needs to be re-enabled for
278          * some revisions of the P series (2120).
279          */
280         ACPI_SERIAL_BEGIN(fujitsu);
281
282         if(sc->gmou.exists) {
283                 status = acpi_SetInteger(sc->handle, "SMOU", 1);
284                 if (ACPI_FAILURE(status))
285                         device_printf(sc->dev, "Couldn't enable pointer\n");
286         }
287         ACPI_SERIAL_END(fujitsu);
288
289         return (0);
290 }
291
292 static void
293 acpi_fujitsu_notify_status_changed(void *arg)
294 {
295         struct acpi_fujitsu_softc *sc;
296
297         ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
298
299         sc = (struct acpi_fujitsu_softc *)arg;
300
301         /*
302          * Since our notify function is called, we know something has
303          * happened.  So the only reason for acpi_fujitsu_update to fail
304          * is if we can't find what has changed or an error occurs.
305          */
306         ACPI_SERIAL_BEGIN(fujitsu);
307         acpi_fujitsu_update(sc);
308         ACPI_SERIAL_END(fujitsu);
309 }
310
311
312 static void
313 acpi_fujitsu_notify_handler(ACPI_HANDLE h, uint32_t notify, void *context)
314 {
315         struct acpi_fujitsu_softc *sc;
316
317         ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, notify);
318
319         sc = (struct acpi_fujitsu_softc *)context;
320
321         switch (notify) {
322         case ACPI_NOTIFY_STATUS_CHANGED:
323                 AcpiOsExecute(OSL_NOTIFY_HANDLER,
324                     acpi_fujitsu_notify_status_changed, sc);
325                 break;
326         default:
327                 /* unknown notification value */
328                 break;
329         }
330 }
331
332 static int
333 acpi_fujitsu_detach(device_t dev)
334 {
335         struct acpi_fujitsu_softc *sc;
336
337         sc = device_get_softc(dev);
338         AcpiRemoveNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
339            acpi_fujitsu_notify_handler);
340
341         sysctl_ctx_free(&sc->sysctl_ctx);
342
343         return (0);
344 }
345
346 /*
347  * Initializes the names of the ACPI control methods and grabs
348  * the current state of all of the ACPI hotkeys into the softc.
349  */
350 static uint8_t
351 acpi_fujitsu_init(struct acpi_fujitsu_softc *sc)
352 {
353         struct acpi_softc *acpi_sc;
354         int i, exists;
355
356         ACPI_SERIAL_ASSERT(fujitsu);
357
358         /* Setup all of the names for each control method */
359         sc->_sta.name = "_STA";
360         sc->gbll.name = "GBLL";
361         sc->ghks.name = "GHKS";
362         sc->gmou.name = "GMOU";
363         sc->gsif.name = "GSIF";
364         sc->gvol.name = "GVOL";
365         sc->ghks.name = "GHKS";
366         sc->gsif.name = "GSIF";
367         sc->rbll.name = "RBLL";
368         sc->rvol.name = "RVOL";
369
370         /* Determine what hardware functionality is available */
371         acpi_fujitsu_check_hardware(sc);
372
373         /* Build the sysctl tree */
374         acpi_sc = acpi_device_get_parent_softc(sc->dev);
375         sysctl_ctx_init(&sc->sysctl_ctx);
376         sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx,
377             SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree),
378             OID_AUTO, "fujitsu", CTLFLAG_RD, 0, "");
379
380         for (i = 0; sysctl_table[i].name != NULL; i++) {
381                 exists = 0;
382                 switch(sysctl_table[i].method) {
383                         case METHOD_GMOU:
384                                 exists = sc->gmou.exists;
385                                 break;
386                         case METHOD_GBLL:
387                                 exists = sc->gbll.exists;
388                                 break;
389                         case METHOD_GVOL:
390                         case METHOD_MUTE:
391                                 exists = sc->gvol.exists;
392                                 break;
393                         case METHOD_RVOL:
394                                 exists = sc->rvol.exists;
395                                 break;
396                         case METHOD_RBLL:
397                                 exists = sc->rbll.exists;
398                                 break;
399                         default:
400                                 /* Allow by default */
401                                 exists = 1;
402                                 break;
403                 }
404                 if(!exists)
405                         continue;
406                 SYSCTL_ADD_PROC(&sc->sysctl_ctx,
407                     SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
408                     sysctl_table[i].name,
409                     CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY,
410                     sc, i, acpi_fujitsu_sysctl, "I",
411                     sysctl_table[i].description);
412         }
413
414
415         /* Set the hotkeys to their initial states */
416         if (!acpi_fujitsu_update(sc)) {
417                 device_printf(sc->dev, "Couldn't init hotkey states\n");
418                 return (FALSE);
419         }
420
421         return (TRUE);
422 }
423
424 static int
425 acpi_fujitsu_sysctl(SYSCTL_HANDLER_ARGS)
426 {
427         struct acpi_fujitsu_softc       *sc;
428         int                             method;
429         int                             arg;
430         int                             function_num, error = 0;
431
432         sc = (struct acpi_fujitsu_softc *)oidp->oid_arg1;
433         function_num = oidp->oid_arg2;
434         method = sysctl_table[function_num].method;
435
436         ACPI_SERIAL_BEGIN(fujitsu);
437
438         /* Get the current value */
439         arg = acpi_fujitsu_method_get(sc, method);
440         error = sysctl_handle_int(oidp, &arg, 0, req);
441
442         if (error != 0 || req->newptr == NULL)
443                 goto out;
444
445         /* Update the value */
446         error = acpi_fujitsu_method_set(sc, method, arg);
447
448 out:
449         ACPI_SERIAL_END(fujitsu);
450         return (error);
451 }
452
453 static int
454 acpi_fujitsu_method_get(struct acpi_fujitsu_softc *sc, int method)
455 {
456         struct int_nameval      nv;
457         ACPI_STATUS             status;
458
459         ACPI_SERIAL_ASSERT(fujitsu);
460
461         switch (method) {
462                 case METHOD_GBLL:
463                         nv = sc->gbll;
464                         break;
465                 case METHOD_GMOU:
466                         nv = sc->gmou;
467                         break;
468                 case METHOD_GVOL:
469                 case METHOD_MUTE:
470                         nv = sc->gvol;
471                         break;
472                 case METHOD_GHKS:
473                         nv = sc->ghks;
474                         break;
475                 case METHOD_GSIF:
476                         nv = sc->gsif;
477                         break;
478                 case METHOD_RBLL:
479                         nv = sc->rbll;
480                         break;
481                 case METHOD_RVOL:
482                         nv = sc->rvol;
483                         break;
484                 default:
485                         return (FALSE);
486         }
487
488         if(!nv.exists)
489                 return (EINVAL);
490
491         status = acpi_GetInteger(sc->handle, nv.name, &nv.value);
492         if (ACPI_FAILURE(status)) {
493                 device_printf(sc->dev, "Couldn't query method (%s)\n", nv.name);
494                 return (FALSE);
495         }
496
497         if (method == METHOD_MUTE) {
498                 sc->bIsMuted = (uint8_t)((nv.value & VOLUME_MUTE_BIT) != 0);
499                 return (sc->bIsMuted);
500         }
501
502         nv.value &= GENERAL_SETTING_BITS;
503         return (nv.value);
504 }
505
506 static int
507 acpi_fujitsu_method_set(struct acpi_fujitsu_softc *sc, int method, int value)
508 {
509         struct int_nameval      nv;
510         ACPI_STATUS             status;
511         char                    *control;
512         int                     changed;
513
514         ACPI_SERIAL_ASSERT(fujitsu);
515
516         switch (method) {
517                 case METHOD_GBLL:
518                         changed = BRIGHT_CHANGED;
519                         control = "SBLL";
520                         nv = sc->gbll;
521                         break;
522                 case METHOD_GMOU:
523                         changed = MOUSE_CHANGED;
524                         control = "SMOU";
525                         nv = sc->gmou;
526                         break;
527                 case METHOD_GVOL:
528                 case METHOD_MUTE:
529                         changed = VOLUME_CHANGED;
530                         control = "SVOL";
531                         nv = sc->gvol;
532                         break;
533                 default:
534                         return (EINVAL);
535         }
536
537         if(!nv.exists)
538                 return (EINVAL);
539
540         if (method == METHOD_MUTE) {
541                 if (value == 1)
542                         value = nv.value | VOLUME_MUTE_BIT;
543                 else if (value == 0)
544                         value = nv.value & ~VOLUME_MUTE_BIT;
545                 else
546                         return (EINVAL);
547         }
548
549         status = acpi_SetInteger(sc->handle, control, value);
550         if (ACPI_FAILURE(status)) {
551                 device_printf(sc->dev, "Couldn't update %s\n", control);
552                 return (FALSE);
553         }
554
555         sc->lastValChanged = changed;
556         return (0);
557 }
558
559 /*
560  * Query the get methods to determine what functionality is available
561  * from the hardware function hotkeys.
562  */
563 static uint8_t
564 acpi_fujitsu_check_hardware(struct acpi_fujitsu_softc *sc)
565 {
566         int val;
567
568         ACPI_SERIAL_ASSERT(fujitsu);
569         /* save the hotkey bitmask */
570         if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
571         sc->gsif.name, &(sc->gsif.value)))) {
572                 sc->gsif.exists = 0;
573                 device_printf(sc->dev, "Couldn't query bitmask value\n");
574         } else {
575                 sc->gsif.exists = 1;
576         }
577
578         /* System Volume Level */
579         if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
580             sc->gvol.name, &val))) {
581                 sc->gvol.exists = 0;
582         } else {
583                 sc->gvol.exists = 1;
584         }
585
586         if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
587             sc->gbll.name, &val))) {
588                 sc->gbll.exists = 0;
589         } else {
590                 sc->gbll.exists = 1;
591         }
592
593         if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
594             sc->ghks.name, &val))) {
595                 sc->ghks.exists = 0;
596         } else {
597                 sc->ghks.exists = 1;
598         }
599
600         if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
601             sc->gmou.name, &val))) {
602                 sc->gmou.exists = 0;
603         } else {
604                 sc->gmou.exists = 1;
605         }
606
607         if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
608             sc->rbll.name, &val))) {
609                 sc->rbll.exists = 0;
610         } else {
611                 sc->rbll.exists = 1;
612         }
613
614         if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
615             sc->rvol.name, &val))) {
616                 sc->rvol.exists = 0;
617         } else {
618                 sc->rvol.exists = 1;
619         }
620
621         return (TRUE);
622 }
623
624 /*
625  * Query each of the ACPI control methods that contain information we're
626  * interested in. We check the return values from the control methods and
627  * adjust any state variables if they should be adjusted.
628  */
629 static uint8_t
630 acpi_fujitsu_update(struct acpi_fujitsu_softc *sc)
631 {
632         int changed;
633         struct acpi_softc *acpi_sc;
634
635         acpi_sc = acpi_device_get_parent_softc(sc->dev);
636
637         ACPI_SERIAL_ASSERT(fujitsu);
638         if(sc->gsif.exists)
639                 changed = sc->gsif.value & acpi_fujitsu_method_get(sc,METHOD_GHKS);
640         else
641                 changed = 0;
642
643         /* System Volume Level */
644         if(sc->gvol.exists) {
645                 if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
646                 sc->gvol.name, &(sc->gvol.value)))) {
647                         device_printf(sc->dev, "Couldn't query volume level\n");
648                         return (FALSE);
649                 }
650         
651                 if (changed & VOLUME_CHANGED) {
652                         sc->bIsMuted =
653                         (uint8_t)((sc->gvol.value & VOLUME_MUTE_BIT) != 0);
654         
655                         /* Clear the modification bit */
656                         sc->gvol.value &= VOLUME_SETTING_BITS;
657         
658                         if (sc->bIsMuted) {
659                                 acpi_UserNotify("FUJITSU", sc->handle, FN_MUTE);
660                                 ACPI_VPRINT(sc->dev, acpi_sc, "Volume is now mute\n");
661                         } else
662                                 ACPI_VPRINT(sc->dev, acpi_sc, "Volume is now %d\n",
663                                 sc->gvol.value);
664         
665                         acpi_UserNotify("FUJITSU", sc->handle, FN_VOLUME);
666                 }
667         }
668
669         /* Internal mouse pointer (eraserhead) */
670         if(sc->gmou.exists) {
671                 if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
672                 sc->gmou.name, &(sc->gmou.value)))) {
673                         device_printf(sc->dev, "Couldn't query pointer state\n");
674                         return (FALSE);
675                 }
676         
677                 if (changed & MOUSE_CHANGED) {
678                         sc->bIntPtrEnabled = (uint8_t)(sc->gmou.value & 0x1);
679         
680                         /* Clear the modification bit */
681                         sc->gmou.value &= MOUSE_SETTING_BITS;
682                         
683                         acpi_UserNotify("FUJITSU", sc->handle, FN_POINTER_ENABLE);
684         
685                         ACPI_VPRINT(sc->dev, acpi_sc, "Internal pointer is now %s\n",
686                         (sc->bIntPtrEnabled) ? "enabled" : "disabled");
687                 }
688         }
689
690         /* Screen Brightness Level */
691         if(sc->gbll.exists) {
692                 if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
693                 sc->gbll.name, &(sc->gbll.value)))) {
694                         device_printf(sc->dev, "Couldn't query brightness level\n");
695                         return (FALSE);
696                 }
697         
698                 if (changed & BRIGHT_CHANGED) {
699                         /* No state to record here. */
700         
701                         /* Clear the modification bit */
702                         sc->gbll.value &= BRIGHTNESS_SETTING_BITS;
703         
704                         acpi_UserNotify("FUJITSU", sc->handle, FN_LCD_BRIGHTNESS);
705         
706                         ACPI_VPRINT(sc->dev, acpi_sc, "Brightness level is now %d\n",
707                         sc->gbll.value);
708                 }
709         }
710
711         sc->lastValChanged = changed;
712         return (TRUE);
713 }