Changeset 3742068 in mainline for uspace/drv/usbhid/hidreq.c
- Timestamp:
- 2011-03-06T17:03:25Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 24d5432
- Parents:
- c18b11a (diff), b330cb1f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/hidreq.c
rc18b11a r3742068 69 69 return sess_rc; 70 70 } 71 72 uint16_t value = 0; 73 value |= (type << 8); 71 74 72 75 usb_log_debug("Sending Set_Report request to the device.\n"); … … 74 77 rc = usb_control_request_set(&hid_dev->ctrl_pipe, 75 78 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 76 USB_HIDREQ_SET_REPORT, type, hid_dev->iface, buffer, buf_size);79 USB_HIDREQ_SET_REPORT, value, hid_dev->iface, buffer, buf_size); 77 80 78 81 sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe); … … 187 190 return sess_rc; 188 191 } 192 193 return EOK; 194 } 195 196 /*----------------------------------------------------------------------------*/ 197 198 int usbhid_req_get_report(usbhid_dev_t *hid_dev, usb_hid_report_type_t type, 199 uint8_t *buffer, size_t buf_size, size_t *actual_size) 200 { 201 if (hid_dev == NULL) { 202 usb_log_error("usbhid_req_set_report(): no HID device structure" 203 " given.\n"); 204 return EINVAL; 205 } 206 207 /* 208 * No need for checking other parameters, as they are checked in 209 * the called function (usb_control_request_set()). 210 */ 211 212 int rc, sess_rc; 213 214 sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe); 215 if (sess_rc != EOK) { 216 usb_log_warning("Failed to start a session: %s.\n", 217 str_error(sess_rc)); 218 return sess_rc; 219 } 220 221 uint16_t value = 0; 222 value |= (type << 8); 223 224 usb_log_debug("Sending Get_Report request to the device.\n"); 225 226 rc = usb_control_request_get(&hid_dev->ctrl_pipe, 227 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 228 USB_HIDREQ_GET_REPORT, value, hid_dev->iface, buffer, buf_size, 229 actual_size); 230 231 sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe); 232 233 if (rc != EOK) { 234 usb_log_warning("Error sending output report to the keyboard: " 235 "%s.\n", str_error(rc)); 236 return rc; 237 } 238 239 if (sess_rc != EOK) { 240 usb_log_warning("Error closing session: %s.\n", 241 str_error(sess_rc)); 242 return sess_rc; 243 } 244 245 return EOK; 246 } 247 248 int usbhid_req_get_protocol(usbhid_dev_t *hid_dev, usb_hid_protocol_t *protocol) 249 { 250 if (hid_dev == NULL) { 251 usb_log_error("usbhid_req_set_protocol(): no HID device " 252 "structure given.\n"); 253 return EINVAL; 254 } 255 256 /* 257 * No need for checking other parameters, as they are checked in 258 * the called function (usb_control_request_set()). 259 */ 260 261 int rc, sess_rc; 262 263 sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe); 264 if (sess_rc != EOK) { 265 usb_log_warning("Failed to start a session: %s.\n", 266 str_error(sess_rc)); 267 return sess_rc; 268 } 269 270 usb_log_debug("Sending Get_Protocol request to the device (" 271 "iface: %d).\n", hid_dev->iface); 272 273 uint8_t buffer[1]; 274 size_t actual_size = 0; 275 276 rc = usb_control_request_get(&hid_dev->ctrl_pipe, 277 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 278 USB_HIDREQ_GET_PROTOCOL, 0, hid_dev->iface, buffer, 1, &actual_size); 279 280 sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe); 281 282 if (rc != EOK) { 283 usb_log_warning("Error sending output report to the keyboard: " 284 "%s.\n", str_error(rc)); 285 return rc; 286 } 287 288 if (sess_rc != EOK) { 289 usb_log_warning("Error closing session: %s.\n", 290 str_error(sess_rc)); 291 return sess_rc; 292 } 293 294 if (actual_size != 1) { 295 usb_log_warning("Wrong data size: %zu, expected: 1.\n", 296 actual_size); 297 return ELIMIT; 298 } 299 300 *protocol = buffer[0]; 301 302 return EOK; 303 } 304 305 int usbhid_req_get_idle(usbhid_dev_t *hid_dev, uint8_t *duration) 306 { 307 if (hid_dev == NULL) { 308 usb_log_error("usbhid_req_set_idle(): no HID device " 309 "structure given.\n"); 310 return EINVAL; 311 } 312 313 /* 314 * No need for checking other parameters, as they are checked in 315 * the called function (usb_control_request_set()). 316 */ 317 318 int rc, sess_rc; 319 320 sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe); 321 if (sess_rc != EOK) { 322 usb_log_warning("Failed to start a session: %s.\n", 323 str_error(sess_rc)); 324 return sess_rc; 325 } 326 327 usb_log_debug("Sending Get_Idle request to the device (" 328 "iface: %d).\n", hid_dev->iface); 329 330 uint16_t value = 0; 331 uint8_t buffer[1]; 332 size_t actual_size = 0; 333 334 rc = usb_control_request_get(&hid_dev->ctrl_pipe, 335 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 336 USB_HIDREQ_GET_IDLE, value, hid_dev->iface, buffer, 1, 337 &actual_size); 338 339 sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe); 340 341 if (rc != EOK) { 342 usb_log_warning("Error sending output report to the keyboard: " 343 "%s.\n", str_error(rc)); 344 return rc; 345 } 346 347 if (sess_rc != EOK) { 348 usb_log_warning("Error closing session: %s.\n", 349 str_error(sess_rc)); 350 return sess_rc; 351 } 352 353 if (actual_size != 1) { 354 usb_log_warning("Wrong data size: %zu, expected: 1.\n", 355 actual_size); 356 return ELIMIT; 357 } 358 359 *duration = buffer[0]; 189 360 190 361 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.