2 * Driver for MT9V022 CMOS Image Sensor from Micron
4 * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/videodev2.h>
12 #include <linux/slab.h>
13 #include <linux/i2c.h>
14 #include <linux/delay.h>
15 #include <linux/log2.h>
17 #include <media/v4l2-common.h>
18 #include <media/v4l2-chip-ident.h>
19 #include <media/soc_camera.h>
21 /* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c
22 * The platform has to define i2c_board_info
23 * and call i2c_register_board_info() */
25 static char *sensor_type
;
26 module_param(sensor_type
, charp
, S_IRUGO
);
27 MODULE_PARM_DESC(sensor_type
, "Sensor type: \"colour\" or \"monochrome\"");
29 /* mt9v022 selected register addresses */
30 #define MT9V022_CHIP_VERSION 0x00
31 #define MT9V022_COLUMN_START 0x01
32 #define MT9V022_ROW_START 0x02
33 #define MT9V022_WINDOW_HEIGHT 0x03
34 #define MT9V022_WINDOW_WIDTH 0x04
35 #define MT9V022_HORIZONTAL_BLANKING 0x05
36 #define MT9V022_VERTICAL_BLANKING 0x06
37 #define MT9V022_CHIP_CONTROL 0x07
38 #define MT9V022_SHUTTER_WIDTH1 0x08
39 #define MT9V022_SHUTTER_WIDTH2 0x09
40 #define MT9V022_SHUTTER_WIDTH_CTRL 0x0a
41 #define MT9V022_TOTAL_SHUTTER_WIDTH 0x0b
42 #define MT9V022_RESET 0x0c
43 #define MT9V022_READ_MODE 0x0d
44 #define MT9V022_MONITOR_MODE 0x0e
45 #define MT9V022_PIXEL_OPERATION_MODE 0x0f
46 #define MT9V022_LED_OUT_CONTROL 0x1b
47 #define MT9V022_ADC_MODE_CONTROL 0x1c
48 #define MT9V022_ANALOG_GAIN 0x34
49 #define MT9V022_BLACK_LEVEL_CALIB_CTRL 0x47
50 #define MT9V022_PIXCLK_FV_LV 0x74
51 #define MT9V022_DIGITAL_TEST_PATTERN 0x7f
52 #define MT9V022_AEC_AGC_ENABLE 0xAF
53 #define MT9V022_MAX_TOTAL_SHUTTER_WIDTH 0xBD
55 /* Progressive scan, master, defaults */
56 #define MT9V022_CHIP_CONTROL_DEFAULT 0x188
58 static const struct soc_camera_data_format mt9v022_colour_formats
[] = {
59 /* Order important: first natively supported,
60 * second supported with a GPIO extender */
62 .name
= "Bayer (sRGB) 10 bit",
64 .fourcc
= V4L2_PIX_FMT_SBGGR16
,
65 .colorspace
= V4L2_COLORSPACE_SRGB
,
67 .name
= "Bayer (sRGB) 8 bit",
69 .fourcc
= V4L2_PIX_FMT_SBGGR8
,
70 .colorspace
= V4L2_COLORSPACE_SRGB
,
74 static const struct soc_camera_data_format mt9v022_monochrome_formats
[] = {
75 /* Order important - see above */
77 .name
= "Monochrome 10 bit",
79 .fourcc
= V4L2_PIX_FMT_Y16
,
81 .name
= "Monochrome 8 bit",
83 .fourcc
= V4L2_PIX_FMT_GREY
,
88 int model
; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */
92 static int reg_read(struct i2c_client
*client
, const u8 reg
)
94 s32 data
= i2c_smbus_read_word_data(client
, reg
);
95 return data
< 0 ? data
: swab16(data
);
98 static int reg_write(struct i2c_client
*client
, const u8 reg
,
101 return i2c_smbus_write_word_data(client
, reg
, swab16(data
));
104 static int reg_set(struct i2c_client
*client
, const u8 reg
,
109 ret
= reg_read(client
, reg
);
112 return reg_write(client
, reg
, ret
| data
);
115 static int reg_clear(struct i2c_client
*client
, const u8 reg
,
120 ret
= reg_read(client
, reg
);
123 return reg_write(client
, reg
, ret
& ~data
);
126 static int mt9v022_init(struct soc_camera_device
*icd
)
128 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
129 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
130 struct mt9v022
*mt9v022
= i2c_get_clientdata(client
);
134 ret
= icl
->power(&client
->dev
, 1);
136 dev_err(icd
->vdev
->parent
,
137 "Platform failed to power-on the camera.\n");
143 * The camera could have been already on, we hard-reset it additionally,
144 * if available. Soft reset is done in video_probe().
147 icl
->reset(&client
->dev
);
149 /* Almost the default mode: master, parallel, simultaneous, and an
150 * undocumented bit 0x200, which is present in table 7, but not in 8,
151 * plus snapshot mode to disable scan for now */
152 mt9v022
->chip_control
|= 0x10;
153 ret
= reg_write(client
, MT9V022_CHIP_CONTROL
, mt9v022
->chip_control
);
155 ret
= reg_write(client
, MT9V022_READ_MODE
, 0x300);
160 ret
= reg_set(client
, MT9V022_AEC_AGC_ENABLE
, 0x3);
162 ret
= reg_write(client
, MT9V022_MAX_TOTAL_SHUTTER_WIDTH
, 480);
165 ret
= reg_clear(client
, MT9V022_BLACK_LEVEL_CALIB_CTRL
, 1);
167 ret
= reg_write(client
, MT9V022_DIGITAL_TEST_PATTERN
, 0);
172 static int mt9v022_release(struct soc_camera_device
*icd
)
174 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
175 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
178 icl
->power(&client
->dev
, 0);
183 static int mt9v022_start_capture(struct soc_camera_device
*icd
)
185 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
186 struct mt9v022
*mt9v022
= i2c_get_clientdata(client
);
187 /* Switch to master "normal" mode */
188 mt9v022
->chip_control
&= ~0x10;
189 if (reg_write(client
, MT9V022_CHIP_CONTROL
,
190 mt9v022
->chip_control
) < 0)
195 static int mt9v022_stop_capture(struct soc_camera_device
*icd
)
197 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
198 struct mt9v022
*mt9v022
= i2c_get_clientdata(client
);
199 /* Switch to snapshot mode */
200 mt9v022
->chip_control
|= 0x10;
201 if (reg_write(client
, MT9V022_CHIP_CONTROL
,
202 mt9v022
->chip_control
) < 0)
207 static int mt9v022_set_bus_param(struct soc_camera_device
*icd
,
210 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
211 struct mt9v022
*mt9v022
= i2c_get_clientdata(client
);
212 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
213 unsigned int width_flag
= flags
& SOCAM_DATAWIDTH_MASK
;
217 /* Only one width bit may be set */
218 if (!is_power_of_2(width_flag
))
221 if (icl
->set_bus_param
) {
222 ret
= icl
->set_bus_param(icl
, width_flag
);
227 * Without board specific bus width settings we only support the
228 * sensors native bus width
230 if (width_flag
!= SOCAM_DATAWIDTH_10
)
234 flags
= soc_camera_apply_sensor_flags(icl
, flags
);
236 if (flags
& SOCAM_PCLK_SAMPLE_RISING
)
239 if (!(flags
& SOCAM_HSYNC_ACTIVE_HIGH
))
242 if (!(flags
& SOCAM_VSYNC_ACTIVE_HIGH
))
245 ret
= reg_write(client
, MT9V022_PIXCLK_FV_LV
, pixclk
);
249 if (!(flags
& SOCAM_MASTER
))
250 mt9v022
->chip_control
&= ~0x8;
252 ret
= reg_write(client
, MT9V022_CHIP_CONTROL
, mt9v022
->chip_control
);
256 dev_dbg(&icd
->dev
, "Calculated pixclk 0x%x, chip control 0x%x\n",
257 pixclk
, mt9v022
->chip_control
);
262 static unsigned long mt9v022_query_bus_param(struct soc_camera_device
*icd
)
264 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
265 unsigned int width_flag
;
267 if (icl
->query_bus_param
)
268 width_flag
= icl
->query_bus_param(icl
) &
269 SOCAM_DATAWIDTH_MASK
;
271 width_flag
= SOCAM_DATAWIDTH_10
;
273 return SOCAM_PCLK_SAMPLE_RISING
| SOCAM_PCLK_SAMPLE_FALLING
|
274 SOCAM_HSYNC_ACTIVE_HIGH
| SOCAM_HSYNC_ACTIVE_LOW
|
275 SOCAM_VSYNC_ACTIVE_HIGH
| SOCAM_VSYNC_ACTIVE_LOW
|
276 SOCAM_DATA_ACTIVE_HIGH
| SOCAM_MASTER
| SOCAM_SLAVE
|
280 static int mt9v022_set_crop(struct soc_camera_device
*icd
,
281 struct v4l2_rect
*rect
)
283 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
286 /* Like in example app. Contradicts the datasheet though */
287 ret
= reg_read(client
, MT9V022_AEC_AGC_ENABLE
);
289 if (ret
& 1) /* Autoexposure */
290 ret
= reg_write(client
, MT9V022_MAX_TOTAL_SHUTTER_WIDTH
,
291 rect
->height
+ icd
->y_skip_top
+ 43);
293 ret
= reg_write(client
, MT9V022_TOTAL_SHUTTER_WIDTH
,
294 rect
->height
+ icd
->y_skip_top
+ 43);
296 /* Setup frame format: defaults apart from width and height */
298 ret
= reg_write(client
, MT9V022_COLUMN_START
, rect
->left
);
300 ret
= reg_write(client
, MT9V022_ROW_START
, rect
->top
);
302 /* Default 94, Phytec driver says:
303 * "width + horizontal blank >= 660" */
304 ret
= reg_write(client
, MT9V022_HORIZONTAL_BLANKING
,
305 rect
->width
> 660 - 43 ? 43 :
308 ret
= reg_write(client
, MT9V022_VERTICAL_BLANKING
, 45);
310 ret
= reg_write(client
, MT9V022_WINDOW_WIDTH
, rect
->width
);
312 ret
= reg_write(client
, MT9V022_WINDOW_HEIGHT
,
313 rect
->height
+ icd
->y_skip_top
);
318 dev_dbg(&icd
->dev
, "Frame %ux%u pixel\n", rect
->width
, rect
->height
);
323 static int mt9v022_set_fmt(struct soc_camera_device
*icd
,
324 struct v4l2_format
*f
)
326 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
327 struct mt9v022
*mt9v022
= i2c_get_clientdata(client
);
328 struct v4l2_pix_format
*pix
= &f
->fmt
.pix
;
329 struct v4l2_rect rect
= {
330 .left
= icd
->x_current
,
331 .top
= icd
->y_current
,
333 .height
= pix
->height
,
336 /* The caller provides a supported format, as verified per call to
337 * icd->try_fmt(), datawidth is from our supported format list */
338 switch (pix
->pixelformat
) {
339 case V4L2_PIX_FMT_GREY
:
340 case V4L2_PIX_FMT_Y16
:
341 if (mt9v022
->model
!= V4L2_IDENT_MT9V022IX7ATM
)
344 case V4L2_PIX_FMT_SBGGR8
:
345 case V4L2_PIX_FMT_SBGGR16
:
346 if (mt9v022
->model
!= V4L2_IDENT_MT9V022IX7ATC
)
350 /* No format change, only geometry */
356 /* No support for scaling on this camera, just crop. */
357 return mt9v022_set_crop(icd
, &rect
);
360 static int mt9v022_try_fmt(struct soc_camera_device
*icd
,
361 struct v4l2_format
*f
)
363 struct v4l2_pix_format
*pix
= &f
->fmt
.pix
;
365 v4l_bound_align_image(&pix
->width
, 48, 752, 2 /* ? */,
366 &pix
->height
, 32 + icd
->y_skip_top
,
367 480 + icd
->y_skip_top
, 0, 0);
372 static int mt9v022_get_chip_id(struct soc_camera_device
*icd
,
373 struct v4l2_dbg_chip_ident
*id
)
375 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
376 struct mt9v022
*mt9v022
= i2c_get_clientdata(client
);
378 if (id
->match
.type
!= V4L2_CHIP_MATCH_I2C_ADDR
)
381 if (id
->match
.addr
!= client
->addr
)
384 id
->ident
= mt9v022
->model
;
390 #ifdef CONFIG_VIDEO_ADV_DEBUG
391 static int mt9v022_get_register(struct soc_camera_device
*icd
,
392 struct v4l2_dbg_register
*reg
)
394 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
396 if (reg
->match
.type
!= V4L2_CHIP_MATCH_I2C_ADDR
|| reg
->reg
> 0xff)
399 if (reg
->match
.addr
!= client
->addr
)
403 reg
->val
= reg_read(client
, reg
->reg
);
405 if (reg
->val
> 0xffff)
411 static int mt9v022_set_register(struct soc_camera_device
*icd
,
412 struct v4l2_dbg_register
*reg
)
414 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
416 if (reg
->match
.type
!= V4L2_CHIP_MATCH_I2C_ADDR
|| reg
->reg
> 0xff)
419 if (reg
->match
.addr
!= client
->addr
)
422 if (reg_write(client
, reg
->reg
, reg
->val
) < 0)
429 static const struct v4l2_queryctrl mt9v022_controls
[] = {
431 .id
= V4L2_CID_VFLIP
,
432 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
433 .name
= "Flip Vertically",
439 .id
= V4L2_CID_HFLIP
,
440 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
441 .name
= "Flip Horizontally",
448 .type
= V4L2_CTRL_TYPE_INTEGER
,
449 .name
= "Analog Gain",
454 .flags
= V4L2_CTRL_FLAG_SLIDER
,
456 .id
= V4L2_CID_EXPOSURE
,
457 .type
= V4L2_CTRL_TYPE_INTEGER
,
462 .default_value
= 255,
463 .flags
= V4L2_CTRL_FLAG_SLIDER
,
465 .id
= V4L2_CID_AUTOGAIN
,
466 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
467 .name
= "Automatic Gain",
473 .id
= V4L2_CID_EXPOSURE_AUTO
,
474 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
475 .name
= "Automatic Exposure",
483 static int mt9v022_get_control(struct soc_camera_device
*, struct v4l2_control
*);
484 static int mt9v022_set_control(struct soc_camera_device
*, struct v4l2_control
*);
486 static struct soc_camera_ops mt9v022_ops
= {
487 .owner
= THIS_MODULE
,
488 .init
= mt9v022_init
,
489 .release
= mt9v022_release
,
490 .start_capture
= mt9v022_start_capture
,
491 .stop_capture
= mt9v022_stop_capture
,
492 .set_crop
= mt9v022_set_crop
,
493 .set_fmt
= mt9v022_set_fmt
,
494 .try_fmt
= mt9v022_try_fmt
,
495 .set_bus_param
= mt9v022_set_bus_param
,
496 .query_bus_param
= mt9v022_query_bus_param
,
497 .controls
= mt9v022_controls
,
498 .num_controls
= ARRAY_SIZE(mt9v022_controls
),
499 .get_control
= mt9v022_get_control
,
500 .set_control
= mt9v022_set_control
,
501 .get_chip_id
= mt9v022_get_chip_id
,
502 #ifdef CONFIG_VIDEO_ADV_DEBUG
503 .get_register
= mt9v022_get_register
,
504 .set_register
= mt9v022_set_register
,
508 static int mt9v022_get_control(struct soc_camera_device
*icd
,
509 struct v4l2_control
*ctrl
)
511 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
516 data
= reg_read(client
, MT9V022_READ_MODE
);
519 ctrl
->value
= !!(data
& 0x10);
522 data
= reg_read(client
, MT9V022_READ_MODE
);
525 ctrl
->value
= !!(data
& 0x20);
527 case V4L2_CID_EXPOSURE_AUTO
:
528 data
= reg_read(client
, MT9V022_AEC_AGC_ENABLE
);
531 ctrl
->value
= !!(data
& 0x1);
533 case V4L2_CID_AUTOGAIN
:
534 data
= reg_read(client
, MT9V022_AEC_AGC_ENABLE
);
537 ctrl
->value
= !!(data
& 0x2);
543 static int mt9v022_set_control(struct soc_camera_device
*icd
,
544 struct v4l2_control
*ctrl
)
547 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
548 const struct v4l2_queryctrl
*qctrl
;
550 qctrl
= soc_camera_find_qctrl(&mt9v022_ops
, ctrl
->id
);
558 data
= reg_set(client
, MT9V022_READ_MODE
, 0x10);
560 data
= reg_clear(client
, MT9V022_READ_MODE
, 0x10);
566 data
= reg_set(client
, MT9V022_READ_MODE
, 0x20);
568 data
= reg_clear(client
, MT9V022_READ_MODE
, 0x20);
573 /* mt9v022 has minimum == default */
574 if (ctrl
->value
> qctrl
->maximum
|| ctrl
->value
< qctrl
->minimum
)
577 unsigned long range
= qctrl
->maximum
- qctrl
->minimum
;
578 /* Datasheet says 16 to 64. autogain only works properly
579 * after setting gain to maximum 14. Larger values
580 * produce "white fly" noise effect. On the whole,
581 * manually setting analog gain does no good. */
582 unsigned long gain
= ((ctrl
->value
- qctrl
->minimum
) *
583 10 + range
/ 2) / range
+ 4;
586 /* The user wants to set gain manually, hope, she
587 * knows, what she's doing... Switch AGC off. */
589 if (reg_clear(client
, MT9V022_AEC_AGC_ENABLE
, 0x2) < 0)
592 dev_info(&icd
->dev
, "Setting gain from %d to %lu\n",
593 reg_read(client
, MT9V022_ANALOG_GAIN
), gain
);
594 if (reg_write(client
, MT9V022_ANALOG_GAIN
, gain
) < 0)
596 icd
->gain
= ctrl
->value
;
599 case V4L2_CID_EXPOSURE
:
600 /* mt9v022 has maximum == default */
601 if (ctrl
->value
> qctrl
->maximum
|| ctrl
->value
< qctrl
->minimum
)
604 unsigned long range
= qctrl
->maximum
- qctrl
->minimum
;
605 unsigned long shutter
= ((ctrl
->value
- qctrl
->minimum
) *
606 479 + range
/ 2) / range
+ 1;
607 /* The user wants to set shutter width manually, hope,
608 * she knows, what she's doing... Switch AEC off. */
610 if (reg_clear(client
, MT9V022_AEC_AGC_ENABLE
, 0x1) < 0)
613 dev_dbg(&icd
->dev
, "Shutter width from %d to %lu\n",
614 reg_read(client
, MT9V022_TOTAL_SHUTTER_WIDTH
),
616 if (reg_write(client
, MT9V022_TOTAL_SHUTTER_WIDTH
,
619 icd
->exposure
= ctrl
->value
;
622 case V4L2_CID_AUTOGAIN
:
624 data
= reg_set(client
, MT9V022_AEC_AGC_ENABLE
, 0x2);
626 data
= reg_clear(client
, MT9V022_AEC_AGC_ENABLE
, 0x2);
630 case V4L2_CID_EXPOSURE_AUTO
:
632 data
= reg_set(client
, MT9V022_AEC_AGC_ENABLE
, 0x1);
634 data
= reg_clear(client
, MT9V022_AEC_AGC_ENABLE
, 0x1);
642 /* Interface active, can use i2c. If it fails, it can indeed mean, that
643 * this wasn't our capture interface, so, we wait for the right one */
644 static int mt9v022_video_probe(struct soc_camera_device
*icd
,
645 struct i2c_client
*client
)
647 struct mt9v022
*mt9v022
= i2c_get_clientdata(client
);
648 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
653 if (!icd
->dev
.parent
||
654 to_soc_camera_host(icd
->dev
.parent
)->nr
!= icd
->iface
)
657 /* Switch master clock on */
658 ret
= soc_camera_video_start(icd
, &client
->dev
);
662 /* Read out the chip version register */
663 data
= reg_read(client
, MT9V022_CHIP_VERSION
);
665 /* must be 0x1311 or 0x1313 */
666 if (data
!= 0x1311 && data
!= 0x1313) {
668 dev_info(&icd
->dev
, "No MT9V022 detected, ID register 0x%x\n",
674 ret
= reg_write(client
, MT9V022_RESET
, 1);
677 /* 15 clock cycles */
679 if (reg_read(client
, MT9V022_RESET
)) {
680 dev_err(&icd
->dev
, "Resetting MT9V022 failed!\n");
686 /* Set monochrome or colour sensor type */
687 if (sensor_type
&& (!strcmp("colour", sensor_type
) ||
688 !strcmp("color", sensor_type
))) {
689 ret
= reg_write(client
, MT9V022_PIXEL_OPERATION_MODE
, 4 | 0x11);
690 mt9v022
->model
= V4L2_IDENT_MT9V022IX7ATC
;
691 icd
->formats
= mt9v022_colour_formats
;
693 ret
= reg_write(client
, MT9V022_PIXEL_OPERATION_MODE
, 0x11);
694 mt9v022
->model
= V4L2_IDENT_MT9V022IX7ATM
;
695 icd
->formats
= mt9v022_monochrome_formats
;
701 icd
->num_formats
= 0;
704 * This is a 10bit sensor, so by default we only allow 10bit.
705 * The platform may support different bus widths due to
706 * different routing of the data lines.
708 if (icl
->query_bus_param
)
709 flags
= icl
->query_bus_param(icl
);
711 flags
= SOCAM_DATAWIDTH_10
;
713 if (flags
& SOCAM_DATAWIDTH_10
)
718 if (flags
& SOCAM_DATAWIDTH_8
)
721 dev_info(&icd
->dev
, "Detected a MT9V022 chip ID %x, %s sensor\n",
722 data
, mt9v022
->model
== V4L2_IDENT_MT9V022IX7ATM
?
723 "monochrome" : "colour");
726 soc_camera_video_stop(icd
);
731 static void mt9v022_video_remove(struct soc_camera_device
*icd
)
733 struct i2c_client
*client
= to_i2c_client(to_soc_camera_control(icd
));
734 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
736 dev_dbg(&icd
->dev
, "Video %x removed: %p, %p\n", client
->addr
,
737 icd
->dev
.parent
, icd
->vdev
);
742 static int mt9v022_probe(struct i2c_client
*client
,
743 const struct i2c_device_id
*did
)
745 struct mt9v022
*mt9v022
;
746 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
747 struct i2c_adapter
*adapter
= to_i2c_adapter(client
->dev
.parent
);
748 struct soc_camera_link
*icl
;
752 dev_err(&client
->dev
, "MT9V022: missing soc-camera data!\n");
756 icl
= to_soc_camera_link(icd
);
758 dev_err(&client
->dev
, "MT9V022 driver needs platform data\n");
762 if (!i2c_check_functionality(adapter
, I2C_FUNC_SMBUS_WORD_DATA
)) {
763 dev_warn(&adapter
->dev
,
764 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n");
768 mt9v022
= kzalloc(sizeof(struct mt9v022
), GFP_KERNEL
);
772 mt9v022
->chip_control
= MT9V022_CHIP_CONTROL_DEFAULT
;
773 i2c_set_clientdata(client
, mt9v022
);
775 icd
->ops
= &mt9v022_ops
;
781 icd
->width_max
= 752;
782 icd
->height_min
= 32;
783 icd
->height_max
= 480;
786 ret
= mt9v022_video_probe(icd
, client
);
789 i2c_set_clientdata(client
, NULL
);
796 static int mt9v022_remove(struct i2c_client
*client
)
798 struct mt9v022
*mt9v022
= i2c_get_clientdata(client
);
799 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
802 mt9v022_video_remove(icd
);
803 i2c_set_clientdata(client
, NULL
);
804 client
->driver
= NULL
;
809 static const struct i2c_device_id mt9v022_id
[] = {
813 MODULE_DEVICE_TABLE(i2c
, mt9v022_id
);
815 static struct i2c_driver mt9v022_i2c_driver
= {
819 .probe
= mt9v022_probe
,
820 .remove
= mt9v022_remove
,
821 .id_table
= mt9v022_id
,
824 static int __init
mt9v022_mod_init(void)
826 return i2c_add_driver(&mt9v022_i2c_driver
);
829 static void __exit
mt9v022_mod_exit(void)
831 i2c_del_driver(&mt9v022_i2c_driver
);
834 module_init(mt9v022_mod_init
);
835 module_exit(mt9v022_mod_exit
);
837 MODULE_DESCRIPTION("Micron MT9V022 Camera driver");
838 MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
839 MODULE_LICENSE("GPL");