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_OV2659
47 #define SENSOR_V4L2_IDENT V4L2_IDENT_OV2659
48 #define SENSOR_ID 0x2656
49 #define SENSOR_MIN_WIDTH 800
50 #define SENSOR_MIN_HEIGHT 600
51 #define SENSOR_MAX_WIDTH 1600
52 #define SENSOR_MAX_HEIGHT 1200
53 #define SENSOR_INIT_WIDTH 800 /* Sensor pixel size for sensor_init_data array */
54 #define SENSOR_INIT_HEIGHT 600
55 #define SENSOR_INIT_WINSEQADR sensor_svga
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 1
68 #define CONFIG_SENSOR_Mirror 0
69 #define CONFIG_SENSOR_Flip 0
71 #define CONFIG_SENSOR_I2C_SPEED 350000 /* 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_LOW |\
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)
102 /* init 800*600 SVGA */
103 static struct reginfo sensor_init_data[] =
108 //{0x0100, 0x01}, //software sleep : Sensor vsync singal may not output if haven't sleep the sensor when transfer the array
274 static struct reginfo sensor_720p[]=
280 //{0x0100, 0x01 }, //software sleep : Sensor vsync singal may not output if haven't sleep the sensor when transfer the array
443 static struct reginfo sensor_uxga[] =
494 static struct reginfo sensor_sxga[] =
499 static struct reginfo sensor_xga[] =
504 static struct reginfo sensor_svga[] =
506 {0x0100, 0x00}, //software sleep : Sensor vsync singal may not output if haven't sleep the sensor when transfer the array,
552 {0x0100, 0x01}, //software wake
557 static struct reginfo sensor_vga[] =
563 static struct reginfo sensor_cif[] =
569 static struct reginfo sensor_qvga[] =
575 static struct reginfo sensor_qcif[] =
581 static struct reginfo ov2655_qqvga[] =
625 static struct reginfo ov2655_Sharpness_auto[] =
630 static struct reginfo ov2655_Sharpness1[] =
636 static struct reginfo ov2655_Sharpness2[][3] =
643 static struct reginfo ov2655_Sharpness3[] =
649 static struct reginfo ov2655_Sharpness4[]=
656 static struct reginfo ov2655_Sharpness5[] =
664 static struct reginfo sensor_ClrFmt_YUYV[]=
670 static struct reginfo sensor_ClrFmt_UYVY[]=
676 #if CONFIG_SENSOR_WhiteBalance
677 static struct reginfo sensor_WhiteB_Auto[]=
679 {0x3406, 0x00}, //AWB auto, bit[1]:0,auto
682 /* Cloudy Colour Temperature : 6500K - 8000K */
683 static struct reginfo sensor_WhiteB_Cloudy[]=
694 /* ClearDay Colour Temperature : 5000K - 6500K */
695 static struct reginfo sensor_WhiteB_ClearDay[]=
707 /* Office Colour Temperature : 3500K - 5000K */
708 static struct reginfo sensor_WhiteB_TungstenLamp1[]=
721 /* Home Colour Temperature : 2500K - 3500K */
722 static struct reginfo sensor_WhiteB_TungstenLamp2[]=
734 static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
735 sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
739 #if CONFIG_SENSOR_Brightness
740 static struct reginfo sensor_Brightness0[]=
746 static struct reginfo sensor_Brightness1[]=
753 static struct reginfo sensor_Brightness2[]=
760 static struct reginfo sensor_Brightness3[]=
767 static struct reginfo sensor_Brightness4[]=
774 static struct reginfo sensor_Brightness5[]=
780 static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
781 sensor_Brightness4, sensor_Brightness5,NULL,
786 #if CONFIG_SENSOR_Effect
787 static struct reginfo sensor_Effect_Normal[] =
793 static struct reginfo sensor_Effect_WandB[] =
799 static struct reginfo sensor_Effect_Sepia[] =
807 static struct reginfo sensor_Effect_Negative[] =
810 {0x507b, 0x40}, //bit[6] negative
813 static struct reginfo sensor_Effect_Bluish[] =
822 static struct reginfo sensor_Effect_Green[] =
830 static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
831 sensor_Effect_Bluish, sensor_Effect_Green,NULL,
834 #if CONFIG_SENSOR_Exposure
835 static struct reginfo sensor_Exposure0[]=
840 static struct reginfo sensor_Exposure1[]=
845 static struct reginfo sensor_Exposure2[]=
850 static struct reginfo sensor_Exposure3[]=
855 static struct reginfo sensor_Exposure4[]=
860 static struct reginfo sensor_Exposure5[]=
865 static struct reginfo sensor_Exposure6[]=
870 static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
871 sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
874 #if CONFIG_SENSOR_Saturation
875 static struct reginfo sensor_Saturation0[]=
880 static struct reginfo sensor_Saturation1[]=
885 static struct reginfo sensor_Saturation2[]=
889 static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
892 #if CONFIG_SENSOR_Contrast
893 static struct reginfo sensor_Contrast0[]=
898 static struct reginfo sensor_Contrast1[]=
903 static struct reginfo sensor_Contrast2[]=
908 static struct reginfo sensor_Contrast3[]=
913 static struct reginfo sensor_Contrast4[]=
919 static struct reginfo sensor_Contrast5[]=
924 static struct reginfo sensor_Contrast6[]=
928 static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
929 sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
933 #if CONFIG_SENSOR_Mirror
934 static struct reginfo sensor_MirrorOn[]=
939 static struct reginfo sensor_MirrorOff[]=
943 static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
945 #if CONFIG_SENSOR_Flip
946 static struct reginfo sensor_FlipOn[]=
951 static struct reginfo sensor_FlipOff[]=
955 static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
958 #if CONFIG_SENSOR_Scene
959 static struct reginfo sensor_SceneAuto[] =
965 static struct reginfo sensor_SceneNight[] =
978 static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
981 #if CONFIG_SENSOR_DigitalZoom
982 static struct reginfo sensor_Zoom0[] =
987 static struct reginfo sensor_Zoom1[] =
992 static struct reginfo sensor_Zoom2[] =
998 static struct reginfo sensor_Zoom3[] =
1002 static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};
1004 static const struct v4l2_querymenu sensor_menus[] =
1006 #if CONFIG_SENSOR_WhiteBalance
1007 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 0, .name = "auto", .reserved = 0, }, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 1, .name = "incandescent", .reserved = 0,},
1008 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
1009 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
1012 #if CONFIG_SENSOR_Effect
1013 { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "mono", .reserved = 0,},
1014 { .id = V4L2_CID_EFFECT, .index = 2, .name = "negative", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "sepia", .reserved = 0,},
1015 { .id = V4L2_CID_EFFECT, .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT, .index = 5, .name = "aqua", .reserved = 0,},
1018 #if CONFIG_SENSOR_Scene
1019 { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
1022 #if CONFIG_SENSOR_Flash
1023 { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
1024 { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
1028 static const struct v4l2_queryctrl sensor_controls[] =
1030 #if CONFIG_SENSOR_WhiteBalance
1032 .id = V4L2_CID_DO_WHITE_BALANCE,
1033 .type = V4L2_CTRL_TYPE_MENU,
1034 .name = "White Balance Control",
1042 #if CONFIG_SENSOR_Brightness
1044 .id = V4L2_CID_BRIGHTNESS,
1045 .type = V4L2_CTRL_TYPE_INTEGER,
1046 .name = "Brightness Control",
1054 #if CONFIG_SENSOR_Effect
1056 .id = V4L2_CID_EFFECT,
1057 .type = V4L2_CTRL_TYPE_MENU,
1058 .name = "Effect Control",
1066 #if CONFIG_SENSOR_Exposure
1068 .id = V4L2_CID_EXPOSURE,
1069 .type = V4L2_CTRL_TYPE_INTEGER,
1070 .name = "Exposure Control",
1078 #if CONFIG_SENSOR_Saturation
1080 .id = V4L2_CID_SATURATION,
1081 .type = V4L2_CTRL_TYPE_INTEGER,
1082 .name = "Saturation Control",
1090 #if CONFIG_SENSOR_Contrast
1092 .id = V4L2_CID_CONTRAST,
1093 .type = V4L2_CTRL_TYPE_INTEGER,
1094 .name = "Contrast Control",
1102 #if CONFIG_SENSOR_Mirror
1104 .id = V4L2_CID_HFLIP,
1105 .type = V4L2_CTRL_TYPE_BOOLEAN,
1106 .name = "Mirror Control",
1114 #if CONFIG_SENSOR_Flip
1116 .id = V4L2_CID_VFLIP,
1117 .type = V4L2_CTRL_TYPE_BOOLEAN,
1118 .name = "Flip Control",
1126 #if CONFIG_SENSOR_Scene
1128 .id = V4L2_CID_SCENE,
1129 .type = V4L2_CTRL_TYPE_MENU,
1130 .name = "Scene Control",
1138 #if CONFIG_SENSOR_DigitalZoom
1140 .id = V4L2_CID_ZOOM_RELATIVE,
1141 .type = V4L2_CTRL_TYPE_INTEGER,
1142 .name = "DigitalZoom Control",
1148 .id = V4L2_CID_ZOOM_ABSOLUTE,
1149 .type = V4L2_CTRL_TYPE_INTEGER,
1150 .name = "DigitalZoom Control",
1158 #if CONFIG_SENSOR_Focus
1160 .id = V4L2_CID_FOCUS_RELATIVE,
1161 .type = V4L2_CTRL_TYPE_INTEGER,
1162 .name = "Focus Control",
1168 .id = V4L2_CID_FOCUS_ABSOLUTE,
1169 .type = V4L2_CTRL_TYPE_INTEGER,
1170 .name = "Focus Control",
1174 .default_value = 125,
1178 #if CONFIG_SENSOR_Flash
1180 .id = V4L2_CID_FLASH,
1181 .type = V4L2_CTRL_TYPE_MENU,
1182 .name = "Flash Control",
1191 static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);
1192 static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
1193 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1194 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1195 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1196 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1197 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
1198 static int sensor_resume(struct soc_camera_device *icd);
1199 static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
1200 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
1201 #if CONFIG_SENSOR_Effect
1202 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1204 #if CONFIG_SENSOR_WhiteBalance
1205 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1207 static int sensor_deactivate(struct i2c_client *client);
1209 static struct soc_camera_ops sensor_ops =
1211 .suspend = sensor_suspend,
1212 .resume = sensor_resume,
1213 .set_bus_param = sensor_set_bus_param,
1214 .query_bus_param = sensor_query_bus_param,
1215 .controls = sensor_controls,
1216 .menus = sensor_menus,
1217 .num_controls = ARRAY_SIZE(sensor_controls),
1218 .num_menus = ARRAY_SIZE(sensor_menus),
1221 /* only one fixed colorspace per pixelcode */
1222 struct sensor_datafmt {
1223 enum v4l2_mbus_pixelcode code;
1224 enum v4l2_colorspace colorspace;
1227 /* Find a data format by a pixel code in an array */
1228 static const struct sensor_datafmt *sensor_find_datafmt(
1229 enum v4l2_mbus_pixelcode code, const struct sensor_datafmt *fmt,
1233 for (i = 0; i < n; i++)
1234 if (fmt[i].code == code)
1240 static const struct sensor_datafmt sensor_colour_fmts[] = {
1241 {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
1242 {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}
1245 typedef struct sensor_info_priv_s
1259 unsigned char mirror; /* HFLIP */
1260 unsigned char flip; /* VFLIP */
1261 unsigned int winseqe_cur_addr;
1262 struct sensor_datafmt fmt;
1263 unsigned int funmodule_state;
1264 } sensor_info_priv_t;
1268 struct v4l2_subdev subdev;
1269 struct i2c_client *client;
1270 sensor_info_priv_t info_priv;
1271 int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
1272 #if CONFIG_SENSOR_I2C_NOSCHED
1273 atomic_t tasklock_cnt;
1275 struct rk29camera_platform_data *sensor_io_request;
1276 struct rk29camera_gpio_res *sensor_gpio_res;
1280 static struct sensor* to_sensor(const struct i2c_client *client)
1282 return container_of(i2c_get_clientdata(client), struct sensor, subdev);
1285 static int sensor_task_lock(struct i2c_client *client, int lock)
1287 #if CONFIG_SENSOR_I2C_NOSCHED
1289 struct sensor *sensor = to_sensor(client);
1292 if (atomic_read(&sensor->tasklock_cnt) == 0) {
1293 while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {
1294 SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());
1298 if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {
1299 SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());
1300 goto sensor_task_lock_err;
1305 atomic_add(1, &sensor->tasklock_cnt);
1307 if (atomic_read(&sensor->tasklock_cnt) > 0) {
1308 atomic_sub(1, &sensor->tasklock_cnt);
1310 if (atomic_read(&sensor->tasklock_cnt) == 0)
1315 sensor_task_lock_err:
1323 /* sensor register write */
1324 static int sensor_write(struct i2c_client *client, u16 reg, u8 val)
1328 struct i2c_msg msg[1];
1331 buf[1] = reg & 0xFF;
1334 msg->addr = client->addr;
1335 msg->flags = client->flags;
1337 msg->len = sizeof(buf);
1338 msg->scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1339 msg->read_type = 0; /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
1344 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
1345 err = i2c_transfer(client->adapter, msg, 1);
1350 SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg, val);
1358 /* sensor register read */
1359 static int sensor_read(struct i2c_client *client, u16 reg, u8 *val)
1363 struct i2c_msg msg[2];
1366 buf[1] = reg & 0xFF;
1368 msg[0].addr = client->addr;
1369 msg[0].flags = client->flags;
1371 msg[0].len = sizeof(buf);
1372 msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1373 msg[0].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
1375 msg[1].addr = client->addr;
1376 msg[1].flags = client->flags|I2C_M_RD;
1379 msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1380 msg[1].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
1384 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
1385 err = i2c_transfer(client->adapter, msg, 2);
1391 SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);
1399 /* write a array of registers */
1400 static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
1404 #if CONFIG_SENSOR_I2C_RDWRCHK
1409 if (sensor_task_lock(client, 1) < 0)
1410 goto sensor_write_array_end;
1412 while (regarray[i].reg != 0)
1414 err = sensor_write(client, regarray[i].reg, regarray[i].val);
1418 SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
1422 SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
1424 goto sensor_write_array_end;
1427 #if CONFIG_SENSOR_I2C_RDWRCHK
1428 sensor_read(client, regarray[i].reg, &valchk);
1429 if (valchk != regarray[i].val)
1430 SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
1436 sensor_write_array_end:
1437 sensor_task_lock(client,0);
1440 #if CONFIG_SENSOR_I2C_RDWRCHK
1441 static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)
1449 while (regarray[i].reg != 0)
1451 sensor_read(client, regarray[i].reg, &valchk);
1452 if (valchk != regarray[i].val)
1453 SENSOR_TR("%s Reg:0x%x read(0x%x, 0x%x) error\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
1460 static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)
1462 struct soc_camera_link *icl = to_soc_camera_link(icd);
1465 SENSOR_DG("%s %s cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);
1468 case Sensor_PowerDown:
1470 if (icl->powerdown) {
1471 ret = icl->powerdown(icd->pdev, on);
1472 if (ret == RK29_CAM_IO_SUCCESS) {
1476 icl->reset(icd->pdev);
1478 } else if (ret == RK29_CAM_EIO_REQUESTFAIL) {
1480 goto sensor_power_end;
1487 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1488 struct sensor *sensor = to_sensor(client);
1490 if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
1491 sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
1497 SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
1504 static int sensor_init(struct v4l2_subdev *sd, u32 val)
1506 struct i2c_client *client = v4l2_get_subdevdata(sd);
1507 struct soc_camera_device *icd = client->dev.platform_data;
1508 struct sensor *sensor = to_sensor(client);
1509 const struct v4l2_queryctrl *qctrl;
1510 const struct sensor_datafmt *fmt;
1514 SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
1516 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
1518 goto sensor_INIT_ERR;
1522 if (sensor_task_lock(client,1)<0)
1523 goto sensor_INIT_ERR;
1525 ret = sensor_write(client, 0x0103, 0x01);
1528 SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
1530 goto sensor_INIT_ERR;
1532 mdelay(5); //delay 5 microseconds
1534 /* check if it is an sensor sensor */
1535 ret = sensor_read(client, 0x300a, &value);
1537 SENSOR_TR("read chip id high byte failed\n");
1539 goto sensor_INIT_ERR;
1542 pid |= (value << 8);
1544 ret = sensor_read(client, 0x300b, &value);
1546 SENSOR_TR("read chip id low byte failed\n");
1548 goto sensor_INIT_ERR;
1551 pid |= (value & 0xff);
1552 SENSOR_DG("\n %s pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
1553 if (pid == SENSOR_ID) {
1554 sensor->model = SENSOR_V4L2_IDENT;
1556 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
1558 goto sensor_INIT_ERR;
1561 ret = sensor_write_array(client, sensor_init_data);
1564 SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
1565 goto sensor_INIT_ERR;
1567 sensor_task_lock(client,0);
1569 sensor->info_priv.winseqe_cur_addr = (int)SENSOR_INIT_WINSEQADR;
1570 fmt = sensor_find_datafmt(SENSOR_INIT_PIXFMT,sensor_colour_fmts, ARRAY_SIZE(sensor_colour_fmts));
1572 SENSOR_TR("error: %s initial array colour fmts is not support!!",SENSOR_NAME_STRING());
1574 goto sensor_INIT_ERR;
1576 sensor->info_priv.fmt = *fmt;
1578 /* sensor sensor information for initialization */
1579 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1581 sensor->info_priv.whiteBalance = qctrl->default_value;
1582 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);
1584 sensor->info_priv.brightness = qctrl->default_value;
1585 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1587 sensor->info_priv.effect = qctrl->default_value;
1588 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);
1590 sensor->info_priv.exposure = qctrl->default_value;
1592 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);
1594 sensor->info_priv.saturation = qctrl->default_value;
1595 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);
1597 sensor->info_priv.contrast = qctrl->default_value;
1598 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);
1600 sensor->info_priv.mirror = qctrl->default_value;
1601 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);
1603 sensor->info_priv.flip = qctrl->default_value;
1604 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);
1606 sensor->info_priv.scene = qctrl->default_value;
1607 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
1609 sensor->info_priv.digitalzoom = qctrl->default_value;
1611 /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
1612 #if CONFIG_SENSOR_Focus
1614 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
1616 sensor->info_priv.focus = qctrl->default_value;
1619 #if CONFIG_SENSOR_Flash
1620 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
1622 sensor->info_priv.flash = qctrl->default_value;
1625 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);
1626 sensor->info_priv.funmodule_state |= SENSOR_INIT_IS_OK;
1629 sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
1630 sensor_task_lock(client,0);
1631 sensor_deactivate(client);
1635 static int sensor_deactivate(struct i2c_client *client)
1637 struct soc_camera_device *icd = client->dev.platform_data;
1639 struct sensor *sensor = to_sensor(client);
1640 SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);
1642 /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
1643 if (sensor->info_priv.funmodule_state & SENSOR_INIT_IS_OK) {
1644 sensor_task_lock(client, 1);
1645 sensor_read(client,0x3000,®_val);
1646 sensor_write(client, 0x3000, reg_val&0xfc);
1647 sensor_write(client, 0x3001, 0x00);
1648 sensor_read(client,0x3002,®_val);
1649 sensor_write(client, 0x3002, reg_val&0x1f);
1650 sensor_task_lock(client, 0);
1652 sensor_ioctrl(icd, Sensor_PowerDown, 1);
1655 /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */
1656 icd->user_width = SENSOR_INIT_WIDTH;
1657 icd->user_height = SENSOR_INIT_HEIGHT;
1658 sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
1663 static struct reginfo sensor_power_down_sequence[]=
1667 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
1670 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1672 if (pm_msg.event == PM_EVENT_SUSPEND) {
1673 SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());
1674 ret = sensor_write_array(client, sensor_power_down_sequence) ;
1676 SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
1679 ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);
1681 SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());
1686 SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
1692 static int sensor_resume(struct soc_camera_device *icd)
1696 ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);
1698 SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());
1702 SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());
1708 static int sensor_set_bus_param(struct soc_camera_device *icd,
1709 unsigned long flags)
1715 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
1717 struct soc_camera_link *icl = to_soc_camera_link(icd);
1718 unsigned long flags = SENSOR_BUS_PARAM;
1720 return soc_camera_apply_sensor_flags(icl, flags);
1723 static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1725 struct i2c_client *client = v4l2_get_subdevdata(sd);
1726 struct soc_camera_device *icd = client->dev.platform_data;
1727 struct sensor *sensor = to_sensor(client);
1729 mf->width = icd->user_width;
1730 mf->height = icd->user_height;
1731 mf->code = sensor->info_priv.fmt.code;
1732 mf->colorspace = sensor->info_priv.fmt.colorspace;
1733 mf->field = V4L2_FIELD_NONE;
1737 static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1741 if ((mf->width == 1024) && (mf->height == 768)) {
1743 } else if ((mf->width == 1280) && (mf->height == 1024)) {
1745 } else if ((mf->width == 1600) && (mf->height == 1200)) {
1747 } else if ((mf->width == 2048) && (mf->height == 1536)) {
1749 } else if ((mf->width == 2592) && (mf->height == 1944)) {
1754 SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, mf->width, mf->height);
1758 static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1762 if ((mf->width == 1280) && (mf->height == 720)) {
1764 } else if ((mf->width == 1920) && (mf->height == 1080)) {
1769 SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, mf->width, mf->height);
1772 static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1774 struct i2c_client *client = v4l2_get_subdevdata(sd);
1775 const struct sensor_datafmt *fmt;
1776 struct sensor *sensor = to_sensor(client);
1777 const struct v4l2_queryctrl *qctrl;
1778 struct soc_camera_device *icd = client->dev.platform_data;
1779 struct reginfo *winseqe_set_addr=NULL;
1780 int ret=0, set_w,set_h;
1782 fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
1783 ARRAY_SIZE(sensor_colour_fmts));
1786 goto sensor_s_fmt_end;
1789 if (sensor->info_priv.fmt.code != mf->code) {
1792 case V4L2_MBUS_FMT_YUYV8_2X8:
1794 winseqe_set_addr = sensor_ClrFmt_YUYV;
1797 case V4L2_MBUS_FMT_UYVY8_2X8:
1799 winseqe_set_addr = sensor_ClrFmt_UYVY;
1805 if (winseqe_set_addr != NULL) {
1806 sensor_write_array(client, winseqe_set_addr);
1807 sensor->info_priv.fmt.code = mf->code;
1808 sensor->info_priv.fmt.colorspace= mf->colorspace;
1809 SENSOR_DG("%s v4l2_mbus_code:%d set success!\n", SENSOR_NAME_STRING(),mf->code);
1811 SENSOR_TR("%s v4l2_mbus_code:%d is invalidate!\n", SENSOR_NAME_STRING(),mf->code);
1818 if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
1820 winseqe_set_addr = sensor_qcif;
1824 else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
1826 winseqe_set_addr = sensor_qvga;
1830 else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
1832 winseqe_set_addr = sensor_cif;
1836 else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
1838 winseqe_set_addr = sensor_vga;
1842 else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
1844 winseqe_set_addr = sensor_svga;
1848 else if (((set_w <= 1280) && (set_h <= 720)) && sensor_720p[0].reg)
1850 winseqe_set_addr = sensor_720p;
1854 else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
1856 winseqe_set_addr = sensor_xga;
1860 else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
1862 winseqe_set_addr = sensor_sxga;
1866 else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
1868 winseqe_set_addr = sensor_uxga;
1874 winseqe_set_addr = SENSOR_INIT_WINSEQADR; /* ddl@rock-chips.com : Sensor output smallest size if isn't support app */
1875 set_w = SENSOR_INIT_WIDTH;
1876 set_h = SENSOR_INIT_HEIGHT;
1877 SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,mf->width,mf->height);
1880 if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr) {
1881 #if CONFIG_SENSOR_Flash
1882 if (sensor_fmt_capturechk(sd,mf) == true) { /* ddl@rock-chips.com : Capture */
1883 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
1884 sensor_ioctrl(icd, Sensor_Flash, Flash_On);
1885 SENSOR_DG("%s flash on in capture!\n", SENSOR_NAME_STRING());
1887 } else { /* ddl@rock-chips.com : Video */
1888 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
1889 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
1890 SENSOR_DG("%s flash off in preivew!\n", SENSOR_NAME_STRING());
1894 ret |= sensor_write_array(client, winseqe_set_addr);
1896 SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
1897 #if CONFIG_SENSOR_Flash
1898 if (sensor_fmt_capturechk(sd,mf) == true) {
1899 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
1900 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
1901 SENSOR_TR("%s Capture format set fail, flash off !\n", SENSOR_NAME_STRING());
1905 goto sensor_s_fmt_end;
1908 sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
1910 if (sensor_fmt_capturechk(sd,mf) == true) { /* ddl@rock-chips.com : Capture */
1911 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1912 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
1913 if (sensor->info_priv.whiteBalance != 0) {
1914 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1915 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
1917 sensor->info_priv.snap2preview = true;
1918 } else if (sensor_fmt_videochk(sd,mf) == true) { /* ddl@rock-chips.com : Video */
1919 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1920 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
1921 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1922 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
1923 sensor->info_priv.video2preview = true;
1924 } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) {
1925 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1926 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
1927 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1928 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
1930 sensor->info_priv.video2preview = false;
1931 sensor->info_priv.snap2preview = false;
1934 SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
1938 SENSOR_DG("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);
1948 static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1950 struct i2c_client *client = v4l2_get_subdevdata(sd);
1951 struct sensor *sensor = to_sensor(client);
1952 const struct sensor_datafmt *fmt;
1955 fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
1956 ARRAY_SIZE(sensor_colour_fmts));
1958 fmt = &sensor->info_priv.fmt;
1959 mf->code = fmt->code;
1962 if (mf->height > SENSOR_MAX_HEIGHT)
1963 mf->height = SENSOR_MAX_HEIGHT;
1964 else if (mf->height < SENSOR_MIN_HEIGHT)
1965 mf->height = SENSOR_MIN_HEIGHT;
1967 if (mf->width > SENSOR_MAX_WIDTH)
1968 mf->width = SENSOR_MAX_WIDTH;
1969 else if (mf->width < SENSOR_MIN_WIDTH)
1970 mf->width = SENSOR_MIN_WIDTH;
1972 mf->colorspace = fmt->colorspace;
1977 static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
1979 struct i2c_client *client = v4l2_get_subdevdata(sd);
1981 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
1984 if (id->match.addr != client->addr)
1987 id->ident = SENSOR_V4L2_IDENT; /* ddl@rock-chips.com : Return OV2655 identifier */
1992 #if CONFIG_SENSOR_Brightness
1993 static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
1995 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1997 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
1999 if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)
2001 if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)
2003 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2006 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2010 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2014 #if CONFIG_SENSOR_Effect
2015 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2017 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2019 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2021 if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)
2023 if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)
2025 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2028 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2032 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2036 #if CONFIG_SENSOR_Exposure
2037 static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2039 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2041 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2043 if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)
2045 if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)
2047 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2050 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2054 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2058 #if CONFIG_SENSOR_Saturation
2059 static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2061 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2063 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2065 if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)
2067 if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)
2069 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2072 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2076 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2080 #if CONFIG_SENSOR_Contrast
2081 static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2083 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2085 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2087 if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)
2089 if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)
2091 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2094 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2098 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2102 #if CONFIG_SENSOR_Mirror
2103 static int sensor_mirror(struct i2c_client *client, int on)
2109 err = sensor_read(client, 0x3821, &val);
2112 err = sensor_write(client, 0x3821, val);
2115 err = sensor_read(client, 0x3821, &val);
2118 err = sensor_write(client, 0x3821, val);
2124 static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2126 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2128 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2130 if (sensor_mirror(client,value) != 0)
2131 SENSOR_TR("%s(%d): sensor_mirror failed, value:0x%x",__FUNCTION__, __LINE__,value);
2133 SENSOR_DG("%s(%d): sensor_mirror success, value:0x%x",__FUNCTION__, __LINE__,value);
2136 SENSOR_TR("\n %s..%s value = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2140 #if CONFIG_SENSOR_Flip
2141 static int sensor_flip(struct i2c_client *client, int on)
2147 err = sensor_read(client, 0x3820, &val);
2150 err = sensor_write(client, 0x3820, val);
2153 err = sensor_read(client, 0x3820, &val);
2156 err = sensor_write(client, 0x3820, val);
2162 static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2164 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2166 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2168 if (sensor_flip(client,value) != 0)
2169 SENSOR_TR("%s(%d): sensor_flip failed, value:0x%x",__FUNCTION__, __LINE__,value);
2171 SENSOR_DG("%s(%d): sensor_flip success, value:0x%x",__FUNCTION__, __LINE__,value);
2174 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2178 #if CONFIG_SENSOR_Scene
2179 static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2181 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2183 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2185 if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)
2187 if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)
2189 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2192 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2196 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2200 #if CONFIG_SENSOR_WhiteBalance
2201 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2203 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2205 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2207 if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
2209 if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
2211 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2214 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2218 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2222 #if CONFIG_SENSOR_DigitalZoom
2223 static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)
2225 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2226 struct sensor *sensor = to_sensor(client);
2227 const struct v4l2_queryctrl *qctrl_info;
2228 int digitalzoom_cur, digitalzoom_total;
2230 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
2234 digitalzoom_cur = sensor->info_priv.digitalzoom;
2235 digitalzoom_total = qctrl_info->maximum;
2237 if ((value > 0) && (digitalzoom_cur >= digitalzoom_total))
2239 SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2243 if ((value < 0) && (digitalzoom_cur <= qctrl_info->minimum))
2245 SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2249 if ((value > 0) && ((digitalzoom_cur + value) > digitalzoom_total))
2251 value = digitalzoom_total - digitalzoom_cur;
2254 if ((value < 0) && ((digitalzoom_cur + value) < 0))
2256 value = 0 - digitalzoom_cur;
2259 digitalzoom_cur += value;
2261 if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)
2263 if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)
2265 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2268 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2275 #if CONFIG_SENSOR_Flash
2276 static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2278 if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {
2279 if (value == 3) { /* ddl@rock-chips.com: torch */
2280 sensor_ioctrl(icd, Sensor_Flash, Flash_Torch); /* Flash On */
2282 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2284 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2288 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2293 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2295 struct i2c_client *client = v4l2_get_subdevdata(sd);
2296 struct sensor *sensor = to_sensor(client);
2297 const struct v4l2_queryctrl *qctrl;
2299 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2303 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2309 case V4L2_CID_BRIGHTNESS:
2311 ctrl->value = sensor->info_priv.brightness;
2314 case V4L2_CID_SATURATION:
2316 ctrl->value = sensor->info_priv.saturation;
2319 case V4L2_CID_CONTRAST:
2321 ctrl->value = sensor->info_priv.contrast;
2324 case V4L2_CID_DO_WHITE_BALANCE:
2326 ctrl->value = sensor->info_priv.whiteBalance;
2329 case V4L2_CID_EXPOSURE:
2331 ctrl->value = sensor->info_priv.exposure;
2334 case V4L2_CID_HFLIP:
2336 ctrl->value = sensor->info_priv.mirror;
2339 case V4L2_CID_VFLIP:
2341 ctrl->value = sensor->info_priv.flip;
2352 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2354 struct i2c_client *client = v4l2_get_subdevdata(sd);
2355 struct sensor *sensor = to_sensor(client);
2356 struct soc_camera_device *icd = client->dev.platform_data;
2357 const struct v4l2_queryctrl *qctrl;
2360 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2364 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2370 #if CONFIG_SENSOR_Brightness
2371 case V4L2_CID_BRIGHTNESS:
2373 if (ctrl->value != sensor->info_priv.brightness)
2375 if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)
2379 sensor->info_priv.brightness = ctrl->value;
2384 #if CONFIG_SENSOR_Exposure
2385 case V4L2_CID_EXPOSURE:
2387 if (ctrl->value != sensor->info_priv.exposure)
2389 if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)
2393 sensor->info_priv.exposure = ctrl->value;
2398 #if CONFIG_SENSOR_Saturation
2399 case V4L2_CID_SATURATION:
2401 if (ctrl->value != sensor->info_priv.saturation)
2403 if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)
2407 sensor->info_priv.saturation = ctrl->value;
2412 #if CONFIG_SENSOR_Contrast
2413 case V4L2_CID_CONTRAST:
2415 if (ctrl->value != sensor->info_priv.contrast)
2417 if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)
2421 sensor->info_priv.contrast = ctrl->value;
2426 #if CONFIG_SENSOR_WhiteBalance
2427 case V4L2_CID_DO_WHITE_BALANCE:
2429 if (ctrl->value != sensor->info_priv.whiteBalance)
2431 if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
2435 sensor->info_priv.whiteBalance = ctrl->value;
2440 #if CONFIG_SENSOR_Mirror
2441 case V4L2_CID_HFLIP:
2443 if (ctrl->value != sensor->info_priv.mirror)
2445 if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)
2447 sensor->info_priv.mirror = ctrl->value;
2452 #if CONFIG_SENSOR_Flip
2453 case V4L2_CID_VFLIP:
2455 if (ctrl->value != sensor->info_priv.flip)
2457 if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)
2459 sensor->info_priv.flip = ctrl->value;
2470 static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
2472 const struct v4l2_queryctrl *qctrl;
2473 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2474 struct sensor *sensor = to_sensor(client);
2476 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
2480 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
2484 switch (ext_ctrl->id)
2486 case V4L2_CID_SCENE:
2488 ext_ctrl->value = sensor->info_priv.scene;
2491 case V4L2_CID_EFFECT:
2493 ext_ctrl->value = sensor->info_priv.effect;
2496 case V4L2_CID_ZOOM_ABSOLUTE:
2498 ext_ctrl->value = sensor->info_priv.digitalzoom;
2501 case V4L2_CID_ZOOM_RELATIVE:
2505 case V4L2_CID_FOCUS_ABSOLUTE:
2507 ext_ctrl->value = sensor->info_priv.focus;
2510 case V4L2_CID_FOCUS_RELATIVE:
2514 case V4L2_CID_FLASH:
2516 ext_ctrl->value = sensor->info_priv.flash;
2524 static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
2526 const struct v4l2_queryctrl *qctrl;
2527 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2528 struct sensor *sensor = to_sensor(client);
2531 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
2535 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
2540 switch (ext_ctrl->id)
2542 #if CONFIG_SENSOR_Scene
2543 case V4L2_CID_SCENE:
2545 if (ext_ctrl->value != sensor->info_priv.scene)
2547 if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)
2549 sensor->info_priv.scene = ext_ctrl->value;
2554 #if CONFIG_SENSOR_Effect
2555 case V4L2_CID_EFFECT:
2557 if (ext_ctrl->value != sensor->info_priv.effect)
2559 if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)
2561 sensor->info_priv.effect= ext_ctrl->value;
2566 #if CONFIG_SENSOR_DigitalZoom
2567 case V4L2_CID_ZOOM_ABSOLUTE:
2569 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
2572 if (ext_ctrl->value != sensor->info_priv.digitalzoom)
2574 val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;
2576 if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)
2578 sensor->info_priv.digitalzoom += val_offset;
2580 SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
2585 case V4L2_CID_ZOOM_RELATIVE:
2587 if (ext_ctrl->value)
2589 if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
2591 sensor->info_priv.digitalzoom += ext_ctrl->value;
2593 SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
2598 #if CONFIG_SENSOR_Focus
2599 case V4L2_CID_FOCUS_ABSOLUTE:
2601 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
2604 if (ext_ctrl->value != sensor->info_priv.focus)
2606 val_offset = ext_ctrl->value -sensor->info_priv.focus;
2608 sensor->info_priv.focus += val_offset;
2613 case V4L2_CID_FOCUS_RELATIVE:
2615 if (ext_ctrl->value)
2617 sensor->info_priv.focus += ext_ctrl->value;
2619 SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);
2624 #if CONFIG_SENSOR_Flash
2625 case V4L2_CID_FLASH:
2627 if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)
2629 sensor->info_priv.flash = ext_ctrl->value;
2631 SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
2642 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
2644 struct i2c_client *client = v4l2_get_subdevdata(sd);
2645 struct soc_camera_device *icd = client->dev.platform_data;
2646 int i, error_cnt=0, error_idx=-1;
2649 for (i=0; i<ext_ctrl->count; i++) {
2650 if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
2657 error_idx = ext_ctrl->count;
2659 if (error_idx != -1) {
2660 ext_ctrl->error_idx = error_idx;
2667 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
2669 struct i2c_client *client = v4l2_get_subdevdata(sd);
2670 struct soc_camera_device *icd = client->dev.platform_data;
2671 int i, error_cnt=0, error_idx=-1;
2674 for (i=0; i<ext_ctrl->count; i++) {
2675 if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
2682 error_idx = ext_ctrl->count;
2684 if (error_idx != -1) {
2685 ext_ctrl->error_idx = error_idx;
2692 /* Interface active, can use i2c. If it fails, it can indeed mean, that
2693 * this wasn't our capture interface, so, we wait for the right one */
2694 static int sensor_video_probe(struct soc_camera_device *icd,
2695 struct i2c_client *client)
2699 struct sensor *sensor = to_sensor(client);
2701 /* We must have a parent by now. And it cannot be a wrong one.
2702 * So this entire test is completely redundant. */
2703 if (!icd->dev.parent ||
2704 to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
2707 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
2709 goto sensor_video_probe_err;
2713 ret = sensor_write(client, 0x0103, 0x01);
2715 SENSOR_TR("soft reset %s failed\n",SENSOR_NAME_STRING());
2717 goto sensor_video_probe_err;
2719 mdelay(5); //delay 5 microseconds
2721 /* check if it is an sensor sensor */
2722 ret = sensor_read(client, 0x300a, &value);
2724 SENSOR_TR("read chip id high byte failed\n");
2726 goto sensor_video_probe_err;
2729 pid |= (value << 8);
2731 ret = sensor_read(client, 0x300b, &value);
2733 SENSOR_TR("read chip id low byte failed\n");
2735 goto sensor_video_probe_err;
2738 pid |= (value & 0xff);
2739 SENSOR_DG("\n %s pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
2740 if (pid == SENSOR_ID) {
2741 sensor->model = SENSOR_V4L2_IDENT;
2743 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
2745 goto sensor_video_probe_err;
2750 sensor_video_probe_err:
2755 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
2757 struct i2c_client *client = v4l2_get_subdevdata(sd);
2758 struct soc_camera_device *icd = client->dev.platform_data;
2759 struct sensor *sensor = to_sensor(client);
2761 #if CONFIG_SENSOR_Flash
2765 SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
2768 case RK29_CAM_SUBDEV_DEACTIVATE:
2770 sensor_deactivate(client);
2774 case RK29_CAM_SUBDEV_IOREQUEST:
2776 sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
2777 if (sensor->sensor_io_request != NULL) {
2778 if (sensor->sensor_io_request->gpio_res[0].dev_name &&
2779 (strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
2780 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
2781 } else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
2782 (strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
2783 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
2786 SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
2788 goto sensor_ioctl_end;
2790 /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
2792 #if CONFIG_SENSOR_Flash
2793 if (sensor->sensor_gpio_res) {
2794 if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
2795 for (i = 0; i < icd->ops->num_controls; i++) {
2796 if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
2797 memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));
2800 sensor->info_priv.flash = 0xff;
2801 SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
2809 SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
2817 static int sensor_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
2818 enum v4l2_mbus_pixelcode *code)
2820 if (index >= ARRAY_SIZE(sensor_colour_fmts))
2823 *code = sensor_colour_fmts[index].code;
2826 static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
2827 .init = sensor_init,
2828 .g_ctrl = sensor_g_control,
2829 .s_ctrl = sensor_s_control,
2830 .g_ext_ctrls = sensor_g_ext_controls,
2831 .s_ext_ctrls = sensor_s_ext_controls,
2832 .g_chip_ident = sensor_g_chip_ident,
2833 .ioctl = sensor_ioctl,
2836 static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
2837 .s_mbus_fmt = sensor_s_fmt,
2838 .g_mbus_fmt = sensor_g_fmt,
2839 .try_mbus_fmt = sensor_try_fmt,
2840 .enum_mbus_fmt = sensor_enum_fmt,
2842 static struct v4l2_subdev_ops sensor_subdev_ops = {
2843 .core = &sensor_subdev_core_ops,
2844 .video = &sensor_subdev_video_ops,
2847 static int sensor_probe(struct i2c_client *client,
2848 const struct i2c_device_id *did)
2850 struct sensor *sensor;
2851 struct soc_camera_device *icd = client->dev.platform_data;
2852 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
2853 struct soc_camera_link *icl;
2856 SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);
2858 dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());
2862 icl = to_soc_camera_link(icd);
2864 dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());
2868 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
2869 dev_warn(&adapter->dev,
2870 "I2C-Adapter doesn't support I2C_FUNC_I2C\n");
2874 sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);
2878 v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);
2880 /* Second stage probe - when a capture adapter is there */
2881 icd->ops = &sensor_ops;
2883 sensor->info_priv.fmt = sensor_colour_fmts[0];
2885 #if CONFIG_SENSOR_I2C_NOSCHED
2886 atomic_set(&sensor->tasklock_cnt,0);
2889 ret = sensor_video_probe(icd, client);
2892 i2c_set_clientdata(client, NULL);
2896 SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
2900 static int sensor_remove(struct i2c_client *client)
2902 struct sensor *sensor = to_sensor(client);
2903 struct soc_camera_device *icd = client->dev.platform_data;
2906 i2c_set_clientdata(client, NULL);
2907 client->driver = NULL;
2913 static const struct i2c_device_id sensor_id[] = {
2914 {SENSOR_NAME_STRING(), 0 },
2917 MODULE_DEVICE_TABLE(i2c, sensor_id);
2919 static struct i2c_driver sensor_i2c_driver = {
2921 .name = SENSOR_NAME_STRING(),
2923 .probe = sensor_probe,
2924 .remove = sensor_remove,
2925 .id_table = sensor_id,
2928 static int __init sensor_mod_init(void)
2930 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
2931 return i2c_add_driver(&sensor_i2c_driver);
2934 static void __exit sensor_mod_exit(void)
2936 i2c_del_driver(&sensor_i2c_driver);
2939 device_initcall_sync(sensor_mod_init);
2940 module_exit(sensor_mod_exit);
2942 MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
2943 MODULE_AUTHOR("ddl <kernel@rock-chips>");
2944 MODULE_LICENSE("GPL");