Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Driver for MT9M001 CMOS Image Sensor from Micron |
| 3 | * |
| 4 | * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de> |
| 5 | * |
| 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. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/videodev2.h> |
| 12 | #include <linux/slab.h> |
| 13 | #include <linux/i2c.h> |
| 14 | #include <linux/log2.h> |
Paul Gortmaker | 7a707b8 | 2011-07-03 14:03:12 -0400 | [diff] [blame] | 15 | #include <linux/module.h> |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 16 | |
Guennadi Liakhovetski | 32ca208 | 2011-07-26 11:46:02 -0300 | [diff] [blame] | 17 | #include <media/soc_camera.h> |
| 18 | #include <media/soc_mediabus.h> |
Guennadi Liakhovetski | 9aea470 | 2012-12-21 13:01:55 -0300 | [diff] [blame] | 19 | #include <media/v4l2-clk.h> |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 20 | #include <media/v4l2-subdev.h> |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 21 | #include <media/v4l2-ctrls.h> |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 22 | |
Guennadi Liakhovetski | 5d28d52 | 2009-12-11 11:15:05 -0300 | [diff] [blame] | 23 | /* |
| 24 | * mt9m001 i2c address 0x5d |
Peter Meerwald | 22cf83f | 2012-06-13 10:48:11 -0300 | [diff] [blame] | 25 | * The platform has to define struct i2c_board_info objects and link to them |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 26 | * from struct soc_camera_host_desc |
Guennadi Liakhovetski | 5d28d52 | 2009-12-11 11:15:05 -0300 | [diff] [blame] | 27 | */ |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 28 | |
| 29 | /* mt9m001 selected register addresses */ |
| 30 | #define MT9M001_CHIP_VERSION 0x00 |
| 31 | #define MT9M001_ROW_START 0x01 |
| 32 | #define MT9M001_COLUMN_START 0x02 |
| 33 | #define MT9M001_WINDOW_HEIGHT 0x03 |
| 34 | #define MT9M001_WINDOW_WIDTH 0x04 |
| 35 | #define MT9M001_HORIZONTAL_BLANKING 0x05 |
| 36 | #define MT9M001_VERTICAL_BLANKING 0x06 |
| 37 | #define MT9M001_OUTPUT_CONTROL 0x07 |
| 38 | #define MT9M001_SHUTTER_WIDTH 0x09 |
| 39 | #define MT9M001_FRAME_RESTART 0x0b |
| 40 | #define MT9M001_SHUTTER_DELAY 0x0c |
| 41 | #define MT9M001_RESET 0x0d |
| 42 | #define MT9M001_READ_OPTIONS1 0x1e |
| 43 | #define MT9M001_READ_OPTIONS2 0x20 |
| 44 | #define MT9M001_GLOBAL_GAIN 0x35 |
| 45 | #define MT9M001_CHIP_ENABLE 0xF1 |
| 46 | |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 47 | #define MT9M001_MAX_WIDTH 1280 |
| 48 | #define MT9M001_MAX_HEIGHT 1024 |
| 49 | #define MT9M001_MIN_WIDTH 48 |
| 50 | #define MT9M001_MIN_HEIGHT 32 |
| 51 | #define MT9M001_COLUMN_SKIP 20 |
| 52 | #define MT9M001_ROW_SKIP 12 |
| 53 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 54 | /* MT9M001 has only one fixed colorspace per pixelcode */ |
| 55 | struct mt9m001_datafmt { |
| 56 | enum v4l2_mbus_pixelcode code; |
| 57 | enum v4l2_colorspace colorspace; |
| 58 | }; |
| 59 | |
| 60 | /* Find a data format by a pixel code in an array */ |
| 61 | static const struct mt9m001_datafmt *mt9m001_find_datafmt( |
| 62 | enum v4l2_mbus_pixelcode code, const struct mt9m001_datafmt *fmt, |
| 63 | int n) |
| 64 | { |
| 65 | int i; |
| 66 | for (i = 0; i < n; i++) |
| 67 | if (fmt[i].code == code) |
| 68 | return fmt + i; |
| 69 | |
| 70 | return NULL; |
| 71 | } |
| 72 | |
| 73 | static const struct mt9m001_datafmt mt9m001_colour_fmts[] = { |
Guennadi Liakhovetski | 5d28d52 | 2009-12-11 11:15:05 -0300 | [diff] [blame] | 74 | /* |
| 75 | * Order important: first natively supported, |
| 76 | * second supported with a GPIO extender |
| 77 | */ |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 78 | {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB}, |
| 79 | {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 80 | }; |
| 81 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 82 | static const struct mt9m001_datafmt mt9m001_monochrome_fmts[] = { |
Guennadi Liakhovetski | bb55de3 | 2008-04-22 14:45:13 -0300 | [diff] [blame] | 83 | /* Order important - see above */ |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 84 | {V4L2_MBUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG}, |
Laurent Pinchart | 07670433 | 2010-09-28 07:01:44 -0300 | [diff] [blame] | 85 | {V4L2_MBUS_FMT_Y8_1X8, V4L2_COLORSPACE_JPEG}, |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | struct mt9m001 { |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 89 | struct v4l2_subdev subdev; |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 90 | struct v4l2_ctrl_handler hdl; |
| 91 | struct { |
| 92 | /* exposure/auto-exposure cluster */ |
| 93 | struct v4l2_ctrl *autoexposure; |
| 94 | struct v4l2_ctrl *exposure; |
| 95 | }; |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 96 | struct v4l2_rect rect; /* Sensor window */ |
Guennadi Liakhovetski | 9aea470 | 2012-12-21 13:01:55 -0300 | [diff] [blame] | 97 | struct v4l2_clk *clk; |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 98 | const struct mt9m001_datafmt *fmt; |
| 99 | const struct mt9m001_datafmt *fmts; |
| 100 | int num_fmts; |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 101 | unsigned int total_h; |
Guennadi Liakhovetski | 3253610 | 2009-12-11 11:14:46 -0300 | [diff] [blame] | 102 | unsigned short y_skip_top; /* Lines to skip at the top */ |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 103 | }; |
| 104 | |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 105 | static struct mt9m001 *to_mt9m001(const struct i2c_client *client) |
| 106 | { |
| 107 | return container_of(i2c_get_clientdata(client), struct mt9m001, subdev); |
| 108 | } |
| 109 | |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 110 | static int reg_read(struct i2c_client *client, const u8 reg) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 111 | { |
Jonathan Cameron | 3f87704 | 2011-10-21 09:30:25 -0300 | [diff] [blame] | 112 | return i2c_smbus_read_word_swapped(client, reg); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 113 | } |
| 114 | |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 115 | static int reg_write(struct i2c_client *client, const u8 reg, |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 116 | const u16 data) |
| 117 | { |
Jonathan Cameron | 3f87704 | 2011-10-21 09:30:25 -0300 | [diff] [blame] | 118 | return i2c_smbus_write_word_swapped(client, reg, data); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 119 | } |
| 120 | |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 121 | static int reg_set(struct i2c_client *client, const u8 reg, |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 122 | const u16 data) |
| 123 | { |
| 124 | int ret; |
| 125 | |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 126 | ret = reg_read(client, reg); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 127 | if (ret < 0) |
| 128 | return ret; |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 129 | return reg_write(client, reg, ret | data); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 130 | } |
| 131 | |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 132 | static int reg_clear(struct i2c_client *client, const u8 reg, |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 133 | const u16 data) |
| 134 | { |
| 135 | int ret; |
| 136 | |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 137 | ret = reg_read(client, reg); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 138 | if (ret < 0) |
| 139 | return ret; |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 140 | return reg_write(client, reg, ret & ~data); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 141 | } |
| 142 | |
Guennadi Liakhovetski | a4c56fd | 2009-08-25 11:53:23 -0300 | [diff] [blame] | 143 | static int mt9m001_init(struct i2c_client *client) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 144 | { |
| 145 | int ret; |
| 146 | |
Guennadi Liakhovetski | 85f8be6 | 2009-08-25 11:47:00 -0300 | [diff] [blame] | 147 | dev_dbg(&client->dev, "%s\n", __func__); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 148 | |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 149 | /* |
Guennadi Liakhovetski | 96c7539 | 2009-08-25 11:53:23 -0300 | [diff] [blame] | 150 | * We don't know, whether platform provides reset, issue a soft reset |
| 151 | * too. This returns all registers to their default values. |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 152 | */ |
| 153 | ret = reg_write(client, MT9M001_RESET, 1); |
| 154 | if (!ret) |
| 155 | ret = reg_write(client, MT9M001_RESET, 0); |
Stefan Herbrechtsmeier | 8103466 | 2008-08-14 12:04:11 -0300 | [diff] [blame] | 156 | |
Guennadi Liakhovetski | 1121164 | 2008-08-14 12:03:18 -0300 | [diff] [blame] | 157 | /* Disable chip, synchronous option update */ |
| 158 | if (!ret) |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 159 | ret = reg_write(client, MT9M001_OUTPUT_CONTROL, 0); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 160 | |
Guennadi Liakhovetski | 1121164 | 2008-08-14 12:03:18 -0300 | [diff] [blame] | 161 | return ret; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 162 | } |
| 163 | |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 164 | static int mt9m001_s_stream(struct v4l2_subdev *sd, int enable) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 165 | { |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 166 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 167 | |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 168 | /* Switch to master "normal" mode or stop sensor readout */ |
| 169 | if (reg_write(client, MT9M001_OUTPUT_CONTROL, enable ? 2 : 0) < 0) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 170 | return -EIO; |
| 171 | return 0; |
| 172 | } |
| 173 | |
Hans Verkuil | 4f99659 | 2012-09-05 05:10:48 -0300 | [diff] [blame] | 174 | static int mt9m001_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a) |
Guennadi Liakhovetski | ad5f2e8 | 2008-03-07 21:57:18 -0300 | [diff] [blame] | 175 | { |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 176 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 177 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 178 | struct v4l2_rect rect = a->c; |
Guennadi Liakhovetski | ad5f2e8 | 2008-03-07 21:57:18 -0300 | [diff] [blame] | 179 | int ret; |
| 180 | const u16 hblank = 9, vblank = 25; |
| 181 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 182 | if (mt9m001->fmts == mt9m001_colour_fmts) |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 183 | /* |
| 184 | * Bayer format - even number of rows for simplicity, |
| 185 | * but let the user play with the top row. |
| 186 | */ |
| 187 | rect.height = ALIGN(rect.height, 2); |
| 188 | |
| 189 | /* Datasheet requirement: see register description */ |
| 190 | rect.width = ALIGN(rect.width, 2); |
| 191 | rect.left = ALIGN(rect.left, 2); |
| 192 | |
| 193 | soc_camera_limit_side(&rect.left, &rect.width, |
| 194 | MT9M001_COLUMN_SKIP, MT9M001_MIN_WIDTH, MT9M001_MAX_WIDTH); |
| 195 | |
| 196 | soc_camera_limit_side(&rect.top, &rect.height, |
| 197 | MT9M001_ROW_SKIP, MT9M001_MIN_HEIGHT, MT9M001_MAX_HEIGHT); |
| 198 | |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 199 | mt9m001->total_h = rect.height + mt9m001->y_skip_top + vblank; |
Guennadi Liakhovetski | 96c7539 | 2009-08-25 11:53:23 -0300 | [diff] [blame] | 200 | |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 201 | /* Blanking and start values - default... */ |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 202 | ret = reg_write(client, MT9M001_HORIZONTAL_BLANKING, hblank); |
Guennadi Liakhovetski | 1121164 | 2008-08-14 12:03:18 -0300 | [diff] [blame] | 203 | if (!ret) |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 204 | ret = reg_write(client, MT9M001_VERTICAL_BLANKING, vblank); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 205 | |
Guennadi Liakhovetski | 5d28d52 | 2009-12-11 11:15:05 -0300 | [diff] [blame] | 206 | /* |
| 207 | * The caller provides a supported format, as verified per |
Guennadi Liakhovetski | 14178aa | 2011-09-21 15:16:30 -0300 | [diff] [blame] | 208 | * call to .try_mbus_fmt() |
Guennadi Liakhovetski | 5d28d52 | 2009-12-11 11:15:05 -0300 | [diff] [blame] | 209 | */ |
Guennadi Liakhovetski | 1121164 | 2008-08-14 12:03:18 -0300 | [diff] [blame] | 210 | if (!ret) |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 211 | ret = reg_write(client, MT9M001_COLUMN_START, rect.left); |
Guennadi Liakhovetski | 1121164 | 2008-08-14 12:03:18 -0300 | [diff] [blame] | 212 | if (!ret) |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 213 | ret = reg_write(client, MT9M001_ROW_START, rect.top); |
Guennadi Liakhovetski | 1121164 | 2008-08-14 12:03:18 -0300 | [diff] [blame] | 214 | if (!ret) |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 215 | ret = reg_write(client, MT9M001_WINDOW_WIDTH, rect.width - 1); |
Guennadi Liakhovetski | 1121164 | 2008-08-14 12:03:18 -0300 | [diff] [blame] | 216 | if (!ret) |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 217 | ret = reg_write(client, MT9M001_WINDOW_HEIGHT, |
Guennadi Liakhovetski | 3253610 | 2009-12-11 11:14:46 -0300 | [diff] [blame] | 218 | rect.height + mt9m001->y_skip_top - 1); |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 219 | if (!ret && v4l2_ctrl_g_ctrl(mt9m001->autoexposure) == V4L2_EXPOSURE_AUTO) |
| 220 | ret = reg_write(client, MT9M001_SHUTTER_WIDTH, mt9m001->total_h); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 221 | |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 222 | if (!ret) |
| 223 | mt9m001->rect = rect; |
| 224 | |
Guennadi Liakhovetski | 1121164 | 2008-08-14 12:03:18 -0300 | [diff] [blame] | 225 | return ret; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 226 | } |
| 227 | |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 228 | static int mt9m001_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) |
| 229 | { |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 230 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 231 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
| 232 | |
| 233 | a->c = mt9m001->rect; |
| 234 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 235 | |
| 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | static int mt9m001_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) |
| 240 | { |
| 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; |
| 249 | |
| 250 | return 0; |
| 251 | } |
| 252 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 253 | static int mt9m001_g_fmt(struct v4l2_subdev *sd, |
| 254 | struct v4l2_mbus_framefmt *mf) |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 255 | { |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 256 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 257 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 258 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 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; |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 264 | |
| 265 | return 0; |
| 266 | } |
| 267 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 268 | static int mt9m001_s_fmt(struct v4l2_subdev *sd, |
| 269 | struct v4l2_mbus_framefmt *mf) |
Guennadi Liakhovetski | 09e231b | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 270 | { |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 271 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 272 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
Guennadi Liakhovetski | 08590b9 | 2009-08-25 11:46:54 -0300 | [diff] [blame] | 273 | struct v4l2_crop a = { |
| 274 | .c = { |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 275 | .left = mt9m001->rect.left, |
| 276 | .top = mt9m001->rect.top, |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 277 | .width = mf->width, |
| 278 | .height = mf->height, |
Guennadi Liakhovetski | 08590b9 | 2009-08-25 11:46:54 -0300 | [diff] [blame] | 279 | }, |
Guennadi Liakhovetski | 09e231b | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 280 | }; |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 281 | int ret; |
Guennadi Liakhovetski | 09e231b | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 282 | |
| 283 | /* No support for scaling so far, just crop. TODO: use skipping */ |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 284 | ret = mt9m001_s_crop(sd, &a); |
| 285 | if (!ret) { |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 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; |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | return ret; |
Guennadi Liakhovetski | 09e231b | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 294 | } |
| 295 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 296 | static int mt9m001_try_fmt(struct v4l2_subdev *sd, |
| 297 | struct v4l2_mbus_framefmt *mf) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 298 | { |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 299 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 3253610 | 2009-12-11 11:14:46 -0300 | [diff] [blame] | 300 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 301 | const struct mt9m001_datafmt *fmt; |
Guennadi Liakhovetski | 64f5905 | 2008-12-18 11:51:55 -0300 | [diff] [blame] | 302 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 303 | v4l_bound_align_image(&mf->width, MT9M001_MIN_WIDTH, |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 304 | MT9M001_MAX_WIDTH, 1, |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 305 | &mf->height, MT9M001_MIN_HEIGHT + mt9m001->y_skip_top, |
Guennadi Liakhovetski | 3253610 | 2009-12-11 11:14:46 -0300 | [diff] [blame] | 306 | MT9M001_MAX_HEIGHT + mt9m001->y_skip_top, 0, 0); |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 307 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 308 | if (mt9m001->fmts == mt9m001_colour_fmts) |
| 309 | mf->height = ALIGN(mf->height - 1, 2); |
| 310 | |
| 311 | fmt = mt9m001_find_datafmt(mf->code, mt9m001->fmts, |
| 312 | mt9m001->num_fmts); |
| 313 | if (!fmt) { |
| 314 | fmt = mt9m001->fmt; |
| 315 | mf->code = fmt->code; |
| 316 | } |
| 317 | |
| 318 | mf->colorspace = fmt->colorspace; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 319 | |
| 320 | return 0; |
| 321 | } |
| 322 | |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 323 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 324 | static int mt9m001_g_register(struct v4l2_subdev *sd, |
| 325 | struct v4l2_dbg_register *reg) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 326 | { |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 327 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 328 | |
Hans Verkuil | 6be89da | 2013-05-29 06:59:50 -0300 | [diff] [blame] | 329 | if (reg->reg > 0xff) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 330 | return -EINVAL; |
| 331 | |
Hans Verkuil | aecde8b5 | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 332 | reg->size = 2; |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 333 | reg->val = reg_read(client, reg->reg); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 334 | |
| 335 | if (reg->val > 0xffff) |
| 336 | return -EIO; |
| 337 | |
| 338 | return 0; |
| 339 | } |
| 340 | |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 341 | static int mt9m001_s_register(struct v4l2_subdev *sd, |
Hans Verkuil | 977ba3b | 2013-03-24 08:28:46 -0300 | [diff] [blame] | 342 | const struct v4l2_dbg_register *reg) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 343 | { |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 344 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 345 | |
Hans Verkuil | 6be89da | 2013-05-29 06:59:50 -0300 | [diff] [blame] | 346 | if (reg->reg > 0xff) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 347 | return -EINVAL; |
| 348 | |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 349 | if (reg_write(client, reg->reg, reg->val) < 0) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 350 | return -EIO; |
| 351 | |
| 352 | return 0; |
| 353 | } |
| 354 | #endif |
| 355 | |
Laurent Pinchart | 4ec10ba | 2012-07-20 10:19:50 -0300 | [diff] [blame] | 356 | static int mt9m001_s_power(struct v4l2_subdev *sd, int on) |
| 357 | { |
| 358 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 359 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
Guennadi Liakhovetski | 9aea470 | 2012-12-21 13:01:55 -0300 | [diff] [blame] | 360 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
Laurent Pinchart | 4ec10ba | 2012-07-20 10:19:50 -0300 | [diff] [blame] | 361 | |
Guennadi Liakhovetski | 9aea470 | 2012-12-21 13:01:55 -0300 | [diff] [blame] | 362 | return soc_camera_set_power(&client->dev, ssdd, mt9m001->clk, on); |
Laurent Pinchart | 4ec10ba | 2012-07-20 10:19:50 -0300 | [diff] [blame] | 363 | } |
| 364 | |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 365 | static int mt9m001_g_volatile_ctrl(struct v4l2_ctrl *ctrl) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 366 | { |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 367 | struct mt9m001 *mt9m001 = container_of(ctrl->handler, |
| 368 | struct mt9m001, hdl); |
| 369 | s32 min, max; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 370 | |
| 371 | switch (ctrl->id) { |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 372 | case V4L2_CID_EXPOSURE_AUTO: |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 373 | min = mt9m001->exposure->minimum; |
| 374 | max = mt9m001->exposure->maximum; |
| 375 | mt9m001->exposure->val = |
| 376 | (524 + (mt9m001->total_h - 1) * (max - min)) / 1048 + min; |
Guennadi Liakhovetski | 96c7539 | 2009-08-25 11:53:23 -0300 | [diff] [blame] | 377 | break; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 378 | } |
| 379 | return 0; |
| 380 | } |
| 381 | |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 382 | static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 383 | { |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 384 | struct mt9m001 *mt9m001 = container_of(ctrl->handler, |
| 385 | struct mt9m001, hdl); |
| 386 | struct v4l2_subdev *sd = &mt9m001->subdev; |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 387 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 388 | struct v4l2_ctrl *exp = mt9m001->exposure; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 389 | int data; |
| 390 | |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 391 | switch (ctrl->id) { |
| 392 | case V4L2_CID_VFLIP: |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 393 | if (ctrl->val) |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 394 | data = reg_set(client, MT9M001_READ_OPTIONS2, 0x8000); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 395 | else |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 396 | data = reg_clear(client, MT9M001_READ_OPTIONS2, 0x8000); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 397 | if (data < 0) |
| 398 | return -EIO; |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 399 | return 0; |
| 400 | |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 401 | case V4L2_CID_GAIN: |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 402 | /* See Datasheet Table 7, Gain settings. */ |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 403 | if (ctrl->val <= ctrl->default_value) { |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 404 | /* Pack it into 0..1 step 0.125, register values 0..8 */ |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 405 | unsigned long range = ctrl->default_value - ctrl->minimum; |
| 406 | data = ((ctrl->val - ctrl->minimum) * 8 + range / 2) / range; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 407 | |
Guennadi Liakhovetski | 85f8be6 | 2009-08-25 11:47:00 -0300 | [diff] [blame] | 408 | dev_dbg(&client->dev, "Setting gain %d\n", data); |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 409 | data = reg_write(client, MT9M001_GLOBAL_GAIN, data); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 410 | if (data < 0) |
| 411 | return -EIO; |
| 412 | } else { |
| 413 | /* Pack it into 1.125..15 variable step, register values 9..67 */ |
| 414 | /* We assume qctrl->maximum - qctrl->default_value - 1 > 0 */ |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 415 | unsigned long range = ctrl->maximum - ctrl->default_value - 1; |
| 416 | unsigned long gain = ((ctrl->val - ctrl->default_value - 1) * |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 417 | 111 + range / 2) / range + 9; |
| 418 | |
| 419 | if (gain <= 32) |
| 420 | data = gain; |
| 421 | else if (gain <= 64) |
| 422 | data = ((gain - 32) * 16 + 16) / 32 + 80; |
| 423 | else |
| 424 | data = ((gain - 64) * 7 + 28) / 56 + 96; |
| 425 | |
Guennadi Liakhovetski | 85f8be6 | 2009-08-25 11:47:00 -0300 | [diff] [blame] | 426 | dev_dbg(&client->dev, "Setting gain from %d to %d\n", |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 427 | reg_read(client, MT9M001_GLOBAL_GAIN), data); |
| 428 | data = reg_write(client, MT9M001_GLOBAL_GAIN, data); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 429 | if (data < 0) |
| 430 | return -EIO; |
| 431 | } |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 432 | return 0; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 433 | |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 434 | case V4L2_CID_EXPOSURE_AUTO: |
| 435 | if (ctrl->val == V4L2_EXPOSURE_MANUAL) { |
| 436 | unsigned long range = exp->maximum - exp->minimum; |
| 437 | unsigned long shutter = ((exp->val - exp->minimum) * 1048 + |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 438 | range / 2) / range + 1; |
| 439 | |
Guennadi Liakhovetski | 85f8be6 | 2009-08-25 11:47:00 -0300 | [diff] [blame] | 440 | dev_dbg(&client->dev, |
| 441 | "Setting shutter width from %d to %lu\n", |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 442 | reg_read(client, MT9M001_SHUTTER_WIDTH), shutter); |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 443 | if (reg_write(client, MT9M001_SHUTTER_WIDTH, shutter) < 0) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 444 | return -EIO; |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 445 | } else { |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 446 | const u16 vblank = 25; |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 447 | |
| 448 | mt9m001->total_h = mt9m001->rect.height + |
Guennadi Liakhovetski | 3253610 | 2009-12-11 11:14:46 -0300 | [diff] [blame] | 449 | mt9m001->y_skip_top + vblank; |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 450 | if (reg_write(client, MT9M001_SHUTTER_WIDTH, mt9m001->total_h) < 0) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 451 | return -EIO; |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 452 | } |
| 453 | return 0; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 454 | } |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 455 | return -EINVAL; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 456 | } |
| 457 | |
Guennadi Liakhovetski | 5d28d52 | 2009-12-11 11:15:05 -0300 | [diff] [blame] | 458 | /* |
| 459 | * Interface active, can use i2c. If it fails, it can indeed mean, that |
| 460 | * this wasn't our capture interface, so, we wait for the right one |
| 461 | */ |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 462 | static int mt9m001_video_probe(struct soc_camera_subdev_desc *ssdd, |
Guennadi Liakhovetski | 40e2e09 | 2009-08-25 11:28:22 -0300 | [diff] [blame] | 463 | struct i2c_client *client) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 464 | { |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 465 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 466 | s32 data; |
Sascha Hauer | 36034dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 467 | unsigned long flags; |
Guennadi Liakhovetski | a4c56fd | 2009-08-25 11:53:23 -0300 | [diff] [blame] | 468 | int ret; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 469 | |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 470 | ret = mt9m001_s_power(&mt9m001->subdev, 1); |
| 471 | if (ret < 0) |
| 472 | return ret; |
| 473 | |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 474 | /* Enable the chip */ |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 475 | data = reg_write(client, MT9M001_CHIP_ENABLE, 1); |
Guennadi Liakhovetski | 85f8be6 | 2009-08-25 11:47:00 -0300 | [diff] [blame] | 476 | dev_dbg(&client->dev, "write: %d\n", data); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 477 | |
| 478 | /* Read out the chip version register */ |
Guennadi Liakhovetski | 9538e1c | 2009-04-24 12:57:01 -0300 | [diff] [blame] | 479 | data = reg_read(client, MT9M001_CHIP_VERSION); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 480 | |
| 481 | /* must be 0x8411 or 0x8421 for colour sensor and 8431 for bw */ |
| 482 | switch (data) { |
| 483 | case 0x8411: |
| 484 | case 0x8421: |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 485 | mt9m001->fmts = mt9m001_colour_fmts; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 486 | break; |
| 487 | case 0x8431: |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 488 | mt9m001->fmts = mt9m001_monochrome_fmts; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 489 | break; |
| 490 | default: |
Guennadi Liakhovetski | 85f8be6 | 2009-08-25 11:47:00 -0300 | [diff] [blame] | 491 | dev_err(&client->dev, |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 492 | "No MT9M001 chip detected, register read %x\n", data); |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 493 | ret = -ENODEV; |
| 494 | goto done; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 495 | } |
| 496 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 497 | mt9m001->num_fmts = 0; |
Sascha Hauer | 36034dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 498 | |
| 499 | /* |
| 500 | * This is a 10bit sensor, so by default we only allow 10bit. |
| 501 | * The platform may support different bus widths due to |
| 502 | * different routing of the data lines. |
| 503 | */ |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 504 | if (ssdd->query_bus_param) |
| 505 | flags = ssdd->query_bus_param(ssdd); |
Sascha Hauer | 36034dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 506 | else |
| 507 | flags = SOCAM_DATAWIDTH_10; |
| 508 | |
| 509 | if (flags & SOCAM_DATAWIDTH_10) |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 510 | mt9m001->num_fmts++; |
Sascha Hauer | 36034dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 511 | else |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 512 | mt9m001->fmts++; |
Sascha Hauer | 36034dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 513 | |
| 514 | if (flags & SOCAM_DATAWIDTH_8) |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 515 | mt9m001->num_fmts++; |
Sascha Hauer | 36034dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 516 | |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 517 | mt9m001->fmt = &mt9m001->fmts[0]; |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 518 | |
Guennadi Liakhovetski | 85f8be6 | 2009-08-25 11:47:00 -0300 | [diff] [blame] | 519 | dev_info(&client->dev, "Detected a MT9M001 chip ID %x (%s)\n", data, |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 520 | data == 0x8431 ? "C12STM" : "C12ST"); |
| 521 | |
Guennadi Liakhovetski | a4c56fd | 2009-08-25 11:53:23 -0300 | [diff] [blame] | 522 | ret = mt9m001_init(client); |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 523 | if (ret < 0) { |
Guennadi Liakhovetski | a4c56fd | 2009-08-25 11:53:23 -0300 | [diff] [blame] | 524 | dev_err(&client->dev, "Failed to initialise the camera\n"); |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 525 | goto done; |
| 526 | } |
Guennadi Liakhovetski | a4c56fd | 2009-08-25 11:53:23 -0300 | [diff] [blame] | 527 | |
Guennadi Liakhovetski | 96c7539 | 2009-08-25 11:53:23 -0300 | [diff] [blame] | 528 | /* mt9m001_init() has reset the chip, returning registers to defaults */ |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 529 | ret = v4l2_ctrl_handler_setup(&mt9m001->hdl); |
| 530 | |
| 531 | done: |
| 532 | mt9m001_s_power(&mt9m001->subdev, 0); |
| 533 | return ret; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 534 | } |
| 535 | |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 536 | static void mt9m001_video_remove(struct soc_camera_subdev_desc *ssdd) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 537 | { |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 538 | if (ssdd->free_bus) |
| 539 | ssdd->free_bus(ssdd); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 540 | } |
| 541 | |
Guennadi Liakhovetski | 3253610 | 2009-12-11 11:14:46 -0300 | [diff] [blame] | 542 | static int mt9m001_g_skip_top_lines(struct v4l2_subdev *sd, u32 *lines) |
| 543 | { |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 544 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 3253610 | 2009-12-11 11:14:46 -0300 | [diff] [blame] | 545 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
| 546 | |
| 547 | *lines = mt9m001->y_skip_top; |
| 548 | |
| 549 | return 0; |
| 550 | } |
| 551 | |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 552 | static const struct v4l2_ctrl_ops mt9m001_ctrl_ops = { |
| 553 | .g_volatile_ctrl = mt9m001_g_volatile_ctrl, |
| 554 | .s_ctrl = mt9m001_s_ctrl, |
| 555 | }; |
| 556 | |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 557 | static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops = { |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 558 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
| 559 | .g_register = mt9m001_g_register, |
| 560 | .s_register = mt9m001_s_register, |
| 561 | #endif |
Laurent Pinchart | 4ec10ba | 2012-07-20 10:19:50 -0300 | [diff] [blame] | 562 | .s_power = mt9m001_s_power, |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 563 | }; |
| 564 | |
Hans Verkuil | 3805f20 | 2010-05-08 17:55:00 -0300 | [diff] [blame] | 565 | static int mt9m001_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 566 | enum v4l2_mbus_pixelcode *code) |
| 567 | { |
Laurent Pinchart | c4ce6d1 | 2010-07-30 17:24:54 -0300 | [diff] [blame] | 568 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 569 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
| 570 | |
Hans Verkuil | 3805f20 | 2010-05-08 17:55:00 -0300 | [diff] [blame] | 571 | if (index >= mt9m001->num_fmts) |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 572 | return -EINVAL; |
| 573 | |
| 574 | *code = mt9m001->fmts[index].code; |
| 575 | return 0; |
| 576 | } |
| 577 | |
Guennadi Liakhovetski | 32ca208 | 2011-07-26 11:46:02 -0300 | [diff] [blame] | 578 | static int mt9m001_g_mbus_config(struct v4l2_subdev *sd, |
| 579 | struct v4l2_mbus_config *cfg) |
| 580 | { |
| 581 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 582 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
Guennadi Liakhovetski | 32ca208 | 2011-07-26 11:46:02 -0300 | [diff] [blame] | 583 | |
| 584 | /* MT9M001 has all capture_format parameters fixed */ |
| 585 | cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING | |
| 586 | V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH | |
| 587 | V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_MASTER; |
| 588 | cfg->type = V4L2_MBUS_PARALLEL; |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 589 | cfg->flags = soc_camera_apply_board_flags(ssdd, cfg); |
Guennadi Liakhovetski | 32ca208 | 2011-07-26 11:46:02 -0300 | [diff] [blame] | 590 | |
| 591 | return 0; |
| 592 | } |
| 593 | |
| 594 | static int mt9m001_s_mbus_config(struct v4l2_subdev *sd, |
| 595 | const struct v4l2_mbus_config *cfg) |
| 596 | { |
Guennadi Liakhovetski | 14178aa | 2011-09-21 15:16:30 -0300 | [diff] [blame] | 597 | const struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 598 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
Guennadi Liakhovetski | 443f483 | 2011-09-09 07:06:50 -0300 | [diff] [blame] | 599 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
| 600 | unsigned int bps = soc_mbus_get_fmtdesc(mt9m001->fmt->code)->bits_per_sample; |
Guennadi Liakhovetski | 32ca208 | 2011-07-26 11:46:02 -0300 | [diff] [blame] | 601 | |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 602 | if (ssdd->set_bus_param) |
| 603 | return ssdd->set_bus_param(ssdd, 1 << (bps - 1)); |
Guennadi Liakhovetski | 32ca208 | 2011-07-26 11:46:02 -0300 | [diff] [blame] | 604 | |
| 605 | /* |
| 606 | * Without board specific bus width settings we only support the |
| 607 | * sensors native bus width |
| 608 | */ |
| 609 | return bps == 10 ? 0 : -EINVAL; |
| 610 | } |
| 611 | |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 612 | static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = { |
| 613 | .s_stream = mt9m001_s_stream, |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 614 | .s_mbus_fmt = mt9m001_s_fmt, |
| 615 | .g_mbus_fmt = mt9m001_g_fmt, |
| 616 | .try_mbus_fmt = mt9m001_try_fmt, |
Guennadi Liakhovetski | 08590b9 | 2009-08-25 11:46:54 -0300 | [diff] [blame] | 617 | .s_crop = mt9m001_s_crop, |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 618 | .g_crop = mt9m001_g_crop, |
| 619 | .cropcap = mt9m001_cropcap, |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 620 | .enum_mbus_fmt = mt9m001_enum_fmt, |
Guennadi Liakhovetski | 32ca208 | 2011-07-26 11:46:02 -0300 | [diff] [blame] | 621 | .g_mbus_config = mt9m001_g_mbus_config, |
| 622 | .s_mbus_config = mt9m001_s_mbus_config, |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 623 | }; |
| 624 | |
Guennadi Liakhovetski | 3253610 | 2009-12-11 11:14:46 -0300 | [diff] [blame] | 625 | static struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = { |
| 626 | .g_skip_top_lines = mt9m001_g_skip_top_lines, |
| 627 | }; |
| 628 | |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 629 | static struct v4l2_subdev_ops mt9m001_subdev_ops = { |
| 630 | .core = &mt9m001_subdev_core_ops, |
| 631 | .video = &mt9m001_subdev_video_ops, |
Guennadi Liakhovetski | 3253610 | 2009-12-11 11:14:46 -0300 | [diff] [blame] | 632 | .sensor = &mt9m001_subdev_sensor_ops, |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 633 | }; |
| 634 | |
Jean Delvare | d2653e9 | 2008-04-29 23:11:39 +0200 | [diff] [blame] | 635 | static int mt9m001_probe(struct i2c_client *client, |
| 636 | const struct i2c_device_id *did) |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 637 | { |
| 638 | struct mt9m001 *mt9m001; |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 639 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 640 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 641 | int ret; |
| 642 | |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 643 | if (!ssdd) { |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 644 | dev_err(&client->dev, "MT9M001 driver needs platform data\n"); |
| 645 | return -EINVAL; |
| 646 | } |
| 647 | |
| 648 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) { |
| 649 | dev_warn(&adapter->dev, |
| 650 | "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n"); |
| 651 | return -EIO; |
| 652 | } |
| 653 | |
Guennadi Liakhovetski | 70e176a | 2012-12-21 10:28:43 -0300 | [diff] [blame] | 654 | mt9m001 = devm_kzalloc(&client->dev, sizeof(struct mt9m001), GFP_KERNEL); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 655 | if (!mt9m001) |
| 656 | return -ENOMEM; |
| 657 | |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 658 | v4l2_i2c_subdev_init(&mt9m001->subdev, client, &mt9m001_subdev_ops); |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 659 | v4l2_ctrl_handler_init(&mt9m001->hdl, 4); |
| 660 | v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops, |
| 661 | V4L2_CID_VFLIP, 0, 1, 1, 0); |
| 662 | v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops, |
| 663 | V4L2_CID_GAIN, 0, 127, 1, 64); |
| 664 | mt9m001->exposure = v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops, |
| 665 | V4L2_CID_EXPOSURE, 1, 255, 1, 255); |
| 666 | /* |
| 667 | * Simulated autoexposure. If enabled, we calculate shutter width |
| 668 | * ourselves in the driver based on vertical blanking and frame width |
| 669 | */ |
| 670 | mt9m001->autoexposure = v4l2_ctrl_new_std_menu(&mt9m001->hdl, |
| 671 | &mt9m001_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0, |
| 672 | V4L2_EXPOSURE_AUTO); |
| 673 | mt9m001->subdev.ctrl_handler = &mt9m001->hdl; |
Guennadi Liakhovetski | 70e176a | 2012-12-21 10:28:43 -0300 | [diff] [blame] | 674 | if (mt9m001->hdl.error) |
| 675 | return mt9m001->hdl.error; |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 676 | |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 677 | v4l2_ctrl_auto_cluster(2, &mt9m001->autoexposure, |
| 678 | V4L2_EXPOSURE_MANUAL, true); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 679 | |
| 680 | /* Second stage probe - when a capture adapter is there */ |
Guennadi Liakhovetski | 3253610 | 2009-12-11 11:14:46 -0300 | [diff] [blame] | 681 | mt9m001->y_skip_top = 0; |
Guennadi Liakhovetski | 6a6c878 | 2009-08-25 11:50:46 -0300 | [diff] [blame] | 682 | mt9m001->rect.left = MT9M001_COLUMN_SKIP; |
| 683 | mt9m001->rect.top = MT9M001_ROW_SKIP; |
| 684 | mt9m001->rect.width = MT9M001_MAX_WIDTH; |
| 685 | mt9m001->rect.height = MT9M001_MAX_HEIGHT; |
| 686 | |
Guennadi Liakhovetski | 9aea470 | 2012-12-21 13:01:55 -0300 | [diff] [blame] | 687 | mt9m001->clk = v4l2_clk_get(&client->dev, "mclk"); |
| 688 | if (IS_ERR(mt9m001->clk)) { |
| 689 | ret = PTR_ERR(mt9m001->clk); |
| 690 | goto eclkget; |
| 691 | } |
| 692 | |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 693 | ret = mt9m001_video_probe(ssdd, client); |
Guennadi Liakhovetski | 9aea470 | 2012-12-21 13:01:55 -0300 | [diff] [blame] | 694 | if (ret) { |
| 695 | v4l2_clk_put(mt9m001->clk); |
| 696 | eclkget: |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 697 | v4l2_ctrl_handler_free(&mt9m001->hdl); |
Guennadi Liakhovetski | 9aea470 | 2012-12-21 13:01:55 -0300 | [diff] [blame] | 698 | } |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 699 | |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 700 | return ret; |
| 701 | } |
| 702 | |
| 703 | static int mt9m001_remove(struct i2c_client *client) |
| 704 | { |
Guennadi Liakhovetski | 979ea1d | 2009-08-25 11:43:33 -0300 | [diff] [blame] | 705 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 706 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 707 | |
Guennadi Liakhovetski | 9aea470 | 2012-12-21 13:01:55 -0300 | [diff] [blame] | 708 | v4l2_clk_put(mt9m001->clk); |
Hans Verkuil | 2dd7d29 | 2011-09-07 06:04:30 -0300 | [diff] [blame] | 709 | v4l2_device_unregister_subdev(&mt9m001->subdev); |
| 710 | v4l2_ctrl_handler_free(&mt9m001->hdl); |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 711 | mt9m001_video_remove(ssdd); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 712 | |
| 713 | return 0; |
| 714 | } |
| 715 | |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 716 | static const struct i2c_device_id mt9m001_id[] = { |
| 717 | { "mt9m001", 0 }, |
| 718 | { } |
| 719 | }; |
| 720 | MODULE_DEVICE_TABLE(i2c, mt9m001_id); |
| 721 | |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 722 | static struct i2c_driver mt9m001_i2c_driver = { |
| 723 | .driver = { |
| 724 | .name = "mt9m001", |
| 725 | }, |
| 726 | .probe = mt9m001_probe, |
| 727 | .remove = mt9m001_remove, |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 728 | .id_table = mt9m001_id, |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 729 | }; |
| 730 | |
Axel Lin | c6e8d86 | 2012-02-12 06:56:32 -0300 | [diff] [blame] | 731 | module_i2c_driver(mt9m001_i2c_driver); |
Guennadi Liakhovetski | f523dd0 | 2008-04-22 14:42:04 -0300 | [diff] [blame] | 732 | |
| 733 | MODULE_DESCRIPTION("Micron MT9M001 Camera driver"); |
| 734 | MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>"); |
| 735 | MODULE_LICENSE("GPL"); |