• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher
3  *		      Mark Cave-Ayland, Carlo E Prelz, Dick Streefland
4  * Copyright (c) 2002, 2003 Tuukka Toivonen
5  * Copyright (c) 2008 Erik Andrén
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  * P/N 861037:      Sensor HDCS1000        ASIC STV0600
22  * P/N 861050-0010: Sensor HDCS1000        ASIC STV0600
23  * P/N 861050-0020: Sensor Photobit PB100  ASIC STV0600-1 - QuickCam Express
24  * P/N 861055:      Sensor ST VV6410       ASIC STV0610   - LEGO cam
25  * P/N 861075-0040: Sensor HDCS1000        ASIC
26  * P/N 961179-0700: Sensor ST VV6410       ASIC STV0602   - Dexxa WebCam USB
27  * P/N 861040-0000: Sensor ST VV6410       ASIC STV0610   - QuickCam Web
28  */
29 
30 #ifndef STV06XX_PB0100_H_
31 #define STV06XX_PB0100_H_
32 
33 #include "stv06xx_sensor.h"
34 
35 /* mode priv field flags */
36 #define PB0100_CROP_TO_VGA	0x01
37 #define PB0100_SUBSAMPLE	0x02
38 
39 /* I2C Registers */
40 #define PB_IDENT		0x00	/* Chip Version */
41 #define PB_RSTART		0x01	/* Row Window Start */
42 #define PB_CSTART		0x02	/* Column Window Start */
43 #define PB_RWSIZE		0x03	/* Row Window Size */
44 #define PB_CWSIZE		0x04	/* Column  Window Size */
45 #define PB_CFILLIN		0x05	/* Column Fill-In */
46 #define PB_VBL			0x06	/* Vertical Blank Count */
47 #define PB_CONTROL		0x07	/* Control Mode */
48 #define PB_FINTTIME		0x08	/* Integration Time/Frame Unit Count */
49 #define PB_RINTTIME		0x09	/* Integration Time/Row Unit Count */
50 #define PB_ROWSPEED		0x0a	/* Row Speed Control */
51 #define PB_ABORTFRAME		0x0b	/* Abort Frame */
52 #define PB_R12			0x0c	/* Reserved */
53 #define PB_RESET		0x0d	/* Reset */
54 #define PB_EXPGAIN		0x0e	/* Exposure Gain Command */
55 #define PB_R15			0x0f	/* Expose0 */
56 #define PB_R16			0x10	/* Expose1 */
57 #define PB_R17			0x11	/* Expose2 */
58 #define PB_R18			0x12	/* Low0_DAC */
59 #define PB_R19			0x13	/* Low1_DAC */
60 #define PB_R20			0x14	/* Low2_DAC */
61 #define PB_R21			0x15	/* Threshold11 */
62 #define PB_R22			0x16	/* Threshold0x */
63 #define PB_UPDATEINT		0x17	/* Update Interval */
64 #define PB_R24			0x18	/* High_DAC */
65 #define PB_R25			0x19	/* Trans0H */
66 #define PB_R26			0x1a	/* Trans1L */
67 #define PB_R27			0x1b	/* Trans1H */
68 #define PB_R28			0x1c	/* Trans2L */
69 #define PB_R29			0x1d	/* Reserved */
70 #define PB_R30			0x1e	/* Reserved */
71 #define PB_R31			0x1f	/* Wait to Read */
72 #define PB_PREADCTRL		0x20	/* Pixel Read Control Mode */
73 #define PB_R33			0x21	/* IREF_VLN */
74 #define PB_R34			0x22	/* IREF_VLP */
75 #define PB_R35			0x23	/* IREF_VLN_INTEG */
76 #define PB_R36			0x24	/* IREF_MASTER */
77 #define PB_R37			0x25	/* IDACP */
78 #define PB_R38			0x26	/* IDACN */
79 #define PB_R39			0x27	/* DAC_Control_Reg */
80 #define PB_R40			0x28	/* VCL */
81 #define PB_R41			0x29	/* IREF_VLN_ADCIN */
82 #define PB_R42			0x2a	/* Reserved */
83 #define PB_G1GAIN		0x2b	/* Green 1 Gain */
84 #define PB_BGAIN		0x2c	/* Blue Gain */
85 #define PB_RGAIN		0x2d	/* Red Gain */
86 #define PB_G2GAIN		0x2e	/* Green 2 Gain */
87 #define PB_R47			0x2f	/* Dark Row Address */
88 #define PB_R48			0x30	/* Dark Row Options */
89 #define PB_R49			0x31	/* Reserved */
90 #define PB_R50			0x32	/* Image Test Data */
91 #define PB_ADCMAXGAIN		0x33	/* Maximum Gain */
92 #define PB_ADCMINGAIN		0x34	/* Minimum Gain */
93 #define PB_ADCGLOBALGAIN	0x35	/* Global Gain */
94 #define PB_R54			0x36	/* Maximum Frame */
95 #define PB_R55			0x37	/* Minimum Frame */
96 #define PB_R56			0x38	/* Reserved */
97 #define PB_VOFFSET		0x39	/* VOFFSET */
98 #define PB_R58			0x3a	/* Snap-Shot Sequence Trigger */
99 #define PB_ADCGAINH		0x3b	/* VREF_HI */
100 #define PB_ADCGAINL		0x3c	/* VREF_LO */
101 #define PB_R61			0x3d	/* Reserved */
102 #define PB_R62			0x3e	/* Reserved */
103 #define PB_R63			0x3f	/* Reserved */
104 #define PB_R64			0x40	/* Red/Blue Gain */
105 #define PB_R65			0x41	/* Green 2/Green 1 Gain */
106 #define PB_R66			0x42	/* VREF_HI/LO */
107 #define PB_R67			0x43	/* Integration Time/Row Unit Count */
108 #define PB_R240			0xf0	/* ADC Test */
109 #define PB_R241			0xf1    /* Chip Enable */
110 #define PB_R242			0xf2	/* Reserved */
111 
112 static int pb0100_probe(struct sd *sd);
113 static int pb0100_start(struct sd *sd);
114 static int pb0100_init(struct sd *sd);
115 static int pb0100_stop(struct sd *sd);
116 static int pb0100_dump(struct sd *sd);
117 
118 /* V4L2 controls supported by the driver */
119 static int pb0100_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
120 static int pb0100_set_gain(struct gspca_dev *gspca_dev, __s32 val);
121 static int pb0100_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val);
122 static int pb0100_set_red_balance(struct gspca_dev *gspca_dev, __s32 val);
123 static int pb0100_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val);
124 static int pb0100_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val);
125 static int pb0100_get_exposure(struct gspca_dev *gspca_dev, __s32 *val);
126 static int pb0100_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
127 static int pb0100_get_autogain(struct gspca_dev *gspca_dev, __s32 *val);
128 static int pb0100_set_autogain(struct gspca_dev *gspca_dev, __s32 val);
129 static int pb0100_get_autogain_target(struct gspca_dev *gspca_dev, __s32 *val);
130 static int pb0100_set_autogain_target(struct gspca_dev *gspca_dev, __s32 val);
131 static int pb0100_get_natural(struct gspca_dev *gspca_dev, __s32 *val);
132 static int pb0100_set_natural(struct gspca_dev *gspca_dev, __s32 val);
133 
134 const struct stv06xx_sensor stv06xx_sensor_pb0100 = {
135 	.name = "PB-0100",
136 	.i2c_flush = 1,
137 	.i2c_addr = 0xba,
138 	.i2c_len = 2,
139 
140 	.nctrls = 7,
141 	.ctrls = {
142 #define GAIN_IDX 0
143 	{
144 		{
145 			.id		= V4L2_CID_GAIN,
146 			.type		= V4L2_CTRL_TYPE_INTEGER,
147 			.name		= "Gain",
148 			.minimum	= 0,
149 			.maximum	= 255,
150 			.step		= 1,
151 			.default_value  = 128
152 		},
153 		.set = pb0100_set_gain,
154 		.get = pb0100_get_gain
155 	},
156 #define RED_BALANCE_IDX 1
157 	{
158 		{
159 			.id		= V4L2_CID_RED_BALANCE,
160 			.type		= V4L2_CTRL_TYPE_INTEGER,
161 			.name		= "Red Balance",
162 			.minimum	= -255,
163 			.maximum	= 255,
164 			.step		= 1,
165 			.default_value  = 0
166 		},
167 		.set = pb0100_set_red_balance,
168 		.get = pb0100_get_red_balance
169 	},
170 #define BLUE_BALANCE_IDX 2
171 	{
172 		{
173 			.id		= V4L2_CID_BLUE_BALANCE,
174 			.type		= V4L2_CTRL_TYPE_INTEGER,
175 			.name		= "Blue Balance",
176 			.minimum	= -255,
177 			.maximum	= 255,
178 			.step		= 1,
179 			.default_value  = 0
180 		},
181 		.set = pb0100_set_blue_balance,
182 		.get = pb0100_get_blue_balance
183 	},
184 #define EXPOSURE_IDX 3
185 	{
186 		{
187 			.id		= V4L2_CID_EXPOSURE,
188 			.type		= V4L2_CTRL_TYPE_INTEGER,
189 			.name		= "Exposure",
190 			.minimum	= 0,
191 			.maximum	= 511,
192 			.step		= 1,
193 			.default_value  = 12
194 		},
195 		.set = pb0100_set_exposure,
196 		.get = pb0100_get_exposure
197 	},
198 #define AUTOGAIN_IDX 4
199 	{
200 		{
201 			.id		= V4L2_CID_AUTOGAIN,
202 			.type		= V4L2_CTRL_TYPE_BOOLEAN,
203 			.name		= "Automatic Gain and Exposure",
204 			.minimum	= 0,
205 			.maximum	= 1,
206 			.step		= 1,
207 			.default_value  = 1
208 		},
209 		.set = pb0100_set_autogain,
210 		.get = pb0100_get_autogain
211 	},
212 #define AUTOGAIN_TARGET_IDX 5
213 	{
214 		{
215 			.id		= V4L2_CTRL_CLASS_USER + 0x1000,
216 			.type		= V4L2_CTRL_TYPE_INTEGER,
217 			.name		= "Automatic Gain Target",
218 			.minimum	= 0,
219 			.maximum	= 255,
220 			.step		= 1,
221 			.default_value  = 128
222 		},
223 		.set = pb0100_set_autogain_target,
224 		.get = pb0100_get_autogain_target
225 	},
226 #define NATURAL_IDX 6
227 	{
228 		{
229 			.id		= V4L2_CTRL_CLASS_USER + 0x1001,
230 			.type		= V4L2_CTRL_TYPE_BOOLEAN,
231 			.name		= "Natural Light Source",
232 			.minimum	= 0,
233 			.maximum	= 1,
234 			.step		= 1,
235 			.default_value  = 1
236 		},
237 		.set = pb0100_set_natural,
238 		.get = pb0100_get_natural
239 	},
240 	},
241 
242 	.init = pb0100_init,
243 	.probe = pb0100_probe,
244 	.start = pb0100_start,
245 	.stop = pb0100_stop,
246 	.dump = pb0100_dump,
247 
248 	.nmodes = 2,
249 	.modes = {
250 /* low res / subsample modes disabled as they are only half res horizontal,
251    halving the vertical resolution does not seem to work */
252 	{
253 		320,
254 		240,
255 		V4L2_PIX_FMT_SGRBG8,
256 		V4L2_FIELD_NONE,
257 		.sizeimage = 320 * 240,
258 		.bytesperline = 320,
259 		.colorspace = V4L2_COLORSPACE_SRGB,
260 		.priv = PB0100_CROP_TO_VGA
261 	},
262 	{
263 		352,
264 		288,
265 		V4L2_PIX_FMT_SGRBG8,
266 		V4L2_FIELD_NONE,
267 		.sizeimage = 352 * 288,
268 		.bytesperline = 352,
269 		.colorspace = V4L2_COLORSPACE_SRGB,
270 		.priv = 0
271 	},
272 	}
273 };
274 
275 #endif
276