patch-2.2.18 linux/drivers/macintosh/mac_keyb.c
Next file: linux/drivers/macintosh/macserial.c
Previous file: linux/drivers/macintosh/mac_hid.c
Back to the patch index
Back to the overall index
- Lines: 236
- Date:
Wed Nov 8 23:00:34 2000
- Orig file:
v2.2.17/drivers/macintosh/mac_keyb.c
- Orig date:
Sat Sep 9 18:42:38 2000
diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/drivers/macintosh/mac_keyb.c linux/drivers/macintosh/mac_keyb.c
@@ -16,7 +16,7 @@
*
* - Standard 1 button mouse
* - All standard Apple Extended protocol (handler ID 4)
- * - mouseman and trackman mice & trackballs
+ * - mouseman and trackman mice & trackballs
* - PowerBook Trackpad (default setup: enable tapping)
* - MicroSpeed mouse & trackball (needs testing)
* - CH Products Trackball Pro (needs testing)
@@ -48,10 +48,16 @@
#include <asm/cuda.h>
#include <asm/pmu.h>
#include <asm/init.h>
+#include <asm/machdep.h>
+#include <asm/backlight.h>
#include <linux/kbd_kern.h>
#include <linux/kbd_ll.h>
+#ifdef CONFIG_PMAC_BACKLIGHT
+#include <asm/backlight.h>
+#endif
+
#define KEYB_KEYREG 0 /* register # for key up/down data */
#define KEYB_LEDREG 2 /* register # for leds on ADB keyboard */
#define MOUSE_DATAREG 0 /* reg# for movement/button codes from mouse */
@@ -226,7 +232,7 @@
static void kbd_repeat(unsigned long);
-static struct timer_list repeat_timer = { NULL, NULL, 0, 0, kbd_repeat };
+static struct timer_list repeat_timer = { function: kbd_repeat };
static int last_keycode;
static void mackeyb_probe(void);
@@ -347,7 +353,7 @@
#ifdef CONFIG_ADBMOUSE
/*
* XXX: Add mouse button 2+3 fake codes here if mouse open.
- * Keep track of 'button' states here as we only send
+ * Keep track of 'button' states here as we only send
* single up/down events!
* Really messy; might need to check if keyboard is in
* VC_RAW mode.
@@ -587,61 +593,47 @@
}
#endif /* CONFIG_ADBMOUSE */
-/* XXX Needs to get rid of this, see comments in pmu.c */
-extern int backlight_level;
-
static void
buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll)
{
+ int backlight = get_backlight_level();
+
/*
* XXX: Where is the contrast control for the passive?
* -- Cort
*/
-
+
/* Ignore data from register other than 0 */
- if ((adb_hardware != ADB_VIAPMU) || (data[0] & 0x3) || (nb < 2))
+ if ((data[0] & 0x3) || (nb < 2))
return;
- switch (data[1]&0xf )
- {
- /* mute */
- case 0x8:
- /* down event */
- if ( data[1] == (data[1]&0xf) ) {
- }
- break;
- /* contrast decrease */
- case 0x7:
- /* down event */
- if ( data[1] == (data[1]&0xf) ) {
- }
- break;
- /* contrast increase */
- case 0x6:
- /* down event */
- if ( data[1] == (data[1]&0xf) ) {
- }
- break;
- /* brightness decrease */
- case 0xa:
- /* down event */
- if ( data[1] == (data[1]&0xf) ) {
- if (backlight_level > 2)
- pmu_set_brightness(backlight_level-2);
- else
- pmu_set_brightness(0);
- }
+ switch (data[1]) {
+ case 0x8: /* mute */
+ break;
+
+ case 0x7: /* contrast decrease */
+ break;
+
+ case 0x6: /* contrast increase */
+ break;
+
+ case 0xa: /* brightness decrease */
+ if (backlight < 0)
break;
- /* brightness increase */
- case 0x9:
- /* down event */
- if ( data[1] == (data[1]&0xf) ) {
- if (backlight_level < 0x1e)
- pmu_set_brightness(backlight_level+2);
- else
- pmu_set_brightness(0x1f);
- }
+ if (backlight > BACKLIGHT_OFF)
+ set_backlight_level(backlight-1);
+ else
+ set_backlight_level(BACKLIGHT_OFF);
+ break;
+
+ case 0x9: /* brightness increase */
+ if (backlight < 0)
break;
+ if (backlight < BACKLIGHT_MAX)
+ set_backlight_level(backlight+1);
+ else
+ set_backlight_level(BACKLIGHT_MAX);
+ break;
}
}
@@ -702,10 +694,10 @@
}
-__initfunc(void mackbd_init_hw(void))
+void __init mackbd_init_hw(void)
{
if ( (_machine != _MACH_chrp) && (_machine != _MACH_Pmac) )
- return;
+ return;
/* setup key map */
memcpy(key_maps[0], macplain_map, sizeof(plain_map));
@@ -736,7 +728,7 @@
switch (code) {
case ADB_MSG_PRE_RESET:
case ADB_MSG_POWERDOWN:
- /* Stop the repeat timer. Autopoll is already off at this point */
+ /* Stop the repeat timer. Autopoll is already off at this point */
save_flags(flags);
cli();
del_timer(&repeat_timer);
@@ -842,7 +834,7 @@
if ((req.reply_len) &&
(req.reply[1] == 0x9a) && ((req.reply[2] == 0x21)
- || (req.reply[2] == 0x20)))
+ || (req.reply[2] == 0x20)))
init_trackball(id);
else if ((req.reply_len >= 4) &&
(req.reply[1] == 0x74) && (req.reply[2] == 0x70) &&
@@ -865,7 +857,7 @@
}
}
-static void
+static void
init_trackpad(int id)
{
struct adb_request req;
@@ -895,15 +887,15 @@
adb_request(&req, NULL, ADBREQ_SYNC, 9,
ADB_WRITEREG(id,2),
- 0x99,
- 0x94,
- 0x19,
- 0xff,
- 0xb2,
- 0x8a,
- 0x1b,
- 0x50);
-
+ 0x99,
+ 0x94,
+ 0x19,
+ 0xff,
+ 0xb2,
+ 0x8a,
+ 0x1b,
+ 0x50);
+
adb_request(&req, NULL, ADBREQ_SYNC, 9,
ADB_WRITEREG(id,1),
r1_buffer[0],
@@ -917,7 +909,7 @@
}
}
-static void
+static void
init_trackball(int id)
{
struct adb_request req;
@@ -1000,7 +992,7 @@
/* This will initialize mice using the Microspeed, MacPoint and
other compatible firmware. Bit 12 enables extended protocol.
-
+
Register 1 Listen (4 Bytes)
0 - 3 Button is mouse (set also for double clicking!!!)
4 - 7 Button is locking (affects change speed also)
@@ -1015,7 +1007,7 @@
0 - 7 Product code
8 - 23 undefined, reserved
24 - 31 Version number
-
+
Speed 0 is max. 1 to 255 set speed in increments of 1/256 of max.
*/
adb_request(&req, NULL, ADBREQ_SYNC, 5,
@@ -1039,7 +1031,7 @@
ADB_WRITEREG(id, 0x2),
0x00,
0x07);
-
+
adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id));
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)