00001
00002
00003
00004
00005
00006 #ifndef _ASM_CMOSCAM_H
00007 #define _ASM_CMOSCAM_H
00008
00009 #define ELPHEL_DEBUG 0 //global debug on/off in multiple files
00010
00011 #define ETRAXFS_MMAP_CACHE_BUG y
00012
00013
00014
00015
00016 #define CMOSCAM_IOCTYPE 124
00017
00018
00019
00020 #define CMOSCAM_MINOR_FRAME 1
00021 #define CMOSCAM_MINOR_FPN 2
00022
00023
00024
00025 #define CMOSCAM_MINOR_I2C 3
00026 #define CMOSCAM_MINOR_DMA 4
00027 #define CMOSCAM_MINOR_MCP 5
00028 #define CMOSCAM_MINOR_LOCK 6
00029 #define CMOSCAM_MINOR_UNLOCK 7
00030 #define CMOSCAM_MINOR_SENSORJTAGFPGA 8
00031 #define CMOSCAM_MINOR_RWTABLES 9
00032 #define CMOSCAM_MINOR_SENSORFPGACOMM 10
00033 #define CMOSCAM_MINOR_CIRCBUF 11
00034 #define CMOSCAM_MINOR_HISTOGRAM 12
00035 #define CMOSCAM_MINOR_JPEAGHEAD 13
00036 #define CMOSCAM_MINOR_GAMMA 14
00037 #define CMOSCAM_MINOR_SENSPARS 15
00038
00039
00040 #define X3X3_I2C 134
00041
00042 #define X3X3_I2C_CTRL 0 // control/reset i2c
00043 #define X3X3_I2C_8_AINC 1 // 8bit registers, autoincement while read/write
00044 #define X3X3_I2C_16_AINC 2 // 16bit registers, autoincement while read/write
00045 #define X3X3_I2C1_8_AINC 3 // 8bit registers, autoincement while read/write (bus 1)
00046 #define X3X3_I2C1_16_AINC 4 // 16bit registers, autoincement while read/write (bus 1)
00047 #define X3X3_I2C_RAW 5 // 8bit registers, no address byte (just slave, then read/write byte(s)
00048 #define X3X3_I2C1_RAW 6 // 8bit registers, no address byte (just slave, then read/write byte(s)
00049 #define X3X3_I2C_ENABLE 7 // enable(/protect) different I2C devices for different types of I2C accesses
00050 #define X3X3_I2C_ENABLE_RD 0 // bit 0 - enable i2c read
00051 #define X3X3_I2C_ENABLE_WR 1 // bit 1 - enable i2c write
00052 #define X3X3_I2C_ENABLE_RAW 2 // bit 2 - enable i2c raw (no address byte)
00053 #define X3X3_I2C_ENABLE_8 3 // bit 3 - enable i2c 8-bit registers access
00054 #define X3X3_I2C_ENABLE_16 4 // bit 4 - enable i2c 16-bit registers access
00055 #define X3X3_I2C_MAXMINOR 7 //
00056 #define X3X3_I2C_CHANNELS 2 // number of i2c channels
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 #define CAMSEQ_OFF 0 // off, not programmed (Video mode off on Zoran sensors)
00068 #define CAMSEQ_READY 1 // sensor programmed may acquire at will (programSensor sets number of frames to skip (if any)
00069 #define CAMSEQ_SKIP 2 // skipping specified number of frames, interrupt service routine counts and will start acquisition
00070 #define CAMSEQ_WAIT_F 3 // set by "start exposure" or interrupt service routine. WAIT_F/WAIT_T/acquire/done differs by hardware register
00071 #define CAMSEQ_WAIT_T 4 // set by "start exposure" or interrupt service routine. Wait/acquire/done differs by hardware register
00072 #define CAMSEQ_ACQUIRE 5 // acquisition in progress (camSeqState is still CAMSEQ_WAIT)
00073 #define CAMSEQ_DONE 6 // acquisition over (camSeqState is still CAMSEQ_WAIT)
00074 #define CAMSEQ_JPEG 7 // waiting for JPEG done interrupt, acquiring/compressing some frames
00075
00076 #define CAMSEQ_RUN 8 // compressor is constantly running (but if camSeqCount>0 - just skipping "bad" frames)
00077 #define CAMSEQ_STOP 9 // compressor is constantly running but will stop after next "compressor ready"
00078 #define CAMSEQ_SINGLE 10 // compressor is constantly running to fill one full buffer
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 #define sensorcom_W_size 1024
00091 #define sensorcom_R_size 256
00092
00093
00094
00095 #define MCP_W_size 1024
00096 #define MCP_R_size 256
00097
00098 #define MCPOtherBits 0xffa7a7ff
00099 #define MCPOffReset 0x00101800
00100 #define MCPReset 0x00001800
00101 #define MCPNoReset 0x00105800
00102 #define MCPToggleA 0x00080000
00103 #define MCPToggleB 0x00001000
00104 #define MCPctlseq 0x00
00105 #define MCPsofttg 0x02
00106 #define MCPeackn 0x03
00107 #define MCPctlgate 0x04
00108 #define MCPwstdly 0x06
00109 #define MCPwrsmsk 0x07
00110 #define MCPwrsup 0x08
00111 #define MCPwrmons 0x09
00112 #define MCPwnom 0x0a
00113 #define MCPwdenom 0x0b
00114 #define MCPwoutw 0x0c
00115 #define MCPwinvctl 0x0d
00116 #define MCPctlsync 0x0e
00117 #define MCPwrdlys 0x10
00118 #define MCPwinv 0x40
00119 #define MCPwshared 0x80
00120 #define MCPwrsynctb 0x100
00121 #define MCPwrseq 0x200
00122
00123
00124
00125 #ifndef I2C_WRITEARG
00126 #define I2C_WRITEARG(bus, slave, reg, value) (((bus) << 24) | ((slave) << 16) | ((reg) << 8) | (value))
00127 #define I2C_READARG(bus, slave, reg) (((bus) << 24) | ((slave) << 16) | ((reg) << 8))
00128
00129 #define I2C_ARGBUS(arg) (((arg) >> 24) & 0x1)
00130 #define I2C_ARGSLAVE(arg) (((arg) >> 16) & 0xff)
00131 #define I2C_ARGREG(arg) (((arg) >> 8) & 0xff)
00132 #define I2C_ARGVALUE(arg) ((arg) & 0xff)
00133
00134 #define I2C_DELAYS 0x0
00135
00136
00137
00138
00139
00140
00141 #define I2C_WRITEREG 0x1
00142 #define I2C_READREG 0x2
00143 #endif
00144
00145
00146 #ifndef I2C_16_WRITEARG
00147 #define I2C_16_WRITEREG 0x3
00148 #define I2C_16_READREG 0x4
00149
00150 #define I2C_16_WRITEARG(slave, reg, value) (((slave) << 24) | ((reg) << 16) | (value))
00151 #define I2C_16_READARG(slave, reg) (((slave) << 24) | ((reg) << 16))
00152
00153 #define I2C_16_ARGSLAVE(arg) (((arg) >> 24) & 0xff)
00154 #define I2C_16_ARGREG(arg) (((arg) >> 16) & 0xff)
00155 #define I2C_16_ARGVALUE(arg) ( (arg) & 0xffff)
00156 #define I2C_16_ARGVALUE_H(arg) (((arg) >> 8) & 0xff)
00157 #define I2C_16_ARGVALUE_L(arg) ( (arg) & 0xff)
00158 #endif
00159
00160
00161
00162
00163
00164 #define _CCCMD(x,y) (_IO(CMOSCAM_IOCTYPE, (x << 6) | (y & 0x3f)))
00165
00166
00167
00168 #define CCAM_CTRL(x) ((_IOC_NR(x) >> 6) & 0x03)
00169 #define CCAM_ADDR(x) (_IOC_NR(x) & 0x3f)
00170
00171
00172 #define CCAM_RPARS 2
00173 #define CCAM_WPARS 3
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 #define P_NUMBER 1024 //number of registers (was 64)
00192 #define P_UPDATE 0
00193 #define P_SENSOR 1
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 #define SENSOR_MASK 0xfc
00211 #define SENSOR_ZR32112 0x04
00212 #define SENSOR_ZR32212 0x08
00213 #define SENSOR_KAC1310 0x20
00214 #define SENSOR_KAC5000 0x24
00215 #define SENSOR_MI1300 0x30
00216 #define SENSOR_MT9X001 0x30 // MT9M001 - 31, MT9D001 - 32, MT9T001 - 33, MT9P001 - 34
00217 #define SENSOR_MT9Y001 0x34 // MT9P001 - 34
00218 #define SENSOR_IBIS51300 0x40
00219 #define SENSOR_KAI11000 0x80
00220 #define SENSOR_NONE 0xfc
00221
00222
00223
00224
00225 #define SENSORWIDTH_ZR32112 1280
00226 #define SENSORHEIGHT_ZR32112 1024
00227
00228 #define SENSORWIDTH_ZR32212 1280
00229 #define SENSORHEIGHT_ZR32212 968
00230 #define SENSORWIDTH_KAC1310 1280
00231 #define SENSORHEIGHT_KAC1310 1024
00232
00233
00234 #define SENSORWIDTH_MI1300 1280
00235 #define SENSORHEIGHT_MI1300 1024
00236
00237 #define SENSORWIDTH_MT9M001 1280
00238 #define SENSORHEIGHT_MT9M001 1024
00239 #define SENSORWIDTH_MT9D001 1600
00240 #define SENSORHEIGHT_MT9D001 1200
00241 #define SENSORWIDTH_MT9T001 2048
00242 #define SENSORHEIGHT_MT9T001 1536
00243 #define SENSORWIDTH_MT9P001 2592
00244 #define SENSORHEIGHT_MT9P001 1944
00245
00246 #define SENSORWIDTH_KAC5000 2592
00247 #define SENSORHEIGHT_KAC5000 1944
00248
00249
00250 #define SENSORWIDTH_IBIS51300 1280
00251 #define SENSORHEIGHT_IBIS51300 1024
00252
00254 #define P_PARS_CHANGED 2
00255 #define P_DMA_VALID 3
00256 #define P_ACTUAL_WIDTH 4
00257 #define P_ACTUAL_HEIGHT 5
00258 #define P_LPR 6
00259 #define P_IMAGE_SIZE 7
00260 #define P_BAYER 8
00261 #define P_TRIGGERED 9
00262 #define P_PERIOD 10 // Frame period (read only)
00263 #define P_FRAME 11 // Frame number (reset with JPEG pointers) -(read only)
00264 #define P_JPEG_WP 12 // Last reported JPEG write pointer in the circular buffer. (may have cashe coherency problem,
00266 #define P_CLK_FPGA 13 // FPGA clock in MHz
00267 #define P_CLK_SENSOR 14 // Sensor clock in MHz
00268 #define P_FPGA_XTRA 15 // Extra cycles needed to compressor (probably constant...)
00269
00270
00271 #define P_TRIG 16
00272
00273
00274
00275
00276 #define P_EXPOS 17
00277 #define P_BGFRAME 18 // Background measurement mode - will use 16-bit mode and no FPN correction
00278
00279
00280
00281
00282 #define P_PAGE_ACQ 19 // Number of image page buffer to acquire to (0.1?)
00283 #define P_PAGE_READ 20 // Number of image page buffer to read from to (0.1?)
00284
00285 #define P_OVERLAP 21 // number of EXRA lines to be acquired
00286 #define P_VIDEO 22
00287
00288 #define P_AUXCM 23
00289
00290 #define P_VIRT_WIDTH 24
00291 #define P_VIRT_HEIGHT 25
00292 #define P_WOI_LEFT 26
00293 #define P_WOI_TOP 27
00294 #define P_WOI_WIDTH 28
00295 #define P_WOI_HEIGHT 29
00296
00297 #define P_FLIP 30 // bit 0 - horizontal, bit 1 - vertical
00298
00299
00300
00301 #define P_FPSLM 31 // FPS limit mode - bit 0 - limit fps (not higher than), bit 1 - maintain fps (not lower than)
00302
00303 #define P_DCM_HOR 32
00304 #define P_DCM_VERT 33
00305 #define P_BIN_HOR 34
00306 #define P_BIN_VERT 35
00307
00308 #define P_COLOR 36
00309 #define P_FRAMESYNC_DLY 37
00310 #define P_MCLK 38
00311 #define P_PF_HEIGHT 39
00312
00313
00314 #define P_BITS 40
00315
00316 #define P_SHIFTL 41
00317 #define P_FPNS 42 // FPN correction mode (subtract) 0..3
00318
00319 #define P_FPNM 43 // FPN correction mode (multiply) 0..3
00320
00321 #define P_VEXPOS 44
00322 #define P_VIRTTRIG 45 // Sum of pixels in a line greater than this value - trigger acquisition
00323
00324 #define P_GAINR 46
00325 #define P_GAING 47
00326 #define P_GAINB 48
00327 #define P_GAINGB 49
00328 #define P_FATZERO 50 // subtract while adding data from to consequitive frames (async trigger)
00329
00330 #define P_SPEC_KAC_GGA 51 // KAC-1310 Global gain A , 6 bits, (14)
00331 #define P_SPEC_KAC_GGB 52 // KAC-1310 Global gain B , 6 bits, (14)
00332 #define P_SPEC_KAC_GGM 53 // KAC-1310 Global gain mode, 3 bits, 0
00333
00334 #define P_GAIN 51 // 8.8 (0x100 - gain==1.0) - not used now
00335 #define P_RSCALE 52 // 8.8 (0x100 - rscale==1.0). This parameter applies to digital processing ("gamma" tables, not analog settings)
00336 #define P_BSCALE 53 // 8.8 (0x100 - rscale==1.0). This parameter applies to digital processing ("gamma" tables, not analog settings)
00337
00338
00339
00340 #define P_QUALITY 54 // JPEG IMAGE QUALITY
00341 #define P_FP100S 55 // Frames per 100 sec (fps * 100)
00342 #define P_SENSOR_WIDTH 56
00343 #define P_SENSOR_HEIGHT 57
00344 #define P_COLOR_SATURATION_BLUE 58 // 100*realtive saturation blue
00345 #define P_COLOR_SATURATION_RED 59 // 100*realtive saturation red
00346 #define P_GAMMA 60 // 100*gamma (for now - just a hint table could be more complex. Use higher bytes for colors in 333)
00347 #define P_PIXEL_LOW 61 // (just a hint for gamma table) "fat zero" (on 8-bit scale)
00348 #define P_PIXEL_HIGH 62 // (just a hint for gamma table) highest pixel value (before table) on a 256-scale
00349
00350
00351 #define P_DONTCARE 63 // write anything - just to force update
00352 #define P_PGMSENSRSLT 64 // result of last programSensor() call
00353 #define P_CAMSEQSTATE 65 // sequncer state (to replace camSeqState eventually)?
00354 #define P_CAMSEQCOUNT 66 // sequncer counter (to replace camSeqCount eventually)?
00355 #define P_CIRCBUFSIZE 67 // Size of the circular buffer (in bytes)
00357 #define P_FREECIRCBUF 68 //* Free space in circbuf (uses global read pointer, in bytes)
00358 #define P_CIRCBUFWP 69 //* circbuf write pointer (in bytes - similar P_JPEG_WP is in long words)
00359 #define P_CIRCBUFRP 70 //* circbuf global read pointer (in bytes )
00360 #define P_SECONDS 71 // seconds (R/W to FPGA timer)
00361 #define P_MICROSECONDS 72 // microseconds (R/W to FPGA timer)
00362 #define P_TILES 73 // Number of 16x16 (20x20) tiles in a compressed frame
00363 #define P_SENSOR_PHASE 74 // packed, low 16 bit - signed fine phase, bits [18:17] - 90-degrees shift
00364 #define P_GSCALE 75 // 8.8 (0x100 - gscale==1.0). Additional parameter to compensate for difference in Green/Green1 gains
00365
00367 #define P_AUTOEXP_ON 76 // unsigned long on;
00369 #define P_AUTOEXP_RWIDTH 77 // unsigned long width (%);
00370 #define P_AUTOEXP_RHEIGHT 78 //unsigned long height (%);
00371 #define P_AUTOEXP_RLEFT 79 // unsigned long left (%);
00372 #define P_AUTOEXP_RTOP 80 // unsigned long top (%);
00373 #define P_AUTOEXP_EXP_MAX 81 //unsigned long exp_max;
00374 #define P_AUTOEXP_OVEREXP_MAX 82 // unsigned long overexp_max;
00375 #define P_AUTOEXP_S_PERCENT 83 // unsigned long s_percent;(controlling that % of pixels that should have value greater than S_INDEX - below)
00376 #define P_AUTOEXP_S_INDEX 84 // unsigned long s_index; Specified number of pixels (S_PERCENT) should have value above S_INDEX
00377 #define P_AUTOEXP_EXP 85 // unsigned long exp; Current exposure time
00378 #define P_AUTOEXP_SKIP_PMIN 86 // unsigned long skip_pmin; - no exposure corrections if the desired change is less than that
00379 #define P_AUTOEXP_SKIP_PMAX 87 // unsigned long skip_pmax; - do not apply chnanges if they are to big - wait for the next frame
00380 #define P_AUTOEXP_SKIP_T 88 // unsigned long skip_t; Not quite sure what it is
00381 #define P_AEXPWND_WIDTH 89 // autoexposure window width (pixels)
00382 #define P_AEXPWND_HEIGHT 90 // autoexposure window height (pixels)
00383 #define P_AEXPWND_TOP 91 // autoexposure window top (pixels)
00384 #define P_AEXPWND_LEFT 92 // autoexposure window left (pixels)
00385 #define P_FOCUS_SHOW 93 // show focus information instead of/combined with the image:
00386
00387 #define P_FOCUS_SHOW1 94 // Additional parameter that modifies visualization mode. Currently just a single bit (how much to add)
00388 #define P_FOCUS_VALUE 95 // (readonly) - sum of all blocks focus values inside focus WOI
00389 #define P_FOCUS_LEFT 96 // focus WOI left margin, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block width)
00390 #define P_FOCUS_WIDTH 97 // focus WOI width (3 LSB will be zeroed as it should be multiple of 8x8 block width)
00391 #define P_FOCUS_TOP 98 // focus WOI top margin, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block height)
00392 #define P_FOCUS_HEIGHT 99 // focus WOI height (3 LSB will be zeroed as it should be multiple of 8x8 block height)
00393 #define P_FOCUS_TOTWIDTH 100 // (readonly) - total width of the image frame in pixels
00394 #define P_FOCUS_FILTER 101 // select 8x8 filter used for the focus calculation (same order as quantization coefficients), 0..14
00395
00397
00398 #define P_TRIG_CONDITION 102 // trigger condition, 0 - internal, else dibits ((use<<1) | level) for each GPIO[11:0] pin
00399 #define P_TRIG_DELAY 103 // trigger delay, 32 bits in pixel clocks
00400 #define P_TRIG_OUT 104 // trigger output to GPIO, dibits ((use << 1) | level_when_active). Bit 24 - test mode, when GPIO[11:10] are controlled by other internal signals
00401 #define P_TRIG_PERIOD 105 // output sync period (32 bits, in pixel clocks). 0- stop. 1..256 - single, >=256 repetitive with specified period.
00402
00403 #define P_TASKLET_CTL 106 // disable individual tasklets
00404 #define P_COMPRESSOR_CMD 107 // read only - compressor command, last written to FPGA
00405
00406 #define COMPRESSOR_CMD_RUN 0x080
00407 #define COMPRESSOR_CMD_SINGLE 0x800
00408 #define P_SKIP_FRAMES 108 // number of frames to skip after restarting sensor+compressor
00409 #define P_I2C_QPERIOD 109 // number of system clock periods in 1/4 of i2c SCL period to the sensor/sensor board
00410 #define P_I2C_BYTES 110 // number of bytes in hardware i2c write (after slave addr) -0/1/2
00411 #define P_IRQ_SMART 111 // "smart" IRQ modes: +1 - wait for VACT in early compressor_done, +2 - wait for dma fifo ready
00412 #define P_EARLY_TIMESTAMP 112 // "1" - use start of TRIG pulse as a timetamp moment (0 - use start of first visible line readout) - prevent jitter in async mode
00413 #define P_OVERSIZE 113 // ignore sensor dimensions, use absolute WOI_LEFT, WOI_TOP
00414
00415 #define P_MAX_PAR 127 // maximal # of used parameter
00416 #define P_HIST_NOT_CHANGE 0xffff // will be available as ELPHEL_HIST_NOT_CHANGE constant in PHP
00417
00418
00420 #define P_AUTOEXP P_AUTOEXP_ON
00421 #define P_AEXPWND P_AEXPWND_WIDTH
00422
00423
00424 struct autoexp_t {
00425 unsigned long on;
00426
00427
00428
00429 unsigned long width;
00430 unsigned long height;
00431 unsigned long left;
00432 unsigned long top;
00433
00434
00435
00436 unsigned long exp_max;
00437 unsigned long overexp_max;
00438
00439
00440
00441 unsigned long s_percent;
00442 unsigned long s_index;
00443
00444
00445
00446 unsigned long exp;
00447
00448
00449
00450 unsigned long skip_pmin;
00451 unsigned long skip_pmax;
00452 unsigned long skip_t;
00453 };
00454 struct aexp_window_t {
00455 unsigned long width;
00456 unsigned long height;
00457 unsigned long top;
00458 unsigned long left;
00459 };
00460
00461
00462 struct p_names_t {
00463 int value;
00464 char* name;
00465 };
00466
00467 #define P_NAME_ENTRY(y) { P_##y, #y }
00468 #define DEFINE_P_NAMES(x) struct p_names_t x[]= { \
00469 P_NAME_ENTRY(NUMBER), \
00470 P_NAME_ENTRY(UPDATE), \
00471 P_NAME_ENTRY(SENSOR), \
00472 P_NAME_ENTRY(PARS_CHANGED), \
00473 P_NAME_ENTRY(DMA_VALID), \
00474 P_NAME_ENTRY(ACTUAL_WIDTH), \
00475 P_NAME_ENTRY(ACTUAL_HEIGHT), \
00476 P_NAME_ENTRY(LPR), \
00477 P_NAME_ENTRY(IMAGE_SIZE), \
00478 P_NAME_ENTRY(BAYER), \
00479 P_NAME_ENTRY(TRIGGERED), \
00480 P_NAME_ENTRY(PERIOD), \
00481 P_NAME_ENTRY(FRAME), \
00482 P_NAME_ENTRY(JPEG_WP), \
00483 P_NAME_ENTRY(CLK_FPGA), \
00484 P_NAME_ENTRY(CLK_SENSOR), \
00485 P_NAME_ENTRY(FPGA_XTRA), \
00486 P_NAME_ENTRY(TRIG), \
00487 P_NAME_ENTRY(EXPOS), \
00488 P_NAME_ENTRY(BGFRAME), \
00489 P_NAME_ENTRY(PAGE_ACQ), \
00490 P_NAME_ENTRY(PAGE_READ), \
00491 P_NAME_ENTRY(OVERLAP), \
00492 P_NAME_ENTRY(VIDEO), \
00493 P_NAME_ENTRY(AUXCM), \
00494 P_NAME_ENTRY(VIRT_WIDTH), \
00495 P_NAME_ENTRY(VIRT_HEIGHT), \
00496 P_NAME_ENTRY(WOI_LEFT), \
00497 P_NAME_ENTRY(WOI_TOP), \
00498 P_NAME_ENTRY(WOI_WIDTH), \
00499 P_NAME_ENTRY(WOI_HEIGHT), \
00500 P_NAME_ENTRY(FLIP), \
00501 P_NAME_ENTRY(FPSLM), \
00502 P_NAME_ENTRY(DCM_HOR), \
00503 P_NAME_ENTRY(DCM_VERT), \
00504 P_NAME_ENTRY(BIN_HOR), \
00505 P_NAME_ENTRY(BIN_VERT), \
00506 P_NAME_ENTRY(COLOR), \
00507 P_NAME_ENTRY(FRAMESYNC_DLY), \
00508 P_NAME_ENTRY(MCLK), \
00509 P_NAME_ENTRY(PF_HEIGHT), \
00510 P_NAME_ENTRY(BITS), \
00511 P_NAME_ENTRY(SHIFTL), \
00512 P_NAME_ENTRY(FPNS), \
00513 P_NAME_ENTRY(FPNM), \
00514 P_NAME_ENTRY(VEXPOS), \
00515 P_NAME_ENTRY(VIRTTRIG), \
00516 P_NAME_ENTRY(GAINR), \
00517 P_NAME_ENTRY(GAING), \
00518 P_NAME_ENTRY(GAINB), \
00519 P_NAME_ENTRY(GAINGB), \
00520 P_NAME_ENTRY(FATZERO), \
00521 P_NAME_ENTRY(SPEC_KAC_GGA), \
00522 P_NAME_ENTRY(SPEC_KAC_GGB), \
00523 P_NAME_ENTRY(SPEC_KAC_GGM), \
00524 P_NAME_ENTRY(GAIN), \
00525 P_NAME_ENTRY(RSCALE), \
00526 P_NAME_ENTRY(BSCALE), \
00527 P_NAME_ENTRY(GSCALE), \
00528 P_NAME_ENTRY(QUALITY), \
00529 P_NAME_ENTRY(FP100S), \
00530 P_NAME_ENTRY(SENSOR_WIDTH), \
00531 P_NAME_ENTRY(SENSOR_HEIGHT), \
00532 P_NAME_ENTRY(COLOR_SATURATION_BLUE), \
00533 P_NAME_ENTRY(COLOR_SATURATION_RED), \
00534 P_NAME_ENTRY(GAMMA), \
00535 P_NAME_ENTRY(PIXEL_LOW), \
00536 P_NAME_ENTRY(PIXEL_HIGH), \
00537 P_NAME_ENTRY(DONTCARE), \
00538 P_NAME_ENTRY(PGMSENSRSLT), \
00539 P_NAME_ENTRY(CAMSEQSTATE), \
00540 P_NAME_ENTRY(CAMSEQCOUNT), \
00541 P_NAME_ENTRY(CIRCBUFSIZE), \
00542 P_NAME_ENTRY(FREECIRCBUF), \
00543 P_NAME_ENTRY(CIRCBUFWP), \
00544 P_NAME_ENTRY(CIRCBUFRP), \
00545 P_NAME_ENTRY(TILES), \
00546 P_NAME_ENTRY(SENSOR_PHASE), \
00547 P_NAME_ENTRY(SECONDS), \
00548 P_NAME_ENTRY(MICROSECONDS), \
00549 P_NAME_ENTRY(TILES), \
00550 P_NAME_ENTRY(SENSOR_PHASE), \
00551 P_NAME_ENTRY(AUTOEXP_ON), \
00552 P_NAME_ENTRY(AUTOEXP_RWIDTH), \
00553 P_NAME_ENTRY(AUTOEXP_RHEIGHT), \
00554 P_NAME_ENTRY(AUTOEXP_RLEFT), \
00555 P_NAME_ENTRY(AUTOEXP_RTOP), \
00556 P_NAME_ENTRY(AUTOEXP_EXP_MAX), \
00557 P_NAME_ENTRY(AUTOEXP_OVEREXP_MAX), \
00558 P_NAME_ENTRY(AUTOEXP_S_PERCENT), \
00559 P_NAME_ENTRY(AUTOEXP_S_INDEX), \
00560 P_NAME_ENTRY(AUTOEXP_EXP), \
00561 P_NAME_ENTRY(AUTOEXP_SKIP_PMIN), \
00562 P_NAME_ENTRY(AUTOEXP_SKIP_PMAX), \
00563 P_NAME_ENTRY(AUTOEXP_SKIP_T), \
00564 P_NAME_ENTRY(AEXPWND_WIDTH), \
00565 P_NAME_ENTRY(AEXPWND_HEIGHT), \
00566 P_NAME_ENTRY(AEXPWND_TOP), \
00567 P_NAME_ENTRY(AEXPWND_LEFT), \
00568 P_NAME_ENTRY(HIST_NOT_CHANGE), \
00569 P_NAME_ENTRY(FOCUS_SHOW), \
00570 P_NAME_ENTRY(FOCUS_SHOW1), \
00571 P_NAME_ENTRY(FOCUS_VALUE), \
00572 P_NAME_ENTRY(FOCUS_LEFT), \
00573 P_NAME_ENTRY(FOCUS_WIDTH), \
00574 P_NAME_ENTRY(FOCUS_TOP), \
00575 P_NAME_ENTRY(FOCUS_HEIGHT), \
00576 P_NAME_ENTRY(FOCUS_TOTWIDTH), \
00577 P_NAME_ENTRY(FOCUS_FILTER), \
00578 P_NAME_ENTRY(TRIG_CONDITION), \
00579 P_NAME_ENTRY(TRIG_DELAY), \
00580 P_NAME_ENTRY(TRIG_OUT), \
00581 P_NAME_ENTRY(TRIG_PERIOD), \
00582 P_NAME_ENTRY(TASKLET_CTL), \
00583 P_NAME_ENTRY(COMPRESSOR_CMD), \
00584 P_NAME_ENTRY(SKIP_FRAMES), \
00585 P_NAME_ENTRY(I2C_QPERIOD), \
00586 P_NAME_ENTRY(I2C_BYTES), \
00587 P_NAME_ENTRY(IRQ_SMART), \
00588 P_NAME_ENTRY(EARLY_TIMESTAMP), \
00589 P_NAME_ENTRY(OVERSIZE) \
00590 };
00591
00592
00593 #ifndef ERR_I2C_SCL_ST0
00594 #define ERR_I2C_SCL_ST0 1
00595 #define ERR_I2C_SDA_ST0 2
00596 #define ERR_I2C_SCL_ST1 4
00597 #define ERR_I2C_SDA_ST1 8
00598 #define ERR_I2C_SCL_NOPULLUP 16
00599 #define ERR_I2C_SDA_NOPULLUP 32
00600
00601
00602 #define ERR_I2C_NOTDETECTED 64
00603 #define ERR_I2C_SHORT 128
00604 #define ERR_I2C_BSY 256
00605 #define ERR_I2C_NACK 512
00606 #endif
00607
00608
00609
00610 #define IO_CCAM_SET_EXT_EXPOSURE 0x06
00611 #define IO_CCAM_MONITOR_SEQ 0x07
00612
00613
00614 #define IO_EXT_BOARD_PRESENT 0xF0
00615
00616
00617
00618
00619
00620
00621 #define IO_CCAM_JPEG 0x08 // JPEG-compressor related commands
00622 #define JPEG_CMD_RESET 0x00 // Resets pointers - both acquisition and readout
00623
00624 #define JPEG_CMD_GET 0x02 // Read current page (will return empty (and length==0) if not ready
00625 #define JPEG_CMD_FORGET 0x03 // increment read frame pointer
00626 #define JPEG_CMD_CATCHUP 0x04 // set read pointer to the last acquired (or acquiring if none is acquired yet)
00627 #define JPEG_CMD_ACQUIRE 0x05 // acquire and compress one frame
00628 #define JPEG_CMD_SAVE_RP 0x06 // save read pointer
00629 #define JPEG_CMD_RESTORE_RP 0x07 // restore read pointer
00630 #define JPEG_CMD_N_DONE 0x08 // return 1 if no more frames to be acquired (frame number)
00631 #define JPEG_CMD_L_DONE 0x09 // return 1 if no more frames to be acquired (total length)
00632 #define JPEG_CMD_START 0x0a // start constant compression mode
00633 #define JPEG_CMD_STOP 0x0b // stop constant compression mode (may want to wait for CAMSEQ_DONE)
00634 #define JPEG_CMD_FRAMES 0x0c // returns number of frames in buffer, (re)uilds frames chain
00635 #define JPEG_CMD_JUST_STOP 0x0d // just stop - don't start cycle if was allready off!
00636 #define JPEG_CMD_DUMP 0x0f // printk all static data/tables
00637 #define JPEG_CMD_RESET0 0x10 // same as JPEG_CMD_RESET, but non-zero, to be used from lseek (SEEK_END)
00638 #define PROGRAM_SENSOR_0 0x11 // programSensor(0) - to be used from lseek (SEEK_END)
00639 #define PROGRAM_SENSOR_1 0x12 // programSensor(1) - to be used from lseek (SEEK_END)
00640 #define LSEEK_CAMSEQSTATE 0x13 // return camSeqState - to be used from lseek (SEEK_END)
00641 #define LSEEK_RESET_SENSOR 0x14 // reset sensor and FPGA - next time will reprogram it
00642 #define LSEEK_INIT_SENSOR 0x15 // initialise SDRAM and sensor if it is not programmed yet (or reset)
00643 #define LSEEK_GET_FPGA_TIME 0x16 // get FPGA timer to P_SECONDS, P_MICROSECONDS
00644 #define LSEEK_SET_FPGA_TIME 0x17 // set FPGA timer to P_SECONDS, P_MICROSECONDS
00645 #define LSEEK_FLUSH_CACHE 0x18 // workaround for Axis mmap cache coherency problems - flush all cache (8KB)
00646 #define LSEEK_AUTOEXP_SET 0x19 // set autoexposure parameters
00647 #define LSEEK_AUTOEXP_GET 0x1a // copy window and exposure parameters to autoexp_state
00648 #define LSEEK_TRIGGER_PGM 0x1b // program trigger parameters
00649 #define LSEEK_I2C_PGM 0x1c // program hardware i2c speed/bytes
00650 #define LSEEK_IRQ_SMART_PGM 0x1d // program "smart" irq modes (+1 - wait VACT, +2 - wait dma fifo)
00651 #define LSEEK_EARLY_TIMESTAMP_PGM 0x1e // 1 - early timestamp in async mode, 0 (or sync) - uses start of first visible line readout
00652 #define JPEG_CTRL_MONOCHROME 0x400
00653 #define JPEG_CTRL_MONOCHROME_BLOCKED 0x1000
00654 #define JPEG_CTRL_NOMOSAIC 0x1000
00655
00656 #define IO_CCAM_JPEG_QUALITY 0x09 // Set P_QUALITY
00657
00658 #define IO_CCAM_JPEG_GET_N 0x0a // get specified number of frames (will add to already asked for if any)
00659 #define IO_CCAM_JPEG_GET_L 0x0b // get specified length (will stop after frame if got more)
00660
00661 #define IO_CCAM_JPEG_CTRL 0x0c // Write JPEG control word (0x10000 - use header, LSW - other settings)
00662 #define IO_CCAM_DMA 0x0d
00663 #define CCAM_DMA_CMD_STOP 0x00
00664 #define CCAM_DMA_CMD_START 0x01 // just starts DMA - descriptor list should be set eatlier
00665
00666 #define IO_CCAM_CR_MODIFY 0x0e //(bit number)<<2 | op; op= 0 - nop, 1 - set, 2 - reset, 3 - toggle)
00667 #define IO_CCAM_CR_SHADOW 0x0f
00668
00669 #define IO_CCAM_PINS_WRITE 0x20
00670 #define IO_CCAM_PINS_READ 0x21
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691 #define CCAM_BYTES_PER_CHUNK (1<<16)
00692 #define CCAM_DESCR_PER_CHUNK 1
00693
00694
00695
00696
00697
00698
00699
00700
00701 #define CCAM_CHUNK_PER_DMABUF 302
00702 #define CCAM_WORDS_PER_DMABUF (CCAM_CHUNK_PER_DMABUF<<14)
00703 #define CCAM_BYTES_PER_DMABUF (CCAM_CHUNK_PER_DMABUF<<16)
00704
00705
00706 #define CCAM_DMA_SIZE CCAM_WORDS_PER_DMABUF
00707
00708
00709
00710
00711 #define CCAM_MMAP_OFFSET_MMAP_HEADER 0
00712 #define CCAM_MMAP_OFFSET_JPEG_HEADER (PAGE_SIZE)
00713 #define CCAM_MMAP_OFFSET_DMABUF (4*PAGE_SIZE)
00714 #define CCAM_MMAP_SIZE (PAGE_SIZE*sizeof(long)+CCAM_BYTES_PER_DMABUF)
00715
00716 #define CCAM_MMAP_META 12 // extra bytes included at the end of each frame (last aligned to 32 bytes)
00717 #define CCAM_MMAP_META_LENGTH 4 // displacement to length frame length data from the end of the 32-byte aligned frame slot
00718 #define CCAM_MMAP_META_USEC 8 // (negative) displacement to USEC data - 20 bits (frame timestamp)
00719 #define CCAM_MMAP_META_SEC 12 // (negative) displacement to SEC data - 32 bits (frame timestamp)
00720
00722 #define CX313_FPGA_TABLES_SIZE 0xC00 //=3000 bytes, 32-bit wide, LSB first, some tables use less
00723 #define CX313_FPGA_TABLES_GAMMA 0x400 // 0x400 words gamma-correction (or arbitrary table)
00724 #define CX313_FPGA_TABLES_FOCUS 0x800 // 15*64 16-bit words (now high 16 bits are unused)
00725 #define CX313_FPGA_TABLES_FOCUSPARS 0xbc0 //block of focus-related parameters: left[11:0],right[11:0],top[11:0],bottom[11:0],full_width[11:0],filter_sel[3:0]
00726
00727
00728
00729
00730
00731
00732
00733
00734 struct ccamMmapHeader
00735 {
00736
00737
00738
00739 int use_header;
00740
00741
00742
00743 int headerSize;
00744
00745
00746
00747 int exposureIdx;
00748 int jpegIdx;
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759 int readOffset;
00760 int writeOffset;
00761
00762
00763 int nfr;
00764
00765
00766
00767
00768 int lfr;
00769
00770
00771 int jpegBusy;
00772 };
00773
00774
00775
00776
00777
00778
00779
00780 struct ccamFileDataHeader
00781 {
00782
00783
00784
00785 int valid;
00786
00787 #define CCAM_IMAGE_VALIDFLAG_NOTDONE 0
00788 #define CCAM_IMAGE_VALIDFLAG_DONEOK 1
00789 #define CCAM_IMAGE_VALIDFLAG_OVERFLOW -1
00790 #define CCAM_IMAGE_VALIDFLAG_FATAL -2
00791
00792
00793
00794 int nBytes;
00795
00796
00797
00798
00799
00800
00801 #define CCAM_IMAGE_OVERFLOW_BYTES 512
00802 int nBytesMax;
00803
00804 int nextOffset;
00805
00806
00807
00808
00809
00810
00811 #define CCAM_IMAGE_NPARTS_MAX 2
00812 struct
00813 {
00814 int offset;
00815 int nBytes;
00816 } part[CCAM_IMAGE_NPARTS_MAX];
00817 };
00818
00819
00820 struct sensor_t {
00821
00822 unsigned long imageWidth;
00823 unsigned long imageHeight;
00824 unsigned long clearWidth;
00825 unsigned long clearHeight;
00826 unsigned long clearTop;
00827 unsigned long clearLeft;
00828 unsigned long arrayWidth;
00829 unsigned long arrayHeight;
00830 unsigned long minWidth;
00831 unsigned long minHeight;
00832 unsigned long minHorBlank;
00833 unsigned long minLineDur;
00834 unsigned long maxHorBlank;
00835 unsigned long minVertBlank;
00836 unsigned long maxVertBlank;
00837 unsigned long maxShutter;
00838 unsigned long flips;
00839 unsigned long dcmHor;
00840 unsigned long dcmVert;
00841 unsigned long binHor;
00842 unsigned long binVert;
00843 unsigned long maxGain256;
00844 unsigned long maxClockFreq;
00845 unsigned long nomClockFreq;
00846 unsigned long sensorType;
00847 unsigned long i2c_addr;
00848 unsigned long i2c_period;
00849 unsigned long i2c_bytes;
00850 unsigned long margins;
00851 unsigned long hact_delay;
00852
00853 unsigned long pixelWidth;
00854 unsigned long pixelHeight;
00855 unsigned short sensorPhase90;
00856 signed short sensorPhase;
00857 };
00858
00859
00860
00861
00862
00863
00864
00865
00866 #define DEFAULT_COLOR_SATURATION_BLUE 0x90 // 100*realtive saturation blue
00867 #define DEFAULT_COLOR_SATURATION_RED 0xb6 // 100*realtive saturation red
00868
00869 #define EXPOSURE_UNIT 100 // to move to finer exposure settings - current unit in microseconds. TODO: Propagate it to drivers...
00871
00872
00880 struct frame_params_t {
00881 unsigned long exposure;
00882 unsigned short width;
00883 unsigned short height;
00884 unsigned long colorsat;
00885 unsigned char color;
00886 unsigned char quality;
00887 unsigned char gamma;
00888 unsigned char black;
00889 unsigned short rscale;
00890 unsigned short bscale;
00891
00892 unsigned char gain_r;
00893 unsigned char gain_g;
00894 unsigned char gain_b;
00895 unsigned char gain_gb;
00896
00897
00898 unsigned short meta_index;
00899
00900 unsigned short signffff;
00901
00902 union {
00903 unsigned long timestamp_sec ;
00904 unsigned long frame_length ;
00905 };
00906 unsigned long timestamp_usec;
00907 };
00908
00909
00910 #define CIRCLSEEK_TORP 1
00911 #define CIRCLSEEK_TOWP 2
00912 #define CIRCLSEEK_PREV 3
00913 #define CIRCLSEEK_NEXT 4
00914 #define CIRCLSEEK_LAST 5
00915 #define CIRCLSEEK_FIRST 6
00916 #define CIRCLSEEK_SCND 7
00917 #define CIRCLSEEK_SETP 8
00918 #define CIRCLSEEK_VALID 9
00919 #define CIRCLSEEK_READY 10
00920 #define CIRCLSEEK_WAIT 11
00921 #define CIRCLSEEK_FREE 12
00922 #define CIRCLSEEK_USED 13
00923
00924 struct i2c_timing_t {
00925 unsigned char scl_high;
00926 unsigned char scl_low;
00927 unsigned char slave2master;
00928 unsigned char master2slave;
00929 unsigned char filter_sda;
00930 unsigned char filter_scl;
00931 };
00932
00933
00934 #endif