et61x251_sensor.h 4.1 KB
Newer Older
1 2 3
/***************************************************************************
 * API for image sensors connected to ET61X[12]51 PC Camera Controllers    *
 *                                                                         *
4
 * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it>  *
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *                                                                         *
 * This program is free software; you can redistribute it and/or modify    *
 * it under the terms of the GNU General Public License as published by    *
 * the Free Software Foundation; either version 2 of the License, or       *
 * (at your option) any later version.                                     *
 *                                                                         *
 * This program is distributed in the hope that it will be useful,         *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU General Public License for more details.                            *
 *                                                                         *
 * You should have received a copy of the GNU General Public License       *
 * along with this program; if not, write to the Free Software             *
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               *
 ***************************************************************************/

#ifndef _ET61X251_SENSOR_H_
#define _ET61X251_SENSOR_H_

#include <linux/usb.h>
25
#include <linux/videodev2.h>
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#include <linux/device.h>
#include <linux/stddef.h>
#include <linux/errno.h>
#include <asm/types.h>

struct et61x251_device;
struct et61x251_sensor;

/*****************************************************************************/

extern int et61x251_probe_tas5130d1b(struct et61x251_device* cam);

#define ET61X251_SENSOR_TABLE                                                 \
/* Weak detections must go at the end of the list */                          \
static int (*et61x251_sensor_table[])(struct et61x251_device*) = {            \
	&et61x251_probe_tas5130d1b,                                           \
	NULL,                                                                 \
};

45 46 47
extern struct et61x251_device*
et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id);

48 49
extern void
et61x251_attach_sensor(struct et61x251_device* cam,
50
		       const struct et61x251_sensor* sensor);
51 52 53 54 55

/*****************************************************************************/

extern int et61x251_write_reg(struct et61x251_device*, u8 value, u16 index);
extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1,
56 57
				  u8 data2, u8 data3, u8 data4, u8 data5,
				  u8 data6, u8 data7, u8 data8, u8 address);
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

/*****************************************************************************/

enum et61x251_i2c_sysfs_ops {
	ET61X251_I2C_READ = 0x01,
	ET61X251_I2C_WRITE = 0x02,
};

enum et61x251_i2c_interface {
	ET61X251_I2C_2WIRES,
	ET61X251_I2C_3WIRES,
};

/* Repeat start condition when RSTA is high */
enum et61x251_i2c_rsta {
	ET61X251_I2C_RSTA_STOP = 0x00, /* stop then start */
	ET61X251_I2C_RSTA_REPEAT = 0x01, /* repeat start */
};

77
#define ET61X251_MAX_CTRLS (V4L2_CID_LASTP1-V4L2_CID_BASE+10)
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94

struct et61x251_sensor {
	char name[32];

	enum et61x251_i2c_sysfs_ops sysfs_ops;

	enum et61x251_i2c_interface interface;
	u8 i2c_slave_id;
	enum et61x251_i2c_rsta rsta;
	struct v4l2_rect active_pixel; /* left and top define FVSX and FVSY */

	struct v4l2_queryctrl qctrl[ET61X251_MAX_CTRLS];
	struct v4l2_cropcap cropcap;
	struct v4l2_pix_format pix_format;

	int (*init)(struct et61x251_device* cam);
	int (*get_ctrl)(struct et61x251_device* cam,
95
			struct v4l2_control* ctrl);
96
	int (*set_ctrl)(struct et61x251_device* cam,
97
			const struct v4l2_control* ctrl);
98
	int (*set_crop)(struct et61x251_device* cam,
99
			const struct v4l2_rect* rect);
100
	int (*set_pix_format)(struct et61x251_device* cam,
101
			      const struct v4l2_pix_format* pix);
102 103 104 105 106 107 108

	/* Private */
	struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS];
	struct v4l2_rect _rect;
};

#endif /* _ET61X251_SENSOR_H_ */