Re: [PATCH v4] input: tablet: add Pegasus Notetaker tablet driver

2016-05-26 Thread Martin Kepplinger
Am 2016-05-26 um 02:29 schrieb Dmitry Torokhov:
> Hi Martin,
> 
> On Wed, May 25, 2016 at 09:44:34AM +0200, Martin Kepplinger wrote:
>> This adds a driver for the Pegasus Notetaker Pen. When connected,
>> this uses the Pen as an input tablet.
>>
>> This device was sold in various different brandings, for example
>>  "Pegasus Mobile Notetaker M210",
>>  "Genie e-note The Notetaker",
>>  "Staedtler Digital ballpoint pen 990 01",
>>  "IRISnotes Express" or
>>  "NEWLink Digital Note Taker".
>>
>> Here's an example, so that you know what we are talking about:
>> http://www.staedtler.com/en/products/ink-writing-instruments/ballpoint-pens/digital-pen-990-01-digital-ballpoint-pen
>>
>> http://pegatech.blogspot.com/ seems to be a remaining official resource.
>>
>> This device can also transfer saved (offline recorded handwritten) data and
>> there are userspace programs that do this, see https://launchpad.net/m210
>> (Well, alternatively there are really fast scanners out there :)
>>
>> It's *really* fun to use as an input tablet though! So let's support this
>> for everybody.
>>
>> There's no way to disable the device. When the pen is out of range, we just
>> don't get any URBs and don't do anything.
>> Like all other mouses or input tablets, we don't use runtime PM.
>>
>> Signed-off-by: Martin Kepplinger 
>> ---
>>
>> Thanks for having a look. Any more suggestions on this?
>>
>> revision history
>> 
>> v4 use normal work queue instead of a kernel thread (thanks to Oliver Neukum)
>> v3 fix reporting low pen battery and add USB list to CC
>> v2 minor cleanup (remove unnecessary variables)
>> v1 initial release
>>

Hi Dmitry,

thanks for the excellent review! All your suggestions seem valuable so
far and I'll prepare a new version for you.

>> +
>> +static int pegasus_open(struct input_dev *dev)
>> +{
>> +struct pegasus *pegasus = input_get_drvdata(dev);
>> +
>> +pegasus->irq->dev = pegasus->usbdev;
> 
> Is this assignment really needed?
> 

If we set URB_NO_TRANSFER_DMA_MAP and use transfer_dma, yes.


thanks again,

  martin
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] input: tablet: add Pegasus Notetaker tablet driver

2016-05-25 Thread Oliver Neukum
On Wed, 2016-05-25 at 09:44 +0200, Martin Kepplinger wrote:
> This adds a driver for the Pegasus Notetaker Pen. When connected,
> this uses the Pen as an input tablet.
> 
> This device was sold in various different brandings, for example
>   "Pegasus Mobile Notetaker M210",
>   "Genie e-note The Notetaker",
>   "Staedtler Digital ballpoint pen 990 01",
>   "IRISnotes Express" or
>   "NEWLink Digital Note Taker".
> 
> Here's an example, so that you know what we are talking about:
> http://www.staedtler.com/en/products/ink-writing-instruments/ballpoint-pens/digital-pen-990-01-digital-ballpoint-pen
> 
> http://pegatech.blogspot.com/ seems to be a remaining official resource.
> 
> This device can also transfer saved (offline recorded handwritten) data and
> there are userspace programs that do this, see https://launchpad.net/m210
> (Well, alternatively there are really fast scanners out there :)
> 
> It's *really* fun to use as an input tablet though! So let's support this
> for everybody.
> 
> There's no way to disable the device. When the pen is out of range, we just
> don't get any URBs and don't do anything.
> Like all other mouses or input tablets, we don't use runtime PM.
> 
> Signed-off-by: Martin Kepplinger 
> ---
> 
> Thanks for having a look. Any more suggestions on this?
> 
> revision history
> 
> v4 use normal work queue instead of a kernel thread (thanks to Oliver Neukum)
> v3 fix reporting low pen battery and add USB list to CC
> v2 minor cleanup (remove unnecessary variables)
> v1 initial release
> 

Hi,

almost there.

Regards
Oliver

> +static void pegasus_close(struct input_dev *dev)
> +{
> + struct pegasus *pegasus = input_get_drvdata(dev);
> +
> + cancel_work_sync(>init);
> +
> + usb_kill_urb(pegasus->irq);
> +}

This is a race condition. The URB can trigger the work.
Therefore the URB needs to die first.


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4] input: tablet: add Pegasus Notetaker tablet driver

2016-05-25 Thread Martin Kepplinger
This adds a driver for the Pegasus Notetaker Pen. When connected,
this uses the Pen as an input tablet.

This device was sold in various different brandings, for example
"Pegasus Mobile Notetaker M210",
"Genie e-note The Notetaker",
"Staedtler Digital ballpoint pen 990 01",
"IRISnotes Express" or
"NEWLink Digital Note Taker".

Here's an example, so that you know what we are talking about:
http://www.staedtler.com/en/products/ink-writing-instruments/ballpoint-pens/digital-pen-990-01-digital-ballpoint-pen

http://pegatech.blogspot.com/ seems to be a remaining official resource.

This device can also transfer saved (offline recorded handwritten) data and
there are userspace programs that do this, see https://launchpad.net/m210
(Well, alternatively there are really fast scanners out there :)

It's *really* fun to use as an input tablet though! So let's support this
for everybody.

There's no way to disable the device. When the pen is out of range, we just
don't get any URBs and don't do anything.
Like all other mouses or input tablets, we don't use runtime PM.

Signed-off-by: Martin Kepplinger 
---

Thanks for having a look. Any more suggestions on this?

revision history

v4 use normal work queue instead of a kernel thread (thanks to Oliver Neukum)
v3 fix reporting low pen battery and add USB list to CC
v2 minor cleanup (remove unnecessary variables)
v1 initial release



 drivers/input/tablet/Kconfig |  15 ++
 drivers/input/tablet/Makefile|   1 +
 drivers/input/tablet/pegasus_notetaker.c | 373 +++
 3 files changed, 389 insertions(+)
 create mode 100644 drivers/input/tablet/pegasus_notetaker.c

diff --git a/drivers/input/tablet/Kconfig b/drivers/input/tablet/Kconfig
index 623bb9e..a2b9f97 100644
--- a/drivers/input/tablet/Kconfig
+++ b/drivers/input/tablet/Kconfig
@@ -73,6 +73,21 @@ config TABLET_USB_KBTAB
  To compile this driver as a module, choose M here: the
  module will be called kbtab.
 
+config TABLET_USB_PEGASUS
+   tristate "Pegasus Mobile Notetaker Pen input tablet support"
+   depends on USB_ARCH_HAS_HCD
+   select USB
+   help
+ Say Y here if you want to use the Pegasus Mobile Notetaker,
+ also known as:
+ Genie e-note The Notetaker,
+ Staedtler Digital ballpoint pen 990 01,
+ IRISnotes Express or
+ NEWLink Digital Note Taker.
+
+ To compile this driver as a module, choose M here: the
+ module will be called pegasus_notetaker.
+
 config TABLET_SERIAL_WACOM4
tristate "Wacom protocol 4 serial tablet support"
select SERIO
diff --git a/drivers/input/tablet/Makefile b/drivers/input/tablet/Makefile
index 2e13010..200fc4e 100644
--- a/drivers/input/tablet/Makefile
+++ b/drivers/input/tablet/Makefile
@@ -8,4 +8,5 @@ obj-$(CONFIG_TABLET_USB_AIPTEK) += aiptek.o
 obj-$(CONFIG_TABLET_USB_GTCO)  += gtco.o
 obj-$(CONFIG_TABLET_USB_HANWANG) += hanwang.o
 obj-$(CONFIG_TABLET_USB_KBTAB) += kbtab.o
+obj-$(CONFIG_TABLET_USB_PEGASUS) += pegasus_notetaker.o
 obj-$(CONFIG_TABLET_SERIAL_WACOM4) += wacom_serial4.o
diff --git a/drivers/input/tablet/pegasus_notetaker.c 
b/drivers/input/tablet/pegasus_notetaker.c
new file mode 100644
index 000..b7bf585
--- /dev/null
+++ b/drivers/input/tablet/pegasus_notetaker.c
@@ -0,0 +1,373 @@
+/*
+ * Pegasus Mobile Notetaker Pen input tablet driver
+ *
+ * Copyright (c) 2016 Martin Kepplinger 
+ */
+
+/*
+ * request packet (control endpoint):
+ * |-|
+ * | Report ID | Nr of bytes | command   |
+ * | (1 byte)  | (1 byte)| (n bytes) |
+ * |-|
+ * | 0x02  | n   |   |
+ * |-|
+ *
+ * data packet after set xy mode command, 0x80 0xb5 0x02 0x01
+ * and pen is in range:
+ *
+ * bytebyte name   value (bits)
+ * 
+ * 0   status  0 1 0 0 0 0 X X
+ * 1   color   0 0 0 0 H 0 S T
+ * 2   X low
+ * 3   X high
+ * 4   Y low
+ * 5   Y high
+ *
+ * X X battery state:
+ * no state reported   0x00
+ * battery low 0x01
+ * battery good0x02
+ *
+ * H   Hovering
+ * S   Switch 1 (pen button)
+ * T   Tip
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/* USB HID defines */
+#define USB_REQ_GET_REPORT 0x01
+#define USB_REQ_SET_REPORT 0x09
+
+#define USB_VENDOR_ID_PEGASUSTECH  0x0e20
+#define USB_DEVICE_ID_PEGASUS_NOTETAKER_EN100  0x0101
+
+/* device specific defines */
+#define NOTETAKER_REPORT_ID0x02
+#define NOTETAKER_SET_CMD  0x80
+#define NOTETAKER_SET_MODE 0xb5
+
+#define NOTETAKER_LED_MOUSE 0x02
+#define PEN_MODE_XY 0x01
+
+#define SPECIAL_COMMAND0x80
+#define