bt832.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /* Bt832 CMOS Camera Video Processor (VP)
  2. The Bt832 CMOS Camera Video Processor chip connects a Quartsight CMOS
  3. color digital camera directly to video capture devices via an 8-bit,
  4. 4:2:2 YUV or YCrCb video interface.
  5. i2c addresses: 0x88 or 0x8a
  6. */
  7. /* The 64 registers: */
  8. // Input Processor
  9. #define BT832_OFFSET 0
  10. #define BT832_RCOMP 1
  11. #define BT832_G1COMP 2
  12. #define BT832_G2COMP 3
  13. #define BT832_BCOMP 4
  14. // Exposures:
  15. #define BT832_FINEH 5
  16. #define BT832_FINEL 6
  17. #define BT832_COARSEH 7
  18. #define BT832_COARSEL 8
  19. #define BT832_CAMGAIN 9
  20. // Main Processor:
  21. #define BT832_M00 10
  22. #define BT832_M01 11
  23. #define BT832_M02 12
  24. #define BT832_M10 13
  25. #define BT832_M11 14
  26. #define BT832_M12 15
  27. #define BT832_M20 16
  28. #define BT832_M21 17
  29. #define BT832_M22 18
  30. #define BT832_APCOR 19
  31. #define BT832_GAMCOR 20
  32. // Level Accumulator Inputs
  33. #define BT832_VPCONTROL2 21
  34. #define BT832_ZONECODE0 22
  35. #define BT832_ZONECODE1 23
  36. #define BT832_ZONECODE2 24
  37. #define BT832_ZONECODE3 25
  38. // Level Accumulator Outputs:
  39. #define BT832_RACC 26
  40. #define BT832_GACC 27
  41. #define BT832_BACC 28
  42. #define BT832_BLACKACC 29
  43. #define BT832_EXP_AGC 30
  44. #define BT832_LACC0 31
  45. #define BT832_LACC1 32
  46. #define BT832_LACC2 33
  47. #define BT832_LACC3 34
  48. #define BT832_LACC4 35
  49. #define BT832_LACC5 36
  50. #define BT832_LACC6 37
  51. #define BT832_LACC7 38
  52. // System:
  53. #define BT832_VP_CONTROL0 39
  54. #define BT832_VP_CONTROL1 40
  55. #define BT832_THRESH 41
  56. #define BT832_VP_TESTCONTROL0 42
  57. #define BT832_VP_DMCODE 43
  58. #define BT832_ACB_CONFIG 44
  59. #define BT832_ACB_GNBASE 45
  60. #define BT832_ACB_MU 46
  61. #define BT832_CAM_TEST0 47
  62. #define BT832_AEC_CONFIG 48
  63. #define BT832_AEC_TL 49
  64. #define BT832_AEC_TC 50
  65. #define BT832_AEC_TH 51
  66. // Status:
  67. #define BT832_VP_STATUS 52
  68. #define BT832_VP_LINECOUNT 53
  69. #define BT832_CAM_DEVICEL 54 // e.g. 0x19
  70. #define BT832_CAM_DEVICEH 55 // e.g. 0x40 == 0x194 Mask0, 0x194 = 404 decimal (VVL-404 camera)
  71. #define BT832_CAM_STATUS 56
  72. #define BT832_56_CAMERA_PRESENT 0x20
  73. //Camera Setups:
  74. #define BT832_CAM_SETUP0 57
  75. #define BT832_CAM_SETUP1 58
  76. #define BT832_CAM_SETUP2 59
  77. #define BT832_CAM_SETUP3 60
  78. // System:
  79. #define BT832_DEFCOR 61
  80. #define BT832_VP_TESTCONTROL1 62
  81. #define BT832_DEVICE_ID 63
  82. # define BT832_DEVICE_ID__31 0x31 // Bt832 has ID 0x31
  83. /* STMicroelectronivcs VV5404 camera module
  84. i2c: 0x20: sensor address
  85. i2c: 0xa0: eeprom for ccd defect map
  86. */
  87. #define VV5404_device_h 0x00 // 0x19
  88. #define VV5404_device_l 0x01 // 0x40
  89. #define VV5404_status0 0x02
  90. #define VV5404_linecountc 0x03 // current line counter
  91. #define VV5404_linecountl 0x04
  92. #define VV5404_setup0 0x10
  93. #define VV5404_setup1 0x11
  94. #define VV5404_setup2 0x12
  95. #define VV5404_setup4 0x14
  96. #define VV5404_setup5 0x15
  97. #define VV5404_fine_h 0x20 // fine exposure
  98. #define VV5404_fine_l 0x21
  99. #define VV5404_coarse_h 0x22 //coarse exposure
  100. #define VV5404_coarse_l 0x23
  101. #define VV5404_gain 0x24 // ADC pre-amp gain setting
  102. #define VV5404_clk_div 0x25
  103. #define VV5404_cr 0x76 // control register
  104. #define VV5404_as0 0x77 // ADC setup register
  105. // IOCTL
  106. #define BT832_HEXDUMP _IOR('b',1,int)
  107. #define BT832_REATTACH _IOR('b',2,int)
  108. /* from BT8x8VXD/capdrv/dialogs.cpp */
  109. /*
  110. typedef enum { SVI, Logitech, Rockwell } CAMERA;
  111. static COMBOBOX_ENTRY gwCameraOptions[] =
  112. {
  113. { SVI, "Silicon Vision 512N" },
  114. { Logitech, "Logitech VideoMan 1.3" },
  115. { Rockwell, "Rockwell QuartzSight PCI 1.0" }
  116. };
  117. // SRAM table values
  118. //===========================================================================
  119. typedef enum { TGB_NTSC624, TGB_NTSC780, TGB_NTSC858, TGB_NTSC392 } TimeGenByte;
  120. BYTE SRAMTable[][ 60 ] =
  121. {
  122. // TGB_NTSC624
  123. {
  124. 0x33, // size of table = 51
  125. 0x0E, 0xC0, 0x00, 0x00, 0x90, 0x02, 0x03, 0x10, 0x03, 0x06,
  126. 0x10, 0x04, 0x12, 0x12, 0x05, 0x02, 0x13, 0x04, 0x19, 0x00,
  127. 0x04, 0x39, 0x00, 0x06, 0x59, 0x08, 0x03, 0x85, 0x08, 0x07,
  128. 0x03, 0x50, 0x00, 0x91, 0x40, 0x00, 0x11, 0x01, 0x01, 0x4D,
  129. 0x0D, 0x02, 0x03, 0x11, 0x01, 0x05, 0x37, 0x00, 0x37, 0x21, 0x00
  130. },
  131. // TGB_NTSC780
  132. {
  133. 0x33, // size of table = 51
  134. 0x0e, 0xc0, 0x00, 0x00, 0x90, 0xe2, 0x03, 0x10, 0x03, 0x06,
  135. 0x10, 0x34, 0x12, 0x12, 0x65, 0x02, 0x13, 0x24, 0x19, 0x00,
  136. 0x24, 0x39, 0x00, 0x96, 0x59, 0x08, 0x93, 0x85, 0x08, 0x97,
  137. 0x03, 0x50, 0x50, 0xaf, 0x40, 0x30, 0x5f, 0x01, 0xf1, 0x7f,
  138. 0x0d, 0xf2, 0x03, 0x11, 0xf1, 0x05, 0x37, 0x30, 0x85, 0x21, 0x50
  139. },
  140. // TGB_NTSC858
  141. {
  142. 0x33, // size of table = 51
  143. 0x0c, 0xc0, 0x00, 0x00, 0x90, 0xc2, 0x03, 0x10, 0x03, 0x06,
  144. 0x10, 0x34, 0x12, 0x12, 0x65, 0x02, 0x13, 0x24, 0x19, 0x00,
  145. 0x24, 0x39, 0x00, 0x96, 0x59, 0x08, 0x93, 0x83, 0x08, 0x97,
  146. 0x03, 0x50, 0x30, 0xc0, 0x40, 0x30, 0x86, 0x01, 0x01, 0xa6,
  147. 0x0d, 0x62, 0x03, 0x11, 0x61, 0x05, 0x37, 0x30, 0xac, 0x21, 0x50
  148. },
  149. // TGB_NTSC392
  150. // This table has been modified to be used for Fusion Rev D
  151. {
  152. 0x2A, // size of table = 42
  153. 0x06, 0x08, 0x04, 0x0a, 0xc0, 0x00, 0x18, 0x08, 0x03, 0x24,
  154. 0x08, 0x07, 0x02, 0x90, 0x02, 0x08, 0x10, 0x04, 0x0c, 0x10,
  155. 0x05, 0x2c, 0x11, 0x04, 0x55, 0x48, 0x00, 0x05, 0x50, 0x00,
  156. 0xbf, 0x0c, 0x02, 0x2f, 0x3d, 0x00, 0x2f, 0x3f, 0x00, 0xc3,
  157. 0x20, 0x00
  158. }
  159. };
  160. //===========================================================================
  161. // This is the structure of the camera specifications
  162. //===========================================================================
  163. typedef struct tag_cameraSpec
  164. {
  165. SignalFormat signal; // which digital signal format the camera has
  166. VideoFormat vidFormat; // video standard
  167. SyncVideoRef syncRef; // which sync video reference is used
  168. State syncOutput; // enable sync output for sync video input?
  169. DecInputClk iClk; // which input clock is used
  170. TimeGenByte tgb; // which timing generator byte does the camera use
  171. int HReset; // select 64, 48, 32, or 16 CLKx1 for HReset
  172. PLLFreq pllFreq; // what synthesized frequency to set PLL to
  173. VSIZEPARMS vSize; // video size the camera produces
  174. int lineCount; // expected total number of half-line per frame - 1
  175. BOOL interlace; // interlace signal?
  176. } CameraSpec;
  177. //===========================================================================
  178. // <UPDATE REQUIRED>
  179. // Camera specifications database. Update this table whenever camera spec
  180. // has been changed or added/deleted supported camera models
  181. //===========================================================================
  182. static CameraSpec dbCameraSpec[ N_CAMERAOPTIONS ] =
  183. { // Silicon Vision 512N
  184. { Signal_CCIR656, VFormat_NTSC, VRef_alignedCb, Off, DecClk_GPCLK, TGB_NTSC624, 64, KHz19636,
  185. // Clkx1_HACTIVE, Clkx1_HDELAY, VActive, VDelay, linesPerField; lineCount, Interlace
  186. { 512, 0x64, 480, 0x13, 240 }, 0, TRUE
  187. },
  188. // Logitech VideoMan 1.3
  189. { Signal_CCIR656, VFormat_NTSC, VRef_alignedCb, Off, DecClk_GPCLK, TGB_NTSC780, 64, KHz24545,
  190. // Clkx1_HACTIVE, Clkx1_HDELAY, VActive, VDelay, linesPerField; lineCount, Interlace
  191. { 640, 0x80, 480, 0x1A, 240 }, 0, TRUE
  192. },
  193. // Rockwell QuartzSight
  194. // Note: Fusion Rev D (rev ID 0x02) and later supports 16 pixels for HReset which is preferable.
  195. // Use 32 for earlier version of hardware. Clkx1_HDELAY also changed from 0x27 to 0x20.
  196. { Signal_CCIR656, VFormat_NTSC, VRef_alignedCb, Off, DecClk_GPCLK, TGB_NTSC392, 16, KHz28636,
  197. // Clkx1_HACTIVE, Clkx1_HDELAY, VActive, VDelay, linesPerField; lineCount, Interlace
  198. { 352, 0x20, 576, 0x08, 288 }, 607, FALSE
  199. }
  200. };
  201. */
  202. /*
  203. The corresponding APIs required to be invoked are:
  204. SetConnector( ConCamera, TRUE/FALSE );
  205. SetSignalFormat( spec.signal );
  206. SetVideoFormat( spec.vidFormat );
  207. SetSyncVideoRef( spec.syncRef );
  208. SetEnableSyncOutput( spec.syncOutput );
  209. SetTimGenByte( SRAMTable[ spec.tgb ], SRAMTableSize[ spec.tgb ] );
  210. SetHReset( spec.HReset );
  211. SetPLL( spec.pllFreq );
  212. SetDecInputClock( spec.iClk );
  213. SetVideoInfo( spec.vSize );
  214. SetTotalLineCount( spec.lineCount );
  215. SetInterlaceMode( spec.interlace );
  216. */
  217. /* from web:
  218. Video Sampling
  219. Digital video is a sampled form of analog video. The most common sampling schemes in use today are:
  220. Pixel Clock Horiz Horiz Vert
  221. Rate Total Active
  222. NTSC square pixel 12.27 MHz 780 640 525
  223. NTSC CCIR-601 13.5 MHz 858 720 525
  224. NTSC 4FSc 14.32 MHz 910 768 525
  225. PAL square pixel 14.75 MHz 944 768 625
  226. PAL CCIR-601 13.5 MHz 864 720 625
  227. PAL 4FSc 17.72 MHz 1135 948 625
  228. For the CCIR-601 standards, the sampling is based on a static orthogonal sampling grid. The luminance component (Y) is sampled at 13.5 MHz, while the two color difference signals, Cr and Cb are sampled at half that, or 6.75 MHz. The Cr and Cb samples are colocated with alternate Y samples, and they are taken at the same position on each line, such that one sample is coincident with the 50% point of the falling edge of analog sync. The samples are coded to either 8 or 10 bits per component.
  229. */
  230. /* from DScaler:*/
  231. /*
  232. //===========================================================================
  233. // CCIR656 Digital Input Support: The tables were taken from DScaler proyect
  234. //
  235. // 13 Dec 2000 - Michael Eskin, Conexant Systems - Initial version
  236. //
  237. //===========================================================================
  238. // Timing generator SRAM table values for CCIR601 720x480 NTSC
  239. //===========================================================================
  240. // For NTSC CCIR656
  241. BYTE BtCard::SRAMTable_NTSC[] =
  242. {
  243. // SRAM Timing Table for NTSC
  244. 0x0c, 0xc0, 0x00,
  245. 0x00, 0x90, 0xc2,
  246. 0x03, 0x10, 0x03,
  247. 0x06, 0x10, 0x34,
  248. 0x12, 0x12, 0x65,
  249. 0x02, 0x13, 0x24,
  250. 0x19, 0x00, 0x24,
  251. 0x39, 0x00, 0x96,
  252. 0x59, 0x08, 0x93,
  253. 0x83, 0x08, 0x97,
  254. 0x03, 0x50, 0x30,
  255. 0xc0, 0x40, 0x30,
  256. 0x86, 0x01, 0x01,
  257. 0xa6, 0x0d, 0x62,
  258. 0x03, 0x11, 0x61,
  259. 0x05, 0x37, 0x30,
  260. 0xac, 0x21, 0x50
  261. };
  262. //===========================================================================
  263. // Timing generator SRAM table values for CCIR601 720x576 NTSC
  264. //===========================================================================
  265. // For PAL CCIR656
  266. BYTE BtCard::SRAMTable_PAL[] =
  267. {
  268. // SRAM Timing Table for PAL
  269. 0x36, 0x11, 0x01,
  270. 0x00, 0x90, 0x02,
  271. 0x05, 0x10, 0x04,
  272. 0x16, 0x14, 0x05,
  273. 0x11, 0x00, 0x04,
  274. 0x12, 0xc0, 0x00,
  275. 0x31, 0x00, 0x06,
  276. 0x51, 0x08, 0x03,
  277. 0x89, 0x08, 0x07,
  278. 0xc0, 0x44, 0x00,
  279. 0x81, 0x01, 0x01,
  280. 0xa9, 0x0d, 0x02,
  281. 0x02, 0x50, 0x03,
  282. 0x37, 0x3d, 0x00,
  283. 0xaf, 0x21, 0x00,
  284. };
  285. */