UsbVideoDesc.Mod 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011
  1. MODULE UsbVideoDesc; (** AUTHOR "Timothée Martiel, 2015"; PURPOSE "USB Video Class standard descriptors"; *)
  2. IMPORT SYSTEM, KernelLog, Usbdi;
  3. CONST
  4. (* Video-class specific descriptor codes *)
  5. Device * = 21H;
  6. Configuration * = 22H;
  7. String * = 23H;
  8. Interface * = 24H;
  9. Endpoint * = 25H;
  10. (* Video-class specific descriptor subtypes for VideoControl Interface *)
  11. VCHeader * = 01H;
  12. VCInputTerminal * = 02H;
  13. VCOutputTerminal * = 03H;
  14. VCSelectorUnit * = 04H;
  15. VCProcessingUnit * = 05H;
  16. VCExtensionUnit * = 06H;
  17. VCEncodingUnit * = 07H;
  18. (* Video-class specific descriptor subtypes for VideoStreaming Interface *)
  19. VSInputHeader * = 01H;
  20. VSOutputHeader * = 02H;
  21. VSStillImageFrame * = 03H;
  22. VSFormatUncompressed * = 04H;
  23. VSFrameUncompressed * = 05H;
  24. VSFormatMjpeg * = 06H;
  25. VSFrameMjpeg * = 07H;
  26. VSFormatMpeg2ts * = 0AH;
  27. VSFormatDv * = 0CH;
  28. VSColorFormat * = 0DH;
  29. VSFormatFrameBased * = 10H;
  30. VSFrameFrameBased * = 11H;
  31. VSFormatStreamBased * = 12H;
  32. VSFormatH264 * = 13H;
  33. VSFrameH264 * = 14H;
  34. VSFormatH264Simulcast * = 15H;
  35. VSFormatVp8 * = 16H;
  36. VSFrameVp8 * = 17H;
  37. VSFormatVp8Simulcast * = 18H;
  38. (* Video-class specific descriptor subtypes for Endpoints *)
  39. EGeneral * = 01H;
  40. EEndpoint * = 02H;
  41. EInterrupt * = 03H;
  42. (*= Terminal types =*)
  43. (* Generic *)
  44. TypeVendorSpecific * = 100H;
  45. TypeStreaming * = 101H;
  46. (* Input *)
  47. TypeInVendorSpecific * = 200H;
  48. TypeInCamera * = 201H;
  49. TypeInMediaTransportInput * = 202H;
  50. (* Output *)
  51. TypeOutVendorSpecific * = 300H;
  52. TypeOutDisplay * = 301H;
  53. TypeOutMediaTransportOutput * = 302H;
  54. TYPE
  55. (*===== Video Class Specific Interfaces =====*)
  56. VideoControlDesc * = POINTER TO RECORD
  57. bcdUVC *: LONGINT;
  58. wTotalLength *: LONGINT;
  59. dwClockFrequency *: LONGINT;
  60. bInCollection *: LONGINT;
  61. baInterfaceNr *: POINTER TO ARRAY OF LONGINT;
  62. END;
  63. Unit * = OBJECT
  64. VAR
  65. bUnitID *: LONGINT;
  66. PROCEDURE Resolve * (CONST cache: ARRAY OF Unit);
  67. BEGIN HALT(210)
  68. END Resolve;
  69. END Unit;
  70. InputTerminalDesc * = OBJECT (Unit)
  71. VAR
  72. wTerminalType *: LONGINT;
  73. bAssocTerminal *: LONGINT;
  74. iTerminal *: LONGINT;
  75. assocTerminal *: OutputTerminalDesc;
  76. PROCEDURE Resolve * (CONST cache: ARRAY OF Unit);
  77. BEGIN
  78. IF bAssocTerminal # 0 THEN
  79. ASSERT(cache[bAssocTerminal - 1] # NIL);
  80. ASSERT(cache[bAssocTerminal - 1] IS OutputTerminalDesc);
  81. assocTerminal := cache[bAssocTerminal - 1](OutputTerminalDesc)
  82. ;TRACE(assocTerminal)
  83. END;
  84. END Resolve;
  85. END InputTerminalDesc;
  86. CameraTerminalDesc * = OBJECT (InputTerminalDesc)
  87. VAR
  88. wObjectiveFocalLengthMin *: LONGINT;
  89. wObjectiveFocalLengthMax *: LONGINT;
  90. wOcularFocalLength *: LONGINT;
  91. bControlSize *: LONGINT;
  92. bmControls *: SET;
  93. END CameraTerminalDesc;
  94. OutputTerminalDesc * = OBJECT (Unit)
  95. VAR
  96. wTerminalType *: LONGINT;
  97. bAssocTerminal *: LONGINT;
  98. bSourceID *: LONGINT;
  99. iTerminal *: LONGINT;
  100. assocTerminal *: InputTerminalDesc;
  101. source *: Unit;
  102. PROCEDURE Resolve * (CONST cache: ARRAY OF Unit);
  103. BEGIN
  104. IF bAssocTerminal # 0 THEN
  105. ASSERT(cache[bAssocTerminal - 1] # NIL);
  106. ASSERT(cache[bAssocTerminal - 1] IS InputTerminalDesc);
  107. assocTerminal := cache[bAssocTerminal - 1](InputTerminalDesc)
  108. ;TRACE(assocTerminal)
  109. END;
  110. ASSERT(cache[bSourceID - 1] # NIL);
  111. source := cache[bSourceID - 1]
  112. ;TRACE(source)
  113. END Resolve;
  114. END OutputTerminalDesc;
  115. SelectorUnitDesc * = OBJECT (Unit)
  116. (*! TODO *)
  117. END SelectorUnitDesc;
  118. ProcessingUnitDesc * = OBJECT (Unit)
  119. VAR
  120. bSourceID *: LONGINT;
  121. wMaxMultiplier *: LONGINT;
  122. bControlSize *: LONGINT;
  123. bmControls *: SET;
  124. iProcessing *: LONGINT;
  125. bmVideoStandards *: SET;
  126. source *: Unit;
  127. PROCEDURE Resolve * (CONST cache: ARRAY OF Unit);
  128. BEGIN
  129. ASSERT(cache[bSourceID - 1] # NIL);
  130. source := cache[bSourceID - 1]
  131. ;TRACE(source)
  132. END Resolve;
  133. END ProcessingUnitDesc;
  134. EncodingUnitDesc * = OBJECT (Unit)
  135. (*! TODO *)
  136. END EncodingUnitDesc;
  137. ExtensionUnitDesc * = OBJECT (Unit)
  138. VAR
  139. guidExtensionCode *: ARRAY 16 OF CHAR;
  140. bNumControls *: LONGINT;
  141. bNrInPins *: LONGINT;
  142. baSourceID *: POINTER TO ARRAY OF LONGINT;
  143. bControlSize *: LONGINT;
  144. bmControls *: SET;
  145. iExtension *: LONGINT;
  146. sources *: POINTER TO ARRAY OF Unit;
  147. PROCEDURE Resolve * (CONST cache: ARRAY OF Unit);
  148. VAR
  149. i: LONGINT;
  150. BEGIN
  151. NEW(sources, bNrInPins);
  152. FOR i := 0 TO bNrInPins - 1 DO
  153. ASSERT(cache[baSourceID[i] - 1] # NIL);
  154. sources[i] := cache[baSourceID[i] - 1]
  155. ;TRACE(i, sources[i])
  156. END
  157. END Resolve;
  158. END ExtensionUnitDesc;
  159. InterruptEndpointDesc * = POINTER TO RECORD
  160. bEndpointAddress *: LONGINT;
  161. bmAttributes *: SET;
  162. wMaxPacketSize *: LONGINT;
  163. bInterval *: LONGINT;
  164. END;
  165. (* Base descriptor. Parsing those is done in a format-specific way. *)
  166. VSInputHeaderDesc * = POINTER TO RECORD
  167. bNumFormats *: LONGINT;
  168. wTotalLength *: LONGINT;
  169. bEndpointAddress *: LONGINT;
  170. bmInfo *: SET;
  171. bTerminalLink *: LONGINT;
  172. bStillCaptureMethod *: LONGINT;
  173. bTriggerSupport *: LONGINT;
  174. bTriggerUsage *: LONGINT;
  175. bControlSize *: LONGINT;
  176. bmaControls *: POINTER TO ARRAY OF SET;
  177. END;
  178. VSFormatDesc * = OBJECT
  179. VAR
  180. bFormatIndex *: LONGINT;
  181. bNumFrameDescriptors *: LONGINT;
  182. frames *: POINTER TO ARRAY OF VSFrameDesc;
  183. (** Abstract printing method for debug *)
  184. PROCEDURE Print *;
  185. BEGIN HALT(210)
  186. END Print;
  187. END VSFormatDesc;
  188. VSFormatUncompressedDesc * = OBJECT (VSFormatDesc)
  189. VAR
  190. guidFormat *: ARRAY 16 OF CHAR;
  191. bBitsPerPixel *: LONGINT;
  192. bDefaultFrameIndex *: LONGINT;
  193. bAspectRatioX *: LONGINT;
  194. bAspectRatioY *: LONGINT;
  195. bmInterlaceFlags *: SET;
  196. bCopyProtect *: BOOLEAN;
  197. PROCEDURE Print *;
  198. VAR
  199. i: LONGINT;
  200. BEGIN
  201. KernelLog.String("= VideoStream Uncompressed Format Descriptor ="); KernelLog.Ln;
  202. KernelLog.String(" format idx: "); KernelLog.Int(bFormatIndex, 0); KernelLog.Ln;
  203. KernelLog.String(" # frame desc: "); KernelLog.Int(bNumFrameDescriptors, 0); KernelLog.Ln;
  204. KernelLog.String(" guid format:"); KernelLog.Ln;
  205. (*FOR i := 0 TO 15 DO KernelLog.Hex(ORD(guidFormat[i]), -2); KernelLog.String(" ") END;*)
  206. KernelLog.Buffer(guidFormat, 0, 16);
  207. KernelLog.String(" bit/pixel: "); KernelLog.Int(bBitsPerPixel, 0); KernelLog.Ln;
  208. KernelLog.String(" aspect ratio X: "); KernelLog.Int(bAspectRatioX, 0); KernelLog.Ln;
  209. KernelLog.String(" aspect ratio Y: "); KernelLog.Int(bAspectRatioY, 0); KernelLog.Ln;
  210. KernelLog.String(" interlace flags: "); KernelLog.Set(bmInterlaceFlags); KernelLog.Ln;
  211. KernelLog.String(" copy protect: "); KernelLog.Boolean(bCopyProtect); KernelLog.Ln
  212. END Print;
  213. END VSFormatUncompressedDesc;
  214. VSFormatMjpegDesc * = OBJECT (VSFormatDesc)
  215. VAR
  216. bmFlags *: SET;
  217. bDefaultFrameIndex *: LONGINT;
  218. bAspectRatioX *: LONGINT;
  219. bAspectRatioY *: LONGINT;
  220. bmInterlaceFlags *: SET;
  221. bCopyProtect *: BOOLEAN;
  222. PROCEDURE Print *;
  223. BEGIN
  224. KernelLog.String("= VideoStream MJPEG Format Descriptor ="); KernelLog.Ln;
  225. KernelLog.String(" format idx: "); KernelLog.Int(bFormatIndex, 0); KernelLog.Ln;
  226. KernelLog.String(" # frame desc: "); KernelLog.Int(bNumFrameDescriptors, 0); KernelLog.Ln;
  227. KernelLog.String(" flags: "); KernelLog.Set(bmFlags); KernelLog.Ln;
  228. KernelLog.String(" dflt fr idx: "); KernelLog.Int(bDefaultFrameIndex, 0); KernelLog.Ln;
  229. KernelLog.String(" aspect ratio X: "); KernelLog.Int(bAspectRatioX, 0); KernelLog.Ln;
  230. KernelLog.String(" aspect ratio Y: "); KernelLog.Int(bAspectRatioY, 0); KernelLog.Ln;
  231. KernelLog.String(" interlace flags: "); KernelLog.Set(bmInterlaceFlags); KernelLog.Ln;
  232. KernelLog.String(" copy protect: "); KernelLog.Boolean(bCopyProtect); KernelLog.Ln
  233. END Print;
  234. END VSFormatMjpegDesc;
  235. VSFrameDesc * = OBJECT
  236. VAR
  237. bFrameIndex *: LONGINT;
  238. format *: VSFormatDesc;
  239. PROCEDURE Print *;
  240. BEGIN HALT(210)
  241. END Print;
  242. END VSFrameDesc;
  243. VSFrameUncompressedDesc * = OBJECT (VSFrameDesc)
  244. VAR
  245. bmCapabilities *: SET;
  246. wWidth *: LONGINT;
  247. wHeight *: LONGINT;
  248. dwMinBitRate *: LONGINT;
  249. dwMaxBitRate *: LONGINT;
  250. dwMaxVideoFrameBufferSize *: LONGINT;
  251. dwDefaultFrameInterval *: LONGINT;
  252. bFrameIntervalType *: LONGINT;
  253. (* If bFrameIntervalType = 0 *)
  254. dwMinFrameInterval *: LONGINT;
  255. dwMaxFrameInterval *: LONGINT;
  256. dwFrameIntervalStep *: LONGINT;
  257. (* If bFramIntervalType #0 *)
  258. dwaFrameInterval *: POINTER TO ARRAY OF LONGINT;
  259. PROCEDURE Print *;
  260. VAR
  261. i: LONGINT;
  262. BEGIN
  263. KernelLog.String("= VideoStream Uncompressed Frame Descriptor ="); KernelLog.Ln;
  264. KernelLog.String(" frame index: "); KernelLog.Int(bFrameIndex, 0); KernelLog.Ln;
  265. KernelLog.String(" capabilities: "); KernelLog.Set(bmCapabilities); KernelLog.Ln;
  266. KernelLog.String(" width: "); KernelLog.Int(wWidth, 0); KernelLog.Ln;
  267. KernelLog.String(" height: "); KernelLog.Int(wHeight, 0); KernelLog.Ln;
  268. KernelLog.String(" min bit rate: "); KernelLog.Int(dwMinBitRate, 0); KernelLog.Ln;
  269. KernelLog.String(" max bit rate: "); KernelLog.Int(dwMaxBitRate, 0); KernelLog.Ln;
  270. KernelLog.String(" max frbuf size: "); KernelLog.Int(dwMaxVideoFrameBufferSize, 0); KernelLog.Ln;
  271. KernelLog.String(" dflt fr. interval: "); KernelLog.Int(dwDefaultFrameInterval, 0); KernelLog.Ln;
  272. KernelLog.String(" fr interval type: ");
  273. IF bFrameIntervalType = 0 THEN
  274. KernelLog.String("Continuous");
  275. KernelLog.String(" min fr interval: "); KernelLog.Int(dwMinFrameInterval, 0); KernelLog.Ln;
  276. KernelLog.String(" max fr interval: "); KernelLog.Int(dwMaxFrameInterval, 0); KernelLog.Ln;
  277. KernelLog.String(" fr interval step: "); KernelLog.Int(dwFrameIntervalStep, 0); KernelLog.Ln
  278. ELSE
  279. KernelLog.Int(bFrameIntervalType, 0); KernelLog.Ln;
  280. KernelLog.String(" fr intervals: ");
  281. FOR i := 0 TO bFrameIntervalType - 1 DO
  282. KernelLog.Int(dwaFrameInterval[i], 0); KernelLog.String(" ")
  283. END;
  284. KernelLog.Ln
  285. END
  286. END Print;
  287. END VSFrameUncompressedDesc;
  288. VSFrameMjpegDesc * = OBJECT (VSFrameDesc)
  289. VAR
  290. bmCapabilities *: SET;
  291. wWidth *,
  292. wHeight *,
  293. dwMinBitRate *,
  294. dwMaxBitRate *,
  295. dwMaxVideoFrameBufferSize* ,
  296. dwDefaultFrameInterval *,
  297. bFrameIntervalType *: LONGINT;
  298. (* bFrameIntervalType = 0 *)
  299. dwMinFrameInterval *,
  300. dwMaxFrameInterval *,
  301. dwFrameIntervalStep *: LONGINT;
  302. (* bFrameIntervalType # 0 *)
  303. dwaFrameInterval *: POINTER TO ARRAY OF LONGINT;
  304. PROCEDURE Print *;
  305. VAR
  306. i: LONGINT;
  307. BEGIN
  308. KernelLog.String("= VideoStream MJPEG Frame Descriptor ="); KernelLog.Ln;
  309. KernelLog.String(" frame index: "); KernelLog.Int(bFrameIndex, 0); KernelLog.Ln;
  310. KernelLog.String(" capabilities: "); KernelLog.Set(bmCapabilities); KernelLog.Ln;
  311. KernelLog.String(" width: "); KernelLog.Int(wWidth, 0); KernelLog.Ln;
  312. KernelLog.String(" height: "); KernelLog.Int(wHeight, 0); KernelLog.Ln;
  313. KernelLog.String(" min bit rate: "); KernelLog.Int(dwMinBitRate, 0); KernelLog.Ln;
  314. KernelLog.String(" max bit rate: "); KernelLog.Int(dwMaxBitRate, 0); KernelLog.Ln;
  315. KernelLog.String(" max frbuf size: "); KernelLog.Int(dwMaxVideoFrameBufferSize, 0); KernelLog.Ln;
  316. KernelLog.String(" dflt fr. interval: "); KernelLog.Int(dwDefaultFrameInterval, 0); KernelLog.Ln;
  317. KernelLog.String(" fr interval type: ");
  318. IF bFrameIntervalType = 0 THEN
  319. KernelLog.String("Continuous");
  320. KernelLog.String(" min fr interval: "); KernelLog.Int(dwMinFrameInterval, 0); KernelLog.Ln;
  321. KernelLog.String(" max fr interval: "); KernelLog.Int(dwMaxFrameInterval, 0); KernelLog.Ln;
  322. KernelLog.String(" fr interval step: "); KernelLog.Int(dwFrameIntervalStep, 0); KernelLog.Ln
  323. ELSE
  324. KernelLog.Int(bFrameIntervalType, 0); KernelLog.Ln;
  325. KernelLog.String(" fr intervals: ");
  326. FOR i := 0 TO bFrameIntervalType - 1 DO
  327. KernelLog.Int(dwaFrameInterval[i], 0); KernelLog.String(" ")
  328. END;
  329. KernelLog.Ln
  330. END
  331. END Print;
  332. END VSFrameMjpegDesc;
  333. StillImageDesc * = POINTER TO RECORD
  334. bEndpointAddress *: LONGINT;
  335. bNumImageSizePattern *: LONGINT;
  336. waWidth *: POINTER TO ARRAY OF LONGINT;
  337. waHeight *: POINTER TO ARRAY OF LONGINT;
  338. bNumCompressionPattern *: LONGINT;
  339. baCompression *: POINTER TO ARRAY OF LONGINT;
  340. END;
  341. ColorMatchingDesc * = POINTER TO RECORD
  342. bColorPrimaries *: LONGINT;
  343. bTransferCharacteristics *: LONGINT;
  344. bMatrixCoefficients *: LONGINT;
  345. END;
  346. VAR
  347. unitCache *: ARRAY 256 OF Unit;
  348. PROCEDURE ParseVideoControlDesc * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VideoControlDesc;
  349. VAR
  350. len, i, n: LONGINT;
  351. vc: VideoControlDesc;
  352. BEGIN
  353. len := ORD(buffer[pos]); INC(pos);
  354. (* Check desc type *)
  355. ASSERT(ORD(buffer[pos]) = Interface); INC(pos);
  356. (* Chek desc subtype *)
  357. ASSERT(ORD(buffer[pos]) = VCHeader); INC(pos);
  358. NEW(vc);
  359. (* Check standard version *)
  360. vc.bcdUVC := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H;
  361. INC(pos, 2);
  362. (*ASSERT(vc.bcdUVC >= 150H);*)
  363. vc.wTotalLength := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H;
  364. INC(pos, 2); (* skip wTotalLength *)
  365. vc.dwClockFrequency := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H;
  366. INC(pos, 4); (* skip dwClockFrequency *)
  367. vc.bInCollection := ORD(buffer[pos]);
  368. INC(pos);
  369. NEW(vc.baInterfaceNr, vc.bInCollection);
  370. FOR i := 0 TO vc.bInCollection - 1 DO
  371. vc.baInterfaceNr[i] := ORD(buffer[pos]); INC(pos)
  372. END;
  373. RETURN vc
  374. END ParseVideoControlDesc;
  375. PROCEDURE ClearUnitCache *;
  376. VAR
  377. i: LONGINT;
  378. BEGIN
  379. FOR i := 0 TO 255 DO
  380. unitCache[i] := NIL
  381. END;
  382. END ClearUnitCache;
  383. PROCEDURE ParseUnit * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): Unit;
  384. VAR
  385. unit: Unit;
  386. id, type: LONGINT;
  387. BEGIN
  388. KernelLog.String("Unit length: "); KernelLog.Int(ORD(buffer[pos]), 0); KernelLog.Ln;
  389. INC(pos);
  390. ASSERT(ORD(buffer[pos]) = Interface); INC(pos);
  391. type := ORD(buffer[pos]); INC(pos);
  392. id := ORD(buffer[pos]); INC(pos);
  393. CASE type OF
  394. VCInputTerminal: unit := ParseInputTerminalDesc(buffer, pos)
  395. |VCOutputTerminal: unit := ParseOutputTerminalDesc(buffer, pos)
  396. |VCProcessingUnit: unit := ParseProcessingUnitDesc(buffer, pos)
  397. |VCExtensionUnit: unit := ParseExtensionUnitDesc(buffer, pos)
  398. ELSE
  399. KernelLog.String("UNSUPPORTED UNIT TYPE");
  400. RETURN NIL
  401. END;
  402. unit.bUnitID := id;
  403. RETURN unit
  404. END ParseUnit;
  405. PROCEDURE ParseInputTerminalDesc * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): InputTerminalDesc;
  406. VAR
  407. type: LONGINT;
  408. it: InputTerminalDesc;
  409. BEGIN
  410. type := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  411. IF type = TypeInCamera THEN
  412. it := ParseCameraTerminalDesc(buffer, pos)
  413. ELSE
  414. NEW(it);
  415. it.bAssocTerminal := ORD(buffer[pos]); INC(pos);
  416. it.iTerminal := ORD(buffer[pos])
  417. END;
  418. it.wTerminalType := type;
  419. RETURN it
  420. END ParseInputTerminalDesc;
  421. PROCEDURE ParseOutputTerminalDesc * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): OutputTerminalDesc;
  422. VAR
  423. ot: OutputTerminalDesc;
  424. BEGIN
  425. NEW(ot);
  426. ot.wTerminalType := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  427. ot.bAssocTerminal := ORD(buffer[pos]); INC(pos);
  428. ot.bSourceID := ORD(buffer[pos]); INC(pos);
  429. ot.iTerminal := ORD(buffer[pos]);
  430. RETURN ot
  431. END ParseOutputTerminalDesc;
  432. PROCEDURE ParseCameraTerminalDesc * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): CameraTerminalDesc;
  433. VAR
  434. c: CameraTerminalDesc;
  435. i, ctrls: LONGINT;
  436. BEGIN
  437. NEW(c);
  438. c.wObjectiveFocalLengthMin := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  439. c.wObjectiveFocalLengthMax := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  440. c.wOcularFocalLength := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  441. c.bControlSize := ORD(buffer[pos]); INC(pos);
  442. FOR i := c.bControlSize - 1 TO 0 BY -1 DO
  443. ctrls := ctrls * 100H;
  444. INC(ctrls, ORD(buffer[pos + i]))
  445. END;
  446. INC(pos, c.bControlSize);
  447. c.bmControls := SYSTEM.VAL(SET, ctrls);
  448. RETURN c
  449. END ParseCameraTerminalDesc;
  450. PROCEDURE ParseProcessingUnitDesc * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): ProcessingUnitDesc;
  451. VAR
  452. p: ProcessingUnitDesc;
  453. i, ctrls: LONGINT;
  454. BEGIN
  455. NEW(p);
  456. TRACE(pos, LEN(buffer));
  457. p.bSourceID := ORD(buffer[pos]); INC(pos);
  458. p.wMaxMultiplier := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  459. p.bControlSize := ORD(buffer[pos]); INC(pos);
  460. TRACE(pos);
  461. FOR i := p.bControlSize - 1 TO 0 BY -1 DO
  462. ctrls := ctrls * 100H;
  463. INC(ctrls, ORD(buffer[pos + i]))
  464. END;
  465. INC(pos, p.bControlSize);
  466. p.bmControls := SYSTEM.VAL(SET, ctrls);
  467. TRACE(pos);
  468. p.iProcessing := ORD(buffer[pos]); INC(pos);
  469. IF pos < LEN(buffer) THEN
  470. p.bmVideoStandards := SYSTEM.VAL(SET, ORD(buffer[pos])); INC(pos)
  471. ELSE
  472. KernelLog.String("PROCESSING UNIT IS TOO SMALL")
  473. END;
  474. RETURN p
  475. END ParseProcessingUnitDesc;
  476. PROCEDURE ParseExtensionUnitDesc * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): ExtensionUnitDesc;
  477. VAR
  478. e: ExtensionUnitDesc;
  479. ctrls, i: LONGINT;
  480. BEGIN
  481. NEW(e);
  482. FOR i := 0 TO 15 DO
  483. e.guidExtensionCode[i] := buffer[pos + i]
  484. END;
  485. INC(pos, 16);
  486. e.bNumControls := ORD(buffer[pos]); INC(pos);
  487. e.bNrInPins := ORD(buffer[pos]); INC(pos);
  488. NEW(e.baSourceID, e.bNrInPins);
  489. FOR i := 0 TO e.bNrInPins - 1 DO
  490. e.baSourceID[i] := ORD(buffer[pos]);
  491. INC(pos)
  492. END;
  493. e.bControlSize := ORD(buffer[pos]); INC(pos);
  494. FOR i := e.bControlSize - 1 TO 0 BY -1 DO
  495. ctrls := ctrls * 100H;
  496. INC(ctrls, ORD(buffer[pos + i]))
  497. END;
  498. INC(pos, e.bControlSize);
  499. e.bmControls := SYSTEM.VAL(SET, ctrls);
  500. e.iExtension := ORD(buffer[pos]); INC(pos);
  501. RETURN e
  502. END ParseExtensionUnitDesc;
  503. PROCEDURE ParseEndpointDesc * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): InterruptEndpointDesc;
  504. VAR
  505. len: LONGINT;
  506. d: InterruptEndpointDesc;
  507. BEGIN
  508. KernelLog.Buffer(buffer, 0, LEN(buffer));
  509. len := ORD(buffer[pos]);
  510. INC(pos);
  511. IF ORD(buffer[pos]) # Endpoint THEN RETURN NIL END;
  512. INC(pos);
  513. NEW(d);
  514. d.bEndpointAddress := ORD(buffer[pos]); INC(pos);
  515. d.bmAttributes := SYSTEM.VAL(SET, ORD(buffer[pos])); INC(pos);
  516. IF len = 7 THEN
  517. d.wMaxPacketSize := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  518. d.bInterval := ORD(buffer[pos])
  519. END;
  520. RETURN d
  521. END ParseEndpointDesc;
  522. PROCEDURE ParseVSInputHeader * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSInputHeaderDesc;
  523. VAR
  524. hdr: VSInputHeaderDesc;
  525. i, j, set: LONGINT;
  526. BEGIN
  527. ASSERT(ORD(buffer[pos]) >= 13); INC(pos);
  528. ASSERT(ORD(buffer[pos]) = Interface); INC(pos);
  529. ASSERT(ORD(buffer[pos]) = VSInputHeader); INC(pos);
  530. NEW(hdr);
  531. hdr.bNumFormats := ORD(buffer[pos]); INC(pos);
  532. hdr.wTotalLength := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  533. hdr.bEndpointAddress := ORD(buffer[pos]); INC(pos);
  534. hdr.bmInfo := SYSTEM.VAL(SET, ORD(buffer[pos])); INC(pos);
  535. hdr.bTerminalLink := ORD(buffer[pos]); INC(pos);
  536. hdr.bStillCaptureMethod := ORD(buffer[pos]); INC(pos);
  537. hdr.bTriggerSupport := ORD(buffer[pos]); INC(pos);
  538. hdr.bTriggerUsage := ORD(buffer[pos]); INC(pos);
  539. hdr.bControlSize := ORD(buffer[pos]); INC(pos);
  540. NEW(hdr.bmaControls, hdr.bNumFormats);
  541. FOR i := 0 TO hdr.bNumFormats - 1 DO
  542. set := 0;
  543. FOR j := hdr.bControlSize - 1 TO 0 BY -1 DO
  544. set := set * 100H;
  545. set := set + ORD(buffer[pos + j])
  546. END;
  547. hdr.bmaControls[i] := SYSTEM.VAL(SET, set);
  548. INC(pos, hdr.bControlSize)
  549. END;
  550. RETURN hdr
  551. END ParseVSInputHeader;
  552. PROCEDURE ParseVSFormat * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFormatDesc;
  553. VAR
  554. parser: PROCEDURE (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFormatDesc;
  555. format: VSFormatDesc;
  556. idx, num: LONGINT;
  557. BEGIN
  558. INC(pos);
  559. ASSERT(ORD(buffer[pos]) = Interface); INC(pos);
  560. CASE ORD(buffer[pos]) OF
  561. VSFormatUncompressed:
  562. parser := ParseVSFormatUncompressed
  563. |VSFormatMjpeg:
  564. parser := ParseVSFormatMjpeg
  565. |VSFormatMpeg2ts:
  566. parser := ParseVSFormatMpeg2ts
  567. |VSFormatH264:
  568. parser := ParseVSFormatH264
  569. |VSFormatVp8:
  570. parser := ParseVSFormatVp8
  571. ELSE
  572. KernelLog.String("Unknown Format subtype: "); KernelLog.Int(ORD(buffer[pos]), 0); KernelLog.Ln;
  573. RETURN NIL
  574. END;
  575. INC(pos);
  576. idx := ORD(buffer[pos]); INC(pos);
  577. num := ORD(buffer[pos]); INC(pos);
  578. format := parser(buffer, pos);
  579. format.bFormatIndex := idx;
  580. format.bNumFrameDescriptors := num;
  581. RETURN format
  582. END ParseVSFormat;
  583. PROCEDURE ParseVSFormatUncompressed (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFormatDesc;
  584. VAR
  585. f: VSFormatUncompressedDesc;
  586. i: LONGINT;
  587. BEGIN
  588. NEW(f);
  589. FOR i := 0 TO 15 DO
  590. f.guidFormat[i] := buffer[pos + i]
  591. END;
  592. INC(pos, 16);
  593. f.bBitsPerPixel := ORD(buffer[pos]); INC(pos);
  594. f.bDefaultFrameIndex := ORD(buffer[pos]); INC(pos);
  595. f.bAspectRatioX := ORD(buffer[pos]); INC(pos);
  596. f.bAspectRatioY := ORD(buffer[pos]); INC(pos);
  597. f.bmInterlaceFlags := SYSTEM.VAL(SET, ORD(buffer[pos])); INC(pos);
  598. f.bCopyProtect := buffer[pos] = 1X;
  599. RETURN f
  600. END ParseVSFormatUncompressed;
  601. PROCEDURE ParseVSFormatMjpeg (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFormatDesc;
  602. VAR
  603. f: VSFormatMjpegDesc;
  604. BEGIN
  605. NEW(f);
  606. f.bmFlags := SYSTEM.VAL(SET, ORD(buffer[pos])); INC(pos);
  607. f.bDefaultFrameIndex := ORD(buffer[pos]); INC(pos);
  608. f.bAspectRatioX := ORD(buffer[pos]); INC(pos);
  609. f.bAspectRatioY := ORD(buffer[pos]); INC(pos);
  610. f.bmInterlaceFlags := SYSTEM.VAL(SET, ORD(buffer[pos])); INC(pos);
  611. f.bCopyProtect := ORD(buffer[pos]) = 1; INC(pos);
  612. RETURN f;
  613. END ParseVSFormatMjpeg;
  614. PROCEDURE ParseVSFormatMpeg2ts (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFormatDesc;
  615. BEGIN
  616. (*! TODO *)
  617. END ParseVSFormatMpeg2ts;
  618. PROCEDURE ParseVSFormatH264 (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFormatDesc;
  619. BEGIN
  620. (*! TODO *)
  621. END ParseVSFormatH264;
  622. PROCEDURE ParseVSFormatVp8 (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFormatDesc;
  623. BEGIN
  624. (*! TODO *)
  625. END ParseVSFormatVp8;
  626. PROCEDURE ParseVSFrame * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFrameDesc;
  627. VAR
  628. parser: PROCEDURE (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFrameDesc;
  629. frame: VSFrameDesc;
  630. idx: LONGINT;
  631. BEGIN
  632. INC(pos);
  633. ASSERT(ORD(buffer[pos]) = Interface); INC(pos);
  634. CASE ORD(buffer[pos]) OF
  635. VSFrameUncompressed:
  636. parser := ParseVSFrameUncompressed
  637. |VSFrameMjpeg:
  638. parser := ParseVSFrameMjpeg
  639. |VSFormatMpeg2ts:
  640. parser := ParseVSFrameMpeg2ts
  641. |VSFormatH264:
  642. parser := ParseVSFrameH264
  643. |VSFormatVp8:
  644. parser := ParseVSFrameVp8
  645. ELSE
  646. KernelLog.String("Unknown Frame subtype: "); KernelLog.Int(ORD(buffer[pos]), 0); KernelLog.Ln;
  647. RETURN NIL
  648. END;
  649. INC(pos);
  650. idx := ORD(buffer[pos]); INC(pos);
  651. frame := parser(buffer, pos);
  652. frame.bFrameIndex := idx;
  653. RETURN frame
  654. END ParseVSFrame;
  655. PROCEDURE ParseVSFrameUncompressed (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFrameDesc;
  656. VAR
  657. f: VSFrameUncompressedDesc;
  658. i: LONGINT;
  659. BEGIN
  660. NEW(f);
  661. f.bmCapabilities := SYSTEM.VAL(SET, ORD(buffer[pos])); INC(pos);
  662. f.wWidth := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  663. f.wHeight := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  664. f.dwMinBitRate := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  665. f.dwMaxBitRate := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  666. f.dwMaxVideoFrameBufferSize := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  667. f.dwDefaultFrameInterval := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  668. f.bFrameIntervalType := ORD(buffer[pos]); INC(pos);
  669. IF f.bFrameIntervalType = 0 THEN
  670. f.dwMinFrameInterval := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  671. f.dwMaxFrameInterval := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  672. f.dwFrameIntervalStep := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  673. ELSE
  674. NEW(f.dwaFrameInterval, f.bFrameIntervalType);
  675. FOR i := 0 TO f.bFrameIntervalType - 1 DO
  676. f.dwaFrameInterval[i] := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  677. END
  678. END;
  679. RETURN f
  680. END ParseVSFrameUncompressed;
  681. PROCEDURE ParseVSFrameMjpeg (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFrameDesc;
  682. VAR
  683. f: VSFrameMjpegDesc;
  684. i: LONGINT;
  685. BEGIN
  686. NEW(f);
  687. f.bmCapabilities := SYSTEM.VAL(SET, ORD(buffer[pos])); INC(pos);
  688. f.wWidth := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  689. f.wHeight := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  690. f.dwMinBitRate := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  691. f.dwMaxBitRate := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  692. f.dwMaxVideoFrameBufferSize := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  693. f.dwDefaultFrameInterval := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  694. f.bFrameIntervalType := ORD(buffer[pos]); INC(pos);
  695. IF f.bFrameIntervalType = 0 THEN
  696. f.dwMinFrameInterval := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  697. f.dwMaxFrameInterval := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  698. f.dwFrameIntervalStep := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  699. ELSE
  700. NEW(f.dwaFrameInterval, f.bFrameIntervalType);
  701. FOR i := 0 TO f.bFrameIntervalType - 1 DO
  702. f.dwaFrameInterval[i] := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H + ORD(buffer[pos + 2]) * 10000H + ORD(buffer[pos + 3]) * 1000000H; INC(pos, 4);
  703. END
  704. END;
  705. RETURN f
  706. END ParseVSFrameMjpeg;
  707. PROCEDURE ParseVSFrameMpeg2ts (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFrameDesc;
  708. BEGIN
  709. (*! TODO *)
  710. END ParseVSFrameMpeg2ts;
  711. PROCEDURE ParseVSFrameH264 (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFrameDesc;
  712. BEGIN
  713. (*! TODO *)
  714. END ParseVSFrameH264;
  715. PROCEDURE ParseVSFrameVp8 (CONST buffer: ARRAY OF CHAR; pos: LONGINT): VSFrameDesc;
  716. BEGIN
  717. (*! TODO *)
  718. END ParseVSFrameVp8;
  719. PROCEDURE ParseStillImageDesc * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): StillImageDesc;
  720. VAR
  721. s: StillImageDesc;
  722. i: LONGINT;
  723. BEGIN
  724. TRACE(LEN(buffer), pos);
  725. ASSERT(ORD(buffer[pos]) > 10); INC(pos);
  726. ASSERT(ORD(buffer[pos]) = Interface); INC(pos);
  727. ASSERT(ORD(buffer[pos]) = VSStillImageFrame); INC(pos);
  728. NEW(s);
  729. s.bEndpointAddress := ORD(buffer[pos]); INC(pos);
  730. s.bNumImageSizePattern := ORD(buffer[pos]); INC(pos);
  731. NEW(s.waWidth, s.bNumImageSizePattern);
  732. NEW(s.waHeight, s.bNumImageSizePattern);
  733. FOR i := 0 TO s.bNumImageSizePattern - 1 DO
  734. s.waWidth[i] := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2);
  735. s.waHeight[i] := ORD(buffer[pos]) + ORD(buffer[pos + 1]) * 100H; INC(pos, 2)
  736. END;
  737. TRACE(pos);
  738. s.bNumCompressionPattern := ORD(buffer[pos]); INC(pos);
  739. TRACE(pos, s.bNumCompressionPattern);
  740. NEW(s.baCompression, s.bNumCompressionPattern);
  741. FOR i := 0 TO s.bNumCompressionPattern - 1 DO
  742. s.baCompression[i] := ORD(buffer[pos + i]);
  743. END;
  744. RETURN s
  745. END ParseStillImageDesc;
  746. PROCEDURE ParseColorMatchingDesc * (CONST buffer: ARRAY OF CHAR; pos: LONGINT): ColorMatchingDesc;
  747. VAR
  748. c: ColorMatchingDesc;
  749. BEGIN
  750. ASSERT(ORD(buffer[pos]) = 6); INC(pos);
  751. ASSERT(ORD(buffer[pos]) = Interface); INC(pos);
  752. ASSERT(ORD(buffer[pos]) = VSColorFormat); INC(pos);
  753. NEW(c);
  754. c.bColorPrimaries := ORD(buffer[pos]); INC(pos);
  755. c.bTransferCharacteristics := ORD(buffer[pos]); INC(pos);
  756. c.bMatrixCoefficients := ORD(buffer[pos]); INC(pos);
  757. RETURN c
  758. END ParseColorMatchingDesc;
  759. PROCEDURE PrintVC * (vc: VideoControlDesc);
  760. VAR
  761. i: LONGINT;
  762. BEGIN
  763. KernelLog.String("= VideoControlDesc ="); KernelLog.Ln;
  764. KernelLog.String(" version: "); KernelLog.Int(vc.bcdUVC, 0); KernelLog.Ln;
  765. KernelLog.String(" total len: "); KernelLog.Int(vc.wTotalLength, 0); KernelLog.Ln;
  766. KernelLog.String(" clock f.: "); KernelLog.Int(vc.dwClockFrequency, 0); KernelLog.Ln;
  767. KernelLog.String(" # of VS: "); KernelLog.Int(vc.bInCollection, 0); KernelLog.Ln;
  768. KernelLog.String(" VSs: ");
  769. FOR i := 0 TO vc.bInCollection - 1 DO
  770. KernelLog.Int(vc.baInterfaceNr[i], 0); KernelLog.String(" ")
  771. END;
  772. KernelLog.Ln
  773. END PrintVC;
  774. PROCEDURE PrintUnit * (unit: Unit);
  775. BEGIN
  776. IF unit = NIL THEN KernelLog.String("= NIL UNIT =")
  777. ELSIF unit IS CameraTerminalDesc THEN
  778. PrintCT(unit(CameraTerminalDesc))
  779. ELSIF unit IS InputTerminalDesc THEN
  780. PrintIT(unit(InputTerminalDesc))
  781. ELSIF unit IS OutputTerminalDesc THEN
  782. PrintOT(unit(OutputTerminalDesc))
  783. ELSIF unit IS ProcessingUnitDesc THEN
  784. PrintProcUnit(unit(ProcessingUnitDesc))
  785. ELSIF unit IS ExtensionUnitDesc THEN
  786. PrintExtUnit(unit(ExtensionUnitDesc))
  787. ELSE
  788. KernelLog.String("= UNKNOWN UNIT ="); KernelLog.Ln;
  789. END;
  790. END PrintUnit;
  791. PROCEDURE PrintIT * (i: InputTerminalDesc);
  792. BEGIN
  793. KernelLog.String("= InputTerminalDesc ="); KernelLog.Ln;
  794. KernelLog.String(" id: "); KernelLog.Int(i.bUnitID, 0); KernelLog.Ln;
  795. KernelLog.String(" type: "); (*KernelLog.Int(i.wTerminalType, 0); KernelLog.Ln;*)
  796. CASE i.wTerminalType OF
  797. TypeVendorSpecific: KernelLog.String("vendor specific")
  798. |TypeStreaming: KernelLog.String("streaming")
  799. |TypeInVendorSpecific: KernelLog.String("vendor specific input")
  800. |TypeInCamera: KernelLog.String("camera")
  801. |TypeInMediaTransportInput: KernelLog.String("media transport input")
  802. ELSE
  803. KernelLog.String("uknown "); KernelLog.Int(i.wTerminalType, 0)
  804. END;
  805. KernelLog.Ln;
  806. KernelLog.String(" assoc: "); KernelLog.Int(i.bAssocTerminal, 0); KernelLog.Ln;
  807. KernelLog.String(" str: "); KernelLog.Int(i.iTerminal, 0); KernelLog.Ln;
  808. END PrintIT;
  809. PROCEDURE PrintCT * (c: CameraTerminalDesc);
  810. BEGIN
  811. PrintIT(c);
  812. KernelLog.String(" obj min focal: "); KernelLog.Int(c.wObjectiveFocalLengthMin, 0); KernelLog.Ln;
  813. KernelLog.String(" obj max focal: "); KernelLog.Int(c.wObjectiveFocalLengthMax, 0); KernelLog.Ln;
  814. KernelLog.String(" ocular min: "); KernelLog.Int(c.wOcularFocalLength, 0); KernelLog.Ln;
  815. KernelLog.String(" ctrl len: "); KernelLog.Int(c.bControlSize, 0); KernelLog.Ln;
  816. KernelLog.String(" ctrls: "); KernelLog.Set(c.bmControls); KernelLog.Ln
  817. END PrintCT;
  818. PROCEDURE PrintOT * (o: OutputTerminalDesc);
  819. BEGIN
  820. KernelLog.String("= OutputTerminalDesc ="); KernelLog.Ln;
  821. KernelLog.String(" id: "); KernelLog.Int(o.bUnitID, 0); KernelLog.Ln;
  822. KernelLog.String(" type: ");
  823. CASE o.wTerminalType OF
  824. TypeVendorSpecific: KernelLog.String("vendor specific")
  825. |TypeStreaming: KernelLog.String("streaming")
  826. |TypeOutVendorSpecific: KernelLog.String("vendor specific output")
  827. |TypeOutDisplay: KernelLog.String("display")
  828. |TypeOutMediaTransportOutput: KernelLog.String("media transport output")
  829. ELSE
  830. KernelLog.String("uknown "); KernelLog.Int(o.wTerminalType, 0)
  831. END;
  832. KernelLog.Ln;
  833. KernelLog.String(" assoc: "); KernelLog.Int(o.bAssocTerminal, 0); KernelLog.Ln;
  834. KernelLog.String(" source: "); KernelLog.Int(o.bSourceID, 0); KernelLog.Ln;
  835. KernelLog.String(" str: "); KernelLog.Int(o.iTerminal, 0); KernelLog.Ln;
  836. END PrintOT;
  837. PROCEDURE PrintProcUnit * (p: ProcessingUnitDesc);
  838. BEGIN
  839. KernelLog.String("= ProcessingUnitDesc ="); KernelLog.Ln;
  840. KernelLog.String(" id: "); KernelLog.Int(p.bUnitID, 0); KernelLog.Ln;
  841. KernelLog.String(" src: "); KernelLog.Int(p.bSourceID, 0); KernelLog.Ln;
  842. KernelLog.String(" max mult: "); KernelLog.Int(p.wMaxMultiplier, 0); KernelLog.Ln;
  843. KernelLog.String(" ctrl len: "); KernelLog.Int(p.bControlSize, 0); KernelLog.Ln;
  844. KernelLog.String(" ctrls: "); KernelLog.Set(p.bmControls); KernelLog.Ln;
  845. KernelLog.String(" str: "); KernelLog.Int(p.iProcessing, 0); KernelLog.Ln;
  846. KernelLog.String(" video stds: "); KernelLog.Set(p.bmVideoStandards); KernelLog.Ln;
  847. END PrintProcUnit;
  848. PROCEDURE PrintExtUnit * (e: ExtensionUnitDesc);
  849. VAR
  850. i: LONGINT;
  851. BEGIN
  852. KernelLog.String("= ExtensionUnitDesc ="); KernelLog.Ln;
  853. KernelLog.String(" id: "); KernelLog.Int(e.bUnitID, 0); KernelLog.Ln;
  854. KernelLog.String(" ext code: ");
  855. FOR i := 0 TO 15 DO KernelLog.Hex(ORD(e.guidExtensionCode[i]), -2); KernelLog.String(' ') END;
  856. KernelLog.Ln;
  857. KernelLog.String(" # ctrls: "); KernelLog.Int(e.bNumControls, 0); KernelLog.Ln;
  858. KernelLog.String(" # src: "); KernelLog.Int(e.bNrInPins, 0); KernelLog.Ln;
  859. KernelLog.String(" srcs: ");
  860. FOR i := 0 TO e.bNrInPins - 1 DO
  861. KernelLog.Int(e.baSourceID[i], 0); KernelLog.String(" ")
  862. END;
  863. KernelLog.Ln;
  864. KernelLog.String(" ctrl len: "); KernelLog.Int(e.bControlSize, 0); KernelLog.Ln;
  865. KernelLog.String(" ctrls: "); KernelLog.Set(e.bmControls); KernelLog.Ln;
  866. KernelLog.String(" str: "); KernelLog.Int(e.iExtension, 0); KernelLog.Ln;
  867. END PrintExtUnit;
  868. PROCEDURE PrintEndpoint * (e: InterruptEndpointDesc);
  869. BEGIN
  870. KernelLog.String("= InterruptEndpointDesc ="); KernelLog.Ln;
  871. KernelLog.String(" address: "); KernelLog.Int(e.bEndpointAddress, 0); KernelLog.Ln;
  872. KernelLog.String(" attributes: "); KernelLog.Set(e.bmAttributes); KernelLog.Ln;
  873. KernelLog.String(" packet size: "); KernelLog.Int(e.wMaxPacketSize, 0); KernelLog.Ln;
  874. KernelLog.String(" interval: "); KernelLog.Int(e.bInterval, 0); KernelLog.Ln
  875. END PrintEndpoint;
  876. PROCEDURE PrintVSInputHeader * (hdr: VSInputHeaderDesc);
  877. VAR
  878. i: LONGINT;
  879. BEGIN
  880. KernelLog.String("= VideoStreaming InputHeaderDesc ="); KernelLog.Ln;
  881. KernelLog.String(" # formats: "); KernelLog.Int(hdr.bNumFormats, 0); KernelLog.Ln;
  882. KernelLog.String(" length: "); KernelLog.Int(hdr.wTotalLength, 0); KernelLog.Ln;
  883. KernelLog.String(" ep adr: "); KernelLog.Int(hdr.bEndpointAddress, 0); KernelLog.Ln;
  884. KernelLog.String(" info: "); KernelLog.Set(hdr.bmInfo); KernelLog.Ln;
  885. KernelLog.String(" term. lnk: "); KernelLog.Int(hdr.bTerminalLink, 0); KernelLog.Ln;
  886. KernelLog.String(" still capture method: "); KernelLog.Int(hdr.bStillCaptureMethod, 0); KernelLog.Ln;
  887. KernelLog.String(" trigger support: "); KernelLog.Int(hdr.bTriggerSupport, 0); KernelLog.Ln;
  888. KernelLog.String(" trigger usage: "); KernelLog.Int(hdr.bTriggerUsage, 0); KernelLog.Ln;
  889. KernelLog.String(" control size: "); KernelLog.Int(hdr.bControlSize, 0); KernelLog.Ln;
  890. KernelLog.String(" controls: ");
  891. FOR i := 0 TO hdr.bNumFormats - 1 DO KernelLog.Set(hdr.bmaControls[i]); KernelLog.String(" ") END;
  892. KernelLog.Ln
  893. END PrintVSInputHeader;
  894. PROCEDURE PrintStillImageDesc * (s: StillImageDesc);
  895. VAR
  896. i: LONGINT;
  897. BEGIN
  898. KernelLog.String("= VideoStreaming Still Image Descriptor ="); KernelLog.Ln;
  899. KernelLog.String(" endpoint adr: "); KernelLog.Int(s.bEndpointAddress, 0); KernelLog.Ln;
  900. KernelLog.String(" # im size pattern: "); KernelLog.Int(s.bNumImageSizePattern, 0); KernelLog.Ln;
  901. KernelLog.String(" im size patterns: ");
  902. FOR i := 0 TO s.bNumImageSizePattern - 1 DO
  903. KernelLog.Int(s.waWidth[i], 0); KernelLog.String('x'); KernelLog.Int(s.waHeight[i], 0); KernelLog.String(" ");
  904. END;
  905. KernelLog.Ln;
  906. KernelLog.String(" # comp. pattern: "); KernelLog.Int(s.bNumCompressionPattern, 0); KernelLog.Ln;
  907. KernelLog.String(" comp. patterns: ");
  908. FOR i := 0 TO s.bNumCompressionPattern - 1 DO
  909. KernelLog.Int(s.baCompression[i], 0); KernelLog.String(" ")
  910. END;
  911. KernelLog.Ln
  912. END PrintStillImageDesc;
  913. PROCEDURE PrintColorMatchingDesc * (c: ColorMatchingDesc);
  914. BEGIN
  915. KernelLog.String("= VideoStreaming Color Matching Desc ="); KernelLog.Ln;
  916. KernelLog.String(" color primaries: "); KernelLog.Int(c.bColorPrimaries, 0); KernelLog.Ln;
  917. KernelLog.String(" tranfer charac.: "); KernelLog.Int(c.bTransferCharacteristics, 0); KernelLog.Ln;
  918. KernelLog.String(" matrix coefs.: "); KernelLog.Int(c.bMatrixCoefficients, 0); KernelLog.Ln;
  919. END PrintColorMatchingDesc;
  920. END UsbVideoDesc.