5 * @brief Common control functions for Omnivision Image Sensors.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 static __u8 mt9m111_init
[][3] = {
32 /* Select Page map 0x01
33 * This means all new writes now have the address prefix 0x1.
34 * Example: 0x3a becomes 0x13a. */
36 /** Select output format:
37 * - output raw bayer (8+2 bit)
38 * FIXME: There are nearly all YUV and RGB variants possible.
39 * Maybe we should use them.
42 /* measure atoexposure through a mix of both possible windows */
44 /* Switch back to Page map 0x00 */
46 /* The following set the resoutiona and window size.
47 * It's a bit more than SXGA.
65 /* Protect settings */
75 /* Blanking (again?) */
81 static __u8 mt9m001_init
[][3] = {
143 struct microdia_video_format mt9m111_fmts
[] = {
145 .pix_fmt
= V4L2_PIX_FMT_SBGGR8
,
146 .desc
= "Bayer 8bit (BGGR)",
148 .set_format
= sn9c20x_set_raw
151 .pix_fmt
= V4L2_PIX_FMT_JPEG
,
152 .desc
= "JPEG (YUV 4:2:2)",
154 .set_format
= sn9c20x_set_jpeg
158 struct microdia_video_resolution mt9m001_resolutions
[] = {
162 .scale
= SN9C20X_1_4_SCALE
,
163 .window
= {2, 2, 640, 480}
168 .scale
= SN9C20X_1_2_SCALE
,
169 .window
= {2, 2, 640, 480}
174 .scale
= SN9C20X_NO_SCALE
,
175 .window
= {2, 2, 640, 480}
180 * @brief Initialize mt9m111 sensors
182 * @param dev Pointer to device structure
184 * @return 0 or negative error code
187 int mt9m001_initialize(struct usb_microdia
*dev
)
193 for (i
= 0; i
< ARRAY_SIZE(mt9m001_init
); i
++) {
194 reg
= mt9m001_init
[i
][0];
195 value
[0] = mt9m001_init
[i
][1];
196 value
[1] = mt9m001_init
[i
][2];
197 ret
= sn9c20x_write_i2c_data(dev
, 2, reg
, value
);
199 UDIA_INFO("Sensor Init Error (%d). line %d\n", ret
, i
);
207 int mt9m001_probe(struct usb_microdia
*dev
)
211 dev
->camera
.sensor_slave_address
= 0x5d;
212 ret
= sn9c20x_read_i2c_data(dev
, 2, 0x00, buf
);
216 if (buf
[1] == 0x31) {
217 mt9m001_initialize(dev
);
218 dev
->camera
.modes
= mt9m001_resolutions
;
219 dev
->camera
.nmodes
= ARRAY_SIZE(mt9m001_resolutions
);
220 dev
->camera
.fmts
= mt9m111_fmts
;
221 dev
->camera
.nfmts
= ARRAY_SIZE(mt9m111_fmts
);
222 return MT9M001_SENSOR
;
229 struct microdia_video_resolution mt9m111_resolutions
[] = {
233 .scale
= SN9C20X_1_4_SCALE
,
234 .window
= {6, 2, 640, 480}
239 .scale
= SN9C20X_1_2_SCALE
,
240 .window
= {6, 2, 640, 480}
245 .scale
= SN9C20X_NO_SCALE
,
246 .window
= {6, 2, 640, 480}
251 * @brief Initialize mt9m111 sensors
253 * @param dev Pointer to device structure
255 * @return 0 or negative error code
258 int mt9m111_initialize(struct usb_microdia
*dev
)
264 for (i
= 0; i
< ARRAY_SIZE(mt9m111_init
); i
++) {
265 reg
= mt9m111_init
[i
][0];
266 value
[0] = mt9m111_init
[i
][1];
267 value
[1] = mt9m111_init
[i
][2];
268 ret
= sn9c20x_write_i2c_data(dev
, 2, reg
, value
);
270 UDIA_INFO("Sensor Init Error (%d). line %d\n", ret
, i
);
278 int mt9m111_probe(struct usb_microdia
*dev
)
282 dev
->camera
.sensor_slave_address
= 0x5d;
283 ret
= sn9c20x_read_i2c_data(dev
, 2, 0x00, buf
);
287 if (buf
[1] == 0x3a) {
288 mt9m111_initialize(dev
);
289 dev
->camera
.modes
= mt9m111_resolutions
;
290 dev
->camera
.nmodes
= ARRAY_SIZE(mt9m111_resolutions
);
291 dev
->camera
.fmts
= mt9m111_fmts
;
292 dev
->camera
.nfmts
= ARRAY_SIZE(mt9m111_fmts
);
293 return MT9M111_SENSOR
;