From 4a5a274bbed9df7acd462a9a02d8a156b8742b12 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 22 Mar 2011 09:23:33 +0100 Subject: Update to natty (2.6.38-7) base Signed-off-by: Henrik Rydberg --- usr/src/dkms_source_tree/hid-ntrig.c | 44 ++++++--------- usr/src/dkms_source_tree/usbhid.h | 106 +++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 26 deletions(-) create mode 100644 usr/src/dkms_source_tree/usbhid.h diff --git a/usr/src/dkms_source_tree/hid-ntrig.c b/usr/src/dkms_source_tree/hid-ntrig.c index 2d6cbc1..0fab58b 100644 --- a/usr/src/dkms_source_tree/hid-ntrig.c +++ b/usr/src/dkms_source_tree/hid-ntrig.c @@ -17,17 +17,12 @@ #include #include #include +#include "usbhid.h" #include #include #include "hid-ids.h" -void usbhid_submit_report -(struct hid_device *hid, struct hid_report *report, unsigned char dir); - -#define hid_to_usb_dev(hid_dev) \ - container_of(hid_dev->dev.parent->parent, struct usb_device, dev) - #define NTRIG_DUPLICATE_USAGES 0x001 #define MAX_SLOTS 20 @@ -100,8 +95,7 @@ static void ntrig_report_version(struct hid_device *hdev) if (ret == 8) { ret = ntrig_version_string(&data[2], buf); - dev_info(&hdev->dev, - "Firmware version: %s (%02x%02x %02x%02x)\n", + hid_info(hdev, "Firmware version: %s (%02x%02x %02x%02x)\n", buf, data[2], data[3], data[4], data[5]); } @@ -116,7 +110,7 @@ err_free: */ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi, - struct hid_field *field, struct hid_usage *usage, + struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { struct ntrig_data *nd = hid_get_drvdata(hdev); @@ -203,8 +197,8 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi, } static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi, - struct hid_field *field, struct hid_usage *usage, - unsigned long **bit, int *max) + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) { /* No special mappings needed for the pen and single touch */ if (field->physical) @@ -336,7 +330,7 @@ static void report_frame(struct input_dev *input, struct ntrig_data *nd) * and call input_mt_sync after each point if necessary */ static int ntrig_event (struct hid_device *hid, struct hid_field *field, - struct hid_usage *usage, __s32 value) + struct hid_usage *usage, __s32 value) { struct input_dev *input = field->hidinput->input; struct ntrig_data *nd = hid_get_drvdata(hid); @@ -370,15 +364,15 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field, } break; case HID_DG_CONTACTCOUNT: /* End of a multitouch group */ - if (nd->hasmt) { - nd->nindex = 0; - nd->ncol = value; - /* skip pen switch events */ - if (nd->ncol == 1 && - nd->col[0].w == 10 && nd->col[0].h == 10) - break; - report_frame(input, nd); - } + if (!nd->hasmt) + break; + nd->nindex = 0; + nd->ncol = value; + /* skip pen switch events */ + if (nd->ncol == 1 && + nd->col[0].w == 10 && nd->col[0].h == 10) + break; + report_frame(input, nd); break; } } @@ -403,7 +397,7 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) nd = kzalloc(sizeof(struct ntrig_data), GFP_KERNEL); if (!nd) { - dev_err(&hdev->dev, "cannot allocate N-Trig data\n"); + hid_err(hdev, "cannot allocate N-Trig data\n"); return -ENOMEM; } @@ -411,13 +405,13 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) ret = hid_parse(hdev); if (ret) { - dev_err(&hdev->dev, "parse failed\n"); + hid_err(hdev, "parse failed\n"); goto err_free; } ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); if (ret) { - dev_err(&hdev->dev, "hw start failed\n"); + hid_err(hdev, "hw start failed\n"); goto err_free; } @@ -448,7 +442,6 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) ntrig_report_version(hdev); - return 0; err_free: kfree(nd); @@ -460,7 +453,6 @@ static void ntrig_remove(struct hid_device *hdev) hid_hw_stop(hdev); kfree(hid_get_drvdata(hdev)); } - #define NTRIG_DEVICE(id) \ { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, id), \ .driver_data = NTRIG_DUPLICATE_USAGES } diff --git a/usr/src/dkms_source_tree/usbhid.h b/usr/src/dkms_source_tree/usbhid.h new file mode 100644 index 0000000..1673cac --- /dev/null +++ b/usr/src/dkms_source_tree/usbhid.h @@ -0,0 +1,106 @@ +#ifndef __USBHID_H +#define __USBHID_H + +/* + * Copyright (c) 1999 Andreas Gal + * Copyright (c) 2000-2001 Vojtech Pavlik + * Copyright (c) 2006 Jiri Kosina + */ + +/* + * 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 + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* API provided by hid-core.c for USB HID drivers */ +int usbhid_wait_io(struct hid_device* hid); +void usbhid_close(struct hid_device *hid); +int usbhid_open(struct hid_device *hid); +void usbhid_init_reports(struct hid_device *hid); +void usbhid_submit_report +(struct hid_device *hid, struct hid_report *report, unsigned char dir); +int usbhid_get_power(struct hid_device *hid); +void usbhid_put_power(struct hid_device *hid); +struct usb_interface *usbhid_find_interface(int minor); + +/* iofl flags */ +#define HID_CTRL_RUNNING 1 +#define HID_OUT_RUNNING 2 +#define HID_IN_RUNNING 3 +#define HID_RESET_PENDING 4 +#define HID_SUSPENDED 5 +#define HID_CLEAR_HALT 6 +#define HID_DISCONNECTED 7 +#define HID_STARTED 8 +#define HID_REPORTED_IDLE 9 +#define HID_KEYS_PRESSED 10 +#define HID_LED_ON 11 + +/* + * USB-specific HID struct, to be pointed to + * from struct hid_device->driver_data + */ + +struct usbhid_device { + struct hid_device *hid; /* pointer to corresponding HID dev */ + + struct usb_interface *intf; /* USB interface */ + int ifnum; /* USB interface number */ + + unsigned int bufsize; /* URB buffer size */ + + struct urb *urbin; /* Input URB */ + char *inbuf; /* Input buffer */ + dma_addr_t inbuf_dma; /* Input buffer dma */ + + struct urb *urbctrl; /* Control URB */ + struct usb_ctrlrequest *cr; /* Control request struct */ + struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */ + unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */ + char *ctrlbuf; /* Control buffer */ + dma_addr_t ctrlbuf_dma; /* Control buffer dma */ + unsigned long last_ctrl; /* record of last output for timeouts */ + + struct urb *urbout; /* Output URB */ + struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */ + unsigned char outhead, outtail; /* Output pipe fifo head & tail */ + char *outbuf; /* Output buffer */ + dma_addr_t outbuf_dma; /* Output buffer dma */ + unsigned long last_out; /* record of last output for timeouts */ + + spinlock_t lock; /* fifo spinlock */ + unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ + struct timer_list io_retry; /* Retry timer */ + unsigned long stop_retry; /* Time to give up, in jiffies */ + unsigned int retry_delay; /* Delay length in ms */ + struct work_struct reset_work; /* Task context for resets */ + wait_queue_head_t wait; /* For sleeping */ + int ledcount; /* counting the number of active leds */ +}; + +#define hid_to_usb_dev(hid_dev) \ + container_of(hid_dev->dev.parent->parent, struct usb_device, dev) + +#endif + -- cgit v1.2.3