/* Common OmniVision image sensor definitions */ #ifndef __LINUX_OVSENSOR_H #define __LINUX_OVSENSOR_H #include // FIXME: need to define info() etc... here #include #include #define OVSENSOR_DEBUG #ifdef OVSENSOR_DEBUG #define PDEBUG(level, fmt, args...) \ if (debug >= (level)) info("[%s:%d] " fmt, \ __PRETTY_FUNCTION__, __LINE__ , ## args) #else #define PDEBUG(level, fmt, args...) do {} while(0) #endif // FIXME: Need official assignments for these #ifndef I2C_DRIVERID_OVSENSOR #define I2C_DRIVERID_OVSENSOR 0xf00f #endif #ifndef I2C_HW_SMBUS_OV511 #define I2C_HW_SMBUS_OV511 0xfd #endif #ifndef I2C_HW_SMBUS_OV518 #define I2C_HW_SMBUS_OV518 0xfe #endif #ifndef I2C_HW_SMBUS_OVFX2 #define I2C_HW_SMBUS_OVFX2 0xff #endif /* Number of times to retry chip detection. Increase this if you are getting * "Failed to init sensor" */ #define I2C_DETECT_RETRIES 10 /* --------------------------------- */ /* ENUMERATIONS */ /* --------------------------------- */ /* Commands */ enum { OVSENSOR_CMD_S_CTRL, OVSENSOR_CMD_G_CTRL, OVSENSOR_CMD_S_MODE, OVSENSOR_CMD_Q_SUBTYPE, }; /* Controls */ enum { OVSENSOR_CID_CONT, /* Contrast */ OVSENSOR_CID_BRIGHT, /* Brightness */ OVSENSOR_CID_SAT, /* Saturation */ OVSENSOR_CID_HUE, /* Hue */ OVSENSOR_CID_EXP, /* Exposure */ OVSENSOR_CID_FREQ, /* Light frequency */ OVSENSOR_CID_BANDFILT, /* Banding filter */ OVSENSOR_CID_AUTOBRIGHT, /* Auto brightness */ OVSENSOR_CID_AUTOEXP, /* Auto exposure */ OVSENSOR_CID_BACKLIGHT, /* Back light compensation */ OVSENSOR_CID_MIRROR, /* Mirror horizontally */ }; /* Sensor types */ #define NUM_SEN_TYPES 10 enum { SEN_UNKNOWN, SEN_OV76BE, SEN_OV7610, SEN_OV7620, SEN_OV7620AE, SEN_OV6620, SEN_OV6630, SEN_OV6630AE, SEN_OV6630AF, SEN_SAA7111A, }; /* --------------------------------- */ /* I2C ADDRESSES */ /* --------------------------------- */ #define OV7xx0_SID (0x42 >> 1) #define OV6xx0_SID (0xC0 >> 1) /* --------------------------------- */ /* DATA STRUCTURES */ /* --------------------------------- */ struct ovsensor_regvals { unsigned char reg; unsigned char val; }; struct ovsensor_control { __u32 id; int value; }; struct ovsensor_ops { int (*configure)(struct i2c_client *); int (*unconfigure)(struct i2c_client *); int (*command)(struct i2c_client *, unsigned int, void *); }; struct ovsensor_window { int x; int y; int width; int height; int format; int quarter; /* Scale width and height down 2x */ /* This stuff will be removed eventually */ int clockdiv; /* Clock divisor setting */ }; struct ovsensor { struct ovsensor_ops *sops; void *spriv; /* Private data for OV7x10.c etc... */ int subtype; /* = SEN_OV7610 etc... */ int mono; /* Is sensor monochrome? */ }; /* --------------------------------- */ /* I2C I/O */ /* --------------------------------- */ static inline int ov_read(struct i2c_client *client, unsigned char reg, unsigned char *value) { int rc; rc = i2c_smbus_read_byte_data(client, reg); *value = (unsigned char) rc; return rc; } static inline int ov_write(struct i2c_client *client, unsigned char reg, unsigned char value ) { return i2c_smbus_write_byte_data(client, reg, value); } /* --------------------------------- */ /* FUNCTION PROTOTYPES */ /* --------------------------------- */ /* Functions in ovsensor.c */ extern int ov_write_regvals(struct i2c_client *client, struct ovsensor_regvals *rvals); extern int ov_write_mask(struct i2c_client *client, unsigned char reg, unsigned char value, unsigned char mask); // FIXME: Remove this once the new I2C code is done extern int init_ov_sensor(struct i2c_client *client); #endif