From: Dmitry Torokhov Add reconnect method to atkbd to restore keyboard state after suspend (to be called from i8042 resume function) drivers/input/keyboard/atkbd.c | 53 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+) diff -puN drivers/input/keyboard/atkbd.c~input-04-atkbd-reconnect-method drivers/input/keyboard/atkbd.c --- 25/drivers/input/keyboard/atkbd.c~input-04-atkbd-reconnect-method 2003-12-16 22:47:36.000000000 -0800 +++ 25-akpm/drivers/input/keyboard/atkbd.c 2003-12-16 22:47:36.000000000 -0800 @@ -700,9 +700,62 @@ static void atkbd_connect(struct serio * printk(KERN_INFO "input: %s on %s\n", atkbd->name, serio->phys); } +/* + * atkbd_reconnect() tries to restore keyboard into a sane state and is + * most likely called on resume. + */ + +static int atkbd_reconnect(struct serio *serio) +{ + struct atkbd *atkbd = serio->private; + struct serio_dev *dev = serio->dev; + int i; + + if (!dev) { + printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n"); + return -1; + } + + if (atkbd->write) { + if (atkbd_probe(atkbd)) + return -1; + + atkbd->set = atkbd_set_3(atkbd); + atkbd_enable(atkbd); + } else { + atkbd->set = 2; + atkbd->id = 0xab00; + } + + /* + * Here we probably should check if the keyboard has the same set that + * it had before and bail out if it's different. But this will most likely + * cause new keyboard device be created... and for the user it will look + * like keyboard is lost + */ + + if (atkbd->translated) { + for (i = 0; i < 128; i++) { + atkbd->keycode[i] = atkbd_set2_keycode[atkbd_unxlate_table[i]]; + atkbd->keycode[i | 0x80] = atkbd_set2_keycode[atkbd_unxlate_table[i] | 0x80]; + } + } else if (atkbd->set == 2) { + memcpy(atkbd->keycode, atkbd_set2_keycode, sizeof(atkbd->keycode)); + } else { + memcpy(atkbd->keycode, atkbd_set3_keycode, sizeof(atkbd->keycode)); + } + + for (i = 0; i < 512; i++) + if (atkbd->keycode[i] && atkbd->keycode[i] < 255) + set_bit(atkbd->keycode[i], atkbd->dev.keybit); + + return 0; +} + static struct serio_dev atkbd_dev = { .interrupt = atkbd_interrupt, .connect = atkbd_connect, + .reconnect = atkbd_reconnect, .disconnect = atkbd_disconnect, .cleanup = atkbd_cleanup, }; _