Merge branch 'upstream' into for-linus
[cascardo/linux.git] / include / linux / hid.h
index c235e4e..449fa38 100644 (file)
@@ -72,6 +72,7 @@
 #include <linux/workqueue.h>
 #include <linux/input.h>
 #include <linux/semaphore.h>
+#include <linux/power_supply.h>
 
 /*
  * We parse each description item into this structure. Short items data
@@ -190,6 +191,7 @@ struct hid_item {
 #define HID_UP_UNDEFINED       0x00000000
 #define HID_UP_GENDESK         0x00010000
 #define HID_UP_SIMULATION      0x00020000
+#define HID_UP_GENDEVCTRLS     0x00060000
 #define HID_UP_KEYBOARD                0x00070000
 #define HID_UP_LED             0x00080000
 #define HID_UP_BUTTON          0x00090000
@@ -239,6 +241,8 @@ struct hid_item {
 #define HID_GD_RIGHT           0x00010092
 #define HID_GD_LEFT            0x00010093
 
+#define HID_DC_BATTERYSTRENGTH 0x00060020
+
 #define HID_DG_DIGITIZER       0x000d0001
 #define HID_DG_PEN             0x000d0002
 #define HID_DG_LIGHTPEN                0x000d0003
@@ -313,13 +317,18 @@ struct hid_item {
 #define HID_QUIRK_BADPAD                       0x00000020
 #define HID_QUIRK_MULTI_INPUT                  0x00000040
 #define HID_QUIRK_HIDINPUT_FORCE               0x00000080
-#define HID_QUIRK_MULTITOUCH                   0x00000100
 #define HID_QUIRK_SKIP_OUTPUT_REPORTS          0x00010000
 #define HID_QUIRK_FULLSPEED_INTERVAL           0x10000000
 #define HID_QUIRK_NO_INIT_REPORTS              0x20000000
 #define HID_QUIRK_NO_IGNORE                    0x40000000
 #define HID_QUIRK_NO_INPUT_SYNC                        0x80000000
 
+/*
+ * HID device groups
+ */
+#define HID_GROUP_GENERIC                      0x0001
+#define HID_GROUP_MULTITOUCH                   0x0002
+
 /*
  * This is the global environment of the parser. This information is
  * persistent for main-items. The global environment can be saved and
@@ -463,6 +472,8 @@ struct hid_driver;
 struct hid_ll_driver;
 
 struct hid_device {                                                    /* device report descriptor */
+       __u8 *dev_rdesc;
+       unsigned dev_rsize;
        __u8 *rdesc;
        unsigned rsize;
        struct hid_collection *collection;                              /* List of HID collections */
@@ -470,6 +481,7 @@ struct hid_device {                                                 /* device report descriptor */
        unsigned maxcollection;                                         /* Number of parsed collections */
        unsigned maxapplication;                                        /* Number of applications */
        __u16 bus;                                                      /* BUS ID */
+       __u16 group;                                                    /* Report group */
        __u32 vendor;                                                   /* Vendor ID */
        __u32 product;                                                  /* Product ID */
        __u32 version;                                                  /* HID version */
@@ -482,6 +494,19 @@ struct hid_device {                                                        /* device report descriptor */
        struct hid_driver *driver;
        struct hid_ll_driver *ll_driver;
 
+#ifdef CONFIG_HID_BATTERY_STRENGTH
+       /*
+        * Power supply information for HID devices which report
+        * battery strength. power_supply is registered iff
+        * battery.name is non-NULL.
+        */
+       struct power_supply battery;
+       __s32 battery_min;
+       __s32 battery_max;
+       __s32 battery_report_type;
+       __s32 battery_report_id;
+#endif
+
        unsigned int status;                                            /* see STAT flags above */
        unsigned claimed;                                               /* Claimed by hidinput, hiddev? */
        unsigned quirks;                                                /* Various quirks the device can pull on us */
@@ -561,12 +586,12 @@ struct hid_descriptor {
        struct hid_class_descriptor desc[1];
 } __attribute__ ((packed));
 
-#define HID_DEVICE(b, ven, prod) \
-       .bus = (b), \
-       .vendor = (ven), .product = (prod)
-
-#define HID_USB_DEVICE(ven, prod)      HID_DEVICE(BUS_USB, ven, prod)
-#define HID_BLUETOOTH_DEVICE(ven, prod)        HID_DEVICE(BUS_BLUETOOTH, ven, prod)
+#define HID_DEVICE(b, g, ven, prod)                                    \
+       .bus = (b), .group = (g), .vendor = (ven), .product = (prod)
+#define HID_USB_DEVICE(ven, prod)                              \
+       .bus = BUS_USB, .vendor = (ven), .product = (prod)
+#define HID_BLUETOOTH_DEVICE(ven, prod)                                        \
+       .bus = BUS_BLUETOOTH, .vendor = (ven), .product = (prod)
 
 #define HID_REPORT_ID(rep) \
        .report_type = (rep)
@@ -712,13 +737,18 @@ extern void hidinput_disconnect(struct hid_device *);
 int hid_set_field(struct hid_field *, unsigned, __s32);
 int hid_input_report(struct hid_device *, int type, u8 *, int, int);
 int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field);
+struct hid_field *hidinput_get_led_field(struct hid_device *hid);
+unsigned int hidinput_count_leds(struct hid_device *hid);
 void hid_output_report(struct hid_report *report, __u8 *data);
 struct hid_device *hid_allocate_device(void);
 struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id);
 int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
+int hid_open_report(struct hid_device *device);
 int hid_check_keys_pressed(struct hid_device *hid);
 int hid_connect(struct hid_device *hid, unsigned int connect_mask);
 void hid_disconnect(struct hid_device *hid);
+const struct hid_device_id *hid_match_id(struct hid_device *hdev,
+                                        const struct hid_device_id *id);
 
 /**
  * hid_map_usage - map usage input bits
@@ -784,16 +814,7 @@ static inline void hid_map_usage_clear(struct hid_input *hidinput,
  */
 static inline int __must_check hid_parse(struct hid_device *hdev)
 {
-       int ret;
-
-       if (hdev->status & HID_STAT_PARSED)
-               return 0;
-
-       ret = hdev->ll_driver->parse(hdev);
-       if (!ret)
-               hdev->status |= HID_STAT_PARSED;
-
-       return ret;
+       return hid_open_report(hdev);
 }
 
 /**
@@ -875,7 +896,7 @@ static inline int hid_hw_power(struct hid_device *hdev, int level)
        return hdev->ll_driver->power ? hdev->ll_driver->power(hdev, level) : 0;
 }
 
-void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
+int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
                int interrupt);
 
 extern int hid_generic_init(void);