[PATCH] Input: Change BTN_TOOL_FINGER flag when hover event trigger

2016-04-05 Thread duson
Only ABS_DISTANCE is not enough for upper OS to distingiush hover event
be triggered from object from faraway to and close touchpad surface or
from object prepare to leave the touchpad surface. Add BTN_TOOL_FINGER
flag to help it.

 object_from_farawayobject_inside_hover_area  
object_touch_surface
BTN_TOUCH 0  01
BTN_TOOL_FINGER   0  11
ABS_DISTANCE  0  10

Signed-off by: Duson Lin <duson...@emc.com.tw>
---
 drivers/hid/hid-magicmouse.c |  2 +-
 drivers/input/input-mt.c |  7 +--
 drivers/input/mouse/elan_i2c_core.c  | 15 +--
 drivers/input/mouse/elantech.c   |  2 +-
 drivers/input/mouse/focaltech.c  |  2 +-
 drivers/input/mouse/synaptics.c  |  2 +-
 drivers/input/touchscreen/atmel_mxt_ts.c |  2 +-
 drivers/input/touchscreen/edt-ft5x06.c   |  2 +-
 drivers/input/touchscreen/egalax_ts.c|  2 +-
 drivers/input/touchscreen/ili210x.c  |  2 +-
 drivers/input/touchscreen/mms114.c   |  4 ++--
 drivers/input/touchscreen/penmount.c |  2 +-
 drivers/input/touchscreen/rohm_bu21023.c |  2 +-
 drivers/input/touchscreen/wacom_w8001.c  |  2 +-
 include/linux/input/mt.h |  3 ++-
 15 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index d6fa496..584e98b 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -353,7 +353,7 @@ static int magicmouse_raw_event(struct hid_device *hdev,
input_report_rel(input, REL_Y, y);
} else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
input_report_key(input, BTN_MOUSE, clicks & 1);
-   input_mt_report_pointer_emulation(input, true);
+   input_mt_report_pointer_emulation(input, true, false);
}
 
input_sync(input);
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index 54fce56..30855a5 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -184,6 +184,7 @@ EXPORT_SYMBOL(input_mt_report_finger_count);
  * input_mt_report_pointer_emulation() - common pointer emulation
  * @dev: input device with allocated MT slots
  * @use_count: report number of active contacts as finger count
+ * @hover: report ABS_DISTANCE as hover event
  *
  * Performs legacy pointer emulation via BTN_TOUCH, ABS_X, ABS_Y and
  * ABS_PRESSURE. Touchpad finger count is emulated if use_count is true.
@@ -191,7 +192,8 @@ EXPORT_SYMBOL(input_mt_report_finger_count);
  * The input core ensures only the KEY and ABS axes already setup for
  * this device will produce output.
  */
-void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
+void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count,
+   bool hover)
 {
struct input_mt *mt = dev->mt;
struct input_mt_slot *oldest;
@@ -220,6 +222,7 @@ void input_mt_report_pointer_emulation(struct input_dev 
*dev, bool use_count)
input_event(dev, EV_KEY, BTN_TOUCH, count > 0);
if (use_count)
input_mt_report_finger_count(dev, count);
+   input_event(dev, EV_ABS, ABS_DISTANCE, hover);
 
if (oldest) {
int x = input_mt_get_value(oldest, ABS_MT_POSITION_X);
@@ -290,7 +293,7 @@ void input_mt_sync_frame(struct input_dev *dev)
if ((mt->flags & INPUT_MT_POINTER) && !(mt->flags & INPUT_MT_SEMI_MT))
use_count = true;
 
-   input_mt_report_pointer_emulation(dev, use_count);
+   input_mt_report_pointer_emulation(dev, use_count, false);
 
mt->frame++;
 }
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 2f58985..8b5e75a 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) <duson...@emc.com.tw>
- * Version: 1.6.0
+ * Version: 1.6.2
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.6.1"
+#define ELAN_DRIVER_VERSION"1.6.2"
 #define ELAN_VENDOR_ID 0x04f3
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
@@ -845,7 +845,7 @@ static void elan_report_absolute(struct elan_tp_data *data, 
u8 *packet)
 {
struct input_dev *input = data->input;
u8 *finger_data = [ETP_FINGER_DATA_OFFSET];
-   int i;
+   int i, valid_count = 0;
u8 tp_info = packet[ETP_TOUCH_INFO_OFFSET];
u8 hover_info = packet[ETP_HOVER_INFO_OFFSET];
bool

[PATCH] Input: Change BTN_TOOL_FINGER flag when hover event trigger

2016-04-05 Thread duson
Only ABS_DISTANCE is not enough for upper OS to distingiush hover event
be triggered from object from faraway to and close touchpad surface or
from object prepare to leave the touchpad surface. Add BTN_TOOL_FINGER
flag to help it.

 object_from_farawayobject_inside_hover_area  
object_touch_surface
BTN_TOUCH 0  01
BTN_TOOL_FINGER   0  11
ABS_DISTANCE  0  10

Signed-off by: Duson Lin 
---
 drivers/hid/hid-magicmouse.c |  2 +-
 drivers/input/input-mt.c |  7 +--
 drivers/input/mouse/elan_i2c_core.c  | 15 +--
 drivers/input/mouse/elantech.c   |  2 +-
 drivers/input/mouse/focaltech.c  |  2 +-
 drivers/input/mouse/synaptics.c  |  2 +-
 drivers/input/touchscreen/atmel_mxt_ts.c |  2 +-
 drivers/input/touchscreen/edt-ft5x06.c   |  2 +-
 drivers/input/touchscreen/egalax_ts.c|  2 +-
 drivers/input/touchscreen/ili210x.c  |  2 +-
 drivers/input/touchscreen/mms114.c   |  4 ++--
 drivers/input/touchscreen/penmount.c |  2 +-
 drivers/input/touchscreen/rohm_bu21023.c |  2 +-
 drivers/input/touchscreen/wacom_w8001.c  |  2 +-
 include/linux/input/mt.h |  3 ++-
 15 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index d6fa496..584e98b 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -353,7 +353,7 @@ static int magicmouse_raw_event(struct hid_device *hdev,
input_report_rel(input, REL_Y, y);
} else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
input_report_key(input, BTN_MOUSE, clicks & 1);
-   input_mt_report_pointer_emulation(input, true);
+   input_mt_report_pointer_emulation(input, true, false);
}
 
input_sync(input);
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index 54fce56..30855a5 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -184,6 +184,7 @@ EXPORT_SYMBOL(input_mt_report_finger_count);
  * input_mt_report_pointer_emulation() - common pointer emulation
  * @dev: input device with allocated MT slots
  * @use_count: report number of active contacts as finger count
+ * @hover: report ABS_DISTANCE as hover event
  *
  * Performs legacy pointer emulation via BTN_TOUCH, ABS_X, ABS_Y and
  * ABS_PRESSURE. Touchpad finger count is emulated if use_count is true.
@@ -191,7 +192,8 @@ EXPORT_SYMBOL(input_mt_report_finger_count);
  * The input core ensures only the KEY and ABS axes already setup for
  * this device will produce output.
  */
-void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
+void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count,
+   bool hover)
 {
struct input_mt *mt = dev->mt;
struct input_mt_slot *oldest;
@@ -220,6 +222,7 @@ void input_mt_report_pointer_emulation(struct input_dev 
*dev, bool use_count)
input_event(dev, EV_KEY, BTN_TOUCH, count > 0);
if (use_count)
input_mt_report_finger_count(dev, count);
+   input_event(dev, EV_ABS, ABS_DISTANCE, hover);
 
if (oldest) {
int x = input_mt_get_value(oldest, ABS_MT_POSITION_X);
@@ -290,7 +293,7 @@ void input_mt_sync_frame(struct input_dev *dev)
if ((mt->flags & INPUT_MT_POINTER) && !(mt->flags & INPUT_MT_SEMI_MT))
use_count = true;
 
-   input_mt_report_pointer_emulation(dev, use_count);
+   input_mt_report_pointer_emulation(dev, use_count, false);
 
mt->frame++;
 }
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 2f58985..8b5e75a 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.6.0
+ * Version: 1.6.2
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.6.1"
+#define ELAN_DRIVER_VERSION"1.6.2"
 #define ELAN_VENDOR_ID 0x04f3
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
@@ -845,7 +845,7 @@ static void elan_report_absolute(struct elan_tp_data *data, 
u8 *packet)
 {
struct input_dev *input = data->input;
u8 *finger_data = [ETP_FINGER_DATA_OFFSET];
-   int i;
+   int i, valid_count = 0;
u8 tp_info = packet[ETP_TOUCH_INFO_OFFSET];
u8 hover_info = packet[ETP_HOVER_INFO_OFFSET];
bool contact_valid, hover_event;
@@ -855,13 +855

[PATCH] Input: Change BTN_TOOL_FINGER falg when HOVER event trigger

2016-03-22 Thread duson
Only ABS_DISTANCE is not enough for upper OS  to distiguish hover event
be triggered from object form faraway to and close touchpad surface or from
object prepare to leave the touchpad surface. We add BNT_TOOL_FINGER to help
it.

 Object_at_faraway   
object_at_hover_area  object_touch_touchpad
 BTN_TOUCH  00  
   1
BTN_TOOL_FINGER  0   1  
1
ABS_DISTANCE  0   1 
 0

Signed-off by: Duson Lin <duson...@emc.com.tw>
---
 drivers/input/mouse/elan_i2c_core.c |   14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 2f58985..9392a8c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) <duson...@emc.com.tw>
- * Version: 1.6.0
+ * Version: 1.6.1
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -845,23 +845,27 @@ static void elan_report_absolute(struct elan_tp_data 
*data, u8 *packet)
 {
struct input_dev *input = data->input;
u8 *finger_data = [ETP_FINGER_DATA_OFFSET];
-   int i;
+   int i, valid_count = 0;
u8 tp_info = packet[ETP_TOUCH_INFO_OFFSET];
u8 hover_info = packet[ETP_HOVER_INFO_OFFSET];
bool contact_valid, hover_event;
 
-   hover_event = hover_info & 0x40;
+   hover_event = (hover_info & 0x40);
for (i = 0; i < ETP_MAX_FINGERS; i++) {
contact_valid = tp_info & (1U << (3 + i));
elan_report_contact(data, i, contact_valid, finger_data);
 
-   if (contact_valid)
+   if (contact_valid) {
finger_data += ETP_FINGER_DATA_LEN;
+   valid_count++;
+   }
}
 
input_report_key(input, BTN_LEFT, tp_info & 0x01);
+   input_report_key(input, BTN_TOOL_FINGER,
+   ((hover_event != 0) | (valid_count > 0)));
input_report_abs(input, ABS_DISTANCE, hover_event != 0);
-   input_mt_report_pointer_emulation(input, true);
+   input_mt_report_pointer_emulation(input, false);
input_sync(input);
 }
 
-- 
1.7.9.5




[PATCH] Input: Change BTN_TOOL_FINGER falg when HOVER event trigger

2016-03-22 Thread duson
Only ABS_DISTANCE is not enough for upper OS  to distiguish hover event
be triggered from object form faraway to and close touchpad surface or from
object prepare to leave the touchpad surface. We add BNT_TOOL_FINGER to help
it.

 Object_at_faraway   
object_at_hover_area  object_touch_touchpad
 BTN_TOUCH  00  
   1
BTN_TOOL_FINGER  0   1  
1
ABS_DISTANCE  0   1 
 0

Signed-off by: Duson Lin 
---
 drivers/input/mouse/elan_i2c_core.c |   14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 2f58985..9392a8c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.6.0
+ * Version: 1.6.1
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -845,23 +845,27 @@ static void elan_report_absolute(struct elan_tp_data 
*data, u8 *packet)
 {
struct input_dev *input = data->input;
u8 *finger_data = [ETP_FINGER_DATA_OFFSET];
-   int i;
+   int i, valid_count = 0;
u8 tp_info = packet[ETP_TOUCH_INFO_OFFSET];
u8 hover_info = packet[ETP_HOVER_INFO_OFFSET];
bool contact_valid, hover_event;
 
-   hover_event = hover_info & 0x40;
+   hover_event = (hover_info & 0x40);
for (i = 0; i < ETP_MAX_FINGERS; i++) {
contact_valid = tp_info & (1U << (3 + i));
elan_report_contact(data, i, contact_valid, finger_data);
 
-   if (contact_valid)
+   if (contact_valid) {
finger_data += ETP_FINGER_DATA_LEN;
+   valid_count++;
+   }
}
 
input_report_key(input, BTN_LEFT, tp_info & 0x01);
+   input_report_key(input, BTN_TOOL_FINGER,
+   ((hover_event != 0) | (valid_count > 0)));
input_report_abs(input, ABS_DISTANCE, hover_event != 0);
-   input_mt_report_pointer_emulation(input, true);
+   input_mt_report_pointer_emulation(input, false);
input_sync(input);
 }
 
-- 
1.7.9.5




[PATCH] Input: elan_i2c - Add all valid ic type for i2c/smbus

2015-09-22 Thread duson
Signed-of-by: Duson Lin 
---
 drivers/input/mouse/elan_i2c_core.c |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 16ac595..357670e 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -98,16 +98,25 @@ static int elan_get_fwinfo(u8 iap_version, u16 
*validpage_count,
   u16 *signature_address)
 {
switch (iap_version) {
+   case 0x00:
+   case 0x06:
case 0x08:
*validpage_count = 512;
break;
-   case 0x09:
case 0x03:
+   case 0x07:
+   case 0x09:
+   case 0x0A:
+   case 0x0B:
+   case 0x0C:
*validpage_count = 768;
break;
case 0x0D:
*validpage_count = 896;
break;
+   case 0x0E:
+   *validpage_count = 640;
+   break;
default:
/* unknown ic type clear value */
*validpage_count = 0;
-- 
1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Add all valid ic type for i2c/smbus

2015-09-22 Thread duson
Signed-of-by: Duson Lin <duson...@emc.com.tw>
---
 drivers/input/mouse/elan_i2c_core.c |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 16ac595..357670e 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -98,16 +98,25 @@ static int elan_get_fwinfo(u8 iap_version, u16 
*validpage_count,
   u16 *signature_address)
 {
switch (iap_version) {
+   case 0x00:
+   case 0x06:
case 0x08:
*validpage_count = 512;
break;
-   case 0x09:
case 0x03:
+   case 0x07:
+   case 0x09:
+   case 0x0A:
+   case 0x0B:
+   case 0x0C:
*validpage_count = 768;
break;
case 0x0D:
*validpage_count = 896;
break;
+   case 0x0E:
+   *validpage_count = 640;
+   break;
default:
/* unknown ic type clear value */
*validpage_count = 0;
-- 
1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Add ic type 0x03

2015-09-20 Thread duson
The 0x03 is valid 3000 serial ic type too.

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/elan_i2c_core.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index fa94530..16ac595 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -102,6 +102,7 @@ static int elan_get_fwinfo(u8 iap_version, u16 
*validpage_count,
*validpage_count = 512;
break;
case 0x09:
+   case 0x03:
*validpage_count = 768;
break;
case 0x0D:
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Add ic type 0x03

2015-09-20 Thread duson
The 0x03 is valid 3000 serial ic type too.

Signed-off-by: Duson Lin <duson...@emc.com.tw>
---
 drivers/input/mouse/elan_i2c_core.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index fa94530..16ac595 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -102,6 +102,7 @@ static int elan_get_fwinfo(u8 iap_version, u16 
*validpage_count,
*validpage_count = 512;
break;
case 0x09:
+   case 0x03:
*validpage_count = 768;
break;
case 0x0D:
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Expand maxmium product_id form 0xFF to 0xFFFF

2015-09-10 Thread duson
In order to support more projects in the feture, we expand the
maxmium product_id value form 0xFF to 0x.

Signed-off by: Duson Lin 
---
 drivers/input/mouse/elan_i2c.h   |2 +-
 drivers/input/mouse/elan_i2c_core.c  |6 +++---
 drivers/input/mouse/elan_i2c_i2c.c   |4 ++--
 drivers/input/mouse/elan_i2c_smbus.c |4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 73670f2..c0ec261 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -60,7 +60,7 @@ struct elan_transport_ops {
int (*get_sm_version)(struct i2c_client *client,
  u8* ic_type, u8 *version);
int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
-   int (*get_product_id)(struct i2c_client *client, u8 *id);
+   int (*get_product_id)(struct i2c_client *client, u16 *id);
 
int (*get_max)(struct i2c_client *client,
   unsigned int *max_x, unsigned int *max_y);
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index e2b7420..4a5450d 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.6.0
+ * Version: 1.6.1
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.6.0"
+#define ELAN_DRIVER_VERSION"1.6.1"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -76,7 +76,7 @@ struct elan_tp_data {
unsigned intx_res;
unsigned inty_res;
 
-   u8  product_id;
+   u16 product_id;
u8  fw_version;
u8  sm_version;
u8  iap_version;
diff --git a/drivers/input/mouse/elan_i2c_i2c.c 
b/drivers/input/mouse/elan_i2c_i2c.c
index 683c840..a679e56 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -276,7 +276,7 @@ static int elan_i2c_get_sm_version(struct i2c_client 
*client,
return 0;
 }
 
-static int elan_i2c_get_product_id(struct i2c_client *client, u8 *id)
+static int elan_i2c_get_product_id(struct i2c_client *client, u16 *id)
 {
int error;
u8 val[3];
@@ -287,7 +287,7 @@ static int elan_i2c_get_product_id(struct i2c_client 
*client, u8 *id)
return error;
}
 
-   *id = val[0];
+   *id = le16_to_cpup((__le16 *)val);
return 0;
 }
 
diff --git a/drivers/input/mouse/elan_i2c_smbus.c 
b/drivers/input/mouse/elan_i2c_smbus.c
index ff36a36..cb6aecb 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -183,7 +183,7 @@ static int elan_smbus_get_sm_version(struct i2c_client 
*client,
return 0;
 }
 
-static int elan_smbus_get_product_id(struct i2c_client *client, u8 *id)
+static int elan_smbus_get_product_id(struct i2c_client *client, u16 *id)
 {
int error;
u8 val[3];
@@ -195,7 +195,7 @@ static int elan_smbus_get_product_id(struct i2c_client 
*client, u8 *id)
return error;
}
 
-   *id = val[1];
+   *id = be16_to_cpup((__be16 *)val);
return 0;
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Expand maxmium product_id form 0xFF to 0xFFFF

2015-09-10 Thread duson
In order to support more projects in the feture, we expand the
maxmium product_id value form 0xFF to 0x.

Signed-off by: Duson Lin <duson...@emc.com.tw>
---
 drivers/input/mouse/elan_i2c.h   |2 +-
 drivers/input/mouse/elan_i2c_core.c  |6 +++---
 drivers/input/mouse/elan_i2c_i2c.c   |4 ++--
 drivers/input/mouse/elan_i2c_smbus.c |4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 73670f2..c0ec261 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -60,7 +60,7 @@ struct elan_transport_ops {
int (*get_sm_version)(struct i2c_client *client,
  u8* ic_type, u8 *version);
int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
-   int (*get_product_id)(struct i2c_client *client, u8 *id);
+   int (*get_product_id)(struct i2c_client *client, u16 *id);
 
int (*get_max)(struct i2c_client *client,
   unsigned int *max_x, unsigned int *max_y);
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index e2b7420..4a5450d 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) <duson...@emc.com.tw>
- * Version: 1.6.0
+ * Version: 1.6.1
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.6.0"
+#define ELAN_DRIVER_VERSION"1.6.1"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -76,7 +76,7 @@ struct elan_tp_data {
unsigned intx_res;
unsigned inty_res;
 
-   u8  product_id;
+   u16 product_id;
u8  fw_version;
u8  sm_version;
u8  iap_version;
diff --git a/drivers/input/mouse/elan_i2c_i2c.c 
b/drivers/input/mouse/elan_i2c_i2c.c
index 683c840..a679e56 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -276,7 +276,7 @@ static int elan_i2c_get_sm_version(struct i2c_client 
*client,
return 0;
 }
 
-static int elan_i2c_get_product_id(struct i2c_client *client, u8 *id)
+static int elan_i2c_get_product_id(struct i2c_client *client, u16 *id)
 {
int error;
u8 val[3];
@@ -287,7 +287,7 @@ static int elan_i2c_get_product_id(struct i2c_client 
*client, u8 *id)
return error;
}
 
-   *id = val[0];
+   *id = le16_to_cpup((__le16 *)val);
return 0;
 }
 
diff --git a/drivers/input/mouse/elan_i2c_smbus.c 
b/drivers/input/mouse/elan_i2c_smbus.c
index ff36a36..cb6aecb 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -183,7 +183,7 @@ static int elan_smbus_get_sm_version(struct i2c_client 
*client,
return 0;
 }
 
-static int elan_smbus_get_product_id(struct i2c_client *client, u8 *id)
+static int elan_smbus_get_product_id(struct i2c_client *client, u16 *id)
 {
int error;
u8 val[3];
@@ -195,7 +195,7 @@ static int elan_smbus_get_product_id(struct i2c_client 
*client, u8 *id)
return error;
}
 
-   *id = val[1];
+   *id = be16_to_cpup((__be16 *)val);
return 0;
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Use iap_version to get firmware information

2015-09-01 Thread duson
When driver get exception ic type (0xFF), maybe occurred from wrong
I2C protocol communication, system crash or other unknown situation,
instead of ic_type we use iap_version to get firmware information.

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/elan_i2c_core.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 5b5f403..d99d40c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.9
+ * Version: 1.6.0
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.9"
+#define ELAN_DRIVER_VERSION"1.6.0"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -261,11 +261,11 @@ static int elan_query_device_info(struct elan_tp_data 
*data)
if (error)
return error;
 
-   error = elan_get_fwinfo(data->ic_type, >fw_vaildpage_count,
+   error = elan_get_fwinfo(data->iap_version, >fw_vaildpage_count,
>fw_signature_address);
if (error) {
dev_err(>client->dev,
-   "unknown ic type %d\n", data->ic_type);
+   "unknown ic type %d\n", data->iap_version);
return error;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Use iap_version to get firmware information

2015-09-01 Thread duson
When driver get exception ic type (0xFF), maybe occurred from wrong
I2C protocol communication, system crash or other unknown situation,
instead of ic_type we use iap_version to get firmware information.

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/elan_i2c_core.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 5b5f403..494858c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.9
+ * Version: 1.6.0
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.9"
+#define ELAN_DRIVER_VERSION"1.6.0"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -261,7 +261,7 @@ static int elan_query_device_info(struct elan_tp_data *data)
if (error)
return error;
 
-   error = elan_get_fwinfo(data->ic_type, >fw_vaildpage_count,
+   error = elan_get_fwinfo(data->iap_version, >fw_vaildpage_count,
>fw_signature_address);
if (error) {
dev_err(>client->dev,--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Use iap_version to get firmware information

2015-09-01 Thread duson
When driver get exception ic type (0xFF), maybe occurred from wrong
I2C protocol communication, system crash or other unknown situation,
instead of ic_type we use iap_version to get firmware information.
---
 drivers/input/mouse/elan_i2c_core.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 5b5f403..494858c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.9
+ * Version: 1.6.0
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.9"
+#define ELAN_DRIVER_VERSION"1.6.0"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -261,7 +261,7 @@ static int elan_query_device_info(struct elan_tp_data *data)
if (error)
return error;
 
-   error = elan_get_fwinfo(data->ic_type, >fw_vaildpage_count,
+   error = elan_get_fwinfo(data->iap_version, >fw_vaildpage_count,
>fw_signature_address);
if (error) {
dev_err(>client->dev,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Use iap_version to get firmware information

2015-09-01 Thread duson
When driver get exception ic type (0xFF), maybe occurred from wrong
I2C protocol communication, system crash or other unknown situation,
instead of ic_type we use iap_version to get firmware information.

Signed-off-by: Duson Lin <duson...@emc.com.tw>
---
 drivers/input/mouse/elan_i2c_core.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 5b5f403..d99d40c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) <duson...@emc.com.tw>
- * Version: 1.5.9
+ * Version: 1.6.0
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.9"
+#define ELAN_DRIVER_VERSION"1.6.0"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -261,11 +261,11 @@ static int elan_query_device_info(struct elan_tp_data 
*data)
if (error)
return error;
 
-   error = elan_get_fwinfo(data->ic_type, >fw_vaildpage_count,
+   error = elan_get_fwinfo(data->iap_version, >fw_vaildpage_count,
>fw_signature_address);
if (error) {
dev_err(>client->dev,
-   "unknown ic type %d\n", data->ic_type);
+   "unknown ic type %d\n", data->iap_version);
return error;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Use iap_version to get firmware information

2015-09-01 Thread duson
When driver get exception ic type (0xFF), maybe occurred from wrong
I2C protocol communication, system crash or other unknown situation,
instead of ic_type we use iap_version to get firmware information.
---
 drivers/input/mouse/elan_i2c_core.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 5b5f403..494858c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) <duson...@emc.com.tw>
- * Version: 1.5.9
+ * Version: 1.6.0
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.9"
+#define ELAN_DRIVER_VERSION"1.6.0"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -261,7 +261,7 @@ static int elan_query_device_info(struct elan_tp_data *data)
if (error)
return error;
 
-   error = elan_get_fwinfo(data->ic_type, >fw_vaildpage_count,
+   error = elan_get_fwinfo(data->iap_version, >fw_vaildpage_count,
>fw_signature_address);
if (error) {
dev_err(>client->dev,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Use iap_version to get firmware information

2015-09-01 Thread duson
When driver get exception ic type (0xFF), maybe occurred from wrong
I2C protocol communication, system crash or other unknown situation,
instead of ic_type we use iap_version to get firmware information.

Signed-off-by: Duson Lin <duson...@emc.com.tw>
---
 drivers/input/mouse/elan_i2c_core.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 5b5f403..494858c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) <duson...@emc.com.tw>
- * Version: 1.5.9
+ * Version: 1.6.0
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.9"
+#define ELAN_DRIVER_VERSION"1.6.0"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -261,7 +261,7 @@ static int elan_query_device_info(struct elan_tp_data *data)
if (error)
return error;
 
-   error = elan_get_fwinfo(data->ic_type, >fw_vaildpage_count,
+   error = elan_get_fwinfo(data->iap_version, >fw_vaildpage_count,
>fw_signature_address);
if (error) {
dev_err(>client->dev,--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Recovery exception ic type

2015-08-30 Thread duson
When driver get exception ic type (0xFF), maybe occurred from wrong
I2C protocol communication, system crash or other unknown situation,
we need to reset ic type from iap_version.
---
 drivers/input/mouse/elan_i2c_core.c |   14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 5b5f403..39d9929 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.9
+ * Version: 1.6.0
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.9"
+#define ELAN_DRIVER_VERSION"1.6.0"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -247,15 +247,19 @@ static int elan_query_device_info(struct elan_tp_data 
*data)
if (error)
return error;
 
-   error = data->ops->get_sm_version(data->client, >ic_type,
- >sm_version);
+   error = data->ops->get_version(data->client, true, >iap_version);
if (error)
return error;
 
-   error = data->ops->get_version(data->client, true, >iap_version);
+   error = data->ops->get_sm_version(data->client, >ic_type,
+ >sm_version);
if (error)
return error;
 
+   /* exception type, need reset from iap_version */
+   if (data->ic_type == 0xFF)
+   data->ic_type = data->iap_version;
+
error = data->ops->get_pressure_adjustment(data->client,
   >pressure_adjustment);
if (error)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Recovery exception ic type

2015-08-30 Thread duson
When driver get exception ic type (0xFF), maybe occurred from wrong
I2C protocol communication, system crash or other unknown situation,
we need to reset ic type from iap_version.
---
 drivers/input/mouse/elan_i2c_core.c |   14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 5b5f403..39d9929 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.9
+ * Version: 1.6.0
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include elan_i2c.h
 
 #define DRIVER_NAMEelan_i2c
-#define ELAN_DRIVER_VERSION1.5.9
+#define ELAN_DRIVER_VERSION1.6.0
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -247,15 +247,19 @@ static int elan_query_device_info(struct elan_tp_data 
*data)
if (error)
return error;
 
-   error = data-ops-get_sm_version(data-client, data-ic_type,
- data-sm_version);
+   error = data-ops-get_version(data-client, true, data-iap_version);
if (error)
return error;
 
-   error = data-ops-get_version(data-client, true, data-iap_version);
+   error = data-ops-get_sm_version(data-client, data-ic_type,
+ data-sm_version);
if (error)
return error;
 
+   /* exception type, need reset from iap_version */
+   if (data-ic_type == 0xFF)
+   data-ic_type = data-iap_version;
+
error = data-ops-get_pressure_adjustment(data-client,
   data-pressure_adjustment);
if (error)


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/4] Input - elantech: Add special check for fw_version 0x470f01 touchpad

2015-08-07 Thread duson
It is no need to check the packet[0] for sanity check when doing
elantech_packet_check_v4() function for fw_version = 0x470f01 touchpad.

Signed-off by: Duson Lin 
---
 drivers/input/mouse/elantech.c |   20 
 drivers/input/mouse/elantech.h |1 +
 2 files changed, 21 insertions(+)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 22b9ca9..2a0f883 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -785,6 +785,9 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
unsigned char packet_type = packet[3] & 0x03;
bool sanity_check;
 
+   /* This represents the version of IC body. */
+   int ver = (etd->fw_version & 0x0f) >> 16;
+
if (etd->tp_dev && (packet[3] & 0x0f) == 0x06)
return PACKET_TRACKPOINT;
 
@@ -796,6 +799,12 @@ static int elantech_packet_check_v4(struct psmouse 
*psmouse)
 */
if (etd->crc_enabled)
sanity_check = ((packet[3] & 0x08) == 0x00);
+   /*
+* The sanity check only need to check packet[3]
+* when IC_body = 7 and PID = 0x2A
+*/
+   else if (ver == 7 && etd->samples[1] == 0x2A)
+   sanity_check = ((packet[3] & 0x1c) == 0x10);
else
sanity_check = ((packet[0] & 0x0c) == 0x04 &&
(packet[3] & 0x1c) == 0x10);
@@ -1116,6 +1125,7 @@ static int elantech_get_resolution_v4(struct psmouse 
*psmouse,
  * Avatar AVIU-145A2   0x361f00?   clickpad
  * Fujitsu LIFEBOOK E544   0x470f00d0, 12, 09  2 hw buttons
  * Fujitsu LIFEBOOK E554   0x570f0140, 14, 0c  2 hw buttons
+ * Fujitsu T725   0x470f0105, 12, 09  2 hw buttons
  * Fujitsu H7300x570f00c0, 14, 0c  3 hw buttons (**)
  * Gigabyte U2442  0x450f0158, 17, 0c  2 hw buttons
  * Lenovo L430 0x350f02b9, 15, 0c  2 hw buttons (*)
@@ -1651,6 +1661,16 @@ int elantech_init(struct psmouse *psmouse)
 etd->capabilities[0], etd->capabilities[1],
 etd->capabilities[2]);
 
+   if (etd->hw_version != 1) {
+   if (etd->send_cmd(psmouse, ETP_SAMPLE_QUERY, etd->samples)) {
+   psmouse_err(psmouse, "failed to query sample data\n");
+   goto init_fail;
+   }
+   psmouse_info(psmouse,
+   "Elan sample query result %02x, %02x, %02x\n",
+   etd->samples[0], etd->samples[1], etd->samples[2]);
+   }
+
if (elantech_set_absolute_mode(psmouse)) {
psmouse_err(psmouse,
"failed to put touchpad into absolute mode.\n");
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index f965d15..e1cbf40 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -129,6 +129,7 @@ struct elantech_data {
unsigned char reg_26;
unsigned char debug;
unsigned char capabilities[3];
+   unsigned char samples[3];
bool paritycheck;
bool jumpy_cursor;
bool reports_pressure;






--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/4] Input - elantech: Add special check for fw_version 0x470f01 touchpad

2015-08-07 Thread duson
It is no need to check the packet[0] for sanity check when doing
elantech_packet_check_v4() function for fw_version = 0x470f01 touchpad.

Signed-off by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elantech.c |   20 
 drivers/input/mouse/elantech.h |1 +
 2 files changed, 21 insertions(+)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 22b9ca9..2a0f883 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -785,6 +785,9 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
unsigned char packet_type = packet[3]  0x03;
bool sanity_check;
 
+   /* This represents the version of IC body. */
+   int ver = (etd-fw_version  0x0f)  16;
+
if (etd-tp_dev  (packet[3]  0x0f) == 0x06)
return PACKET_TRACKPOINT;
 
@@ -796,6 +799,12 @@ static int elantech_packet_check_v4(struct psmouse 
*psmouse)
 */
if (etd-crc_enabled)
sanity_check = ((packet[3]  0x08) == 0x00);
+   /*
+* The sanity check only need to check packet[3]
+* when IC_body = 7 and PID = 0x2A
+*/
+   else if (ver == 7  etd-samples[1] == 0x2A)
+   sanity_check = ((packet[3]  0x1c) == 0x10);
else
sanity_check = ((packet[0]  0x0c) == 0x04 
(packet[3]  0x1c) == 0x10);
@@ -1116,6 +1125,7 @@ static int elantech_get_resolution_v4(struct psmouse 
*psmouse,
  * Avatar AVIU-145A2   0x361f00?   clickpad
  * Fujitsu LIFEBOOK E544   0x470f00d0, 12, 09  2 hw buttons
  * Fujitsu LIFEBOOK E554   0x570f0140, 14, 0c  2 hw buttons
+ * Fujitsu T725   0x470f0105, 12, 09  2 hw buttons
  * Fujitsu H7300x570f00c0, 14, 0c  3 hw buttons (**)
  * Gigabyte U2442  0x450f0158, 17, 0c  2 hw buttons
  * Lenovo L430 0x350f02b9, 15, 0c  2 hw buttons (*)
@@ -1651,6 +1661,16 @@ int elantech_init(struct psmouse *psmouse)
 etd-capabilities[0], etd-capabilities[1],
 etd-capabilities[2]);
 
+   if (etd-hw_version != 1) {
+   if (etd-send_cmd(psmouse, ETP_SAMPLE_QUERY, etd-samples)) {
+   psmouse_err(psmouse, failed to query sample data\n);
+   goto init_fail;
+   }
+   psmouse_info(psmouse,
+   Elan sample query result %02x, %02x, %02x\n,
+   etd-samples[0], etd-samples[1], etd-samples[2]);
+   }
+
if (elantech_set_absolute_mode(psmouse)) {
psmouse_err(psmouse,
failed to put touchpad into absolute mode.\n);
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index f965d15..e1cbf40 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -129,6 +129,7 @@ struct elantech_data {
unsigned char reg_26;
unsigned char debug;
unsigned char capabilities[3];
+   unsigned char samples[3];
bool paritycheck;
bool jumpy_cursor;
bool reports_pressure;






--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] Input - elantech: Add special check for fw_version 0x470f01 touchpad

2015-08-01 Thread duson
It is no need to check the packet[0] for sanity check when doing
elantech_packet_check_v4() function for fw_version = 0x470f01 touchpad.

Signed-off by: Duson Lin 
---
 drivers/input/mouse/elantech.c |   28 +---
 drivers/input/mouse/elantech.h |1 +
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 22b9ca9..5bc3d55 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -785,6 +785,9 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
unsigned char packet_type = packet[3] & 0x03;
bool sanity_check;

+   /* This represents the version of IC body. */
+   int ver = (etd->fw_version & 0x0f) >> 16;
+
if (etd->tp_dev && (packet[3] & 0x0f) == 0x06)
return PACKET_TRACKPOINT;

@@ -796,9 +799,17 @@ static int elantech_packet_check_v4(struct psmouse 
*psmouse)
 */
if (etd->crc_enabled)
sanity_check = ((packet[3] & 0x08) == 0x00);
-   else
-   sanity_check = ((packet[0] & 0x0c) == 0x04 &&
-   (packet[3] & 0x1c) == 0x10);
+   else {
+   /*
+* The sanity check only need to check packet[3]
+* when IC_body = 7 and PID = 0x2A
+*/
+   if (ver == 7 && etd->samples[1] == 0x2A)
+   sanity_check = ((packet[3] & 0x1c) == 0x10);
+   else
+   sanity_check = ((packet[0] & 0x0c) == 0x04 &&
+   (packet[3] & 0x1c) == 0x10);
+   }

if (!sanity_check)
return PACKET_UNKNOWN;
@@ -1116,6 +1127,7 @@ static int elantech_get_resolution_v4(struct psmouse 
*psmouse,
  * Avatar AVIU-145A2   0x361f00?   clickpad
  * Fujitsu LIFEBOOK E544   0x470f00d0, 12, 09  2 hw buttons
  * Fujitsu LIFEBOOK E554   0x570f0140, 14, 0c  2 hw buttons
+ * Fujitsu T725   0x470f0105, 12, 09  2 hw buttons
  * Fujitsu H7300x570f00c0, 14, 0c  3 hw buttons (**)
  * Gigabyte U2442  0x450f0158, 17, 0c  2 hw buttons
  * Lenovo L430 0x350f02b9, 15, 0c  2 hw buttons (*)
@@ -1651,6 +1663,16 @@ int elantech_init(struct psmouse *psmouse)
 etd->capabilities[0], etd->capabilities[1],
 etd->capabilities[2]);

+   if (etd->hw_version != 1) {
+   if (etd->send_cmd(psmouse, ETP_SAMPLE_QUERY, etd->samples)) {
+   psmouse_err(psmouse, "failed to query sample data\n");
+   goto init_fail;
+   }
+   psmouse_info(psmouse,
+   "Elan sample query result %02x, %02x, %02x\n",
+   etd->samples[0], etd->samples[1], etd->samples[2]);
+   }
+
if (elantech_set_absolute_mode(psmouse)) {
psmouse_err(psmouse,
"failed to put touchpad into absolute mode.\n");
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index f965d15..e1cbf40 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -129,6 +129,7 @@ struct elantech_data {
unsigned char reg_26;
unsigned char debug;
unsigned char capabilities[3];
+   unsigned char samples[3];
bool paritycheck;
bool jumpy_cursor;
bool reports_pressure;
--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] Input - elantech: Add special check for fw_version 0x470f01 touchpad

2015-08-01 Thread duson
It is no need to check the packet[0] for sanity check when doing
elantech_packet_check_v4() function for fw_version = 0x470f01 touchpad.

Signed-off by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elantech.c |   28 +---
 drivers/input/mouse/elantech.h |1 +
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 22b9ca9..5bc3d55 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -785,6 +785,9 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
unsigned char packet_type = packet[3]  0x03;
bool sanity_check;

+   /* This represents the version of IC body. */
+   int ver = (etd-fw_version  0x0f)  16;
+
if (etd-tp_dev  (packet[3]  0x0f) == 0x06)
return PACKET_TRACKPOINT;

@@ -796,9 +799,17 @@ static int elantech_packet_check_v4(struct psmouse 
*psmouse)
 */
if (etd-crc_enabled)
sanity_check = ((packet[3]  0x08) == 0x00);
-   else
-   sanity_check = ((packet[0]  0x0c) == 0x04 
-   (packet[3]  0x1c) == 0x10);
+   else {
+   /*
+* The sanity check only need to check packet[3]
+* when IC_body = 7 and PID = 0x2A
+*/
+   if (ver == 7  etd-samples[1] == 0x2A)
+   sanity_check = ((packet[3]  0x1c) == 0x10);
+   else
+   sanity_check = ((packet[0]  0x0c) == 0x04 
+   (packet[3]  0x1c) == 0x10);
+   }

if (!sanity_check)
return PACKET_UNKNOWN;
@@ -1116,6 +1127,7 @@ static int elantech_get_resolution_v4(struct psmouse 
*psmouse,
  * Avatar AVIU-145A2   0x361f00?   clickpad
  * Fujitsu LIFEBOOK E544   0x470f00d0, 12, 09  2 hw buttons
  * Fujitsu LIFEBOOK E554   0x570f0140, 14, 0c  2 hw buttons
+ * Fujitsu T725   0x470f0105, 12, 09  2 hw buttons
  * Fujitsu H7300x570f00c0, 14, 0c  3 hw buttons (**)
  * Gigabyte U2442  0x450f0158, 17, 0c  2 hw buttons
  * Lenovo L430 0x350f02b9, 15, 0c  2 hw buttons (*)
@@ -1651,6 +1663,16 @@ int elantech_init(struct psmouse *psmouse)
 etd-capabilities[0], etd-capabilities[1],
 etd-capabilities[2]);

+   if (etd-hw_version != 1) {
+   if (etd-send_cmd(psmouse, ETP_SAMPLE_QUERY, etd-samples)) {
+   psmouse_err(psmouse, failed to query sample data\n);
+   goto init_fail;
+   }
+   psmouse_info(psmouse,
+   Elan sample query result %02x, %02x, %02x\n,
+   etd-samples[0], etd-samples[1], etd-samples[2]);
+   }
+
if (elantech_set_absolute_mode(psmouse)) {
psmouse_err(psmouse,
failed to put touchpad into absolute mode.\n);
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index f965d15..e1cbf40 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -129,6 +129,7 @@ struct elantech_data {
unsigned char reg_26;
unsigned char debug;
unsigned char capabilities[3];
+   unsigned char samples[3];
bool paritycheck;
bool jumpy_cursor;
bool reports_pressure;
--

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] Input - elantech: Add special check for fw_version 0x470f01 touchpad

2015-07-22 Thread duson
It is no need to check the packet[0] for sanity check when doing
elantech_packet_check_v4() function for fw_version = 0x470f01 touchpad.

Signed-off by: Duson Lin 
---
 drivers/input/mouse/elantech.c |   26 +++---
 drivers/input/mouse/elantech.h |1 +
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index ce3d400..6c6c2bb 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -784,6 +784,8 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
unsigned char *packet = psmouse->packet;
unsigned char packet_type = packet[3] & 0x03;
bool sanity_check;
+   /* This represents the version of IC body. */
+   int ver = (etd->fw_version & 0x0f) >> 16;
 
if (etd->tp_dev && (packet[3] & 0x0f) == 0x06)
return PACKET_TRACKPOINT;
@@ -796,9 +798,17 @@ static int elantech_packet_check_v4(struct psmouse 
*psmouse)
 */
if (etd->crc_enabled)
sanity_check = ((packet[3] & 0x08) == 0x00);
-   else
-   sanity_check = ((packet[0] & 0x0c) == 0x04 &&
-   (packet[3] & 0x1c) == 0x10);
+   else {
+   /* 
+* The sanity check only need to check packet[3]
+* when IC_body = 7 and PID = 0x2A  
+*/
+   if (ver == 7 && etd->samples[1] == 0x2A)
+   sanity_check = ((packet[3] & 0x1c) == 0x10);
+   else
+   sanity_check = ((packet[0] & 0x0c) == 0x04 &&
+   (packet[3] & 0x1c) == 0x10);
+   }
 
if (!sanity_check)
return PACKET_UNKNOWN;
@@ -1117,6 +1127,7 @@ static int elantech_get_resolution_v4(struct psmouse 
*psmouse,
  * Fujitsu LIFEBOOK E544   0x470f00d0, 12, 09  2 hw buttons
  * Fujitsu LIFEBOOK E554   0x570f0140, 14, 0c  2 hw buttons
  * Fujitsu H7300x570f00c0, 14, 0c  3 hw buttons (**)
+ * Fujitsu T725   0x470f0105, 12, 09  2 hw buttons
  * Gigabyte U2442  0x450f0158, 17, 0c  2 hw buttons
  * Lenovo L430 0x350f02b9, 15, 0c  2 hw buttons (*)
  * Lenovo L530 0x350f02b9, 15, 0c  2 hw buttons (*)
@@ -1648,6 +1659,15 @@ int elantech_init(struct psmouse *psmouse)
 etd->capabilities[0], etd->capabilities[1],
 etd->capabilities[2]);
 
+   if (etd->send_cmd(psmouse, ETP_SAMPLE_QUERY,
+   etd->samples)) {
+   psmouse_err(psmouse, "failed to query sample data.\n");
+   goto init_fail;
+   }
+   psmouse_info(psmouse,
+"Elan sample query result 0x%02x, 0x%02x, 0x%02x.\n",
+etd->samples[0], etd->samples[1], etd->samples[2]);
+
if (elantech_set_absolute_mode(psmouse)) {
psmouse_err(psmouse,
"failed to put touchpad into absolute mode.\n");
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index f965d15..e1cbf40 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -129,6 +129,7 @@ struct elantech_data {
unsigned char reg_26;
unsigned char debug;
unsigned char capabilities[3];
+   unsigned char samples[3];
bool paritycheck;
bool jumpy_cursor;
bool reports_pressure;






--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input - elantech: Add special check for fw_version 0x470f01 touchpad

2015-07-22 Thread duson
t is no need to check the packet[0] for sanity check when doing
elantech_packet_check_v4() function for fw_version = 0x470f01 touchpad.

Signed-off by: Duson Lin 
---
 drivers/input/mouse/elantech.c |   25 ++---
 drivers/input/mouse/elantech.h |1 +
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index ce3d400..d969153 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -784,6 +784,8 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
unsigned char *packet = psmouse->packet;
unsigned char packet_type = packet[3] & 0x03;
bool sanity_check;
+   /* This represents the version of IC body. */
+   int ver = (etd->fw_version & 0x0f) >> 16;
 
if (etd->tp_dev && (packet[3] & 0x0f) == 0x06)
return PACKET_TRACKPOINT;
@@ -796,9 +798,17 @@ static int elantech_packet_check_v4(struct psmouse 
*psmouse)
 */
if (etd->crc_enabled)
sanity_check = ((packet[3] & 0x08) == 0x00);
-   else
-   sanity_check = ((packet[0] & 0x0c) == 0x04 &&
-   (packet[3] & 0x1c) == 0x10);
+   else {
+   /* 
+* The sanity check only need to check packet[3]
+* when IC_body = 7 and PID = 0x2A  
+*/
+   if (ver == 7 && etd->samples[1] == 0x2A)
+   sanity_check = ((packet[3] & 0x1c) == 0x10);
+   else
+   sanity_check = ((packet[0] & 0x0c) == 0x04 &&
+   (packet[3] & 0x1c) == 0x10);
+   }
 
if (!sanity_check)
return PACKET_UNKNOWN;
@@ -1648,6 +1658,15 @@ int elantech_init(struct psmouse *psmouse)
 etd->capabilities[0], etd->capabilities[1],
 etd->capabilities[2]);
 
+   if (etd->send_cmd(psmouse, ETP_SAMPLE_QUERY,
+   etd->samples)) {
+   psmouse_err(psmouse, "failed to query sample data.\n");
+   goto init_fail;
+   }
+   psmouse_info(psmouse,
+"Elan sample query result 0x%02x, 0x%02x, 0x%02x.\n",
+etd->samples[0], etd->samples[1], etd->samples[2]);
+
if (elantech_set_absolute_mode(psmouse)) {
psmouse_err(psmouse,
"failed to put touchpad into absolute mode.\n");
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index f965d15..e1cbf40 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -129,6 +129,7 @@ struct elantech_data {
unsigned char reg_26;
unsigned char debug;
unsigned char capabilities[3];
+   unsigned char samples[3];
bool paritycheck;
bool jumpy_cursor;
bool reports_pressure;






--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input - elantech: Add special check for fw_version 0x470f01 touchpad

2015-07-22 Thread duson
t is no need to check the packet[0] for sanity check when doing
elantech_packet_check_v4() function for fw_version = 0x470f01 touchpad.

Signed-off by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elantech.c |   25 ++---
 drivers/input/mouse/elantech.h |1 +
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index ce3d400..d969153 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -784,6 +784,8 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
unsigned char *packet = psmouse-packet;
unsigned char packet_type = packet[3]  0x03;
bool sanity_check;
+   /* This represents the version of IC body. */
+   int ver = (etd-fw_version  0x0f)  16;
 
if (etd-tp_dev  (packet[3]  0x0f) == 0x06)
return PACKET_TRACKPOINT;
@@ -796,9 +798,17 @@ static int elantech_packet_check_v4(struct psmouse 
*psmouse)
 */
if (etd-crc_enabled)
sanity_check = ((packet[3]  0x08) == 0x00);
-   else
-   sanity_check = ((packet[0]  0x0c) == 0x04 
-   (packet[3]  0x1c) == 0x10);
+   else {
+   /* 
+* The sanity check only need to check packet[3]
+* when IC_body = 7 and PID = 0x2A  
+*/
+   if (ver == 7  etd-samples[1] == 0x2A)
+   sanity_check = ((packet[3]  0x1c) == 0x10);
+   else
+   sanity_check = ((packet[0]  0x0c) == 0x04 
+   (packet[3]  0x1c) == 0x10);
+   }
 
if (!sanity_check)
return PACKET_UNKNOWN;
@@ -1648,6 +1658,15 @@ int elantech_init(struct psmouse *psmouse)
 etd-capabilities[0], etd-capabilities[1],
 etd-capabilities[2]);
 
+   if (etd-send_cmd(psmouse, ETP_SAMPLE_QUERY,
+   etd-samples)) {
+   psmouse_err(psmouse, failed to query sample data.\n);
+   goto init_fail;
+   }
+   psmouse_info(psmouse,
+Elan sample query result 0x%02x, 0x%02x, 0x%02x.\n,
+etd-samples[0], etd-samples[1], etd-samples[2]);
+
if (elantech_set_absolute_mode(psmouse)) {
psmouse_err(psmouse,
failed to put touchpad into absolute mode.\n);
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index f965d15..e1cbf40 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -129,6 +129,7 @@ struct elantech_data {
unsigned char reg_26;
unsigned char debug;
unsigned char capabilities[3];
+   unsigned char samples[3];
bool paritycheck;
bool jumpy_cursor;
bool reports_pressure;






--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] Input - elantech: Add special check for fw_version 0x470f01 touchpad

2015-07-22 Thread duson
It is no need to check the packet[0] for sanity check when doing
elantech_packet_check_v4() function for fw_version = 0x470f01 touchpad.

Signed-off by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elantech.c |   26 +++---
 drivers/input/mouse/elantech.h |1 +
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index ce3d400..6c6c2bb 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -784,6 +784,8 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
unsigned char *packet = psmouse-packet;
unsigned char packet_type = packet[3]  0x03;
bool sanity_check;
+   /* This represents the version of IC body. */
+   int ver = (etd-fw_version  0x0f)  16;
 
if (etd-tp_dev  (packet[3]  0x0f) == 0x06)
return PACKET_TRACKPOINT;
@@ -796,9 +798,17 @@ static int elantech_packet_check_v4(struct psmouse 
*psmouse)
 */
if (etd-crc_enabled)
sanity_check = ((packet[3]  0x08) == 0x00);
-   else
-   sanity_check = ((packet[0]  0x0c) == 0x04 
-   (packet[3]  0x1c) == 0x10);
+   else {
+   /* 
+* The sanity check only need to check packet[3]
+* when IC_body = 7 and PID = 0x2A  
+*/
+   if (ver == 7  etd-samples[1] == 0x2A)
+   sanity_check = ((packet[3]  0x1c) == 0x10);
+   else
+   sanity_check = ((packet[0]  0x0c) == 0x04 
+   (packet[3]  0x1c) == 0x10);
+   }
 
if (!sanity_check)
return PACKET_UNKNOWN;
@@ -1117,6 +1127,7 @@ static int elantech_get_resolution_v4(struct psmouse 
*psmouse,
  * Fujitsu LIFEBOOK E544   0x470f00d0, 12, 09  2 hw buttons
  * Fujitsu LIFEBOOK E554   0x570f0140, 14, 0c  2 hw buttons
  * Fujitsu H7300x570f00c0, 14, 0c  3 hw buttons (**)
+ * Fujitsu T725   0x470f0105, 12, 09  2 hw buttons
  * Gigabyte U2442  0x450f0158, 17, 0c  2 hw buttons
  * Lenovo L430 0x350f02b9, 15, 0c  2 hw buttons (*)
  * Lenovo L530 0x350f02b9, 15, 0c  2 hw buttons (*)
@@ -1648,6 +1659,15 @@ int elantech_init(struct psmouse *psmouse)
 etd-capabilities[0], etd-capabilities[1],
 etd-capabilities[2]);
 
+   if (etd-send_cmd(psmouse, ETP_SAMPLE_QUERY,
+   etd-samples)) {
+   psmouse_err(psmouse, failed to query sample data.\n);
+   goto init_fail;
+   }
+   psmouse_info(psmouse,
+Elan sample query result 0x%02x, 0x%02x, 0x%02x.\n,
+etd-samples[0], etd-samples[1], etd-samples[2]);
+
if (elantech_set_absolute_mode(psmouse)) {
psmouse_err(psmouse,
failed to put touchpad into absolute mode.\n);
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index f965d15..e1cbf40 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -129,6 +129,7 @@ struct elantech_data {
unsigned char reg_26;
unsigned char debug;
unsigned char capabilities[3];
+   unsigned char samples[3];
bool paritycheck;
bool jumpy_cursor;
bool reports_pressure;






--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Change the hover event from MT to ST

2015-07-06 Thread duson
We want the hover event like BTN_LEFT, even no contract object,
it still can be reported to upper OS system.

Signed-off by: Duson Lin 
---
 drivers/input/mouse/elan_i2c_core.c |   12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 62641f2..5b5f403 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -771,7 +771,7 @@ static const struct attribute_group *elan_sysfs_groups[] = {
  */
 static void elan_report_contact(struct elan_tp_data *data,
int contact_num, bool contact_valid,
-   bool hover_event, u8 *finger_data)
+   u8 *finger_data)
 {
struct input_dev *input = data->input;
unsigned int pos_x, pos_y;
@@ -815,9 +815,7 @@ static void elan_report_contact(struct elan_tp_data *data,
input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
input_report_abs(input, ABS_MT_POSITION_X, pos_x);
input_report_abs(input, ABS_MT_POSITION_Y, data->max_y - pos_y);
-   input_report_abs(input, ABS_MT_DISTANCE, hover_event);
-   input_report_abs(input, ABS_MT_PRESSURE,
-hover_event ? 0 : scaled_pressure);
+   input_report_abs(input, ABS_MT_PRESSURE, scaled_pressure);
input_report_abs(input, ABS_TOOL_WIDTH, mk_x);
input_report_abs(input, ABS_MT_TOUCH_MAJOR, major);
input_report_abs(input, ABS_MT_TOUCH_MINOR, minor);
@@ -839,14 +837,14 @@ static void elan_report_absolute(struct elan_tp_data 
*data, u8 *packet)
hover_event = hover_info & 0x40;
for (i = 0; i < ETP_MAX_FINGERS; i++) {
contact_valid = tp_info & (1U << (3 + i));
-   elan_report_contact(data, i, contact_valid, hover_event,
-   finger_data);
+   elan_report_contact(data, i, contact_valid, finger_data);
 
if (contact_valid)
finger_data += ETP_FINGER_DATA_LEN;
}
 
input_report_key(input, BTN_LEFT, tp_info & 0x01);
+   input_report_abs(input, ABS_DISTANCE, hover_event != 0);
input_mt_report_pointer_emulation(input, true);
input_sync(input);
 }
@@ -922,6 +920,7 @@ static int elan_setup_input_device(struct elan_tp_data 
*data)
input_abs_set_res(input, ABS_Y, data->y_res);
input_set_abs_params(input, ABS_PRESSURE, 0, ETP_MAX_PRESSURE, 0, 0);
input_set_abs_params(input, ABS_TOOL_WIDTH, 0, ETP_FINGER_WIDTH, 0, 0);
+   input_set_abs_params(input, ABS_DISTANCE, 0, 1, 0, 0);
 
/* And MT parameters */
input_set_abs_params(input, ABS_MT_POSITION_X, 0, data->max_x, 0, 0);
@@ -934,7 +933,6 @@ static int elan_setup_input_device(struct elan_tp_data 
*data)
 ETP_FINGER_WIDTH * max_width, 0, 0);
input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0,
 ETP_FINGER_WIDTH * min_width, 0, 0);
-   input_set_abs_params(input, ABS_MT_DISTANCE, 0, 1, 0, 0);
 
data->input = input;





--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Change the hover event from MT to ST

2015-07-06 Thread duson
We want the hover event like BTN_LEFT, even no contract object,
it still can be reported to upper OS system.

Signed-off by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elan_i2c_core.c |   12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 62641f2..5b5f403 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -771,7 +771,7 @@ static const struct attribute_group *elan_sysfs_groups[] = {
  */
 static void elan_report_contact(struct elan_tp_data *data,
int contact_num, bool contact_valid,
-   bool hover_event, u8 *finger_data)
+   u8 *finger_data)
 {
struct input_dev *input = data-input;
unsigned int pos_x, pos_y;
@@ -815,9 +815,7 @@ static void elan_report_contact(struct elan_tp_data *data,
input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
input_report_abs(input, ABS_MT_POSITION_X, pos_x);
input_report_abs(input, ABS_MT_POSITION_Y, data-max_y - pos_y);
-   input_report_abs(input, ABS_MT_DISTANCE, hover_event);
-   input_report_abs(input, ABS_MT_PRESSURE,
-hover_event ? 0 : scaled_pressure);
+   input_report_abs(input, ABS_MT_PRESSURE, scaled_pressure);
input_report_abs(input, ABS_TOOL_WIDTH, mk_x);
input_report_abs(input, ABS_MT_TOUCH_MAJOR, major);
input_report_abs(input, ABS_MT_TOUCH_MINOR, minor);
@@ -839,14 +837,14 @@ static void elan_report_absolute(struct elan_tp_data 
*data, u8 *packet)
hover_event = hover_info  0x40;
for (i = 0; i  ETP_MAX_FINGERS; i++) {
contact_valid = tp_info  (1U  (3 + i));
-   elan_report_contact(data, i, contact_valid, hover_event,
-   finger_data);
+   elan_report_contact(data, i, contact_valid, finger_data);
 
if (contact_valid)
finger_data += ETP_FINGER_DATA_LEN;
}
 
input_report_key(input, BTN_LEFT, tp_info  0x01);
+   input_report_abs(input, ABS_DISTANCE, hover_event != 0);
input_mt_report_pointer_emulation(input, true);
input_sync(input);
 }
@@ -922,6 +920,7 @@ static int elan_setup_input_device(struct elan_tp_data 
*data)
input_abs_set_res(input, ABS_Y, data-y_res);
input_set_abs_params(input, ABS_PRESSURE, 0, ETP_MAX_PRESSURE, 0, 0);
input_set_abs_params(input, ABS_TOOL_WIDTH, 0, ETP_FINGER_WIDTH, 0, 0);
+   input_set_abs_params(input, ABS_DISTANCE, 0, 1, 0, 0);
 
/* And MT parameters */
input_set_abs_params(input, ABS_MT_POSITION_X, 0, data-max_x, 0, 0);
@@ -934,7 +933,6 @@ static int elan_setup_input_device(struct elan_tp_data 
*data)
 ETP_FINGER_WIDTH * max_width, 0, 0);
input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0,
 ETP_FINGER_WIDTH * min_width, 0, 0);
-   input_set_abs_params(input, ABS_MT_DISTANCE, 0, 1, 0, 0);
 
data-input = input;





--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Add hover event for ST format

2015-06-28 Thread duson
Signed-off by: Duson Lin 
---
 drivers/input/mouse/elan_i2c_core.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 62641f2..ce97e28 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -847,6 +847,7 @@ static void elan_report_absolute(struct elan_tp_data *data, 
u8 *packet)
}
 
input_report_key(input, BTN_LEFT, tp_info & 0x01);
+   input_report_abs(input, ABS_DISTANCE, hover_event != 0);
input_mt_report_pointer_emulation(input, true);
input_sync(input);
 }
@@ -922,6 +923,7 @@ static int elan_setup_input_device(struct elan_tp_data 
*data)
input_abs_set_res(input, ABS_Y, data->y_res);
input_set_abs_params(input, ABS_PRESSURE, 0, ETP_MAX_PRESSURE, 0, 0);
input_set_abs_params(input, ABS_TOOL_WIDTH, 0, ETP_FINGER_WIDTH, 0, 0);
+   input_set_abs_params(input, ABS_DISTANCE, 0, 1, 0, 0);
 
/* And MT parameters */
input_set_abs_params(input, ABS_MT_POSITION_X, 0, data->max_x, 0, 0);




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Add hover event for ST format

2015-06-28 Thread duson
Signed-off by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elan_i2c_core.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 62641f2..ce97e28 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -847,6 +847,7 @@ static void elan_report_absolute(struct elan_tp_data *data, 
u8 *packet)
}
 
input_report_key(input, BTN_LEFT, tp_info  0x01);
+   input_report_abs(input, ABS_DISTANCE, hover_event != 0);
input_mt_report_pointer_emulation(input, true);
input_sync(input);
 }
@@ -922,6 +923,7 @@ static int elan_setup_input_device(struct elan_tp_data 
*data)
input_abs_set_res(input, ABS_Y, data-y_res);
input_set_abs_params(input, ABS_PRESSURE, 0, ETP_MAX_PRESSURE, 0, 0);
input_set_abs_params(input, ABS_TOOL_WIDTH, 0, ETP_FINGER_WIDTH, 0, 0);
+   input_set_abs_params(input, ABS_DISTANCE, 0, 1, 0, 0);
 
/* And MT parameters */
input_set_abs_params(input, ABS_MT_POSITION_X, 0, data-max_x, 0, 0);




--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input - elan_i2c: support multi ic type and iap format

2015-06-06 Thread duson
In order to support multi ic type for i2c/smbus protocol, add get ic type
command and check fw vaild page count and signature address function.

Signed-off by: Duson Lin 
---
 drivers/input/mouse/elan_i2c.h   |5 ++--
 drivers/input/mouse/elan_i2c_core.c  |   44 ++
 drivers/input/mouse/elan_i2c_i2c.c   |5 +++-
 drivers/input/mouse/elan_i2c_smbus.c |6 +++--
 4 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 6d5f8a4..ff622a1 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -33,9 +33,7 @@
 #define ETP_FW_IAP_PAGE_ERR(1 << 5)
 #define ETP_FW_IAP_INTF_ERR(1 << 4)
 #define ETP_FW_PAGE_SIZE   64
-#define ETP_FW_VAILDPAGE_COUNT 768
 #define ETP_FW_SIGNATURE_SIZE  6
-#define ETP_FW_SIGNATURE_ADDRESS   0xBFFA
 
 struct i2c_client;
 struct completion;
@@ -58,7 +56,8 @@ struct elan_transport_ops {
 bool max_baseliune, u8 *value);
 
int (*get_version)(struct i2c_client *client, bool iap, u8 *version);
-   int (*get_sm_version)(struct i2c_client *client, u8 *version);
+   int (*get_sm_version)(struct i2c_client *client,
+ u8* ic_type, u8 *version);
int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
int (*get_product_id)(struct i2c_client *client, u8 *id);
 
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index fd5068b..81e7bc9 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.7
+ * Version: 1.5.8
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.7"
+#define ELAN_DRIVER_VERSION"1.5.8"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -83,6 +83,9 @@ struct elan_tp_data {
u16 fw_checksum;
int pressure_adjustment;
u8  mode;
+   u8  ic_type;
+   u16 fw_vaildpage_count;
+   u16 fw_signature_address;
 
boolirq_wake;
 
@@ -91,6 +94,28 @@ struct elan_tp_data {
boolbaseline_ready;
 };
 
+static int elan_get_fwinfo(u8 ic_type, u16 *vaildpage_count,
+  u16 *signature_address)
+{
+   
+   switch(ic_type) {
+   case 0x09:
+   *vaildpage_count = 768;
+   break;
+   case 0x0D:
+   *vaildpage_count = 896;
+   break;
+   default:
+   /* unknown ic type clear value */
+   *vaildpage_count = 0;
+   *signature_address = 0;
+   return -ENXIO;
+   }
+   *signature_address = (*vaildpage_count * ETP_FW_PAGE_SIZE)
+- ETP_FW_SIGNATURE_SIZE;
+   return 0;
+}
+
 static int elan_enable_power(struct elan_tp_data *data)
 {
int repeat = ETP_RETRY_COUNT;
@@ -221,7 +246,8 @@ static int elan_query_device_info(struct elan_tp_data *data)
if (error)
return error;
 
-   error = data->ops->get_sm_version(data->client, >sm_version);
+   error = data->ops->get_sm_version(data->client, >ic_type,
+ >sm_version);
if (error)
return error;
 
@@ -234,6 +260,14 @@ static int elan_query_device_info(struct elan_tp_data 
*data)
if (error)
return error;
 
+   error = elan_get_fwinfo(data->ic_type, >fw_vaildpage_count,
+   >fw_signature_address);
+   if (error) {
+   dev_err(>client->dev,
+   "unknown ic type %d\n", data->ic_type);
+   return error;
+   }
+
return 0;
 }
 
@@ -318,7 +352,7 @@ static int __elan_update_firmware(struct elan_tp_data *data,
iap_start_addr = get_unaligned_le16(>data[ETP_IAP_START_ADDR * 2]);
 
boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE;
-   for (i = boot_page_count; i < ETP_FW_VAILDPAGE_COUNT; i++) {
+   for (i = boot_page_count; i < data->fw_vaildpage_count; i++) {
u16 checksum = 0;
const u8 *page = >data[i * ETP_FW_PAGE_SIZE];
 
@@ -454,7 +488,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
}
 
/* Firmware file must match signature data */
-   fw_signature = >data[ETP_FW_SIGNATURE_ADDRESS];
+   fw_signature = >

[PATCH] Input - elan_i2c: support multi ic type and iap format

2015-06-06 Thread duson
In order to support multi ic type for i2c/smbus protocol, add get ic type
command and check fw vaild page count and signature address function.

Signed-off by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elan_i2c.h   |5 ++--
 drivers/input/mouse/elan_i2c_core.c  |   44 ++
 drivers/input/mouse/elan_i2c_i2c.c   |5 +++-
 drivers/input/mouse/elan_i2c_smbus.c |6 +++--
 4 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 6d5f8a4..ff622a1 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -33,9 +33,7 @@
 #define ETP_FW_IAP_PAGE_ERR(1  5)
 #define ETP_FW_IAP_INTF_ERR(1  4)
 #define ETP_FW_PAGE_SIZE   64
-#define ETP_FW_VAILDPAGE_COUNT 768
 #define ETP_FW_SIGNATURE_SIZE  6
-#define ETP_FW_SIGNATURE_ADDRESS   0xBFFA
 
 struct i2c_client;
 struct completion;
@@ -58,7 +56,8 @@ struct elan_transport_ops {
 bool max_baseliune, u8 *value);
 
int (*get_version)(struct i2c_client *client, bool iap, u8 *version);
-   int (*get_sm_version)(struct i2c_client *client, u8 *version);
+   int (*get_sm_version)(struct i2c_client *client,
+ u8* ic_type, u8 *version);
int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
int (*get_product_id)(struct i2c_client *client, u8 *id);
 
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index fd5068b..81e7bc9 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.7
+ * Version: 1.5.8
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include elan_i2c.h
 
 #define DRIVER_NAMEelan_i2c
-#define ELAN_DRIVER_VERSION1.5.7
+#define ELAN_DRIVER_VERSION1.5.8
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -83,6 +83,9 @@ struct elan_tp_data {
u16 fw_checksum;
int pressure_adjustment;
u8  mode;
+   u8  ic_type;
+   u16 fw_vaildpage_count;
+   u16 fw_signature_address;
 
boolirq_wake;
 
@@ -91,6 +94,28 @@ struct elan_tp_data {
boolbaseline_ready;
 };
 
+static int elan_get_fwinfo(u8 ic_type, u16 *vaildpage_count,
+  u16 *signature_address)
+{
+   
+   switch(ic_type) {
+   case 0x09:
+   *vaildpage_count = 768;
+   break;
+   case 0x0D:
+   *vaildpage_count = 896;
+   break;
+   default:
+   /* unknown ic type clear value */
+   *vaildpage_count = 0;
+   *signature_address = 0;
+   return -ENXIO;
+   }
+   *signature_address = (*vaildpage_count * ETP_FW_PAGE_SIZE)
+- ETP_FW_SIGNATURE_SIZE;
+   return 0;
+}
+
 static int elan_enable_power(struct elan_tp_data *data)
 {
int repeat = ETP_RETRY_COUNT;
@@ -221,7 +246,8 @@ static int elan_query_device_info(struct elan_tp_data *data)
if (error)
return error;
 
-   error = data-ops-get_sm_version(data-client, data-sm_version);
+   error = data-ops-get_sm_version(data-client, data-ic_type,
+ data-sm_version);
if (error)
return error;
 
@@ -234,6 +260,14 @@ static int elan_query_device_info(struct elan_tp_data 
*data)
if (error)
return error;
 
+   error = elan_get_fwinfo(data-ic_type, data-fw_vaildpage_count,
+   data-fw_signature_address);
+   if (error) {
+   dev_err(data-client-dev,
+   unknown ic type %d\n, data-ic_type);
+   return error;
+   }
+
return 0;
 }
 
@@ -318,7 +352,7 @@ static int __elan_update_firmware(struct elan_tp_data *data,
iap_start_addr = get_unaligned_le16(fw-data[ETP_IAP_START_ADDR * 2]);
 
boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE;
-   for (i = boot_page_count; i  ETP_FW_VAILDPAGE_COUNT; i++) {
+   for (i = boot_page_count; i  data-fw_vaildpage_count; i++) {
u16 checksum = 0;
const u8 *page = fw-data[i * ETP_FW_PAGE_SIZE];
 
@@ -454,7 +488,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
}
 
/* Firmware file must match signature data */
-   fw_signature = fw-data[ETP_FW_SIGNATURE_ADDRESS];
+   fw_signature = fw-data[data-fw_signature_address];
if (memcmp(fw_signature, signature, sizeof

Re: [PATCH 5/5] Input: elan_i2c - Correct the x and y trace number.

2015-04-20 Thread duson
Hi Dmitry,

How about the description? Is it looks good for you?
Please let me know if you have any concern.

--
Thank you,
ELAN Duson
✉ Email: duson...@emc.com.tw
--





> duson  於 2015年4月16日 上午9:37 寫道:
> 
> Hi Dmitry,
> 
> I double check with our firmware team and the SPEC, it looks like the 
> subtract 1 just a misunderstanding.
> So, the correct should not subtract 1. For example, if the touchpad x 
> resolution is 2800 and x trace number is 20,
> the pitch size of x should be 2800/20 = 140, not 2800/19 = 147.36. 
> 
> ------
> Thanks,
> ELAN Duson
> ✉ Email: duson...@emc.com.tw
> --
> 
> 
> 
> 
> 
>> Dmitry Torokhov  於 2015年4月16日 上午1:47 寫道:
>> 
>> On Wed, Apr 15, 2015 at 09:55:43AM +0800, DusonLin wrote:
>>> The trace number does not need to subtract 1 now.
>> 
>> Could you provide a bit more of background for this change? Why don't we
>> need to decrement the number returned by the firmware anymore? We have
>> been running with the old numbers for many years...
>> 
>> Thanks!
>> 
>>> 
>>> Signed-off-by: Duson Lin 
>>> ---
>>> drivers/input/mouse/elan_i2c_i2c.c   |4 ++--
>>> drivers/input/mouse/elan_i2c_smbus.c |4 ++--
>>> 2 files changed, 4 insertions(+), 4 deletions(-)
>>> 
>>> diff --git a/drivers/input/mouse/elan_i2c_i2c.c
>>> b/drivers/input/mouse/elan_i2c_i2c.c
>>> index 029941f..550f905 100644
>>> --- a/drivers/input/mouse/elan_i2c_i2c.c
>>> +++ b/drivers/input/mouse/elan_i2c_i2c.c
>>> @@ -356,8 +356,8 @@ static int elan_i2c_get_num_traces(struct i2c_client
>>> *client,
>>> return error;
>>> }
>>> 
>>> -   *x_traces = val[0] - 1;
>>> -   *y_traces = val[1] - 1;
>>> +   *x_traces = val[0];
>>> +   *y_traces = val[1];
>>> 
>>> return 0;
>>> }
>>> diff --git a/drivers/input/mouse/elan_i2c_smbus.c
>>> b/drivers/input/mouse/elan_i2c_smbus.c
>>> index 06a2bcd..0b04151 100644
>>> --- a/drivers/input/mouse/elan_i2c_smbus.c
>>> +++ b/drivers/input/mouse/elan_i2c_smbus.c
>>> @@ -268,8 +268,8 @@ static int elan_smbus_get_num_traces(struct i2c_client
>>> *client,
>>> return error;
>>> }
>>> 
>>> -   *x_traces = val[1] - 1;
>>> -   *y_traces = val[2] - 1;
>>> +   *x_traces = val[1];
>>> +   *y_traces = val[2];
>>> 
>>> return 0;
>>> }
>>> 
>> 
>> -- 
>> Dmitry
>> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 6/6] Input: elan_i2c - Add hover detection flag

2015-04-20 Thread duson
Hi Dmitry,

Is this patch looks good for you?
If you have any advice, please let me know.

--
Thank you
ELAN Duson
✉ Email: duson...@emc.com.tw
--





> duson  於 2015年4月17日 上午9:56 寫道:
> 
> When hover event coming, set ABS_MT_DISTANCE as 1, otherwise clear to 0.
> 
> Signed-off-by: Duson Lin 
> ---
> drivers/input/mouse/elan_i2c_core.c |   15 +++
> 1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/mouse/elan_i2c_core.c 
> b/drivers/input/mouse/elan_i2c_core.c
> index 6333ba6..da7893f 100644
> --- a/drivers/input/mouse/elan_i2c_core.c
> +++ b/drivers/input/mouse/elan_i2c_core.c
> @@ -52,6 +52,7 @@
> #define ETP_REPORT_ID_OFFSET  2
> #define ETP_TOUCH_INFO_OFFSET 3
> #define ETP_FINGER_DATA_OFFSET4
> +#define ETP_HOVER_INFO_OFFSET30
> #define ETP_MAX_REPORT_LEN34
> 
> /* The main device structure */
> @@ -725,7 +726,7 @@ static const struct attribute_group *elan_sysfs_groups[] 
> = {
>  */
> static void elan_report_contact(struct elan_tp_data *data,
>   int contact_num, bool contact_valid,
> - u8 *finger_data)
> + bool hover_event, u8 *finger_data)
> {
>   struct input_dev *input = data->input;
>   unsigned int pos_x, pos_y;
> @@ -769,7 +770,9 @@ static void elan_report_contact(struct elan_tp_data *data,
>   input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
>   input_report_abs(input, ABS_MT_POSITION_X, pos_x);
>   input_report_abs(input, ABS_MT_POSITION_Y, data->max_y - pos_y);
> - input_report_abs(input, ABS_MT_PRESSURE, scaled_pressure);
> + input_report_abs(input, ABS_MT_DISTANCE, hover_event);
> + input_report_abs(input, ABS_MT_PRESSURE,
> +  hover_event ? 0 : scaled_pressure);
>   input_report_abs(input, ABS_TOOL_WIDTH, mk_x);
>   input_report_abs(input, ABS_MT_TOUCH_MAJOR, major);
>   input_report_abs(input, ABS_MT_TOUCH_MINOR, minor);
> @@ -785,11 +788,14 @@ static void elan_report_absolute(struct elan_tp_data 
> *data, u8 *packet)
>   u8 *finger_data = [ETP_FINGER_DATA_OFFSET];
>   int i;
>   u8 tp_info = packet[ETP_TOUCH_INFO_OFFSET];
> - bool contact_valid;
> + u8 hover_info = packet[ETP_HOVER_INFO_OFFSET];
> + bool contact_valid, hover_event;
> 
> + hover_event = hover_info & 0x40;
>   for (i = 0; i < ETP_MAX_FINGERS; i++) {
>   contact_valid = tp_info & (1U << (3 + i));
> - elan_report_contact(data, i, contact_valid, finger_data);
> + elan_report_contact(data, i, contact_valid, hover_event,
> + finger_data);
> 
>   if (contact_valid)
>   finger_data += ETP_FINGER_DATA_LEN;
> @@ -883,6 +889,7 @@ static int elan_setup_input_device(struct elan_tp_data 
> *data)
>ETP_FINGER_WIDTH * max_width, 0, 0);
>   input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0,
>ETP_FINGER_WIDTH * min_width, 0, 0);
> + input_set_abs_params(input, ABS_MT_DISTANCE, 0, 1, 0, 0);
> 
>   data->input = input;
> 
> 
> 
> 
> 
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/5] Input: elan_i2c - Correct the x and y trace number.

2015-04-20 Thread duson
Hi Dmitry,

How about the description? Is it looks good for you?
Please let me know if you have any concern.

--
Thank you,
ELAN Duson
✉ Email: duson...@emc.com.tw
--





 duson duson...@emc.com.tw 於 2015年4月16日 上午9:37 寫道:
 
 Hi Dmitry,
 
 I double check with our firmware team and the SPEC, it looks like the 
 subtract 1 just a misunderstanding.
 So, the correct should not subtract 1. For example, if the touchpad x 
 resolution is 2800 and x trace number is 20,
 the pitch size of x should be 2800/20 = 140, not 2800/19 = 147.36. 
 
 --
 Thanks,
 ELAN Duson
 ✉ Email: duson...@emc.com.tw
 --
 
 
 
 
 
 Dmitry Torokhov dmitry.torok...@gmail.com 於 2015年4月16日 上午1:47 寫道:
 
 On Wed, Apr 15, 2015 at 09:55:43AM +0800, DusonLin wrote:
 The trace number does not need to subtract 1 now.
 
 Could you provide a bit more of background for this change? Why don't we
 need to decrement the number returned by the firmware anymore? We have
 been running with the old numbers for many years...
 
 Thanks!
 
 
 Signed-off-by: Duson Lin duson...@emc.com.tw
 ---
 drivers/input/mouse/elan_i2c_i2c.c   |4 ++--
 drivers/input/mouse/elan_i2c_smbus.c |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/input/mouse/elan_i2c_i2c.c
 b/drivers/input/mouse/elan_i2c_i2c.c
 index 029941f..550f905 100644
 --- a/drivers/input/mouse/elan_i2c_i2c.c
 +++ b/drivers/input/mouse/elan_i2c_i2c.c
 @@ -356,8 +356,8 @@ static int elan_i2c_get_num_traces(struct i2c_client
 *client,
 return error;
 }
 
 -   *x_traces = val[0] - 1;
 -   *y_traces = val[1] - 1;
 +   *x_traces = val[0];
 +   *y_traces = val[1];
 
 return 0;
 }
 diff --git a/drivers/input/mouse/elan_i2c_smbus.c
 b/drivers/input/mouse/elan_i2c_smbus.c
 index 06a2bcd..0b04151 100644
 --- a/drivers/input/mouse/elan_i2c_smbus.c
 +++ b/drivers/input/mouse/elan_i2c_smbus.c
 @@ -268,8 +268,8 @@ static int elan_smbus_get_num_traces(struct i2c_client
 *client,
 return error;
 }
 
 -   *x_traces = val[1] - 1;
 -   *y_traces = val[2] - 1;
 +   *x_traces = val[1];
 +   *y_traces = val[2];
 
 return 0;
 }
 
 
 -- 
 Dmitry
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 6/6] Input: elan_i2c - Add hover detection flag

2015-04-20 Thread duson
Hi Dmitry,

Is this patch looks good for you?
If you have any advice, please let me know.

--
Thank you
ELAN Duson
✉ Email: duson...@emc.com.tw
--





 duson duson...@emc.com.tw 於 2015年4月17日 上午9:56 寫道:
 
 When hover event coming, set ABS_MT_DISTANCE as 1, otherwise clear to 0.
 
 Signed-off-by: Duson Lin duson...@emc.com.tw
 ---
 drivers/input/mouse/elan_i2c_core.c |   15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/input/mouse/elan_i2c_core.c 
 b/drivers/input/mouse/elan_i2c_core.c
 index 6333ba6..da7893f 100644
 --- a/drivers/input/mouse/elan_i2c_core.c
 +++ b/drivers/input/mouse/elan_i2c_core.c
 @@ -52,6 +52,7 @@
 #define ETP_REPORT_ID_OFFSET  2
 #define ETP_TOUCH_INFO_OFFSET 3
 #define ETP_FINGER_DATA_OFFSET4
 +#define ETP_HOVER_INFO_OFFSET30
 #define ETP_MAX_REPORT_LEN34
 
 /* The main device structure */
 @@ -725,7 +726,7 @@ static const struct attribute_group *elan_sysfs_groups[] 
 = {
  */
 static void elan_report_contact(struct elan_tp_data *data,
   int contact_num, bool contact_valid,
 - u8 *finger_data)
 + bool hover_event, u8 *finger_data)
 {
   struct input_dev *input = data-input;
   unsigned int pos_x, pos_y;
 @@ -769,7 +770,9 @@ static void elan_report_contact(struct elan_tp_data *data,
   input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
   input_report_abs(input, ABS_MT_POSITION_X, pos_x);
   input_report_abs(input, ABS_MT_POSITION_Y, data-max_y - pos_y);
 - input_report_abs(input, ABS_MT_PRESSURE, scaled_pressure);
 + input_report_abs(input, ABS_MT_DISTANCE, hover_event);
 + input_report_abs(input, ABS_MT_PRESSURE,
 +  hover_event ? 0 : scaled_pressure);
   input_report_abs(input, ABS_TOOL_WIDTH, mk_x);
   input_report_abs(input, ABS_MT_TOUCH_MAJOR, major);
   input_report_abs(input, ABS_MT_TOUCH_MINOR, minor);
 @@ -785,11 +788,14 @@ static void elan_report_absolute(struct elan_tp_data 
 *data, u8 *packet)
   u8 *finger_data = packet[ETP_FINGER_DATA_OFFSET];
   int i;
   u8 tp_info = packet[ETP_TOUCH_INFO_OFFSET];
 - bool contact_valid;
 + u8 hover_info = packet[ETP_HOVER_INFO_OFFSET];
 + bool contact_valid, hover_event;
 
 + hover_event = hover_info  0x40;
   for (i = 0; i  ETP_MAX_FINGERS; i++) {
   contact_valid = tp_info  (1U  (3 + i));
 - elan_report_contact(data, i, contact_valid, finger_data);
 + elan_report_contact(data, i, contact_valid, hover_event,
 + finger_data);
 
   if (contact_valid)
   finger_data += ETP_FINGER_DATA_LEN;
 @@ -883,6 +889,7 @@ static int elan_setup_input_device(struct elan_tp_data 
 *data)
ETP_FINGER_WIDTH * max_width, 0, 0);
   input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0,
ETP_FINGER_WIDTH * min_width, 0, 0);
 + input_set_abs_params(input, ABS_MT_DISTANCE, 0, 1, 0, 0);
 
   data-input = input;
 
 
 
 
 
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] Input: elan_i2c - Add hover detection flag

2015-04-16 Thread duson
When hover event coming, set ABS_MT_DISTANCE as 1, otherwise clear to 0.

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/elan_i2c_core.c |   15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 6333ba6..da7893f 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -52,6 +52,7 @@
 #define ETP_REPORT_ID_OFFSET   2
 #define ETP_TOUCH_INFO_OFFSET  3
 #define ETP_FINGER_DATA_OFFSET 4
+#define ETP_HOVER_INFO_OFFSET  30
 #define ETP_MAX_REPORT_LEN 34
 
 /* The main device structure */
@@ -725,7 +726,7 @@ static const struct attribute_group *elan_sysfs_groups[] = {
  */
 static void elan_report_contact(struct elan_tp_data *data,
int contact_num, bool contact_valid,
-   u8 *finger_data)
+   bool hover_event, u8 *finger_data)
 {
struct input_dev *input = data->input;
unsigned int pos_x, pos_y;
@@ -769,7 +770,9 @@ static void elan_report_contact(struct elan_tp_data *data,
input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
input_report_abs(input, ABS_MT_POSITION_X, pos_x);
input_report_abs(input, ABS_MT_POSITION_Y, data->max_y - pos_y);
-   input_report_abs(input, ABS_MT_PRESSURE, scaled_pressure);
+   input_report_abs(input, ABS_MT_DISTANCE, hover_event);
+   input_report_abs(input, ABS_MT_PRESSURE,
+hover_event ? 0 : scaled_pressure);
input_report_abs(input, ABS_TOOL_WIDTH, mk_x);
input_report_abs(input, ABS_MT_TOUCH_MAJOR, major);
input_report_abs(input, ABS_MT_TOUCH_MINOR, minor);
@@ -785,11 +788,14 @@ static void elan_report_absolute(struct elan_tp_data 
*data, u8 *packet)
u8 *finger_data = [ETP_FINGER_DATA_OFFSET];
int i;
u8 tp_info = packet[ETP_TOUCH_INFO_OFFSET];
-   bool contact_valid;
+   u8 hover_info = packet[ETP_HOVER_INFO_OFFSET];
+   bool contact_valid, hover_event;
 
+   hover_event = hover_info & 0x40;
for (i = 0; i < ETP_MAX_FINGERS; i++) {
contact_valid = tp_info & (1U << (3 + i));
-   elan_report_contact(data, i, contact_valid, finger_data);
+   elan_report_contact(data, i, contact_valid, hover_event,
+   finger_data);
 
if (contact_valid)
finger_data += ETP_FINGER_DATA_LEN;
@@ -883,6 +889,7 @@ static int elan_setup_input_device(struct elan_tp_data 
*data)
 ETP_FINGER_WIDTH * max_width, 0, 0);
input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0,
 ETP_FINGER_WIDTH * min_width, 0, 0);
+   input_set_abs_params(input, ABS_MT_DISTANCE, 0, 1, 0, 0);
 
data->input = input;
 






--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] Input: elan_i2c - Add hover detection flag

2015-04-16 Thread duson
When hover event coming, set ABS_MT_DISTANCE as 1, otherwise clear to 0.

Signed-off-by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elan_i2c_core.c |   15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 6333ba6..da7893f 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -52,6 +52,7 @@
 #define ETP_REPORT_ID_OFFSET   2
 #define ETP_TOUCH_INFO_OFFSET  3
 #define ETP_FINGER_DATA_OFFSET 4
+#define ETP_HOVER_INFO_OFFSET  30
 #define ETP_MAX_REPORT_LEN 34
 
 /* The main device structure */
@@ -725,7 +726,7 @@ static const struct attribute_group *elan_sysfs_groups[] = {
  */
 static void elan_report_contact(struct elan_tp_data *data,
int contact_num, bool contact_valid,
-   u8 *finger_data)
+   bool hover_event, u8 *finger_data)
 {
struct input_dev *input = data-input;
unsigned int pos_x, pos_y;
@@ -769,7 +770,9 @@ static void elan_report_contact(struct elan_tp_data *data,
input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
input_report_abs(input, ABS_MT_POSITION_X, pos_x);
input_report_abs(input, ABS_MT_POSITION_Y, data-max_y - pos_y);
-   input_report_abs(input, ABS_MT_PRESSURE, scaled_pressure);
+   input_report_abs(input, ABS_MT_DISTANCE, hover_event);
+   input_report_abs(input, ABS_MT_PRESSURE,
+hover_event ? 0 : scaled_pressure);
input_report_abs(input, ABS_TOOL_WIDTH, mk_x);
input_report_abs(input, ABS_MT_TOUCH_MAJOR, major);
input_report_abs(input, ABS_MT_TOUCH_MINOR, minor);
@@ -785,11 +788,14 @@ static void elan_report_absolute(struct elan_tp_data 
*data, u8 *packet)
u8 *finger_data = packet[ETP_FINGER_DATA_OFFSET];
int i;
u8 tp_info = packet[ETP_TOUCH_INFO_OFFSET];
-   bool contact_valid;
+   u8 hover_info = packet[ETP_HOVER_INFO_OFFSET];
+   bool contact_valid, hover_event;
 
+   hover_event = hover_info  0x40;
for (i = 0; i  ETP_MAX_FINGERS; i++) {
contact_valid = tp_info  (1U  (3 + i));
-   elan_report_contact(data, i, contact_valid, finger_data);
+   elan_report_contact(data, i, contact_valid, hover_event,
+   finger_data);
 
if (contact_valid)
finger_data += ETP_FINGER_DATA_LEN;
@@ -883,6 +889,7 @@ static int elan_setup_input_device(struct elan_tp_data 
*data)
 ETP_FINGER_WIDTH * max_width, 0, 0);
input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0,
 ETP_FINGER_WIDTH * min_width, 0, 0);
+   input_set_abs_params(input, ABS_MT_DISTANCE, 0, 1, 0, 0);
 
data-input = input;
 






--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/5] Input: elan_i2c - Correct the x and y trace number.

2015-04-15 Thread duson
Hi Dmitry,

I double check with our firmware team and the SPEC, it looks like the subtract 
1 just a misunderstanding.
So, the correct should not subtract 1. For example, if the touchpad x 
resolution is 2800 and x trace number is 20,
the pitch size of x should be 2800/20 = 140, not 2800/19 = 147.36. 

--
Thanks,
ELAN Duson
✉ Email: duson...@emc.com.tw
--





> Dmitry Torokhov  於 2015年4月16日 上午1:47 寫道:
> 
> On Wed, Apr 15, 2015 at 09:55:43AM +0800, DusonLin wrote:
>> The trace number does not need to subtract 1 now.
> 
> Could you provide a bit more of background for this change? Why don't we
> need to decrement the number returned by the firmware anymore? We have
> been running with the old numbers for many years...
> 
> Thanks!
> 
>> 
>> Signed-off-by: Duson Lin 
>> ---
>> drivers/input/mouse/elan_i2c_i2c.c   |4 ++--
>> drivers/input/mouse/elan_i2c_smbus.c |4 ++--
>> 2 files changed, 4 insertions(+), 4 deletions(-)
>> 
>> diff --git a/drivers/input/mouse/elan_i2c_i2c.c
>> b/drivers/input/mouse/elan_i2c_i2c.c
>> index 029941f..550f905 100644
>> --- a/drivers/input/mouse/elan_i2c_i2c.c
>> +++ b/drivers/input/mouse/elan_i2c_i2c.c
>> @@ -356,8 +356,8 @@ static int elan_i2c_get_num_traces(struct i2c_client
>> *client,
>>  return error;
>>  }
>> 
>> -*x_traces = val[0] - 1;
>> -*y_traces = val[1] - 1;
>> +*x_traces = val[0];
>> +*y_traces = val[1];
>> 
>>  return 0;
>> }
>> diff --git a/drivers/input/mouse/elan_i2c_smbus.c
>> b/drivers/input/mouse/elan_i2c_smbus.c
>> index 06a2bcd..0b04151 100644
>> --- a/drivers/input/mouse/elan_i2c_smbus.c
>> +++ b/drivers/input/mouse/elan_i2c_smbus.c
>> @@ -268,8 +268,8 @@ static int elan_smbus_get_num_traces(struct i2c_client
>> *client,
>>  return error;
>>  }
>> 
>> -*x_traces = val[1] - 1;
>> -*y_traces = val[2] - 1;
>> +*x_traces = val[1];
>> +*y_traces = val[2];
>> 
>>  return 0;
>> }
>> 
> 
> -- 
> Dmitry
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/5] Input: elan_i2c - Correct the x and y trace number.

2015-04-15 Thread duson
Hi Dmitry,

I double check with our firmware team and the SPEC, it looks like the subtract 
1 just a misunderstanding.
So, the correct should not subtract 1. For example, if the touchpad x 
resolution is 2800 and x trace number is 20,
the pitch size of x should be 2800/20 = 140, not 2800/19 = 147.36. 

--
Thanks,
ELAN Duson
✉ Email: duson...@emc.com.tw
--





 Dmitry Torokhov dmitry.torok...@gmail.com 於 2015年4月16日 上午1:47 寫道:
 
 On Wed, Apr 15, 2015 at 09:55:43AM +0800, DusonLin wrote:
 The trace number does not need to subtract 1 now.
 
 Could you provide a bit more of background for this change? Why don't we
 need to decrement the number returned by the firmware anymore? We have
 been running with the old numbers for many years...
 
 Thanks!
 
 
 Signed-off-by: Duson Lin duson...@emc.com.tw
 ---
 drivers/input/mouse/elan_i2c_i2c.c   |4 ++--
 drivers/input/mouse/elan_i2c_smbus.c |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/input/mouse/elan_i2c_i2c.c
 b/drivers/input/mouse/elan_i2c_i2c.c
 index 029941f..550f905 100644
 --- a/drivers/input/mouse/elan_i2c_i2c.c
 +++ b/drivers/input/mouse/elan_i2c_i2c.c
 @@ -356,8 +356,8 @@ static int elan_i2c_get_num_traces(struct i2c_client
 *client,
  return error;
  }
 
 -*x_traces = val[0] - 1;
 -*y_traces = val[1] - 1;
 +*x_traces = val[0];
 +*y_traces = val[1];
 
  return 0;
 }
 diff --git a/drivers/input/mouse/elan_i2c_smbus.c
 b/drivers/input/mouse/elan_i2c_smbus.c
 index 06a2bcd..0b04151 100644
 --- a/drivers/input/mouse/elan_i2c_smbus.c
 +++ b/drivers/input/mouse/elan_i2c_smbus.c
 @@ -268,8 +268,8 @@ static int elan_smbus_get_num_traces(struct i2c_client
 *client,
  return error;
  }
 
 -*x_traces = val[1] - 1;
 -*y_traces = val[2] - 1;
 +*x_traces = val[1];
 +*y_traces = val[2];
 
  return 0;
 }
 
 
 -- 
 Dmitry
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/4] Input: elan_i2c - Add pressure normalization

2015-04-11 Thread duson
Get pressure format flag form firmware to check need to send normalized
pressure data to upper OS or not. The normalized data will approximate
the measure of area of the ideal metal weight. For example, using the
8 mm metal weight touch the touchpad surface, the ideal value is 4*4=16
(ignore the constent pi) and the pressure get from firmware will near 16.

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/elan_i2c.h   |7 +--
 drivers/input/mouse/elan_i2c_core.c  |   25 +++--
 drivers/input/mouse/elan_i2c_i2c.c   |   26 --
 drivers/input/mouse/elan_i2c_smbus.c |   12 ++--
 4 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index e100c1b..5ca846e 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -1,4 +1,4 @@
-/*
+/*
  * Elan I2C/SMBus Touchpad driver
  *
  * Copyright (c) 2013 ELAN Microelectronics Corp.
@@ -17,7 +17,7 @@
  */
 
 #ifndef _ELAN_I2C_H
-#define _ELAN_i2C_H
+#define _ELAN_I2C_H
 
 #include 
 
@@ -25,6 +25,7 @@
 #define ETP_ENABLE_CALIBRATE   0x0002
 #define ETP_DISABLE_CALIBRATE  0x
 #define ETP_DISABLE_POWER  0x0001
+#define ETP_PRESSURE_OFFSET25
 
 /* IAP Firmware handling */
 #define ETP_FW_NAME"elan_i2c.bin"
@@ -79,6 +80,8 @@ struct elan_transport_ops {
struct completion *reset_done);
 
int (*get_report)(struct i2c_client *client, u8 *report);
+   int (*get_pressure_adjustment)(struct i2c_client *client,
+  int *adjustment);
 };
 
 extern const struct elan_transport_ops elan_smbus_ops, elan_i2c_ops;
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 4b970e2..6333ba6 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.6
+ * Version: 1.5.7
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,8 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.6"
-#define ETP_PRESSURE_OFFSET25
+#define ELAN_DRIVER_VERSION"1.5.7"
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -81,7 +80,7 @@ struct elan_tp_data {
u8  sm_version;
u8  iap_version;
u16 fw_checksum;
-
+   int pressure_adjustment;
u8  mode;
 
boolirq_wake;
@@ -229,6 +228,11 @@ static int elan_query_device_info(struct elan_tp_data 
*data)
if (error)
return error;
 
+   error = data->ops->get_pressure_adjustment(data->client,
+  >pressure_adjustment);
+   if (error)
+   return error;
+
return 0;
 }
 
@@ -726,8 +730,8 @@ static void elan_report_contact(struct elan_tp_data *data,
struct input_dev *input = data->input;
unsigned int pos_x, pos_y;
unsigned int pressure, mk_x, mk_y;
-   unsigned int area_x, area_y, major, minor, new_pressure;
-
+   unsigned int area_x, area_y, major, minor;
+   unsigned int scaled_pressure;
 
if (contact_valid) {
pos_x = ((finger_data[0] & 0xf0) << 4) |
@@ -756,15 +760,16 @@ static void elan_report_contact(struct elan_tp_data *data,
major = max(area_x, area_y);
minor = min(area_x, area_y);
 
-   new_pressure = pressure + ETP_PRESSURE_OFFSET;
-   if (new_pressure > ETP_MAX_PRESSURE)
-   new_pressure = ETP_MAX_PRESSURE;
+   scaled_pressure = pressure + data->pressure_adjustment;
+
+   if (scaled_pressure > ETP_MAX_PRESSURE)
+   scaled_pressure = ETP_MAX_PRESSURE;
 
input_mt_slot(input, contact_num);
input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
input_report_abs(input, ABS_MT_POSITION_X, pos_x);
input_report_abs(input, ABS_MT_POSITION_Y, data->max_y - pos_y);
-   input_report_abs(input, ABS_MT_PRESSURE, new_pressure);
+   input_report_abs(input, ABS_MT_PRESSURE, scaled_pressure);
input_report_abs(input, ABS_TOOL_WIDTH, mk_x);
input_report_abs(input, ABS_MT_TOUCH_MAJOR, major);
input_report_abs(input, ABS_MT_TOUCH_MINOR, minor);
diff --git a/drivers/input/mouse/elan_i2c_i2c.c 
b/drivers/input/mouse/elan_i2c_i2c.c
index e29b28c..f5031b5 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/e

[PATCH 4/4] Input: elan_i2c - Add pressure normalization

2015-04-11 Thread duson
Get pressure format flag form firmware to check need to send normalized
pressure data to upper OS or not. The normalized data will approximate
the measure of area of the ideal metal weight. For example, using the
8 mm metal weight touch the touchpad surface, the ideal value is 4*4=16
(ignore the constent pi) and the pressure get from firmware will near 16.

Signed-off-by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elan_i2c.h   |7 +--
 drivers/input/mouse/elan_i2c_core.c  |   25 +++--
 drivers/input/mouse/elan_i2c_i2c.c   |   26 --
 drivers/input/mouse/elan_i2c_smbus.c |   12 ++--
 4 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index e100c1b..5ca846e 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -1,4 +1,4 @@
-/*
+/*
  * Elan I2C/SMBus Touchpad driver
  *
  * Copyright (c) 2013 ELAN Microelectronics Corp.
@@ -17,7 +17,7 @@
  */
 
 #ifndef _ELAN_I2C_H
-#define _ELAN_i2C_H
+#define _ELAN_I2C_H
 
 #include linux/types.h
 
@@ -25,6 +25,7 @@
 #define ETP_ENABLE_CALIBRATE   0x0002
 #define ETP_DISABLE_CALIBRATE  0x
 #define ETP_DISABLE_POWER  0x0001
+#define ETP_PRESSURE_OFFSET25
 
 /* IAP Firmware handling */
 #define ETP_FW_NAMEelan_i2c.bin
@@ -79,6 +80,8 @@ struct elan_transport_ops {
struct completion *reset_done);
 
int (*get_report)(struct i2c_client *client, u8 *report);
+   int (*get_pressure_adjustment)(struct i2c_client *client,
+  int *adjustment);
 };
 
 extern const struct elan_transport_ops elan_smbus_ops, elan_i2c_ops;
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 4b970e2..6333ba6 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.6
+ * Version: 1.5.7
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,8 +40,7 @@
 #include elan_i2c.h
 
 #define DRIVER_NAMEelan_i2c
-#define ELAN_DRIVER_VERSION1.5.6
-#define ETP_PRESSURE_OFFSET25
+#define ELAN_DRIVER_VERSION1.5.7
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
 #define ETP_FINGER_WIDTH   15
@@ -81,7 +80,7 @@ struct elan_tp_data {
u8  sm_version;
u8  iap_version;
u16 fw_checksum;
-
+   int pressure_adjustment;
u8  mode;
 
boolirq_wake;
@@ -229,6 +228,11 @@ static int elan_query_device_info(struct elan_tp_data 
*data)
if (error)
return error;
 
+   error = data-ops-get_pressure_adjustment(data-client,
+  data-pressure_adjustment);
+   if (error)
+   return error;
+
return 0;
 }
 
@@ -726,8 +730,8 @@ static void elan_report_contact(struct elan_tp_data *data,
struct input_dev *input = data-input;
unsigned int pos_x, pos_y;
unsigned int pressure, mk_x, mk_y;
-   unsigned int area_x, area_y, major, minor, new_pressure;
-
+   unsigned int area_x, area_y, major, minor;
+   unsigned int scaled_pressure;
 
if (contact_valid) {
pos_x = ((finger_data[0]  0xf0)  4) |
@@ -756,15 +760,16 @@ static void elan_report_contact(struct elan_tp_data *data,
major = max(area_x, area_y);
minor = min(area_x, area_y);
 
-   new_pressure = pressure + ETP_PRESSURE_OFFSET;
-   if (new_pressure  ETP_MAX_PRESSURE)
-   new_pressure = ETP_MAX_PRESSURE;
+   scaled_pressure = pressure + data-pressure_adjustment;
+
+   if (scaled_pressure  ETP_MAX_PRESSURE)
+   scaled_pressure = ETP_MAX_PRESSURE;
 
input_mt_slot(input, contact_num);
input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
input_report_abs(input, ABS_MT_POSITION_X, pos_x);
input_report_abs(input, ABS_MT_POSITION_Y, data-max_y - pos_y);
-   input_report_abs(input, ABS_MT_PRESSURE, new_pressure);
+   input_report_abs(input, ABS_MT_PRESSURE, scaled_pressure);
input_report_abs(input, ABS_TOOL_WIDTH, mk_x);
input_report_abs(input, ABS_MT_TOUCH_MAJOR, major);
input_report_abs(input, ABS_MT_TOUCH_MINOR, minor);
diff --git a/drivers/input/mouse/elan_i2c_i2c.c 
b/drivers/input/mouse/elan_i2c_i2c.c
index e29b28c..f5031b5 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -41,6 +41,7 @@
 #define ETP_I2C_MAX_X_AXIS_CMD

[PATCH 3/3] Input: elan_i2c - Remove duplicate repeat code

2015-03-08 Thread Duson Lin
Remove duplicate "repeat--" from function elan_initialize.

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/elan_i2c_core.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index f24078b..4b970e2 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -198,7 +198,6 @@ static int elan_initialize(struct elan_tp_data *data)
if (!error)
return 0;
 
-   repeat--;
msleep(30);
} while (--repeat > 0);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] Input: elan_i2c - Remove duplicate repeat code

2015-03-08 Thread Duson Lin
Remove duplicate repeat-- from function elan_initialize.

Signed-off-by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elan_i2c_core.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index f24078b..4b970e2 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -198,7 +198,6 @@ static int elan_initialize(struct elan_tp_data *data)
if (!error)
return 0;
 
-   repeat--;
msleep(30);
} while (--repeat  0);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] Input: elan_i2c - Return error code when resume fail.

2015-03-07 Thread Duson Lin
The resume function always return success, so stop event can not be
triggered when "suspend_stress_test" running. In order to debug more
easily, we add some error messages in elan_enable_power and
elan_disable_power funtion.

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/elan_i2c_core.c |   10 +++---
 drivers/input/mouse/elan_i2c_i2c.c  |7 ++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 16f9584..f24078b 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -111,6 +111,7 @@ static int elan_enable_power(struct elan_tp_data *data)
msleep(30);
} while (--repeat > 0);
 
+   dev_err(>client->dev, "Failed to enable power\n");
return error;
 }
 
@@ -138,6 +139,7 @@ static int elan_disable_power(struct elan_tp_data *data)
msleep(30);
} while (--repeat > 0);
 
+   dev_err(>client->dev, "Failed to disable power\n");
return error;
 }
 
@@ -1084,16 +1086,18 @@ static int __maybe_unused elan_resume(struct device 
*dev)
}
 
error = elan_enable_power(data);
-   if (error)
+   if (error) {
dev_err(dev, "power up when resuming failed: %d\n", error);
+   goto err;
+   }
 
error = elan_initialize(data);
if (error)
dev_err(dev, "initialize when resuming failed: %d\n", error);
 
+err:
enable_irq(data->client->irq);
-
-   return 0;
+   return error;
 }
 
 static SIMPLE_DEV_PM_OPS(elan_pm_ops, elan_suspend, elan_resume);
diff --git a/drivers/input/mouse/elan_i2c_i2c.c 
b/drivers/input/mouse/elan_i2c_i2c.c
index 029941f..e29b28c 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -117,7 +117,12 @@ static int elan_i2c_write_cmd(struct i2c_client *client, 
u16 reg, u16 cmd)
int ret;
 
ret = i2c_transfer(client->adapter, , 1);
-   return ret == 1 ? 0 : (ret < 0 ? ret : -EIO);
+   if (ret != 1) {
+   dev_err(>dev, "writing cmd (0x%04x) fail.\n", reg);
+   return ret < 0 ? ret : -EIO;
+   }
+
+   return 0;
 }
 
 static int elan_i2c_initialize(struct i2c_client *client)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] Input: elan_i2c - Return error code when resume fail.

2015-03-07 Thread Duson Lin
The resume function always return success, so stop event can not be
triggered when suspend_stress_test running. In order to debug more
easily, we add some error messages in elan_enable_power and
elan_disable_power funtion.

Signed-off-by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elan_i2c_core.c |   10 +++---
 drivers/input/mouse/elan_i2c_i2c.c  |7 ++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 16f9584..f24078b 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -111,6 +111,7 @@ static int elan_enable_power(struct elan_tp_data *data)
msleep(30);
} while (--repeat  0);
 
+   dev_err(data-client-dev, Failed to enable power\n);
return error;
 }
 
@@ -138,6 +139,7 @@ static int elan_disable_power(struct elan_tp_data *data)
msleep(30);
} while (--repeat  0);
 
+   dev_err(data-client-dev, Failed to disable power\n);
return error;
 }
 
@@ -1084,16 +1086,18 @@ static int __maybe_unused elan_resume(struct device 
*dev)
}
 
error = elan_enable_power(data);
-   if (error)
+   if (error) {
dev_err(dev, power up when resuming failed: %d\n, error);
+   goto err;
+   }
 
error = elan_initialize(data);
if (error)
dev_err(dev, initialize when resuming failed: %d\n, error);
 
+err:
enable_irq(data-client-irq);
-
-   return 0;
+   return error;
 }
 
 static SIMPLE_DEV_PM_OPS(elan_pm_ops, elan_suspend, elan_resume);
diff --git a/drivers/input/mouse/elan_i2c_i2c.c 
b/drivers/input/mouse/elan_i2c_i2c.c
index 029941f..e29b28c 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -117,7 +117,12 @@ static int elan_i2c_write_cmd(struct i2c_client *client, 
u16 reg, u16 cmd)
int ret;
 
ret = i2c_transfer(client-adapter, msg, 1);
-   return ret == 1 ? 0 : (ret  0 ? ret : -EIO);
+   if (ret != 1) {
+   dev_err(client-dev, writing cmd (0x%04x) fail.\n, reg);
+   return ret  0 ? ret : -EIO;
+   }
+
+   return 0;
 }
 
 static int elan_i2c_initialize(struct i2c_client *client)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: elan_i2c - Compare signature metadata before update fw

2015-03-06 Thread Duson Lin
To match different firmware file format, we replace original firmware file size
checking with the signature metadata comparison when update firmware, If failed,
the update will be aborted.

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/elan_i2c.h   |6 +++---
 drivers/input/mouse/elan_i2c_core.c  |   23 +--
 drivers/input/mouse/elan_i2c_i2c.c   |1 -
 drivers/input/mouse/elan_i2c_smbus.c |1 -
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 2e83862..e100c1b 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -33,8 +32,9 @@
 #define ETP_FW_IAP_PAGE_ERR(1 << 5)
 #define ETP_FW_IAP_INTF_ERR(1 << 4)
 #define ETP_FW_PAGE_SIZE   64
-#define ETP_FW_PAGE_COUNT  768
-#define ETP_FW_SIZE(ETP_FW_PAGE_SIZE * ETP_FW_PAGE_COUNT)
+#define ETP_FW_VAILDPAGE_COUNT 768
+#define ETP_FW_SIGNATURE_SIZE  6
+#define ETP_FW_SIGNATURE_ADDRESS   0xBFFA
 
 struct i2c_client;
 struct completion;
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 0cb2be4..16f9584 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.5
+ * Version: 1.5.6
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.5"
+#define ELAN_DRIVER_VERSION"1.5.6"
 #define ETP_PRESSURE_OFFSET25
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
@@ -312,7 +312,7 @@ static int __elan_update_firmware(struct elan_tp_data *data,
iap_start_addr = get_unaligned_le16(>data[ETP_IAP_START_ADDR * 2]);
 
boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE;
-   for (i = boot_page_count; i < ETP_FW_PAGE_COUNT; i++) {
+   for (i = boot_page_count; i < ETP_FW_VAILDPAGE_COUNT; i++) {
u16 checksum = 0;
const u8 *page = >data[i * ETP_FW_PAGE_SIZE];
 
@@ -434,10 +434,11 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct i2c_client *client = to_i2c_client(dev);
-   struct elan_tp_data *data = i2c_get_clientdata(client);
+   struct elan_tp_data *data = dev_get_drvdata(dev);
const struct firmware *fw;
int error;
+   const u8 *fw_signature;
+   static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF};
 
error = request_firmware(, ETP_FW_NAME, dev);
if (error) {
@@ -446,10 +447,12 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
return error;
}
 
-   /* Firmware must be exactly PAGE_NUM * PAGE_SIZE bytes */
-   if (fw->size != ETP_FW_SIZE) {
-   dev_err(dev, "invalid firmware size = %zu, expected %d.\n",
-   fw->size, ETP_FW_SIZE);
+   /* Firmware file must match signature data */
+   fw_signature = >data[ETP_FW_SIGNATURE_ADDRESS];
+   if (memcmp(fw_signature, signature, sizeof(signature)) != 0) {
+   dev_err(dev, "signature mismatch (expected %*ph, got %*ph)\n",
+(int)sizeof(signature), signature,
+(int)sizeof(signature), fw_signature);
error = -EBADF;
goto out_release_fw;
}
@@ -464,7 +467,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
 
 out_release_fw:
release_firmware(fw);
-   return error ?: count;
+   return error?: count;
 }
 
 static ssize_t calibrate_store(struct device *dev,
diff --git a/drivers/input/mouse/elan_i2c_i2c.c 
b/drivers/input/mouse/elan_i2c_i2c.c
index 97d4937..029941f 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
diff --git a/drivers/input/mouse/elan_i2c_smbus.c 
b/drivers/input/mouse/elan_i2c_smbus.c
index 359bf85..5cd4a05 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (

[PATCH] Input: elan_i2c - Compare signature metadata before update fw

2015-03-06 Thread Duson Lin
To match different firmware file format, we replace original firmware file size
checking with the signature metadata comparison when update firmware, If failed,
the update will be aborted.

Signed-off-by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elan_i2c.h   |6 +++---
 drivers/input/mouse/elan_i2c_core.c  |   23 +--
 drivers/input/mouse/elan_i2c_i2c.c   |1 -
 drivers/input/mouse/elan_i2c_smbus.c |1 -
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 2e83862..e100c1b 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -33,8 +32,9 @@
 #define ETP_FW_IAP_PAGE_ERR(1  5)
 #define ETP_FW_IAP_INTF_ERR(1  4)
 #define ETP_FW_PAGE_SIZE   64
-#define ETP_FW_PAGE_COUNT  768
-#define ETP_FW_SIZE(ETP_FW_PAGE_SIZE * ETP_FW_PAGE_COUNT)
+#define ETP_FW_VAILDPAGE_COUNT 768
+#define ETP_FW_SIGNATURE_SIZE  6
+#define ETP_FW_SIGNATURE_ADDRESS   0xBFFA
 
 struct i2c_client;
 struct completion;
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 0cb2be4..16f9584 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.5
+ * Version: 1.5.6
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include elan_i2c.h
 
 #define DRIVER_NAMEelan_i2c
-#define ELAN_DRIVER_VERSION1.5.5
+#define ELAN_DRIVER_VERSION1.5.6
 #define ETP_PRESSURE_OFFSET25
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
@@ -312,7 +312,7 @@ static int __elan_update_firmware(struct elan_tp_data *data,
iap_start_addr = get_unaligned_le16(fw-data[ETP_IAP_START_ADDR * 2]);
 
boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE;
-   for (i = boot_page_count; i  ETP_FW_PAGE_COUNT; i++) {
+   for (i = boot_page_count; i  ETP_FW_VAILDPAGE_COUNT; i++) {
u16 checksum = 0;
const u8 *page = fw-data[i * ETP_FW_PAGE_SIZE];
 
@@ -434,10 +434,11 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct i2c_client *client = to_i2c_client(dev);
-   struct elan_tp_data *data = i2c_get_clientdata(client);
+   struct elan_tp_data *data = dev_get_drvdata(dev);
const struct firmware *fw;
int error;
+   const u8 *fw_signature;
+   static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF};
 
error = request_firmware(fw, ETP_FW_NAME, dev);
if (error) {
@@ -446,10 +447,12 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
return error;
}
 
-   /* Firmware must be exactly PAGE_NUM * PAGE_SIZE bytes */
-   if (fw-size != ETP_FW_SIZE) {
-   dev_err(dev, invalid firmware size = %zu, expected %d.\n,
-   fw-size, ETP_FW_SIZE);
+   /* Firmware file must match signature data */
+   fw_signature = fw-data[ETP_FW_SIGNATURE_ADDRESS];
+   if (memcmp(fw_signature, signature, sizeof(signature)) != 0) {
+   dev_err(dev, signature mismatch (expected %*ph, got %*ph)\n,
+(int)sizeof(signature), signature,
+(int)sizeof(signature), fw_signature);
error = -EBADF;
goto out_release_fw;
}
@@ -464,7 +467,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
 
 out_release_fw:
release_firmware(fw);
-   return error ?: count;
+   return error?: count;
 }
 
 static ssize_t calibrate_store(struct device *dev,
diff --git a/drivers/input/mouse/elan_i2c_i2c.c 
b/drivers/input/mouse/elan_i2c_i2c.c
index 97d4937..029941f 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
diff --git a/drivers/input/mouse/elan_i2c_smbus.c 
b/drivers/input/mouse/elan_i2c_smbus.c
index 359bf85..5cd4a05 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012

[PATCH] Input: elan_i2c - Compare signature metadata before update fw

2015-01-23 Thread Duson Lin
To match different firmware file format, we replace original firmware file size
checking with the signature metadata comparison when update firmware, If failed,
the update will be aborted.

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/elan_i2c.h   |6 +++---
 drivers/input/mouse/elan_i2c_core.c  |   23 +--
 drivers/input/mouse/elan_i2c_i2c.c   |1 -
 drivers/input/mouse/elan_i2c_smbus.c |1 -
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 2e83862..e100c1b 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -33,8 +32,9 @@
 #define ETP_FW_IAP_PAGE_ERR(1 << 5)
 #define ETP_FW_IAP_INTF_ERR(1 << 4)
 #define ETP_FW_PAGE_SIZE   64
-#define ETP_FW_PAGE_COUNT  768
-#define ETP_FW_SIZE(ETP_FW_PAGE_SIZE * ETP_FW_PAGE_COUNT)
+#define ETP_FW_VAILDPAGE_COUNT 768
+#define ETP_FW_SIGNATURE_SIZE  6
+#define ETP_FW_SIGNATURE_ADDRESS   0xBFFA
 
 struct i2c_client;
 struct completion;
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 0cb2be4..16f9584 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.5
+ * Version: 1.5.6
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include "elan_i2c.h"
 
 #define DRIVER_NAME"elan_i2c"
-#define ELAN_DRIVER_VERSION"1.5.5"
+#define ELAN_DRIVER_VERSION"1.5.6"
 #define ETP_PRESSURE_OFFSET25
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
@@ -312,7 +312,7 @@ static int __elan_update_firmware(struct elan_tp_data *data,
iap_start_addr = get_unaligned_le16(>data[ETP_IAP_START_ADDR * 2]);
 
boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE;
-   for (i = boot_page_count; i < ETP_FW_PAGE_COUNT; i++) {
+   for (i = boot_page_count; i < ETP_FW_VAILDPAGE_COUNT; i++) {
u16 checksum = 0;
const u8 *page = >data[i * ETP_FW_PAGE_SIZE];
 
@@ -434,10 +434,11 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct i2c_client *client = to_i2c_client(dev);
-   struct elan_tp_data *data = i2c_get_clientdata(client);
+   struct elan_tp_data *data = dev_get_drvdata(dev);
const struct firmware *fw;
int error;
+   const u8 *fw_signature;
+   static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF};
 
error = request_firmware(, ETP_FW_NAME, dev);
if (error) {
@@ -446,10 +447,12 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
return error;
}
 
-   /* Firmware must be exactly PAGE_NUM * PAGE_SIZE bytes */
-   if (fw->size != ETP_FW_SIZE) {
-   dev_err(dev, "invalid firmware size = %zu, expected %d.\n",
-   fw->size, ETP_FW_SIZE);
+   /* Firmware file must match signature data */
+   fw_signature = >data[ETP_FW_SIGNATURE_ADDRESS];
+   if (memcmp(fw_signature, signature, sizeof(signature)) != 0) {
+   dev_err(dev, "signature mismatch (expected %*ph, got %*ph)\n",
+(int)sizeof(signature), signature,
+(int)sizeof(signature), fw_signature);
error = -EBADF;
goto out_release_fw;
}
@@ -464,7 +467,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
 
 out_release_fw:
release_firmware(fw);
-   return error ?: count;
+   return error?: count;
 }
 
 static ssize_t calibrate_store(struct device *dev,
diff --git a/drivers/input/mouse/elan_i2c_i2c.c 
b/drivers/input/mouse/elan_i2c_i2c.c
index 97d4937..029941f 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
diff --git a/drivers/input/mouse/elan_i2c_smbus.c 
b/drivers/input/mouse/elan_i2c_smbus.c
index 359bf85..5cd4a05 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) 
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (

[PATCH] Input: elan_i2c - Compare signature metadata before update fw

2015-01-23 Thread Duson Lin
To match different firmware file format, we replace original firmware file size
checking with the signature metadata comparison when update firmware, If failed,
the update will be aborted.

Signed-off-by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elan_i2c.h   |6 +++---
 drivers/input/mouse/elan_i2c_core.c  |   23 +--
 drivers/input/mouse/elan_i2c_i2c.c   |1 -
 drivers/input/mouse/elan_i2c_smbus.c |1 -
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 2e83862..e100c1b 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -33,8 +32,9 @@
 #define ETP_FW_IAP_PAGE_ERR(1  5)
 #define ETP_FW_IAP_INTF_ERR(1  4)
 #define ETP_FW_PAGE_SIZE   64
-#define ETP_FW_PAGE_COUNT  768
-#define ETP_FW_SIZE(ETP_FW_PAGE_SIZE * ETP_FW_PAGE_COUNT)
+#define ETP_FW_VAILDPAGE_COUNT 768
+#define ETP_FW_SIGNATURE_SIZE  6
+#define ETP_FW_SIGNATURE_ADDRESS   0xBFFA
 
 struct i2c_client;
 struct completion;
diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 0cb2be4..16f9584 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.5
+ * Version: 1.5.6
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
@@ -40,7 +40,7 @@
 #include elan_i2c.h
 
 #define DRIVER_NAMEelan_i2c
-#define ELAN_DRIVER_VERSION1.5.5
+#define ELAN_DRIVER_VERSION1.5.6
 #define ETP_PRESSURE_OFFSET25
 #define ETP_MAX_PRESSURE   255
 #define ETP_FWIDTH_REDUCE  90
@@ -312,7 +312,7 @@ static int __elan_update_firmware(struct elan_tp_data *data,
iap_start_addr = get_unaligned_le16(fw-data[ETP_IAP_START_ADDR * 2]);
 
boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE;
-   for (i = boot_page_count; i  ETP_FW_PAGE_COUNT; i++) {
+   for (i = boot_page_count; i  ETP_FW_VAILDPAGE_COUNT; i++) {
u16 checksum = 0;
const u8 *page = fw-data[i * ETP_FW_PAGE_SIZE];
 
@@ -434,10 +434,11 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct i2c_client *client = to_i2c_client(dev);
-   struct elan_tp_data *data = i2c_get_clientdata(client);
+   struct elan_tp_data *data = dev_get_drvdata(dev);
const struct firmware *fw;
int error;
+   const u8 *fw_signature;
+   static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF};
 
error = request_firmware(fw, ETP_FW_NAME, dev);
if (error) {
@@ -446,10 +447,12 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
return error;
}
 
-   /* Firmware must be exactly PAGE_NUM * PAGE_SIZE bytes */
-   if (fw-size != ETP_FW_SIZE) {
-   dev_err(dev, invalid firmware size = %zu, expected %d.\n,
-   fw-size, ETP_FW_SIZE);
+   /* Firmware file must match signature data */
+   fw_signature = fw-data[ETP_FW_SIGNATURE_ADDRESS];
+   if (memcmp(fw_signature, signature, sizeof(signature)) != 0) {
+   dev_err(dev, signature mismatch (expected %*ph, got %*ph)\n,
+(int)sizeof(signature), signature,
+(int)sizeof(signature), fw_signature);
error = -EBADF;
goto out_release_fw;
}
@@ -464,7 +467,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
 
 out_release_fw:
release_firmware(fw);
-   return error ?: count;
+   return error?: count;
 }
 
 static ssize_t calibrate_store(struct device *dev,
diff --git a/drivers/input/mouse/elan_i2c_i2c.c 
b/drivers/input/mouse/elan_i2c_i2c.c
index 97d4937..029941f 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
diff --git a/drivers/input/mouse/elan_i2c_smbus.c 
b/drivers/input/mouse/elan_i2c_smbus.c
index 359bf85..5cd4a05 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -4,7 +4,6 @@
  * Copyright (c) 2013 ELAN Microelectronics Corp.
  *
  * Author: 林政維 (Duson Lin) duson...@emc.com.tw
- * Version: 1.5.5
  *
  * Based on cyapa driver:
  * copyright (c) 2011-2012

[PATCH v2] Input: add i2c/smbus driver for elan touchpad

2014-01-06 Thread Duson Lin
This driver adds support for elan i2c/smbus touchpad found on some laptops PC

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/Kconfig|   10 +
 drivers/input/mouse/Makefile   |1 +
 drivers/input/mouse/elan_i2c.c |  890 
 3 files changed, 901 insertions(+)
 create mode 100644 drivers/input/mouse/elan_i2c.c

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index effa9c5..095eccc 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -215,6 +215,16 @@ config MOUSE_CYAPA
  To compile this driver as a module, choose M here: the module will be
  called cyapa.
 
+config MOUSE_ELAN_I2C
+   tristate "ELAN I2C Touchpad support"
+   depends on I2C
+   help
+ This driver adds support for Elan I2C Trackpads.
+ Say Y here if you have a ELAN I2C Touchpad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called elan_i2c.
+
 config MOUSE_INPORT
tristate "InPort/MS/ATIXL busmouse"
depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..24a12a6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH)  += appletouch.o
 obj-$(CONFIG_MOUSE_ATARI)  += atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)  += cyapa.o
+obj-$(CONFIG_MOUSE_ELAN_I2C)   += elan_i2c.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
 obj-$(CONFIG_MOUSE_INPORT) += inport.o
 obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
diff --git a/drivers/input/mouse/elan_i2c.c b/drivers/input/mouse/elan_i2c.c
new file mode 100644
index 000..f7bfa22
--- /dev/null
+++ b/drivers/input/mouse/elan_i2c.c
@@ -0,0 +1,890 @@
+/*
+ * Elan I2C/SMBus Touchpad driver
+ *
+ * Copyright (c) 2013 ELAN Microelectronics Corp.
+ *
+ * Author: 林政維 (Duson Lin) 
+ * Version: 1.4.6
+ *
+ * Based on cyapa driver:
+ * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
+ * copyright (c) 2011-2012 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_NAME"elan_i2c"
+#define ELAN_DRIVER_VERSION"1.4.6"
+#define ETP_PRESSURE_OFFSET25
+#define ETP_MAX_PRESSURE   255
+#define ETP_FWIDTH_REDUCE  90
+#define ETP_FINGER_WIDTH   15
+
+#define ELAN_ADAPTER_FUNC_NONE   0
+#define ELAN_ADAPTER_FUNC_I2C1
+#define ELAN_ADAPTER_FUNC_SMBUS  2
+#define ELAN_ADAPTER_FUNC_BOTH   3
+
+/* Length of Elan touchpad information */
+#define ETP_INF_LENGTH 2
+#define ETP_MAX_FINGERS5
+#define ETP_FINGER_DATA_LEN5
+#define ETP_REPORT_ID  0x5D
+#define ETP_MAX_REPORT_LEN 34
+#define ETP_ENABLE_ABS 0x0001
+#define ETP_ENABLE_CALIBRATE   0x0002
+#define ETP_DISABLE_CALIBRATE  0x
+
+/* Elan smbus command */
+#define ETP_SMBUS_IAP_CMD  0x00
+#define ETP_SMBUS_ENABLE_TP0x20
+#define ETP_SMBUS_SLEEP_CMD0x21
+#define ETP_SMBUS_IAP_PASSWORD_WRITE   0x29
+#define ETP_SMBUS_IAP_PASSWORD_READ0x80
+#define ETP_SMBUS_WRITE_FW_BLOCK   0x2A
+#define ETP_SMBUS_IAP_RESET_CMD0x2B
+#define ETP_SMBUS_RANGE_CMD0xA0
+#define ETP_SMBUS_FW_VERSION_CMD   0xA1
+#define ETP_SMBUS_XY_TRACENUM_CMD  0xA2
+#define ETP_SMBUS_SM_VERSION_CMD   0xA3
+#define ETP_SMBUS_UNIQUEID_CMD 0xA3
+#define ETP_SMBUS_RESOLUTION_CMD   0xA4
+#define ETP_SMBUS_HELLOPACKET_CMD  0xA7
+#define ETP_SMBUS_PACKET_QUERY 0xA8
+#define ETP_SMBUS_IAP_VERSION_CMD  0xAC
+#define ETP_SMBUS_IAP_CTRL_CMD 0xAD
+#define ETP_SMBUS_IAP_CHECKSUM_CMD 0xAE
+#define ETP_SMBUS_FW_CHECKSUM_CMD  0xAF
+#define ETP_SMBUS_MAX_BASELINE_CMD 0xC3
+#define ETP_SMBUS_MIN_BASELINE_CMD 0xC4
+#define ETP_SMBUS_CALIBRATE_QUERY  0xC5
+#define ETP_SMBUS_REPORT_LEN   32
+#define ETP_SMBUS_FINGER_DATA_OFFSET   2
+#define ETP_SMBUS_HELLOPACKET_LEN  5
+#define ETP_SMBUS_IAP_PASSWORD 0x1234
+#define ETP_SMBUS_IAP_MODE_ON  (1<<6)
+
+/* Elan i2c command */
+#define ETP_I2C_RESET  0x0100
+#define ETP_I2C_WAKE_UP0x0800
+#define ETP_I2C_SLEEP  0x0801
+#define ETP_I2C_DESC_CMD   0x0001
+#define ETP_I2C_REPORT_DESC_CMD0x0002
+#define ETP_I2C_STAND_CMD  0x0005
+#define ETP_I2C_UNIQUEID_CMD   

[PATCH v2] Input: add i2c/smbus driver for elan touchpad

2014-01-06 Thread Duson Lin
This driver adds support for elan i2c/smbus touchpad found on some laptops PC

Signed-off-by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/Kconfig|   10 +
 drivers/input/mouse/Makefile   |1 +
 drivers/input/mouse/elan_i2c.c |  890 
 3 files changed, 901 insertions(+)
 create mode 100644 drivers/input/mouse/elan_i2c.c

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index effa9c5..095eccc 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -215,6 +215,16 @@ config MOUSE_CYAPA
  To compile this driver as a module, choose M here: the module will be
  called cyapa.
 
+config MOUSE_ELAN_I2C
+   tristate ELAN I2C Touchpad support
+   depends on I2C
+   help
+ This driver adds support for Elan I2C Trackpads.
+ Say Y here if you have a ELAN I2C Touchpad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called elan_i2c.
+
 config MOUSE_INPORT
tristate InPort/MS/ATIXL busmouse
depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..24a12a6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH)  += appletouch.o
 obj-$(CONFIG_MOUSE_ATARI)  += atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)  += cyapa.o
+obj-$(CONFIG_MOUSE_ELAN_I2C)   += elan_i2c.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
 obj-$(CONFIG_MOUSE_INPORT) += inport.o
 obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
diff --git a/drivers/input/mouse/elan_i2c.c b/drivers/input/mouse/elan_i2c.c
new file mode 100644
index 000..f7bfa22
--- /dev/null
+++ b/drivers/input/mouse/elan_i2c.c
@@ -0,0 +1,890 @@
+/*
+ * Elan I2C/SMBus Touchpad driver
+ *
+ * Copyright (c) 2013 ELAN Microelectronics Corp.
+ *
+ * Author: 林政維 (Duson Lin) duson...@emc.com.tw
+ * Version: 1.4.6
+ *
+ * Based on cyapa driver:
+ * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
+ * copyright (c) 2011-2012 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+#include linux/delay.h
+#include linux/device.h
+#include linux/firmware.h
+#include linux/i2c.h
+#include linux/init.h
+#include linux/input/mt.h
+#include linux/interrupt.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/debugfs.h
+#include linux/cdev.h
+#include linux/kernel.h
+#include linux/major.h
+#include linux/sched.h
+#include linux/input.h
+#include linux/uaccess.h
+#include linux/jiffies.h
+
+#define DRIVER_NAMEelan_i2c
+#define ELAN_DRIVER_VERSION1.4.6
+#define ETP_PRESSURE_OFFSET25
+#define ETP_MAX_PRESSURE   255
+#define ETP_FWIDTH_REDUCE  90
+#define ETP_FINGER_WIDTH   15
+
+#define ELAN_ADAPTER_FUNC_NONE   0
+#define ELAN_ADAPTER_FUNC_I2C1
+#define ELAN_ADAPTER_FUNC_SMBUS  2
+#define ELAN_ADAPTER_FUNC_BOTH   3
+
+/* Length of Elan touchpad information */
+#define ETP_INF_LENGTH 2
+#define ETP_MAX_FINGERS5
+#define ETP_FINGER_DATA_LEN5
+#define ETP_REPORT_ID  0x5D
+#define ETP_MAX_REPORT_LEN 34
+#define ETP_ENABLE_ABS 0x0001
+#define ETP_ENABLE_CALIBRATE   0x0002
+#define ETP_DISABLE_CALIBRATE  0x
+
+/* Elan smbus command */
+#define ETP_SMBUS_IAP_CMD  0x00
+#define ETP_SMBUS_ENABLE_TP0x20
+#define ETP_SMBUS_SLEEP_CMD0x21
+#define ETP_SMBUS_IAP_PASSWORD_WRITE   0x29
+#define ETP_SMBUS_IAP_PASSWORD_READ0x80
+#define ETP_SMBUS_WRITE_FW_BLOCK   0x2A
+#define ETP_SMBUS_IAP_RESET_CMD0x2B
+#define ETP_SMBUS_RANGE_CMD0xA0
+#define ETP_SMBUS_FW_VERSION_CMD   0xA1
+#define ETP_SMBUS_XY_TRACENUM_CMD  0xA2
+#define ETP_SMBUS_SM_VERSION_CMD   0xA3
+#define ETP_SMBUS_UNIQUEID_CMD 0xA3
+#define ETP_SMBUS_RESOLUTION_CMD   0xA4
+#define ETP_SMBUS_HELLOPACKET_CMD  0xA7
+#define ETP_SMBUS_PACKET_QUERY 0xA8
+#define ETP_SMBUS_IAP_VERSION_CMD  0xAC
+#define ETP_SMBUS_IAP_CTRL_CMD 0xAD
+#define ETP_SMBUS_IAP_CHECKSUM_CMD 0xAE
+#define ETP_SMBUS_FW_CHECKSUM_CMD  0xAF
+#define ETP_SMBUS_MAX_BASELINE_CMD 0xC3
+#define ETP_SMBUS_MIN_BASELINE_CMD 0xC4
+#define ETP_SMBUS_CALIBRATE_QUERY  0xC5
+#define ETP_SMBUS_REPORT_LEN   32
+#define ETP_SMBUS_FINGER_DATA_OFFSET   2
+#define ETP_SMBUS_HELLOPACKET_LEN  5
+#define ETP_SMBUS_IAP_PASSWORD 0x1234
+#define ETP_SMBUS_IAP_MODE_ON  (16)
+
+/* Elan i2c command */
+#define ETP_I2C_RESET  0x0100
+#define ETP_I2C_WAKE_UP0x0800
+#define

[PATCH v2] Input: add i2c/smbus driver for elan touchpad

2013-12-17 Thread Duson Lin
This driver adds support for elan i2c/smbus touchpad found on some laptops PC

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/Kconfig|   10 +
 drivers/input/mouse/Makefile   |1 +
 drivers/input/mouse/elan_i2c.c |  890 
 3 files changed, 901 insertions(+)
 create mode 100644 drivers/input/mouse/elan_i2c.c

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index effa9c5..095eccc 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -215,6 +215,16 @@ config MOUSE_CYAPA
  To compile this driver as a module, choose M here: the module will be
  called cyapa.
 
+config MOUSE_ELAN_I2C
+   tristate "ELAN I2C Touchpad support"
+   depends on I2C
+   help
+ This driver adds support for Elan I2C Trackpads.
+ Say Y here if you have a ELAN I2C Touchpad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called elan_i2c.
+
 config MOUSE_INPORT
tristate "InPort/MS/ATIXL busmouse"
depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..24a12a6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH)  += appletouch.o
 obj-$(CONFIG_MOUSE_ATARI)  += atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)  += cyapa.o
+obj-$(CONFIG_MOUSE_ELAN_I2C)   += elan_i2c.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
 obj-$(CONFIG_MOUSE_INPORT) += inport.o
 obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
diff --git a/drivers/input/mouse/elan_i2c.c b/drivers/input/mouse/elan_i2c.c
new file mode 100644
index 000..f7bfa22
--- /dev/null
+++ b/drivers/input/mouse/elan_i2c.c
@@ -0,0 +1,890 @@
+/*
+ * Elan I2C/SMBus Touchpad driver
+ *
+ * Copyright (c) 2013 ELAN Microelectronics Corp.
+ *
+ * Author: 林政維 (Duson Lin) 
+ * Version: 1.4.6
+ *
+ * Based on cyapa driver:
+ * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
+ * copyright (c) 2011-2012 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_NAME"elan_i2c"
+#define ELAN_DRIVER_VERSION"1.4.6"
+#define ETP_PRESSURE_OFFSET25
+#define ETP_MAX_PRESSURE   255
+#define ETP_FWIDTH_REDUCE  90
+#define ETP_FINGER_WIDTH   15
+
+#define ELAN_ADAPTER_FUNC_NONE   0
+#define ELAN_ADAPTER_FUNC_I2C1
+#define ELAN_ADAPTER_FUNC_SMBUS  2
+#define ELAN_ADAPTER_FUNC_BOTH   3
+
+/* Length of Elan touchpad information */
+#define ETP_INF_LENGTH 2
+#define ETP_MAX_FINGERS5
+#define ETP_FINGER_DATA_LEN5
+#define ETP_REPORT_ID  0x5D
+#define ETP_MAX_REPORT_LEN 34
+#define ETP_ENABLE_ABS 0x0001
+#define ETP_ENABLE_CALIBRATE   0x0002
+#define ETP_DISABLE_CALIBRATE  0x
+
+/* Elan smbus command */
+#define ETP_SMBUS_IAP_CMD  0x00
+#define ETP_SMBUS_ENABLE_TP0x20
+#define ETP_SMBUS_SLEEP_CMD0x21
+#define ETP_SMBUS_IAP_PASSWORD_WRITE   0x29
+#define ETP_SMBUS_IAP_PASSWORD_READ0x80
+#define ETP_SMBUS_WRITE_FW_BLOCK   0x2A
+#define ETP_SMBUS_IAP_RESET_CMD0x2B
+#define ETP_SMBUS_RANGE_CMD0xA0
+#define ETP_SMBUS_FW_VERSION_CMD   0xA1
+#define ETP_SMBUS_XY_TRACENUM_CMD  0xA2
+#define ETP_SMBUS_SM_VERSION_CMD   0xA3
+#define ETP_SMBUS_UNIQUEID_CMD 0xA3
+#define ETP_SMBUS_RESOLUTION_CMD   0xA4
+#define ETP_SMBUS_HELLOPACKET_CMD  0xA7
+#define ETP_SMBUS_PACKET_QUERY 0xA8
+#define ETP_SMBUS_IAP_VERSION_CMD  0xAC
+#define ETP_SMBUS_IAP_CTRL_CMD 0xAD
+#define ETP_SMBUS_IAP_CHECKSUM_CMD 0xAE
+#define ETP_SMBUS_FW_CHECKSUM_CMD  0xAF
+#define ETP_SMBUS_MAX_BASELINE_CMD 0xC3
+#define ETP_SMBUS_MIN_BASELINE_CMD 0xC4
+#define ETP_SMBUS_CALIBRATE_QUERY  0xC5
+#define ETP_SMBUS_REPORT_LEN   32
+#define ETP_SMBUS_FINGER_DATA_OFFSET   2
+#define ETP_SMBUS_HELLOPACKET_LEN  5
+#define ETP_SMBUS_IAP_PASSWORD 0x1234
+#define ETP_SMBUS_IAP_MODE_ON  (1<<6)
+
+/* Elan i2c command */
+#define ETP_I2C_RESET  0x0100
+#define ETP_I2C_WAKE_UP0x0800
+#define ETP_I2C_SLEEP  0x0801
+#define ETP_I2C_DESC_CMD   0x0001
+#define ETP_I2C_REPORT_DESC_CMD0x0002
+#define ETP_I2C_STAND_CMD  0x0005
+#define ETP_I2C_UNIQUEID_CMD   

[PATCH v2] Input: add i2c/smbus driver for elan touchpad

2013-12-17 Thread Duson Lin
This driver adds support for elan i2c/smbus touchpad found on some laptops PC

Signed-off-by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/Kconfig|   10 +
 drivers/input/mouse/Makefile   |1 +
 drivers/input/mouse/elan_i2c.c |  890 
 3 files changed, 901 insertions(+)
 create mode 100644 drivers/input/mouse/elan_i2c.c

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index effa9c5..095eccc 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -215,6 +215,16 @@ config MOUSE_CYAPA
  To compile this driver as a module, choose M here: the module will be
  called cyapa.
 
+config MOUSE_ELAN_I2C
+   tristate ELAN I2C Touchpad support
+   depends on I2C
+   help
+ This driver adds support for Elan I2C Trackpads.
+ Say Y here if you have a ELAN I2C Touchpad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called elan_i2c.
+
 config MOUSE_INPORT
tristate InPort/MS/ATIXL busmouse
depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..24a12a6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH)  += appletouch.o
 obj-$(CONFIG_MOUSE_ATARI)  += atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)  += cyapa.o
+obj-$(CONFIG_MOUSE_ELAN_I2C)   += elan_i2c.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
 obj-$(CONFIG_MOUSE_INPORT) += inport.o
 obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
diff --git a/drivers/input/mouse/elan_i2c.c b/drivers/input/mouse/elan_i2c.c
new file mode 100644
index 000..f7bfa22
--- /dev/null
+++ b/drivers/input/mouse/elan_i2c.c
@@ -0,0 +1,890 @@
+/*
+ * Elan I2C/SMBus Touchpad driver
+ *
+ * Copyright (c) 2013 ELAN Microelectronics Corp.
+ *
+ * Author: 林政維 (Duson Lin) duson...@emc.com.tw
+ * Version: 1.4.6
+ *
+ * Based on cyapa driver:
+ * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
+ * copyright (c) 2011-2012 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+#include linux/delay.h
+#include linux/device.h
+#include linux/firmware.h
+#include linux/i2c.h
+#include linux/init.h
+#include linux/input/mt.h
+#include linux/interrupt.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/debugfs.h
+#include linux/cdev.h
+#include linux/kernel.h
+#include linux/major.h
+#include linux/sched.h
+#include linux/input.h
+#include linux/uaccess.h
+#include linux/jiffies.h
+
+#define DRIVER_NAMEelan_i2c
+#define ELAN_DRIVER_VERSION1.4.6
+#define ETP_PRESSURE_OFFSET25
+#define ETP_MAX_PRESSURE   255
+#define ETP_FWIDTH_REDUCE  90
+#define ETP_FINGER_WIDTH   15
+
+#define ELAN_ADAPTER_FUNC_NONE   0
+#define ELAN_ADAPTER_FUNC_I2C1
+#define ELAN_ADAPTER_FUNC_SMBUS  2
+#define ELAN_ADAPTER_FUNC_BOTH   3
+
+/* Length of Elan touchpad information */
+#define ETP_INF_LENGTH 2
+#define ETP_MAX_FINGERS5
+#define ETP_FINGER_DATA_LEN5
+#define ETP_REPORT_ID  0x5D
+#define ETP_MAX_REPORT_LEN 34
+#define ETP_ENABLE_ABS 0x0001
+#define ETP_ENABLE_CALIBRATE   0x0002
+#define ETP_DISABLE_CALIBRATE  0x
+
+/* Elan smbus command */
+#define ETP_SMBUS_IAP_CMD  0x00
+#define ETP_SMBUS_ENABLE_TP0x20
+#define ETP_SMBUS_SLEEP_CMD0x21
+#define ETP_SMBUS_IAP_PASSWORD_WRITE   0x29
+#define ETP_SMBUS_IAP_PASSWORD_READ0x80
+#define ETP_SMBUS_WRITE_FW_BLOCK   0x2A
+#define ETP_SMBUS_IAP_RESET_CMD0x2B
+#define ETP_SMBUS_RANGE_CMD0xA0
+#define ETP_SMBUS_FW_VERSION_CMD   0xA1
+#define ETP_SMBUS_XY_TRACENUM_CMD  0xA2
+#define ETP_SMBUS_SM_VERSION_CMD   0xA3
+#define ETP_SMBUS_UNIQUEID_CMD 0xA3
+#define ETP_SMBUS_RESOLUTION_CMD   0xA4
+#define ETP_SMBUS_HELLOPACKET_CMD  0xA7
+#define ETP_SMBUS_PACKET_QUERY 0xA8
+#define ETP_SMBUS_IAP_VERSION_CMD  0xAC
+#define ETP_SMBUS_IAP_CTRL_CMD 0xAD
+#define ETP_SMBUS_IAP_CHECKSUM_CMD 0xAE
+#define ETP_SMBUS_FW_CHECKSUM_CMD  0xAF
+#define ETP_SMBUS_MAX_BASELINE_CMD 0xC3
+#define ETP_SMBUS_MIN_BASELINE_CMD 0xC4
+#define ETP_SMBUS_CALIBRATE_QUERY  0xC5
+#define ETP_SMBUS_REPORT_LEN   32
+#define ETP_SMBUS_FINGER_DATA_OFFSET   2
+#define ETP_SMBUS_HELLOPACKET_LEN  5
+#define ETP_SMBUS_IAP_PASSWORD 0x1234
+#define ETP_SMBUS_IAP_MODE_ON  (16)
+
+/* Elan i2c command */
+#define ETP_I2C_RESET  0x0100
+#define ETP_I2C_WAKE_UP0x0800
+#define

[PATCH] Input: add i2c/smbus driver for elan touchpad

2013-12-16 Thread Duson Lin
This driver adds support for elan i2c/smbus touchpad found on some laptops PC

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/Kconfig|   10 +
 drivers/input/mouse/Makefile   |1 +
 drivers/input/mouse/elan_i2c.c |  908 
 3 files changed, 919 insertions(+)
 create mode 100644 drivers/input/mouse/elan_i2c.c

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index effa9c5..095eccc 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -215,6 +215,16 @@ config MOUSE_CYAPA
  To compile this driver as a module, choose M here: the module will be
  called cyapa.
 
+config MOUSE_ELAN_I2C
+   tristate "ELAN I2C Touchpad support"
+   depends on I2C
+   help
+ This driver adds support for Elan I2C Trackpads.
+ Say Y here if you have a ELAN I2C Touchpad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called elan_i2c.
+
 config MOUSE_INPORT
tristate "InPort/MS/ATIXL busmouse"
depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..24a12a6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH)  += appletouch.o
 obj-$(CONFIG_MOUSE_ATARI)  += atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)  += cyapa.o
+obj-$(CONFIG_MOUSE_ELAN_I2C)   += elan_i2c.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
 obj-$(CONFIG_MOUSE_INPORT) += inport.o
 obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
diff --git a/drivers/input/mouse/elan_i2c.c b/drivers/input/mouse/elan_i2c.c
new file mode 100644
index 000..a5a11bb
--- /dev/null
+++ b/drivers/input/mouse/elan_i2c.c
@@ -0,0 +1,908 @@
+/*
+ * Elan I2C/SMBus Touchpad driver
+ *
+ * Copyright (c) 2013 ELAN Microelectronics Corp.
+ *
+ * Author: 林政維 (Duson Lin) 
+ * Version: 1.4.6
+ *
+ * Based on cyapa driver:
+ * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
+ * copyright (c) 2011-2012 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_NAME"elan_i2c"
+#define ELAN_DRIVER_VERSION"1.4.6"
+#define ETP_PRESSURE_OFFSET25
+#define ETP_MAX_PRESSURE   255
+#define ETP_FWIDTH_REDUCE  90
+#define ETP_FINGER_WIDTH   15
+
+#define ELAN_ADAPTER_FUNC_NONE   0
+#define ELAN_ADAPTER_FUNC_I2C1
+#define ELAN_ADAPTER_FUNC_SMBUS  2
+#define ELAN_ADAPTER_FUNC_BOTH   3
+
+/* Length of Elan touchpad information */
+#define ETP_INF_LENGTH 2
+#define ETP_MAX_FINGERS5
+#define ETP_FINGER_DATA_LEN5
+#define ETP_REPORT_ID  0x5D
+#define ETP_MAX_REPORT_LEN 34
+#define ETP_ENABLE_ABS 0x0001
+#define ETP_ENABLE_CALIBRATE   0x0002
+#define ETP_DISABLE_CALIBRATE  0x
+
+/* Elan smbus command */
+#define ETP_SMBUS_IAP_CMD  0x00
+#define ETP_SMBUS_ENABLE_TP0x20
+#define ETP_SMBUS_SLEEP_CMD0x21
+#define ETP_SMBUS_IAP_PASSWORD_WRITE   0x29
+#define ETP_SMBUS_IAP_PASSWORD_READ0x80
+#define ETP_SMBUS_WRITE_FW_BLOCK   0x2A
+#define ETP_SMBUS_IAP_RESET_CMD0x2B
+#define ETP_SMBUS_RANGE_CMD0xA0
+#define ETP_SMBUS_FW_VERSION_CMD   0xA1
+#define ETP_SMBUS_XY_TRACENUM_CMD  0xA2
+#define ETP_SMBUS_SM_VERSION_CMD   0xA3
+#define ETP_SMBUS_UNIQUEID_CMD 0xA3
+#define ETP_SMBUS_RESOLUTION_CMD   0xA4
+#define ETP_SMBUS_HELLOPACKET_CMD  0xA7
+#define ETP_SMBUS_PACKET_QUERY 0xA8
+#define ETP_SMBUS_IAP_VERSION_CMD  0xAC
+#define ETP_SMBUS_IAP_CTRL_CMD 0xAD
+#define ETP_SMBUS_IAP_CHECKSUM_CMD 0xAE
+#define ETP_SMBUS_FW_CHECKSUM_CMD  0xAF
+#define ETP_SMBUS_MAX_BASELINE_CMD 0xC3
+#define ETP_SMBUS_MIN_BASELINE_CMD 0xC4
+#define ETP_SMBUS_CALIBRATE_QUERY  0xC5
+#define ETP_SMBUS_REPORT_LEN   32
+#define ETP_SMBUS_FINGER_DATA_OFFSET   2
+#define ETP_SMBUS_HELLOPACKET_LEN  5
+#define ETP_SMBUS_IAP_PASSWORD 0x1234
+#define ETP_SMBUS_IAP_MODE_ON  (1<<6)
+
+/* Elan i2c command */
+#define ETP_I2C_RESET  0x0100
+#define ETP_I2C_WAKE_UP0x0800
+#define ETP_I2C_SLEEP  0x0801
+#define ETP_I2C_DESC_CMD   0x0001
+#define ETP_I2C_REPORT_DESC_CMD0x0002
+#define ETP_I2C_STAND_CMD  0x0005
+#define ETP_I2C_UNIQUEID_CMD   

[PATCH] Input: add i2c/smbus driver for elan touchpad

2013-12-16 Thread Duson Lin
This driver adds support for elan i2c/smbus touchpad found on some laptops PC

Signed-off-by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/Kconfig|   10 +
 drivers/input/mouse/Makefile   |1 +
 drivers/input/mouse/elan_i2c.c |  908 
 3 files changed, 919 insertions(+)
 create mode 100644 drivers/input/mouse/elan_i2c.c

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index effa9c5..095eccc 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -215,6 +215,16 @@ config MOUSE_CYAPA
  To compile this driver as a module, choose M here: the module will be
  called cyapa.
 
+config MOUSE_ELAN_I2C
+   tristate ELAN I2C Touchpad support
+   depends on I2C
+   help
+ This driver adds support for Elan I2C Trackpads.
+ Say Y here if you have a ELAN I2C Touchpad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called elan_i2c.
+
 config MOUSE_INPORT
tristate InPort/MS/ATIXL busmouse
depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..24a12a6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH)  += appletouch.o
 obj-$(CONFIG_MOUSE_ATARI)  += atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)  += cyapa.o
+obj-$(CONFIG_MOUSE_ELAN_I2C)   += elan_i2c.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
 obj-$(CONFIG_MOUSE_INPORT) += inport.o
 obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
diff --git a/drivers/input/mouse/elan_i2c.c b/drivers/input/mouse/elan_i2c.c
new file mode 100644
index 000..a5a11bb
--- /dev/null
+++ b/drivers/input/mouse/elan_i2c.c
@@ -0,0 +1,908 @@
+/*
+ * Elan I2C/SMBus Touchpad driver
+ *
+ * Copyright (c) 2013 ELAN Microelectronics Corp.
+ *
+ * Author: 林政維 (Duson Lin) duson...@emc.com.tw
+ * Version: 1.4.6
+ *
+ * Based on cyapa driver:
+ * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
+ * copyright (c) 2011-2012 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+#include linux/delay.h
+#include linux/device.h
+#include linux/firmware.h
+#include linux/i2c.h
+#include linux/init.h
+#include linux/input/mt.h
+#include linux/interrupt.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/debugfs.h
+#include linux/cdev.h
+#include linux/kernel.h
+#include linux/major.h
+#include linux/sched.h
+#include linux/input.h
+#include linux/uaccess.h
+#include linux/jiffies.h
+
+#define DRIVER_NAMEelan_i2c
+#define ELAN_DRIVER_VERSION1.4.6
+#define ETP_PRESSURE_OFFSET25
+#define ETP_MAX_PRESSURE   255
+#define ETP_FWIDTH_REDUCE  90
+#define ETP_FINGER_WIDTH   15
+
+#define ELAN_ADAPTER_FUNC_NONE   0
+#define ELAN_ADAPTER_FUNC_I2C1
+#define ELAN_ADAPTER_FUNC_SMBUS  2
+#define ELAN_ADAPTER_FUNC_BOTH   3
+
+/* Length of Elan touchpad information */
+#define ETP_INF_LENGTH 2
+#define ETP_MAX_FINGERS5
+#define ETP_FINGER_DATA_LEN5
+#define ETP_REPORT_ID  0x5D
+#define ETP_MAX_REPORT_LEN 34
+#define ETP_ENABLE_ABS 0x0001
+#define ETP_ENABLE_CALIBRATE   0x0002
+#define ETP_DISABLE_CALIBRATE  0x
+
+/* Elan smbus command */
+#define ETP_SMBUS_IAP_CMD  0x00
+#define ETP_SMBUS_ENABLE_TP0x20
+#define ETP_SMBUS_SLEEP_CMD0x21
+#define ETP_SMBUS_IAP_PASSWORD_WRITE   0x29
+#define ETP_SMBUS_IAP_PASSWORD_READ0x80
+#define ETP_SMBUS_WRITE_FW_BLOCK   0x2A
+#define ETP_SMBUS_IAP_RESET_CMD0x2B
+#define ETP_SMBUS_RANGE_CMD0xA0
+#define ETP_SMBUS_FW_VERSION_CMD   0xA1
+#define ETP_SMBUS_XY_TRACENUM_CMD  0xA2
+#define ETP_SMBUS_SM_VERSION_CMD   0xA3
+#define ETP_SMBUS_UNIQUEID_CMD 0xA3
+#define ETP_SMBUS_RESOLUTION_CMD   0xA4
+#define ETP_SMBUS_HELLOPACKET_CMD  0xA7
+#define ETP_SMBUS_PACKET_QUERY 0xA8
+#define ETP_SMBUS_IAP_VERSION_CMD  0xAC
+#define ETP_SMBUS_IAP_CTRL_CMD 0xAD
+#define ETP_SMBUS_IAP_CHECKSUM_CMD 0xAE
+#define ETP_SMBUS_FW_CHECKSUM_CMD  0xAF
+#define ETP_SMBUS_MAX_BASELINE_CMD 0xC3
+#define ETP_SMBUS_MIN_BASELINE_CMD 0xC4
+#define ETP_SMBUS_CALIBRATE_QUERY  0xC5
+#define ETP_SMBUS_REPORT_LEN   32
+#define ETP_SMBUS_FINGER_DATA_OFFSET   2
+#define ETP_SMBUS_HELLOPACKET_LEN  5
+#define ETP_SMBUS_IAP_PASSWORD 0x1234
+#define ETP_SMBUS_IAP_MODE_ON  (16)
+
+/* Elan i2c command */
+#define ETP_I2C_RESET  0x0100
+#define ETP_I2C_WAKE_UP0x0800
+#define

RE: [PATCH] Add: (1) Detection for newer Elantech touchpads, so that kernel doesn't fall-back to default PS/2 driver. (2) Enable hardware version 4 touchpad right click function.

2013-12-10 Thread duson
Hi Dmitry

> -Original Message-
> From: linux-input-ow...@vger.kernel.org
[mailto:linux-input-ow...@vger.kernel.org]
> On Behalf Of Dmitry Torokhov
> Sent: Monday, December 09, 2013 2:32 PM
> To: Duson Lin
> Cc: linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org
> Subject: Re: [PATCH] Add: (1) Detection for newer Elantech touchpads, so
that
> kernel doesn't fall-back to default PS/2 driver. (2) Enable hardware
version 4
> touchpad right click function.
> 
> Hi Duson.
> 
> 
> On Mon, Dec 09, 2013 at 10:59:50AM +0800, Duson Lin wrote:
> > Modify:
> > (1) crc_enabled only support for v3 and v4 touchpad, so initialize
crc_enabled as
> false first and
> > check this hardware flag when hw_version as 3 or 4.
> 
> It looks to me there are several fixes rolled up together in this patch:
> 
> 1. Support for the new hardware signatures (8 and 10, although I already
> applied patch for 8)
> 2. Fix to handle CRC check
> 3. Changes to report BTN_RIGHT.
> 
> Could you please split them up please?
OK, I will split them up.

> 
> Also, I am not sure if we can simply start reporting BTN_RIGHT as
> present, even on devices that don't actually have the right button, as
> this will interfere with userspace providing emulation for multiple
> buttons.
> 
> Is it possible to determine if a given model had right button or not?
It is hard to determine if a given model had right button, but depend on
per-discuss in Hans de Goede's mailing list, it is possible to determine if
given model need right click function.
Thanks.
Duosn 

> 
> >
> > Signed-off-by: Duson Lin 
> > ---
> >  drivers/input/mouse/elantech.c |   30 ++
> >  drivers/input/mouse/elantech.h |2 +-
> >  2 files changed, 15 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/input/mouse/elantech.c
b/drivers/input/mouse/elantech.c
> > index 8551dca..b3627cf 100644
> > --- a/drivers/input/mouse/elantech.c
> > +++ b/drivers/input/mouse/elantech.c
> > @@ -1,5 +1,5 @@
> >  /*
> > - * Elantech Touchpad driver (v6)
> > + * Elantech Touchpad driver (v7)
> >   *
> >   * Copyright (C) 2007-2009 Arjan Opmeer 
> >   *
> > @@ -486,6 +486,7 @@ static void elantech_input_sync_v4(struct psmouse
> *psmouse)
> > unsigned char *packet = psmouse->packet;
> >
> > input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
> > +   input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
> > input_mt_report_pointer_emulation(dev, true);
> > input_sync(dev);
> >  }
> > @@ -1047,9 +1048,7 @@ static int elantech_set_input_params(struct
psmouse
> *psmouse)
> >  */
> > psmouse_warn(psmouse, "couldn't query resolution
data.\n");
> > }
> > -   /* v4 is clickpad, with only one button. */
> > __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
> > -   __clear_bit(BTN_RIGHT, dev->keybit);
> > __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
> > /* For X to recognize me as touchpad. */
> > input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
> > @@ -1186,19 +1185,12 @@ static struct attribute_group
elantech_attr_group = {
> >
> >  static bool elantech_is_signature_valid(const unsigned char *param)
> >  {
> > -   static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10
};
> > -   int i;
> > -
> > if (param[0] == 0)
> > return false;
> >
> > if (param[1] == 0)
> > return true;
> >
> > -   for (i = 0; i < ARRAY_SIZE(rates); i++)
> > -   if (param[2] == rates[i])
> > -   return false;
> > -
> > return true;
> >  }
> >
> > @@ -1298,6 +1290,14 @@ static int elantech_set_properties(struct
> elantech_data *etd)
> >  {
> > /* This represents the version of IC body. */
> > int ver = (etd->fw_version & 0x0f) >> 16;
> > +   /*
> > +* The signatures of v3 and v4 packets change depending on the
> > +* value of this hardware flag. But the v1 and v2 have not crc
> > +* check mechanism and the same hardware flag are also defined
> > +* as other function. So crc_enabled must be initialized as false
> > +* first and checking by different hw_version.
> > +*/
> > +   etd->crc_enabled = false;
> >
> > /* Early version of Elan touchpads doesn't obey the rule. */
> > if (etd->fw_version < 0x020030 || etd->fw_version == 0x020600)
> > @@ -1309,10 +

RE: [PATCH] Add: (1) Detection for newer Elantech touchpads, so that kernel doesn't fall-back to default PS/2 driver. (2) Enable hardware version 4 touchpad right click function.

2013-12-10 Thread duson
Hi Dmitry

 -Original Message-
 From: linux-input-ow...@vger.kernel.org
[mailto:linux-input-ow...@vger.kernel.org]
 On Behalf Of Dmitry Torokhov
 Sent: Monday, December 09, 2013 2:32 PM
 To: Duson Lin
 Cc: linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org
 Subject: Re: [PATCH] Add: (1) Detection for newer Elantech touchpads, so
that
 kernel doesn't fall-back to default PS/2 driver. (2) Enable hardware
version 4
 touchpad right click function.
 
 Hi Duson.
 
 
 On Mon, Dec 09, 2013 at 10:59:50AM +0800, Duson Lin wrote:
  Modify:
  (1) crc_enabled only support for v3 and v4 touchpad, so initialize
crc_enabled as
 false first and
  check this hardware flag when hw_version as 3 or 4.
 
 It looks to me there are several fixes rolled up together in this patch:
 
 1. Support for the new hardware signatures (8 and 10, although I already
 applied patch for 8)
 2. Fix to handle CRC check
 3. Changes to report BTN_RIGHT.
 
 Could you please split them up please?
OK, I will split them up.

 
 Also, I am not sure if we can simply start reporting BTN_RIGHT as
 present, even on devices that don't actually have the right button, as
 this will interfere with userspace providing emulation for multiple
 buttons.
 
 Is it possible to determine if a given model had right button or not?
It is hard to determine if a given model had right button, but depend on
per-discuss in Hans de Goede's mailing list, it is possible to determine if
given model need right click function.
Thanks.
Duosn 

 
 
  Signed-off-by: Duson Lin duson...@emc.com.tw
  ---
   drivers/input/mouse/elantech.c |   30 ++
   drivers/input/mouse/elantech.h |2 +-
   2 files changed, 15 insertions(+), 17 deletions(-)
 
  diff --git a/drivers/input/mouse/elantech.c
b/drivers/input/mouse/elantech.c
  index 8551dca..b3627cf 100644
  --- a/drivers/input/mouse/elantech.c
  +++ b/drivers/input/mouse/elantech.c
  @@ -1,5 +1,5 @@
   /*
  - * Elantech Touchpad driver (v6)
  + * Elantech Touchpad driver (v7)
*
* Copyright (C) 2007-2009 Arjan Opmeer ar...@opmeer.net
*
  @@ -486,6 +486,7 @@ static void elantech_input_sync_v4(struct psmouse
 *psmouse)
  unsigned char *packet = psmouse-packet;
 
  input_report_key(dev, BTN_LEFT, packet[0]  0x01);
  +   input_report_key(dev, BTN_RIGHT, packet[0]  0x02);
  input_mt_report_pointer_emulation(dev, true);
  input_sync(dev);
   }
  @@ -1047,9 +1048,7 @@ static int elantech_set_input_params(struct
psmouse
 *psmouse)
   */
  psmouse_warn(psmouse, couldn't query resolution
data.\n);
  }
  -   /* v4 is clickpad, with only one button. */
  __set_bit(INPUT_PROP_BUTTONPAD, dev-propbit);
  -   __clear_bit(BTN_RIGHT, dev-keybit);
  __set_bit(BTN_TOOL_QUADTAP, dev-keybit);
  /* For X to recognize me as touchpad. */
  input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
  @@ -1186,19 +1185,12 @@ static struct attribute_group
elantech_attr_group = {
 
   static bool elantech_is_signature_valid(const unsigned char *param)
   {
  -   static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10
};
  -   int i;
  -
  if (param[0] == 0)
  return false;
 
  if (param[1] == 0)
  return true;
 
  -   for (i = 0; i  ARRAY_SIZE(rates); i++)
  -   if (param[2] == rates[i])
  -   return false;
  -
  return true;
   }
 
  @@ -1298,6 +1290,14 @@ static int elantech_set_properties(struct
 elantech_data *etd)
   {
  /* This represents the version of IC body. */
  int ver = (etd-fw_version  0x0f)  16;
  +   /*
  +* The signatures of v3 and v4 packets change depending on the
  +* value of this hardware flag. But the v1 and v2 have not crc
  +* check mechanism and the same hardware flag are also defined
  +* as other function. So crc_enabled must be initialized as false
  +* first and checking by different hw_version.
  +*/
  +   etd-crc_enabled = false;
 
  /* Early version of Elan touchpads doesn't obey the rule. */
  if (etd-fw_version  0x020030 || etd-fw_version == 0x020600)
  @@ -1309,10 +1309,14 @@ static int elantech_set_properties(struct
 elantech_data *etd)
  etd-hw_version = 2;
  break;
  case 5:
  +   etd-crc_enabled = ((etd-fw_version  0x4000) ==
0x4000);
  etd-hw_version = 3;
  break;
  case 6:
  case 7:
  +   case 8:
  +   case 10:
  +   etd-crc_enabled = ((etd-fw_version  0x4000) ==
0x4000);
  etd-hw_version = 4;
  break;
  default:
  @@ -1343,12 +1347,6 @@ static int elantech_set_properties(struct
 elantech_data *etd)
  etd-reports_pressure = true;
  }
 
  -   /*
  -* The signatures of v3 and v4 packets change

[PATCH] Add: (1) Detection for newer Elantech touchpads, so that kernel doesn't fall-back to default PS/2 driver. (2) Enable hardware version 4 touchpad right click function.

2013-12-08 Thread Duson Lin
Modify:
(1) crc_enabled only support for v3 and v4 touchpad, so initialize crc_enabled 
as false first and
check this hardware flag when hw_version as 3 or 4.

Signed-off-by: Duson Lin 
---
 drivers/input/mouse/elantech.c |   30 ++
 drivers/input/mouse/elantech.h |2 +-
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 8551dca..b3627cf 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1,5 +1,5 @@
 /*
- * Elantech Touchpad driver (v6)
+ * Elantech Touchpad driver (v7)
  *
  * Copyright (C) 2007-2009 Arjan Opmeer 
  *
@@ -486,6 +486,7 @@ static void elantech_input_sync_v4(struct psmouse *psmouse)
unsigned char *packet = psmouse->packet;
 
input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
+   input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
input_mt_report_pointer_emulation(dev, true);
input_sync(dev);
 }
@@ -1047,9 +1048,7 @@ static int elantech_set_input_params(struct psmouse 
*psmouse)
 */
psmouse_warn(psmouse, "couldn't query resolution 
data.\n");
}
-   /* v4 is clickpad, with only one button. */
__set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
-   __clear_bit(BTN_RIGHT, dev->keybit);
__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
/* For X to recognize me as touchpad. */
input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
@@ -1186,19 +1185,12 @@ static struct attribute_group elantech_attr_group = {
 
 static bool elantech_is_signature_valid(const unsigned char *param)
 {
-   static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10 };
-   int i;
-
if (param[0] == 0)
return false;
 
if (param[1] == 0)
return true;
 
-   for (i = 0; i < ARRAY_SIZE(rates); i++)
-   if (param[2] == rates[i])
-   return false;
-
return true;
 }
 
@@ -1298,6 +1290,14 @@ static int elantech_set_properties(struct elantech_data 
*etd)
 {
/* This represents the version of IC body. */
int ver = (etd->fw_version & 0x0f) >> 16;
+   /*
+* The signatures of v3 and v4 packets change depending on the
+* value of this hardware flag. But the v1 and v2 have not crc
+* check mechanism and the same hardware flag are also defined
+* as other function. So crc_enabled must be initialized as false 
+* first and checking by different hw_version.
+*/
+   etd->crc_enabled = false;
 
/* Early version of Elan touchpads doesn't obey the rule. */
if (etd->fw_version < 0x020030 || etd->fw_version == 0x020600)
@@ -1309,10 +1309,14 @@ static int elantech_set_properties(struct elantech_data 
*etd)
etd->hw_version = 2;
break;
case 5:
+   etd->crc_enabled = ((etd->fw_version & 0x4000) == 
0x4000);
etd->hw_version = 3;
break;
case 6:
case 7:
+   case 8:
+   case 10:
+   etd->crc_enabled = ((etd->fw_version & 0x4000) == 
0x4000);
etd->hw_version = 4;
break;
default:
@@ -1343,12 +1347,6 @@ static int elantech_set_properties(struct elantech_data 
*etd)
etd->reports_pressure = true;
}
 
-   /*
-* The signatures of v3 and v4 packets change depending on the
-* value of this hardware flag.
-*/
-   etd->crc_enabled = ((etd->fw_version & 0x4000) == 0x4000);
-
return 0;
 }
 
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index 036a04a..c963ac8 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -1,5 +1,5 @@
 /*
- * Elantech Touchpad driver (v6)
+ * Elantech Touchpad driver (v7)
  *
  * Copyright (C) 2007-2009 Arjan Opmeer 
  *
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Add: (1) Detection for newer Elantech touchpads, so that kernel doesn't fall-back to default PS/2 driver. (2) Enable hardware version 4 touchpad right click function.

2013-12-08 Thread Duson Lin
Modify:
(1) crc_enabled only support for v3 and v4 touchpad, so initialize crc_enabled 
as false first and
check this hardware flag when hw_version as 3 or 4.

Signed-off-by: Duson Lin duson...@emc.com.tw
---
 drivers/input/mouse/elantech.c |   30 ++
 drivers/input/mouse/elantech.h |2 +-
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 8551dca..b3627cf 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1,5 +1,5 @@
 /*
- * Elantech Touchpad driver (v6)
+ * Elantech Touchpad driver (v7)
  *
  * Copyright (C) 2007-2009 Arjan Opmeer ar...@opmeer.net
  *
@@ -486,6 +486,7 @@ static void elantech_input_sync_v4(struct psmouse *psmouse)
unsigned char *packet = psmouse-packet;
 
input_report_key(dev, BTN_LEFT, packet[0]  0x01);
+   input_report_key(dev, BTN_RIGHT, packet[0]  0x02);
input_mt_report_pointer_emulation(dev, true);
input_sync(dev);
 }
@@ -1047,9 +1048,7 @@ static int elantech_set_input_params(struct psmouse 
*psmouse)
 */
psmouse_warn(psmouse, couldn't query resolution 
data.\n);
}
-   /* v4 is clickpad, with only one button. */
__set_bit(INPUT_PROP_BUTTONPAD, dev-propbit);
-   __clear_bit(BTN_RIGHT, dev-keybit);
__set_bit(BTN_TOOL_QUADTAP, dev-keybit);
/* For X to recognize me as touchpad. */
input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
@@ -1186,19 +1185,12 @@ static struct attribute_group elantech_attr_group = {
 
 static bool elantech_is_signature_valid(const unsigned char *param)
 {
-   static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10 };
-   int i;
-
if (param[0] == 0)
return false;
 
if (param[1] == 0)
return true;
 
-   for (i = 0; i  ARRAY_SIZE(rates); i++)
-   if (param[2] == rates[i])
-   return false;
-
return true;
 }
 
@@ -1298,6 +1290,14 @@ static int elantech_set_properties(struct elantech_data 
*etd)
 {
/* This represents the version of IC body. */
int ver = (etd-fw_version  0x0f)  16;
+   /*
+* The signatures of v3 and v4 packets change depending on the
+* value of this hardware flag. But the v1 and v2 have not crc
+* check mechanism and the same hardware flag are also defined
+* as other function. So crc_enabled must be initialized as false 
+* first and checking by different hw_version.
+*/
+   etd-crc_enabled = false;
 
/* Early version of Elan touchpads doesn't obey the rule. */
if (etd-fw_version  0x020030 || etd-fw_version == 0x020600)
@@ -1309,10 +1309,14 @@ static int elantech_set_properties(struct elantech_data 
*etd)
etd-hw_version = 2;
break;
case 5:
+   etd-crc_enabled = ((etd-fw_version  0x4000) == 
0x4000);
etd-hw_version = 3;
break;
case 6:
case 7:
+   case 8:
+   case 10:
+   etd-crc_enabled = ((etd-fw_version  0x4000) == 
0x4000);
etd-hw_version = 4;
break;
default:
@@ -1343,12 +1347,6 @@ static int elantech_set_properties(struct elantech_data 
*etd)
etd-reports_pressure = true;
}
 
-   /*
-* The signatures of v3 and v4 packets change depending on the
-* value of this hardware flag.
-*/
-   etd-crc_enabled = ((etd-fw_version  0x4000) == 0x4000);
-
return 0;
 }
 
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index 036a04a..c963ac8 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -1,5 +1,5 @@
 /*
- * Elantech Touchpad driver (v6)
+ * Elantech Touchpad driver (v7)
  *
  * Copyright (C) 2007-2009 Arjan Opmeer ar...@opmeer.net
  *
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Input: add i2c/smbus driver for elan touchpad

2013-11-22 Thread Duson Lin
This driver adds support for elan i2c/smbus touchpad found on some laptops PC
---
 drivers/input/mouse/Kconfig|   10 +
 drivers/input/mouse/Makefile   |1 +
 drivers/input/mouse/elan_i2c.c | 1846 
 3 files changed, 1857 insertions(+)
 create mode 100644 drivers/input/mouse/elan_i2c.c

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index effa9c5..8ad4b38 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -215,6 +215,16 @@ config MOUSE_CYAPA
  To compile this driver as a module, choose M here: the module will be
  called cyapa.
 
+config MOUSE_ELAN_I2C
+   tristate "ELAN I2C Touchpad support"
+   depends on I2C
+   help
+ This driver adds support for Elan I2C Trackpads.
+ Say y here if you have a ELAN I2C Touchpad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called elan_i2c.
+
 config MOUSE_INPORT
tristate "InPort/MS/ATIXL busmouse"
depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..24a12a6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH)  += appletouch.o
 obj-$(CONFIG_MOUSE_ATARI)  += atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)  += cyapa.o
+obj-$(CONFIG_MOUSE_ELAN_I2C)   += elan_i2c.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
 obj-$(CONFIG_MOUSE_INPORT) += inport.o
 obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
diff --git a/drivers/input/mouse/elan_i2c.c b/drivers/input/mouse/elan_i2c.c
new file mode 100644
index 000..9892ee1
--- /dev/null
+++ b/drivers/input/mouse/elan_i2c.c
@@ -0,0 +1,1846 @@
+/*
+ * Elan I2C/SMBus Touchpad driver
+ *
+ * Copyright (c) 2013 ELAN Microelectronics Corp.
+ *
+ * Author: 林政維 (Duson Lin) 
+ * Version: 1.4.6
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_NAME"elan_i2c"
+#define ELAN_DRIVER_VERSION"1.4.6"
+#define ETP_PRESSURE_OFFSET25
+#define ETP_MAX_PRESSURE   255
+#define ETP_FWIDTH_REDUCE  90
+#define ETP_FINGER_WIDTH   15
+
+#define ELAN_ADAPTER_FUNC_NONE   0
+#define ELAN_ADAPTER_FUNC_I2C1
+#define ELAN_ADAPTER_FUNC_SMBUS  2
+#define ELAN_ADAPTER_FUNC_BOTH   3
+
+/* Length of Elan touchpad information */
+#define ETP_INF_LENGTH 2
+#define ETP_MAX_FINGERS5
+#define ETP_FINGER_DATA_LEN5
+#define ETP_REPORT_ID  0x5D
+#define ETP_MAX_REPORT_LEN 34
+#define ETP_ENABLE_ABS 0x0001
+#define ETP_ENABLE_CALIBRATE   0x0002
+#define ETP_DISABLE_CALIBRATE  0x
+
+/* Elan smbus command */
+#define ETP_SMBUS_IAP_CMD  0x00
+#define ETP_SMBUS_ENABLE_TP0x20
+#define ETP_SMBUS_DISABLE_TP   0x21
+#define ETP_SMBUS_IAP_PASSWORD_WRITE   0x29
+#define ETP_SMBUS_IAP_PASSWORD_READ0x80
+#define ETP_SMBUS_WRITE_FW_BLOCK   0x2A
+#define ETP_SMBUS_IAP_RESET_CMD0x2B
+#define ETP_SMBUS_RANGE_CMD0xA0
+#define ETP_SMBUS_FW_VERSION_CMD   0xA1
+#define ETP_SMBUS_XY_TRACENUM_CMD  0xA2
+#define ETP_SMBUS_SM_VERSION_CMD   0xA3
+#define ETP_SMBUS_UNIQUEID_CMD 0xA3
+#define ETP_SMBUS_RESOLUTION_CMD   0xA4
+#define ETP_SMBUS_HELLOPACKET_CMD  0xA7
+#define ETP_SMBUS_PACKET_QUERY 0xA8
+#define ETP_SMBUS_IAP_VERSION_CMD  0xAC
+#define ETP_SMBUS_IAP_CTRL_CMD 0xAD
+#define ETP_SMBUS_IAP_CHECKSUM_CMD 0xAE
+#define ETP_SMBUS_FW_CHECKSUM_CMD  0xAF
+#define ETP_SMBUS_MAX_BASELINE_CMD 0xC3
+#define ETP_SMBUS_MIN_BASELINE_CMD 0xC4
+#define ETP_SMBUS_CALIBRATE_QUERY  0xC5
+#define ETP_SMBUS_REPORT_LEN   32
+#define ETP_SMBUS_FINGER_DATA_OFFSET   2
+#define ETP_SMBUS_HELLOPACKET_LEN  5
+#define ETP_SMBUS_IAP_PASSWORD 0x1234
+#define ETP_SMBUS_IAP_MODE_ON  (1<<6)
+
+/* Elan i2c command */
+#define ETP_I2C_RESET  0x0100
+#define ETP_I2C_WAKE_UP0x0800
+#define ETP_I2C_SLEEP  0x0801
+#define ETP_I2C_DESC_CMD   0x0001
+#define ETP_I2C_REPORT_DESC_CMD0x0002
+#define ETP_I2C_STAND_CMD  0x0005
+#define ETP_I2C_UNIQUEID_CMD   0x0101
+#define ETP_I2C_FW_VERSION_CMD 0x0102
+#define ETP_I2C_SM_VERSION_CMD 0x0103
+#define ETP_I2C_XY_TRACENUM_CMD

[PATCH] Input: add i2c/smbus driver for elan touchpad

2013-11-22 Thread Duson Lin
This driver adds support for elan i2c/smbus touchpad found on some laptops PC
---
 drivers/input/mouse/Kconfig|   10 +
 drivers/input/mouse/Makefile   |1 +
 drivers/input/mouse/elan_i2c.c | 1846 
 3 files changed, 1857 insertions(+)
 create mode 100644 drivers/input/mouse/elan_i2c.c

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index effa9c5..8ad4b38 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -215,6 +215,16 @@ config MOUSE_CYAPA
  To compile this driver as a module, choose M here: the module will be
  called cyapa.
 
+config MOUSE_ELAN_I2C
+   tristate ELAN I2C Touchpad support
+   depends on I2C
+   help
+ This driver adds support for Elan I2C Trackpads.
+ Say y here if you have a ELAN I2C Touchpad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called elan_i2c.
+
 config MOUSE_INPORT
tristate InPort/MS/ATIXL busmouse
depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..24a12a6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH)  += appletouch.o
 obj-$(CONFIG_MOUSE_ATARI)  += atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)  += cyapa.o
+obj-$(CONFIG_MOUSE_ELAN_I2C)   += elan_i2c.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
 obj-$(CONFIG_MOUSE_INPORT) += inport.o
 obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
diff --git a/drivers/input/mouse/elan_i2c.c b/drivers/input/mouse/elan_i2c.c
new file mode 100644
index 000..9892ee1
--- /dev/null
+++ b/drivers/input/mouse/elan_i2c.c
@@ -0,0 +1,1846 @@
+/*
+ * Elan I2C/SMBus Touchpad driver
+ *
+ * Copyright (c) 2013 ELAN Microelectronics Corp.
+ *
+ * Author: 林政維 (Duson Lin) duson...@emc.com.tw
+ * Version: 1.4.6
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+#include linux/delay.h
+#include linux/device.h
+#include linux/firmware.h
+#include linux/i2c.h
+#include linux/init.h
+#include linux/input/mt.h
+#include linux/interrupt.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/debugfs.h
+#include linux/cdev.h
+#include linux/kernel.h
+#include linux/major.h
+#include linux/sched.h
+#include linux/input.h
+#include linux/uaccess.h
+#include linux/jiffies.h
+
+#define DRIVER_NAMEelan_i2c
+#define ELAN_DRIVER_VERSION1.4.6
+#define ETP_PRESSURE_OFFSET25
+#define ETP_MAX_PRESSURE   255
+#define ETP_FWIDTH_REDUCE  90
+#define ETP_FINGER_WIDTH   15
+
+#define ELAN_ADAPTER_FUNC_NONE   0
+#define ELAN_ADAPTER_FUNC_I2C1
+#define ELAN_ADAPTER_FUNC_SMBUS  2
+#define ELAN_ADAPTER_FUNC_BOTH   3
+
+/* Length of Elan touchpad information */
+#define ETP_INF_LENGTH 2
+#define ETP_MAX_FINGERS5
+#define ETP_FINGER_DATA_LEN5
+#define ETP_REPORT_ID  0x5D
+#define ETP_MAX_REPORT_LEN 34
+#define ETP_ENABLE_ABS 0x0001
+#define ETP_ENABLE_CALIBRATE   0x0002
+#define ETP_DISABLE_CALIBRATE  0x
+
+/* Elan smbus command */
+#define ETP_SMBUS_IAP_CMD  0x00
+#define ETP_SMBUS_ENABLE_TP0x20
+#define ETP_SMBUS_DISABLE_TP   0x21
+#define ETP_SMBUS_IAP_PASSWORD_WRITE   0x29
+#define ETP_SMBUS_IAP_PASSWORD_READ0x80
+#define ETP_SMBUS_WRITE_FW_BLOCK   0x2A
+#define ETP_SMBUS_IAP_RESET_CMD0x2B
+#define ETP_SMBUS_RANGE_CMD0xA0
+#define ETP_SMBUS_FW_VERSION_CMD   0xA1
+#define ETP_SMBUS_XY_TRACENUM_CMD  0xA2
+#define ETP_SMBUS_SM_VERSION_CMD   0xA3
+#define ETP_SMBUS_UNIQUEID_CMD 0xA3
+#define ETP_SMBUS_RESOLUTION_CMD   0xA4
+#define ETP_SMBUS_HELLOPACKET_CMD  0xA7
+#define ETP_SMBUS_PACKET_QUERY 0xA8
+#define ETP_SMBUS_IAP_VERSION_CMD  0xAC
+#define ETP_SMBUS_IAP_CTRL_CMD 0xAD
+#define ETP_SMBUS_IAP_CHECKSUM_CMD 0xAE
+#define ETP_SMBUS_FW_CHECKSUM_CMD  0xAF
+#define ETP_SMBUS_MAX_BASELINE_CMD 0xC3
+#define ETP_SMBUS_MIN_BASELINE_CMD 0xC4
+#define ETP_SMBUS_CALIBRATE_QUERY  0xC5
+#define ETP_SMBUS_REPORT_LEN   32
+#define ETP_SMBUS_FINGER_DATA_OFFSET   2
+#define ETP_SMBUS_HELLOPACKET_LEN  5
+#define ETP_SMBUS_IAP_PASSWORD 0x1234
+#define ETP_SMBUS_IAP_MODE_ON  (16)
+
+/* Elan i2c command */
+#define ETP_I2C_RESET  0x0100
+#define ETP_I2C_WAKE_UP0x0800
+#define ETP_I2C_SLEEP  0x0801
+#define ETP_I2C_DESC_CMD   0x0001
+#define ETP_I2C_REPORT_DESC_CMD0x0002
+#define ETP_I2C_STAND_CMD

[PATCH] Input: add i2c driver for elan i2c touchpad

2013-10-23 Thread Duson Lin
From: Duson Lin 

This driver adds support for elan i2c touchpad found on some laptops.
---
 drivers/input/mouse/Kconfig|   10 +
 drivers/input/mouse/Makefile   |1 +
 drivers/input/mouse/elan_i2c.c | 1439 
 3 files changed, 1450 insertions(+)
 create mode 100644 drivers/input/mouse/elan_i2c.c

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index effa9c5..8ad4b38 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -215,6 +215,16 @@ config MOUSE_CYAPA
  To compile this driver as a module, choose M here: the module will be
  called cyapa.
 
+config MOUSE_ELAN_I2C
+   tristate "ELAN I2C Touchpad support"
+   depends on I2C
+   help
+ This driver adds support for Elan I2C Trackpads.
+ Say y here if you have a ELAN I2C Touchpad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called elan_i2c.
+
 config MOUSE_INPORT
tristate "InPort/MS/ATIXL busmouse"
depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..24a12a6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH)  += appletouch.o
 obj-$(CONFIG_MOUSE_ATARI)  += atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)  += cyapa.o
+obj-$(CONFIG_MOUSE_ELAN_I2C)   += elan_i2c.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
 obj-$(CONFIG_MOUSE_INPORT) += inport.o
 obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
diff --git a/drivers/input/mouse/elan_i2c.c b/drivers/input/mouse/elan_i2c.c
new file mode 100644
index 000..bc6e957
--- /dev/null
+++ b/drivers/input/mouse/elan_i2c.c
@@ -0,0 +1,1439 @@
+/*
+ * Elan I2C Touchpad driver
+ *
+ * Copyright (c) 2013 ELAN Microelectronics Corp.
+ *
+ * Author: 林政維 (Duson Lin) 
+ * Version: 1.4.5
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_NAME"elan_i2c"
+#define ELAN_DRIVER_VERSION"1.4.5"
+#define ETP_PRESSURE_OFFSET25
+#define ETP_MAX_PRESSURE   255
+#define ETP_FWIDTH_REDUCE  90
+#define ETP_FINGER_WIDTH   15
+
+#define ELAN_ADAPTER_FUNC_NONE   0
+#define ELAN_ADAPTER_FUNC_I2C1
+
+/* Length of Elan touchpad information */
+#define ETP_INF_LENGTH 2
+#define ETP_MAX_FINGERS5
+#define ETP_FINGER_DATA_LEN5
+#define ETP_REPORT_ID  0x5D
+#define ETP_MAX_REPORT_LEN 34
+#define ETP_ENABLE_ABS 0x0001
+#define ETP_ENABLE_CALIBRATE   0x0002
+#define ETP_DISABLE_CALIBRATE  0x
+
+/* Elan i2c command */
+#define ETP_I2C_RESET  0x0100
+#define ETP_I2C_WAKE_UP0x0800
+#define ETP_I2C_SLEEP  0x0801
+#define ETP_I2C_DESC_CMD   0x0001
+#define ETP_I2C_REPORT_DESC_CMD0x0002
+#define ETP_I2C_STAND_CMD  0x0005
+#define ETP_I2C_UNIQUEID_CMD   0x0101
+#define ETP_I2C_FW_VERSION_CMD 0x0102
+#define ETP_I2C_SM_VERSION_CMD 0x0103
+#define ETP_I2C_XY_TRACENUM_CMD0x0105
+#define ETP_I2C_MAX_X_AXIS_CMD 0x0106
+#define ETP_I2C_MAX_Y_AXIS_CMD 0x0107
+#define ETP_I2C_RESOLUTION_CMD 0x0108
+#define ETP_I2C_IAP_VERSION_CMD0x0110
+#define ETP_I2C_SET_CMD0x0300
+#define ETP_I2C_MAX_BASELINE_CMD   0x0306
+#define ETP_I2C_MIN_BASELINE_CMD   0x0307
+#define ETP_I2C_FW_CHECKSUM_CMD0x030F
+#define ETP_I2C_IAP_CTRL_CMD   0x0310
+#define ETP_I2C_IAP_CMD0x0311
+#define ETP_I2C_IAP_RESET_CMD  0x0314
+#define ETP_I2C_IAP_CHECKSUM_CMD   0x0315
+#define ETP_I2C_CALIBRATE_CMD  0x0316
+#define ETP_I2C_REPORT_LEN 34
+#define ETP_I2C_FINGER_DATA_OFFSET 4
+#define ETP_I2C_REPORT_ID_OFFSET   2
+#define ETP_I2C_DESC_LENGTH30
+#define ETP_I2C_REPORT_DESC_LENGTH 158
+
+/* IAP F/W updater */
+#define ETP_FW_NAME"elan_i2c.bin"
+#define ETP_FW_IAP_REG_L   0x01
+#define ETP_FW_IAP_REG_H   0x06
+#define ETP_IAP_VERSION_ADDR   0x0082
+#define ETP_IAP_START_ADDR 0x0083
+#define ETP_IAP_RESET  0xF0F0
+#define ETP_ENABLE_FWUPDATE0x1EA5
+#define ETP_FW_IAP_MODE_ON (1<<9)
+#define ETP_FW_IAP_PAGE_ERR(1<<5)
+#define ETP_FW_IAP_INTERFACE_ERR (1<<4)
+#define ET

[PATCH] Input: add i2c driver for elan i2c touchpad

2013-10-23 Thread Duson Lin
From: Duson Lin duson...@emc.com.tw

This driver adds support for elan i2c touchpad found on some laptops.
---
 drivers/input/mouse/Kconfig|   10 +
 drivers/input/mouse/Makefile   |1 +
 drivers/input/mouse/elan_i2c.c | 1439 
 3 files changed, 1450 insertions(+)
 create mode 100644 drivers/input/mouse/elan_i2c.c

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index effa9c5..8ad4b38 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -215,6 +215,16 @@ config MOUSE_CYAPA
  To compile this driver as a module, choose M here: the module will be
  called cyapa.
 
+config MOUSE_ELAN_I2C
+   tristate ELAN I2C Touchpad support
+   depends on I2C
+   help
+ This driver adds support for Elan I2C Trackpads.
+ Say y here if you have a ELAN I2C Touchpad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called elan_i2c.
+
 config MOUSE_INPORT
tristate InPort/MS/ATIXL busmouse
depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..24a12a6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH)  += appletouch.o
 obj-$(CONFIG_MOUSE_ATARI)  += atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)  += cyapa.o
+obj-$(CONFIG_MOUSE_ELAN_I2C)   += elan_i2c.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
 obj-$(CONFIG_MOUSE_INPORT) += inport.o
 obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
diff --git a/drivers/input/mouse/elan_i2c.c b/drivers/input/mouse/elan_i2c.c
new file mode 100644
index 000..bc6e957
--- /dev/null
+++ b/drivers/input/mouse/elan_i2c.c
@@ -0,0 +1,1439 @@
+/*
+ * Elan I2C Touchpad driver
+ *
+ * Copyright (c) 2013 ELAN Microelectronics Corp.
+ *
+ * Author: 林政維 (Duson Lin) duson...@emc.com.tw
+ * Version: 1.4.5
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+#include linux/delay.h
+#include linux/device.h
+#include linux/firmware.h
+#include linux/i2c.h
+#include linux/init.h
+#include linux/input/mt.h
+#include linux/interrupt.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/debugfs.h
+#include linux/cdev.h
+#include linux/kernel.h
+#include linux/major.h
+#include linux/sched.h
+#include linux/input.h
+#include linux/uaccess.h
+#include linux/jiffies.h
+
+#define DRIVER_NAMEelan_i2c
+#define ELAN_DRIVER_VERSION1.4.5
+#define ETP_PRESSURE_OFFSET25
+#define ETP_MAX_PRESSURE   255
+#define ETP_FWIDTH_REDUCE  90
+#define ETP_FINGER_WIDTH   15
+
+#define ELAN_ADAPTER_FUNC_NONE   0
+#define ELAN_ADAPTER_FUNC_I2C1
+
+/* Length of Elan touchpad information */
+#define ETP_INF_LENGTH 2
+#define ETP_MAX_FINGERS5
+#define ETP_FINGER_DATA_LEN5
+#define ETP_REPORT_ID  0x5D
+#define ETP_MAX_REPORT_LEN 34
+#define ETP_ENABLE_ABS 0x0001
+#define ETP_ENABLE_CALIBRATE   0x0002
+#define ETP_DISABLE_CALIBRATE  0x
+
+/* Elan i2c command */
+#define ETP_I2C_RESET  0x0100
+#define ETP_I2C_WAKE_UP0x0800
+#define ETP_I2C_SLEEP  0x0801
+#define ETP_I2C_DESC_CMD   0x0001
+#define ETP_I2C_REPORT_DESC_CMD0x0002
+#define ETP_I2C_STAND_CMD  0x0005
+#define ETP_I2C_UNIQUEID_CMD   0x0101
+#define ETP_I2C_FW_VERSION_CMD 0x0102
+#define ETP_I2C_SM_VERSION_CMD 0x0103
+#define ETP_I2C_XY_TRACENUM_CMD0x0105
+#define ETP_I2C_MAX_X_AXIS_CMD 0x0106
+#define ETP_I2C_MAX_Y_AXIS_CMD 0x0107
+#define ETP_I2C_RESOLUTION_CMD 0x0108
+#define ETP_I2C_IAP_VERSION_CMD0x0110
+#define ETP_I2C_SET_CMD0x0300
+#define ETP_I2C_MAX_BASELINE_CMD   0x0306
+#define ETP_I2C_MIN_BASELINE_CMD   0x0307
+#define ETP_I2C_FW_CHECKSUM_CMD0x030F
+#define ETP_I2C_IAP_CTRL_CMD   0x0310
+#define ETP_I2C_IAP_CMD0x0311
+#define ETP_I2C_IAP_RESET_CMD  0x0314
+#define ETP_I2C_IAP_CHECKSUM_CMD   0x0315
+#define ETP_I2C_CALIBRATE_CMD  0x0316
+#define ETP_I2C_REPORT_LEN 34
+#define ETP_I2C_FINGER_DATA_OFFSET 4
+#define ETP_I2C_REPORT_ID_OFFSET   2
+#define ETP_I2C_DESC_LENGTH30
+#define ETP_I2C_REPORT_DESC_LENGTH 158
+
+/* IAP F/W updater */
+#define ETP_FW_NAMEelan_i2c.bin
+#define ETP_FW_IAP_REG_L   0x01
+#define ETP_FW_IAP_REG_H   0x06
+#define ETP_IAP_VERSION_ADDR   0x0082
+#define ETP_IAP_START_ADDR 0x0083
+#define