Release 4.7 drivers/hid/usbhid/usbmouse.c
/*
* Copyright (c) 1999-2001 Vojtech Pavlik
*
* USB HIDBP Mouse support
*/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Should you need to contact me, the author, you can do so either by
* e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
* Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
*/
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/usb/input.h>
#include <linux/hid.h>
/* for apple IDs */
#ifdef CONFIG_USB_HID_MODULE
#include "../hid-ids.h"
#endif
/*
* Version Information
*/
#define DRIVER_VERSION "v1.6"
#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
#define DRIVER_DESC "USB HID Boot Protocol mouse driver"
#define DRIVER_LICENSE "GPL"
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE(DRIVER_LICENSE);
struct usb_mouse {
char name[128];
char phys[64];
struct usb_device *usbdev;
struct input_dev *dev;
struct urb *irq;
signed char *data;
dma_addr_t data_dma;
};
static void usb_mouse_irq(struct urb *urb)
{
struct usb_mouse *mouse = urb->context;
signed char *data = mouse->data;
struct input_dev *dev = mouse->dev;
int status;
switch (urb->status) {
case 0: /* success */
break;
case -ECONNRESET: /* unlink */
case -ENOENT:
case -ESHUTDOWN:
return;
/* -EPIPE: should clear the halt */
default: /* error */
goto resubmit;
}
input_report_key(dev, BTN_LEFT, data[0] & 0x01);
input_report_key(dev, BTN_RIGHT, data[0] & 0x02);
input_report_key(dev, BTN_MIDDLE, data[0] & 0x04);
input_report_key(dev, BTN_SIDE, data[0] & 0x08);
input_report_key(dev, BTN_EXTRA, data[0] & 0x10);
input_report_rel(dev, REL_X, data[1]);
input_report_rel(dev, REL_Y, data[2]);
input_report_rel(dev, REL_WHEEL, data[3]);
input_sync(dev);
resubmit:
status = usb_submit_urb (urb, GFP_ATOMIC);
if (status)
dev_err(&mouse->usbdev->dev,
"can't resubmit intr, %s-%s/input0, status %d\n",
mouse->usbdev->bus->bus_name,
mouse->usbdev->devpath, status);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 150 | 65.79% | 2 | 33.33% |
david brownell | david brownell | 63 | 27.63% | 1 | 16.67% |
greg kroah-hartman | greg kroah-hartman | 9 | 3.95% | 1 | 16.67% |
vojtech pavlik | vojtech pavlik | 5 | 2.19% | 1 | 16.67% |
christoph lameter | christoph lameter | 1 | 0.44% | 1 | 16.67% |
| Total | 228 | 100.00% | 6 | 100.00% |
static int usb_mouse_open(struct input_dev *dev)
{
struct usb_mouse *mouse = input_get_drvdata(dev);
mouse->irq->dev = mouse->usbdev;
if (usb_submit_urb(mouse->irq, GFP_KERNEL))
return -EIO;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 43 | 87.76% | 3 | 50.00% |
dmitry torokhov | dmitry torokhov | 3 | 6.12% | 1 | 16.67% |
greg kroah-hartman | greg kroah-hartman | 2 | 4.08% | 1 | 16.67% |
linus torvalds | linus torvalds | 1 | 2.04% | 1 | 16.67% |
| Total | 49 | 100.00% | 6 | 100.00% |
static void usb_mouse_close(struct input_dev *dev)
{
struct usb_mouse *mouse = input_get_drvdata(dev);
usb_kill_urb(mouse->irq);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 24 | 85.71% | 2 | 50.00% |
dmitry torokhov | dmitry torokhov | 3 | 10.71% | 1 | 25.00% |
borislav petkov | borislav petkov | 1 | 3.57% | 1 | 25.00% |
| Total | 28 | 100.00% | 4 | 100.00% |
static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *dev = interface_to_usbdev(intf);
struct usb_host_interface *interface;
struct usb_endpoint_descriptor *endpoint;
struct usb_mouse *mouse;
struct input_dev *input_dev;
int pipe, maxp;
int error = -ENOMEM;
interface = intf->cur_altsetting;
if (interface->desc.bNumEndpoints != 1)
return -ENODEV;
endpoint = &interface->endpoint[0].desc;
if (!usb_endpoint_is_int_in(endpoint))
return -ENODEV;
pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
mouse = kzalloc(sizeof(struct usb_mouse), GFP_KERNEL);
input_dev = input_allocate_device();
if (!mouse || !input_dev)
goto fail1;
mouse->data = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &mouse->data_dma);
if (!mouse->data)
goto fail1;
mouse->irq = usb_alloc_urb(0, GFP_KERNEL);
if (!mouse->irq)
goto fail2;
mouse->usbdev = dev;
mouse->dev = input_dev;
if (dev->manufacturer)
strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name));
if (dev->product) {
if (dev->manufacturer)
strlcat(mouse->name, " ", sizeof(mouse->name));
strlcat(mouse->name, dev->product, sizeof(mouse->name));
}
if (!strlen(mouse->name))
snprintf(mouse->name, sizeof(mouse->name),
"USB HIDBP Mouse %04x:%04x",
le16_to_cpu(dev->descriptor.idVendor),
le16_to_cpu(dev->descriptor.idProduct));
usb_make_path(dev, mouse->phys, sizeof(mouse->phys));
strlcat(mouse->phys, "/input0", sizeof(mouse->phys));
input_dev->name = mouse->name;
input_dev->phys = mouse->phys;
usb_to_input_id(dev, &input_dev->id);
input_dev->dev.parent = &intf->dev;
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_SIDE) |
BIT_MASK(BTN_EXTRA);
input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
input_set_drvdata(input_dev, mouse);
input_dev->open = usb_mouse_open;
input_dev->close = usb_mouse_close;
usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data,
(maxp > 8 ? 8 : maxp),
usb_mouse_irq, mouse, endpoint->bInterval);
mouse->irq->transfer_dma = mouse->data_dma;
mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
error = input_register_device(mouse->dev);
if (error)
goto fail3;
usb_set_intfdata(intf, mouse);
return 0;
fail3:
usb_free_urb(mouse->irq);
fail2:
usb_free_coherent(dev, 8, mouse->data, mouse->data_dma);
fail1:
input_free_device(input_dev);
kfree(mouse);
return error;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dmitry torokhov | dmitry torokhov | 268 | 42.54% | 3 | 16.67% |
pre-git | pre-git | 239 | 37.94% | 4 | 22.22% |
david s. miller | david s. miller | 53 | 8.41% | 1 | 5.56% |
greg kroah-hartman | greg kroah-hartman | 22 | 3.49% | 3 | 16.67% |
linus torvalds | linus torvalds | 21 | 3.33% | 1 | 5.56% |
jiri slaby | jiri slaby | 12 | 1.90% | 1 | 5.56% |
david brownell | david brownell | 8 | 1.27% | 1 | 5.56% |
luiz fernando capitulino | luiz fernando capitulino | 3 | 0.48% | 1 | 5.56% |
daniel mack | daniel mack | 2 | 0.32% | 1 | 5.56% |
christoph lameter | christoph lameter | 1 | 0.16% | 1 | 5.56% |
alan stern | alan stern | 1 | 0.16% | 1 | 5.56% |
| Total | 630 | 100.00% | 18 | 100.00% |
static void usb_mouse_disconnect(struct usb_interface *intf)
{
struct usb_mouse *mouse = usb_get_intfdata (intf);
usb_set_intfdata(intf, NULL);
if (mouse) {
usb_kill_urb(mouse->irq);
input_unregister_device(mouse->dev);
usb_free_urb(mouse->irq);
usb_free_coherent(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma);
kfree(mouse);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 33 | 42.31% | 1 | 14.29% |
greg kroah-hartman | greg kroah-hartman | 23 | 29.49% | 2 | 28.57% |
david s. miller | david s. miller | 13 | 16.67% | 1 | 14.29% |
linus torvalds | linus torvalds | 7 | 8.97% | 1 | 14.29% |
borislav petkov | borislav petkov | 1 | 1.28% | 1 | 14.29% |
daniel mack | daniel mack | 1 | 1.28% | 1 | 14.29% |
| Total | 78 | 100.00% | 7 | 100.00% |
static struct usb_device_id usb_mouse_id_table [] = {
{ USB_INTERFACE_INFO(USB_INTERFACE_CLASS_HID, USB_INTERFACE_SUBCLASS_BOOT,
USB_INTERFACE_PROTOCOL_MOUSE) },
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE (usb, usb_mouse_id_table);
static struct usb_driver usb_mouse_driver = {
.name = "usbmouse",
.probe = usb_mouse_probe,
.disconnect = usb_mouse_disconnect,
.id_table = usb_mouse_id_table,
};
module_usb_driver(usb_mouse_driver);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 581 | 49.45% | 8 | 20.00% |
dmitry torokhov | dmitry torokhov | 276 | 23.49% | 4 | 10.00% |
david s. miller | david s. miller | 74 | 6.30% | 1 | 2.50% |
david brownell | david brownell | 72 | 6.13% | 3 | 7.50% |
greg kroah-hartman | greg kroah-hartman | 58 | 4.94% | 7 | 17.50% |
linus torvalds | linus torvalds | 49 | 4.17% | 4 | 10.00% |
jiri slaby | jiri slaby | 21 | 1.79% | 2 | 5.00% |
vojtech pavlik | vojtech pavlik | 17 | 1.45% | 2 | 5.00% |
rusty russell | rusty russell | 8 | 0.68% | 1 | 2.50% |
michael opdenacker | michael opdenacker | 6 | 0.51% | 1 | 2.50% |
daniel mack | daniel mack | 3 | 0.26% | 1 | 2.50% |
luiz fernando capitulino | luiz fernando capitulino | 3 | 0.26% | 1 | 2.50% |
borislav petkov | borislav petkov | 2 | 0.17% | 1 | 2.50% |
christoph lameter | christoph lameter | 2 | 0.17% | 1 | 2.50% |
johannes erdfelt | johannes erdfelt | 1 | 0.09% | 1 | 2.50% |
adrian bunk | adrian bunk | 1 | 0.09% | 1 | 2.50% |
alan stern | alan stern | 1 | 0.09% | 1 | 2.50% |
| Total | 1175 | 100.00% | 40 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.