diff options
43 files changed, 2491 insertions, 1050 deletions
diff --git a/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus b/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus index c2a270b45b03..833fd59926a7 100644 --- a/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus +++ b/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus | |||
| @@ -8,3 +8,41 @@ Description: The integer value of this attribute ranges from 0-4. | |||
| 8 | When written, this file sets the number of the startup profile | 8 | When written, this file sets the number of the startup profile |
| 9 | and the mouse activates this profile immediately. | 9 | and the mouse activates this profile immediately. |
| 10 | Please use actual_profile, it does the same thing. | 10 | Please use actual_profile, it does the same thing. |
| 11 | Users: http://roccat.sourceforge.net | ||
| 12 | |||
| 13 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/firmware_version | ||
| 14 | Date: October 2010 | ||
| 15 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 16 | Description: When read, this file returns the raw integer version number of the | ||
| 17 | firmware reported by the mouse. Using the integer value eases | ||
| 18 | further usage in other programs. To receive the real version | ||
| 19 | number the decimal point has to be shifted 2 positions to the | ||
| 20 | left. E.g. a returned value of 121 means 1.21 | ||
| 21 | This file is readonly. | ||
| 22 | Please read binary attribute info which contains firmware version. | ||
| 23 | Users: http://roccat.sourceforge.net | ||
| 24 | |||
| 25 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/profile[1-5]_buttons | ||
| 26 | Date: August 2010 | ||
| 27 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 28 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 29 | press of a button. A profile is split in settings and buttons. | ||
| 30 | profile_buttons holds information about button layout. | ||
| 31 | When read, these files return the respective profile buttons. | ||
| 32 | The returned data is 77 bytes in size. | ||
| 33 | This file is readonly. | ||
| 34 | Write control to select profile and read profile_buttons instead. | ||
| 35 | Users: http://roccat.sourceforge.net | ||
| 36 | |||
| 37 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/profile[1-5]_settings | ||
| 38 | Date: August 2010 | ||
| 39 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 40 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 41 | press of a button. A profile is split in settings and buttons. | ||
| 42 | profile_settings holds information like resolution, sensitivity | ||
| 43 | and light effects. | ||
| 44 | When read, these files return the respective profile settings. | ||
| 45 | The returned data is 43 bytes in size. | ||
| 46 | This file is readonly. | ||
| 47 | Write control to select profile and read profile_settings instead. | ||
| 48 | Users: http://roccat.sourceforge.net \ No newline at end of file | ||
diff --git a/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus b/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus new file mode 100644 index 000000000000..4a98e02b6c6a --- /dev/null +++ b/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/actual_cpi | ||
| 2 | Date: January 2011 | ||
| 3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 4 | Description: The integer value of this attribute ranges from 1-4. | ||
| 5 | When read, this attribute returns the number of the active | ||
| 6 | cpi level. | ||
| 7 | This file is readonly. | ||
| 8 | Has never been used. If bookkeeping is done, it's done in userland tools. | ||
| 9 | Users: http://roccat.sourceforge.net | ||
| 10 | |||
| 11 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/actual_sensitivity_x | ||
| 12 | Date: January 2011 | ||
| 13 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 14 | Description: The integer value of this attribute ranges from 1-10. | ||
| 15 | When read, this attribute returns the number of the actual | ||
| 16 | sensitivity in x direction. | ||
| 17 | This file is readonly. | ||
| 18 | Has never been used. If bookkeeping is done, it's done in userland tools. | ||
| 19 | Users: http://roccat.sourceforge.net | ||
| 20 | |||
| 21 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/actual_sensitivity_y | ||
| 22 | Date: January 2011 | ||
| 23 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 24 | Description: The integer value of this attribute ranges from 1-10. | ||
| 25 | When read, this attribute returns the number of the actual | ||
| 26 | sensitivity in y direction. | ||
| 27 | This file is readonly. | ||
| 28 | Has never been used. If bookkeeping is done, it's done in userland tools. | ||
| 29 | Users: http://roccat.sourceforge.net | ||
| 30 | |||
| 31 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/firmware_version | ||
| 32 | Date: January 2011 | ||
| 33 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 34 | Description: When read, this file returns the raw integer version number of the | ||
| 35 | firmware reported by the mouse. Using the integer value eases | ||
| 36 | further usage in other programs. To receive the real version | ||
| 37 | number the decimal point has to be shifted 2 positions to the | ||
| 38 | left. E.g. a returned value of 121 means 1.21 | ||
| 39 | This file is readonly. | ||
| 40 | Obsoleted by binary sysfs attribute "info". | ||
| 41 | Users: http://roccat.sourceforge.net | ||
| 42 | |||
| 43 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/profile[1-5]_buttons | ||
| 44 | Date: January 2011 | ||
| 45 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 46 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 47 | press of a button. A profile is split in settings and buttons. | ||
| 48 | profile_buttons holds information about button layout. | ||
| 49 | When read, these files return the respective profile buttons. | ||
| 50 | The returned data is 23 bytes in size. | ||
| 51 | This file is readonly. | ||
| 52 | Write control to select profile and read profile_buttons instead. | ||
| 53 | Users: http://roccat.sourceforge.net | ||
| 54 | |||
| 55 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/profile[1-5]_settings | ||
| 56 | Date: January 2011 | ||
| 57 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 58 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 59 | press of a button. A profile is split in settings and buttons. | ||
| 60 | profile_settings holds information like resolution, sensitivity | ||
| 61 | and light effects. | ||
| 62 | When read, these files return the respective profile settings. | ||
| 63 | The returned data is 16 bytes in size. | ||
| 64 | This file is readonly. | ||
| 65 | Write control to select profile and read profile_settings instead. | ||
| 66 | Users: http://roccat.sourceforge.net | ||
diff --git a/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra b/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra new file mode 100644 index 000000000000..87ac87e9556d --- /dev/null +++ b/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/actual_cpi | ||
| 2 | Date: August 2010 | ||
| 3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 4 | Description: It is possible to switch the cpi setting of the mouse with the | ||
| 5 | press of a button. | ||
| 6 | When read, this file returns the raw number of the actual cpi | ||
| 7 | setting reported by the mouse. This number has to be further | ||
| 8 | processed to receive the real dpi value. | ||
| 9 | |||
| 10 | VALUE DPI | ||
| 11 | 1 400 | ||
| 12 | 2 800 | ||
| 13 | 4 1600 | ||
| 14 | |||
| 15 | This file is readonly. | ||
| 16 | Has never been used. If bookkeeping is done, it's done in userland tools. | ||
| 17 | Users: http://roccat.sourceforge.net | ||
| 18 | |||
| 19 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/actual_profile | ||
| 20 | Date: August 2010 | ||
| 21 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 22 | Description: When read, this file returns the number of the actual profile in | ||
| 23 | range 0-4. | ||
| 24 | This file is readonly. | ||
| 25 | Please use binary attribute "settings" which provides this information. | ||
| 26 | Users: http://roccat.sourceforge.net | ||
| 27 | |||
| 28 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/firmware_version | ||
| 29 | Date: August 2010 | ||
| 30 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 31 | Description: When read, this file returns the raw integer version number of the | ||
| 32 | firmware reported by the mouse. Using the integer value eases | ||
| 33 | further usage in other programs. To receive the real version | ||
| 34 | number the decimal point has to be shifted 2 positions to the | ||
| 35 | left. E.g. a returned value of 138 means 1.38 | ||
| 36 | This file is readonly. | ||
| 37 | Please use binary attribute "info" which provides this information. | ||
| 38 | Users: http://roccat.sourceforge.net | ||
| 39 | |||
| 40 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile[1-5]_buttons | ||
| 41 | Date: August 2010 | ||
| 42 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 43 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 44 | press of a button. A profile is split in settings and buttons. | ||
| 45 | profile_buttons holds information about button layout. | ||
| 46 | When read, these files return the respective profile buttons. | ||
| 47 | The returned data is 19 bytes in size. | ||
| 48 | This file is readonly. | ||
| 49 | Write control to select profile and read profile_buttons instead. | ||
| 50 | Users: http://roccat.sourceforge.net | ||
| 51 | |||
| 52 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile[1-5]_settings | ||
| 53 | Date: August 2010 | ||
| 54 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 55 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 56 | press of a button. A profile is split in settings and buttons. | ||
| 57 | profile_settings holds information like resolution, sensitivity | ||
| 58 | and light effects. | ||
| 59 | When read, these files return the respective profile settings. | ||
| 60 | The returned data is 13 bytes in size. | ||
| 61 | This file is readonly. | ||
| 62 | Write control to select profile and read profile_settings instead. | ||
| 63 | Users: http://roccat.sourceforge.net | ||
| 64 | |||
| 65 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/startup_profile | ||
| 66 | Date: August 2010 | ||
| 67 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 68 | Description: The integer value of this attribute ranges from 0-4. | ||
| 69 | When read, this attribute returns the number of the profile | ||
| 70 | that's active when the mouse is powered on. | ||
| 71 | This file is readonly. | ||
| 72 | Please use binary attribute "settings" which provides this information. | ||
| 73 | Users: http://roccat.sourceforge.net | ||
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-roccat-isku b/Documentation/ABI/testing/sysfs-driver-hid-roccat-isku index 189dc43891bf..9eca5a182e64 100644 --- a/Documentation/ABI/testing/sysfs-driver-hid-roccat-isku +++ b/Documentation/ABI/testing/sysfs-driver-hid-roccat-isku | |||
| @@ -117,6 +117,14 @@ Description: When written, this file lets one store macros with max 500 | |||
| 117 | which profile and key to read. | 117 | which profile and key to read. |
| 118 | Users: http://roccat.sourceforge.net | 118 | Users: http://roccat.sourceforge.net |
| 119 | 119 | ||
| 120 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/isku/roccatisku<minor>/reset | ||
| 121 | Date: November 2012 | ||
| 122 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 123 | Description: When written, this file lets one reset the device. | ||
| 124 | The data has to be 3 bytes long. | ||
| 125 | This file is writeonly. | ||
| 126 | Users: http://roccat.sourceforge.net | ||
| 127 | |||
| 120 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/isku/roccatisku<minor>/control | 128 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/isku/roccatisku<minor>/control |
| 121 | Date: June 2011 | 129 | Date: June 2011 |
| 122 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 130 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus b/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus index 65e6e5dd67e8..7bd776f9c3c7 100644 --- a/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus +++ b/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus | |||
| @@ -9,15 +9,12 @@ Description: The integer value of this attribute ranges from 0-4. | |||
| 9 | and the mouse activates this profile immediately. | 9 | and the mouse activates this profile immediately. |
| 10 | Users: http://roccat.sourceforge.net | 10 | Users: http://roccat.sourceforge.net |
| 11 | 11 | ||
| 12 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/firmware_version | 12 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/info |
| 13 | Date: October 2010 | 13 | Date: November 2012 |
| 14 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 14 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
| 15 | Description: When read, this file returns the raw integer version number of the | 15 | Description: When read, this file returns general data like firmware version. |
| 16 | firmware reported by the mouse. Using the integer value eases | 16 | When written, the device can be reset. |
| 17 | further usage in other programs. To receive the real version | 17 | The data is 8 bytes long. |
| 18 | number the decimal point has to be shifted 2 positions to the | ||
| 19 | left. E.g. a returned value of 121 means 1.21 | ||
| 20 | This file is readonly. | ||
| 21 | Users: http://roccat.sourceforge.net | 18 | Users: http://roccat.sourceforge.net |
| 22 | 19 | ||
| 23 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/macro | 20 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/macro |
| @@ -42,18 +39,8 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
| 42 | The mouse will reject invalid data. | 39 | The mouse will reject invalid data. |
| 43 | Which profile to write is determined by the profile number | 40 | Which profile to write is determined by the profile number |
| 44 | contained in the data. | 41 | contained in the data. |
| 45 | This file is writeonly. | 42 | Before reading this file, control has to be written to select |
| 46 | Users: http://roccat.sourceforge.net | 43 | which profile to read. |
| 47 | |||
| 48 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/profile[1-5]_buttons | ||
| 49 | Date: August 2010 | ||
| 50 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 51 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 52 | press of a button. A profile is split in settings and buttons. | ||
| 53 | profile_buttons holds information about button layout. | ||
| 54 | When read, these files return the respective profile buttons. | ||
| 55 | The returned data is 77 bytes in size. | ||
| 56 | This file is readonly. | ||
| 57 | Users: http://roccat.sourceforge.net | 44 | Users: http://roccat.sourceforge.net |
| 58 | 45 | ||
| 59 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/profile_settings | 46 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/profile_settings |
| @@ -68,19 +55,8 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
| 68 | The mouse will reject invalid data. | 55 | The mouse will reject invalid data. |
| 69 | Which profile to write is determined by the profile number | 56 | Which profile to write is determined by the profile number |
| 70 | contained in the data. | 57 | contained in the data. |
| 71 | This file is writeonly. | 58 | Before reading this file, control has to be written to select |
| 72 | Users: http://roccat.sourceforge.net | 59 | which profile to read. |
| 73 | |||
| 74 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/profile[1-5]_settings | ||
| 75 | Date: August 2010 | ||
| 76 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 77 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 78 | press of a button. A profile is split in settings and buttons. | ||
| 79 | profile_settings holds information like resolution, sensitivity | ||
| 80 | and light effects. | ||
| 81 | When read, these files return the respective profile settings. | ||
| 82 | The returned data is 43 bytes in size. | ||
| 83 | This file is readonly. | ||
| 84 | Users: http://roccat.sourceforge.net | 60 | Users: http://roccat.sourceforge.net |
| 85 | 61 | ||
| 86 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/sensor | 62 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/sensor |
| @@ -104,9 +80,9 @@ What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid- | |||
| 104 | Date: October 2010 | 80 | Date: October 2010 |
| 105 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 81 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
| 106 | Description: When written a calibration process for the tracking control unit | 82 | Description: When written a calibration process for the tracking control unit |
| 107 | can be initiated/cancelled. | 83 | can be initiated/cancelled. Also lets one read/write sensor |
| 108 | The data has to be 3 bytes long. | 84 | registers. |
| 109 | This file is writeonly. | 85 | The data has to be 4 bytes long. |
| 110 | Users: http://roccat.sourceforge.net | 86 | Users: http://roccat.sourceforge.net |
| 111 | 87 | ||
| 112 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/tcu_image | 88 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/tcu_image |
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-roccat-kovaplus b/Documentation/ABI/testing/sysfs-driver-hid-roccat-kovaplus index 20f937c9d84f..a10404f15a54 100644 --- a/Documentation/ABI/testing/sysfs-driver-hid-roccat-kovaplus +++ b/Documentation/ABI/testing/sysfs-driver-hid-roccat-kovaplus | |||
| @@ -1,12 +1,3 @@ | |||
| 1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/actual_cpi | ||
| 2 | Date: January 2011 | ||
| 3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 4 | Description: The integer value of this attribute ranges from 1-4. | ||
| 5 | When read, this attribute returns the number of the active | ||
| 6 | cpi level. | ||
| 7 | This file is readonly. | ||
| 8 | Users: http://roccat.sourceforge.net | ||
| 9 | |||
| 10 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/actual_profile | 1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/actual_profile |
| 11 | Date: January 2011 | 2 | Date: January 2011 |
| 12 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
| @@ -18,33 +9,12 @@ Description: The integer value of this attribute ranges from 0-4. | |||
| 18 | active when the mouse is powered on. | 9 | active when the mouse is powered on. |
| 19 | Users: http://roccat.sourceforge.net | 10 | Users: http://roccat.sourceforge.net |
| 20 | 11 | ||
| 21 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/actual_sensitivity_x | 12 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/info |
| 22 | Date: January 2011 | 13 | Date: November 2012 |
| 23 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 14 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
| 24 | Description: The integer value of this attribute ranges from 1-10. | 15 | Description: When read, this file returns general data like firmware version. |
| 25 | When read, this attribute returns the number of the actual | 16 | When written, the device can be reset. |
| 26 | sensitivity in x direction. | 17 | The data is 6 bytes long. |
| 27 | This file is readonly. | ||
| 28 | Users: http://roccat.sourceforge.net | ||
| 29 | |||
| 30 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/actual_sensitivity_y | ||
| 31 | Date: January 2011 | ||
| 32 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 33 | Description: The integer value of this attribute ranges from 1-10. | ||
| 34 | When read, this attribute returns the number of the actual | ||
| 35 | sensitivity in y direction. | ||
| 36 | This file is readonly. | ||
| 37 | Users: http://roccat.sourceforge.net | ||
| 38 | |||
| 39 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/firmware_version | ||
| 40 | Date: January 2011 | ||
| 41 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 42 | Description: When read, this file returns the raw integer version number of the | ||
| 43 | firmware reported by the mouse. Using the integer value eases | ||
| 44 | further usage in other programs. To receive the real version | ||
| 45 | number the decimal point has to be shifted 2 positions to the | ||
| 46 | left. E.g. a returned value of 121 means 1.21 | ||
| 47 | This file is readonly. | ||
| 48 | Users: http://roccat.sourceforge.net | 18 | Users: http://roccat.sourceforge.net |
| 49 | 19 | ||
| 50 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/profile_buttons | 20 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/profile_buttons |
| @@ -58,18 +28,8 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
| 58 | The mouse will reject invalid data. | 28 | The mouse will reject invalid data. |
| 59 | Which profile to write is determined by the profile number | 29 | Which profile to write is determined by the profile number |
| 60 | contained in the data. | 30 | contained in the data. |
| 61 | This file is writeonly. | 31 | Before reading this file, control has to be written to select |
| 62 | Users: http://roccat.sourceforge.net | 32 | which profile to read. |
| 63 | |||
| 64 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/profile[1-5]_buttons | ||
| 65 | Date: January 2011 | ||
| 66 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 67 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 68 | press of a button. A profile is split in settings and buttons. | ||
| 69 | profile_buttons holds information about button layout. | ||
| 70 | When read, these files return the respective profile buttons. | ||
| 71 | The returned data is 23 bytes in size. | ||
| 72 | This file is readonly. | ||
| 73 | Users: http://roccat.sourceforge.net | 33 | Users: http://roccat.sourceforge.net |
| 74 | 34 | ||
| 75 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/profile_settings | 35 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/profile_settings |
| @@ -84,17 +44,6 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
| 84 | The mouse will reject invalid data. | 44 | The mouse will reject invalid data. |
| 85 | Which profile to write is determined by the profile number | 45 | Which profile to write is determined by the profile number |
| 86 | contained in the data. | 46 | contained in the data. |
| 87 | This file is writeonly. | 47 | Before reading this file, control has to be written to select |
| 88 | Users: http://roccat.sourceforge.net | 48 | which profile to read. |
| 89 | |||
| 90 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kovaplus/roccatkovaplus<minor>/profile[1-5]_settings | ||
| 91 | Date: January 2011 | ||
| 92 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 93 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 94 | press of a button. A profile is split in settings and buttons. | ||
| 95 | profile_settings holds information like resolution, sensitivity | ||
| 96 | and light effects. | ||
| 97 | When read, these files return the respective profile settings. | ||
| 98 | The returned data is 16 bytes in size. | ||
| 99 | This file is readonly. | ||
| 100 | Users: http://roccat.sourceforge.net | 49 | Users: http://roccat.sourceforge.net |
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-roccat-lua b/Documentation/ABI/testing/sysfs-driver-hid-roccat-lua new file mode 100644 index 000000000000..31c6c4c8ba2b --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-hid-roccat-lua | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/control | ||
| 2 | Date: October 2012 | ||
| 3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 4 | Description: When written, cpi, button and light settings can be configured. | ||
| 5 | When read, actual cpi setting and sensor data are returned. | ||
| 6 | The data has to be 8 bytes long. | ||
| 7 | Users: http://roccat.sourceforge.net | ||
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-roccat-pyra b/Documentation/ABI/testing/sysfs-driver-hid-roccat-pyra index 3f8de50e4ff1..9fa9de30d14b 100644 --- a/Documentation/ABI/testing/sysfs-driver-hid-roccat-pyra +++ b/Documentation/ABI/testing/sysfs-driver-hid-roccat-pyra | |||
| @@ -1,37 +1,9 @@ | |||
| 1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/actual_cpi | 1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/info |
| 2 | Date: August 2010 | 2 | Date: November 2012 |
| 3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 4 | Description: It is possible to switch the cpi setting of the mouse with the | ||
| 5 | press of a button. | ||
| 6 | When read, this file returns the raw number of the actual cpi | ||
| 7 | setting reported by the mouse. This number has to be further | ||
| 8 | processed to receive the real dpi value. | ||
| 9 | |||
| 10 | VALUE DPI | ||
| 11 | 1 400 | ||
| 12 | 2 800 | ||
| 13 | 4 1600 | ||
| 14 | |||
| 15 | This file is readonly. | ||
| 16 | Users: http://roccat.sourceforge.net | ||
| 17 | |||
| 18 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/actual_profile | ||
| 19 | Date: August 2010 | ||
| 20 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
| 21 | Description: When read, this file returns the number of the actual profile in | 4 | Description: When read, this file returns general data like firmware version. |
| 22 | range 0-4. | 5 | When written, the device can be reset. |
| 23 | This file is readonly. | 6 | The data is 6 bytes long. |
| 24 | Users: http://roccat.sourceforge.net | ||
| 25 | |||
| 26 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/firmware_version | ||
| 27 | Date: August 2010 | ||
| 28 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 29 | Description: When read, this file returns the raw integer version number of the | ||
| 30 | firmware reported by the mouse. Using the integer value eases | ||
| 31 | further usage in other programs. To receive the real version | ||
| 32 | number the decimal point has to be shifted 2 positions to the | ||
| 33 | left. E.g. a returned value of 138 means 1.38 | ||
| 34 | This file is readonly. | ||
| 35 | Users: http://roccat.sourceforge.net | 7 | Users: http://roccat.sourceforge.net |
| 36 | 8 | ||
| 37 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile_settings | 9 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile_settings |
| @@ -46,19 +18,8 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
| 46 | The mouse will reject invalid data. | 18 | The mouse will reject invalid data. |
| 47 | Which profile to write is determined by the profile number | 19 | Which profile to write is determined by the profile number |
| 48 | contained in the data. | 20 | contained in the data. |
| 49 | This file is writeonly. | 21 | Before reading this file, control has to be written to select |
| 50 | Users: http://roccat.sourceforge.net | 22 | which profile to read. |
| 51 | |||
| 52 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile[1-5]_settings | ||
| 53 | Date: August 2010 | ||
| 54 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 55 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 56 | press of a button. A profile is split in settings and buttons. | ||
| 57 | profile_settings holds information like resolution, sensitivity | ||
| 58 | and light effects. | ||
| 59 | When read, these files return the respective profile settings. | ||
| 60 | The returned data is 13 bytes in size. | ||
| 61 | This file is readonly. | ||
| 62 | Users: http://roccat.sourceforge.net | 23 | Users: http://roccat.sourceforge.net |
| 63 | 24 | ||
| 64 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile_buttons | 25 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile_buttons |
| @@ -72,27 +33,8 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
| 72 | The mouse will reject invalid data. | 33 | The mouse will reject invalid data. |
| 73 | Which profile to write is determined by the profile number | 34 | Which profile to write is determined by the profile number |
| 74 | contained in the data. | 35 | contained in the data. |
| 75 | This file is writeonly. | 36 | Before reading this file, control has to be written to select |
| 76 | Users: http://roccat.sourceforge.net | 37 | which profile to read. |
| 77 | |||
| 78 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile[1-5]_buttons | ||
| 79 | Date: August 2010 | ||
| 80 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 81 | Description: The mouse can store 5 profiles which can be switched by the | ||
| 82 | press of a button. A profile is split in settings and buttons. | ||
| 83 | profile_buttons holds information about button layout. | ||
| 84 | When read, these files return the respective profile buttons. | ||
| 85 | The returned data is 19 bytes in size. | ||
| 86 | This file is readonly. | ||
| 87 | Users: http://roccat.sourceforge.net | ||
| 88 | |||
| 89 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/startup_profile | ||
| 90 | Date: August 2010 | ||
| 91 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 92 | Description: The integer value of this attribute ranges from 0-4. | ||
| 93 | When read, this attribute returns the number of the profile | ||
| 94 | that's active when the mouse is powered on. | ||
| 95 | This file is readonly. | ||
| 96 | Users: http://roccat.sourceforge.net | 38 | Users: http://roccat.sourceforge.net |
| 97 | 39 | ||
| 98 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/settings | 40 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/settings |
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-roccat-savu b/Documentation/ABI/testing/sysfs-driver-hid-roccat-savu index b42922cf6b1f..f1e02a98bd9d 100644 --- a/Documentation/ABI/testing/sysfs-driver-hid-roccat-savu +++ b/Documentation/ABI/testing/sysfs-driver-hid-roccat-savu | |||
| @@ -40,8 +40,8 @@ What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid- | |||
| 40 | Date: Mai 2012 | 40 | Date: Mai 2012 |
| 41 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 41 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
| 42 | Description: When read, this file returns general data like firmware version. | 42 | Description: When read, this file returns general data like firmware version. |
| 43 | When written, the device can be reset. | ||
| 43 | The data is 8 bytes long. | 44 | The data is 8 bytes long. |
| 44 | This file is readonly. | ||
| 45 | Users: http://roccat.sourceforge.net | 45 | Users: http://roccat.sourceforge.net |
| 46 | 46 | ||
| 47 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/savu/roccatsavu<minor>/macro | 47 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/savu/roccatsavu<minor>/macro |
| @@ -74,4 +74,3 @@ Description: The mouse has a Avago ADNS-3090 sensor. | |||
| 74 | This file allows reading and writing of the mouse sensors registers. | 74 | This file allows reading and writing of the mouse sensors registers. |
| 75 | The data has to be 4 bytes long. | 75 | The data has to be 4 bytes long. |
| 76 | Users: http://roccat.sourceforge.net | 76 | Users: http://roccat.sourceforge.net |
| 77 | |||
diff --git a/Documentation/input/event-codes.txt b/Documentation/input/event-codes.txt index 53305bd08182..f1ea2c69648d 100644 --- a/Documentation/input/event-codes.txt +++ b/Documentation/input/event-codes.txt | |||
| @@ -196,6 +196,17 @@ EV_MSC: | |||
| 196 | EV_MSC events are used for input and output events that do not fall under other | 196 | EV_MSC events are used for input and output events that do not fall under other |
| 197 | categories. | 197 | categories. |
| 198 | 198 | ||
| 199 | A few EV_MSC codes have special meaning: | ||
| 200 | |||
| 201 | * MSC_TIMESTAMP: | ||
| 202 | - Used to report the number of microseconds since the last reset. This event | ||
| 203 | should be coded as an uint32 value, which is allowed to wrap around with | ||
| 204 | no special consequence. It is assumed that the time difference between two | ||
| 205 | consecutive events is reliable on a reasonable time scale (hours). | ||
| 206 | A reset to zero can happen, in which case the time since the last event is | ||
| 207 | unknown. If the device does not provide this information, the driver must | ||
| 208 | not provide it to user space. | ||
| 209 | |||
| 199 | EV_LED: | 210 | EV_LED: |
| 200 | ---------- | 211 | ---------- |
| 201 | EV_LED events are used for input and output to set and query the state of | 212 | EV_LED events are used for input and output to set and query the state of |
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 1630150ad2b1..e7d6a13ec6a6 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
| @@ -265,6 +265,15 @@ config HID_GYRATION | |||
| 265 | ---help--- | 265 | ---help--- |
| 266 | Support for Gyration remote control. | 266 | Support for Gyration remote control. |
| 267 | 267 | ||
| 268 | config HID_ICADE | ||
| 269 | tristate "ION iCade arcade controller" | ||
| 270 | depends on BT_HIDP | ||
| 271 | ---help--- | ||
| 272 | Support for the ION iCade arcade controller to work as a joystick. | ||
| 273 | |||
| 274 | To compile this driver as a module, choose M here: the | ||
| 275 | module will be called hid-icade. | ||
| 276 | |||
| 268 | config HID_TWINHAN | 277 | config HID_TWINHAN |
| 269 | tristate "Twinhan IR remote control" | 278 | tristate "Twinhan IR remote control" |
| 270 | depends on USB_HID | 279 | depends on USB_HID |
| @@ -728,4 +737,6 @@ endif # HID | |||
| 728 | 737 | ||
| 729 | source "drivers/hid/usbhid/Kconfig" | 738 | source "drivers/hid/usbhid/Kconfig" |
| 730 | 739 | ||
| 740 | source "drivers/hid/i2c-hid/Kconfig" | ||
| 741 | |||
| 731 | endmenu | 742 | endmenu |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index cef68ca859d3..b62215716b2f 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
| @@ -52,6 +52,7 @@ obj-$(CONFIG_HID_GYRATION) += hid-gyration.o | |||
| 52 | obj-$(CONFIG_HID_HOLTEK) += hid-holtek-kbd.o | 52 | obj-$(CONFIG_HID_HOLTEK) += hid-holtek-kbd.o |
| 53 | obj-$(CONFIG_HID_HOLTEK) += hid-holtekff.o | 53 | obj-$(CONFIG_HID_HOLTEK) += hid-holtekff.o |
| 54 | obj-$(CONFIG_HID_HYPERV_MOUSE) += hid-hyperv.o | 54 | obj-$(CONFIG_HID_HYPERV_MOUSE) += hid-hyperv.o |
| 55 | obj-$(CONFIG_HID_ICADE) += hid-icade.o | ||
| 55 | obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o | 56 | obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o |
| 56 | obj-$(CONFIG_HID_KEYTOUCH) += hid-keytouch.o | 57 | obj-$(CONFIG_HID_KEYTOUCH) += hid-keytouch.o |
| 57 | obj-$(CONFIG_HID_KYE) += hid-kye.o | 58 | obj-$(CONFIG_HID_KYE) += hid-kye.o |
| @@ -93,8 +94,8 @@ obj-$(CONFIG_HID_PRIMAX) += hid-primax.o | |||
| 93 | obj-$(CONFIG_HID_PS3REMOTE) += hid-ps3remote.o | 94 | obj-$(CONFIG_HID_PS3REMOTE) += hid-ps3remote.o |
| 94 | obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \ | 95 | obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \ |
| 95 | hid-roccat-arvo.o hid-roccat-isku.o hid-roccat-kone.o \ | 96 | hid-roccat-arvo.o hid-roccat-isku.o hid-roccat-kone.o \ |
| 96 | hid-roccat-koneplus.o hid-roccat-kovaplus.o hid-roccat-pyra.o \ | 97 | hid-roccat-koneplus.o hid-roccat-kovaplus.o hid-roccat-lua.o \ |
| 97 | hid-roccat-savu.o | 98 | hid-roccat-pyra.o hid-roccat-savu.o |
| 98 | obj-$(CONFIG_HID_SAITEK) += hid-saitek.o | 99 | obj-$(CONFIG_HID_SAITEK) += hid-saitek.o |
| 99 | obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o | 100 | obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o |
| 100 | obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o | 101 | obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o |
| @@ -118,3 +119,4 @@ obj-$(CONFIG_USB_HID) += usbhid/ | |||
| 118 | obj-$(CONFIG_USB_MOUSE) += usbhid/ | 119 | obj-$(CONFIG_USB_MOUSE) += usbhid/ |
| 119 | obj-$(CONFIG_USB_KBD) += usbhid/ | 120 | obj-$(CONFIG_USB_KBD) += usbhid/ |
| 120 | 121 | ||
| 122 | obj-$(CONFIG_I2C_HID) += i2c-hid/ | ||
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index fd7722aecf77..d0f7662aacca 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c | |||
| @@ -439,7 +439,8 @@ static const struct hid_device_id apple_devices[] = { | |||
| 439 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI), | 439 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI), |
| 440 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | 440 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
| 441 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO), | 441 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO), |
| 442 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | 442 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
| 443 | APPLE_ISO_KEYBOARD }, | ||
| 443 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS), | 444 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS), |
| 444 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | 445 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
| 445 | APPLE_RDESC_JIS }, | 446 | APPLE_RDESC_JIS }, |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index f4109fd657ff..eb2ee11b6412 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
| @@ -92,6 +92,7 @@ EXPORT_SYMBOL_GPL(hid_register_report); | |||
| 92 | static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) | 92 | static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) |
| 93 | { | 93 | { |
| 94 | struct hid_field *field; | 94 | struct hid_field *field; |
| 95 | int i; | ||
| 95 | 96 | ||
| 96 | if (report->maxfield == HID_MAX_FIELDS) { | 97 | if (report->maxfield == HID_MAX_FIELDS) { |
| 97 | hid_err(report->device, "too many fields in report\n"); | 98 | hid_err(report->device, "too many fields in report\n"); |
| @@ -110,6 +111,9 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned | |||
| 110 | field->value = (s32 *)(field->usage + usages); | 111 | field->value = (s32 *)(field->usage + usages); |
| 111 | field->report = report; | 112 | field->report = report; |
| 112 | 113 | ||
| 114 | for (i = 0; i < usages; i++) | ||
| 115 | field->usage[i].usage_index = i; | ||
| 116 | |||
| 113 | return field; | 117 | return field; |
| 114 | } | 118 | } |
| 115 | 119 | ||
| @@ -315,6 +319,7 @@ static s32 item_sdata(struct hid_item *item) | |||
| 315 | 319 | ||
| 316 | static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) | 320 | static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) |
| 317 | { | 321 | { |
| 322 | __u32 raw_value; | ||
| 318 | switch (item->tag) { | 323 | switch (item->tag) { |
| 319 | case HID_GLOBAL_ITEM_TAG_PUSH: | 324 | case HID_GLOBAL_ITEM_TAG_PUSH: |
| 320 | 325 | ||
| @@ -365,7 +370,14 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) | |||
| 365 | return 0; | 370 | return 0; |
| 366 | 371 | ||
| 367 | case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: | 372 | case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: |
| 368 | parser->global.unit_exponent = item_sdata(item); | 373 | /* Units exponent negative numbers are given through a |
| 374 | * two's complement. | ||
| 375 | * See "6.2.2.7 Global Items" for more information. */ | ||
| 376 | raw_value = item_udata(item); | ||
| 377 | if (!(raw_value & 0xfffffff0)) | ||
| 378 | parser->global.unit_exponent = hid_snto32(raw_value, 4); | ||
| 379 | else | ||
| 380 | parser->global.unit_exponent = raw_value; | ||
| 369 | return 0; | 381 | return 0; |
| 370 | 382 | ||
| 371 | case HID_GLOBAL_ITEM_TAG_UNIT: | 383 | case HID_GLOBAL_ITEM_TAG_UNIT: |
| @@ -713,7 +725,12 @@ static int hid_scan_report(struct hid_device *hid) | |||
| 713 | hid_scan_usage(hid, u); | 725 | hid_scan_usage(hid, u); |
| 714 | break; | 726 | break; |
| 715 | } | 727 | } |
| 716 | } | 728 | } else if (page == HID_UP_SENSOR && |
| 729 | item.type == HID_ITEM_TYPE_MAIN && | ||
| 730 | item.tag == HID_MAIN_ITEM_TAG_BEGIN_COLLECTION && | ||
| 731 | (item_udata(&item) & 0xff) == HID_COLLECTION_PHYSICAL && | ||
| 732 | hid->bus == BUS_USB) | ||
| 733 | hid->group = HID_GROUP_SENSOR_HUB; | ||
| 717 | } | 734 | } |
| 718 | 735 | ||
| 719 | return 0; | 736 | return 0; |
| @@ -865,6 +882,12 @@ static s32 snto32(__u32 value, unsigned n) | |||
| 865 | return value & (1 << (n - 1)) ? value | (-1 << n) : value; | 882 | return value & (1 << (n - 1)) ? value | (-1 << n) : value; |
| 866 | } | 883 | } |
| 867 | 884 | ||
| 885 | s32 hid_snto32(__u32 value, unsigned n) | ||
| 886 | { | ||
| 887 | return snto32(value, n); | ||
| 888 | } | ||
| 889 | EXPORT_SYMBOL_GPL(hid_snto32); | ||
| 890 | |||
| 868 | /* | 891 | /* |
| 869 | * Convert a signed 32-bit integer to a signed n-bit integer. | 892 | * Convert a signed 32-bit integer to a signed n-bit integer. |
| 870 | */ | 893 | */ |
| @@ -1465,6 +1488,10 @@ EXPORT_SYMBOL_GPL(hid_disconnect); | |||
| 1465 | * there is a proper autodetection and autoloading in place (based on presence | 1488 | * there is a proper autodetection and autoloading in place (based on presence |
| 1466 | * of HID_DG_CONTACTID), so those devices don't need to be added to this list, | 1489 | * of HID_DG_CONTACTID), so those devices don't need to be added to this list, |
| 1467 | * as we are doing the right thing in hid_scan_usage(). | 1490 | * as we are doing the right thing in hid_scan_usage(). |
| 1491 | * | ||
| 1492 | * Autodetection for (USB) HID sensor hubs exists too. If a collection of type | ||
| 1493 | * physical is found inside a usage page of type sensor, hid-sensor-hub will be | ||
| 1494 | * used as a driver. See hid_scan_report(). | ||
| 1468 | */ | 1495 | */ |
| 1469 | static const struct hid_device_id hid_have_special_driver[] = { | 1496 | static const struct hid_device_id hid_have_special_driver[] = { |
| 1470 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, | 1497 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, |
| @@ -1538,6 +1565,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
| 1538 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, | 1565 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, |
| 1539 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, | 1566 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, |
| 1540 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, | 1567 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, |
| 1568 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI) }, | ||
| 1541 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) }, | 1569 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) }, |
| 1542 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, | 1570 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
| 1543 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, | 1571 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
| @@ -1571,10 +1599,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
| 1571 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, | 1599 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, |
| 1572 | { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) }, | 1600 | { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) }, |
| 1573 | { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD) }, | 1601 | { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD) }, |
| 1574 | { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8086, USB_DEVICE_ID_SENSOR_HUB_1020) }, | 1602 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ION, USB_DEVICE_ID_ICADE) }, |
| 1575 | { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8086, USB_DEVICE_ID_SENSOR_HUB_09FA) }, | ||
| 1576 | { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8087, USB_DEVICE_ID_SENSOR_HUB_1020) }, | ||
| 1577 | { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8087, USB_DEVICE_ID_SENSOR_HUB_09FA) }, | ||
| 1578 | { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, | 1603 | { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, |
| 1579 | { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, | 1604 | { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, |
| 1580 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, | 1605 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, |
| @@ -1658,6 +1683,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
| 1658 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) }, | 1683 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) }, |
| 1659 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, | 1684 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, |
| 1660 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) }, | 1685 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) }, |
| 1686 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_LUA) }, | ||
| 1661 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, | 1687 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, |
| 1662 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) }, | 1688 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) }, |
| 1663 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_SAVU) }, | 1689 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_SAVU) }, |
| @@ -1672,7 +1698,6 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
| 1672 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, | 1698 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, |
| 1673 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, | 1699 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, |
| 1674 | { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, | 1700 | { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, |
| 1675 | { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_SENSOR_HUB_7014) }, | ||
| 1676 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, | 1701 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, |
| 1677 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, | 1702 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, |
| 1678 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, | 1703 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, |
| @@ -2150,8 +2175,13 @@ static const struct hid_device_id hid_mouse_ignore_list[] = { | |||
| 2150 | { } | 2175 | { } |
| 2151 | }; | 2176 | }; |
| 2152 | 2177 | ||
| 2153 | static bool hid_ignore(struct hid_device *hdev) | 2178 | bool hid_ignore(struct hid_device *hdev) |
| 2154 | { | 2179 | { |
| 2180 | if (hdev->quirks & HID_QUIRK_NO_IGNORE) | ||
| 2181 | return false; | ||
| 2182 | if (hdev->quirks & HID_QUIRK_IGNORE) | ||
| 2183 | return true; | ||
| 2184 | |||
| 2155 | switch (hdev->vendor) { | 2185 | switch (hdev->vendor) { |
| 2156 | case USB_VENDOR_ID_CODEMERCS: | 2186 | case USB_VENDOR_ID_CODEMERCS: |
| 2157 | /* ignore all Code Mercenaries IOWarrior devices */ | 2187 | /* ignore all Code Mercenaries IOWarrior devices */ |
| @@ -2188,7 +2218,16 @@ static bool hid_ignore(struct hid_device *hdev) | |||
| 2188 | if (hdev->product == USB_DEVICE_ID_JESS_YUREX && | 2218 | if (hdev->product == USB_DEVICE_ID_JESS_YUREX && |
| 2189 | hdev->type == HID_TYPE_USBNONE) | 2219 | hdev->type == HID_TYPE_USBNONE) |
| 2190 | return true; | 2220 | return true; |
| 2191 | break; | 2221 | break; |
| 2222 | case USB_VENDOR_ID_DWAV: | ||
| 2223 | /* These are handled by usbtouchscreen. hdev->type is probably | ||
| 2224 | * HID_TYPE_USBNONE, but we say !HID_TYPE_USBMOUSE to match | ||
| 2225 | * usbtouchscreen. */ | ||
| 2226 | if ((hdev->product == USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER || | ||
| 2227 | hdev->product == USB_DEVICE_ID_DWAV_TOUCHCONTROLLER) && | ||
| 2228 | hdev->type != HID_TYPE_USBMOUSE) | ||
| 2229 | return true; | ||
| 2230 | break; | ||
| 2192 | } | 2231 | } |
| 2193 | 2232 | ||
| 2194 | if (hdev->type == HID_TYPE_USBMOUSE && | 2233 | if (hdev->type == HID_TYPE_USBMOUSE && |
| @@ -2197,6 +2236,7 @@ static bool hid_ignore(struct hid_device *hdev) | |||
| 2197 | 2236 | ||
| 2198 | return !!hid_match_id(hdev, hid_ignore_list); | 2237 | return !!hid_match_id(hdev, hid_ignore_list); |
| 2199 | } | 2238 | } |
| 2239 | EXPORT_SYMBOL_GPL(hid_ignore); | ||
| 2200 | 2240 | ||
| 2201 | int hid_add_device(struct hid_device *hdev) | 2241 | int hid_add_device(struct hid_device *hdev) |
| 2202 | { | 2242 | { |
| @@ -2208,8 +2248,7 @@ int hid_add_device(struct hid_device *hdev) | |||
| 2208 | 2248 | ||
| 2209 | /* we need to kill them here, otherwise they will stay allocated to | 2249 | /* we need to kill them here, otherwise they will stay allocated to |
| 2210 | * wait for coming driver */ | 2250 | * wait for coming driver */ |
| 2211 | if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) | 2251 | if (hid_ignore(hdev)) |
| 2212 | && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE))) | ||
| 2213 | return -ENODEV; | 2252 | return -ENODEV; |
| 2214 | 2253 | ||
| 2215 | /* | 2254 | /* |
diff --git a/drivers/hid/hid-icade.c b/drivers/hid/hid-icade.c new file mode 100644 index 000000000000..1d6565e37ba3 --- /dev/null +++ b/drivers/hid/hid-icade.c | |||
| @@ -0,0 +1,259 @@ | |||
| 1 | /* | ||
| 2 | * ION iCade input driver | ||
| 3 | * | ||
| 4 | * Copyright (c) 2012 Bastien Nocera <hadess@hadess.net> | ||
| 5 | * Copyright (c) 2012 Benjamin Tissoires <benjamin.tissoires@gmail.com> | ||
| 6 | */ | ||
| 7 | |||
| 8 | /* | ||
| 9 | * This program is free software; you can redistribute it and/or modify it | ||
| 10 | * under the terms of the GNU General Public License as published by the Free | ||
| 11 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 12 | * any later version. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <linux/device.h> | ||
| 16 | #include <linux/hid.h> | ||
| 17 | #include <linux/module.h> | ||
| 18 | |||
| 19 | #include "hid-ids.h" | ||
| 20 | |||
| 21 | /* | ||
| 22 | * ↑ A C Y L | ||
| 23 | * ← → | ||
| 24 | * ↓ B X Z R | ||
| 25 | * | ||
| 26 | * | ||
| 27 | * UP ON,OFF = w,e | ||
| 28 | * RT ON,OFF = d,c | ||
| 29 | * DN ON,OFF = x,z | ||
| 30 | * LT ON,OFF = a,q | ||
| 31 | * A ON,OFF = y,t | ||
| 32 | * B ON,OFF = h,r | ||
| 33 | * C ON,OFF = u,f | ||
| 34 | * X ON,OFF = j,n | ||
| 35 | * Y ON,OFF = i,m | ||
| 36 | * Z ON,OFF = k,p | ||
| 37 | * L ON,OFF = o,g | ||
| 38 | * R ON,OFF = l,v | ||
| 39 | */ | ||
| 40 | |||
| 41 | /* The translation code uses HID usage instead of input layer | ||
| 42 | * keys. This code generates a lookup table that makes | ||
| 43 | * translation quick. | ||
| 44 | * | ||
| 45 | * #include <linux/input.h> | ||
| 46 | * #include <stdio.h> | ||
| 47 | * #include <assert.h> | ||
| 48 | * | ||
| 49 | * #define unk KEY_UNKNOWN | ||
| 50 | * | ||
| 51 | * < copy of hid_keyboard[] from hid-input.c > | ||
| 52 | * | ||
| 53 | * struct icade_key_translation { | ||
| 54 | * int from; | ||
| 55 | * const char *to; | ||
| 56 | * int press; | ||
| 57 | * }; | ||
| 58 | * | ||
| 59 | * static const struct icade_key_translation icade_keys[] = { | ||
| 60 | * { KEY_W, "KEY_UP", 1 }, | ||
| 61 | * { KEY_E, "KEY_UP", 0 }, | ||
| 62 | * { KEY_D, "KEY_RIGHT", 1 }, | ||
| 63 | * { KEY_C, "KEY_RIGHT", 0 }, | ||
| 64 | * { KEY_X, "KEY_DOWN", 1 }, | ||
| 65 | * { KEY_Z, "KEY_DOWN", 0 }, | ||
| 66 | * { KEY_A, "KEY_LEFT", 1 }, | ||
| 67 | * { KEY_Q, "KEY_LEFT", 0 }, | ||
| 68 | * { KEY_Y, "BTN_A", 1 }, | ||
| 69 | * { KEY_T, "BTN_A", 0 }, | ||
| 70 | * { KEY_H, "BTN_B", 1 }, | ||
| 71 | * { KEY_R, "BTN_B", 0 }, | ||
| 72 | * { KEY_U, "BTN_C", 1 }, | ||
| 73 | * { KEY_F, "BTN_C", 0 }, | ||
| 74 | * { KEY_J, "BTN_X", 1 }, | ||
| 75 | * { KEY_N, "BTN_X", 0 }, | ||
| 76 | * { KEY_I, "BTN_Y", 1 }, | ||
| 77 | * { KEY_M, "BTN_Y", 0 }, | ||
| 78 | * { KEY_K, "BTN_Z", 1 }, | ||
| 79 | * { KEY_P, "BTN_Z", 0 }, | ||
| 80 | * { KEY_O, "BTN_THUMBL", 1 }, | ||
| 81 | * { KEY_G, "BTN_THUMBL", 0 }, | ||
| 82 | * { KEY_L, "BTN_THUMBR", 1 }, | ||
| 83 | * { KEY_V, "BTN_THUMBR", 0 }, | ||
| 84 | * | ||
| 85 | * { } | ||
| 86 | * }; | ||
| 87 | * | ||
| 88 | * static int | ||
| 89 | * usage_for_key (int key) | ||
| 90 | * { | ||
| 91 | * int i; | ||
| 92 | * for (i = 0; i < 256; i++) { | ||
| 93 | * if (hid_keyboard[i] == key) | ||
| 94 | * return i; | ||
| 95 | * } | ||
| 96 | * assert(0); | ||
| 97 | * } | ||
| 98 | * | ||
| 99 | * int main (int argc, char **argv) | ||
| 100 | * { | ||
| 101 | * const struct icade_key_translation *trans; | ||
| 102 | * int max_usage = 0; | ||
| 103 | * | ||
| 104 | * for (trans = icade_keys; trans->from; trans++) { | ||
| 105 | * int usage = usage_for_key (trans->from); | ||
| 106 | * max_usage = usage > max_usage ? usage : max_usage; | ||
| 107 | * } | ||
| 108 | * | ||
| 109 | * printf ("#define ICADE_MAX_USAGE %d\n\n", max_usage); | ||
| 110 | * printf ("struct icade_key {\n"); | ||
| 111 | * printf ("\tu16 to;\n"); | ||
| 112 | * printf ("\tu8 press:1;\n"); | ||
| 113 | * printf ("};\n\n"); | ||
| 114 | * printf ("static const struct icade_key " | ||
| 115 | * "icade_usage_table[%d] = {\n", max_usage + 1); | ||
| 116 | * for (trans = icade_keys; trans->from; trans++) { | ||
| 117 | * printf ("\t[%d] = { %s, %d },\n", | ||
| 118 | * usage_for_key (trans->from), trans->to, trans->press); | ||
| 119 | * } | ||
| 120 | * printf ("};\n"); | ||
| 121 | * | ||
| 122 | * return 0; | ||
| 123 | * } | ||
| 124 | */ | ||
| 125 | |||
| 126 | #define ICADE_MAX_USAGE 29 | ||
| 127 | |||
| 128 | struct icade_key { | ||
| 129 | u16 to; | ||
| 130 | u8 press:1; | ||
| 131 | }; | ||
| 132 | |||
| 133 | static const struct icade_key icade_usage_table[30] = { | ||
| 134 | [26] = { KEY_UP, 1 }, | ||
| 135 | [8] = { KEY_UP, 0 }, | ||
| 136 | [7] = { KEY_RIGHT, 1 }, | ||
| 137 | [6] = { KEY_RIGHT, 0 }, | ||
| 138 | [27] = { KEY_DOWN, 1 }, | ||
| 139 | [29] = { KEY_DOWN, 0 }, | ||
| 140 | [4] = { KEY_LEFT, 1 }, | ||
| 141 | [20] = { KEY_LEFT, 0 }, | ||
| 142 | [28] = { BTN_A, 1 }, | ||
| 143 | [23] = { BTN_A, 0 }, | ||
| 144 | [11] = { BTN_B, 1 }, | ||
| 145 | [21] = { BTN_B, 0 }, | ||
| 146 | [24] = { BTN_C, 1 }, | ||
| 147 | [9] = { BTN_C, 0 }, | ||
| 148 | [13] = { BTN_X, 1 }, | ||
| 149 | [17] = { BTN_X, 0 }, | ||
| 150 | [12] = { BTN_Y, 1 }, | ||
| 151 | [16] = { BTN_Y, 0 }, | ||
| 152 | [14] = { BTN_Z, 1 }, | ||
| 153 | [19] = { BTN_Z, 0 }, | ||
| 154 | [18] = { BTN_THUMBL, 1 }, | ||
| 155 | [10] = { BTN_THUMBL, 0 }, | ||
| 156 | [15] = { BTN_THUMBR, 1 }, | ||
| 157 | [25] = { BTN_THUMBR, 0 }, | ||
| 158 | }; | ||
| 159 | |||
| 160 | static const struct icade_key *icade_find_translation(u16 from) | ||
| 161 | { | ||
| 162 | if (from < 0 || from > ICADE_MAX_USAGE) | ||
| 163 | return NULL; | ||
| 164 | return &icade_usage_table[from]; | ||
| 165 | } | ||
| 166 | |||
| 167 | static int icade_event(struct hid_device *hdev, struct hid_field *field, | ||
| 168 | struct hid_usage *usage, __s32 value) | ||
| 169 | { | ||
| 170 | const struct icade_key *trans; | ||
| 171 | |||
| 172 | if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput || | ||
| 173 | !usage->type) | ||
| 174 | return 0; | ||
| 175 | |||
| 176 | /* We ignore the fake key up, and act only on key down */ | ||
| 177 | if (!value) | ||
| 178 | return 1; | ||
| 179 | |||
| 180 | trans = icade_find_translation(usage->hid & HID_USAGE); | ||
| 181 | |||
| 182 | if (!trans) | ||
| 183 | return 1; | ||
| 184 | |||
| 185 | input_event(field->hidinput->input, usage->type, | ||
| 186 | trans->to, trans->press); | ||
| 187 | |||
| 188 | return 1; | ||
| 189 | } | ||
| 190 | |||
| 191 | static int icade_input_mapping(struct hid_device *hdev, struct hid_input *hi, | ||
| 192 | struct hid_field *field, struct hid_usage *usage, | ||
| 193 | unsigned long **bit, int *max) | ||
| 194 | { | ||
| 195 | const struct icade_key *trans; | ||
| 196 | |||
| 197 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_KEYBOARD) { | ||
| 198 | trans = icade_find_translation(usage->hid & HID_USAGE); | ||
| 199 | |||
| 200 | if (!trans) | ||
| 201 | return -1; | ||
| 202 | |||
| 203 | hid_map_usage(hi, usage, bit, max, EV_KEY, trans->to); | ||
| 204 | set_bit(trans->to, hi->input->keybit); | ||
| 205 | |||
| 206 | return 1; | ||
| 207 | } | ||
| 208 | |||
| 209 | /* ignore others */ | ||
| 210 | return -1; | ||
| 211 | |||
| 212 | } | ||
| 213 | |||
| 214 | static int icade_input_mapped(struct hid_device *hdev, struct hid_input *hi, | ||
| 215 | struct hid_field *field, struct hid_usage *usage, | ||
| 216 | unsigned long **bit, int *max) | ||
| 217 | { | ||
| 218 | if (usage->type == EV_KEY) | ||
| 219 | set_bit(usage->type, hi->input->evbit); | ||
| 220 | |||
| 221 | return -1; | ||
| 222 | } | ||
| 223 | |||
| 224 | static const struct hid_device_id icade_devices[] = { | ||
| 225 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ION, USB_DEVICE_ID_ICADE) }, | ||
| 226 | |||
| 227 | { } | ||
| 228 | }; | ||
| 229 | MODULE_DEVICE_TABLE(hid, icade_devices); | ||
| 230 | |||
| 231 | static struct hid_driver icade_driver = { | ||
| 232 | .name = "icade", | ||
| 233 | .id_table = icade_devices, | ||
| 234 | .event = icade_event, | ||
| 235 | .input_mapped = icade_input_mapped, | ||
| 236 | .input_mapping = icade_input_mapping, | ||
| 237 | }; | ||
| 238 | |||
| 239 | static int __init icade_init(void) | ||
| 240 | { | ||
| 241 | int ret; | ||
| 242 | |||
| 243 | ret = hid_register_driver(&icade_driver); | ||
| 244 | if (ret) | ||
| 245 | pr_err("can't register icade driver\n"); | ||
| 246 | |||
| 247 | return ret; | ||
| 248 | } | ||
| 249 | |||
| 250 | static void __exit icade_exit(void) | ||
| 251 | { | ||
| 252 | hid_unregister_driver(&icade_driver); | ||
| 253 | } | ||
| 254 | |||
| 255 | module_init(icade_init); | ||
| 256 | module_exit(icade_exit); | ||
| 257 | MODULE_LICENSE("GPL"); | ||
| 258 | MODULE_AUTHOR("Bastien Nocera <hadess@hadess.net>"); | ||
| 259 | MODULE_DESCRIPTION("ION iCade input driver"); | ||
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 9d7a42857ea1..4dfa605e2d14 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
| @@ -257,6 +257,7 @@ | |||
| 257 | 257 | ||
| 258 | #define USB_VENDOR_ID_DWAV 0x0eef | 258 | #define USB_VENDOR_ID_DWAV 0x0eef |
| 259 | #define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER 0x0001 | 259 | #define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER 0x0001 |
| 260 | #define USB_DEVICE_ID_DWAV_TOUCHCONTROLLER 0x0002 | ||
| 260 | #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D 0x480d | 261 | #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D 0x480d |
| 261 | #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E 0x480e | 262 | #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E 0x480e |
| 262 | #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207 0x7207 | 263 | #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207 0x7207 |
| @@ -423,6 +424,9 @@ | |||
| 423 | #define USB_VENDOR_ID_ILITEK 0x222a | 424 | #define USB_VENDOR_ID_ILITEK 0x222a |
| 424 | #define USB_DEVICE_ID_ILITEK_MULTITOUCH 0x0001 | 425 | #define USB_DEVICE_ID_ILITEK_MULTITOUCH 0x0001 |
| 425 | 426 | ||
| 427 | #define USB_VENDOR_ID_ION 0x15e4 | ||
| 428 | #define USB_DEVICE_ID_ICADE 0x0132 | ||
| 429 | |||
| 426 | #define USB_VENDOR_ID_HOLTEK 0x1241 | 430 | #define USB_VENDOR_ID_HOLTEK 0x1241 |
| 427 | #define USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP 0x5015 | 431 | #define USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP 0x5015 |
| 428 | 432 | ||
| @@ -432,11 +436,6 @@ | |||
| 432 | #define USB_VENDOR_ID_IMATION 0x0718 | 436 | #define USB_VENDOR_ID_IMATION 0x0718 |
| 433 | #define USB_DEVICE_ID_DISC_STAKKA 0xd000 | 437 | #define USB_DEVICE_ID_DISC_STAKKA 0xd000 |
| 434 | 438 | ||
| 435 | #define USB_VENDOR_ID_INTEL_8086 0x8086 | ||
| 436 | #define USB_VENDOR_ID_INTEL_8087 0x8087 | ||
| 437 | #define USB_DEVICE_ID_SENSOR_HUB_1020 0x1020 | ||
| 438 | #define USB_DEVICE_ID_SENSOR_HUB_09FA 0x09FA | ||
| 439 | |||
| 440 | #define USB_VENDOR_ID_IRTOUCHSYSTEMS 0x6615 | 439 | #define USB_VENDOR_ID_IRTOUCHSYSTEMS 0x6615 |
| 441 | #define USB_DEVICE_ID_IRTOUCH_INFRARED_USB 0x0070 | 440 | #define USB_DEVICE_ID_IRTOUCH_INFRARED_USB 0x0070 |
| 442 | 441 | ||
| @@ -603,6 +602,7 @@ | |||
| 603 | 602 | ||
| 604 | #define USB_VENDOR_ID_NOVATEK 0x0603 | 603 | #define USB_VENDOR_ID_NOVATEK 0x0603 |
| 605 | #define USB_DEVICE_ID_NOVATEK_PCT 0x0600 | 604 | #define USB_DEVICE_ID_NOVATEK_PCT 0x0600 |
| 605 | #define USB_DEVICE_ID_NOVATEK_MOUSE 0x1602 | ||
| 606 | 606 | ||
| 607 | #define USB_VENDOR_ID_NTRIG 0x1b96 | 607 | #define USB_VENDOR_ID_NTRIG 0x1b96 |
| 608 | #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001 | 608 | #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001 |
| @@ -677,7 +677,9 @@ | |||
| 677 | #define USB_DEVICE_ID_ROCCAT_ISKU 0x319c | 677 | #define USB_DEVICE_ID_ROCCAT_ISKU 0x319c |
| 678 | #define USB_DEVICE_ID_ROCCAT_KONE 0x2ced | 678 | #define USB_DEVICE_ID_ROCCAT_KONE 0x2ced |
| 679 | #define USB_DEVICE_ID_ROCCAT_KONEPLUS 0x2d51 | 679 | #define USB_DEVICE_ID_ROCCAT_KONEPLUS 0x2d51 |
| 680 | #define USB_DEVICE_ID_ROCCAT_KONEXTD 0x2e22 | ||
| 680 | #define USB_DEVICE_ID_ROCCAT_KOVAPLUS 0x2d50 | 681 | #define USB_DEVICE_ID_ROCCAT_KOVAPLUS 0x2d50 |
| 682 | #define USB_DEVICE_ID_ROCCAT_LUA 0x2c2e | ||
| 681 | #define USB_DEVICE_ID_ROCCAT_PYRA_WIRED 0x2c24 | 683 | #define USB_DEVICE_ID_ROCCAT_PYRA_WIRED 0x2c24 |
| 682 | #define USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS 0x2cf6 | 684 | #define USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS 0x2cf6 |
| 683 | #define USB_DEVICE_ID_ROCCAT_SAVU 0x2d5a | 685 | #define USB_DEVICE_ID_ROCCAT_SAVU 0x2d5a |
| @@ -696,6 +698,9 @@ | |||
| 696 | #define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f | 698 | #define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f |
| 697 | #define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002 | 699 | #define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002 |
| 698 | 700 | ||
| 701 | #define USB_VENDOR_ID_SIGMATEL 0x066F | ||
| 702 | #define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780 | ||
| 703 | |||
| 699 | #define USB_VENDOR_ID_SKYCABLE 0x1223 | 704 | #define USB_VENDOR_ID_SKYCABLE 0x1223 |
| 700 | #define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07 | 705 | #define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07 |
| 701 | 706 | ||
| @@ -714,7 +719,6 @@ | |||
| 714 | 719 | ||
| 715 | #define USB_VENDOR_ID_STANTUM_STM 0x0483 | 720 | #define USB_VENDOR_ID_STANTUM_STM 0x0483 |
| 716 | #define USB_DEVICE_ID_MTP_STM 0x3261 | 721 | #define USB_DEVICE_ID_MTP_STM 0x3261 |
| 717 | #define USB_DEVICE_ID_SENSOR_HUB_7014 0x7014 | ||
| 718 | 722 | ||
| 719 | #define USB_VENDOR_ID_STANTUM_SITRONIX 0x1403 | 723 | #define USB_VENDOR_ID_STANTUM_SITRONIX 0x1403 |
| 720 | #define USB_DEVICE_ID_MTP_SITRONIX 0x5001 | 724 | #define USB_DEVICE_ID_MTP_SITRONIX 0x5001 |
| @@ -762,6 +766,9 @@ | |||
| 762 | #define USB_VENDOR_ID_TOUCHPACK 0x1bfd | 766 | #define USB_VENDOR_ID_TOUCHPACK 0x1bfd |
| 763 | #define USB_DEVICE_ID_TOUCHPACK_RTS 0x1688 | 767 | #define USB_DEVICE_ID_TOUCHPACK_RTS 0x1688 |
| 764 | 768 | ||
| 769 | #define USB_VENDOR_ID_TPV 0x25aa | ||
| 770 | #define USB_DEVICE_ID_TPV_OPTICAL_TOUCHSCREEN 0x8883 | ||
| 771 | |||
| 765 | #define USB_VENDOR_ID_TURBOX 0x062a | 772 | #define USB_VENDOR_ID_TURBOX 0x062a |
| 766 | #define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201 | 773 | #define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201 |
| 767 | #define USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART 0x7100 | 774 | #define USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART 0x7100 |
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index d917c0d53685..21b196c394b1 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
| @@ -192,7 +192,6 @@ static int hidinput_setkeycode(struct input_dev *dev, | |||
| 192 | return -EINVAL; | 192 | return -EINVAL; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | |||
| 196 | /** | 195 | /** |
| 197 | * hidinput_calc_abs_res - calculate an absolute axis resolution | 196 | * hidinput_calc_abs_res - calculate an absolute axis resolution |
| 198 | * @field: the HID report field to calculate resolution for | 197 | * @field: the HID report field to calculate resolution for |
| @@ -208,7 +207,7 @@ static int hidinput_setkeycode(struct input_dev *dev, | |||
| 208 | * Only exponent 1 length units are processed. Centimeters and inches are | 207 | * Only exponent 1 length units are processed. Centimeters and inches are |
| 209 | * converted to millimeters. Degrees are converted to radians. | 208 | * converted to millimeters. Degrees are converted to radians. |
| 210 | */ | 209 | */ |
| 211 | static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) | 210 | __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) |
| 212 | { | 211 | { |
| 213 | __s32 unit_exponent = field->unit_exponent; | 212 | __s32 unit_exponent = field->unit_exponent; |
| 214 | __s32 logical_extents = field->logical_maximum - | 213 | __s32 logical_extents = field->logical_maximum - |
| @@ -229,17 +228,29 @@ static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) | |||
| 229 | case ABS_X: | 228 | case ABS_X: |
| 230 | case ABS_Y: | 229 | case ABS_Y: |
| 231 | case ABS_Z: | 230 | case ABS_Z: |
| 232 | if (field->unit == 0x11) { /* If centimeters */ | 231 | case ABS_MT_POSITION_X: |
| 232 | case ABS_MT_POSITION_Y: | ||
| 233 | case ABS_MT_TOOL_X: | ||
| 234 | case ABS_MT_TOOL_Y: | ||
| 235 | case ABS_MT_TOUCH_MAJOR: | ||
| 236 | case ABS_MT_TOUCH_MINOR: | ||
| 237 | if (field->unit & 0xffffff00) /* Not a length */ | ||
| 238 | return 0; | ||
| 239 | unit_exponent += hid_snto32(field->unit >> 4, 4) - 1; | ||
| 240 | switch (field->unit & 0xf) { | ||
| 241 | case 0x1: /* If centimeters */ | ||
| 233 | /* Convert to millimeters */ | 242 | /* Convert to millimeters */ |
| 234 | unit_exponent += 1; | 243 | unit_exponent += 1; |
| 235 | } else if (field->unit == 0x13) { /* If inches */ | 244 | break; |
| 245 | case 0x3: /* If inches */ | ||
| 236 | /* Convert to millimeters */ | 246 | /* Convert to millimeters */ |
| 237 | prev = physical_extents; | 247 | prev = physical_extents; |
| 238 | physical_extents *= 254; | 248 | physical_extents *= 254; |
| 239 | if (physical_extents < prev) | 249 | if (physical_extents < prev) |
| 240 | return 0; | 250 | return 0; |
| 241 | unit_exponent -= 1; | 251 | unit_exponent -= 1; |
| 242 | } else { | 252 | break; |
| 253 | default: | ||
| 243 | return 0; | 254 | return 0; |
| 244 | } | 255 | } |
| 245 | break; | 256 | break; |
| @@ -281,8 +292,9 @@ static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) | |||
| 281 | } | 292 | } |
| 282 | 293 | ||
| 283 | /* Calculate resolution */ | 294 | /* Calculate resolution */ |
| 284 | return logical_extents / physical_extents; | 295 | return DIV_ROUND_CLOSEST(logical_extents, physical_extents); |
| 285 | } | 296 | } |
| 297 | EXPORT_SYMBOL_GPL(hidinput_calc_abs_res); | ||
| 286 | 298 | ||
| 287 | #ifdef CONFIG_HID_BATTERY_STRENGTH | 299 | #ifdef CONFIG_HID_BATTERY_STRENGTH |
| 288 | static enum power_supply_property hidinput_battery_props[] = { | 300 | static enum power_supply_property hidinput_battery_props[] = { |
| @@ -299,6 +311,9 @@ static enum power_supply_property hidinput_battery_props[] = { | |||
| 299 | 311 | ||
| 300 | static const struct hid_device_id hid_battery_quirks[] = { | 312 | static const struct hid_device_id hid_battery_quirks[] = { |
| 301 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, | 313 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, |
| 314 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), | ||
| 315 | HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, | ||
| 316 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, | ||
| 302 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), | 317 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), |
| 303 | HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, | 318 | HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, |
| 304 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, | 319 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, |
| @@ -502,9 +517,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
| 502 | if (code <= 0xf) | 517 | if (code <= 0xf) |
| 503 | code += BTN_JOYSTICK; | 518 | code += BTN_JOYSTICK; |
| 504 | else | 519 | else |
| 505 | code += BTN_TRIGGER_HAPPY; | 520 | code += BTN_TRIGGER_HAPPY - 0x10; |
| 521 | break; | ||
| 522 | case HID_GD_GAMEPAD: | ||
| 523 | if (code <= 0xf) | ||
| 524 | code += BTN_GAMEPAD; | ||
| 525 | else | ||
| 526 | code += BTN_TRIGGER_HAPPY - 0x10; | ||
| 506 | break; | 527 | break; |
| 507 | case HID_GD_GAMEPAD: code += BTN_GAMEPAD; break; | ||
| 508 | default: | 528 | default: |
| 509 | switch (field->physical) { | 529 | switch (field->physical) { |
| 510 | case HID_GD_MOUSE: | 530 | case HID_GD_MOUSE: |
| @@ -1146,6 +1166,38 @@ static void report_features(struct hid_device *hid) | |||
| 1146 | } | 1166 | } |
| 1147 | } | 1167 | } |
| 1148 | 1168 | ||
| 1169 | static struct hid_input *hidinput_allocate(struct hid_device *hid) | ||
| 1170 | { | ||
| 1171 | struct hid_input *hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL); | ||
| 1172 | struct input_dev *input_dev = input_allocate_device(); | ||
| 1173 | if (!hidinput || !input_dev) { | ||
| 1174 | kfree(hidinput); | ||
| 1175 | input_free_device(input_dev); | ||
| 1176 | hid_err(hid, "Out of memory during hid input probe\n"); | ||
| 1177 | return NULL; | ||
| 1178 | } | ||
| 1179 | |||
| 1180 | input_set_drvdata(input_dev, hid); | ||
| 1181 | input_dev->event = hid->ll_driver->hidinput_input_event; | ||
| 1182 | input_dev->open = hidinput_open; | ||
| 1183 | input_dev->close = hidinput_close; | ||
| 1184 | input_dev->setkeycode = hidinput_setkeycode; | ||
| 1185 | input_dev->getkeycode = hidinput_getkeycode; | ||
| 1186 | |||
| 1187 | input_dev->name = hid->name; | ||
| 1188 | input_dev->phys = hid->phys; | ||
| 1189 | input_dev->uniq = hid->uniq; | ||
| 1190 | input_dev->id.bustype = hid->bus; | ||
| 1191 | input_dev->id.vendor = hid->vendor; | ||
| 1192 | input_dev->id.product = hid->product; | ||
| 1193 | input_dev->id.version = hid->version; | ||
| 1194 | input_dev->dev.parent = hid->dev.parent; | ||
| 1195 | hidinput->input = input_dev; | ||
| 1196 | list_add_tail(&hidinput->list, &hid->inputs); | ||
| 1197 | |||
| 1198 | return hidinput; | ||
| 1199 | } | ||
| 1200 | |||
| 1149 | /* | 1201 | /* |
| 1150 | * Register the input device; print a message. | 1202 | * Register the input device; print a message. |
| 1151 | * Configure the input layer interface | 1203 | * Configure the input layer interface |
| @@ -1157,7 +1209,6 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
| 1157 | struct hid_driver *drv = hid->driver; | 1209 | struct hid_driver *drv = hid->driver; |
| 1158 | struct hid_report *report; | 1210 | struct hid_report *report; |
| 1159 | struct hid_input *hidinput = NULL; | 1211 | struct hid_input *hidinput = NULL; |
| 1160 | struct input_dev *input_dev; | ||
| 1161 | int i, j, k; | 1212 | int i, j, k; |
| 1162 | 1213 | ||
| 1163 | INIT_LIST_HEAD(&hid->inputs); | 1214 | INIT_LIST_HEAD(&hid->inputs); |
| @@ -1188,33 +1239,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
| 1188 | continue; | 1239 | continue; |
| 1189 | 1240 | ||
| 1190 | if (!hidinput) { | 1241 | if (!hidinput) { |
| 1191 | hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL); | 1242 | hidinput = hidinput_allocate(hid); |
| 1192 | input_dev = input_allocate_device(); | 1243 | if (!hidinput) |
| 1193 | if (!hidinput || !input_dev) { | ||
| 1194 | kfree(hidinput); | ||
| 1195 | input_free_device(input_dev); | ||
| 1196 | hid_err(hid, "Out of memory during hid input probe\n"); | ||
| 1197 | goto out_unwind; | 1244 | goto out_unwind; |
| 1198 | } | ||
| 1199 | |||
| 1200 | input_set_drvdata(input_dev, hid); | ||
| 1201 | input_dev->event = | ||
| 1202 | hid->ll_driver->hidinput_input_event; | ||
| 1203 | input_dev->open = hidinput_open; | ||
| 1204 | input_dev->close = hidinput_close; | ||
| 1205 | input_dev->setkeycode = hidinput_setkeycode; | ||
| 1206 | input_dev->getkeycode = hidinput_getkeycode; | ||
| 1207 | |||
| 1208 | input_dev->name = hid->name; | ||
| 1209 | input_dev->phys = hid->phys; | ||
| 1210 | input_dev->uniq = hid->uniq; | ||
| 1211 | input_dev->id.bustype = hid->bus; | ||
| 1212 | input_dev->id.vendor = hid->vendor; | ||
| 1213 | input_dev->id.product = hid->product; | ||
| 1214 | input_dev->id.version = hid->version; | ||
| 1215 | input_dev->dev.parent = hid->dev.parent; | ||
| 1216 | hidinput->input = input_dev; | ||
| 1217 | list_add_tail(&hidinput->list, &hid->inputs); | ||
| 1218 | } | 1245 | } |
| 1219 | 1246 | ||
| 1220 | for (i = 0; i < report->maxfield; i++) | 1247 | for (i = 0; i < report->maxfield; i++) |
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 7867d69f0efe..61543c02ea0b 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
| @@ -52,11 +52,14 @@ MODULE_LICENSE("GPL"); | |||
| 52 | #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6) | 52 | #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6) |
| 53 | #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8) | 53 | #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8) |
| 54 | #define MT_QUIRK_NO_AREA (1 << 9) | 54 | #define MT_QUIRK_NO_AREA (1 << 9) |
| 55 | #define MT_QUIRK_IGNORE_DUPLICATES (1 << 10) | ||
| 56 | #define MT_QUIRK_HOVERING (1 << 11) | ||
| 55 | 57 | ||
| 56 | struct mt_slot { | 58 | struct mt_slot { |
| 57 | __s32 x, y, p, w, h; | 59 | __s32 x, y, cx, cy, p, w, h; |
| 58 | __s32 contactid; /* the device ContactID assigned to this slot */ | 60 | __s32 contactid; /* the device ContactID assigned to this slot */ |
| 59 | bool touch_state; /* is the touch valid? */ | 61 | bool touch_state; /* is the touch valid? */ |
| 62 | bool inrange_state; /* is the finger in proximity of the sensor? */ | ||
| 60 | }; | 63 | }; |
| 61 | 64 | ||
| 62 | struct mt_class { | 65 | struct mt_class { |
| @@ -121,6 +124,7 @@ struct mt_device { | |||
| 121 | #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 | 124 | #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 |
| 122 | 125 | ||
| 123 | #define MT_DEFAULT_MAXCONTACT 10 | 126 | #define MT_DEFAULT_MAXCONTACT 10 |
| 127 | #define MT_MAX_MAXCONTACT 250 | ||
| 124 | 128 | ||
| 125 | #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p) | 129 | #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p) |
| 126 | #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p) | 130 | #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p) |
| @@ -282,11 +286,26 @@ static void mt_feature_mapping(struct hid_device *hdev, | |||
| 282 | case HID_DG_CONTACTMAX: | 286 | case HID_DG_CONTACTMAX: |
| 283 | td->maxcontact_report_id = field->report->id; | 287 | td->maxcontact_report_id = field->report->id; |
| 284 | td->maxcontacts = field->value[0]; | 288 | td->maxcontacts = field->value[0]; |
| 289 | if (!td->maxcontacts && | ||
| 290 | field->logical_maximum <= MT_MAX_MAXCONTACT) | ||
| 291 | td->maxcontacts = field->logical_maximum; | ||
| 285 | if (td->mtclass.maxcontacts) | 292 | if (td->mtclass.maxcontacts) |
| 286 | /* check if the maxcontacts is given by the class */ | 293 | /* check if the maxcontacts is given by the class */ |
| 287 | td->maxcontacts = td->mtclass.maxcontacts; | 294 | td->maxcontacts = td->mtclass.maxcontacts; |
| 288 | 295 | ||
| 289 | break; | 296 | break; |
| 297 | case 0xff0000c5: | ||
| 298 | if (field->report_count == 256 && field->report_size == 8) { | ||
| 299 | /* Win 8 devices need special quirks */ | ||
| 300 | __s32 *quirks = &td->mtclass.quirks; | ||
| 301 | *quirks |= MT_QUIRK_ALWAYS_VALID; | ||
| 302 | *quirks |= MT_QUIRK_IGNORE_DUPLICATES; | ||
| 303 | *quirks |= MT_QUIRK_HOVERING; | ||
| 304 | *quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP; | ||
| 305 | *quirks &= ~MT_QUIRK_VALID_IS_INRANGE; | ||
| 306 | *quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE; | ||
| 307 | } | ||
| 308 | break; | ||
| 290 | } | 309 | } |
| 291 | } | 310 | } |
| 292 | 311 | ||
| @@ -297,6 +316,7 @@ static void set_abs(struct input_dev *input, unsigned int code, | |||
| 297 | int fmax = field->logical_maximum; | 316 | int fmax = field->logical_maximum; |
| 298 | int fuzz = snratio ? (fmax - fmin) / snratio : 0; | 317 | int fuzz = snratio ? (fmax - fmin) / snratio : 0; |
| 299 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); | 318 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); |
| 319 | input_abs_set_res(input, code, hidinput_calc_abs_res(field, code)); | ||
| 300 | } | 320 | } |
| 301 | 321 | ||
| 302 | static void mt_store_field(struct hid_usage *usage, struct mt_device *td, | 322 | static void mt_store_field(struct hid_usage *usage, struct mt_device *td, |
| @@ -317,6 +337,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 317 | struct mt_device *td = hid_get_drvdata(hdev); | 337 | struct mt_device *td = hid_get_drvdata(hdev); |
| 318 | struct mt_class *cls = &td->mtclass; | 338 | struct mt_class *cls = &td->mtclass; |
| 319 | int code; | 339 | int code; |
| 340 | struct hid_usage *prev_usage = NULL; | ||
| 320 | 341 | ||
| 321 | /* Only map fields from TouchScreen or TouchPad collections. | 342 | /* Only map fields from TouchScreen or TouchPad collections. |
| 322 | * We need to ignore fields that belong to other collections | 343 | * We need to ignore fields that belong to other collections |
| @@ -339,23 +360,42 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 339 | if (field->physical == HID_DG_STYLUS) | 360 | if (field->physical == HID_DG_STYLUS) |
| 340 | return -1; | 361 | return -1; |
| 341 | 362 | ||
| 363 | if (usage->usage_index) | ||
| 364 | prev_usage = &field->usage[usage->usage_index - 1]; | ||
| 365 | |||
| 342 | switch (usage->hid & HID_USAGE_PAGE) { | 366 | switch (usage->hid & HID_USAGE_PAGE) { |
| 343 | 367 | ||
| 344 | case HID_UP_GENDESK: | 368 | case HID_UP_GENDESK: |
| 345 | switch (usage->hid) { | 369 | switch (usage->hid) { |
| 346 | case HID_GD_X: | 370 | case HID_GD_X: |
| 347 | hid_map_usage(hi, usage, bit, max, | 371 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
| 372 | hid_map_usage(hi, usage, bit, max, | ||
| 373 | EV_ABS, ABS_MT_TOOL_X); | ||
| 374 | set_abs(hi->input, ABS_MT_TOOL_X, field, | ||
| 375 | cls->sn_move); | ||
| 376 | } else { | ||
| 377 | hid_map_usage(hi, usage, bit, max, | ||
| 348 | EV_ABS, ABS_MT_POSITION_X); | 378 | EV_ABS, ABS_MT_POSITION_X); |
| 349 | set_abs(hi->input, ABS_MT_POSITION_X, field, | 379 | set_abs(hi->input, ABS_MT_POSITION_X, field, |
| 350 | cls->sn_move); | 380 | cls->sn_move); |
| 381 | } | ||
| 382 | |||
| 351 | mt_store_field(usage, td, hi); | 383 | mt_store_field(usage, td, hi); |
| 352 | td->last_field_index = field->index; | 384 | td->last_field_index = field->index; |
| 353 | return 1; | 385 | return 1; |
| 354 | case HID_GD_Y: | 386 | case HID_GD_Y: |
| 355 | hid_map_usage(hi, usage, bit, max, | 387 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
| 388 | hid_map_usage(hi, usage, bit, max, | ||
| 389 | EV_ABS, ABS_MT_TOOL_Y); | ||
| 390 | set_abs(hi->input, ABS_MT_TOOL_Y, field, | ||
| 391 | cls->sn_move); | ||
| 392 | } else { | ||
| 393 | hid_map_usage(hi, usage, bit, max, | ||
| 356 | EV_ABS, ABS_MT_POSITION_Y); | 394 | EV_ABS, ABS_MT_POSITION_Y); |
| 357 | set_abs(hi->input, ABS_MT_POSITION_Y, field, | 395 | set_abs(hi->input, ABS_MT_POSITION_Y, field, |
| 358 | cls->sn_move); | 396 | cls->sn_move); |
| 397 | } | ||
| 398 | |||
| 359 | mt_store_field(usage, td, hi); | 399 | mt_store_field(usage, td, hi); |
| 360 | td->last_field_index = field->index; | 400 | td->last_field_index = field->index; |
| 361 | return 1; | 401 | return 1; |
| @@ -365,6 +405,12 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 365 | case HID_UP_DIGITIZER: | 405 | case HID_UP_DIGITIZER: |
| 366 | switch (usage->hid) { | 406 | switch (usage->hid) { |
| 367 | case HID_DG_INRANGE: | 407 | case HID_DG_INRANGE: |
| 408 | if (cls->quirks & MT_QUIRK_HOVERING) { | ||
| 409 | hid_map_usage(hi, usage, bit, max, | ||
| 410 | EV_ABS, ABS_MT_DISTANCE); | ||
| 411 | input_set_abs_params(hi->input, | ||
| 412 | ABS_MT_DISTANCE, 0, 1, 0, 0); | ||
| 413 | } | ||
| 368 | mt_store_field(usage, td, hi); | 414 | mt_store_field(usage, td, hi); |
| 369 | td->last_field_index = field->index; | 415 | td->last_field_index = field->index; |
| 370 | return 1; | 416 | return 1; |
| @@ -477,18 +523,26 @@ static int mt_compute_slot(struct mt_device *td, struct input_dev *input) | |||
| 477 | */ | 523 | */ |
| 478 | static void mt_complete_slot(struct mt_device *td, struct input_dev *input) | 524 | static void mt_complete_slot(struct mt_device *td, struct input_dev *input) |
| 479 | { | 525 | { |
| 480 | if (td->curvalid) { | 526 | if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { |
| 481 | int slotnum = mt_compute_slot(td, input); | 527 | int slotnum = mt_compute_slot(td, input); |
| 482 | struct mt_slot *s = &td->curdata; | 528 | struct mt_slot *s = &td->curdata; |
| 529 | struct input_mt *mt = input->mt; | ||
| 483 | 530 | ||
| 484 | if (slotnum < 0 || slotnum >= td->maxcontacts) | 531 | if (slotnum < 0 || slotnum >= td->maxcontacts) |
| 485 | return; | 532 | return; |
| 486 | 533 | ||
| 534 | if ((td->mtclass.quirks & MT_QUIRK_IGNORE_DUPLICATES) && mt) { | ||
| 535 | struct input_mt_slot *slot = &mt->slots[slotnum]; | ||
| 536 | if (input_mt_is_active(slot) && | ||
| 537 | input_mt_is_used(mt, slot)) | ||
| 538 | return; | ||
| 539 | } | ||
| 540 | |||
| 487 | input_mt_slot(input, slotnum); | 541 | input_mt_slot(input, slotnum); |
| 488 | input_mt_report_slot_state(input, MT_TOOL_FINGER, | 542 | input_mt_report_slot_state(input, MT_TOOL_FINGER, |
| 489 | s->touch_state); | 543 | s->touch_state || s->inrange_state); |
| 490 | if (s->touch_state) { | 544 | if (s->touch_state || s->inrange_state) { |
| 491 | /* this finger is on the screen */ | 545 | /* this finger is in proximity of the sensor */ |
| 492 | int wide = (s->w > s->h); | 546 | int wide = (s->w > s->h); |
| 493 | /* divided by two to match visual scale of touch */ | 547 | /* divided by two to match visual scale of touch */ |
| 494 | int major = max(s->w, s->h) >> 1; | 548 | int major = max(s->w, s->h) >> 1; |
| @@ -496,6 +550,10 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) | |||
| 496 | 550 | ||
| 497 | input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x); | 551 | input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x); |
| 498 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y); | 552 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y); |
| 553 | input_event(input, EV_ABS, ABS_MT_TOOL_X, s->cx); | ||
| 554 | input_event(input, EV_ABS, ABS_MT_TOOL_Y, s->cy); | ||
| 555 | input_event(input, EV_ABS, ABS_MT_DISTANCE, | ||
| 556 | !s->touch_state); | ||
| 499 | input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide); | 557 | input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide); |
| 500 | input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p); | 558 | input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p); |
| 501 | input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); | 559 | input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); |
| @@ -526,10 +584,10 @@ static int mt_event(struct hid_device *hid, struct hid_field *field, | |||
| 526 | if (hid->claimed & HID_CLAIMED_INPUT) { | 584 | if (hid->claimed & HID_CLAIMED_INPUT) { |
| 527 | switch (usage->hid) { | 585 | switch (usage->hid) { |
| 528 | case HID_DG_INRANGE: | 586 | case HID_DG_INRANGE: |
| 529 | if (quirks & MT_QUIRK_ALWAYS_VALID) | 587 | if (quirks & MT_QUIRK_VALID_IS_INRANGE) |
| 530 | td->curvalid = true; | ||
| 531 | else if (quirks & MT_QUIRK_VALID_IS_INRANGE) | ||
| 532 | td->curvalid = value; | 588 | td->curvalid = value; |
| 589 | if (quirks & MT_QUIRK_HOVERING) | ||
| 590 | td->curdata.inrange_state = value; | ||
| 533 | break; | 591 | break; |
| 534 | case HID_DG_TIPSWITCH: | 592 | case HID_DG_TIPSWITCH: |
| 535 | if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) | 593 | if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
| @@ -547,10 +605,16 @@ static int mt_event(struct hid_device *hid, struct hid_field *field, | |||
| 547 | td->curdata.p = value; | 605 | td->curdata.p = value; |
| 548 | break; | 606 | break; |
| 549 | case HID_GD_X: | 607 | case HID_GD_X: |
| 550 | td->curdata.x = value; | 608 | if (usage->code == ABS_MT_TOOL_X) |
| 609 | td->curdata.cx = value; | ||
| 610 | else | ||
| 611 | td->curdata.x = value; | ||
| 551 | break; | 612 | break; |
| 552 | case HID_GD_Y: | 613 | case HID_GD_Y: |
| 553 | td->curdata.y = value; | 614 | if (usage->code == ABS_MT_TOOL_Y) |
| 615 | td->curdata.cy = value; | ||
| 616 | else | ||
| 617 | td->curdata.y = value; | ||
| 554 | break; | 618 | break; |
| 555 | case HID_DG_WIDTH: | 619 | case HID_DG_WIDTH: |
| 556 | td->curdata.w = value; | 620 | td->curdata.w = value; |
| @@ -575,12 +639,15 @@ static int mt_event(struct hid_device *hid, struct hid_field *field, | |||
| 575 | return 0; | 639 | return 0; |
| 576 | } | 640 | } |
| 577 | 641 | ||
| 578 | if (usage->hid == td->last_slot_field) | 642 | if (usage->usage_index + 1 == field->report_count) { |
| 579 | mt_complete_slot(td, field->hidinput->input); | 643 | /* we only take into account the last report. */ |
| 644 | if (usage->hid == td->last_slot_field) | ||
| 645 | mt_complete_slot(td, field->hidinput->input); | ||
| 580 | 646 | ||
| 581 | if (field->index == td->last_field_index | 647 | if (field->index == td->last_field_index |
| 582 | && td->num_received >= td->num_expected) | 648 | && td->num_received >= td->num_expected) |
| 583 | mt_sync_frame(td, field->hidinput->input); | 649 | mt_sync_frame(td, field->hidinput->input); |
| 650 | } | ||
| 584 | 651 | ||
| 585 | } | 652 | } |
| 586 | 653 | ||
diff --git a/drivers/hid/hid-roccat-isku.c b/drivers/hid/hid-roccat-isku.c index 5669916c2943..1219998a02d6 100644 --- a/drivers/hid/hid-roccat-isku.c +++ b/drivers/hid/hid-roccat-isku.c | |||
| @@ -167,7 +167,7 @@ static ssize_t isku_sysfs_write_ ## thingy(struct file *fp, struct kobject *kobj | |||
| 167 | loff_t off, size_t count) \ | 167 | loff_t off, size_t count) \ |
| 168 | { \ | 168 | { \ |
| 169 | return isku_sysfs_write(fp, kobj, buf, off, count, \ | 169 | return isku_sysfs_write(fp, kobj, buf, off, count, \ |
| 170 | sizeof(struct isku_ ## thingy), ISKU_COMMAND_ ## THINGY); \ | 170 | ISKU_SIZE_ ## THINGY, ISKU_COMMAND_ ## THINGY); \ |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | #define ISKU_SYSFS_R(thingy, THINGY) \ | 173 | #define ISKU_SYSFS_R(thingy, THINGY) \ |
| @@ -176,32 +176,32 @@ static ssize_t isku_sysfs_read_ ## thingy(struct file *fp, struct kobject *kobj, | |||
| 176 | loff_t off, size_t count) \ | 176 | loff_t off, size_t count) \ |
| 177 | { \ | 177 | { \ |
| 178 | return isku_sysfs_read(fp, kobj, buf, off, count, \ | 178 | return isku_sysfs_read(fp, kobj, buf, off, count, \ |
| 179 | sizeof(struct isku_ ## thingy), ISKU_COMMAND_ ## THINGY); \ | 179 | ISKU_SIZE_ ## THINGY, ISKU_COMMAND_ ## THINGY); \ |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | #define ISKU_SYSFS_RW(thingy, THINGY) \ | 182 | #define ISKU_SYSFS_RW(thingy, THINGY) \ |
| 183 | ISKU_SYSFS_R(thingy, THINGY) \ | 183 | ISKU_SYSFS_R(thingy, THINGY) \ |
| 184 | ISKU_SYSFS_W(thingy, THINGY) | 184 | ISKU_SYSFS_W(thingy, THINGY) |
| 185 | 185 | ||
| 186 | #define ISKU_BIN_ATTR_RW(thingy) \ | 186 | #define ISKU_BIN_ATTR_RW(thingy, THINGY) \ |
| 187 | { \ | 187 | { \ |
| 188 | .attr = { .name = #thingy, .mode = 0660 }, \ | 188 | .attr = { .name = #thingy, .mode = 0660 }, \ |
| 189 | .size = sizeof(struct isku_ ## thingy), \ | 189 | .size = ISKU_SIZE_ ## THINGY, \ |
| 190 | .read = isku_sysfs_read_ ## thingy, \ | 190 | .read = isku_sysfs_read_ ## thingy, \ |
| 191 | .write = isku_sysfs_write_ ## thingy \ | 191 | .write = isku_sysfs_write_ ## thingy \ |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | #define ISKU_BIN_ATTR_R(thingy) \ | 194 | #define ISKU_BIN_ATTR_R(thingy, THINGY) \ |
| 195 | { \ | 195 | { \ |
| 196 | .attr = { .name = #thingy, .mode = 0440 }, \ | 196 | .attr = { .name = #thingy, .mode = 0440 }, \ |
| 197 | .size = sizeof(struct isku_ ## thingy), \ | 197 | .size = ISKU_SIZE_ ## THINGY, \ |
| 198 | .read = isku_sysfs_read_ ## thingy, \ | 198 | .read = isku_sysfs_read_ ## thingy, \ |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | #define ISKU_BIN_ATTR_W(thingy) \ | 201 | #define ISKU_BIN_ATTR_W(thingy, THINGY) \ |
| 202 | { \ | 202 | { \ |
| 203 | .attr = { .name = #thingy, .mode = 0220 }, \ | 203 | .attr = { .name = #thingy, .mode = 0220 }, \ |
| 204 | .size = sizeof(struct isku_ ## thingy), \ | 204 | .size = ISKU_SIZE_ ## THINGY, \ |
| 205 | .write = isku_sysfs_write_ ## thingy \ | 205 | .write = isku_sysfs_write_ ## thingy \ |
| 206 | } | 206 | } |
| 207 | 207 | ||
| @@ -218,21 +218,23 @@ ISKU_SYSFS_RW(last_set, LAST_SET) | |||
| 218 | ISKU_SYSFS_W(talk, TALK) | 218 | ISKU_SYSFS_W(talk, TALK) |
| 219 | ISKU_SYSFS_R(info, INFO) | 219 | ISKU_SYSFS_R(info, INFO) |
| 220 | ISKU_SYSFS_W(control, CONTROL) | 220 | ISKU_SYSFS_W(control, CONTROL) |
| 221 | ISKU_SYSFS_W(reset, RESET) | ||
| 221 | 222 | ||
| 222 | static struct bin_attribute isku_bin_attributes[] = { | 223 | static struct bin_attribute isku_bin_attributes[] = { |
| 223 | ISKU_BIN_ATTR_RW(macro), | 224 | ISKU_BIN_ATTR_RW(macro, MACRO), |
| 224 | ISKU_BIN_ATTR_RW(keys_function), | 225 | ISKU_BIN_ATTR_RW(keys_function, KEYS_FUNCTION), |
| 225 | ISKU_BIN_ATTR_RW(keys_easyzone), | 226 | ISKU_BIN_ATTR_RW(keys_easyzone, KEYS_EASYZONE), |
| 226 | ISKU_BIN_ATTR_RW(keys_media), | 227 | ISKU_BIN_ATTR_RW(keys_media, KEYS_MEDIA), |
| 227 | ISKU_BIN_ATTR_RW(keys_thumbster), | 228 | ISKU_BIN_ATTR_RW(keys_thumbster, KEYS_THUMBSTER), |
| 228 | ISKU_BIN_ATTR_RW(keys_macro), | 229 | ISKU_BIN_ATTR_RW(keys_macro, KEYS_MACRO), |
| 229 | ISKU_BIN_ATTR_RW(keys_capslock), | 230 | ISKU_BIN_ATTR_RW(keys_capslock, KEYS_CAPSLOCK), |
| 230 | ISKU_BIN_ATTR_RW(light), | 231 | ISKU_BIN_ATTR_RW(light, LIGHT), |
| 231 | ISKU_BIN_ATTR_RW(key_mask), | 232 | ISKU_BIN_ATTR_RW(key_mask, KEY_MASK), |
| 232 | ISKU_BIN_ATTR_RW(last_set), | 233 | ISKU_BIN_ATTR_RW(last_set, LAST_SET), |
| 233 | ISKU_BIN_ATTR_W(talk), | 234 | ISKU_BIN_ATTR_W(talk, TALK), |
| 234 | ISKU_BIN_ATTR_R(info), | 235 | ISKU_BIN_ATTR_R(info, INFO), |
| 235 | ISKU_BIN_ATTR_W(control), | 236 | ISKU_BIN_ATTR_W(control, CONTROL), |
| 237 | ISKU_BIN_ATTR_W(reset, RESET), | ||
| 236 | __ATTR_NULL | 238 | __ATTR_NULL |
| 237 | }; | 239 | }; |
| 238 | 240 | ||
diff --git a/drivers/hid/hid-roccat-isku.h b/drivers/hid/hid-roccat-isku.h index 605b3ce21638..cf6896c83867 100644 --- a/drivers/hid/hid-roccat-isku.h +++ b/drivers/hid/hid-roccat-isku.h | |||
| @@ -15,76 +15,33 @@ | |||
| 15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
| 16 | 16 | ||
| 17 | enum { | 17 | enum { |
| 18 | ISKU_SIZE_CONTROL = 0x03, | ||
| 19 | ISKU_SIZE_INFO = 0x06, | ||
| 20 | ISKU_SIZE_KEY_MASK = 0x06, | ||
| 21 | ISKU_SIZE_KEYS_FUNCTION = 0x29, | ||
| 22 | ISKU_SIZE_KEYS_EASYZONE = 0x41, | ||
| 23 | ISKU_SIZE_KEYS_MEDIA = 0x1d, | ||
| 24 | ISKU_SIZE_KEYS_THUMBSTER = 0x17, | ||
| 25 | ISKU_SIZE_KEYS_MACRO = 0x23, | ||
| 26 | ISKU_SIZE_KEYS_CAPSLOCK = 0x06, | ||
| 27 | ISKU_SIZE_LAST_SET = 0x14, | ||
| 28 | ISKU_SIZE_LIGHT = 0x0a, | ||
| 29 | ISKU_SIZE_MACRO = 0x823, | ||
| 30 | ISKU_SIZE_RESET = 0x03, | ||
| 31 | ISKU_SIZE_TALK = 0x10, | ||
| 32 | }; | ||
| 33 | |||
| 34 | enum { | ||
| 18 | ISKU_PROFILE_NUM = 5, | 35 | ISKU_PROFILE_NUM = 5, |
| 19 | ISKU_USB_INTERFACE_PROTOCOL = 0, | 36 | ISKU_USB_INTERFACE_PROTOCOL = 0, |
| 20 | }; | 37 | }; |
| 21 | 38 | ||
| 22 | struct isku_control { | ||
| 23 | uint8_t command; /* ISKU_COMMAND_CONTROL */ | ||
| 24 | uint8_t value; | ||
| 25 | uint8_t request; | ||
| 26 | } __packed; | ||
| 27 | |||
| 28 | struct isku_actual_profile { | 39 | struct isku_actual_profile { |
| 29 | uint8_t command; /* ISKU_COMMAND_ACTUAL_PROFILE */ | 40 | uint8_t command; /* ISKU_COMMAND_ACTUAL_PROFILE */ |
| 30 | uint8_t size; /* always 3 */ | 41 | uint8_t size; /* always 3 */ |
| 31 | uint8_t actual_profile; | 42 | uint8_t actual_profile; |
| 32 | } __packed; | 43 | } __packed; |
| 33 | 44 | ||
| 34 | struct isku_key_mask { | ||
| 35 | uint8_t command; /* ISKU_COMMAND_KEY_MASK */ | ||
| 36 | uint8_t size; /* 6 */ | ||
| 37 | uint8_t profile_number; /* 0-4 */ | ||
| 38 | uint8_t mask; | ||
| 39 | uint16_t checksum; | ||
| 40 | } __packed; | ||
| 41 | |||
| 42 | struct isku_keys_function { | ||
| 43 | uint8_t data[0x29]; | ||
| 44 | } __packed; | ||
| 45 | |||
| 46 | struct isku_keys_easyzone { | ||
| 47 | uint8_t data[0x41]; | ||
| 48 | } __packed; | ||
| 49 | |||
| 50 | struct isku_keys_media { | ||
| 51 | uint8_t data[0x1d]; | ||
| 52 | } __packed; | ||
| 53 | |||
| 54 | struct isku_keys_thumbster { | ||
| 55 | uint8_t data[0x17]; | ||
| 56 | } __packed; | ||
| 57 | |||
| 58 | struct isku_keys_macro { | ||
| 59 | uint8_t data[0x23]; | ||
| 60 | } __packed; | ||
| 61 | |||
| 62 | struct isku_keys_capslock { | ||
| 63 | uint8_t data[0x6]; | ||
| 64 | } __packed; | ||
| 65 | |||
| 66 | struct isku_macro { | ||
| 67 | uint8_t data[0x823]; | ||
| 68 | } __packed; | ||
| 69 | |||
| 70 | struct isku_light { | ||
| 71 | uint8_t data[0xa]; | ||
| 72 | } __packed; | ||
| 73 | |||
| 74 | struct isku_info { | ||
| 75 | uint8_t data[2]; | ||
| 76 | uint8_t firmware_version; | ||
| 77 | uint8_t unknown[3]; | ||
| 78 | } __packed; | ||
| 79 | |||
| 80 | struct isku_talk { | ||
| 81 | uint8_t data[0x10]; | ||
| 82 | } __packed; | ||
| 83 | |||
| 84 | struct isku_last_set { | ||
| 85 | uint8_t data[0x14]; | ||
| 86 | } __packed; | ||
| 87 | |||
| 88 | enum isku_commands { | 45 | enum isku_commands { |
| 89 | ISKU_COMMAND_CONTROL = 0x4, | 46 | ISKU_COMMAND_CONTROL = 0x4, |
| 90 | ISKU_COMMAND_ACTUAL_PROFILE = 0x5, | 47 | ISKU_COMMAND_ACTUAL_PROFILE = 0x5, |
| @@ -97,6 +54,7 @@ enum isku_commands { | |||
| 97 | ISKU_COMMAND_MACRO = 0xe, | 54 | ISKU_COMMAND_MACRO = 0xe, |
| 98 | ISKU_COMMAND_INFO = 0xf, | 55 | ISKU_COMMAND_INFO = 0xf, |
| 99 | ISKU_COMMAND_LIGHT = 0x10, | 56 | ISKU_COMMAND_LIGHT = 0x10, |
| 57 | ISKU_COMMAND_RESET = 0x11, | ||
| 100 | ISKU_COMMAND_KEYS_CAPSLOCK = 0x13, | 58 | ISKU_COMMAND_KEYS_CAPSLOCK = 0x13, |
| 101 | ISKU_COMMAND_LAST_SET = 0x14, | 59 | ISKU_COMMAND_LAST_SET = 0x14, |
| 102 | ISKU_COMMAND_15 = 0x15, | 60 | ISKU_COMMAND_15 = 0x15, |
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c index f5602fec4865..6a48fa3c7da9 100644 --- a/drivers/hid/hid-roccat-koneplus.c +++ b/drivers/hid/hid-roccat-koneplus.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | /* | 14 | /* |
| 15 | * Roccat Kone[+] is an updated/improved version of the Kone with more memory | 15 | * Roccat Kone[+] is an updated/improved version of the Kone with more memory |
| 16 | * and functionality and without the non-standard behaviours the Kone had. | 16 | * and functionality and without the non-standard behaviours the Kone had. |
| 17 | * KoneXTD has same capabilities but updated sensor. | ||
| 17 | */ | 18 | */ |
| 18 | 19 | ||
| 19 | #include <linux/device.h> | 20 | #include <linux/device.h> |
| @@ -55,56 +56,6 @@ static int koneplus_send_control(struct usb_device *usb_dev, uint value, | |||
| 55 | &control, sizeof(struct roccat_common2_control)); | 56 | &control, sizeof(struct roccat_common2_control)); |
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | static int koneplus_get_info(struct usb_device *usb_dev, | ||
| 59 | struct koneplus_info *buf) | ||
| 60 | { | ||
| 61 | return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_INFO, | ||
| 62 | buf, sizeof(struct koneplus_info)); | ||
| 63 | } | ||
| 64 | |||
| 65 | static int koneplus_get_profile_settings(struct usb_device *usb_dev, | ||
| 66 | struct koneplus_profile_settings *buf, uint number) | ||
| 67 | { | ||
| 68 | int retval; | ||
| 69 | |||
| 70 | retval = koneplus_send_control(usb_dev, number, | ||
| 71 | KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS); | ||
| 72 | if (retval) | ||
| 73 | return retval; | ||
| 74 | |||
| 75 | return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_SETTINGS, | ||
| 76 | buf, sizeof(struct koneplus_profile_settings)); | ||
| 77 | } | ||
| 78 | |||
| 79 | static int koneplus_set_profile_settings(struct usb_device *usb_dev, | ||
| 80 | struct koneplus_profile_settings const *settings) | ||
| 81 | { | ||
| 82 | return roccat_common2_send_with_status(usb_dev, | ||
| 83 | KONEPLUS_COMMAND_PROFILE_SETTINGS, | ||
| 84 | settings, sizeof(struct koneplus_profile_settings)); | ||
| 85 | } | ||
| 86 | |||
| 87 | static int koneplus_get_profile_buttons(struct usb_device *usb_dev, | ||
| 88 | struct koneplus_profile_buttons *buf, int number) | ||
| 89 | { | ||
| 90 | int retval; | ||
| 91 | |||
| 92 | retval = koneplus_send_control(usb_dev, number, | ||
| 93 | KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS); | ||
| 94 | if (retval) | ||
| 95 | return retval; | ||
| 96 | |||
| 97 | return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_BUTTONS, | ||
| 98 | buf, sizeof(struct koneplus_profile_buttons)); | ||
| 99 | } | ||
| 100 | |||
| 101 | static int koneplus_set_profile_buttons(struct usb_device *usb_dev, | ||
| 102 | struct koneplus_profile_buttons const *buttons) | ||
| 103 | { | ||
| 104 | return roccat_common2_send_with_status(usb_dev, | ||
| 105 | KONEPLUS_COMMAND_PROFILE_BUTTONS, | ||
| 106 | buttons, sizeof(struct koneplus_profile_buttons)); | ||
| 107 | } | ||
| 108 | 59 | ||
| 109 | /* retval is 0-4 on success, < 0 on error */ | 60 | /* retval is 0-4 on success, < 0 on error */ |
| 110 | static int koneplus_get_actual_profile(struct usb_device *usb_dev) | 61 | static int koneplus_get_actual_profile(struct usb_device *usb_dev) |
| @@ -113,7 +64,7 @@ static int koneplus_get_actual_profile(struct usb_device *usb_dev) | |||
| 113 | int retval; | 64 | int retval; |
| 114 | 65 | ||
| 115 | retval = roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_ACTUAL_PROFILE, | 66 | retval = roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_ACTUAL_PROFILE, |
| 116 | &buf, sizeof(struct koneplus_actual_profile)); | 67 | &buf, KONEPLUS_SIZE_ACTUAL_PROFILE); |
| 117 | 68 | ||
| 118 | return retval ? retval : buf.actual_profile; | 69 | return retval ? retval : buf.actual_profile; |
| 119 | } | 70 | } |
| @@ -124,12 +75,12 @@ static int koneplus_set_actual_profile(struct usb_device *usb_dev, | |||
| 124 | struct koneplus_actual_profile buf; | 75 | struct koneplus_actual_profile buf; |
| 125 | 76 | ||
| 126 | buf.command = KONEPLUS_COMMAND_ACTUAL_PROFILE; | 77 | buf.command = KONEPLUS_COMMAND_ACTUAL_PROFILE; |
| 127 | buf.size = sizeof(struct koneplus_actual_profile); | 78 | buf.size = KONEPLUS_SIZE_ACTUAL_PROFILE; |
| 128 | buf.actual_profile = new_profile; | 79 | buf.actual_profile = new_profile; |
| 129 | 80 | ||
| 130 | return roccat_common2_send_with_status(usb_dev, | 81 | return roccat_common2_send_with_status(usb_dev, |
| 131 | KONEPLUS_COMMAND_ACTUAL_PROFILE, | 82 | KONEPLUS_COMMAND_ACTUAL_PROFILE, |
| 132 | &buf, sizeof(struct koneplus_actual_profile)); | 83 | &buf, KONEPLUS_SIZE_ACTUAL_PROFILE); |
| 133 | } | 84 | } |
| 134 | 85 | ||
| 135 | static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj, | 86 | static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj, |
| @@ -182,111 +133,77 @@ static ssize_t koneplus_sysfs_write(struct file *fp, struct kobject *kobj, | |||
| 182 | return real_size; | 133 | return real_size; |
| 183 | } | 134 | } |
| 184 | 135 | ||
| 185 | static ssize_t koneplus_sysfs_write_talk(struct file *fp, | 136 | #define KONEPLUS_SYSFS_W(thingy, THINGY) \ |
| 186 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 137 | static ssize_t koneplus_sysfs_write_ ## thingy(struct file *fp, \ |
| 187 | loff_t off, size_t count) | 138 | struct kobject *kobj, struct bin_attribute *attr, char *buf, \ |
| 188 | { | 139 | loff_t off, size_t count) \ |
| 189 | return koneplus_sysfs_write(fp, kobj, buf, off, count, | 140 | { \ |
| 190 | sizeof(struct koneplus_talk), KONEPLUS_COMMAND_TALK); | 141 | return koneplus_sysfs_write(fp, kobj, buf, off, count, \ |
| 142 | KONEPLUS_SIZE_ ## THINGY, KONEPLUS_COMMAND_ ## THINGY); \ | ||
| 191 | } | 143 | } |
| 192 | 144 | ||
| 193 | static ssize_t koneplus_sysfs_write_macro(struct file *fp, | 145 | #define KONEPLUS_SYSFS_R(thingy, THINGY) \ |
| 194 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 146 | static ssize_t koneplus_sysfs_read_ ## thingy(struct file *fp, \ |
| 195 | loff_t off, size_t count) | 147 | struct kobject *kobj, struct bin_attribute *attr, char *buf, \ |
| 196 | { | 148 | loff_t off, size_t count) \ |
| 197 | return koneplus_sysfs_write(fp, kobj, buf, off, count, | 149 | { \ |
| 198 | sizeof(struct koneplus_macro), KONEPLUS_COMMAND_MACRO); | 150 | return koneplus_sysfs_read(fp, kobj, buf, off, count, \ |
| 151 | KONEPLUS_SIZE_ ## THINGY, KONEPLUS_COMMAND_ ## THINGY); \ | ||
| 199 | } | 152 | } |
| 200 | 153 | ||
| 201 | static ssize_t koneplus_sysfs_read_sensor(struct file *fp, | 154 | #define KONEPLUS_SYSFS_RW(thingy, THINGY) \ |
| 202 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 155 | KONEPLUS_SYSFS_W(thingy, THINGY) \ |
| 203 | loff_t off, size_t count) | 156 | KONEPLUS_SYSFS_R(thingy, THINGY) |
| 204 | { | ||
| 205 | return koneplus_sysfs_read(fp, kobj, buf, off, count, | ||
| 206 | sizeof(struct koneplus_sensor), KONEPLUS_COMMAND_SENSOR); | ||
| 207 | } | ||
| 208 | 157 | ||
| 209 | static ssize_t koneplus_sysfs_write_sensor(struct file *fp, | 158 | #define KONEPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \ |
| 210 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 159 | { \ |
| 211 | loff_t off, size_t count) | 160 | .attr = { .name = #thingy, .mode = 0660 }, \ |
| 212 | { | 161 | .size = KONEPLUS_SIZE_ ## THINGY, \ |
| 213 | return koneplus_sysfs_write(fp, kobj, buf, off, count, | 162 | .read = koneplus_sysfs_read_ ## thingy, \ |
| 214 | sizeof(struct koneplus_sensor), KONEPLUS_COMMAND_SENSOR); | 163 | .write = koneplus_sysfs_write_ ## thingy \ |
| 215 | } | 164 | } |
| 216 | 165 | ||
| 217 | static ssize_t koneplus_sysfs_write_tcu(struct file *fp, | 166 | #define KONEPLUS_BIN_ATTRIBUTE_R(thingy, THINGY) \ |
| 218 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 167 | { \ |
| 219 | loff_t off, size_t count) | 168 | .attr = { .name = #thingy, .mode = 0440 }, \ |
| 220 | { | 169 | .size = KONEPLUS_SIZE_ ## THINGY, \ |
| 221 | return koneplus_sysfs_write(fp, kobj, buf, off, count, | 170 | .read = koneplus_sysfs_read_ ## thingy, \ |
| 222 | sizeof(struct koneplus_tcu), KONEPLUS_COMMAND_TCU); | ||
| 223 | } | 171 | } |
| 224 | 172 | ||
| 225 | static ssize_t koneplus_sysfs_read_tcu_image(struct file *fp, | 173 | #define KONEPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \ |
| 226 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 174 | { \ |
| 227 | loff_t off, size_t count) | 175 | .attr = { .name = #thingy, .mode = 0220 }, \ |
| 228 | { | 176 | .size = KONEPLUS_SIZE_ ## THINGY, \ |
| 229 | return koneplus_sysfs_read(fp, kobj, buf, off, count, | 177 | .write = koneplus_sysfs_write_ ## thingy \ |
| 230 | sizeof(struct koneplus_tcu_image), KONEPLUS_COMMAND_TCU); | ||
| 231 | } | 178 | } |
| 232 | 179 | ||
| 233 | static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp, | 180 | KONEPLUS_SYSFS_W(control, CONTROL) |
| 234 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 181 | KONEPLUS_SYSFS_RW(info, INFO) |
| 235 | loff_t off, size_t count) | 182 | KONEPLUS_SYSFS_W(talk, TALK) |
| 236 | { | 183 | KONEPLUS_SYSFS_W(macro, MACRO) |
| 237 | struct device *dev = | 184 | KONEPLUS_SYSFS_RW(sensor, SENSOR) |
| 238 | container_of(kobj, struct device, kobj)->parent->parent; | 185 | KONEPLUS_SYSFS_RW(tcu, TCU) |
| 239 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | 186 | KONEPLUS_SYSFS_R(tcu_image, TCU_IMAGE) |
| 240 | 187 | KONEPLUS_SYSFS_RW(profile_settings, PROFILE_SETTINGS) | |
| 241 | if (off >= sizeof(struct koneplus_profile_settings)) | 188 | KONEPLUS_SYSFS_RW(profile_buttons, PROFILE_BUTTONS) |
| 242 | return 0; | ||
| 243 | 189 | ||
| 244 | if (off + count > sizeof(struct koneplus_profile_settings)) | 190 | static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp, |
| 245 | count = sizeof(struct koneplus_profile_settings) - off; | ||
| 246 | |||
| 247 | mutex_lock(&koneplus->koneplus_lock); | ||
| 248 | memcpy(buf, ((char const *)&koneplus->profile_settings[*(uint *)(attr->private)]) + off, | ||
| 249 | count); | ||
| 250 | mutex_unlock(&koneplus->koneplus_lock); | ||
| 251 | |||
| 252 | return count; | ||
| 253 | } | ||
| 254 | |||
| 255 | static ssize_t koneplus_sysfs_write_profile_settings(struct file *fp, | ||
| 256 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 191 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 257 | loff_t off, size_t count) | 192 | loff_t off, size_t count) |
| 258 | { | 193 | { |
| 259 | struct device *dev = | 194 | struct device *dev = |
| 260 | container_of(kobj, struct device, kobj)->parent->parent; | 195 | container_of(kobj, struct device, kobj)->parent->parent; |
| 261 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
| 262 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 196 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 263 | int retval = 0; | 197 | ssize_t retval; |
| 264 | int difference; | ||
| 265 | int profile_number; | ||
| 266 | struct koneplus_profile_settings *profile_settings; | ||
| 267 | |||
| 268 | if (off != 0 || count != sizeof(struct koneplus_profile_settings)) | ||
| 269 | return -EINVAL; | ||
| 270 | |||
| 271 | profile_number = ((struct koneplus_profile_settings const *)buf)->number; | ||
| 272 | profile_settings = &koneplus->profile_settings[profile_number]; | ||
| 273 | |||
| 274 | mutex_lock(&koneplus->koneplus_lock); | ||
| 275 | difference = memcmp(buf, profile_settings, | ||
| 276 | sizeof(struct koneplus_profile_settings)); | ||
| 277 | if (difference) { | ||
| 278 | retval = koneplus_set_profile_settings(usb_dev, | ||
| 279 | (struct koneplus_profile_settings const *)buf); | ||
| 280 | if (!retval) | ||
| 281 | memcpy(profile_settings, buf, | ||
| 282 | sizeof(struct koneplus_profile_settings)); | ||
| 283 | } | ||
| 284 | mutex_unlock(&koneplus->koneplus_lock); | ||
| 285 | 198 | ||
| 199 | retval = koneplus_send_control(usb_dev, *(uint *)(attr->private), | ||
| 200 | KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS); | ||
| 286 | if (retval) | 201 | if (retval) |
| 287 | return retval; | 202 | return retval; |
| 288 | 203 | ||
| 289 | return sizeof(struct koneplus_profile_settings); | 204 | return koneplus_sysfs_read(fp, kobj, buf, off, count, |
| 205 | KONEPLUS_SIZE_PROFILE_SETTINGS, | ||
| 206 | KONEPLUS_COMMAND_PROFILE_SETTINGS); | ||
| 290 | } | 207 | } |
| 291 | 208 | ||
| 292 | static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp, | 209 | static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp, |
| @@ -295,57 +212,17 @@ static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp, | |||
| 295 | { | 212 | { |
| 296 | struct device *dev = | 213 | struct device *dev = |
| 297 | container_of(kobj, struct device, kobj)->parent->parent; | 214 | container_of(kobj, struct device, kobj)->parent->parent; |
| 298 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
| 299 | |||
| 300 | if (off >= sizeof(struct koneplus_profile_buttons)) | ||
| 301 | return 0; | ||
| 302 | |||
| 303 | if (off + count > sizeof(struct koneplus_profile_buttons)) | ||
| 304 | count = sizeof(struct koneplus_profile_buttons) - off; | ||
| 305 | |||
| 306 | mutex_lock(&koneplus->koneplus_lock); | ||
| 307 | memcpy(buf, ((char const *)&koneplus->profile_buttons[*(uint *)(attr->private)]) + off, | ||
| 308 | count); | ||
| 309 | mutex_unlock(&koneplus->koneplus_lock); | ||
| 310 | |||
| 311 | return count; | ||
| 312 | } | ||
| 313 | |||
| 314 | static ssize_t koneplus_sysfs_write_profile_buttons(struct file *fp, | ||
| 315 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
| 316 | loff_t off, size_t count) | ||
| 317 | { | ||
| 318 | struct device *dev = | ||
| 319 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 320 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
| 321 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 215 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 322 | int retval = 0; | 216 | ssize_t retval; |
| 323 | int difference; | ||
| 324 | uint profile_number; | ||
| 325 | struct koneplus_profile_buttons *profile_buttons; | ||
| 326 | |||
| 327 | if (off != 0 || count != sizeof(struct koneplus_profile_buttons)) | ||
| 328 | return -EINVAL; | ||
| 329 | |||
| 330 | profile_number = ((struct koneplus_profile_buttons const *)buf)->number; | ||
| 331 | profile_buttons = &koneplus->profile_buttons[profile_number]; | ||
| 332 | |||
| 333 | mutex_lock(&koneplus->koneplus_lock); | ||
| 334 | difference = memcmp(buf, profile_buttons, | ||
| 335 | sizeof(struct koneplus_profile_buttons)); | ||
| 336 | if (difference) { | ||
| 337 | retval = koneplus_set_profile_buttons(usb_dev, | ||
| 338 | (struct koneplus_profile_buttons const *)buf); | ||
| 339 | if (!retval) | ||
| 340 | memcpy(profile_buttons, buf, | ||
| 341 | sizeof(struct koneplus_profile_buttons)); | ||
| 342 | } | ||
| 343 | mutex_unlock(&koneplus->koneplus_lock); | ||
| 344 | 217 | ||
| 218 | retval = koneplus_send_control(usb_dev, *(uint *)(attr->private), | ||
| 219 | KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS); | ||
| 345 | if (retval) | 220 | if (retval) |
| 346 | return retval; | 221 | return retval; |
| 347 | 222 | ||
| 348 | return sizeof(struct koneplus_profile_buttons); | 223 | return koneplus_sysfs_read(fp, kobj, buf, off, count, |
| 224 | KONEPLUS_SIZE_PROFILE_BUTTONS, | ||
| 225 | KONEPLUS_COMMAND_PROFILE_BUTTONS); | ||
| 349 | } | 226 | } |
| 350 | 227 | ||
| 351 | static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev, | 228 | static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev, |
| @@ -401,9 +278,20 @@ static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev, | |||
| 401 | static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev, | 278 | static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev, |
| 402 | struct device_attribute *attr, char *buf) | 279 | struct device_attribute *attr, char *buf) |
| 403 | { | 280 | { |
| 404 | struct koneplus_device *koneplus = | 281 | struct koneplus_device *koneplus; |
| 405 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | 282 | struct usb_device *usb_dev; |
| 406 | return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->info.firmware_version); | 283 | struct koneplus_info info; |
| 284 | |||
| 285 | dev = dev->parent->parent; | ||
| 286 | koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
| 287 | usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
| 288 | |||
| 289 | mutex_lock(&koneplus->koneplus_lock); | ||
| 290 | roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_INFO, | ||
| 291 | &info, KONEPLUS_SIZE_INFO); | ||
| 292 | mutex_unlock(&koneplus->koneplus_lock); | ||
| 293 | |||
| 294 | return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version); | ||
| 407 | } | 295 | } |
| 408 | 296 | ||
| 409 | static struct device_attribute koneplus_attributes[] = { | 297 | static struct device_attribute koneplus_attributes[] = { |
| @@ -419,132 +307,85 @@ static struct device_attribute koneplus_attributes[] = { | |||
| 419 | }; | 307 | }; |
| 420 | 308 | ||
| 421 | static struct bin_attribute koneplus_bin_attributes[] = { | 309 | static struct bin_attribute koneplus_bin_attributes[] = { |
| 422 | { | 310 | KONEPLUS_BIN_ATTRIBUTE_W(control, CONTROL), |
| 423 | .attr = { .name = "sensor", .mode = 0660 }, | 311 | KONEPLUS_BIN_ATTRIBUTE_RW(info, INFO), |
| 424 | .size = sizeof(struct koneplus_sensor), | 312 | KONEPLUS_BIN_ATTRIBUTE_W(talk, TALK), |
| 425 | .read = koneplus_sysfs_read_sensor, | 313 | KONEPLUS_BIN_ATTRIBUTE_W(macro, MACRO), |
| 426 | .write = koneplus_sysfs_write_sensor | 314 | KONEPLUS_BIN_ATTRIBUTE_RW(sensor, SENSOR), |
| 427 | }, | 315 | KONEPLUS_BIN_ATTRIBUTE_RW(tcu, TCU), |
| 428 | { | 316 | KONEPLUS_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE), |
| 429 | .attr = { .name = "tcu", .mode = 0220 }, | 317 | KONEPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS), |
| 430 | .size = sizeof(struct koneplus_tcu), | 318 | KONEPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS), |
| 431 | .write = koneplus_sysfs_write_tcu | ||
| 432 | }, | ||
| 433 | { | ||
| 434 | .attr = { .name = "tcu_image", .mode = 0440 }, | ||
| 435 | .size = sizeof(struct koneplus_tcu_image), | ||
| 436 | .read = koneplus_sysfs_read_tcu_image | ||
| 437 | }, | ||
| 438 | { | ||
| 439 | .attr = { .name = "profile_settings", .mode = 0220 }, | ||
| 440 | .size = sizeof(struct koneplus_profile_settings), | ||
| 441 | .write = koneplus_sysfs_write_profile_settings | ||
| 442 | }, | ||
| 443 | { | 319 | { |
| 444 | .attr = { .name = "profile1_settings", .mode = 0440 }, | 320 | .attr = { .name = "profile1_settings", .mode = 0440 }, |
| 445 | .size = sizeof(struct koneplus_profile_settings), | 321 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, |
| 446 | .read = koneplus_sysfs_read_profilex_settings, | 322 | .read = koneplus_sysfs_read_profilex_settings, |
| 447 | .private = &profile_numbers[0] | 323 | .private = &profile_numbers[0] |
| 448 | }, | 324 | }, |
| 449 | { | 325 | { |
| 450 | .attr = { .name = "profile2_settings", .mode = 0440 }, | 326 | .attr = { .name = "profile2_settings", .mode = 0440 }, |
| 451 | .size = sizeof(struct koneplus_profile_settings), | 327 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, |
| 452 | .read = koneplus_sysfs_read_profilex_settings, | 328 | .read = koneplus_sysfs_read_profilex_settings, |
| 453 | .private = &profile_numbers[1] | 329 | .private = &profile_numbers[1] |
| 454 | }, | 330 | }, |
| 455 | { | 331 | { |
| 456 | .attr = { .name = "profile3_settings", .mode = 0440 }, | 332 | .attr = { .name = "profile3_settings", .mode = 0440 }, |
| 457 | .size = sizeof(struct koneplus_profile_settings), | 333 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, |
| 458 | .read = koneplus_sysfs_read_profilex_settings, | 334 | .read = koneplus_sysfs_read_profilex_settings, |
| 459 | .private = &profile_numbers[2] | 335 | .private = &profile_numbers[2] |
| 460 | }, | 336 | }, |
| 461 | { | 337 | { |
| 462 | .attr = { .name = "profile4_settings", .mode = 0440 }, | 338 | .attr = { .name = "profile4_settings", .mode = 0440 }, |
| 463 | .size = sizeof(struct koneplus_profile_settings), | 339 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, |
| 464 | .read = koneplus_sysfs_read_profilex_settings, | 340 | .read = koneplus_sysfs_read_profilex_settings, |
| 465 | .private = &profile_numbers[3] | 341 | .private = &profile_numbers[3] |
| 466 | }, | 342 | }, |
| 467 | { | 343 | { |
| 468 | .attr = { .name = "profile5_settings", .mode = 0440 }, | 344 | .attr = { .name = "profile5_settings", .mode = 0440 }, |
| 469 | .size = sizeof(struct koneplus_profile_settings), | 345 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, |
| 470 | .read = koneplus_sysfs_read_profilex_settings, | 346 | .read = koneplus_sysfs_read_profilex_settings, |
| 471 | .private = &profile_numbers[4] | 347 | .private = &profile_numbers[4] |
| 472 | }, | 348 | }, |
| 473 | { | 349 | { |
| 474 | .attr = { .name = "profile_buttons", .mode = 0220 }, | ||
| 475 | .size = sizeof(struct koneplus_profile_buttons), | ||
| 476 | .write = koneplus_sysfs_write_profile_buttons | ||
| 477 | }, | ||
| 478 | { | ||
| 479 | .attr = { .name = "profile1_buttons", .mode = 0440 }, | 350 | .attr = { .name = "profile1_buttons", .mode = 0440 }, |
| 480 | .size = sizeof(struct koneplus_profile_buttons), | 351 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, |
| 481 | .read = koneplus_sysfs_read_profilex_buttons, | 352 | .read = koneplus_sysfs_read_profilex_buttons, |
| 482 | .private = &profile_numbers[0] | 353 | .private = &profile_numbers[0] |
| 483 | }, | 354 | }, |
| 484 | { | 355 | { |
| 485 | .attr = { .name = "profile2_buttons", .mode = 0440 }, | 356 | .attr = { .name = "profile2_buttons", .mode = 0440 }, |
| 486 | .size = sizeof(struct koneplus_profile_buttons), | 357 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, |
| 487 | .read = koneplus_sysfs_read_profilex_buttons, | 358 | .read = koneplus_sysfs_read_profilex_buttons, |
| 488 | .private = &profile_numbers[1] | 359 | .private = &profile_numbers[1] |
| 489 | }, | 360 | }, |
| 490 | { | 361 | { |
| 491 | .attr = { .name = "profile3_buttons", .mode = 0440 }, | 362 | .attr = { .name = "profile3_buttons", .mode = 0440 }, |
| 492 | .size = sizeof(struct koneplus_profile_buttons), | 363 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, |
| 493 | .read = koneplus_sysfs_read_profilex_buttons, | 364 | .read = koneplus_sysfs_read_profilex_buttons, |
| 494 | .private = &profile_numbers[2] | 365 | .private = &profile_numbers[2] |
| 495 | }, | 366 | }, |
| 496 | { | 367 | { |
| 497 | .attr = { .name = "profile4_buttons", .mode = 0440 }, | 368 | .attr = { .name = "profile4_buttons", .mode = 0440 }, |
| 498 | .size = sizeof(struct koneplus_profile_buttons), | 369 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, |
| 499 | .read = koneplus_sysfs_read_profilex_buttons, | 370 | .read = koneplus_sysfs_read_profilex_buttons, |
| 500 | .private = &profile_numbers[3] | 371 | .private = &profile_numbers[3] |
| 501 | }, | 372 | }, |
| 502 | { | 373 | { |
| 503 | .attr = { .name = "profile5_buttons", .mode = 0440 }, | 374 | .attr = { .name = "profile5_buttons", .mode = 0440 }, |
| 504 | .size = sizeof(struct koneplus_profile_buttons), | 375 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, |
| 505 | .read = koneplus_sysfs_read_profilex_buttons, | 376 | .read = koneplus_sysfs_read_profilex_buttons, |
| 506 | .private = &profile_numbers[4] | 377 | .private = &profile_numbers[4] |
| 507 | }, | 378 | }, |
| 508 | { | ||
| 509 | .attr = { .name = "macro", .mode = 0220 }, | ||
| 510 | .size = sizeof(struct koneplus_macro), | ||
| 511 | .write = koneplus_sysfs_write_macro | ||
| 512 | }, | ||
| 513 | { | ||
| 514 | .attr = { .name = "talk", .mode = 0220 }, | ||
| 515 | .size = sizeof(struct koneplus_talk), | ||
| 516 | .write = koneplus_sysfs_write_talk | ||
| 517 | }, | ||
| 518 | __ATTR_NULL | 379 | __ATTR_NULL |
| 519 | }; | 380 | }; |
| 520 | 381 | ||
| 521 | static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, | 382 | static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, |
| 522 | struct koneplus_device *koneplus) | 383 | struct koneplus_device *koneplus) |
| 523 | { | 384 | { |
| 524 | int retval, i; | 385 | int retval; |
| 525 | static uint wait = 200; | ||
| 526 | 386 | ||
| 527 | mutex_init(&koneplus->koneplus_lock); | 387 | mutex_init(&koneplus->koneplus_lock); |
| 528 | 388 | ||
| 529 | retval = koneplus_get_info(usb_dev, &koneplus->info); | ||
| 530 | if (retval) | ||
| 531 | return retval; | ||
| 532 | |||
| 533 | for (i = 0; i < 5; ++i) { | ||
| 534 | msleep(wait); | ||
| 535 | retval = koneplus_get_profile_settings(usb_dev, | ||
| 536 | &koneplus->profile_settings[i], i); | ||
| 537 | if (retval) | ||
| 538 | return retval; | ||
| 539 | |||
| 540 | msleep(wait); | ||
| 541 | retval = koneplus_get_profile_buttons(usb_dev, | ||
| 542 | &koneplus->profile_buttons[i], i); | ||
| 543 | if (retval) | ||
| 544 | return retval; | ||
| 545 | } | ||
| 546 | |||
| 547 | msleep(wait); | ||
| 548 | retval = koneplus_get_actual_profile(usb_dev); | 389 | retval = koneplus_get_actual_profile(usb_dev); |
| 549 | if (retval < 0) | 390 | if (retval < 0) |
| 550 | return retval; | 391 | return retval; |
| @@ -709,6 +550,7 @@ static int koneplus_raw_event(struct hid_device *hdev, | |||
| 709 | 550 | ||
| 710 | static const struct hid_device_id koneplus_devices[] = { | 551 | static const struct hid_device_id koneplus_devices[] = { |
| 711 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, | 552 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, |
| 553 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEXTD) }, | ||
| 712 | { } | 554 | { } |
| 713 | }; | 555 | }; |
| 714 | 556 | ||
| @@ -749,5 +591,5 @@ module_init(koneplus_init); | |||
| 749 | module_exit(koneplus_exit); | 591 | module_exit(koneplus_exit); |
| 750 | 592 | ||
| 751 | MODULE_AUTHOR("Stefan Achatz"); | 593 | MODULE_AUTHOR("Stefan Achatz"); |
| 752 | MODULE_DESCRIPTION("USB Roccat Kone[+] driver"); | 594 | MODULE_DESCRIPTION("USB Roccat Kone[+]/XTD driver"); |
| 753 | MODULE_LICENSE("GPL v2"); | 595 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/hid/hid-roccat-koneplus.h b/drivers/hid/hid-roccat-koneplus.h index 7074b2a4b94b..af7f57e8cf3b 100644 --- a/drivers/hid/hid-roccat-koneplus.h +++ b/drivers/hid/hid-roccat-koneplus.h | |||
| @@ -14,11 +14,19 @@ | |||
| 14 | 14 | ||
| 15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
| 16 | 16 | ||
| 17 | struct koneplus_talk { | 17 | enum { |
| 18 | uint8_t command; /* KONEPLUS_COMMAND_TALK */ | 18 | KONEPLUS_SIZE_ACTUAL_PROFILE = 0x03, |
| 19 | uint8_t size; /* always 0x10 */ | 19 | KONEPLUS_SIZE_CONTROL = 0x03, |
| 20 | uint8_t data[14]; | 20 | KONEPLUS_SIZE_FIRMWARE_WRITE = 0x0402, |
| 21 | } __packed; | 21 | KONEPLUS_SIZE_INFO = 0x06, |
| 22 | KONEPLUS_SIZE_MACRO = 0x0822, | ||
| 23 | KONEPLUS_SIZE_PROFILE_SETTINGS = 0x2b, | ||
| 24 | KONEPLUS_SIZE_PROFILE_BUTTONS = 0x4d, | ||
| 25 | KONEPLUS_SIZE_SENSOR = 0x06, | ||
| 26 | KONEPLUS_SIZE_TALK = 0x10, | ||
| 27 | KONEPLUS_SIZE_TCU = 0x04, | ||
| 28 | KONEPLUS_SIZE_TCU_IMAGE = 0x0404, | ||
| 29 | }; | ||
| 22 | 30 | ||
| 23 | enum koneplus_control_requests { | 31 | enum koneplus_control_requests { |
| 24 | KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS = 0x80, | 32 | KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS = 0x80, |
| @@ -31,45 +39,6 @@ struct koneplus_actual_profile { | |||
| 31 | uint8_t actual_profile; /* Range 0-4! */ | 39 | uint8_t actual_profile; /* Range 0-4! */ |
| 32 | } __attribute__ ((__packed__)); | 40 | } __attribute__ ((__packed__)); |
| 33 | 41 | ||
| 34 | struct koneplus_profile_settings { | ||
| 35 | uint8_t command; /* KONEPLUS_COMMAND_PROFILE_SETTINGS */ | ||
| 36 | uint8_t size; /* always 43 */ | ||
| 37 | uint8_t number; /* range 0-4 */ | ||
| 38 | uint8_t advanced_sensitivity; | ||
| 39 | uint8_t sensitivity_x; | ||
| 40 | uint8_t sensitivity_y; | ||
| 41 | uint8_t cpi_levels_enabled; | ||
| 42 | uint8_t cpi_levels_x[5]; | ||
| 43 | uint8_t cpi_startup_level; /* range 0-4 */ | ||
| 44 | uint8_t cpi_levels_y[5]; /* range 1-60 means 100-6000 cpi */ | ||
| 45 | uint8_t unknown1; | ||
| 46 | uint8_t polling_rate; | ||
| 47 | uint8_t lights_enabled; | ||
| 48 | uint8_t light_effect_mode; | ||
| 49 | uint8_t color_flow_effect; | ||
| 50 | uint8_t light_effect_type; | ||
| 51 | uint8_t light_effect_speed; | ||
| 52 | uint8_t lights[16]; | ||
| 53 | uint16_t checksum; | ||
| 54 | } __attribute__ ((__packed__)); | ||
| 55 | |||
| 56 | struct koneplus_profile_buttons { | ||
| 57 | uint8_t command; /* KONEPLUS_COMMAND_PROFILE_BUTTONS */ | ||
| 58 | uint8_t size; /* always 77 */ | ||
| 59 | uint8_t number; /* range 0-4 */ | ||
| 60 | uint8_t data[72]; | ||
| 61 | uint16_t checksum; | ||
| 62 | } __attribute__ ((__packed__)); | ||
| 63 | |||
| 64 | struct koneplus_macro { | ||
| 65 | uint8_t command; /* KONEPLUS_COMMAND_MACRO */ | ||
| 66 | uint16_t size; /* always 0x822 little endian */ | ||
| 67 | uint8_t profile; /* range 0-4 */ | ||
| 68 | uint8_t button; /* range 0-23 */ | ||
| 69 | uint8_t data[2075]; | ||
| 70 | uint16_t checksum; | ||
| 71 | } __attribute__ ((__packed__)); | ||
| 72 | |||
| 73 | struct koneplus_info { | 42 | struct koneplus_info { |
| 74 | uint8_t command; /* KONEPLUS_COMMAND_INFO */ | 43 | uint8_t command; /* KONEPLUS_COMMAND_INFO */ |
| 75 | uint8_t size; /* always 6 */ | 44 | uint8_t size; /* always 6 */ |
| @@ -77,51 +46,15 @@ struct koneplus_info { | |||
| 77 | uint8_t unknown[3]; | 46 | uint8_t unknown[3]; |
| 78 | } __attribute__ ((__packed__)); | 47 | } __attribute__ ((__packed__)); |
| 79 | 48 | ||
| 80 | struct koneplus_e { | ||
| 81 | uint8_t command; /* KONEPLUS_COMMAND_E */ | ||
| 82 | uint8_t size; /* always 3 */ | ||
| 83 | uint8_t unknown; /* TODO 1; 0 before firmware update */ | ||
| 84 | } __attribute__ ((__packed__)); | ||
| 85 | |||
| 86 | struct koneplus_sensor { | ||
| 87 | uint8_t command; /* KONEPLUS_COMMAND_SENSOR */ | ||
| 88 | uint8_t size; /* always 6 */ | ||
| 89 | uint8_t data[4]; | ||
| 90 | } __attribute__ ((__packed__)); | ||
| 91 | |||
| 92 | struct koneplus_firmware_write { | ||
| 93 | uint8_t command; /* KONEPLUS_COMMAND_FIRMWARE_WRITE */ | ||
| 94 | uint8_t unknown[1025]; | ||
| 95 | } __attribute__ ((__packed__)); | ||
| 96 | |||
| 97 | struct koneplus_firmware_write_control { | ||
| 98 | uint8_t command; /* KONEPLUS_COMMAND_FIRMWARE_WRITE_CONTROL */ | ||
| 99 | /* | ||
| 100 | * value is 1 on success | ||
| 101 | * 3 means "not finished yet" | ||
| 102 | */ | ||
| 103 | uint8_t value; | ||
| 104 | uint8_t unknown; /* always 0x75 */ | ||
| 105 | } __attribute__ ((__packed__)); | ||
| 106 | |||
| 107 | struct koneplus_tcu { | ||
| 108 | uint16_t usb_command; /* KONEPLUS_USB_COMMAND_TCU */ | ||
| 109 | uint8_t data[2]; | ||
| 110 | } __attribute__ ((__packed__)); | ||
| 111 | |||
| 112 | struct koneplus_tcu_image { | ||
| 113 | uint16_t usb_command; /* KONEPLUS_USB_COMMAND_TCU */ | ||
| 114 | uint8_t data[1024]; | ||
| 115 | uint16_t checksum; | ||
| 116 | } __attribute__ ((__packed__)); | ||
| 117 | |||
| 118 | enum koneplus_commands { | 49 | enum koneplus_commands { |
| 119 | KONEPLUS_COMMAND_ACTUAL_PROFILE = 0x5, | 50 | KONEPLUS_COMMAND_ACTUAL_PROFILE = 0x5, |
| 51 | KONEPLUS_COMMAND_CONTROL = 0x4, | ||
| 120 | KONEPLUS_COMMAND_PROFILE_SETTINGS = 0x6, | 52 | KONEPLUS_COMMAND_PROFILE_SETTINGS = 0x6, |
| 121 | KONEPLUS_COMMAND_PROFILE_BUTTONS = 0x7, | 53 | KONEPLUS_COMMAND_PROFILE_BUTTONS = 0x7, |
| 122 | KONEPLUS_COMMAND_MACRO = 0x8, | 54 | KONEPLUS_COMMAND_MACRO = 0x8, |
| 123 | KONEPLUS_COMMAND_INFO = 0x9, | 55 | KONEPLUS_COMMAND_INFO = 0x9, |
| 124 | KONEPLUS_COMMAND_TCU = 0xc, | 56 | KONEPLUS_COMMAND_TCU = 0xc, |
| 57 | KONEPLUS_COMMAND_TCU_IMAGE = 0xc, | ||
| 125 | KONEPLUS_COMMAND_E = 0xe, | 58 | KONEPLUS_COMMAND_E = 0xe, |
| 126 | KONEPLUS_COMMAND_SENSOR = 0xf, | 59 | KONEPLUS_COMMAND_SENSOR = 0xf, |
| 127 | KONEPLUS_COMMAND_TALK = 0x10, | 60 | KONEPLUS_COMMAND_TALK = 0x10, |
| @@ -187,10 +120,6 @@ struct koneplus_device { | |||
| 187 | int chrdev_minor; | 120 | int chrdev_minor; |
| 188 | 121 | ||
| 189 | struct mutex koneplus_lock; | 122 | struct mutex koneplus_lock; |
| 190 | |||
| 191 | struct koneplus_info info; | ||
| 192 | struct koneplus_profile_settings profile_settings[5]; | ||
| 193 | struct koneplus_profile_buttons profile_buttons[5]; | ||
| 194 | }; | 123 | }; |
| 195 | 124 | ||
| 196 | #endif | 125 | #endif |
diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c index ca6527ac655d..b8b37789b864 100644 --- a/drivers/hid/hid-roccat-kovaplus.c +++ b/drivers/hid/hid-roccat-kovaplus.c | |||
| @@ -70,13 +70,6 @@ static int kovaplus_select_profile(struct usb_device *usb_dev, uint number, | |||
| 70 | return kovaplus_send_control(usb_dev, number, request); | 70 | return kovaplus_send_control(usb_dev, number, request); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | static int kovaplus_get_info(struct usb_device *usb_dev, | ||
| 74 | struct kovaplus_info *buf) | ||
| 75 | { | ||
| 76 | return roccat_common2_receive(usb_dev, KOVAPLUS_COMMAND_INFO, | ||
| 77 | buf, sizeof(struct kovaplus_info)); | ||
| 78 | } | ||
| 79 | |||
| 80 | static int kovaplus_get_profile_settings(struct usb_device *usb_dev, | 73 | static int kovaplus_get_profile_settings(struct usb_device *usb_dev, |
| 81 | struct kovaplus_profile_settings *buf, uint number) | 74 | struct kovaplus_profile_settings *buf, uint number) |
| 82 | { | 75 | { |
| @@ -88,15 +81,7 @@ static int kovaplus_get_profile_settings(struct usb_device *usb_dev, | |||
| 88 | return retval; | 81 | return retval; |
| 89 | 82 | ||
| 90 | return roccat_common2_receive(usb_dev, KOVAPLUS_COMMAND_PROFILE_SETTINGS, | 83 | return roccat_common2_receive(usb_dev, KOVAPLUS_COMMAND_PROFILE_SETTINGS, |
| 91 | buf, sizeof(struct kovaplus_profile_settings)); | 84 | buf, KOVAPLUS_SIZE_PROFILE_SETTINGS); |
| 92 | } | ||
| 93 | |||
| 94 | static int kovaplus_set_profile_settings(struct usb_device *usb_dev, | ||
| 95 | struct kovaplus_profile_settings const *settings) | ||
| 96 | { | ||
| 97 | return roccat_common2_send_with_status(usb_dev, | ||
| 98 | KOVAPLUS_COMMAND_PROFILE_SETTINGS, | ||
| 99 | settings, sizeof(struct kovaplus_profile_settings)); | ||
| 100 | } | 85 | } |
| 101 | 86 | ||
| 102 | static int kovaplus_get_profile_buttons(struct usb_device *usb_dev, | 87 | static int kovaplus_get_profile_buttons(struct usb_device *usb_dev, |
| @@ -110,15 +95,7 @@ static int kovaplus_get_profile_buttons(struct usb_device *usb_dev, | |||
| 110 | return retval; | 95 | return retval; |
| 111 | 96 | ||
| 112 | return roccat_common2_receive(usb_dev, KOVAPLUS_COMMAND_PROFILE_BUTTONS, | 97 | return roccat_common2_receive(usb_dev, KOVAPLUS_COMMAND_PROFILE_BUTTONS, |
| 113 | buf, sizeof(struct kovaplus_profile_buttons)); | 98 | buf, KOVAPLUS_SIZE_PROFILE_BUTTONS); |
| 114 | } | ||
| 115 | |||
| 116 | static int kovaplus_set_profile_buttons(struct usb_device *usb_dev, | ||
| 117 | struct kovaplus_profile_buttons const *buttons) | ||
| 118 | { | ||
| 119 | return roccat_common2_send_with_status(usb_dev, | ||
| 120 | KOVAPLUS_COMMAND_PROFILE_BUTTONS, | ||
| 121 | buttons, sizeof(struct kovaplus_profile_buttons)); | ||
| 122 | } | 99 | } |
| 123 | 100 | ||
| 124 | /* retval is 0-4 on success, < 0 on error */ | 101 | /* retval is 0-4 on success, < 0 on error */ |
| @@ -147,122 +124,141 @@ static int kovaplus_set_actual_profile(struct usb_device *usb_dev, | |||
| 147 | &buf, sizeof(struct kovaplus_actual_profile)); | 124 | &buf, sizeof(struct kovaplus_actual_profile)); |
| 148 | } | 125 | } |
| 149 | 126 | ||
| 150 | static ssize_t kovaplus_sysfs_read_profilex_settings(struct file *fp, | 127 | static ssize_t kovaplus_sysfs_read(struct file *fp, struct kobject *kobj, |
| 151 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 128 | char *buf, loff_t off, size_t count, |
| 152 | loff_t off, size_t count) | 129 | size_t real_size, uint command) |
| 153 | { | 130 | { |
| 154 | struct device *dev = | 131 | struct device *dev = |
| 155 | container_of(kobj, struct device, kobj)->parent->parent; | 132 | container_of(kobj, struct device, kobj)->parent->parent; |
| 156 | struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); | 133 | struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); |
| 134 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
| 135 | int retval; | ||
| 157 | 136 | ||
| 158 | if (off >= sizeof(struct kovaplus_profile_settings)) | 137 | if (off >= real_size) |
| 159 | return 0; | 138 | return 0; |
| 160 | 139 | ||
| 161 | if (off + count > sizeof(struct kovaplus_profile_settings)) | 140 | if (off != 0 || count != real_size) |
| 162 | count = sizeof(struct kovaplus_profile_settings) - off; | 141 | return -EINVAL; |
| 163 | 142 | ||
| 164 | mutex_lock(&kovaplus->kovaplus_lock); | 143 | mutex_lock(&kovaplus->kovaplus_lock); |
| 165 | memcpy(buf, ((char const *)&kovaplus->profile_settings[*(uint *)(attr->private)]) + off, | 144 | retval = roccat_common2_receive(usb_dev, command, buf, real_size); |
| 166 | count); | ||
| 167 | mutex_unlock(&kovaplus->kovaplus_lock); | 145 | mutex_unlock(&kovaplus->kovaplus_lock); |
| 168 | 146 | ||
| 169 | return count; | 147 | if (retval) |
| 148 | return retval; | ||
| 149 | |||
| 150 | return real_size; | ||
| 170 | } | 151 | } |
| 171 | 152 | ||
| 172 | static ssize_t kovaplus_sysfs_write_profile_settings(struct file *fp, | 153 | static ssize_t kovaplus_sysfs_write(struct file *fp, struct kobject *kobj, |
| 173 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 154 | void const *buf, loff_t off, size_t count, |
| 174 | loff_t off, size_t count) | 155 | size_t real_size, uint command) |
| 175 | { | 156 | { |
| 176 | struct device *dev = | 157 | struct device *dev = |
| 177 | container_of(kobj, struct device, kobj)->parent->parent; | 158 | container_of(kobj, struct device, kobj)->parent->parent; |
| 178 | struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); | 159 | struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); |
| 179 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 160 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 180 | int retval = 0; | 161 | int retval; |
| 181 | int difference; | ||
| 182 | int profile_index; | ||
| 183 | struct kovaplus_profile_settings *profile_settings; | ||
| 184 | 162 | ||
| 185 | if (off != 0 || count != sizeof(struct kovaplus_profile_settings)) | 163 | if (off != 0 || count != real_size) |
| 186 | return -EINVAL; | 164 | return -EINVAL; |
| 187 | 165 | ||
| 188 | profile_index = ((struct kovaplus_profile_settings const *)buf)->profile_index; | ||
| 189 | profile_settings = &kovaplus->profile_settings[profile_index]; | ||
| 190 | |||
| 191 | mutex_lock(&kovaplus->kovaplus_lock); | 166 | mutex_lock(&kovaplus->kovaplus_lock); |
| 192 | difference = memcmp(buf, profile_settings, | 167 | retval = roccat_common2_send_with_status(usb_dev, command, |
| 193 | sizeof(struct kovaplus_profile_settings)); | 168 | buf, real_size); |
| 194 | if (difference) { | ||
| 195 | retval = kovaplus_set_profile_settings(usb_dev, | ||
| 196 | (struct kovaplus_profile_settings const *)buf); | ||
| 197 | if (!retval) | ||
| 198 | memcpy(profile_settings, buf, | ||
| 199 | sizeof(struct kovaplus_profile_settings)); | ||
| 200 | } | ||
| 201 | mutex_unlock(&kovaplus->kovaplus_lock); | 169 | mutex_unlock(&kovaplus->kovaplus_lock); |
| 202 | 170 | ||
| 203 | if (retval) | 171 | if (retval) |
| 204 | return retval; | 172 | return retval; |
| 205 | 173 | ||
| 206 | return sizeof(struct kovaplus_profile_settings); | 174 | return real_size; |
| 207 | } | 175 | } |
| 208 | 176 | ||
| 209 | static ssize_t kovaplus_sysfs_read_profilex_buttons(struct file *fp, | 177 | #define KOVAPLUS_SYSFS_W(thingy, THINGY) \ |
| 210 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 178 | static ssize_t kovaplus_sysfs_write_ ## thingy(struct file *fp, \ |
| 211 | loff_t off, size_t count) | 179 | struct kobject *kobj, struct bin_attribute *attr, char *buf, \ |
| 212 | { | 180 | loff_t off, size_t count) \ |
| 213 | struct device *dev = | 181 | { \ |
| 214 | container_of(kobj, struct device, kobj)->parent->parent; | 182 | return kovaplus_sysfs_write(fp, kobj, buf, off, count, \ |
| 215 | struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); | 183 | KOVAPLUS_SIZE_ ## THINGY, KOVAPLUS_COMMAND_ ## THINGY); \ |
| 184 | } | ||
| 216 | 185 | ||
| 217 | if (off >= sizeof(struct kovaplus_profile_buttons)) | 186 | #define KOVAPLUS_SYSFS_R(thingy, THINGY) \ |
| 218 | return 0; | 187 | static ssize_t kovaplus_sysfs_read_ ## thingy(struct file *fp, \ |
| 188 | struct kobject *kobj, struct bin_attribute *attr, char *buf, \ | ||
| 189 | loff_t off, size_t count) \ | ||
| 190 | { \ | ||
| 191 | return kovaplus_sysfs_read(fp, kobj, buf, off, count, \ | ||
| 192 | KOVAPLUS_SIZE_ ## THINGY, KOVAPLUS_COMMAND_ ## THINGY); \ | ||
| 193 | } | ||
| 219 | 194 | ||
| 220 | if (off + count > sizeof(struct kovaplus_profile_buttons)) | 195 | #define KOVAPLUS_SYSFS_RW(thingy, THINGY) \ |
| 221 | count = sizeof(struct kovaplus_profile_buttons) - off; | 196 | KOVAPLUS_SYSFS_W(thingy, THINGY) \ |
| 197 | KOVAPLUS_SYSFS_R(thingy, THINGY) | ||
| 222 | 198 | ||
| 223 | mutex_lock(&kovaplus->kovaplus_lock); | 199 | #define KOVAPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \ |
| 224 | memcpy(buf, ((char const *)&kovaplus->profile_buttons[*(uint *)(attr->private)]) + off, | 200 | { \ |
| 225 | count); | 201 | .attr = { .name = #thingy, .mode = 0660 }, \ |
| 226 | mutex_unlock(&kovaplus->kovaplus_lock); | 202 | .size = KOVAPLUS_SIZE_ ## THINGY, \ |
| 203 | .read = kovaplus_sysfs_read_ ## thingy, \ | ||
| 204 | .write = kovaplus_sysfs_write_ ## thingy \ | ||
| 205 | } | ||
| 206 | |||
| 207 | #define KOVAPLUS_BIN_ATTRIBUTE_R(thingy, THINGY) \ | ||
| 208 | { \ | ||
| 209 | .attr = { .name = #thingy, .mode = 0440 }, \ | ||
| 210 | .size = KOVAPLUS_SIZE_ ## THINGY, \ | ||
| 211 | .read = kovaplus_sysfs_read_ ## thingy, \ | ||
| 212 | } | ||
| 227 | 213 | ||
| 228 | return count; | 214 | #define KOVAPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \ |
| 215 | { \ | ||
| 216 | .attr = { .name = #thingy, .mode = 0220 }, \ | ||
| 217 | .size = KOVAPLUS_SIZE_ ## THINGY, \ | ||
| 218 | .write = kovaplus_sysfs_write_ ## thingy \ | ||
| 229 | } | 219 | } |
| 230 | 220 | ||
| 231 | static ssize_t kovaplus_sysfs_write_profile_buttons(struct file *fp, | 221 | KOVAPLUS_SYSFS_W(control, CONTROL) |
| 222 | KOVAPLUS_SYSFS_RW(info, INFO) | ||
| 223 | KOVAPLUS_SYSFS_RW(profile_settings, PROFILE_SETTINGS) | ||
| 224 | KOVAPLUS_SYSFS_RW(profile_buttons, PROFILE_BUTTONS) | ||
| 225 | |||
| 226 | static ssize_t kovaplus_sysfs_read_profilex_settings(struct file *fp, | ||
| 232 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 227 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 233 | loff_t off, size_t count) | 228 | loff_t off, size_t count) |
| 234 | { | 229 | { |
| 235 | struct device *dev = | 230 | struct device *dev = |
| 236 | container_of(kobj, struct device, kobj)->parent->parent; | 231 | container_of(kobj, struct device, kobj)->parent->parent; |
| 237 | struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
| 238 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 232 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 239 | int retval = 0; | 233 | ssize_t retval; |
| 240 | int difference; | ||
| 241 | uint profile_index; | ||
| 242 | struct kovaplus_profile_buttons *profile_buttons; | ||
| 243 | 234 | ||
| 244 | if (off != 0 || count != sizeof(struct kovaplus_profile_buttons)) | 235 | retval = kovaplus_select_profile(usb_dev, *(uint *)(attr->private), |
| 245 | return -EINVAL; | 236 | KOVAPLUS_CONTROL_REQUEST_PROFILE_SETTINGS); |
| 237 | if (retval) | ||
| 238 | return retval; | ||
| 246 | 239 | ||
| 247 | profile_index = ((struct kovaplus_profile_buttons const *)buf)->profile_index; | 240 | return kovaplus_sysfs_read(fp, kobj, buf, off, count, |
| 248 | profile_buttons = &kovaplus->profile_buttons[profile_index]; | 241 | KOVAPLUS_SIZE_PROFILE_SETTINGS, |
| 242 | KOVAPLUS_COMMAND_PROFILE_SETTINGS); | ||
| 243 | } | ||
| 249 | 244 | ||
| 250 | mutex_lock(&kovaplus->kovaplus_lock); | 245 | static ssize_t kovaplus_sysfs_read_profilex_buttons(struct file *fp, |
| 251 | difference = memcmp(buf, profile_buttons, | 246 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 252 | sizeof(struct kovaplus_profile_buttons)); | 247 | loff_t off, size_t count) |
| 253 | if (difference) { | 248 | { |
| 254 | retval = kovaplus_set_profile_buttons(usb_dev, | 249 | struct device *dev = |
| 255 | (struct kovaplus_profile_buttons const *)buf); | 250 | container_of(kobj, struct device, kobj)->parent->parent; |
| 256 | if (!retval) | 251 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 257 | memcpy(profile_buttons, buf, | 252 | ssize_t retval; |
| 258 | sizeof(struct kovaplus_profile_buttons)); | ||
| 259 | } | ||
| 260 | mutex_unlock(&kovaplus->kovaplus_lock); | ||
| 261 | 253 | ||
| 254 | retval = kovaplus_select_profile(usb_dev, *(uint *)(attr->private), | ||
| 255 | KOVAPLUS_CONTROL_REQUEST_PROFILE_BUTTONS); | ||
| 262 | if (retval) | 256 | if (retval) |
| 263 | return retval; | 257 | return retval; |
| 264 | 258 | ||
| 265 | return sizeof(struct kovaplus_profile_buttons); | 259 | return kovaplus_sysfs_read(fp, kobj, buf, off, count, |
| 260 | KOVAPLUS_SIZE_PROFILE_BUTTONS, | ||
| 261 | KOVAPLUS_COMMAND_PROFILE_BUTTONS); | ||
| 266 | } | 262 | } |
| 267 | 263 | ||
| 268 | static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev, | 264 | static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev, |
| @@ -342,9 +338,20 @@ static ssize_t kovaplus_sysfs_show_actual_sensitivity_y(struct device *dev, | |||
| 342 | static ssize_t kovaplus_sysfs_show_firmware_version(struct device *dev, | 338 | static ssize_t kovaplus_sysfs_show_firmware_version(struct device *dev, |
| 343 | struct device_attribute *attr, char *buf) | 339 | struct device_attribute *attr, char *buf) |
| 344 | { | 340 | { |
| 345 | struct kovaplus_device *kovaplus = | 341 | struct kovaplus_device *kovaplus; |
| 346 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | 342 | struct usb_device *usb_dev; |
| 347 | return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->info.firmware_version); | 343 | struct kovaplus_info info; |
| 344 | |||
| 345 | dev = dev->parent->parent; | ||
| 346 | kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
| 347 | usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
| 348 | |||
| 349 | mutex_lock(&kovaplus->kovaplus_lock); | ||
| 350 | roccat_common2_receive(usb_dev, KOVAPLUS_COMMAND_INFO, | ||
| 351 | &info, KOVAPLUS_SIZE_INFO); | ||
| 352 | mutex_unlock(&kovaplus->kovaplus_lock); | ||
| 353 | |||
| 354 | return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version); | ||
| 348 | } | 355 | } |
| 349 | 356 | ||
| 350 | static struct device_attribute kovaplus_attributes[] = { | 357 | static struct device_attribute kovaplus_attributes[] = { |
| @@ -363,73 +370,67 @@ static struct device_attribute kovaplus_attributes[] = { | |||
| 363 | }; | 370 | }; |
| 364 | 371 | ||
| 365 | static struct bin_attribute kovaplus_bin_attributes[] = { | 372 | static struct bin_attribute kovaplus_bin_attributes[] = { |
| 366 | { | 373 | KOVAPLUS_BIN_ATTRIBUTE_W(control, CONTROL), |
| 367 | .attr = { .name = "profile_settings", .mode = 0220 }, | 374 | KOVAPLUS_BIN_ATTRIBUTE_RW(info, INFO), |
| 368 | .size = sizeof(struct kovaplus_profile_settings), | 375 | KOVAPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS), |
| 369 | .write = kovaplus_sysfs_write_profile_settings | 376 | KOVAPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS), |
| 370 | }, | ||
| 371 | { | 377 | { |
| 372 | .attr = { .name = "profile1_settings", .mode = 0440 }, | 378 | .attr = { .name = "profile1_settings", .mode = 0440 }, |
| 373 | .size = sizeof(struct kovaplus_profile_settings), | 379 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, |
| 374 | .read = kovaplus_sysfs_read_profilex_settings, | 380 | .read = kovaplus_sysfs_read_profilex_settings, |
| 375 | .private = &profile_numbers[0] | 381 | .private = &profile_numbers[0] |
| 376 | }, | 382 | }, |
| 377 | { | 383 | { |
| 378 | .attr = { .name = "profile2_settings", .mode = 0440 }, | 384 | .attr = { .name = "profile2_settings", .mode = 0440 }, |
| 379 | .size = sizeof(struct kovaplus_profile_settings), | 385 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, |
| 380 | .read = kovaplus_sysfs_read_profilex_settings, | 386 | .read = kovaplus_sysfs_read_profilex_settings, |
| 381 | .private = &profile_numbers[1] | 387 | .private = &profile_numbers[1] |
| 382 | }, | 388 | }, |
| 383 | { | 389 | { |
| 384 | .attr = { .name = "profile3_settings", .mode = 0440 }, | 390 | .attr = { .name = "profile3_settings", .mode = 0440 }, |
| 385 | .size = sizeof(struct kovaplus_profile_settings), | 391 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, |
| 386 | .read = kovaplus_sysfs_read_profilex_settings, | 392 | .read = kovaplus_sysfs_read_profilex_settings, |
| 387 | .private = &profile_numbers[2] | 393 | .private = &profile_numbers[2] |
| 388 | }, | 394 | }, |
| 389 | { | 395 | { |
| 390 | .attr = { .name = "profile4_settings", .mode = 0440 }, | 396 | .attr = { .name = "profile4_settings", .mode = 0440 }, |
| 391 | .size = sizeof(struct kovaplus_profile_settings), | 397 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, |
| 392 | .read = kovaplus_sysfs_read_profilex_settings, | 398 | .read = kovaplus_sysfs_read_profilex_settings, |
| 393 | .private = &profile_numbers[3] | 399 | .private = &profile_numbers[3] |
| 394 | }, | 400 | }, |
| 395 | { | 401 | { |
| 396 | .attr = { .name = "profile5_settings", .mode = 0440 }, | 402 | .attr = { .name = "profile5_settings", .mode = 0440 }, |
| 397 | .size = sizeof(struct kovaplus_profile_settings), | 403 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, |
| 398 | .read = kovaplus_sysfs_read_profilex_settings, | 404 | .read = kovaplus_sysfs_read_profilex_settings, |
| 399 | .private = &profile_numbers[4] | 405 | .private = &profile_numbers[4] |
| 400 | }, | 406 | }, |
| 401 | { | 407 | { |
| 402 | .attr = { .name = "profile_buttons", .mode = 0220 }, | ||
| 403 | .size = sizeof(struct kovaplus_profile_buttons), | ||
| 404 | .write = kovaplus_sysfs_write_profile_buttons | ||
| 405 | }, | ||
| 406 | { | ||
| 407 | .attr = { .name = "profile1_buttons", .mode = 0440 }, | 408 | .attr = { .name = "profile1_buttons", .mode = 0440 }, |
| 408 | .size = sizeof(struct kovaplus_profile_buttons), | 409 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, |
| 409 | .read = kovaplus_sysfs_read_profilex_buttons, | 410 | .read = kovaplus_sysfs_read_profilex_buttons, |
| 410 | .private = &profile_numbers[0] | 411 | .private = &profile_numbers[0] |
| 411 | }, | 412 | }, |
| 412 | { | 413 | { |
| 413 | .attr = { .name = "profile2_buttons", .mode = 0440 }, | 414 | .attr = { .name = "profile2_buttons", .mode = 0440 }, |
| 414 | .size = sizeof(struct kovaplus_profile_buttons), | 415 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, |
| 415 | .read = kovaplus_sysfs_read_profilex_buttons, | 416 | .read = kovaplus_sysfs_read_profilex_buttons, |
| 416 | .private = &profile_numbers[1] | 417 | .private = &profile_numbers[1] |
| 417 | }, | 418 | }, |
| 418 | { | 419 | { |
| 419 | .attr = { .name = "profile3_buttons", .mode = 0440 }, | 420 | .attr = { .name = "profile3_buttons", .mode = 0440 }, |
| 420 | .size = sizeof(struct kovaplus_profile_buttons), | 421 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, |
| 421 | .read = kovaplus_sysfs_read_profilex_buttons, | 422 | .read = kovaplus_sysfs_read_profilex_buttons, |
| 422 | .private = &profile_numbers[2] | 423 | .private = &profile_numbers[2] |
| 423 | }, | 424 | }, |
| 424 | { | 425 | { |
| 425 | .attr = { .name = "profile4_buttons", .mode = 0440 }, | 426 | .attr = { .name = "profile4_buttons", .mode = 0440 }, |
| 426 | .size = sizeof(struct kovaplus_profile_buttons), | 427 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, |
| 427 | .read = kovaplus_sysfs_read_profilex_buttons, | 428 | .read = kovaplus_sysfs_read_profilex_buttons, |
| 428 | .private = &profile_numbers[3] | 429 | .private = &profile_numbers[3] |
| 429 | }, | 430 | }, |
| 430 | { | 431 | { |
| 431 | .attr = { .name = "profile5_buttons", .mode = 0440 }, | 432 | .attr = { .name = "profile5_buttons", .mode = 0440 }, |
| 432 | .size = sizeof(struct kovaplus_profile_buttons), | 433 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, |
| 433 | .read = kovaplus_sysfs_read_profilex_buttons, | 434 | .read = kovaplus_sysfs_read_profilex_buttons, |
| 434 | .private = &profile_numbers[4] | 435 | .private = &profile_numbers[4] |
| 435 | }, | 436 | }, |
| @@ -444,10 +445,6 @@ static int kovaplus_init_kovaplus_device_struct(struct usb_device *usb_dev, | |||
| 444 | 445 | ||
| 445 | mutex_init(&kovaplus->kovaplus_lock); | 446 | mutex_init(&kovaplus->kovaplus_lock); |
| 446 | 447 | ||
| 447 | retval = kovaplus_get_info(usb_dev, &kovaplus->info); | ||
| 448 | if (retval) | ||
| 449 | return retval; | ||
| 450 | |||
| 451 | for (i = 0; i < 5; ++i) { | 448 | for (i = 0; i < 5; ++i) { |
| 452 | msleep(wait); | 449 | msleep(wait); |
| 453 | retval = kovaplus_get_profile_settings(usb_dev, | 450 | retval = kovaplus_get_profile_settings(usb_dev, |
diff --git a/drivers/hid/hid-roccat-kovaplus.h b/drivers/hid/hid-roccat-kovaplus.h index f82daa1cdcb9..fbb7a16a7e54 100644 --- a/drivers/hid/hid-roccat-kovaplus.h +++ b/drivers/hid/hid-roccat-kovaplus.h | |||
| @@ -14,6 +14,13 @@ | |||
| 14 | 14 | ||
| 15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
| 16 | 16 | ||
| 17 | enum { | ||
| 18 | KOVAPLUS_SIZE_CONTROL = 0x03, | ||
| 19 | KOVAPLUS_SIZE_INFO = 0x06, | ||
| 20 | KOVAPLUS_SIZE_PROFILE_SETTINGS = 0x10, | ||
| 21 | KOVAPLUS_SIZE_PROFILE_BUTTONS = 0x17, | ||
| 22 | }; | ||
| 23 | |||
| 17 | enum kovaplus_control_requests { | 24 | enum kovaplus_control_requests { |
| 18 | /* write; value = profile number range 0-4 */ | 25 | /* write; value = profile number range 0-4 */ |
| 19 | KOVAPLUS_CONTROL_REQUEST_PROFILE_SETTINGS = 0x10, | 26 | KOVAPLUS_CONTROL_REQUEST_PROFILE_SETTINGS = 0x10, |
| @@ -53,15 +60,9 @@ struct kovaplus_info { | |||
| 53 | uint8_t unknown[3]; | 60 | uint8_t unknown[3]; |
| 54 | } __packed; | 61 | } __packed; |
| 55 | 62 | ||
| 56 | /* writes 1 on plugin */ | ||
| 57 | struct kovaplus_a { | ||
| 58 | uint8_t command; /* KOVAPLUS_COMMAND_A */ | ||
| 59 | uint8_t size; /* 3 */ | ||
| 60 | uint8_t unknown; | ||
| 61 | } __packed; | ||
| 62 | |||
| 63 | enum kovaplus_commands { | 63 | enum kovaplus_commands { |
| 64 | KOVAPLUS_COMMAND_ACTUAL_PROFILE = 0x5, | 64 | KOVAPLUS_COMMAND_ACTUAL_PROFILE = 0x5, |
| 65 | KOVAPLUS_COMMAND_CONTROL = 0x4, | ||
| 65 | KOVAPLUS_COMMAND_PROFILE_SETTINGS = 0x6, | 66 | KOVAPLUS_COMMAND_PROFILE_SETTINGS = 0x6, |
| 66 | KOVAPLUS_COMMAND_PROFILE_BUTTONS = 0x7, | 67 | KOVAPLUS_COMMAND_PROFILE_BUTTONS = 0x7, |
| 67 | KOVAPLUS_COMMAND_INFO = 0x9, | 68 | KOVAPLUS_COMMAND_INFO = 0x9, |
| @@ -125,7 +126,6 @@ struct kovaplus_device { | |||
| 125 | int roccat_claimed; | 126 | int roccat_claimed; |
| 126 | int chrdev_minor; | 127 | int chrdev_minor; |
| 127 | struct mutex kovaplus_lock; | 128 | struct mutex kovaplus_lock; |
| 128 | struct kovaplus_info info; | ||
| 129 | struct kovaplus_profile_settings profile_settings[5]; | 129 | struct kovaplus_profile_settings profile_settings[5]; |
| 130 | struct kovaplus_profile_buttons profile_buttons[5]; | 130 | struct kovaplus_profile_buttons profile_buttons[5]; |
| 131 | }; | 131 | }; |
diff --git a/drivers/hid/hid-roccat-lua.c b/drivers/hid/hid-roccat-lua.c new file mode 100644 index 000000000000..5084fb4b7e91 --- /dev/null +++ b/drivers/hid/hid-roccat-lua.c | |||
| @@ -0,0 +1,227 @@ | |||
| 1 | /* | ||
| 2 | * Roccat Lua driver for Linux | ||
| 3 | * | ||
| 4 | * Copyright (c) 2012 Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 5 | */ | ||
| 6 | |||
| 7 | /* | ||
| 8 | * This program is free software; you can redistribute it and/or modify it | ||
| 9 | * under the terms of the GNU General Public License as published by the Free | ||
| 10 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 11 | * any later version. | ||
| 12 | */ | ||
| 13 | |||
| 14 | /* | ||
| 15 | * Roccat Lua is a gamer mouse which cpi, button and light settings can be | ||
| 16 | * configured. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <linux/device.h> | ||
| 20 | #include <linux/input.h> | ||
| 21 | #include <linux/hid.h> | ||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/slab.h> | ||
| 24 | #include <linux/hid-roccat.h> | ||
| 25 | #include "hid-ids.h" | ||
| 26 | #include "hid-roccat-common.h" | ||
| 27 | #include "hid-roccat-lua.h" | ||
| 28 | |||
| 29 | static ssize_t lua_sysfs_read(struct file *fp, struct kobject *kobj, | ||
| 30 | char *buf, loff_t off, size_t count, | ||
| 31 | size_t real_size, uint command) | ||
| 32 | { | ||
| 33 | struct device *dev = container_of(kobj, struct device, kobj); | ||
| 34 | struct lua_device *lua = hid_get_drvdata(dev_get_drvdata(dev)); | ||
| 35 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
| 36 | int retval; | ||
| 37 | |||
| 38 | if (off >= real_size) | ||
| 39 | return 0; | ||
| 40 | |||
| 41 | if (off != 0 || count != real_size) | ||
| 42 | return -EINVAL; | ||
| 43 | |||
| 44 | mutex_lock(&lua->lua_lock); | ||
| 45 | retval = roccat_common2_receive(usb_dev, command, buf, real_size); | ||
| 46 | mutex_unlock(&lua->lua_lock); | ||
| 47 | |||
| 48 | return retval ? retval : real_size; | ||
| 49 | } | ||
| 50 | |||
| 51 | static ssize_t lua_sysfs_write(struct file *fp, struct kobject *kobj, | ||
| 52 | void const *buf, loff_t off, size_t count, | ||
| 53 | size_t real_size, uint command) | ||
| 54 | { | ||
| 55 | struct device *dev = container_of(kobj, struct device, kobj); | ||
| 56 | struct lua_device *lua = hid_get_drvdata(dev_get_drvdata(dev)); | ||
| 57 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
| 58 | int retval; | ||
| 59 | |||
| 60 | if (off != 0 || count != real_size) | ||
| 61 | return -EINVAL; | ||
| 62 | |||
| 63 | mutex_lock(&lua->lua_lock); | ||
| 64 | retval = roccat_common2_send(usb_dev, command, (void *)buf, real_size); | ||
| 65 | mutex_unlock(&lua->lua_lock); | ||
| 66 | |||
| 67 | return retval ? retval : real_size; | ||
| 68 | } | ||
| 69 | |||
| 70 | #define LUA_SYSFS_W(thingy, THINGY) \ | ||
| 71 | static ssize_t lua_sysfs_write_ ## thingy(struct file *fp, \ | ||
| 72 | struct kobject *kobj, struct bin_attribute *attr, \ | ||
| 73 | char *buf, loff_t off, size_t count) \ | ||
| 74 | { \ | ||
| 75 | return lua_sysfs_write(fp, kobj, buf, off, count, \ | ||
| 76 | LUA_SIZE_ ## THINGY, LUA_COMMAND_ ## THINGY); \ | ||
| 77 | } | ||
| 78 | |||
| 79 | #define LUA_SYSFS_R(thingy, THINGY) \ | ||
| 80 | static ssize_t lua_sysfs_read_ ## thingy(struct file *fp, \ | ||
| 81 | struct kobject *kobj, struct bin_attribute *attr, \ | ||
| 82 | char *buf, loff_t off, size_t count) \ | ||
| 83 | { \ | ||
| 84 | return lua_sysfs_read(fp, kobj, buf, off, count, \ | ||
| 85 | LUA_SIZE_ ## THINGY, LUA_COMMAND_ ## THINGY); \ | ||
| 86 | } | ||
| 87 | |||
| 88 | #define LUA_BIN_ATTRIBUTE_RW(thingy, THINGY) \ | ||
| 89 | LUA_SYSFS_W(thingy, THINGY) \ | ||
| 90 | LUA_SYSFS_R(thingy, THINGY) \ | ||
| 91 | static struct bin_attribute lua_ ## thingy ## _attr = { \ | ||
| 92 | .attr = { .name = #thingy, .mode = 0660 }, \ | ||
| 93 | .size = LUA_SIZE_ ## THINGY, \ | ||
| 94 | .read = lua_sysfs_read_ ## thingy, \ | ||
| 95 | .write = lua_sysfs_write_ ## thingy \ | ||
| 96 | }; | ||
| 97 | |||
| 98 | LUA_BIN_ATTRIBUTE_RW(control, CONTROL) | ||
| 99 | |||
| 100 | static int lua_create_sysfs_attributes(struct usb_interface *intf) | ||
| 101 | { | ||
| 102 | return sysfs_create_bin_file(&intf->dev.kobj, &lua_control_attr); | ||
| 103 | } | ||
| 104 | |||
| 105 | static void lua_remove_sysfs_attributes(struct usb_interface *intf) | ||
| 106 | { | ||
| 107 | sysfs_remove_bin_file(&intf->dev.kobj, &lua_control_attr); | ||
| 108 | } | ||
| 109 | |||
| 110 | static int lua_init_lua_device_struct(struct usb_device *usb_dev, | ||
| 111 | struct lua_device *lua) | ||
| 112 | { | ||
| 113 | mutex_init(&lua->lua_lock); | ||
| 114 | |||
| 115 | return 0; | ||
| 116 | } | ||
| 117 | |||
| 118 | static int lua_init_specials(struct hid_device *hdev) | ||
| 119 | { | ||
| 120 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); | ||
| 121 | struct usb_device *usb_dev = interface_to_usbdev(intf); | ||
| 122 | struct lua_device *lua; | ||
| 123 | int retval; | ||
| 124 | |||
| 125 | lua = kzalloc(sizeof(*lua), GFP_KERNEL); | ||
| 126 | if (!lua) { | ||
| 127 | hid_err(hdev, "can't alloc device descriptor\n"); | ||
| 128 | return -ENOMEM; | ||
| 129 | } | ||
| 130 | hid_set_drvdata(hdev, lua); | ||
| 131 | |||
| 132 | retval = lua_init_lua_device_struct(usb_dev, lua); | ||
| 133 | if (retval) { | ||
| 134 | hid_err(hdev, "couldn't init struct lua_device\n"); | ||
| 135 | goto exit; | ||
| 136 | } | ||
| 137 | |||
| 138 | retval = lua_create_sysfs_attributes(intf); | ||
| 139 | if (retval) { | ||
| 140 | hid_err(hdev, "cannot create sysfs files\n"); | ||
| 141 | goto exit; | ||
| 142 | } | ||
| 143 | |||
| 144 | return 0; | ||
| 145 | exit: | ||
| 146 | kfree(lua); | ||
| 147 | return retval; | ||
| 148 | } | ||
| 149 | |||
| 150 | static void lua_remove_specials(struct hid_device *hdev) | ||
| 151 | { | ||
| 152 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); | ||
| 153 | struct lua_device *lua; | ||
| 154 | |||
| 155 | lua_remove_sysfs_attributes(intf); | ||
| 156 | |||
| 157 | lua = hid_get_drvdata(hdev); | ||
| 158 | kfree(lua); | ||
| 159 | } | ||
| 160 | |||
| 161 | static int lua_probe(struct hid_device *hdev, | ||
| 162 | const struct hid_device_id *id) | ||
| 163 | { | ||
| 164 | int retval; | ||
| 165 | |||
| 166 | retval = hid_parse(hdev); | ||
| 167 | if (retval) { | ||
| 168 | hid_err(hdev, "parse failed\n"); | ||
| 169 | goto exit; | ||
| 170 | } | ||
| 171 | |||
| 172 | retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | ||
| 173 | if (retval) { | ||
| 174 | hid_err(hdev, "hw start failed\n"); | ||
| 175 | goto exit; | ||
| 176 | } | ||
| 177 | |||
| 178 | retval = lua_init_specials(hdev); | ||
| 179 | if (retval) { | ||
| 180 | hid_err(hdev, "couldn't install mouse\n"); | ||
| 181 | goto exit_stop; | ||
| 182 | } | ||
| 183 | |||
| 184 | return 0; | ||
| 185 | |||
| 186 | exit_stop: | ||
| 187 | hid_hw_stop(hdev); | ||
| 188 | exit: | ||
| 189 | return retval; | ||
| 190 | } | ||
| 191 | |||
| 192 | static void lua_remove(struct hid_device *hdev) | ||
| 193 | { | ||
| 194 | lua_remove_specials(hdev); | ||
| 195 | hid_hw_stop(hdev); | ||
| 196 | } | ||
| 197 | |||
| 198 | static const struct hid_device_id lua_devices[] = { | ||
| 199 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_LUA) }, | ||
| 200 | { } | ||
| 201 | }; | ||
| 202 | |||
| 203 | MODULE_DEVICE_TABLE(hid, lua_devices); | ||
| 204 | |||
| 205 | static struct hid_driver lua_driver = { | ||
| 206 | .name = "lua", | ||
| 207 | .id_table = lua_devices, | ||
| 208 | .probe = lua_probe, | ||
| 209 | .remove = lua_remove | ||
| 210 | }; | ||
| 211 | |||
| 212 | static int __init lua_init(void) | ||
| 213 | { | ||
| 214 | return hid_register_driver(&lua_driver); | ||
| 215 | } | ||
| 216 | |||
| 217 | static void __exit lua_exit(void) | ||
| 218 | { | ||
| 219 | hid_unregister_driver(&lua_driver); | ||
| 220 | } | ||
| 221 | |||
| 222 | module_init(lua_init); | ||
| 223 | module_exit(lua_exit); | ||
| 224 | |||
| 225 | MODULE_AUTHOR("Stefan Achatz"); | ||
| 226 | MODULE_DESCRIPTION("USB Roccat Lua driver"); | ||
| 227 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/hid/hid-roccat-lua.h b/drivers/hid/hid-roccat-lua.h new file mode 100644 index 000000000000..547d77a375d1 --- /dev/null +++ b/drivers/hid/hid-roccat-lua.h | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #ifndef __HID_ROCCAT_LUA_H | ||
| 2 | #define __HID_ROCCAT_LUA_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Copyright (c) 2012 Stefan Achatz <erazor_de@users.sourceforge.net> | ||
| 6 | */ | ||
| 7 | |||
| 8 | /* | ||
| 9 | * This program is free software; you can redistribute it and/or modify it | ||
| 10 | * under the terms of the GNU General Public License as published by the Free | ||
| 11 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 12 | * any later version. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <linux/types.h> | ||
| 16 | |||
| 17 | enum { | ||
| 18 | LUA_SIZE_CONTROL = 8, | ||
| 19 | }; | ||
| 20 | |||
| 21 | enum lua_commands { | ||
| 22 | LUA_COMMAND_CONTROL = 3, | ||
| 23 | }; | ||
| 24 | |||
| 25 | struct lua_device { | ||
| 26 | struct mutex lua_lock; | ||
| 27 | }; | ||
| 28 | |||
| 29 | #endif | ||
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index 1317c177a3e2..d4f1e3bee590 100644 --- a/drivers/hid/hid-roccat-pyra.c +++ b/drivers/hid/hid-roccat-pyra.c | |||
| @@ -66,48 +66,14 @@ static int pyra_get_profile_settings(struct usb_device *usb_dev, | |||
| 66 | if (retval) | 66 | if (retval) |
| 67 | return retval; | 67 | return retval; |
| 68 | return roccat_common2_receive(usb_dev, PYRA_COMMAND_PROFILE_SETTINGS, | 68 | return roccat_common2_receive(usb_dev, PYRA_COMMAND_PROFILE_SETTINGS, |
| 69 | buf, sizeof(struct pyra_profile_settings)); | 69 | buf, PYRA_SIZE_PROFILE_SETTINGS); |
| 70 | } | ||
| 71 | |||
| 72 | static int pyra_get_profile_buttons(struct usb_device *usb_dev, | ||
| 73 | struct pyra_profile_buttons *buf, int number) | ||
| 74 | { | ||
| 75 | int retval; | ||
| 76 | retval = pyra_send_control(usb_dev, number, | ||
| 77 | PYRA_CONTROL_REQUEST_PROFILE_BUTTONS); | ||
| 78 | if (retval) | ||
| 79 | return retval; | ||
| 80 | return roccat_common2_receive(usb_dev, PYRA_COMMAND_PROFILE_BUTTONS, | ||
| 81 | buf, sizeof(struct pyra_profile_buttons)); | ||
| 82 | } | 70 | } |
| 83 | 71 | ||
| 84 | static int pyra_get_settings(struct usb_device *usb_dev, | 72 | static int pyra_get_settings(struct usb_device *usb_dev, |
| 85 | struct pyra_settings *buf) | 73 | struct pyra_settings *buf) |
| 86 | { | 74 | { |
| 87 | return roccat_common2_receive(usb_dev, PYRA_COMMAND_SETTINGS, | 75 | return roccat_common2_receive(usb_dev, PYRA_COMMAND_SETTINGS, |
| 88 | buf, sizeof(struct pyra_settings)); | 76 | buf, PYRA_SIZE_SETTINGS); |
| 89 | } | ||
| 90 | |||
| 91 | static int pyra_get_info(struct usb_device *usb_dev, struct pyra_info *buf) | ||
| 92 | { | ||
| 93 | return roccat_common2_receive(usb_dev, PYRA_COMMAND_INFO, | ||
| 94 | buf, sizeof(struct pyra_info)); | ||
| 95 | } | ||
| 96 | |||
| 97 | static int pyra_set_profile_settings(struct usb_device *usb_dev, | ||
| 98 | struct pyra_profile_settings const *settings) | ||
| 99 | { | ||
| 100 | return roccat_common2_send_with_status(usb_dev, | ||
| 101 | PYRA_COMMAND_PROFILE_SETTINGS, settings, | ||
| 102 | sizeof(struct pyra_profile_settings)); | ||
| 103 | } | ||
| 104 | |||
| 105 | static int pyra_set_profile_buttons(struct usb_device *usb_dev, | ||
| 106 | struct pyra_profile_buttons const *buttons) | ||
| 107 | { | ||
| 108 | return roccat_common2_send_with_status(usb_dev, | ||
| 109 | PYRA_COMMAND_PROFILE_BUTTONS, buttons, | ||
| 110 | sizeof(struct pyra_profile_buttons)); | ||
| 111 | } | 77 | } |
| 112 | 78 | ||
| 113 | static int pyra_set_settings(struct usb_device *usb_dev, | 79 | static int pyra_set_settings(struct usb_device *usb_dev, |
| @@ -115,146 +81,144 @@ static int pyra_set_settings(struct usb_device *usb_dev, | |||
| 115 | { | 81 | { |
| 116 | return roccat_common2_send_with_status(usb_dev, | 82 | return roccat_common2_send_with_status(usb_dev, |
| 117 | PYRA_COMMAND_SETTINGS, settings, | 83 | PYRA_COMMAND_SETTINGS, settings, |
| 118 | sizeof(struct pyra_settings)); | 84 | PYRA_SIZE_SETTINGS); |
| 119 | } | 85 | } |
| 120 | 86 | ||
| 121 | static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp, | 87 | static ssize_t pyra_sysfs_read(struct file *fp, struct kobject *kobj, |
| 122 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 88 | char *buf, loff_t off, size_t count, |
| 123 | loff_t off, size_t count) | 89 | size_t real_size, uint command) |
| 124 | { | 90 | { |
| 125 | struct device *dev = | 91 | struct device *dev = |
| 126 | container_of(kobj, struct device, kobj)->parent->parent; | 92 | container_of(kobj, struct device, kobj)->parent->parent; |
| 127 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 93 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 94 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
| 95 | int retval; | ||
| 128 | 96 | ||
| 129 | if (off >= sizeof(struct pyra_profile_settings)) | 97 | if (off >= real_size) |
| 130 | return 0; | 98 | return 0; |
| 131 | 99 | ||
| 132 | if (off + count > sizeof(struct pyra_profile_settings)) | 100 | if (off != 0 || count != real_size) |
| 133 | count = sizeof(struct pyra_profile_settings) - off; | 101 | return -EINVAL; |
| 134 | 102 | ||
| 135 | mutex_lock(&pyra->pyra_lock); | 103 | mutex_lock(&pyra->pyra_lock); |
| 136 | memcpy(buf, ((char const *)&pyra->profile_settings[*(uint *)(attr->private)]) + off, | 104 | retval = roccat_common2_receive(usb_dev, command, buf, real_size); |
| 137 | count); | ||
| 138 | mutex_unlock(&pyra->pyra_lock); | 105 | mutex_unlock(&pyra->pyra_lock); |
| 139 | 106 | ||
| 140 | return count; | 107 | if (retval) |
| 108 | return retval; | ||
| 109 | |||
| 110 | return real_size; | ||
| 141 | } | 111 | } |
| 142 | 112 | ||
| 143 | static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp, | 113 | static ssize_t pyra_sysfs_write(struct file *fp, struct kobject *kobj, |
| 144 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 114 | void const *buf, loff_t off, size_t count, |
| 145 | loff_t off, size_t count) | 115 | size_t real_size, uint command) |
| 146 | { | 116 | { |
| 147 | struct device *dev = | 117 | struct device *dev = |
| 148 | container_of(kobj, struct device, kobj)->parent->parent; | 118 | container_of(kobj, struct device, kobj)->parent->parent; |
| 149 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 119 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 120 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
| 121 | int retval; | ||
| 150 | 122 | ||
| 151 | if (off >= sizeof(struct pyra_profile_buttons)) | 123 | if (off != 0 || count != real_size) |
| 152 | return 0; | 124 | return -EINVAL; |
| 153 | |||
| 154 | if (off + count > sizeof(struct pyra_profile_buttons)) | ||
| 155 | count = sizeof(struct pyra_profile_buttons) - off; | ||
| 156 | 125 | ||
| 157 | mutex_lock(&pyra->pyra_lock); | 126 | mutex_lock(&pyra->pyra_lock); |
| 158 | memcpy(buf, ((char const *)&pyra->profile_buttons[*(uint *)(attr->private)]) + off, | 127 | retval = roccat_common2_send_with_status(usb_dev, command, (void *)buf, real_size); |
| 159 | count); | ||
| 160 | mutex_unlock(&pyra->pyra_lock); | 128 | mutex_unlock(&pyra->pyra_lock); |
| 161 | 129 | ||
| 162 | return count; | 130 | if (retval) |
| 131 | return retval; | ||
| 132 | |||
| 133 | return real_size; | ||
| 163 | } | 134 | } |
| 164 | 135 | ||
| 165 | static ssize_t pyra_sysfs_write_profile_settings(struct file *fp, | 136 | #define PYRA_SYSFS_W(thingy, THINGY) \ |
| 166 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 137 | static ssize_t pyra_sysfs_write_ ## thingy(struct file *fp, \ |
| 167 | loff_t off, size_t count) | 138 | struct kobject *kobj, struct bin_attribute *attr, char *buf, \ |
| 168 | { | 139 | loff_t off, size_t count) \ |
| 169 | struct device *dev = | 140 | { \ |
| 170 | container_of(kobj, struct device, kobj)->parent->parent; | 141 | return pyra_sysfs_write(fp, kobj, buf, off, count, \ |
| 171 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 142 | PYRA_SIZE_ ## THINGY, PYRA_COMMAND_ ## THINGY); \ |
| 172 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 143 | } |
| 173 | int retval = 0; | ||
| 174 | int difference; | ||
| 175 | int profile_number; | ||
| 176 | struct pyra_profile_settings *profile_settings; | ||
| 177 | 144 | ||
| 178 | if (off != 0 || count != sizeof(struct pyra_profile_settings)) | 145 | #define PYRA_SYSFS_R(thingy, THINGY) \ |
| 179 | return -EINVAL; | 146 | static ssize_t pyra_sysfs_read_ ## thingy(struct file *fp, \ |
| 147 | struct kobject *kobj, struct bin_attribute *attr, char *buf, \ | ||
| 148 | loff_t off, size_t count) \ | ||
| 149 | { \ | ||
| 150 | return pyra_sysfs_read(fp, kobj, buf, off, count, \ | ||
| 151 | PYRA_SIZE_ ## THINGY, PYRA_COMMAND_ ## THINGY); \ | ||
| 152 | } | ||
| 180 | 153 | ||
| 181 | profile_number = ((struct pyra_profile_settings const *)buf)->number; | 154 | #define PYRA_SYSFS_RW(thingy, THINGY) \ |
| 182 | profile_settings = &pyra->profile_settings[profile_number]; | 155 | PYRA_SYSFS_W(thingy, THINGY) \ |
| 156 | PYRA_SYSFS_R(thingy, THINGY) | ||
| 183 | 157 | ||
| 184 | mutex_lock(&pyra->pyra_lock); | 158 | #define PYRA_BIN_ATTRIBUTE_RW(thingy, THINGY) \ |
| 185 | difference = memcmp(buf, profile_settings, | 159 | { \ |
| 186 | sizeof(struct pyra_profile_settings)); | 160 | .attr = { .name = #thingy, .mode = 0660 }, \ |
| 187 | if (difference) { | 161 | .size = PYRA_SIZE_ ## THINGY, \ |
| 188 | retval = pyra_set_profile_settings(usb_dev, | 162 | .read = pyra_sysfs_read_ ## thingy, \ |
| 189 | (struct pyra_profile_settings const *)buf); | 163 | .write = pyra_sysfs_write_ ## thingy \ |
| 190 | if (!retval) | 164 | } |
| 191 | memcpy(profile_settings, buf, | ||
| 192 | sizeof(struct pyra_profile_settings)); | ||
| 193 | } | ||
| 194 | mutex_unlock(&pyra->pyra_lock); | ||
| 195 | 165 | ||
| 196 | if (retval) | 166 | #define PYRA_BIN_ATTRIBUTE_R(thingy, THINGY) \ |
| 197 | return retval; | 167 | { \ |
| 168 | .attr = { .name = #thingy, .mode = 0440 }, \ | ||
| 169 | .size = PYRA_SIZE_ ## THINGY, \ | ||
| 170 | .read = pyra_sysfs_read_ ## thingy, \ | ||
| 171 | } | ||
| 198 | 172 | ||
| 199 | return sizeof(struct pyra_profile_settings); | 173 | #define PYRA_BIN_ATTRIBUTE_W(thingy, THINGY) \ |
| 174 | { \ | ||
| 175 | .attr = { .name = #thingy, .mode = 0220 }, \ | ||
| 176 | .size = PYRA_SIZE_ ## THINGY, \ | ||
| 177 | .write = pyra_sysfs_write_ ## thingy \ | ||
| 200 | } | 178 | } |
| 201 | 179 | ||
| 202 | static ssize_t pyra_sysfs_write_profile_buttons(struct file *fp, | 180 | PYRA_SYSFS_W(control, CONTROL) |
| 181 | PYRA_SYSFS_RW(info, INFO) | ||
| 182 | PYRA_SYSFS_RW(profile_settings, PROFILE_SETTINGS) | ||
| 183 | PYRA_SYSFS_RW(profile_buttons, PROFILE_BUTTONS) | ||
| 184 | PYRA_SYSFS_R(settings, SETTINGS) | ||
| 185 | |||
| 186 | static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp, | ||
| 203 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 187 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 204 | loff_t off, size_t count) | 188 | loff_t off, size_t count) |
| 205 | { | 189 | { |
| 206 | struct device *dev = | 190 | struct device *dev = |
| 207 | container_of(kobj, struct device, kobj)->parent->parent; | 191 | container_of(kobj, struct device, kobj)->parent->parent; |
| 208 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | ||
| 209 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 192 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 210 | int retval = 0; | 193 | ssize_t retval; |
| 211 | int difference; | ||
| 212 | int profile_number; | ||
| 213 | struct pyra_profile_buttons *profile_buttons; | ||
| 214 | |||
| 215 | if (off != 0 || count != sizeof(struct pyra_profile_buttons)) | ||
| 216 | return -EINVAL; | ||
| 217 | |||
| 218 | profile_number = ((struct pyra_profile_buttons const *)buf)->number; | ||
| 219 | profile_buttons = &pyra->profile_buttons[profile_number]; | ||
| 220 | |||
| 221 | mutex_lock(&pyra->pyra_lock); | ||
| 222 | difference = memcmp(buf, profile_buttons, | ||
| 223 | sizeof(struct pyra_profile_buttons)); | ||
| 224 | if (difference) { | ||
| 225 | retval = pyra_set_profile_buttons(usb_dev, | ||
| 226 | (struct pyra_profile_buttons const *)buf); | ||
| 227 | if (!retval) | ||
| 228 | memcpy(profile_buttons, buf, | ||
| 229 | sizeof(struct pyra_profile_buttons)); | ||
| 230 | } | ||
| 231 | mutex_unlock(&pyra->pyra_lock); | ||
| 232 | 194 | ||
| 195 | retval = pyra_send_control(usb_dev, *(uint *)(attr->private), | ||
| 196 | PYRA_CONTROL_REQUEST_PROFILE_SETTINGS); | ||
| 233 | if (retval) | 197 | if (retval) |
| 234 | return retval; | 198 | return retval; |
| 235 | 199 | ||
| 236 | return sizeof(struct pyra_profile_buttons); | 200 | return pyra_sysfs_read(fp, kobj, buf, off, count, |
| 201 | PYRA_SIZE_PROFILE_SETTINGS, | ||
| 202 | PYRA_COMMAND_PROFILE_SETTINGS); | ||
| 237 | } | 203 | } |
| 238 | 204 | ||
| 239 | static ssize_t pyra_sysfs_read_settings(struct file *fp, | 205 | static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp, |
| 240 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 206 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 241 | loff_t off, size_t count) | 207 | loff_t off, size_t count) |
| 242 | { | 208 | { |
| 243 | struct device *dev = | 209 | struct device *dev = |
| 244 | container_of(kobj, struct device, kobj)->parent->parent; | 210 | container_of(kobj, struct device, kobj)->parent->parent; |
| 245 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 211 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 246 | 212 | ssize_t retval; | |
| 247 | if (off >= sizeof(struct pyra_settings)) | ||
| 248 | return 0; | ||
| 249 | |||
| 250 | if (off + count > sizeof(struct pyra_settings)) | ||
| 251 | count = sizeof(struct pyra_settings) - off; | ||
| 252 | 213 | ||
| 253 | mutex_lock(&pyra->pyra_lock); | 214 | retval = pyra_send_control(usb_dev, *(uint *)(attr->private), |
| 254 | memcpy(buf, ((char const *)&pyra->settings) + off, count); | 215 | PYRA_CONTROL_REQUEST_PROFILE_BUTTONS); |
| 255 | mutex_unlock(&pyra->pyra_lock); | 216 | if (retval) |
| 217 | return retval; | ||
| 256 | 218 | ||
| 257 | return count; | 219 | return pyra_sysfs_read(fp, kobj, buf, off, count, |
| 220 | PYRA_SIZE_PROFILE_BUTTONS, | ||
| 221 | PYRA_COMMAND_PROFILE_BUTTONS); | ||
| 258 | } | 222 | } |
| 259 | 223 | ||
| 260 | static ssize_t pyra_sysfs_write_settings(struct file *fp, | 224 | static ssize_t pyra_sysfs_write_settings(struct file *fp, |
| @@ -266,35 +230,32 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp, | |||
| 266 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 230 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 267 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 231 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 268 | int retval = 0; | 232 | int retval = 0; |
| 269 | int difference; | ||
| 270 | struct pyra_roccat_report roccat_report; | 233 | struct pyra_roccat_report roccat_report; |
| 234 | struct pyra_settings const *settings; | ||
| 271 | 235 | ||
| 272 | if (off != 0 || count != sizeof(struct pyra_settings)) | 236 | if (off != 0 || count != PYRA_SIZE_SETTINGS) |
| 273 | return -EINVAL; | 237 | return -EINVAL; |
| 274 | 238 | ||
| 275 | mutex_lock(&pyra->pyra_lock); | 239 | mutex_lock(&pyra->pyra_lock); |
| 276 | difference = memcmp(buf, &pyra->settings, sizeof(struct pyra_settings)); | ||
| 277 | if (difference) { | ||
| 278 | retval = pyra_set_settings(usb_dev, | ||
| 279 | (struct pyra_settings const *)buf); | ||
| 280 | if (retval) { | ||
| 281 | mutex_unlock(&pyra->pyra_lock); | ||
| 282 | return retval; | ||
| 283 | } | ||
| 284 | |||
| 285 | memcpy(&pyra->settings, buf, | ||
| 286 | sizeof(struct pyra_settings)); | ||
| 287 | 240 | ||
| 288 | profile_activated(pyra, pyra->settings.startup_profile); | 241 | settings = (struct pyra_settings const *)buf; |
| 289 | 242 | ||
| 290 | roccat_report.type = PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2; | 243 | retval = pyra_set_settings(usb_dev, settings); |
| 291 | roccat_report.value = pyra->settings.startup_profile + 1; | 244 | if (retval) { |
| 292 | roccat_report.key = 0; | 245 | mutex_unlock(&pyra->pyra_lock); |
| 293 | roccat_report_event(pyra->chrdev_minor, | 246 | return retval; |
| 294 | (uint8_t const *)&roccat_report); | ||
| 295 | } | 247 | } |
| 248 | |||
| 249 | profile_activated(pyra, settings->startup_profile); | ||
| 250 | |||
| 251 | roccat_report.type = PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2; | ||
| 252 | roccat_report.value = settings->startup_profile + 1; | ||
| 253 | roccat_report.key = 0; | ||
| 254 | roccat_report_event(pyra->chrdev_minor, | ||
| 255 | (uint8_t const *)&roccat_report); | ||
| 256 | |||
| 296 | mutex_unlock(&pyra->pyra_lock); | 257 | mutex_unlock(&pyra->pyra_lock); |
| 297 | return sizeof(struct pyra_settings); | 258 | return PYRA_SIZE_SETTINGS; |
| 298 | } | 259 | } |
| 299 | 260 | ||
| 300 | 261 | ||
| @@ -311,23 +272,34 @@ static ssize_t pyra_sysfs_show_actual_profile(struct device *dev, | |||
| 311 | { | 272 | { |
| 312 | struct pyra_device *pyra = | 273 | struct pyra_device *pyra = |
| 313 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | 274 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); |
| 314 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_profile); | 275 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 276 | struct pyra_settings settings; | ||
| 277 | |||
| 278 | mutex_lock(&pyra->pyra_lock); | ||
| 279 | roccat_common2_receive(usb_dev, PYRA_COMMAND_SETTINGS, | ||
| 280 | &settings, PYRA_SIZE_SETTINGS); | ||
| 281 | mutex_unlock(&pyra->pyra_lock); | ||
| 282 | |||
| 283 | return snprintf(buf, PAGE_SIZE, "%d\n", settings.startup_profile); | ||
| 315 | } | 284 | } |
| 316 | 285 | ||
| 317 | static ssize_t pyra_sysfs_show_firmware_version(struct device *dev, | 286 | static ssize_t pyra_sysfs_show_firmware_version(struct device *dev, |
| 318 | struct device_attribute *attr, char *buf) | 287 | struct device_attribute *attr, char *buf) |
| 319 | { | 288 | { |
| 320 | struct pyra_device *pyra = | 289 | struct pyra_device *pyra; |
| 321 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | 290 | struct usb_device *usb_dev; |
| 322 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->firmware_version); | 291 | struct pyra_info info; |
| 323 | } | ||
| 324 | 292 | ||
| 325 | static ssize_t pyra_sysfs_show_startup_profile(struct device *dev, | 293 | dev = dev->parent->parent; |
| 326 | struct device_attribute *attr, char *buf) | 294 | pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 327 | { | 295 | usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 328 | struct pyra_device *pyra = | 296 | |
| 329 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | 297 | mutex_lock(&pyra->pyra_lock); |
| 330 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->settings.startup_profile); | 298 | roccat_common2_receive(usb_dev, PYRA_COMMAND_INFO, |
| 299 | &info, PYRA_SIZE_INFO); | ||
| 300 | mutex_unlock(&pyra->pyra_lock); | ||
| 301 | |||
| 302 | return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version); | ||
| 331 | } | 303 | } |
| 332 | 304 | ||
| 333 | static struct device_attribute pyra_attributes[] = { | 305 | static struct device_attribute pyra_attributes[] = { |
| @@ -336,105 +308,88 @@ static struct device_attribute pyra_attributes[] = { | |||
| 336 | __ATTR(firmware_version, 0440, | 308 | __ATTR(firmware_version, 0440, |
| 337 | pyra_sysfs_show_firmware_version, NULL), | 309 | pyra_sysfs_show_firmware_version, NULL), |
| 338 | __ATTR(startup_profile, 0440, | 310 | __ATTR(startup_profile, 0440, |
| 339 | pyra_sysfs_show_startup_profile, NULL), | 311 | pyra_sysfs_show_actual_profile, NULL), |
| 340 | __ATTR_NULL | 312 | __ATTR_NULL |
| 341 | }; | 313 | }; |
| 342 | 314 | ||
| 343 | static struct bin_attribute pyra_bin_attributes[] = { | 315 | static struct bin_attribute pyra_bin_attributes[] = { |
| 344 | { | 316 | PYRA_BIN_ATTRIBUTE_W(control, CONTROL), |
| 345 | .attr = { .name = "profile_settings", .mode = 0220 }, | 317 | PYRA_BIN_ATTRIBUTE_RW(info, INFO), |
| 346 | .size = sizeof(struct pyra_profile_settings), | 318 | PYRA_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS), |
| 347 | .write = pyra_sysfs_write_profile_settings | 319 | PYRA_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS), |
| 348 | }, | 320 | PYRA_BIN_ATTRIBUTE_RW(settings, SETTINGS), |
| 349 | { | 321 | { |
| 350 | .attr = { .name = "profile1_settings", .mode = 0440 }, | 322 | .attr = { .name = "profile1_settings", .mode = 0440 }, |
| 351 | .size = sizeof(struct pyra_profile_settings), | 323 | .size = PYRA_SIZE_PROFILE_SETTINGS, |
| 352 | .read = pyra_sysfs_read_profilex_settings, | 324 | .read = pyra_sysfs_read_profilex_settings, |
| 353 | .private = &profile_numbers[0] | 325 | .private = &profile_numbers[0] |
| 354 | }, | 326 | }, |
| 355 | { | 327 | { |
| 356 | .attr = { .name = "profile2_settings", .mode = 0440 }, | 328 | .attr = { .name = "profile2_settings", .mode = 0440 }, |
| 357 | .size = sizeof(struct pyra_profile_settings), | 329 | .size = PYRA_SIZE_PROFILE_SETTINGS, |
| 358 | .read = pyra_sysfs_read_profilex_settings, | 330 | .read = pyra_sysfs_read_profilex_settings, |
| 359 | .private = &profile_numbers[1] | 331 | .private = &profile_numbers[1] |
| 360 | }, | 332 | }, |
| 361 | { | 333 | { |
| 362 | .attr = { .name = "profile3_settings", .mode = 0440 }, | 334 | .attr = { .name = "profile3_settings", .mode = 0440 }, |
| 363 | .size = sizeof(struct pyra_profile_settings), | 335 | .size = PYRA_SIZE_PROFILE_SETTINGS, |
| 364 | .read = pyra_sysfs_read_profilex_settings, | 336 | .read = pyra_sysfs_read_profilex_settings, |
| 365 | .private = &profile_numbers[2] | 337 | .private = &profile_numbers[2] |
| 366 | }, | 338 | }, |
| 367 | { | 339 | { |
| 368 | .attr = { .name = "profile4_settings", .mode = 0440 }, | 340 | .attr = { .name = "profile4_settings", .mode = 0440 }, |
| 369 | .size = sizeof(struct pyra_profile_settings), | 341 | .size = PYRA_SIZE_PROFILE_SETTINGS, |
| 370 | .read = pyra_sysfs_read_profilex_settings, | 342 | .read = pyra_sysfs_read_profilex_settings, |
| 371 | .private = &profile_numbers[3] | 343 | .private = &profile_numbers[3] |
| 372 | }, | 344 | }, |
| 373 | { | 345 | { |
| 374 | .attr = { .name = "profile5_settings", .mode = 0440 }, | 346 | .attr = { .name = "profile5_settings", .mode = 0440 }, |
| 375 | .size = sizeof(struct pyra_profile_settings), | 347 | .size = PYRA_SIZE_PROFILE_SETTINGS, |
| 376 | .read = pyra_sysfs_read_profilex_settings, | 348 | .read = pyra_sysfs_read_profilex_settings, |
| 377 | .private = &profile_numbers[4] | 349 | .private = &profile_numbers[4] |
| 378 | }, | 350 | }, |
| 379 | { | 351 | { |
| 380 | .attr = { .name = "profile_buttons", .mode = 0220 }, | ||
| 381 | .size = sizeof(struct pyra_profile_buttons), | ||
| 382 | .write = pyra_sysfs_write_profile_buttons | ||
| 383 | }, | ||
| 384 | { | ||
| 385 | .attr = { .name = "profile1_buttons", .mode = 0440 }, | 352 | .attr = { .name = "profile1_buttons", .mode = 0440 }, |
| 386 | .size = sizeof(struct pyra_profile_buttons), | 353 | .size = PYRA_SIZE_PROFILE_BUTTONS, |
| 387 | .read = pyra_sysfs_read_profilex_buttons, | 354 | .read = pyra_sysfs_read_profilex_buttons, |
| 388 | .private = &profile_numbers[0] | 355 | .private = &profile_numbers[0] |
| 389 | }, | 356 | }, |
| 390 | { | 357 | { |
| 391 | .attr = { .name = "profile2_buttons", .mode = 0440 }, | 358 | .attr = { .name = "profile2_buttons", .mode = 0440 }, |
| 392 | .size = sizeof(struct pyra_profile_buttons), | 359 | .size = PYRA_SIZE_PROFILE_BUTTONS, |
| 393 | .read = pyra_sysfs_read_profilex_buttons, | 360 | .read = pyra_sysfs_read_profilex_buttons, |
| 394 | .private = &profile_numbers[1] | 361 | .private = &profile_numbers[1] |
| 395 | }, | 362 | }, |
| 396 | { | 363 | { |
| 397 | .attr = { .name = "profile3_buttons", .mode = 0440 }, | 364 | .attr = { .name = "profile3_buttons", .mode = 0440 }, |
| 398 | .size = sizeof(struct pyra_profile_buttons), | 365 | .size = PYRA_SIZE_PROFILE_BUTTONS, |
| 399 | .read = pyra_sysfs_read_profilex_buttons, | 366 | .read = pyra_sysfs_read_profilex_buttons, |
| 400 | .private = &profile_numbers[2] | 367 | .private = &profile_numbers[2] |
| 401 | }, | 368 | }, |
| 402 | { | 369 | { |
| 403 | .attr = { .name = "profile4_buttons", .mode = 0440 }, | 370 | .attr = { .name = "profile4_buttons", .mode = 0440 }, |
| 404 | .size = sizeof(struct pyra_profile_buttons), | 371 | .size = PYRA_SIZE_PROFILE_BUTTONS, |
| 405 | .read = pyra_sysfs_read_profilex_buttons, | 372 | .read = pyra_sysfs_read_profilex_buttons, |
| 406 | .private = &profile_numbers[3] | 373 | .private = &profile_numbers[3] |
| 407 | }, | 374 | }, |
| 408 | { | 375 | { |
| 409 | .attr = { .name = "profile5_buttons", .mode = 0440 }, | 376 | .attr = { .name = "profile5_buttons", .mode = 0440 }, |
| 410 | .size = sizeof(struct pyra_profile_buttons), | 377 | .size = PYRA_SIZE_PROFILE_BUTTONS, |
| 411 | .read = pyra_sysfs_read_profilex_buttons, | 378 | .read = pyra_sysfs_read_profilex_buttons, |
| 412 | .private = &profile_numbers[4] | 379 | .private = &profile_numbers[4] |
| 413 | }, | 380 | }, |
| 414 | { | ||
| 415 | .attr = { .name = "settings", .mode = 0660 }, | ||
| 416 | .size = sizeof(struct pyra_settings), | ||
| 417 | .read = pyra_sysfs_read_settings, | ||
| 418 | .write = pyra_sysfs_write_settings | ||
| 419 | }, | ||
| 420 | __ATTR_NULL | 381 | __ATTR_NULL |
| 421 | }; | 382 | }; |
| 422 | 383 | ||
| 423 | static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, | 384 | static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, |
| 424 | struct pyra_device *pyra) | 385 | struct pyra_device *pyra) |
| 425 | { | 386 | { |
| 426 | struct pyra_info info; | 387 | struct pyra_settings settings; |
| 427 | int retval, i; | 388 | int retval, i; |
| 428 | 389 | ||
| 429 | mutex_init(&pyra->pyra_lock); | 390 | mutex_init(&pyra->pyra_lock); |
| 430 | 391 | ||
| 431 | retval = pyra_get_info(usb_dev, &info); | 392 | retval = pyra_get_settings(usb_dev, &settings); |
| 432 | if (retval) | ||
| 433 | return retval; | ||
| 434 | |||
| 435 | pyra->firmware_version = info.firmware_version; | ||
| 436 | |||
| 437 | retval = pyra_get_settings(usb_dev, &pyra->settings); | ||
| 438 | if (retval) | 393 | if (retval) |
| 439 | return retval; | 394 | return retval; |
| 440 | 395 | ||
| @@ -443,14 +398,9 @@ static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, | |||
| 443 | &pyra->profile_settings[i], i); | 398 | &pyra->profile_settings[i], i); |
| 444 | if (retval) | 399 | if (retval) |
| 445 | return retval; | 400 | return retval; |
| 446 | |||
| 447 | retval = pyra_get_profile_buttons(usb_dev, | ||
| 448 | &pyra->profile_buttons[i], i); | ||
| 449 | if (retval) | ||
| 450 | return retval; | ||
| 451 | } | 401 | } |
| 452 | 402 | ||
| 453 | profile_activated(pyra, pyra->settings.startup_profile); | 403 | profile_activated(pyra, settings.startup_profile); |
| 454 | 404 | ||
| 455 | return 0; | 405 | return 0; |
| 456 | } | 406 | } |
diff --git a/drivers/hid/hid-roccat-pyra.h b/drivers/hid/hid-roccat-pyra.h index eada7830fa99..beedcf001ceb 100644 --- a/drivers/hid/hid-roccat-pyra.h +++ b/drivers/hid/hid-roccat-pyra.h | |||
| @@ -14,11 +14,13 @@ | |||
| 14 | 14 | ||
| 15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
| 16 | 16 | ||
| 17 | struct pyra_b { | 17 | enum { |
| 18 | uint8_t command; /* PYRA_COMMAND_B */ | 18 | PYRA_SIZE_CONTROL = 0x03, |
| 19 | uint8_t size; /* always 3 */ | 19 | PYRA_SIZE_INFO = 0x06, |
| 20 | uint8_t unknown; /* 1 */ | 20 | PYRA_SIZE_PROFILE_SETTINGS = 0x0d, |
| 21 | } __attribute__ ((__packed__)); | 21 | PYRA_SIZE_PROFILE_BUTTONS = 0x13, |
| 22 | PYRA_SIZE_SETTINGS = 0x03, | ||
| 23 | }; | ||
| 22 | 24 | ||
| 23 | enum pyra_control_requests { | 25 | enum pyra_control_requests { |
| 24 | PYRA_CONTROL_REQUEST_PROFILE_SETTINGS = 0x10, | 26 | PYRA_CONTROL_REQUEST_PROFILE_SETTINGS = 0x10, |
| @@ -46,14 +48,6 @@ struct pyra_profile_settings { | |||
| 46 | uint16_t checksum; /* byte sum */ | 48 | uint16_t checksum; /* byte sum */ |
| 47 | } __attribute__ ((__packed__)); | 49 | } __attribute__ ((__packed__)); |
| 48 | 50 | ||
| 49 | struct pyra_profile_buttons { | ||
| 50 | uint8_t command; /* PYRA_COMMAND_PROFILE_BUTTONS */ | ||
| 51 | uint8_t size; /* always 0x13 */ | ||
| 52 | uint8_t number; /* Range 0-4 */ | ||
| 53 | uint8_t buttons[14]; | ||
| 54 | uint16_t checksum; /* byte sum */ | ||
| 55 | } __attribute__ ((__packed__)); | ||
| 56 | |||
| 57 | struct pyra_info { | 51 | struct pyra_info { |
| 58 | uint8_t command; /* PYRA_COMMAND_INFO */ | 52 | uint8_t command; /* PYRA_COMMAND_INFO */ |
| 59 | uint8_t size; /* always 6 */ | 53 | uint8_t size; /* always 6 */ |
| @@ -64,6 +58,7 @@ struct pyra_info { | |||
| 64 | } __attribute__ ((__packed__)); | 58 | } __attribute__ ((__packed__)); |
| 65 | 59 | ||
| 66 | enum pyra_commands { | 60 | enum pyra_commands { |
| 61 | PYRA_COMMAND_CONTROL = 0x4, | ||
| 67 | PYRA_COMMAND_SETTINGS = 0x5, | 62 | PYRA_COMMAND_SETTINGS = 0x5, |
| 68 | PYRA_COMMAND_PROFILE_SETTINGS = 0x6, | 63 | PYRA_COMMAND_PROFILE_SETTINGS = 0x6, |
| 69 | PYRA_COMMAND_PROFILE_BUTTONS = 0x7, | 64 | PYRA_COMMAND_PROFILE_BUTTONS = 0x7, |
| @@ -148,13 +143,10 @@ struct pyra_roccat_report { | |||
| 148 | struct pyra_device { | 143 | struct pyra_device { |
| 149 | int actual_profile; | 144 | int actual_profile; |
| 150 | int actual_cpi; | 145 | int actual_cpi; |
| 151 | int firmware_version; | ||
| 152 | int roccat_claimed; | 146 | int roccat_claimed; |
| 153 | int chrdev_minor; | 147 | int chrdev_minor; |
| 154 | struct mutex pyra_lock; | 148 | struct mutex pyra_lock; |
| 155 | struct pyra_settings settings; | ||
| 156 | struct pyra_profile_settings profile_settings[5]; | 149 | struct pyra_profile_settings profile_settings[5]; |
| 157 | struct pyra_profile_buttons profile_buttons[5]; | ||
| 158 | }; | 150 | }; |
| 159 | 151 | ||
| 160 | #endif | 152 | #endif |
diff --git a/drivers/hid/hid-roccat-savu.c b/drivers/hid/hid-roccat-savu.c index 014afba407e0..31747a29c093 100644 --- a/drivers/hid/hid-roccat-savu.c +++ b/drivers/hid/hid-roccat-savu.c | |||
| @@ -120,7 +120,7 @@ SAVU_SYSFS_RW(profile, PROFILE) | |||
| 120 | SAVU_SYSFS_RW(general, GENERAL) | 120 | SAVU_SYSFS_RW(general, GENERAL) |
| 121 | SAVU_SYSFS_RW(buttons, BUTTONS) | 121 | SAVU_SYSFS_RW(buttons, BUTTONS) |
| 122 | SAVU_SYSFS_RW(macro, MACRO) | 122 | SAVU_SYSFS_RW(macro, MACRO) |
| 123 | SAVU_SYSFS_R(info, INFO) | 123 | SAVU_SYSFS_RW(info, INFO) |
| 124 | SAVU_SYSFS_RW(sensor, SENSOR) | 124 | SAVU_SYSFS_RW(sensor, SENSOR) |
| 125 | 125 | ||
| 126 | static struct bin_attribute savu_bin_attributes[] = { | 126 | static struct bin_attribute savu_bin_attributes[] = { |
| @@ -129,7 +129,7 @@ static struct bin_attribute savu_bin_attributes[] = { | |||
| 129 | SAVU_BIN_ATTRIBUTE_RW(general, GENERAL), | 129 | SAVU_BIN_ATTRIBUTE_RW(general, GENERAL), |
| 130 | SAVU_BIN_ATTRIBUTE_RW(buttons, BUTTONS), | 130 | SAVU_BIN_ATTRIBUTE_RW(buttons, BUTTONS), |
| 131 | SAVU_BIN_ATTRIBUTE_RW(macro, MACRO), | 131 | SAVU_BIN_ATTRIBUTE_RW(macro, MACRO), |
| 132 | SAVU_BIN_ATTRIBUTE_R(info, INFO), | 132 | SAVU_BIN_ATTRIBUTE_RW(info, INFO), |
| 133 | SAVU_BIN_ATTRIBUTE_RW(sensor, SENSOR), | 133 | SAVU_BIN_ATTRIBUTE_RW(sensor, SENSOR), |
| 134 | __ATTR_NULL | 134 | __ATTR_NULL |
| 135 | }; | 135 | }; |
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index d9d73e9163eb..0bc58bd8d4f5 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c | |||
| @@ -82,23 +82,6 @@ struct hid_sensor_hub_callbacks_list { | |||
| 82 | void *priv; | 82 | void *priv; |
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| 85 | static int sensor_hub_check_for_sensor_page(struct hid_device *hdev) | ||
| 86 | { | ||
| 87 | int i; | ||
| 88 | int ret = -EINVAL; | ||
| 89 | |||
| 90 | for (i = 0; i < hdev->maxcollection; i++) { | ||
| 91 | struct hid_collection *col = &hdev->collection[i]; | ||
| 92 | if (col->type == HID_COLLECTION_PHYSICAL && | ||
| 93 | (col->usage & HID_USAGE_PAGE) == HID_UP_SENSOR) { | ||
| 94 | ret = 0; | ||
| 95 | break; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | |||
| 99 | return ret; | ||
| 100 | } | ||
| 101 | |||
| 102 | static struct hid_report *sensor_hub_report(int id, struct hid_device *hdev, | 85 | static struct hid_report *sensor_hub_report(int id, struct hid_device *hdev, |
| 103 | int dir) | 86 | int dir) |
| 104 | { | 87 | { |
| @@ -437,9 +420,6 @@ static int sensor_hub_raw_event(struct hid_device *hdev, | |||
| 437 | ptr = raw_data; | 420 | ptr = raw_data; |
| 438 | ptr++; /*Skip report id*/ | 421 | ptr++; /*Skip report id*/ |
| 439 | 422 | ||
| 440 | if (!report) | ||
| 441 | goto err_report; | ||
| 442 | |||
| 443 | spin_lock_irqsave(&pdata->lock, flags); | 423 | spin_lock_irqsave(&pdata->lock, flags); |
| 444 | 424 | ||
| 445 | for (i = 0; i < report->maxfield; ++i) { | 425 | for (i = 0; i < report->maxfield; ++i) { |
| @@ -485,7 +465,6 @@ static int sensor_hub_raw_event(struct hid_device *hdev, | |||
| 485 | callback->pdev); | 465 | callback->pdev); |
| 486 | spin_unlock_irqrestore(&pdata->lock, flags); | 466 | spin_unlock_irqrestore(&pdata->lock, flags); |
| 487 | 467 | ||
| 488 | err_report: | ||
| 489 | return 1; | 468 | return 1; |
| 490 | } | 469 | } |
| 491 | 470 | ||
| @@ -524,10 +503,6 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
| 524 | hid_err(hdev, "parse failed\n"); | 503 | hid_err(hdev, "parse failed\n"); |
| 525 | goto err_free; | 504 | goto err_free; |
| 526 | } | 505 | } |
| 527 | if (sensor_hub_check_for_sensor_page(hdev) < 0) { | ||
| 528 | hid_err(hdev, "sensor page not found\n"); | ||
| 529 | goto err_free; | ||
| 530 | } | ||
| 531 | INIT_LIST_HEAD(&hdev->inputs); | 506 | INIT_LIST_HEAD(&hdev->inputs); |
| 532 | 507 | ||
| 533 | ret = hid_hw_start(hdev, 0); | 508 | ret = hid_hw_start(hdev, 0); |
| @@ -630,16 +605,7 @@ static void sensor_hub_remove(struct hid_device *hdev) | |||
| 630 | } | 605 | } |
| 631 | 606 | ||
| 632 | static const struct hid_device_id sensor_hub_devices[] = { | 607 | static const struct hid_device_id sensor_hub_devices[] = { |
| 633 | { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8086, | 608 | { HID_DEVICE(BUS_USB, HID_GROUP_SENSOR_HUB, HID_ANY_ID, HID_ANY_ID) }, |
| 634 | USB_DEVICE_ID_SENSOR_HUB_1020) }, | ||
| 635 | { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8087, | ||
| 636 | USB_DEVICE_ID_SENSOR_HUB_1020) }, | ||
| 637 | { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8086, | ||
| 638 | USB_DEVICE_ID_SENSOR_HUB_09FA) }, | ||
| 639 | { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8087, | ||
| 640 | USB_DEVICE_ID_SENSOR_HUB_09FA) }, | ||
| 641 | { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, | ||
| 642 | USB_DEVICE_ID_SENSOR_HUB_7014) }, | ||
| 643 | { } | 609 | { } |
| 644 | }; | 610 | }; |
| 645 | MODULE_DEVICE_TABLE(hid, sensor_hub_devices); | 611 | MODULE_DEVICE_TABLE(hid, sensor_hub_devices); |
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 7c47fc3f7b2b..413a73187d33 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
| @@ -57,10 +57,6 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, | |||
| 57 | set_current_state(TASK_INTERRUPTIBLE); | 57 | set_current_state(TASK_INTERRUPTIBLE); |
| 58 | 58 | ||
| 59 | while (list->head == list->tail) { | 59 | while (list->head == list->tail) { |
| 60 | if (file->f_flags & O_NONBLOCK) { | ||
| 61 | ret = -EAGAIN; | ||
| 62 | break; | ||
| 63 | } | ||
| 64 | if (signal_pending(current)) { | 60 | if (signal_pending(current)) { |
| 65 | ret = -ERESTARTSYS; | 61 | ret = -ERESTARTSYS; |
| 66 | break; | 62 | break; |
| @@ -69,6 +65,10 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, | |||
| 69 | ret = -EIO; | 65 | ret = -EIO; |
| 70 | break; | 66 | break; |
| 71 | } | 67 | } |
| 68 | if (file->f_flags & O_NONBLOCK) { | ||
| 69 | ret = -EAGAIN; | ||
| 70 | break; | ||
| 71 | } | ||
| 72 | 72 | ||
| 73 | /* allow O_NONBLOCK to work well from other threads */ | 73 | /* allow O_NONBLOCK to work well from other threads */ |
| 74 | mutex_unlock(&list->read_mutex); | 74 | mutex_unlock(&list->read_mutex); |
| @@ -295,6 +295,13 @@ out: | |||
| 295 | 295 | ||
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | static int hidraw_fasync(int fd, struct file *file, int on) | ||
| 299 | { | ||
| 300 | struct hidraw_list *list = file->private_data; | ||
| 301 | |||
| 302 | return fasync_helper(fd, file, on, &list->fasync); | ||
| 303 | } | ||
| 304 | |||
| 298 | static int hidraw_release(struct inode * inode, struct file * file) | 305 | static int hidraw_release(struct inode * inode, struct file * file) |
| 299 | { | 306 | { |
| 300 | unsigned int minor = iminor(inode); | 307 | unsigned int minor = iminor(inode); |
| @@ -438,6 +445,7 @@ static const struct file_operations hidraw_ops = { | |||
| 438 | .open = hidraw_open, | 445 | .open = hidraw_open, |
| 439 | .release = hidraw_release, | 446 | .release = hidraw_release, |
| 440 | .unlocked_ioctl = hidraw_ioctl, | 447 | .unlocked_ioctl = hidraw_ioctl, |
| 448 | .fasync = hidraw_fasync, | ||
| 441 | #ifdef CONFIG_COMPAT | 449 | #ifdef CONFIG_COMPAT |
| 442 | .compat_ioctl = hidraw_ioctl, | 450 | .compat_ioctl = hidraw_ioctl, |
| 443 | #endif | 451 | #endif |
diff --git a/drivers/hid/i2c-hid/Kconfig b/drivers/hid/i2c-hid/Kconfig new file mode 100644 index 000000000000..b66617a020bd --- /dev/null +++ b/drivers/hid/i2c-hid/Kconfig | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | menu "I2C HID support" | ||
| 2 | depends on I2C | ||
| 3 | |||
| 4 | config I2C_HID | ||
| 5 | tristate "HID over I2C transport layer" | ||
| 6 | default n | ||
| 7 | depends on I2C && INPUT | ||
| 8 | select HID | ||
| 9 | ---help--- | ||
| 10 | Say Y here if you use a keyboard, a touchpad, a touchscreen, or any | ||
| 11 | other HID based devices which is connected to your computer via I2C. | ||
| 12 | |||
| 13 | If unsure, say N. | ||
| 14 | |||
| 15 | This support is also available as a module. If so, the module | ||
| 16 | will be called i2c-hid. | ||
| 17 | |||
| 18 | endmenu | ||
diff --git a/drivers/hid/i2c-hid/Makefile b/drivers/hid/i2c-hid/Makefile new file mode 100644 index 000000000000..832d8f9aaba2 --- /dev/null +++ b/drivers/hid/i2c-hid/Makefile | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | # | ||
| 2 | # Makefile for the I2C input drivers | ||
| 3 | # | ||
| 4 | |||
| 5 | obj-$(CONFIG_I2C_HID) += i2c-hid.o | ||
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c new file mode 100644 index 000000000000..9ef222442ca0 --- /dev/null +++ b/drivers/hid/i2c-hid/i2c-hid.c | |||
| @@ -0,0 +1,979 @@ | |||
| 1 | /* | ||
| 2 | * HID over I2C protocol implementation | ||
| 3 | * | ||
| 4 | * Copyright (c) 2012 Benjamin Tissoires <benjamin.tissoires@gmail.com> | ||
| 5 | * Copyright (c) 2012 Ecole Nationale de l'Aviation Civile, France | ||
| 6 | * Copyright (c) 2012 Red Hat, Inc | ||
| 7 | * | ||
| 8 | * This code is partly based on "USB HID support for Linux": | ||
| 9 | * | ||
| 10 | * Copyright (c) 1999 Andreas Gal | ||
| 11 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> | ||
| 12 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc | ||
| 13 | * Copyright (c) 2007-2008 Oliver Neukum | ||
| 14 | * Copyright (c) 2006-2010 Jiri Kosina | ||
| 15 | * | ||
| 16 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 17 | * License. See the file COPYING in the main directory of this archive for | ||
| 18 | * more details. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <linux/module.h> | ||
| 22 | #include <linux/i2c.h> | ||
| 23 | #include <linux/interrupt.h> | ||
| 24 | #include <linux/input.h> | ||
| 25 | #include <linux/delay.h> | ||
| 26 | #include <linux/slab.h> | ||
| 27 | #include <linux/pm.h> | ||
| 28 | #include <linux/device.h> | ||
| 29 | #include <linux/wait.h> | ||
| 30 | #include <linux/err.h> | ||
| 31 | #include <linux/string.h> | ||
| 32 | #include <linux/list.h> | ||
| 33 | #include <linux/jiffies.h> | ||
| 34 | #include <linux/kernel.h> | ||
| 35 | #include <linux/hid.h> | ||
| 36 | #include <linux/mutex.h> | ||
| 37 | |||
| 38 | #include <linux/i2c/i2c-hid.h> | ||
| 39 | |||
| 40 | /* flags */ | ||
| 41 | #define I2C_HID_STARTED (1 << 0) | ||
| 42 | #define I2C_HID_RESET_PENDING (1 << 1) | ||
| 43 | #define I2C_HID_READ_PENDING (1 << 2) | ||
| 44 | |||
| 45 | #define I2C_HID_PWR_ON 0x00 | ||
| 46 | #define I2C_HID_PWR_SLEEP 0x01 | ||
| 47 | |||
| 48 | /* debug option */ | ||
| 49 | static bool debug; | ||
| 50 | module_param(debug, bool, 0444); | ||
| 51 | MODULE_PARM_DESC(debug, "print a lot of debug information"); | ||
| 52 | |||
| 53 | #define i2c_hid_dbg(ihid, fmt, arg...) \ | ||
| 54 | do { \ | ||
| 55 | if (debug) \ | ||
| 56 | dev_printk(KERN_DEBUG, &(ihid)->client->dev, fmt, ##arg); \ | ||
| 57 | } while (0) | ||
| 58 | |||
| 59 | struct i2c_hid_desc { | ||
| 60 | __le16 wHIDDescLength; | ||
| 61 | __le16 bcdVersion; | ||
| 62 | __le16 wReportDescLength; | ||
| 63 | __le16 wReportDescRegister; | ||
| 64 | __le16 wInputRegister; | ||
| 65 | __le16 wMaxInputLength; | ||
| 66 | __le16 wOutputRegister; | ||
| 67 | __le16 wMaxOutputLength; | ||
| 68 | __le16 wCommandRegister; | ||
| 69 | __le16 wDataRegister; | ||
| 70 | __le16 wVendorID; | ||
| 71 | __le16 wProductID; | ||
| 72 | __le16 wVersionID; | ||
| 73 | __le32 reserved; | ||
| 74 | } __packed; | ||
| 75 | |||
| 76 | struct i2c_hid_cmd { | ||
| 77 | unsigned int registerIndex; | ||
| 78 | __u8 opcode; | ||
| 79 | unsigned int length; | ||
| 80 | bool wait; | ||
| 81 | }; | ||
| 82 | |||
| 83 | union command { | ||
| 84 | u8 data[0]; | ||
| 85 | struct cmd { | ||
| 86 | __le16 reg; | ||
| 87 | __u8 reportTypeID; | ||
| 88 | __u8 opcode; | ||
| 89 | } __packed c; | ||
| 90 | }; | ||
| 91 | |||
| 92 | #define I2C_HID_CMD(opcode_) \ | ||
| 93 | .opcode = opcode_, .length = 4, \ | ||
| 94 | .registerIndex = offsetof(struct i2c_hid_desc, wCommandRegister) | ||
| 95 | |||
| 96 | /* fetch HID descriptor */ | ||
| 97 | static const struct i2c_hid_cmd hid_descr_cmd = { .length = 2 }; | ||
| 98 | /* fetch report descriptors */ | ||
| 99 | static const struct i2c_hid_cmd hid_report_descr_cmd = { | ||
| 100 | .registerIndex = offsetof(struct i2c_hid_desc, | ||
| 101 | wReportDescRegister), | ||
| 102 | .opcode = 0x00, | ||
| 103 | .length = 2 }; | ||
| 104 | /* commands */ | ||
| 105 | static const struct i2c_hid_cmd hid_reset_cmd = { I2C_HID_CMD(0x01), | ||
| 106 | .wait = true }; | ||
| 107 | static const struct i2c_hid_cmd hid_get_report_cmd = { I2C_HID_CMD(0x02) }; | ||
| 108 | static const struct i2c_hid_cmd hid_set_report_cmd = { I2C_HID_CMD(0x03) }; | ||
| 109 | static const struct i2c_hid_cmd hid_set_power_cmd = { I2C_HID_CMD(0x08) }; | ||
| 110 | |||
| 111 | /* | ||
| 112 | * These definitions are not used here, but are defined by the spec. | ||
| 113 | * Keeping them here for documentation purposes. | ||
| 114 | * | ||
| 115 | * static const struct i2c_hid_cmd hid_get_idle_cmd = { I2C_HID_CMD(0x04) }; | ||
| 116 | * static const struct i2c_hid_cmd hid_set_idle_cmd = { I2C_HID_CMD(0x05) }; | ||
| 117 | * static const struct i2c_hid_cmd hid_get_protocol_cmd = { I2C_HID_CMD(0x06) }; | ||
| 118 | * static const struct i2c_hid_cmd hid_set_protocol_cmd = { I2C_HID_CMD(0x07) }; | ||
| 119 | */ | ||
| 120 | |||
| 121 | static DEFINE_MUTEX(i2c_hid_open_mut); | ||
| 122 | |||
| 123 | /* The main device structure */ | ||
| 124 | struct i2c_hid { | ||
| 125 | struct i2c_client *client; /* i2c client */ | ||
| 126 | struct hid_device *hid; /* pointer to corresponding HID dev */ | ||
| 127 | union { | ||
| 128 | __u8 hdesc_buffer[sizeof(struct i2c_hid_desc)]; | ||
| 129 | struct i2c_hid_desc hdesc; /* the HID Descriptor */ | ||
| 130 | }; | ||
| 131 | __le16 wHIDDescRegister; /* location of the i2c | ||
| 132 | * register of the HID | ||
| 133 | * descriptor. */ | ||
| 134 | unsigned int bufsize; /* i2c buffer size */ | ||
| 135 | char *inbuf; /* Input buffer */ | ||
| 136 | char *cmdbuf; /* Command buffer */ | ||
| 137 | char *argsbuf; /* Command arguments buffer */ | ||
| 138 | |||
| 139 | unsigned long flags; /* device flags */ | ||
| 140 | |||
| 141 | wait_queue_head_t wait; /* For waiting the interrupt */ | ||
| 142 | }; | ||
| 143 | |||
| 144 | static int __i2c_hid_command(struct i2c_client *client, | ||
| 145 | const struct i2c_hid_cmd *command, u8 reportID, | ||
| 146 | u8 reportType, u8 *args, int args_len, | ||
| 147 | unsigned char *buf_recv, int data_len) | ||
| 148 | { | ||
| 149 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 150 | union command *cmd = (union command *)ihid->cmdbuf; | ||
| 151 | int ret; | ||
| 152 | struct i2c_msg msg[2]; | ||
| 153 | int msg_num = 1; | ||
| 154 | |||
| 155 | int length = command->length; | ||
| 156 | bool wait = command->wait; | ||
| 157 | unsigned int registerIndex = command->registerIndex; | ||
| 158 | |||
| 159 | /* special case for hid_descr_cmd */ | ||
| 160 | if (command == &hid_descr_cmd) { | ||
| 161 | cmd->c.reg = ihid->wHIDDescRegister; | ||
| 162 | } else { | ||
| 163 | cmd->data[0] = ihid->hdesc_buffer[registerIndex]; | ||
| 164 | cmd->data[1] = ihid->hdesc_buffer[registerIndex + 1]; | ||
| 165 | } | ||
| 166 | |||
| 167 | if (length > 2) { | ||
| 168 | cmd->c.opcode = command->opcode; | ||
| 169 | cmd->c.reportTypeID = reportID | reportType << 4; | ||
| 170 | } | ||
| 171 | |||
| 172 | memcpy(cmd->data + length, args, args_len); | ||
| 173 | length += args_len; | ||
| 174 | |||
| 175 | i2c_hid_dbg(ihid, "%s: cmd=%*ph\n", __func__, length, cmd->data); | ||
| 176 | |||
| 177 | msg[0].addr = client->addr; | ||
| 178 | msg[0].flags = client->flags & I2C_M_TEN; | ||
| 179 | msg[0].len = length; | ||
| 180 | msg[0].buf = cmd->data; | ||
| 181 | if (data_len > 0) { | ||
| 182 | msg[1].addr = client->addr; | ||
| 183 | msg[1].flags = client->flags & I2C_M_TEN; | ||
| 184 | msg[1].flags |= I2C_M_RD; | ||
| 185 | msg[1].len = data_len; | ||
| 186 | msg[1].buf = buf_recv; | ||
| 187 | msg_num = 2; | ||
| 188 | set_bit(I2C_HID_READ_PENDING, &ihid->flags); | ||
| 189 | } | ||
| 190 | |||
| 191 | if (wait) | ||
| 192 | set_bit(I2C_HID_RESET_PENDING, &ihid->flags); | ||
| 193 | |||
| 194 | ret = i2c_transfer(client->adapter, msg, msg_num); | ||
| 195 | |||
| 196 | if (data_len > 0) | ||
| 197 | clear_bit(I2C_HID_READ_PENDING, &ihid->flags); | ||
| 198 | |||
| 199 | if (ret != msg_num) | ||
| 200 | return ret < 0 ? ret : -EIO; | ||
| 201 | |||
| 202 | ret = 0; | ||
| 203 | |||
| 204 | if (wait) { | ||
| 205 | i2c_hid_dbg(ihid, "%s: waiting...\n", __func__); | ||
| 206 | if (!wait_event_timeout(ihid->wait, | ||
| 207 | !test_bit(I2C_HID_RESET_PENDING, &ihid->flags), | ||
| 208 | msecs_to_jiffies(5000))) | ||
| 209 | ret = -ENODATA; | ||
| 210 | i2c_hid_dbg(ihid, "%s: finished.\n", __func__); | ||
| 211 | } | ||
| 212 | |||
| 213 | return ret; | ||
| 214 | } | ||
| 215 | |||
| 216 | static int i2c_hid_command(struct i2c_client *client, | ||
| 217 | const struct i2c_hid_cmd *command, | ||
| 218 | unsigned char *buf_recv, int data_len) | ||
| 219 | { | ||
| 220 | return __i2c_hid_command(client, command, 0, 0, NULL, 0, | ||
| 221 | buf_recv, data_len); | ||
| 222 | } | ||
| 223 | |||
| 224 | static int i2c_hid_get_report(struct i2c_client *client, u8 reportType, | ||
| 225 | u8 reportID, unsigned char *buf_recv, int data_len) | ||
| 226 | { | ||
| 227 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 228 | u8 args[3]; | ||
| 229 | int ret; | ||
| 230 | int args_len = 0; | ||
| 231 | u16 readRegister = le16_to_cpu(ihid->hdesc.wDataRegister); | ||
| 232 | |||
| 233 | i2c_hid_dbg(ihid, "%s\n", __func__); | ||
| 234 | |||
| 235 | if (reportID >= 0x0F) { | ||
| 236 | args[args_len++] = reportID; | ||
| 237 | reportID = 0x0F; | ||
| 238 | } | ||
| 239 | |||
| 240 | args[args_len++] = readRegister & 0xFF; | ||
| 241 | args[args_len++] = readRegister >> 8; | ||
| 242 | |||
| 243 | ret = __i2c_hid_command(client, &hid_get_report_cmd, reportID, | ||
| 244 | reportType, args, args_len, buf_recv, data_len); | ||
| 245 | if (ret) { | ||
| 246 | dev_err(&client->dev, | ||
| 247 | "failed to retrieve report from device.\n"); | ||
| 248 | return ret; | ||
| 249 | } | ||
| 250 | |||
| 251 | return 0; | ||
| 252 | } | ||
| 253 | |||
| 254 | static int i2c_hid_set_report(struct i2c_client *client, u8 reportType, | ||
| 255 | u8 reportID, unsigned char *buf, size_t data_len) | ||
| 256 | { | ||
| 257 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 258 | u8 *args = ihid->argsbuf; | ||
| 259 | int ret; | ||
| 260 | u16 dataRegister = le16_to_cpu(ihid->hdesc.wDataRegister); | ||
| 261 | |||
| 262 | /* hidraw already checked that data_len < HID_MAX_BUFFER_SIZE */ | ||
| 263 | u16 size = 2 /* size */ + | ||
| 264 | (reportID ? 1 : 0) /* reportID */ + | ||
| 265 | data_len /* buf */; | ||
| 266 | int args_len = (reportID >= 0x0F ? 1 : 0) /* optional third byte */ + | ||
| 267 | 2 /* dataRegister */ + | ||
| 268 | size /* args */; | ||
| 269 | int index = 0; | ||
| 270 | |||
| 271 | i2c_hid_dbg(ihid, "%s\n", __func__); | ||
| 272 | |||
| 273 | if (reportID >= 0x0F) { | ||
| 274 | args[index++] = reportID; | ||
| 275 | reportID = 0x0F; | ||
| 276 | } | ||
| 277 | |||
| 278 | args[index++] = dataRegister & 0xFF; | ||
| 279 | args[index++] = dataRegister >> 8; | ||
| 280 | |||
| 281 | args[index++] = size & 0xFF; | ||
| 282 | args[index++] = size >> 8; | ||
| 283 | |||
| 284 | if (reportID) | ||
| 285 | args[index++] = reportID; | ||
| 286 | |||
| 287 | memcpy(&args[index], buf, data_len); | ||
| 288 | |||
| 289 | ret = __i2c_hid_command(client, &hid_set_report_cmd, reportID, | ||
| 290 | reportType, args, args_len, NULL, 0); | ||
| 291 | if (ret) { | ||
| 292 | dev_err(&client->dev, "failed to set a report to device.\n"); | ||
| 293 | return ret; | ||
| 294 | } | ||
| 295 | |||
| 296 | return data_len; | ||
| 297 | } | ||
| 298 | |||
| 299 | static int i2c_hid_set_power(struct i2c_client *client, int power_state) | ||
| 300 | { | ||
| 301 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 302 | int ret; | ||
| 303 | |||
| 304 | i2c_hid_dbg(ihid, "%s\n", __func__); | ||
| 305 | |||
| 306 | ret = __i2c_hid_command(client, &hid_set_power_cmd, power_state, | ||
| 307 | 0, NULL, 0, NULL, 0); | ||
| 308 | if (ret) | ||
| 309 | dev_err(&client->dev, "failed to change power setting.\n"); | ||
| 310 | |||
| 311 | return ret; | ||
| 312 | } | ||
| 313 | |||
| 314 | static int i2c_hid_hwreset(struct i2c_client *client) | ||
| 315 | { | ||
| 316 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 317 | int ret; | ||
| 318 | |||
| 319 | i2c_hid_dbg(ihid, "%s\n", __func__); | ||
| 320 | |||
| 321 | ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); | ||
| 322 | if (ret) | ||
| 323 | return ret; | ||
| 324 | |||
| 325 | i2c_hid_dbg(ihid, "resetting...\n"); | ||
| 326 | |||
| 327 | ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0); | ||
| 328 | if (ret) { | ||
| 329 | dev_err(&client->dev, "failed to reset device.\n"); | ||
| 330 | i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); | ||
| 331 | return ret; | ||
| 332 | } | ||
| 333 | |||
| 334 | return 0; | ||
| 335 | } | ||
| 336 | |||
| 337 | static void i2c_hid_get_input(struct i2c_hid *ihid) | ||
| 338 | { | ||
| 339 | int ret, ret_size; | ||
| 340 | int size = le16_to_cpu(ihid->hdesc.wMaxInputLength); | ||
| 341 | |||
| 342 | ret = i2c_master_recv(ihid->client, ihid->inbuf, size); | ||
| 343 | if (ret != size) { | ||
| 344 | if (ret < 0) | ||
| 345 | return; | ||
| 346 | |||
| 347 | dev_err(&ihid->client->dev, "%s: got %d data instead of %d\n", | ||
| 348 | __func__, ret, size); | ||
| 349 | return; | ||
| 350 | } | ||
| 351 | |||
| 352 | ret_size = ihid->inbuf[0] | ihid->inbuf[1] << 8; | ||
| 353 | |||
| 354 | if (!ret_size) { | ||
| 355 | /* host or device initiated RESET completed */ | ||
| 356 | if (test_and_clear_bit(I2C_HID_RESET_PENDING, &ihid->flags)) | ||
| 357 | wake_up(&ihid->wait); | ||
| 358 | return; | ||
| 359 | } | ||
| 360 | |||
| 361 | if (ret_size > size) { | ||
| 362 | dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n", | ||
| 363 | __func__, size, ret_size); | ||
| 364 | return; | ||
| 365 | } | ||
| 366 | |||
| 367 | i2c_hid_dbg(ihid, "input: %*ph\n", ret_size, ihid->inbuf); | ||
| 368 | |||
| 369 | if (test_bit(I2C_HID_STARTED, &ihid->flags)) | ||
| 370 | hid_input_report(ihid->hid, HID_INPUT_REPORT, ihid->inbuf + 2, | ||
| 371 | ret_size - 2, 1); | ||
| 372 | |||
| 373 | return; | ||
| 374 | } | ||
| 375 | |||
| 376 | static irqreturn_t i2c_hid_irq(int irq, void *dev_id) | ||
| 377 | { | ||
| 378 | struct i2c_hid *ihid = dev_id; | ||
| 379 | |||
| 380 | if (test_bit(I2C_HID_READ_PENDING, &ihid->flags)) | ||
| 381 | return IRQ_HANDLED; | ||
| 382 | |||
| 383 | i2c_hid_get_input(ihid); | ||
| 384 | |||
| 385 | return IRQ_HANDLED; | ||
| 386 | } | ||
| 387 | |||
| 388 | static int i2c_hid_get_report_length(struct hid_report *report) | ||
| 389 | { | ||
| 390 | return ((report->size - 1) >> 3) + 1 + | ||
| 391 | report->device->report_enum[report->type].numbered + 2; | ||
| 392 | } | ||
| 393 | |||
| 394 | static void i2c_hid_init_report(struct hid_report *report, u8 *buffer, | ||
| 395 | size_t bufsize) | ||
| 396 | { | ||
| 397 | struct hid_device *hid = report->device; | ||
| 398 | struct i2c_client *client = hid->driver_data; | ||
| 399 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 400 | unsigned int size, ret_size; | ||
| 401 | |||
| 402 | size = i2c_hid_get_report_length(report); | ||
| 403 | if (i2c_hid_get_report(client, | ||
| 404 | report->type == HID_FEATURE_REPORT ? 0x03 : 0x01, | ||
| 405 | report->id, buffer, size)) | ||
| 406 | return; | ||
| 407 | |||
| 408 | i2c_hid_dbg(ihid, "report (len=%d): %*ph\n", size, size, ihid->inbuf); | ||
| 409 | |||
| 410 | ret_size = buffer[0] | (buffer[1] << 8); | ||
| 411 | |||
| 412 | if (ret_size != size) { | ||
| 413 | dev_err(&client->dev, "error in %s size:%d / ret_size:%d\n", | ||
| 414 | __func__, size, ret_size); | ||
| 415 | return; | ||
| 416 | } | ||
| 417 | |||
| 418 | /* hid->driver_lock is held as we are in probe function, | ||
| 419 | * we just need to setup the input fields, so using | ||
| 420 | * hid_report_raw_event is safe. */ | ||
| 421 | hid_report_raw_event(hid, report->type, buffer + 2, size - 2, 1); | ||
| 422 | } | ||
| 423 | |||
| 424 | /* | ||
| 425 | * Initialize all reports | ||
| 426 | */ | ||
| 427 | static void i2c_hid_init_reports(struct hid_device *hid) | ||
| 428 | { | ||
| 429 | struct hid_report *report; | ||
| 430 | struct i2c_client *client = hid->driver_data; | ||
| 431 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 432 | u8 *inbuf = kzalloc(ihid->bufsize, GFP_KERNEL); | ||
| 433 | |||
| 434 | if (!inbuf) { | ||
| 435 | dev_err(&client->dev, "can not retrieve initial reports\n"); | ||
| 436 | return; | ||
| 437 | } | ||
| 438 | |||
| 439 | list_for_each_entry(report, | ||
| 440 | &hid->report_enum[HID_INPUT_REPORT].report_list, list) | ||
| 441 | i2c_hid_init_report(report, inbuf, ihid->bufsize); | ||
| 442 | |||
| 443 | list_for_each_entry(report, | ||
| 444 | &hid->report_enum[HID_FEATURE_REPORT].report_list, list) | ||
| 445 | i2c_hid_init_report(report, inbuf, ihid->bufsize); | ||
| 446 | |||
| 447 | kfree(inbuf); | ||
| 448 | } | ||
| 449 | |||
| 450 | /* | ||
| 451 | * Traverse the supplied list of reports and find the longest | ||
| 452 | */ | ||
| 453 | static void i2c_hid_find_max_report(struct hid_device *hid, unsigned int type, | ||
| 454 | unsigned int *max) | ||
| 455 | { | ||
| 456 | struct hid_report *report; | ||
| 457 | unsigned int size; | ||
| 458 | |||
| 459 | /* We should not rely on wMaxInputLength, as some devices may set it to | ||
| 460 | * a wrong length. */ | ||
| 461 | list_for_each_entry(report, &hid->report_enum[type].report_list, list) { | ||
| 462 | size = i2c_hid_get_report_length(report); | ||
| 463 | if (*max < size) | ||
| 464 | *max = size; | ||
| 465 | } | ||
| 466 | } | ||
| 467 | |||
| 468 | static void i2c_hid_free_buffers(struct i2c_hid *ihid) | ||
| 469 | { | ||
| 470 | kfree(ihid->inbuf); | ||
| 471 | kfree(ihid->argsbuf); | ||
| 472 | kfree(ihid->cmdbuf); | ||
| 473 | ihid->inbuf = NULL; | ||
| 474 | ihid->cmdbuf = NULL; | ||
| 475 | ihid->argsbuf = NULL; | ||
| 476 | ihid->bufsize = 0; | ||
| 477 | } | ||
| 478 | |||
| 479 | static int i2c_hid_alloc_buffers(struct i2c_hid *ihid, size_t report_size) | ||
| 480 | { | ||
| 481 | /* the worst case is computed from the set_report command with a | ||
| 482 | * reportID > 15 and the maximum report length */ | ||
| 483 | int args_len = sizeof(__u8) + /* optional ReportID byte */ | ||
| 484 | sizeof(__u16) + /* data register */ | ||
| 485 | sizeof(__u16) + /* size of the report */ | ||
| 486 | report_size; /* report */ | ||
| 487 | |||
| 488 | ihid->inbuf = kzalloc(report_size, GFP_KERNEL); | ||
| 489 | ihid->argsbuf = kzalloc(args_len, GFP_KERNEL); | ||
| 490 | ihid->cmdbuf = kzalloc(sizeof(union command) + args_len, GFP_KERNEL); | ||
| 491 | |||
| 492 | if (!ihid->inbuf || !ihid->argsbuf || !ihid->cmdbuf) { | ||
| 493 | i2c_hid_free_buffers(ihid); | ||
| 494 | return -ENOMEM; | ||
| 495 | } | ||
| 496 | |||
| 497 | ihid->bufsize = report_size; | ||
| 498 | |||
| 499 | return 0; | ||
| 500 | } | ||
| 501 | |||
| 502 | static int i2c_hid_get_raw_report(struct hid_device *hid, | ||
| 503 | unsigned char report_number, __u8 *buf, size_t count, | ||
| 504 | unsigned char report_type) | ||
| 505 | { | ||
| 506 | struct i2c_client *client = hid->driver_data; | ||
| 507 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 508 | size_t ret_count, ask_count; | ||
| 509 | int ret; | ||
| 510 | |||
| 511 | if (report_type == HID_OUTPUT_REPORT) | ||
| 512 | return -EINVAL; | ||
| 513 | |||
| 514 | /* +2 bytes to include the size of the reply in the query buffer */ | ||
| 515 | ask_count = min(count + 2, (size_t)ihid->bufsize); | ||
| 516 | |||
| 517 | ret = i2c_hid_get_report(client, | ||
| 518 | report_type == HID_FEATURE_REPORT ? 0x03 : 0x01, | ||
| 519 | report_number, ihid->inbuf, ask_count); | ||
| 520 | |||
| 521 | if (ret < 0) | ||
| 522 | return ret; | ||
| 523 | |||
| 524 | ret_count = ihid->inbuf[0] | (ihid->inbuf[1] << 8); | ||
| 525 | |||
| 526 | if (ret_count <= 2) | ||
| 527 | return 0; | ||
| 528 | |||
| 529 | ret_count = min(ret_count, ask_count); | ||
| 530 | |||
| 531 | /* The query buffer contains the size, dropping it in the reply */ | ||
| 532 | count = min(count, ret_count - 2); | ||
| 533 | memcpy(buf, ihid->inbuf + 2, count); | ||
| 534 | |||
| 535 | return count; | ||
| 536 | } | ||
| 537 | |||
| 538 | static int i2c_hid_output_raw_report(struct hid_device *hid, __u8 *buf, | ||
| 539 | size_t count, unsigned char report_type) | ||
| 540 | { | ||
| 541 | struct i2c_client *client = hid->driver_data; | ||
| 542 | int report_id = buf[0]; | ||
| 543 | |||
| 544 | if (report_type == HID_INPUT_REPORT) | ||
| 545 | return -EINVAL; | ||
| 546 | |||
| 547 | return i2c_hid_set_report(client, | ||
| 548 | report_type == HID_FEATURE_REPORT ? 0x03 : 0x02, | ||
| 549 | report_id, buf, count); | ||
| 550 | } | ||
| 551 | |||
| 552 | static int i2c_hid_parse(struct hid_device *hid) | ||
| 553 | { | ||
| 554 | struct i2c_client *client = hid->driver_data; | ||
| 555 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 556 | struct i2c_hid_desc *hdesc = &ihid->hdesc; | ||
| 557 | unsigned int rsize; | ||
| 558 | char *rdesc; | ||
| 559 | int ret; | ||
| 560 | int tries = 3; | ||
| 561 | |||
| 562 | i2c_hid_dbg(ihid, "entering %s\n", __func__); | ||
| 563 | |||
| 564 | rsize = le16_to_cpu(hdesc->wReportDescLength); | ||
| 565 | if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) { | ||
| 566 | dbg_hid("weird size of report descriptor (%u)\n", rsize); | ||
| 567 | return -EINVAL; | ||
| 568 | } | ||
| 569 | |||
| 570 | do { | ||
| 571 | ret = i2c_hid_hwreset(client); | ||
| 572 | if (ret) | ||
| 573 | msleep(1000); | ||
| 574 | } while (tries-- > 0 && ret); | ||
| 575 | |||
| 576 | if (ret) | ||
| 577 | return ret; | ||
| 578 | |||
| 579 | rdesc = kzalloc(rsize, GFP_KERNEL); | ||
| 580 | |||
| 581 | if (!rdesc) { | ||
| 582 | dbg_hid("couldn't allocate rdesc memory\n"); | ||
| 583 | return -ENOMEM; | ||
| 584 | } | ||
| 585 | |||
| 586 | i2c_hid_dbg(ihid, "asking HID report descriptor\n"); | ||
| 587 | |||
| 588 | ret = i2c_hid_command(client, &hid_report_descr_cmd, rdesc, rsize); | ||
| 589 | if (ret) { | ||
| 590 | hid_err(hid, "reading report descriptor failed\n"); | ||
| 591 | kfree(rdesc); | ||
| 592 | return -EIO; | ||
| 593 | } | ||
| 594 | |||
| 595 | i2c_hid_dbg(ihid, "Report Descriptor: %*ph\n", rsize, rdesc); | ||
| 596 | |||
| 597 | ret = hid_parse_report(hid, rdesc, rsize); | ||
| 598 | kfree(rdesc); | ||
| 599 | if (ret) { | ||
| 600 | dbg_hid("parsing report descriptor failed\n"); | ||
| 601 | return ret; | ||
| 602 | } | ||
| 603 | |||
| 604 | return 0; | ||
| 605 | } | ||
| 606 | |||
| 607 | static int i2c_hid_start(struct hid_device *hid) | ||
| 608 | { | ||
| 609 | struct i2c_client *client = hid->driver_data; | ||
| 610 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 611 | int ret; | ||
| 612 | unsigned int bufsize = HID_MIN_BUFFER_SIZE; | ||
| 613 | |||
| 614 | i2c_hid_find_max_report(hid, HID_INPUT_REPORT, &bufsize); | ||
| 615 | i2c_hid_find_max_report(hid, HID_OUTPUT_REPORT, &bufsize); | ||
| 616 | i2c_hid_find_max_report(hid, HID_FEATURE_REPORT, &bufsize); | ||
| 617 | |||
| 618 | if (bufsize > ihid->bufsize) { | ||
| 619 | i2c_hid_free_buffers(ihid); | ||
| 620 | |||
| 621 | ret = i2c_hid_alloc_buffers(ihid, bufsize); | ||
| 622 | |||
| 623 | if (ret) | ||
| 624 | return ret; | ||
| 625 | } | ||
| 626 | |||
| 627 | if (!(hid->quirks & HID_QUIRK_NO_INIT_REPORTS)) | ||
| 628 | i2c_hid_init_reports(hid); | ||
| 629 | |||
| 630 | return 0; | ||
| 631 | } | ||
| 632 | |||
| 633 | static void i2c_hid_stop(struct hid_device *hid) | ||
| 634 | { | ||
| 635 | struct i2c_client *client = hid->driver_data; | ||
| 636 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 637 | |||
| 638 | hid->claimed = 0; | ||
| 639 | |||
| 640 | i2c_hid_free_buffers(ihid); | ||
| 641 | } | ||
| 642 | |||
| 643 | static int i2c_hid_open(struct hid_device *hid) | ||
| 644 | { | ||
| 645 | struct i2c_client *client = hid->driver_data; | ||
| 646 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 647 | int ret = 0; | ||
| 648 | |||
| 649 | mutex_lock(&i2c_hid_open_mut); | ||
| 650 | if (!hid->open++) { | ||
| 651 | ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); | ||
| 652 | if (ret) { | ||
| 653 | hid->open--; | ||
| 654 | goto done; | ||
| 655 | } | ||
| 656 | set_bit(I2C_HID_STARTED, &ihid->flags); | ||
| 657 | } | ||
| 658 | done: | ||
| 659 | mutex_unlock(&i2c_hid_open_mut); | ||
| 660 | return ret; | ||
| 661 | } | ||
| 662 | |||
| 663 | static void i2c_hid_close(struct hid_device *hid) | ||
| 664 | { | ||
| 665 | struct i2c_client *client = hid->driver_data; | ||
| 666 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 667 | |||
| 668 | /* protecting hid->open to make sure we don't restart | ||
| 669 | * data acquistion due to a resumption we no longer | ||
| 670 | * care about | ||
| 671 | */ | ||
| 672 | mutex_lock(&i2c_hid_open_mut); | ||
| 673 | if (!--hid->open) { | ||
| 674 | clear_bit(I2C_HID_STARTED, &ihid->flags); | ||
| 675 | |||
| 676 | /* Save some power */ | ||
| 677 | i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); | ||
| 678 | } | ||
| 679 | mutex_unlock(&i2c_hid_open_mut); | ||
| 680 | } | ||
| 681 | |||
| 682 | static int i2c_hid_power(struct hid_device *hid, int lvl) | ||
| 683 | { | ||
| 684 | struct i2c_client *client = hid->driver_data; | ||
| 685 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 686 | int ret = 0; | ||
| 687 | |||
| 688 | i2c_hid_dbg(ihid, "%s lvl:%d\n", __func__, lvl); | ||
| 689 | |||
| 690 | switch (lvl) { | ||
| 691 | case PM_HINT_FULLON: | ||
| 692 | ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); | ||
| 693 | break; | ||
| 694 | case PM_HINT_NORMAL: | ||
| 695 | ret = i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); | ||
| 696 | break; | ||
| 697 | } | ||
| 698 | return ret; | ||
| 699 | } | ||
| 700 | |||
| 701 | static int i2c_hid_hidinput_input_event(struct input_dev *dev, | ||
| 702 | unsigned int type, unsigned int code, int value) | ||
| 703 | { | ||
| 704 | struct hid_device *hid = input_get_drvdata(dev); | ||
| 705 | struct hid_field *field; | ||
| 706 | int offset; | ||
| 707 | |||
| 708 | if (type == EV_FF) | ||
| 709 | return input_ff_event(dev, type, code, value); | ||
| 710 | |||
| 711 | if (type != EV_LED) | ||
| 712 | return -1; | ||
| 713 | |||
| 714 | offset = hidinput_find_field(hid, type, code, &field); | ||
| 715 | |||
| 716 | if (offset == -1) { | ||
| 717 | hid_warn(dev, "event field not found\n"); | ||
| 718 | return -1; | ||
| 719 | } | ||
| 720 | |||
| 721 | return hid_set_field(field, offset, value); | ||
| 722 | } | ||
| 723 | |||
| 724 | static struct hid_ll_driver i2c_hid_ll_driver = { | ||
| 725 | .parse = i2c_hid_parse, | ||
| 726 | .start = i2c_hid_start, | ||
| 727 | .stop = i2c_hid_stop, | ||
| 728 | .open = i2c_hid_open, | ||
| 729 | .close = i2c_hid_close, | ||
| 730 | .power = i2c_hid_power, | ||
| 731 | .hidinput_input_event = i2c_hid_hidinput_input_event, | ||
| 732 | }; | ||
| 733 | |||
| 734 | static int __devinit i2c_hid_init_irq(struct i2c_client *client) | ||
| 735 | { | ||
| 736 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 737 | int ret; | ||
| 738 | |||
| 739 | dev_dbg(&client->dev, "Requesting IRQ: %d\n", client->irq); | ||
| 740 | |||
| 741 | ret = request_threaded_irq(client->irq, NULL, i2c_hid_irq, | ||
| 742 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | ||
| 743 | client->name, ihid); | ||
| 744 | if (ret < 0) { | ||
| 745 | dev_warn(&client->dev, | ||
| 746 | "Could not register for %s interrupt, irq = %d," | ||
| 747 | " ret = %d\n", | ||
| 748 | client->name, client->irq, ret); | ||
| 749 | |||
| 750 | return ret; | ||
| 751 | } | ||
| 752 | |||
| 753 | return 0; | ||
| 754 | } | ||
| 755 | |||
| 756 | static int __devinit i2c_hid_fetch_hid_descriptor(struct i2c_hid *ihid) | ||
| 757 | { | ||
| 758 | struct i2c_client *client = ihid->client; | ||
| 759 | struct i2c_hid_desc *hdesc = &ihid->hdesc; | ||
| 760 | unsigned int dsize; | ||
| 761 | int ret; | ||
| 762 | |||
| 763 | /* Fetch the length of HID description, retrieve the 4 first bytes: | ||
| 764 | * bytes 0-1 -> length | ||
| 765 | * bytes 2-3 -> bcdVersion (has to be 1.00) */ | ||
| 766 | ret = i2c_hid_command(client, &hid_descr_cmd, ihid->hdesc_buffer, 4); | ||
| 767 | |||
| 768 | i2c_hid_dbg(ihid, "%s, ihid->hdesc_buffer: %*ph\n", | ||
| 769 | __func__, 4, ihid->hdesc_buffer); | ||
| 770 | |||
| 771 | if (ret) { | ||
| 772 | dev_err(&client->dev, | ||
| 773 | "unable to fetch the size of HID descriptor (ret=%d)\n", | ||
| 774 | ret); | ||
| 775 | return -ENODEV; | ||
| 776 | } | ||
| 777 | |||
| 778 | dsize = le16_to_cpu(hdesc->wHIDDescLength); | ||
| 779 | /* | ||
| 780 | * the size of the HID descriptor should at least contain | ||
| 781 | * its size and the bcdVersion (4 bytes), and should not be greater | ||
| 782 | * than sizeof(struct i2c_hid_desc) as we directly fill this struct | ||
| 783 | * through i2c_hid_command. | ||
| 784 | */ | ||
| 785 | if (dsize < 4 || dsize > sizeof(struct i2c_hid_desc)) { | ||
| 786 | dev_err(&client->dev, "weird size of HID descriptor (%u)\n", | ||
| 787 | dsize); | ||
| 788 | return -ENODEV; | ||
| 789 | } | ||
| 790 | |||
| 791 | /* check bcdVersion == 1.0 */ | ||
| 792 | if (le16_to_cpu(hdesc->bcdVersion) != 0x0100) { | ||
| 793 | dev_err(&client->dev, | ||
| 794 | "unexpected HID descriptor bcdVersion (0x%04hx)\n", | ||
| 795 | le16_to_cpu(hdesc->bcdVersion)); | ||
| 796 | return -ENODEV; | ||
| 797 | } | ||
| 798 | |||
| 799 | i2c_hid_dbg(ihid, "Fetching the HID descriptor\n"); | ||
| 800 | |||
| 801 | ret = i2c_hid_command(client, &hid_descr_cmd, ihid->hdesc_buffer, | ||
| 802 | dsize); | ||
| 803 | if (ret) { | ||
| 804 | dev_err(&client->dev, "hid_descr_cmd Fail\n"); | ||
| 805 | return -ENODEV; | ||
| 806 | } | ||
| 807 | |||
| 808 | i2c_hid_dbg(ihid, "HID Descriptor: %*ph\n", dsize, ihid->hdesc_buffer); | ||
| 809 | |||
| 810 | return 0; | ||
| 811 | } | ||
| 812 | |||
| 813 | static int __devinit i2c_hid_probe(struct i2c_client *client, | ||
| 814 | const struct i2c_device_id *dev_id) | ||
| 815 | { | ||
| 816 | int ret; | ||
| 817 | struct i2c_hid *ihid; | ||
| 818 | struct hid_device *hid; | ||
| 819 | __u16 hidRegister; | ||
| 820 | struct i2c_hid_platform_data *platform_data = client->dev.platform_data; | ||
| 821 | |||
| 822 | dbg_hid("HID probe called for i2c 0x%02x\n", client->addr); | ||
| 823 | |||
| 824 | if (!platform_data) { | ||
| 825 | dev_err(&client->dev, "HID register address not provided\n"); | ||
| 826 | return -EINVAL; | ||
| 827 | } | ||
| 828 | |||
| 829 | if (!client->irq) { | ||
| 830 | dev_err(&client->dev, | ||
| 831 | "HID over i2c has not been provided an Int IRQ\n"); | ||
| 832 | return -EINVAL; | ||
| 833 | } | ||
| 834 | |||
| 835 | ihid = kzalloc(sizeof(struct i2c_hid), GFP_KERNEL); | ||
| 836 | if (!ihid) | ||
| 837 | return -ENOMEM; | ||
| 838 | |||
| 839 | i2c_set_clientdata(client, ihid); | ||
| 840 | |||
| 841 | ihid->client = client; | ||
| 842 | |||
| 843 | hidRegister = platform_data->hid_descriptor_address; | ||
| 844 | ihid->wHIDDescRegister = cpu_to_le16(hidRegister); | ||
| 845 | |||
| 846 | init_waitqueue_head(&ihid->wait); | ||
| 847 | |||
| 848 | /* we need to allocate the command buffer without knowing the maximum | ||
| 849 | * size of the reports. Let's use HID_MIN_BUFFER_SIZE, then we do the | ||
| 850 | * real computation later. */ | ||
| 851 | ret = i2c_hid_alloc_buffers(ihid, HID_MIN_BUFFER_SIZE); | ||
| 852 | if (ret < 0) | ||
| 853 | goto err; | ||
| 854 | |||
| 855 | ret = i2c_hid_fetch_hid_descriptor(ihid); | ||
| 856 | if (ret < 0) | ||
| 857 | goto err; | ||
| 858 | |||
| 859 | ret = i2c_hid_init_irq(client); | ||
| 860 | if (ret < 0) | ||
| 861 | goto err; | ||
| 862 | |||
| 863 | hid = hid_allocate_device(); | ||
| 864 | if (IS_ERR(hid)) { | ||
| 865 | ret = PTR_ERR(hid); | ||
| 866 | goto err_irq; | ||
| 867 | } | ||
| 868 | |||
| 869 | ihid->hid = hid; | ||
| 870 | |||
| 871 | hid->driver_data = client; | ||
| 872 | hid->ll_driver = &i2c_hid_ll_driver; | ||
| 873 | hid->hid_get_raw_report = i2c_hid_get_raw_report; | ||
| 874 | hid->hid_output_raw_report = i2c_hid_output_raw_report; | ||
| 875 | hid->dev.parent = &client->dev; | ||
| 876 | hid->bus = BUS_I2C; | ||
| 877 | hid->version = le16_to_cpu(ihid->hdesc.bcdVersion); | ||
| 878 | hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID); | ||
| 879 | hid->product = le16_to_cpu(ihid->hdesc.wProductID); | ||
| 880 | |||
| 881 | snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX", | ||
| 882 | client->name, hid->vendor, hid->product); | ||
| 883 | |||
| 884 | ret = hid_add_device(hid); | ||
| 885 | if (ret) { | ||
| 886 | if (ret != -ENODEV) | ||
| 887 | hid_err(client, "can't add hid device: %d\n", ret); | ||
| 888 | goto err_mem_free; | ||
| 889 | } | ||
| 890 | |||
| 891 | return 0; | ||
| 892 | |||
| 893 | err_mem_free: | ||
| 894 | hid_destroy_device(hid); | ||
| 895 | |||
| 896 | err_irq: | ||
| 897 | free_irq(client->irq, ihid); | ||
| 898 | |||
| 899 | err: | ||
| 900 | i2c_hid_free_buffers(ihid); | ||
| 901 | kfree(ihid); | ||
| 902 | return ret; | ||
| 903 | } | ||
| 904 | |||
| 905 | static int __devexit i2c_hid_remove(struct i2c_client *client) | ||
| 906 | { | ||
| 907 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 908 | struct hid_device *hid; | ||
| 909 | |||
| 910 | hid = ihid->hid; | ||
| 911 | hid_destroy_device(hid); | ||
| 912 | |||
| 913 | free_irq(client->irq, ihid); | ||
| 914 | |||
| 915 | if (ihid->bufsize) | ||
| 916 | i2c_hid_free_buffers(ihid); | ||
| 917 | |||
| 918 | kfree(ihid); | ||
| 919 | |||
| 920 | return 0; | ||
| 921 | } | ||
| 922 | |||
| 923 | #ifdef CONFIG_PM_SLEEP | ||
| 924 | static int i2c_hid_suspend(struct device *dev) | ||
| 925 | { | ||
| 926 | struct i2c_client *client = to_i2c_client(dev); | ||
| 927 | |||
| 928 | if (device_may_wakeup(&client->dev)) | ||
| 929 | enable_irq_wake(client->irq); | ||
| 930 | |||
| 931 | /* Save some power */ | ||
| 932 | i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); | ||
| 933 | |||
| 934 | return 0; | ||
| 935 | } | ||
| 936 | |||
| 937 | static int i2c_hid_resume(struct device *dev) | ||
| 938 | { | ||
| 939 | int ret; | ||
| 940 | struct i2c_client *client = to_i2c_client(dev); | ||
| 941 | |||
| 942 | ret = i2c_hid_hwreset(client); | ||
| 943 | if (ret) | ||
| 944 | return ret; | ||
| 945 | |||
| 946 | if (device_may_wakeup(&client->dev)) | ||
| 947 | disable_irq_wake(client->irq); | ||
| 948 | |||
| 949 | return 0; | ||
| 950 | } | ||
| 951 | #endif | ||
| 952 | |||
| 953 | static SIMPLE_DEV_PM_OPS(i2c_hid_pm, i2c_hid_suspend, i2c_hid_resume); | ||
| 954 | |||
| 955 | static const struct i2c_device_id i2c_hid_id_table[] = { | ||
| 956 | { "hid", 0 }, | ||
| 957 | { }, | ||
| 958 | }; | ||
| 959 | MODULE_DEVICE_TABLE(i2c, i2c_hid_id_table); | ||
| 960 | |||
| 961 | |||
| 962 | static struct i2c_driver i2c_hid_driver = { | ||
| 963 | .driver = { | ||
| 964 | .name = "i2c_hid", | ||
| 965 | .owner = THIS_MODULE, | ||
| 966 | .pm = &i2c_hid_pm, | ||
| 967 | }, | ||
| 968 | |||
| 969 | .probe = i2c_hid_probe, | ||
| 970 | .remove = __devexit_p(i2c_hid_remove), | ||
| 971 | |||
| 972 | .id_table = i2c_hid_id_table, | ||
| 973 | }; | ||
| 974 | |||
| 975 | module_i2c_driver(i2c_hid_driver); | ||
| 976 | |||
| 977 | MODULE_DESCRIPTION("HID over I2C core driver"); | ||
| 978 | MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>"); | ||
| 979 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 11c7932dc7e6..ac9e35228254 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
| @@ -72,6 +72,7 @@ static const struct hid_blacklist { | |||
| 72 | { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, | 72 | { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, |
| 73 | { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, | 73 | { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, |
| 74 | { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, | 74 | { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, |
| 75 | { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS }, | ||
| 75 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS }, | 76 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS }, |
| 76 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS }, | 77 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS }, |
| 77 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, HID_QUIRK_NO_INIT_REPORTS }, | 78 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, HID_QUIRK_NO_INIT_REPORTS }, |
| @@ -79,9 +80,11 @@ static const struct hid_blacklist { | |||
| 79 | { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001, HID_QUIRK_NOGET }, | 80 | { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001, HID_QUIRK_NOGET }, |
| 80 | { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008, HID_QUIRK_NOGET }, | 81 | { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008, HID_QUIRK_NOGET }, |
| 81 | { USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB, HID_QUIRK_NOGET }, | 82 | { USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB, HID_QUIRK_NOGET }, |
| 83 | { USB_VENDOR_ID_SIGMATEL, USB_DEVICE_ID_SIGMATEL_STMP3780, HID_QUIRK_NOGET }, | ||
| 82 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, | 84 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, |
| 83 | { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_1, HID_QUIRK_NOGET }, | 85 | { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_1, HID_QUIRK_NOGET }, |
| 84 | { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_2, HID_QUIRK_NOGET }, | 86 | { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_2, HID_QUIRK_NOGET }, |
| 87 | { USB_VENDOR_ID_TPV, USB_DEVICE_ID_TPV_OPTICAL_TOUCHSCREEN, HID_QUIRK_NOGET }, | ||
| 85 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, | 88 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, |
| 86 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT }, | 89 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT }, |
| 87 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U, HID_QUIRK_MULTI_INPUT }, | 90 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U, HID_QUIRK_MULTI_INPUT }, |
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index 14599e256791..87bd64959a91 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c | |||
| @@ -361,10 +361,6 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun | |||
| 361 | prepare_to_wait(&list->hiddev->wait, &wait, TASK_INTERRUPTIBLE); | 361 | prepare_to_wait(&list->hiddev->wait, &wait, TASK_INTERRUPTIBLE); |
| 362 | 362 | ||
| 363 | while (list->head == list->tail) { | 363 | while (list->head == list->tail) { |
| 364 | if (file->f_flags & O_NONBLOCK) { | ||
| 365 | retval = -EAGAIN; | ||
| 366 | break; | ||
| 367 | } | ||
| 368 | if (signal_pending(current)) { | 364 | if (signal_pending(current)) { |
| 369 | retval = -ERESTARTSYS; | 365 | retval = -ERESTARTSYS; |
| 370 | break; | 366 | break; |
| @@ -373,6 +369,10 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun | |||
| 373 | retval = -EIO; | 369 | retval = -EIO; |
| 374 | break; | 370 | break; |
| 375 | } | 371 | } |
| 372 | if (file->f_flags & O_NONBLOCK) { | ||
| 373 | retval = -EAGAIN; | ||
| 374 | break; | ||
| 375 | } | ||
| 376 | 376 | ||
| 377 | /* let O_NONBLOCK tasks run */ | 377 | /* let O_NONBLOCK tasks run */ |
| 378 | mutex_unlock(&list->thread_lock); | 378 | mutex_unlock(&list->thread_lock); |
| @@ -625,7 +625,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 625 | break; | 625 | break; |
| 626 | 626 | ||
| 627 | case HIDIOCAPPLICATION: | 627 | case HIDIOCAPPLICATION: |
| 628 | if (arg < 0 || arg >= hid->maxapplication) | 628 | if (arg >= hid->maxapplication) |
| 629 | break; | 629 | break; |
| 630 | 630 | ||
| 631 | for (i = 0; i < hid->maxcollection; i++) | 631 | for (i = 0; i < hid->maxcollection; i++) |
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index 1abbc170d8b7..8c4b50fd9a79 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c | |||
| @@ -251,7 +251,7 @@ void input_mt_sync_frame(struct input_dev *dev) | |||
| 251 | 251 | ||
| 252 | if (mt->flags & INPUT_MT_DROP_UNUSED) { | 252 | if (mt->flags & INPUT_MT_DROP_UNUSED) { |
| 253 | for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { | 253 | for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { |
| 254 | if (s->frame == mt->frame) | 254 | if (input_mt_is_used(mt, s)) |
| 255 | continue; | 255 | continue; |
| 256 | input_mt_slot(dev, s - mt->slots); | 256 | input_mt_slot(dev, s - mt->slots); |
| 257 | input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); | 257 | input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); |
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index ca8d7e94eb3c..55f277372fed 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | #ifndef _HID_SENSORS_IDS_H | 19 | #ifndef _HID_SENSORS_IDS_H |
| 20 | #define _HID_SENSORS_IDS_H | 20 | #define _HID_SENSORS_IDS_H |
| 21 | 21 | ||
| 22 | #define HID_UP_SENSOR 0x00200000 | ||
| 23 | #define HID_MAX_PHY_DEVICES 0xFF | 22 | #define HID_MAX_PHY_DEVICES 0xFF |
| 24 | 23 | ||
| 25 | /* Accel 3D (200073) */ | 24 | /* Accel 3D (200073) */ |
diff --git a/include/linux/hid.h b/include/linux/hid.h index c076041a069e..7330a0fef0c0 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h | |||
| @@ -167,6 +167,7 @@ struct hid_item { | |||
| 167 | #define HID_UP_MSVENDOR 0xff000000 | 167 | #define HID_UP_MSVENDOR 0xff000000 |
| 168 | #define HID_UP_CUSTOM 0x00ff0000 | 168 | #define HID_UP_CUSTOM 0x00ff0000 |
| 169 | #define HID_UP_LOGIVENDOR 0xffbc0000 | 169 | #define HID_UP_LOGIVENDOR 0xffbc0000 |
| 170 | #define HID_UP_SENSOR 0x00200000 | ||
| 170 | 171 | ||
| 171 | #define HID_USAGE 0x0000ffff | 172 | #define HID_USAGE 0x0000ffff |
| 172 | 173 | ||
| @@ -292,6 +293,7 @@ struct hid_item { | |||
| 292 | */ | 293 | */ |
| 293 | #define HID_GROUP_GENERIC 0x0001 | 294 | #define HID_GROUP_GENERIC 0x0001 |
| 294 | #define HID_GROUP_MULTITOUCH 0x0002 | 295 | #define HID_GROUP_MULTITOUCH 0x0002 |
| 296 | #define HID_GROUP_SENSOR_HUB 0x0003 | ||
| 295 | 297 | ||
| 296 | /* | 298 | /* |
| 297 | * This is the global environment of the parser. This information is | 299 | * This is the global environment of the parser. This information is |
| @@ -342,6 +344,7 @@ struct hid_collection { | |||
| 342 | struct hid_usage { | 344 | struct hid_usage { |
| 343 | unsigned hid; /* hid usage code */ | 345 | unsigned hid; /* hid usage code */ |
| 344 | unsigned collection_index; /* index into collection array */ | 346 | unsigned collection_index; /* index into collection array */ |
| 347 | unsigned usage_index; /* index into usage array */ | ||
| 345 | /* hidinput data */ | 348 | /* hidinput data */ |
| 346 | __u16 code; /* input driver code */ | 349 | __u16 code; /* input driver code */ |
| 347 | __u8 type; /* input driver type */ | 350 | __u8 type; /* input driver type */ |
| @@ -684,6 +687,7 @@ struct hid_ll_driver { | |||
| 684 | 687 | ||
| 685 | extern int hid_debug; | 688 | extern int hid_debug; |
| 686 | 689 | ||
| 690 | extern bool hid_ignore(struct hid_device *); | ||
| 687 | extern int hid_add_device(struct hid_device *); | 691 | extern int hid_add_device(struct hid_device *); |
| 688 | extern void hid_destroy_device(struct hid_device *); | 692 | extern void hid_destroy_device(struct hid_device *); |
| 689 | 693 | ||
| @@ -706,6 +710,7 @@ int hid_input_report(struct hid_device *, int type, u8 *, int, int); | |||
| 706 | int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); | 710 | int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); |
| 707 | struct hid_field *hidinput_get_led_field(struct hid_device *hid); | 711 | struct hid_field *hidinput_get_led_field(struct hid_device *hid); |
| 708 | unsigned int hidinput_count_leds(struct hid_device *hid); | 712 | unsigned int hidinput_count_leds(struct hid_device *hid); |
| 713 | __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code); | ||
| 709 | void hid_output_report(struct hid_report *report, __u8 *data); | 714 | void hid_output_report(struct hid_report *report, __u8 *data); |
| 710 | struct hid_device *hid_allocate_device(void); | 715 | struct hid_device *hid_allocate_device(void); |
| 711 | struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id); | 716 | struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id); |
| @@ -716,6 +721,7 @@ int hid_connect(struct hid_device *hid, unsigned int connect_mask); | |||
| 716 | void hid_disconnect(struct hid_device *hid); | 721 | void hid_disconnect(struct hid_device *hid); |
| 717 | const struct hid_device_id *hid_match_id(struct hid_device *hdev, | 722 | const struct hid_device_id *hid_match_id(struct hid_device *hdev, |
| 718 | const struct hid_device_id *id); | 723 | const struct hid_device_id *id); |
| 724 | s32 hid_snto32(__u32 value, unsigned n); | ||
| 719 | 725 | ||
| 720 | /** | 726 | /** |
| 721 | * hid_map_usage - map usage input bits | 727 | * hid_map_usage - map usage input bits |
diff --git a/include/linux/i2c/i2c-hid.h b/include/linux/i2c/i2c-hid.h new file mode 100644 index 000000000000..60e411d764d4 --- /dev/null +++ b/include/linux/i2c/i2c-hid.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | /* | ||
| 2 | * HID over I2C protocol implementation | ||
| 3 | * | ||
| 4 | * Copyright (c) 2012 Benjamin Tissoires <benjamin.tissoires@gmail.com> | ||
| 5 | * Copyright (c) 2012 Ecole Nationale de l'Aviation Civile, France | ||
| 6 | * | ||
| 7 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 8 | * License. See the file COPYING in the main directory of this archive for | ||
| 9 | * more details. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef __LINUX_I2C_HID_H | ||
| 13 | #define __LINUX_I2C_HID_H | ||
| 14 | |||
| 15 | #include <linux/types.h> | ||
| 16 | |||
| 17 | /** | ||
| 18 | * struct i2chid_platform_data - used by hid over i2c implementation. | ||
| 19 | * @hid_descriptor_address: i2c register where the HID descriptor is stored. | ||
| 20 | * | ||
| 21 | * Note that it is the responsibility of the platform driver (or the acpi 5.0 | ||
| 22 | * driver) to setup the irq related to the gpio in the struct i2c_board_info. | ||
| 23 | * The platform driver should also setup the gpio according to the device: | ||
| 24 | * | ||
| 25 | * A typical example is the following: | ||
| 26 | * irq = gpio_to_irq(intr_gpio); | ||
| 27 | * hkdk4412_i2c_devs5[0].irq = irq; // store the irq in i2c_board_info | ||
| 28 | * gpio_request(intr_gpio, "elan-irq"); | ||
| 29 | * s3c_gpio_setpull(intr_gpio, S3C_GPIO_PULL_UP); | ||
| 30 | */ | ||
| 31 | struct i2c_hid_platform_data { | ||
| 32 | u16 hid_descriptor_address; | ||
| 33 | }; | ||
| 34 | |||
| 35 | #endif /* __LINUX_I2C_HID_H */ | ||
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h index cc5cca774bab..2e86bd0bfba1 100644 --- a/include/linux/input/mt.h +++ b/include/linux/input/mt.h | |||
| @@ -69,6 +69,12 @@ static inline bool input_mt_is_active(const struct input_mt_slot *slot) | |||
| 69 | return input_mt_get_value(slot, ABS_MT_TRACKING_ID) >= 0; | 69 | return input_mt_get_value(slot, ABS_MT_TRACKING_ID) >= 0; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | static inline bool input_mt_is_used(const struct input_mt *mt, | ||
| 73 | const struct input_mt_slot *slot) | ||
| 74 | { | ||
| 75 | return slot->frame == mt->frame; | ||
| 76 | } | ||
| 77 | |||
| 72 | int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, | 78 | int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, |
| 73 | unsigned int flags); | 79 | unsigned int flags); |
| 74 | void input_mt_destroy_slots(struct input_dev *dev); | 80 | void input_mt_destroy_slots(struct input_dev *dev); |
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index 558828590a69..935119c698ac 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h | |||
| @@ -851,6 +851,7 @@ struct input_keymap_entry { | |||
| 851 | #define MSC_GESTURE 0x02 | 851 | #define MSC_GESTURE 0x02 |
| 852 | #define MSC_RAW 0x03 | 852 | #define MSC_RAW 0x03 |
| 853 | #define MSC_SCAN 0x04 | 853 | #define MSC_SCAN 0x04 |
| 854 | #define MSC_TIMESTAMP 0x05 | ||
| 854 | #define MSC_MAX 0x07 | 855 | #define MSC_MAX 0x07 |
| 855 | #define MSC_CNT (MSC_MAX+1) | 856 | #define MSC_CNT (MSC_MAX+1) |
| 856 | 857 | ||
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 0c0028463fa3..b2bcbe2dc328 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
| @@ -945,6 +945,13 @@ static int hidp_setup_hid(struct hidp_session *session, | |||
| 945 | hid->hid_get_raw_report = hidp_get_raw_report; | 945 | hid->hid_get_raw_report = hidp_get_raw_report; |
| 946 | hid->hid_output_raw_report = hidp_output_raw_report; | 946 | hid->hid_output_raw_report = hidp_output_raw_report; |
| 947 | 947 | ||
| 948 | /* True if device is blacklisted in drivers/hid/hid-core.c */ | ||
| 949 | if (hid_ignore(hid)) { | ||
| 950 | hid_destroy_device(session->hid); | ||
| 951 | session->hid = NULL; | ||
| 952 | return -ENODEV; | ||
| 953 | } | ||
| 954 | |||
| 948 | return 0; | 955 | return 0; |
| 949 | 956 | ||
| 950 | fault: | 957 | fault: |
| @@ -1017,7 +1024,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, | |||
| 1017 | 1024 | ||
| 1018 | if (req->rd_size > 0) { | 1025 | if (req->rd_size > 0) { |
| 1019 | err = hidp_setup_hid(session, req); | 1026 | err = hidp_setup_hid(session, req); |
| 1020 | if (err) | 1027 | if (err && err != -ENODEV) |
| 1021 | goto purge; | 1028 | goto purge; |
| 1022 | } | 1029 | } |
| 1023 | 1030 | ||
