--- linux-2.6.32-orig/drivers/input/mouse/alps.c 2010-11-23 14:07:11.000000000 +0100 +++ linux-2.6.32/drivers/input/mouse/alps.c 2010-11-23 14:01:34.000000000 +0100 @@ -61,6 +61,8 @@ static const struct alps_model_info alps /* Dell Latitude E5500, E6400, E6500, Precision M4400 */ { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, + /* Dell Precision 4500 */ + { { 0x73, 0x02, 0x64 }, 0x80, 0x80, 0 }, { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 }, /* Dell Vostro 1400 */ { { 0x52, 0x01, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */ @@ -109,6 +111,33 @@ static const struct alps_model_info alps * on a dualpoint, etc. */ + +static int dell_e2_setup_intellimouse_mode(void *data); + +static struct alps_model_quirk alps_model_init_quirk_tbl[] = { + + { {0x73, 0x02, 0x64}, dell_e2_setup_intellimouse_mode }, + {} +}; + +static int alps_model_init_quirk(struct psmouse *psmouse, + const struct alps_model_info *model) +{ + + int rc = 1; + struct alps_model_quirk *d = alps_model_init_quirk_tbl; + + for (d = alps_model_init_quirk_tbl; d; d++) { + if (!memcmp(model->signature, d->signature, + sizeof(d->signature))) { + rc = d->callback(psmouse); + break; + } + } + + return rc; +} + static bool alps_is_valid_first_byte(const struct alps_model_info *model, unsigned char data) { @@ -652,11 +681,64 @@ static void alps_disconnect(struct psmou kfree(priv); } +/* Magic Sequence to enable Intellimouse Mode on Dell E2 Touchpads*/ + +static int dell_e2_setup_intellimouse_mode(void *data) +{ + struct psmouse *psmouse = (struct psmouse *)(data); + struct ps2dev *ps2dev = &psmouse->ps2dev; + struct input_dev *dev = psmouse->dev; + unsigned char param[3] = {0, 0, 0}; + + if (ps2_command(ps2dev, param, 0x00f5) || + ps2_command(ps2dev, param, 0x00ea) || + ps2_command(ps2dev, param, 0x00ec) || + ps2_command(ps2dev, param, 0x00ec) || + ps2_command(ps2dev, param, 0x00ec) || + ps2_command(ps2dev, param, 0x03e9)) + return -1; + + dbg("alps:dell_e2_setup: param[0]: %x," + "param[1]: %x, param[2]: %x\n", param[0], + param[1], param[2]); +/* Check for supported model to continue */ + + if (!((param[0] == 0x88) && (param[1] == 0x07) + && ((param[2] == 0x9D) || (param[2] == 0x9B)))) + return -1; + + if (ps2_command(ps2dev, NULL, 0x00ec) || + ps2_command(ps2dev, NULL, 0x00f0) || + ps2_command(ps2dev, NULL, 0x00f0) || + ps2_command(ps2dev, NULL, 0x00f0) || + ps2_command(ps2dev, NULL, 0x00f3) || + ps2_command(ps2dev, NULL, 0x0028) || + ps2_command(ps2dev, NULL, 0x00f0) || + ps2_command(ps2dev, NULL, 0x00f6) || + ps2_command(ps2dev, NULL, 0x00ea) || + ps2_command(ps2dev, NULL, 0x00f4)) + return -1; + + __set_bit(BTN_MIDDLE, dev->keybit); + __set_bit(REL_WHEEL, dev->relbit); + + psmouse->pktsize = 4; + psmouse->type = PSMOUSE_IMPS; + + return 0; +} + int alps_init(struct psmouse *psmouse) { struct alps_data *priv; struct input_dev *dev1 = psmouse->dev, *dev2; int version; + const struct alps_model_info *model; + + model = alps_get_model(psmouse, &version); + + if (!model) + return -1; priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL); dev2 = input_allocate_device(); @@ -670,7 +752,15 @@ int alps_init(struct psmouse *psmouse) if (alps_hw_init(psmouse, &version)) goto init_fail; - + + if (!alps_model_init_quirk(psmouse, model)) { + printk(KERN_WARNING "alps.c: Enabled hardware quirk, falling back to psmouse-core\n"); + input_free_device(dev2); + kfree(priv); + psmouse->private = NULL; + return 0; + } + dev1->evbit[BIT_WORD(EV_KEY)] |= BIT_MASK(EV_KEY); dev1->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH); dev1->keybit[BIT_WORD(BTN_TOOL_FINGER)] |= BIT_MASK(BTN_TOOL_FINGER); --- linux-2.6.32-orig/drivers/input/mouse/alps.h 2010-11-23 14:07:11.000000000 +0100 +++ linux-2.6.32/drivers/input/mouse/alps.h 2010-11-22 12:18:19.000000000 +0100 @@ -26,6 +26,11 @@ struct alps_data { struct timer_list timer; }; +struct alps_model_quirk { +unsigned char signature[3]; +int (*callback)(void *data); +}; + #ifdef CONFIG_MOUSE_PS2_ALPS int alps_detect(struct psmouse *psmouse, bool set_properties); int alps_init(struct psmouse *psmouse); --- linux-2.6.32-orig/drivers/input/mouse/psmouse-base.c 2010-11-23 14:07:11.000000000 +0100 +++ linux-2.6.32/drivers/input/mouse/psmouse-base.c 2010-11-22 12:18:19.000000000 +0100 @@ -633,7 +633,8 @@ static int psmouse_extensions(struct psm ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); if (alps_detect(psmouse, set_properties) == 0) { if (!set_properties || alps_init(psmouse) == 0) - return PSMOUSE_ALPS; + /*If ALPS model quirk was applied, don't change the settings*/ + return psmouse->type ? psmouse->type : PSMOUSE_ALPS; /* * Init failed, try basic relative protocols */