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>
16 #include <linux/gpio.h>
18 #include <media/v4l2-common.h>
19 #include <media/v4l2-chip-ident.h>
20 #include <media/soc_camera.h>
22 /* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c
23 * The platform has to define i2c_board_info
24 * and call i2c_register_board_info() */
26 static char *sensor_type;
27 module_param(sensor_type, charp, S_IRUGO);
28 MODULE_PARM_DESC(sensor_type, "Sensor type: \"colour\" or \"monochrome\"\n");
30 /* mt9v022 selected register addresses */
31 #define MT9V022_CHIP_VERSION 0x00
32 #define MT9V022_COLUMN_START 0x01
33 #define MT9V022_ROW_START 0x02
34 #define MT9V022_WINDOW_HEIGHT 0x03
35 #define MT9V022_WINDOW_WIDTH 0x04
36 #define MT9V022_HORIZONTAL_BLANKING 0x05
37 #define MT9V022_VERTICAL_BLANKING 0x06
38 #define MT9V022_CHIP_CONTROL 0x07
39 #define MT9V022_SHUTTER_WIDTH1 0x08
40 #define MT9V022_SHUTTER_WIDTH2 0x09
41 #define MT9V022_SHUTTER_WIDTH_CTRL 0x0a
42 #define MT9V022_TOTAL_SHUTTER_WIDTH 0x0b
43 #define MT9V022_RESET 0x0c
44 #define MT9V022_READ_MODE 0x0d
45 #define MT9V022_MONITOR_MODE 0x0e
46 #define MT9V022_PIXEL_OPERATION_MODE 0x0f
47 #define MT9V022_LED_OUT_CONTROL 0x1b
48 #define MT9V022_ADC_MODE_CONTROL 0x1c
49 #define MT9V022_ANALOG_GAIN 0x34
50 #define MT9V022_BLACK_LEVEL_CALIB_CTRL 0x47
51 #define MT9V022_PIXCLK_FV_LV 0x74
52 #define MT9V022_DIGITAL_TEST_PATTERN 0x7f
53 #define MT9V022_AEC_AGC_ENABLE 0xAF
54 #define MT9V022_MAX_TOTAL_SHUTTER_WIDTH 0xBD
56 /* Progressive scan, master, defaults */
57 #define MT9V022_CHIP_CONTROL_DEFAULT 0x188
59 static const struct soc_camera_data_format mt9v022_colour_formats[] = {
60 /* Order important: first natively supported,
61 * second supported with a GPIO extender */
63 .name = "Bayer (sRGB) 10 bit",
65 .fourcc = V4L2_PIX_FMT_SBGGR16,
66 .colorspace = V4L2_COLORSPACE_SRGB,
68 .name = "Bayer (sRGB) 8 bit",
70 .fourcc = V4L2_PIX_FMT_SBGGR8,
71 .colorspace = V4L2_COLORSPACE_SRGB,
75 static const struct soc_camera_data_format mt9v022_monochrome_formats[] = {
76 /* Order important - see above */
78 .name = "Monochrome 10 bit",
80 .fourcc = V4L2_PIX_FMT_Y16,
82 .name = "Monochrome 8 bit",
84 .fourcc = V4L2_PIX_FMT_GREY,
89 struct i2c_client *client;
90 struct soc_camera_device icd;
91 int model; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */
94 unsigned char datawidth;
97 static int reg_read(struct soc_camera_device *icd, const u8 reg)
99 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
100 struct i2c_client *client = mt9v022->client;
101 s32 data = i2c_smbus_read_word_data(client, reg);
102 return data < 0 ? data : swab16(data);
105 static int reg_write(struct soc_camera_device *icd, const u8 reg,
108 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
109 return i2c_smbus_write_word_data(mt9v022->client, reg, swab16(data));
112 static int reg_set(struct soc_camera_device *icd, const u8 reg,
117 ret = reg_read(icd, reg);
120 return reg_write(icd, reg, ret | data);
123 static int reg_clear(struct soc_camera_device *icd, const u8 reg,
128 ret = reg_read(icd, reg);
131 return reg_write(icd, reg, ret & ~data);
134 static int mt9v022_init(struct soc_camera_device *icd)
136 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
139 /* Almost the default mode: master, parallel, simultaneous, and an
140 * undocumented bit 0x200, which is present in table 7, but not in 8,
141 * plus snapshot mode to disable scan for now */
142 mt9v022->chip_control |= 0x10;
143 ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
145 reg_write(icd, MT9V022_READ_MODE, 0x300);
150 ret = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x3);
152 ret = reg_write(icd, MT9V022_MAX_TOTAL_SHUTTER_WIDTH, 480);
155 ret = reg_clear(icd, MT9V022_BLACK_LEVEL_CALIB_CTRL, 1);
157 ret = reg_write(icd, MT9V022_DIGITAL_TEST_PATTERN, 0);
159 return ret >= 0 ? 0 : -EIO;
162 static int mt9v022_release(struct soc_camera_device *icd)
168 static int mt9v022_start_capture(struct soc_camera_device *icd)
170 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
171 /* Switch to master "normal" mode */
172 mt9v022->chip_control &= ~0x10;
173 if (reg_write(icd, MT9V022_CHIP_CONTROL,
174 mt9v022->chip_control) < 0)
179 static int mt9v022_stop_capture(struct soc_camera_device *icd)
181 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
182 /* Switch to snapshot mode */
183 mt9v022->chip_control |= 0x10;
184 if (reg_write(icd, MT9V022_CHIP_CONTROL,
185 mt9v022->chip_control) < 0)
190 static int bus_switch_request(struct mt9v022 *mt9v022, struct soc_camera_link *icl)
192 #ifdef CONFIG_MT9V022_PCA9536_SWITCH
194 unsigned int gpio = icl->gpio;
196 if (gpio_is_valid(gpio)) {
197 /* We have a data bus switch. */
198 ret = gpio_request(gpio, "mt9v022");
200 dev_err(&mt9v022->client->dev, "Cannot get GPIO %u\n", gpio);
204 ret = gpio_direction_output(gpio, 0);
206 dev_err(&mt9v022->client->dev,
207 "Cannot set GPIO %u to output\n", gpio);
213 mt9v022->switch_gpio = gpio;
215 mt9v022->switch_gpio = -EINVAL;
220 static void bus_switch_release(struct mt9v022 *mt9v022)
222 #ifdef CONFIG_MT9V022_PCA9536_SWITCH
223 if (gpio_is_valid(mt9v022->switch_gpio))
224 gpio_free(mt9v022->switch_gpio);
228 static int bus_switch_act(struct mt9v022 *mt9v022, int go8bit)
230 #ifdef CONFIG_MT9V022_PCA9536_SWITCH
231 if (!gpio_is_valid(mt9v022->switch_gpio))
234 gpio_set_value_cansleep(mt9v022->switch_gpio, go8bit);
241 static int bus_switch_possible(struct mt9v022 *mt9v022)
243 #ifdef CONFIG_MT9V022_PCA9536_SWITCH
244 return gpio_is_valid(mt9v022->switch_gpio);
250 static int mt9v022_set_bus_param(struct soc_camera_device *icd,
253 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
254 unsigned int width_flag = flags & SOCAM_DATAWIDTH_MASK;
258 /* Only one width bit may be set */
259 if (!is_power_of_2(width_flag))
262 if ((mt9v022->datawidth != 10 && (width_flag == SOCAM_DATAWIDTH_10)) ||
263 (mt9v022->datawidth != 9 && (width_flag == SOCAM_DATAWIDTH_9)) ||
264 (mt9v022->datawidth != 8 && (width_flag == SOCAM_DATAWIDTH_8))) {
265 /* Well, we actually only can do 10 or 8 bits... */
266 if (width_flag == SOCAM_DATAWIDTH_9)
269 ret = bus_switch_act(mt9v022,
270 width_flag == SOCAM_DATAWIDTH_8);
274 mt9v022->datawidth = width_flag == SOCAM_DATAWIDTH_8 ? 8 : 10;
277 if (flags & SOCAM_PCLK_SAMPLE_RISING)
280 if (!(flags & SOCAM_HSYNC_ACTIVE_HIGH))
283 if (!(flags & SOCAM_VSYNC_ACTIVE_HIGH))
286 ret = reg_write(icd, MT9V022_PIXCLK_FV_LV, pixclk);
290 if (!(flags & SOCAM_MASTER))
291 mt9v022->chip_control &= ~0x8;
293 ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
297 dev_dbg(&icd->dev, "Calculated pixclk 0x%x, chip control 0x%x\n",
298 pixclk, mt9v022->chip_control);
303 static unsigned long mt9v022_query_bus_param(struct soc_camera_device *icd)
305 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
306 unsigned int width_flag = SOCAM_DATAWIDTH_10;
308 if (bus_switch_possible(mt9v022))
309 width_flag |= SOCAM_DATAWIDTH_8;
311 return SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING |
312 SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW |
313 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |
314 SOCAM_MASTER | SOCAM_SLAVE |
318 static int mt9v022_set_fmt_cap(struct soc_camera_device *icd,
319 __u32 pixfmt, struct v4l2_rect *rect)
321 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
324 /* The caller provides a supported format, as verified per call to
325 * icd->try_fmt_cap(), datawidth is from our supported format list */
327 case V4L2_PIX_FMT_GREY:
328 case V4L2_PIX_FMT_Y16:
329 if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATM)
332 case V4L2_PIX_FMT_SBGGR8:
333 case V4L2_PIX_FMT_SBGGR16:
334 if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATC)
338 /* No format change, only geometry */
344 /* Like in example app. Contradicts the datasheet though */
345 ret = reg_read(icd, MT9V022_AEC_AGC_ENABLE);
347 if (ret & 1) /* Autoexposure */
348 ret = reg_write(icd, MT9V022_MAX_TOTAL_SHUTTER_WIDTH,
349 rect->height + icd->y_skip_top + 43);
351 ret = reg_write(icd, MT9V022_TOTAL_SHUTTER_WIDTH,
352 rect->height + icd->y_skip_top + 43);
354 /* Setup frame format: defaults apart from width and height */
356 ret = reg_write(icd, MT9V022_COLUMN_START, rect->left);
358 ret = reg_write(icd, MT9V022_ROW_START, rect->top);
360 /* Default 94, Phytec driver says:
361 * "width + horizontal blank >= 660" */
362 ret = reg_write(icd, MT9V022_HORIZONTAL_BLANKING,
363 rect->width > 660 - 43 ? 43 :
366 ret = reg_write(icd, MT9V022_VERTICAL_BLANKING, 45);
368 ret = reg_write(icd, MT9V022_WINDOW_WIDTH, rect->width);
370 ret = reg_write(icd, MT9V022_WINDOW_HEIGHT,
371 rect->height + icd->y_skip_top);
376 dev_dbg(&icd->dev, "Frame %ux%u pixel\n", rect->width, rect->height);
381 static int mt9v022_try_fmt_cap(struct soc_camera_device *icd,
382 struct v4l2_format *f)
384 if (f->fmt.pix.height < 32 + icd->y_skip_top)
385 f->fmt.pix.height = 32 + icd->y_skip_top;
386 if (f->fmt.pix.height > 480 + icd->y_skip_top)
387 f->fmt.pix.height = 480 + icd->y_skip_top;
388 if (f->fmt.pix.width < 48)
389 f->fmt.pix.width = 48;
390 if (f->fmt.pix.width > 752)
391 f->fmt.pix.width = 752;
392 f->fmt.pix.width &= ~0x03; /* ? */
397 static int mt9v022_get_chip_id(struct soc_camera_device *icd,
398 struct v4l2_chip_ident *id)
400 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
402 if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR)
405 if (id->match_chip != mt9v022->client->addr)
408 id->ident = mt9v022->model;
414 #ifdef CONFIG_VIDEO_ADV_DEBUG
415 static int mt9v022_get_register(struct soc_camera_device *icd,
416 struct v4l2_register *reg)
418 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
420 if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
423 if (reg->match_chip != mt9v022->client->addr)
426 reg->val = reg_read(icd, reg->reg);
428 if (reg->val > 0xffff)
434 static int mt9v022_set_register(struct soc_camera_device *icd,
435 struct v4l2_register *reg)
437 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
439 if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
442 if (reg->match_chip != mt9v022->client->addr)
445 if (reg_write(icd, reg->reg, reg->val) < 0)
452 static const struct v4l2_queryctrl mt9v022_controls[] = {
454 .id = V4L2_CID_VFLIP,
455 .type = V4L2_CTRL_TYPE_BOOLEAN,
456 .name = "Flip Vertically",
462 .id = V4L2_CID_HFLIP,
463 .type = V4L2_CTRL_TYPE_BOOLEAN,
464 .name = "Flip Horizontally",
471 .type = V4L2_CTRL_TYPE_INTEGER,
472 .name = "Analog Gain",
477 .flags = V4L2_CTRL_FLAG_SLIDER,
479 .id = V4L2_CID_EXPOSURE,
480 .type = V4L2_CTRL_TYPE_INTEGER,
485 .default_value = 255,
486 .flags = V4L2_CTRL_FLAG_SLIDER,
488 .id = V4L2_CID_AUTOGAIN,
489 .type = V4L2_CTRL_TYPE_BOOLEAN,
490 .name = "Automatic Gain",
496 .id = V4L2_CID_EXPOSURE_AUTO,
497 .type = V4L2_CTRL_TYPE_BOOLEAN,
498 .name = "Automatic Exposure",
506 static int mt9v022_video_probe(struct soc_camera_device *);
507 static void mt9v022_video_remove(struct soc_camera_device *);
508 static int mt9v022_get_control(struct soc_camera_device *, struct v4l2_control *);
509 static int mt9v022_set_control(struct soc_camera_device *, struct v4l2_control *);
511 static struct soc_camera_ops mt9v022_ops = {
512 .owner = THIS_MODULE,
513 .probe = mt9v022_video_probe,
514 .remove = mt9v022_video_remove,
515 .init = mt9v022_init,
516 .release = mt9v022_release,
517 .start_capture = mt9v022_start_capture,
518 .stop_capture = mt9v022_stop_capture,
519 .set_fmt_cap = mt9v022_set_fmt_cap,
520 .try_fmt_cap = mt9v022_try_fmt_cap,
521 .set_bus_param = mt9v022_set_bus_param,
522 .query_bus_param = mt9v022_query_bus_param,
523 .controls = mt9v022_controls,
524 .num_controls = ARRAY_SIZE(mt9v022_controls),
525 .get_control = mt9v022_get_control,
526 .set_control = mt9v022_set_control,
527 .get_chip_id = mt9v022_get_chip_id,
528 #ifdef CONFIG_VIDEO_ADV_DEBUG
529 .get_register = mt9v022_get_register,
530 .set_register = mt9v022_set_register,
534 static int mt9v022_get_control(struct soc_camera_device *icd,
535 struct v4l2_control *ctrl)
541 data = reg_read(icd, MT9V022_READ_MODE);
544 ctrl->value = !!(data & 0x10);
547 data = reg_read(icd, MT9V022_READ_MODE);
550 ctrl->value = !!(data & 0x20);
552 case V4L2_CID_EXPOSURE_AUTO:
553 data = reg_read(icd, MT9V022_AEC_AGC_ENABLE);
556 ctrl->value = !!(data & 0x1);
558 case V4L2_CID_AUTOGAIN:
559 data = reg_read(icd, MT9V022_AEC_AGC_ENABLE);
562 ctrl->value = !!(data & 0x2);
568 static int mt9v022_set_control(struct soc_camera_device *icd,
569 struct v4l2_control *ctrl)
572 const struct v4l2_queryctrl *qctrl;
574 qctrl = soc_camera_find_qctrl(&mt9v022_ops, ctrl->id);
582 data = reg_set(icd, MT9V022_READ_MODE, 0x10);
584 data = reg_clear(icd, MT9V022_READ_MODE, 0x10);
590 data = reg_set(icd, MT9V022_READ_MODE, 0x20);
592 data = reg_clear(icd, MT9V022_READ_MODE, 0x20);
597 /* mt9v022 has minimum == default */
598 if (ctrl->value > qctrl->maximum || ctrl->value < qctrl->minimum)
601 unsigned long range = qctrl->maximum - qctrl->minimum;
602 /* Datasheet says 16 to 64. autogain only works properly
603 * after setting gain to maximum 14. Larger values
604 * produce "white fly" noise effect. On the whole,
605 * manually setting analog gain does no good. */
606 unsigned long gain = ((ctrl->value - qctrl->minimum) *
607 10 + range / 2) / range + 4;
610 /* The user wants to set gain manually, hope, she
611 * knows, what she's doing... Switch AGC off. */
613 if (reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x2) < 0)
616 dev_info(&icd->dev, "Setting gain from %d to %lu\n",
617 reg_read(icd, MT9V022_ANALOG_GAIN), gain);
618 if (reg_write(icd, MT9V022_ANALOG_GAIN, gain) < 0)
620 icd->gain = ctrl->value;
623 case V4L2_CID_EXPOSURE:
624 /* mt9v022 has maximum == default */
625 if (ctrl->value > qctrl->maximum || ctrl->value < qctrl->minimum)
628 unsigned long range = qctrl->maximum - qctrl->minimum;
629 unsigned long shutter = ((ctrl->value - qctrl->minimum) *
630 479 + range / 2) / range + 1;
631 /* The user wants to set shutter width manually, hope,
632 * she knows, what she's doing... Switch AEC off. */
634 if (reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x1) < 0)
637 dev_dbg(&icd->dev, "Shutter width from %d to %lu\n",
638 reg_read(icd, MT9V022_TOTAL_SHUTTER_WIDTH),
640 if (reg_write(icd, MT9V022_TOTAL_SHUTTER_WIDTH,
643 icd->exposure = ctrl->value;
646 case V4L2_CID_AUTOGAIN:
648 data = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x2);
650 data = reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x2);
654 case V4L2_CID_EXPOSURE_AUTO:
656 data = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x1);
658 data = reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x1);
666 /* Interface active, can use i2c. If it fails, it can indeed mean, that
667 * this wasn't our capture interface, so, we wait for the right one */
668 static int mt9v022_video_probe(struct soc_camera_device *icd)
670 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
674 if (!icd->dev.parent ||
675 to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
678 /* Read out the chip version register */
679 data = reg_read(icd, MT9V022_CHIP_VERSION);
681 /* must be 0x1311 or 0x1313 */
682 if (data != 0x1311 && data != 0x1313) {
684 dev_info(&icd->dev, "No MT9V022 detected, ID register 0x%x\n",
690 ret = reg_write(icd, MT9V022_RESET, 1);
693 /* 15 clock cycles */
695 if (reg_read(icd, MT9V022_RESET)) {
696 dev_err(&icd->dev, "Resetting MT9V022 failed!\n");
700 /* Set monochrome or colour sensor type */
701 if (sensor_type && (!strcmp("colour", sensor_type) ||
702 !strcmp("color", sensor_type))) {
703 ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11);
704 mt9v022->model = V4L2_IDENT_MT9V022IX7ATC;
705 icd->formats = mt9v022_colour_formats;
706 if (mt9v022->client->dev.platform_data)
707 icd->num_formats = ARRAY_SIZE(mt9v022_colour_formats);
709 icd->num_formats = 1;
711 ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 0x11);
712 mt9v022->model = V4L2_IDENT_MT9V022IX7ATM;
713 icd->formats = mt9v022_monochrome_formats;
714 if (mt9v022->client->dev.platform_data)
715 icd->num_formats = ARRAY_SIZE(mt9v022_monochrome_formats);
717 icd->num_formats = 1;
721 ret = soc_camera_video_start(icd);
725 dev_info(&icd->dev, "Detected a MT9V022 chip ID %x, %s sensor\n",
726 data, mt9v022->model == V4L2_IDENT_MT9V022IX7ATM ?
727 "monochrome" : "colour");
736 static void mt9v022_video_remove(struct soc_camera_device *icd)
738 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
740 dev_dbg(&icd->dev, "Video %x removed: %p, %p\n", mt9v022->client->addr,
741 mt9v022->icd.dev.parent, mt9v022->icd.vdev);
742 soc_camera_video_stop(&mt9v022->icd);
745 static int mt9v022_probe(struct i2c_client *client,
746 const struct i2c_device_id *did)
748 struct mt9v022 *mt9v022;
749 struct soc_camera_device *icd;
750 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
751 struct soc_camera_link *icl = client->dev.platform_data;
755 dev_err(&client->dev, "MT9V022 driver needs platform data\n");
759 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) {
760 dev_warn(&adapter->dev,
761 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n");
765 mt9v022 = kzalloc(sizeof(struct mt9v022), GFP_KERNEL);
769 mt9v022->chip_control = MT9V022_CHIP_CONTROL_DEFAULT;
770 mt9v022->client = client;
771 i2c_set_clientdata(client, mt9v022);
774 icd->ops = &mt9v022_ops;
775 icd->control = &client->dev;
781 icd->width_max = 752;
782 icd->height_min = 32;
783 icd->height_max = 480;
785 icd->iface = icl->bus_id;
786 /* Default datawidth - this is the only width this camera (normally)
787 * supports. It is only with extra logic that it can support
788 * other widths. Therefore it seems to be a sensible default. */
789 mt9v022->datawidth = 10;
791 ret = bus_switch_request(mt9v022, icl);
795 ret = soc_camera_device_register(icd);
802 bus_switch_release(mt9v022);
808 static int mt9v022_remove(struct i2c_client *client)
810 struct mt9v022 *mt9v022 = i2c_get_clientdata(client);
812 soc_camera_device_unregister(&mt9v022->icd);
813 bus_switch_release(mt9v022);
818 static const struct i2c_device_id mt9v022_id[] = {
822 MODULE_DEVICE_TABLE(i2c, mt9v022_id);
824 static struct i2c_driver mt9v022_i2c_driver = {
828 .probe = mt9v022_probe,
829 .remove = mt9v022_remove,
830 .id_table = mt9v022_id,
833 static int __init mt9v022_mod_init(void)
835 return i2c_add_driver(&mt9v022_i2c_driver);
838 static void __exit mt9v022_mod_exit(void)
840 i2c_del_driver(&mt9v022_i2c_driver);
843 module_init(mt9v022_mod_init);
844 module_exit(mt9v022_mod_exit);
846 MODULE_DESCRIPTION("Micron MT9V022 Camera driver");
847 MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
848 MODULE_LICENSE("GPL");