Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / macintosh / adbhid.c
index c69d23b..394334e 100644 (file)
@@ -34,6 +34,7 @@
  * Move to syfs
  */
 
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/pmu.h>
 
 #include <asm/machdep.h>
-#include <asm/backlight.h>
 #ifdef CONFIG_PPC_PMAC
 #include <asm/pmac_feature.h>
 #endif
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+#include <asm/backlight.h>
+#endif
+
 MODULE_AUTHOR("Franz Sirl <Franz.Sirl-kernel@lauterbach.com>");
 
 #define KEYB_KEYREG    0       /* register # for key up/down data */
@@ -175,7 +179,7 @@ u8 adb_to_linux_keycodes[128] = {
        /* 0x65 */ KEY_F9,              /*  67 */
        /* 0x66 */ KEY_HANJA,           /* 123 */
        /* 0x67 */ KEY_F11,             /*  87 */
-       /* 0x68 */ KEY_HANGEUL,         /* 122 */
+       /* 0x68 */ KEY_HANGUEL,         /* 122 */
        /* 0x69 */ KEY_SYSRQ,           /*  99 */
        /* 0x6a */ 0,
        /* 0x6b */ KEY_SCROLLLOCK,      /*  70 */
@@ -234,6 +238,11 @@ static struct adb_ids keyboard_ids;
 static struct adb_ids mouse_ids;
 static struct adb_ids buttons_ids;
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+/* Exported to via-pmu.c */
+int disable_kernel_backlight = 0;
+#endif /* CONFIG_PMAC_BACKLIGHT */
+
 /* Kind of keyboard, see Apple technote 1152  */
 #define ADB_KEYBOARD_UNKNOWN   0
 #define ADB_KEYBOARD_ANSI      0x0100
@@ -494,7 +503,9 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
        case 0x1f: /* Powerbook button device */
          {
                int down = (data[1] == (data[1] & 0xf));
-
+#ifdef CONFIG_PMAC_BACKLIGHT
+               int backlight = get_backlight_level();
+#endif
                /*
                 * XXX: Where is the contrast control for the passive?
                 *  -- Cort
@@ -519,17 +530,29 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
 
                case 0xa:       /* brightness decrease */
 #ifdef CONFIG_PMAC_BACKLIGHT
-                       if (down)
-                               pmac_backlight_key_down();
-#endif
+                       if (!disable_kernel_backlight) {
+                               if (down && backlight >= 0) {
+                                       if (backlight > BACKLIGHT_OFF)
+                                               set_backlight_level(backlight-1);
+                                       else
+                                               set_backlight_level(BACKLIGHT_OFF);
+                               }
+                       }
+#endif /* CONFIG_PMAC_BACKLIGHT */
                        input_report_key(adbhid[id]->input, KEY_BRIGHTNESSDOWN, down);
                        break;
 
                case 0x9:       /* brightness increase */
 #ifdef CONFIG_PMAC_BACKLIGHT
-                       if (down)
-                               pmac_backlight_key_up();
-#endif
+                       if (!disable_kernel_backlight) {
+                               if (down && backlight >= 0) {
+                                       if (backlight < BACKLIGHT_MAX)
+                                               set_backlight_level(backlight+1);
+                                       else 
+                                               set_backlight_level(BACKLIGHT_MAX);
+                               }
+                       }
+#endif /* CONFIG_PMAC_BACKLIGHT */
                        input_report_key(adbhid[id]->input, KEY_BRIGHTNESSUP, down);
                        break;