| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame^] | 1 | #ifndef __LINUX_OV511_H | 
 | 2 | #define __LINUX_OV511_H | 
 | 3 |  | 
 | 4 | #include <asm/uaccess.h> | 
 | 5 | #include <linux/videodev.h> | 
 | 6 | #include <linux/smp_lock.h> | 
 | 7 | #include <linux/usb.h> | 
 | 8 |  | 
 | 9 | #define OV511_DEBUG	/* Turn on debug messages */ | 
 | 10 |  | 
 | 11 | #ifdef OV511_DEBUG | 
 | 12 | 	#define PDEBUG(level, fmt, args...) \ | 
 | 13 | 		if (debug >= (level)) info("[%s:%d] " fmt, \ | 
 | 14 | 		__FUNCTION__, __LINE__ , ## args) | 
 | 15 | #else | 
 | 16 | 	#define PDEBUG(level, fmt, args...) do {} while(0) | 
 | 17 | #endif | 
 | 18 |  | 
 | 19 | /* This macro restricts an int variable to an inclusive range */ | 
 | 20 | #define RESTRICT_TO_RANGE(v,mi,ma) { \ | 
 | 21 | 	if ((v) < (mi)) (v) = (mi); \ | 
 | 22 | 	else if ((v) > (ma)) (v) = (ma); \ | 
 | 23 | } | 
 | 24 |  | 
 | 25 | /* --------------------------------- */ | 
 | 26 | /* DEFINES FOR OV511 AND OTHER CHIPS */ | 
 | 27 | /* --------------------------------- */ | 
 | 28 |  | 
 | 29 | /* USB IDs */ | 
 | 30 | #define VEND_OMNIVISION	0x05A9 | 
 | 31 | #define PROD_OV511	0x0511 | 
 | 32 | #define PROD_OV511PLUS	0xA511 | 
 | 33 | #define PROD_OV518	0x0518 | 
 | 34 | #define PROD_OV518PLUS	0xA518 | 
 | 35 |  | 
 | 36 | #define VEND_MATTEL	0x0813 | 
 | 37 | #define PROD_ME2CAM	0x0002 | 
 | 38 |  | 
 | 39 | /* --------------------------------- */ | 
 | 40 | /*     OV51x REGISTER MNEMONICS      */ | 
 | 41 | /* --------------------------------- */ | 
 | 42 |  | 
 | 43 | /* Camera interface register numbers */ | 
 | 44 | #define R511_CAM_DELAY		0x10 | 
 | 45 | #define R511_CAM_EDGE		0x11 | 
 | 46 | #define R511_CAM_PXCNT		0x12 | 
 | 47 | #define R511_CAM_LNCNT		0x13 | 
 | 48 | #define R511_CAM_PXDIV		0x14 | 
 | 49 | #define R511_CAM_LNDIV		0x15 | 
 | 50 | #define R511_CAM_UV_EN		0x16 | 
 | 51 | #define R511_CAM_LINE_MODE	0x17 | 
 | 52 | #define R511_CAM_OPTS		0x18 | 
 | 53 |  | 
 | 54 | /* Snapshot mode camera interface register numbers */ | 
 | 55 | #define R511_SNAP_FRAME		0x19 | 
 | 56 | #define R511_SNAP_PXCNT		0x1A | 
 | 57 | #define R511_SNAP_LNCNT		0x1B | 
 | 58 | #define R511_SNAP_PXDIV		0x1C | 
 | 59 | #define R511_SNAP_LNDIV		0x1D | 
 | 60 | #define R511_SNAP_UV_EN		0x1E | 
 | 61 | #define R511_SNAP_OPTS		0x1F | 
 | 62 |  | 
 | 63 | /* DRAM register numbers */ | 
 | 64 | #define R511_DRAM_FLOW_CTL	0x20 | 
 | 65 | #define R511_DRAM_ARCP		0x21 | 
 | 66 | #define R511_DRAM_MRC		0x22 | 
 | 67 | #define R511_DRAM_RFC		0x23 | 
 | 68 |  | 
 | 69 | /* ISO FIFO register numbers */ | 
 | 70 | #define R51x_FIFO_PSIZE		0x30	/* 2 bytes wide w/ OV518(+) */ | 
 | 71 | #define R511_FIFO_OPTS		0x31 | 
 | 72 |  | 
 | 73 | /* Parallel IO register numbers */ | 
 | 74 | #define R511_PIO_OPTS		0x38 | 
 | 75 | #define R511_PIO_DATA		0x39 | 
 | 76 | #define R511_PIO_BIST		0x3E | 
 | 77 | #define R518_GPIO_IN		0x55	/* OV518(+) only */ | 
 | 78 | #define R518_GPIO_OUT		0x56	/* OV518(+) only */ | 
 | 79 | #define R518_GPIO_CTL		0x57	/* OV518(+) only */ | 
 | 80 | #define R518_GPIO_PULSE_IN	0x58	/* OV518(+) only */ | 
 | 81 | #define R518_GPIO_PULSE_CLEAR	0x59	/* OV518(+) only */ | 
 | 82 | #define R518_GPIO_PULSE_POL	0x5a	/* OV518(+) only */ | 
 | 83 | #define R518_GPIO_PULSE_EN	0x5b	/* OV518(+) only */ | 
 | 84 | #define R518_GPIO_RESET		0x5c	/* OV518(+) only */ | 
 | 85 |  | 
 | 86 | /* I2C registers */ | 
 | 87 | #define R511_I2C_CTL		0x40 | 
 | 88 | #define R518_I2C_CTL		0x47	/* OV518(+) only */ | 
 | 89 | #define R51x_I2C_W_SID		0x41 | 
 | 90 | #define R51x_I2C_SADDR_3	0x42 | 
 | 91 | #define R51x_I2C_SADDR_2	0x43 | 
 | 92 | #define R51x_I2C_R_SID		0x44 | 
 | 93 | #define R51x_I2C_DATA		0x45 | 
 | 94 | #define R51x_I2C_CLOCK		0x46 | 
 | 95 | #define R51x_I2C_TIMEOUT	0x47 | 
 | 96 |  | 
 | 97 | /* I2C snapshot registers */ | 
 | 98 | #define R511_SI2C_SADDR_3	0x48 | 
 | 99 | #define R511_SI2C_DATA		0x49 | 
 | 100 |  | 
 | 101 | /* System control registers */ | 
 | 102 | #define R51x_SYS_RESET		0x50 | 
 | 103 | 		/* Reset type definitions */ | 
 | 104 | #define 	OV511_RESET_UDC		0x01 | 
 | 105 | #define 	OV511_RESET_I2C		0x02 | 
 | 106 | #define 	OV511_RESET_FIFO	0x04 | 
 | 107 | #define 	OV511_RESET_OMNICE	0x08 | 
 | 108 | #define 	OV511_RESET_DRAM	0x10 | 
 | 109 | #define 	OV511_RESET_CAM_INT	0x20 | 
 | 110 | #define 	OV511_RESET_OV511	0x40 | 
 | 111 | #define 	OV511_RESET_NOREGS	0x3F /* All but OV511 & regs */ | 
 | 112 | #define 	OV511_RESET_ALL		0x7F | 
 | 113 |  | 
 | 114 | #define R511_SYS_CLOCK_DIV	0x51 | 
 | 115 | #define R51x_SYS_SNAP		0x52 | 
 | 116 | #define R51x_SYS_INIT         	0x53 | 
 | 117 | #define R511_SYS_PWR_CLK	0x54 /* OV511+/OV518(+) only */ | 
 | 118 | #define R511_SYS_LED_CTL	0x55 /* OV511+ only */ | 
 | 119 | #define R511_SYS_USER		0x5E | 
 | 120 | #define R511_SYS_CUST_ID	0x5F | 
 | 121 |  | 
 | 122 | /* OmniCE (compression) registers */ | 
 | 123 | #define R511_COMP_PHY		0x70 | 
 | 124 | #define R511_COMP_PHUV		0x71 | 
 | 125 | #define R511_COMP_PVY		0x72 | 
 | 126 | #define R511_COMP_PVUV		0x73 | 
 | 127 | #define R511_COMP_QHY		0x74 | 
 | 128 | #define R511_COMP_QHUV		0x75 | 
 | 129 | #define R511_COMP_QVY		0x76 | 
 | 130 | #define R511_COMP_QVUV		0x77 | 
 | 131 | #define R511_COMP_EN		0x78 | 
 | 132 | #define R511_COMP_LUT_EN	0x79		 | 
 | 133 | #define R511_COMP_LUT_BEGIN	0x80 | 
 | 134 |  | 
 | 135 | /* --------------------------------- */ | 
 | 136 | /*         ALTERNATE NUMBERS         */ | 
 | 137 | /* --------------------------------- */ | 
 | 138 |  | 
 | 139 | /* Alternate numbers for various max packet sizes (OV511 only) */ | 
 | 140 | #define OV511_ALT_SIZE_992	0 | 
 | 141 | #define OV511_ALT_SIZE_993	1 | 
 | 142 | #define OV511_ALT_SIZE_768	2 | 
 | 143 | #define OV511_ALT_SIZE_769	3 | 
 | 144 | #define OV511_ALT_SIZE_512	4 | 
 | 145 | #define OV511_ALT_SIZE_513	5 | 
 | 146 | #define OV511_ALT_SIZE_257	6 | 
 | 147 | #define OV511_ALT_SIZE_0	7 | 
 | 148 |  | 
 | 149 | /* Alternate numbers for various max packet sizes (OV511+ only) */ | 
 | 150 | #define OV511PLUS_ALT_SIZE_0	0 | 
 | 151 | #define OV511PLUS_ALT_SIZE_33	1 | 
 | 152 | #define OV511PLUS_ALT_SIZE_129	2 | 
 | 153 | #define OV511PLUS_ALT_SIZE_257	3 | 
 | 154 | #define OV511PLUS_ALT_SIZE_385	4 | 
 | 155 | #define OV511PLUS_ALT_SIZE_513	5 | 
 | 156 | #define OV511PLUS_ALT_SIZE_769	6 | 
 | 157 | #define OV511PLUS_ALT_SIZE_961	7 | 
 | 158 |  | 
 | 159 | /* Alternate numbers for various max packet sizes (OV518(+) only) */ | 
 | 160 | #define OV518_ALT_SIZE_0	0 | 
 | 161 | #define OV518_ALT_SIZE_128	1 | 
 | 162 | #define OV518_ALT_SIZE_256	2 | 
 | 163 | #define OV518_ALT_SIZE_384	3 | 
 | 164 | #define OV518_ALT_SIZE_512	4 | 
 | 165 | #define OV518_ALT_SIZE_640	5 | 
 | 166 | #define OV518_ALT_SIZE_768	6 | 
 | 167 | #define OV518_ALT_SIZE_896	7 | 
 | 168 |  | 
 | 169 | /* --------------------------------- */ | 
 | 170 | /*     OV7610 REGISTER MNEMONICS     */ | 
 | 171 | /* --------------------------------- */ | 
 | 172 |  | 
 | 173 | /* OV7610 registers */ | 
 | 174 | #define OV7610_REG_GAIN          0x00	/* gain setting (5:0) */ | 
 | 175 | #define OV7610_REG_BLUE          0x01	/* blue channel balance */ | 
 | 176 | #define OV7610_REG_RED           0x02	/* red channel balance */ | 
 | 177 | #define OV7610_REG_SAT           0x03	/* saturation */ | 
 | 178 | 					/* 04 reserved */ | 
 | 179 | #define OV7610_REG_CNT           0x05	/* Y contrast */ | 
 | 180 | #define OV7610_REG_BRT           0x06	/* Y brightness */ | 
 | 181 | 					/* 08-0b reserved */ | 
 | 182 | #define OV7610_REG_BLUE_BIAS     0x0C	/* blue channel bias (5:0) */ | 
 | 183 | #define OV7610_REG_RED_BIAS      0x0D	/* read channel bias (5:0) */ | 
 | 184 | #define OV7610_REG_GAMMA_COEFF   0x0E	/* gamma settings */ | 
 | 185 | #define OV7610_REG_WB_RANGE      0x0F	/* AEC/ALC/S-AWB settings */ | 
 | 186 | #define OV7610_REG_EXP           0x10	/* manual exposure setting */ | 
 | 187 | #define OV7610_REG_CLOCK         0x11	/* polarity/clock prescaler */ | 
 | 188 | #define OV7610_REG_COM_A         0x12	/* misc common regs */ | 
 | 189 | #define OV7610_REG_COM_B         0x13	/* misc common regs */ | 
 | 190 | #define OV7610_REG_COM_C         0x14	/* misc common regs */ | 
 | 191 | #define OV7610_REG_COM_D         0x15	/* misc common regs */ | 
 | 192 | #define OV7610_REG_FIELD_DIVIDE  0x16	/* field interval/mode settings */ | 
 | 193 | #define OV7610_REG_HWIN_START    0x17	/* horizontal window start */ | 
 | 194 | #define OV7610_REG_HWIN_END      0x18	/* horizontal window end */ | 
 | 195 | #define OV7610_REG_VWIN_START    0x19	/* vertical window start */ | 
 | 196 | #define OV7610_REG_VWIN_END      0x1A	/* vertical window end */ | 
 | 197 | #define OV7610_REG_PIXEL_SHIFT   0x1B	/* pixel shift */ | 
 | 198 | #define OV7610_REG_ID_HIGH       0x1C	/* manufacturer ID MSB */ | 
 | 199 | #define OV7610_REG_ID_LOW        0x1D	/* manufacturer ID LSB */ | 
 | 200 | 					/* 0e-0f reserved */ | 
 | 201 | #define OV7610_REG_COM_E         0x20	/* misc common regs */ | 
 | 202 | #define OV7610_REG_YOFFSET       0x21	/* Y channel offset */ | 
 | 203 | #define OV7610_REG_UOFFSET       0x22	/* U channel offset */ | 
 | 204 | 					/* 23 reserved */ | 
 | 205 | #define OV7610_REG_ECW           0x24	/* Exposure white level for AEC */ | 
 | 206 | #define OV7610_REG_ECB           0x25	/* Exposure black level for AEC */ | 
 | 207 | #define OV7610_REG_COM_F         0x26	/* misc settings */ | 
 | 208 | #define OV7610_REG_COM_G         0x27	/* misc settings */ | 
 | 209 | #define OV7610_REG_COM_H         0x28	/* misc settings */ | 
 | 210 | #define OV7610_REG_COM_I         0x29	/* misc settings */ | 
 | 211 | #define OV7610_REG_FRAMERATE_H   0x2A	/* frame rate MSB + misc */ | 
 | 212 | #define OV7610_REG_FRAMERATE_L   0x2B	/* frame rate LSB */ | 
 | 213 | #define OV7610_REG_ALC           0x2C	/* Auto Level Control settings */ | 
 | 214 | #define OV7610_REG_COM_J         0x2D	/* misc settings */ | 
 | 215 | #define OV7610_REG_VOFFSET       0x2E	/* V channel offset adjustment */ | 
 | 216 | #define OV7610_REG_ARRAY_BIAS	 0x2F	/* Array bias -- don't change */ | 
 | 217 | 					/* 30-32 reserved */ | 
 | 218 | #define OV7610_REG_YGAMMA        0x33	/* misc gamma settings (7:6) */ | 
 | 219 | #define OV7610_REG_BIAS_ADJUST   0x34	/* misc bias settings */ | 
 | 220 | #define OV7610_REG_COM_L         0x35	/* misc settings */ | 
 | 221 | 					/* 36-37 reserved */ | 
 | 222 | #define OV7610_REG_COM_K         0x38	/* misc registers */ | 
 | 223 |  | 
 | 224 | /* --------------------------------- */ | 
 | 225 | /*           I2C ADDRESSES           */ | 
 | 226 | /* --------------------------------- */ | 
 | 227 |  | 
 | 228 | #define OV7xx0_SID   0x42 | 
 | 229 | #define OV6xx0_SID   0xC0 | 
 | 230 | #define OV8xx0_SID   0xA0 | 
 | 231 | #define KS0127_SID   0xD8 | 
 | 232 | #define SAA7111A_SID 0x48 | 
 | 233 |  | 
 | 234 | /* --------------------------------- */ | 
 | 235 | /*       MISCELLANEOUS DEFINES       */ | 
 | 236 | /* --------------------------------- */ | 
 | 237 |  | 
 | 238 | #define I2C_CLOCK_PRESCALER 	0x03 | 
 | 239 |  | 
 | 240 | #define FRAMES_PER_DESC		10	/* FIXME - What should this be? */ | 
 | 241 | #define MAX_FRAME_SIZE_PER_DESC	993	/* For statically allocated stuff */ | 
 | 242 | #define PIXELS_PER_SEG		256	/* Pixels per segment */ | 
 | 243 |  | 
 | 244 | #define OV511_ENDPOINT_ADDRESS	1	/* Isoc endpoint number */ | 
 | 245 |  | 
 | 246 | #define OV511_NUMFRAMES	2 | 
 | 247 | #if OV511_NUMFRAMES > VIDEO_MAX_FRAME | 
 | 248 | 	#error "OV511_NUMFRAMES is too high" | 
 | 249 | #endif | 
 | 250 |  | 
 | 251 | #define OV511_NUMSBUF		2 | 
 | 252 |  | 
 | 253 | /* Control transfers use up to 4 bytes */ | 
 | 254 | #define OV511_CBUF_SIZE		4 | 
 | 255 |  | 
 | 256 | /* Size of usb_make_path() buffer */ | 
 | 257 | #define OV511_USB_PATH_LEN	64 | 
 | 258 |  | 
 | 259 | /* Bridge types */ | 
 | 260 | enum { | 
 | 261 | 	BRG_UNKNOWN, | 
 | 262 | 	BRG_OV511, | 
 | 263 | 	BRG_OV511PLUS, | 
 | 264 | 	BRG_OV518, | 
 | 265 | 	BRG_OV518PLUS, | 
 | 266 | }; | 
 | 267 |  | 
 | 268 | /* Bridge classes */ | 
 | 269 | enum { | 
 | 270 | 	BCL_UNKNOWN, | 
 | 271 | 	BCL_OV511, | 
 | 272 | 	BCL_OV518, | 
 | 273 | }; | 
 | 274 |  | 
 | 275 | /* Sensor types */ | 
 | 276 | enum { | 
 | 277 | 	SEN_UNKNOWN, | 
 | 278 | 	SEN_OV76BE, | 
 | 279 | 	SEN_OV7610, | 
 | 280 | 	SEN_OV7620, | 
 | 281 | 	SEN_OV7620AE, | 
 | 282 | 	SEN_OV6620, | 
 | 283 | 	SEN_OV6630, | 
 | 284 | 	SEN_OV6630AE, | 
 | 285 | 	SEN_OV6630AF, | 
 | 286 | 	SEN_OV8600, | 
 | 287 | 	SEN_KS0127, | 
 | 288 | 	SEN_KS0127B, | 
 | 289 | 	SEN_SAA7111A, | 
 | 290 | }; | 
 | 291 |  | 
 | 292 | enum { | 
 | 293 | 	STATE_SCANNING,		/* Scanning for start */ | 
 | 294 | 	STATE_HEADER,		/* Parsing header */ | 
 | 295 | 	STATE_LINES,		/* Parsing lines */ | 
 | 296 | }; | 
 | 297 |  | 
 | 298 | /* Buffer states */ | 
 | 299 | enum { | 
 | 300 | 	BUF_NOT_ALLOCATED, | 
 | 301 | 	BUF_ALLOCATED, | 
 | 302 | }; | 
 | 303 |  | 
 | 304 | /* --------- Definition of ioctl interface --------- */ | 
 | 305 |  | 
 | 306 | #define OV511_INTERFACE_VER 101 | 
 | 307 |  | 
 | 308 | /* LED options */ | 
 | 309 | enum { | 
 | 310 | 	LED_OFF, | 
 | 311 | 	LED_ON, | 
 | 312 | 	LED_AUTO, | 
 | 313 | }; | 
 | 314 |  | 
 | 315 | /* Raw frame formats */ | 
 | 316 | enum { | 
 | 317 | 	RAWFMT_INVALID, | 
 | 318 | 	RAWFMT_YUV400, | 
 | 319 | 	RAWFMT_YUV420, | 
 | 320 | 	RAWFMT_YUV422, | 
 | 321 | 	RAWFMT_GBR422, | 
 | 322 | }; | 
 | 323 |  | 
 | 324 | struct ov511_i2c_struct { | 
 | 325 | 	unsigned char slave; /* Write slave ID (read ID - 1) */ | 
 | 326 | 	unsigned char reg;   /* Index of register */ | 
 | 327 | 	unsigned char value; /* User sets this w/ write, driver does w/ read */ | 
 | 328 | 	unsigned char mask;  /* Bits to be changed. Not used with read ops */ | 
 | 329 | }; | 
 | 330 |  | 
 | 331 | /* ioctls */ | 
 | 332 | #define OV511IOC_WI2C     _IOW('v', BASE_VIDIOCPRIVATE + 5, \ | 
 | 333 | 			       struct ov511_i2c_struct) | 
 | 334 | #define OV511IOC_RI2C    _IOWR('v', BASE_VIDIOCPRIVATE + 6, \ | 
 | 335 | 			       struct ov511_i2c_struct) | 
 | 336 | /* ------------- End IOCTL interface -------------- */ | 
 | 337 |  | 
 | 338 | struct usb_ov511;		/* Forward declaration */ | 
 | 339 |  | 
 | 340 | struct ov511_sbuf { | 
 | 341 | 	struct usb_ov511 *ov; | 
 | 342 | 	unsigned char *data; | 
 | 343 | 	struct urb *urb; | 
 | 344 | 	spinlock_t lock; | 
 | 345 | 	int n; | 
 | 346 | }; | 
 | 347 |  | 
 | 348 | enum { | 
 | 349 | 	FRAME_UNUSED,		/* Unused (no MCAPTURE) */ | 
 | 350 | 	FRAME_READY,		/* Ready to start grabbing */ | 
 | 351 | 	FRAME_GRABBING,		/* In the process of being grabbed into */ | 
 | 352 | 	FRAME_DONE,		/* Finished grabbing, but not been synced yet */ | 
 | 353 | 	FRAME_ERROR,		/* Something bad happened while processing */ | 
 | 354 | }; | 
 | 355 |  | 
 | 356 | struct ov511_regvals { | 
 | 357 | 	enum { | 
 | 358 | 		OV511_DONE_BUS, | 
 | 359 | 		OV511_REG_BUS, | 
 | 360 | 		OV511_I2C_BUS, | 
 | 361 | 	} bus; | 
 | 362 | 	unsigned char reg; | 
 | 363 | 	unsigned char val; | 
 | 364 | }; | 
 | 365 |  | 
 | 366 | struct ov511_frame { | 
 | 367 | 	int framenum;		/* Index of this frame */ | 
 | 368 | 	unsigned char *data;	/* Frame buffer */ | 
 | 369 | 	unsigned char *tempdata; /* Temp buffer for multi-stage conversions */ | 
 | 370 | 	unsigned char *rawdata;	/* Raw camera data buffer */ | 
 | 371 | 	unsigned char *compbuf;	/* Temp buffer for decompressor */ | 
 | 372 |  | 
 | 373 | 	int depth;		/* Bytes per pixel */ | 
 | 374 | 	int width;		/* Width application is expecting */ | 
 | 375 | 	int height;		/* Height application is expecting */ | 
 | 376 |  | 
 | 377 | 	int rawwidth;		/* Actual width of frame sent from camera */ | 
 | 378 | 	int rawheight;		/* Actual height of frame sent from camera */ | 
 | 379 |  | 
 | 380 | 	int sub_flag;		/* Sub-capture mode for this frame? */ | 
 | 381 | 	unsigned int format;	/* Format for this frame */ | 
 | 382 | 	int compressed;		/* Is frame compressed? */ | 
 | 383 |  | 
 | 384 | 	volatile int grabstate;	/* State of grabbing */ | 
 | 385 | 	int scanstate;		/* State of scanning */ | 
 | 386 |  | 
 | 387 | 	int bytes_recvd;	/* Number of image bytes received from camera */ | 
 | 388 |  | 
 | 389 | 	long bytes_read;	/* Amount that has been read() */ | 
 | 390 |  | 
 | 391 | 	wait_queue_head_t wq;	/* Processes waiting */ | 
 | 392 |  | 
 | 393 | 	int snapshot;		/* True if frame was a snapshot */ | 
 | 394 | }; | 
 | 395 |  | 
 | 396 | #define DECOMP_INTERFACE_VER 4 | 
 | 397 |  | 
 | 398 | /* Compression module operations */ | 
 | 399 | struct ov51x_decomp_ops { | 
 | 400 | 	int (*decomp_400)(unsigned char *, unsigned char *, unsigned char *, | 
 | 401 | 			  int, int, int); | 
 | 402 | 	int (*decomp_420)(unsigned char *, unsigned char *, unsigned char *, | 
 | 403 | 			  int, int, int); | 
 | 404 | 	int (*decomp_422)(unsigned char *, unsigned char *, unsigned char *, | 
 | 405 | 			  int, int, int); | 
 | 406 | 	struct module *owner; | 
 | 407 | }; | 
 | 408 |  | 
 | 409 | struct usb_ov511 { | 
 | 410 | 	struct video_device *vdev; | 
 | 411 | 	struct usb_device *dev; | 
 | 412 |  | 
 | 413 | 	int customid; | 
 | 414 | 	char *desc; | 
 | 415 | 	unsigned char iface; | 
 | 416 | 	char usb_path[OV511_USB_PATH_LEN]; | 
 | 417 |  | 
 | 418 | 	/* Determined by sensor type */ | 
 | 419 | 	int maxwidth; | 
 | 420 | 	int maxheight; | 
 | 421 | 	int minwidth; | 
 | 422 | 	int minheight; | 
 | 423 |  | 
 | 424 | 	int brightness; | 
 | 425 | 	int colour; | 
 | 426 | 	int contrast; | 
 | 427 | 	int hue; | 
 | 428 | 	int whiteness; | 
 | 429 | 	int exposure; | 
 | 430 | 	int auto_brt;		/* Auto brightness enabled flag */ | 
 | 431 | 	int auto_gain;		/* Auto gain control enabled flag */ | 
 | 432 | 	int auto_exp;		/* Auto exposure enabled flag */ | 
 | 433 | 	int backlight;		/* Backlight exposure algorithm flag */ | 
 | 434 | 	int mirror;		/* Image is reversed horizontally */ | 
 | 435 |  | 
 | 436 | 	int led_policy;		/* LED: off|on|auto; OV511+ only */ | 
 | 437 |  | 
 | 438 | 	struct semaphore lock;	/* Serializes user-accessible operations */ | 
 | 439 | 	int user;		/* user count for exclusive use */ | 
 | 440 |  | 
 | 441 | 	int streaming;		/* Are we streaming Isochronous? */ | 
 | 442 | 	int grabbing;		/* Are we grabbing? */ | 
 | 443 |  | 
 | 444 | 	int compress;		/* Should the next frame be compressed? */ | 
 | 445 | 	int compress_inited;	/* Are compression params uploaded? */ | 
 | 446 |  | 
 | 447 | 	int lightfreq;		/* Power (lighting) frequency */ | 
 | 448 | 	int bandfilt;		/* Banding filter enabled flag */ | 
 | 449 |  | 
 | 450 | 	unsigned char *fbuf;	/* Videodev buffer area */ | 
 | 451 | 	unsigned char *tempfbuf; /* Temporary (intermediate) buffer area */ | 
 | 452 | 	unsigned char *rawfbuf;	/* Raw camera data buffer area */ | 
 | 453 |  | 
 | 454 | 	int sub_flag;		/* Pix Array subcapture on flag */ | 
 | 455 | 	int subx;		/* Pix Array subcapture x offset */ | 
 | 456 | 	int suby;		/* Pix Array subcapture y offset */ | 
 | 457 | 	int subw;		/* Pix Array subcapture width */ | 
 | 458 | 	int subh;		/* Pix Array subcapture height */ | 
 | 459 |  | 
 | 460 | 	int curframe;		/* Current receiving sbuf */ | 
 | 461 | 	struct ov511_frame frame[OV511_NUMFRAMES];	 | 
 | 462 |  | 
 | 463 | 	struct ov511_sbuf sbuf[OV511_NUMSBUF]; | 
 | 464 |  | 
 | 465 | 	wait_queue_head_t wq;	/* Processes waiting */ | 
 | 466 |  | 
 | 467 | 	int snap_enabled;	/* Snapshot mode enabled */ | 
 | 468 | 	 | 
 | 469 | 	int bridge;		/* Type of bridge (BRG_*) */ | 
 | 470 | 	int bclass;		/* Class of bridge (BCL_*) */ | 
 | 471 | 	int sensor;		/* Type of image sensor chip (SEN_*) */ | 
 | 472 |  | 
 | 473 | 	int packet_size;	/* Frame size per isoc desc */ | 
 | 474 | 	int packet_numbering;	/* Is ISO frame numbering enabled? */ | 
 | 475 |  | 
 | 476 | 	struct semaphore param_lock;	/* params lock for this camera */ | 
 | 477 |  | 
 | 478 | 	/* Framebuffer/sbuf management */ | 
 | 479 | 	int buf_state; | 
 | 480 | 	struct semaphore buf_lock; | 
 | 481 |  | 
 | 482 | 	struct ov51x_decomp_ops *decomp_ops; | 
 | 483 |  | 
 | 484 | 	/* Stop streaming while changing picture settings */ | 
 | 485 | 	int stop_during_set; | 
 | 486 |  | 
 | 487 | 	int stopped;		/* Streaming is temporarily paused */ | 
 | 488 |  | 
 | 489 | 	/* Video decoder stuff */ | 
 | 490 | 	int input;		/* Composite, S-VIDEO, etc... */ | 
 | 491 | 	int num_inputs;		/* Number of inputs */ | 
 | 492 | 	int norm; 		/* NTSC / PAL / SECAM */ | 
 | 493 | 	int has_decoder;	/* Device has a video decoder */ | 
 | 494 | 	int pal;		/* Device is designed for PAL resolution */ | 
 | 495 |  | 
 | 496 | 	/* I2C interface */ | 
 | 497 | 	struct semaphore i2c_lock;	  /* Protect I2C controller regs */ | 
 | 498 | 	unsigned char primary_i2c_slave;  /* I2C write id of sensor */ | 
 | 499 |  | 
 | 500 | 	/* Control transaction stuff */ | 
 | 501 | 	unsigned char *cbuf;		/* Buffer for payload */ | 
 | 502 | 	struct semaphore cbuf_lock; | 
 | 503 | }; | 
 | 504 |  | 
 | 505 | /* Used to represent a list of values and their respective symbolic names */ | 
 | 506 | struct symbolic_list { | 
 | 507 | 	int num; | 
 | 508 | 	char *name; | 
 | 509 | }; | 
 | 510 |  | 
 | 511 | #define NOT_DEFINED_STR "Unknown" | 
 | 512 |  | 
 | 513 | /* Returns the name of the matching element in the symbolic_list array. The | 
 | 514 |  * end of the list must be marked with an element that has a NULL name. | 
 | 515 |  */ | 
 | 516 | static inline char *  | 
 | 517 | symbolic(struct symbolic_list list[], int num) | 
 | 518 | { | 
 | 519 | 	int i; | 
 | 520 |  | 
 | 521 | 	for (i = 0; list[i].name != NULL; i++) | 
 | 522 | 			if (list[i].num == num) | 
 | 523 | 				return (list[i].name); | 
 | 524 |  | 
 | 525 | 	return (NOT_DEFINED_STR); | 
 | 526 | } | 
 | 527 |  | 
 | 528 | /* Compression stuff */ | 
 | 529 |  | 
 | 530 | #define OV511_QUANTABLESIZE	64 | 
 | 531 | #define OV518_QUANTABLESIZE	32 | 
 | 532 |  | 
 | 533 | #define OV511_YQUANTABLE { \ | 
 | 534 | 	0, 1, 1, 2, 2, 3, 3, 4, \ | 
 | 535 | 	1, 1, 1, 2, 2, 3, 4, 4, \ | 
 | 536 | 	1, 1, 2, 2, 3, 4, 4, 4, \ | 
 | 537 | 	2, 2, 2, 3, 4, 4, 4, 4, \ | 
 | 538 | 	2, 2, 3, 4, 4, 5, 5, 5, \ | 
 | 539 | 	3, 3, 4, 4, 5, 5, 5, 5, \ | 
 | 540 | 	3, 4, 4, 4, 5, 5, 5, 5, \ | 
 | 541 | 	4, 4, 4, 4, 5, 5, 5, 5  \ | 
 | 542 | } | 
 | 543 |  | 
 | 544 | #define OV511_UVQUANTABLE { \ | 
 | 545 | 	0, 2, 2, 3, 4, 4, 4, 4, \ | 
 | 546 | 	2, 2, 2, 4, 4, 4, 4, 4, \ | 
 | 547 | 	2, 2, 3, 4, 4, 4, 4, 4, \ | 
 | 548 | 	3, 4, 4, 4, 4, 4, 4, 4, \ | 
 | 549 | 	4, 4, 4, 4, 4, 4, 4, 4, \ | 
 | 550 | 	4, 4, 4, 4, 4, 4, 4, 4, \ | 
 | 551 | 	4, 4, 4, 4, 4, 4, 4, 4, \ | 
 | 552 | 	4, 4, 4, 4, 4, 4, 4, 4  \ | 
 | 553 | } | 
 | 554 |  | 
 | 555 | #define OV518_YQUANTABLE { \ | 
 | 556 | 	5, 4, 5, 6, 6, 7, 7, 7, \ | 
 | 557 | 	5, 5, 5, 5, 6, 7, 7, 7, \ | 
 | 558 | 	6, 6, 6, 6, 7, 7, 7, 8, \ | 
 | 559 | 	7, 7, 6, 7, 7, 7, 8, 8  \ | 
 | 560 | } | 
 | 561 |  | 
 | 562 | #define OV518_UVQUANTABLE { \ | 
 | 563 | 	6, 6, 6, 7, 7, 7, 7, 7, \ | 
 | 564 | 	6, 6, 6, 7, 7, 7, 7, 7, \ | 
 | 565 | 	6, 6, 6, 7, 7, 7, 7, 8, \ | 
 | 566 | 	7, 7, 7, 7, 7, 7, 8, 8  \ | 
 | 567 | } | 
 | 568 |  | 
 | 569 | #endif |