xref: /freebsd/sys/dev/usb/usb_request.h (revision 759736470cac5ee5c7e86400bff165c7af6b400b)
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 
2775973647SAndrew Thompson #ifndef _USB_REQUEST_H_
2875973647SAndrew Thompson #define	_USB_REQUEST_H_
2902ac6454SAndrew Thompson 
30760bc48eSAndrew Thompson struct usb_process;
3102ac6454SAndrew Thompson 
32a593f6b8SAndrew Thompson usb_error_t usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx,
33760bc48eSAndrew Thompson 		    struct usb_device_request *req, void *data, uint16_t flags,
34e0a69b51SAndrew Thompson 		    uint16_t *actlen, usb_timeout_t timeout);
35a593f6b8SAndrew Thompson usb_error_t usbd_do_request_proc(struct usb_device *udev, struct usb_process *pproc,
36760bc48eSAndrew Thompson 		    struct usb_device_request *req, void *data, uint16_t flags,
37e0a69b51SAndrew Thompson 		    uint16_t *actlen, usb_timeout_t timeout);
38a593f6b8SAndrew Thompson usb_error_t usbd_req_clear_hub_feature(struct usb_device *udev,
3902ac6454SAndrew Thompson 		    struct mtx *mtx, uint16_t sel);
40a593f6b8SAndrew Thompson usb_error_t usbd_req_clear_port_feature(struct usb_device *udev,
4102ac6454SAndrew Thompson 		    struct mtx *mtx, uint8_t port, uint16_t sel);
42a593f6b8SAndrew Thompson usb_error_t usbd_req_get_alt_interface_no(struct usb_device *udev,
4302ac6454SAndrew Thompson 		    struct mtx *mtx, uint8_t *alt_iface_no,
4402ac6454SAndrew Thompson 		    uint8_t iface_index);
45a593f6b8SAndrew Thompson usb_error_t usbd_req_get_config(struct usb_device *udev, struct mtx *mtx,
4602ac6454SAndrew Thompson 		    uint8_t *pconf);
47a593f6b8SAndrew Thompson usb_error_t usbd_req_get_descriptor_ptr(struct usb_device *udev,
48760bc48eSAndrew Thompson 		    struct usb_config_descriptor **ppcd, uint16_t wValue);
49a593f6b8SAndrew Thompson usb_error_t usbd_req_get_config_desc(struct usb_device *udev, struct mtx *mtx,
50760bc48eSAndrew Thompson 		    struct usb_config_descriptor *d, uint8_t conf_index);
51a593f6b8SAndrew Thompson usb_error_t usbd_req_get_config_desc_full(struct usb_device *udev,
52760bc48eSAndrew Thompson 		    struct mtx *mtx, struct usb_config_descriptor **ppcd,
5302ac6454SAndrew Thompson 		    struct malloc_type *mtype, uint8_t conf_index);
54a593f6b8SAndrew Thompson usb_error_t usbd_req_get_desc(struct usb_device *udev, struct mtx *mtx,
5516589beaSAndrew Thompson 		    uint16_t *actlen, void *desc, uint16_t min_len,
5616589beaSAndrew Thompson 		    uint16_t max_len, uint16_t id, uint8_t type,
5716589beaSAndrew Thompson 		    uint8_t index, uint8_t retries);
58a593f6b8SAndrew Thompson usb_error_t usbd_req_get_device_desc(struct usb_device *udev, struct mtx *mtx,
59760bc48eSAndrew Thompson 		    struct usb_device_descriptor *d);
60a593f6b8SAndrew Thompson usb_error_t usbd_req_get_device_status(struct usb_device *udev,
61760bc48eSAndrew Thompson 		    struct mtx *mtx, struct usb_status *st);
62a593f6b8SAndrew Thompson usb_error_t usbd_req_get_hub_descriptor(struct usb_device *udev,
63760bc48eSAndrew Thompson 		    struct mtx *mtx, struct usb_hub_descriptor *hd,
6402ac6454SAndrew Thompson 		    uint8_t nports);
65a593f6b8SAndrew Thompson usb_error_t usbd_req_get_hub_status(struct usb_device *udev, struct mtx *mtx,
66760bc48eSAndrew Thompson 		    struct usb_hub_status *st);
67a593f6b8SAndrew Thompson usb_error_t usbd_req_get_port_status(struct usb_device *udev, struct mtx *mtx,
68760bc48eSAndrew Thompson 		    struct usb_port_status *ps, uint8_t port);
69a593f6b8SAndrew Thompson usb_error_t usbd_req_get_report(struct usb_device *udev, struct mtx *mtx,
7002ac6454SAndrew Thompson 		    void *data, uint16_t len, uint8_t iface_index, uint8_t type,
7102ac6454SAndrew Thompson 		    uint8_t id);
72a593f6b8SAndrew Thompson usb_error_t usbd_req_get_report_descriptor(struct usb_device *udev,
7302ac6454SAndrew Thompson 		    struct mtx *mtx, void *d, uint16_t size,
7402ac6454SAndrew Thompson 		    uint8_t iface_index);
75a593f6b8SAndrew Thompson usb_error_t usbd_req_get_string_any(struct usb_device *udev, struct mtx *mtx,
7602ac6454SAndrew Thompson 		    char *buf, uint16_t len, uint8_t string_index);
77a593f6b8SAndrew Thompson usb_error_t usbd_req_get_string_desc(struct usb_device *udev, struct mtx *mtx,
7802ac6454SAndrew Thompson 		    void *sdesc, uint16_t max_len, uint16_t lang_id,
7902ac6454SAndrew Thompson 		    uint8_t string_index);
80a593f6b8SAndrew Thompson usb_error_t usbd_req_reset_port(struct usb_device *udev, struct mtx *mtx,
8102ac6454SAndrew Thompson 		    uint8_t port);
82a593f6b8SAndrew Thompson usb_error_t usbd_req_set_address(struct usb_device *udev, struct mtx *mtx,
8302ac6454SAndrew Thompson 		    uint16_t addr);
84a593f6b8SAndrew Thompson usb_error_t usbd_req_set_alt_interface_no(struct usb_device *udev,
8502ac6454SAndrew Thompson 		    struct mtx *mtx, uint8_t iface_index, uint8_t alt_no);
86a593f6b8SAndrew Thompson usb_error_t usbd_req_set_config(struct usb_device *udev, struct mtx *mtx,
8702ac6454SAndrew Thompson 		    uint8_t conf);
88a593f6b8SAndrew Thompson usb_error_t usbd_req_set_hub_feature(struct usb_device *udev, struct mtx *mtx,
8902ac6454SAndrew Thompson 		    uint16_t sel);
90a593f6b8SAndrew Thompson usb_error_t usbd_req_set_idle(struct usb_device *udev, struct mtx *mtx,
9102ac6454SAndrew Thompson 		    uint8_t iface_index, uint8_t duration, uint8_t id);
92a593f6b8SAndrew Thompson usb_error_t usbd_req_set_port_feature(struct usb_device *udev,
9302ac6454SAndrew Thompson 		    struct mtx *mtx, uint8_t port, uint16_t sel);
94a593f6b8SAndrew Thompson usb_error_t usbd_req_set_protocol(struct usb_device *udev, struct mtx *mtx,
9502ac6454SAndrew Thompson 		    uint8_t iface_index, uint16_t report);
96a593f6b8SAndrew Thompson usb_error_t usbd_req_set_report(struct usb_device *udev, struct mtx *mtx,
9702ac6454SAndrew Thompson 		    void *data, uint16_t len, uint8_t iface_index,
9802ac6454SAndrew Thompson 		    uint8_t type, uint8_t id);
99a593f6b8SAndrew Thompson usb_error_t usbd_req_re_enumerate(struct usb_device *udev, struct mtx *mtx);
100a593f6b8SAndrew Thompson usb_error_t usbd_req_clear_device_feature(struct usb_device *udev, struct mtx *mtx, uint16_t sel);
101a593f6b8SAndrew Thompson usb_error_t usbd_req_set_device_feature(struct usb_device *udev, struct mtx *mtx, uint16_t sel);
10202ac6454SAndrew Thompson 
103a593f6b8SAndrew Thompson #define	usbd_do_request(u,m,r,d) \
104a593f6b8SAndrew Thompson   usbd_do_request_flags(u,m,r,d,0,NULL,USB_DEFAULT_TIMEOUT)
10502ac6454SAndrew Thompson 
10675973647SAndrew Thompson #endif					/* _USB_REQUEST_H_ */
107