diff options
Diffstat (limited to 'drivers/hid/hid-roccat-pyra.c')
| -rw-r--r-- | drivers/hid/hid-roccat-pyra.c | 59 |
1 files changed, 14 insertions, 45 deletions
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index df05c1b1064f..1317c177a3e2 100644 --- a/drivers/hid/hid-roccat-pyra.c +++ b/drivers/hid/hid-roccat-pyra.c | |||
| @@ -42,43 +42,19 @@ static void profile_activated(struct pyra_device *pyra, | |||
| 42 | static int pyra_send_control(struct usb_device *usb_dev, int value, | 42 | static int pyra_send_control(struct usb_device *usb_dev, int value, |
| 43 | enum pyra_control_requests request) | 43 | enum pyra_control_requests request) |
| 44 | { | 44 | { |
| 45 | struct pyra_control control; | 45 | struct roccat_common2_control control; |
| 46 | 46 | ||
| 47 | if ((request == PYRA_CONTROL_REQUEST_PROFILE_SETTINGS || | 47 | if ((request == PYRA_CONTROL_REQUEST_PROFILE_SETTINGS || |
| 48 | request == PYRA_CONTROL_REQUEST_PROFILE_BUTTONS) && | 48 | request == PYRA_CONTROL_REQUEST_PROFILE_BUTTONS) && |
| 49 | (value < 0 || value > 4)) | 49 | (value < 0 || value > 4)) |
| 50 | return -EINVAL; | 50 | return -EINVAL; |
| 51 | 51 | ||
| 52 | control.command = PYRA_COMMAND_CONTROL; | 52 | control.command = ROCCAT_COMMON_COMMAND_CONTROL; |
| 53 | control.value = value; | 53 | control.value = value; |
| 54 | control.request = request; | 54 | control.request = request; |
| 55 | 55 | ||
| 56 | return roccat_common_send(usb_dev, PYRA_COMMAND_CONTROL, | 56 | return roccat_common2_send(usb_dev, ROCCAT_COMMON_COMMAND_CONTROL, |
| 57 | &control, sizeof(struct pyra_control)); | 57 | &control, sizeof(struct roccat_common2_control)); |
| 58 | } | ||
| 59 | |||
| 60 | static int pyra_receive_control_status(struct usb_device *usb_dev) | ||
| 61 | { | ||
| 62 | int retval; | ||
| 63 | struct pyra_control control; | ||
| 64 | |||
| 65 | do { | ||
| 66 | msleep(10); | ||
| 67 | retval = roccat_common_receive(usb_dev, PYRA_COMMAND_CONTROL, | ||
| 68 | &control, sizeof(struct pyra_control)); | ||
| 69 | |||
| 70 | /* requested too early, try again */ | ||
| 71 | } while (retval == -EPROTO); | ||
| 72 | |||
| 73 | if (!retval && control.command == PYRA_COMMAND_CONTROL && | ||
| 74 | control.request == PYRA_CONTROL_REQUEST_STATUS && | ||
| 75 | control.value == 1) | ||
| 76 | return 0; | ||
| 77 | else { | ||
| 78 | hid_err(usb_dev, "receive control status: unknown response 0x%x 0x%x\n", | ||
| 79 | control.request, control.value); | ||
| 80 | return retval ? retval : -EINVAL; | ||
| 81 | } | ||
| 82 | } | 58 | } |
| 83 | 59 | ||
| 84 | static int pyra_get_profile_settings(struct usb_device *usb_dev, | 60 | static int pyra_get_profile_settings(struct usb_device *usb_dev, |
| @@ -89,7 +65,7 @@ static int pyra_get_profile_settings(struct usb_device *usb_dev, | |||
| 89 | PYRA_CONTROL_REQUEST_PROFILE_SETTINGS); | 65 | PYRA_CONTROL_REQUEST_PROFILE_SETTINGS); |
| 90 | if (retval) | 66 | if (retval) |
| 91 | return retval; | 67 | return retval; |
| 92 | return roccat_common_receive(usb_dev, PYRA_COMMAND_PROFILE_SETTINGS, | 68 | return roccat_common2_receive(usb_dev, PYRA_COMMAND_PROFILE_SETTINGS, |
| 93 | buf, sizeof(struct pyra_profile_settings)); | 69 | buf, sizeof(struct pyra_profile_settings)); |
| 94 | } | 70 | } |
| 95 | 71 | ||
| @@ -101,51 +77,44 @@ static int pyra_get_profile_buttons(struct usb_device *usb_dev, | |||
| 101 | PYRA_CONTROL_REQUEST_PROFILE_BUTTONS); | 77 | PYRA_CONTROL_REQUEST_PROFILE_BUTTONS); |
| 102 | if (retval) | 78 | if (retval) |
| 103 | return retval; | 79 | return retval; |
| 104 | return roccat_common_receive(usb_dev, PYRA_COMMAND_PROFILE_BUTTONS, | 80 | return roccat_common2_receive(usb_dev, PYRA_COMMAND_PROFILE_BUTTONS, |
| 105 | buf, sizeof(struct pyra_profile_buttons)); | 81 | buf, sizeof(struct pyra_profile_buttons)); |
| 106 | } | 82 | } |
| 107 | 83 | ||
| 108 | static int pyra_get_settings(struct usb_device *usb_dev, | 84 | static int pyra_get_settings(struct usb_device *usb_dev, |
| 109 | struct pyra_settings *buf) | 85 | struct pyra_settings *buf) |
| 110 | { | 86 | { |
| 111 | return roccat_common_receive(usb_dev, PYRA_COMMAND_SETTINGS, | 87 | return roccat_common2_receive(usb_dev, PYRA_COMMAND_SETTINGS, |
| 112 | buf, sizeof(struct pyra_settings)); | 88 | buf, sizeof(struct pyra_settings)); |
| 113 | } | 89 | } |
| 114 | 90 | ||
| 115 | static int pyra_get_info(struct usb_device *usb_dev, struct pyra_info *buf) | 91 | static int pyra_get_info(struct usb_device *usb_dev, struct pyra_info *buf) |
| 116 | { | 92 | { |
| 117 | return roccat_common_receive(usb_dev, PYRA_COMMAND_INFO, | 93 | return roccat_common2_receive(usb_dev, PYRA_COMMAND_INFO, |
| 118 | buf, sizeof(struct pyra_info)); | 94 | buf, sizeof(struct pyra_info)); |
| 119 | } | 95 | } |
| 120 | 96 | ||
| 121 | static int pyra_send(struct usb_device *usb_dev, uint command, | ||
| 122 | void const *buf, uint size) | ||
| 123 | { | ||
| 124 | int retval; | ||
| 125 | retval = roccat_common_send(usb_dev, command, buf, size); | ||
| 126 | if (retval) | ||
| 127 | return retval; | ||
| 128 | return pyra_receive_control_status(usb_dev); | ||
| 129 | } | ||
| 130 | |||
| 131 | static int pyra_set_profile_settings(struct usb_device *usb_dev, | 97 | static int pyra_set_profile_settings(struct usb_device *usb_dev, |
| 132 | struct pyra_profile_settings const *settings) | 98 | struct pyra_profile_settings const *settings) |
| 133 | { | 99 | { |
| 134 | return pyra_send(usb_dev, PYRA_COMMAND_PROFILE_SETTINGS, settings, | 100 | return roccat_common2_send_with_status(usb_dev, |
| 101 | PYRA_COMMAND_PROFILE_SETTINGS, settings, | ||
| 135 | sizeof(struct pyra_profile_settings)); | 102 | sizeof(struct pyra_profile_settings)); |
| 136 | } | 103 | } |
| 137 | 104 | ||
| 138 | static int pyra_set_profile_buttons(struct usb_device *usb_dev, | 105 | static int pyra_set_profile_buttons(struct usb_device *usb_dev, |
| 139 | struct pyra_profile_buttons const *buttons) | 106 | struct pyra_profile_buttons const *buttons) |
| 140 | { | 107 | { |
| 141 | return pyra_send(usb_dev, PYRA_COMMAND_PROFILE_BUTTONS, buttons, | 108 | return roccat_common2_send_with_status(usb_dev, |
| 109 | PYRA_COMMAND_PROFILE_BUTTONS, buttons, | ||
| 142 | sizeof(struct pyra_profile_buttons)); | 110 | sizeof(struct pyra_profile_buttons)); |
| 143 | } | 111 | } |
| 144 | 112 | ||
| 145 | static int pyra_set_settings(struct usb_device *usb_dev, | 113 | static int pyra_set_settings(struct usb_device *usb_dev, |
| 146 | struct pyra_settings const *settings) | 114 | struct pyra_settings const *settings) |
| 147 | { | 115 | { |
| 148 | return pyra_send(usb_dev, PYRA_COMMAND_SETTINGS, settings, | 116 | return roccat_common2_send_with_status(usb_dev, |
| 117 | PYRA_COMMAND_SETTINGS, settings, | ||
| 149 | sizeof(struct pyra_settings)); | 118 | sizeof(struct pyra_settings)); |
| 150 | } | 119 | } |
| 151 | 120 | ||
