/* Common OmniVision image sensor definitions */

#ifndef __LINUX_OVSENSOR_H
#define __LINUX_OVSENSOR_H

// FIXME: Get official assignment for this
#ifndef I2C_DRIVERID_OVSENSOR
	#define I2C_DRIVERID_OVSENSOR	0xf000
#endif

/* --------------------------------- */
/*           ENUMERATIONS            */
/* --------------------------------- */

/* Commands */
enum {
	OVSENSOR_CMD_S_CTRL,
	OVSENSOR_CMD_G_CTRL,
};

/* 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 */
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)
#define SAA7111A_SID (0x48 >> 1)

/* --------------------------------- */
/*          DATA STRUCTURES          */
/* --------------------------------- */

/* Forward declaration */
struct usb_ov511;

struct ovsensor_regvals {
	unsigned char reg;
	unsigned char val;
};

struct ovsensor_control {
	__u32 id;
	int value;
};

struct ovsensor_ops {
	int (*configure)(struct usb_ov511 *);
	int (*unconfigure)(struct usb_ov511 *);
	int (*set_window)(struct usb_ov511 *, int, int, int, int);
	int (*mode_init)(struct usb_ov511 *, int, int, int, int, int);
	int (*command)(struct usb_ov511 *, unsigned int, void *);
};

/* --------------------------------- */
/*              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);

#endif
