aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/sn9c102/sn9c102_sensor.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/sn9c102/sn9c102_sensor.h')
-rw-r--r--drivers/media/video/sn9c102/sn9c102_sensor.h168
1 files changed, 39 insertions, 129 deletions
diff --git a/drivers/media/video/sn9c102/sn9c102_sensor.h b/drivers/media/video/sn9c102/sn9c102_sensor.h
index 2a874ee6f9f..05f2942639c 100644
--- a/drivers/media/video/sn9c102/sn9c102_sensor.h
+++ b/drivers/media/video/sn9c102/sn9c102_sensor.h
@@ -1,7 +1,7 @@
1/*************************************************************************** 1/***************************************************************************
2 * API for image sensors connected to the SN9C10x PC Camera Controllers * 2 * API for image sensors connected to the SN9C1xx PC Camera Controllers *
3 * * 3 * *
4 * Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> * 4 * Copyright (C) 2004-2007 by Luca Risolia <luca.risolia@studio.unibo.it> *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 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 * 7 * it under the terms of the GNU General Public License as published by *
@@ -36,14 +36,13 @@ struct sn9c102_sensor;
36/* 36/*
37 OVERVIEW. 37 OVERVIEW.
38 This is a small interface that allows you to add support for any CCD/CMOS 38 This is a small interface that allows you to add support for any CCD/CMOS
39 image sensors connected to the SN9C10X bridges. The entire API is documented 39 image sensors connected to the SN9C1XX bridges. The entire API is documented
40 below. In the most general case, to support a sensor there are three steps 40 below. In the most general case, to support a sensor there are three steps
41 you have to follow: 41 you have to follow:
42 1) define the main "sn9c102_sensor" structure by setting the basic fields; 42 1) define the main "sn9c102_sensor" structure by setting the basic fields;
43 2) write a probing function to be called by the core module when the USB 43 2) write a probing function to be called by the core module when the USB
44 camera is recognized, then add both the USB ids and the name of that 44 camera is recognized, then add both the USB ids and the name of that
45 function to the two corresponding tables SENSOR_TABLE and ID_TABLE (see 45 function to the two corresponding tables in sn9c102_devtable.h;
46 below);
47 3) implement the methods that you want/need (and fill the rest of the main 46 3) implement the methods that you want/need (and fill the rest of the main
48 structure accordingly). 47 structure accordingly).
49 "sn9c102_pas106b.c" is an example of all this stuff. Remember that you do 48 "sn9c102_pas106b.c" is an example of all this stuff. Remember that you do
@@ -54,42 +53,21 @@ struct sn9c102_sensor;
54 53
55/*****************************************************************************/ 54/*****************************************************************************/
56 55
57/* 56enum sn9c102_bridge {
58 Probing functions: on success, you must attach the sensor to the camera 57 BRIDGE_SN9C101 = 0x01,
59 by calling sn9c102_attach_sensor() provided below. 58 BRIDGE_SN9C102 = 0x02,
60 To enable the I2C communication, you might need to perform a really basic 59 BRIDGE_SN9C103 = 0x04,
61 initialization of the SN9C10X chip by using the write function declared 60 BRIDGE_SN9C105 = 0x08,
62 ahead. 61 BRIDGE_SN9C120 = 0x10,
63 Functions must return 0 on success, the appropriate error otherwise.
64*/
65extern int sn9c102_probe_hv7131d(struct sn9c102_device* cam);
66extern int sn9c102_probe_mi0343(struct sn9c102_device* cam);
67extern int sn9c102_probe_ov7630(struct sn9c102_device* cam);
68extern int sn9c102_probe_pas106b(struct sn9c102_device* cam);
69extern int sn9c102_probe_pas202bca(struct sn9c102_device* cam);
70extern int sn9c102_probe_pas202bcb(struct sn9c102_device* cam);
71extern int sn9c102_probe_tas5110c1b(struct sn9c102_device* cam);
72extern int sn9c102_probe_tas5130d1b(struct sn9c102_device* cam);
73
74/*
75 Add the above entries to this table. Be sure to add the entry in the right
76 place, since, on failure, the next probing routine is called according to
77 the order of the list below, from top to bottom.
78*/
79#define SN9C102_SENSOR_TABLE \
80static int (*sn9c102_sensor_table[])(struct sn9c102_device*) = { \
81 &sn9c102_probe_mi0343, /* strong detection based on SENSOR ids */ \
82 &sn9c102_probe_pas106b, /* strong detection based on SENSOR ids */ \
83 &sn9c102_probe_pas202bcb, /* strong detection based on SENSOR ids */ \
84 &sn9c102_probe_hv7131d, /* strong detection based on SENSOR ids */ \
85 &sn9c102_probe_pas202bca, /* detection mostly based on USB pid/vid */ \
86 &sn9c102_probe_ov7630, /* detection mostly based on USB pid/vid */ \
87 &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ \
88 &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ \
89 NULL, \
90}; 62};
91 63
92/* Device identification */ 64/* Return the bridge name */
65enum sn9c102_bridge sn9c102_get_bridge(struct sn9c102_device* cam);
66
67/* Return a pointer the sensor struct attached to the camera */
68struct sn9c102_sensor* sn9c102_get_sensor(struct sn9c102_device* cam);
69
70/* Identify a device */
93extern struct sn9c102_device* 71extern struct sn9c102_device*
94sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id); 72sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id);
95 73
@@ -99,68 +77,8 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
99 struct sn9c102_sensor* sensor); 77 struct sn9c102_sensor* sensor);
100 78
101/* 79/*
102 Each SN9C10x camera has proper PID/VID identifiers.
103 SN9C103 supports multiple interfaces, but we only handle the video class
104 interface.
105*/
106#define SN9C102_USB_DEVICE(vend, prod, intclass) \
107 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
108 USB_DEVICE_ID_MATCH_INT_CLASS, \
109 .idVendor = (vend), \
110 .idProduct = (prod), \
111 .bInterfaceClass = (intclass)
112
113#define SN9C102_ID_TABLE \
114static const struct usb_device_id sn9c102_id_table[] = { \
115 { USB_DEVICE(0x0c45, 0x6001), }, /* TAS5110C1B */ \
116 { USB_DEVICE(0x0c45, 0x6005), }, /* TAS5110C1B */ \
117 { USB_DEVICE(0x0c45, 0x6007), }, \
118 { USB_DEVICE(0x0c45, 0x6009), }, /* PAS106B */ \
119 { USB_DEVICE(0x0c45, 0x600d), }, /* PAS106B */ \
120 { USB_DEVICE(0x0c45, 0x6024), }, \
121 { USB_DEVICE(0x0c45, 0x6025), }, /* TAS5130D1B and TAS5110C1B */ \
122 { USB_DEVICE(0x0c45, 0x6028), }, /* PAS202BCB */ \
123 { USB_DEVICE(0x0c45, 0x6029), }, /* PAS106B */ \
124 { USB_DEVICE(0x0c45, 0x602a), }, /* HV7131D */ \
125 { USB_DEVICE(0x0c45, 0x602b), }, /* MI-0343 */ \
126 { USB_DEVICE(0x0c45, 0x602c), }, /* OV7630 */ \
127 { USB_DEVICE(0x0c45, 0x602d), }, \
128 { USB_DEVICE(0x0c45, 0x602e), }, /* OV7630 */ \
129 { USB_DEVICE(0x0c45, 0x6030), }, /* MI03x */ \
130 { SN9C102_USB_DEVICE(0x0c45, 0x6080, 0xff), }, \
131 { SN9C102_USB_DEVICE(0x0c45, 0x6082, 0xff), }, /* MI0343 & MI0360 */ \
132 { SN9C102_USB_DEVICE(0x0c45, 0x6083, 0xff), }, /* HV7131[D|E1] */ \
133 { SN9C102_USB_DEVICE(0x0c45, 0x6088, 0xff), }, \
134 { SN9C102_USB_DEVICE(0x0c45, 0x608a, 0xff), }, \
135 { SN9C102_USB_DEVICE(0x0c45, 0x608b, 0xff), }, \
136 { SN9C102_USB_DEVICE(0x0c45, 0x608c, 0xff), }, /* HV7131/R */ \
137 { SN9C102_USB_DEVICE(0x0c45, 0x608e, 0xff), }, /* CIS-VF10 */ \
138 { SN9C102_USB_DEVICE(0x0c45, 0x608f, 0xff), }, /* OV7630 */ \
139 { SN9C102_USB_DEVICE(0x0c45, 0x60a0, 0xff), }, \
140 { SN9C102_USB_DEVICE(0x0c45, 0x60a2, 0xff), }, \
141 { SN9C102_USB_DEVICE(0x0c45, 0x60a3, 0xff), }, \
142 { SN9C102_USB_DEVICE(0x0c45, 0x60a8, 0xff), }, /* PAS106B */ \
143 { SN9C102_USB_DEVICE(0x0c45, 0x60aa, 0xff), }, /* TAS5130D1B */ \
144 { SN9C102_USB_DEVICE(0x0c45, 0x60ab, 0xff), }, /* TAS5110C1B */ \
145 { SN9C102_USB_DEVICE(0x0c45, 0x60ac, 0xff), }, \
146 { SN9C102_USB_DEVICE(0x0c45, 0x60ae, 0xff), }, \
147 { SN9C102_USB_DEVICE(0x0c45, 0x60af, 0xff), }, /* PAS202BCB */ \
148 { SN9C102_USB_DEVICE(0x0c45, 0x60b0, 0xff), }, /* OV7630 (?) */ \
149 { SN9C102_USB_DEVICE(0x0c45, 0x60b2, 0xff), }, \
150 { SN9C102_USB_DEVICE(0x0c45, 0x60b3, 0xff), }, \
151 { SN9C102_USB_DEVICE(0x0c45, 0x60b8, 0xff), }, \
152 { SN9C102_USB_DEVICE(0x0c45, 0x60ba, 0xff), }, \
153 { SN9C102_USB_DEVICE(0x0c45, 0x60bb, 0xff), }, \
154 { SN9C102_USB_DEVICE(0x0c45, 0x60bc, 0xff), }, \
155 { SN9C102_USB_DEVICE(0x0c45, 0x60be, 0xff), }, \
156 { } \
157};
158
159/*****************************************************************************/
160
161/*
162 Read/write routines: they always return -1 on error, 0 or the read value 80 Read/write routines: they always return -1 on error, 0 or the read value
163 otherwise. NOTE that a real read operation is not supported by the SN9C10X 81 otherwise. NOTE that a real read operation is not supported by the SN9C1XX
164 chip for some of its registers. To work around this problem, a pseudo-read 82 chip for some of its registers. To work around this problem, a pseudo-read
165 call is provided instead: it returns the last successfully written value 83 call is provided instead: it returns the last successfully written value
166 on the register (0 if it has never been written), the usual -1 on error. 84 on the register (0 if it has never been written), the usual -1 on error.
@@ -176,7 +94,7 @@ extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
176 These must be used if and only if the sensor doesn't implement the standard 94 These must be used if and only if the sensor doesn't implement the standard
177 I2C protocol. There are a number of good reasons why you must use the 95 I2C protocol. There are a number of good reasons why you must use the
178 single-byte versions of these functions: do not abuse. The first function 96 single-byte versions of these functions: do not abuse. The first function
179 writes n bytes, from data0 to datan, to registers 0x09 - 0x09+n of SN9C10X 97 writes n bytes, from data0 to datan, to registers 0x09 - 0x09+n of SN9C1XX
180 chip. The second one programs the registers 0x09 and 0x10 with data0 and 98 chip. The second one programs the registers 0x09 and 0x10 with data0 and
181 data1, and places the n bytes read from the sensor register table in the 99 data1, and places the n bytes read from the sensor register table in the
182 buffer pointed by 'buffer'. Both the functions return -1 on error; the write 100 buffer pointed by 'buffer'. Both the functions return -1 on error; the write
@@ -200,16 +118,6 @@ extern int sn9c102_write_regs(struct sn9c102_device*, u8* buff, u16 index);
200extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); 118extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index);
201extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index); 119extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index);
202 120
203/*
204 NOTE: there are no exported debugging functions. To uniform the output you
205 must use the dev_info()/dev_warn()/dev_err() macros defined in device.h,
206 already included here, the argument being the struct device '&usbdev->dev'
207 of the sensor structure. Do NOT use these macros before the sensor is
208 attached or the kernel will crash! However, you should not need to notify
209 the user about common errors or other messages, since this is done by the
210 master module.
211*/
212
213/*****************************************************************************/ 121/*****************************************************************************/
214 122
215enum sn9c102_i2c_sysfs_ops { 123enum sn9c102_i2c_sysfs_ops {
@@ -227,17 +135,19 @@ enum sn9c102_i2c_interface {
227 SN9C102_I2C_3WIRES, 135 SN9C102_I2C_3WIRES,
228}; 136};
229 137
230#define SN9C102_MAX_CTRLS V4L2_CID_LASTP1-V4L2_CID_BASE+10 138#define SN9C102_MAX_CTRLS (V4L2_CID_LASTP1-V4L2_CID_BASE+10)
231 139
232struct sn9c102_sensor { 140struct sn9c102_sensor {
233 char name[32], /* sensor name */ 141 char name[32], /* sensor name */
234 maintainer[64]; /* name of the mantainer <email> */ 142 maintainer[64]; /* name of the mantainer <email> */
235 143
144 enum sn9c102_bridge supported_bridge; /* supported SN9C1xx bridges */
145
236 /* Supported operations through the 'sysfs' interface */ 146 /* Supported operations through the 'sysfs' interface */
237 enum sn9c102_i2c_sysfs_ops sysfs_ops; 147 enum sn9c102_i2c_sysfs_ops sysfs_ops;
238 148
239 /* 149 /*
240 These sensor capabilities must be provided if the SN9C10X controller 150 These sensor capabilities must be provided if the SN9C1XX controller
241 needs to communicate through the sensor serial interface by using 151 needs to communicate through the sensor serial interface by using
242 at least one of the i2c functions available. 152 at least one of the i2c functions available.
243 */ 153 */
@@ -260,7 +170,7 @@ struct sn9c102_sensor {
260 /* 170 /*
261 This function will be called after the sensor has been attached. 171 This function will be called after the sensor has been attached.
262 It should be used to initialize the sensor only, but may also 172 It should be used to initialize the sensor only, but may also
263 configure part of the SN9C10X chip if necessary. You don't need to 173 configure part of the SN9C1XX chip if necessary. You don't need to
264 setup picture settings like brightness, contrast, etc.. here, if 174 setup picture settings like brightness, contrast, etc.. here, if
265 the corrisponding controls are implemented (see below), since 175 the corrisponding controls are implemented (see below), since
266 they are adjusted in the core driver by calling the set_ctrl() 176 they are adjusted in the core driver by calling the set_ctrl()
@@ -300,7 +210,7 @@ struct sn9c102_sensor {
300 It is not always true that the largest achievable active window can 210 It is not always true that the largest achievable active window can
301 cover the whole array of pixels. The V4L2 API defines another 211 cover the whole array of pixels. The V4L2 API defines another
302 area called "source rectangle", which, in turn, is a subrectangle of 212 area called "source rectangle", which, in turn, is a subrectangle of
303 the active window. The SN9C10X chip is always programmed to read the 213 the active window. The SN9C1XX chip is always programmed to read the
304 source rectangle. 214 source rectangle.
305 The bounds of both the active window and the source rectangle are 215 The bounds of both the active window and the source rectangle are
306 specified in the cropcap substructures 'bounds' and 'defrect'. 216 specified in the cropcap substructures 'bounds' and 'defrect'.
@@ -326,13 +236,13 @@ struct sn9c102_sensor {
326 const struct v4l2_rect* rect); 236 const struct v4l2_rect* rect);
327 /* 237 /*
328 To be called on VIDIOC_C_SETCROP. The core module always calls a 238 To be called on VIDIOC_C_SETCROP. The core module always calls a
329 default routine which configures the appropriate SN9C10X regs (also 239 default routine which configures the appropriate SN9C1XX regs (also
330 scaling), but you may need to override/adjust specific stuff. 240 scaling), but you may need to override/adjust specific stuff.
331 'rect' contains width and height values that are multiple of 16: in 241 'rect' contains width and height values that are multiple of 16: in
332 case you override the default function, you always have to program 242 case you override the default function, you always have to program
333 the chip to match those values; on error return the corresponding 243 the chip to match those values; on error return the corresponding
334 error code without rolling back. 244 error code without rolling back.
335 NOTE: in case, you must program the SN9C10X chip to get rid of 245 NOTE: in case, you must program the SN9C1XX chip to get rid of
336 blank pixels or blank lines at the _start_ of each line or 246 blank pixels or blank lines at the _start_ of each line or
337 frame after each HSYNC or VSYNC, so that the image starts with 247 frame after each HSYNC or VSYNC, so that the image starts with
338 real RGB data (see regs 0x12, 0x13) (having set H_SIZE and, 248 real RGB data (see regs 0x12, 0x13) (having set H_SIZE and,
@@ -344,16 +254,16 @@ struct sn9c102_sensor {
344 /* 254 /*
345 What you have to define here are: 1) initial 'width' and 'height' of 255 What you have to define here are: 1) initial 'width' and 'height' of
346 the target rectangle 2) the initial 'pixelformat', which can be 256 the target rectangle 2) the initial 'pixelformat', which can be
347 either V4L2_PIX_FMT_SN9C10X (for compressed video) or 257 either V4L2_PIX_FMT_SN9C10X, V4L2_PIX_FMT_JPEG (for ompressed video)
348 V4L2_PIX_FMT_SBGGR8 3) 'priv', which we'll be used to indicate the 258 or V4L2_PIX_FMT_SBGGR8 3) 'priv', which we'll be used to indicate
349 number of bits per pixel for uncompressed video, 8 or 9 (despite the 259 the number of bits per pixel for uncompressed video, 8 or 9 (despite
350 current value of 'pixelformat'). 260 the current value of 'pixelformat').
351 NOTE 1: both 'width' and 'height' _must_ be either 1/1 or 1/2 or 1/4 261 NOTE 1: both 'width' and 'height' _must_ be either 1/1 or 1/2 or 1/4
352 of cropcap.defrect.width and cropcap.defrect.height. I 262 of cropcap.defrect.width and cropcap.defrect.height. I
353 suggest 1/1. 263 suggest 1/1.
354 NOTE 2: The initial compression quality is defined by the first bit 264 NOTE 2: The initial compression quality is defined by the first bit
355 of reg 0x17 during the initialization of the image sensor. 265 of reg 0x17 during the initialization of the image sensor.
356 NOTE 3: as said above, you have to program the SN9C10X chip to get 266 NOTE 3: as said above, you have to program the SN9C1XX chip to get
357 rid of any blank pixels, so that the output of the sensor 267 rid of any blank pixels, so that the output of the sensor
358 matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR). 268 matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR).
359 */ 269 */
@@ -378,12 +288,12 @@ struct sn9c102_sensor {
378/*****************************************************************************/ 288/*****************************************************************************/
379 289
380/* Private ioctl's for control settings supported by some image sensors */ 290/* Private ioctl's for control settings supported by some image sensors */
381#define SN9C102_V4L2_CID_DAC_MAGNITUDE V4L2_CID_PRIVATE_BASE 291#define SN9C102_V4L2_CID_DAC_MAGNITUDE (V4L2_CID_PRIVATE_BASE + 0)
382#define SN9C102_V4L2_CID_GREEN_BALANCE V4L2_CID_PRIVATE_BASE + 1 292#define SN9C102_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE + 1)
383#define SN9C102_V4L2_CID_RESET_LEVEL V4L2_CID_PRIVATE_BASE + 2 293#define SN9C102_V4L2_CID_RESET_LEVEL (V4L2_CID_PRIVATE_BASE + 2)
384#define SN9C102_V4L2_CID_PIXEL_BIAS_VOLTAGE V4L2_CID_PRIVATE_BASE + 3 294#define SN9C102_V4L2_CID_PIXEL_BIAS_VOLTAGE (V4L2_CID_PRIVATE_BASE + 3)
385#define SN9C102_V4L2_CID_GAMMA V4L2_CID_PRIVATE_BASE + 4 295#define SN9C102_V4L2_CID_GAMMA (V4L2_CID_PRIVATE_BASE + 4)
386#define SN9C102_V4L2_CID_BAND_FILTER V4L2_CID_PRIVATE_BASE + 5 296#define SN9C102_V4L2_CID_BAND_FILTER (V4L2_CID_PRIVATE_BASE + 5)
387#define SN9C102_V4L2_CID_BRIGHT_LEVEL V4L2_CID_PRIVATE_BASE + 6 297#define SN9C102_V4L2_CID_BRIGHT_LEVEL (V4L2_CID_PRIVATE_BASE + 6)
388 298
389#endif /* _SN9C102_SENSOR_H_ */ 299#endif /* _SN9C102_SENSOR_H_ */