| 1 |
This is a quick and dirty reverse engineer of the ST microelectronics STV0674 |
| 2 |
*NOTE* this is *not* the STV0680 that is a completely separate device! |
| 3 |
|
| 4 |
the current web page for this device is |
| 5 |
http://www.vvl.co.uk/products/co-processors/674/674.htm |
| 6 |
|
| 7 |
As is becoming increasingly more common the chip vendors are being |
| 8 |
right pains in the bum and forcing me to reverse engineer their |
| 9 |
protocols from snoops rather than giving me the data sheet. If your in |
| 10 |
a position to get the datasheet for this product please please do |
| 11 |
improve this driver! |
| 12 |
|
| 13 |
So far this driver has only been tested on a l'espion xtra other |
| 14 |
cameras may need more tweaks. |
| 15 |
|
| 16 |
The device has a single interface with several alternate configs, |
| 17 |
alternate 1 has 3 endpoints :bulk in, bulk out and an interrupt. |
| 18 |
|
| 19 |
The driver selects alternate one and uses the bulk in endpoint for |
| 20 |
data. Several control transactions are used to control the data |
| 21 |
available on the bulk in pipe. |
| 22 |
|
| 23 |
|
| 24 |
Most transactions are associated with an image number this is a 4 |
| 25 |
byte MSB value which appears to start at *2* ie the first image is 00 |
| 26 |
00 00 02. |
| 27 |
|
| 28 |
The image "header" is a block of data which is not associated with the |
| 29 |
jpeg data at all but contains several pieces of information, some |
| 30 |
important bits are: |
| 31 |
|
| 32 |
- image length (bytes 0x47(MSB) and 0x48) |
| 33 |
- x size (0x49 (MSB) 0x4a) |
| 34 |
- y size (0x4b (MSB) 0x4c |
| 35 |
|
| 36 |
|
| 37 |
Control transactions |
| 38 |
-------------------- |
| 39 |
|
| 40 |
Ping |
| 41 |
---- |
| 42 |
I assume this transaction is a "ping" as the windows driver seems to |
| 43 |
perform this transaction like a nervous twitch, its done all over for |
| 44 |
no good reason I can see, always with the same result |
| 45 |
|
| 46 |
The host reads a control transaction with 1 byte URB |
| 47 |
bRequest = 0x80 |
| 48 |
wValue=0x0000 |
| 49 |
wIndex=0x0000 |
| 50 |
wLength=0x0001 |
| 51 |
|
| 52 |
the returned URB: |
| 53 |
byte 0 is always 0x00 |
| 54 |
|
| 55 |
Get header |
| 56 |
---------- |
| 57 |
This obtains a block of data which contains the image "header" |
| 58 |
|
| 59 |
The host writes a control transaction with 6 byte buffer |
| 60 |
|
| 61 |
bRequest = 0x0A |
| 62 |
wValue=0x0000 |
| 63 |
wIndex=0x0000 |
| 64 |
wLength=0x0006 |
| 65 |
|
| 66 |
the data buffer has: |
| 67 |
bytes 0-3 are image number |
| 68 |
bytes 4-5 are length (MSB) this is always 0x56 in the doze driver |
| 69 |
|
| 70 |
the client may then read the "length" bytes from the bulk in pipe |
| 71 |
|
| 72 |
Set Image Number |
| 73 |
---------------- |
| 74 |
I believe this is used to select the image for some transactions that |
| 75 |
don't explicitly set the image number themselves |
| 76 |
This and the following are done immediately before each image download |
| 77 |
|
| 78 |
The host writes a control transaction with 4 byte buffer |
| 79 |
|
| 80 |
bRequest = 0x03 |
| 81 |
wValue=0x0000 |
| 82 |
wIndex=0x0000 |
| 83 |
wLength=0x0004 |
| 84 |
|
| 85 |
the data buffer has: |
| 86 |
bytes 0-3 are image number |
| 87 |
|
| 88 |
Unknown |
| 89 |
------- |
| 90 |
This *always* follows the above |
| 91 |
|
| 92 |
The host reads a control transaction with 2 byte buffer |
| 93 |
bRequest = 0x86 |
| 94 |
wValue=0x0000 |
| 95 |
wIndex=0x0000 |
| 96 |
wLength=0x0004 |
| 97 |
|
| 98 |
the data buffer has: |
| 99 |
byte 0 is always 0x03 |
| 100 |
byte 0 is always 0x01 |
| 101 |
|
| 102 |
Image header read |
| 103 |
----------------- |
| 104 |
This is performed before each image is read, its just a repeat of the |
| 105 |
header obtained with the other request but its useful here for getting |
| 106 |
the image size, the doze driver always does it here and if you don't it |
| 107 |
breaks ;-) |
| 108 |
|
| 109 |
The host writes a control transaction with 8 byte buffer |
| 110 |
|
| 111 |
bRequest = 0x05 |
| 112 |
wValue=0x00ff |
| 113 |
wIndex=0x0000 |
| 114 |
wLength=0x0008 |
| 115 |
|
| 116 |
the written URB contains: |
| 117 |
bytes 0-3 are image number |
| 118 |
bytes 4-7 are the length of data to read (always 0x200 for the header read) |
| 119 |
|
| 120 |
0x200 bytes are then read from the bulk in pipe, this seems to be an |
| 121 |
extended header? |
| 122 |
|
| 123 |
Image read |
| 124 |
---------- |
| 125 |
This is identical to the image header read above except the wValue has |
| 126 |
changed from 0xff to 0x08. The windows driver writes a series of these |
| 127 |
commands asking for 0x1000 bytes of data a time, larger seems to |
| 128 |
fail... so reading blocks of 0x1000 and a fragment of smaller seems to |
| 129 |
be the best way to go. |
| 130 |
|
| 131 |
The host writes a control transaction with 8 byte buffer |
| 132 |
|
| 133 |
bRequest = 0x05 |
| 134 |
wValue=0x0008 |
| 135 |
wIndex=0x0000 |
| 136 |
wLength=0x0008 |
| 137 |
|
| 138 |
the written URB contains: |
| 139 |
bytes 0-3 are image number |
| 140 |
bytes 4-7 are the length of data to read (0x1000 or less) |
| 141 |
|
| 142 |
read close |
| 143 |
---------- |
| 144 |
This transaction is performed at the end of the image read. |
| 145 |
|
| 146 |
The host writes a control transaction with 4 byte buffer |
| 147 |
|
| 148 |
bRequest = 0x09 |
| 149 |
wValue=0x0000 |
| 150 |
wIndex=0x0000 |
| 151 |
wLength=0x0004 |
| 152 |
|
| 153 |
the data buffer has: |
| 154 |
bytes 0-3 are image number |