Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Driver for IMX074 CMOS Image Sensor from Sony |
| 3 | * |
| 4 | * Copyright (C) 2010, Guennadi Liakhovetski <g.liakhovetski@gmx.de> |
| 5 | * |
| 6 | * Partially inspired by the IMX074 driver from the Android / MSM tree |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/delay.h> |
| 14 | #include <linux/i2c.h> |
Guennadi Liakhovetski | 95d2010 | 2011-09-09 13:56:04 -0300 | [diff] [blame] | 15 | #include <linux/v4l2-mediabus.h> |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 16 | #include <linux/slab.h> |
| 17 | #include <linux/videodev2.h> |
Paul Gortmaker | 7a707b8 | 2011-07-03 14:03:12 -0400 | [diff] [blame] | 18 | #include <linux/module.h> |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 19 | |
| 20 | #include <media/soc_camera.h> |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 21 | #include <media/v4l2-subdev.h> |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 22 | |
| 23 | /* IMX074 registers */ |
| 24 | |
| 25 | #define MODE_SELECT 0x0100 |
| 26 | #define IMAGE_ORIENTATION 0x0101 |
| 27 | #define GROUPED_PARAMETER_HOLD 0x0104 |
| 28 | |
| 29 | /* Integration Time */ |
| 30 | #define COARSE_INTEGRATION_TIME_HI 0x0202 |
| 31 | #define COARSE_INTEGRATION_TIME_LO 0x0203 |
| 32 | /* Gain */ |
| 33 | #define ANALOGUE_GAIN_CODE_GLOBAL_HI 0x0204 |
| 34 | #define ANALOGUE_GAIN_CODE_GLOBAL_LO 0x0205 |
| 35 | |
| 36 | /* PLL registers */ |
| 37 | #define PRE_PLL_CLK_DIV 0x0305 |
| 38 | #define PLL_MULTIPLIER 0x0307 |
| 39 | #define PLSTATIM 0x302b |
| 40 | #define VNDMY_ABLMGSHLMT 0x300a |
| 41 | #define Y_OPBADDR_START_DI 0x3014 |
| 42 | /* mode setting */ |
| 43 | #define FRAME_LENGTH_LINES_HI 0x0340 |
| 44 | #define FRAME_LENGTH_LINES_LO 0x0341 |
| 45 | #define LINE_LENGTH_PCK_HI 0x0342 |
| 46 | #define LINE_LENGTH_PCK_LO 0x0343 |
| 47 | #define YADDR_START 0x0347 |
| 48 | #define YADDR_END 0x034b |
| 49 | #define X_OUTPUT_SIZE_MSB 0x034c |
| 50 | #define X_OUTPUT_SIZE_LSB 0x034d |
| 51 | #define Y_OUTPUT_SIZE_MSB 0x034e |
| 52 | #define Y_OUTPUT_SIZE_LSB 0x034f |
| 53 | #define X_EVEN_INC 0x0381 |
| 54 | #define X_ODD_INC 0x0383 |
| 55 | #define Y_EVEN_INC 0x0385 |
| 56 | #define Y_ODD_INC 0x0387 |
| 57 | |
| 58 | #define HMODEADD 0x3001 |
| 59 | #define VMODEADD 0x3016 |
| 60 | #define VAPPLINE_START 0x3069 |
| 61 | #define VAPPLINE_END 0x306b |
| 62 | #define SHUTTER 0x3086 |
| 63 | #define HADDAVE 0x30e8 |
| 64 | #define LANESEL 0x3301 |
| 65 | |
| 66 | /* IMX074 supported geometry */ |
| 67 | #define IMX074_WIDTH 1052 |
| 68 | #define IMX074_HEIGHT 780 |
| 69 | |
| 70 | /* IMX074 has only one fixed colorspace per pixelcode */ |
| 71 | struct imx074_datafmt { |
| 72 | enum v4l2_mbus_pixelcode code; |
| 73 | enum v4l2_colorspace colorspace; |
| 74 | }; |
| 75 | |
| 76 | struct imx074 { |
| 77 | struct v4l2_subdev subdev; |
| 78 | const struct imx074_datafmt *fmt; |
| 79 | }; |
| 80 | |
| 81 | static const struct imx074_datafmt imx074_colour_fmts[] = { |
| 82 | {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, |
| 83 | }; |
| 84 | |
| 85 | static struct imx074 *to_imx074(const struct i2c_client *client) |
| 86 | { |
| 87 | return container_of(i2c_get_clientdata(client), struct imx074, subdev); |
| 88 | } |
| 89 | |
| 90 | /* Find a data format by a pixel code in an array */ |
| 91 | static const struct imx074_datafmt *imx074_find_datafmt(enum v4l2_mbus_pixelcode code) |
| 92 | { |
| 93 | int i; |
| 94 | |
| 95 | for (i = 0; i < ARRAY_SIZE(imx074_colour_fmts); i++) |
| 96 | if (imx074_colour_fmts[i].code == code) |
| 97 | return imx074_colour_fmts + i; |
| 98 | |
| 99 | return NULL; |
| 100 | } |
| 101 | |
| 102 | static int reg_write(struct i2c_client *client, const u16 addr, const u8 data) |
| 103 | { |
| 104 | struct i2c_adapter *adap = client->adapter; |
| 105 | struct i2c_msg msg; |
| 106 | unsigned char tx[3]; |
| 107 | int ret; |
| 108 | |
| 109 | msg.addr = client->addr; |
| 110 | msg.buf = tx; |
| 111 | msg.len = 3; |
| 112 | msg.flags = 0; |
| 113 | |
| 114 | tx[0] = addr >> 8; |
| 115 | tx[1] = addr & 0xff; |
| 116 | tx[2] = data; |
| 117 | |
| 118 | ret = i2c_transfer(adap, &msg, 1); |
| 119 | |
| 120 | mdelay(2); |
| 121 | |
| 122 | return ret == 1 ? 0 : -EIO; |
| 123 | } |
| 124 | |
| 125 | static int reg_read(struct i2c_client *client, const u16 addr) |
| 126 | { |
| 127 | u8 buf[2] = {addr >> 8, addr & 0xff}; |
| 128 | int ret; |
| 129 | struct i2c_msg msgs[] = { |
| 130 | { |
| 131 | .addr = client->addr, |
| 132 | .flags = 0, |
| 133 | .len = 2, |
| 134 | .buf = buf, |
| 135 | }, { |
| 136 | .addr = client->addr, |
| 137 | .flags = I2C_M_RD, |
| 138 | .len = 2, |
| 139 | .buf = buf, |
| 140 | }, |
| 141 | }; |
| 142 | |
| 143 | ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); |
| 144 | if (ret < 0) { |
| 145 | dev_warn(&client->dev, "Reading register %x from %x failed\n", |
| 146 | addr, client->addr); |
| 147 | return ret; |
| 148 | } |
| 149 | |
| 150 | return buf[0] & 0xff; /* no sign-extension */ |
| 151 | } |
| 152 | |
| 153 | static int imx074_try_fmt(struct v4l2_subdev *sd, |
| 154 | struct v4l2_mbus_framefmt *mf) |
| 155 | { |
| 156 | const struct imx074_datafmt *fmt = imx074_find_datafmt(mf->code); |
| 157 | |
| 158 | dev_dbg(sd->v4l2_dev->dev, "%s(%u)\n", __func__, mf->code); |
| 159 | |
| 160 | if (!fmt) { |
| 161 | mf->code = imx074_colour_fmts[0].code; |
| 162 | mf->colorspace = imx074_colour_fmts[0].colorspace; |
| 163 | } |
| 164 | |
| 165 | mf->width = IMX074_WIDTH; |
| 166 | mf->height = IMX074_HEIGHT; |
| 167 | mf->field = V4L2_FIELD_NONE; |
| 168 | |
| 169 | return 0; |
| 170 | } |
| 171 | |
| 172 | static int imx074_s_fmt(struct v4l2_subdev *sd, |
| 173 | struct v4l2_mbus_framefmt *mf) |
| 174 | { |
| 175 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
| 176 | struct imx074 *priv = to_imx074(client); |
| 177 | |
| 178 | dev_dbg(sd->v4l2_dev->dev, "%s(%u)\n", __func__, mf->code); |
| 179 | |
| 180 | /* MIPI CSI could have changed the format, double-check */ |
| 181 | if (!imx074_find_datafmt(mf->code)) |
| 182 | return -EINVAL; |
| 183 | |
| 184 | imx074_try_fmt(sd, mf); |
| 185 | |
| 186 | priv->fmt = imx074_find_datafmt(mf->code); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | static int imx074_g_fmt(struct v4l2_subdev *sd, |
| 192 | struct v4l2_mbus_framefmt *mf) |
| 193 | { |
| 194 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
| 195 | struct imx074 *priv = to_imx074(client); |
| 196 | |
| 197 | const struct imx074_datafmt *fmt = priv->fmt; |
| 198 | |
| 199 | mf->code = fmt->code; |
| 200 | mf->colorspace = fmt->colorspace; |
| 201 | mf->width = IMX074_WIDTH; |
| 202 | mf->height = IMX074_HEIGHT; |
| 203 | mf->field = V4L2_FIELD_NONE; |
| 204 | |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | static int imx074_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) |
| 209 | { |
| 210 | struct v4l2_rect *rect = &a->c; |
| 211 | |
| 212 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 213 | rect->top = 0; |
| 214 | rect->left = 0; |
| 215 | rect->width = IMX074_WIDTH; |
| 216 | rect->height = IMX074_HEIGHT; |
| 217 | |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | static int imx074_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) |
| 222 | { |
| 223 | a->bounds.left = 0; |
| 224 | a->bounds.top = 0; |
| 225 | a->bounds.width = IMX074_WIDTH; |
| 226 | a->bounds.height = IMX074_HEIGHT; |
| 227 | a->defrect = a->bounds; |
| 228 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 229 | a->pixelaspect.numerator = 1; |
| 230 | a->pixelaspect.denominator = 1; |
| 231 | |
| 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | static int imx074_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
| 236 | enum v4l2_mbus_pixelcode *code) |
| 237 | { |
| 238 | if ((unsigned int)index >= ARRAY_SIZE(imx074_colour_fmts)) |
| 239 | return -EINVAL; |
| 240 | |
| 241 | *code = imx074_colour_fmts[index].code; |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | static int imx074_s_stream(struct v4l2_subdev *sd, int enable) |
| 246 | { |
| 247 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
| 248 | |
| 249 | /* MODE_SELECT: stream or standby */ |
| 250 | return reg_write(client, MODE_SELECT, !!enable); |
| 251 | } |
| 252 | |
Laurent Pinchart | 4ec10ba | 2012-07-20 10:19:50 -0300 | [diff] [blame] | 253 | static int imx074_s_power(struct v4l2_subdev *sd, int on) |
| 254 | { |
| 255 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 256 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
Laurent Pinchart | 4ec10ba | 2012-07-20 10:19:50 -0300 | [diff] [blame] | 257 | |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 258 | return soc_camera_set_power(&client->dev, ssdd, on); |
Laurent Pinchart | 4ec10ba | 2012-07-20 10:19:50 -0300 | [diff] [blame] | 259 | } |
| 260 | |
Guennadi Liakhovetski | 7cd74ff | 2011-07-26 11:26:56 -0300 | [diff] [blame] | 261 | static int imx074_g_mbus_config(struct v4l2_subdev *sd, |
| 262 | struct v4l2_mbus_config *cfg) |
| 263 | { |
| 264 | cfg->type = V4L2_MBUS_CSI2; |
| 265 | cfg->flags = V4L2_MBUS_CSI2_2_LANE | |
| 266 | V4L2_MBUS_CSI2_CHANNEL_0 | |
| 267 | V4L2_MBUS_CSI2_CONTINUOUS_CLOCK; |
| 268 | |
| 269 | return 0; |
| 270 | } |
| 271 | |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 272 | static struct v4l2_subdev_video_ops imx074_subdev_video_ops = { |
| 273 | .s_stream = imx074_s_stream, |
| 274 | .s_mbus_fmt = imx074_s_fmt, |
| 275 | .g_mbus_fmt = imx074_g_fmt, |
| 276 | .try_mbus_fmt = imx074_try_fmt, |
| 277 | .enum_mbus_fmt = imx074_enum_fmt, |
| 278 | .g_crop = imx074_g_crop, |
| 279 | .cropcap = imx074_cropcap, |
Guennadi Liakhovetski | 7cd74ff | 2011-07-26 11:26:56 -0300 | [diff] [blame] | 280 | .g_mbus_config = imx074_g_mbus_config, |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | static struct v4l2_subdev_core_ops imx074_subdev_core_ops = { |
Laurent Pinchart | 4ec10ba | 2012-07-20 10:19:50 -0300 | [diff] [blame] | 284 | .s_power = imx074_s_power, |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 285 | }; |
| 286 | |
| 287 | static struct v4l2_subdev_ops imx074_subdev_ops = { |
| 288 | .core = &imx074_subdev_core_ops, |
| 289 | .video = &imx074_subdev_video_ops, |
| 290 | }; |
| 291 | |
Guennadi Liakhovetski | 14178aa | 2011-09-21 15:16:30 -0300 | [diff] [blame] | 292 | static int imx074_video_probe(struct i2c_client *client) |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 293 | { |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 294 | struct v4l2_subdev *subdev = i2c_get_clientdata(client); |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 295 | int ret; |
| 296 | u16 id; |
| 297 | |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 298 | ret = imx074_s_power(subdev, 1); |
| 299 | if (ret < 0) |
| 300 | return ret; |
| 301 | |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 302 | /* Read sensor Model ID */ |
| 303 | ret = reg_read(client, 0); |
| 304 | if (ret < 0) |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 305 | goto done; |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 306 | |
| 307 | id = ret << 8; |
| 308 | |
| 309 | ret = reg_read(client, 1); |
| 310 | if (ret < 0) |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 311 | goto done; |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 312 | |
| 313 | id |= ret; |
| 314 | |
| 315 | dev_info(&client->dev, "Chip ID 0x%04x detected\n", id); |
| 316 | |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 317 | if (id != 0x74) { |
| 318 | ret = -ENODEV; |
| 319 | goto done; |
| 320 | } |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 321 | |
| 322 | /* PLL Setting EXTCLK=24MHz, 22.5times */ |
| 323 | reg_write(client, PLL_MULTIPLIER, 0x2D); |
| 324 | reg_write(client, PRE_PLL_CLK_DIV, 0x02); |
| 325 | reg_write(client, PLSTATIM, 0x4B); |
| 326 | |
| 327 | /* 2-lane mode */ |
| 328 | reg_write(client, 0x3024, 0x00); |
| 329 | |
| 330 | reg_write(client, IMAGE_ORIENTATION, 0x00); |
| 331 | |
| 332 | /* select RAW mode: |
| 333 | * 0x08+0x08 = top 8 bits |
| 334 | * 0x0a+0x08 = compressed 8-bits |
| 335 | * 0x0a+0x0a = 10 bits |
| 336 | */ |
| 337 | reg_write(client, 0x0112, 0x08); |
| 338 | reg_write(client, 0x0113, 0x08); |
| 339 | |
| 340 | /* Base setting for High frame mode */ |
| 341 | reg_write(client, VNDMY_ABLMGSHLMT, 0x80); |
| 342 | reg_write(client, Y_OPBADDR_START_DI, 0x08); |
| 343 | reg_write(client, 0x3015, 0x37); |
| 344 | reg_write(client, 0x301C, 0x01); |
| 345 | reg_write(client, 0x302C, 0x05); |
| 346 | reg_write(client, 0x3031, 0x26); |
| 347 | reg_write(client, 0x3041, 0x60); |
| 348 | reg_write(client, 0x3051, 0x24); |
| 349 | reg_write(client, 0x3053, 0x34); |
| 350 | reg_write(client, 0x3057, 0xC0); |
| 351 | reg_write(client, 0x305C, 0x09); |
| 352 | reg_write(client, 0x305D, 0x07); |
| 353 | reg_write(client, 0x3060, 0x30); |
| 354 | reg_write(client, 0x3065, 0x00); |
| 355 | reg_write(client, 0x30AA, 0x08); |
| 356 | reg_write(client, 0x30AB, 0x1C); |
| 357 | reg_write(client, 0x30B0, 0x32); |
| 358 | reg_write(client, 0x30B2, 0x83); |
| 359 | reg_write(client, 0x30D3, 0x04); |
| 360 | reg_write(client, 0x3106, 0x78); |
| 361 | reg_write(client, 0x310C, 0x82); |
| 362 | reg_write(client, 0x3304, 0x05); |
| 363 | reg_write(client, 0x3305, 0x04); |
| 364 | reg_write(client, 0x3306, 0x11); |
| 365 | reg_write(client, 0x3307, 0x02); |
| 366 | reg_write(client, 0x3308, 0x0C); |
| 367 | reg_write(client, 0x3309, 0x06); |
| 368 | reg_write(client, 0x330A, 0x08); |
| 369 | reg_write(client, 0x330B, 0x04); |
| 370 | reg_write(client, 0x330C, 0x08); |
| 371 | reg_write(client, 0x330D, 0x06); |
| 372 | reg_write(client, 0x330E, 0x01); |
| 373 | reg_write(client, 0x3381, 0x00); |
| 374 | |
| 375 | /* V : 1/2V-addition (1,3), H : 1/2H-averaging (1,3) -> Full HD */ |
| 376 | /* 1608 = 1560 + 48 (black lines) */ |
| 377 | reg_write(client, FRAME_LENGTH_LINES_HI, 0x06); |
| 378 | reg_write(client, FRAME_LENGTH_LINES_LO, 0x48); |
| 379 | reg_write(client, YADDR_START, 0x00); |
| 380 | reg_write(client, YADDR_END, 0x2F); |
| 381 | /* 0x838 == 2104 */ |
| 382 | reg_write(client, X_OUTPUT_SIZE_MSB, 0x08); |
| 383 | reg_write(client, X_OUTPUT_SIZE_LSB, 0x38); |
| 384 | /* 0x618 == 1560 */ |
| 385 | reg_write(client, Y_OUTPUT_SIZE_MSB, 0x06); |
| 386 | reg_write(client, Y_OUTPUT_SIZE_LSB, 0x18); |
| 387 | reg_write(client, X_EVEN_INC, 0x01); |
| 388 | reg_write(client, X_ODD_INC, 0x03); |
| 389 | reg_write(client, Y_EVEN_INC, 0x01); |
| 390 | reg_write(client, Y_ODD_INC, 0x03); |
| 391 | reg_write(client, HMODEADD, 0x00); |
| 392 | reg_write(client, VMODEADD, 0x16); |
| 393 | reg_write(client, VAPPLINE_START, 0x24); |
| 394 | reg_write(client, VAPPLINE_END, 0x53); |
| 395 | reg_write(client, SHUTTER, 0x00); |
| 396 | reg_write(client, HADDAVE, 0x80); |
| 397 | |
| 398 | reg_write(client, LANESEL, 0x00); |
| 399 | |
| 400 | reg_write(client, GROUPED_PARAMETER_HOLD, 0x00); /* off */ |
| 401 | |
Laurent Pinchart | 4bbc6d5 | 2012-07-18 10:54:04 -0300 | [diff] [blame] | 402 | ret = 0; |
| 403 | |
| 404 | done: |
| 405 | imx074_s_power(subdev, 0); |
| 406 | return ret; |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | static int imx074_probe(struct i2c_client *client, |
| 410 | const struct i2c_device_id *did) |
| 411 | { |
| 412 | struct imx074 *priv; |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 413 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 414 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 415 | |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 416 | if (!ssdd) { |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 417 | dev_err(&client->dev, "IMX074: missing platform data!\n"); |
| 418 | return -EINVAL; |
| 419 | } |
| 420 | |
| 421 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
| 422 | dev_warn(&adapter->dev, |
| 423 | "I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE\n"); |
| 424 | return -EIO; |
| 425 | } |
| 426 | |
Guennadi Liakhovetski | 70e176a | 2012-12-21 10:28:43 -0300 | [diff] [blame] | 427 | priv = devm_kzalloc(&client->dev, sizeof(struct imx074), GFP_KERNEL); |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 428 | if (!priv) |
| 429 | return -ENOMEM; |
| 430 | |
| 431 | v4l2_i2c_subdev_init(&priv->subdev, client, &imx074_subdev_ops); |
| 432 | |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 433 | priv->fmt = &imx074_colour_fmts[0]; |
| 434 | |
Guennadi Liakhovetski | 70e176a | 2012-12-21 10:28:43 -0300 | [diff] [blame] | 435 | return imx074_video_probe(client); |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | static int imx074_remove(struct i2c_client *client) |
| 439 | { |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 440 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 441 | |
Guennadi Liakhovetski | 25a3481 | 2012-12-21 08:11:48 -0300 | [diff] [blame] | 442 | if (ssdd->free_bus) |
| 443 | ssdd->free_bus(ssdd); |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 444 | |
| 445 | return 0; |
| 446 | } |
| 447 | |
| 448 | static const struct i2c_device_id imx074_id[] = { |
| 449 | { "imx074", 0 }, |
| 450 | { } |
| 451 | }; |
| 452 | MODULE_DEVICE_TABLE(i2c, imx074_id); |
| 453 | |
| 454 | static struct i2c_driver imx074_i2c_driver = { |
| 455 | .driver = { |
| 456 | .name = "imx074", |
| 457 | }, |
| 458 | .probe = imx074_probe, |
| 459 | .remove = imx074_remove, |
| 460 | .id_table = imx074_id, |
| 461 | }; |
| 462 | |
Axel Lin | c6e8d86 | 2012-02-12 06:56:32 -0300 | [diff] [blame] | 463 | module_i2c_driver(imx074_i2c_driver); |
Guennadi Liakhovetski | 6782623 | 2010-10-05 12:33:25 -0300 | [diff] [blame] | 464 | |
| 465 | MODULE_DESCRIPTION("Sony IMX074 Camera driver"); |
| 466 | MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>"); |
| 467 | MODULE_LICENSE("GPL v2"); |