00001
00002
00003
00004
00005
00006 #ifndef _ASM_CMOSCAM_H
00007 #define _ASM_CMOSCAM_H
00008
00009
00010
00011 #define ELPHEL_DEBUG_STARTUP 0 ;
00012 #define ELPHEL_DEBUG 1 //global debug on/off in multiple files
00013 #define ELPHEL_DEBUG_DELAY 100000 //delay after some printk-s
00014 #define ELP_KERR(x) printk("%s:%d:%s: ERROR ",__FILE__,__LINE__,__FUNCTION__);x
00015 #define ELP_FERR(x) fprintf(stderr,"%s:%d:%s: ERROR ",__FILE__,__LINE__,__FUNCTION__);x
00016
00017 #define USELONGLONG 1
00018 #define ETRAXFS_MMAP_CACHE_BUG y
00019
00020
00021
00022 #define CMOSCAM_IOCTYPE 124
00023
00024
00025
00026 #define X3X3_I2C_CTRL 0 // control/reset i2c
00027 #define X3X3_I2C_8_AINC 1 // 8bit registers, autoincement while read/write
00028 #define X3X3_I2C_16_AINC 2 // 16bit registers, autoincement while read/write
00029 #define X3X3_I2C1_8_AINC 3 // 8bit registers, autoincement while read/write (bus 1)
00030 #define X3X3_I2C1_16_AINC 4 // 16bit registers, autoincement while read/write (bus 1)
00031 #define X3X3_I2C_RAW 5 // 8bit registers, no address byte (just slave, then read/write byte(s)
00032 #define X3X3_I2C1_RAW 6 // 8bit registers, no address byte (just slave, then read/write byte(s)
00033 #define X3X3_I2C_ENABLE 7 // enable(/protect) different I2C devices for different types of I2C accesses
00034 #define X3X3_I2C_ENABLE_RD 0 // bit 0 - enable i2c read
00035 #define X3X3_I2C_ENABLE_WR 1 // bit 1 - enable i2c write
00036 #define X3X3_I2C_ENABLE_RAW 2 // bit 2 - enable i2c raw (no address byte)
00037 #define X3X3_I2C_ENABLE_8 3 // bit 3 - enable i2c 8-bit registers access
00038 #define X3X3_I2C_ENABLE_16 4 // bit 4 - enable i2c 16-bit registers access
00039 #define X3X3_I2C_MAXMINOR 7 //
00040 #define X3X3_I2C_CHANNELS 2 // number of i2c channels
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00052 #define CAMSEQ_OFF 0 // off, not programmed (Video mode off on Zoran sensors)
00053 #define CAMSEQ_READY 1 // sensor programmed may acquire at will (programSensor sets number of frames to skip (if any)
00054 #define CAMSEQ_SKIP 2 // skipping specified number of frames, interrupt service routine counts and will start acquisition
00055 #define CAMSEQ_WAIT_F 3 // set by "start exposure" or interrupt service routine. WAIT_F/WAIT_T/acquire/done differs by hardware register
00056 #define CAMSEQ_WAIT_T 4 // set by "start exposure" or interrupt service routine. Wait/acquire/done differs by hardware register
00057 #define CAMSEQ_ACQUIRE 5 // acquisition in progress (camSeqState is still CAMSEQ_WAIT)
00058 #define CAMSEQ_DONE 6 // acquisition over (camSeqState is still CAMSEQ_WAIT)
00059 #define CAMSEQ_JPEG 7 // waiting for JPEG done interrupt, acquiring/compressing some frames
00060
00061 #define CAMSEQ_RUN 8 // compressor is constantly running (but if camSeqCount>0 - just skipping "bad" frames)
00062 #define CAMSEQ_STOP 9 // compressor is constantly running but will stop after next "compressor ready"
00063 #define CAMSEQ_SINGLE 10 // compressor is constantly running to fill one full buffer
00064
00065 #define sensorcom_W_size 1024
00066 #define sensorcom_R_size 256
00067
00068
00069
00070 #define MCP_W_size 1024
00071 #define MCP_R_size 256
00072
00073 #define MCPOtherBits 0xffa7a7ff
00074 #define MCPOffReset 0x00101800
00075 #define MCPReset 0x00001800
00076 #define MCPNoReset 0x00105800
00077 #define MCPToggleA 0x00080000
00078 #define MCPToggleB 0x00001000
00079 #define MCPctlseq 0x00
00080 #define MCPsofttg 0x02
00081 #define MCPeackn 0x03
00082 #define MCPctlgate 0x04
00083 #define MCPwstdly 0x06
00084 #define MCPwrsmsk 0x07
00085 #define MCPwrsup 0x08
00086 #define MCPwrmons 0x09
00087 #define MCPwnom 0x0a
00088 #define MCPwdenom 0x0b
00089 #define MCPwoutw 0x0c
00090 #define MCPwinvctl 0x0d
00091 #define MCPctlsync 0x0e
00092 #define MCPwrdlys 0x10
00093 #define MCPwinv 0x40
00094 #define MCPwshared 0x80
00095 #define MCPwrsynctb 0x100
00096 #define MCPwrseq 0x200
00097
00098
00099
00100 #ifndef I2C_WRITEARG
00101 #define I2C_WRITEARG(bus, slave, reg, value) (((bus) << 24) | ((slave) << 16) | ((reg) << 8) | (value))
00102 #define I2C_READARG(bus, slave, reg) (((bus) << 24) | ((slave) << 16) | ((reg) << 8))
00103
00104 #define I2C_ARGBUS(arg) (((arg) >> 24) & 0x1)
00105 #define I2C_ARGSLAVE(arg) (((arg) >> 16) & 0xff)
00106 #define I2C_ARGREG(arg) (((arg) >> 8) & 0xff)
00107 #define I2C_ARGVALUE(arg) ((arg) & 0xff)
00108
00109 #define I2C_DELAYS 0x0 // read/write bit deleys for I2C
00110
00111
00112
00113
00114
00115
00116 #define I2C_WRITEREG 0x1 // write to an i2c register
00117 #define I2C_READREG 0x2 // read from an i2c register
00118 #endif
00119
00120
00121 #ifndef I2C_16_WRITEARG
00122 #define I2C_16_WRITEREG 0x3 // write 2 bytes to an i2c register
00123 #define I2C_16_READREG 0x4 // read 2 bytes from an i2c register
00124
00125 #define I2C_16_WRITEARG(slave, reg, value) (((slave) << 24) | ((reg) << 16) | (value))
00126 #define I2C_16_READARG(slave, reg) (((slave) << 24) | ((reg) << 16))
00127
00128 #define I2C_16_ARGSLAVE(arg) (((arg) >> 24) & 0xff)
00129 #define I2C_16_ARGREG(arg) (((arg) >> 16) & 0xff)
00130 #define I2C_16_ARGVALUE(arg) ( (arg) & 0xffff)
00131 #define I2C_16_ARGVALUE_H(arg) (((arg) >> 8) & 0xff)
00132 #define I2C_16_ARGVALUE_L(arg) ( (arg) & 0xff)
00133 #endif
00134
00135
00136
00137
00138
00139 #define _CCCMD(x,y) (_IO(CMOSCAM_IOCTYPE, (x << 6) | (y & 0x3f)))
00140
00141
00142
00143 #define CCAM_CTRL(x) ((_IOC_NR(x) >> 6) & 0x03)
00144 #define CCAM_ADDR(x) (_IOC_NR(x) & 0x3f)
00145
00146
00147 #define CCAM_RPARS 2
00148 #define CCAM_WPARS 3
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00166 #define P_NUMBER 1024 //number of registers (was 64) - NOTE: obsolete?
00167 #define P_SENSOR 1
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 #define SENSOR_MASK 0xfc
00185 #define SENSOR_ZR32112 0x04
00186 #define SENSOR_ZR32212 0x08
00187 #define SENSOR_KAC1310 0x20
00188 #define SENSOR_KAC5000 0x24
00189 #define SENSOR_MI1300 0x30
00190 #define SENSOR_MT9X001 0x30 // MT9M001 - 31, MT9D001 - 32, MT9T001 - 33, MT9P001 - 34
00191 #define SENSOR_MT9Y001 0x34 // MT9P001 - 34
00192 #define SENSOR_IBIS51300 0x40
00193 #define SENSOR_KAI11000 0x80
00194 #define SENSOR_NONE 0xfc
00195
00196
00197
00198
00199 #define SENSORWIDTH_ZR32112 1280
00200 #define SENSORHEIGHT_ZR32112 1024
00201
00202 #define SENSORWIDTH_ZR32212 1280
00203 #define SENSORHEIGHT_ZR32212 968
00204 #define SENSORWIDTH_KAC1310 1280
00205 #define SENSORHEIGHT_KAC1310 1024
00206
00207
00208 #define SENSORWIDTH_MI1300 1280
00209 #define SENSORHEIGHT_MI1300 1024
00210
00211 #define SENSORWIDTH_MT9M001 1280
00212 #define SENSORHEIGHT_MT9M001 1024
00213 #define SENSORWIDTH_MT9D001 1600
00214 #define SENSORHEIGHT_MT9D001 1200
00215 #define SENSORWIDTH_MT9T001 2048
00216 #define SENSORHEIGHT_MT9T001 1536
00217 #define SENSORWIDTH_MT9P001 2592
00218 #define SENSORHEIGHT_MT9P001 1944
00219
00220 #define SENSORWIDTH_KAC5000 2592
00221 #define SENSORHEIGHT_KAC5000 1944
00222
00223
00224 #define SENSORWIDTH_IBIS51300 1280
00225 #define SENSORHEIGHT_IBIS51300 1024
00226
00228 #define P_SENSOR_RUN 4 // 0 - stop, 1 - single, 2 - run
00229 #define SENSOR_RUN_STOP 0
00230 #define SENSOR_RUN_SINGLE 1
00231 #define SENSOR_RUN_CONT 2
00232 #define P_COMPRESSOR_RUN 5 // 0 - stop, 1 - single, 2 - run
00233 #define COMPRESSOR_RUN_STOP 0
00234 #define COMPRESSOR_RUN_SINGLE 1
00235 #define COMPRESSOR_RUN_CONT 2
00236
00237 #define P_BAYER 6 // filter number at (0,0) 0-R, 1-G(R), 2-G(B), 3 - B. Write enabled at first, move to WindowSize later
00238 #define P_TRIGGERED 7 // when trigger occured - 4 LSBs - pixel in DMA word, higher bits - number of DMA word OBSOLETE
00239 #define P_PERIOD 8 // Frame period in pixel clocks (read only)
00240 #define P_FP1000SLIM 9 // FPS limit, frames per 1000 sec
00241 #define P_FPSFLAGS 10 // FPS limit mode - bit 0 - limit fps (not higher than), bit 1 - maintain fps (not lower than)
00242
00243 #define P_JPEG_WP 11 // Last reported JPEG write pointer in the circular buffer. ** OBSOLETE
00245 #define P_CLK_FPGA 12 // FPGA clock in MHz
00246 #define P_CLK_SENSOR 13 // Sensor clock in MHz
00247 #define P_FPGA_XTRA 14 // Extra cycles needed to compressor (probably constant...)
00248 #define P_TRIG 15
00249
00250
00251
00252
00253 #define P_BGFRAME 16 // Background measurement mode - will use 16-bit mode and no FPN correction
00254
00255 #define P_IMGSZMEM 17 // image size in video memory (calculated when channel 0 is programmed)
00256
00257
00258
00259 #define P_PAGE_ACQ 18 // Number of image page buffer to acquire to (0.1?)
00260 #define P_PAGE_READ 19 // Number of image page buffer to read from to (0.1?)
00261
00262 #define P_OVERLAP 20 // number of EXRA lines to be acquired - probably dead,
00263
00264 #define P_VIRT_KEEP 21 // 0 - recalculate P_VIRT_WIDTH, P_VIRT_HEIGHT when window is changed, 1 - keep those parameters
00265 #define P_VIRT_WIDTH 22 // Virtual window width
00266 #define P_VIRT_HEIGHT 23 // Virtual window height
00267 #define P_WOI_LEFT 24 // WOI left corner (before applying decimation)
00268 #define P_WOI_TOP 25 // WOI top corner
00269 #define P_WOI_WIDTH 26 // WOI width
00270 #define P_WOI_HEIGHT 27 // WOI height
00271
00272 #define P_FLIPH 28 // bit 0 horizontal flip
00273 #define P_FLIPV 29 // bit 0 vertical flip
00274
00275 #define P_DCM_HOR 30
00276 #define P_DCM_VERT 31
00277 #define P_BIN_HOR 32
00278 #define P_BIN_VERT 33
00279 #define P_FPGATEST 34 // FPGA test modes (now - just one)
00280
00281 #define P_FRAMESYNC_DLY 35
00282
00283 #define P_PF_HEIGHT 36
00284
00285
00286 #define P_BITS 37
00287
00288 #define P_SHIFTL 38
00289 #define P_FPNS 39 // FPN correction mode (subtract) 0..3
00290
00291 #define P_FPNM 40 // FPN correction mode (multiply) 0..3
00292
00293 #define P_TESTSENSOR 41 // sensor test mode(s) 0x10000 - enable, lower bits - test mode
00294 #define P_VIRTTRIG 42 // Sum of pixels in a line greater than this value - trigger acquisition
00295
00296 #define P_PERIOD_MIN 43 // (readonly) minimal frame period (in pixel clocks) limited by user or compressor
00297 #define P_PERIOD_MAX 44 // (readonly) frame period (in pixel clocks) limited by user
00298 #define P_SENSOR_PIXH 45 // (readonly) pixels to be read from the sensor, horizontal (incliding margins, excluding embedded timestamps)
00299 #define P_SENSOR_PIXV 46 // (readonly) pixels to be read from the sensor, vertical (incliding margins)
00300 #define P_FATZERO 47 // subtract while adding data from to consequitive frames (async trigger)
00301
00302 #define P_COMPMOD_TILSH 48
00303 #define P_COMPMOD_DCSUB 49
00304 #define P_COMPMOD_QTAB 50 // to be written not directly, but by pgm_quality ?
00305
00306 #define P_FP1000S 51 // Frames per 1000 sec (fps * 1000)
00307 #define P_SENSOR_WIDTH 52
00308 #define P_SENSOR_HEIGHT 53
00309 #define P_COLOR_SATURATION_BLUE 54 // 100*realtive saturation blue - preserve?
00310 #define P_COLOR_SATURATION_RED 55 // 100*realtive saturation red
00311
00313 #define P_VIGNET_AX 56
00314 #define P_VIGNET_AY 57
00315 #define P_VIGNET_BX 58
00316 #define P_VIGNET_BY 59
00317 #define P_VIGNET_C 60
00318 #define P_VIGNET_SHL 61
00319 #define P_VIGNET_ZERIN 62
00320 #define P_VIGNET_ZEROUT 63
00321
00322 #define P_DGAINR 64
00323 #define P_DGAING 65
00324 #define P_DGAINGB 66
00325 #define P_DGAINB 67
00326
00327
00328 #define P_ZBINROUND 71 // zero bin + ((rounding add) << 8) 8-bit JPEG quantizer zero bin size, fractional addition to absolute value before truncating
00329 #define P_HISTRQ 72 // per-frame enabling of histogram calculation - bit 0 - Y (G), bit 2 - C (R,G2,B)
00330 #define P_TILES 73 // Number of 16x16 (20x20) tiles in a compressed frame
00331 #define P_SENSOR_PHASE 74 // packed, low 16 bit - signed fine phase, bits [18:17] - 90-degrees shift
00332
00333
00334 #define P_AUTOEXP_ON 76 // unsigned long on;
00335
00337 #define P_HISTWND_RWIDTH 77 // unsigned long width (%)->relative (0x10000 - 1.0);
00338 #define P_HISTWND_RHEIGHT 78 //unsigned long height (%);
00339 #define P_HISTWND_RLEFT 79 // unsigned long left (%);
00340 #define P_HISTWND_RTOP 80 // unsigned long top (%);
00341
00343 #define P_AUTOEXP_EXP_MAX 81 //unsigned long exp_max;
00344 #define P_AUTOEXP_OVEREXP_MAX 82 // unsigned long overexp_max;
00345 #define P_AUTOEXP_S_PERCENT 83 // unsigned long s_percent;(controlling that % of pixels that should have value greater than S_INDEX - below)
00346 #define P_AUTOEXP_S_INDEX 84 // unsigned long s_index; Specified number of pixels (S_PERCENT) should have value above S_INDEX
00347 #define P_AUTOEXP_EXP 85 // unsigned long exp; Current exposure time
00348 #define P_AUTOEXP_SKIP_PMIN 86 // unsigned long skip_pmin; - no exposure corrections if the desired change is less than that
00349 #define P_AUTOEXP_SKIP_PMAX 87 // unsigned long skip_pmax; - do not apply chnanges if they are to big - wait for the next frame
00350 #define P_AUTOEXP_SKIP_T 88 // unsigned long skip_t; Not quite sure what it is
00351
00353 #define P_HISTWND_WIDTH 89 // autoexposure window width (pixels)
00354 #define P_HISTWND_HEIGHT 90 // autoexposure window height (pixels)
00355 #define P_HISTWND_TOP 91 // autoexposure window top (pixels)
00356 #define P_HISTWND_LEFT 92 // autoexposure window left (pixels)
00357
00358 #define P_FOCUS_SHOW 93 // show focus information instead of/combined with the image:
00359
00360 #define P_FOCUS_SHOW1 94 // Additional parameter that modifies visualization mode. Currently just a single bit (how much to add)
00361
00362 #define P_FOCUS_LEFT 96 // focus WOI left margin, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block width)
00363 #define P_FOCUS_WIDTH 97 // focus WOI width (3 LSB will be zeroed as it should be multiple of 8x8 block width)
00364 #define P_FOCUS_TOP 98 // focus WOI top margin, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block height)
00365 #define P_FOCUS_HEIGHT 99 // focus WOI height (3 LSB will be zeroed as it should be multiple of 8x8 block height)
00366 #define P_FOCUS_TOTWIDTH 100 // (readonly) - total width of the image frame in pixels
00367 #define P_FOCUS_FILTER 101 // select 8x8 filter used for the focus calculation (same order as quantization coefficients), 0..14
00368
00370
00371 #define P_TRIG_CONDITION 102 // trigger condition, 0 - internal, else dibits ((use<<1) | level) for each GPIO[11:0] pin
00372 #define P_TRIG_DELAY 103 // trigger delay, 32 bits in pixel clocks
00373 #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
00374 #define P_TRIG_PERIOD 105 // output sync period (32 bits, in pixel clocks). 0- stop. 1..256 - single, >=256 repetitive with specified period.
00375
00376
00377 #define P_SKIP_FRAMES 107 // number of frames to skip after restarting sensor+compressor - now zero/nonzero?
00378 #define P_I2C_QPERIOD 108 // number of system clock periods in 1/4 of i2c SCL period to the sensor/sensor board
00379 #define P_I2C_BYTES 109 // number of bytes in hardware i2c write (after slave addr) -0/1/2
00380 #define P_IRQ_SMART 110 // "smart" IRQ modes: +1 - wait for VACT in early compressor_done, +2 - wait for dma fifo ready
00382 #define P_EARLY_TIMESTAMP 111 // "1" - use start of TRIG pulse as a timetamp moment (0 - use start of first visible line readout) - prevent jitter in async mode
00383 #define P_OVERSIZE 112 // ignore sensor dimensions, use absolute WOI_LEFT, WOI_TOP
00384
00385
00386
00387 #define P_RFOCUS_LEFT 115 // relative (0x10000 - 1.0) focus WOI left margin, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block width)
00388 #define P_RFOCUS_WIDTH 116 // relative (0x10000 - 1.0)focus WOI width (3 LSB will be zeroed as it should be multiple of 8x8 block width)
00389 #define P_RFOCUS_TOP 117 // relative (0x10000 - 1.0)focus WOI top margin, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block height)
00390 #define P_RFOCUS_HEIGHT 118 // relative (0x10000 - 1.0)focus WOI height (3 LSB will be zeroed as it should be multiple of 8x8 block height)
00391
00392 #define P_SDRAM_CHN20 125 // data to be written to the SDRAM CH2 REG 0 (last moment)
00393 #define P_SDRAM_CHN21 126 // data to be written to the SDRAM CH2 REG 1
00394 #define P_SDRAM_CHN22 127 // data to be written to the SDRAM CH2 REG 2
00395
00396
00399 #define P_GTAB_R 128 // combines (P_PIXEL_LOW<<24) | (P_GAMMA <<16) and 16-bit (6.10) scale for gamma tables, individually for each color.
00400
00401 #define P_GTAB_G 129 // same for the first green (red line)
00402 #define P_GTAB_GB 130 // same for the second green (blue line)
00403 #define P_GTAB_B 131 // same for the blue
00404 #define P_QUALITY 132 //JPEG IMAGE QUALITY (now uses 2 bytes)
00405 #define P_ACTUAL_WIDTH 133 // RD P_RO_WIDTH 1 pixels/row
00406 #define P_ACTUAL_HEIGHT 134 // RD P_RO_HEIGHT 2 pixels/column
00407 #define P_COLOR 135
00408 #define COLORMODE_MONO6 0 // monochrome, (4:2:0),
00409 #define COLORMODE_COLOR 1 // color, 4:2:0, 18x18(old)
00410 #define COLORMODE_JP46 2 // jp4, original (4:2:0)
00411 #define COLORMODE_JP46DC 3 // jp4, dc -improved (4:2:0)
00412 #define COLORMODE_COLOR20 4 // color, 4:2:0, 20x20, middle of the tile (not yet implemented)
00413 #define COLORMODE_JP4 5 // jp4, 4 blocks, (legacy)
00414 #define COLORMODE_JP4DC 6 // jp4, 4 blocks, dc -improved
00415 #define COLORMODE_JP4DIFF 7 // jp4, 4 blocks, differential red := (R-G1), blue:=(B-G1), green=G1, green2 (G2-G1). G1 is defined by Bayer shift, any pixel can be used
00416 #define COLORMODE_JP4HDR 8 // jp4, 4 blocks, differential HDR: red := (R-G1), blue:=(B-G1), green=G1, green2 (high gain)=G2) (G1 and G2 - diagonally opposite)
00417 #define COLORMODE_JP4DIFF2 9 // jp4, 4 blocks, differential, divide differences by 2: red := (R-G1)/2, blue:=(B-G1)/2, green=G1, green2 (G2-G1)/2
00418 #define COLORMODE_JP4HDR2 10 // jp4, 4 blocks, differential HDR: red := (R-G1)/2, blue:=(B-G1)/2, green=G1, green2 (high gain)=G2),
00419 #define COLORMODE_MONO4 14 // monochrome, 4 blocks (but still with 2x2 macroblocks)
00420 #define P_FRAME 136 // Frame number (reset with JPEG pointers) -(read only)
00421 #define P_GAINR 137 //R channel gain (mono gain) 8.8 0x100 - 1.0
00422 #define P_GAING 138 //G channel gain ("red line")
00423 #define P_GAINGB 139 // G channel gain ("blue line")
00424 #define P_GAINB 140 // B channel gain
00425 #define P_EXPOS 141 //P_RW_EXPOS 1 exposure time - now in microseconds?
00426 #define P_VEXPOS 142 // video exposure (if 0 - use P_RW_EXPOS in ms)
00427 #define P_FOCUS_VALUE 143 // (readonly) - sum of all blocks focus values inside focus WOI
00428
00430
00431 #define P_COMPMOD_BYRSH 160 // Bayer shift in compressor
00432
00433
00434
00443
00444 #define P_DAEMON_EN 165 // disable all autoexp features AEXP, WB, HDR- make extra sleep for AUTOEXP_EN to become non-zero (normal frame rules)
00445 #define P_AEXP_FRACPIX 166 // Fraction of all pixels that should be below P_AEXP_LEVEL (16.16 - 0x10000 - all pixels)
00446 #define P_AEXP_LEVEL 167 // Target output level: [P_AEXP_FRACPIX]/0x10000 of all pixels should have value below it (also 16.16 - 0x10000 - full output scale)
00447
00448 #define P_HDR_DUR 168 // 0 - HDR 0ff, >1 - duration of same exposure (currently 1 or 2 - for free running)
00449 #define P_HDR_VEXPOS 169 // if less than 0x10000 - number of lines of exposure, >=10000 - relative to "normal" exposure
00450
00451 #define P_AE_PERIOD 170 // Autoexposure period (will be increased if below the latency)
00452 #define P_WB_PERIOD 171 // White balance period (will be increased if below the latency)
00453 #define P_WB_MASK 172 // bitmask - which colors to correct (1 - correct, 0 - ignore)
00454 #define P_WB_WHITELEV 173 // White balance level of white (16.16 - 0x10000 is full scale, 0xfae1 - 98%, default)
00455 #define P_WB_WHITEFRAC 174 // White balance fraction (16.16) of all pixels that have level above [P_WB_WHITELEV] for the brightest color
00456
00457
00458 #define P_WB_SCALE_R 175 // additional correction for R from calulated by white balance (16.16)
00459 #define P_WB_SCALE_GB 176 // additional correction for G2(GB) from calulated by white balance (16.16)
00460 #define P_WB_SCALE_B 177 // additional correction for B from calulated by white balance (16.16)
00461
00462 #define P_EXP_AHEAD 178 // How many frames ahead of the current frame write exposure to the sensor
00463 #define P_AE_THRESH 179 // AE error (logariphmic exposures) is integrated between frame and corrections are scaled when error is below thershold (500)
00464 #define P_WB_THRESH 180 // same for WB
00465
00467 #define P_GAIN_MIN 181 // minimal sensor analog gain (0x100 - 1.0)
00468 #define P_GAIN_MAX 182 // maximal sensor analog gain (0x100 - 1.0)
00469 #define P_GAIN_CTRL 183 // minimal correction to be applied to the analog gain (should be set larger that sensor actual gain step to prevent oscillations (0x100 - 1.0, 0x20 - 1/8)
00470 #define GAIN_BIT_STEP 0 // start bit of gain step control in P_GAIN_CTRL
00471 #define GAIN_BIT_ENABLE 16 // start bit of enabling analog gain controls in white balancing
00472
00474 #define P_AUTOCAMPARS_CTRL 184 // bits 0..24 - groups to restore, bits 24..27 - page number to save bits 28..30: 1 - restore, 2 - save, 3 - set default 4 save as default 5 - init
00475
00478 #define P_FTP_PERIOD 190 // FTP image upload period
00479 #define P_FTP_TIMEOUT 191 // Maximal time allowed for image uploading
00480 #define P_FTP_UPDATE 192 // Maximal time between updates (camera wil re-read remote configuration file)
00481
00482
00483 #define P_SENSOR_REGS 256 // shadows of the sensor registers (should be multiple of 32)
00484 #define P_SENSOR_NUMREGS 256 // number of the sensor registers (should be multiple of 32)
00485
00486 #define P_MAX_PAR 511 // maximal # of used parameter
00487 #define P_MAX_GPAR 1023 // maximal # of global parameter
00488
00489
00490 #define PARS_SAVE_FROM 128 // PARS_SAVE_NUM parameters starting from PARS_SAVE_FROM from "this" frame will be saved in circular buffer, PASTPARS_SAVE_ENTRIES entries
00491 #define PARS_SAVE_COPY 16 // number of parameters copied from future (framepars) to the past (pastpars)
00492 #define PARS_SAVE_NUM 32 // total size of previous parameter save page
00493 #define PP_PROFILE_START 16 // index of the first profile timestamp in pastpars
00494 #define P_PROFILE (PARS_SAVE_FROM + PP_PROFILE_START) //index to access profiles as pastpars (i.e. from PHP ELPHEL_PROFILE1,PHP ELPHEL_PROFILE2)
00495
00497 #define FRAMEPAR_GLOBALS 0x01000 // start of global (not frame-related) parameters
00498
00499
00500 #define GLOBALPARS(x) globalPars[(x)-FRAMEPAR_GLOBALS] // should work in drivers and applications
00501
00502 #define G_DEBUG (FRAMEPAR_GLOBALS + 2)
00503 #define G_MAXAHEAD (FRAMEPAR_GLOBALS + 3) // Maximal number of frames ahead of current to be programmed to hardware
00504 #define G_THIS_FRAME (FRAMEPAR_GLOBALS + 4) // Current frame number (may lag from the hardwaere)
00505 #define G_CIRCBUFSIZE (FRAMEPAR_GLOBALS + 5) // Size of the circular buffer (in bytes)
00507 #define G_FREECIRCBUF (FRAMEPAR_GLOBALS + 6) //* Free space in circbuf (uses global read pointer, in bytes)
00508 #define G_CIRCBUFWP (FRAMEPAR_GLOBALS + 7) //* circbuf write pointer (in bytes - similar P_JPEG_WP is in long words)
00509 #define G_CIRCBUFRP (FRAMEPAR_GLOBALS + 8) //* circbuf global read pointer (in bytes )
00510
00511 #define G_SECONDS (FRAMEPAR_GLOBALS + 9) // seconds (R/W to FPGA timer)
00512 #define G_MICROSECONDS (FRAMEPAR_GLOBALS + 10) // microseconds (R/W to FPGA timer)
00513
00515 #define G_CALLNASAP (FRAMEPAR_GLOBALS + 11) // bitmask - what functions can be used not only in the current frame (ASAP) mode
00516 #define G_CALLNEXT (FRAMEPAR_GLOBALS + 11) // (same as G_CALLNASAP) bitmask of actions to be one or more frames ahead of the programmed one (OR-ed with G_CALLNEXT2..G_CALLNEXT4)
00518 //#define G_CALLNEXT1 (FRAMEPAR_GLOBALS + 12) // bitmask of actions to be one or more frames ahead of the programmed one (OR-ed with G_CALLNEXT2..G_CALLNEXT4)
00519
00520
00521
00522
00523 #define G_NEXT_AE_FRAME (FRAMEPAR_GLOBALS + 16) // Next frame to be processed by autoexposure - written directly from daemon through mmap
00524 #define G_NEXT_WB_FRAME (FRAMEPAR_GLOBALS + 17) // Next frame to be processed by white balance - written directly from daemon through mmap
00525 #define G_HIST_DIM_01 (FRAMEPAR_GLOBALS + 18) // Percentile measured for colors 0 (lower 16 bits) and 1 (high 16 bits) for VEXPOS=1
00526 #define G_HIST_DIM_23 (FRAMEPAR_GLOBALS + 19) // Percentile measured for colors 2 (lower 16 bits) and 3 (high 16 bits) for VEXPOS=1
00528 //#define G_EW_HYSTCNTR (FRAMEPAR_GLOBALS + 20) // autoexposure/white balance hysteresis counters , 1 byte each, (sign and count, Y,R,G2,B)
00529 #define G_AE_INTEGERR (FRAMEPAR_GLOBALS + 20) // current integrated error in the AE loop
00530 #define G_WB_INTEGERR (FRAMEPAR_GLOBALS + 21) // current integrated error in WB loop
00531
00532 #define G_TASKLET_CTL (FRAMEPAR_GLOBALS + 22)
00533 #define G_GFOCUS_VALUE (FRAMEPAR_GLOBALS + 23) // (readonly) - sum of all blocks focus values inside focus WOI (global)
00534
00535 #define TASKLET_CTL_PGM 0
00536 #define TASKLET_CTL_IGNPAST 1
00537 #define TASKLET_CTL_NOSAME 2
00538 #define TASKLET_CTL_ENPROF 3
00539
00540 #define TASKLET_HIST_ALL 0
00541 #define TASKLET_HIST_HALF 1
00542 #define TASKLET_HIST_QUATER 2
00543
00544
00545 #define TASKLET_HIST_ONCE 3
00546 #define TASKLET_HIST_RQONLY 4
00547 #define TASKLET_HIST_NEVER 7
00548
00549 #define TASKLET_CTL_HISTY_BIT 4
00550 #define TASKLET_CTL_HISTC_BIT 8
00551
00552 #define G_HIST_LAST_INDEX (FRAMEPAR_GLOBALS + 24) // last used index in histogram cache
00553 #define G_HIST_Y_FRAME (FRAMEPAR_GLOBALS + 25) // last frame for which Y histogram was calualted
00554 #define G_HIST_C_FRAME (FRAMEPAR_GLOBALS + 26) // last frame for which C histograms were calualted
00555 #define G_SKIP_DIFF_FRAME (FRAMEPAR_GLOBALS + 27) // number of frames with different size to tolerate before producing POLLHUP in poll(circbuf)
00556 #define G_FTP_NEXT_TIME (FRAMEPAR_GLOBALS + 28) // time of the next FTP upload (seconds from epoch)
00557
00558 #define G_DAEMON_ERR (FRAMEPAR_GLOBALS + 31) // 1 bit per daemon error that needs attention (daemon would put itself to sleep through P_DAEMON_EN)
00559 #define G_DAEMON_RETCODE (FRAMEPAR_GLOBALS + 32) // return codes (32 32-bit words) for daemons, provided with a corresponding bit in G_DAEMON_ERR set
00561
00562
00563
00565 #define FRAMEPAIR_FORCE_NEW 0x040000000 // will mark parameter as "modified" even the new==old
00566 #define FRAMEPAIR_FORCE_PROC 0x080000000 // will mark schedule functions for that parameter even if called from setFramePars/setFramePar (normally it is not)
00567 #define FRAMEPAIR_FORCE_NEWPROC 0x0c0000000 // combines both
00568 #define FRAMEPAIR_JUST_THIS 0x10000000 // write only to this frame, don't propagate
00569
00570 #define FRAMEPAIR_FRAME_FUNC 0x20000000 // write to func2call instead of the frame parameters
00572 #define FRAMEPAIR_FRAME_BITS(w,b) ((((w) & 0x1f)<<21) | (((b) & 0x1f)<<16))
00574 #define FRAMEPAIR_FRAME_MASK_NEW(a,od,nd) ((((od) ^ ((nd) << (((a)>>16) & 0x1f))) & (((1 << (((a)>>21) & 0x1f))-1) << (((a)>>16) & 0x1f))) ^ (od))
00575
00577 #define FRAMEPAIR_FRAME_FIELD(a,d) (((d) >> (((a)>>16) & 0x1f)) & ((1 << (((a) >> 21) & 0x1f))-1))
00578
00579 #define FRAMEPAIR_MASK_BYTES (FRAMEPAIR_FRAME_BITS(31,31))
00580
00582 #define FRAMEPAIR_BYTE0 (FRAMEPAIR_FRAME_BITS( 8, 0)) // overwrite only byte0 (LSB) in the paremater
00583 #define FRAMEPAIR_BYTE1 (FRAMEPAIR_FRAME_BITS( 8, 8)) // overwrite only byte1 in the paremater
00584 #define FRAMEPAIR_BYTE2 (FRAMEPAIR_FRAME_BITS( 8, 16)) // overwrite only byte2 in the paremater
00585 #define FRAMEPAIR_BYTE3 (FRAMEPAIR_FRAME_BITS( 8, 24)) // overwrite only byte3 (MSB) in the paremater
00586 #define FRAMEPAIR_WORD0 (FRAMEPAIR_FRAME_BITS(16, 0)) // overwrite only word0 (LSW) in the paremater (i.e. gamma scale)
00587 #define FRAMEPAIR_WORD1 (FRAMEPAIR_FRAME_BITS(16, 16)) // overwrite only word1 (MSW) in the paremater (i.e. gamma hash16)
00588
00589
00590 #define DAEMON_BIT_AUTOEXPOSURE 0
00591 #define DAEMON_BIT_STREAMER 1
00592 #define DAEMON_BIT_CCAMFTP 2
00593 #define DAEMON_BIT_CAMOGM 3
00594 #define DAEMON_BIT_AUTOCAMPARS 4
00595
00596
00597 #define P_DAEMON_EN_AUTOEXPOSURE (P_DAEMON_EN | FRAMEPAIR_FRAME_BITS(1, DAEMON_BIT_AUTOEXPOSURE))
00598 #define P_DAEMON_EN_STREAMER (P_DAEMON_EN | FRAMEPAIR_FRAME_BITS(1, DAEMON_BIT_STREAMER))
00599 #define P_DAEMON_EN_CCAMFTP (P_DAEMON_EN | FRAMEPAIR_FRAME_BITS(1, DAEMON_BIT_CCAMFTP))
00600 #define P_DAEMON_EN_CAMOGM (P_DAEMON_EN | FRAMEPAIR_FRAME_BITS(1, DAEMON_BIT_CAMOGM))
00601 #define P_DAEMON_EN_AUTOCAMPARS (P_DAEMON_EN | FRAMEPAIR_FRAME_BITS(1, DAEMON_BIT_AUTOCAMPARS))
00602
00603 #define P_GAIN_CTRL 183 // combines GAIN_STEP and GAIN_ENABLE
00604 #define P_GAIN_STEP (P_GAIN_CTRL | FRAMEPAIR_FRAME_BITS(16, GAIN_BIT_STEP)) // minimal correction to be applied to the analog gain
00605
00606 #define P_GAIN_ENABLE (P_GAIN_CTRL | FRAMEPAIR_FRAME_BITS(1, GAIN_BIT_ENABLE)) // enable analog gain adjustment in white balance procedure
00607
00608
00609
00610
00611
00612 #define HISTRQ_BIT_Y 0
00613 #define HISTRQ_BIT_C 1
00614
00615 #define P_HISTRQ_Y (P_HISTRQ | FRAMEPAIR_FRAME_BITS(1, HISTRQ_BIT_Y) | FRAMEPAIR_JUST_THIS)
00616 #define P_HISTRQ_C (P_HISTRQ | FRAMEPAIR_FRAME_BITS(1, HISTRQ_BIT_C) | FRAMEPAIR_JUST_THIS)
00617 #define P_HISTRQ_YC (P_HISTRQ | FRAMEPAIR_FRAME_BITS(2, HISTRQ_BIT_Y) | FRAMEPAIR_JUST_THIS)
00618
00619 #define G_HISTMODE_Y (G_TASKLET_CTL | FRAMEPAIR_FRAME_BITS(3, TASKLET_CTL_HISTY_BIT))
00620 #define G_HISTMODE_C (G_TASKLET_CTL | FRAMEPAIR_FRAME_BITS(3, TASKLET_CTL_HISTC_BIT))
00621
00622 #define G_PROFILING_EN (G_TASKLET_CTL | FRAMEPAIR_FRAME_BITS(1, TASKLET_CTL_ENPROF))
00623
00624
00625
00626 #define P_AUTOCAMPARS_GROUPS (P_AUTOCAMPARS_CTRL | FRAMEPAIR_FRAME_BITS(24, 0))
00627 #define P_AUTOCAMPARS_PAGE (P_AUTOCAMPARS_CTRL | FRAMEPAIR_FRAME_BITS(4, 24))
00628 #define P_AUTOCAMPARS_CMD (P_AUTOCAMPARS_CTRL | FRAMEPAIR_FRAME_BITS(3, 28))
00629
00631 #define AUTOCAMPARS_CMD_RESTORE 1
00632 #define AUTOCAMPARS_CMD_SAVE 2
00633 #define AUTOCAMPARS_CMD_DFLT 3
00634 #define AUTOCAMPARS_CMD_SAVEDFLT 4
00635 #define AUTOCAMPARS_CMD_INIT 5
00636
00637
00638
00640 #define HISTOGRAMS_WAKEUP_ALWAYS 0
00641
00642
00649 #define PARS_FRAMES 8 // number of frames handled in buffer
00650 #define PARS_FRAMES_MASK (PARS_FRAMES-1) // currently 7
00651 #define PASTPARS_SAVE_ENTRIES (PARS_FRAMES << 8) // 2048
00652 #define PASTPARS_SAVE_ENTRIES_MASK ((PARS_FRAMES << 8)-1) // 0x7ff
00653 struct framepars_t {
00654 unsigned long pars[927];
00655 unsigned long functions;
00656 unsigned long modsince[31];
00657 unsigned long modsince32;
00658 unsigned long mod[31];
00659 unsigned long mod32;
00660 unsigned long needproc[31];
00661 unsigned long needproc32;
00662 };
00664
00668
00676
00677
00680
00682 enum onchange_functions_t {
00683 onchange_recalcseq=0,
00684 onchange_detectsensor,
00685 onchange_sensorphase,
00686 onchange_i2c,
00687 onchange_sensorregs,
00688 onchange_initsensor,
00689 onchange_afterinit,
00690 onchange_window,
00691 onchange_window_safe,
00692
00693 onchange_gains,
00694 onchange_triggermode,
00695 onchange_sensorin,
00696 onchange_sensorstop,
00697 onchange_sensorrun,
00698 onchange_gamma,
00699 onchange_hist,
00700 onchange_aexp,
00701 onchange_quality,
00702 onchange_memsensor,
00703 onchange_memcompressor,
00704 onchange_limitfps,
00705 onchange_exposure,
00706
00707 onchange_compmode,
00708 onchange_focusmode,
00709 onchange_trigseq,
00710 onchange_irq,
00711 onchange_comprestart,
00712 onchange_compstop,
00713 onchange_compctl,
00714 onchange_gammaload,
00715 onchange_prescal
00716
00717
00719 };
00720
00721 struct framepars_past_t {
00722 unsigned long past_pars[PARS_SAVE_NUM];
00723 };
00724
00725 struct framepars_all_t {
00726 struct framepars_t framePars[PARS_FRAMES];
00727 struct framepars_t func2call;
00728 unsigned long globalPars[1024];
00729 struct framepars_past_t pastPars [PASTPARS_SAVE_ENTRIES];
00730 };
00731
00732 struct frameparspair_t {
00733 unsigned long num;
00734 unsigned long val;
00735 };
00736
00737
00738
00739 #define ERR_FRAMEPARS_TOOEARLY 100
00740 #define ERR_FRAMEPARS_TOOLATE 101
00741 #define ERR_FRAMEPARS_BADINDEX 102
00742 #define ERR_PGM_TRYAGAINLATER 103
00743
00744
00745 #define FRAMEPARS_SETFRAME 0xff01
00746 #define FRAMEPARS_SETFRAMEREL 0xff02
00747 #define FRAMEPARS_SETLATENCY 0xff03
00748 #define FRAMEPARS_SETFPGATIME 0xff04
00749 #define FRAMEPARS_GETFPGATIME 0xff05
00750
00751 #define FRAME_DEAFAULT_AHEAD 3 // program current frame+3 if not specified
00752
00753
00755 #define P_AUTOEXP P_AUTOEXP_ON
00756 #define P_AEXPWND P_HISTWND_WIDTH
00757
00758
00759 struct autoexp_t {
00760 unsigned long on;
00761
00762
00763
00764 unsigned long width;
00765 unsigned long height;
00766 unsigned long left;
00767 unsigned long top;
00768
00769
00770
00771 unsigned long exp_max;
00772 unsigned long overexp_max;
00773
00774
00775
00776 unsigned long s_percent;
00777 unsigned long s_index;
00778
00779
00780
00781 unsigned long exp;
00782
00783
00784
00785 unsigned long skip_pmin;
00786 unsigned long skip_pmax;
00787 unsigned long skip_t;
00788 };
00789 struct aexp_window_t {
00790 unsigned long width;
00791 unsigned long height;
00792 unsigned long top;
00793 unsigned long left;
00794 };
00795
00796
00797 struct p_names_t {
00798 int value;
00799 char* name;
00800 };
00801
00802 #define P_NAME_ENTRY(y) { P_##y, #y }
00803 #define G_NAME_ENTRY(y) { G_##y, #y }
00804 #define DEFINE_P_NAMES(x) struct p_names_t x[]= { \
00805 P_NAME_ENTRY(NUMBER), \
00806 P_NAME_ENTRY(SENSOR), \
00807 P_NAME_ENTRY(SENSOR_RUN), \
00808 P_NAME_ENTRY(ACTUAL_WIDTH), \
00809 P_NAME_ENTRY(ACTUAL_HEIGHT), \
00810 P_NAME_ENTRY(BAYER), \
00811 P_NAME_ENTRY(PERIOD), \
00812 P_NAME_ENTRY(FP1000SLIM), \
00813 P_NAME_ENTRY(FRAME), \
00814 P_NAME_ENTRY(CLK_FPGA), \
00815 P_NAME_ENTRY(CLK_SENSOR), \
00816 P_NAME_ENTRY(FPGA_XTRA), \
00817 P_NAME_ENTRY(TRIG), \
00818 P_NAME_ENTRY(EXPOS), \
00819 P_NAME_ENTRY(BGFRAME), \
00820 P_NAME_ENTRY(IMGSZMEM), \
00821 P_NAME_ENTRY(PAGE_ACQ), \
00822 P_NAME_ENTRY(PAGE_READ), \
00823 P_NAME_ENTRY(OVERLAP), \
00824 P_NAME_ENTRY(VIRT_KEEP), \
00825 P_NAME_ENTRY(VIRT_WIDTH), \
00826 P_NAME_ENTRY(VIRT_HEIGHT), \
00827 P_NAME_ENTRY(WOI_LEFT), \
00828 P_NAME_ENTRY(WOI_TOP), \
00829 P_NAME_ENTRY(WOI_WIDTH), \
00830 P_NAME_ENTRY(WOI_HEIGHT), \
00831 P_NAME_ENTRY(FLIPH), \
00832 P_NAME_ENTRY(FLIPV), \
00833 P_NAME_ENTRY(FPSFLAGS), \
00834 P_NAME_ENTRY(DCM_HOR), \
00835 P_NAME_ENTRY(DCM_VERT), \
00836 P_NAME_ENTRY(BIN_HOR), \
00837 P_NAME_ENTRY(BIN_VERT), \
00838 P_NAME_ENTRY(FPGATEST), \
00839 P_NAME_ENTRY(TESTSENSOR), \
00840 P_NAME_ENTRY(COLOR), \
00841 P_NAME_ENTRY(FRAMESYNC_DLY), \
00842 P_NAME_ENTRY(PF_HEIGHT), \
00843 P_NAME_ENTRY(BITS), \
00844 P_NAME_ENTRY(SHIFTL), \
00845 P_NAME_ENTRY(FPNS), \
00846 P_NAME_ENTRY(FPNM), \
00847 P_NAME_ENTRY(VEXPOS), \
00848 P_NAME_ENTRY(VIRTTRIG), \
00849 P_NAME_ENTRY(PERIOD_MIN), \
00850 P_NAME_ENTRY(PERIOD_MAX), \
00851 P_NAME_ENTRY(SENSOR_PIXH), \
00852 P_NAME_ENTRY(SENSOR_PIXV), \
00853 P_NAME_ENTRY(GAINR), \
00854 P_NAME_ENTRY(GAING), \
00855 P_NAME_ENTRY(GAINB), \
00856 P_NAME_ENTRY(GAINGB), \
00857 P_NAME_ENTRY(FATZERO), \
00858 P_NAME_ENTRY(QUALITY), \
00859 P_NAME_ENTRY(FP1000S), \
00860 P_NAME_ENTRY(SENSOR_WIDTH), \
00861 P_NAME_ENTRY(SENSOR_HEIGHT), \
00862 P_NAME_ENTRY(COLOR_SATURATION_BLUE), \
00863 P_NAME_ENTRY(COLOR_SATURATION_RED), \
00864 P_NAME_ENTRY(VIGNET_AX), \
00865 P_NAME_ENTRY(VIGNET_AY), \
00866 P_NAME_ENTRY(VIGNET_BX), \
00867 P_NAME_ENTRY(VIGNET_BY), \
00868 P_NAME_ENTRY(VIGNET_C), \
00869 P_NAME_ENTRY(VIGNET_SHL), \
00870 P_NAME_ENTRY(VIGNET_ZERIN), \
00871 P_NAME_ENTRY(VIGNET_ZEROUT), \
00872 P_NAME_ENTRY(DGAINR), \
00873 P_NAME_ENTRY(DGAING), \
00874 P_NAME_ENTRY(DGAINGB), \
00875 P_NAME_ENTRY(DGAINB), \
00876 P_NAME_ENTRY(ZBINROUND), \
00877 P_NAME_ENTRY(TILES), \
00878 P_NAME_ENTRY(SENSOR_PHASE), \
00879 P_NAME_ENTRY(AUTOEXP_ON), \
00880 P_NAME_ENTRY(HISTWND_RWIDTH), \
00881 P_NAME_ENTRY(HISTWND_RHEIGHT), \
00882 P_NAME_ENTRY(HISTWND_RLEFT), \
00883 P_NAME_ENTRY(HISTWND_RTOP), \
00884 P_NAME_ENTRY(AUTOEXP_EXP_MAX), \
00885 P_NAME_ENTRY(AUTOEXP_OVEREXP_MAX), \
00886 P_NAME_ENTRY(AUTOEXP_S_PERCENT), \
00887 P_NAME_ENTRY(AUTOEXP_S_INDEX), \
00888 P_NAME_ENTRY(AUTOEXP_EXP), \
00889 P_NAME_ENTRY(AUTOEXP_SKIP_PMIN), \
00890 P_NAME_ENTRY(AUTOEXP_SKIP_PMAX), \
00891 P_NAME_ENTRY(AUTOEXP_SKIP_T), \
00892 P_NAME_ENTRY(HISTWND_WIDTH), \
00893 P_NAME_ENTRY(HISTWND_HEIGHT), \
00894 P_NAME_ENTRY(HISTWND_TOP), \
00895 P_NAME_ENTRY(HISTWND_LEFT), \
00896 P_NAME_ENTRY(FOCUS_SHOW), \
00897 P_NAME_ENTRY(FOCUS_SHOW1), \
00898 P_NAME_ENTRY(FOCUS_LEFT), \
00899 P_NAME_ENTRY(FOCUS_WIDTH), \
00900 P_NAME_ENTRY(FOCUS_TOP), \
00901 P_NAME_ENTRY(FOCUS_HEIGHT), \
00902 P_NAME_ENTRY(FOCUS_TOTWIDTH), \
00903 P_NAME_ENTRY(FOCUS_FILTER), \
00904 P_NAME_ENTRY(TRIG_CONDITION), \
00905 P_NAME_ENTRY(TRIG_DELAY), \
00906 P_NAME_ENTRY(TRIG_OUT), \
00907 P_NAME_ENTRY(TRIG_PERIOD), \
00908 P_NAME_ENTRY(SKIP_FRAMES), \
00909 P_NAME_ENTRY(I2C_QPERIOD), \
00910 P_NAME_ENTRY(I2C_BYTES), \
00911 P_NAME_ENTRY(IRQ_SMART), \
00912 P_NAME_ENTRY(EARLY_TIMESTAMP), \
00913 P_NAME_ENTRY(OVERSIZE), \
00914 P_NAME_ENTRY(GTAB_R), \
00915 P_NAME_ENTRY(GTAB_G), \
00916 P_NAME_ENTRY(GTAB_GB), \
00917 P_NAME_ENTRY(GTAB_B), \
00918 P_NAME_ENTRY(RFOCUS_LEFT), \
00919 P_NAME_ENTRY(RFOCUS_WIDTH), \
00920 P_NAME_ENTRY(RFOCUS_TOP), \
00921 P_NAME_ENTRY(RFOCUS_HEIGHT), \
00922 P_NAME_ENTRY(SDRAM_CHN20), \
00923 P_NAME_ENTRY(SDRAM_CHN21), \
00924 P_NAME_ENTRY(SDRAM_CHN22), \
00925 P_NAME_ENTRY(COMPRESSOR_RUN), \
00926 P_NAME_ENTRY(COMPMOD_BYRSH), \
00927 P_NAME_ENTRY(COMPMOD_TILSH), \
00928 P_NAME_ENTRY(COMPMOD_DCSUB), \
00929 P_NAME_ENTRY(COMPMOD_QTAB), \
00930 P_NAME_ENTRY(SENSOR_REGS), \
00931 P_NAME_ENTRY(SENSOR_NUMREGS), \
00932 P_NAME_ENTRY(DAEMON_EN), \
00933 P_NAME_ENTRY(DAEMON_EN_AUTOEXPOSURE), \
00934 P_NAME_ENTRY(DAEMON_EN_STREAMER), \
00935 P_NAME_ENTRY(DAEMON_EN_CCAMFTP), \
00936 P_NAME_ENTRY(DAEMON_EN_CAMOGM), \
00937 P_NAME_ENTRY(DAEMON_EN_AUTOCAMPARS), \
00938 P_NAME_ENTRY(AEXP_FRACPIX), \
00939 P_NAME_ENTRY(AEXP_LEVEL), \
00940 P_NAME_ENTRY(HDR_DUR), \
00941 P_NAME_ENTRY(HDR_VEXPOS), \
00942 P_NAME_ENTRY(EXP_AHEAD), \
00943 P_NAME_ENTRY(AE_THRESH), \
00944 P_NAME_ENTRY(WB_THRESH), \
00945 P_NAME_ENTRY(AE_PERIOD), \
00946 P_NAME_ENTRY(WB_PERIOD), \
00947 P_NAME_ENTRY(WB_MASK), \
00948 P_NAME_ENTRY(WB_WHITELEV), \
00949 P_NAME_ENTRY(WB_WHITEFRAC), \
00950 P_NAME_ENTRY(WB_SCALE_R), \
00951 P_NAME_ENTRY(WB_SCALE_GB), \
00952 P_NAME_ENTRY(WB_SCALE_B), \
00953 P_NAME_ENTRY(HISTRQ), \
00954 P_NAME_ENTRY(HISTRQ_Y), \
00955 P_NAME_ENTRY(HISTRQ_C), \
00956 P_NAME_ENTRY(HISTRQ_YC), \
00957 P_NAME_ENTRY(PROFILE), \
00958 P_NAME_ENTRY(GAIN_MIN), \
00959 P_NAME_ENTRY(GAIN_MAX), \
00960 P_NAME_ENTRY(GAIN_CTRL), \
00961 P_NAME_ENTRY(GAIN_STEP), \
00962 P_NAME_ENTRY(GAIN_ENABLE), \
00963 P_NAME_ENTRY(AUTOCAMPARS_CTRL), \
00964 P_NAME_ENTRY(AUTOCAMPARS_GROUPS), \
00965 P_NAME_ENTRY(AUTOCAMPARS_PAGE), \
00966 P_NAME_ENTRY(AUTOCAMPARS_CMD), \
00967 P_NAME_ENTRY(FTP_PERIOD), \
00968 P_NAME_ENTRY(FTP_TIMEOUT), \
00969 P_NAME_ENTRY(FTP_UPDATE), \
00970 G_NAME_ENTRY(DEBUG), \
00971 G_NAME_ENTRY(MAXAHEAD), \
00972 G_NAME_ENTRY(THIS_FRAME), \
00973 G_NAME_ENTRY(CIRCBUFSIZE), \
00974 G_NAME_ENTRY(FREECIRCBUF), \
00975 G_NAME_ENTRY(CIRCBUFWP), \
00976 G_NAME_ENTRY(CIRCBUFRP), \
00977 G_NAME_ENTRY(SECONDS), \
00978 G_NAME_ENTRY(MICROSECONDS), \
00979 G_NAME_ENTRY(CALLNASAP), \
00980 G_NAME_ENTRY(CALLNEXT), \
00981 G_NAME_ENTRY(NEXT_AE_FRAME), \
00982 G_NAME_ENTRY(NEXT_WB_FRAME), \
00983 G_NAME_ENTRY(HIST_DIM_01), \
00984 G_NAME_ENTRY(HIST_DIM_23), \
00985 G_NAME_ENTRY(AE_INTEGERR), \
00986 G_NAME_ENTRY(WB_INTEGERR), \
00987 G_NAME_ENTRY(TASKLET_CTL), \
00988 G_NAME_ENTRY(GFOCUS_VALUE), \
00989 G_NAME_ENTRY(HISTMODE_Y), \
00990 G_NAME_ENTRY(HISTMODE_C), \
00991 G_NAME_ENTRY(HIST_LAST_INDEX), \
00992 G_NAME_ENTRY(HIST_Y_FRAME), \
00993 G_NAME_ENTRY(HIST_C_FRAME), \
00994 G_NAME_ENTRY(SKIP_DIFF_FRAME), \
00995 G_NAME_ENTRY(FTP_NEXT_TIME), \
00996 G_NAME_ENTRY(DAEMON_ERR), \
00997 G_NAME_ENTRY(DAEMON_RETCODE), \
00998 G_NAME_ENTRY(PROFILING_EN) \
00999 };
01000
01001 #define ONCHANGE_NAME_ENTRY(y) { onchange_##y, #y }
01002 #define DEFINE_ONCHANGE_NAMES(x) struct p_names_t x[]= { \
01003 ONCHANGE_NAME_ENTRY(recalcseq), \
01004 ONCHANGE_NAME_ENTRY(detectsensor), \
01005 ONCHANGE_NAME_ENTRY(sensorphase), \
01006 ONCHANGE_NAME_ENTRY(i2c), \
01007 ONCHANGE_NAME_ENTRY(sensorregs), \
01008 ONCHANGE_NAME_ENTRY(initsensor), \
01009 ONCHANGE_NAME_ENTRY(afterinit), \
01010 ONCHANGE_NAME_ENTRY(window), \
01011 ONCHANGE_NAME_ENTRY(window_safe), \
01012 ONCHANGE_NAME_ENTRY(gains), \
01013 ONCHANGE_NAME_ENTRY(triggermode), \
01014 ONCHANGE_NAME_ENTRY(sensorin), \
01015 ONCHANGE_NAME_ENTRY(sensorstop), \
01016 ONCHANGE_NAME_ENTRY(sensorrun), \
01017 ONCHANGE_NAME_ENTRY(gamma), \
01018 ONCHANGE_NAME_ENTRY(hist), \
01019 ONCHANGE_NAME_ENTRY(aexp), \
01020 ONCHANGE_NAME_ENTRY(quality), \
01021 ONCHANGE_NAME_ENTRY(memsensor), \
01022 ONCHANGE_NAME_ENTRY(memcompressor), \
01023 ONCHANGE_NAME_ENTRY(limitfps), \
01024 ONCHANGE_NAME_ENTRY(exposure), \
01025 ONCHANGE_NAME_ENTRY(compmode), \
01026 ONCHANGE_NAME_ENTRY(focusmode), \
01027 ONCHANGE_NAME_ENTRY(trigseq), \
01028 ONCHANGE_NAME_ENTRY(irq), \
01029 ONCHANGE_NAME_ENTRY(comprestart), \
01030 ONCHANGE_NAME_ENTRY(compstop), \
01031 ONCHANGE_NAME_ENTRY(compctl), \
01032 ONCHANGE_NAME_ENTRY(gammaload) \
01033 };
01034
01035
01036
01037
01038 #ifndef ERR_I2C_SCL_ST0
01039 #define ERR_I2C_SCL_ST0 1
01040 #define ERR_I2C_SDA_ST0 2
01041 #define ERR_I2C_SCL_ST1 4
01042 #define ERR_I2C_SDA_ST1 8
01043 #define ERR_I2C_SCL_NOPULLUP 16
01044 #define ERR_I2C_SDA_NOPULLUP 32
01045
01046
01047 #define ERR_I2C_NOTDETECTED 64
01048 #define ERR_I2C_SHORT 128
01049 #define ERR_I2C_BSY 256
01050 #define ERR_I2C_NACK 512
01051 #endif
01052
01053
01054
01055 #define IO_CCAM_SET_EXT_EXPOSURE 0x06
01056 #define IO_CCAM_MONITOR_SEQ 0x07
01057
01058
01059 #define IO_EXT_BOARD_PRESENT 0xF0
01060
01061
01062
01063
01064
01066 #define IO_CCAM_JPEG 0x08
01067
01068 #define JPEG_CMD_RESET 0x00
01069 //#define JPEG_CMD_ARM 0x01
01070 #define JPEG_CMD_GET 0x02
01071 #define JPEG_CMD_FORGET 0x03
01072 #define JPEG_CMD_CATCHUP 0x04
01073 #define JPEG_CMD_ACQUIRE 0x05
01074 #define JPEG_CMD_SAVE_RP 0x06
01075 #define JPEG_CMD_RESTORE_RP 0x07
01076 #define JPEG_CMD_N_DONE 0x08
01077 #define JPEG_CMD_L_DONE 0x09
01078 #define JPEG_CMD_START 0x0a
01079 #define JPEG_CMD_STOP 0x0b
01080 #define JPEG_CMD_FRAMES 0x0c
01081 #define JPEG_CMD_JUST_STOP 0x0d
01082 #define JPEG_CMD_DUMP 0x0f
01083 #define JPEG_CMD_RESET0 0x10
01084
01085
01086
01088
01089 #define LSEEK_GAMMA_INIT 1 // SEEK_END LSEEK_GAMMA_INIT to initialize all the gamma data structures
01090 #define LSEEK_GAMMA_ISCURRENT 2 // SEEK_END to check if the selected node(pointed by file pointer) is current - returns 0 if not, otherwise - node index
01091
01092
01093 #define LSEEK_CIRC_TORP 1
01094 #define LSEEK_CIRC_TOWP 2
01095 #define LSEEK_CIRC_PREV 3
01096 #define LSEEK_CIRC_NEXT 4
01097 #define LSEEK_CIRC_LAST 5
01098 #define LSEEK_CIRC_FIRST 6
01099 #define LSEEK_CIRC_SCND 7
01100 #define LSEEK_CIRC_SETP 8
01101 #define LSEEK_CIRC_VALID 9
01102 #define LSEEK_CIRC_READY 10
01103 #define LSEEK_CIRC_WAIT 11
01104 #define LSEEK_CIRC_FREE 12
01105 #define LSEEK_CIRC_USED 13
01106
01107 #define LSEEK_HUFFMAN_DC0 1
01108 #define LSEEK_HUFFMAN_AC0 2
01109 #define LSEEK_HUFFMAN_DC1 3
01110 #define LSEEK_HUFFMAN_AC1 4
01111 #define LSEEK_HUFFMAN_FPGATAB 5
01112 #define LSEEK_HUFFMAN_DEFAULT 6
01113 #define LSEEK_HUFFMAN_FPGACALC 7
01114 #define LSEEK_HUFFMAN_FPGAPGM 8
01115
01116
01117
01118
01119 #define LSEEK_GET_FPGA_TIME 0x16
01120 #define LSEEK_SET_FPGA_TIME 0x17
01121
01122
01123 #define LSEEK_AUTOEXP_SET 0x19
01124 #define LSEEK_AUTOEXP_GET 0x1a
01125 #define LSEEK_TRIGGER_PGM 0x1b
01126 #define LSEEK_I2C_PGM 0x1c
01127 #define LSEEK_IRQ_SMART_PGM 0x1d
01128 #define LSEEK_EARLY_TIMESTAMP_PGM 0x1e
01129 #define LSEEK_DMA_INIT 0x1f
01130 #define LSEEK_DMA_STOP 0x20
01131 #define LSEEK_DMA_START 0x21
01132 #define LSEEK_COMPRESSOR_RESET 0x22
01133 #define LSEEK_INTERRUPT_OFF 0x23
01134 #define LSEEK_INTERRUPT_ON 0x24
01135
01136 #define LSEEK_FRAMEPARS_INIT 0x25
01137 #define LSEEK_SENSORPROC 0x26
01138
01139 #define LSEEK_FRAME_RESET 0x27
01140
01142 #define LSEEK_HIST_WAIT_Y 0x28
01143 #define LSEEK_HIST_WAIT_C 0x29
01144 #define LSEEK_HIST_REQ_EN 0x2a
01145 #define LSEEK_HIST_REQ_DIS 0x2b
01146 #define LSEEK_HIST_NEEDED 0x10000
01147 //#define LSEEK_HIST_WAIT_AE 0x2a
01148
01149 #define LSEEK_DAEMON_FRAME 0x80
01150 #define LSEEK_DAEMON_CIRCBUF 0xa0
01151 #define LSEEK_DAEMON_HIST_Y 0xc0
01152 #define LSEEK_DAEMON_HIST_C 0xe0
01153
01154
01155 #define LSEEK_FRAME_WAIT_REL 0x100
01156 #define LSEEK_FRAME_WAIT_ABS 0x200
01157
01158 #define LSEEK_FSDRAM_RESET 0x01 // re-program FSDRAM (to be programmed again when accessed)
01159
01160 #define JPEG_CTRL_MONOCHROME 0x400
01161 #define JPEG_CTRL_MONOCHROME_BLOCKED 0x1000
01162 #define JPEG_CTRL_NOMOSAIC 0x1000
01163
01164 #define IO_CCAM_JPEG_QUALITY 0x09 // Set P_QUALITY
01165
01166 #define IO_CCAM_JPEG_GET_N 0x0a // get specified number of frames (will add to already asked for if any)
01167 #define IO_CCAM_JPEG_GET_L 0x0b // get specified length (will stop after frame if got more)
01168
01169 #define IO_CCAM_JPEG_CTRL 0x0c // Write JPEG control word (0x10000 - use header, LSW - other settings)
01170 #define IO_CCAM_DMA 0x0d
01171 #define CCAM_DMA_CMD_STOP 0x00
01172 #define CCAM_DMA_CMD_START 0x01 // just starts DMA - descriptor list should be set eatlier
01173
01174 #define IO_CCAM_CR_MODIFY 0x0e //(bit number)<<2 | op; op= 0 - nop, 1 - set, 2 - reset, 3 - toggle)
01175 #define IO_CCAM_CR_SHADOW 0x0f
01176
01177 #define IO_CCAM_PINS_WRITE 0x20
01178 #define IO_CCAM_PINS_READ 0x21
01179
01180
01181 #define LSEEK_NAME_ENTRY(y) { LSEEK_##y, #y }
01182 #define DEFINE_LSEEK_NAMES(x) struct p_names_t x[]= { \
01183 LSEEK_NAME_ENTRY(GAMMA_INIT), \
01184 LSEEK_NAME_ENTRY(GAMMA_ISCURRENT), \
01185 LSEEK_NAME_ENTRY(CIRC_TORP), \
01186 LSEEK_NAME_ENTRY(CIRC_TOWP), \
01187 LSEEK_NAME_ENTRY(CIRC_PREV), \
01188 LSEEK_NAME_ENTRY(CIRC_NEXT), \
01189 LSEEK_NAME_ENTRY(CIRC_LAST), \
01190 LSEEK_NAME_ENTRY(CIRC_FIRST), \
01191 LSEEK_NAME_ENTRY(CIRC_SCND), \
01192 LSEEK_NAME_ENTRY(CIRC_SETP), \
01193 LSEEK_NAME_ENTRY(CIRC_VALID), \
01194 LSEEK_NAME_ENTRY(CIRC_READY), \
01195 LSEEK_NAME_ENTRY(CIRC_WAIT), \
01196 LSEEK_NAME_ENTRY(CIRC_FREE), \
01197 LSEEK_NAME_ENTRY(CIRC_USED), \
01198 LSEEK_NAME_ENTRY(HUFFMAN_DC0), \
01199 LSEEK_NAME_ENTRY(HUFFMAN_AC0), \
01200 LSEEK_NAME_ENTRY(HUFFMAN_DC1), \
01201 LSEEK_NAME_ENTRY(HUFFMAN_AC1), \
01202 LSEEK_NAME_ENTRY(HUFFMAN_FPGATAB), \
01203 LSEEK_NAME_ENTRY(HUFFMAN_DEFAULT), \
01204 LSEEK_NAME_ENTRY(HUFFMAN_FPGACALC), \
01205 LSEEK_NAME_ENTRY(HUFFMAN_FPGAPGM), \
01206 LSEEK_NAME_ENTRY(GET_FPGA_TIME), \
01207 LSEEK_NAME_ENTRY(SET_FPGA_TIME), \
01208 LSEEK_NAME_ENTRY(AUTOEXP_SET), \
01209 LSEEK_NAME_ENTRY(AUTOEXP_GET), \
01210 LSEEK_NAME_ENTRY(TRIGGER_PGM), \
01211 LSEEK_NAME_ENTRY(I2C_PGM), \
01212 LSEEK_NAME_ENTRY(IRQ_SMART_PGM), \
01213 LSEEK_NAME_ENTRY(EARLY_TIMESTAMP_PGM), \
01214 LSEEK_NAME_ENTRY(DMA_INIT), \
01215 LSEEK_NAME_ENTRY(DMA_STOP), \
01216 LSEEK_NAME_ENTRY(DMA_START), \
01217 LSEEK_NAME_ENTRY(COMPRESSOR_RESET), \
01218 LSEEK_NAME_ENTRY(INTERRUPT_OFF), \
01219 LSEEK_NAME_ENTRY(INTERRUPT_ON), \
01220 LSEEK_NAME_ENTRY(FRAMEPARS_INIT), \
01221 LSEEK_NAME_ENTRY(SENSORPROC), \
01222 LSEEK_NAME_ENTRY(FRAME_RESET), \
01223 LSEEK_NAME_ENTRY(HIST_WAIT_Y), \
01224 LSEEK_NAME_ENTRY(HIST_WAIT_C), \
01225 LSEEK_NAME_ENTRY(HIST_REQ_EN), \
01226 LSEEK_NAME_ENTRY(HIST_REQ_DIS), \
01227 LSEEK_NAME_ENTRY(HIST_NEEDED), \
01228 LSEEK_NAME_ENTRY(DAEMON_FRAME), \
01229 LSEEK_NAME_ENTRY(DAEMON_CIRCBUF), \
01230 LSEEK_NAME_ENTRY(DAEMON_HIST_Y), \
01231 LSEEK_NAME_ENTRY(DAEMON_HIST_C), \
01232 LSEEK_NAME_ENTRY(FRAME_WAIT_REL), \
01233 LSEEK_NAME_ENTRY(FRAME_WAIT_ABS), \
01234 LSEEK_NAME_ENTRY(FSDRAM_RESET) \
01235 };
01236
01237
01238 #define CCAM_BYTES_PER_CHUNK (1<<16)
01239 #define CCAM_DESCR_PER_CHUNK 1
01240
01241
01242
01243
01244
01245
01246
01247
01248 #define CCAM_CHUNK_PER_DMABUF 302
01249 #define CCAM_WORDS_PER_DMABUF (CCAM_CHUNK_PER_DMABUF<<14)
01250 #define CCAM_BYTES_PER_DMABUF (CCAM_CHUNK_PER_DMABUF<<16)
01251
01252
01253 #define CCAM_DMA_SIZE CCAM_WORDS_PER_DMABUF
01254
01255
01256
01257
01258 #define CCAM_MMAP_OFFSET_MMAP_HEADER 0
01259 #define CCAM_MMAP_OFFSET_JPEG_HEADER (PAGE_SIZE)
01260 #define CCAM_MMAP_OFFSET_DMABUF (4*PAGE_SIZE)
01261 #define CCAM_MMAP_SIZE (PAGE_SIZE*sizeof(long)+CCAM_BYTES_PER_DMABUF)
01262
01263 #define CCAM_MMAP_META 12 // extra bytes included at the end of each frame (last aligned to 32 bytes)
01264 #define CCAM_MMAP_META_LENGTH 4 // displacement to length frame length data from the end of the 32-byte aligned frame slot
01265 #define CCAM_MMAP_META_USEC 8 // (negative) displacement to USEC data - 20 bits (frame timestamp)
01266 #define CCAM_MMAP_META_SEC 12 // (negative) displacement to SEC data - 32 bits (frame timestamp)
01267
01269 #define CX313_FPGA_TABLES_SIZE 0xC00 //=3000 bytes, 32-bit wide, LSB first, some tables use less
01270 #define CX313_FPGA_TABLES_QUANT 0x0 // 0x200 words quantization (8*64*2/2)
01271 #define CX313_FPGA_TABLES_HUFF 0x200 // 0x200 words Huffman table
01272 #define CX313_FPGA_TABLES_GAMMA 0x400 // 0x400 words gamma-correction (or arbitrary table)
01273 #define CX313_FPGA_TABLES_FOCUS 0x800 // 15*64 16-bit words (now high 16 bits are unused)
01274 #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]
01275
01276
01277
01278 struct sensor_t {
01279
01280 unsigned long imageWidth;
01281 unsigned long imageHeight;
01282 unsigned long clearWidth;
01283 unsigned long clearHeight;
01284 unsigned long clearTop;
01285 unsigned long clearLeft;
01286 unsigned long arrayWidth;
01287 unsigned long arrayHeight;
01288 unsigned long minWidth;
01289 unsigned long minHeight;
01290 unsigned long minHorBlank;
01291 unsigned long minLineDur;
01292 unsigned long maxHorBlank;
01293 unsigned long minVertBlank;
01294 unsigned long maxVertBlank;
01295 unsigned long maxShutter;
01296 unsigned long flips;
01297 unsigned long init_flips;
01298 unsigned long bayer;
01299 unsigned long dcmHor;
01300 unsigned long dcmVert;
01301 unsigned long binHor;
01302 unsigned long binVert;
01303 unsigned long maxGain256;
01304 unsigned long minClockFreq;
01305 unsigned long maxClockFreq;
01306 unsigned long nomClockFreq;
01307 unsigned long sensorType;
01308 unsigned long i2c_addr;
01309 unsigned long i2c_period;
01310 unsigned long i2c_bytes;
01311 unsigned long hact_delay;
01312 unsigned short sensorPhase90;
01313 signed short sensorPhase;
01314 unsigned long needReset;
01315 };
01316 #define SENSOR_NEED_RESET_CLK 1
01317 #define SENSOR_NEED_RESET_PHASE 2
01318
01319 struct sensorproc_t {
01320 struct sensor_t sensor;
01324 int (*pgm_func[64]) (struct sensor_t * sensor,
01325 struct framepars_t * framepars,
01326 struct framepars_t * prevpars,
01327 int frame8);
01328 };
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339 #define DEFAULT_COLOR_SATURATION_BLUE 0x90 // 100*realtive saturation blue
01340 #define DEFAULT_COLOR_SATURATION_RED 0xb6 // 100*realtive saturation red
01341
01342
01343 #define EXPOSURE_UNIT 1 // to move to finer exposure settings - current unit in microseconds. TODO: Propagate it to drivers...
01345
01346
01354 struct interframe_params_t {
01357 union{unsigned long hash32_r; struct{unsigned short scale_r; union {unsigned short hash16_r; struct{unsigned char gamma_r; unsigned char black_r; };};};};
01358 union{unsigned long hash32_g; struct{unsigned short scale_g; union {unsigned short hash16_g; struct{unsigned char gamma_g; unsigned char black_g; };};};};
01359 union{unsigned long hash32_gb;struct{unsigned short scale_gb;union {unsigned short hash16_gb;struct{unsigned char gamma_gb;unsigned char black_gb;};};};};
01360 union{unsigned long hash32_b; struct{unsigned short scale_b; union {unsigned short hash16_b; struct{unsigned char gamma_b; unsigned char black_b; };};};};
01361 unsigned short quality2;
01362
01363
01364
01365 unsigned char color;
01366 unsigned char byrshift;
01367 unsigned short width;
01368 unsigned short height;
01369
01370 # if 0
01371 unsigned long exposure;
01372 unsigned short width;
01373 unsigned short height;
01374 unsigned long colorsat;
01375 unsigned char color;
01376 unsigned char quality;
01377 unsigned char gamma;
01378 unsigned char black;
01379 unsigned short rscale;
01380 unsigned short bscale;
01381
01382
01383 unsigned short unused20;
01384 unsigned short past_index;
01385 #endif
01386
01387
01388
01389 unsigned short meta_index;
01390
01391 unsigned short signffff;
01392
01393 union {
01394 unsigned long timestamp_sec ;
01395 unsigned long frame_length ;
01396 };
01397 unsigned long timestamp_usec;
01398 };
01399
01400 struct i2c_timing_t {
01401 unsigned char scl_high;
01402 unsigned char scl_low;
01403 unsigned char slave2master;
01404 unsigned char master2slave;
01405 unsigned char filter_sda;
01406 unsigned char filter_scl;
01407 };
01408
01410 #define GAMMA_CACHE_NUMBER 256 // number of gamma-tables cached
01411 #define GAMMA_VALID_MASK 1 // table is calculated, matches given hash/scale
01412 #define GAMMA_VALID_REVERSE 2 // reverse table is calculated for the given hash/scale
01413 #define GAMMA_FPGA_MASK 4 // gamma-table encoded for the FPGA is valid
01414
01415
01416
01417 #define GAMMA_MODE_NOT_NICE 1 // if set, no interrupts will be enabled between steps, whole operation is atomic
01418 #define GAMMA_MODE_NEED_REVERSE 2 // reverse gamma table is needed
01419 #define GAMMA_MODE_HARDWARE 4 // the table is needed to program FPGA: fpga-encoded table will be calculated (if not yet),
01420 #define GAMMA_MODE_LOCK 8 // Lock the table for the specified color (used from irq/tasklet - it is needed because all 4 tables in FPGA have to be overwritten at once)
01421
01422 #define GAMMA_SCALE_SHIFT 10 // when scaling - shift right by GAMMA_SCALE_SHIFT (treat scale as 6.10)
01423 #define GAMMA_SCLALE_1 ( 1 << GAMMA_SCALE_SHIFT ) // gamma scale 1.0 - 0x400
01424 struct gamma_stuct_t {
01425 union {
01426 unsigned long hash32;
01427 struct {
01428 unsigned short scale;
01429 union {
01430 unsigned short hash16;
01431 struct {
01432 unsigned char gamma;
01433 unsigned char black;
01434 };
01435 };
01436 };
01437 };
01438 int valid;
01439
01440 int locked;
01441 int this_non_scaled;
01442 union {
01443 struct {
01444 int oldest_non_scaled;
01445 int newest_non_scaled;
01446 };
01447 struct {
01448 int newer_non_scaled;
01449 int older_non_scaled;
01450 };
01451 };
01452 union {
01453 struct {
01454 int oldest_all;
01455 int newest_all;
01456 };
01457 struct {
01458 int newer_all;
01459 int older_all;
01460
01461 };
01462 };
01463 union {
01464 struct {
01465 int oldest_scaled;
01466 int newest_scaled;
01467 };
01468 struct {
01469 int newer_scaled;
01470 int older_scaled;
01471 };
01472 struct {
01473 int non_scaled_length;
01474 int num_locked;
01475 };
01476 };
01477 union {
01478 struct {
01479 unsigned short direct[257];
01480 unsigned short dummy1;
01481
01482 unsigned char reverse[256];
01483 unsigned long fpga[256];
01484 };
01485 struct {
01486
01487 int locked_color[4];
01488
01489
01490 int other [129+64+256 -4];
01491 };
01492 };
01493 };
01494
01496 #define HISTOGRAM_CACHE_NUMBER 8 // number of frames histograms are kept after acquisition (should be 2^n)
01497 #define COLOR_RED 0
01498 #define COLOR_GREEN1 1
01499 #define COLOR_GREEN2 2
01500 #define COLOR_BLUE 3
01501
01502
01503 #define COLOR_Y_NUMBER COLOR_GREEN1 // green1 (index=1) is used as Y color (i.e. for auto exposure). Histogram for is calculated first (or only)
01504
01505
01506
01507
01508
01509
01510
01511 struct histogram_stuct_t {
01512 unsigned long frame;
01513 unsigned long valid;
01514
01515 union {
01516 unsigned long gtab[4];
01517 struct {
01518 unsigned long gtab_r;
01519 unsigned long gtab_g;
01520 unsigned long gtab_gb;
01521 unsigned long gtab_b;
01522 };
01523 };
01525 union {
01526 unsigned long hist[1024] ;
01527 struct {
01528 unsigned long hist_r [256] ;
01529 unsigned long hist_g [256] ;
01530 unsigned long hist_gb[256] ;
01531 unsigned long hist_b [256] ;
01532 };
01533 };
01535 union {
01536 unsigned long cumul_hist[1024] ;
01537 struct {
01538 unsigned long cumul_hist_r [256] ;
01539 unsigned long cumul_hist_g [256] ;
01540 unsigned long cumul_hist_gb[256] ;
01541 unsigned long cumul_hist_b [256] ;
01542 };
01543 };
01551 union {
01552 unsigned char percentile[1024] ;
01553 struct {
01554 unsigned char percentile_r [256] ;
01555 unsigned char percentile_g [256] ;
01556 unsigned char percentile_gb[256] ;
01557 unsigned char percentile_b [256] ;
01558 };
01559 };
01560
01561 };
01562
01565 struct huffman_encoded_t {
01566 unsigned char bits[16];
01567 unsigned char huffval[256];
01568 };
01569
01571 #define CONST_NAME_ENTRY(y) { y, #y }
01572 #define DEFINE_CONST_NAMES(x) struct p_names_t x[]= { \
01573 CONST_NAME_ENTRY(SENSOR_RUN_STOP), \
01574 CONST_NAME_ENTRY(SENSOR_RUN_SINGLE), \
01575 CONST_NAME_ENTRY(SENSOR_RUN_CONT), \
01576 CONST_NAME_ENTRY(COMPRESSOR_RUN_STOP), \
01577 CONST_NAME_ENTRY(COMPRESSOR_RUN_SINGLE), \
01578 CONST_NAME_ENTRY(COMPRESSOR_RUN_CONT), \
01579 CONST_NAME_ENTRY(TASKLET_CTL_PGM), \
01580 CONST_NAME_ENTRY(TASKLET_CTL_IGNPAST), \
01581 CONST_NAME_ENTRY(TASKLET_CTL_NOSAME), \
01582 CONST_NAME_ENTRY(COLORMODE_MONO6), \
01583 CONST_NAME_ENTRY(COLORMODE_COLOR), \
01584 CONST_NAME_ENTRY(COLORMODE_JP46), \
01585 CONST_NAME_ENTRY(COLORMODE_JP46DC), \
01586 CONST_NAME_ENTRY(COLORMODE_COLOR20), \
01587 CONST_NAME_ENTRY(COLORMODE_JP4), \
01588 CONST_NAME_ENTRY(COLORMODE_JP4DC), \
01589 CONST_NAME_ENTRY(COLORMODE_JP4DIFF), \
01590 CONST_NAME_ENTRY(COLORMODE_JP4HDR), \
01591 CONST_NAME_ENTRY(COLORMODE_JP4DIFF2), \
01592 CONST_NAME_ENTRY(COLORMODE_JP4HDR2), \
01593 CONST_NAME_ENTRY(COLORMODE_MONO4), \
01594 CONST_NAME_ENTRY(PARS_FRAMES), \
01595 CONST_NAME_ENTRY(PARS_FRAMES_MASK), \
01596 CONST_NAME_ENTRY(PASTPARS_SAVE_ENTRIES), \
01597 CONST_NAME_ENTRY(PASTPARS_SAVE_ENTRIES_MASK), \
01598 CONST_NAME_ENTRY(FRAMEPAIR_FORCE_NEW), \
01599 CONST_NAME_ENTRY(FRAMEPAIR_FORCE_PROC), \
01600 CONST_NAME_ENTRY(FRAMEPAIR_FORCE_NEWPROC), \
01601 CONST_NAME_ENTRY(FRAMEPAIR_JUST_THIS), \
01602 CONST_NAME_ENTRY(FRAMEPAR_GLOBALS), \
01603 CONST_NAME_ENTRY(FRAMEPAIR_FRAME_FUNC), \
01604 CONST_NAME_ENTRY(FRAMEPAIR_MASK_BYTES), \
01605 CONST_NAME_ENTRY(FRAMEPAIR_BYTE0), \
01606 CONST_NAME_ENTRY(FRAMEPAIR_BYTE1), \
01607 CONST_NAME_ENTRY(FRAMEPAIR_BYTE2), \
01608 CONST_NAME_ENTRY(FRAMEPAIR_BYTE3), \
01609 CONST_NAME_ENTRY(FRAMEPAIR_WORD0), \
01610 CONST_NAME_ENTRY(FRAMEPAIR_WORD1), \
01611 CONST_NAME_ENTRY(ERR_FRAMEPARS_TOOEARLY), \
01612 CONST_NAME_ENTRY(ERR_FRAMEPARS_TOOLATE), \
01613 CONST_NAME_ENTRY(ERR_FRAMEPARS_BADINDEX), \
01614 CONST_NAME_ENTRY(DAEMON_BIT_AUTOEXPOSURE), \
01615 CONST_NAME_ENTRY(DAEMON_BIT_STREAMER), \
01616 CONST_NAME_ENTRY(DAEMON_BIT_CCAMFTP), \
01617 CONST_NAME_ENTRY(DAEMON_BIT_CAMOGM), \
01618 CONST_NAME_ENTRY(DAEMON_BIT_AUTOCAMPARS), \
01619 CONST_NAME_ENTRY(ERR_PGM_TRYAGAINLATER), \
01620 CONST_NAME_ENTRY(FRAMEPARS_SETFRAME), \
01621 CONST_NAME_ENTRY(FRAMEPARS_SETFRAMEREL), \
01622 CONST_NAME_ENTRY(FRAMEPARS_SETLATENCY), \
01623 CONST_NAME_ENTRY(FRAMEPARS_SETFPGATIME), \
01624 CONST_NAME_ENTRY(FRAMEPARS_GETFPGATIME), \
01625 CONST_NAME_ENTRY(GAMMA_CACHE_NUMBER), \
01626 CONST_NAME_ENTRY(GAMMA_VALID_MASK), \
01627 CONST_NAME_ENTRY(GAMMA_VALID_REVERSE), \
01628 CONST_NAME_ENTRY(GAMMA_FPGA_MASK), \
01629 CONST_NAME_ENTRY(GAMMA_MODE_NOT_NICE), \
01630 CONST_NAME_ENTRY(GAMMA_MODE_NEED_REVERSE), \
01631 CONST_NAME_ENTRY(GAMMA_MODE_HARDWARE), \
01632 CONST_NAME_ENTRY(GAMMA_MODE_LOCK), \
01633 CONST_NAME_ENTRY(GAMMA_SCALE_SHIFT), \
01634 CONST_NAME_ENTRY(GAMMA_SCLALE_1), \
01635 CONST_NAME_ENTRY(HISTOGRAM_CACHE_NUMBER), \
01636 CONST_NAME_ENTRY(COLOR_Y_NUMBER), \
01637 CONST_NAME_ENTRY(FRAME_DEAFAULT_AHEAD), \
01638 CONST_NAME_ENTRY(AUTOCAMPARS_CMD_RESTORE), \
01639 CONST_NAME_ENTRY(AUTOCAMPARS_CMD_SAVE), \
01640 CONST_NAME_ENTRY(AUTOCAMPARS_CMD_DFLT), \
01641 CONST_NAME_ENTRY(AUTOCAMPARS_CMD_SAVEDFLT), \
01642 CONST_NAME_ENTRY(AUTOCAMPARS_CMD_INIT), \
01643 CONST_NAME_ENTRY(COLOR_RED), \
01644 CONST_NAME_ENTRY(COLOR_GREEN1), \
01645 CONST_NAME_ENTRY(COLOR_GREEN2), \
01646 CONST_NAME_ENTRY(COLOR_BLUE) \
01647 };
01648
01650
01651
01652
01653
01654
01655
01656
01657
01658 #endif