• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
3 
4 #ifndef __USB_OPS_H_
5 #define __USB_OPS_H_
6 
7 #include "osdep_service.h"
8 #include "drv_types.h"
9 #include "osdep_intf.h"
10 
11 #define REALTEK_USB_VENQT_READ		(USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
12 #define REALTEK_USB_VENQT_WRITE		(USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
13 #define REALTEK_USB_VENQT_CMD_REQ	0x05
14 #define REALTEK_USB_VENQT_CMD_IDX	0x00
15 
16 #define ALIGNMENT_UNIT			16
17 #define MAX_VENDOR_REQ_CMD_SIZE	254	/* 8188cu SIE Support */
18 #define MAX_USB_IO_CTL_SIZE	(MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
19 
20 #include "usb_ops_linux.h"
21 
22 void rtl8188eu_set_hw_type(struct adapter *padapter);
23 #define hal_set_hw_type rtl8188eu_set_hw_type
24 void rtl8188eu_set_intf_ops(struct _io_ops *pops);
25 #define usb_set_intf_ops rtl8188eu_set_intf_ops
26 
27 /*
28  * Increase and check if the continual_urb_error of this @param dvobjprivei
29  * is larger than MAX_CONTINUAL_URB_ERR
30  * @return true:
31  * @return false:
32  */
rtw_inc_and_chk_continual_urb_error(struct dvobj_priv * dvobj)33 static inline int rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj)
34 {
35 	int ret = false;
36 	int value;
37 	value = atomic_inc_return(&dvobj->continual_urb_error);
38 	if (value > MAX_CONTINUAL_URB_ERR) {
39 		DBG_88E("[dvobj:%p][ERROR] continual_urb_error:%d > %d\n",
40 			dvobj, value, MAX_CONTINUAL_URB_ERR);
41 		ret = true;
42 	}
43 	return ret;
44 }
45 
46 /*
47 * Set the continual_urb_error of this @param dvobjprive to 0
48 */
rtw_reset_continual_urb_error(struct dvobj_priv * dvobj)49 static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj)
50 {
51 	atomic_set(&dvobj->continual_urb_error, 0);
52 }
53 
54 #define USB_HIGH_SPEED_BULK_SIZE	512
55 #define USB_FULL_SPEED_BULK_SIZE	64
56 
rtw_usb_bulk_size_boundary(struct adapter * padapter,int buf_len)57 static inline u8 rtw_usb_bulk_size_boundary(struct adapter *padapter,
58 					    int buf_len)
59 {
60 	u8 rst = true;
61 	struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
62 
63 	if (pdvobjpriv->ishighspeed)
64 		rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ?
65 		      true : false;
66 	else
67 		rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ?
68 		      true : false;
69 	return rst;
70 }
71 
72 #endif /* __USB_OPS_H_ */
73