• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2   * Copyright (C) 2008 The Android Open Source Project
3   * All rights reserved.
4   *
5   * Redistribution and use in source and binary forms, with or without
6   * modification, are permitted provided that the following conditions
7   * are met:
8   *  * Redistributions of source code must retain the above copyright
9   *    notice, this list of conditions and the following disclaimer.
10   *  * Redistributions in binary form must reproduce the above copyright
11   *    notice, this list of conditions and the following disclaimer in
12   *    the documentation and/or other materials provided with the
13   *    distribution.
14   *
15   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18   * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19   * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21   * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22   * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23   * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26   * SUCH DAMAGE.
27   */
28  
29  #ifndef _USB_COMMON_DEFINES_H
30  #define _USB_COMMON_DEFINES_H
31  
32  #define GET_STATUS           0
33  #define CLEAR_FEATURE        1
34  #define SET_FEATURE          3
35  #define SET_ADDRESS          5
36  #define GET_DESCRIPTOR       6
37  #define SET_DESCRIPTOR       7
38  #define GET_CONFIGURATION    8
39  #define SET_CONFIGURATION    9
40  #define GET_INTERFACE        10
41  #define SET_INTERFACE        11
42  #define SYNCH_FRAME          12
43  
44  #define TYPE_DEVICE          1
45  #define TYPE_CONFIGURATION   2
46  #define TYPE_STRING          3
47  #define TYPE_INTERFACE       4
48  #define TYPE_ENDPOINT        5
49  
50  #define DEVICE_READ          0x80
51  #define DEVICE_WRITE         0x00
52  #define INTERFACE_READ       0x81
53  #define INTERFACE_WRITE      0x01
54  #define ENDPOINT_READ        0x82
55  #define ENDPOINT_WRITE       0x02
56  
57  typedef struct
58  {
59      unsigned char type;
60      unsigned char request;
61      unsigned short value;
62      unsigned short index;
63      unsigned short length;
64  } __attribute__ ((packed)) setup_packet;
65  
66  
67  struct usb_request
68  {
69      struct ept_queue_item *item;
70  
71      void *buf;
72      unsigned length;
73  
74      void (*complete)(struct usb_request *req, unsigned actual, int status);
75      void *context;
76  };
77  
78  struct usb_request *usb_request_alloc();
79  struct usb_endpoint *usb_endpoint_alloc(unsigned num, unsigned in, unsigned maxpkt);
80  int usb_queue_req(struct usb_endpoint *ept, struct usb_request *req);
81  
82  void usb_init(void);
83  void usb_shutdown(void);
84  void usb_poll(void);
85  
86  /* called to indicate online/offline status */
87  void usb_status(unsigned online, unsigned highspeed);
88  
89  #endif
90