1 /****************************************************************************** 2 * 3 * Copyright(c) 2007 - 2019 Realtek Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 *****************************************************************************/ 15 #ifndef __USB_OPS_LINUX_H__ 16 #define __USB_OPS_LINUX_H__ 17 18 #define RTW_USB_CONTROL_MSG_TIMEOUT_TEST 10/* ms */ 19 #define RTW_USB_CONTROL_MSG_TIMEOUT 500/* ms */ 20 21 #define RECV_BULK_IN_ADDR 0x80/* assign by drv, not real address */ 22 #define RECV_INT_IN_ADDR 0x81/* assign by drv, not real address */ 23 24 #define INTERRUPT_MSG_FORMAT_LEN 60 25 26 #if defined(CONFIG_VENDOR_REQ_RETRY) && defined(CONFIG_USB_VENDOR_REQ_MUTEX) 27 /* vendor req retry should be in the situation when each vendor req is atomically submitted from others */ 28 #define MAX_USBCTRL_VENDORREQ_TIMES 10 29 #else 30 #define MAX_USBCTRL_VENDORREQ_TIMES 1 31 #endif 32 33 #define RTW_USB_BULKOUT_TIMEOUT 5000/* ms */ 34 35 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12)) 36 #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size, timeout_ms) \ 37 usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), (timeout_ms)) 38 #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \ 39 usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), (timeout_ms)) 40 #else 41 #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size, timeout_ms) \ 42 usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), \ 43 ((timeout_ms) == 0) || ((timeout_ms) * HZ / 1000 > 0) ? ((timeout_ms) * HZ / 1000) : 1) 44 #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \ 45 usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \ 46 ((timeout_ms) == 0) || ((timeout_ms) * HZ / 1000 > 0) ? ((timeout_ms) * HZ / 1000) : 1) 47 #endif 48 49 50 int rtw_os_urb_resource_alloc(struct data_urb *dataurb); 51 void rtw_os_urb_resource_free(struct data_urb *dataurb); 52 53 int usbctrl_vendorreq(struct dvobj_priv *pdvobjpriv, u8 request, u16 value, u16 index, 54 void *pdata, u16 len, u8 requesttype); 55 56 u32 rtw_usb_write_port(void *d, u8 *phl_tx_buf_ptr, 57 u8 bulk_id, u32 len, u8 *pkt_data_buf); 58 59 void rtw_usb_write_port_cancel(void *d); 60 61 u32 rtw_usb_read_port(void *d, void *rxobj, 62 u8 *inbuf, u32 inbuf_len, u8 bulk_id, u8 minlen); 63 64 void rtw_usb_read_port_cancel(void *d); 65 66 #endif 67