2 * Driver for MT9M001 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/log2.h>
16 #include <media/v4l2-subdev.h>
17 #include <media/v4l2-chip-ident.h>
18 #include <media/soc_camera.h>
20 /* mt9m001 i2c address 0x5d
21 * The platform has to define ctruct i2c_board_info objects and link to them
22 * from struct soc_camera_link */
24 /* mt9m001 selected register addresses */
25 #define MT9M001_CHIP_VERSION 0x00
26 #define MT9M001_ROW_START 0x01
27 #define MT9M001_COLUMN_START 0x02
28 #define MT9M001_WINDOW_HEIGHT 0x03
29 #define MT9M001_WINDOW_WIDTH 0x04
30 #define MT9M001_HORIZONTAL_BLANKING 0x05
31 #define MT9M001_VERTICAL_BLANKING 0x06
32 #define MT9M001_OUTPUT_CONTROL 0x07
33 #define MT9M001_SHUTTER_WIDTH 0x09
34 #define MT9M001_FRAME_RESTART 0x0b
35 #define MT9M001_SHUTTER_DELAY 0x0c
36 #define MT9M001_RESET 0x0d
37 #define MT9M001_READ_OPTIONS1 0x1e
38 #define MT9M001_READ_OPTIONS2 0x20
39 #define MT9M001_GLOBAL_GAIN 0x35
40 #define MT9M001_CHIP_ENABLE 0xF1
42 #define MT9M001_MAX_WIDTH 1280
43 #define MT9M001_MAX_HEIGHT 1024
44 #define MT9M001_MIN_WIDTH 48
45 #define MT9M001_MIN_HEIGHT 32
46 #define MT9M001_COLUMN_SKIP 20
47 #define MT9M001_ROW_SKIP 12
49 static const struct soc_camera_data_format mt9m001_colour_formats
[] = {
50 /* Order important: first natively supported,
51 * second supported with a GPIO extender */
53 .name
= "Bayer (sRGB) 10 bit",
55 .fourcc
= V4L2_PIX_FMT_SBGGR16
,
56 .colorspace
= V4L2_COLORSPACE_SRGB
,
58 .name
= "Bayer (sRGB) 8 bit",
60 .fourcc
= V4L2_PIX_FMT_SBGGR8
,
61 .colorspace
= V4L2_COLORSPACE_SRGB
,
65 static const struct soc_camera_data_format mt9m001_monochrome_formats
[] = {
66 /* Order important - see above */
68 .name
= "Monochrome 10 bit",
70 .fourcc
= V4L2_PIX_FMT_Y16
,
72 .name
= "Monochrome 8 bit",
74 .fourcc
= V4L2_PIX_FMT_GREY
,
79 struct v4l2_subdev subdev
;
80 struct v4l2_rect rect
; /* Sensor window */
82 int model
; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */
84 unsigned int exposure
;
85 unsigned char autoexposure
;
88 static struct mt9m001
*to_mt9m001(const struct i2c_client
*client
)
90 return container_of(i2c_get_clientdata(client
), struct mt9m001
, subdev
);
93 static int reg_read(struct i2c_client
*client
, const u8 reg
)
95 s32 data
= i2c_smbus_read_word_data(client
, reg
);
96 return data
< 0 ? data
: swab16(data
);
99 static int reg_write(struct i2c_client
*client
, const u8 reg
,
102 return i2c_smbus_write_word_data(client
, reg
, swab16(data
));
105 static int reg_set(struct i2c_client
*client
, const u8 reg
,
110 ret
= reg_read(client
, reg
);
113 return reg_write(client
, reg
, ret
| data
);
116 static int reg_clear(struct i2c_client
*client
, const u8 reg
,
121 ret
= reg_read(client
, reg
);
124 return reg_write(client
, reg
, ret
& ~data
);
127 static int mt9m001_init(struct i2c_client
*client
)
131 dev_dbg(&client
->dev
, "%s\n", __func__
);
134 * We don't know, whether platform provides reset, issue a soft reset
135 * too. This returns all registers to their default values.
137 ret
= reg_write(client
, MT9M001_RESET
, 1);
139 ret
= reg_write(client
, MT9M001_RESET
, 0);
141 /* Disable chip, synchronous option update */
143 ret
= reg_write(client
, MT9M001_OUTPUT_CONTROL
, 0);
148 static int mt9m001_s_stream(struct v4l2_subdev
*sd
, int enable
)
150 struct i2c_client
*client
= sd
->priv
;
152 /* Switch to master "normal" mode or stop sensor readout */
153 if (reg_write(client
, MT9M001_OUTPUT_CONTROL
, enable
? 2 : 0) < 0)
158 static int mt9m001_set_bus_param(struct soc_camera_device
*icd
,
161 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
162 unsigned long width_flag
= flags
& SOCAM_DATAWIDTH_MASK
;
164 /* Only one width bit may be set */
165 if (!is_power_of_2(width_flag
))
168 if (icl
->set_bus_param
)
169 return icl
->set_bus_param(icl
, width_flag
);
172 * Without board specific bus width settings we only support the
173 * sensors native bus width
175 if (width_flag
== SOCAM_DATAWIDTH_10
)
181 static unsigned long mt9m001_query_bus_param(struct soc_camera_device
*icd
)
183 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
184 /* MT9M001 has all capture_format parameters fixed */
185 unsigned long flags
= SOCAM_PCLK_SAMPLE_FALLING
|
186 SOCAM_HSYNC_ACTIVE_HIGH
| SOCAM_VSYNC_ACTIVE_HIGH
|
187 SOCAM_DATA_ACTIVE_HIGH
| SOCAM_MASTER
;
189 if (icl
->query_bus_param
)
190 flags
|= icl
->query_bus_param(icl
) & SOCAM_DATAWIDTH_MASK
;
192 flags
|= SOCAM_DATAWIDTH_10
;
194 return soc_camera_apply_sensor_flags(icl
, flags
);
197 static int mt9m001_s_crop(struct v4l2_subdev
*sd
, struct v4l2_crop
*a
)
199 struct i2c_client
*client
= sd
->priv
;
200 struct mt9m001
*mt9m001
= to_mt9m001(client
);
201 struct v4l2_rect rect
= a
->c
;
202 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
204 const u16 hblank
= 9, vblank
= 25;
205 unsigned int total_h
;
207 if (mt9m001
->fourcc
== V4L2_PIX_FMT_SBGGR8
||
208 mt9m001
->fourcc
== V4L2_PIX_FMT_SBGGR16
)
210 * Bayer format - even number of rows for simplicity,
211 * but let the user play with the top row.
213 rect
.height
= ALIGN(rect
.height
, 2);
215 /* Datasheet requirement: see register description */
216 rect
.width
= ALIGN(rect
.width
, 2);
217 rect
.left
= ALIGN(rect
.left
, 2);
219 soc_camera_limit_side(&rect
.left
, &rect
.width
,
220 MT9M001_COLUMN_SKIP
, MT9M001_MIN_WIDTH
, MT9M001_MAX_WIDTH
);
222 soc_camera_limit_side(&rect
.top
, &rect
.height
,
223 MT9M001_ROW_SKIP
, MT9M001_MIN_HEIGHT
, MT9M001_MAX_HEIGHT
);
225 total_h
= rect
.height
+ icd
->y_skip_top
+ vblank
;
227 /* Blanking and start values - default... */
228 ret
= reg_write(client
, MT9M001_HORIZONTAL_BLANKING
, hblank
);
230 ret
= reg_write(client
, MT9M001_VERTICAL_BLANKING
, vblank
);
232 /* The caller provides a supported format, as verified per
233 * call to icd->try_fmt() */
235 ret
= reg_write(client
, MT9M001_COLUMN_START
, rect
.left
);
237 ret
= reg_write(client
, MT9M001_ROW_START
, rect
.top
);
239 ret
= reg_write(client
, MT9M001_WINDOW_WIDTH
, rect
.width
- 1);
241 ret
= reg_write(client
, MT9M001_WINDOW_HEIGHT
,
242 rect
.height
+ icd
->y_skip_top
- 1);
243 if (!ret
&& mt9m001
->autoexposure
) {
244 ret
= reg_write(client
, MT9M001_SHUTTER_WIDTH
, total_h
);
246 const struct v4l2_queryctrl
*qctrl
=
247 soc_camera_find_qctrl(icd
->ops
,
249 mt9m001
->exposure
= (524 + (total_h
- 1) *
250 (qctrl
->maximum
- qctrl
->minimum
)) /
251 1048 + qctrl
->minimum
;
256 mt9m001
->rect
= rect
;
261 static int mt9m001_g_crop(struct v4l2_subdev
*sd
, struct v4l2_crop
*a
)
263 struct i2c_client
*client
= sd
->priv
;
264 struct mt9m001
*mt9m001
= to_mt9m001(client
);
266 a
->c
= mt9m001
->rect
;
267 a
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
272 static int mt9m001_cropcap(struct v4l2_subdev
*sd
, struct v4l2_cropcap
*a
)
274 a
->bounds
.left
= MT9M001_COLUMN_SKIP
;
275 a
->bounds
.top
= MT9M001_ROW_SKIP
;
276 a
->bounds
.width
= MT9M001_MAX_WIDTH
;
277 a
->bounds
.height
= MT9M001_MAX_HEIGHT
;
278 a
->defrect
= a
->bounds
;
279 a
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
280 a
->pixelaspect
.numerator
= 1;
281 a
->pixelaspect
.denominator
= 1;
286 static int mt9m001_g_fmt(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
288 struct i2c_client
*client
= sd
->priv
;
289 struct mt9m001
*mt9m001
= to_mt9m001(client
);
290 struct v4l2_pix_format
*pix
= &f
->fmt
.pix
;
292 pix
->width
= mt9m001
->rect
.width
;
293 pix
->height
= mt9m001
->rect
.height
;
294 pix
->pixelformat
= mt9m001
->fourcc
;
295 pix
->field
= V4L2_FIELD_NONE
;
296 pix
->colorspace
= V4L2_COLORSPACE_SRGB
;
301 static int mt9m001_s_fmt(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
303 struct i2c_client
*client
= sd
->priv
;
304 struct mt9m001
*mt9m001
= to_mt9m001(client
);
305 struct v4l2_pix_format
*pix
= &f
->fmt
.pix
;
306 struct v4l2_crop a
= {
308 .left
= mt9m001
->rect
.left
,
309 .top
= mt9m001
->rect
.top
,
311 .height
= pix
->height
,
316 /* No support for scaling so far, just crop. TODO: use skipping */
317 ret
= mt9m001_s_crop(sd
, &a
);
319 pix
->width
= mt9m001
->rect
.width
;
320 pix
->height
= mt9m001
->rect
.height
;
321 mt9m001
->fourcc
= pix
->pixelformat
;
327 static int mt9m001_try_fmt(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
329 struct i2c_client
*client
= sd
->priv
;
330 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
331 struct v4l2_pix_format
*pix
= &f
->fmt
.pix
;
333 v4l_bound_align_image(&pix
->width
, MT9M001_MIN_WIDTH
,
334 MT9M001_MAX_WIDTH
, 1,
335 &pix
->height
, MT9M001_MIN_HEIGHT
+ icd
->y_skip_top
,
336 MT9M001_MAX_HEIGHT
+ icd
->y_skip_top
, 0, 0);
338 if (pix
->pixelformat
== V4L2_PIX_FMT_SBGGR8
||
339 pix
->pixelformat
== V4L2_PIX_FMT_SBGGR16
)
340 pix
->height
= ALIGN(pix
->height
- 1, 2);
345 static int mt9m001_g_chip_ident(struct v4l2_subdev
*sd
,
346 struct v4l2_dbg_chip_ident
*id
)
348 struct i2c_client
*client
= sd
->priv
;
349 struct mt9m001
*mt9m001
= to_mt9m001(client
);
351 if (id
->match
.type
!= V4L2_CHIP_MATCH_I2C_ADDR
)
354 if (id
->match
.addr
!= client
->addr
)
357 id
->ident
= mt9m001
->model
;
363 #ifdef CONFIG_VIDEO_ADV_DEBUG
364 static int mt9m001_g_register(struct v4l2_subdev
*sd
,
365 struct v4l2_dbg_register
*reg
)
367 struct i2c_client
*client
= sd
->priv
;
369 if (reg
->match
.type
!= V4L2_CHIP_MATCH_I2C_ADDR
|| reg
->reg
> 0xff)
372 if (reg
->match
.addr
!= client
->addr
)
376 reg
->val
= reg_read(client
, reg
->reg
);
378 if (reg
->val
> 0xffff)
384 static int mt9m001_s_register(struct v4l2_subdev
*sd
,
385 struct v4l2_dbg_register
*reg
)
387 struct i2c_client
*client
= sd
->priv
;
389 if (reg
->match
.type
!= V4L2_CHIP_MATCH_I2C_ADDR
|| reg
->reg
> 0xff)
392 if (reg
->match
.addr
!= client
->addr
)
395 if (reg_write(client
, reg
->reg
, reg
->val
) < 0)
402 static const struct v4l2_queryctrl mt9m001_controls
[] = {
404 .id
= V4L2_CID_VFLIP
,
405 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
406 .name
= "Flip Vertically",
413 .type
= V4L2_CTRL_TYPE_INTEGER
,
419 .flags
= V4L2_CTRL_FLAG_SLIDER
,
421 .id
= V4L2_CID_EXPOSURE
,
422 .type
= V4L2_CTRL_TYPE_INTEGER
,
427 .default_value
= 255,
428 .flags
= V4L2_CTRL_FLAG_SLIDER
,
430 .id
= V4L2_CID_EXPOSURE_AUTO
,
431 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
432 .name
= "Automatic Exposure",
440 static struct soc_camera_ops mt9m001_ops
= {
441 .set_bus_param
= mt9m001_set_bus_param
,
442 .query_bus_param
= mt9m001_query_bus_param
,
443 .controls
= mt9m001_controls
,
444 .num_controls
= ARRAY_SIZE(mt9m001_controls
),
447 static int mt9m001_g_ctrl(struct v4l2_subdev
*sd
, struct v4l2_control
*ctrl
)
449 struct i2c_client
*client
= sd
->priv
;
450 struct mt9m001
*mt9m001
= to_mt9m001(client
);
455 data
= reg_read(client
, MT9M001_READ_OPTIONS2
);
458 ctrl
->value
= !!(data
& 0x8000);
460 case V4L2_CID_EXPOSURE_AUTO
:
461 ctrl
->value
= mt9m001
->autoexposure
;
464 ctrl
->value
= mt9m001
->gain
;
466 case V4L2_CID_EXPOSURE
:
467 ctrl
->value
= mt9m001
->exposure
;
473 static int mt9m001_s_ctrl(struct v4l2_subdev
*sd
, struct v4l2_control
*ctrl
)
475 struct i2c_client
*client
= sd
->priv
;
476 struct mt9m001
*mt9m001
= to_mt9m001(client
);
477 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
478 const struct v4l2_queryctrl
*qctrl
;
481 qctrl
= soc_camera_find_qctrl(&mt9m001_ops
, ctrl
->id
);
489 data
= reg_set(client
, MT9M001_READ_OPTIONS2
, 0x8000);
491 data
= reg_clear(client
, MT9M001_READ_OPTIONS2
, 0x8000);
496 if (ctrl
->value
> qctrl
->maximum
|| ctrl
->value
< qctrl
->minimum
)
498 /* See Datasheet Table 7, Gain settings. */
499 if (ctrl
->value
<= qctrl
->default_value
) {
500 /* Pack it into 0..1 step 0.125, register values 0..8 */
501 unsigned long range
= qctrl
->default_value
- qctrl
->minimum
;
502 data
= ((ctrl
->value
- qctrl
->minimum
) * 8 + range
/ 2) / range
;
504 dev_dbg(&client
->dev
, "Setting gain %d\n", data
);
505 data
= reg_write(client
, MT9M001_GLOBAL_GAIN
, data
);
509 /* Pack it into 1.125..15 variable step, register values 9..67 */
510 /* We assume qctrl->maximum - qctrl->default_value - 1 > 0 */
511 unsigned long range
= qctrl
->maximum
- qctrl
->default_value
- 1;
512 unsigned long gain
= ((ctrl
->value
- qctrl
->default_value
- 1) *
513 111 + range
/ 2) / range
+ 9;
518 data
= ((gain
- 32) * 16 + 16) / 32 + 80;
520 data
= ((gain
- 64) * 7 + 28) / 56 + 96;
522 dev_dbg(&client
->dev
, "Setting gain from %d to %d\n",
523 reg_read(client
, MT9M001_GLOBAL_GAIN
), data
);
524 data
= reg_write(client
, MT9M001_GLOBAL_GAIN
, data
);
530 mt9m001
->gain
= ctrl
->value
;
532 case V4L2_CID_EXPOSURE
:
533 /* mt9m001 has maximum == default */
534 if (ctrl
->value
> qctrl
->maximum
|| ctrl
->value
< qctrl
->minimum
)
537 unsigned long range
= qctrl
->maximum
- qctrl
->minimum
;
538 unsigned long shutter
= ((ctrl
->value
- qctrl
->minimum
) * 1048 +
539 range
/ 2) / range
+ 1;
541 dev_dbg(&client
->dev
,
542 "Setting shutter width from %d to %lu\n",
543 reg_read(client
, MT9M001_SHUTTER_WIDTH
),
545 if (reg_write(client
, MT9M001_SHUTTER_WIDTH
, shutter
) < 0)
547 mt9m001
->exposure
= ctrl
->value
;
548 mt9m001
->autoexposure
= 0;
551 case V4L2_CID_EXPOSURE_AUTO
:
553 const u16 vblank
= 25;
554 unsigned int total_h
= mt9m001
->rect
.height
+
555 icd
->y_skip_top
+ vblank
;
556 if (reg_write(client
, MT9M001_SHUTTER_WIDTH
,
559 qctrl
= soc_camera_find_qctrl(icd
->ops
, V4L2_CID_EXPOSURE
);
560 mt9m001
->exposure
= (524 + (total_h
- 1) *
561 (qctrl
->maximum
- qctrl
->minimum
)) /
562 1048 + qctrl
->minimum
;
563 mt9m001
->autoexposure
= 1;
565 mt9m001
->autoexposure
= 0;
571 /* Interface active, can use i2c. If it fails, it can indeed mean, that
572 * this wasn't our capture interface, so, we wait for the right one */
573 static int mt9m001_video_probe(struct soc_camera_device
*icd
,
574 struct i2c_client
*client
)
576 struct mt9m001
*mt9m001
= to_mt9m001(client
);
577 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
582 /* We must have a parent by now. And it cannot be a wrong one.
583 * So this entire test is completely redundant. */
584 if (!icd
->dev
.parent
||
585 to_soc_camera_host(icd
->dev
.parent
)->nr
!= icd
->iface
)
588 /* Enable the chip */
589 data
= reg_write(client
, MT9M001_CHIP_ENABLE
, 1);
590 dev_dbg(&client
->dev
, "write: %d\n", data
);
592 /* Read out the chip version register */
593 data
= reg_read(client
, MT9M001_CHIP_VERSION
);
595 /* must be 0x8411 or 0x8421 for colour sensor and 8431 for bw */
599 mt9m001
->model
= V4L2_IDENT_MT9M001C12ST
;
600 icd
->formats
= mt9m001_colour_formats
;
603 mt9m001
->model
= V4L2_IDENT_MT9M001C12STM
;
604 icd
->formats
= mt9m001_monochrome_formats
;
607 dev_err(&client
->dev
,
608 "No MT9M001 chip detected, register read %x\n", data
);
612 icd
->num_formats
= 0;
615 * This is a 10bit sensor, so by default we only allow 10bit.
616 * The platform may support different bus widths due to
617 * different routing of the data lines.
619 if (icl
->query_bus_param
)
620 flags
= icl
->query_bus_param(icl
);
622 flags
= SOCAM_DATAWIDTH_10
;
624 if (flags
& SOCAM_DATAWIDTH_10
)
629 if (flags
& SOCAM_DATAWIDTH_8
)
632 mt9m001
->fourcc
= icd
->formats
->fourcc
;
634 dev_info(&client
->dev
, "Detected a MT9M001 chip ID %x (%s)\n", data
,
635 data
== 0x8431 ? "C12STM" : "C12ST");
637 ret
= mt9m001_init(client
);
639 dev_err(&client
->dev
, "Failed to initialise the camera\n");
641 /* mt9m001_init() has reset the chip, returning registers to defaults */
643 mt9m001
->exposure
= 255;
648 static void mt9m001_video_remove(struct soc_camera_device
*icd
)
650 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
652 dev_dbg(&icd
->dev
, "Video removed: %p, %p\n",
653 icd
->dev
.parent
, icd
->vdev
);
658 static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops
= {
659 .g_ctrl
= mt9m001_g_ctrl
,
660 .s_ctrl
= mt9m001_s_ctrl
,
661 .g_chip_ident
= mt9m001_g_chip_ident
,
662 #ifdef CONFIG_VIDEO_ADV_DEBUG
663 .g_register
= mt9m001_g_register
,
664 .s_register
= mt9m001_s_register
,
668 static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops
= {
669 .s_stream
= mt9m001_s_stream
,
670 .s_fmt
= mt9m001_s_fmt
,
671 .g_fmt
= mt9m001_g_fmt
,
672 .try_fmt
= mt9m001_try_fmt
,
673 .s_crop
= mt9m001_s_crop
,
674 .g_crop
= mt9m001_g_crop
,
675 .cropcap
= mt9m001_cropcap
,
678 static struct v4l2_subdev_ops mt9m001_subdev_ops
= {
679 .core
= &mt9m001_subdev_core_ops
,
680 .video
= &mt9m001_subdev_video_ops
,
683 static int mt9m001_probe(struct i2c_client
*client
,
684 const struct i2c_device_id
*did
)
686 struct mt9m001
*mt9m001
;
687 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
688 struct i2c_adapter
*adapter
= to_i2c_adapter(client
->dev
.parent
);
689 struct soc_camera_link
*icl
;
693 dev_err(&client
->dev
, "MT9M001: missing soc-camera data!\n");
697 icl
= to_soc_camera_link(icd
);
699 dev_err(&client
->dev
, "MT9M001 driver needs platform data\n");
703 if (!i2c_check_functionality(adapter
, I2C_FUNC_SMBUS_WORD_DATA
)) {
704 dev_warn(&adapter
->dev
,
705 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n");
709 mt9m001
= kzalloc(sizeof(struct mt9m001
), GFP_KERNEL
);
713 v4l2_i2c_subdev_init(&mt9m001
->subdev
, client
, &mt9m001_subdev_ops
);
715 /* Second stage probe - when a capture adapter is there */
716 icd
->ops
= &mt9m001_ops
;
719 mt9m001
->rect
.left
= MT9M001_COLUMN_SKIP
;
720 mt9m001
->rect
.top
= MT9M001_ROW_SKIP
;
721 mt9m001
->rect
.width
= MT9M001_MAX_WIDTH
;
722 mt9m001
->rect
.height
= MT9M001_MAX_HEIGHT
;
724 /* Simulated autoexposure. If enabled, we calculate shutter width
725 * ourselves in the driver based on vertical blanking and frame width */
726 mt9m001
->autoexposure
= 1;
728 ret
= mt9m001_video_probe(icd
, client
);
731 i2c_set_clientdata(client
, NULL
);
738 static int mt9m001_remove(struct i2c_client
*client
)
740 struct mt9m001
*mt9m001
= to_mt9m001(client
);
741 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
744 mt9m001_video_remove(icd
);
745 i2c_set_clientdata(client
, NULL
);
746 client
->driver
= NULL
;
752 static const struct i2c_device_id mt9m001_id
[] = {
756 MODULE_DEVICE_TABLE(i2c
, mt9m001_id
);
758 static struct i2c_driver mt9m001_i2c_driver
= {
762 .probe
= mt9m001_probe
,
763 .remove
= mt9m001_remove
,
764 .id_table
= mt9m001_id
,
767 static int __init
mt9m001_mod_init(void)
769 return i2c_add_driver(&mt9m001_i2c_driver
);
772 static void __exit
mt9m001_mod_exit(void)
774 i2c_del_driver(&mt9m001_i2c_driver
);
777 module_init(mt9m001_mod_init
);
778 module_exit(mt9m001_mod_exit
);
780 MODULE_DESCRIPTION("Micron MT9M001 Camera driver");
781 MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
782 MODULE_LICENSE("GPL");