Skip to contentSkip to conversation

Input: Accelerated touchscreen support for Marvell Zylonite

PATCH In review Mark Brown 3 participants 10 messages Mar 2, 2009 – Mar 3, 2009

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/2 Input: Accelerated touchscreen support for Marvell Zylonite

This patch implements accelerated touchscreen support for the Marvell Zylonite development platform, supporting pen down interrupts and continuous mode data transfers.

---
 drivers/input/touchscreen/Kconfig           |   13 ++
 drivers/input/touchscreen/Makefile          |    1 +
 drivers/input/touchscreen/zylonite-wm97xx.c |  239 +++++++++++++++++++++++++++
 3 files changed, 253 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/touchscreen/zylonite-wm97xx.c
drivers/input/touchscreen/Kconfig +13 -0
index bb6486a..a31d434 100644
@@ -308,6 +308,19 @@ config TOUCHSCREEN_WM97XX_MAINSTONE
 	  To compile this driver as a module, choose M here: the
 	  module will be called mainstone-wm97xx.
 
+config TOUCHSCREEN_WM97XX_ZYLONITE
+	tristate "Zylonite accelerated touch"
+	depends on TOUCHSCREEN_WM97XX && MACH_ZYLONITE
+	select TOUCHSCREEN_WM9713
+	help
+	  Say Y here for support for streaming mode with the touchscreen
+	  on Zylonite systems.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called zylonite-wm97xx.
+
 config TOUCHSCREEN_USB_COMPOSITE
 	tristate "USB Touchscreen Driver"
 	depends on USB_ARCH_HAS_HCD
drivers/input/touchscreen/Makefile +1 -0
index d3375af..82dd918 100644
@@ -34,3 +34,4 @@ wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705)	+= wm9705.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712)	+= wm9712.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713)	+= wm9713.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)	+= mainstone-wm97xx.o
+obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)	+= zylonite-wm97xx.o
drivers/input/touchscreen/zylonite-wm97xx.c new file +239 -0

239 lines not on this page · raw message

Signature · 1 line
1.6.1.3
author
#1 lore raw

PATCH 2/2 Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors

From: Hans-Christian Egtvedt <[email protected]>

This patch adds an accelerated driver for Atmel AVR32 AT32AP700X microprocessors. It uses interrupts on the channel B in the AC97 controller. Thus, offloading the work queue in the wm97xx-ts driver.

The driver has been tested with Atmel AVR32 AT32AP7000 and Wolfson WM9712 codec.

---
 drivers/input/touchscreen/Kconfig       |   15 ++
 drivers/input/touchscreen/Makefile      |    1 +
 drivers/input/touchscreen/at32-wm97xx.c |  410 +++++++++++++++++++++++++++++++
 drivers/input/touchscreen/at32-wm97xx.h |   48 ++++
 4 files changed, 474 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/touchscreen/at32-wm97xx.c
 create mode 100644 drivers/input/touchscreen/at32-wm97xx.h
drivers/input/touchscreen/Kconfig +15 -0
index a31d434..d63fc2f 100644
@@ -296,6 +296,21 @@ config TOUCHSCREEN_WM9713
 	  Say Y here to enable support for the Wolfson Microelectronics
 	  WM9713 touchscreen controller.
 
+config TOUCHSCREEN_WM97XX_AT32
+	tristate "WM97xx Atmel AVR32 accelerated touch"
+	depends on TOUCHSCREEN_WM97XX && AVR32
+	help
+	  Say Y here for support for streaming mode with WM97xx touchscreens on
+	  Atmel AVR32 systems with an AC97 controller.
+
+	  Be aware that this will use channel B in the controller for streaming
+	  data, this must not conflict with other AC97 drivers.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the module will be
+	  called at32-wm97xx.
+
 config TOUCHSCREEN_WM97XX_MAINSTONE
 	tristate "WM97xx Mainstone accelerated touch"
 	depends on TOUCHSCREEN_WM97XX && ARCH_PXA
drivers/input/touchscreen/Makefile +1 -0
index 82dd918..29a0257 100644
@@ -33,5 +33,6 @@ obj-$(CONFIG_TOUCHSCREEN_DA9034)	+= da9034-ts.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705)	+= wm9705.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712)	+= wm9712.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713)	+= wm9713.o
+obj-$(CONFIG_TOUCHSCREEN_WM97XX_AT32)	+= at32-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)	+= mainstone-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)	+= zylonite-wm97xx.o
drivers/input/touchscreen/at32-wm97xx.c new file +410 -0

410 lines not on this page · raw message

drivers/input/touchscreen/at32-wm97xx.h new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
1.6.1.3
#2 lore raw

Re: [PATCH 2/2] Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors

drivers/input/touchscreen/at32-wm97xx.c line 162

Quoted 3 lines
drivers/input/touchscreen/at32-wm97xx.c new file +1 -0
+static void at32_wm97xx_pen_timer(unsigned long data)

Wouldn't be delayed_work more appropriate (and convenient) here?

Quoted 16 lines
drivers/input/touchscreen/at32-wm97xx.c new file +15 -0
+{
+	struct at32_wm97xx *at32_wm97xx = (struct at32_wm97xx *)data;
+	struct wm97xx *wm = at32_wm97xx->wm;
+	int pen_down = gpio_get_value(at32_wm97xx->gpio_pen);
+
+	if (pen_down != 0) {
+		mod_timer(&at32_wm97xx->pen_timer, jiffies
+				+ msecs_to_jiffies(1));
+	} else {
+		input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
+		input_sync(wm->input_dev);
+	}
+}
 
+static int __init at32_wm97xx_probe(struct platform_device *pdev)
+{

[...]

drivers/input/touchscreen/at32-wm97xx.c line 323

Quoted 1 line
drivers/input/touchscreen/at32-wm97xx.c new file +1 -0
+	at32_wm97xx->regs	= (void *)AT32_WM97XX_AC97C_IOMEM;

(void __iomem *)?
Did you feed it through sparse?

Quoted 3 lines
drivers/input/touchscreen/at32-wm97xx.c new file +3 -0
+	ret = request_irq(at32_wm97xx->ac97c_irq,
+			at32_wm97xx_channel_b_interrupt,
+			IRQF_SHARED, "at32-wm97xx-ch-b", at32_wm97xx);

[...]

drivers/input/touchscreen/at32-wm97xx.c

Quoted 1 line
drivers/input/touchscreen/at32-wm97xx.c new file +1 -0
+	return wm97xx_register_mach_ops(wm,&at32_mach_ops);

In case it fails, irq remains set up.

drivers/input/touchscreen/at32-wm97xx.c line 365

Quoted 7 lines
drivers/input/touchscreen/at32-wm97xx.c new file +7 -0
+#ifdef CONFIG_PM
+static int at32_wm97xx_suspend(struct platform_device *pdev, pm_message_t msg)
+{
+	struct at32_wm97xx *at32_wm97xx = platform_get_drvdata(pdev);
+
+	ac97c_writel(at32_wm97xx, IDR, AC97C_INT_CBEVT);
+	disable_irq(at32_wm97xx->gpio_irq);

Here, you should call disable_irq_sync() (that's what I meant by _sync in the last post).

#3 lore raw

Re: [PATCH 2/2] Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors

Quoted 10 lines · Jiri Slaby

drivers/input/touchscreen/at32-wm97xx.c line 365

Quoted 7 lines

+static int at32_wm97xx_suspend(struct platform_device *pdev, pm_message_t msg)

drivers/input/touchscreen/at32-wm97xx.c new file +5 -0
+{
+ struct at32_wm97xx *at32_wm97xx = platform_get_drvdata(pdev);
+
+ ac97c_writel(at32_wm97xx, IDR, AC97C_INT_CBEVT);
+ disable_irq(at32_wm97xx->gpio_irq);

Here, you should call disable_irq_sync() (that's what I meant by _sync in the last post).

Ah, it's in the opposite way. This one is fine, the patch 1/2 should use disable_irq_nosync(), if I understand the code correctly.

author
#4 lore raw

Re: [PATCH 2/2] Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors

Quoted 2 lines · Jiri Slaby

Ah, it's in the opposite way. This one is fine, the patch 1/2 should use disable_irq_nosync(), if I understand the code correctly.

Actually it makes no odds either way for zylonite (it can be guaranteed to be uniprocessor) but I'll change it for next time I spin.

maintainer
#5 lore raw

Re: [PATCH 2/2] Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors

In reply to Mark Brown

Hi Mark,

drivers/input/touchscreen/at32-wm97xx.c line 147

Quoted 5 lines · Mark Brown
drivers/input/touchscreen/at32-wm97xx.c new file +5 -0
+
+		if (!pressure && source == WM97XX_ADCSEL_Y) {
+			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);

Please do not report pressure (and don't advertise ABS_PRESSURE) if you don't actually read it. I have seen a follow-up patch that adds BTN_TOUCH that should work just fine here. The usage below is good since there you actually do provide true pressure readings. BTW, why would one not want pressure readings?

drivers/input/touchscreen/at32-wm97xx.c line 153

Quoted 6 lines
drivers/input/touchscreen/at32-wm97xx.c new file +6 -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_sync(wm->input_dev);

Thanks.

Signature · 1 line
Dmitry
author
#6 lore raw

Re: [PATCH 2/2] Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors

Quoted 1 line · Dmitry Torokhov

Hi Mark,

This is actually Hans-Christian's patch but here goes...

Quoted 9 lines

drivers/input/touchscreen/at32-wm97xx.c line 147

Quoted 4 lines
drivers/input/touchscreen/at32-wm97xx.c new file +4 -0
+		if (!pressure && source == WM97XX_ADCSEL_Y) {
+			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);

Please do not report pressure (and don't advertise ABS_PRESSURE) if you don't actually read it. I have seen a follow-up patch that adds BTN_TOUCH that should work just fine here. The usage below is good since there you actually do provide true pressure readings. BTW, why would one not want pressure readings?

These parts are usually deployed in embedded systems where performance is sufficiently tightly constrained that the additional work involved in taking pressure measurements is noticable. This is mostly the case where PIO is used but users have reported problems even when using DMA so idiomatically WM97xx drivers provide the option.

#7 lore raw
In reply to Mark Brown
Quoted 3 lines · Mark Brown

index 0000000..b016021

drivers/input/touchscreen/zylonite-wm97xx.c new file +0 -0

[...]

drivers/input/touchscreen/zylonite-wm97xx.c line 67

Quoted 7 lines
drivers/input/touchscreen/zylonite-wm97xx.c new file +7 -0
+/*
+ * Pressure readback.
+ *
+ * Set to 1 to read back pen down pressure
+ */
+static int pressure;
+module_param(pressure, int, 1);

Weird permissions.

drivers/input/touchscreen/zylonite-wm97xx.c line 84

Quoted 5 lines
drivers/input/touchscreen/zylonite-wm97xx.c new file +5 -0
+/* flush AC97 slot 5 FIFO machines */
+static void wm97xx_acc_pen_up(struct wm97xx *wm)
+{
+	int count = 16;
+	schedule_timeout_uninterruptible(1);

You meant ssleep(1)?

drivers/input/touchscreen/zylonite-wm97xx.c

Quoted 2 lines
drivers/input/touchscreen/zylonite-wm97xx.c new file +2 -0
+
+	while (count<  16) {

Weird condition.
+ conding style

Quoted 6 lines
drivers/input/touchscreen/zylonite-wm97xx.c new file +6 -0
+		MODR;
+		count--;
+	}
+}
+
+static int wm97xx_acc_pen_down(struct wm97xx *wm)

drivers/input/touchscreen/zylonite-wm97xx.c line 102

Quoted 10 lines
drivers/input/touchscreen/zylonite-wm97xx.c new file +10 -0
+{
+	u16 x, y, p = 0x100 | WM97XX_ADCSEL_PRES;
+	int reads = 0;
+
+	/* When the AC97 queue has been drained we need to allow time
+	 * to buffer up samples otherwise we end up spinning polling
+	 * for samples.  The controller can't have a suitably low
+	 * threashold set to use the notifications it gives.
+	 */
+	schedule_timeout_uninterruptible(1);

ssleep

drivers/input/touchscreen/zylonite-wm97xx.c

Quoted 1 line
drivers/input/touchscreen/zylonite-wm97xx.c new file +1 -0
+	if (tries>  5) {

Where is tries defined?

drivers/input/touchscreen/zylonite-wm97xx.c line 142

Quoted 3 lines
drivers/input/touchscreen/zylonite-wm97xx.c new file +3 -0
+static int wm97xx_acc_startup(struct wm97xx *wm)
+{
+	int idx = 0;

No need to initialize.

drivers/input/touchscreen/zylonite-wm97xx.c line 170

Quoted 6 lines
drivers/input/touchscreen/zylonite-wm97xx.c new file +6 -0
+static void wm97xx_irq_enable(struct wm97xx *wm, int enable)
+{
+	if (enable)
+		enable_irq(wm->pen_irq);
+	else
+		disable_irq(wm->pen_irq);

sync?

author
#8 lore raw
Quoted 6 lines · Jiri Slaby

drivers/input/touchscreen/zylonite-wm97xx.c line 67

Quoted 2 lines · Mark Brown
drivers/input/touchscreen/zylonite-wm97xx.c new file +2 -0
+static int pressure;
+module_param(pressure, int, 1);

Weird permissions.

Fixed.

Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	int count = 16;
+	schedule_timeout_uninterruptible(1);

You meant ssleep(1)?

msleep, but yes. Shows how old the code is - I'll update.

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	while (count<  16) {

Weird condition.
+ conding style

Hrm. This appears to have been mangled somewhere in the mail path to you - the indentation is normal in my send-mail folder and in the copy I got back from the list.

Quoted 3 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (tries>  5) {

Where is tries defined?

Further up the file as a global static. I've pulled the variables into the function since it's the only place they're used.

Quoted 5 lines

drivers/input/touchscreen/zylonite-wm97xx.c line 142

Quoted 3 lines
drivers/input/touchscreen/zylonite-wm97xx.c new file +3 -0
+static int wm97xx_acc_startup(struct wm97xx *wm)
+{
+	int idx = 0;

No need to initialize.

Fixed.

Quoted 8 lines

drivers/input/touchscreen/zylonite-wm97xx.c line 170

Quoted 6 lines
drivers/input/touchscreen/zylonite-wm97xx.c new file +6 -0
+static void wm97xx_irq_enable(struct wm97xx *wm, int enable)
+{
+	if (enable)
+		enable_irq(wm->pen_irq);
+	else
+		disable_irq(wm->pen_irq);

sync?

Could you expand on this, please?

#9 lore raw
Quoted 4 lines · Mark Brown
Quoted 3 lines · Jiri Slaby
Quoted 2 lines · Mark Brown
(quoted diff) +2 -0
+	int count = 16;
+	schedule_timeout_uninterruptible(1);

[...]

Quoted 8 lines
Quoted 4 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	while (count<   16) {

Weird condition.
+ conding style

Hrm. This appears to have been mangled somewhere in the mail path to you - the indentation is normal in my send-mail folder and in the copy I got back from the list.

OK, anyway the condition looks weird on a semantic layer.

Quoted 10 lines
Quoted 8 lines

drivers/input/touchscreen/zylonite-wm97xx.c line 170

Quoted 6 lines
drivers/input/touchscreen/zylonite-wm97xx.c new file +6 -0
+static void wm97xx_irq_enable(struct wm97xx *wm, int enable)
+{
+	if (enable)
+		enable_irq(wm->pen_irq);
+	else
+		disable_irq(wm->pen_irq);

sync?

Could you expand on this, please?

No, I was wrong, ignore this one. It's called from within the interrupt it disables.