1 | /* $Id: VUSBUrbTrace.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Virtual USB - URBs.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_DRV_VUSB
|
---|
23 | #include <VBox/vmm/pdm.h>
|
---|
24 | #include <VBox/vmm/vmapi.h>
|
---|
25 | #include <iprt/errcore.h>
|
---|
26 | #include <iprt/alloc.h>
|
---|
27 | #include <VBox/log.h>
|
---|
28 | #include <iprt/time.h>
|
---|
29 | #include <iprt/thread.h>
|
---|
30 | #include <iprt/semaphore.h>
|
---|
31 | #include <iprt/string.h>
|
---|
32 | #include <iprt/assert.h>
|
---|
33 | #include <iprt/asm.h>
|
---|
34 | #include <iprt/env.h>
|
---|
35 | #include "VUSBInternal.h"
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 | #ifdef LOG_ENABLED
|
---|
40 | DECLINLINE(const char *) GetScsiErrCd(uint8_t ScsiErr)
|
---|
41 | {
|
---|
42 | switch (ScsiErr)
|
---|
43 | {
|
---|
44 | case 0: return "?";
|
---|
45 | }
|
---|
46 | return "?";
|
---|
47 | }
|
---|
48 |
|
---|
49 | DECLINLINE(const char *) GetScsiKCQ(uint8_t Key, uint8_t ASC, uint8_t ASCQ)
|
---|
50 | {
|
---|
51 | switch (Key)
|
---|
52 | {
|
---|
53 | case 0:
|
---|
54 | switch (RT_MAKE_U16(ASC, ASCQ))
|
---|
55 | {
|
---|
56 | case RT_MAKE_U16(0x00, 0x00): return "No error";
|
---|
57 | }
|
---|
58 | break;
|
---|
59 |
|
---|
60 | case 1:
|
---|
61 | return "Soft Error";
|
---|
62 |
|
---|
63 | case 2:
|
---|
64 | return "Not Ready";
|
---|
65 |
|
---|
66 | case 3:
|
---|
67 | return "Medium Error";
|
---|
68 |
|
---|
69 | case 4:
|
---|
70 | return "Hard Error";
|
---|
71 |
|
---|
72 | case 5:
|
---|
73 | return "Illegal Request";
|
---|
74 |
|
---|
75 | case 6:
|
---|
76 | return "Unit Attention";
|
---|
77 |
|
---|
78 | case 7:
|
---|
79 | return "Write Protected";
|
---|
80 |
|
---|
81 | case 0xb:
|
---|
82 | return "Aborted Command";
|
---|
83 | }
|
---|
84 | return "?";
|
---|
85 | }
|
---|
86 |
|
---|
87 | DECLHIDDEN(const char *) vusbUrbStatusName(VUSBSTATUS enmStatus)
|
---|
88 | {
|
---|
89 | /** Strings for the URB statuses. */
|
---|
90 | static const char * const s_apszNames[] =
|
---|
91 | {
|
---|
92 | "OK",
|
---|
93 | "STALL",
|
---|
94 | "ERR_DNR",
|
---|
95 | "ERR_CRC",
|
---|
96 | "DATA_UNDERRUN",
|
---|
97 | "DATA_OVERRUN",
|
---|
98 | "NOT_ACCESSED",
|
---|
99 | "7", "8", "9", "10", "11", "12", "13", "14", "15"
|
---|
100 | };
|
---|
101 |
|
---|
102 | return enmStatus < (int)RT_ELEMENTS(s_apszNames)
|
---|
103 | ? s_apszNames[enmStatus]
|
---|
104 | : enmStatus == VUSBSTATUS_INVALID
|
---|
105 | ? "INVALID"
|
---|
106 | : "??";
|
---|
107 | }
|
---|
108 |
|
---|
109 | DECLHIDDEN(const char *) vusbUrbDirName(VUSBDIRECTION enmDir)
|
---|
110 | {
|
---|
111 | /** Strings for the URB directions. */
|
---|
112 | static const char * const s_apszNames[] =
|
---|
113 | {
|
---|
114 | "setup",
|
---|
115 | "in",
|
---|
116 | "out"
|
---|
117 | };
|
---|
118 |
|
---|
119 | return enmDir < (int)RT_ELEMENTS(s_apszNames)
|
---|
120 | ? s_apszNames[enmDir]
|
---|
121 | : "??";
|
---|
122 | }
|
---|
123 |
|
---|
124 | DECLHIDDEN(const char *) vusbUrbTypeName(VUSBXFERTYPE enmType)
|
---|
125 | {
|
---|
126 | /** Strings for the URB types. */
|
---|
127 | static const char * const s_apszName[] =
|
---|
128 | {
|
---|
129 | "control-part",
|
---|
130 | "isochronous",
|
---|
131 | "bulk",
|
---|
132 | "interrupt",
|
---|
133 | "control"
|
---|
134 | };
|
---|
135 |
|
---|
136 | return enmType < (int)RT_ELEMENTS(s_apszName)
|
---|
137 | ? s_apszName[enmType]
|
---|
138 | : "??";
|
---|
139 | }
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * Logs an URB.
|
---|
143 | *
|
---|
144 | * Note that pUrb->pVUsb->pDev and pUrb->pVUsb->pDev->pUsbIns can all be NULL.
|
---|
145 | */
|
---|
146 | DECLHIDDEN(void) vusbUrbTrace(PVUSBURB pUrb, const char *pszMsg, bool fComplete)
|
---|
147 | {
|
---|
148 | PVUSBDEV pDev = pUrb->pVUsb ? pUrb->pVUsb->pDev : NULL; /* Can be NULL when called from usbProxyConstruct and friends. */
|
---|
149 | PVUSBPIPE pPipe = &pDev->aPipes[pUrb->EndPt];
|
---|
150 | const uint8_t *pbData = pUrb->abData;
|
---|
151 | uint32_t cbData = pUrb->cbData;
|
---|
152 | PCVUSBSETUP pSetup = NULL;
|
---|
153 | bool fDescriptors = false;
|
---|
154 | static size_t s_cchMaxMsg = 10;
|
---|
155 | size_t cchMsg = strlen(pszMsg);
|
---|
156 | if (cchMsg > s_cchMaxMsg)
|
---|
157 | s_cchMaxMsg = cchMsg;
|
---|
158 |
|
---|
159 | Log(("%s: %*s: pDev=%p[%s] rc=%s a=%i e=%u d=%s t=%s cb=%#x(%d) ts=%RU64 (%RU64 ns ago) %s\n",
|
---|
160 | pUrb->pszDesc, s_cchMaxMsg, pszMsg,
|
---|
161 | pDev,
|
---|
162 | pUrb->pVUsb && pUrb->pVUsb->pDev ? pUrb->pVUsb->pDev->pUsbIns->pszName : "",
|
---|
163 | vusbUrbStatusName(pUrb->enmStatus),
|
---|
164 | pDev ? pDev->u8Address : -1,
|
---|
165 | pUrb->EndPt,
|
---|
166 | vusbUrbDirName(pUrb->enmDir),
|
---|
167 | vusbUrbTypeName(pUrb->enmType),
|
---|
168 | pUrb->cbData,
|
---|
169 | pUrb->cbData,
|
---|
170 | pUrb->pVUsb ? pUrb->pVUsb->u64SubmitTS : 0,
|
---|
171 | pUrb->pVUsb ? RTTimeNanoTS() - pUrb->pVUsb->u64SubmitTS : 0,
|
---|
172 | pUrb->fShortNotOk ? "ShortNotOk" : "ShortOk"));
|
---|
173 |
|
---|
174 | #ifndef DEBUG_bird
|
---|
175 | if ( pUrb->enmType == VUSBXFERTYPE_CTRL
|
---|
176 | && pUrb->enmStatus == VUSBSTATUS_OK)
|
---|
177 | return;
|
---|
178 | #endif
|
---|
179 |
|
---|
180 | if ( pUrb->enmType == VUSBXFERTYPE_MSG
|
---|
181 | || ( pUrb->enmDir == VUSBDIRECTION_SETUP
|
---|
182 | && pUrb->enmType == VUSBXFERTYPE_CTRL
|
---|
183 | && cbData))
|
---|
184 | {
|
---|
185 | static const char * const s_apszReqDirs[] = {"host2dev", "dev2host"};
|
---|
186 | static const char * const s_apszReqTypes[] = {"std", "class", "vendor", "reserved"};
|
---|
187 | static const char * const s_apszReqRecipients[] = {"dev", "if", "endpoint", "other"};
|
---|
188 | static const char * const s_apszRequests[] =
|
---|
189 | {
|
---|
190 | "GET_STATUS", "CLEAR_FEATURE", "2?", "SET_FEATURE",
|
---|
191 | "4?", "SET_ADDRESS", "GET_DESCRIPTOR", "SET_DESCRIPTOR",
|
---|
192 | "GET_CONFIGURATION", "SET_CONFIGURATION", "GET_INTERFACE", "SET_INTERFACE",
|
---|
193 | "SYNCH_FRAME"
|
---|
194 | };
|
---|
195 | pSetup = (PVUSBSETUP)pUrb->abData;
|
---|
196 | pbData += sizeof(*pSetup);
|
---|
197 | cbData -= sizeof(*pSetup);
|
---|
198 |
|
---|
199 | Log(("%s: %*s: CTRL: bmRequestType=0x%.2x (%s %s %s) bRequest=0x%.2x (%s) wValue=0x%.4x wIndex=0x%.4x wLength=0x%.4x\n",
|
---|
200 | pUrb->pszDesc, s_cchMaxMsg, pszMsg,
|
---|
201 | pSetup->bmRequestType, s_apszReqDirs[pSetup->bmRequestType >> 7], s_apszReqTypes[(pSetup->bmRequestType >> 5) & 0x3],
|
---|
202 | (unsigned)(pSetup->bmRequestType & 0xf) < RT_ELEMENTS(s_apszReqRecipients) ? s_apszReqRecipients[pSetup->bmRequestType & 0xf] : "??",
|
---|
203 | pSetup->bRequest, pSetup->bRequest < RT_ELEMENTS(s_apszRequests) ? s_apszRequests[pSetup->bRequest] : "??",
|
---|
204 | pSetup->wValue, pSetup->wIndex, pSetup->wLength));
|
---|
205 |
|
---|
206 | if ( pSetup->bRequest == VUSB_REQ_GET_DESCRIPTOR
|
---|
207 | && fComplete
|
---|
208 | && pUrb->enmStatus == VUSBSTATUS_OK
|
---|
209 | && ((pSetup->bmRequestType >> 5) & 0x3) < 2 /* vendor */)
|
---|
210 | fDescriptors = true;
|
---|
211 | }
|
---|
212 | else if ( fComplete
|
---|
213 | && pUrb->enmDir == VUSBDIRECTION_IN
|
---|
214 | && pUrb->enmType == VUSBXFERTYPE_CTRL
|
---|
215 | && pUrb->enmStatus == VUSBSTATUS_OK
|
---|
216 | && pPipe->pCtrl
|
---|
217 | && pPipe->pCtrl->enmStage == CTLSTAGE_DATA
|
---|
218 | && cbData > 0)
|
---|
219 | {
|
---|
220 | pSetup = pPipe->pCtrl->pMsg;
|
---|
221 | if (pSetup->bRequest == VUSB_REQ_GET_DESCRIPTOR)
|
---|
222 | fDescriptors = true;
|
---|
223 | }
|
---|
224 |
|
---|
225 | /*
|
---|
226 | * Dump descriptors.
|
---|
227 | */
|
---|
228 | if (fDescriptors)
|
---|
229 | {
|
---|
230 | const uint8_t *pb = pbData;
|
---|
231 | const uint8_t *pbEnd = pbData + cbData;
|
---|
232 | while (pb + 1 < pbEnd)
|
---|
233 | {
|
---|
234 | const unsigned cbLeft = pbEnd - pb;
|
---|
235 | const unsigned cbLength = *pb;
|
---|
236 | unsigned cb = cbLength;
|
---|
237 | uint8_t bDescriptorType = pb[1];
|
---|
238 |
|
---|
239 | /* length out of bounds? */
|
---|
240 | if (cbLength > cbLeft)
|
---|
241 | {
|
---|
242 | cb = cbLeft;
|
---|
243 | if (cbLength != 0xff) /* ignore this */
|
---|
244 | Log(("URB: %*s: DESC: warning descriptor length goes beyond the end of the URB! cbLength=%d cbLeft=%d\n",
|
---|
245 | s_cchMaxMsg, pszMsg, cbLength, cbLeft));
|
---|
246 | }
|
---|
247 |
|
---|
248 | if (cb >= 2)
|
---|
249 | {
|
---|
250 | Log(("URB: %*s: DESC: %04x: %25s = %#04x (%d)\n"
|
---|
251 | "URB: %*s: %04x: %25s = %#04x (",
|
---|
252 | s_cchMaxMsg, pszMsg, pb - pbData, "bLength", cbLength, cbLength,
|
---|
253 | s_cchMaxMsg, pszMsg, pb - pbData + 1, "bDescriptorType", bDescriptorType));
|
---|
254 |
|
---|
255 | #pragma pack(1)
|
---|
256 | #define BYTE_FIELD(strct, memb) \
|
---|
257 | if ((unsigned)RT_OFFSETOF(strct, memb) < cb) \
|
---|
258 | Log(("URB: %*s: %04x: %25s = %#04x\n", s_cchMaxMsg, pszMsg, \
|
---|
259 | pb + RT_OFFSETOF(strct, memb) - pbData, #memb, pb[RT_OFFSETOF(strct, memb)]))
|
---|
260 | #define BYTE_FIELD_START(strct, memb) do { \
|
---|
261 | if ((unsigned)RT_OFFSETOF(strct, memb) < cb) \
|
---|
262 | { \
|
---|
263 | Log(("URB: %*s: %04x: %25s = %#04x", s_cchMaxMsg, pszMsg, \
|
---|
264 | pb + RT_OFFSETOF(strct, memb) - pbData, #memb, pb[RT_OFFSETOF(strct, memb)]))
|
---|
265 | #define BYTE_FIELD_END(strct, memb) \
|
---|
266 | Log(("\n")); \
|
---|
267 | } } while (0)
|
---|
268 | #define WORD_FIELD(strct, memb) \
|
---|
269 | if ((unsigned)RT_OFFSETOF(strct, memb) + 1 < cb) \
|
---|
270 | Log(("URB: %*s: %04x: %25s = %#06x\n", s_cchMaxMsg, pszMsg, \
|
---|
271 | pb + RT_OFFSETOF(strct, memb) - pbData, #memb, *(uint16_t *)&pb[RT_OFFSETOF(strct, memb)]))
|
---|
272 | #define BCD_FIELD(strct, memb) \
|
---|
273 | if ((unsigned)RT_OFFSETOF(strct, memb) + 1 < cb) \
|
---|
274 | Log(("URB: %*s: %04x: %25s = %#06x (%02x.%02x)\n", s_cchMaxMsg, pszMsg, \
|
---|
275 | pb + RT_OFFSETOF(strct, memb) - pbData, #memb, *(uint16_t *)&pb[RT_OFFSETOF(strct, memb)], \
|
---|
276 | pb[RT_OFFSETOF(strct, memb) + 1], pb[RT_OFFSETOF(strct, memb)]))
|
---|
277 | #define SIZE_CHECK(strct) \
|
---|
278 | if (cb > sizeof(strct)) \
|
---|
279 | Log(("URB: %*s: %04x: WARNING %d extra byte(s) %.*Rhxs\n", s_cchMaxMsg, pszMsg, \
|
---|
280 | pb + sizeof(strct) - pbData, cb - sizeof(strct), cb - sizeof(strct), pb + sizeof(strct))); \
|
---|
281 | else if (cb < sizeof(strct)) \
|
---|
282 | Log(("URB: %*s: %04x: WARNING %d missing byte(s)! Expected size %d.\n", s_cchMaxMsg, pszMsg, \
|
---|
283 | pb + cb - pbData, sizeof(strct) - cb, sizeof(strct)))
|
---|
284 |
|
---|
285 | /* on type */
|
---|
286 | switch (bDescriptorType)
|
---|
287 | {
|
---|
288 | case VUSB_DT_DEVICE:
|
---|
289 | {
|
---|
290 | struct dev_desc
|
---|
291 | {
|
---|
292 | uint8_t bLength;
|
---|
293 | uint8_t bDescriptorType;
|
---|
294 | uint16_t bcdUSB;
|
---|
295 | uint8_t bDeviceClass;
|
---|
296 | uint8_t bDeviceSubClass;
|
---|
297 | uint8_t bDeviceProtocol;
|
---|
298 | uint8_t bMaxPacketSize0;
|
---|
299 | uint16_t idVendor;
|
---|
300 | uint16_t idProduct;
|
---|
301 | uint16_t bcdDevice;
|
---|
302 | uint8_t iManufacturer;
|
---|
303 | uint8_t iProduct;
|
---|
304 | uint8_t iSerialNumber;
|
---|
305 | uint8_t bNumConfigurations;
|
---|
306 | } *pDesc = (struct dev_desc *)pb; NOREF(pDesc);
|
---|
307 | Log(("DEV)\n"));
|
---|
308 | BCD_FIELD( struct dev_desc, bcdUSB);
|
---|
309 | BYTE_FIELD(struct dev_desc, bDeviceClass);
|
---|
310 | BYTE_FIELD(struct dev_desc, bDeviceSubClass);
|
---|
311 | BYTE_FIELD(struct dev_desc, bDeviceProtocol);
|
---|
312 | BYTE_FIELD(struct dev_desc, bMaxPacketSize0);
|
---|
313 | WORD_FIELD(struct dev_desc, idVendor);
|
---|
314 | WORD_FIELD(struct dev_desc, idProduct);
|
---|
315 | BCD_FIELD( struct dev_desc, bcdDevice);
|
---|
316 | BYTE_FIELD(struct dev_desc, iManufacturer);
|
---|
317 | BYTE_FIELD(struct dev_desc, iProduct);
|
---|
318 | BYTE_FIELD(struct dev_desc, iSerialNumber);
|
---|
319 | BYTE_FIELD(struct dev_desc, bNumConfigurations);
|
---|
320 | SIZE_CHECK(struct dev_desc);
|
---|
321 | break;
|
---|
322 | }
|
---|
323 |
|
---|
324 | case VUSB_DT_CONFIG:
|
---|
325 | {
|
---|
326 | struct cfg_desc
|
---|
327 | {
|
---|
328 | uint8_t bLength;
|
---|
329 | uint8_t bDescriptorType;
|
---|
330 | uint16_t wTotalLength;
|
---|
331 | uint8_t bNumInterfaces;
|
---|
332 | uint8_t bConfigurationValue;
|
---|
333 | uint8_t iConfiguration;
|
---|
334 | uint8_t bmAttributes;
|
---|
335 | uint8_t MaxPower;
|
---|
336 | } *pDesc = (struct cfg_desc *)pb; NOREF(pDesc);
|
---|
337 | Log(("CFG)\n"));
|
---|
338 | WORD_FIELD(struct cfg_desc, wTotalLength);
|
---|
339 | BYTE_FIELD(struct cfg_desc, bNumInterfaces);
|
---|
340 | BYTE_FIELD(struct cfg_desc, bConfigurationValue);
|
---|
341 | BYTE_FIELD(struct cfg_desc, iConfiguration);
|
---|
342 | BYTE_FIELD_START(struct cfg_desc, bmAttributes);
|
---|
343 | static const char * const s_apszTransType[4] = { "Control", "Isochronous", "Bulk", "Interrupt" };
|
---|
344 | static const char * const s_apszSyncType[4] = { "NoSync", "Asynchronous", "Adaptive", "Synchronous" };
|
---|
345 | static const char * const s_apszUsageType[4] = { "Data ep", "Feedback ep.", "Implicit feedback Data ep.", "Reserved" };
|
---|
346 | Log((" %s - %s - %s", s_apszTransType[(pDesc->bmAttributes & 0x3)],
|
---|
347 | s_apszSyncType[((pDesc->bmAttributes >> 2) & 0x3)], s_apszUsageType[((pDesc->bmAttributes >> 4) & 0x3)]));
|
---|
348 | BYTE_FIELD_END(struct cfg_desc, bmAttributes);
|
---|
349 | BYTE_FIELD(struct cfg_desc, MaxPower);
|
---|
350 | SIZE_CHECK(struct cfg_desc);
|
---|
351 | break;
|
---|
352 | }
|
---|
353 |
|
---|
354 | case VUSB_DT_STRING:
|
---|
355 | if (!pSetup->wIndex)
|
---|
356 | {
|
---|
357 | /* langid array */
|
---|
358 | uint16_t *pu16 = (uint16_t *)pb + 1;
|
---|
359 | Log(("LANGIDs)\n"));
|
---|
360 | while ((uintptr_t)pu16 + 2 - (uintptr_t)pb <= cb)
|
---|
361 | {
|
---|
362 | Log(("URB: %*s: %04x: wLANGID[%#x] = %#06x\n",
|
---|
363 | s_cchMaxMsg, pszMsg, (uint8_t *)pu16 - pbData, pu16 - (uint16_t *)pb, *pu16));
|
---|
364 | pu16++;
|
---|
365 | }
|
---|
366 | if (cb & 1)
|
---|
367 | Log(("URB: %*s: %04x: WARNING descriptor size is odd! extra byte: %02\n",
|
---|
368 | s_cchMaxMsg, pszMsg, (uint8_t *)pu16 - pbData, *(uint8_t *)pu16));
|
---|
369 | }
|
---|
370 | else
|
---|
371 | {
|
---|
372 | /** a string. */
|
---|
373 | Log(("STRING)\n"));
|
---|
374 | if (cb > 2)
|
---|
375 | Log(("URB: %*s: %04x: Length=%d String=%.*ls\n",
|
---|
376 | s_cchMaxMsg, pszMsg, pb - pbData, cb - 2, cb / 2 - 1, pb + 2));
|
---|
377 | else
|
---|
378 | Log(("URB: %*s: %04x: Length=0!\n", s_cchMaxMsg, pszMsg, pb - pbData));
|
---|
379 | }
|
---|
380 | break;
|
---|
381 |
|
---|
382 | case VUSB_DT_INTERFACE:
|
---|
383 | {
|
---|
384 | struct if_desc
|
---|
385 | {
|
---|
386 | uint8_t bLength;
|
---|
387 | uint8_t bDescriptorType;
|
---|
388 | uint8_t bInterfaceNumber;
|
---|
389 | uint8_t bAlternateSetting;
|
---|
390 | uint8_t bNumEndpoints;
|
---|
391 | uint8_t bInterfaceClass;
|
---|
392 | uint8_t bInterfaceSubClass;
|
---|
393 | uint8_t bInterfaceProtocol;
|
---|
394 | uint8_t iInterface;
|
---|
395 | } *pDesc = (struct if_desc *)pb; NOREF(pDesc);
|
---|
396 | Log(("IF)\n"));
|
---|
397 | BYTE_FIELD(struct if_desc, bInterfaceNumber);
|
---|
398 | BYTE_FIELD(struct if_desc, bAlternateSetting);
|
---|
399 | BYTE_FIELD(struct if_desc, bNumEndpoints);
|
---|
400 | BYTE_FIELD(struct if_desc, bInterfaceClass);
|
---|
401 | BYTE_FIELD(struct if_desc, bInterfaceSubClass);
|
---|
402 | BYTE_FIELD(struct if_desc, bInterfaceProtocol);
|
---|
403 | BYTE_FIELD(struct if_desc, iInterface);
|
---|
404 | SIZE_CHECK(struct if_desc);
|
---|
405 | break;
|
---|
406 | }
|
---|
407 |
|
---|
408 | case VUSB_DT_ENDPOINT:
|
---|
409 | {
|
---|
410 | struct ep_desc
|
---|
411 | {
|
---|
412 | uint8_t bLength;
|
---|
413 | uint8_t bDescriptorType;
|
---|
414 | uint8_t bEndpointAddress;
|
---|
415 | uint8_t bmAttributes;
|
---|
416 | uint16_t wMaxPacketSize;
|
---|
417 | uint8_t bInterval;
|
---|
418 | } *pDesc = (struct ep_desc *)pb; NOREF(pDesc);
|
---|
419 | Log(("EP)\n"));
|
---|
420 | BYTE_FIELD(struct ep_desc, bEndpointAddress);
|
---|
421 | BYTE_FIELD(struct ep_desc, bmAttributes);
|
---|
422 | WORD_FIELD(struct ep_desc, wMaxPacketSize);
|
---|
423 | BYTE_FIELD(struct ep_desc, bInterval);
|
---|
424 | SIZE_CHECK(struct ep_desc);
|
---|
425 | break;
|
---|
426 | }
|
---|
427 |
|
---|
428 | case VUSB_DT_DEVICE_QUALIFIER:
|
---|
429 | {
|
---|
430 | struct dq_desc
|
---|
431 | {
|
---|
432 | uint8_t bLength;
|
---|
433 | uint8_t bDescriptorType;
|
---|
434 | uint16_t bcdUSB;
|
---|
435 | uint8_t bDeviceClass;
|
---|
436 | uint8_t bDeviceSubClass;
|
---|
437 | uint8_t bDeviceProtocol;
|
---|
438 | uint8_t bMaxPacketSize0;
|
---|
439 | uint8_t bNumConfigurations;
|
---|
440 | uint8_t bReserved;
|
---|
441 | } *pDQDesc = (struct dq_desc *)pb; NOREF(pDQDesc);
|
---|
442 | Log(("DEVQ)\n"));
|
---|
443 | BCD_FIELD( struct dq_desc, bcdUSB);
|
---|
444 | BYTE_FIELD(struct dq_desc, bDeviceClass);
|
---|
445 | BYTE_FIELD(struct dq_desc, bDeviceSubClass);
|
---|
446 | BYTE_FIELD(struct dq_desc, bDeviceProtocol);
|
---|
447 | BYTE_FIELD(struct dq_desc, bMaxPacketSize0);
|
---|
448 | BYTE_FIELD(struct dq_desc, bNumConfigurations);
|
---|
449 | BYTE_FIELD(struct dq_desc, bReserved);
|
---|
450 | SIZE_CHECK(struct dq_desc);
|
---|
451 | break;
|
---|
452 | }
|
---|
453 |
|
---|
454 | case VUSB_DT_OTHER_SPEED_CFG:
|
---|
455 | {
|
---|
456 | struct oth_cfg_desc
|
---|
457 | {
|
---|
458 | uint8_t bLength;
|
---|
459 | uint8_t bDescriptorType;
|
---|
460 | uint16_t wTotalLength;
|
---|
461 | uint8_t bNumInterfaces;
|
---|
462 | uint8_t bConfigurationValue;
|
---|
463 | uint8_t iConfiguration;
|
---|
464 | uint8_t bmAttributes;
|
---|
465 | uint8_t MaxPower;
|
---|
466 | } *pDesc = (struct oth_cfg_desc *)pb; NOREF(pDesc);
|
---|
467 | Log(("OCFG)\n"));
|
---|
468 | WORD_FIELD(struct oth_cfg_desc, wTotalLength);
|
---|
469 | BYTE_FIELD(struct oth_cfg_desc, bNumInterfaces);
|
---|
470 | BYTE_FIELD(struct oth_cfg_desc, bConfigurationValue);
|
---|
471 | BYTE_FIELD(struct oth_cfg_desc, iConfiguration);
|
---|
472 | BYTE_FIELD_START(struct oth_cfg_desc, bmAttributes);
|
---|
473 | static const char * const s_apszTransType[4] = { "Control", "Isochronous", "Bulk", "Interrupt" };
|
---|
474 | static const char * const s_apszSyncType[4] = { "NoSync", "Asynchronous", "Adaptive", "Synchronous" };
|
---|
475 | static const char * const s_apszUsageType[4] = { "Data ep", "Feedback ep.", "Implicit feedback Data ep.", "Reserved" };
|
---|
476 | Log((" %s - %s - %s", s_apszTransType[(pDesc->bmAttributes & 0x3)],
|
---|
477 | s_apszSyncType[((pDesc->bmAttributes >> 2) & 0x3)], s_apszUsageType[((pDesc->bmAttributes >> 4) & 0x3)]));
|
---|
478 | BYTE_FIELD_END(struct oth_cfg_desc, bmAttributes);
|
---|
479 | BYTE_FIELD(struct oth_cfg_desc, MaxPower);
|
---|
480 | SIZE_CHECK(struct oth_cfg_desc);
|
---|
481 | break;
|
---|
482 | }
|
---|
483 |
|
---|
484 | case 0x21:
|
---|
485 | {
|
---|
486 | struct hid_desc
|
---|
487 | {
|
---|
488 | uint8_t bLength;
|
---|
489 | uint8_t bDescriptorType;
|
---|
490 | uint16_t bcdHid;
|
---|
491 | uint8_t bCountry;
|
---|
492 | uint8_t bNumDescriptors;
|
---|
493 | uint8_t bReportType;
|
---|
494 | uint16_t wReportLength;
|
---|
495 | } *pDesc = (struct hid_desc *)pb; NOREF(pDesc);
|
---|
496 | Log(("EP)\n"));
|
---|
497 | BCD_FIELD( struct hid_desc, bcdHid);
|
---|
498 | BYTE_FIELD(struct hid_desc, bCountry);
|
---|
499 | BYTE_FIELD(struct hid_desc, bNumDescriptors);
|
---|
500 | BYTE_FIELD(struct hid_desc, bReportType);
|
---|
501 | WORD_FIELD(struct hid_desc, wReportLength);
|
---|
502 | SIZE_CHECK(struct hid_desc);
|
---|
503 | break;
|
---|
504 | }
|
---|
505 |
|
---|
506 | case 0xff:
|
---|
507 | Log(("UNKNOWN-ignore)\n"));
|
---|
508 | break;
|
---|
509 |
|
---|
510 | default:
|
---|
511 | Log(("UNKNOWN)!!!\n"));
|
---|
512 | break;
|
---|
513 | }
|
---|
514 |
|
---|
515 | #undef BYTE_FIELD
|
---|
516 | #undef WORD_FIELD
|
---|
517 | #undef BCD_FIELD
|
---|
518 | #undef SIZE_CHECK
|
---|
519 | #pragma pack()
|
---|
520 | }
|
---|
521 | else
|
---|
522 | {
|
---|
523 | Log(("URB: %*s: DESC: %04x: bLength=%d bDescriptorType=%d - invalid length\n",
|
---|
524 | s_cchMaxMsg, pszMsg, pb - pbData, cb, bDescriptorType));
|
---|
525 | break;
|
---|
526 | }
|
---|
527 |
|
---|
528 | /* next */
|
---|
529 | pb += cb;
|
---|
530 | }
|
---|
531 | }
|
---|
532 |
|
---|
533 | /*
|
---|
534 | * SCSI
|
---|
535 | */
|
---|
536 | if ( pUrb->enmType == VUSBXFERTYPE_BULK
|
---|
537 | && pUrb->enmDir == VUSBDIRECTION_OUT
|
---|
538 | && pUrb->cbData >= 12
|
---|
539 | && !memcmp(pUrb->abData, "USBC", 4))
|
---|
540 | {
|
---|
541 | const struct usbc
|
---|
542 | {
|
---|
543 | uint32_t Signature;
|
---|
544 | uint32_t Tag;
|
---|
545 | uint32_t DataTransferLength;
|
---|
546 | uint8_t Flags;
|
---|
547 | uint8_t Lun;
|
---|
548 | uint8_t Length;
|
---|
549 | uint8_t CDB[13];
|
---|
550 | } *pUsbC = (struct usbc *)pUrb->abData;
|
---|
551 | Log(("URB: %*s: SCSI: Tag=%#x DataTransferLength=%#x Flags=%#x Lun=%#x Length=%#x CDB=%.*Rhxs\n",
|
---|
552 | s_cchMaxMsg, pszMsg, pUsbC->Tag, pUsbC->DataTransferLength, pUsbC->Flags, pUsbC->Lun,
|
---|
553 | pUsbC->Length, pUsbC->Length, pUsbC->CDB));
|
---|
554 | const uint8_t *pb = &pUsbC->CDB[0];
|
---|
555 | switch (pb[0])
|
---|
556 | {
|
---|
557 | case 0x00: /* test unit read */
|
---|
558 | Log(("URB: %*s: SCSI: TEST_UNIT_READY LUN=%d Ctrl=%#RX8\n",
|
---|
559 | s_cchMaxMsg, pszMsg, pb[1] >> 5, pb[5]));
|
---|
560 | break;
|
---|
561 | case 0x03: /* Request Sense command */
|
---|
562 | Log(("URB: %*s: SCSI: REQUEST_SENSE LUN=%d AlcLen=%#RX16 Ctrl=%#RX8\n",
|
---|
563 | s_cchMaxMsg, pszMsg, pb[1] >> 5, pb[4], pb[5]));
|
---|
564 | break;
|
---|
565 | case 0x12: /* Inquiry command. */
|
---|
566 | Log(("URB: %*s: SCSI: INQUIRY EVPD=%d LUN=%d PgCd=%#RX8 AlcLen=%#RX8 Ctrl=%#RX8\n",
|
---|
567 | s_cchMaxMsg, pszMsg, pb[1] & 1, pb[1] >> 5, pb[2], pb[4], pb[5]));
|
---|
568 | break;
|
---|
569 | case 0x1a: /* Mode Sense(6) command */
|
---|
570 | Log(("URB: %*s: SCSI: MODE_SENSE6 LUN=%d DBD=%d PC=%d PgCd=%#RX8 AlcLen=%#RX8 Ctrl=%#RX8\n",
|
---|
571 | s_cchMaxMsg, pszMsg, pb[1] >> 5, !!(pb[1] & RT_BIT(3)), pb[2] >> 6, pb[2] & 0x3f, pb[4], pb[5]));
|
---|
572 | break;
|
---|
573 | case 0x5a:
|
---|
574 | Log(("URB: %*s: SCSI: MODE_SENSE10 LUN=%d DBD=%d PC=%d PgCd=%#RX8 AlcLen=%#RX16 Ctrl=%#RX8\n",
|
---|
575 | s_cchMaxMsg, pszMsg, pb[1] >> 5, !!(pb[1] & RT_BIT(3)), pb[2] >> 6, pb[2] & 0x3f,
|
---|
576 | RT_MAKE_U16(pb[8], pb[7]), pb[9]));
|
---|
577 | break;
|
---|
578 | case 0x25: /* Read Capacity(6) command. */
|
---|
579 | Log(("URB: %*s: SCSI: READ_CAPACITY\n",
|
---|
580 | s_cchMaxMsg, pszMsg));
|
---|
581 | break;
|
---|
582 | case 0x28: /* Read(10) command. */
|
---|
583 | Log(("URB: %*s: SCSI: READ10 RelAdr=%d FUA=%d DPO=%d LUN=%d LBA=%#RX32 Len=%#RX16 Ctrl=%#RX8\n",
|
---|
584 | s_cchMaxMsg, pszMsg,
|
---|
585 | pb[1] & 1, !!(pb[1] & RT_BIT(3)), !!(pb[1] & RT_BIT(4)), pb[1] >> 5,
|
---|
586 | RT_MAKE_U32_FROM_U8(pb[5], pb[4], pb[3], pb[2]),
|
---|
587 | RT_MAKE_U16(pb[8], pb[7]), pb[9]));
|
---|
588 | break;
|
---|
589 | case 0xa8: /* Read(12) command. */
|
---|
590 | Log(("URB: %*s: SCSI: READ12 RelAdr=%d FUA=%d DPO=%d LUN=%d LBA=%#RX32 Len=%#RX32 Ctrl=%#RX8\n",
|
---|
591 | s_cchMaxMsg, pszMsg,
|
---|
592 | pb[1] & 1, !!(pb[1] & RT_BIT(3)), !!(pb[1] & RT_BIT(4)), pb[1] >> 5,
|
---|
593 | RT_MAKE_U32_FROM_U8(pb[5], pb[4], pb[3], pb[2]),
|
---|
594 | RT_MAKE_U32_FROM_U8(pb[9], pb[8], pb[7], pb[6]),
|
---|
595 | pb[11]));
|
---|
596 | break;
|
---|
597 | case 0x3e: /* Read Long command. */
|
---|
598 | Log(("URB: %*s: SCSI: READ LONG RelAdr=%d Correct=%d LUN=%d LBA=%#RX16 ByteLen=%#RX16 Ctrl=%#RX8\n",
|
---|
599 | s_cchMaxMsg, pszMsg,
|
---|
600 | pb[1] & 1, !!(pb[1] & RT_BIT(1)), pb[1] >> 5,
|
---|
601 | RT_MAKE_U16(pb[3], pb[2]), RT_MAKE_U16(pb[6], pb[5]),
|
---|
602 | pb[11]));
|
---|
603 | break;
|
---|
604 | case 0x2a: /* Write(10) command. */
|
---|
605 | Log(("URB: %*s: SCSI: WRITE10 RelAdr=%d EBP=%d FUA=%d DPO=%d LUN=%d LBA=%#RX32 Len=%#RX16 Ctrl=%#RX8\n",
|
---|
606 | s_cchMaxMsg, pszMsg,
|
---|
607 | pb[1] & 1, !!(pb[1] & RT_BIT(2)), !!(pb[1] & RT_BIT(3)),
|
---|
608 | !!(pb[1] & RT_BIT(4)), pb[1] >> 5,
|
---|
609 | RT_MAKE_U32_FROM_U8(pb[5], pb[4], pb[3], pb[2]),
|
---|
610 | RT_MAKE_U16(pb[8], pb[7]), pb[9]));
|
---|
611 | break;
|
---|
612 | case 0xaa: /* Write(12) command. */
|
---|
613 | Log(("URB: %*s: SCSI: WRITE12 RelAdr=%d EBP=%d FUA=%d DPO=%d LUN=%d LBA=%#RX32 Len=%#RX32 Ctrl=%#RX8\n",
|
---|
614 | s_cchMaxMsg, pszMsg,
|
---|
615 | pb[1] & 1, !!(pb[1] & RT_BIT(3)), !!(pb[1] & RT_BIT(4)),
|
---|
616 | !!(pb[1] & RT_BIT(4)), pb[1] >> 5,
|
---|
617 | RT_MAKE_U32_FROM_U8(pb[5], pb[4], pb[3], pb[2]),
|
---|
618 | RT_MAKE_U32_FROM_U8(pb[9], pb[8], pb[7], pb[6]),
|
---|
619 | pb[11]));
|
---|
620 | break;
|
---|
621 | case 0x3f: /* Write Long command. */
|
---|
622 | Log(("URB: %*s: SCSI: WRITE LONG RelAdr=%d LUN=%d LBA=%#RX16 ByteLen=%#RX16 Ctrl=%#RX8\n",
|
---|
623 | s_cchMaxMsg, pszMsg,
|
---|
624 | pb[1] & 1, pb[1] >> 5,
|
---|
625 | RT_MAKE_U16(pb[3], pb[2]), RT_MAKE_U16(pb[6], pb[5]),
|
---|
626 | pb[11]));
|
---|
627 | break;
|
---|
628 | case 0x35: /* Synchronize Cache(10) command. */
|
---|
629 | Log(("URB: %*s: SCSI: SYNCHRONIZE_CACHE10\n",
|
---|
630 | s_cchMaxMsg, pszMsg));
|
---|
631 | break;
|
---|
632 | case 0xa0: /* Report LUNs command. */
|
---|
633 | Log(("URB: %*s: SCSI: REPORT_LUNS\n",
|
---|
634 | s_cchMaxMsg, pszMsg));
|
---|
635 | break;
|
---|
636 | default:
|
---|
637 | Log(("URB: %*s: SCSI: cmd=%#x\n",
|
---|
638 | s_cchMaxMsg, pszMsg, pb[0]));
|
---|
639 | break;
|
---|
640 | }
|
---|
641 | if (pDev)
|
---|
642 | pDev->Urb.u8ScsiCmd = pb[0];
|
---|
643 | }
|
---|
644 | else if ( fComplete
|
---|
645 | && pUrb->enmType == VUSBXFERTYPE_BULK
|
---|
646 | && pUrb->enmDir == VUSBDIRECTION_IN
|
---|
647 | && pUrb->cbData >= 12
|
---|
648 | && !memcmp(pUrb->abData, "USBS", 4))
|
---|
649 | {
|
---|
650 | const struct usbs
|
---|
651 | {
|
---|
652 | uint32_t Signature;
|
---|
653 | uint32_t Tag;
|
---|
654 | uint32_t DataResidue;
|
---|
655 | uint8_t Status;
|
---|
656 | uint8_t CDB[3];
|
---|
657 | } *pUsbS = (struct usbs *)pUrb->abData;
|
---|
658 | static const char * const s_apszStatuses[] = { "PASSED", "FAILED", "PHASE ERROR", "RESERVED" };
|
---|
659 | Log(("URB: %*s: SCSI: Tag=%#x DataResidue=%#RX32 Status=%#RX8 %s\n",
|
---|
660 | s_cchMaxMsg, pszMsg, pUsbS->Tag, pUsbS->DataResidue, pUsbS->Status,
|
---|
661 | s_apszStatuses[pUsbS->Status < RT_ELEMENTS(s_apszStatuses) ? pUsbS->Status : RT_ELEMENTS(s_apszStatuses) - 1]));
|
---|
662 | if (pDev)
|
---|
663 | pDev->Urb.u8ScsiCmd = 0xff;
|
---|
664 | }
|
---|
665 | else if ( fComplete
|
---|
666 | && pUrb->enmType == VUSBXFERTYPE_BULK
|
---|
667 | && pUrb->enmDir == VUSBDIRECTION_IN
|
---|
668 | && pDev
|
---|
669 | && pDev->Urb.u8ScsiCmd != 0xff)
|
---|
670 | {
|
---|
671 | const uint8_t *pb = pUrb->abData;
|
---|
672 | switch (pDev->Urb.u8ScsiCmd)
|
---|
673 | {
|
---|
674 | case 0x03: /* REQUEST_SENSE */
|
---|
675 | Log(("URB: %*s: SCSI: RESPONSE: REQUEST_SENSE (%s)\n",
|
---|
676 | s_cchMaxMsg, pszMsg, pb[0] & 7 ? "scsi compliant" : "not scsi compliant"));
|
---|
677 | Log(("URB: %*s: SCSI: ErrCd=%#RX8 (%s) Seg=%#RX8 Filemark=%d EOM=%d ILI=%d\n",
|
---|
678 | s_cchMaxMsg, pszMsg, pb[0] & 0x7f, GetScsiErrCd(pb[0] & 0x7f), pb[1],
|
---|
679 | pb[2] >> 7, !!(pb[2] & RT_BIT(6)), !!(pb[2] & RT_BIT(5))));
|
---|
680 | Log(("URB: %*s: SCSI: SenseKey=%#x ASC=%#RX8 ASCQ=%#RX8 : %s\n",
|
---|
681 | s_cchMaxMsg, pszMsg, pb[2] & 0xf, pb[12], pb[13],
|
---|
682 | GetScsiKCQ(pb[2] & 0xf, pb[12], pb[13])));
|
---|
683 | /** @todo more later */
|
---|
684 | break;
|
---|
685 |
|
---|
686 | case 0x12: /* INQUIRY. */
|
---|
687 | {
|
---|
688 | unsigned cb = pb[4] + 5;
|
---|
689 | Log(("URB: %*s: SCSI: RESPONSE: INQUIRY\n"
|
---|
690 | "URB: %*s: SCSI: PeripheralQualifier=%d PeripheralType=%#RX8 RMB=%d DevTypeMod=%#RX8\n",
|
---|
691 | s_cchMaxMsg, pszMsg, s_cchMaxMsg, pszMsg,
|
---|
692 | pb[0] >> 5, pb[0] & 0x1f, pb[1] >> 7, pb[1] & 0x7f));
|
---|
693 | Log(("URB: %*s: SCSI: ISOVer=%d ECMAVer=%d ANSIVer=%d\n",
|
---|
694 | s_cchMaxMsg, pszMsg, pb[2] >> 6, (pb[2] >> 3) & 7, pb[2] & 7));
|
---|
695 | Log(("URB: %*s: SCSI: AENC=%d TrmlOP=%d RespDataFmt=%d (%s) AddLen=%d\n",
|
---|
696 | s_cchMaxMsg, pszMsg, pb[3] >> 7, (pb[3] >> 6) & 1,
|
---|
697 | pb[3] & 0xf, pb[3] & 0xf ? "legacy" : "scsi", pb[4]));
|
---|
698 | if (cb < 8)
|
---|
699 | break;
|
---|
700 | Log(("URB: %*s: SCSI: RelAdr=%d WBus32=%d WBus16=%d Sync=%d Linked=%d CmdQue=%d SftRe=%d\n",
|
---|
701 | s_cchMaxMsg, pszMsg, pb[7] >> 7, !!(pb[7] >> 6), !!(pb[7] >> 5), !!(pb[7] >> 4),
|
---|
702 | !!(pb[7] >> 3), !!(pb[7] >> 1), pb[7] & 1));
|
---|
703 | if (cb < 16)
|
---|
704 | break;
|
---|
705 | Log(("URB: %*s: SCSI: VendorId=%.8s\n", s_cchMaxMsg, pszMsg, &pb[8]));
|
---|
706 | if (cb < 32)
|
---|
707 | break;
|
---|
708 | Log(("URB: %*s: SCSI: ProductId=%.16s\n", s_cchMaxMsg, pszMsg, &pb[16]));
|
---|
709 | if (cb < 36)
|
---|
710 | break;
|
---|
711 | Log(("URB: %*s: SCSI: ProdRevLvl=%.4s\n", s_cchMaxMsg, pszMsg, &pb[32]));
|
---|
712 | if (cb > 36)
|
---|
713 | Log(("URB: %*s: SCSI: VendorSpecific=%.*s\n",
|
---|
714 | s_cchMaxMsg, pszMsg, RT_MIN(cb - 36, 20), &pb[36]));
|
---|
715 | if (cb > 96)
|
---|
716 | Log(("URB: %*s: SCSI: VendorParam=%.*Rhxs\n",
|
---|
717 | s_cchMaxMsg, pszMsg, cb - 96, &pb[96]));
|
---|
718 | break;
|
---|
719 | }
|
---|
720 |
|
---|
721 | case 0x25: /* Read Capacity(6) command. */
|
---|
722 | Log(("URB: %*s: SCSI: RESPONSE: READ_CAPACITY\n"
|
---|
723 | "URB: %*s: SCSI: LBA=%#RX32 BlockLen=%#RX32\n",
|
---|
724 | s_cchMaxMsg, pszMsg, s_cchMaxMsg, pszMsg,
|
---|
725 | RT_MAKE_U32_FROM_U8(pb[3], pb[2], pb[1], pb[0]),
|
---|
726 | RT_MAKE_U32_FROM_U8(pb[7], pb[6], pb[5], pb[4])));
|
---|
727 | break;
|
---|
728 | }
|
---|
729 |
|
---|
730 | pDev->Urb.u8ScsiCmd = 0xff;
|
---|
731 | }
|
---|
732 |
|
---|
733 | /*
|
---|
734 | * The Quickcam control pipe.
|
---|
735 | */
|
---|
736 | if ( pSetup
|
---|
737 | && ((pSetup->bmRequestType >> 5) & 0x3) >= 2 /* vendor */
|
---|
738 | && (fComplete || !(pSetup->bmRequestType >> 7))
|
---|
739 | && pDev
|
---|
740 | && pDev->pDescCache
|
---|
741 | && pDev->pDescCache->pDevice
|
---|
742 | && pDev->pDescCache->pDevice->idVendor == 0x046d
|
---|
743 | && ( pDev->pDescCache->pDevice->idProduct == 0x8f6
|
---|
744 | || pDev->pDescCache->pDevice->idProduct == 0x8f5
|
---|
745 | || pDev->pDescCache->pDevice->idProduct == 0x8f0)
|
---|
746 | )
|
---|
747 | {
|
---|
748 | pbData = (const uint8_t *)(pSetup + 1);
|
---|
749 | cbData = pUrb->cbData - sizeof(*pSetup);
|
---|
750 |
|
---|
751 | if ( pSetup->bRequest == 0x04
|
---|
752 | && pSetup->wIndex == 0
|
---|
753 | && (cbData == 1 || cbData == 2))
|
---|
754 | {
|
---|
755 | /* the value */
|
---|
756 | unsigned uVal = pbData[0];
|
---|
757 | if (cbData > 1)
|
---|
758 | uVal |= (unsigned)pbData[1] << 8;
|
---|
759 |
|
---|
760 | const char *pszReg = NULL;
|
---|
761 | switch (pSetup->wValue)
|
---|
762 | {
|
---|
763 | case 0: pszReg = "i2c init"; break;
|
---|
764 | case 0x0423: pszReg = "STV_REG23"; break;
|
---|
765 | case 0x0509: pszReg = "RED something"; break;
|
---|
766 | case 0x050a: pszReg = "GREEN something"; break;
|
---|
767 | case 0x050b: pszReg = "BLUE something"; break;
|
---|
768 | case 0x143f: pszReg = "COMMIT? INIT DONE?"; break;
|
---|
769 | case 0x1440: pszReg = "STV_ISO_ENABLE"; break;
|
---|
770 | case 0x1442: pszReg = uVal & (RT_BIT(7)|RT_BIT(5)) ? "BUTTON PRESSED" : "BUTTON" ; break;
|
---|
771 | case 0x1443: pszReg = "STV_SCAN_RATE"; break;
|
---|
772 | case 0x1445: pszReg = "LED?"; break;
|
---|
773 | case 0x1500: pszReg = "STV_REG00"; break;
|
---|
774 | case 0x1501: pszReg = "STV_REG01"; break;
|
---|
775 | case 0x1502: pszReg = "STV_REG02"; break;
|
---|
776 | case 0x1503: pszReg = "STV_REG03"; break;
|
---|
777 | case 0x1504: pszReg = "STV_REG04"; break;
|
---|
778 | case 0x15c1: pszReg = "STV_ISO_SIZE"; break;
|
---|
779 | case 0x15c3: pszReg = "STV_Y_CTRL"; break;
|
---|
780 | case 0x1680: pszReg = "STV_X_CTRL"; break;
|
---|
781 | case 0xe00a: pszReg = "ProductId"; break;
|
---|
782 | default: pszReg = "[no clue]"; break;
|
---|
783 | }
|
---|
784 | if (pszReg)
|
---|
785 | Log(("URB: %*s: QUICKCAM: %s %#x (%d) %s '%s' (%#x)\n",
|
---|
786 | s_cchMaxMsg, pszMsg,
|
---|
787 | (pSetup->bmRequestType >> 7) ? "read" : "write", uVal, uVal, (pSetup->bmRequestType >> 7) ? "from" : "to",
|
---|
788 | pszReg, pSetup->wValue));
|
---|
789 | }
|
---|
790 | else if (cbData)
|
---|
791 | Log(("URB: %*s: QUICKCAM: Unknown request: bRequest=%#x bmRequestType=%#x wValue=%#x wIndex=%#x: %.*Rhxs\n", s_cchMaxMsg, pszMsg,
|
---|
792 | pSetup->bRequest, pSetup->bmRequestType, pSetup->wValue, pSetup->wIndex, cbData, pbData));
|
---|
793 | else
|
---|
794 | Log(("URB: %*s: QUICKCAM: Unknown request: bRequest=%#x bmRequestType=%#x wValue=%#x wIndex=%#x: (no data)\n", s_cchMaxMsg, pszMsg,
|
---|
795 | pSetup->bRequest, pSetup->bmRequestType, pSetup->wValue, pSetup->wIndex));
|
---|
796 | }
|
---|
797 |
|
---|
798 | #if 1
|
---|
799 | if ( cbData /** @todo Fix RTStrFormatV to communicate .* so formatter doesn't apply defaults when cbData=0. */
|
---|
800 | && (fComplete
|
---|
801 | ? pUrb->enmDir != VUSBDIRECTION_OUT
|
---|
802 | : pUrb->enmDir == VUSBDIRECTION_OUT))
|
---|
803 | Log3(("%16.*Rhxd\n", cbData, pbData));
|
---|
804 | #endif
|
---|
805 | if (pUrb->enmType == VUSBXFERTYPE_MSG && pUrb->pVUsb && pUrb->pVUsb->pCtrlUrb)
|
---|
806 | vusbUrbTrace(pUrb->pVUsb->pCtrlUrb, "NESTED MSG", fComplete);
|
---|
807 | }
|
---|
808 | #endif /* LOG_ENABLED */
|
---|
809 |
|
---|