Fixed Tab 7 Plus melfas touchscreen on Android 4.0 ICS

A few weeks ago I started working on a port of CyanogenMod 9 (Android 4.0) for the Galaxy Tab 7 Plus (GT-P6200). It took quite a while to get the device tree up and running, and then when I finally got it to boot, the touch screen was a pain in the ass to use. As it turns out, Android 4.0 requires updated touch screen drivers, which explains why everyone porting Ice Cream Sandwich using pre-ICS kernel sources has to walk this road.

After a few hours of staring at Linux kernel code, reading documentation, and cross referencing fixes for other touch screen drivers, I finally figured out what to do. It’s all in this commit, diff here:

diff --git a/drivers/input/touchscreen/melfas_ts.c b/drivers/input/touchscreen/melfas_ts.c
index 2bb5b95..3b6e9c1 100755
--- a/drivers/input/touchscreen/melfas_ts.c
+++ b/drivers/input/touchscreen/melfas_ts.c
@@ -144,7 +144,8 @@
 	input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x);             \
 	input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y);             \
 	input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, amplitude);         \
-	input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, width); \
+	input_report_abs(ts->input_dev, ABS_MT_PRESSURE, amplitude); \
+	input_report_key(ts->input_dev, BTN_TOUCH, 1); \
 	input_mt_sync(ts->input_dev);                                      \
 } while (0)
 
@@ -2100,7 +2101,7 @@ static int melfas_ts_probe(struct i2c_client *client, const struct i2c_device_id
 	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, TS_MAX_Y_COORD, 0, 0);
 	input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, TS_MAX_Z_TOUCH, 0, 0);
 	input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, MELFAS_MAX_TOUCH - 1, 0, 0);
-	input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, TS_MAX_W_TOUCH, 0, 0);
+	input_set_abs_params(ts->input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0);
 
 //	__set_bit(EV_SYN, ts->input_dev->evbit);
 //	__set_bit(EV_KEY, ts->input_dev->evbit);

Basically, Ice Cream Sandwich expects ABS_MT_PRESSURE data and BTN_TOUCH events to be sent from the touch screen driver. Without a properly-patched driver, you have to do funny things to get touch events to work (like using two fingers and mashing icons repeatedly on the screen). Very annoying!

Now that we’re back in business… here’s a picture to prove that it’s up:

Great progress, but still a lot more to do! btw, technically I got ICS on this device before Samsung ;). w00t.

2 thoughts on “Fixed Tab 7 Plus melfas touchscreen on Android 4.0 ICS

  1. you sir are genius, and you are my hero!

    Really, great work. We appreciate your efforts.

    That being said what are the next kinks to iron out?

    a lot of Force Closes, etc? can we get a list of working/not working?

    I may have to build this soon. I still have to set up my dual boot and enviornment on my new CPU. Have honestly been busy.

    1. No force closes… it runs really well actually, buttery smooth! I will put up a post on XDA soon. Off the top of my head, accelerometers and hardware acceleration on the UI are working… wifi, audio, and telephony aren’t working.

Comments are closed.