Skip to contentSkip to conversation

Input: add mmio xi driver

PATCH In review Greg KH 5 participants 8 messages Sep 25, 2008 – Nov 25, 2008

Subsystems (2)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 Input: add mmio xi driver

From: Greg Kroah-Hartman <[email protected]>

This patch adds the Mimio Xi interactive whiteboard driver to the tree.

It was originally written by [email protected], but cleaned up and forward ported by me to the latest kernel version.

---
 drivers/input/misc/Kconfig  |   11 
 drivers/input/misc/Makefile |    1 
 drivers/input/misc/mimio.c  |  913 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 925 insertions(+)
drivers/input/misc/Kconfig +11 -0
@@ -164,6 +164,17 @@ config INPUT_POWERMATE
 	  To compile this driver as a module, choose M here: the
 	  module will be called powermate.
 
+config INPUT_MIMIO
+	tristate "Mimio Xi interactive whiteboard support"
+	depends on USB_ARCH_HAS_HCD
+	select USB
+	help
+	  Say Y here if you want to use a Mimio Xi interactive
+	  whiteboard device.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mimio.
+
 config INPUT_YEALINK
 	tristate "Yealink usb-p1k voip phone"
 	depends on EXPERIMENTAL
drivers/input/misc/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_INPUT_ATI_REMOTE)		+= ati_r
 obj-$(CONFIG_INPUT_ATI_REMOTE2)		+= ati_remote2.o
 obj-$(CONFIG_INPUT_KEYSPAN_REMOTE)	+= keyspan_remote.o
 obj-$(CONFIG_INPUT_POWERMATE)		+= powermate.o
+obj-$(CONFIG_INPUT_MIMIO)		+= mimio.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
drivers/input/misc/mimio.c new file +913 -0

913 lines not on this page · raw message

#1 lore raw
Quoted 22 lines · On Thu, 25 Sep 2008 16:22:37 -0700 Greg KH wrote:

From: Greg Kroah-Hartman <[email protected]>

This patch adds the Mimio Xi interactive whiteboard driver to the tree.

It was originally written by mwilder-qcTL/[email protected], but cleaned up and forward ported by me to the latest kernel version.

Cc Phil Hannent <[email protected]>
Cc <mwilder-qcTL/[email protected]>
---
 drivers/input/misc/Kconfig  |   11 
 drivers/input/misc/Makefile |    1 
 drivers/input/misc/mimio.c  |  913 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 925 insertions(+)

drivers/input/misc/Kconfig config INPUT_POWERMATE · line 170

Quoted 7 lines
drivers/input/misc/Kconfig +4 -0
@@ -164,6 +164,17 @@ config INPUT_POWERMATE
 	  To compile this driver as a module, choose M here: the
 	  module will be called powermate.
 
+config INPUT_MIMIO
+	tristate "Mimio Xi interactive whiteboard support"
+	depends on USB_ARCH_HAS_HCD
+	select USB

Prefer not to select entire subsystems, but to depend on them. However, lots of drivers in drivers/input/ select USB... :(

Quoted 19 lines
drivers/input/misc/Kconfig +7 -0
+	help
+	  Say Y here if you want to use a Mimio Xi interactive
+	  whiteboard device.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mimio.
+
 config INPUT_YEALINK
 	tristate "Yealink usb-p1k voip phone"
 	depends on EXPERIMENTAL
drivers/input/misc/mimio.c new file +4 -0
@@ -0,0 +1,913 @@
 
+static void mimio_irq_out(struct urb *urb)
+{
+	unsigned long flags;
+	struct mimio *mimio;

drivers/input/misc/mimio.c line 331

Quoted 10 lines
drivers/input/misc/mimio.c new file +10 -0
+
+	mimio = urb->context;
+
+	if (urb->status)
+		dev_dbg(&mimio->idev->dev, "urb-status: %d.\n", urb->status);
+
+	spin_lock_irqsave(&mimio->txlock, flags);
+	mimio->txflags |= MIMIO_TXDONE;
+	spin_unlock_irqrestore(&mimio->txlock, flags);
+	wmb();

We want comments/explanation on all barriers or just "barrier();" ??

Quoted 85 lines
drivers/input/misc/mimio.c new file +84 -0
+	wake_up(&mimio->waitq);
+}
 
+static int mimio_probe(struct usb_interface *ifc,
+		       const struct usb_device_id *id)
+{
+	char path[64];
+	int pipe, maxp;
+	struct mimio *mimio;
+	struct usb_device *udev;
+	struct usb_host_interface *hostifc;
+	struct input_dev *input_dev;
+	int res = 0;
+	int i;
+
+	udev = interface_to_usbdev(ifc);
+
+	mimio = kzalloc(sizeof(struct mimio), GFP_KERNEL);
+	if (!mimio)
+		return -ENOMEM;
+
+	input_dev = input_allocate_device();
+	if (!input_dev) {
+		mimio_dealloc(mimio);
+		return -ENOMEM;
+	}
+
+	mimio->uifc = ifc;
+	mimio->udev = udev;
+	mimio->pktbuf.p = mimio->pktbuf.buf;
+	mimio->pktbuf.q = mimio->pktbuf.buf;
+	/* init_input_dev(mimio->idev); */
+	mimio->idev = input_dev;
+	init_waitqueue_head(&mimio->waitq);
+	spin_lock_init(&mimio->txlock);
+	hostifc = ifc->cur_altsetting;
+
+	if (hostifc->desc.bNumEndpoints != 2) {
+		dev_err(&udev->dev, "Unexpected endpoint count: %d.\n",
+			hostifc->desc.bNumEndpoints);
+		mimio_dealloc(mimio);
+		return -ENODEV;
+	}
+
+	mimio->in.desc = &(hostifc->endpoint[0].desc);
+	mimio->out.desc = &(hostifc->endpoint[1].desc);
+
+	mimio->in.buf = usb_buffer_alloc(udev, MIMIO_MAXPAYLOAD, GFP_KERNEL,
+					 &mimio->in.dma);
+	mimio->out.buf = usb_buffer_alloc(udev, MIMIO_MAXPAYLOAD, GFP_KERNEL,
+					  &mimio->out.dma);
+
+	if (mimio->in.buf == NULL || mimio->out.buf == NULL) {
+		dev_err(&udev->dev, "usb_buffer_alloc failure.\n");
+		mimio_dealloc(mimio);
+		return -ENOMEM;
+	}
+
+	mimio->in.urb = usb_alloc_urb(0, GFP_KERNEL);
+	mimio->out.urb = usb_alloc_urb(0, GFP_KERNEL);
+
+	if (mimio->in.urb == NULL || mimio->out.urb == NULL) {
+		dev_err(&udev->dev, "usb_alloc_urb failure.\n");
+		mimio_dealloc(mimio);
+		return -ENOMEM;
+	}
+
+	/*
+	 * Build the input urb.
+	 */
+	pipe = usb_rcvintpipe(udev, mimio->in.desc->bEndpointAddress);
+	maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
+	if (maxp > MIMIO_MAXPAYLOAD)
+		maxp = MIMIO_MAXPAYLOAD;
+	usb_fill_int_urb(mimio->in.urb, udev, pipe, mimio->in.buf, maxp,
+			 mimio_irq_in, mimio, mimio->in.desc->bInterval);
+	mimio->in.urb->transfer_dma = mimio->in.dma;
+	mimio->in.urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+
+	/*
+	 * Build the output urb.
+	 */
+	pipe = usb_sndintpipe(udev, mimio->out.desc->bEndpointAddress);
+	maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
+	if (maxp > MIMIO_MAXPAYLOAD)

drivers/input/misc/mimio.c line 477

Quoted 10 lines
drivers/input/misc/mimio.c new file +10 -0
+		maxp = MIMIO_MAXPAYLOAD;
+	usb_fill_int_urb(mimio->out.urb, udev, pipe, mimio->out.buf, maxp,
+			 mimio_irq_out, mimio, mimio->out.desc->bInterval);
+	mimio->out.urb->transfer_dma = mimio->out.dma;
+	mimio->out.urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+
+	/*
+	 * Build input device info
+	 */
+	usb_make_path(udev, path, 64);

s/64/sizeof(path)/

Quoted 88 lines
drivers/input/misc/mimio.c new file +88 -0
+	snprintf(mimio->phys, MIMIO_MAXNAMELEN, "%s/input0", path);
+	input_set_drvdata(input_dev, mimio);
+	/* input_dev->dev = &ifc->dev; */
+	input_dev->open = mimio_open;
+	input_dev->close = mimio_close;
+	input_dev->name = mimio_name;
+	input_dev->phys = mimio->phys;
+	input_dev->dev.parent = &ifc->dev;
+
+	input_dev->id.bustype = BUS_USB;
+	input_dev->id.vendor = le16_to_cpu(udev->descriptor.idVendor);
+	input_dev->id.product = le16_to_cpu(udev->descriptor.idProduct);
+	input_dev->id.version = le16_to_cpu(udev->descriptor.bcdDevice);
+
+	input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);
+	for (i = BTN_TOOL_PEN; i <= LOCALBTN_TOOL_EXTRA2; ++i)
+		set_bit(i, input_dev->keybit);
+
+	input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
+						 BIT_MASK(BTN_1) |
+						 BIT_MASK(BTN_2) |
+						 BIT_MASK(BTN_3) |
+						 BIT_MASK(BTN_4) |
+						 BIT_MASK(BTN_5);
+	/*   input_dev->keybit[BTN_MOUSE] |= BIT(BTN_LEFT); */
+	input_dev->absbit[0] |= BIT_MASK(ABS_X) | BIT_MASK(ABS_Y);
+	input_set_abs_params(input_dev, ABS_X, 0, MIMIO_XRANGE_MAX, 0, 0);
+	input_set_abs_params(input_dev, ABS_Y, 0, MIMIO_YRANGE_MAX, 0, 0);
+	input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
+
+#if 0
+	input_dev->absmin[ABS_X] = 0;
+	input_dev->absmin[ABS_Y] = 0;
+	input_dev->absmax[ABS_X] = 9600;
+	input_dev->absmax[ABS_Y] = 4800;
+	input_dev->absfuzz[ABS_X] = 0;
+	input_dev->absfuzz[ABS_Y] = 0;
+	input_dev->absflat[ABS_X] = 0;
+	input_dev->absflat[ABS_Y] = 0;
+#endif
+
+#if 0
+	/* this will just reduce the precision */
+	input_dev->absfuzz[ABS_X] = 8; /* experimental; may need to change */
+	input_dev->absfuzz[ABS_Y] = 8; /* experimental; may need to change */
+#endif
+
+	/*
+	 * Register the input device.
+	 */
+	res = input_register_device(mimio->idev);
+	if (res) {
+		dev_err(&udev->dev, "input_register_device failure (%d)\n",
+			res);
+		mimio_dealloc(mimio);
+		return -EIO;
+	}
+	dev_dbg(&mimio->idev->dev, "input: %s on %s (res = %d).\n",
+		input_dev->name, input_dev->phys, res);
+
+	usb_set_intfdata(ifc, mimio);
+	mimio->present = 1;
+
+	/*
+	 * Submit the input urb to the usb subsystem.
+	 */
+	mimio->in.urb->dev = mimio->udev;
+	res = usb_submit_urb(mimio->in.urb, GFP_KERNEL);
+	if (res) {
+		dev_err(&mimio->idev->dev, "usb_submit_urb failure (%d)\n",
+			res);
+		mimio_dealloc(mimio);
+		return -EIO;
+	}
+
+	/*
+	 * Attempt to greet the mimio after giving
+	 * it some post-init settling time.
+	 *
+	 * note: sometimes this sleep interval isn't
+	 * long enough to permit the device to re-init
+	 * after a hot-swap; maybe need to bump it up.
+	 *
+	 * As it is, this probably breaks module unloading support!
+	 */
+	msleep(1024);
+
+	res = mimio_greet(mimio);

drivers/input/misc/mimio.c line 575

Quoted 10 lines
drivers/input/misc/mimio.c new file +10 -0
+	if (res == 0) {
+		dev_dbg(&mimio->idev->dev, "Mimio greeted OK.\n");
+		mimio->greeted = 1;
+		mimio->rxhandler = mimio_rx_handler;
+	} else {
+		dev_dbg(&mimio->idev->dev, "Mimio greet Failure (%d)\n", res);
+	}
+
+	return 0;
+}

---
~Randy
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw
Quoted 27 lines · Randy Dunlap
Quoted 25 lines · On Thu, 25 Sep 2008 16:22:37 -0700 Greg KH wrote:

From: Greg Kroah-Hartman <[email protected]>

This patch adds the Mimio Xi interactive whiteboard driver to the tree.

It was originally written by [email protected], but cleaned up and forward ported by me to the latest kernel version.

---
 drivers/input/misc/Kconfig  |   11 
 drivers/input/misc/Makefile |    1 
 drivers/input/misc/mimio.c  |  913 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 925 insertions(+)
drivers/input/misc/Kconfig +0 -0
@@ -164,6 +164,17 @@ config INPUT_POWERMATE
 	  To compile this driver as a module, choose M here: the
 	  module will be called powermate.
 
Quoted 7 lines

drivers/input/misc/Kconfig config INPUT_POWERMATE · line 170

Quoted 4 lines
drivers/input/misc/Kconfig +4 -0
+config INPUT_MIMIO
+	tristate "Mimio Xi interactive whiteboard support"
+	depends on USB_ARCH_HAS_HCD
+	select USB

Prefer not to select entire subsystems, but to depend on them. However, lots of drivers in drivers/input/ select USB... :(

When in Rome... :)

Quoted 8 lines
Quoted 8 lines
drivers/input/misc/Kconfig +8 -0
+static void mimio_irq_out(struct urb *urb)
+{
+	unsigned long flags;
+	struct mimio *mimio;
+
+	mimio = urb->context;
+
+	if (urb->status)
Quoted 8 lines

drivers/input/misc/Kconfig config INPUT_POWERMATE

Quoted 6 lines
drivers/input/misc/Kconfig +6 -0
+		dev_dbg(&mimio->idev->dev, "urb-status: %d.\n", urb->status);
+
+	spin_lock_irqsave(&mimio->txlock, flags);
+	mimio->txflags |= MIMIO_TXDONE;
+	spin_unlock_irqrestore(&mimio->txlock, flags);
+	wmb();

We want comments/explanation on all barriers or just "barrier();" ??

Ick, good catch, that shouldn't be needed, I'll go delete it.

Quoted 6 lines

drivers/input/misc/Kconfig

Quoted 4 lines
drivers/input/misc/Kconfig +4 -0
+	/*
+	 * Build input device info
+	 */
+	usb_make_path(udev, path, 64);

s/64/sizeof(path)/

Thanks, will fix.

Thanks for the review, I appreciate it.

greg k-h

#3 lore raw
Quoted 9 lines · Greg KH
Quoted 8 lines · Randy Dunlap
Quoted 6 lines · On Thu, 25 Sep 2008 16:22:37 -0700 Greg KH wrote:

From: Greg Kroah-Hartman <[email protected]>

This patch adds the Mimio Xi interactive whiteboard driver to the tree.

It was originally written by [email protected], but cleaned up and forward ported by me to the latest kernel version.

I have been given the protocol document for the whiteboards, I am not allowed to share it with anybody unfortunately.

I am just waiting for approval of funds for me to start development of this driver and an X11 library to make the ink capture work.

I expect to start work at the end of October, I could do with a mentor to help me with this.

Just so you do not get the wrong idea, I plan on sticking around to maintain the driver once its complete even if its my spare time to do so.

Regards
Phil Hannent

author
#4 lore raw
Quoted 4 lines · Phil Hannent
Quoted 3 lines · Greg KH
Quoted 2 lines · Randy Dunlap

On Thu, 25 Sep 2008 16:22:37 -0700 Greg KH wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

From: Greg Kroah-Hartman <[email protected]>

This patch adds the Mimio Xi interactive whiteboard driver to the tree.

It was originally written by [email protected], but cleaned up and forward ported by me to the latest kernel version.

I have been given the protocol document for the whiteboards, I am not allowed to share it with anybody unfortunately.

That's great news, and not that big of a deal about the "no share" issue as long as you are allowed to contribute.

Quoted 2 lines

I am just waiting for approval of funds for me to start development of this driver and an X11 library to make the ink capture work.

Um, what's wrong with the driver that I just posted? Does it not work properly? I'll gladly accept patches for things that are wrong, but don't start over from scratch please.

Quoted 2 lines

I expect to start work at the end of October, I could do with a mentor to help me with this.

If you need help on the kernel side, feel free to contact me off-list.

thanks,

greg k-h

#7 lore raw
In reply to Greg KH
Quoted 3 lines · On Thu, 25 Sep 2008 16:22:37 -0700 Greg KH <[email protected]> wrote:

From: Greg Kroah-Hartman <[email protected]>

Is this true?

Quoted 4 lines

This patch adds the Mimio Xi interactive whiteboard driver to the tree.

It was originally written by [email protected], but cleaned up and forward ported by me to the latest kernel version.

Oh. Tricky.

Quoted 4 lines

...

+#define isvalidtxsize(n) ((n) > 0 && (n) <= MIMIO_MAXPAYLOAD)

grumble.

- should be written in C

- buggy when passed expresion-with-side-effects.

Quoted 4 lines

...

+static DECLARE_MUTEX(disconnect_sem);

ooh, a semaphore - I remember them.

checkpatch used to warn about newly-added semaphores but a) it broke and
b) this patch doesn't seem to have met checkpatch.

Quoted 13 lines

...

drivers/input/misc/mimio.c new file +10 -0
+static int mimio_greet(struct mimio *mimio)
+{
+	const struct grtpkt {
+		int nbytes;
+		unsigned delay;
+		char data[8];
+	} grtpkts[] = {
+		{ 3, 0, { 0x11, 0x55, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00 } },
+		{ 5, 0, { 0x53, 0x55, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00 } },
+		{ 5, 0, { 0x43, 0x55, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00 } },

drivers/input/misc/mimio.c line 260

Quoted 10 lines
drivers/input/misc/mimio.c new file +10 -0
+		{ 5, 0, { 0x33, 0x55, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00 } },
+		{ 5, 0, { 0x13, 0x00, 0x5e, 0x02, 0x4f, 0x00, 0x00, 0x00 } },
+		{ 5, 0, { 0x13, 0x00, 0x04, 0x03, 0x14, 0x00, 0x00, 0x00 } },
+		{ 5, 2, { 0x13, 0x00, 0x00, 0x04, 0x17, 0x00, 0x00, 0x00 } },
+		{ 5, 0, { 0x13, 0x00, 0x0d, 0x08, 0x16, 0x00, 0x00, 0x00 } },
+		{ 5, 0, { 0x13, 0x00, 0x4d, 0x01, 0x5f, 0x00, 0x00, 0x00 } },
+		{ 3, 0, { 0xf1, 0x55, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00 } },
+		{ 7, 2, { 0x52, 0x55, 0x00, 0x07, 0x31, 0x55, 0x64, 0x00 } },
+		{ 0, 0, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
+	};

I believe that gcc does the right thing here, but an explict `static' would set minds at ease.

#5 lore raw
In reply to Greg KH

Hello. I am the original developer of the mimio Xi driver for 2.4 kernel linux. I have been observing this particular thread of emails for quite some time. I haven't been able to devote much attention to the developments in this thread because my primary research emphasis lies elsewhere. Recent events, however, have provoked me to pay close attention to this thread.

I would like to thank [email protected] for his work folding in the 2.6-specific mods to the driver. This is something that I do not have the time to do, and I am glad to see that he has taken up the slack so
that others may benefit from this work.

I would like to discuss the following dialog:

Quoted 25 lines · Phil Hannent
Quoted 4 lines
Quoted 3 lines · Greg KH
Quoted 2 lines · Randy Dunlap

On Thu, 25 Sep 2008 16:22:37 -0700 Greg KH wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

From: Greg Kroah-Hartman <[email protected]>

This patch adds the Mimio Xi interactive whiteboard driver to the tree.

It was originally written by mwilder-qcTL/[email protected], but cleaned up and forward ported by me to the latest kernel version.

I have been given the protocol document for the whiteboards, I am not allowed to share it with anybody unfortunately.

That's great news, and not that big of a deal about the "no share" issue as long as you are allowed to contribute.

Quoted 2 lines

I am just waiting for approval of funds for me to start development of this driver and an X11 library to make the ink capture work.

Um, what's wrong with the driver that I just posted? Does it not work properly? I'll gladly accept patches for things that are wrong, but don't start over from scratch please.

Quoted 6 lines
Quoted 2 lines

I expect to start work at the end of October, I could do with a mentor to help me with this.

If you need help on the kernel side, feel free to contact me off-list.

What _is_ wrong with the driver? I am guessing that phil-U4DcaGvlwG/[email protected] is just struggling with creating X bindings for the module, but I would like
to hear some elaboration on what is actually happening here. Enlighten
me.

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

#6 lore raw
Quoted 5 lines · mwilder

What _is_ wrong with the driver? I am guessing that [email protected] is just struggling with creating X bindings for the module, but I would like to hear some elaboration on what is actually happening here. Enlighten me.

Hello,

The driver is great, however I have been given the Mimio Xi protocol documentation and it describes what all of the hex is doing. Unfortunately I am not at liberty to share the documentation with anybody due to an NDA, however I would hope that the code will be fairly clear as to what's happening as a lot of the protocol hex I have setup as defines.

The initialisation sequence in the current driver is just a series of hex codes which I am reimplementing as per the Xi protocol. Also the board has on-board flash for the boards layout, dpi and firmware based upgrade methods. I am going to implement access to these.

I am also, as you state, working on the X side of things.

I certainly would not want to tread on your toes with regard to the development of this driver, however as you had mentioned to me in the past that you did not have the time to devote to this I decided to move ahead with it myself. Are you planing on making changes to the existing driver?

Regards
Phil Hannent