102ac6454SAndrew Thompson /* $FreeBSD$ */ 202ac6454SAndrew Thompson /*- 302ac6454SAndrew Thompson * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 402ac6454SAndrew Thompson * 502ac6454SAndrew Thompson * Redistribution and use in source and binary forms, with or without 602ac6454SAndrew Thompson * modification, are permitted provided that the following conditions 702ac6454SAndrew Thompson * are met: 802ac6454SAndrew Thompson * 1. Redistributions of source code must retain the above copyright 902ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer. 1002ac6454SAndrew Thompson * 2. Redistributions in binary form must reproduce the above copyright 1102ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer in the 1202ac6454SAndrew Thompson * documentation and/or other materials provided with the distribution. 1302ac6454SAndrew Thompson * 1402ac6454SAndrew Thompson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1502ac6454SAndrew Thompson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1602ac6454SAndrew Thompson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1702ac6454SAndrew Thompson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1802ac6454SAndrew Thompson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1902ac6454SAndrew Thompson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2002ac6454SAndrew Thompson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2102ac6454SAndrew Thompson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2202ac6454SAndrew Thompson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2302ac6454SAndrew Thompson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2402ac6454SAndrew Thompson * SUCH DAMAGE. 2502ac6454SAndrew Thompson */ 2602ac6454SAndrew Thompson 2702ac6454SAndrew Thompson #ifndef _USB2_REQUEST_H_ 2802ac6454SAndrew Thompson #define _USB2_REQUEST_H_ 2902ac6454SAndrew Thompson 3002ac6454SAndrew Thompson struct usb2_process; 3102ac6454SAndrew Thompson 3202ac6454SAndrew Thompson usb2_error_t usb2_do_request_flags(struct usb2_device *udev, struct mtx *mtx, 3302ac6454SAndrew Thompson struct usb2_device_request *req, void *data, uint32_t flags, 3402ac6454SAndrew Thompson uint16_t *actlen, uint32_t timeout); 3502ac6454SAndrew Thompson usb2_error_t usb2_do_request_proc(struct usb2_device *udev, struct usb2_process *pproc, 3602ac6454SAndrew Thompson struct usb2_device_request *req, void *data, uint32_t flags, 3702ac6454SAndrew Thompson uint16_t *actlen, uint32_t timeout); 3802ac6454SAndrew Thompson usb2_error_t usb2_req_clear_hub_feature(struct usb2_device *udev, 3902ac6454SAndrew Thompson struct mtx *mtx, uint16_t sel); 4002ac6454SAndrew Thompson usb2_error_t usb2_req_clear_port_feature(struct usb2_device *udev, 4102ac6454SAndrew Thompson struct mtx *mtx, uint8_t port, uint16_t sel); 4202ac6454SAndrew Thompson usb2_error_t usb2_req_get_alt_interface_no(struct usb2_device *udev, 4302ac6454SAndrew Thompson struct mtx *mtx, uint8_t *alt_iface_no, 4402ac6454SAndrew Thompson uint8_t iface_index); 4502ac6454SAndrew Thompson usb2_error_t usb2_req_get_config(struct usb2_device *udev, struct mtx *mtx, 4602ac6454SAndrew Thompson uint8_t *pconf); 4702ac6454SAndrew Thompson usb2_error_t usb2_req_get_config_desc(struct usb2_device *udev, struct mtx *mtx, 4802ac6454SAndrew Thompson struct usb2_config_descriptor *d, uint8_t conf_index); 4902ac6454SAndrew Thompson usb2_error_t usb2_req_get_config_desc_full(struct usb2_device *udev, 5002ac6454SAndrew Thompson struct mtx *mtx, struct usb2_config_descriptor **ppcd, 5102ac6454SAndrew Thompson struct malloc_type *mtype, uint8_t conf_index); 5202ac6454SAndrew Thompson usb2_error_t usb2_req_get_desc(struct usb2_device *udev, struct mtx *mtx, 5302ac6454SAndrew Thompson void *desc, uint16_t min_len, uint16_t max_len, uint16_t id, 5402ac6454SAndrew Thompson uint8_t type, uint8_t index, uint8_t retries); 5502ac6454SAndrew Thompson usb2_error_t usb2_req_get_device_desc(struct usb2_device *udev, struct mtx *mtx, 5602ac6454SAndrew Thompson struct usb2_device_descriptor *d); 5702ac6454SAndrew Thompson usb2_error_t usb2_req_get_device_status(struct usb2_device *udev, 5802ac6454SAndrew Thompson struct mtx *mtx, struct usb2_status *st); 5902ac6454SAndrew Thompson usb2_error_t usb2_req_get_hub_descriptor(struct usb2_device *udev, 6002ac6454SAndrew Thompson struct mtx *mtx, struct usb2_hub_descriptor *hd, 6102ac6454SAndrew Thompson uint8_t nports); 6202ac6454SAndrew Thompson usb2_error_t usb2_req_get_hub_status(struct usb2_device *udev, struct mtx *mtx, 6302ac6454SAndrew Thompson struct usb2_hub_status *st); 6402ac6454SAndrew Thompson usb2_error_t usb2_req_get_port_status(struct usb2_device *udev, struct mtx *mtx, 6502ac6454SAndrew Thompson struct usb2_port_status *ps, uint8_t port); 6602ac6454SAndrew Thompson usb2_error_t usb2_req_get_report(struct usb2_device *udev, struct mtx *mtx, 6702ac6454SAndrew Thompson void *data, uint16_t len, uint8_t iface_index, uint8_t type, 6802ac6454SAndrew Thompson uint8_t id); 6902ac6454SAndrew Thompson usb2_error_t usb2_req_get_report_descriptor(struct usb2_device *udev, 7002ac6454SAndrew Thompson struct mtx *mtx, void *d, uint16_t size, 7102ac6454SAndrew Thompson uint8_t iface_index); 7202ac6454SAndrew Thompson usb2_error_t usb2_req_get_string_any(struct usb2_device *udev, struct mtx *mtx, 7302ac6454SAndrew Thompson char *buf, uint16_t len, uint8_t string_index); 7402ac6454SAndrew Thompson usb2_error_t usb2_req_get_string_desc(struct usb2_device *udev, struct mtx *mtx, 7502ac6454SAndrew Thompson void *sdesc, uint16_t max_len, uint16_t lang_id, 7602ac6454SAndrew Thompson uint8_t string_index); 7702ac6454SAndrew Thompson usb2_error_t usb2_req_reset_port(struct usb2_device *udev, struct mtx *mtx, 7802ac6454SAndrew Thompson uint8_t port); 7902ac6454SAndrew Thompson usb2_error_t usb2_req_set_address(struct usb2_device *udev, struct mtx *mtx, 8002ac6454SAndrew Thompson uint16_t addr); 8102ac6454SAndrew Thompson usb2_error_t usb2_req_set_alt_interface_no(struct usb2_device *udev, 8202ac6454SAndrew Thompson struct mtx *mtx, uint8_t iface_index, uint8_t alt_no); 8302ac6454SAndrew Thompson usb2_error_t usb2_req_set_config(struct usb2_device *udev, struct mtx *mtx, 8402ac6454SAndrew Thompson uint8_t conf); 8502ac6454SAndrew Thompson usb2_error_t usb2_req_set_hub_feature(struct usb2_device *udev, struct mtx *mtx, 8602ac6454SAndrew Thompson uint16_t sel); 8702ac6454SAndrew Thompson usb2_error_t usb2_req_set_idle(struct usb2_device *udev, struct mtx *mtx, 8802ac6454SAndrew Thompson uint8_t iface_index, uint8_t duration, uint8_t id); 8902ac6454SAndrew Thompson usb2_error_t usb2_req_set_port_feature(struct usb2_device *udev, 9002ac6454SAndrew Thompson struct mtx *mtx, uint8_t port, uint16_t sel); 9102ac6454SAndrew Thompson usb2_error_t usb2_req_set_protocol(struct usb2_device *udev, struct mtx *mtx, 9202ac6454SAndrew Thompson uint8_t iface_index, uint16_t report); 9302ac6454SAndrew Thompson usb2_error_t usb2_req_set_report(struct usb2_device *udev, struct mtx *mtx, 9402ac6454SAndrew Thompson void *data, uint16_t len, uint8_t iface_index, 9502ac6454SAndrew Thompson uint8_t type, uint8_t id); 9602ac6454SAndrew Thompson usb2_error_t usb2_req_re_enumerate(struct usb2_device *udev, struct mtx *mtx); 9702ac6454SAndrew Thompson usb2_error_t usb2_req_clear_device_feature(struct usb2_device *udev, struct mtx *mtx, uint16_t sel); 9802ac6454SAndrew Thompson usb2_error_t usb2_req_set_device_feature(struct usb2_device *udev, struct mtx *mtx, uint16_t sel); 9902ac6454SAndrew Thompson 10002ac6454SAndrew Thompson #define usb2_do_request(u,m,r,d) \ 10102ac6454SAndrew Thompson usb2_do_request_flags(u,m,r,d,0,NULL,USB_DEFAULT_TIMEOUT) 10202ac6454SAndrew Thompson 10302ac6454SAndrew Thompson #endif /* _USB2_REQUEST_H_ */ 104