linux/drivers/staging/rtl8188eu/include/usb_ops.h
<<
>>
Prefs
   1/******************************************************************************
   2 *
   3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
   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 * You should have received a copy of the GNU General Public License along with
  15 * this program; if not, write to the Free Software Foundation, Inc.,
  16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17 *
  18 *
  19 ******************************************************************************/
  20#ifndef __USB_OPS_H_
  21#define __USB_OPS_H_
  22
  23#include <linux/version.h>
  24#include <osdep_service.h>
  25#include <drv_types.h>
  26#include <osdep_intf.h>
  27
  28#define REALTEK_USB_VENQT_READ          0xC0
  29#define REALTEK_USB_VENQT_WRITE         0x40
  30#define REALTEK_USB_VENQT_CMD_REQ       0x05
  31#define REALTEK_USB_VENQT_CMD_IDX       0x00
  32
  33enum{
  34        VENDOR_WRITE = 0x00,
  35        VENDOR_READ = 0x01,
  36};
  37#define ALIGNMENT_UNIT                  16
  38#define MAX_VENDOR_REQ_CMD_SIZE 254     /* 8188cu SIE Support */
  39#define MAX_USB_IO_CTL_SIZE     (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
  40
  41#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12))
  42#define rtw_usb_control_msg(dev, pipe, request, requesttype,            \
  43                            value, index, data, size, timeout_ms)       \
  44        usb_control_msg((dev), (pipe), (request), (requesttype), (value),\
  45                        (index), (data), (size), (timeout_ms))
  46#define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
  47        usb_bulk_msg((usb_dev), (pipe), (data), (len),                  \
  48                     (actual_length), (timeout_ms))
  49#else
  50#define rtw_usb_control_msg(dev, pipe, request, requesttype,            \
  51                            value, index, data, size, timeout_ms)       \
  52        usb_control_msg((dev), (pipe), (request), (requesttype),        \
  53                        (value), (index), (data), (size),               \
  54                        ((timeout_ms) == 0) ||                          \
  55                        ((timeout_ms)*HZ/1000 > 0) ?                    \
  56                        ((timeout_ms)*HZ/1000) : 1)
  57#define rtw_usb_bulk_msg(usb_dev, pipe, data, len,                      \
  58                         actual_length, timeout_ms) \
  59        usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \
  60                     ((timeout_ms) == 0) || ((timeout_ms)*HZ/1000 > 0) ?\
  61                     ((timeout_ms)*HZ/1000) : 1)
  62#endif
  63#include <usb_ops_linux.h>
  64
  65void rtl8188eu_set_hw_type(struct adapter *padapter);
  66#define hal_set_hw_type rtl8188eu_set_hw_type
  67void rtl8188eu_set_intf_ops(struct _io_ops *pops);
  68#define usb_set_intf_ops rtl8188eu_set_intf_ops
  69
  70/*
  71 * Increase and check if the continual_urb_error of this @param dvobjprivei
  72 * is larger than MAX_CONTINUAL_URB_ERR
  73 * @return true:
  74 * @return false:
  75 */
  76static inline int rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj)
  77{
  78        int ret = false;
  79        int value;
  80        value = atomic_inc_return(&dvobj->continual_urb_error);
  81        if (value > MAX_CONTINUAL_URB_ERR) {
  82                DBG_88E("[dvobj:%p][ERROR] continual_urb_error:%d > %d\n",
  83                        dvobj, value, MAX_CONTINUAL_URB_ERR);
  84                ret = true;
  85        }
  86        return ret;
  87}
  88
  89/*
  90* Set the continual_urb_error of this @param dvobjprive to 0
  91*/
  92static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj)
  93{
  94        atomic_set(&dvobj->continual_urb_error, 0);
  95}
  96
  97#define USB_HIGH_SPEED_BULK_SIZE        512
  98#define USB_FULL_SPEED_BULK_SIZE        64
  99
 100static inline u8 rtw_usb_bulk_size_boundary(struct adapter *padapter,
 101                                            int buf_len)
 102{
 103        u8 rst = true;
 104        struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
 105
 106        if (pdvobjpriv->ishighspeed)
 107                rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ?
 108                      true : false;
 109        else
 110                rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ?
 111                      true : false;
 112        return rst;
 113}
 114
 115#endif /* __USB_OPS_H_ */
 116