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_DEBUG 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_OV2655
47 #define SENSOR_V4L2_IDENT V4L2_IDENT_OV2655
48 #define SENSOR_ID 0x2656
49 #define SENSOR_MIN_WIDTH 176
50 #define SENSOR_MIN_HEIGHT 144
51 #define SENSOR_MAX_WIDTH 1600
52 #define SENSOR_MAX_HEIGHT 1200
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_PIX_FMT_UYVY
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 100000 /* Hz */
72 /* Sensor write register continues by preempt_disable/preempt_enable for current process not be scheduled */
73 #define CONFIG_SENSOR_I2C_NOSCHED 1
74 #define CONFIG_SENSOR_I2C_RDWRCHK 1
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)
98 /* init 352X288 SVGA */
99 static struct reginfo sensor_init_data[] =
113 {0x3090, 0x3b},//0x33},
190 {0x3088, 0x02},//{0x3088, 0x01},
191 {0x3089, 0x88},//{0x3089, 0x68},
192 {0x308A, 0x01},//{0x308a, 0x01},
193 {0x308B, 0xe0},//{0x308b, 0x20},
200 {0x331A, 0x28},//{0x331a, 0x16},
201 {0x331B, 0x1e},//{0x331b, 0x12},
264 {0x3350, 0x37},//0x33},
265 {0x3351, 0x27},//0x28},
276 {0x335c, 0x37},//0x34},
305 {0x307c, 0x13},//0x10},
323 {0x0, 0x0} //end flag
328 static struct reginfo sensor_uxga[] =
370 static struct reginfo sensor_sxga[] =
409 static struct reginfo sensor_xga[] =
414 static struct reginfo sensor_svga[] =
455 static struct reginfo sensor_vga[] =
496 static struct reginfo sensor_cif[] =
536 static struct reginfo sensor_qvga[] =
577 static struct reginfo sensor_qcif[] =
617 static struct reginfo ov2655_qqvga[] =
661 static struct reginfo ov2655_Sharpness_auto[] =
666 static struct reginfo ov2655_Sharpness1[] =
672 static struct reginfo ov2655_Sharpness2[][3] =
679 static struct reginfo ov2655_Sharpness3[] =
685 static struct reginfo ov2655_Sharpness4[]=
692 static struct reginfo ov2655_Sharpness5[] =
700 static struct reginfo sensor_ClrFmt_YUYV[]=
706 static struct reginfo sensor_ClrFmt_UYVY[]=
712 #if CONFIG_SENSOR_WhiteBalance
713 static struct reginfo sensor_WhiteB_Auto[]=
715 {0x3306, 0x00}, //AWB auto, bit[1]:0,auto
718 /* Cloudy Colour Temperature : 6500K - 8000K */
719 static struct reginfo sensor_WhiteB_Cloudy[]=
727 /* ClearDay Colour Temperature : 5000K - 6500K */
728 static struct reginfo sensor_WhiteB_ClearDay[]=
731 {0x3306, 0x02}, //AWB off
737 /* Office Colour Temperature : 3500K - 5000K */
738 static struct reginfo sensor_WhiteB_TungstenLamp1[]=
748 /* Home Colour Temperature : 2500K - 3500K */
749 static struct reginfo sensor_WhiteB_TungstenLamp2[]=
758 static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
759 sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
763 #if CONFIG_SENSOR_Brightness
764 static struct reginfo sensor_Brightness0[]=
767 {0x3301, 0xff},//bit[7]:1, enable SDE
774 static struct reginfo sensor_Brightness1[]=
777 {0x3301, 0xff},//bit[7]:1, enable SDE
784 static struct reginfo sensor_Brightness2[]=
787 {0x3301, 0xff},//bit[7]:1, enable SDE
794 static struct reginfo sensor_Brightness3[]=
797 {0x3301, 0xff},//bit[7]:1, enable SDE
804 static struct reginfo sensor_Brightness4[]=
807 {0x3301, 0xff},//bit[7]:1, enable SDE
814 static struct reginfo sensor_Brightness5[]=
817 {0x3301, 0xff},//bit[7]:1, enable SDE
818 {0x3391, 0x04}, //bit[2] enable
819 {0x3390, 0x41}, //bit[3] sign of brightness
823 static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
824 sensor_Brightness4, sensor_Brightness5,NULL,
829 #if CONFIG_SENSOR_Effect
830 static struct reginfo sensor_Effect_Normal[] =
836 static struct reginfo sensor_Effect_WandB[] =
842 static struct reginfo sensor_Effect_Sepia[] =
850 static struct reginfo sensor_Effect_Negative[] =
853 {0x3391, 0x40}, //bit[6] negative
856 static struct reginfo sensor_Effect_Bluish[] =
865 static struct reginfo sensor_Effect_Green[] =
873 static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
874 sensor_Effect_Bluish, sensor_Effect_Green,NULL,
877 #if CONFIG_SENSOR_Exposure
878 static struct reginfo sensor_Exposure0[]=
888 static struct reginfo sensor_Exposure1[]=
898 static struct reginfo sensor_Exposure2[]=
908 static struct reginfo sensor_Exposure3[]=
918 static struct reginfo sensor_Exposure4[]=
928 static struct reginfo sensor_Exposure5[]=
938 static struct reginfo sensor_Exposure6[]=
948 static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
949 sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
952 #if CONFIG_SENSOR_Saturation
953 static struct reginfo sensor_Saturation0[]=
955 {0x3301, 0xff},//bit[7]:1, enable SDE
962 static struct reginfo sensor_Saturation1[]=
964 {0x3301, 0xff},//bit[7]:1, enable SDE
971 static struct reginfo sensor_Saturation2[]=
973 {0x3301, 0xff},//bit[7]:1, enable SDE
974 {0x3391, 0x02}, //enable color saturation
979 static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
982 #if CONFIG_SENSOR_Contrast
983 static struct reginfo sensor_Contrast0[]=
986 {0x3301, 0xff},//bit[7]:1, enable SDE
994 static struct reginfo sensor_Contrast1[]=
997 {0x3301, 0xff},//bit[7]:1, enable SDE
1005 static struct reginfo sensor_Contrast2[]=
1008 {0x3301, 0xff},//bit[7]:1, enable SDE
1016 static struct reginfo sensor_Contrast3[]=
1019 {0x3301, 0xff},//bit[7]:1, enable SDE
1027 static struct reginfo sensor_Contrast4[]=
1030 {0x3301, 0xff},//bit[7]:1, enable SDE
1039 static struct reginfo sensor_Contrast5[]=
1042 {0x3301, 0xff},//bit[7]:1, enable SDE
1050 static struct reginfo sensor_Contrast6[]=
1053 {0x3301, 0xff},//bit[7]:1, enable SDE
1054 {0x3391, 0x04}, //bit[2] enable contrast/brightness
1055 {0x3390, 0x45}, //bit[2] Yoffset sign
1060 static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
1061 sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
1065 #if CONFIG_SENSOR_Mirror
1066 static struct reginfo sensor_MirrorOn[]=
1074 static struct reginfo sensor_MirrorOff[]=
1081 static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
1083 #if CONFIG_SENSOR_Flip
1084 static struct reginfo sensor_FlipOn[]=
1097 static struct reginfo sensor_FlipOff[]=
1109 static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
1112 #if CONFIG_SENSOR_Scene
1113 static struct reginfo sensor_SceneAuto[] =
1115 #if 0 /* ddl@rock-chips.com : */
1130 static struct reginfo sensor_SceneNight[] =
1133 //30fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,36Mzh pclk
1144 {0x3015, 0x50},//add 5 dummy frame
1149 //15fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,18Mhz pclk
1165 static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
1168 #if CONFIG_SENSOR_DigitalZoom
1169 static struct reginfo sensor_Zoom0[] =
1174 static struct reginfo sensor_Zoom1[] =
1179 static struct reginfo sensor_Zoom2[] =
1185 static struct reginfo sensor_Zoom3[] =
1189 static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};
1191 static const struct v4l2_querymenu sensor_menus[] =
1193 #if CONFIG_SENSOR_WhiteBalance
1194 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 0, .name = "auto", .reserved = 0, }, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 1, .name = "incandescent", .reserved = 0,},
1195 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
1196 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
1199 #if CONFIG_SENSOR_Effect
1200 { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "mono", .reserved = 0,},
1201 { .id = V4L2_CID_EFFECT, .index = 2, .name = "negative", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "sepia", .reserved = 0,},
1202 { .id = V4L2_CID_EFFECT, .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT, .index = 5, .name = "aqua", .reserved = 0,},
1205 #if CONFIG_SENSOR_Scene
1206 { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
1209 #if CONFIG_SENSOR_Flash
1210 { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
1211 { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
1215 static const struct v4l2_queryctrl sensor_controls[] =
1217 #if CONFIG_SENSOR_WhiteBalance
1219 .id = V4L2_CID_DO_WHITE_BALANCE,
1220 .type = V4L2_CTRL_TYPE_MENU,
1221 .name = "White Balance Control",
1229 #if CONFIG_SENSOR_Brightness
1231 .id = V4L2_CID_BRIGHTNESS,
1232 .type = V4L2_CTRL_TYPE_INTEGER,
1233 .name = "Brightness Control",
1241 #if CONFIG_SENSOR_Effect
1243 .id = V4L2_CID_EFFECT,
1244 .type = V4L2_CTRL_TYPE_MENU,
1245 .name = "Effect Control",
1253 #if CONFIG_SENSOR_Exposure
1255 .id = V4L2_CID_EXPOSURE,
1256 .type = V4L2_CTRL_TYPE_INTEGER,
1257 .name = "Exposure Control",
1265 #if CONFIG_SENSOR_Saturation
1267 .id = V4L2_CID_SATURATION,
1268 .type = V4L2_CTRL_TYPE_INTEGER,
1269 .name = "Saturation Control",
1277 #if CONFIG_SENSOR_Contrast
1279 .id = V4L2_CID_CONTRAST,
1280 .type = V4L2_CTRL_TYPE_INTEGER,
1281 .name = "Contrast Control",
1289 #if CONFIG_SENSOR_Mirror
1291 .id = V4L2_CID_HFLIP,
1292 .type = V4L2_CTRL_TYPE_BOOLEAN,
1293 .name = "Mirror Control",
1301 #if CONFIG_SENSOR_Flip
1303 .id = V4L2_CID_VFLIP,
1304 .type = V4L2_CTRL_TYPE_BOOLEAN,
1305 .name = "Flip Control",
1313 #if CONFIG_SENSOR_Scene
1315 .id = V4L2_CID_SCENE,
1316 .type = V4L2_CTRL_TYPE_MENU,
1317 .name = "Scene Control",
1325 #if CONFIG_SENSOR_DigitalZoom
1327 .id = V4L2_CID_ZOOM_RELATIVE,
1328 .type = V4L2_CTRL_TYPE_INTEGER,
1329 .name = "DigitalZoom Control",
1335 .id = V4L2_CID_ZOOM_ABSOLUTE,
1336 .type = V4L2_CTRL_TYPE_INTEGER,
1337 .name = "DigitalZoom Control",
1345 #if CONFIG_SENSOR_Focus
1347 .id = V4L2_CID_FOCUS_RELATIVE,
1348 .type = V4L2_CTRL_TYPE_INTEGER,
1349 .name = "Focus Control",
1355 .id = V4L2_CID_FOCUS_ABSOLUTE,
1356 .type = V4L2_CTRL_TYPE_INTEGER,
1357 .name = "Focus Control",
1361 .default_value = 125,
1365 #if CONFIG_SENSOR_Flash
1367 .id = V4L2_CID_FLASH,
1368 .type = V4L2_CTRL_TYPE_MENU,
1369 .name = "Flash Control",
1378 static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);
1379 static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
1380 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1381 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1382 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1383 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1384 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
1385 static int sensor_resume(struct soc_camera_device *icd);
1386 static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
1387 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
1388 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1389 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1390 static int sensor_deactivate(struct i2c_client *client);
1392 static struct soc_camera_ops sensor_ops =
1394 .suspend = sensor_suspend,
1395 .resume = sensor_resume,
1396 .set_bus_param = sensor_set_bus_param,
1397 .query_bus_param = sensor_query_bus_param,
1398 .controls = sensor_controls,
1399 .menus = sensor_menus,
1400 .num_controls = ARRAY_SIZE(sensor_controls),
1401 .num_menus = ARRAY_SIZE(sensor_menus),
1404 #define COL_FMT(_name, _depth, _fourcc, _colorspace) \
1405 { .name = _name, .depth = _depth, .fourcc = _fourcc, \
1406 .colorspace = _colorspace }
1408 #define JPG_FMT(_name, _depth, _fourcc) \
1409 COL_FMT(_name, _depth, _fourcc, V4L2_COLORSPACE_JPEG)
1411 static const struct soc_camera_data_format sensor_colour_formats[] = {
1412 JPG_FMT(SENSOR_NAME_STRING(UYVY), 16, V4L2_PIX_FMT_UYVY),
1413 JPG_FMT(SENSOR_NAME_STRING(YUYV), 16, V4L2_PIX_FMT_YUYV),
1416 typedef struct sensor_info_priv_s
1430 unsigned char mirror; /* HFLIP */
1431 unsigned char flip; /* VFLIP */
1432 unsigned int winseqe_cur_addr;
1433 unsigned int pixfmt;
1435 } sensor_info_priv_t;
1439 struct v4l2_subdev subdev;
1440 struct i2c_client *client;
1441 sensor_info_priv_t info_priv;
1442 int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
1443 #if CONFIG_SENSOR_I2C_NOSCHED
1444 atomic_t tasklock_cnt;
1446 struct rk29camera_platform_data *sensor_io_request;
1447 struct rk29camera_gpio_res *sensor_gpio_res;
1450 static struct sensor* to_sensor(const struct i2c_client *client)
1452 return container_of(i2c_get_clientdata(client), struct sensor, subdev);
1455 static int sensor_task_lock(struct i2c_client *client, int lock)
1457 #if CONFIG_SENSOR_I2C_NOSCHED
1459 struct sensor *sensor = to_sensor(client);
1462 if (atomic_read(&sensor->tasklock_cnt) == 0) {
1463 while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {
1464 SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());
1468 if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {
1469 SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());
1470 goto sensor_task_lock_err;
1475 atomic_add(1, &sensor->tasklock_cnt);
1477 if (atomic_read(&sensor->tasklock_cnt) > 0) {
1478 atomic_sub(1, &sensor->tasklock_cnt);
1480 if (atomic_read(&sensor->tasklock_cnt) == 0)
1485 sensor_task_lock_err:
1493 /* sensor register write */
1494 static int sensor_write(struct i2c_client *client, u16 reg, u8 val)
1498 struct i2c_msg msg[1];
1501 buf[1] = reg & 0xFF;
1504 msg->addr = client->addr;
1505 msg->flags = client->flags;
1507 msg->len = sizeof(buf);
1508 msg->scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1509 msg->read_type = 0; /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
1514 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
1515 err = i2c_transfer(client->adapter, msg, 1);
1520 SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg, val);
1528 /* sensor register read */
1529 static int sensor_read(struct i2c_client *client, u16 reg, u8 *val)
1533 struct i2c_msg msg[2];
1536 buf[1] = reg & 0xFF;
1538 msg[0].addr = client->addr;
1539 msg[0].flags = client->flags;
1541 msg[0].len = sizeof(buf);
1542 msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1543 msg[0].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
1545 msg[1].addr = client->addr;
1546 msg[1].flags = client->flags|I2C_M_RD;
1549 msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1550 msg[1].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
1554 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
1555 err = i2c_transfer(client->adapter, msg, 2);
1561 SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);
1569 /* write a array of registers */
1570 static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
1574 #if CONFIG_SENSOR_I2C_RDWRCHK
1579 if (sensor_task_lock(client, 1) < 0)
1580 goto sensor_write_array_end;
1581 while (regarray[i].reg != 0)
1583 err = sensor_write(client, regarray[i].reg, regarray[i].val);
1587 SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
1591 SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
1593 goto sensor_write_array_end;
1596 #if CONFIG_SENSOR_I2C_RDWRCHK
1597 sensor_read(client, regarray[i].reg, &valchk);
1598 if (valchk != regarray[i].val)
1599 SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
1605 sensor_write_array_end:
1606 sensor_task_lock(client,0);
1609 static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)
1617 while (regarray[i].reg != 0)
1619 sensor_read(client, regarray[i].reg, &valchk);
1620 if (valchk != regarray[i].val)
1621 SENSOR_TR("%s Reg:0x%x read(0x%x, 0x%x) error\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
1627 static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)
1629 struct soc_camera_link *icl = to_soc_camera_link(icd);
1632 SENSOR_DG("%s %s cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);
1636 case Sensor_PowerDown:
1638 if (icl->powerdown) {
1639 ret = icl->powerdown(icd->pdev, on);
1640 if (ret == RK29_CAM_IO_SUCCESS) {
1644 icl->reset(icd->pdev);
1646 } else if (ret == RK29_CAM_EIO_REQUESTFAIL) {
1648 goto sensor_power_end;
1655 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1656 struct sensor *sensor = to_sensor(client);
1658 if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
1659 sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
1664 SENSOR_TR("%s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),cmd);
1671 static int sensor_init(struct v4l2_subdev *sd, u32 val)
1673 struct i2c_client *client = sd->priv;
1674 struct soc_camera_device *icd = client->dev.platform_data;
1675 struct sensor *sensor = to_sensor(client);
1676 const struct v4l2_queryctrl *qctrl;
1680 SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
1682 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
1684 goto sensor_INIT_ERR;
1688 if (sensor_task_lock(client,1)<0)
1689 goto sensor_INIT_ERR;
1690 ret = sensor_write(client, 0x3012, 0x80);
1693 SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
1695 goto sensor_INIT_ERR;
1698 mdelay(5); //delay 5 microseconds
1699 /* check if it is an sensor sensor */
1700 ret = sensor_read(client, 0x300a, &value);
1702 SENSOR_TR("read chip id high byte failed\n");
1704 goto sensor_INIT_ERR;
1707 pid |= (value << 8);
1709 ret = sensor_read(client, 0x300b, &value);
1711 SENSOR_TR("read chip id low byte failed\n");
1713 goto sensor_INIT_ERR;
1716 pid |= (value & 0xff);
1717 SENSOR_DG("\n %s pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
1718 if (pid == SENSOR_ID) {
1719 sensor->model = SENSOR_V4L2_IDENT;
1721 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
1723 goto sensor_INIT_ERR;
1726 ret = sensor_write_array(client, sensor_init_data);
1729 SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
1730 goto sensor_INIT_ERR;
1732 sensor_task_lock(client,0);
1733 //icd->user_width = SENSOR_INIT_WIDTH;
1734 //icd->user_height = SENSOR_INIT_HEIGHT;
1735 sensor->info_priv.winseqe_cur_addr = (int)SENSOR_INIT_WINSEQADR;
1736 sensor->info_priv.pixfmt = SENSOR_INIT_PIXFMT;
1738 /* sensor sensor information for initialization */
1739 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1741 sensor->info_priv.whiteBalance = qctrl->default_value;
1742 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);
1744 sensor->info_priv.brightness = qctrl->default_value;
1745 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1747 sensor->info_priv.effect = qctrl->default_value;
1748 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);
1750 sensor->info_priv.exposure = qctrl->default_value;
1752 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);
1754 sensor->info_priv.saturation = qctrl->default_value;
1755 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);
1757 sensor->info_priv.contrast = qctrl->default_value;
1758 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);
1760 sensor->info_priv.mirror = qctrl->default_value;
1761 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);
1763 sensor->info_priv.flip = qctrl->default_value;
1764 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);
1766 sensor->info_priv.scene = qctrl->default_value;
1767 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
1769 sensor->info_priv.digitalzoom = qctrl->default_value;
1771 /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
1772 #if CONFIG_SENSOR_Focus
1774 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
1776 sensor->info_priv.focus = qctrl->default_value;
1779 #if CONFIG_SENSOR_Flash
1780 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
1782 sensor->info_priv.flash = qctrl->default_value;
1785 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);
1789 sensor_task_lock(client,0);
1790 sensor_deactivate(client);
1794 static int sensor_deactivate(struct i2c_client *client)
1796 struct soc_camera_device *icd = client->dev.platform_data;
1798 SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);
1800 /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
1801 sensor_task_lock(client, 1);
1802 sensor_write(client, 0x30b0, 0x00);
1803 sensor_write(client, 0x30b1, 0x00);
1804 sensor_task_lock(client, 0);
1805 sensor_ioctrl(icd, Sensor_PowerDown, 1);
1807 /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */
1808 icd->user_width = SENSOR_INIT_WIDTH;
1809 icd->user_height = SENSOR_INIT_HEIGHT;
1814 static struct reginfo sensor_power_down_sequence[]=
1822 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
1825 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1827 if (pm_msg.event == PM_EVENT_SUSPEND) {
1828 SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());
1829 ret = sensor_write_array(client, sensor_power_down_sequence) ;
1831 SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
1834 ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);
1836 SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());
1841 SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
1847 static int sensor_resume(struct soc_camera_device *icd)
1851 ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);
1853 SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());
1857 SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());
1863 static int sensor_set_bus_param(struct soc_camera_device *icd,
1864 unsigned long flags)
1870 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
1872 struct soc_camera_link *icl = to_soc_camera_link(icd);
1873 unsigned long flags = SENSOR_BUS_PARAM;
1875 return soc_camera_apply_sensor_flags(icl, flags);
1878 static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
1880 struct i2c_client *client = sd->priv;
1881 struct soc_camera_device *icd = client->dev.platform_data;
1882 struct sensor *sensor = to_sensor(client);
1883 struct v4l2_pix_format *pix = &f->fmt.pix;
1885 pix->width = icd->user_width;
1886 pix->height = icd->user_height;
1887 pix->pixelformat = sensor->info_priv.pixfmt;
1888 pix->field = V4L2_FIELD_NONE;
1889 pix->colorspace = V4L2_COLORSPACE_JPEG;
1893 static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_format *f)
1897 if ((f->fmt.pix.width == 1024) && (f->fmt.pix.height == 768)) {
1899 } else if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 1024)) {
1901 } else if ((f->fmt.pix.width == 1600) && (f->fmt.pix.height == 1200)) {
1903 } else if ((f->fmt.pix.width == 2048) && (f->fmt.pix.height == 1536)) {
1905 } else if ((f->fmt.pix.width == 2592) && (f->fmt.pix.height == 1944)) {
1910 SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height);
1914 static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_format *f)
1918 if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 720)) {
1920 } else if ((f->fmt.pix.width == 1920) && (f->fmt.pix.height == 1080)) {
1925 SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height);
1928 static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
1930 struct i2c_client *client = sd->priv;
1931 struct sensor *sensor = to_sensor(client);
1932 struct v4l2_pix_format *pix = &f->fmt.pix;
1933 const struct v4l2_queryctrl *qctrl;
1934 struct soc_camera_device *icd = client->dev.platform_data;
1935 struct reginfo *winseqe_set_addr=NULL;
1936 int ret=0, set_w,set_h;
1938 if (sensor->info_priv.pixfmt != pix->pixelformat) {
1939 switch (pix->pixelformat)
1941 case V4L2_PIX_FMT_YUYV:
1943 winseqe_set_addr = sensor_ClrFmt_YUYV;
1946 case V4L2_PIX_FMT_UYVY:
1948 winseqe_set_addr = sensor_ClrFmt_UYVY;
1954 if (winseqe_set_addr != NULL) {
1955 sensor_write_array(client, winseqe_set_addr);
1956 sensor->info_priv.pixfmt = pix->pixelformat;
1958 SENSOR_DG("%s Pixelformat(0x%x) set success!\n", SENSOR_NAME_STRING(),pix->pixelformat);
1960 SENSOR_TR("%s Pixelformat(0x%x) is invalidate!\n", SENSOR_NAME_STRING(),pix->pixelformat);
1965 set_h = pix->height;
1967 if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
1969 winseqe_set_addr = sensor_qcif;
1973 else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
1975 winseqe_set_addr = sensor_qvga;
1979 else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
1981 winseqe_set_addr = sensor_cif;
1985 else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
1987 winseqe_set_addr = sensor_vga;
1991 else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
1993 winseqe_set_addr = sensor_svga;
1997 else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
1999 winseqe_set_addr = sensor_xga;
2003 else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
2005 winseqe_set_addr = sensor_sxga;
2009 else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
2011 winseqe_set_addr = sensor_uxga;
2017 winseqe_set_addr = SENSOR_INIT_WINSEQADR; /* ddl@rock-chips.com : Sensor output smallest size if isn't support app */
2018 set_w = SENSOR_INIT_WIDTH;
2019 set_h = SENSOR_INIT_HEIGHT;
2020 SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,pix->width,pix->height);
2023 if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr) {
2024 #if CONFIG_SENSOR_Flash
2025 if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */
2026 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
2027 sensor_ioctrl(icd, Sensor_Flash, Flash_On);
2028 SENSOR_DG("%s flash on in capture!\n", SENSOR_NAME_STRING());
2030 } else { /* ddl@rock-chips.com : Video */
2031 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
2032 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2033 SENSOR_DG("%s flash off in preivew!\n", SENSOR_NAME_STRING());
2037 ret |= sensor_write_array(client, winseqe_set_addr);
2039 SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
2040 #if CONFIG_SENSOR_Flash
2041 if (sensor_fmt_capturechk(sd,f) == true) {
2042 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
2043 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2044 SENSOR_TR("%s Capture format set fail, flash off !\n", SENSOR_NAME_STRING());
2048 goto sensor_s_fmt_end;
2051 sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
2053 if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */
2054 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
2055 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
2056 if (sensor->info_priv.whiteBalance != 0) {
2057 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
2058 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
2060 sensor->info_priv.snap2preview = true;
2061 } else if (sensor_fmt_videochk(sd,f) == true) { /* ddl@rock-chips.com : Video */
2062 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
2063 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
2064 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
2065 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
2066 sensor->info_priv.video2preview = true;
2067 } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) {
2068 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
2069 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
2070 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
2071 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
2072 sensor->info_priv.video2preview = false;
2073 sensor->info_priv.snap2preview = false;
2075 SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
2079 SENSOR_DG("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);
2083 pix->height = set_h;
2089 static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
2091 struct v4l2_pix_format *pix = &f->fmt.pix;
2092 bool bayer = pix->pixelformat == V4L2_PIX_FMT_UYVY ||
2093 pix->pixelformat == V4L2_PIX_FMT_YUYV;
2096 * With Bayer format enforce even side lengths, but let the user play
2097 * with the starting pixel
2100 if (pix->height > SENSOR_MAX_HEIGHT)
2101 pix->height = SENSOR_MAX_HEIGHT;
2102 else if (pix->height < SENSOR_MIN_HEIGHT)
2103 pix->height = SENSOR_MIN_HEIGHT;
2105 pix->height = ALIGN(pix->height, 2);
2107 if (pix->width > SENSOR_MAX_WIDTH)
2108 pix->width = SENSOR_MAX_WIDTH;
2109 else if (pix->width < SENSOR_MIN_WIDTH)
2110 pix->width = SENSOR_MIN_WIDTH;
2112 pix->width = ALIGN(pix->width, 2);
2117 static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
2119 struct i2c_client *client = sd->priv;
2121 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
2124 if (id->match.addr != client->addr)
2127 id->ident = SENSOR_V4L2_IDENT; /* ddl@rock-chips.com : Return OV2655 identifier */
2132 #if CONFIG_SENSOR_Brightness
2133 static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2135 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2137 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2139 if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)
2141 if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)
2143 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2146 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2150 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2154 #if CONFIG_SENSOR_Effect
2155 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2157 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2159 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2161 if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)
2163 if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)
2165 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2168 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2172 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2176 #if CONFIG_SENSOR_Exposure
2177 static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2179 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2181 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2183 if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)
2185 if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)
2187 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2190 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2194 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2198 #if CONFIG_SENSOR_Saturation
2199 static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2201 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2203 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2205 if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)
2207 if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)
2209 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2212 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2216 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2220 #if CONFIG_SENSOR_Contrast
2221 static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2223 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2225 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2227 if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)
2229 if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)
2231 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2234 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2238 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2242 #if CONFIG_SENSOR_Mirror
2243 static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2245 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2247 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2249 if (sensor_MirrorSeqe[value - qctrl->minimum] != NULL)
2251 if (sensor_write_array(client, sensor_MirrorSeqe[value - qctrl->minimum]) != 0)
2253 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2256 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2260 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2264 #if CONFIG_SENSOR_Flip
2265 static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2267 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2269 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2271 if (sensor_FlipSeqe[value - qctrl->minimum] != NULL)
2273 if (sensor_write_array(client, sensor_FlipSeqe[value - qctrl->minimum]) != 0)
2275 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2278 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2282 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2286 #if CONFIG_SENSOR_Scene
2287 static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2289 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2291 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2293 if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)
2295 if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)
2297 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2300 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2304 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2308 #if CONFIG_SENSOR_WhiteBalance
2309 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2311 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2313 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2315 if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
2317 if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
2319 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2322 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2326 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2330 #if CONFIG_SENSOR_DigitalZoom
2331 static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)
2333 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2334 struct sensor *sensor = to_sensor(client);
2335 const struct v4l2_queryctrl *qctrl_info;
2336 int digitalzoom_cur, digitalzoom_total;
2338 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
2342 digitalzoom_cur = sensor->info_priv.digitalzoom;
2343 digitalzoom_total = qctrl_info->maximum;
2345 if ((*value > 0) && (digitalzoom_cur >= digitalzoom_total))
2347 SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2351 if ((*value < 0) && (digitalzoom_cur <= qctrl_info->minimum))
2353 SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2357 if ((*value > 0) && ((digitalzoom_cur + *value) > digitalzoom_total))
2359 *value = digitalzoom_total - digitalzoom_cur;
2362 if ((*value < 0) && ((digitalzoom_cur + *value) < 0))
2364 *value = 0 - digitalzoom_cur;
2367 digitalzoom_cur += *value;
2369 if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)
2371 if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)
2373 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2376 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, *value);
2383 #if CONFIG_SENSOR_Flash
2384 static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2386 if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {
2387 if (value == 3) { /* ddl@rock-chips.com: torch */
2388 sensor_ioctrl(icd, Sensor_Flash, Flash_Torch); /* Flash On */
2390 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2392 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2396 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2401 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2403 struct i2c_client *client = sd->priv;
2404 struct sensor *sensor = to_sensor(client);
2405 const struct v4l2_queryctrl *qctrl;
2407 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2411 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2417 case V4L2_CID_BRIGHTNESS:
2419 ctrl->value = sensor->info_priv.brightness;
2422 case V4L2_CID_SATURATION:
2424 ctrl->value = sensor->info_priv.saturation;
2427 case V4L2_CID_CONTRAST:
2429 ctrl->value = sensor->info_priv.contrast;
2432 case V4L2_CID_DO_WHITE_BALANCE:
2434 ctrl->value = sensor->info_priv.whiteBalance;
2437 case V4L2_CID_EXPOSURE:
2439 ctrl->value = sensor->info_priv.exposure;
2442 case V4L2_CID_HFLIP:
2444 ctrl->value = sensor->info_priv.mirror;
2447 case V4L2_CID_VFLIP:
2449 ctrl->value = sensor->info_priv.flip;
2460 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2462 struct i2c_client *client = sd->priv;
2463 struct sensor *sensor = to_sensor(client);
2464 struct soc_camera_device *icd = client->dev.platform_data;
2465 const struct v4l2_queryctrl *qctrl;
2468 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2472 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2478 #if CONFIG_SENSOR_Brightness
2479 case V4L2_CID_BRIGHTNESS:
2481 if (ctrl->value != sensor->info_priv.brightness)
2483 if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)
2487 sensor->info_priv.brightness = ctrl->value;
2492 #if CONFIG_SENSOR_Exposure
2493 case V4L2_CID_EXPOSURE:
2495 if (ctrl->value != sensor->info_priv.exposure)
2497 if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)
2501 sensor->info_priv.exposure = ctrl->value;
2506 #if CONFIG_SENSOR_Saturation
2507 case V4L2_CID_SATURATION:
2509 if (ctrl->value != sensor->info_priv.saturation)
2511 if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)
2515 sensor->info_priv.saturation = ctrl->value;
2520 #if CONFIG_SENSOR_Contrast
2521 case V4L2_CID_CONTRAST:
2523 if (ctrl->value != sensor->info_priv.contrast)
2525 if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)
2529 sensor->info_priv.contrast = ctrl->value;
2534 #if CONFIG_SENSOR_WhiteBalance
2535 case V4L2_CID_DO_WHITE_BALANCE:
2537 if (ctrl->value != sensor->info_priv.whiteBalance)
2539 if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
2543 sensor->info_priv.whiteBalance = ctrl->value;
2548 #if CONFIG_SENSOR_Mirror
2549 case V4L2_CID_HFLIP:
2551 if (ctrl->value != sensor->info_priv.mirror)
2553 if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)
2555 sensor->info_priv.mirror = ctrl->value;
2560 #if CONFIG_SENSOR_Flip
2561 case V4L2_CID_VFLIP:
2563 if (ctrl->value != sensor->info_priv.flip)
2565 if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)
2567 sensor->info_priv.flip = ctrl->value;
2578 static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
2580 const struct v4l2_queryctrl *qctrl;
2581 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2582 struct sensor *sensor = to_sensor(client);
2584 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
2588 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
2592 switch (ext_ctrl->id)
2594 case V4L2_CID_SCENE:
2596 ext_ctrl->value = sensor->info_priv.scene;
2599 case V4L2_CID_EFFECT:
2601 ext_ctrl->value = sensor->info_priv.effect;
2604 case V4L2_CID_ZOOM_ABSOLUTE:
2606 ext_ctrl->value = sensor->info_priv.digitalzoom;
2609 case V4L2_CID_ZOOM_RELATIVE:
2613 case V4L2_CID_FOCUS_ABSOLUTE:
2615 ext_ctrl->value = sensor->info_priv.focus;
2618 case V4L2_CID_FOCUS_RELATIVE:
2622 case V4L2_CID_FLASH:
2624 ext_ctrl->value = sensor->info_priv.flash;
2632 static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
2634 const struct v4l2_queryctrl *qctrl;
2635 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2636 struct sensor *sensor = to_sensor(client);
2639 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
2643 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
2648 switch (ext_ctrl->id)
2650 #if CONFIG_SENSOR_Scene
2651 case V4L2_CID_SCENE:
2653 if (ext_ctrl->value != sensor->info_priv.scene)
2655 if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)
2657 sensor->info_priv.scene = ext_ctrl->value;
2662 #if CONFIG_SENSOR_Effect
2663 case V4L2_CID_EFFECT:
2665 if (ext_ctrl->value != sensor->info_priv.effect)
2667 if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)
2669 sensor->info_priv.effect= ext_ctrl->value;
2674 #if CONFIG_SENSOR_DigitalZoom
2675 case V4L2_CID_ZOOM_ABSOLUTE:
2677 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
2680 if (ext_ctrl->value != sensor->info_priv.digitalzoom)
2682 val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;
2684 if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)
2686 sensor->info_priv.digitalzoom += val_offset;
2688 SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
2693 case V4L2_CID_ZOOM_RELATIVE:
2695 if (ext_ctrl->value)
2697 if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
2699 sensor->info_priv.digitalzoom += ext_ctrl->value;
2701 SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
2706 #if CONFIG_SENSOR_Focus
2707 case V4L2_CID_FOCUS_ABSOLUTE:
2709 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
2712 if (ext_ctrl->value != sensor->info_priv.focus)
2714 val_offset = ext_ctrl->value -sensor->info_priv.focus;
2716 sensor->info_priv.focus += val_offset;
2721 case V4L2_CID_FOCUS_RELATIVE:
2723 if (ext_ctrl->value)
2725 sensor->info_priv.focus += ext_ctrl->value;
2727 SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);
2732 #if CONFIG_SENSOR_Flash
2733 case V4L2_CID_FLASH:
2735 if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)
2737 sensor->info_priv.flash = ext_ctrl->value;
2739 SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
2750 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
2752 struct i2c_client *client = sd->priv;
2753 struct soc_camera_device *icd = client->dev.platform_data;
2754 int i, error_cnt=0, error_idx=-1;
2757 for (i=0; i<ext_ctrl->count; i++) {
2758 if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
2765 error_idx = ext_ctrl->count;
2767 if (error_idx != -1) {
2768 ext_ctrl->error_idx = error_idx;
2775 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
2777 struct i2c_client *client = sd->priv;
2778 struct soc_camera_device *icd = client->dev.platform_data;
2779 int i, error_cnt=0, error_idx=-1;
2782 for (i=0; i<ext_ctrl->count; i++) {
2783 if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
2790 error_idx = ext_ctrl->count;
2792 if (error_idx != -1) {
2793 ext_ctrl->error_idx = error_idx;
2800 /* Interface active, can use i2c. If it fails, it can indeed mean, that
2801 * this wasn't our capture interface, so, we wait for the right one */
2802 static int sensor_video_probe(struct soc_camera_device *icd,
2803 struct i2c_client *client)
2807 struct sensor *sensor = to_sensor(client);
2809 /* We must have a parent by now. And it cannot be a wrong one.
2810 * So this entire test is completely redundant. */
2811 if (!icd->dev.parent ||
2812 to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
2815 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
2817 goto sensor_video_probe_err;
2821 ret = sensor_write(client, 0x3012, 0x80);
2824 SENSOR_TR("soft reset %s failed\n",SENSOR_NAME_STRING());
2827 mdelay(5); //delay 5 microseconds
2829 /* check if it is an sensor sensor */
2830 ret = sensor_read(client, 0x300a, &value);
2832 SENSOR_TR("read chip id high byte failed\n");
2834 goto sensor_video_probe_err;
2837 pid |= (value << 8);
2839 ret = sensor_read(client, 0x300b, &value);
2841 SENSOR_TR("read chip id low byte failed\n");
2843 goto sensor_video_probe_err;
2846 pid |= (value & 0xff);
2847 SENSOR_DG("\n %s pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
2848 if (pid == SENSOR_ID) {
2849 sensor->model = SENSOR_V4L2_IDENT;
2851 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
2853 goto sensor_video_probe_err;
2856 icd->formats = sensor_colour_formats;
2857 icd->num_formats = ARRAY_SIZE(sensor_colour_formats);
2860 sensor_video_probe_err:
2863 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
2865 struct i2c_client *client = sd->priv;
2866 struct soc_camera_device *icd = client->dev.platform_data;
2867 struct sensor *sensor = to_sensor(client);
2870 SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
2873 case RK29_CAM_SUBDEV_DEACTIVATE:
2875 sensor_deactivate(client);
2879 case RK29_CAM_SUBDEV_IOREQUEST:
2881 sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
2882 if (sensor->sensor_io_request != NULL) {
2883 if (sensor->sensor_io_request->gpio_res[0].dev_name &&
2884 (strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
2885 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
2886 } else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
2887 (strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
2888 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
2891 SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
2893 goto sensor_ioctl_end;
2895 /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
2897 #if CONFIG_SENSOR_Flash
2898 if (sensor->sensor_gpio_res) {
2899 if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
2900 for (i = 0; i < icd->ops->num_controls; i++) {
2901 if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
2902 memset(&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));
2905 sensor->info_priv.flash = 0xff;
2906 SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
2914 SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
2923 static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
2924 .init = sensor_init,
2925 .g_ctrl = sensor_g_control,
2926 .s_ctrl = sensor_s_control,
2927 .g_ext_ctrls = sensor_g_ext_controls,
2928 .s_ext_ctrls = sensor_s_ext_controls,
2929 .g_chip_ident = sensor_g_chip_ident,
2930 .ioctl = sensor_ioctl,
2933 static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
2934 .s_fmt = sensor_s_fmt,
2935 .g_fmt = sensor_g_fmt,
2936 .try_fmt = sensor_try_fmt,
2939 static struct v4l2_subdev_ops sensor_subdev_ops = {
2940 .core = &sensor_subdev_core_ops,
2941 .video = &sensor_subdev_video_ops,
2944 static int sensor_probe(struct i2c_client *client,
2945 const struct i2c_device_id *did)
2947 struct sensor *sensor;
2948 struct soc_camera_device *icd = client->dev.platform_data;
2949 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
2950 struct soc_camera_link *icl;
2953 SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);
2955 dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());
2959 icl = to_soc_camera_link(icd);
2961 dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());
2965 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
2966 dev_warn(&adapter->dev,
2967 "I2C-Adapter doesn't support I2C_FUNC_I2C\n");
2971 sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);
2975 v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);
2977 /* Second stage probe - when a capture adapter is there */
2978 icd->ops = &sensor_ops;
2979 icd->y_skip_top = 0;
2980 #if CONFIG_SENSOR_I2C_NOSCHED
2981 atomic_set(&sensor->tasklock_cnt,0);
2984 ret = sensor_video_probe(icd, client);
2987 i2c_set_clientdata(client, NULL);
2990 SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
2994 static int sensor_remove(struct i2c_client *client)
2996 struct sensor *sensor = to_sensor(client);
2997 struct soc_camera_device *icd = client->dev.platform_data;
3000 i2c_set_clientdata(client, NULL);
3001 client->driver = NULL;
3007 static const struct i2c_device_id sensor_id[] = {
3008 {SENSOR_NAME_STRING(), 0 },
3011 MODULE_DEVICE_TABLE(i2c, sensor_id);
3013 static struct i2c_driver sensor_i2c_driver = {
3015 .name = SENSOR_NAME_STRING(),
3017 .probe = sensor_probe,
3018 .remove = sensor_remove,
3019 .id_table = sensor_id,
3022 static int __init sensor_mod_init(void)
3024 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
3025 return i2c_add_driver(&sensor_i2c_driver);
3028 static void __exit sensor_mod_exit(void)
3030 i2c_del_driver(&sensor_i2c_driver);
3033 device_initcall_sync(sensor_mod_init);
3034 module_exit(sensor_mod_exit);
3036 MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
3037 MODULE_AUTHOR("ddl <kernel@rock-chips>");
3038 MODULE_LICENSE("GPL");