Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / usb / input / hid.h
index 283ddbc..9c62837 100644 (file)
@@ -31,6 +31,8 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/workqueue.h>
 
 /*
  * USB HID (Human Interface Device) interface class code
@@ -118,7 +120,7 @@ struct hid_item {
 #define HID_MAIN_ITEM_CONSTANT         0x001
 #define HID_MAIN_ITEM_VARIABLE         0x002
 #define HID_MAIN_ITEM_RELATIVE         0x004
-#define HID_MAIN_ITEM_WRAP             0x008   
+#define HID_MAIN_ITEM_WRAP             0x008
 #define HID_MAIN_ITEM_NONLINEAR                0x010
 #define HID_MAIN_ITEM_NO_PREFERRED     0x020
 #define HID_MAIN_ITEM_NULL_STATE       0x040
@@ -171,15 +173,20 @@ struct hid_item {
 
 #define HID_USAGE_PAGE         0xffff0000
 
-#define HID_UP_GENDESK                 0x00010000
-#define HID_UP_KEYBOARD        0x00070000
-#define HID_UP_LED             0x00080000
-#define HID_UP_BUTTON          0x00090000
-#define HID_UP_ORDINAL                 0x000a0000
+#define HID_UP_UNDEFINED       0x00000000
+#define HID_UP_GENDESK         0x00010000
+#define HID_UP_SIMULATION      0x00020000
+#define HID_UP_KEYBOARD                0x00070000
+#define HID_UP_LED             0x00080000
+#define HID_UP_BUTTON          0x00090000
+#define HID_UP_ORDINAL         0x000a0000
 #define HID_UP_CONSUMER                0x000c0000
-#define HID_UP_DIGITIZER       0x000d0000
-#define HID_UP_PID             0x000f0000
+#define HID_UP_DIGITIZER       0x000d0000
+#define HID_UP_PID             0x000f0000
 #define HID_UP_HPVENDOR         0xff7f0000
+#define HID_UP_MSVENDOR                0xff000000
+#define HID_UP_CUSTOM          0x00ff0000
+#define HID_UP_LOGIVENDOR      0xffbc0000
 
 #define HID_USAGE              0x0000ffff
 
@@ -187,7 +194,36 @@ struct hid_item {
 #define HID_GD_MOUSE           0x00010002
 #define HID_GD_JOYSTICK                0x00010004
 #define HID_GD_GAMEPAD         0x00010005
+#define HID_GD_KEYBOARD                0x00010006
+#define HID_GD_KEYPAD          0x00010007
+#define HID_GD_MULTIAXIS       0x00010008
+#define HID_GD_X               0x00010030
+#define HID_GD_Y               0x00010031
+#define HID_GD_Z               0x00010032
+#define HID_GD_RX              0x00010033
+#define HID_GD_RY              0x00010034
+#define HID_GD_RZ              0x00010035
+#define HID_GD_SLIDER          0x00010036
+#define HID_GD_DIAL            0x00010037
+#define HID_GD_WHEEL           0x00010038
 #define HID_GD_HATSWITCH       0x00010039
+#define HID_GD_BUFFER          0x0001003a
+#define HID_GD_BYTECOUNT       0x0001003b
+#define HID_GD_MOTION          0x0001003c
+#define HID_GD_START           0x0001003d
+#define HID_GD_SELECT          0x0001003e
+#define HID_GD_VX              0x00010040
+#define HID_GD_VY              0x00010041
+#define HID_GD_VZ              0x00010042
+#define HID_GD_VBRX            0x00010043
+#define HID_GD_VBRY            0x00010044
+#define HID_GD_VBRZ            0x00010045
+#define HID_GD_VNO             0x00010046
+#define HID_GD_FEATURE         0x00010047
+#define HID_GD_UP              0x00010090
+#define HID_GD_DOWN            0x00010091
+#define HID_GD_RIGHT           0x00010092
+#define HID_GD_LEFT            0x00010093
 
 /*
  * HID report types --- Ouch! HID spec says 1 2 3!
@@ -201,16 +237,20 @@ struct hid_item {
  * HID device quirks.
  */
 
-#define HID_QUIRK_INVERT                       0x001
-#define HID_QUIRK_NOTOUCH                      0x002
-#define HID_QUIRK_IGNORE                       0x004
-#define HID_QUIRK_NOGET                                0x008
-#define HID_QUIRK_HIDDEV                       0x010
-#define HID_QUIRK_BADPAD                       0x020
-#define HID_QUIRK_MULTI_INPUT                  0x040
-#define HID_QUIRK_2WHEEL_MOUSE_HACK_BACK       0x080
-#define HID_QUIRK_2WHEEL_MOUSE_HACK_EXTRA      0x100
-#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON         0x200
+#define HID_QUIRK_INVERT                       0x00000001
+#define HID_QUIRK_NOTOUCH                      0x00000002
+#define HID_QUIRK_IGNORE                       0x00000004
+#define HID_QUIRK_NOGET                                0x00000008
+#define HID_QUIRK_HIDDEV                       0x00000010
+#define HID_QUIRK_BADPAD                       0x00000020
+#define HID_QUIRK_MULTI_INPUT                  0x00000040
+#define HID_QUIRK_2WHEEL_MOUSE_HACK_7          0x00000080
+#define HID_QUIRK_2WHEEL_MOUSE_HACK_5          0x00000100
+#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON         0x00000200
+#define HID_QUIRK_2WHEEL_POWERMOUSE            0x00000400
+#define HID_QUIRK_CYMOTION                     0x00000800
+#define HID_QUIRK_POWERBOOK_HAS_FN             0x00001000
+#define HID_QUIRK_POWERBOOK_FN_ON              0x00002000
 
 /*
  * This is the global environment of the parser. This information is
@@ -262,12 +302,16 @@ struct hid_collection {
 struct hid_usage {
        unsigned  hid;                  /* hid usage code */
        unsigned  collection_index;     /* index into collection array */
+       /* hidinput data */
        __u16     code;                 /* input driver code */
        __u8      type;                 /* input driver type */
        __s8      hat_min;              /* hat switch fun */
        __s8      hat_max;              /* ditto */
+       __s8      hat_dir;              /* ditto */
 };
 
+struct hid_input;
+
 struct hid_field {
        unsigned  physical;             /* physical usage for this field */
        unsigned  logical;              /* logical usage for this field */
@@ -288,6 +332,9 @@ struct hid_field {
        unsigned  unit;
        struct hid_report *report;      /* associated report */
        unsigned index;                 /* index into report->field[] */
+       /* hidinput data */
+       struct hid_input *hidinput;     /* associated input structure */
+       __u16 dpad;                     /* dpad input code */
 };
 
 #define HID_MAX_FIELDS 64
@@ -310,7 +357,8 @@ struct hid_report_enum {
 
 #define HID_REPORT_TYPES 3
 
-#define HID_BUFFER_SIZE                64              /* use 64 for compatibility with all possible packetlen */
+#define HID_MIN_BUFFER_SIZE    64              /* make sure there is at least a packet size of space */
+#define HID_MAX_BUFFER_SIZE    4096            /* 4kb */
 #define HID_CONTROL_FIFO_SIZE  256             /* to init devices with >100 reports */
 #define HID_OUTPUT_FIFO_SIZE   64
 
@@ -324,11 +372,14 @@ struct hid_control_fifo {
 
 #define HID_CTRL_RUNNING       1
 #define HID_OUT_RUNNING                2
+#define HID_IN_RUNNING         3
+#define HID_RESET_PENDING      4
+#define HID_SUSPENDED          5
 
 struct hid_input {
        struct list_head list;
        struct hid_report *report;
-       struct input_dev input;
+       struct input_dev *input;
 };
 
 struct hid_device {                                                    /* device report descriptor */
@@ -347,10 +398,17 @@ struct hid_device {                                                       /* device report descriptor */
        int ifnum;                                                      /* USB interface number */
 
        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 */
+
+       unsigned int bufsize;                                           /* URB buffer size */
 
        struct urb *urbin;                                              /* Input URB */
        char *inbuf;                                                    /* Input buffer */
        dma_addr_t inbuf_dma;                                           /* Input buffer dma */
+       spinlock_t inlock;                                              /* Input fifo spinlock */
 
        struct urb *urbctrl;                                            /* Control URB */
        struct usb_ctrlrequest *cr;                                     /* Control request struct */
@@ -368,7 +426,7 @@ struct hid_device {                                                 /* device report descriptor */
        dma_addr_t outbuf_dma;                                          /* Output buffer dma */
        spinlock_t outlock;                                             /* Output fifo spinlock */
 
-       unsigned claimed;                                               /* Claimed by hidinput, hiddev? */      
+       unsigned claimed;                                               /* Claimed by hidinput, hiddev? */
        unsigned quirks;                                                /* Various quirks the device can pull on us */
 
        struct list_head inputs;                                        /* The list of inputs */
@@ -386,6 +444,11 @@ struct hid_device {                                                        /* device report descriptor */
        void (*ff_exit)(struct hid_device*);                            /* Called by hid_exit_ff(hid) */
        int (*ff_event)(struct hid_device *hid, struct input_dev *input,
                        unsigned int type, unsigned int code, int value);
+
+#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
+       unsigned long pb_pressed_fn[NBITS(KEY_MAX)];
+       unsigned long pb_pressed_numlock[NBITS(KEY_MAX)];
+#endif
 };
 
 #define HID_GLOBAL_STACK_SIZE 4
@@ -423,6 +486,7 @@ struct hid_descriptor {
 #define hid_dump_device(c)     do { } while (0)
 #define hid_dump_field(a,b)    do { } while (0)
 #define resolv_usage(a)                do { } while (0)
+#define resolv_event(a,b)      do { } while (0)
 #endif
 
 #endif
@@ -430,7 +494,7 @@ struct hid_descriptor {
 #ifdef CONFIG_USB_HIDINPUT
 /* Applications from HID Usage Tables 4/8/99 Version 1.1 */
 /* We ignore a few input applications that are not widely used */
-#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || ( a == 0x00010080) || ( a == 0x000c0001))
+#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001))
 extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32, struct pt_regs *regs);
 extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
 extern int hidinput_connect(struct hid_device *);
@@ -445,11 +509,10 @@ static inline void hidinput_disconnect(struct hid_device *hid) { }
 
 int hid_open(struct hid_device *);
 void hid_close(struct hid_device *);
-int hid_find_field(struct hid_device *, unsigned int, unsigned int, struct hid_field **);
 int hid_set_field(struct hid_field *, unsigned, __s32);
 void hid_submit_report(struct hid_device *, struct hid_report *, unsigned char dir);
 void hid_init_reports(struct hid_device *hid);
-int hid_find_report_by_usage(struct hid_device *hid, __u32 wanted_usage, struct hid_report **report, int type);
+struct hid_field *hid_find_field_by_usage(struct hid_device *hid, __u32 wanted_usage, int type);
 int hid_wait_io(struct hid_device* hid);
 
 
@@ -470,3 +533,8 @@ static inline int hid_ff_event(struct hid_device *hid, struct input_dev *input,
                return hid->ff_event(hid, input, type, code, value);
        return -ENOSYS;
 }
+
+int hid_lgff_init(struct hid_device* hid);
+int hid_tmff_init(struct hid_device* hid);
+int hid_pid_init(struct hid_device* hid);
+