2 * Driver for MT9T031 CMOS Image Sensor from Micron
4 * Copyright (C) 2008, Guennadi Liakhovetski, DENX Software Engineering <lg@denx.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 /* mt9t031 i2c address 0x5d
21 * The platform has to define i2c_board_info and link to it from
22 * struct soc_camera_link */
24 /* mt9t031 selected register addresses */
25 #define MT9T031_CHIP_VERSION 0x00
26 #define MT9T031_ROW_START 0x01
27 #define MT9T031_COLUMN_START 0x02
28 #define MT9T031_WINDOW_HEIGHT 0x03
29 #define MT9T031_WINDOW_WIDTH 0x04
30 #define MT9T031_HORIZONTAL_BLANKING 0x05
31 #define MT9T031_VERTICAL_BLANKING 0x06
32 #define MT9T031_OUTPUT_CONTROL 0x07
33 #define MT9T031_SHUTTER_WIDTH_UPPER 0x08
34 #define MT9T031_SHUTTER_WIDTH 0x09
35 #define MT9T031_PIXEL_CLOCK_CONTROL 0x0a
36 #define MT9T031_FRAME_RESTART 0x0b
37 #define MT9T031_SHUTTER_DELAY 0x0c
38 #define MT9T031_RESET 0x0d
39 #define MT9T031_READ_MODE_1 0x1e
40 #define MT9T031_READ_MODE_2 0x20
41 #define MT9T031_READ_MODE_3 0x21
42 #define MT9T031_ROW_ADDRESS_MODE 0x22
43 #define MT9T031_COLUMN_ADDRESS_MODE 0x23
44 #define MT9T031_GLOBAL_GAIN 0x35
45 #define MT9T031_CHIP_ENABLE 0xF8
47 #define MT9T031_MAX_HEIGHT 1536
48 #define MT9T031_MAX_WIDTH 2048
49 #define MT9T031_MIN_HEIGHT 2
50 #define MT9T031_MIN_WIDTH 18
51 #define MT9T031_HORIZONTAL_BLANK 142
52 #define MT9T031_VERTICAL_BLANK 25
53 #define MT9T031_COLUMN_SKIP 32
54 #define MT9T031_ROW_SKIP 20
56 #define MT9T031_BUS_PARAM (SOCAM_PCLK_SAMPLE_RISING | \
57 SOCAM_PCLK_SAMPLE_FALLING | SOCAM_HSYNC_ACTIVE_HIGH | \
58 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_HIGH | \
59 SOCAM_MASTER | SOCAM_DATAWIDTH_10)
61 static const struct soc_camera_data_format mt9t031_colour_formats[] = {
63 .name = "Bayer (sRGB) 10 bit",
65 .fourcc = V4L2_PIX_FMT_SGRBG10,
66 .colorspace = V4L2_COLORSPACE_SRGB,
71 struct v4l2_subdev subdev;
72 struct v4l2_rect rect; /* Sensor window */
73 int model; /* V4L2_IDENT_MT9T031* codes from v4l2-chip-ident.h */
76 unsigned char autoexposure;
79 static struct mt9t031 *to_mt9t031(const struct i2c_client *client)
81 return container_of(i2c_get_clientdata(client), struct mt9t031, subdev);
84 static int reg_read(struct i2c_client *client, const u8 reg)
86 s32 data = i2c_smbus_read_word_data(client, reg);
87 return data < 0 ? data : swab16(data);
90 static int reg_write(struct i2c_client *client, const u8 reg,
93 return i2c_smbus_write_word_data(client, reg, swab16(data));
96 static int reg_set(struct i2c_client *client, const u8 reg,
101 ret = reg_read(client, reg);
104 return reg_write(client, reg, ret | data);
107 static int reg_clear(struct i2c_client *client, const u8 reg,
112 ret = reg_read(client, reg);
115 return reg_write(client, reg, ret & ~data);
118 static int set_shutter(struct i2c_client *client, const u32 data)
122 ret = reg_write(client, MT9T031_SHUTTER_WIDTH_UPPER, data >> 16);
125 ret = reg_write(client, MT9T031_SHUTTER_WIDTH, data & 0xffff);
130 static int get_shutter(struct i2c_client *client, u32 *data)
134 ret = reg_read(client, MT9T031_SHUTTER_WIDTH_UPPER);
138 ret = reg_read(client, MT9T031_SHUTTER_WIDTH);
139 *data |= ret & 0xffff;
141 return ret < 0 ? ret : 0;
144 static int mt9t031_idle(struct i2c_client *client)
148 /* Disable chip output, synchronous option update */
149 ret = reg_write(client, MT9T031_RESET, 1);
151 ret = reg_write(client, MT9T031_RESET, 0);
153 ret = reg_clear(client, MT9T031_OUTPUT_CONTROL, 2);
155 return ret >= 0 ? 0 : -EIO;
158 static int mt9t031_disable(struct i2c_client *client)
160 /* Disable the chip */
161 reg_clear(client, MT9T031_OUTPUT_CONTROL, 2);
166 static int mt9t031_init(struct soc_camera_device *icd)
168 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
170 return mt9t031_idle(client);
173 static int mt9t031_release(struct soc_camera_device *icd)
175 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
177 return mt9t031_disable(client);
180 static int mt9t031_s_stream(struct v4l2_subdev *sd, int enable)
182 struct i2c_client *client = sd->priv;
186 /* Switch to master "normal" mode */
187 ret = reg_set(client, MT9T031_OUTPUT_CONTROL, 2);
189 /* Stop sensor readout */
190 ret = reg_clear(client, MT9T031_OUTPUT_CONTROL, 2);
198 static int mt9t031_set_bus_param(struct soc_camera_device *icd,
201 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
203 /* The caller should have queried our parameters, check anyway */
204 if (flags & ~MT9T031_BUS_PARAM)
207 if (flags & SOCAM_PCLK_SAMPLE_FALLING)
208 reg_clear(client, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000);
210 reg_set(client, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000);
215 static unsigned long mt9t031_query_bus_param(struct soc_camera_device *icd)
217 struct soc_camera_link *icl = to_soc_camera_link(icd);
219 return soc_camera_apply_sensor_flags(icl, MT9T031_BUS_PARAM);
222 /* target must be _even_ */
223 static u16 mt9t031_skip(s32 *source, s32 target, s32 max)
227 if (*source < target + target / 2) {
232 skip = min(max, *source + target / 2) / target;
235 *source = target * skip;
240 /* rect is the sensor rectangle, the caller guarantees parameter validity */
241 static int mt9t031_set_params(struct soc_camera_device *icd,
242 struct v4l2_rect *rect, u16 xskip, u16 yskip)
244 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
245 struct mt9t031 *mt9t031 = to_mt9t031(client);
248 const u16 hblank = MT9T031_HORIZONTAL_BLANK,
249 vblank = MT9T031_VERTICAL_BLANK;
251 xbin = min(xskip, (u16)3);
252 ybin = min(yskip, (u16)3);
255 * Could just do roundup(rect->left, [xy]bin * 2); but this is cheaper.
256 * There is always a valid suitably aligned value. The worst case is
257 * xbin = 3, width = 2048. Then we will start at 36, the last read out
258 * pixel will be 2083, which is < 2085 - first black pixel.
260 * MT9T031 datasheet imposes window left border alignment, depending on
261 * the selected xskip. Failing to conform to this requirement produces
262 * dark horizontal stripes in the image. However, even obeying to this
263 * requirement doesn't eliminate the stripes in all configurations. They
264 * appear "locally reproducibly," but can differ between tests under
265 * different lighting conditions.
275 rect->left = rect->left > roundup(MT9T031_COLUMN_SKIP, 6) ?
276 (rect->left / 6) * 6 : roundup(MT9T031_COLUMN_SKIP, 6);
281 dev_dbg(&client->dev, "skip %u:%u, rect %ux%u@%u:%u\n",
282 xskip, yskip, rect->width, rect->height, rect->left, rect->top);
284 /* Disable register update, reconfigure atomically */
285 ret = reg_set(client, MT9T031_OUTPUT_CONTROL, 1);
289 /* Blanking and start values - default... */
290 ret = reg_write(client, MT9T031_HORIZONTAL_BLANKING, hblank);
292 ret = reg_write(client, MT9T031_VERTICAL_BLANKING, vblank);
294 if (yskip != mt9t031->yskip || xskip != mt9t031->xskip) {
295 /* Binning, skipping */
297 ret = reg_write(client, MT9T031_COLUMN_ADDRESS_MODE,
298 ((xbin - 1) << 4) | (xskip - 1));
300 ret = reg_write(client, MT9T031_ROW_ADDRESS_MODE,
301 ((ybin - 1) << 4) | (yskip - 1));
303 dev_dbg(&client->dev, "new physical left %u, top %u\n",
304 rect->left, rect->top);
306 /* The caller provides a supported format, as guaranteed by
307 * icd->try_fmt_cap(), soc_camera_s_crop() and soc_camera_cropcap() */
309 ret = reg_write(client, MT9T031_COLUMN_START, rect->left);
311 ret = reg_write(client, MT9T031_ROW_START, rect->top);
313 ret = reg_write(client, MT9T031_WINDOW_WIDTH, rect->width - 1);
315 ret = reg_write(client, MT9T031_WINDOW_HEIGHT,
316 rect->height + icd->y_skip_top - 1);
317 if (ret >= 0 && mt9t031->autoexposure) {
318 ret = set_shutter(client,
319 rect->height + icd->y_skip_top + vblank);
321 const u32 shutter_max = MT9T031_MAX_HEIGHT + vblank;
322 const struct v4l2_queryctrl *qctrl =
323 soc_camera_find_qctrl(icd->ops,
325 icd->exposure = (shutter_max / 2 + (rect->height +
326 icd->y_skip_top + vblank - 1) *
327 (qctrl->maximum - qctrl->minimum)) /
328 shutter_max + qctrl->minimum;
332 /* Re-enable register update, commit all changes */
334 ret = reg_clear(client, MT9T031_OUTPUT_CONTROL, 1);
337 mt9t031->rect = *rect;
338 mt9t031->xskip = xskip;
339 mt9t031->yskip = yskip;
342 return ret < 0 ? ret : 0;
345 static int mt9t031_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
347 struct v4l2_rect rect = a->c;
348 struct i2c_client *client = sd->priv;
349 struct mt9t031 *mt9t031 = to_mt9t031(client);
350 struct soc_camera_device *icd = client->dev.platform_data;
352 rect.width = ALIGN(rect.width, 2);
353 rect.height = ALIGN(rect.height, 2);
355 soc_camera_limit_side(&rect.left, &rect.width,
356 MT9T031_COLUMN_SKIP, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH);
358 soc_camera_limit_side(&rect.top, &rect.height,
359 MT9T031_ROW_SKIP, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT);
361 return mt9t031_set_params(icd, &rect, mt9t031->xskip, mt9t031->yskip);
364 static int mt9t031_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
366 struct i2c_client *client = sd->priv;
367 struct mt9t031 *mt9t031 = to_mt9t031(client);
369 a->c = mt9t031->rect;
370 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
375 static int mt9t031_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
377 a->bounds.left = MT9T031_COLUMN_SKIP;
378 a->bounds.top = MT9T031_ROW_SKIP;
379 a->bounds.width = MT9T031_MAX_WIDTH;
380 a->bounds.height = MT9T031_MAX_HEIGHT;
381 a->defrect = a->bounds;
382 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
383 a->pixelaspect.numerator = 1;
384 a->pixelaspect.denominator = 1;
389 static int mt9t031_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
391 struct i2c_client *client = sd->priv;
392 struct mt9t031 *mt9t031 = to_mt9t031(client);
393 struct v4l2_pix_format *pix = &f->fmt.pix;
395 pix->width = mt9t031->rect.width / mt9t031->xskip;
396 pix->height = mt9t031->rect.height / mt9t031->yskip;
397 pix->pixelformat = V4L2_PIX_FMT_SGRBG10;
398 pix->field = V4L2_FIELD_NONE;
399 pix->colorspace = V4L2_COLORSPACE_SRGB;
404 static int mt9t031_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
406 struct i2c_client *client = sd->priv;
407 struct mt9t031 *mt9t031 = to_mt9t031(client);
408 struct soc_camera_device *icd = client->dev.platform_data;
409 struct v4l2_pix_format *pix = &f->fmt.pix;
411 struct v4l2_rect rect = mt9t031->rect;
414 * try_fmt has put width and height within limits.
415 * S_FMT: use binning and skipping for scaling
417 xskip = mt9t031_skip(&rect.width, pix->width, MT9T031_MAX_WIDTH);
418 yskip = mt9t031_skip(&rect.height, pix->height, MT9T031_MAX_HEIGHT);
420 /* mt9t031_set_params() doesn't change width and height */
421 return mt9t031_set_params(icd, &rect, xskip, yskip);
425 * If a user window larger than sensor window is requested, we'll increase the
428 static int mt9t031_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
430 struct v4l2_pix_format *pix = &f->fmt.pix;
432 v4l_bound_align_image(
433 &pix->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1,
434 &pix->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0);
439 static int mt9t031_g_chip_ident(struct v4l2_subdev *sd,
440 struct v4l2_dbg_chip_ident *id)
442 struct i2c_client *client = sd->priv;
443 struct mt9t031 *mt9t031 = to_mt9t031(client);
445 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
448 if (id->match.addr != client->addr)
451 id->ident = mt9t031->model;
457 #ifdef CONFIG_VIDEO_ADV_DEBUG
458 static int mt9t031_g_register(struct v4l2_subdev *sd,
459 struct v4l2_dbg_register *reg)
461 struct i2c_client *client = sd->priv;
463 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
466 if (reg->match.addr != client->addr)
469 reg->val = reg_read(client, reg->reg);
471 if (reg->val > 0xffff)
477 static int mt9t031_s_register(struct v4l2_subdev *sd,
478 struct v4l2_dbg_register *reg)
480 struct i2c_client *client = sd->priv;
482 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
485 if (reg->match.addr != client->addr)
488 if (reg_write(client, reg->reg, reg->val) < 0)
495 static const struct v4l2_queryctrl mt9t031_controls[] = {
497 .id = V4L2_CID_VFLIP,
498 .type = V4L2_CTRL_TYPE_BOOLEAN,
499 .name = "Flip Vertically",
505 .id = V4L2_CID_HFLIP,
506 .type = V4L2_CTRL_TYPE_BOOLEAN,
507 .name = "Flip Horizontally",
514 .type = V4L2_CTRL_TYPE_INTEGER,
520 .flags = V4L2_CTRL_FLAG_SLIDER,
522 .id = V4L2_CID_EXPOSURE,
523 .type = V4L2_CTRL_TYPE_INTEGER,
528 .default_value = 255,
529 .flags = V4L2_CTRL_FLAG_SLIDER,
531 .id = V4L2_CID_EXPOSURE_AUTO,
532 .type = V4L2_CTRL_TYPE_BOOLEAN,
533 .name = "Automatic Exposure",
541 static struct soc_camera_ops mt9t031_ops = {
542 .init = mt9t031_init,
543 .release = mt9t031_release,
544 .set_bus_param = mt9t031_set_bus_param,
545 .query_bus_param = mt9t031_query_bus_param,
546 .controls = mt9t031_controls,
547 .num_controls = ARRAY_SIZE(mt9t031_controls),
550 static int mt9t031_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
552 struct i2c_client *client = sd->priv;
553 struct mt9t031 *mt9t031 = to_mt9t031(client);
558 data = reg_read(client, MT9T031_READ_MODE_2);
561 ctrl->value = !!(data & 0x8000);
564 data = reg_read(client, MT9T031_READ_MODE_2);
567 ctrl->value = !!(data & 0x4000);
569 case V4L2_CID_EXPOSURE_AUTO:
570 ctrl->value = mt9t031->autoexposure;
576 static int mt9t031_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
578 struct i2c_client *client = sd->priv;
579 struct mt9t031 *mt9t031 = to_mt9t031(client);
580 struct soc_camera_device *icd = client->dev.platform_data;
581 const struct v4l2_queryctrl *qctrl;
584 qctrl = soc_camera_find_qctrl(&mt9t031_ops, ctrl->id);
592 data = reg_set(client, MT9T031_READ_MODE_2, 0x8000);
594 data = reg_clear(client, MT9T031_READ_MODE_2, 0x8000);
600 data = reg_set(client, MT9T031_READ_MODE_2, 0x4000);
602 data = reg_clear(client, MT9T031_READ_MODE_2, 0x4000);
607 if (ctrl->value > qctrl->maximum || ctrl->value < qctrl->minimum)
609 /* See Datasheet Table 7, Gain settings. */
610 if (ctrl->value <= qctrl->default_value) {
611 /* Pack it into 0..1 step 0.125, register values 0..8 */
612 unsigned long range = qctrl->default_value - qctrl->minimum;
613 data = ((ctrl->value - qctrl->minimum) * 8 + range / 2) / range;
615 dev_dbg(&client->dev, "Setting gain %d\n", data);
616 data = reg_write(client, MT9T031_GLOBAL_GAIN, data);
620 /* Pack it into 1.125..128 variable step, register values 9..0x7860 */
621 /* We assume qctrl->maximum - qctrl->default_value - 1 > 0 */
622 unsigned long range = qctrl->maximum - qctrl->default_value - 1;
623 /* calculated gain: map 65..127 to 9..1024 step 0.125 */
624 unsigned long gain = ((ctrl->value - qctrl->default_value - 1) *
625 1015 + range / 2) / range + 9;
627 if (gain <= 32) /* calculated gain 9..32 -> 9..32 */
629 else if (gain <= 64) /* calculated gain 33..64 -> 0x51..0x60 */
630 data = ((gain - 32) * 16 + 16) / 32 + 80;
632 /* calculated gain 65..1024 -> (1..120) << 8 + 0x60 */
633 data = (((gain - 64 + 7) * 32) & 0xff00) | 0x60;
635 dev_dbg(&client->dev, "Set gain from 0x%x to 0x%x\n",
636 reg_read(client, MT9T031_GLOBAL_GAIN), data);
637 data = reg_write(client, MT9T031_GLOBAL_GAIN, data);
643 icd->gain = ctrl->value;
645 case V4L2_CID_EXPOSURE:
646 /* mt9t031 has maximum == default */
647 if (ctrl->value > qctrl->maximum || ctrl->value < qctrl->minimum)
650 const unsigned long range = qctrl->maximum - qctrl->minimum;
651 const u32 shutter = ((ctrl->value - qctrl->minimum) * 1048 +
652 range / 2) / range + 1;
655 get_shutter(client, &old);
656 dev_dbg(&client->dev, "Set shutter from %u to %u\n",
658 if (set_shutter(client, shutter) < 0)
660 icd->exposure = ctrl->value;
661 mt9t031->autoexposure = 0;
664 case V4L2_CID_EXPOSURE_AUTO:
666 const u16 vblank = MT9T031_VERTICAL_BLANK;
667 const u32 shutter_max = MT9T031_MAX_HEIGHT + vblank;
668 if (set_shutter(client, mt9t031->rect.height +
669 icd->y_skip_top + vblank) < 0)
671 qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE);
672 icd->exposure = (shutter_max / 2 +
673 (mt9t031->rect.height +
674 icd->y_skip_top + vblank - 1) *
675 (qctrl->maximum - qctrl->minimum)) /
676 shutter_max + qctrl->minimum;
677 mt9t031->autoexposure = 1;
679 mt9t031->autoexposure = 0;
685 /* Interface active, can use i2c. If it fails, it can indeed mean, that
686 * this wasn't our capture interface, so, we wait for the right one */
687 static int mt9t031_video_probe(struct i2c_client *client)
689 struct soc_camera_device *icd = client->dev.platform_data;
690 struct mt9t031 *mt9t031 = to_mt9t031(client);
693 /* Enable the chip */
694 data = reg_write(client, MT9T031_CHIP_ENABLE, 1);
695 dev_dbg(&client->dev, "write: %d\n", data);
697 /* Read out the chip version register */
698 data = reg_read(client, MT9T031_CHIP_VERSION);
702 mt9t031->model = V4L2_IDENT_MT9T031;
703 icd->formats = mt9t031_colour_formats;
704 icd->num_formats = ARRAY_SIZE(mt9t031_colour_formats);
707 dev_err(&client->dev,
708 "No MT9T031 chip detected, register read %x\n", data);
712 dev_info(&client->dev, "Detected a MT9T031 chip ID %x\n", data);
717 static struct v4l2_subdev_core_ops mt9t031_subdev_core_ops = {
718 .g_ctrl = mt9t031_g_ctrl,
719 .s_ctrl = mt9t031_s_ctrl,
720 .g_chip_ident = mt9t031_g_chip_ident,
721 #ifdef CONFIG_VIDEO_ADV_DEBUG
722 .g_register = mt9t031_g_register,
723 .s_register = mt9t031_s_register,
727 static struct v4l2_subdev_video_ops mt9t031_subdev_video_ops = {
728 .s_stream = mt9t031_s_stream,
729 .s_fmt = mt9t031_s_fmt,
730 .g_fmt = mt9t031_g_fmt,
731 .try_fmt = mt9t031_try_fmt,
732 .s_crop = mt9t031_s_crop,
733 .g_crop = mt9t031_g_crop,
734 .cropcap = mt9t031_cropcap,
737 static struct v4l2_subdev_ops mt9t031_subdev_ops = {
738 .core = &mt9t031_subdev_core_ops,
739 .video = &mt9t031_subdev_video_ops,
742 static int mt9t031_probe(struct i2c_client *client,
743 const struct i2c_device_id *did)
745 struct mt9t031 *mt9t031;
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, "MT9T031: missing soc-camera data!\n");
756 icl = to_soc_camera_link(icd);
758 dev_err(&client->dev, "MT9T031 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 mt9t031 = kzalloc(sizeof(struct mt9t031), GFP_KERNEL);
772 v4l2_i2c_subdev_init(&mt9t031->subdev, client, &mt9t031_subdev_ops);
774 /* Second stage probe - when a capture adapter is there */
775 icd->ops = &mt9t031_ops;
778 mt9t031->rect.left = MT9T031_COLUMN_SKIP;
779 mt9t031->rect.top = MT9T031_ROW_SKIP;
780 mt9t031->rect.width = MT9T031_MAX_WIDTH;
781 mt9t031->rect.height = MT9T031_MAX_HEIGHT;
783 /* Simulated autoexposure. If enabled, we calculate shutter width
784 * ourselves in the driver based on vertical blanking and frame width */
785 mt9t031->autoexposure = 1;
790 mt9t031_idle(client);
792 ret = mt9t031_video_probe(client);
794 mt9t031_disable(client);
798 i2c_set_clientdata(client, NULL);
805 static int mt9t031_remove(struct i2c_client *client)
807 struct mt9t031 *mt9t031 = to_mt9t031(client);
808 struct soc_camera_device *icd = client->dev.platform_data;
811 i2c_set_clientdata(client, NULL);
812 client->driver = NULL;
818 static const struct i2c_device_id mt9t031_id[] = {
822 MODULE_DEVICE_TABLE(i2c, mt9t031_id);
824 static struct i2c_driver mt9t031_i2c_driver = {
828 .probe = mt9t031_probe,
829 .remove = mt9t031_remove,
830 .id_table = mt9t031_id,
833 static int __init mt9t031_mod_init(void)
835 return i2c_add_driver(&mt9t031_i2c_driver);
838 static void __exit mt9t031_mod_exit(void)
840 i2c_del_driver(&mt9t031_i2c_driver);
843 module_init(mt9t031_mod_init);
844 module_exit(mt9t031_mod_exit);
846 MODULE_DESCRIPTION("Micron MT9T031 Camera driver");
847 MODULE_AUTHOR("Guennadi Liakhovetski <lg@denx.de>");
848 MODULE_LICENSE("GPL v2");