mt9m111.c 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. /*
  2. * Driver for MT9M111/MT9M112/MT9M131 CMOS Image Sensor from Micron/Aptina
  3. *
  4. * Copyright (C) 2008, Robert Jarzmik <robert.jarzmik@free.fr>
  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. #include <linux/videodev2.h>
  11. #include <linux/slab.h>
  12. #include <linux/i2c.h>
  13. #include <linux/log2.h>
  14. #include <linux/gpio.h>
  15. #include <linux/delay.h>
  16. #include <media/v4l2-common.h>
  17. #include <media/v4l2-chip-ident.h>
  18. #include <media/soc_camera.h>
  19. /*
  20. * MT9M111, MT9M112 and MT9M131:
  21. * i2c address is 0x48 or 0x5d (depending on SADDR pin)
  22. * The platform has to define i2c_board_info and call i2c_register_board_info()
  23. */
  24. /*
  25. * Sensor core register addresses (0x000..0x0ff)
  26. */
  27. #define MT9M111_CHIP_VERSION 0x000
  28. #define MT9M111_ROW_START 0x001
  29. #define MT9M111_COLUMN_START 0x002
  30. #define MT9M111_WINDOW_HEIGHT 0x003
  31. #define MT9M111_WINDOW_WIDTH 0x004
  32. #define MT9M111_HORIZONTAL_BLANKING_B 0x005
  33. #define MT9M111_VERTICAL_BLANKING_B 0x006
  34. #define MT9M111_HORIZONTAL_BLANKING_A 0x007
  35. #define MT9M111_VERTICAL_BLANKING_A 0x008
  36. #define MT9M111_SHUTTER_WIDTH 0x009
  37. #define MT9M111_ROW_SPEED 0x00a
  38. #define MT9M111_EXTRA_DELAY 0x00b
  39. #define MT9M111_SHUTTER_DELAY 0x00c
  40. #define MT9M111_RESET 0x00d
  41. #define MT9M111_READ_MODE_B 0x020
  42. #define MT9M111_READ_MODE_A 0x021
  43. #define MT9M111_FLASH_CONTROL 0x023
  44. #define MT9M111_GREEN1_GAIN 0x02b
  45. #define MT9M111_BLUE_GAIN 0x02c
  46. #define MT9M111_RED_GAIN 0x02d
  47. #define MT9M111_GREEN2_GAIN 0x02e
  48. #define MT9M111_GLOBAL_GAIN 0x02f
  49. #define MT9M111_CONTEXT_CONTROL 0x0c8
  50. #define MT9M111_PAGE_MAP 0x0f0
  51. #define MT9M111_BYTE_WISE_ADDR 0x0f1
  52. #define MT9M111_RESET_SYNC_CHANGES (1 << 15)
  53. #define MT9M111_RESET_RESTART_BAD_FRAME (1 << 9)
  54. #define MT9M111_RESET_SHOW_BAD_FRAMES (1 << 8)
  55. #define MT9M111_RESET_RESET_SOC (1 << 5)
  56. #define MT9M111_RESET_OUTPUT_DISABLE (1 << 4)
  57. #define MT9M111_RESET_CHIP_ENABLE (1 << 3)
  58. #define MT9M111_RESET_ANALOG_STANDBY (1 << 2)
  59. #define MT9M111_RESET_RESTART_FRAME (1 << 1)
  60. #define MT9M111_RESET_RESET_MODE (1 << 0)
  61. #define MT9M111_RMB_MIRROR_COLS (1 << 1)
  62. #define MT9M111_RMB_MIRROR_ROWS (1 << 0)
  63. #define MT9M111_CTXT_CTRL_RESTART (1 << 15)
  64. #define MT9M111_CTXT_CTRL_DEFECTCOR_B (1 << 12)
  65. #define MT9M111_CTXT_CTRL_RESIZE_B (1 << 10)
  66. #define MT9M111_CTXT_CTRL_CTRL2_B (1 << 9)
  67. #define MT9M111_CTXT_CTRL_GAMMA_B (1 << 8)
  68. #define MT9M111_CTXT_CTRL_XENON_EN (1 << 7)
  69. #define MT9M111_CTXT_CTRL_READ_MODE_B (1 << 3)
  70. #define MT9M111_CTXT_CTRL_LED_FLASH_EN (1 << 2)
  71. #define MT9M111_CTXT_CTRL_VBLANK_SEL_B (1 << 1)
  72. #define MT9M111_CTXT_CTRL_HBLANK_SEL_B (1 << 0)
  73. /*
  74. * Colorpipe register addresses (0x100..0x1ff)
  75. */
  76. #define MT9M111_OPER_MODE_CTRL 0x106
  77. #define MT9M111_OUTPUT_FORMAT_CTRL 0x108
  78. #define MT9M111_REDUCER_XZOOM_B 0x1a0
  79. #define MT9M111_REDUCER_XSIZE_B 0x1a1
  80. #define MT9M111_REDUCER_YZOOM_B 0x1a3
  81. #define MT9M111_REDUCER_YSIZE_B 0x1a4
  82. #define MT9M111_REDUCER_XZOOM_A 0x1a6
  83. #define MT9M111_REDUCER_XSIZE_A 0x1a7
  84. #define MT9M111_REDUCER_YZOOM_A 0x1a9
  85. #define MT9M111_REDUCER_YSIZE_A 0x1aa
  86. #define MT9M111_OUTPUT_FORMAT_CTRL2_A 0x13a
  87. #define MT9M111_OUTPUT_FORMAT_CTRL2_B 0x19b
  88. #define MT9M111_OPMODE_AUTOEXPO_EN (1 << 14)
  89. #define MT9M111_OPMODE_AUTOWHITEBAL_EN (1 << 1)
  90. #define MT9M111_OUTFMT_PROCESSED_BAYER (1 << 14)
  91. #define MT9M111_OUTFMT_BYPASS_IFP (1 << 10)
  92. #define MT9M111_OUTFMT_INV_PIX_CLOCK (1 << 9)
  93. #define MT9M111_OUTFMT_RGB (1 << 8)
  94. #define MT9M111_OUTFMT_RGB565 (0 << 6)
  95. #define MT9M111_OUTFMT_RGB555 (1 << 6)
  96. #define MT9M111_OUTFMT_RGB444x (2 << 6)
  97. #define MT9M111_OUTFMT_RGBx444 (3 << 6)
  98. #define MT9M111_OUTFMT_TST_RAMP_OFF (0 << 4)
  99. #define MT9M111_OUTFMT_TST_RAMP_COL (1 << 4)
  100. #define MT9M111_OUTFMT_TST_RAMP_ROW (2 << 4)
  101. #define MT9M111_OUTFMT_TST_RAMP_FRAME (3 << 4)
  102. #define MT9M111_OUTFMT_SHIFT_3_UP (1 << 3)
  103. #define MT9M111_OUTFMT_AVG_CHROMA (1 << 2)
  104. #define MT9M111_OUTFMT_SWAP_YCbCr_C_Y (1 << 1)
  105. #define MT9M111_OUTFMT_SWAP_RGB_EVEN (1 << 1)
  106. #define MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr (1 << 0)
  107. /*
  108. * Camera control register addresses (0x200..0x2ff not implemented)
  109. */
  110. #define reg_read(reg) mt9m111_reg_read(client, MT9M111_##reg)
  111. #define reg_write(reg, val) mt9m111_reg_write(client, MT9M111_##reg, (val))
  112. #define reg_set(reg, val) mt9m111_reg_set(client, MT9M111_##reg, (val))
  113. #define reg_clear(reg, val) mt9m111_reg_clear(client, MT9M111_##reg, (val))
  114. #define MT9M111_MIN_DARK_ROWS 8
  115. #define MT9M111_MIN_DARK_COLS 26
  116. #define MT9M111_MAX_HEIGHT 1024
  117. #define MT9M111_MAX_WIDTH 1280
  118. /* MT9M111 has only one fixed colorspace per pixelcode */
  119. struct mt9m111_datafmt {
  120. enum v4l2_mbus_pixelcode code;
  121. enum v4l2_colorspace colorspace;
  122. };
  123. /* Find a data format by a pixel code in an array */
  124. static const struct mt9m111_datafmt *mt9m111_find_datafmt(
  125. enum v4l2_mbus_pixelcode code, const struct mt9m111_datafmt *fmt,
  126. int n)
  127. {
  128. int i;
  129. for (i = 0; i < n; i++)
  130. if (fmt[i].code == code)
  131. return fmt + i;
  132. return NULL;
  133. }
  134. static const struct mt9m111_datafmt mt9m111_colour_fmts[] = {
  135. {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
  136. {V4L2_MBUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG},
  137. {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
  138. {V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG},
  139. {V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
  140. {V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
  141. {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
  142. {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
  143. };
  144. enum mt9m111_context {
  145. HIGHPOWER = 0,
  146. LOWPOWER,
  147. };
  148. struct mt9m111 {
  149. struct v4l2_subdev subdev;
  150. int model; /* V4L2_IDENT_MT9M111 or V4L2_IDENT_MT9M112 code
  151. * from v4l2-chip-ident.h */
  152. enum mt9m111_context context;
  153. struct v4l2_rect rect;
  154. const struct mt9m111_datafmt *fmt;
  155. unsigned int gain;
  156. unsigned char autoexposure;
  157. unsigned char datawidth;
  158. unsigned int powered:1;
  159. unsigned int hflip:1;
  160. unsigned int vflip:1;
  161. unsigned int swap_rgb_even_odd:1;
  162. unsigned int swap_rgb_red_blue:1;
  163. unsigned int swap_yuv_y_chromas:1;
  164. unsigned int swap_yuv_cb_cr:1;
  165. unsigned int autowhitebalance:1;
  166. };
  167. static struct mt9m111 *to_mt9m111(const struct i2c_client *client)
  168. {
  169. return container_of(i2c_get_clientdata(client), struct mt9m111, subdev);
  170. }
  171. static int reg_page_map_set(struct i2c_client *client, const u16 reg)
  172. {
  173. int ret;
  174. u16 page;
  175. static int lastpage = -1; /* PageMap cache value */
  176. page = (reg >> 8);
  177. if (page == lastpage)
  178. return 0;
  179. if (page > 2)
  180. return -EINVAL;
  181. ret = i2c_smbus_write_word_data(client, MT9M111_PAGE_MAP, swab16(page));
  182. if (!ret)
  183. lastpage = page;
  184. return ret;
  185. }
  186. static int mt9m111_reg_read(struct i2c_client *client, const u16 reg)
  187. {
  188. int ret;
  189. ret = reg_page_map_set(client, reg);
  190. if (!ret)
  191. ret = swab16(i2c_smbus_read_word_data(client, reg & 0xff));
  192. dev_dbg(&client->dev, "read reg.%03x -> %04x\n", reg, ret);
  193. return ret;
  194. }
  195. static int mt9m111_reg_write(struct i2c_client *client, const u16 reg,
  196. const u16 data)
  197. {
  198. int ret;
  199. ret = reg_page_map_set(client, reg);
  200. if (!ret)
  201. ret = i2c_smbus_write_word_data(client, reg & 0xff,
  202. swab16(data));
  203. dev_dbg(&client->dev, "write reg.%03x = %04x -> %d\n", reg, data, ret);
  204. return ret;
  205. }
  206. static int mt9m111_reg_set(struct i2c_client *client, const u16 reg,
  207. const u16 data)
  208. {
  209. int ret;
  210. ret = mt9m111_reg_read(client, reg);
  211. if (ret >= 0)
  212. ret = mt9m111_reg_write(client, reg, ret | data);
  213. return ret;
  214. }
  215. static int mt9m111_reg_clear(struct i2c_client *client, const u16 reg,
  216. const u16 data)
  217. {
  218. int ret;
  219. ret = mt9m111_reg_read(client, reg);
  220. return mt9m111_reg_write(client, reg, ret & ~data);
  221. }
  222. static int mt9m111_set_context(struct i2c_client *client,
  223. enum mt9m111_context ctxt)
  224. {
  225. int valB = MT9M111_CTXT_CTRL_RESTART | MT9M111_CTXT_CTRL_DEFECTCOR_B
  226. | MT9M111_CTXT_CTRL_RESIZE_B | MT9M111_CTXT_CTRL_CTRL2_B
  227. | MT9M111_CTXT_CTRL_GAMMA_B | MT9M111_CTXT_CTRL_READ_MODE_B
  228. | MT9M111_CTXT_CTRL_VBLANK_SEL_B
  229. | MT9M111_CTXT_CTRL_HBLANK_SEL_B;
  230. int valA = MT9M111_CTXT_CTRL_RESTART;
  231. if (ctxt == HIGHPOWER)
  232. return reg_write(CONTEXT_CONTROL, valB);
  233. else
  234. return reg_write(CONTEXT_CONTROL, valA);
  235. }
  236. static int mt9m111_setup_rect(struct i2c_client *client,
  237. struct v4l2_rect *rect)
  238. {
  239. struct mt9m111 *mt9m111 = to_mt9m111(client);
  240. int ret, is_raw_format;
  241. int width = rect->width;
  242. int height = rect->height;
  243. if (mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
  244. mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE)
  245. is_raw_format = 1;
  246. else
  247. is_raw_format = 0;
  248. ret = reg_write(COLUMN_START, rect->left);
  249. if (!ret)
  250. ret = reg_write(ROW_START, rect->top);
  251. if (is_raw_format) {
  252. if (!ret)
  253. ret = reg_write(WINDOW_WIDTH, width);
  254. if (!ret)
  255. ret = reg_write(WINDOW_HEIGHT, height);
  256. } else {
  257. if (!ret)
  258. ret = reg_write(REDUCER_XZOOM_B, MT9M111_MAX_WIDTH);
  259. if (!ret)
  260. ret = reg_write(REDUCER_YZOOM_B, MT9M111_MAX_HEIGHT);
  261. if (!ret)
  262. ret = reg_write(REDUCER_XSIZE_B, width);
  263. if (!ret)
  264. ret = reg_write(REDUCER_YSIZE_B, height);
  265. if (!ret)
  266. ret = reg_write(REDUCER_XZOOM_A, MT9M111_MAX_WIDTH);
  267. if (!ret)
  268. ret = reg_write(REDUCER_YZOOM_A, MT9M111_MAX_HEIGHT);
  269. if (!ret)
  270. ret = reg_write(REDUCER_XSIZE_A, width);
  271. if (!ret)
  272. ret = reg_write(REDUCER_YSIZE_A, height);
  273. }
  274. return ret;
  275. }
  276. static int mt9m111_setup_pixfmt(struct i2c_client *client, u16 outfmt)
  277. {
  278. int ret;
  279. ret = reg_write(OUTPUT_FORMAT_CTRL2_A, outfmt);
  280. if (!ret)
  281. ret = reg_write(OUTPUT_FORMAT_CTRL2_B, outfmt);
  282. return ret;
  283. }
  284. static int mt9m111_setfmt_bayer8(struct i2c_client *client)
  285. {
  286. return mt9m111_setup_pixfmt(client, MT9M111_OUTFMT_PROCESSED_BAYER |
  287. MT9M111_OUTFMT_RGB);
  288. }
  289. static int mt9m111_setfmt_bayer10(struct i2c_client *client)
  290. {
  291. return mt9m111_setup_pixfmt(client, MT9M111_OUTFMT_BYPASS_IFP);
  292. }
  293. static int mt9m111_setfmt_rgb565(struct i2c_client *client)
  294. {
  295. struct mt9m111 *mt9m111 = to_mt9m111(client);
  296. int val = 0;
  297. if (mt9m111->swap_rgb_red_blue)
  298. val |= MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr;
  299. if (mt9m111->swap_rgb_even_odd)
  300. val |= MT9M111_OUTFMT_SWAP_RGB_EVEN;
  301. val |= MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565;
  302. return mt9m111_setup_pixfmt(client, val);
  303. }
  304. static int mt9m111_setfmt_rgb555(struct i2c_client *client)
  305. {
  306. struct mt9m111 *mt9m111 = to_mt9m111(client);
  307. int val = 0;
  308. if (mt9m111->swap_rgb_red_blue)
  309. val |= MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr;
  310. if (mt9m111->swap_rgb_even_odd)
  311. val |= MT9M111_OUTFMT_SWAP_RGB_EVEN;
  312. val |= MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB555;
  313. return mt9m111_setup_pixfmt(client, val);
  314. }
  315. static int mt9m111_setfmt_yuv(struct i2c_client *client)
  316. {
  317. struct mt9m111 *mt9m111 = to_mt9m111(client);
  318. int val = 0;
  319. if (mt9m111->swap_yuv_cb_cr)
  320. val |= MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr;
  321. if (mt9m111->swap_yuv_y_chromas)
  322. val |= MT9M111_OUTFMT_SWAP_YCbCr_C_Y;
  323. return mt9m111_setup_pixfmt(client, val);
  324. }
  325. static int mt9m111_enable(struct i2c_client *client)
  326. {
  327. struct mt9m111 *mt9m111 = to_mt9m111(client);
  328. int ret;
  329. ret = reg_set(RESET, MT9M111_RESET_CHIP_ENABLE);
  330. if (!ret)
  331. mt9m111->powered = 1;
  332. return ret;
  333. }
  334. static int mt9m111_reset(struct i2c_client *client)
  335. {
  336. int ret;
  337. ret = reg_set(RESET, MT9M111_RESET_RESET_MODE);
  338. if (!ret)
  339. ret = reg_set(RESET, MT9M111_RESET_RESET_SOC);
  340. if (!ret)
  341. ret = reg_clear(RESET, MT9M111_RESET_RESET_MODE
  342. | MT9M111_RESET_RESET_SOC);
  343. return ret;
  344. }
  345. static unsigned long mt9m111_query_bus_param(struct soc_camera_device *icd)
  346. {
  347. struct soc_camera_link *icl = to_soc_camera_link(icd);
  348. unsigned long flags = SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |
  349. SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH |
  350. SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8;
  351. return soc_camera_apply_sensor_flags(icl, flags);
  352. }
  353. static int mt9m111_set_bus_param(struct soc_camera_device *icd, unsigned long f)
  354. {
  355. return 0;
  356. }
  357. static int mt9m111_make_rect(struct i2c_client *client,
  358. struct v4l2_rect *rect)
  359. {
  360. struct mt9m111 *mt9m111 = to_mt9m111(client);
  361. if (mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
  362. mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) {
  363. /* Bayer format - even size lengths */
  364. rect->width = ALIGN(rect->width, 2);
  365. rect->height = ALIGN(rect->height, 2);
  366. /* Let the user play with the starting pixel */
  367. }
  368. /* FIXME: the datasheet doesn't specify minimum sizes */
  369. soc_camera_limit_side(&rect->left, &rect->width,
  370. MT9M111_MIN_DARK_COLS, 2, MT9M111_MAX_WIDTH);
  371. soc_camera_limit_side(&rect->top, &rect->height,
  372. MT9M111_MIN_DARK_ROWS, 2, MT9M111_MAX_HEIGHT);
  373. return mt9m111_setup_rect(client, rect);
  374. }
  375. static int mt9m111_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
  376. {
  377. struct v4l2_rect rect = a->c;
  378. struct i2c_client *client = v4l2_get_subdevdata(sd);
  379. struct mt9m111 *mt9m111 = to_mt9m111(client);
  380. int ret;
  381. dev_dbg(&client->dev, "%s left=%d, top=%d, width=%d, height=%d\n",
  382. __func__, rect.left, rect.top, rect.width, rect.height);
  383. if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
  384. return -EINVAL;
  385. ret = mt9m111_make_rect(client, &rect);
  386. if (!ret)
  387. mt9m111->rect = rect;
  388. return ret;
  389. }
  390. static int mt9m111_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
  391. {
  392. struct i2c_client *client = v4l2_get_subdevdata(sd);
  393. struct mt9m111 *mt9m111 = to_mt9m111(client);
  394. a->c = mt9m111->rect;
  395. a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  396. return 0;
  397. }
  398. static int mt9m111_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
  399. {
  400. if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
  401. return -EINVAL;
  402. a->bounds.left = MT9M111_MIN_DARK_COLS;
  403. a->bounds.top = MT9M111_MIN_DARK_ROWS;
  404. a->bounds.width = MT9M111_MAX_WIDTH;
  405. a->bounds.height = MT9M111_MAX_HEIGHT;
  406. a->defrect = a->bounds;
  407. a->pixelaspect.numerator = 1;
  408. a->pixelaspect.denominator = 1;
  409. return 0;
  410. }
  411. static int mt9m111_g_fmt(struct v4l2_subdev *sd,
  412. struct v4l2_mbus_framefmt *mf)
  413. {
  414. struct i2c_client *client = v4l2_get_subdevdata(sd);
  415. struct mt9m111 *mt9m111 = to_mt9m111(client);
  416. mf->width = mt9m111->rect.width;
  417. mf->height = mt9m111->rect.height;
  418. mf->code = mt9m111->fmt->code;
  419. mf->colorspace = mt9m111->fmt->colorspace;
  420. mf->field = V4L2_FIELD_NONE;
  421. return 0;
  422. }
  423. static int mt9m111_set_pixfmt(struct i2c_client *client,
  424. enum v4l2_mbus_pixelcode code)
  425. {
  426. struct mt9m111 *mt9m111 = to_mt9m111(client);
  427. int ret;
  428. switch (code) {
  429. case V4L2_MBUS_FMT_SBGGR8_1X8:
  430. ret = mt9m111_setfmt_bayer8(client);
  431. break;
  432. case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
  433. ret = mt9m111_setfmt_bayer10(client);
  434. break;
  435. case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
  436. ret = mt9m111_setfmt_rgb555(client);
  437. break;
  438. case V4L2_MBUS_FMT_RGB565_2X8_LE:
  439. ret = mt9m111_setfmt_rgb565(client);
  440. break;
  441. case V4L2_MBUS_FMT_UYVY8_2X8:
  442. mt9m111->swap_yuv_y_chromas = 0;
  443. mt9m111->swap_yuv_cb_cr = 0;
  444. ret = mt9m111_setfmt_yuv(client);
  445. break;
  446. case V4L2_MBUS_FMT_VYUY8_2X8:
  447. mt9m111->swap_yuv_y_chromas = 0;
  448. mt9m111->swap_yuv_cb_cr = 1;
  449. ret = mt9m111_setfmt_yuv(client);
  450. break;
  451. case V4L2_MBUS_FMT_YUYV8_2X8:
  452. mt9m111->swap_yuv_y_chromas = 1;
  453. mt9m111->swap_yuv_cb_cr = 0;
  454. ret = mt9m111_setfmt_yuv(client);
  455. break;
  456. case V4L2_MBUS_FMT_YVYU8_2X8:
  457. mt9m111->swap_yuv_y_chromas = 1;
  458. mt9m111->swap_yuv_cb_cr = 1;
  459. ret = mt9m111_setfmt_yuv(client);
  460. break;
  461. default:
  462. dev_err(&client->dev, "Pixel format not handled : %x\n",
  463. code);
  464. ret = -EINVAL;
  465. }
  466. return ret;
  467. }
  468. static int mt9m111_s_fmt(struct v4l2_subdev *sd,
  469. struct v4l2_mbus_framefmt *mf)
  470. {
  471. struct i2c_client *client = v4l2_get_subdevdata(sd);
  472. const struct mt9m111_datafmt *fmt;
  473. struct mt9m111 *mt9m111 = to_mt9m111(client);
  474. struct v4l2_rect rect = {
  475. .left = mt9m111->rect.left,
  476. .top = mt9m111->rect.top,
  477. .width = mf->width,
  478. .height = mf->height,
  479. };
  480. int ret;
  481. fmt = mt9m111_find_datafmt(mf->code, mt9m111_colour_fmts,
  482. ARRAY_SIZE(mt9m111_colour_fmts));
  483. if (!fmt)
  484. return -EINVAL;
  485. dev_dbg(&client->dev,
  486. "%s code=%x left=%d, top=%d, width=%d, height=%d\n", __func__,
  487. mf->code, rect.left, rect.top, rect.width, rect.height);
  488. ret = mt9m111_make_rect(client, &rect);
  489. if (!ret)
  490. ret = mt9m111_set_pixfmt(client, mf->code);
  491. if (!ret) {
  492. mt9m111->rect = rect;
  493. mt9m111->fmt = fmt;
  494. mf->colorspace = fmt->colorspace;
  495. }
  496. return ret;
  497. }
  498. static int mt9m111_try_fmt(struct v4l2_subdev *sd,
  499. struct v4l2_mbus_framefmt *mf)
  500. {
  501. struct i2c_client *client = v4l2_get_subdevdata(sd);
  502. struct mt9m111 *mt9m111 = to_mt9m111(client);
  503. const struct mt9m111_datafmt *fmt;
  504. bool bayer = mf->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
  505. mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE;
  506. fmt = mt9m111_find_datafmt(mf->code, mt9m111_colour_fmts,
  507. ARRAY_SIZE(mt9m111_colour_fmts));
  508. if (!fmt) {
  509. fmt = mt9m111->fmt;
  510. mf->code = fmt->code;
  511. }
  512. /*
  513. * With Bayer format enforce even side lengths, but let the user play
  514. * with the starting pixel
  515. */
  516. if (mf->height > MT9M111_MAX_HEIGHT)
  517. mf->height = MT9M111_MAX_HEIGHT;
  518. else if (mf->height < 2)
  519. mf->height = 2;
  520. else if (bayer)
  521. mf->height = ALIGN(mf->height, 2);
  522. if (mf->width > MT9M111_MAX_WIDTH)
  523. mf->width = MT9M111_MAX_WIDTH;
  524. else if (mf->width < 2)
  525. mf->width = 2;
  526. else if (bayer)
  527. mf->width = ALIGN(mf->width, 2);
  528. mf->colorspace = fmt->colorspace;
  529. return 0;
  530. }
  531. static int mt9m111_g_chip_ident(struct v4l2_subdev *sd,
  532. struct v4l2_dbg_chip_ident *id)
  533. {
  534. struct i2c_client *client = v4l2_get_subdevdata(sd);
  535. struct mt9m111 *mt9m111 = to_mt9m111(client);
  536. if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
  537. return -EINVAL;
  538. if (id->match.addr != client->addr)
  539. return -ENODEV;
  540. id->ident = mt9m111->model;
  541. id->revision = 0;
  542. return 0;
  543. }
  544. #ifdef CONFIG_VIDEO_ADV_DEBUG
  545. static int mt9m111_g_register(struct v4l2_subdev *sd,
  546. struct v4l2_dbg_register *reg)
  547. {
  548. struct i2c_client *client = v4l2_get_subdevdata(sd);
  549. int val;
  550. if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff)
  551. return -EINVAL;
  552. if (reg->match.addr != client->addr)
  553. return -ENODEV;
  554. val = mt9m111_reg_read(client, reg->reg);
  555. reg->size = 2;
  556. reg->val = (u64)val;
  557. if (reg->val > 0xffff)
  558. return -EIO;
  559. return 0;
  560. }
  561. static int mt9m111_s_register(struct v4l2_subdev *sd,
  562. struct v4l2_dbg_register *reg)
  563. {
  564. struct i2c_client *client = v4l2_get_subdevdata(sd);
  565. if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff)
  566. return -EINVAL;
  567. if (reg->match.addr != client->addr)
  568. return -ENODEV;
  569. if (mt9m111_reg_write(client, reg->reg, reg->val) < 0)
  570. return -EIO;
  571. return 0;
  572. }
  573. #endif
  574. static const struct v4l2_queryctrl mt9m111_controls[] = {
  575. {
  576. .id = V4L2_CID_VFLIP,
  577. .type = V4L2_CTRL_TYPE_BOOLEAN,
  578. .name = "Flip Verticaly",
  579. .minimum = 0,
  580. .maximum = 1,
  581. .step = 1,
  582. .default_value = 0,
  583. }, {
  584. .id = V4L2_CID_HFLIP,
  585. .type = V4L2_CTRL_TYPE_BOOLEAN,
  586. .name = "Flip Horizontaly",
  587. .minimum = 0,
  588. .maximum = 1,
  589. .step = 1,
  590. .default_value = 0,
  591. }, { /* gain = 1/32*val (=>gain=1 if val==32) */
  592. .id = V4L2_CID_GAIN,
  593. .type = V4L2_CTRL_TYPE_INTEGER,
  594. .name = "Gain",
  595. .minimum = 0,
  596. .maximum = 63 * 2 * 2,
  597. .step = 1,
  598. .default_value = 32,
  599. .flags = V4L2_CTRL_FLAG_SLIDER,
  600. }, {
  601. .id = V4L2_CID_EXPOSURE_AUTO,
  602. .type = V4L2_CTRL_TYPE_BOOLEAN,
  603. .name = "Auto Exposure",
  604. .minimum = 0,
  605. .maximum = 1,
  606. .step = 1,
  607. .default_value = 1,
  608. }
  609. };
  610. static int mt9m111_resume(struct soc_camera_device *icd);
  611. static int mt9m111_suspend(struct soc_camera_device *icd, pm_message_t state);
  612. static struct soc_camera_ops mt9m111_ops = {
  613. .suspend = mt9m111_suspend,
  614. .resume = mt9m111_resume,
  615. .query_bus_param = mt9m111_query_bus_param,
  616. .set_bus_param = mt9m111_set_bus_param,
  617. .controls = mt9m111_controls,
  618. .num_controls = ARRAY_SIZE(mt9m111_controls),
  619. };
  620. static int mt9m111_set_flip(struct i2c_client *client, int flip, int mask)
  621. {
  622. struct mt9m111 *mt9m111 = to_mt9m111(client);
  623. int ret;
  624. if (mt9m111->context == HIGHPOWER) {
  625. if (flip)
  626. ret = reg_set(READ_MODE_B, mask);
  627. else
  628. ret = reg_clear(READ_MODE_B, mask);
  629. } else {
  630. if (flip)
  631. ret = reg_set(READ_MODE_A, mask);
  632. else
  633. ret = reg_clear(READ_MODE_A, mask);
  634. }
  635. return ret;
  636. }
  637. static int mt9m111_get_global_gain(struct i2c_client *client)
  638. {
  639. int data;
  640. data = reg_read(GLOBAL_GAIN);
  641. if (data >= 0)
  642. return (data & 0x2f) * (1 << ((data >> 10) & 1)) *
  643. (1 << ((data >> 9) & 1));
  644. return data;
  645. }
  646. static int mt9m111_set_global_gain(struct i2c_client *client, int gain)
  647. {
  648. struct mt9m111 *mt9m111 = to_mt9m111(client);
  649. u16 val;
  650. if (gain > 63 * 2 * 2)
  651. return -EINVAL;
  652. mt9m111->gain = gain;
  653. if ((gain >= 64 * 2) && (gain < 63 * 2 * 2))
  654. val = (1 << 10) | (1 << 9) | (gain / 4);
  655. else if ((gain >= 64) && (gain < 64 * 2))
  656. val = (1 << 9) | (gain / 2);
  657. else
  658. val = gain;
  659. return reg_write(GLOBAL_GAIN, val);
  660. }
  661. static int mt9m111_set_autoexposure(struct i2c_client *client, int on)
  662. {
  663. struct mt9m111 *mt9m111 = to_mt9m111(client);
  664. int ret;
  665. if (on)
  666. ret = reg_set(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN);
  667. else
  668. ret = reg_clear(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN);
  669. if (!ret)
  670. mt9m111->autoexposure = on;
  671. return ret;
  672. }
  673. static int mt9m111_set_autowhitebalance(struct i2c_client *client, int on)
  674. {
  675. struct mt9m111 *mt9m111 = to_mt9m111(client);
  676. int ret;
  677. if (on)
  678. ret = reg_set(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOWHITEBAL_EN);
  679. else
  680. ret = reg_clear(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOWHITEBAL_EN);
  681. if (!ret)
  682. mt9m111->autowhitebalance = on;
  683. return ret;
  684. }
  685. static int mt9m111_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
  686. {
  687. struct i2c_client *client = v4l2_get_subdevdata(sd);
  688. struct mt9m111 *mt9m111 = to_mt9m111(client);
  689. int data;
  690. switch (ctrl->id) {
  691. case V4L2_CID_VFLIP:
  692. if (mt9m111->context == HIGHPOWER)
  693. data = reg_read(READ_MODE_B);
  694. else
  695. data = reg_read(READ_MODE_A);
  696. if (data < 0)
  697. return -EIO;
  698. ctrl->value = !!(data & MT9M111_RMB_MIRROR_ROWS);
  699. break;
  700. case V4L2_CID_HFLIP:
  701. if (mt9m111->context == HIGHPOWER)
  702. data = reg_read(READ_MODE_B);
  703. else
  704. data = reg_read(READ_MODE_A);
  705. if (data < 0)
  706. return -EIO;
  707. ctrl->value = !!(data & MT9M111_RMB_MIRROR_COLS);
  708. break;
  709. case V4L2_CID_GAIN:
  710. data = mt9m111_get_global_gain(client);
  711. if (data < 0)
  712. return data;
  713. ctrl->value = data;
  714. break;
  715. case V4L2_CID_EXPOSURE_AUTO:
  716. ctrl->value = mt9m111->autoexposure;
  717. break;
  718. case V4L2_CID_AUTO_WHITE_BALANCE:
  719. ctrl->value = mt9m111->autowhitebalance;
  720. break;
  721. }
  722. return 0;
  723. }
  724. static int mt9m111_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
  725. {
  726. struct i2c_client *client = v4l2_get_subdevdata(sd);
  727. struct mt9m111 *mt9m111 = to_mt9m111(client);
  728. const struct v4l2_queryctrl *qctrl;
  729. int ret;
  730. qctrl = soc_camera_find_qctrl(&mt9m111_ops, ctrl->id);
  731. if (!qctrl)
  732. return -EINVAL;
  733. switch (ctrl->id) {
  734. case V4L2_CID_VFLIP:
  735. mt9m111->vflip = ctrl->value;
  736. ret = mt9m111_set_flip(client, ctrl->value,
  737. MT9M111_RMB_MIRROR_ROWS);
  738. break;
  739. case V4L2_CID_HFLIP:
  740. mt9m111->hflip = ctrl->value;
  741. ret = mt9m111_set_flip(client, ctrl->value,
  742. MT9M111_RMB_MIRROR_COLS);
  743. break;
  744. case V4L2_CID_GAIN:
  745. ret = mt9m111_set_global_gain(client, ctrl->value);
  746. break;
  747. case V4L2_CID_EXPOSURE_AUTO:
  748. ret = mt9m111_set_autoexposure(client, ctrl->value);
  749. break;
  750. case V4L2_CID_AUTO_WHITE_BALANCE:
  751. ret = mt9m111_set_autowhitebalance(client, ctrl->value);
  752. break;
  753. default:
  754. ret = -EINVAL;
  755. }
  756. return ret;
  757. }
  758. static int mt9m111_suspend(struct soc_camera_device *icd, pm_message_t state)
  759. {
  760. struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
  761. struct mt9m111 *mt9m111 = to_mt9m111(client);
  762. mt9m111->gain = mt9m111_get_global_gain(client);
  763. return 0;
  764. }
  765. static int mt9m111_restore_state(struct i2c_client *client)
  766. {
  767. struct mt9m111 *mt9m111 = to_mt9m111(client);
  768. mt9m111_set_context(client, mt9m111->context);
  769. mt9m111_set_pixfmt(client, mt9m111->fmt->code);
  770. mt9m111_setup_rect(client, &mt9m111->rect);
  771. mt9m111_set_flip(client, mt9m111->hflip, MT9M111_RMB_MIRROR_COLS);
  772. mt9m111_set_flip(client, mt9m111->vflip, MT9M111_RMB_MIRROR_ROWS);
  773. mt9m111_set_global_gain(client, mt9m111->gain);
  774. mt9m111_set_autoexposure(client, mt9m111->autoexposure);
  775. mt9m111_set_autowhitebalance(client, mt9m111->autowhitebalance);
  776. return 0;
  777. }
  778. static int mt9m111_resume(struct soc_camera_device *icd)
  779. {
  780. struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
  781. struct mt9m111 *mt9m111 = to_mt9m111(client);
  782. int ret = 0;
  783. if (mt9m111->powered) {
  784. ret = mt9m111_enable(client);
  785. if (!ret)
  786. ret = mt9m111_reset(client);
  787. if (!ret)
  788. ret = mt9m111_restore_state(client);
  789. }
  790. return ret;
  791. }
  792. static int mt9m111_init(struct i2c_client *client)
  793. {
  794. struct mt9m111 *mt9m111 = to_mt9m111(client);
  795. int ret;
  796. mt9m111->context = HIGHPOWER;
  797. ret = mt9m111_enable(client);
  798. if (!ret)
  799. ret = mt9m111_reset(client);
  800. if (!ret)
  801. ret = mt9m111_set_context(client, mt9m111->context);
  802. if (!ret)
  803. ret = mt9m111_set_autoexposure(client, mt9m111->autoexposure);
  804. if (ret)
  805. dev_err(&client->dev, "mt9m111 init failed: %d\n", ret);
  806. return ret;
  807. }
  808. /*
  809. * Interface active, can use i2c. If it fails, it can indeed mean, that
  810. * this wasn't our capture interface, so, we wait for the right one
  811. */
  812. static int mt9m111_video_probe(struct soc_camera_device *icd,
  813. struct i2c_client *client)
  814. {
  815. struct mt9m111 *mt9m111 = to_mt9m111(client);
  816. s32 data;
  817. int ret;
  818. /*
  819. * We must have a parent by now. And it cannot be a wrong one.
  820. * So this entire test is completely redundant.
  821. */
  822. if (!icd->dev.parent ||
  823. to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
  824. return -ENODEV;
  825. mt9m111->autoexposure = 1;
  826. mt9m111->autowhitebalance = 1;
  827. mt9m111->swap_rgb_even_odd = 1;
  828. mt9m111->swap_rgb_red_blue = 1;
  829. data = reg_read(CHIP_VERSION);
  830. switch (data) {
  831. case 0x143a: /* MT9M111 or MT9M131 */
  832. mt9m111->model = V4L2_IDENT_MT9M111;
  833. dev_info(&client->dev,
  834. "Detected a MT9M111/MT9M131 chip ID %x\n", data);
  835. break;
  836. case 0x148c: /* MT9M112 */
  837. mt9m111->model = V4L2_IDENT_MT9M112;
  838. dev_info(&client->dev, "Detected a MT9M112 chip ID %x\n", data);
  839. break;
  840. default:
  841. ret = -ENODEV;
  842. dev_err(&client->dev,
  843. "No MT9M111/MT9M112/MT9M131 chip detected register read %x\n",
  844. data);
  845. goto ei2c;
  846. }
  847. ret = mt9m111_init(client);
  848. ei2c:
  849. return ret;
  850. }
  851. static struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = {
  852. .g_ctrl = mt9m111_g_ctrl,
  853. .s_ctrl = mt9m111_s_ctrl,
  854. .g_chip_ident = mt9m111_g_chip_ident,
  855. #ifdef CONFIG_VIDEO_ADV_DEBUG
  856. .g_register = mt9m111_g_register,
  857. .s_register = mt9m111_s_register,
  858. #endif
  859. };
  860. static int mt9m111_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
  861. enum v4l2_mbus_pixelcode *code)
  862. {
  863. if (index >= ARRAY_SIZE(mt9m111_colour_fmts))
  864. return -EINVAL;
  865. *code = mt9m111_colour_fmts[index].code;
  866. return 0;
  867. }
  868. static struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = {
  869. .s_mbus_fmt = mt9m111_s_fmt,
  870. .g_mbus_fmt = mt9m111_g_fmt,
  871. .try_mbus_fmt = mt9m111_try_fmt,
  872. .s_crop = mt9m111_s_crop,
  873. .g_crop = mt9m111_g_crop,
  874. .cropcap = mt9m111_cropcap,
  875. .enum_mbus_fmt = mt9m111_enum_fmt,
  876. };
  877. static struct v4l2_subdev_ops mt9m111_subdev_ops = {
  878. .core = &mt9m111_subdev_core_ops,
  879. .video = &mt9m111_subdev_video_ops,
  880. };
  881. static int mt9m111_probe(struct i2c_client *client,
  882. const struct i2c_device_id *did)
  883. {
  884. struct mt9m111 *mt9m111;
  885. struct soc_camera_device *icd = client->dev.platform_data;
  886. struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
  887. struct soc_camera_link *icl;
  888. int ret;
  889. if (!icd) {
  890. dev_err(&client->dev, "mt9m111: soc-camera data missing!\n");
  891. return -EINVAL;
  892. }
  893. icl = to_soc_camera_link(icd);
  894. if (!icl) {
  895. dev_err(&client->dev, "mt9m111: driver needs platform data\n");
  896. return -EINVAL;
  897. }
  898. if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) {
  899. dev_warn(&adapter->dev,
  900. "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n");
  901. return -EIO;
  902. }
  903. mt9m111 = kzalloc(sizeof(struct mt9m111), GFP_KERNEL);
  904. if (!mt9m111)
  905. return -ENOMEM;
  906. v4l2_i2c_subdev_init(&mt9m111->subdev, client, &mt9m111_subdev_ops);
  907. /* Second stage probe - when a capture adapter is there */
  908. icd->ops = &mt9m111_ops;
  909. mt9m111->rect.left = MT9M111_MIN_DARK_COLS;
  910. mt9m111->rect.top = MT9M111_MIN_DARK_ROWS;
  911. mt9m111->rect.width = MT9M111_MAX_WIDTH;
  912. mt9m111->rect.height = MT9M111_MAX_HEIGHT;
  913. mt9m111->fmt = &mt9m111_colour_fmts[0];
  914. ret = mt9m111_video_probe(icd, client);
  915. if (ret) {
  916. icd->ops = NULL;
  917. kfree(mt9m111);
  918. }
  919. return ret;
  920. }
  921. static int mt9m111_remove(struct i2c_client *client)
  922. {
  923. struct mt9m111 *mt9m111 = to_mt9m111(client);
  924. struct soc_camera_device *icd = client->dev.platform_data;
  925. icd->ops = NULL;
  926. kfree(mt9m111);
  927. return 0;
  928. }
  929. static const struct i2c_device_id mt9m111_id[] = {
  930. { "mt9m111", 0 },
  931. { }
  932. };
  933. MODULE_DEVICE_TABLE(i2c, mt9m111_id);
  934. static struct i2c_driver mt9m111_i2c_driver = {
  935. .driver = {
  936. .name = "mt9m111",
  937. },
  938. .probe = mt9m111_probe,
  939. .remove = mt9m111_remove,
  940. .id_table = mt9m111_id,
  941. };
  942. static int __init mt9m111_mod_init(void)
  943. {
  944. return i2c_add_driver(&mt9m111_i2c_driver);
  945. }
  946. static void __exit mt9m111_mod_exit(void)
  947. {
  948. i2c_del_driver(&mt9m111_i2c_driver);
  949. }
  950. module_init(mt9m111_mod_init);
  951. module_exit(mt9m111_mod_exit);
  952. MODULE_DESCRIPTION("Micron/Aptina MT9M111/MT9M112/MT9M131 Camera driver");
  953. MODULE_AUTHOR("Robert Jarzmik");
  954. MODULE_LICENSE("GPL");