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>
21 * mt9m001 i2c address 0x5d
22 * The platform has to define ctruct i2c_board_info objects and link to them
23 * from struct soc_camera_link
26 /* mt9m001 selected register addresses */
27 #define MT9M001_CHIP_VERSION 0x00
28 #define MT9M001_ROW_START 0x01
29 #define MT9M001_COLUMN_START 0x02
30 #define MT9M001_WINDOW_HEIGHT 0x03
31 #define MT9M001_WINDOW_WIDTH 0x04
32 #define MT9M001_HORIZONTAL_BLANKING 0x05
33 #define MT9M001_VERTICAL_BLANKING 0x06
34 #define MT9M001_OUTPUT_CONTROL 0x07
35 #define MT9M001_SHUTTER_WIDTH 0x09
36 #define MT9M001_FRAME_RESTART 0x0b
37 #define MT9M001_SHUTTER_DELAY 0x0c
38 #define MT9M001_RESET 0x0d
39 #define MT9M001_READ_OPTIONS1 0x1e
40 #define MT9M001_READ_OPTIONS2 0x20
41 #define MT9M001_GLOBAL_GAIN 0x35
42 #define MT9M001_CHIP_ENABLE 0xF1
44 #define MT9M001_MAX_WIDTH 1280
45 #define MT9M001_MAX_HEIGHT 1024
46 #define MT9M001_MIN_WIDTH 48
47 #define MT9M001_MIN_HEIGHT 32
48 #define MT9M001_COLUMN_SKIP 20
49 #define MT9M001_ROW_SKIP 12
51 static const struct soc_camera_data_format mt9m001_colour_formats
[] = {
53 * Order important: first natively supported,
54 * second supported with a GPIO extender
57 .name
= "Bayer (sRGB) 10 bit",
59 .fourcc
= V4L2_PIX_FMT_SBGGR16
,
60 .colorspace
= V4L2_COLORSPACE_SRGB
,
62 .name
= "Bayer (sRGB) 8 bit",
64 .fourcc
= V4L2_PIX_FMT_SBGGR8
,
65 .colorspace
= V4L2_COLORSPACE_SRGB
,
69 static const struct soc_camera_data_format mt9m001_monochrome_formats
[] = {
70 /* Order important - see above */
72 .name
= "Monochrome 10 bit",
74 .fourcc
= V4L2_PIX_FMT_Y16
,
76 .name
= "Monochrome 8 bit",
78 .fourcc
= V4L2_PIX_FMT_GREY
,
83 struct v4l2_subdev subdev
;
84 struct v4l2_rect rect
; /* Sensor window */
86 int model
; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */
88 unsigned int exposure
;
89 unsigned short y_skip_top
; /* Lines to skip at the top */
90 unsigned char autoexposure
;
93 static struct mt9m001
*to_mt9m001(const struct i2c_client
*client
)
95 return container_of(i2c_get_clientdata(client
), struct mt9m001
, subdev
);
98 static int reg_read(struct i2c_client
*client
, const u8 reg
)
100 s32 data
= i2c_smbus_read_word_data(client
, reg
);
101 return data
< 0 ? data
: swab16(data
);
104 static int reg_write(struct i2c_client
*client
, const u8 reg
,
107 return i2c_smbus_write_word_data(client
, reg
, swab16(data
));
110 static int reg_set(struct i2c_client
*client
, const u8 reg
,
115 ret
= reg_read(client
, reg
);
118 return reg_write(client
, reg
, ret
| data
);
121 static int reg_clear(struct i2c_client
*client
, const u8 reg
,
126 ret
= reg_read(client
, reg
);
129 return reg_write(client
, reg
, ret
& ~data
);
132 static int mt9m001_init(struct i2c_client
*client
)
136 dev_dbg(&client
->dev
, "%s\n", __func__
);
139 * We don't know, whether platform provides reset, issue a soft reset
140 * too. This returns all registers to their default values.
142 ret
= reg_write(client
, MT9M001_RESET
, 1);
144 ret
= reg_write(client
, MT9M001_RESET
, 0);
146 /* Disable chip, synchronous option update */
148 ret
= reg_write(client
, MT9M001_OUTPUT_CONTROL
, 0);
153 static int mt9m001_s_stream(struct v4l2_subdev
*sd
, int enable
)
155 struct i2c_client
*client
= sd
->priv
;
157 /* Switch to master "normal" mode or stop sensor readout */
158 if (reg_write(client
, MT9M001_OUTPUT_CONTROL
, enable
? 2 : 0) < 0)
163 static int mt9m001_set_bus_param(struct soc_camera_device
*icd
,
166 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
167 unsigned long width_flag
= flags
& SOCAM_DATAWIDTH_MASK
;
169 /* Only one width bit may be set */
170 if (!is_power_of_2(width_flag
))
173 if (icl
->set_bus_param
)
174 return icl
->set_bus_param(icl
, width_flag
);
177 * Without board specific bus width settings we only support the
178 * sensors native bus width
180 if (width_flag
== SOCAM_DATAWIDTH_10
)
186 static unsigned long mt9m001_query_bus_param(struct soc_camera_device
*icd
)
188 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
189 /* MT9M001 has all capture_format parameters fixed */
190 unsigned long flags
= SOCAM_PCLK_SAMPLE_FALLING
|
191 SOCAM_HSYNC_ACTIVE_HIGH
| SOCAM_VSYNC_ACTIVE_HIGH
|
192 SOCAM_DATA_ACTIVE_HIGH
| SOCAM_MASTER
;
194 if (icl
->query_bus_param
)
195 flags
|= icl
->query_bus_param(icl
) & SOCAM_DATAWIDTH_MASK
;
197 flags
|= SOCAM_DATAWIDTH_10
;
199 return soc_camera_apply_sensor_flags(icl
, flags
);
202 static int mt9m001_s_crop(struct v4l2_subdev
*sd
, struct v4l2_crop
*a
)
204 struct i2c_client
*client
= sd
->priv
;
205 struct mt9m001
*mt9m001
= to_mt9m001(client
);
206 struct v4l2_rect rect
= a
->c
;
207 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
209 const u16 hblank
= 9, vblank
= 25;
210 unsigned int total_h
;
212 if (mt9m001
->fourcc
== V4L2_PIX_FMT_SBGGR8
||
213 mt9m001
->fourcc
== V4L2_PIX_FMT_SBGGR16
)
215 * Bayer format - even number of rows for simplicity,
216 * but let the user play with the top row.
218 rect
.height
= ALIGN(rect
.height
, 2);
220 /* Datasheet requirement: see register description */
221 rect
.width
= ALIGN(rect
.width
, 2);
222 rect
.left
= ALIGN(rect
.left
, 2);
224 soc_camera_limit_side(&rect
.left
, &rect
.width
,
225 MT9M001_COLUMN_SKIP
, MT9M001_MIN_WIDTH
, MT9M001_MAX_WIDTH
);
227 soc_camera_limit_side(&rect
.top
, &rect
.height
,
228 MT9M001_ROW_SKIP
, MT9M001_MIN_HEIGHT
, MT9M001_MAX_HEIGHT
);
230 total_h
= rect
.height
+ mt9m001
->y_skip_top
+ vblank
;
232 /* Blanking and start values - default... */
233 ret
= reg_write(client
, MT9M001_HORIZONTAL_BLANKING
, hblank
);
235 ret
= reg_write(client
, MT9M001_VERTICAL_BLANKING
, vblank
);
238 * The caller provides a supported format, as verified per
239 * call to icd->try_fmt()
242 ret
= reg_write(client
, MT9M001_COLUMN_START
, rect
.left
);
244 ret
= reg_write(client
, MT9M001_ROW_START
, rect
.top
);
246 ret
= reg_write(client
, MT9M001_WINDOW_WIDTH
, rect
.width
- 1);
248 ret
= reg_write(client
, MT9M001_WINDOW_HEIGHT
,
249 rect
.height
+ mt9m001
->y_skip_top
- 1);
250 if (!ret
&& mt9m001
->autoexposure
) {
251 ret
= reg_write(client
, MT9M001_SHUTTER_WIDTH
, total_h
);
253 const struct v4l2_queryctrl
*qctrl
=
254 soc_camera_find_qctrl(icd
->ops
,
256 mt9m001
->exposure
= (524 + (total_h
- 1) *
257 (qctrl
->maximum
- qctrl
->minimum
)) /
258 1048 + qctrl
->minimum
;
263 mt9m001
->rect
= rect
;
268 static int mt9m001_g_crop(struct v4l2_subdev
*sd
, struct v4l2_crop
*a
)
270 struct i2c_client
*client
= sd
->priv
;
271 struct mt9m001
*mt9m001
= to_mt9m001(client
);
273 a
->c
= mt9m001
->rect
;
274 a
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
279 static int mt9m001_cropcap(struct v4l2_subdev
*sd
, struct v4l2_cropcap
*a
)
281 a
->bounds
.left
= MT9M001_COLUMN_SKIP
;
282 a
->bounds
.top
= MT9M001_ROW_SKIP
;
283 a
->bounds
.width
= MT9M001_MAX_WIDTH
;
284 a
->bounds
.height
= MT9M001_MAX_HEIGHT
;
285 a
->defrect
= a
->bounds
;
286 a
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
287 a
->pixelaspect
.numerator
= 1;
288 a
->pixelaspect
.denominator
= 1;
293 static int mt9m001_g_fmt(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
295 struct i2c_client
*client
= sd
->priv
;
296 struct mt9m001
*mt9m001
= to_mt9m001(client
);
297 struct v4l2_pix_format
*pix
= &f
->fmt
.pix
;
299 pix
->width
= mt9m001
->rect
.width
;
300 pix
->height
= mt9m001
->rect
.height
;
301 pix
->pixelformat
= mt9m001
->fourcc
;
302 pix
->field
= V4L2_FIELD_NONE
;
303 pix
->colorspace
= V4L2_COLORSPACE_SRGB
;
308 static int mt9m001_s_fmt(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
310 struct i2c_client
*client
= sd
->priv
;
311 struct mt9m001
*mt9m001
= to_mt9m001(client
);
312 struct v4l2_pix_format
*pix
= &f
->fmt
.pix
;
313 struct v4l2_crop a
= {
315 .left
= mt9m001
->rect
.left
,
316 .top
= mt9m001
->rect
.top
,
318 .height
= pix
->height
,
323 /* No support for scaling so far, just crop. TODO: use skipping */
324 ret
= mt9m001_s_crop(sd
, &a
);
326 pix
->width
= mt9m001
->rect
.width
;
327 pix
->height
= mt9m001
->rect
.height
;
328 mt9m001
->fourcc
= pix
->pixelformat
;
334 static int mt9m001_try_fmt(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
336 struct i2c_client
*client
= sd
->priv
;
337 struct mt9m001
*mt9m001
= to_mt9m001(client
);
338 struct v4l2_pix_format
*pix
= &f
->fmt
.pix
;
340 v4l_bound_align_image(&pix
->width
, MT9M001_MIN_WIDTH
,
341 MT9M001_MAX_WIDTH
, 1,
342 &pix
->height
, MT9M001_MIN_HEIGHT
+ mt9m001
->y_skip_top
,
343 MT9M001_MAX_HEIGHT
+ mt9m001
->y_skip_top
, 0, 0);
345 if (pix
->pixelformat
== V4L2_PIX_FMT_SBGGR8
||
346 pix
->pixelformat
== V4L2_PIX_FMT_SBGGR16
)
347 pix
->height
= ALIGN(pix
->height
- 1, 2);
352 static int mt9m001_g_chip_ident(struct v4l2_subdev
*sd
,
353 struct v4l2_dbg_chip_ident
*id
)
355 struct i2c_client
*client
= sd
->priv
;
356 struct mt9m001
*mt9m001
= to_mt9m001(client
);
358 if (id
->match
.type
!= V4L2_CHIP_MATCH_I2C_ADDR
)
361 if (id
->match
.addr
!= client
->addr
)
364 id
->ident
= mt9m001
->model
;
370 #ifdef CONFIG_VIDEO_ADV_DEBUG
371 static int mt9m001_g_register(struct v4l2_subdev
*sd
,
372 struct v4l2_dbg_register
*reg
)
374 struct i2c_client
*client
= sd
->priv
;
376 if (reg
->match
.type
!= V4L2_CHIP_MATCH_I2C_ADDR
|| reg
->reg
> 0xff)
379 if (reg
->match
.addr
!= client
->addr
)
383 reg
->val
= reg_read(client
, reg
->reg
);
385 if (reg
->val
> 0xffff)
391 static int mt9m001_s_register(struct v4l2_subdev
*sd
,
392 struct v4l2_dbg_register
*reg
)
394 struct i2c_client
*client
= sd
->priv
;
396 if (reg
->match
.type
!= V4L2_CHIP_MATCH_I2C_ADDR
|| reg
->reg
> 0xff)
399 if (reg
->match
.addr
!= client
->addr
)
402 if (reg_write(client
, reg
->reg
, reg
->val
) < 0)
409 static const struct v4l2_queryctrl mt9m001_controls
[] = {
411 .id
= V4L2_CID_VFLIP
,
412 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
413 .name
= "Flip Vertically",
420 .type
= V4L2_CTRL_TYPE_INTEGER
,
426 .flags
= V4L2_CTRL_FLAG_SLIDER
,
428 .id
= V4L2_CID_EXPOSURE
,
429 .type
= V4L2_CTRL_TYPE_INTEGER
,
434 .default_value
= 255,
435 .flags
= V4L2_CTRL_FLAG_SLIDER
,
437 .id
= V4L2_CID_EXPOSURE_AUTO
,
438 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
439 .name
= "Automatic Exposure",
447 static struct soc_camera_ops mt9m001_ops
= {
448 .set_bus_param
= mt9m001_set_bus_param
,
449 .query_bus_param
= mt9m001_query_bus_param
,
450 .controls
= mt9m001_controls
,
451 .num_controls
= ARRAY_SIZE(mt9m001_controls
),
454 static int mt9m001_g_ctrl(struct v4l2_subdev
*sd
, struct v4l2_control
*ctrl
)
456 struct i2c_client
*client
= sd
->priv
;
457 struct mt9m001
*mt9m001
= to_mt9m001(client
);
462 data
= reg_read(client
, MT9M001_READ_OPTIONS2
);
465 ctrl
->value
= !!(data
& 0x8000);
467 case V4L2_CID_EXPOSURE_AUTO
:
468 ctrl
->value
= mt9m001
->autoexposure
;
471 ctrl
->value
= mt9m001
->gain
;
473 case V4L2_CID_EXPOSURE
:
474 ctrl
->value
= mt9m001
->exposure
;
480 static int mt9m001_s_ctrl(struct v4l2_subdev
*sd
, struct v4l2_control
*ctrl
)
482 struct i2c_client
*client
= sd
->priv
;
483 struct mt9m001
*mt9m001
= to_mt9m001(client
);
484 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
485 const struct v4l2_queryctrl
*qctrl
;
488 qctrl
= soc_camera_find_qctrl(&mt9m001_ops
, ctrl
->id
);
496 data
= reg_set(client
, MT9M001_READ_OPTIONS2
, 0x8000);
498 data
= reg_clear(client
, MT9M001_READ_OPTIONS2
, 0x8000);
503 if (ctrl
->value
> qctrl
->maximum
|| ctrl
->value
< qctrl
->minimum
)
505 /* See Datasheet Table 7, Gain settings. */
506 if (ctrl
->value
<= qctrl
->default_value
) {
507 /* Pack it into 0..1 step 0.125, register values 0..8 */
508 unsigned long range
= qctrl
->default_value
- qctrl
->minimum
;
509 data
= ((ctrl
->value
- qctrl
->minimum
) * 8 + range
/ 2) / range
;
511 dev_dbg(&client
->dev
, "Setting gain %d\n", data
);
512 data
= reg_write(client
, MT9M001_GLOBAL_GAIN
, data
);
516 /* Pack it into 1.125..15 variable step, register values 9..67 */
517 /* We assume qctrl->maximum - qctrl->default_value - 1 > 0 */
518 unsigned long range
= qctrl
->maximum
- qctrl
->default_value
- 1;
519 unsigned long gain
= ((ctrl
->value
- qctrl
->default_value
- 1) *
520 111 + range
/ 2) / range
+ 9;
525 data
= ((gain
- 32) * 16 + 16) / 32 + 80;
527 data
= ((gain
- 64) * 7 + 28) / 56 + 96;
529 dev_dbg(&client
->dev
, "Setting gain from %d to %d\n",
530 reg_read(client
, MT9M001_GLOBAL_GAIN
), data
);
531 data
= reg_write(client
, MT9M001_GLOBAL_GAIN
, data
);
537 mt9m001
->gain
= ctrl
->value
;
539 case V4L2_CID_EXPOSURE
:
540 /* mt9m001 has maximum == default */
541 if (ctrl
->value
> qctrl
->maximum
|| ctrl
->value
< qctrl
->minimum
)
544 unsigned long range
= qctrl
->maximum
- qctrl
->minimum
;
545 unsigned long shutter
= ((ctrl
->value
- qctrl
->minimum
) * 1048 +
546 range
/ 2) / range
+ 1;
548 dev_dbg(&client
->dev
,
549 "Setting shutter width from %d to %lu\n",
550 reg_read(client
, MT9M001_SHUTTER_WIDTH
),
552 if (reg_write(client
, MT9M001_SHUTTER_WIDTH
, shutter
) < 0)
554 mt9m001
->exposure
= ctrl
->value
;
555 mt9m001
->autoexposure
= 0;
558 case V4L2_CID_EXPOSURE_AUTO
:
560 const u16 vblank
= 25;
561 unsigned int total_h
= mt9m001
->rect
.height
+
562 mt9m001
->y_skip_top
+ vblank
;
563 if (reg_write(client
, MT9M001_SHUTTER_WIDTH
,
566 qctrl
= soc_camera_find_qctrl(icd
->ops
, V4L2_CID_EXPOSURE
);
567 mt9m001
->exposure
= (524 + (total_h
- 1) *
568 (qctrl
->maximum
- qctrl
->minimum
)) /
569 1048 + qctrl
->minimum
;
570 mt9m001
->autoexposure
= 1;
572 mt9m001
->autoexposure
= 0;
579 * Interface active, can use i2c. If it fails, it can indeed mean, that
580 * this wasn't our capture interface, so, we wait for the right one
582 static int mt9m001_video_probe(struct soc_camera_device
*icd
,
583 struct i2c_client
*client
)
585 struct mt9m001
*mt9m001
= to_mt9m001(client
);
586 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
592 * We must have a parent by now. And it cannot be a wrong one.
593 * So this entire test is completely redundant.
595 if (!icd
->dev
.parent
||
596 to_soc_camera_host(icd
->dev
.parent
)->nr
!= icd
->iface
)
599 /* Enable the chip */
600 data
= reg_write(client
, MT9M001_CHIP_ENABLE
, 1);
601 dev_dbg(&client
->dev
, "write: %d\n", data
);
603 /* Read out the chip version register */
604 data
= reg_read(client
, MT9M001_CHIP_VERSION
);
606 /* must be 0x8411 or 0x8421 for colour sensor and 8431 for bw */
610 mt9m001
->model
= V4L2_IDENT_MT9M001C12ST
;
611 icd
->formats
= mt9m001_colour_formats
;
614 mt9m001
->model
= V4L2_IDENT_MT9M001C12STM
;
615 icd
->formats
= mt9m001_monochrome_formats
;
618 dev_err(&client
->dev
,
619 "No MT9M001 chip detected, register read %x\n", data
);
623 icd
->num_formats
= 0;
626 * This is a 10bit sensor, so by default we only allow 10bit.
627 * The platform may support different bus widths due to
628 * different routing of the data lines.
630 if (icl
->query_bus_param
)
631 flags
= icl
->query_bus_param(icl
);
633 flags
= SOCAM_DATAWIDTH_10
;
635 if (flags
& SOCAM_DATAWIDTH_10
)
640 if (flags
& SOCAM_DATAWIDTH_8
)
643 mt9m001
->fourcc
= icd
->formats
->fourcc
;
645 dev_info(&client
->dev
, "Detected a MT9M001 chip ID %x (%s)\n", data
,
646 data
== 0x8431 ? "C12STM" : "C12ST");
648 ret
= mt9m001_init(client
);
650 dev_err(&client
->dev
, "Failed to initialise the camera\n");
652 /* mt9m001_init() has reset the chip, returning registers to defaults */
654 mt9m001
->exposure
= 255;
659 static void mt9m001_video_remove(struct soc_camera_device
*icd
)
661 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
663 dev_dbg(&icd
->dev
, "Video removed: %p, %p\n",
664 icd
->dev
.parent
, icd
->vdev
);
669 static int mt9m001_g_skip_top_lines(struct v4l2_subdev
*sd
, u32
*lines
)
671 struct i2c_client
*client
= sd
->priv
;
672 struct mt9m001
*mt9m001
= to_mt9m001(client
);
674 *lines
= mt9m001
->y_skip_top
;
679 static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops
= {
680 .g_ctrl
= mt9m001_g_ctrl
,
681 .s_ctrl
= mt9m001_s_ctrl
,
682 .g_chip_ident
= mt9m001_g_chip_ident
,
683 #ifdef CONFIG_VIDEO_ADV_DEBUG
684 .g_register
= mt9m001_g_register
,
685 .s_register
= mt9m001_s_register
,
689 static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops
= {
690 .s_stream
= mt9m001_s_stream
,
691 .s_fmt
= mt9m001_s_fmt
,
692 .g_fmt
= mt9m001_g_fmt
,
693 .try_fmt
= mt9m001_try_fmt
,
694 .s_crop
= mt9m001_s_crop
,
695 .g_crop
= mt9m001_g_crop
,
696 .cropcap
= mt9m001_cropcap
,
699 static struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops
= {
700 .g_skip_top_lines
= mt9m001_g_skip_top_lines
,
703 static struct v4l2_subdev_ops mt9m001_subdev_ops
= {
704 .core
= &mt9m001_subdev_core_ops
,
705 .video
= &mt9m001_subdev_video_ops
,
706 .sensor
= &mt9m001_subdev_sensor_ops
,
709 static int mt9m001_probe(struct i2c_client
*client
,
710 const struct i2c_device_id
*did
)
712 struct mt9m001
*mt9m001
;
713 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
714 struct i2c_adapter
*adapter
= to_i2c_adapter(client
->dev
.parent
);
715 struct soc_camera_link
*icl
;
719 dev_err(&client
->dev
, "MT9M001: missing soc-camera data!\n");
723 icl
= to_soc_camera_link(icd
);
725 dev_err(&client
->dev
, "MT9M001 driver needs platform data\n");
729 if (!i2c_check_functionality(adapter
, I2C_FUNC_SMBUS_WORD_DATA
)) {
730 dev_warn(&adapter
->dev
,
731 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n");
735 mt9m001
= kzalloc(sizeof(struct mt9m001
), GFP_KERNEL
);
739 v4l2_i2c_subdev_init(&mt9m001
->subdev
, client
, &mt9m001_subdev_ops
);
741 /* Second stage probe - when a capture adapter is there */
742 icd
->ops
= &mt9m001_ops
;
744 mt9m001
->y_skip_top
= 0;
745 mt9m001
->rect
.left
= MT9M001_COLUMN_SKIP
;
746 mt9m001
->rect
.top
= MT9M001_ROW_SKIP
;
747 mt9m001
->rect
.width
= MT9M001_MAX_WIDTH
;
748 mt9m001
->rect
.height
= MT9M001_MAX_HEIGHT
;
751 * Simulated autoexposure. If enabled, we calculate shutter width
752 * ourselves in the driver based on vertical blanking and frame width
754 mt9m001
->autoexposure
= 1;
756 ret
= mt9m001_video_probe(icd
, client
);
759 i2c_set_clientdata(client
, NULL
);
766 static int mt9m001_remove(struct i2c_client
*client
)
768 struct mt9m001
*mt9m001
= to_mt9m001(client
);
769 struct soc_camera_device
*icd
= client
->dev
.platform_data
;
772 mt9m001_video_remove(icd
);
773 i2c_set_clientdata(client
, NULL
);
774 client
->driver
= NULL
;
780 static const struct i2c_device_id mt9m001_id
[] = {
784 MODULE_DEVICE_TABLE(i2c
, mt9m001_id
);
786 static struct i2c_driver mt9m001_i2c_driver
= {
790 .probe
= mt9m001_probe
,
791 .remove
= mt9m001_remove
,
792 .id_table
= mt9m001_id
,
795 static int __init
mt9m001_mod_init(void)
797 return i2c_add_driver(&mt9m001_i2c_driver
);
800 static void __exit
mt9m001_mod_exit(void)
802 i2c_del_driver(&mt9m001_i2c_driver
);
805 module_init(mt9m001_mod_init
);
806 module_exit(mt9m001_mod_exit
);
808 MODULE_DESCRIPTION("Micron MT9M001 Camera driver");
809 MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
810 MODULE_LICENSE("GPL");