Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261420AbTIYQ4S (ORCPT ); Thu, 25 Sep 2003 12:56:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261246AbTIYQyN (ORCPT ); Thu, 25 Sep 2003 12:54:13 -0400 Received: from twilight.ucw.cz ([81.30.235.3]:38615 "EHLO twilight.ucw.cz") by vger.kernel.org with ESMTP id S261585AbTIYQug convert rfc822-to-8bit (ORCPT ); Thu, 25 Sep 2003 12:50:36 -0400 Subject: [PATCH 3/8] Synaptics code cleanups. In-Reply-To: <1064508612553@twilight.ucw.cz> X-Mailer: gregkh_patchbomb_levon_offspring Date: Thu, 25 Sep 2003 18:50:12 +0200 Message-Id: <10645086121942@twilight.ucw.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII To: akpm@osdl.org, dtor_core@ameritech.net, petero2@telia.com, Andries.Brouwer@cwi.nl, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7BIT From: Vojtech Pavlik Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9598 Lines: 311 You can pull this changeset from: bk://kernel.bkbits.net/vojtech/input =================================================================== ChangeSet@1.1343, 2003-09-25 18:19:41+02:00, dtor_core@ameritech.net input: Synaptics code cleanups. synaptics.c | 161 +++++++++++++++++++++++++++++++----------------------------- 1 files changed, 85 insertions(+), 76 deletions(-) =================================================================== diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c --- a/drivers/input/mouse/synaptics.c Thu Sep 25 18:37:35 2003 +++ b/drivers/input/mouse/synaptics.c Thu Sep 25 18:37:35 2003 @@ -36,7 +36,7 @@ * Use the Synaptics extended ps/2 syntax to write a special command byte. * special command: 0xE8 rr 0xE8 ss 0xE8 tt 0xE8 uu where (rr*64)+(ss*16)+(tt*4)+uu * is the command. A 0xF3 or 0xE9 must follow (see synaptics_send_cmd - * and synaptics_set_mode) + * and synaptics_mode_cmd) */ static int synaptics_special_cmd(struct psmouse *psmouse, unsigned char command) { @@ -69,7 +69,7 @@ /* * Set the synaptics touchpad mode byte by special commands */ -static int synaptics_set_mode(struct psmouse *psmouse, unsigned char mode) +static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode) { unsigned char param[1]; @@ -96,13 +96,14 @@ * Read the model-id bytes from the touchpad * see also SYN_MODEL_* macros */ -static int synaptics_model_id(struct psmouse *psmouse, unsigned long int *model_id) +static int synaptics_model_id(struct psmouse *psmouse) { + struct synaptics_data *priv = psmouse->private; unsigned char mi[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_MODEL, mi)) return -1; - *model_id = (mi[0]<<16) | (mi[1]<<8) | mi[2]; + priv->model_id = (mi[0]<<16) | (mi[1]<<8) | mi[2]; return 0; } @@ -110,23 +111,24 @@ * Read the capability-bits from the touchpad * see also the SYN_CAP_* macros */ -static int synaptics_capability(struct psmouse *psmouse, unsigned long int *capability, unsigned long int *ext_cap) +static int synaptics_capability(struct psmouse *psmouse) { + struct synaptics_data *priv = psmouse->private; unsigned char cap[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap)) return -1; - *capability = (cap[0]<<16) | (cap[1]<<8) | cap[2]; - *ext_cap = 0; - if (!SYN_CAP_VALID(*capability)) + priv->capabilities = (cap[0]<<16) | (cap[1]<<8) | cap[2]; + priv->ext_cap = 0; + if (!SYN_CAP_VALID(priv->capabilities)) return -1; - if (SYN_EXT_CAP_REQUESTS(*capability)) { + if (SYN_EXT_CAP_REQUESTS(priv->capabilities)) { if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) { printk(KERN_ERR "Synaptics claims to have extended capabilities," " but I'm not able to read them."); } else - *ext_cap = (cap[0]<<16) | (cap[1]<<8) | cap[2]; + priv->ext_cap = (cap[0]<<16) | (cap[1]<<8) | cap[2]; } return 0; } @@ -135,14 +137,15 @@ * Identify Touchpad * See also the SYN_ID_* macros */ -static int synaptics_identify(struct psmouse *psmouse, unsigned long int *ident) +static int synaptics_identify(struct psmouse *psmouse) { + struct synaptics_data *priv = psmouse->private; unsigned char id[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_IDENTIFY, id)) return -1; - *ident = (id[0]<<16) | (id[1]<<8) | id[2]; - if (SYN_ID_IS_SYNAPTICS(*ident)) + priv->identity = (id[0]<<16) | (id[1]<<8) | id[2]; + if (SYN_ID_IS_SYNAPTICS(priv->identity)) return 0; return -1; } @@ -179,7 +182,7 @@ } } -static int query_hardware(struct psmouse *psmouse) +static int synaptics_query_hardware(struct psmouse *psmouse) { struct synaptics_data *priv = psmouse->private; int retries = 0; @@ -188,11 +191,11 @@ while ((retries++ < 3) && synaptics_reset(psmouse)) printk(KERN_ERR "synaptics reset failed\n"); - if (synaptics_identify(psmouse, &priv->identity)) + if (synaptics_identify(psmouse)) return -1; - if (synaptics_model_id(psmouse, &priv->model_id)) + if (synaptics_model_id(psmouse)) return -1; - if (synaptics_capability(psmouse, &priv->capabilities, &priv->ext_cap)) + if (synaptics_capability(psmouse)) return -1; mode = SYN_BIT_ABSOLUTE_MODE | SYN_BIT_HIGH_RATE; @@ -200,7 +203,7 @@ mode |= SYN_BIT_DISABLE_GESTURE; if (SYN_CAP_EXTENDED(priv->capabilities)) mode |= SYN_BIT_W_MODE; - if (synaptics_set_mode(psmouse, mode)) + if (synaptics_mode_cmd(psmouse, mode)) return -1; return 0; @@ -286,7 +289,7 @@ /* adjust the touchpad to child's choice of protocol */ child = port->private; if (child && child->type >= PSMOUSE_GENPS) { - if (synaptics_set_mode(psmouse, (SYN_BIT_ABSOLUTE_MODE | + if (synaptics_mode_cmd(psmouse, (SYN_BIT_ABSOLUTE_MODE | SYN_BIT_HIGH_RATE | SYN_BIT_DISABLE_GESTURE | SYN_BIT_FOUR_BYTE_CLIENT | @@ -311,46 +314,27 @@ set_bit(axis, dev->absbit); } -int synaptics_init(struct psmouse *psmouse) +static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) { - struct synaptics_data *priv; - -#ifndef CONFIG_MOUSE_PS2_SYNAPTICS - return -1; -#endif - psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL); - if (!priv) - return -1; - memset(priv, 0, sizeof(struct synaptics_data)); - - priv->out_of_sync = 0; - - if (query_hardware(psmouse)) { - printk(KERN_ERR "Unable to query/initialize Synaptics hardware.\n"); - goto init_fail; - } - - print_ident(priv); - /* * The x/y limits are taken from the Synaptics TouchPad interfacing Guide, * which says that they should be valid regardless of the actual size of * the sensor. */ - set_bit(EV_ABS, psmouse->dev.evbit); - set_abs_params(&psmouse->dev, ABS_X, 1472, 5472, 0, 0); - set_abs_params(&psmouse->dev, ABS_Y, 1408, 4448, 0, 0); - set_abs_params(&psmouse->dev, ABS_PRESSURE, 0, 255, 0, 0); - - set_bit(EV_MSC, psmouse->dev.evbit); - set_bit(MSC_GESTURE, psmouse->dev.mscbit); - - set_bit(EV_KEY, psmouse->dev.evbit); - set_bit(BTN_LEFT, psmouse->dev.keybit); - set_bit(BTN_RIGHT, psmouse->dev.keybit); - set_bit(BTN_FORWARD, psmouse->dev.keybit); - set_bit(BTN_BACK, psmouse->dev.keybit); - if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)) + set_bit(EV_ABS, dev->evbit); + set_abs_params(dev, ABS_X, 1472, 5472, 0, 0); + set_abs_params(dev, ABS_Y, 1408, 4448, 0, 0); + set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); + + set_bit(EV_MSC, dev->evbit); + set_bit(MSC_GESTURE, dev->mscbit); + + set_bit(EV_KEY, dev->evbit); + set_bit(BTN_LEFT, dev->keybit); + set_bit(BTN_RIGHT, dev->keybit); + set_bit(BTN_FORWARD, dev->keybit); + set_bit(BTN_BACK, dev->keybit); + if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)) { switch (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) { default: /* @@ -359,22 +343,46 @@ */ break; case 8: - set_bit(BTN_7, psmouse->dev.keybit); - set_bit(BTN_6, psmouse->dev.keybit); + set_bit(BTN_7, dev->keybit); + set_bit(BTN_6, dev->keybit); case 6: - set_bit(BTN_5, psmouse->dev.keybit); - set_bit(BTN_4, psmouse->dev.keybit); + set_bit(BTN_5, dev->keybit); + set_bit(BTN_4, dev->keybit); case 4: - set_bit(BTN_3, psmouse->dev.keybit); - set_bit(BTN_2, psmouse->dev.keybit); + set_bit(BTN_3, dev->keybit); + set_bit(BTN_2, dev->keybit); case 2: - set_bit(BTN_1, psmouse->dev.keybit); - set_bit(BTN_0, psmouse->dev.keybit); + set_bit(BTN_1, dev->keybit); + set_bit(BTN_0, dev->keybit); break; } - clear_bit(EV_REL, psmouse->dev.evbit); - clear_bit(REL_X, psmouse->dev.relbit); - clear_bit(REL_Y, psmouse->dev.relbit); + } + + clear_bit(EV_REL, dev->evbit); + clear_bit(REL_X, dev->relbit); + clear_bit(REL_Y, dev->relbit); +} + +int synaptics_init(struct psmouse *psmouse) +{ + struct synaptics_data *priv; + +#ifndef CONFIG_MOUSE_PS2_SYNAPTICS + return -1; +#endif + + psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL); + if (!priv) + return -1; + memset(priv, 0, sizeof(struct synaptics_data)); + + if (synaptics_query_hardware(psmouse)) { + printk(KERN_ERR "Unable to query/initialize Synaptics hardware.\n"); + goto init_fail; + } + + print_ident(priv); + set_input_params(&psmouse->dev, priv); return 0; @@ -388,7 +396,7 @@ struct synaptics_data *priv = psmouse->private; if (psmouse->type == PSMOUSE_SYNAPTICS && priv) { - synaptics_set_mode(psmouse, 0); + synaptics_mode_cmd(psmouse, 0); if (priv->ptport) { serio_unregister_slave_port(priv->ptport); kfree(priv->ptport); @@ -582,19 +590,20 @@ } break; default: - if (psmouse->pktcnt >= 6) { /* Full packet received */ - if (priv->out_of_sync) { - priv->out_of_sync = 0; - printk(KERN_NOTICE "Synaptics driver resynced.\n"); - } + if (psmouse->pktcnt < 6) + break; /* Wait for full packet */ - if (priv->ptport && synaptics_is_pt_packet(psmouse->packet)) - synaptics_pass_pt_packet(priv->ptport, psmouse->packet); - else - synaptics_process_packet(psmouse); - - psmouse->pktcnt = 0; + if (priv->out_of_sync) { + priv->out_of_sync = 0; + printk(KERN_NOTICE "Synaptics driver resynced.\n"); } + + if (priv->ptport && synaptics_is_pt_packet(psmouse->packet)) + synaptics_pass_pt_packet(priv->ptport, psmouse->packet); + else + synaptics_process_packet(psmouse); + + psmouse->pktcnt = 0; break; } return; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/