[patch v2 1/1] HID:hid-multitouch: Add ELAN prouction request when resume

2012-08-09 Thread Scott Liu
Some of ELAN's production need to with set_idle commmand when reusme.

Signed-off-by: Scott Liu 
---
 drivers/hid/hid-ids.h|3 +++
 drivers/hid/hid-multitouch.c |   20 
 2 files changed, 23 insertions(+)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 41c34f2..a4d810c 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -829,4 +829,7 @@
 #define USB_VENDOR_ID_PRIMAX   0x0461
 #define USB_DEVICE_ID_PRIMAX_KEYBOARD  0x4e05
 
+#define USB_VENDOR_ID_ELAN  0x04f3
+#define USB_DEVICE_ID_ELAN_MOCCA0x000a
+
 #endif
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 59c8b5c..b06b7d3 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -767,6 +767,25 @@ static int mt_reset_resume(struct hid_device *hdev)
mt_set_input_mode(hdev);
return 0;
 }
+
+static int mt_resume(struct hid_device *hdev)
+{
+   if (hdev->vendor == USB_VENDOR_ID_ELAN &&
+   hdev->product == USB_DEVICE_ID_ELAN_MOCCA) {
+
+   struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
+   struct usb_host_interface *interface = intf->cur_altsetting;
+   struct usb_device *dev = hid_to_usb_dev(hdev);
+
+   usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+   HID_REQ_SET_IDLE, 
USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+   0, 
interface->desc.bInterfaceNumber,
+   NULL, 0, USB_CTRL_SET_TIMEOUT);
+}
+
+return 0;
+}
+
 #endif
 
 static void mt_remove(struct hid_device *hdev)
@@ -1092,6 +,7 @@ static struct hid_driver mt_driver = {
.event = mt_event,
 #ifdef CONFIG_PM
.reset_resume = mt_reset_resume,
+   .resume = mt_resume,
 #endif
 };
 
-- 
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 v3 1/1] HID:hid-multitouch: Add ELAN production request when resume.

2012-08-13 Thread Scott Liu
Add ELAN production request when resume

Signed-off-by: Scott Liu 
Suggested-off-by: Benjamin Tissoires 
---
 drivers/hid/hid-multitouch.c |   27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 59c8b5c..e824c37 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -767,6 +767,32 @@ static int mt_reset_resume(struct hid_device *hdev)
mt_set_input_mode(hdev);
return 0;
 }
+
+static int mt_resume(struct hid_device *hdev)
+{
+   struct usb_interface *intf;
+   struct usb_host_interface *interface;
+   struct usb_device *dev;
+
+   if (hdev->bus != BUS_USB)
+   return 0;
+
+   intf = to_usb_interface(hdev->dev.parent);
+   interface = intf->cur_altsetting;
+   dev = hid_to_usb_dev(hdev);
+
+   /* Some Elan legacy devices require SET_IDLE to be set on resume.
+* It should be safe to send it to other devices too.
+* Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. */
+
+   usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+   HID_REQ_SET_IDLE,
+   USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+   0, interface->desc.bInterfaceNumber,
+   NULL, 0, USB_CTRL_SET_TIMEOUT);
+
+   return 0;
+}
 #endif
 
 static void mt_remove(struct hid_device *hdev)
@@ -1092,6 +1118,7 @@ static struct hid_driver mt_driver = {
.event = mt_event,
 #ifdef CONFIG_PM
.reset_resume = mt_reset_resume,
+   .resume = mt_resume,
 #endif
 };
 
-- 
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 v4 1/1] HID:hid-multitouch: Add ELAN production request when resume.

2012-08-15 Thread Scott Liu
Add ELAN production request when resume.

Some Elan legacy devices require SET_IDLE to be set on resume.
It should be safe to send it to other devices too.
Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. 


Signed-off-by: Scott Liu 
Suggested-off-by: Benjamin Tissoires 
---
 drivers/hid/hid-multitouch.c |   27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 59c8b5c..e824c37 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -767,6 +767,32 @@ static int mt_reset_resume(struct hid_device *hdev)
mt_set_input_mode(hdev);
return 0;
 }
+
+static int mt_resume(struct hid_device *hdev)
+{
+   struct usb_interface *intf;
+   struct usb_host_interface *interface;
+   struct usb_device *dev;
+
+   if (hdev->bus != BUS_USB)
+   return 0;
+
+   intf = to_usb_interface(hdev->dev.parent);
+   interface = intf->cur_altsetting;
+   dev = hid_to_usb_dev(hdev);
+
+   /* Some Elan legacy devices require SET_IDLE to be set on resume.
+* It should be safe to send it to other devices too.
+* Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. */
+
+   usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+   HID_REQ_SET_IDLE,
+   USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+   0, interface->desc.bInterfaceNumber,
+   NULL, 0, USB_CTRL_SET_TIMEOUT);
+
+   return 0;
+}
 #endif
 
 static void mt_remove(struct hid_device *hdev)
@@ -1092,6 +1118,7 @@ static struct hid_driver mt_driver = {
.event = mt_event,
 #ifdef CONFIG_PM
.reset_resume = mt_reset_resume,
+   .resume = mt_resume,
 #endif
 };
 
-- 
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] hid:hid-multitouch: add mt_resume for ELAN's production

2012-08-07 Thread Scott Liu
Some of ELAN’s production need to issue set_idle when resume.

Signed-off-by: Scott Liu 
---
 drivers/hid/hid-ids.h|3 +++
 drivers/hid/hid-multitouch.c |   26 ++
 2 files changed, 29 insertions(+)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 41c34f2..703aaed 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -829,4 +829,7 @@
 #define USB_VENDOR_ID_PRIMAX   0x0461
 #define USB_DEVICE_ID_PRIMAX_KEYBOARD  0x4e05
 
+#define USB_VENDOR_ID_ELAN 0x04f3
+#define USB_DEVICE_ID_ELAN_MOCCA   0x000a
+
 #endif
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 59c8b5c..a086a16 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -767,6 +767,31 @@ static int mt_reset_resume(struct hid_device *hdev)
mt_set_input_mode(hdev);
return 0;
 }
+
+static int mt_resume(struct hid_device *hdev)
+{
+   struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
+   struct usb_host_interface *interface = intf->cur_altsetting;
+
+   struct usb_device *dev = hid_to_usb_dev(hdev);
+
+   if (hdev->vendor == USB_VENDOR_ID_ELAN && 
+   hdev->product == USB_DEVICE_ID_ELAN_MOCCA) {
+
+   usb_control_msg(dev, 
+   usb_sndctrlpipe(dev, 0),

+   HID_REQ_SET_IDLE, 
+   USB_TYPE_CLASS | 
USB_RECIP_INTERFACE, 
+   0,
+   interface->desc.bInterfaceNumber, 
+   NULL, 
+   0, 
+   USB_CTRL_SET_TIMEOUT);
+   }
+
+   return 0;
+}
+
 #endif
 
 static void mt_remove(struct hid_device *hdev)
@@ -1092,6 +1117,7 @@ static struct hid_driver mt_driver = {
.event = mt_event,
 #ifdef CONFIG_PM
.reset_resume = mt_reset_resume,
+   .resume=mt_resume,
 #endif
 };
 
-- 
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 v3] Support Elan Touchscreen eKTF product.

2012-10-29 Thread Scott Liu
This patch is for Elan eKTF Touchscreen product, I2C adpater module.

Signed-off-by: Scott Liu 
---
Hi Dmitry,
v3 chagnes:
* remove elants_prove() thread.
* follow standard kernel-doc.
* sysfs only for device information.
* add ioctl function handled by user.

Thanks.

 drivers/input/touchscreen/Kconfig  |9 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/elants_i2c.c | 2265 
 include/linux/i2c/elants.h |   58 +
 4 files changed, 2333 insertions(+)
 create mode 100644 drivers/input/touchscreen/elants_i2c.c
 create mode 100644 include/linux/i2c/elants.h

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 1ba232c..50e6f05 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -237,6 +237,15 @@ config TOUCHSCREEN_EETI
  To compile this driver as a module, choose M here: the
  module will be called eeti_ts.
 
+config TOUCHSCREEN_ELAN
+ tristate "Elan touchscreen panel support"
+ depends on I2C
+ help
+   Say Y here to enable support for I2C connected Elan touch panels.
+
+   To compile this driver as a module, choose M here: the
+   module will be called elants_i2c.
+
 config TOUCHSCREEN_EGALAX
tristate "EETI eGalax multi-touch panel support"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 178eb12..428a631 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_TOUCHSCREEN_EDT_FT5X06)  += edt-ft5x06.o
 obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE)+= hampshire.o
 obj-$(CONFIG_TOUCHSCREEN_GUNZE)+= gunze.o
 obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o
+obj-$(CONFIG_TOUCHSCREEN_ELAN) += elants_i2c.o
 obj-$(CONFIG_TOUCHSCREEN_ELO)  += elo.o
 obj-$(CONFIG_TOUCHSCREEN_EGALAX)   += egalax_ts.o
 obj-$(CONFIG_TOUCHSCREEN_FUJITSU)  += fujitsu_ts.o
diff --git a/drivers/input/touchscreen/elants_i2c.c 
b/drivers/input/touchscreen/elants_i2c.c
new file mode 100644
index 000..996b7df
--- /dev/null
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -0,0 +1,2265 @@
+/*
+ * Elan Microelectronics touchpanels with I2C interface
+ *
+ * Copyright (C) 2012 Elan Microelectronics Corporation.
+ * Scott Liu 
+ *
+ * This code is partly based on hid-multitouch.c:
+ *
+ *  Copyright (c) 2010-2012 Stephane Chatty 
+ *  Copyright (c) 2010-2012 Benjamin Tissoires 
+ *  Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France
+ *
+ */
+
+/*
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+/* debug option */
+static bool debug = false;
+module_param(debug, bool, 0444);
+MODULE_PARM_DESC(debug, "print a lot of debug information");
+
+#define elan_dbg(client, fmt, arg...)   \
+   if (debug)  \
+   dev_printk(KERN_DEBUG, &client->dev, fmt, ##arg)
+
+/*
+ * Device, Driver information
+ */
+
+#define DRV_NAME"elants_i2c"
+
+#define DRV_MA_VER 2
+#define DRV_MI_VER 0
+#define DRV_SUB_MI_VER 0
+
+#define _str(s) #s
+#define str(s)  _str(s)
+#define DRIVER_VERSION  str(DRV_MA_VER.DRV_MI_VER.DRV_SUB_MI_VER)
+
+/*
+ * Finger report description
+ */
+
+#define MAX_CONTACT_NUM10
+
+/*
+ *FW Power Saving Mode
+ */
+
+#define PWR_STATE_DEEP_SLEEP   0
+#define PWR_STATE_NORMAL1
+#define PWR_STATE_MASK  BIT(3)
+
+/*
+ * kfifo buffer size, used for Read command handshake
+ */
+
+#define FIFO_SIZE   (64)
+
+/*
+ *Convert from rows or columns into resolution
+ */
+
+#define ELAN_TS_RESOLUTION(n)   ((n - 1) * 64)
+
+static const char hello_packet[4] = { 0x55, 0x55, 0x55, 0x55 };
+static const char iniap_packet[4] = { 0x55, 0xaa, 0x33, 0xcc };
+static const char recov_packet[4] = { 0x55, 0x55, 0x80, 0x80 };
+
+
+/* driver status flag */
+#define STA_NONINIT 0x0001
+#define STA_INIT0x0002
+#define STA_INIT2   0x0004
+#define STA_INIT3   0x0100
+#define STA_INIT4   0x0200
+#define STA_PROBED  0x0008
+#define STA_ERR_HELLO_PKT   0x0010
+#define STA_USE_IRQ 0x0020
+#defineSTA_SLEEP_MODE  0x0040
+
+/*
+ * Elan I2C Address definition
+ */
+
+#defineDEV_MASTER  0x10
+#defineDEV_SLAVE1  0x20
+#defineDEV_SLAVE2  0x21
+#defineMAX_DEVICE  3
+
+/*
+ *