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/soc_camera.h>
17 #include <media/soc_mediabus.h>
18 #include <media/v4l2-subdev.h>
19 #include <media/v4l2-chip-ident.h>
20 #include <media/v4l2-ctrls.h>
23 * mt9m001 i2c address 0x5d
24 * The platform has to define ctruct i2c_board_info objects and link to them
25 * from struct soc_camera_link
28 /* mt9m001 selected register addresses */
29 #define MT9M001_CHIP_VERSION 0x00
30 #define MT9M001_ROW_START 0x01
31 #define MT9M001_COLUMN_START 0x02
32 #define MT9M001_WINDOW_HEIGHT 0x03
33 #define MT9M001_WINDOW_WIDTH 0x04
34 #define MT9M001_HORIZONTAL_BLANKING 0x05
35 #define MT9M001_VERTICAL_BLANKING 0x06
36 #define MT9M001_OUTPUT_CONTROL 0x07
37 #define MT9M001_SHUTTER_WIDTH 0x09
38 #define MT9M001_FRAME_RESTART 0x0b
39 #define MT9M001_SHUTTER_DELAY 0x0c
40 #define MT9M001_RESET 0x0d
41 #define MT9M001_READ_OPTIONS1 0x1e
42 #define MT9M001_READ_OPTIONS2 0x20
43 #define MT9M001_GLOBAL_GAIN 0x35
44 #define MT9M001_CHIP_ENABLE 0xF1
46 #define MT9M001_MAX_WIDTH 1280
47 #define MT9M001_MAX_HEIGHT 1024
48 #define MT9M001_MIN_WIDTH 48
49 #define MT9M001_MIN_HEIGHT 32
50 #define MT9M001_COLUMN_SKIP 20
51 #define MT9M001_ROW_SKIP 12
53 /* MT9M001 has only one fixed colorspace per pixelcode */
54 struct mt9m001_datafmt {
55 enum v4l2_mbus_pixelcode code;
56 enum v4l2_colorspace colorspace;
59 /* Find a data format by a pixel code in an array */
60 static const struct mt9m001_datafmt *mt9m001_find_datafmt(
61 enum v4l2_mbus_pixelcode code, const struct mt9m001_datafmt *fmt,
65 for (i = 0; i < n; i++)
66 if (fmt[i].code == code)
72 static const struct mt9m001_datafmt mt9m001_colour_fmts[] = {
74 * Order important: first natively supported,
75 * second supported with a GPIO extender
77 {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
78 {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
81 static const struct mt9m001_datafmt mt9m001_monochrome_fmts[] = {
82 /* Order important - see above */
83 {V4L2_MBUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG},
84 {V4L2_MBUS_FMT_Y8_1X8, V4L2_COLORSPACE_JPEG},
88 struct v4l2_subdev subdev;
89 struct v4l2_ctrl_handler hdl;
91 /* exposure/auto-exposure cluster */
92 struct v4l2_ctrl *autoexposure;
93 struct v4l2_ctrl *exposure;
95 struct v4l2_rect rect; /* Sensor window */
96 const struct mt9m001_datafmt *fmt;
97 const struct mt9m001_datafmt *fmts;
99 int model; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */
100 unsigned int total_h;
101 unsigned short y_skip_top; /* Lines to skip at the top */
104 static struct mt9m001 *to_mt9m001(const struct i2c_client *client)
106 return container_of(i2c_get_clientdata(client), struct mt9m001, subdev);
109 static int reg_read(struct i2c_client *client, const u8 reg)
111 s32 data = i2c_smbus_read_word_data(client, reg);
112 return data < 0 ? data : swab16(data);
115 static int reg_write(struct i2c_client *client, const u8 reg,
118 return i2c_smbus_write_word_data(client, reg, swab16(data));
121 static int reg_set(struct i2c_client *client, const u8 reg,
126 ret = reg_read(client, reg);
129 return reg_write(client, reg, ret | data);
132 static int reg_clear(struct i2c_client *client, const u8 reg,
137 ret = reg_read(client, reg);
140 return reg_write(client, reg, ret & ~data);
143 static int mt9m001_init(struct i2c_client *client)
147 dev_dbg(&client->dev, "%s\n", __func__);
150 * We don't know, whether platform provides reset, issue a soft reset
151 * too. This returns all registers to their default values.
153 ret = reg_write(client, MT9M001_RESET, 1);
155 ret = reg_write(client, MT9M001_RESET, 0);
157 /* Disable chip, synchronous option update */
159 ret = reg_write(client, MT9M001_OUTPUT_CONTROL, 0);
164 static int mt9m001_s_stream(struct v4l2_subdev *sd, int enable)
166 struct i2c_client *client = v4l2_get_subdevdata(sd);
168 /* Switch to master "normal" mode or stop sensor readout */
169 if (reg_write(client, MT9M001_OUTPUT_CONTROL, enable ? 2 : 0) < 0)
174 static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
176 struct i2c_client *client = v4l2_get_subdevdata(sd);
177 struct mt9m001 *mt9m001 = to_mt9m001(client);
178 struct v4l2_rect rect = a->c;
180 const u16 hblank = 9, vblank = 25;
182 if (mt9m001->fmts == mt9m001_colour_fmts)
184 * Bayer format - even number of rows for simplicity,
185 * but let the user play with the top row.
187 rect.height = ALIGN(rect.height, 2);
189 /* Datasheet requirement: see register description */
190 rect.width = ALIGN(rect.width, 2);
191 rect.left = ALIGN(rect.left, 2);
193 soc_camera_limit_side(&rect.left, &rect.width,
194 MT9M001_COLUMN_SKIP, MT9M001_MIN_WIDTH, MT9M001_MAX_WIDTH);
196 soc_camera_limit_side(&rect.top, &rect.height,
197 MT9M001_ROW_SKIP, MT9M001_MIN_HEIGHT, MT9M001_MAX_HEIGHT);
199 mt9m001->total_h = rect.height + mt9m001->y_skip_top + vblank;
201 /* Blanking and start values - default... */
202 ret = reg_write(client, MT9M001_HORIZONTAL_BLANKING, hblank);
204 ret = reg_write(client, MT9M001_VERTICAL_BLANKING, vblank);
207 * The caller provides a supported format, as verified per
208 * call to icd->try_fmt()
211 ret = reg_write(client, MT9M001_COLUMN_START, rect.left);
213 ret = reg_write(client, MT9M001_ROW_START, rect.top);
215 ret = reg_write(client, MT9M001_WINDOW_WIDTH, rect.width - 1);
217 ret = reg_write(client, MT9M001_WINDOW_HEIGHT,
218 rect.height + mt9m001->y_skip_top - 1);
219 if (!ret && v4l2_ctrl_g_ctrl(mt9m001->autoexposure) == V4L2_EXPOSURE_AUTO)
220 ret = reg_write(client, MT9M001_SHUTTER_WIDTH, mt9m001->total_h);
223 mt9m001->rect = rect;
228 static int mt9m001_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
230 struct i2c_client *client = v4l2_get_subdevdata(sd);
231 struct mt9m001 *mt9m001 = to_mt9m001(client);
233 a->c = mt9m001->rect;
234 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
239 static int mt9m001_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
241 a->bounds.left = MT9M001_COLUMN_SKIP;
242 a->bounds.top = MT9M001_ROW_SKIP;
243 a->bounds.width = MT9M001_MAX_WIDTH;
244 a->bounds.height = MT9M001_MAX_HEIGHT;
245 a->defrect = a->bounds;
246 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
247 a->pixelaspect.numerator = 1;
248 a->pixelaspect.denominator = 1;
253 static int mt9m001_g_fmt(struct v4l2_subdev *sd,
254 struct v4l2_mbus_framefmt *mf)
256 struct i2c_client *client = v4l2_get_subdevdata(sd);
257 struct mt9m001 *mt9m001 = to_mt9m001(client);
259 mf->width = mt9m001->rect.width;
260 mf->height = mt9m001->rect.height;
261 mf->code = mt9m001->fmt->code;
262 mf->colorspace = mt9m001->fmt->colorspace;
263 mf->field = V4L2_FIELD_NONE;
268 static int mt9m001_s_fmt(struct v4l2_subdev *sd,
269 struct v4l2_mbus_framefmt *mf)
271 struct i2c_client *client = v4l2_get_subdevdata(sd);
272 struct mt9m001 *mt9m001 = to_mt9m001(client);
273 struct v4l2_crop a = {
275 .left = mt9m001->rect.left,
276 .top = mt9m001->rect.top,
278 .height = mf->height,
283 /* No support for scaling so far, just crop. TODO: use skipping */
284 ret = mt9m001_s_crop(sd, &a);
286 mf->width = mt9m001->rect.width;
287 mf->height = mt9m001->rect.height;
288 mt9m001->fmt = mt9m001_find_datafmt(mf->code,
289 mt9m001->fmts, mt9m001->num_fmts);
290 mf->colorspace = mt9m001->fmt->colorspace;
296 static int mt9m001_try_fmt(struct v4l2_subdev *sd,
297 struct v4l2_mbus_framefmt *mf)
299 struct i2c_client *client = v4l2_get_subdevdata(sd);
300 struct mt9m001 *mt9m001 = to_mt9m001(client);
301 const struct mt9m001_datafmt *fmt;
303 v4l_bound_align_image(&mf->width, MT9M001_MIN_WIDTH,
304 MT9M001_MAX_WIDTH, 1,
305 &mf->height, MT9M001_MIN_HEIGHT + mt9m001->y_skip_top,
306 MT9M001_MAX_HEIGHT + mt9m001->y_skip_top, 0, 0);
308 if (mt9m001->fmts == mt9m001_colour_fmts)
309 mf->height = ALIGN(mf->height - 1, 2);
311 fmt = mt9m001_find_datafmt(mf->code, mt9m001->fmts,
315 mf->code = fmt->code;
318 mf->colorspace = fmt->colorspace;
323 static int mt9m001_g_chip_ident(struct v4l2_subdev *sd,
324 struct v4l2_dbg_chip_ident *id)
326 struct i2c_client *client = v4l2_get_subdevdata(sd);
327 struct mt9m001 *mt9m001 = to_mt9m001(client);
329 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
332 if (id->match.addr != client->addr)
335 id->ident = mt9m001->model;
341 #ifdef CONFIG_VIDEO_ADV_DEBUG
342 static int mt9m001_g_register(struct v4l2_subdev *sd,
343 struct v4l2_dbg_register *reg)
345 struct i2c_client *client = v4l2_get_subdevdata(sd);
347 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
350 if (reg->match.addr != client->addr)
354 reg->val = reg_read(client, reg->reg);
356 if (reg->val > 0xffff)
362 static int mt9m001_s_register(struct v4l2_subdev *sd,
363 struct v4l2_dbg_register *reg)
365 struct i2c_client *client = v4l2_get_subdevdata(sd);
367 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
370 if (reg->match.addr != client->addr)
373 if (reg_write(client, reg->reg, reg->val) < 0)
380 static int mt9m001_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
382 struct mt9m001 *mt9m001 = container_of(ctrl->handler,
383 struct mt9m001, hdl);
387 case V4L2_CID_EXPOSURE_AUTO:
388 min = mt9m001->exposure->minimum;
389 max = mt9m001->exposure->maximum;
390 mt9m001->exposure->val =
391 (524 + (mt9m001->total_h - 1) * (max - min)) / 1048 + min;
397 static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl)
399 struct mt9m001 *mt9m001 = container_of(ctrl->handler,
400 struct mt9m001, hdl);
401 struct v4l2_subdev *sd = &mt9m001->subdev;
402 struct i2c_client *client = v4l2_get_subdevdata(sd);
403 struct v4l2_ctrl *exp = mt9m001->exposure;
409 data = reg_set(client, MT9M001_READ_OPTIONS2, 0x8000);
411 data = reg_clear(client, MT9M001_READ_OPTIONS2, 0x8000);
417 /* See Datasheet Table 7, Gain settings. */
418 if (ctrl->val <= ctrl->default_value) {
419 /* Pack it into 0..1 step 0.125, register values 0..8 */
420 unsigned long range = ctrl->default_value - ctrl->minimum;
421 data = ((ctrl->val - ctrl->minimum) * 8 + range / 2) / range;
423 dev_dbg(&client->dev, "Setting gain %d\n", data);
424 data = reg_write(client, MT9M001_GLOBAL_GAIN, data);
428 /* Pack it into 1.125..15 variable step, register values 9..67 */
429 /* We assume qctrl->maximum - qctrl->default_value - 1 > 0 */
430 unsigned long range = ctrl->maximum - ctrl->default_value - 1;
431 unsigned long gain = ((ctrl->val - ctrl->default_value - 1) *
432 111 + range / 2) / range + 9;
437 data = ((gain - 32) * 16 + 16) / 32 + 80;
439 data = ((gain - 64) * 7 + 28) / 56 + 96;
441 dev_dbg(&client->dev, "Setting gain from %d to %d\n",
442 reg_read(client, MT9M001_GLOBAL_GAIN), data);
443 data = reg_write(client, MT9M001_GLOBAL_GAIN, data);
449 case V4L2_CID_EXPOSURE_AUTO:
450 if (ctrl->val == V4L2_EXPOSURE_MANUAL) {
451 unsigned long range = exp->maximum - exp->minimum;
452 unsigned long shutter = ((exp->val - exp->minimum) * 1048 +
453 range / 2) / range + 1;
455 dev_dbg(&client->dev,
456 "Setting shutter width from %d to %lu\n",
457 reg_read(client, MT9M001_SHUTTER_WIDTH), shutter);
458 if (reg_write(client, MT9M001_SHUTTER_WIDTH, shutter) < 0)
461 const u16 vblank = 25;
463 mt9m001->total_h = mt9m001->rect.height +
464 mt9m001->y_skip_top + vblank;
465 if (reg_write(client, MT9M001_SHUTTER_WIDTH, mt9m001->total_h) < 0)
474 * Interface active, can use i2c. If it fails, it can indeed mean, that
475 * this wasn't our capture interface, so, we wait for the right one
477 static int mt9m001_video_probe(struct soc_camera_device *icd,
478 struct i2c_client *client)
480 struct mt9m001 *mt9m001 = to_mt9m001(client);
481 struct soc_camera_link *icl = to_soc_camera_link(icd);
486 /* We must have a parent by now. And it cannot be a wrong one. */
487 BUG_ON(!icd->parent ||
488 to_soc_camera_host(icd->parent)->nr != icd->iface);
490 /* Enable the chip */
491 data = reg_write(client, MT9M001_CHIP_ENABLE, 1);
492 dev_dbg(&client->dev, "write: %d\n", data);
494 /* Read out the chip version register */
495 data = reg_read(client, MT9M001_CHIP_VERSION);
497 /* must be 0x8411 or 0x8421 for colour sensor and 8431 for bw */
501 mt9m001->model = V4L2_IDENT_MT9M001C12ST;
502 mt9m001->fmts = mt9m001_colour_fmts;
505 mt9m001->model = V4L2_IDENT_MT9M001C12STM;
506 mt9m001->fmts = mt9m001_monochrome_fmts;
509 dev_err(&client->dev,
510 "No MT9M001 chip detected, register read %x\n", data);
514 mt9m001->num_fmts = 0;
517 * This is a 10bit sensor, so by default we only allow 10bit.
518 * The platform may support different bus widths due to
519 * different routing of the data lines.
521 if (icl->query_bus_param)
522 flags = icl->query_bus_param(icl);
524 flags = SOCAM_DATAWIDTH_10;
526 if (flags & SOCAM_DATAWIDTH_10)
531 if (flags & SOCAM_DATAWIDTH_8)
534 mt9m001->fmt = &mt9m001->fmts[0];
536 dev_info(&client->dev, "Detected a MT9M001 chip ID %x (%s)\n", data,
537 data == 0x8431 ? "C12STM" : "C12ST");
539 ret = mt9m001_init(client);
541 dev_err(&client->dev, "Failed to initialise the camera\n");
543 /* mt9m001_init() has reset the chip, returning registers to defaults */
544 return v4l2_ctrl_handler_setup(&mt9m001->hdl);
547 static void mt9m001_video_remove(struct soc_camera_device *icd)
549 struct soc_camera_link *icl = to_soc_camera_link(icd);
551 dev_dbg(icd->pdev, "Video removed: %p, %p\n",
552 icd->parent, icd->vdev);
557 static int mt9m001_g_skip_top_lines(struct v4l2_subdev *sd, u32 *lines)
559 struct i2c_client *client = v4l2_get_subdevdata(sd);
560 struct mt9m001 *mt9m001 = to_mt9m001(client);
562 *lines = mt9m001->y_skip_top;
567 static const struct v4l2_ctrl_ops mt9m001_ctrl_ops = {
568 .g_volatile_ctrl = mt9m001_g_volatile_ctrl,
569 .s_ctrl = mt9m001_s_ctrl,
572 static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops = {
573 .g_chip_ident = mt9m001_g_chip_ident,
574 #ifdef CONFIG_VIDEO_ADV_DEBUG
575 .g_register = mt9m001_g_register,
576 .s_register = mt9m001_s_register,
580 static int mt9m001_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
581 enum v4l2_mbus_pixelcode *code)
583 struct i2c_client *client = v4l2_get_subdevdata(sd);
584 struct mt9m001 *mt9m001 = to_mt9m001(client);
586 if (index >= mt9m001->num_fmts)
589 *code = mt9m001->fmts[index].code;
593 static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,
594 struct v4l2_mbus_config *cfg)
596 struct i2c_client *client = v4l2_get_subdevdata(sd);
597 struct soc_camera_device *icd = client->dev.platform_data;
598 struct soc_camera_link *icl = to_soc_camera_link(icd);
600 /* MT9M001 has all capture_format parameters fixed */
601 cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
602 V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
603 V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_MASTER;
604 cfg->type = V4L2_MBUS_PARALLEL;
605 cfg->flags = soc_camera_apply_board_flags(icl, cfg);
610 static int mt9m001_s_mbus_config(struct v4l2_subdev *sd,
611 const struct v4l2_mbus_config *cfg)
613 struct i2c_client *client = v4l2_get_subdevdata(sd);
614 struct soc_camera_device *icd = client->dev.platform_data;
615 struct soc_camera_link *icl = to_soc_camera_link(icd);
617 * Cannot use icd->current_fmt->host_fmt->bits_per_sample, because that
618 * is the number of bits, that the host has to sample, not the number of
619 * bits, that we have to send. See mx3_camera.c for an example of 10-bit
620 * formats being truncated to 8 bits by the host.
622 unsigned int bps = soc_mbus_get_fmtdesc(icd->current_fmt->code)->bits_per_sample;
624 if (icl->set_bus_param)
625 return icl->set_bus_param(icl, 1 << (bps - 1));
628 * Without board specific bus width settings we only support the
629 * sensors native bus width
631 return bps == 10 ? 0 : -EINVAL;
634 static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = {
635 .s_stream = mt9m001_s_stream,
636 .s_mbus_fmt = mt9m001_s_fmt,
637 .g_mbus_fmt = mt9m001_g_fmt,
638 .try_mbus_fmt = mt9m001_try_fmt,
639 .s_crop = mt9m001_s_crop,
640 .g_crop = mt9m001_g_crop,
641 .cropcap = mt9m001_cropcap,
642 .enum_mbus_fmt = mt9m001_enum_fmt,
643 .g_mbus_config = mt9m001_g_mbus_config,
644 .s_mbus_config = mt9m001_s_mbus_config,
647 static struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = {
648 .g_skip_top_lines = mt9m001_g_skip_top_lines,
651 static struct v4l2_subdev_ops mt9m001_subdev_ops = {
652 .core = &mt9m001_subdev_core_ops,
653 .video = &mt9m001_subdev_video_ops,
654 .sensor = &mt9m001_subdev_sensor_ops,
657 static int mt9m001_probe(struct i2c_client *client,
658 const struct i2c_device_id *did)
660 struct mt9m001 *mt9m001;
661 struct soc_camera_device *icd = client->dev.platform_data;
662 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
663 struct soc_camera_link *icl;
667 dev_err(&client->dev, "MT9M001: missing soc-camera data!\n");
671 icl = to_soc_camera_link(icd);
673 dev_err(&client->dev, "MT9M001 driver needs platform data\n");
677 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) {
678 dev_warn(&adapter->dev,
679 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n");
683 mt9m001 = kzalloc(sizeof(struct mt9m001), GFP_KERNEL);
687 v4l2_i2c_subdev_init(&mt9m001->subdev, client, &mt9m001_subdev_ops);
688 v4l2_ctrl_handler_init(&mt9m001->hdl, 4);
689 v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops,
690 V4L2_CID_VFLIP, 0, 1, 1, 0);
691 v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops,
692 V4L2_CID_GAIN, 0, 127, 1, 64);
693 mt9m001->exposure = v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops,
694 V4L2_CID_EXPOSURE, 1, 255, 1, 255);
696 * Simulated autoexposure. If enabled, we calculate shutter width
697 * ourselves in the driver based on vertical blanking and frame width
699 mt9m001->autoexposure = v4l2_ctrl_new_std_menu(&mt9m001->hdl,
700 &mt9m001_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0,
702 mt9m001->subdev.ctrl_handler = &mt9m001->hdl;
703 if (mt9m001->hdl.error) {
704 int err = mt9m001->hdl.error;
709 v4l2_ctrl_auto_cluster(2, &mt9m001->autoexposure,
710 V4L2_EXPOSURE_MANUAL, true);
712 /* Second stage probe - when a capture adapter is there */
713 mt9m001->y_skip_top = 0;
714 mt9m001->rect.left = MT9M001_COLUMN_SKIP;
715 mt9m001->rect.top = MT9M001_ROW_SKIP;
716 mt9m001->rect.width = MT9M001_MAX_WIDTH;
717 mt9m001->rect.height = MT9M001_MAX_HEIGHT;
719 ret = mt9m001_video_probe(icd, client);
721 v4l2_ctrl_handler_free(&mt9m001->hdl);
728 static int mt9m001_remove(struct i2c_client *client)
730 struct mt9m001 *mt9m001 = to_mt9m001(client);
731 struct soc_camera_device *icd = client->dev.platform_data;
733 v4l2_device_unregister_subdev(&mt9m001->subdev);
734 v4l2_ctrl_handler_free(&mt9m001->hdl);
735 mt9m001_video_remove(icd);
741 static const struct i2c_device_id mt9m001_id[] = {
745 MODULE_DEVICE_TABLE(i2c, mt9m001_id);
747 static struct i2c_driver mt9m001_i2c_driver = {
751 .probe = mt9m001_probe,
752 .remove = mt9m001_remove,
753 .id_table = mt9m001_id,
756 static int __init mt9m001_mod_init(void)
758 return i2c_add_driver(&mt9m001_i2c_driver);
761 static void __exit mt9m001_mod_exit(void)
763 i2c_del_driver(&mt9m001_i2c_driver);
766 module_init(mt9m001_mod_init);
767 module_exit(mt9m001_mod_exit);
769 MODULE_DESCRIPTION("Micron MT9M001 Camera driver");
770 MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
771 MODULE_LICENSE("GPL");