Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * API for image sensors connected to ET61X[12]51 PC Camera Controllers * |
| 3 | * * |
Luca Risolia | 2656312 | 2007-01-08 11:38:36 -0300 | [diff] [blame] | 4 | * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it> * |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 5 | * * |
| 6 | * This program is free software; you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, write to the Free Software * |
| 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #ifndef _ET61X251_SENSOR_H_ |
| 22 | #define _ET61X251_SENSOR_H_ |
| 23 | |
| 24 | #include <linux/usb.h> |
Luca Risolia | 3b2ae0b | 2007-06-13 14:52:01 -0300 | [diff] [blame] | 25 | #include <linux/videodev2.h> |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 26 | #include <linux/device.h> |
| 27 | #include <linux/stddef.h> |
| 28 | #include <linux/errno.h> |
| 29 | #include <asm/types.h> |
| 30 | |
| 31 | struct et61x251_device; |
| 32 | struct et61x251_sensor; |
| 33 | |
| 34 | /*****************************************************************************/ |
| 35 | |
| 36 | extern int et61x251_probe_tas5130d1b(struct et61x251_device* cam); |
| 37 | |
| 38 | #define ET61X251_SENSOR_TABLE \ |
| 39 | /* Weak detections must go at the end of the list */ \ |
| 40 | static int (*et61x251_sensor_table[])(struct et61x251_device*) = { \ |
| 41 | &et61x251_probe_tas5130d1b, \ |
| 42 | NULL, \ |
| 43 | }; |
| 44 | |
Luca Risolia | ccad778 | 2006-02-25 06:54:18 +0000 | [diff] [blame] | 45 | extern struct et61x251_device* |
| 46 | et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id); |
| 47 | |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 48 | extern void |
| 49 | et61x251_attach_sensor(struct et61x251_device* cam, |
Luca Risolia | 3b2ae0b | 2007-06-13 14:52:01 -0300 | [diff] [blame] | 50 | const struct et61x251_sensor* sensor); |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 51 | |
| 52 | /*****************************************************************************/ |
| 53 | |
| 54 | extern int et61x251_write_reg(struct et61x251_device*, u8 value, u16 index); |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 55 | extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 56 | u8 data2, u8 data3, u8 data4, u8 data5, |
| 57 | u8 data6, u8 data7, u8 data8, u8 address); |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 58 | |
| 59 | /*****************************************************************************/ |
| 60 | |
| 61 | enum et61x251_i2c_sysfs_ops { |
| 62 | ET61X251_I2C_READ = 0x01, |
| 63 | ET61X251_I2C_WRITE = 0x02, |
| 64 | }; |
| 65 | |
| 66 | enum et61x251_i2c_interface { |
| 67 | ET61X251_I2C_2WIRES, |
| 68 | ET61X251_I2C_3WIRES, |
| 69 | }; |
| 70 | |
| 71 | /* Repeat start condition when RSTA is high */ |
| 72 | enum et61x251_i2c_rsta { |
| 73 | ET61X251_I2C_RSTA_STOP = 0x00, /* stop then start */ |
| 74 | ET61X251_I2C_RSTA_REPEAT = 0x01, /* repeat start */ |
| 75 | }; |
| 76 | |
Luca Risolia | 2656312 | 2007-01-08 11:38:36 -0300 | [diff] [blame] | 77 | #define ET61X251_MAX_CTRLS (V4L2_CID_LASTP1-V4L2_CID_BASE+10) |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 78 | |
| 79 | struct et61x251_sensor { |
| 80 | char name[32]; |
| 81 | |
| 82 | enum et61x251_i2c_sysfs_ops sysfs_ops; |
| 83 | |
| 84 | enum et61x251_i2c_interface interface; |
| 85 | u8 i2c_slave_id; |
| 86 | enum et61x251_i2c_rsta rsta; |
| 87 | struct v4l2_rect active_pixel; /* left and top define FVSX and FVSY */ |
| 88 | |
| 89 | struct v4l2_queryctrl qctrl[ET61X251_MAX_CTRLS]; |
| 90 | struct v4l2_cropcap cropcap; |
| 91 | struct v4l2_pix_format pix_format; |
| 92 | |
| 93 | int (*init)(struct et61x251_device* cam); |
| 94 | int (*get_ctrl)(struct et61x251_device* cam, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 95 | struct v4l2_control* ctrl); |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 96 | int (*set_ctrl)(struct et61x251_device* cam, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 97 | const struct v4l2_control* ctrl); |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 98 | int (*set_crop)(struct et61x251_device* cam, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 99 | const struct v4l2_rect* rect); |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 100 | int (*set_pix_format)(struct et61x251_device* cam, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 101 | const struct v4l2_pix_format* pix); |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 102 | |
Luca Risolia | 7ce08c9 | 2006-01-11 02:06:59 +0000 | [diff] [blame] | 103 | /* Private */ |
| 104 | struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS]; |
| 105 | struct v4l2_rect _rect; |
| 106 | }; |
| 107 | |
| 108 | #endif /* _ET61X251_SENSOR_H_ */ |