2 o* Driver for MT9M001 CMOS Image Sensor from Micron
4 * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/videodev2.h>
12 #include <linux/slab.h>
13 #include <linux/i2c.h>
14 #include <linux/log2.h>
15 #include <linux/platform_device.h>
16 #include <linux/delay.h>
17 #include <linux/circ_buf.h>
18 #include <linux/miscdevice.h>
19 #include <media/v4l2-common.h>
20 #include <media/v4l2-chip-ident.h>
21 #include <media/soc_camera.h>
22 #include <mach/rk29_camera.h>
25 module_param(debug, int, S_IRUGO|S_IWUSR);
27 #define dprintk(level, fmt, arg...) do { \
29 printk(KERN_WARNING fmt , ## arg); } while (0)
31 #define SENSOR_TR(format, ...) printk(KERN_ERR format, ## __VA_ARGS__)
32 #define SENSOR_DG(format, ...) dprintk(1, format, ## __VA_ARGS__)
35 #define _CONS(a,b) a##b
36 #define CONS(a,b) _CONS(a,b)
39 #define _STR(x) __STR(x)
40 #define STR(x) _STR(x)
42 #define MIN(x,y) ((x<y) ? x: y)
43 #define MAX(x,y) ((x>y) ? x: y)
45 /* Sensor Driver Configuration */
46 #define SENSOR_NAME RK29_CAM_SENSOR_GC0309
47 #define SENSOR_V4L2_IDENT V4L2_IDENT_GC0309
48 #define SENSOR_ID 0xa0
49 #define SENSOR_MIN_WIDTH 176
50 #define SENSOR_MIN_HEIGHT 144
51 #define SENSOR_MAX_WIDTH 640
52 #define SENSOR_MAX_HEIGHT 480
53 #define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
54 #define SENSOR_INIT_HEIGHT 480
55 #define SENSOR_INIT_WINSEQADR sensor_vga
56 #define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
58 #define CONFIG_SENSOR_WhiteBalance 1
59 #define CONFIG_SENSOR_Brightness 0
60 #define CONFIG_SENSOR_Contrast 0
61 #define CONFIG_SENSOR_Saturation 0
62 #define CONFIG_SENSOR_Effect 1
63 #define CONFIG_SENSOR_Scene 1
64 #define CONFIG_SENSOR_DigitalZoom 0
65 #define CONFIG_SENSOR_Focus 0
66 #define CONFIG_SENSOR_Exposure 0
67 #define CONFIG_SENSOR_Flash 0
68 #define CONFIG_SENSOR_Mirror 0
69 #define CONFIG_SENSOR_Flip 0
71 #define CONFIG_SENSOR_I2C_SPEED 250000 /* Hz */
72 /* Sensor write register continues by preempt_disable/preempt_enable for current process not be scheduled */
73 #define CONFIG_SENSOR_I2C_NOSCHED 0
74 #define CONFIG_SENSOR_I2C_RDWRCHK 0
76 #define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|\
77 SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH |\
78 SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ)
80 #define COLOR_TEMPERATURE_CLOUDY_DN 6500
81 #define COLOR_TEMPERATURE_CLOUDY_UP 8000
82 #define COLOR_TEMPERATURE_CLEARDAY_DN 5000
83 #define COLOR_TEMPERATURE_CLEARDAY_UP 6500
84 #define COLOR_TEMPERATURE_OFFICE_DN 3500
85 #define COLOR_TEMPERATURE_OFFICE_UP 5000
86 #define COLOR_TEMPERATURE_HOME_DN 2500
87 #define COLOR_TEMPERATURE_HOME_UP 3500
89 #define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))
90 #define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)
92 #define SENSOR_AF_IS_ERR (0x00<<0)
93 #define SENSOR_AF_IS_OK (0x01<<0)
94 #define SENSOR_INIT_IS_ERR (0x00<<28)
95 #define SENSOR_INIT_IS_OK (0x01<<28)
103 /* init SVGA preview */
104 static struct reginfo sensor_init_data[] =
106 /*init registers code.*/
108 {0xfe,0x80}, // soft reset
111 {0xd2,0x10}, // close AEC
112 {0x22,0x55}, // close AWB
162 /////////////////////////////////////////////////////////////////////
163 /////////////////////////// grab_t ////////////////////////////////
164 /////////////////////////////////////////////////////////////////////
184 /////////////////////////////////////////////////////////////////////
185 /////////////////////////// LSC_t ////////////////////////////////
186 /////////////////////////////////////////////////////////////////////
198 /////////////////////////////////////////////////////////////////////
199 /////////////////////////// DNDD_t ///////////////////////////////
200 /////////////////////////////////////////////////////////////////////
209 /////////////////////////////////////////////////////////////////////
210 /////////////////////////// asde_t ///////////////////////////////
211 /////////////////////////////////////////////////////////////////////
221 /////////////////////////////////////////////////////////////////////
222 /////////////////////////// eeintp_t///////////////////////////////
223 /////////////////////////////////////////////////////////////////////
226 //for high resolution in light scene
238 /////////////////////////////////////////////////////////////////////
239 ///////////////////////////CC_t///////////////////////////////
240 /////////////////////////////////////////////////////////////////////
253 /////////////////////////////////////////////////////////////////////
254 ///////////////////////////YCP_t///////////////////////////////
255 /////////////////////////////////////////////////////////////////////
261 /////////////////////////////////////////////////////////////////////
262 ///////////////////////////AEC_t///////////////////////////////
263 /////////////////////////////////////////////////////////////////////
297 /////////////////////////////////////////////////////////////////
298 /////////////////////////// ABS_t ///////////////////////////////
299 /////////////////////////////////////////////////////////////////
305 /////////////////////////////////////////////////////////////////
306 /////////////////////////// Measure Window ///////////////////////
307 /////////////////////////////////////////////////////////////////
314 {0xfe,0x80}, // soft reset
317 {0xd2,0x10}, // close AEC
318 {0x22,0x55}, // close AWB
369 /////////////////////////////////////////////////////////////////////
370 /////////////////////////// grab_t ////////////////////////////////
371 /////////////////////////////////////////////////////////////////////
391 /////////////////////////////////////////////////////////////////////
392 /////////////////////////// LSC_t ////////////////////////////////
393 /////////////////////////////////////////////////////////////////////
405 /////////////////////////////////////////////////////////////////////
406 /////////////////////////// DNDD_t ///////////////////////////////
407 /////////////////////////////////////////////////////////////////////
416 /////////////////////////////////////////////////////////////////////
417 /////////////////////////// asde_t ///////////////////////////////
418 /////////////////////////////////////////////////////////////////////
428 /////////////////////////////////////////////////////////////////////
429 /////////////////////////// eeintp_t///////////////////////////////
436 static struct reginfo sensor_vga[] =
438 //{0x45 , 0x0f}, //output enable
439 {0x15 , 0x0a}, //output enable
444 static struct reginfo sensor_cif[] =
448 static struct reginfo sensor_qvga[] =
452 static struct reginfo sensor_qcif[] =
456 static struct reginfo sensor_ClrFmt_YUYV[]=
462 static struct reginfo sensor_ClrFmt_UYVY[]=
468 #if CONFIG_SENSOR_WhiteBalance
469 static struct reginfo sensor_WhiteB_Auto[]=
471 {0x5a,0x56}, //for AWB can adjust back
474 {0x22,0x57}, // Enable AWB
477 /* Cloudy Colour Temperature : 6500K - 8000K */
478 static struct reginfo sensor_WhiteB_Cloudy[]=
480 {0x22,0x55}, // Disable AWB
481 {0x5a,0x8c}, //WB_manual_gain
486 /* ClearDay Colour Temperature : 5000K - 6500K */
487 static struct reginfo sensor_WhiteB_ClearDay[]=
496 /* Office Colour Temperature : 3500K - 5000K */
497 static struct reginfo sensor_WhiteB_Incandescent[]=
507 /* Home Colour Temperature : 2500K - 3500K */
508 static struct reginfo sensor_WhiteB_Fluorescent[]=
517 static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_Incandescent,sensor_WhiteB_Fluorescent,
518 sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
522 #if CONFIG_SENSOR_Brightness
523 static struct reginfo sensor_Brightness0[]=
530 static struct reginfo sensor_Brightness1[]=
537 static struct reginfo sensor_Brightness2[]=
544 static struct reginfo sensor_Brightness3[]=
551 static struct reginfo sensor_Brightness4[]=
558 static struct reginfo sensor_Brightness5[]=
564 static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
565 sensor_Brightness4, sensor_Brightness5,NULL,
570 #if CONFIG_SENSOR_Effect
571 static struct reginfo sensor_Effect_Normal[] =
587 static struct reginfo sensor_Effect_WandB[] =
604 static struct reginfo sensor_Effect_Sepia[] =
619 static struct reginfo sensor_Effect_Negative[] =
634 static struct reginfo sensor_Effect_Bluish[] =
650 static struct reginfo sensor_Effect_Green[] =
667 static struct reginfo sensor_Effect_Grayscale[]=
682 static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
683 sensor_Effect_Bluish, sensor_Effect_Green,sensor_Effect_Grayscale,NULL,
686 #if CONFIG_SENSOR_Exposure
687 static struct reginfo sensor_Exposure0[]=
693 static struct reginfo sensor_Exposure1[]=
700 static struct reginfo sensor_Exposure2[]=
707 static struct reginfo sensor_Exposure3[]=
714 static struct reginfo sensor_Exposure4[]=
721 static struct reginfo sensor_Exposure5[]=
728 static struct reginfo sensor_Exposure6[]=
735 static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
736 sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
739 #if CONFIG_SENSOR_Saturation
740 static struct reginfo sensor_Saturation0[]=
746 static struct reginfo sensor_Saturation1[]=
752 static struct reginfo sensor_Saturation2[]=
757 static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
760 #if CONFIG_SENSOR_Contrast
761 static struct reginfo sensor_Contrast0[]=
768 static struct reginfo sensor_Contrast1[]=
775 static struct reginfo sensor_Contrast2[]=
782 static struct reginfo sensor_Contrast3[]=
789 static struct reginfo sensor_Contrast4[]=
797 static struct reginfo sensor_Contrast5[]=
804 static struct reginfo sensor_Contrast6[]=
810 static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
811 sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
815 #if CONFIG_SENSOR_Mirror
816 static struct reginfo sensor_MirrorOn[]=
822 static struct reginfo sensor_MirrorOff[]=
827 static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
829 #if CONFIG_SENSOR_Flip
830 static struct reginfo sensor_FlipOn[]=
836 static struct reginfo sensor_FlipOff[]=
841 static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
844 #if CONFIG_SENSOR_Scene
845 static struct reginfo sensor_SceneAuto[] =
847 #if 0 /* ddl@rock-chips.com : */
855 {0x20 ,0x7f}, // close cc
864 static struct reginfo sensor_SceneNight[] =
867 //30fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,36Mzh pclk
869 {0x20 ,0x5f}, // close cc
876 //15fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,18Mhz pclk
892 static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
895 #if CONFIG_SENSOR_DigitalZoom
896 static struct reginfo sensor_Zoom0[] =
901 static struct reginfo sensor_Zoom1[] =
906 static struct reginfo sensor_Zoom2[] =
912 static struct reginfo sensor_Zoom3[] =
916 static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};
918 static const struct v4l2_querymenu sensor_menus[] =
920 #if CONFIG_SENSOR_WhiteBalance
921 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 0, .name = "auto", .reserved = 0, }, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 1, .name = "incandescent", .reserved = 0,},
922 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
923 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
926 #if CONFIG_SENSOR_Effect
927 { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "mono", .reserved = 0,},
928 { .id = V4L2_CID_EFFECT, .index = 2, .name = "negative", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "sepia", .reserved = 0,},
929 { .id = V4L2_CID_EFFECT, .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT, .index = 5, .name = "aqua", .reserved = 0,},
930 { .id = V4L2_CID_EFFECT, .index = 6, .name = "grayscale", .reserved = 0,},
933 #if CONFIG_SENSOR_Scene
934 { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
937 #if CONFIG_SENSOR_Flash
938 { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
939 { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
943 static const struct v4l2_queryctrl sensor_controls[] =
945 #if CONFIG_SENSOR_WhiteBalance
947 .id = V4L2_CID_DO_WHITE_BALANCE,
948 .type = V4L2_CTRL_TYPE_MENU,
949 .name = "White Balance Control",
957 #if CONFIG_SENSOR_Brightness
959 .id = V4L2_CID_BRIGHTNESS,
960 .type = V4L2_CTRL_TYPE_INTEGER,
961 .name = "Brightness Control",
969 #if CONFIG_SENSOR_Effect
971 .id = V4L2_CID_EFFECT,
972 .type = V4L2_CTRL_TYPE_MENU,
973 .name = "Effect Control",
981 #if CONFIG_SENSOR_Exposure
983 .id = V4L2_CID_EXPOSURE,
984 .type = V4L2_CTRL_TYPE_INTEGER,
985 .name = "Exposure Control",
993 #if CONFIG_SENSOR_Saturation
995 .id = V4L2_CID_SATURATION,
996 .type = V4L2_CTRL_TYPE_INTEGER,
997 .name = "Saturation Control",
1005 #if CONFIG_SENSOR_Contrast
1007 .id = V4L2_CID_CONTRAST,
1008 .type = V4L2_CTRL_TYPE_INTEGER,
1009 .name = "Contrast Control",
1017 #if CONFIG_SENSOR_Mirror
1019 .id = V4L2_CID_HFLIP,
1020 .type = V4L2_CTRL_TYPE_BOOLEAN,
1021 .name = "Mirror Control",
1029 #if CONFIG_SENSOR_Flip
1031 .id = V4L2_CID_VFLIP,
1032 .type = V4L2_CTRL_TYPE_BOOLEAN,
1033 .name = "Flip Control",
1041 #if CONFIG_SENSOR_Scene
1043 .id = V4L2_CID_SCENE,
1044 .type = V4L2_CTRL_TYPE_MENU,
1045 .name = "Scene Control",
1053 #if CONFIG_SENSOR_DigitalZoom
1055 .id = V4L2_CID_ZOOM_RELATIVE,
1056 .type = V4L2_CTRL_TYPE_INTEGER,
1057 .name = "DigitalZoom Control",
1063 .id = V4L2_CID_ZOOM_ABSOLUTE,
1064 .type = V4L2_CTRL_TYPE_INTEGER,
1065 .name = "DigitalZoom Control",
1073 #if CONFIG_SENSOR_Focus
1075 .id = V4L2_CID_FOCUS_RELATIVE,
1076 .type = V4L2_CTRL_TYPE_INTEGER,
1077 .name = "Focus Control",
1083 .id = V4L2_CID_FOCUS_ABSOLUTE,
1084 .type = V4L2_CTRL_TYPE_INTEGER,
1085 .name = "Focus Control",
1089 .default_value = 125,
1093 #if CONFIG_SENSOR_Flash
1095 .id = V4L2_CID_FLASH,
1096 .type = V4L2_CTRL_TYPE_MENU,
1097 .name = "Flash Control",
1106 static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);
1107 static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
1108 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1109 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1110 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1111 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1112 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
1113 static int sensor_resume(struct soc_camera_device *icd);
1114 static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
1115 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
1116 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1117 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1118 static int sensor_deactivate(struct i2c_client *client);
1120 static struct soc_camera_ops sensor_ops =
1122 .suspend = sensor_suspend,
1123 .resume = sensor_resume,
1124 .set_bus_param = sensor_set_bus_param,
1125 .query_bus_param = sensor_query_bus_param,
1126 .controls = sensor_controls,
1127 .menus = sensor_menus,
1128 .num_controls = ARRAY_SIZE(sensor_controls),
1129 .num_menus = ARRAY_SIZE(sensor_menus),
1132 /* only one fixed colorspace per pixelcode */
1133 struct sensor_datafmt {
1134 enum v4l2_mbus_pixelcode code;
1135 enum v4l2_colorspace colorspace;
1138 /* Find a data format by a pixel code in an array */
1139 static const struct sensor_datafmt *sensor_find_datafmt(
1140 enum v4l2_mbus_pixelcode code, const struct sensor_datafmt *fmt,
1144 for (i = 0; i < n; i++)
1145 if (fmt[i].code == code)
1151 static const struct sensor_datafmt sensor_colour_fmts[] = {
1152 {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
1153 {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}
1156 typedef struct sensor_info_priv_s
1170 unsigned char mirror; /* HFLIP */
1171 unsigned char flip; /* VFLIP */
1172 unsigned int winseqe_cur_addr;
1173 struct sensor_datafmt fmt;
1174 unsigned int funmodule_state;
1175 } sensor_info_priv_t;
1179 struct v4l2_subdev subdev;
1180 struct i2c_client *client;
1181 sensor_info_priv_t info_priv;
1182 int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
1183 #if CONFIG_SENSOR_I2C_NOSCHED
1184 atomic_t tasklock_cnt;
1186 struct rk29camera_platform_data *sensor_io_request;
1187 struct rk29camera_gpio_res *sensor_gpio_res;
1190 static struct sensor* to_sensor(const struct i2c_client *client)
1192 return container_of(i2c_get_clientdata(client), struct sensor, subdev);
1195 static int sensor_task_lock(struct i2c_client *client, int lock)
1197 #if CONFIG_SENSOR_I2C_NOSCHED
1199 struct sensor *sensor = to_sensor(client);
1202 if (atomic_read(&sensor->tasklock_cnt) == 0) {
1203 while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {
1204 SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());
1208 if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {
1209 SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());
1210 goto sensor_task_lock_err;
1215 atomic_add(1, &sensor->tasklock_cnt);
1217 if (atomic_read(&sensor->tasklock_cnt) > 0) {
1218 atomic_sub(1, &sensor->tasklock_cnt);
1220 if (atomic_read(&sensor->tasklock_cnt) == 0)
1225 sensor_task_lock_err:
1234 /* sensor register */
1235 static int sensor_read(struct i2c_client *client, u8 reg, u8 *val)
1239 ret = i2c_master_reg8_recv(client, reg, val, 1, CONFIG_SENSOR_I2C_SPEED);
1241 return (ret > 0)? 0 : ret;
1244 static int sensor_write(struct i2c_client *client, u8 reg, u8 val)
1248 ret = i2c_master_reg8_send(client, reg, &val, 1, CONFIG_SENSOR_I2C_SPEED);
1250 return (ret > 0)? 0 : ret;
1253 static int sensor_write(struct i2c_client *client, u8 reg, u8 val)
1257 struct i2c_msg msg[1];
1265 msg->addr = client->addr;
1266 msg->flags = client->flags;
1268 msg->len = sizeof(buf);
1269 msg->scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1270 msg->read_type = 0; /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
1275 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
1276 err = i2c_transfer(client->adapter, msg, 1);
1281 SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg, val);
1289 /* sensor register read */
1290 static int sensor_read(struct i2c_client *client, u8 reg, u8 *val)
1294 struct i2c_msg msg[2];
1298 msg[0].addr = client->addr;
1299 msg[0].flags = client->flags;
1301 msg[0].len = sizeof(buf);
1302 msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1303 msg[0].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
1305 msg[1].addr = client->addr;
1306 msg[1].flags = client->flags|I2C_M_RD;
1309 msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1310 msg[1].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
1314 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
1315 err = i2c_transfer(client->adapter, msg, 2);
1321 SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);
1331 /* write a array of registers */
1332 static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
1336 #if CONFIG_SENSOR_I2C_RDWRCHK
1342 if (sensor_task_lock(client, 1) < 0)
1343 goto sensor_write_array_end;
1344 while (regarray[i].reg != 0)
1346 err = sensor_write(client, regarray[i].reg, regarray[i].val);
1350 SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
1354 SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
1356 goto sensor_write_array_end;
1359 #if CONFIG_SENSOR_I2C_RDWRCHK
1361 sensor_read(client, regarray[i].reg, &valchk);
1362 if (valchk != regarray[i].val)
1363 SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
1369 sensor_write_array_end:
1370 sensor_task_lock(client,0);
1373 #if CONFIG_SENSOR_I2C_RDWRCHK
1374 static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)
1382 while (regarray[i].reg != 0)
1384 sensor_read(client, regarray[i].reg, &valchk);
1385 if (valchk != regarray[i].val)
1386 SENSOR_TR("%s Reg:0x%x read(0x%x, 0x%x) error\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
1393 static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)
1395 struct soc_camera_link *icl = to_soc_camera_link(icd);
1398 SENSOR_DG("%s %s cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);
1401 case Sensor_PowerDown:
1403 if (icl->powerdown) {
1404 ret = icl->powerdown(icd->pdev, on);
1405 if (ret == RK29_CAM_IO_SUCCESS) {
1409 icl->reset(icd->pdev);
1411 } else if (ret == RK29_CAM_EIO_REQUESTFAIL) {
1413 goto sensor_power_end;
1420 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1421 struct sensor *sensor = to_sensor(client);
1423 if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
1424 sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
1430 SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
1437 static int sensor_init(struct v4l2_subdev *sd, u32 val)
1439 struct i2c_client *client = sd->priv;
1440 struct soc_camera_device *icd = client->dev.platform_data;
1441 struct sensor *sensor = to_sensor(client);
1442 const struct v4l2_queryctrl *qctrl;
1443 const struct sensor_datafmt *fmt;
1447 SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
1449 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
1451 goto sensor_INIT_ERR;
1455 if (sensor_task_lock(client,1)<0)
1456 goto sensor_INIT_ERR;
1457 ret = sensor_write(client, 0xfe, 0x80);
1460 SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
1462 goto sensor_INIT_ERR;
1464 mdelay(5); //delay 5 microseconds
1465 /* check if it is an sensor sensor */
1466 ret = sensor_read(client, 0x00, &value);
1468 SENSOR_TR("read chip id high byte failed\n");
1470 goto sensor_INIT_ERR;
1473 if (value == SENSOR_ID) {
1474 sensor->model = SENSOR_V4L2_IDENT;
1476 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), value);
1478 goto sensor_INIT_ERR;
1481 ret = sensor_write_array(client, sensor_init_data);
1484 SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
1485 goto sensor_INIT_ERR;
1487 sensor_task_lock(client,0);
1489 sensor->info_priv.winseqe_cur_addr = (int)SENSOR_INIT_WINSEQADR;
1490 fmt = sensor_find_datafmt(SENSOR_INIT_PIXFMT,sensor_colour_fmts, ARRAY_SIZE(sensor_colour_fmts));
1492 SENSOR_TR("error: %s initial array colour fmts is not support!!",SENSOR_NAME_STRING());
1494 goto sensor_INIT_ERR;
1496 sensor->info_priv.fmt = *fmt;
1498 /* sensor sensor information for initialization */
1499 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1501 sensor->info_priv.whiteBalance = qctrl->default_value;
1502 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);
1504 sensor->info_priv.brightness = qctrl->default_value;
1505 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1507 sensor->info_priv.effect = qctrl->default_value;
1508 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);
1510 sensor->info_priv.exposure = qctrl->default_value;
1512 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);
1514 sensor->info_priv.saturation = qctrl->default_value;
1515 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);
1517 sensor->info_priv.contrast = qctrl->default_value;
1518 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);
1520 sensor->info_priv.mirror = qctrl->default_value;
1521 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);
1523 sensor->info_priv.flip = qctrl->default_value;
1524 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);
1526 sensor->info_priv.scene = qctrl->default_value;
1527 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
1529 sensor->info_priv.digitalzoom = qctrl->default_value;
1531 /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
1532 #if CONFIG_SENSOR_Focus
1533 //sensor_set_focus();
1534 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
1536 sensor->info_priv.focus = qctrl->default_value;
1539 #if CONFIG_SENSOR_Flash
1540 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
1542 sensor->info_priv.flash = qctrl->default_value;
1545 SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),((val == 0)?__FUNCTION__:"sensor_reinit"),icd->user_width,icd->user_height);
1546 sensor->info_priv.funmodule_state |= SENSOR_INIT_IS_OK;
1549 sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
1550 sensor_task_lock(client,0);
1551 sensor_deactivate(client);
1555 static int sensor_deactivate(struct i2c_client *client)
1557 struct soc_camera_device *icd = client->dev.platform_data;
1559 struct sensor *sensor = to_sensor(client);
1560 SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);
1562 /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
1563 sensor_ioctrl(icd, Sensor_PowerDown, 1);
1566 /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */
1567 icd->user_width = SENSOR_INIT_WIDTH;
1568 icd->user_height = SENSOR_INIT_HEIGHT;
1569 sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
1574 static struct reginfo sensor_power_down_sequence[]=
1578 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
1581 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1583 if (pm_msg.event == PM_EVENT_SUSPEND) {
1584 SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());
1585 ret = sensor_write_array(client, sensor_power_down_sequence) ;
1587 SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
1590 ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);
1592 SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());
1597 SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
1603 static int sensor_resume(struct soc_camera_device *icd)
1607 ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);
1609 SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());
1613 SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());
1619 static int sensor_set_bus_param(struct soc_camera_device *icd,
1620 unsigned long flags)
1626 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
1628 struct soc_camera_link *icl = to_soc_camera_link(icd);
1629 unsigned long flags = SENSOR_BUS_PARAM;
1631 return soc_camera_apply_sensor_flags(icl, flags);
1634 static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1636 struct i2c_client *client = sd->priv;
1637 struct soc_camera_device *icd = client->dev.platform_data;
1638 struct sensor *sensor = to_sensor(client);
1640 mf->width = icd->user_width;
1641 mf->height = icd->user_height;
1642 mf->code = sensor->info_priv.fmt.code;
1643 mf->colorspace = sensor->info_priv.fmt.colorspace;
1644 mf->field = V4L2_FIELD_NONE;
1648 static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1652 if ((mf->width == 1024) && (mf->height == 768)) {
1654 } else if ((mf->width == 1280) && (mf->height == 1024)) {
1656 } else if ((mf->width == 1600) && (mf->height == 1200)) {
1658 } else if ((mf->width == 2048) && (mf->height == 1536)) {
1660 } else if ((mf->width == 2592) && (mf->height == 1944)) {
1665 SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, mf->width, mf->height);
1669 static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1673 if ((mf->width == 1280) && (mf->height == 720)) {
1675 } else if ((mf->width == 1920) && (mf->height == 1080)) {
1680 SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, mf->width, mf->height);
1683 static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1685 struct i2c_client *client = sd->priv;
1686 const struct sensor_datafmt *fmt;
1687 struct sensor *sensor = to_sensor(client);
1688 const struct v4l2_queryctrl *qctrl;
1689 struct soc_camera_device *icd = client->dev.platform_data;
1690 struct reginfo *winseqe_set_addr=NULL;
1691 int ret=0, set_w,set_h;
1693 fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
1694 ARRAY_SIZE(sensor_colour_fmts));
1697 goto sensor_s_fmt_end;
1700 if (sensor->info_priv.fmt.code != mf->code) {
1703 case V4L2_MBUS_FMT_YUYV8_2X8:
1705 winseqe_set_addr = sensor_ClrFmt_YUYV;
1708 case V4L2_MBUS_FMT_UYVY8_2X8:
1710 winseqe_set_addr = sensor_ClrFmt_UYVY;
1716 if (winseqe_set_addr != NULL) {
1717 sensor_write_array(client, winseqe_set_addr);
1718 sensor->info_priv.fmt.code = mf->code;
1719 sensor->info_priv.fmt.colorspace= mf->colorspace;
1720 SENSOR_DG("%s v4l2_mbus_code:%d set success!\n", SENSOR_NAME_STRING(),mf->code);
1722 SENSOR_TR("%s v4l2_mbus_code:%d is invalidate!\n", SENSOR_NAME_STRING(),mf->code);
1729 if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
1731 winseqe_set_addr = sensor_qcif;
1735 else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
1737 winseqe_set_addr = sensor_qvga;
1741 else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
1743 winseqe_set_addr = sensor_cif;
1747 else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
1749 winseqe_set_addr = sensor_vga;
1756 winseqe_set_addr = SENSOR_INIT_WINSEQADR; /* ddl@rock-chips.com : Sensor output smallest size if isn't support app */
1757 set_w = SENSOR_INIT_WIDTH;
1758 set_h = SENSOR_INIT_HEIGHT;
1759 SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,mf->width,mf->height);
1762 if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr) {
1763 #if CONFIG_SENSOR_Flash
1764 if (sensor_fmt_capturechk(sd,mf) == true) { /* ddl@rock-chips.com : Capture */
1765 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
1766 sensor_ioctrl(icd, Sensor_Flash, Flash_On);
1767 SENSOR_DG("%s flash on in capture!\n", SENSOR_NAME_STRING());
1769 } else { /* ddl@rock-chips.com : Video */
1770 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
1771 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
1772 SENSOR_DG("%s flash off in preivew!\n", SENSOR_NAME_STRING());
1776 ret |= sensor_write_array(client, winseqe_set_addr);
1778 SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
1779 #if CONFIG_SENSOR_Flash
1780 if (sensor_fmt_capturechk(sd,mf) == true) {
1781 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
1782 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
1783 SENSOR_TR("%s Capture format set fail, flash off !\n", SENSOR_NAME_STRING());
1787 goto sensor_s_fmt_end;
1790 sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
1792 if (sensor_fmt_capturechk(sd,mf) == true) { /* ddl@rock-chips.com : Capture */
1793 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1794 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
1795 if (sensor->info_priv.whiteBalance != 0) {
1796 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1797 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
1799 sensor->info_priv.snap2preview = true;
1800 } else if (sensor_fmt_videochk(sd,mf) == true) { /* ddl@rock-chips.com : Video */
1801 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1802 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
1803 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1804 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
1805 sensor->info_priv.video2preview = true;
1806 } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) {
1807 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1808 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
1809 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1810 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
1811 sensor->info_priv.video2preview = false;
1812 sensor->info_priv.snap2preview = false;
1814 SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
1818 SENSOR_DG("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);
1828 static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1830 struct i2c_client *client = sd->priv;
1831 struct sensor *sensor = to_sensor(client);
1832 const struct sensor_datafmt *fmt;
1835 fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
1836 ARRAY_SIZE(sensor_colour_fmts));
1838 fmt = &sensor->info_priv.fmt;
1839 mf->code = fmt->code;
1842 if (mf->height > SENSOR_MAX_HEIGHT)
1843 mf->height = SENSOR_MAX_HEIGHT;
1844 else if (mf->height < SENSOR_MIN_HEIGHT)
1845 mf->height = SENSOR_MIN_HEIGHT;
1847 if (mf->width > SENSOR_MAX_WIDTH)
1848 mf->width = SENSOR_MAX_WIDTH;
1849 else if (mf->width < SENSOR_MIN_WIDTH)
1850 mf->width = SENSOR_MIN_WIDTH;
1852 mf->colorspace = fmt->colorspace;
1857 static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
1859 struct i2c_client *client = sd->priv;
1861 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
1864 if (id->match.addr != client->addr)
1867 id->ident = SENSOR_V4L2_IDENT; /* ddl@rock-chips.com : Return OV2655 identifier */
1872 #if CONFIG_SENSOR_Brightness
1873 static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
1875 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1877 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
1879 if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)
1881 if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)
1883 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
1886 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
1890 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
1894 #if CONFIG_SENSOR_Effect
1895 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
1897 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1899 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
1901 if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)
1903 if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)
1905 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
1908 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
1912 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
1916 #if CONFIG_SENSOR_Exposure
1917 static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
1919 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1921 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
1923 if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)
1925 if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)
1927 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
1930 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
1934 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
1938 #if CONFIG_SENSOR_Saturation
1939 static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
1941 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1943 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
1945 if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)
1947 if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)
1949 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
1952 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
1956 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
1960 #if CONFIG_SENSOR_Contrast
1961 static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
1963 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1965 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
1967 if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)
1969 if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)
1971 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
1974 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
1978 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
1982 #if CONFIG_SENSOR_Mirror
1983 static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
1985 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1987 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
1989 if (sensor_MirrorSeqe[value - qctrl->minimum] != NULL)
1991 if (sensor_write_array(client, sensor_MirrorSeqe[value - qctrl->minimum]) != 0)
1993 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
1996 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2000 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2004 #if CONFIG_SENSOR_Flip
2005 static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2007 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2009 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2011 if (sensor_FlipSeqe[value - qctrl->minimum] != NULL)
2013 if (sensor_write_array(client, sensor_FlipSeqe[value - qctrl->minimum]) != 0)
2015 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2018 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2022 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2026 #if CONFIG_SENSOR_Scene
2027 static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2029 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2031 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2033 if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)
2035 if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)
2037 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2040 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2044 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2048 #if CONFIG_SENSOR_WhiteBalance
2049 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2051 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2053 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2055 if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
2057 if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
2059 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2062 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2066 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2070 #if CONFIG_SENSOR_DigitalZoom
2071 static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)
2073 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2074 struct sensor *sensor = to_sensor(client);
2075 const struct v4l2_queryctrl *qctrl_info;
2076 int digitalzoom_cur, digitalzoom_total;
2078 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
2082 digitalzoom_cur = sensor->info_priv.digitalzoom;
2083 digitalzoom_total = qctrl_info->maximum;
2085 if ((value > 0) && (digitalzoom_cur >= digitalzoom_total))
2087 SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2091 if ((value < 0) && (digitalzoom_cur <= qctrl_info->minimum))
2093 SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2097 if ((value > 0) && ((digitalzoom_cur + value) > digitalzoom_total))
2099 value = digitalzoom_total - digitalzoom_cur;
2102 if ((value < 0) && ((digitalzoom_cur + value) < 0))
2104 value = 0 - digitalzoom_cur;
2107 digitalzoom_cur += value;
2109 if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)
2111 if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)
2113 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2116 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2123 #if CONFIG_SENSOR_Flash
2124 static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2126 if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {
2127 if (value == 3) { /* ddl@rock-chips.com: torch */
2128 sensor_ioctrl(icd, Sensor_Flash, Flash_Torch); /* Flash On */
2130 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2132 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2136 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2141 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2143 struct i2c_client *client = sd->priv;
2144 struct sensor *sensor = to_sensor(client);
2145 const struct v4l2_queryctrl *qctrl;
2147 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2151 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2157 case V4L2_CID_BRIGHTNESS:
2159 ctrl->value = sensor->info_priv.brightness;
2162 case V4L2_CID_SATURATION:
2164 ctrl->value = sensor->info_priv.saturation;
2167 case V4L2_CID_CONTRAST:
2169 ctrl->value = sensor->info_priv.contrast;
2172 case V4L2_CID_DO_WHITE_BALANCE:
2174 ctrl->value = sensor->info_priv.whiteBalance;
2177 case V4L2_CID_EXPOSURE:
2179 ctrl->value = sensor->info_priv.exposure;
2182 case V4L2_CID_HFLIP:
2184 ctrl->value = sensor->info_priv.mirror;
2187 case V4L2_CID_VFLIP:
2189 ctrl->value = sensor->info_priv.flip;
2200 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2202 struct i2c_client *client = sd->priv;
2203 struct sensor *sensor = to_sensor(client);
2204 struct soc_camera_device *icd = client->dev.platform_data;
2205 const struct v4l2_queryctrl *qctrl;
2208 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2212 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2218 #if CONFIG_SENSOR_Brightness
2219 case V4L2_CID_BRIGHTNESS:
2221 if (ctrl->value != sensor->info_priv.brightness)
2223 if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)
2227 sensor->info_priv.brightness = ctrl->value;
2232 #if CONFIG_SENSOR_Exposure
2233 case V4L2_CID_EXPOSURE:
2235 if (ctrl->value != sensor->info_priv.exposure)
2237 if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)
2241 sensor->info_priv.exposure = ctrl->value;
2246 #if CONFIG_SENSOR_Saturation
2247 case V4L2_CID_SATURATION:
2249 if (ctrl->value != sensor->info_priv.saturation)
2251 if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)
2255 sensor->info_priv.saturation = ctrl->value;
2260 #if CONFIG_SENSOR_Contrast
2261 case V4L2_CID_CONTRAST:
2263 if (ctrl->value != sensor->info_priv.contrast)
2265 if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)
2269 sensor->info_priv.contrast = ctrl->value;
2274 #if CONFIG_SENSOR_WhiteBalance
2275 case V4L2_CID_DO_WHITE_BALANCE:
2277 if (ctrl->value != sensor->info_priv.whiteBalance)
2279 if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
2283 sensor->info_priv.whiteBalance = ctrl->value;
2288 #if CONFIG_SENSOR_Mirror
2289 case V4L2_CID_HFLIP:
2291 if (ctrl->value != sensor->info_priv.mirror)
2293 if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)
2295 sensor->info_priv.mirror = ctrl->value;
2300 #if CONFIG_SENSOR_Flip
2301 case V4L2_CID_VFLIP:
2303 if (ctrl->value != sensor->info_priv.flip)
2305 if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)
2307 sensor->info_priv.flip = ctrl->value;
2318 static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
2320 const struct v4l2_queryctrl *qctrl;
2321 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2322 struct sensor *sensor = to_sensor(client);
2324 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
2328 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
2332 switch (ext_ctrl->id)
2334 case V4L2_CID_SCENE:
2336 ext_ctrl->value = sensor->info_priv.scene;
2339 case V4L2_CID_EFFECT:
2341 ext_ctrl->value = sensor->info_priv.effect;
2344 case V4L2_CID_ZOOM_ABSOLUTE:
2346 ext_ctrl->value = sensor->info_priv.digitalzoom;
2349 case V4L2_CID_ZOOM_RELATIVE:
2353 case V4L2_CID_FOCUS_ABSOLUTE:
2355 ext_ctrl->value = sensor->info_priv.focus;
2358 case V4L2_CID_FOCUS_RELATIVE:
2362 case V4L2_CID_FLASH:
2364 ext_ctrl->value = sensor->info_priv.flash;
2372 static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
2374 const struct v4l2_queryctrl *qctrl;
2375 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2376 struct sensor *sensor = to_sensor(client);
2379 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
2383 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
2388 switch (ext_ctrl->id)
2390 #if CONFIG_SENSOR_Scene
2391 case V4L2_CID_SCENE:
2393 if (ext_ctrl->value != sensor->info_priv.scene)
2395 if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)
2397 sensor->info_priv.scene = ext_ctrl->value;
2402 #if CONFIG_SENSOR_Effect
2403 case V4L2_CID_EFFECT:
2405 if (ext_ctrl->value != sensor->info_priv.effect)
2407 if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)
2409 sensor->info_priv.effect= ext_ctrl->value;
2414 #if CONFIG_SENSOR_DigitalZoom
2415 case V4L2_CID_ZOOM_ABSOLUTE:
2417 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
2420 if (ext_ctrl->value != sensor->info_priv.digitalzoom)
2422 val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;
2424 if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)
2426 sensor->info_priv.digitalzoom += val_offset;
2428 SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
2433 case V4L2_CID_ZOOM_RELATIVE:
2435 if (ext_ctrl->value)
2437 if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
2439 sensor->info_priv.digitalzoom += ext_ctrl->value;
2441 SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
2446 #if CONFIG_SENSOR_Focus
2447 case V4L2_CID_FOCUS_ABSOLUTE:
2449 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
2452 if (ext_ctrl->value != sensor->info_priv.focus)
2454 val_offset = ext_ctrl->value -sensor->info_priv.focus;
2456 sensor->info_priv.focus += val_offset;
2461 case V4L2_CID_FOCUS_RELATIVE:
2463 if (ext_ctrl->value)
2465 sensor->info_priv.focus += ext_ctrl->value;
2467 SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);
2472 #if CONFIG_SENSOR_Flash
2473 case V4L2_CID_FLASH:
2475 if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)
2477 sensor->info_priv.flash = ext_ctrl->value;
2479 SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
2490 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
2492 struct i2c_client *client = sd->priv;
2493 struct soc_camera_device *icd = client->dev.platform_data;
2494 int i, error_cnt=0, error_idx=-1;
2497 for (i=0; i<ext_ctrl->count; i++) {
2498 if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
2505 error_idx = ext_ctrl->count;
2507 if (error_idx != -1) {
2508 ext_ctrl->error_idx = error_idx;
2515 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
2517 struct i2c_client *client = sd->priv;
2518 struct soc_camera_device *icd = client->dev.platform_data;
2519 int i, error_cnt=0, error_idx=-1;
2522 for (i=0; i<ext_ctrl->count; i++) {
2523 if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
2530 error_idx = ext_ctrl->count;
2532 if (error_idx != -1) {
2533 ext_ctrl->error_idx = error_idx;
2540 /* Interface active, can use i2c. If it fails, it can indeed mean, that
2541 * this wasn't our capture interface, so, we wait for the right one */
2542 static int sensor_video_probe(struct soc_camera_device *icd,
2543 struct i2c_client *client)
2547 struct sensor *sensor = to_sensor(client);
2549 /* We must have a parent by now. And it cannot be a wrong one.
2550 * So this entire test is completely redundant. */
2551 if (!icd->dev.parent ||
2552 to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
2555 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
2557 goto sensor_video_probe_err;
2561 ret = sensor_write(client, 0xfe, 0x80);
2564 SENSOR_TR("soft reset %s failed\n",SENSOR_NAME_STRING());
2567 mdelay(5); //delay 5 microseconds
2569 /* check if it is an sensor sensor */
2570 ret = sensor_read(client, 0x00, &value);
2572 SENSOR_TR("read chip id high byte failed\n");
2574 goto sensor_video_probe_err;
2577 if (value == SENSOR_ID) {
2578 sensor->model = SENSOR_V4L2_IDENT;
2579 SENSOR_TR("chip id:0x%x\n",value);
2581 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), value);
2583 goto sensor_video_probe_err;
2588 sensor_video_probe_err:
2592 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
2594 struct i2c_client *client = sd->priv;
2595 struct soc_camera_device *icd = client->dev.platform_data;
2596 struct sensor *sensor = to_sensor(client);
2598 #if CONFIG_SENSOR_Flash
2602 SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
2605 case RK29_CAM_SUBDEV_DEACTIVATE:
2607 sensor_deactivate(client);
2611 case RK29_CAM_SUBDEV_IOREQUEST:
2613 sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
2614 if (sensor->sensor_io_request != NULL) {
2615 if (sensor->sensor_io_request->gpio_res[0].dev_name &&
2616 (strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
2617 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
2618 } else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
2619 (strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
2620 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
2623 SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
2625 goto sensor_ioctl_end;
2627 /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
2629 #if CONFIG_SENSOR_Flash
2630 if (sensor->sensor_gpio_res) {
2631 if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
2632 for (i = 0; i < icd->ops->num_controls; i++) {
2633 if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
2634 memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));
2637 sensor->info_priv.flash = 0xff;
2638 SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
2646 SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
2654 static int sensor_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
2655 enum v4l2_mbus_pixelcode *code)
2657 if (index >= ARRAY_SIZE(sensor_colour_fmts))
2660 *code = sensor_colour_fmts[index].code;
2663 static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
2664 .init = sensor_init,
2665 .g_ctrl = sensor_g_control,
2666 .s_ctrl = sensor_s_control,
2667 .g_ext_ctrls = sensor_g_ext_controls,
2668 .s_ext_ctrls = sensor_s_ext_controls,
2669 .g_chip_ident = sensor_g_chip_ident,
2670 .ioctl = sensor_ioctl,
2673 static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
2674 .s_mbus_fmt = sensor_s_fmt,
2675 .g_mbus_fmt = sensor_g_fmt,
2676 .try_mbus_fmt = sensor_try_fmt,
2677 .enum_mbus_fmt = sensor_enum_fmt,
2680 static struct v4l2_subdev_ops sensor_subdev_ops = {
2681 .core = &sensor_subdev_core_ops,
2682 .video = &sensor_subdev_video_ops,
2685 static int sensor_probe(struct i2c_client *client,
2686 const struct i2c_device_id *did)
2688 struct sensor *sensor;
2689 struct soc_camera_device *icd = client->dev.platform_data;
2690 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
2691 struct soc_camera_link *icl;
2694 SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);
2696 dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());
2700 icl = to_soc_camera_link(icd);
2702 dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());
2706 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
2707 dev_warn(&adapter->dev,
2708 "I2C-Adapter doesn't support I2C_FUNC_I2C\n");
2712 sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);
2716 v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);
2718 /* Second stage probe - when a capture adapter is there */
2719 icd->ops = &sensor_ops;
2721 sensor->info_priv.fmt = sensor_colour_fmts[0];
2723 #if CONFIG_SENSOR_I2C_NOSCHED
2724 atomic_set(&sensor->tasklock_cnt,0);
2727 ret = sensor_video_probe(icd, client);
2730 i2c_set_clientdata(client, NULL);
2734 SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
2738 static int sensor_remove(struct i2c_client *client)
2740 struct sensor *sensor = to_sensor(client);
2741 struct soc_camera_device *icd = client->dev.platform_data;
2744 i2c_set_clientdata(client, NULL);
2745 client->driver = NULL;
2751 static const struct i2c_device_id sensor_id[] = {
2752 {SENSOR_NAME_STRING(), 0 },
2755 MODULE_DEVICE_TABLE(i2c, sensor_id);
2757 static struct i2c_driver sensor_i2c_driver = {
2759 .name = SENSOR_NAME_STRING(),
2761 .probe = sensor_probe,
2762 .remove = sensor_remove,
2763 .id_table = sensor_id,
2766 static int __init sensor_mod_init(void)
2768 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
2769 return i2c_add_driver(&sensor_i2c_driver);
2772 static void __exit sensor_mod_exit(void)
2774 i2c_del_driver(&sensor_i2c_driver);
2777 device_initcall_sync(sensor_mod_init);
2778 module_exit(sensor_mod_exit);
2780 MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
2781 MODULE_AUTHOR("ddl <kernel@rock-chips>");
2782 MODULE_LICENSE("GPL");