• 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 static unsigned short manufacturer_string[] = {
30     (TYPE_STRING << 8) | (12 * 2),
31     'G', 'o', 'o', 'g', 'l', 'e', ',', ' ', 'I', 'n', 'c',
32 };
33 
34 static unsigned short product_string[] = {
35     (TYPE_STRING << 8) | (12 * 2),
36     'A', 'n', 'd', 'r', 'o', 'i', 'd', ' ', '1', '.', '0',
37 };
38 
39 static unsigned short default_string[] = {
40     (TYPE_STRING << 8) | (8 * 2),
41     'd', 'e', 'f', 'a', 'u', 'l', 't',
42 };
43 
44 static unsigned short language_table[] = {
45     (TYPE_STRING << 8) | 4,
46     0x0409, // LANGID for US English
47 };
48 
49 static unsigned char device_desc[] = {
50     18,              // length
51     TYPE_DEVICE,     // type
52     0x10, 0x02,      // usb spec rev 1.00
53     0x00,            // class
54     0x00,            // subclass
55     0x00,            // protocol
56     0x40,            // max packet size
57     0xD1, 0x18,      // vendor id
58     0x0D, 0xD0,      // product id
59     0x00, 0x01,      // version 1.0
60     0x01,            // manufacturer str idx
61     0x02,            // product str idx
62     0x00,            // serial number index
63     0x01,            // number of configs,
64 };
65 
66 static unsigned char config_desc[] = {
67     0x09,            // length
68     TYPE_CONFIGURATION,
69     0x20, 0x00,      // total length
70     0x01,            // # interfaces
71     0x01,            // config value
72     0x00,            // config string
73     0x80,            // attributes
74     0x80,            // XXX max power (250ma)
75 
76     0x09,            // length
77     TYPE_INTERFACE,
78     0x00,            // interface number
79     0x00,            // alt number
80     0x02,            // # endpoints
81     0xFF,
82     0x42,
83     0x03,
84     0x00,            // interface string
85 
86     0x07,            // length
87     TYPE_ENDPOINT,
88     0x81,            // in, #1
89     0x02,            // bulk
90     0x00, 0x02,      // max packet 512
91     0x00,            // interval
92 
93     0x07,            // length
94     TYPE_ENDPOINT,
95     0x01,            // out, #1
96     0x02,            // bulk
97     0x00, 0x02,      // max packet 512
98     0x01,            // interval
99 };
100 
101 static unsigned char config_desc_fs[] = {
102     0x09,            // length
103     TYPE_CONFIGURATION,
104     0x20, 0x00,      // total length
105     0x01,            // # interfaces
106     0x01,            // config value
107     0x00,            // config string
108     0x80,            // attributes
109     0x80,            // XXX max power (250ma)
110 
111     0x09,            // length
112     TYPE_INTERFACE,
113     0x00,            // interface number
114     0x00,            // alt number
115     0x02,            // # endpoints
116     0xFF,
117     0x42,
118     0x03,
119     0x00,            // interface string
120 
121     0x07,            // length
122     TYPE_ENDPOINT,
123     0x81,            // in, #1
124     0x02,            // bulk
125     0x40, 0x00,      // max packet 64
126     0x00,            // interval
127 
128     0x07,            // length
129     TYPE_ENDPOINT,
130     0x01,            // out, #1
131     0x02,            // bulk
132     0x40, 0x00,      // max packet 64
133     0x00,            // interval
134 };
135 
136 typedef struct
137 {
138     void *data;
139     unsigned short length;
140     unsigned short id;
141 } dtable;
142 
143 #define ID(type,num) ((type << 8) | num)
144 
145 static dtable descr_hs[] = {
146     { device_desc, sizeof(device_desc), ID(TYPE_DEVICE, 0) },
147     { config_desc, sizeof(config_desc), ID(TYPE_CONFIGURATION, 0) },
148     { manufacturer_string, sizeof(manufacturer_string), ID(TYPE_STRING, 1) },
149     { product_string, sizeof(product_string), ID(TYPE_STRING, 2) },
150     { default_string, sizeof(default_string), ID(TYPE_STRING, 4) },
151     { language_table, sizeof(language_table), ID(TYPE_STRING, 0) },
152     { 0, 0, 0 },
153 };
154 
155 static dtable descr_fs[] = {
156     { device_desc, sizeof(device_desc), ID(TYPE_DEVICE, 0) },
157     { config_desc_fs, sizeof(config_desc), ID(TYPE_CONFIGURATION, 0) },
158     { manufacturer_string, sizeof(manufacturer_string), ID(TYPE_STRING, 1) },
159     { product_string, sizeof(product_string), ID(TYPE_STRING, 2) },
160     { default_string, sizeof(default_string), ID(TYPE_STRING, 4) },
161     { language_table, sizeof(language_table), ID(TYPE_STRING, 0) },
162     { 0, 0, 0 },
163 };
164