Input: sentelic - multiple finger output support
v2 cover Input: sentelic - multiple finger output support
Hi,
This patch set (against for-linus) is intended to add support for newer Sentelic FSP(hardware revision Cx/Dx). The relative coordinates output mode is retained for supporting older hardware(prior to Cx release).
Patch set v2 are mostly identical to the previous submission except:
- fsp_packet_debug() parameter fixing up in patch #5
- acknowledge the work done by Oskari Saarenmaa <[email protected]>
Tai-hwa Liang (5):
Input: sentelic - code refactorying for upcoming new hardware support
Input: sentelic - enabling absolute coordinates output for newer
hardware
Input: sentelic - enabling hardware supported gesture ID output
Input: sentelic - minor code cleaning up
Input: sentelic - improving packet debugging information
drivers/input/mouse/sentelic.c | 297 ++++++++++++++++++++++++++++++++-------- drivers/input/mouse/sentelic.h | 108 ++++++++++++++- 2 files changed, 347 insertions(+), 58 deletions(-)
Signature · 1 line
1.7.9
PATCH v2 1/5 Input: sentelic - code refactorying for upcoming new hardware support
- Moving event bits setup code to a separated function, fsp_set_input_params(), such that we can perform hardware specific settings in the future;
- Taking hardware version information into account when activating protocol;
- Removing button information from boot message as it's somewhat confusing and is only for internal processing. Whilst here, also moving button retrieving code to be a part of protocol activation process.
--- drivers/input/mouse/sentelic.c | 106 +++++++++++++++++++++++---------------- drivers/input/mouse/sentelic.h | 13 +++++- 2 files changed, 74 insertions(+), 45 deletions(-)
drivers/input/mouse/sentelic.c +62 -44
@@ -745,37 +745,64 @@ static int fsp_activate_protocol(struct psmouse *psmouse)return -EIO ; } -if (fsp_reg_read (psmouse,FSP_REG_SYSCTL5 , &val)) { -dev_err (&psmouse->ps2dev.serio->dev, -"Unable to read SYSCTL5 register.\n" ); -return -EIO ; - } +if (pad->ver <FSP_VER_STL3888_C0 ) { +/* Preparing relative coordinates output for older hardware */ +if (fsp_reg_read (psmouse,FSP_REG_SYSCTL5 , &val)) { +dev_err (&psmouse->ps2dev.serio->dev, +"Unable to read SYSCTL5 register.\n" ); +return -EIO ; + } - val &= ~(FSP_BIT_EN_MSID7 |FSP_BIT_EN_MSID8 |FSP_BIT_EN_AUTO_MSID8 ); -/* Ensure we are not in absolute mode */ - val &= ~FSP_BIT_EN_PKT_G0 ; -if (pad->buttons ==0x06 ) { -/* Left/Middle/Right & Scroll Up/Down/Right/Left */ - val |=FSP_BIT_EN_MSID6 ; - } +if (fsp_get_buttons (psmouse, &pad->buttons)) { +dev_err (&psmouse->ps2dev.serio->dev, +"Unable to retrieve number of buttons.\n" ); +return -EIO ; + } -if (fsp_reg_write (psmouse,FSP_REG_SYSCTL5 , val)) { -dev_err (&psmouse->ps2dev.serio->dev, -"Unable to set up required mode bits.\n" ); -return -EIO ; + val &= ~(FSP_BIT_EN_MSID7 |FSP_BIT_EN_MSID8 |FSP_BIT_EN_AUTO_MSID8 ); +/* Ensure we are not in absolute mode */ + val &= ~FSP_BIT_EN_PKT_G0 ; +if (pad->buttons ==0x06 ) { +/* Left/Middle/Right & Scroll Up/Down/Right/Left */ + val |=FSP_BIT_EN_MSID6 ; + } + +if (fsp_reg_write (psmouse,FSP_REG_SYSCTL5 , val)) { +dev_err (&psmouse->ps2dev.serio->dev, +"Unable to set up required mode bits.\n" ); +return -EIO ; + } + +/* +* Enable OPC tags such that driver can tell the difference +* between on-pad and real button click +*/ +if (fsp_opc_tag_enable (psmouse, true)) +dev_warn (&psmouse->ps2dev.serio->dev, +"Failed to enable OPC tag mode.\n" ); +/* enable on-pad click by default */ + pad->flags |=FSPDRV_FLAG_EN_OPC ; + +/* Enable on-pad vertical and horizontal scrolling */ +fsp_onpad_vscr (psmouse, true); +fsp_onpad_hscr (psmouse, true); } -/* -* Enable OPC tags such that driver can tell the difference between -* on-pad and real button click -*/ -if (fsp_opc_tag_enable (psmouse, true)) -dev_warn (&psmouse->ps2dev.serio->dev, -"Failed to enable OPC tag mode.\n" ); +return 0 ; +} + +static int fsp_set_input_params (struct psmouse *psmouse) +{ +struct input_dev *dev = psmouse->dev; +struct fsp_data *pad = psmouse->private; -/* Enable on-pad vertical and horizontal scrolling */ -fsp_onpad_vscr (psmouse, true); -fsp_onpad_hscr (psmouse, true); +if (pad->ver <FSP_VER_STL3888_C0 ) { +__set_bit (BTN_MIDDLE , dev->keybit); +__set_bit (BTN_BACK , dev->keybit); +__set_bit (BTN_FORWARD , dev->keybit); +__set_bit (REL_WHEEL , dev->relbit); +__set_bit (REL_HWHEEL , dev->relbit); + }return 0 ; }
@@ -833,18 +860,16 @@ static int fsp_reconnect(struct psmouse *psmouse)int fsp_init (struct psmouse *psmouse) {struct fsp_data *priv; -int ver, rev, buttons; +int ver, rev;int error;if (fsp_get_version (psmouse, &ver) || -fsp_get_revision (psmouse, &rev) || -fsp_get_buttons (psmouse, &buttons)) { +fsp_get_revision (psmouse, &rev)) {return -ENODEV ; } -psmouse_info (psmouse, -"Finger Sensing Pad, hw: %d.%d.%d, sw: %s, buttons: %d\n" , - ver >>4 , ver &0x0F , rev, fsp_drv_ver, buttons &7 ); +psmouse_info (psmouse,"Finger Sensing Pad, hw: %d.%d.%d, sw: %s\n" , + ver >>4 , ver &0x0F , rev, fsp_drv_ver); psmouse->private = priv =kzalloc (sizeof (struct fsp_data ),GFP_KERNEL );if (!priv)
@@ -852,17 +877,6 @@ int fsp_init(struct psmouse *psmouse) priv->ver = ver; priv->rev = rev; - priv->buttons = buttons; - -/* enable on-pad click by default */ - priv->flags |=FSPDRV_FLAG_EN_OPC ; - -/* Set up various supported input event bits */ -__set_bit (BTN_MIDDLE , psmouse->dev->keybit); -__set_bit (BTN_BACK , psmouse->dev->keybit); -__set_bit (BTN_FORWARD , psmouse->dev->keybit); -__set_bit (REL_WHEEL , psmouse->dev->relbit); -__set_bit (REL_HWHEEL , psmouse->dev->relbit); psmouse->protocol_handler = fsp_process_byte; psmouse->disconnect = fsp_disconnect;
@@ -870,11 +884,15 @@ int fsp_init(struct psmouse *psmouse) psmouse->cleanup = fsp_reset; psmouse->pktsize =4 ; -/* set default packet output based on number of buttons we found */ error =fsp_activate_protocol (psmouse);if (error) goto err_out; +/* Set up various supported input event bits */ + error =fsp_set_input_params (psmouse); +if (error) + goto err_out; + error =sysfs_create_group (&psmouse->ps2dev.serio->dev.kobj, &fsp_attribute_group);if (error) {
drivers/input/mouse/sentelic.h +12 -1
@@ -64,12 +64,23 @@#define FSP_PKT_TYPE_NORMAL_OPC (0x03)#define FSP_PKT_TYPE_SHIFT (6) +/* hardware revisions */ +#define FSP_VER_STL3888_A4 (0xC1) +#define FSP_VER_STL3888_B0 (0xD0) +#define FSP_VER_STL3888_B1 (0xD1) +#define FSP_VER_STL3888_B2 (0xD2) +#define FSP_VER_STL3888_C0 (0xE0) +#define FSP_VER_STL3888_C1 (0xE1) +#define FSP_VER_STL3888_D0 (0xE2) +#define FSP_VER_STL3888_D1 (0xE3) +#define FSP_VER_STL3888_E0 (0xE4) + #ifdef __KERNEL__ struct fsp_data { unsigned char ver; /* hardware version */ unsigned char rev; /* hardware revison */ - unsigned char buttons; /* Number of buttons */ + unsigned int buttons; /* Number of buttons */ unsigned int flags; #define FSPDRV_FLAG_EN_OPC (0x001) /* enable on-pad clicking */
Signature · 1 line
1.7.9.1
PATCH v2 2/5 Input: sentelic - enabling absolute coordinates output for newer hardware
In reply to Tai-hwa Liang- Hooking multi-finger coordinates output with kernel multitouch library;
- Enabling absolute coordinates output for Cx+ hardware. The older hardware performs much better in relative mode; thus relative mode related code are preserved.
Part of the code is based on the work done by Oskari Saarenmaa <[email protected]>, which was used to support the clickpad found on ASUS UX21/31 Ultrabook. On the other hand, the FSP found on UX21/31 doesn't have hardware capability register other than PnP ID, which means that we'll have to figure out an alternative approach to identify such pad correctly; otherwise, blindly adding INPUT_PROP_BUTTONPAD property may compatability issues amongst existing FSPs.
--- drivers/input/mouse/sentelic.c | 114 ++++++++++++++++++++++++++++++++++++++- drivers/input/mouse/sentelic.h | 22 +++++++- 2 files changed, 132 insertions(+), 4 deletions(-)
drivers/input/mouse/sentelic.c +111 -3
@@ -2,7 +2,7 @@* Finger Sensing Pad PS/2 mouse driver. * * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd. -* Copyright (C) 2005-2011 Tai-hwa Liang, Sentelic Corporation. +* Copyright (C) 2005-2012 Tai-hwa Liang, Sentelic Corporation. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License
@@ -21,6 +21,7 @@#include <linux/module.h> #include <linux/input.h> +#include <linux/input/mt.h> #include <linux/ctype.h> #include <linux/libps2.h> #include <linux/serio.h>
@@ -644,12 +645,24 @@ static void fsp_packet_debug(unsigned char packet[]) }#endif +static void fsp_set_slot (struct input_dev *dev,int slot,bool active, +unsigned int x,unsigned int y) +{ +input_mt_slot (dev, slot); +input_mt_report_slot_state (dev,MT_TOOL_FINGER , active); +if (active) { +input_report_abs (dev,ABS_MT_POSITION_X , x); +input_report_abs (dev,ABS_MT_POSITION_Y , y); + } +} +static psmouse_ret_t fsp_process_byte (struct psmouse *psmouse) {struct input_dev *dev = psmouse->dev;struct fsp_data *ad = psmouse->private;unsigned char *packet = psmouse->packet;unsigned char button_status =0 , lscroll =0 , rscroll =0 ; +unsigned short abs_x, abs_y, fgrs =0 ;int rel_x, rel_y;if (psmouse->pktcnt <4 )
@@ -661,8 +674,66 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)switch (psmouse->packet[0 ] >>FSP_PKT_TYPE_SHIFT ) {case FSP_PKT_TYPE_ABS : -dev_warn (&psmouse->ps2dev.serio->dev, -"Unexpected absolute mode packet, ignored.\n" ); + abs_x = (packet[1 ] <<2 ) | ((packet[3 ] >>2 ) &0x03 ); + abs_y = (packet[2 ] <<2 ) | (packet[3 ] &0x03 ); + +if (packet[0 ] &FSP_PB0_MFMC ) { +/* +* MFMC packet: assume that there are two fingers on +* pad +*/ + fgrs =2 ; + +/* MFMC packet */ +if (packet[0 ] &FSP_PB0_MFMC_FGR2 ) { +/* 2nd finger */ +if (ad->last_mt_fgr ==2 ) { +/* +* workaround for buggy firmware +* which doesn't clear MFMC bit if +* the 1st finger is up +*/ + fgrs =1 ; +fsp_set_slot (dev,0 , false,0 ,0 ); + } + ad->last_mt_fgr =2 ; + +fsp_set_slot (dev,1 , fgrs ==2 , abs_x, abs_y); + }else { +/* 1st finger */ +if (ad->last_mt_fgr ==1 ) { +/* +* workaround for buggy firmware +* which doesn't clear MFMC bit if +* the 2nd finger is up +*/ + fgrs =1 ; +fsp_set_slot (dev,1 , false,0 ,0 ); + } + ad->last_mt_fgr =1 ; +fsp_set_slot (dev,0 , fgrs !=0 , abs_x, abs_y); + } + }else { +/* SFAC packet */ + +/* no multi-finger information */ + ad->last_mt_fgr =0 ; + +if (abs_x !=0 && abs_y !=0 ) + fgrs =1 ; + +fsp_set_slot (dev,0 , fgrs >0 , abs_x, abs_y); +fsp_set_slot (dev,1 , false,0 ,0 ); + } +if (fgrs >0 ) { +input_report_abs (dev,ABS_X , abs_x); +input_report_abs (dev,ABS_Y , abs_y); + } +input_report_key (dev,BTN_LEFT , packet[0 ] &0x01 ); +input_report_key (dev,BTN_RIGHT , packet[0 ] &0x02 ); +input_report_key (dev,BTN_TOUCH , fgrs); +input_report_key (dev,BTN_TOOL_FINGER , fgrs ==1 ); +input_report_key (dev,BTN_TOOL_DOUBLETAP , fgrs ==2 );break ;case FSP_PKT_TYPE_NORMAL_OPC :
@@ -786,6 +857,17 @@ static int fsp_activate_protocol(struct psmouse *psmouse)/* Enable on-pad vertical and horizontal scrolling */ fsp_onpad_vscr (psmouse, true);fsp_onpad_hscr (psmouse, true); + }else { +/* Enable absolute coordinates output for Cx/Dx hardware */ +if (fsp_reg_write (psmouse,FSP_REG_SWC1 , +FSP_BIT_SWC1_EN_ABS_1F | +FSP_BIT_SWC1_EN_ABS_2F | +FSP_BIT_SWC1_EN_FUP_OUT | +FSP_BIT_SWC1_EN_ABS_CON )) { +dev_err (&psmouse->ps2dev.serio->dev, +"Unable to enable absolute coordinates output.\n" ); +return -EIO ; + } }return 0 ;
@@ -802,6 +884,32 @@ static int fsp_set_input_params(struct psmouse *psmouse)__set_bit (BTN_FORWARD , dev->keybit);__set_bit (REL_WHEEL , dev->relbit);__set_bit (REL_HWHEEL , dev->relbit); + }else { +/* +* Hardware prior to Cx performs much better in relative mode; +* hence, only enable absolute coordinates output as well as +* multi-touch output for the newer hardware. +* +* Maximum coordinates can be computed as: +* +* number of scanlines * 64 - 57 +* +* where number of X/Y scanline lines are 16/12. +*/ +int abs_x =967 , abs_y =711 ; + +__set_bit (EV_ABS , dev->evbit); +__clear_bit (EV_REL , dev->evbit); +__set_bit (BTN_TOUCH , dev->keybit); +__set_bit (BTN_TOOL_FINGER , dev->keybit); +__set_bit (BTN_TOOL_DOUBLETAP , dev->keybit); +__set_bit (INPUT_PROP_SEMI_MT , dev->propbit); + +input_set_abs_params (dev,ABS_X ,0 , abs_x,0 ,0 ); +input_set_abs_params (dev,ABS_Y ,0 , abs_y,0 ,0 ); +input_mt_init_slots (dev,2 ); +input_set_abs_params (dev,ABS_MT_POSITION_X ,0 , abs_x,0 ,0 ); +input_set_abs_params (dev,ABS_MT_POSITION_Y ,0 , abs_y,0 ,0 ); }return 0 ;
drivers/input/mouse/sentelic.h +21 -1
@@ -2,7 +2,7 @@* Finger Sensing Pad PS/2 mouse driver. * * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd. -* Copyright (C) 2005-2011 Tai-hwa Liang, Sentelic Corporation. +* Copyright (C) 2005-2012 Tai-hwa Liang, Sentelic Corporation. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License
@@ -55,6 +55,16 @@#define FSP_BIT_FIX_HSCR BIT(5)#define FSP_BIT_DRAG_LOCK BIT(6) +#define FSP_REG_SWC1 (0x90) +#define FSP_BIT_SWC1_EN_ABS_1F BIT(0) +#define FSP_BIT_SWC1_EN_GID BIT(1) +#define FSP_BIT_SWC1_EN_ABS_2F BIT(2) +#define FSP_BIT_SWC1_EN_FUP_OUT BIT(3) +#define FSP_BIT_SWC1_EN_ABS_CON BIT(4) +#define FSP_BIT_SWC1_GST_GRP0 BIT(5) +#define FSP_BIT_SWC1_GST_GRP1 BIT(6) +#define FSP_BIT_SWC1_BX_COMPAT BIT(7) +/* Finger-sensing Pad packet formating related definitions */ /* absolute packet type */
@@ -64,6 +74,15 @@#define FSP_PKT_TYPE_NORMAL_OPC (0x03)#define FSP_PKT_TYPE_SHIFT (6) +/* bit definitions for the first byte of report packet */ +#define FSP_PB0_LBTN BIT(0) +#define FSP_PB0_RBTN BIT(1) +#define FSP_PB0_MBTN BIT(2) +#define FSP_PB0_MFMC_FGR2 FSP_PB0_MBTN +#define FSP_PB0_MUST_SET BIT(3) +#define FSP_PB0_PHY_BTN BIT(4) +#define FSP_PB0_MFMC BIT(5) +/* hardware revisions */ #define FSP_VER_STL3888_A4 (0xC1)#define FSP_VER_STL3888_B0 (0xD0)
@@ -89,6 +108,7 @@ struct fsp_data {unsigned char last_reg;/* Last register we requested read from */ unsigned char last_val; +unsigned int last_mt_fgr;/* Last seen finger(multitouch) */ };#ifdef CONFIG_MOUSE_PS2_SENTELIC
Signature · 1 line
1.7.9.1
Re: [PATCH v2 2/5] Input: sentelic - enabling absolute coordinates output for newer hardware
Quoted 5 lines
On the other hand, the FSP found on UX21/31 doesn't have hardware capability register other than PnP ID, which means that we'll have to figure out an alternative approach to identify such pad correctly; otherwise, blindly adding
INPUT_PROP_BUTTONPADproperty may compatability issues amongst existing FSPs.
If its tied to specific boards then the DMI data from the BIOS may be what you need for that. It'll let you identify boards/vendors.
Alan
PATCH v2 3/5 Input: sentelic - enabling hardware supported gesture ID output
In reply to Tai-hwa LiangEnabling on-chip gesture processing mode and send the result to the user land through MSC_GESTURE event. This event could be useful for 3rd party applications.
--- drivers/input/mouse/sentelic.c | 38 +++++++++++++++++++- drivers/input/mouse/sentelic.h | 73 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 2 deletions(-)
drivers/input/mouse/sentelic.c +36 -2
@@ -661,8 +661,9 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)struct input_dev *dev = psmouse->dev;struct fsp_data *ad = psmouse->private;unsigned char *packet = psmouse->packet; -unsigned char button_status =0 , lscroll =0 , rscroll =0 ; +unsigned char button_status =0 ;unsigned short abs_x, abs_y, fgrs =0 ; +unsigned short vscroll =0 , hscroll =0 , lscroll =0 , rscroll =0 ;int rel_x, rel_y;if (psmouse->pktcnt <4 )
@@ -673,6 +674,33 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)*/ switch (psmouse->packet[0 ] >>FSP_PKT_TYPE_SHIFT ) { +case FSP_PKT_TYPE_NOTIFY : +if (packet[1 ] !=FSP_NOTIFY_MSG_GID ) +break ;/* unsupported message types */ + +switch (packet[2 ]) { +case FSP_GID_SP_UP : + vscroll =1 ; +break ; +case FSP_GID_SP_DOWN : + vscroll =-1 ; +break ; +case FSP_GID_SP_LEFT : + hscroll =1 ; +break ; +case FSP_GID_SP_RIGHT : + hscroll =-1 ; +break ; +default : +dev_dbg (&psmouse->ps2dev.serio->dev, +"GID 0x%x\n" , packet[2 ]); +break ; + } +input_report_rel (dev,REL_WHEEL , vscroll); +input_report_rel (dev,REL_HWHEEL , hscroll); +input_event (dev,EV_MSC ,MSC_GESTURE , packet[2 ]); +break ; +case FSP_PKT_TYPE_ABS : abs_x = (packet[1 ] <<2 ) | ((packet[3 ] >>2 ) &0x03 ); abs_y = (packet[2 ] <<2 ) | (packet[3 ] &0x03 );
@@ -861,9 +889,12 @@ static int fsp_activate_protocol(struct psmouse *psmouse)/* Enable absolute coordinates output for Cx/Dx hardware */ if (fsp_reg_write (psmouse,FSP_REG_SWC1 ,FSP_BIT_SWC1_EN_ABS_1F | +FSP_BIT_SWC1_EN_GID |FSP_BIT_SWC1_EN_ABS_2F |FSP_BIT_SWC1_EN_FUP_OUT | -FSP_BIT_SWC1_EN_ABS_CON )) { +FSP_BIT_SWC1_EN_ABS_CON | +FSP_BIT_SWC1_GST_GRP0 | +FSP_BIT_SWC1_GST_GRP1 )) {dev_err (&psmouse->ps2dev.serio->dev,"Unable to enable absolute coordinates output.\n" );return -EIO ;
@@ -910,6 +941,9 @@ static int fsp_set_input_params(struct psmouse *psmouse)input_mt_init_slots (dev,2 );input_set_abs_params (dev,ABS_MT_POSITION_X ,0 , abs_x,0 ,0 );input_set_abs_params (dev,ABS_MT_POSITION_Y ,0 , abs_y,0 ,0 ); + +/* device generated gesture ID events */ +input_set_capability (dev,EV_MSC ,MSC_GESTURE ); }return 0 ;
drivers/input/mouse/sentelic.h +73 -0
79 lines not on this page · raw message
Signature · 1 line
1.7.9.1
PATCH v2 4/5 Input: sentelic - minor code cleaning up
In reply to Tai-hwa LiangImproving code readability by converting yet another magic number into a pre-defined constant.
--- drivers/input/mouse/sentelic.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/input/mouse/sentelic.c +1 -1
@@ -767,7 +767,7 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)case FSP_PKT_TYPE_NORMAL_OPC :/* on-pad click, filter it if necessary */ if ((ad->flags &FSPDRV_FLAG_EN_OPC ) !=FSPDRV_FLAG_EN_OPC ) - packet[0 ] &= ~BIT (0 ); + packet[0 ] &= ~FSP_PB0_LBTN ;/* fall through */ case FSP_PKT_TYPE_NORMAL :
Signature · 1 line
1.7.9.1
PATCH v2 5/5 Input: sentelic - improving packet debugging information
In reply to Tai-hwa LiangFrom: Oskari Saarenmaa <[email protected]>
Incorporating detail message submitted by Oskari Saarenmaa <[email protected]>. Whilst here, also converting a few common absolute coordinate extraction code into macros.
--- drivers/input/mouse/sentelic.c | 43 +++++++++++++++++++++++++++++++-------- 1 files changed, 34 insertions(+), 9 deletions(-)
drivers/input/mouse/sentelic.c +34 -9
@@ -37,6 +37,9 @@#define FSP_CMD_TIMEOUT 200#define FSP_CMD_TIMEOUT2 30 +#define GET_ABS_X (packet) ((packet[1] << 2) | ((packet[3] >> 2) & 0x03)) +#define GET_ABS_Y (packet) ((packet[2] << 2) | (packet[3] & 0x03)) +/** Driver version. */ static const char fsp_drv_ver[] ="1.0.0-K" ;
@@ -620,18 +623,40 @@ static struct attribute_group fsp_attribute_group = { .attrs = fsp_attributes, }; -#ifdef FSP_DEBUG -static void fsp_packet_debug (unsigned char packet[]) +#ifdef FSP_DEBUG +static void fsp_packet_debug (struct psmouse *psmouse,unsigned char packet[]) {static unsigned int ps2_packet_cnt;static unsigned int ps2_last_second;unsigned int jiffies_msec; +const char *packet_type ="UNKNOWN" ; +unsigned short abs_x =0 , abs_y =0 ; + +/* Interpret & dump the packet data. */ +switch (packet[0 ] >>FSP_PKT_TYPE_SHIFT ) { +case FSP_PKT_TYPE_ABS : + packet_type ="Absolute" ; + abs_x =GET_ABS_X (packet); + abs_y =GET_ABS_Y (packet); +break ; +case FSP_PKT_TYPE_NORMAL : + packet_type ="Normal" ; +break ; +case FSP_PKT_TYPE_NOTIFY : + packet_type ="Notify" ; +break ; +case FSP_PKT_TYPE_NORMAL_OPC : + packet_type ="Normal-OPC" ; +break ; + } ps2_packet_cnt++; jiffies_msec =jiffies_to_msecs (jiffies);psmouse_dbg (psmouse, -"%08dms PS/2 packets: %02x, %02x, %02x, %02x\n" , - jiffies_msec, packet[0 ], packet[1 ], packet[2 ], packet[3 ]); +"%08dms %s packets: %02x, %02x, %02x, %02x; " +"abs_x: %d, abs_y: %d\n" , + jiffies_msec, packet_type, + packet[0 ], packet[1 ], packet[2 ], packet[3 ], abs_x, abs_y);if (jiffies_msec - ps2_last_second >1000 ) {psmouse_dbg (psmouse,"PS/2 packets/sec = %d\n" , ps2_packet_cnt);
@@ -640,7 +665,7 @@ static void fsp_packet_debug(unsigned char packet[]) } }#else -static void fsp_packet_debug (unsigned char packet[]) +static void fsp_packet_debug (struct psmouse *psmouse,unsigned char packet[]) { }#endif
@@ -673,6 +698,8 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)* Full packet accumulated, process it */ +fsp_packet_debug (psmouse, packet); +switch (psmouse->packet[0 ] >>FSP_PKT_TYPE_SHIFT ) {case FSP_PKT_TYPE_NOTIFY :if (packet[1 ] !=FSP_NOTIFY_MSG_GID )
@@ -702,8 +729,8 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)break ;case FSP_PKT_TYPE_ABS : - abs_x = (packet[1 ] <<2 ) | ((packet[3 ] >>2 ) &0x03 ); - abs_y = (packet[2 ] <<2 ) | (packet[3 ] &0x03 ); + abs_x =GET_ABS_X (packet); + abs_y =GET_ABS_Y (packet);if (packet[0 ] &FSP_PB0_MFMC ) {/*
@@ -814,8 +841,6 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)input_sync (dev); -fsp_packet_debug (packet); -return PSMOUSE_FULL_PACKET ; }
Signature · 1 line
1.7.9.1