Skip to contentSkip to conversation

Input: wm97xx: add BTN_TOUCH event to wm97xx to use it with Android

PATCH RESEND In review Mike Rapoport 2 participants 6 messages Mar 2, 2009 – Mar 3, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 Input: wm97xx: add BTN_TOUCH event to wm97xx to use it with Android

Android expects BTN_TOUCH events when pen state changes. Add BTN_TOUCH event reporting to allow use of wm97xx touchscreen controller with Android devices.

---
 drivers/input/touchscreen/wm97xx-core.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/input/touchscreen/wm97xx-core.c +4 -0
index d15aa11..4551f88 100644
@@ -409,6 +409,7 @@ static int wm97xx_read_samples(struct wm97xx *wm)
 			wm->pen_is_down = 0;
 			dev_dbg(wm->dev, "pen up\n");
 			input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
+			input_report_key(wm->input_dev, BTN_TOUCH, 0);
 			input_sync(wm->input_dev);
 		} else if (!(rc & RC_AGAIN)) {
 			/* We need high frequency updates only while
@@ -433,6 +434,7 @@ static int wm97xx_read_samples(struct wm97xx *wm)
 		input_report_abs(wm->input_dev, ABS_X, data.x & 0xfff);
 		input_report_abs(wm->input_dev, ABS_Y, data.y & 0xfff);
 		input_report_abs(wm->input_dev, ABS_PRESSURE, data.p & 0xfff);
+		input_report_key(wm->input_dev, BTN_TOUCH, 1);
 		input_sync(wm->input_dev);
 		wm->pen_is_down = 1;
 		wm->ts_reader_interval = wm->ts_reader_min_interval;
@@ -629,9 +631,11 @@ static int wm97xx_probe(struct device *dev)
 	wm->input_dev->open = wm97xx_ts_input_open;
 	wm->input_dev->close = wm97xx_ts_input_close;
 	set_bit(EV_ABS, wm->input_dev->evbit);
+	set_bit(EV_KEY, wm->input_dev->evbit);
 	set_bit(ABS_X, wm->input_dev->absbit);
 	set_bit(ABS_Y, wm->input_dev->absbit);
 	set_bit(ABS_PRESSURE, wm->input_dev->absbit);
+	set_bit(BTN_TOUCH, wm->input_dev->keybit);
 	input_set_abs_params(wm->input_dev, ABS_X, abs_x[0], abs_x[1],
 			     abs_x[2], 0);
 	input_set_abs_params(wm->input_dev, ABS_Y, abs_y[0], abs_y[1],
Signature · 6 lines
1.5.6.4


-- 
Sincerely yours,
Mike.
#1 lore raw
Quoted 6 lines · Mike Rapoport

Android expects BTN_TOUCH events when pen state changes. Add BTN_TOUCH event reporting to allow use of wm97xx touchscreen controller with Android devices.

I'd still like to see more consistency over touchscreen drivers on this one, BTW - if we're doing this it should be done for all touchscreen drivers (either by updating the individual drivers or having the input core do it). This isn't the only touchscreen driver that doesn't do BTN_TOUCH.

#2 lore raw

Mark,

Quoted 5 lines · Mark Brown
Quoted 3 lines · Mike Rapoport

Android expects BTN_TOUCH events when pen state changes. Add BTN_TOUCH event reporting to allow use of wm97xx touchscreen controller with Android devices.

Quoted 8 lines
Quoted 2 lines

I'd still like to see more consistency over touchscreen drivers on this one, BTW - if we're doing this it should be done for all touchscreen drivers (either by updating the individual drivers or having the input core do it). This isn't the only touchscreen driver that doesn't do BTN_TOUCH.

Most touchscreen drivers already have BTN_TOUCH event generation:

Quoted 1 line

git-grep -L BTN_TOUCH v2.6.29-rc6 drivers/input/touchscreen/

v2.6.29-rc6:drivers/input/touchscreen/Kconfig v2.6.29-rc6:drivers/input/touchscreen/Makefile v2.6.29-rc6:drivers/input/touchscreen/mainstone-wm97xx.c v2.6.29-rc6:drivers/input/touchscreen/ucb1400_ts.c v2.6.29-rc6:drivers/input/touchscreen/wm9705.c v2.6.29-rc6:drivers/input/touchscreen/wm9712.c v2.6.29-rc6:drivers/input/touchscreen/wm9713.c v2.6.29-rc6:drivers/input/touchscreen/wm97xx-core.c

If there no objection I can make a similar patch for mainstone-wm97xx.c and ucb1400_ts.c

Quoted 6 lines

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

Signature · 2 lines
Sincerely yours,
Mike.
#3 lore raw
Quoted 1 line · Mike Rapoport

Most touchscreen drivers already have BTN_TOUCH event generation:

Hrm, I'd found some other hits but I could well have been working on a platform tree with additional drivers merged at the time.

Quoted 1 line

If there no objection I can make a similar patch for mainstone-wm97xx.c and ucb1400_ts.c

No problem for me. Please see the other two accelerated WM97xx drivers I posted today too.

#4 lore raw

PATCH 1/1 Input: add BTN_TOUCH event (Was: [PATCH RESEND] Input: wm97xx: add BTN_TOUCH event to wm97xx)

Quoted 8 lines · Mark Brown
Quoted 1 line · Mike Rapoport

Most touchscreen drivers already have BTN_TOUCH event generation:

Hrm, I'd found some other hits but I could well have been working on a platform tree with additional drivers merged at the time.

Quoted 1 line

If there no objection I can make a similar patch for mainstone-wm97xx.c and ucb1400_ts.c

Add BTN_TOUCH event reporting to ucb1400_ts and accelerated mainstone-wm97xx touchscreen drivers. Together with previously posted similar patch for wm97xx-core this will make all touchscreen drivers behave consistently wrt. BTN_TOUCH.

 drivers/input/touchscreen/mainstone-wm97xx.c |    1 +
 drivers/input/touchscreen/ucb1400_ts.c       |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletions(-)
drivers/input/touchscreen/mainstone-wm97xx.c +1 -0
index 1d11e2b..4d49690 100644
@@ -162,6 +162,7 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm)
 		input_report_abs(wm->input_dev, ABS_X, x & 0xfff);
 		input_report_abs(wm->input_dev, ABS_Y, y & 0xfff);
 		input_report_abs(wm->input_dev, ABS_PRESSURE, p & 0xfff);
+		input_report_key(wm->input_dev, BTN_TOUCH, (p != 0));
 		input_sync(wm->input_dev);
 		reads++;
 	} while (reads < cinfo[sp_idx].reads);
drivers/input/touchscreen/ucb1400_ts.c +4 -1
index 5498662..e868264 100644
@@ -151,12 +151,14 @@ static void ucb1400_ts_evt_add(struct input_dev *idev, u16 pressure, u16 x, u16
 	input_report_abs(idev, ABS_X, x);
 	input_report_abs(idev, ABS_Y, y);
 	input_report_abs(idev, ABS_PRESSURE, pressure);
+	input_report_key(idev, BTN_TOUCH, 1);
 	input_sync(idev);
 }
 
 static void ucb1400_ts_event_release(struct input_dev *idev)
 {
 	input_report_abs(idev, ABS_PRESSURE, 0);
+	input_report_key(idev, BTN_TOUCH, 0);
 	input_sync(idev);
 }
 
@@ -377,7 +379,8 @@ static int ucb1400_ts_probe(struct platform_device *dev)
 	ucb->ts_idev->id.product	= ucb->id;
 	ucb->ts_idev->open		= ucb1400_ts_open;
 	ucb->ts_idev->close		= ucb1400_ts_close;
-	ucb->ts_idev->evbit[0]		= BIT_MASK(EV_ABS);
+	ucb->ts_idev->evbit[0]		= BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY);
+	ucb->ts_idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
 
 	ucb1400_adc_enable(ucb->ac97);
 	x_res = ucb1400_ts_read_xres(ucb);
Signature · 2 lines
Sincerely yours,
Mike.
#5 lore raw
In reply to Mark Brown

Mark,

Quoted 11 lines · Mark Brown
Quoted 1 line · Mike Rapoport

Most touchscreen drivers already have BTN_TOUCH event generation:

Hrm, I'd found some other hits but I could well have been working on a platform tree with additional drivers merged at the time.

Quoted 1 line

If there no objection I can make a similar patch for mainstone-wm97xx.c and ucb1400_ts.c

No problem for me. Please see the other two accelerated WM97xx drivers I posted today too.

The below patch adds BTN_TOUCH event reporting for two accelerated drivers you've posted yesterday [1] and [2]. This patch is incremental vs. the first spin.

[1] http://lkml.org/lkml/2009/3/2/49
[2] http://lkml.org/lkml/2009/3/2/50

 drivers/input/touchscreen/at32-wm97xx.c     |    6 ++++++
 drivers/input/touchscreen/zylonite-wm97xx.c |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)
drivers/input/touchscreen/at32-wm97xx.c +6 -0
index 96eeb2d..e34edcd 100644
@@ -145,11 +145,15 @@ static irqreturn_t at32_wm97xx_channel_b_interrupt(int irq, void *dev_id)
 			input_report_abs(wm->input_dev, ABS_X, at32_wm97xx->x);
 			input_report_abs(wm->input_dev, ABS_Y, at32_wm97xx->y);
 			input_report_abs(wm->input_dev, ABS_PRESSURE, pen_down);
+			input_report_key(wm->input_dev, BTN_TOUCH,
+					 (pen_down != 0));
 			input_sync(wm->input_dev);
 		} else if (pressure && source == WM97XX_ADCSEL_PRES) {
 			input_report_abs(wm->input_dev, ABS_X, at32_wm97xx->x);
 			input_report_abs(wm->input_dev, ABS_Y, at32_wm97xx->y);
 			input_report_abs(wm->input_dev, ABS_PRESSURE, value);
+			input_report_key(wm->input_dev, BTN_TOUCH,
+					 (value != 0));
 			input_sync(wm->input_dev);
 		}
 
@@ -170,6 +174,7 @@ static void at32_wm97xx_pen_timer(unsigned long data)
 				+ msecs_to_jiffies(1));
 	} else {
 		input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
+		input_report_key(wm->input_dev, BTN_TOUCH, 0);
 		input_sync(wm->input_dev);
 	}
 }
@@ -184,6 +189,7 @@ static void at32_wm97xx_acc_pen_up(struct wm97xx *wm)
 				+ msecs_to_jiffies(1));
 	} else {
 		input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
+		input_report_key(wm->input_dev, BTN_TOUCH, 0);
 		input_sync(wm->input_dev);
 	}
 }
drivers/input/touchscreen/zylonite-wm97xx.c +1 -0
index b016021..609c23c 100644
@@ -130,6 +130,7 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm)
 		input_report_abs(wm->input_dev, ABS_X, x & 0xfff);
 		input_report_abs(wm->input_dev, ABS_Y, y & 0xfff);
 		input_report_abs(wm->input_dev, ABS_PRESSURE, p & 0xfff);
+		input_report_key(wm->input_dev, BTN_TOUCH, (p != 0));
 		input_sync(wm->input_dev);
 		reads++;
 	} while (reads < cinfo[sp_idx].reads);
Signature · 2 lines
Sincerely yours,
Mike.