Revision 4696425c hw/usb-bt.c

b/hw/usb-bt.c
20 20

  
21 21
#include "qemu-common.h"
22 22
#include "usb.h"
23
#include "usb-desc.h"
23 24
#include "net.h"
24 25
#include "bt.h"
25 26

  
......
51 52
#define USB_ACL_EP	2
52 53
#define USB_SCO_EP	3
53 54

  
54
static const uint8_t qemu_bt_dev_descriptor[] = {
55
    0x12,		/*  u8 bLength; */
56
    USB_DT_DEVICE,	/*  u8 bDescriptorType; Device */
57
    0x10, 0x01,		/*  u16 bcdUSB; v1.10 */
55
enum {
56
    STR_MANUFACTURER = 1,
57
    STR_SERIALNUMBER,
58
};
58 59

  
59
    0xe0,	/*  u8  bDeviceClass; Wireless */
60
    0x01,	/*  u8  bDeviceSubClass; Radio Frequency */
61
    0x01,	/*  u8  bDeviceProtocol; Bluetooth */
62
    0x40,	/*  u8  bMaxPacketSize0; 64 Bytes */
60
static const USBDescStrings desc_strings = {
61
    [STR_MANUFACTURER]     = "QEMU " QEMU_VERSION,
62
    [STR_SERIALNUMBER]     = "1",
63
};
63 64

  
64
    0x12, 0x0a,	/*  u16 idVendor; */
65
    0x01, 0x00,	/*  u16 idProduct; Bluetooth Dongle (HCI mode) */
66
    0x58, 0x19,	/*  u16 bcdDevice; (some devices have 0x48, 0x02) */
65
static const USBDescIface desc_iface_bluetooth[] = {
66
    {
67
        .bInterfaceNumber              = 0,
68
        .bNumEndpoints                 = 3,
69
        .bInterfaceClass               = 0xe0, /* Wireless */
70
        .bInterfaceSubClass            = 0x01, /* Radio Frequency */
71
        .bInterfaceProtocol            = 0x01, /* Bluetooth */
72
        .eps = (USBDescEndpoint[]) {
73
            {
74
                .bEndpointAddress      = USB_DIR_IN | USB_EVT_EP,
75
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
76
                .wMaxPacketSize        = 0x10,
77
                .bInterval             = 0x02,
78
            },
79
            {
80
                .bEndpointAddress      = USB_DIR_OUT | USB_ACL_EP,
81
                .bmAttributes          = USB_ENDPOINT_XFER_BULK,
82
                .wMaxPacketSize        = 0x40,
83
                .bInterval             = 0x0a,
84
            },
85
            {
86
                .bEndpointAddress      = USB_DIR_IN | USB_ACL_EP,
87
                .bmAttributes          = USB_ENDPOINT_XFER_BULK,
88
                .wMaxPacketSize        = 0x40,
89
                .bInterval             = 0x0a,
90
            },
91
        },
92
    },{
93
        .bInterfaceNumber              = 1,
94
        .bAlternateSetting             = 0,
95
        .bNumEndpoints                 = 2,
96
        .bInterfaceClass               = 0xe0, /* Wireless */
97
        .bInterfaceSubClass            = 0x01, /* Radio Frequency */
98
        .bInterfaceProtocol            = 0x01, /* Bluetooth */
99
        .eps = (USBDescEndpoint[]) {
100
            {
101
                .bEndpointAddress      = USB_DIR_OUT | USB_SCO_EP,
102
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
103
                .wMaxPacketSize        = 0,
104
                .bInterval             = 0x01,
105
            },
106
            {
107
                .bEndpointAddress      = USB_DIR_IN | USB_SCO_EP,
108
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
109
                .wMaxPacketSize        = 0,
110
                .bInterval             = 0x01,
111
            },
112
        },
113
    },{
114
        .bInterfaceNumber              = 1,
115
        .bAlternateSetting             = 1,
116
        .bNumEndpoints                 = 2,
117
        .bInterfaceClass               = 0xe0, /* Wireless */
118
        .bInterfaceSubClass            = 0x01, /* Radio Frequency */
119
        .bInterfaceProtocol            = 0x01, /* Bluetooth */
120
        .eps = (USBDescEndpoint[]) {
121
            {
122
                .bEndpointAddress      = USB_DIR_OUT | USB_SCO_EP,
123
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
124
                .wMaxPacketSize        = 0x09,
125
                .bInterval             = 0x01,
126
            },
127
            {
128
                .bEndpointAddress      = USB_DIR_IN | USB_SCO_EP,
129
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
130
                .wMaxPacketSize        = 0x09,
131
                .bInterval             = 0x01,
132
            },
133
        },
134
    },{
135
        .bInterfaceNumber              = 1,
136
        .bAlternateSetting             = 2,
137
        .bNumEndpoints                 = 2,
138
        .bInterfaceClass               = 0xe0, /* Wireless */
139
        .bInterfaceSubClass            = 0x01, /* Radio Frequency */
140
        .bInterfaceProtocol            = 0x01, /* Bluetooth */
141
        .eps = (USBDescEndpoint[]) {
142
            {
143
                .bEndpointAddress      = USB_DIR_OUT | USB_SCO_EP,
144
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
145
                .wMaxPacketSize        = 0x11,
146
                .bInterval             = 0x01,
147
            },
148
            {
149
                .bEndpointAddress      = USB_DIR_IN | USB_SCO_EP,
150
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
151
                .wMaxPacketSize        = 0x11,
152
                .bInterval             = 0x01,
153
            },
154
        },
155
    },{
156
        .bInterfaceNumber              = 1,
157
        .bAlternateSetting             = 3,
158
        .bNumEndpoints                 = 2,
159
        .bInterfaceClass               = 0xe0, /* Wireless */
160
        .bInterfaceSubClass            = 0x01, /* Radio Frequency */
161
        .bInterfaceProtocol            = 0x01, /* Bluetooth */
162
        .eps = (USBDescEndpoint[]) {
163
            {
164
                .bEndpointAddress      = USB_DIR_OUT | USB_SCO_EP,
165
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
166
                .wMaxPacketSize        = 0x19,
167
                .bInterval             = 0x01,
168
            },
169
            {
170
                .bEndpointAddress      = USB_DIR_IN | USB_SCO_EP,
171
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
172
                .wMaxPacketSize        = 0x19,
173
                .bInterval             = 0x01,
174
            },
175
        },
176
    },{
177
        .bInterfaceNumber              = 1,
178
        .bAlternateSetting             = 4,
179
        .bNumEndpoints                 = 2,
180
        .bInterfaceClass               = 0xe0, /* Wireless */
181
        .bInterfaceSubClass            = 0x01, /* Radio Frequency */
182
        .bInterfaceProtocol            = 0x01, /* Bluetooth */
183
        .eps = (USBDescEndpoint[]) {
184
            {
185
                .bEndpointAddress      = USB_DIR_OUT | USB_SCO_EP,
186
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
187
                .wMaxPacketSize        = 0x21,
188
                .bInterval             = 0x01,
189
            },
190
            {
191
                .bEndpointAddress      = USB_DIR_IN | USB_SCO_EP,
192
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
193
                .wMaxPacketSize        = 0x21,
194
                .bInterval             = 0x01,
195
            },
196
        },
197
    },{
198
        .bInterfaceNumber              = 1,
199
        .bAlternateSetting             = 5,
200
        .bNumEndpoints                 = 2,
201
        .bInterfaceClass               = 0xe0, /* Wireless */
202
        .bInterfaceSubClass            = 0x01, /* Radio Frequency */
203
        .bInterfaceProtocol            = 0x01, /* Bluetooth */
204
        .eps = (USBDescEndpoint[]) {
205
            {
206
                .bEndpointAddress      = USB_DIR_OUT | USB_SCO_EP,
207
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
208
                .wMaxPacketSize        = 0x31,
209
                .bInterval             = 0x01,
210
            },
211
            {
212
                .bEndpointAddress      = USB_DIR_IN | USB_SCO_EP,
213
                .bmAttributes          = USB_ENDPOINT_XFER_INT,
214
                .wMaxPacketSize        = 0x31,
215
                .bInterval             = 0x01,
216
            },
217
        },
218
    }
219
};
67 220

  
68
    0x00,	/*  u8  iManufacturer; */
69
    0x00,	/*  u8  iProduct; */
70
    0x00,	/*  u8  iSerialNumber; */
71
    0x01,	/*  u8  bNumConfigurations; */
221
static const USBDescDevice desc_device_bluetooth = {
222
    .bcdUSB                        = 0x0110,
223
    .bDeviceClass                  = 0xe0, /* Wireless */
224
    .bDeviceSubClass               = 0x01, /* Radio Frequency */
225
    .bDeviceProtocol               = 0x01, /* Bluetooth */
226
    .bMaxPacketSize0               = 64,
227
    .bNumConfigurations            = 1,
228
    .confs = (USBDescConfig[]) {
229
        {
230
            .bNumInterfaces        = 2,
231
            .bConfigurationValue   = 1,
232
            .bmAttributes          = 0xc0,
233
            .bMaxPower             = 0,
234
            .nif = ARRAY_SIZE(desc_iface_bluetooth),
235
            .ifs = desc_iface_bluetooth,
236
        },
237
    },
72 238
};
73 239

  
74
static const uint8_t qemu_bt_config_descriptor[] = {
75
    /* one configuration */
76
    0x09,		/*  u8  bLength; */
77
    USB_DT_CONFIG,	/*  u8  bDescriptorType; */
78
    0xb1, 0x00,		/*  u16 wTotalLength; */
79
    0x02,		/*  u8  bNumInterfaces; (2) */
80
    0x01,		/*  u8  bConfigurationValue; */
81
    0x00,		/*  u8  iConfiguration; */
82
    0xc0,		/*  u8  bmAttributes;
83
				     Bit 7: must be set,
84
					 6: Self-powered,
85
					 5: Remote wakeup,
86
					 4..0: resvd */
87
    0x00,		/*  u8  MaxPower; */
88

  
89
    /* USB 1.1:
90
     * USB 2.0, single TT organization (mandatory):
91
     *	one interface, protocol 0
92
     *
93
     * USB 2.0, multiple TT organization (optional):
94
     *	two interfaces, protocols 1 (like single TT)
95
     *	and 2 (multiple TT mode) ... config is
96
     *	sometimes settable
97
     *	NOT IMPLEMENTED
98
     */
99

  
100
    /* interface one */
101
    0x09,		/*  u8  if_bLength; */
102
    USB_DT_INTERFACE,	/*  u8  if_bDescriptorType; */
103
    0x00,		/*  u8  if_bInterfaceNumber; */
104
    0x00,		/*  u8  if_bAlternateSetting; */
105
    0x03,		/*  u8  if_bNumEndpoints; */
106
    0xe0,		/*  u8  if_bInterfaceClass; Wireless */
107
    0x01,		/*  u8  if_bInterfaceSubClass; Radio Frequency */
108
    0x01,		/*  u8  if_bInterfaceProtocol; Bluetooth */
109
    0x00,		/*  u8  if_iInterface; */
110

  
111
    /* endpoint one */
112
    0x07,		/*  u8  ep_bLength; */
113
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
114
    USB_DIR_IN | USB_EVT_EP,	/*  u8  ep_bEndpointAddress; */
115
    0x03,		/*  u8  ep_bmAttributes; Interrupt */
116
    0x10, 0x00,		/*  u16 ep_wMaxPacketSize; */
117
    0x02,		/*  u8  ep_bInterval; */
118

  
119
    /* endpoint two */
120
    0x07,		/*  u8  ep_bLength; */
121
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
122
    USB_DIR_OUT | USB_ACL_EP,	/*  u8  ep_bEndpointAddress; */
123
    0x02,		/*  u8  ep_bmAttributes; Bulk */
124
    0x40, 0x00,		/*  u16 ep_wMaxPacketSize; */
125
    0x0a,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
126

  
127
    /* endpoint three */
128
    0x07,		/*  u8  ep_bLength; */
129
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
130
    USB_DIR_IN | USB_ACL_EP,	/*  u8  ep_bEndpointAddress; */
131
    0x02,		/*  u8  ep_bmAttributes; Bulk */
132
    0x40, 0x00,		/*  u16 ep_wMaxPacketSize; */
133
    0x0a,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
134

  
135
    /* interface two setting one */
136
    0x09,		/*  u8  if_bLength; */
137
    USB_DT_INTERFACE,	/*  u8  if_bDescriptorType; */
138
    0x01,		/*  u8  if_bInterfaceNumber; */
139
    0x00,		/*  u8  if_bAlternateSetting; */
140
    0x02,		/*  u8  if_bNumEndpoints; */
141
    0xe0,		/*  u8  if_bInterfaceClass; Wireless */
142
    0x01,		/*  u8  if_bInterfaceSubClass; Radio Frequency */
143
    0x01,		/*  u8  if_bInterfaceProtocol; Bluetooth */
144
    0x00,		/*  u8  if_iInterface; */
145

  
146
    /* endpoint one */
147
    0x07,		/*  u8  ep_bLength; */
148
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
149
    USB_DIR_OUT | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
150
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
151
    0x00, 0x00,		/*  u16 ep_wMaxPacketSize; */
152
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
153

  
154
    /* endpoint two */
155
    0x07,		/*  u8  ep_bLength; */
156
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
157
    USB_DIR_IN | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
158
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
159
    0x00, 0x00,		/*  u16 ep_wMaxPacketSize; */
160
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
161

  
162
    /* interface two setting two */
163
    0x09,		/*  u8  if_bLength; */
164
    USB_DT_INTERFACE,	/*  u8  if_bDescriptorType; */
165
    0x01,		/*  u8  if_bInterfaceNumber; */
166
    0x01,		/*  u8  if_bAlternateSetting; */
167
    0x02,		/*  u8  if_bNumEndpoints; */
168
    0xe0,		/*  u8  if_bInterfaceClass; Wireless */
169
    0x01,		/*  u8  if_bInterfaceSubClass; Radio Frequency */
170
    0x01,		/*  u8  if_bInterfaceProtocol; Bluetooth */
171
    0x00,		/*  u8  if_iInterface; */
172

  
173
    /* endpoint one */
174
    0x07,		/*  u8  ep_bLength; */
175
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
176
    USB_DIR_OUT | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
177
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
178
    0x09, 0x00,		/*  u16 ep_wMaxPacketSize; */
179
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
180

  
181
    /* endpoint two */
182
    0x07,		/*  u8  ep_bLength; */
183
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
184
    USB_DIR_IN | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
185
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
186
    0x09, 0x00,		/*  u16 ep_wMaxPacketSize; */
187
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
188

  
189
    /* interface two setting three */
190
    0x09,		/*  u8  if_bLength; */
191
    USB_DT_INTERFACE,	/*  u8  if_bDescriptorType; */
192
    0x01,		/*  u8  if_bInterfaceNumber; */
193
    0x02,		/*  u8  if_bAlternateSetting; */
194
    0x02,		/*  u8  if_bNumEndpoints; */
195
    0xe0,		/*  u8  if_bInterfaceClass; Wireless */
196
    0x01,		/*  u8  if_bInterfaceSubClass; Radio Frequency */
197
    0x01,		/*  u8  if_bInterfaceProtocol; Bluetooth */
198
    0x00,		/*  u8  if_iInterface; */
199

  
200
    /* endpoint one */
201
    0x07,		/*  u8  ep_bLength; */
202
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
203
    USB_DIR_OUT | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
204
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
205
    0x11, 0x00,		/*  u16 ep_wMaxPacketSize; */
206
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
207

  
208
    /* endpoint two */
209
    0x07,		/*  u8  ep_bLength; */
210
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
211
    USB_DIR_IN | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
212
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
213
    0x11, 0x00,		/*  u16 ep_wMaxPacketSize; */
214
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
215

  
216
    /* interface two setting four */
217
    0x09,		/*  u8  if_bLength; */
218
    USB_DT_INTERFACE,	/*  u8  if_bDescriptorType; */
219
    0x01,		/*  u8  if_bInterfaceNumber; */
220
    0x03,		/*  u8  if_bAlternateSetting; */
221
    0x02,		/*  u8  if_bNumEndpoints; */
222
    0xe0,		/*  u8  if_bInterfaceClass; Wireless */
223
    0x01,		/*  u8  if_bInterfaceSubClass; Radio Frequency */
224
    0x01,		/*  u8  if_bInterfaceProtocol; Bluetooth */
225
    0x00,		/*  u8  if_iInterface; */
226

  
227
    /* endpoint one */
228
    0x07,		/*  u8  ep_bLength; */
229
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
230
    USB_DIR_OUT | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
231
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
232
    0x19, 0x00,		/*  u16 ep_wMaxPacketSize; */
233
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
234

  
235
    /* endpoint two */
236
    0x07,		/*  u8  ep_bLength; */
237
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
238
    USB_DIR_IN | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
239
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
240
    0x19, 0x00,		/*  u16 ep_wMaxPacketSize; */
241
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
242

  
243
    /* interface two setting five */
244
    0x09,		/*  u8  if_bLength; */
245
    USB_DT_INTERFACE,	/*  u8  if_bDescriptorType; */
246
    0x01,		/*  u8  if_bInterfaceNumber; */
247
    0x04,		/*  u8  if_bAlternateSetting; */
248
    0x02,		/*  u8  if_bNumEndpoints; */
249
    0xe0,		/*  u8  if_bInterfaceClass; Wireless */
250
    0x01,		/*  u8  if_bInterfaceSubClass; Radio Frequency */
251
    0x01,		/*  u8  if_bInterfaceProtocol; Bluetooth */
252
    0x00,		/*  u8  if_iInterface; */
253

  
254
    /* endpoint one */
255
    0x07,		/*  u8  ep_bLength; */
256
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
257
    USB_DIR_OUT | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
258
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
259
    0x21, 0x00,		/*  u16 ep_wMaxPacketSize; */
260
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
261

  
262
    /* endpoint two */
263
    0x07,		/*  u8  ep_bLength; */
264
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
265
    USB_DIR_IN | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
266
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
267
    0x21, 0x00,		/*  u16 ep_wMaxPacketSize; */
268
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
269

  
270
    /* interface two setting six */
271
    0x09,		/*  u8  if_bLength; */
272
    USB_DT_INTERFACE,	/*  u8  if_bDescriptorType; */
273
    0x01,		/*  u8  if_bInterfaceNumber; */
274
    0x05,		/*  u8  if_bAlternateSetting; */
275
    0x02,		/*  u8  if_bNumEndpoints; */
276
    0xe0,		/*  u8  if_bInterfaceClass; Wireless */
277
    0x01,		/*  u8  if_bInterfaceSubClass; Radio Frequency */
278
    0x01,		/*  u8  if_bInterfaceProtocol; Bluetooth */
279
    0x00,		/*  u8  if_iInterface; */
280

  
281
    /* endpoint one */
282
    0x07,		/*  u8  ep_bLength; */
283
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
284
    USB_DIR_OUT | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
285
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
286
    0x31, 0x00,		/*  u16 ep_wMaxPacketSize; */
287
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
288

  
289
    /* endpoint two */
290
    0x07,		/*  u8  ep_bLength; */
291
    USB_DT_ENDPOINT,	/*  u8  ep_bDescriptorType; */
292
    USB_DIR_IN | USB_SCO_EP,	/*  u8  ep_bEndpointAddress; */
293
    0x01,		/*  u8  ep_bmAttributes; Isochronous */
294
    0x31, 0x00,		/*  u16 ep_wMaxPacketSize; */
295
    0x01,		/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
296

  
297
    /* If implemented, the DFU interface descriptor goes here with no
298
     * endpoints or alternative settings.  */
240
static const USBDesc desc_bluetooth = {
241
    .id = {
242
        .idVendor          = 0x0a12,
243
        .idProduct         = 0x0001,
244
        .bcdDevice         = 0x1958,
245
        .iManufacturer     = STR_MANUFACTURER,
246
        .iProduct          = 0,
247
        .iSerialNumber     = STR_SERIALNUMBER,
248
    },
249
    .full = &desc_device_bluetooth,
250
    .str  = desc_strings,
299 251
};
300 252

  
301 253
static void usb_bt_fifo_reset(struct usb_hci_in_fifo_s *fifo)
......
424 376
                int index, int length, uint8_t *data)
425 377
{
426 378
    struct USBBtState *s = (struct USBBtState *) dev->opaque;
427
    int ret = 0;
379
    int ret;
380

  
381
    ret = usb_desc_handle_control(dev, request, value, index, length, data);
382
    if (ret >= 0) {
383
        return ret;
384
    }
428 385

  
386
    ret = 0;
429 387
    switch (request) {
430 388
    case DeviceRequest | USB_REQ_GET_STATUS:
431 389
    case InterfaceRequest | USB_REQ_GET_STATUS:
......
459 417
        dev->addr = value;
460 418
        ret = 0;
461 419
        break;
462
    case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
463
        switch (value >> 8) {
464
        case USB_DT_DEVICE:
465
            ret = sizeof(qemu_bt_dev_descriptor);
466
            memcpy(data, qemu_bt_dev_descriptor, ret);
467
            break;
468
        case USB_DT_CONFIG:
469
            ret = sizeof(qemu_bt_config_descriptor);
470
            memcpy(data, qemu_bt_config_descriptor, ret);
471
            break;
472
        case USB_DT_STRING:
473
            switch(value & 0xff) {
474
            case 0:
475
                /* language ids */
476
                data[0] = 4;
477
                data[1] = 3;
478
                data[2] = 0x09;
479
                data[3] = 0x04;
480
                ret = 4;
481
                break;
482
            default:
483
                goto fail;
484
            }
485
            break;
486
        default:
487
            goto fail;
488
        }
489
        break;
490 420
    case DeviceRequest | USB_REQ_GET_CONFIGURATION:
491
        data[0] = qemu_bt_config_descriptor[0x5];
421
        data[0] = 1;
492 422
        ret = 1;
493 423
        s->config = 0;
494 424
        break;
495 425
    case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
496 426
        ret = 0;
497
        if (value != qemu_bt_config_descriptor[0x5] && value != 0) {
427
        if (value != 1 && value != 0) {
498 428
            printf("%s: Wrong SET_CONFIGURATION request (%i)\n",
499 429
                            __FUNCTION__, value);
500 430
            goto fail;
......
648 578
    .product_desc   = "QEMU BT dongle",
649 579
    .qdev.name      = "usb-bt-dongle",
650 580
    .qdev.size      = sizeof(struct USBBtState),
581
    .usb_desc       = &desc_bluetooth,
651 582
    .init           = usb_bt_initfn,
652 583
    .handle_packet  = usb_generic_handle_packet,
653 584
    .handle_reset   = usb_bt_handle_reset,

Also available in: Unified diff