ilitek touch-screen Driver

4,081 views
Skip to first unread message

天秤惡魔

unread,
Aug 7, 2011, 10:43:40 AM8/7/11
to Android-x86
This driver works fine on Intel OakTrail Android-x86 2.3.

Add
kernel/arch/x86/configs
CONFIG_HID_ILITEK=y

Put hid-ilitek.c in /kernel/drivers/hid sorce code as fellow.

Add
obj-$(CONFIG_HID_ILITEK) += hid-ilitek.o
in /kernel/drivers/hid/Makefile

Add
config HID_ILITEK
tristate "ILITEK2105 dual touch panel"
depends on USB_HID
---help---
Support for ILITEK 2105 dual touch panel.
in /kernel/drivers/hid/Kconfig

/*
* This program is free software; you can redistribute it and/or
modify it
* under the terms of the GNU General Public License as published by
the Free
* Software Foundation; either version 2 of the License, or (at your
option)
* any later version.
*/

hid-ilitek.c

#include <linux/device.h>
#include <linux/hid.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/proc_fs.h>
#include <linux/usb.h>
#include "usbhid/usbhid.h"
#include "hid-ids.h"

MODULE_DESCRIPTION("ILITEK dual-touch panel driver");
MODULE_LICENSE("GPL");

struct ilitek_data {
__u16 x, y, z;
__u8 id;
__s8 oldest; /* id of the oldest finger in previous
frame */
bool valid; /* valid finger data, or just
placeholder? */
bool first; /* is this the first finger in this
frame? */
__s8 firstid; /* id of the first finger in the frame
*/
__u16 firstx, firsty; /* (x, y) of the first finger in the
frame */
};

static int ilitek_input_mapping(struct hid_device *hdev, struct
hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
switch (usage->hid & HID_USAGE_PAGE) {

case HID_UP_GENDESK:
switch (usage->hid) {
case HID_GD_X:
hid_map_usage(hi, usage, bit, max,
EV_ABS, ABS_MT_POSITION_X);
input_set_abs_params(hi->input,
ABS_MT_POSITION_X,
field-
>logical_minimum,
field-
>logical_maximum, 0, 0);
/* touchscreen emulation */
input_set_abs_params(hi->input, ABS_X,
field-
>logical_minimum,
field-
>logical_maximum, 0, 0);
return 1;
case HID_GD_Y:
hid_map_usage(hi, usage, bit, max,
EV_ABS, ABS_MT_POSITION_Y);
input_set_abs_params(hi->input,
ABS_MT_POSITION_Y,
field-
>logical_minimum,
field-
>logical_maximum, 0, 0);
/* touchscreen emulation */
input_set_abs_params(hi->input, ABS_Y,
field-
>logical_minimum,
field-
>logical_maximum, 0, 0);
return 1;
}
return 0;

case HID_UP_DIGITIZER:
switch (usage->hid) {
case HID_DG_TIPSWITCH:
/* touchscreen emulation */
hid_map_usage(hi, usage, bit, max, EV_KEY,
BTN_TOUCH);
input_set_capability(hi->input, EV_KEY,
BTN_TOUCH);
return 1;
case HID_DG_INRANGE:
case HID_DG_CONFIDENCE:
case HID_DG_CONTACTMAX:
case HID_DG_CONTACTCOUNT:
return -1;
case HID_DG_CONTACTID:
hid_map_usage(hi, usage, bit, max,
EV_ABS, ABS_MT_TRACKING_ID);
return 1;
case HID_DG_TIPPRESSURE:
hid_map_usage(hi, usage, bit, max,
EV_ABS, ABS_MT_PRESSURE);
input_set_abs_params(hi->input,
ABS_MT_PRESSURE,
field-
>logical_minimum,
field-
>logical_maximum, 0, 0);
/* touchscreen emulation */
input_set_abs_params(hi->input, ABS_PRESSURE,
field-
>logical_minimum,
field-
>logical_maximum, 0, 0);
return 1;
}
return 0;
}

return 0;
}

static int ilitek_input_mapped(struct hid_device *hdev, struct
hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
if (usage->type == EV_KEY || usage->type == EV_ABS)
clear_bit(usage->code, *bit);

return 0;
}

/*
* this function is called when a whole finger has been parsed,
* so that it can decide what to send to the input layer.
*/
static void ilitek_filter_event(struct ilitek_data *td,
struct input_dev *input)
{
td->first = !td->first; /* touchscreen emulation */

if (!td->valid) {
/*
* touchscreen emulation: if this is the second finger
and
* the first was valid, the first was the oldest; if
the
* first was not valid and there was a valid finger in
the
* previous frame, this is a release.
*/
if (td->first) {
td->firstid = -1;
} else if (td->firstid >= 0) {
input_event(input, EV_ABS, ABS_X, td->firstx);
input_event(input, EV_ABS, ABS_Y, td->firsty);
input_event(input, EV_ABS, ABS_PRESSURE, td-
>z);
td->oldest = td->firstid;
} else if (td->oldest >= 0) {
input_event(input, EV_KEY, BTN_TOUCH, 0);
td->oldest = -1;
}

return;
}

input_event(input, EV_ABS, ABS_MT_TRACKING_ID, td->id);
input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x);
input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y);
input_event(input, EV_ABS, ABS_MT_PRESSURE, td->z);

input_mt_sync(input);

/*
* touchscreen emulation: if there was no touching finger
previously,
* emit touch event
*/
if (td->oldest < 0) {
input_event(input, EV_KEY, BTN_TOUCH, 1);
td->oldest = td->id;
}

/*
* touchscreen emulation: if this is the first finger, wait
for the
* second; the oldest is then the second if it was the oldest
already
* or if there was no first, the first otherwise.
*/
if (td->first) {
td->firstx = td->x;
td->firsty = td->y;
td->firstid = td->id;
} else {
int x, y, oldest;
if (td->id == td->oldest || td->firstid < 0) {
x = td->x;
y = td->y;
oldest = td->id;
} else {
x = td->firstx;
y = td->firsty;
oldest = td->firstid;
}
input_event(input, EV_ABS, ABS_X, x);
input_event(input, EV_ABS, ABS_Y, y);
td->oldest = oldest;
}
}

static int ilitek_event(struct hid_device *hid, struct hid_field
*field,
struct hid_usage *usage, __s32 value)
{
struct ilitek_data *sd = hid_get_drvdata(hid);

if (hid->claimed & HID_CLAIMED_INPUT) {
struct input_dev *input = field->hidinput->input;

switch (usage->hid) {
case HID_DG_INRANGE:
break;
case HID_GD_X:
sd->x = value;
break;
case HID_GD_Y:
sd->y = value;
ilitek_filter_event(sd, input);
break;
case HID_DG_CONTACTID:
sd->id = value;
break;
case HID_DG_CONFIDENCE:
break;
case HID_DG_TIPSWITCH:
sd->valid = value;
break;
case HID_DG_TIPPRESSURE:
sd->z = value;
break;
default:
/* fallback to the generic hidinput handling
*/
return 0;
}
}

/* we have handled the hidinput part, now remains hiddev */
if (hid->claimed & HID_CLAIMED_HIDDEV && hid-
>hiddev_hid_event)
hid->hiddev_hid_event(hid, field, usage, value);

return 1;
}

static int ilitek_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
int ret;
struct ilitek_data *sd;
struct hid_report *report;

sd = kmalloc(sizeof(struct ilitek_data), GFP_KERNEL);
if (!sd) {
dev_err(&hdev->dev, "cannot allocate Stantum data\n");
return -ENOMEM;
}

hid_set_drvdata(hdev, sd);
sd->first = false;
sd->oldest = -1;
sd->valid = false;

ret = hid_parse(hdev);
if (!ret)
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);

report= hdev-
>report_enum[HID_FEATURE_REPORT].report_id_hash[5];
if(report){
report->field[0]->value[0]=2;
usbhid_submit_report(hdev,report,USB_DIR_OUT);
}

if (ret)
kfree(sd);

return ret;
}

static void ilitek_remove(struct hid_device *hdev)
{
hid_hw_stop(hdev);
kfree(hid_get_drvdata(hdev));
hid_set_drvdata(hdev, NULL);
}

static const struct hid_device_id ilitek_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_ILITEK,
USB_DEVICE_ID_ILITEK_MT) },
{ }
};
MODULE_DEVICE_TABLE(hid, ilitek_devices);

static const struct hid_usage_id ilitek_grabbed_usages[] = {
{ HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
{ HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
};

static struct hid_driver ilitek_driver = {
.name = "ilitek",
.id_table = ilitek_devices,
.probe = ilitek_probe,
.remove = ilitek_remove,
.input_mapping = ilitek_input_mapping,
.input_mapped = ilitek_input_mapped,
.usage_table = ilitek_grabbed_usages,
.event = ilitek_event,
};

static int __init ilitek_init(void)
{
return hid_register_driver(&ilitek_driver);
}

static void __exit ilitek_exit(void)
{
hid_unregister_driver(&ilitek_driver);
}

module_init(ilitek_init);
module_exit(ilitek_exit);


Chih-Wei Huang

unread,
Aug 7, 2011, 11:33:01 AM8/7/11
to andro...@googlegroups.com
Thanks. Actually ILITEK is already supported by
the hid-multitouch driver in the android-2.6.38/39 branch.

在 2011年8月7日下午10:43,天秤惡魔 <love...@gmail.com> 寫道:
> This driver works fine on Intel OakTrail Android-x86 2.3.
>
> Add
> kernel/arch/x86/configs
> CONFIG_HID_ILITEK=y


--
Chih-Wei
Android-x86 project
http://www.android-x86.org

John Kang

unread,
Aug 7, 2011, 9:22:04 PM8/7/11
to andro...@googlegroups.com
OK,Thanks.
How about MRST? The intel GMA Driver?

Thanks and Best Regards,
John Kang.

> --
> You received this message because you are subscribed to the Google Groups "Android-x86" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-x86...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-x86?hl=en.
>
>

Chih-Wei Huang

unread,
Aug 7, 2011, 10:53:21 PM8/7/11
to andro...@googlegroups.com
在 2011年8月8日上午9:22,John Kang <love...@gmail.com> 寫道:
> OK,Thanks.
> How about MRST? The intel GMA Driver?

No, we don't have that.
Welcome to contribute it.

John Kang

unread,
Aug 7, 2011, 11:28:21 PM8/7/11
to andro...@googlegroups.com
OK,
But, it is huge.
kernel-adaptation-oaktrail-2.6.37.6-11.1
Maybe the hyperlink is better.

http://download.meego.com/live/MeeGo:/1.2.0:/oss/standard/src/kernel-adaptation-oaktrail-2.6.37.6-11.1.src.rpm

There are
linux-2.6.37-gma600.patch
...
13 files and linux-2.6.37-drm-forward-1.patch files.

Thanks and Best Regards,
John Kang.

Chih-Wei Huang

unread,
Aug 7, 2011, 11:49:00 PM8/7/11
to andro...@googlegroups.com
Thanks.
Have you tested and verified it work on
our kernel android-2.6.38 or 2.6.39?

在 2011年8月8日上午11:28,John Kang <love...@gmail.com> 寫道:
> OK,
> But, it is huge.
> kernel-adaptation-oaktrail-2.6.37.6-11.1
> Maybe the hyperlink is better.
>
> http://download.meego.com/live/MeeGo:/1.2.0:/oss/standard/src/kernel-adaptation-oaktrail-2.6.37.6-11.1.src.rpm
>
> There are
> linux-2.6.37-gma600.patch
> ...
> 13 files and linux-2.6.37-drm-forward-1.patch files.

--

John Kang

unread,
Aug 8, 2011, 1:46:59 AM8/8/11
to andro...@googlegroups.com
Not yet.
But, Still working on it.
BTW, Meego uses the same kernel as Android x86 2.3.
In the blog of Oaktrail Report, the gma600 driver works fine, but sensors.

Thanks and Best Regards,
John Kang.

Scott

unread,
Aug 11, 2011, 7:43:56 AM8/11/11
to Android-x86
Can this be applied to the Intel Atom processor? I have an exoPC and
am having touchscreen issues.

Thanks,
Scott

On Aug 8, 1:46 am, John Kang <lovelo...@gmail.com> wrote:
> Not yet.
> But, Still working on it.
> BTW, Meego uses the same kernel as Android x86 2.3.
> In the blog of Oaktrail Report, the gma600 driver works fine, but sensors.
>
> Thanks and Best Regards,
> John Kang.
>
> 在 2011年8月8日上午11:49,Chih-Wei Huang <cwhu...@android-x86.org> 寫道:
>
>
>
> > Thanks.
> > Have you tested and verified it work on
> > our kernel android-2.6.38 or 2.6.39?
>
> > 在 2011年8月8日上午11:28,John Kang <lovelo...@gmail.com> 寫道:
> >> OK,
> >> But, it is huge.
> >> kernel-adaptation-oaktrail-2.6.37.6-11.1
> >> Maybe the hyperlink is better.
>
> >>http://download.meego.com/live/MeeGo:/1.2.0:/oss/standard/src/kernel-...
>
> >> There are
> >> linux-2.6.37-gma600.patch
> >> ...
> >> 13 files and linux-2.6.37-drm-forward-1.patch files.
>
> > --
> > Chih-Wei
> > Android-x86 project
> >http://www.android-x86.org
>
> > --
> > You received this message because you are subscribed to the Google Groups "Android-x86" group.
> > To post to this group, send email to andro...@googlegroups.com.
> > To unsubscribe from this group, send email to android-x86...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/android-x86?hl=en.- Hide quoted text -
>
> - Show quoted text -

John Kang

unread,
Aug 11, 2011, 9:39:01 AM8/11/11
to andro...@googlegroups.com
Yes, but this driver should be base on previous version of android 2.3.
If you wish use this driver on the last edition of Android 2.3, there
are some thing has to be modified.
And this driver was tested on Intel Soluciton with ATOM CPU.

Thanks and Best Regards,
John Kang.

JezzaUK

unread,
Aug 15, 2011, 5:09:16 PM8/15/11
to Android-x86
could we have a separate build for wetab/exopc/lucid tablets?

damn cool machines and getting cheaper....

more than willing to test iso's

:-)

On Aug 11, 2:39 pm, John Kang <lovelo...@gmail.com> wrote:
> Yes, but this driver should be base on previous version of android 2.3.
> If you wish use this driver on the last edition of Android 2.3, there
> are some thing has to be modified.
> And this driver was tested on Intel Soluciton with ATOM CPU.
>
> Thanks and Best Regards,
> John Kang.
> >> > For more options, visit this group athttp://groups.google.com/group/android-x86?hl=en.-Hide quoted text -
Reply all
Reply to author
Forward
0 new messages