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 0
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)
91 #define SENSOR_INIT_IS_ERR (0x00<<28)
92 #define SENSOR_INIT_IS_OK (0x01<<28)
100 /* init 352X288 SVGA */
101 static struct reginfo sensor_init_data[] =
115 {0x3090, 0x33},//0x3b},
192 {0x3088, 0x02},//{0x3088, 0x01},
193 {0x3089, 0x88},//{0x3089, 0x68},
194 {0x308A, 0x01},//{0x308a, 0x01},
195 {0x308B, 0xe0},//{0x308b, 0x20},
202 {0x331A, 0x28},//{0x331a, 0x16},
203 {0x331B, 0x1e},//{0x331b, 0x12},
266 {0x3350, 0x37},//0x33},
267 {0x3351, 0x27},//0x28},
278 {0x335c, 0x37},//0x34},
307 {0x307c, 0x13},//0x10},
325 {0x0, 0x0} //end flag
330 static struct reginfo sensor_uxga[] =
372 static struct reginfo sensor_sxga[] =
411 static struct reginfo sensor_xga[] =
416 static struct reginfo sensor_svga[] =
457 static struct reginfo sensor_vga[] =
498 static struct reginfo sensor_cif[] =
538 static struct reginfo sensor_qvga[] =
579 static struct reginfo sensor_qcif[] =
619 static struct reginfo ov2655_qqvga[] =
663 static struct reginfo ov2655_Sharpness_auto[] =
668 static struct reginfo ov2655_Sharpness1[] =
674 static struct reginfo ov2655_Sharpness2[][3] =
681 static struct reginfo ov2655_Sharpness3[] =
687 static struct reginfo ov2655_Sharpness4[]=
694 static struct reginfo ov2655_Sharpness5[] =
702 static struct reginfo sensor_ClrFmt_YUYV[]=
708 static struct reginfo sensor_ClrFmt_UYVY[]=
714 #if CONFIG_SENSOR_WhiteBalance
715 static struct reginfo sensor_WhiteB_Auto[]=
717 {0x3306, 0x00}, //AWB auto, bit[1]:0,auto
720 /* Cloudy Colour Temperature : 6500K - 8000K */
721 static struct reginfo sensor_WhiteB_Cloudy[]=
729 /* ClearDay Colour Temperature : 5000K - 6500K */
730 static struct reginfo sensor_WhiteB_ClearDay[]=
733 {0x3306, 0x02}, //AWB off
739 /* Office Colour Temperature : 3500K - 5000K */
740 static struct reginfo sensor_WhiteB_TungstenLamp1[]=
750 /* Home Colour Temperature : 2500K - 3500K */
751 static struct reginfo sensor_WhiteB_TungstenLamp2[]=
760 static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
761 sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
765 #if CONFIG_SENSOR_Brightness
766 static struct reginfo sensor_Brightness0[]=
769 {0x3301, 0xff},//bit[7]:1, enable SDE
776 static struct reginfo sensor_Brightness1[]=
779 {0x3301, 0xff},//bit[7]:1, enable SDE
786 static struct reginfo sensor_Brightness2[]=
789 {0x3301, 0xff},//bit[7]:1, enable SDE
796 static struct reginfo sensor_Brightness3[]=
799 {0x3301, 0xff},//bit[7]:1, enable SDE
806 static struct reginfo sensor_Brightness4[]=
809 {0x3301, 0xff},//bit[7]:1, enable SDE
816 static struct reginfo sensor_Brightness5[]=
819 {0x3301, 0xff},//bit[7]:1, enable SDE
820 {0x3391, 0x04}, //bit[2] enable
821 {0x3390, 0x41}, //bit[3] sign of brightness
825 static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
826 sensor_Brightness4, sensor_Brightness5,NULL,
831 #if CONFIG_SENSOR_Effect
832 static struct reginfo sensor_Effect_Normal[] =
838 static struct reginfo sensor_Effect_WandB[] =
844 static struct reginfo sensor_Effect_Sepia[] =
852 static struct reginfo sensor_Effect_Negative[] =
855 {0x3391, 0x40}, //bit[6] negative
858 static struct reginfo sensor_Effect_Bluish[] =
867 static struct reginfo sensor_Effect_Green[] =
875 static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
876 sensor_Effect_Bluish, sensor_Effect_Green,NULL,
879 #if CONFIG_SENSOR_Exposure
880 static struct reginfo sensor_Exposure0[]=
890 static struct reginfo sensor_Exposure1[]=
900 static struct reginfo sensor_Exposure2[]=
910 static struct reginfo sensor_Exposure3[]=
920 static struct reginfo sensor_Exposure4[]=
930 static struct reginfo sensor_Exposure5[]=
940 static struct reginfo sensor_Exposure6[]=
950 static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
951 sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
954 #if CONFIG_SENSOR_Saturation
955 static struct reginfo sensor_Saturation0[]=
957 {0x3301, 0xff},//bit[7]:1, enable SDE
964 static struct reginfo sensor_Saturation1[]=
966 {0x3301, 0xff},//bit[7]:1, enable SDE
973 static struct reginfo sensor_Saturation2[]=
975 {0x3301, 0xff},//bit[7]:1, enable SDE
976 {0x3391, 0x02}, //enable color saturation
981 static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
984 #if CONFIG_SENSOR_Contrast
985 static struct reginfo sensor_Contrast0[]=
988 {0x3301, 0xff},//bit[7]:1, enable SDE
996 static struct reginfo sensor_Contrast1[]=
999 {0x3301, 0xff},//bit[7]:1, enable SDE
1007 static struct reginfo sensor_Contrast2[]=
1010 {0x3301, 0xff},//bit[7]:1, enable SDE
1018 static struct reginfo sensor_Contrast3[]=
1021 {0x3301, 0xff},//bit[7]:1, enable SDE
1029 static struct reginfo sensor_Contrast4[]=
1032 {0x3301, 0xff},//bit[7]:1, enable SDE
1041 static struct reginfo sensor_Contrast5[]=
1044 {0x3301, 0xff},//bit[7]:1, enable SDE
1052 static struct reginfo sensor_Contrast6[]=
1055 {0x3301, 0xff},//bit[7]:1, enable SDE
1056 {0x3391, 0x04}, //bit[2] enable contrast/brightness
1057 {0x3390, 0x45}, //bit[2] Yoffset sign
1062 static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
1063 sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
1067 #if CONFIG_SENSOR_Mirror
1068 static struct reginfo sensor_MirrorOn[]=
1076 static struct reginfo sensor_MirrorOff[]=
1083 static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
1085 #if CONFIG_SENSOR_Flip
1086 static struct reginfo sensor_FlipOn[]=
1099 static struct reginfo sensor_FlipOff[]=
1111 static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
1114 #if CONFIG_SENSOR_Scene
1115 static struct reginfo sensor_SceneAuto[] =
1117 #if 0 /* ddl@rock-chips.com : */
1132 static struct reginfo sensor_SceneNight[] =
1135 //30fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,36Mzh pclk
1146 {0x3015, 0x50},//add 5 dummy frame
1151 //15fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,18Mhz pclk
1167 static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
1170 #if CONFIG_SENSOR_DigitalZoom
1171 static struct reginfo sensor_Zoom0[] =
1176 static struct reginfo sensor_Zoom1[] =
1181 static struct reginfo sensor_Zoom2[] =
1187 static struct reginfo sensor_Zoom3[] =
1191 static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};
1193 static const struct v4l2_querymenu sensor_menus[] =
1195 #if CONFIG_SENSOR_WhiteBalance
1196 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 0, .name = "auto", .reserved = 0, }, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 1, .name = "incandescent", .reserved = 0,},
1197 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
1198 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
1201 #if CONFIG_SENSOR_Effect
1202 { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "mono", .reserved = 0,},
1203 { .id = V4L2_CID_EFFECT, .index = 2, .name = "negative", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "sepia", .reserved = 0,},
1204 { .id = V4L2_CID_EFFECT, .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT, .index = 5, .name = "aqua", .reserved = 0,},
1207 #if CONFIG_SENSOR_Scene
1208 { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
1211 #if CONFIG_SENSOR_Flash
1212 { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
1213 { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
1217 static const struct v4l2_queryctrl sensor_controls[] =
1219 #if CONFIG_SENSOR_WhiteBalance
1221 .id = V4L2_CID_DO_WHITE_BALANCE,
1222 .type = V4L2_CTRL_TYPE_MENU,
1223 .name = "White Balance Control",
1231 #if CONFIG_SENSOR_Brightness
1233 .id = V4L2_CID_BRIGHTNESS,
1234 .type = V4L2_CTRL_TYPE_INTEGER,
1235 .name = "Brightness Control",
1243 #if CONFIG_SENSOR_Effect
1245 .id = V4L2_CID_EFFECT,
1246 .type = V4L2_CTRL_TYPE_MENU,
1247 .name = "Effect Control",
1255 #if CONFIG_SENSOR_Exposure
1257 .id = V4L2_CID_EXPOSURE,
1258 .type = V4L2_CTRL_TYPE_INTEGER,
1259 .name = "Exposure Control",
1267 #if CONFIG_SENSOR_Saturation
1269 .id = V4L2_CID_SATURATION,
1270 .type = V4L2_CTRL_TYPE_INTEGER,
1271 .name = "Saturation Control",
1279 #if CONFIG_SENSOR_Contrast
1281 .id = V4L2_CID_CONTRAST,
1282 .type = V4L2_CTRL_TYPE_INTEGER,
1283 .name = "Contrast Control",
1291 #if CONFIG_SENSOR_Mirror
1293 .id = V4L2_CID_HFLIP,
1294 .type = V4L2_CTRL_TYPE_BOOLEAN,
1295 .name = "Mirror Control",
1303 #if CONFIG_SENSOR_Flip
1305 .id = V4L2_CID_VFLIP,
1306 .type = V4L2_CTRL_TYPE_BOOLEAN,
1307 .name = "Flip Control",
1315 #if CONFIG_SENSOR_Scene
1317 .id = V4L2_CID_SCENE,
1318 .type = V4L2_CTRL_TYPE_MENU,
1319 .name = "Scene Control",
1327 #if CONFIG_SENSOR_DigitalZoom
1329 .id = V4L2_CID_ZOOM_RELATIVE,
1330 .type = V4L2_CTRL_TYPE_INTEGER,
1331 .name = "DigitalZoom Control",
1337 .id = V4L2_CID_ZOOM_ABSOLUTE,
1338 .type = V4L2_CTRL_TYPE_INTEGER,
1339 .name = "DigitalZoom Control",
1347 #if CONFIG_SENSOR_Focus
1349 .id = V4L2_CID_FOCUS_RELATIVE,
1350 .type = V4L2_CTRL_TYPE_INTEGER,
1351 .name = "Focus Control",
1357 .id = V4L2_CID_FOCUS_ABSOLUTE,
1358 .type = V4L2_CTRL_TYPE_INTEGER,
1359 .name = "Focus Control",
1363 .default_value = 125,
1367 #if CONFIG_SENSOR_Flash
1369 .id = V4L2_CID_FLASH,
1370 .type = V4L2_CTRL_TYPE_MENU,
1371 .name = "Flash Control",
1380 static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);
1381 static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
1382 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1383 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1384 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1385 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1386 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
1387 static int sensor_resume(struct soc_camera_device *icd);
1388 static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
1389 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
1390 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1391 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1392 static int sensor_deactivate(struct i2c_client *client);
1394 static struct soc_camera_ops sensor_ops =
1396 .suspend = sensor_suspend,
1397 .resume = sensor_resume,
1398 .set_bus_param = sensor_set_bus_param,
1399 .query_bus_param = sensor_query_bus_param,
1400 .controls = sensor_controls,
1401 .menus = sensor_menus,
1402 .num_controls = ARRAY_SIZE(sensor_controls),
1403 .num_menus = ARRAY_SIZE(sensor_menus),
1406 #define COL_FMT(_name, _depth, _fourcc, _colorspace) \
1407 { .name = _name, .depth = _depth, .fourcc = _fourcc, \
1408 .colorspace = _colorspace }
1410 #define JPG_FMT(_name, _depth, _fourcc) \
1411 COL_FMT(_name, _depth, _fourcc, V4L2_COLORSPACE_JPEG)
1413 static const struct soc_camera_data_format sensor_colour_formats[] = {
1414 JPG_FMT(SENSOR_NAME_STRING(UYVY), 16, V4L2_PIX_FMT_UYVY),
1415 JPG_FMT(SENSOR_NAME_STRING(YUYV), 16, V4L2_PIX_FMT_YUYV),
1418 typedef struct sensor_info_priv_s
1432 unsigned char mirror; /* HFLIP */
1433 unsigned char flip; /* VFLIP */
1434 unsigned int winseqe_cur_addr;
1435 unsigned int pixfmt;
1436 unsigned int funmodule_state;
1437 } sensor_info_priv_t;
1441 struct v4l2_subdev subdev;
1442 struct i2c_client *client;
1443 sensor_info_priv_t info_priv;
1444 int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
1445 #if CONFIG_SENSOR_I2C_NOSCHED
1446 atomic_t tasklock_cnt;
1448 struct rk29camera_platform_data *sensor_io_request;
1449 struct rk29camera_gpio_res *sensor_gpio_res;
1452 static struct sensor* to_sensor(const struct i2c_client *client)
1454 return container_of(i2c_get_clientdata(client), struct sensor, subdev);
1457 static int sensor_task_lock(struct i2c_client *client, int lock)
1459 #if CONFIG_SENSOR_I2C_NOSCHED
1461 struct sensor *sensor = to_sensor(client);
1464 if (atomic_read(&sensor->tasklock_cnt) == 0) {
1465 while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {
1466 SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());
1470 if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {
1471 SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());
1472 goto sensor_task_lock_err;
1477 atomic_add(1, &sensor->tasklock_cnt);
1479 if (atomic_read(&sensor->tasklock_cnt) > 0) {
1480 atomic_sub(1, &sensor->tasklock_cnt);
1482 if (atomic_read(&sensor->tasklock_cnt) == 0)
1487 sensor_task_lock_err:
1495 /* sensor register write */
1496 static int sensor_write(struct i2c_client *client, u16 reg, u8 val)
1500 struct i2c_msg msg[1];
1503 buf[1] = reg & 0xFF;
1506 msg->addr = client->addr;
1507 msg->flags = client->flags;
1509 msg->len = sizeof(buf);
1510 msg->scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1511 msg->read_type = 0; /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
1516 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
1517 err = i2c_transfer(client->adapter, msg, 1);
1522 SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg, val);
1530 /* sensor register read */
1531 static int sensor_read(struct i2c_client *client, u16 reg, u8 *val)
1535 struct i2c_msg msg[2];
1538 buf[1] = reg & 0xFF;
1540 msg[0].addr = client->addr;
1541 msg[0].flags = client->flags;
1543 msg[0].len = sizeof(buf);
1544 msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1545 msg[0].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
1547 msg[1].addr = client->addr;
1548 msg[1].flags = client->flags|I2C_M_RD;
1551 msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1552 msg[1].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
1556 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
1557 err = i2c_transfer(client->adapter, msg, 2);
1563 SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);
1571 /* write a array of registers */
1572 static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
1576 #if CONFIG_SENSOR_I2C_RDWRCHK
1581 if (sensor_task_lock(client, 1) < 0)
1582 goto sensor_write_array_end;
1583 while (regarray[i].reg != 0)
1585 err = sensor_write(client, regarray[i].reg, regarray[i].val);
1589 SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
1593 SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
1595 goto sensor_write_array_end;
1598 #if CONFIG_SENSOR_I2C_RDWRCHK
1599 sensor_read(client, regarray[i].reg, &valchk);
1600 if (valchk != regarray[i].val)
1601 SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
1607 sensor_write_array_end:
1608 sensor_task_lock(client,0);
1611 #if CONFIG_SENSOR_I2C_RDWRCHK
1612 static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)
1620 while (regarray[i].reg != 0)
1622 sensor_read(client, regarray[i].reg, &valchk);
1623 if (valchk != regarray[i].val)
1624 SENSOR_TR("%s Reg:0x%x read(0x%x, 0x%x) error\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
1631 static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)
1633 struct soc_camera_link *icl = to_soc_camera_link(icd);
1636 SENSOR_DG("%s %s cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);
1640 case Sensor_PowerDown:
1642 if (icl->powerdown) {
1643 ret = icl->powerdown(icd->pdev, on);
1644 if (ret == RK29_CAM_IO_SUCCESS) {
1648 icl->reset(icd->pdev);
1650 } else if (ret == RK29_CAM_EIO_REQUESTFAIL) {
1652 goto sensor_power_end;
1659 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1660 struct sensor *sensor = to_sensor(client);
1662 if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
1663 sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
1669 SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
1676 static int sensor_init(struct v4l2_subdev *sd, u32 val)
1678 struct i2c_client *client = sd->priv;
1679 struct soc_camera_device *icd = client->dev.platform_data;
1680 struct sensor *sensor = to_sensor(client);
1681 const struct v4l2_queryctrl *qctrl;
1685 SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
1687 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
1689 goto sensor_INIT_ERR;
1693 if (sensor_task_lock(client,1)<0)
1694 goto sensor_INIT_ERR;
1695 ret = sensor_write(client, 0x3012, 0x80);
1698 SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
1700 goto sensor_INIT_ERR;
1703 mdelay(5); //delay 5 microseconds
1704 /* check if it is an sensor sensor */
1705 ret = sensor_read(client, 0x300a, &value);
1707 SENSOR_TR("read chip id high byte failed\n");
1709 goto sensor_INIT_ERR;
1712 pid |= (value << 8);
1714 ret = sensor_read(client, 0x300b, &value);
1716 SENSOR_TR("read chip id low byte failed\n");
1718 goto sensor_INIT_ERR;
1721 pid |= (value & 0xff);
1722 SENSOR_DG("\n %s pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
1723 if (pid == SENSOR_ID) {
1724 sensor->model = SENSOR_V4L2_IDENT;
1726 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
1728 goto sensor_INIT_ERR;
1731 ret = sensor_write_array(client, sensor_init_data);
1734 SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
1735 goto sensor_INIT_ERR;
1737 sensor_task_lock(client,0);
1738 //icd->user_width = SENSOR_INIT_WIDTH;
1739 //icd->user_height = SENSOR_INIT_HEIGHT;
1740 sensor->info_priv.winseqe_cur_addr = (int)SENSOR_INIT_WINSEQADR;
1741 sensor->info_priv.pixfmt = SENSOR_INIT_PIXFMT;
1743 /* sensor sensor information for initialization */
1744 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1746 sensor->info_priv.whiteBalance = qctrl->default_value;
1747 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);
1749 sensor->info_priv.brightness = qctrl->default_value;
1750 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1752 sensor->info_priv.effect = qctrl->default_value;
1753 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);
1755 sensor->info_priv.exposure = qctrl->default_value;
1757 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);
1759 sensor->info_priv.saturation = qctrl->default_value;
1760 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);
1762 sensor->info_priv.contrast = qctrl->default_value;
1763 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);
1765 sensor->info_priv.mirror = qctrl->default_value;
1766 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);
1768 sensor->info_priv.flip = qctrl->default_value;
1769 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);
1771 sensor->info_priv.scene = qctrl->default_value;
1772 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
1774 sensor->info_priv.digitalzoom = qctrl->default_value;
1776 /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
1777 #if CONFIG_SENSOR_Focus
1779 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
1781 sensor->info_priv.focus = qctrl->default_value;
1784 #if CONFIG_SENSOR_Flash
1785 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
1787 sensor->info_priv.flash = qctrl->default_value;
1790 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);
1791 sensor->info_priv.funmodule_state |= SENSOR_INIT_IS_OK;
1794 sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
1795 sensor_task_lock(client,0);
1796 sensor_deactivate(client);
1800 static int sensor_deactivate(struct i2c_client *client)
1802 struct soc_camera_device *icd = client->dev.platform_data;
1804 struct sensor *sensor = to_sensor(client);
1805 SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);
1807 /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
1808 if (sensor->info_priv.funmodule_state & SENSOR_INIT_IS_OK) {
1809 sensor_task_lock(client, 1);
1810 sensor_write(client, 0x30b0, 0x00);
1811 sensor_write(client, 0x30b1, 0x00);
1812 sensor_task_lock(client, 0);
1814 sensor_ioctrl(icd, Sensor_PowerDown, 1);
1817 /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */
1818 icd->user_width = SENSOR_INIT_WIDTH;
1819 icd->user_height = SENSOR_INIT_HEIGHT;
1820 sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
1825 static struct reginfo sensor_power_down_sequence[]=
1833 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
1836 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1838 if (pm_msg.event == PM_EVENT_SUSPEND) {
1839 SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());
1840 ret = sensor_write_array(client, sensor_power_down_sequence) ;
1842 SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
1845 ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);
1847 SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());
1852 SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
1858 static int sensor_resume(struct soc_camera_device *icd)
1862 ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);
1864 SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());
1868 SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());
1874 static int sensor_set_bus_param(struct soc_camera_device *icd,
1875 unsigned long flags)
1881 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
1883 struct soc_camera_link *icl = to_soc_camera_link(icd);
1884 unsigned long flags = SENSOR_BUS_PARAM;
1886 return soc_camera_apply_sensor_flags(icl, flags);
1889 static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
1891 struct i2c_client *client = sd->priv;
1892 struct soc_camera_device *icd = client->dev.platform_data;
1893 struct sensor *sensor = to_sensor(client);
1894 struct v4l2_pix_format *pix = &f->fmt.pix;
1896 pix->width = icd->user_width;
1897 pix->height = icd->user_height;
1898 pix->pixelformat = sensor->info_priv.pixfmt;
1899 pix->field = V4L2_FIELD_NONE;
1900 pix->colorspace = V4L2_COLORSPACE_JPEG;
1904 static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_format *f)
1908 if ((f->fmt.pix.width == 1024) && (f->fmt.pix.height == 768)) {
1910 } else if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 1024)) {
1912 } else if ((f->fmt.pix.width == 1600) && (f->fmt.pix.height == 1200)) {
1914 } else if ((f->fmt.pix.width == 2048) && (f->fmt.pix.height == 1536)) {
1916 } else if ((f->fmt.pix.width == 2592) && (f->fmt.pix.height == 1944)) {
1921 SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height);
1925 static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_format *f)
1929 if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 720)) {
1931 } else if ((f->fmt.pix.width == 1920) && (f->fmt.pix.height == 1080)) {
1936 SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height);
1939 static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
1941 struct i2c_client *client = sd->priv;
1942 struct sensor *sensor = to_sensor(client);
1943 struct v4l2_pix_format *pix = &f->fmt.pix;
1944 const struct v4l2_queryctrl *qctrl;
1945 struct soc_camera_device *icd = client->dev.platform_data;
1946 struct reginfo *winseqe_set_addr=NULL;
1947 int ret=0, set_w,set_h;
1949 if (sensor->info_priv.pixfmt != pix->pixelformat) {
1950 switch (pix->pixelformat)
1952 case V4L2_PIX_FMT_YUYV:
1954 winseqe_set_addr = sensor_ClrFmt_YUYV;
1957 case V4L2_PIX_FMT_UYVY:
1959 winseqe_set_addr = sensor_ClrFmt_UYVY;
1965 if (winseqe_set_addr != NULL) {
1966 sensor_write_array(client, winseqe_set_addr);
1967 sensor->info_priv.pixfmt = pix->pixelformat;
1969 SENSOR_DG("%s Pixelformat(0x%x) set success!\n", SENSOR_NAME_STRING(),pix->pixelformat);
1971 SENSOR_TR("%s Pixelformat(0x%x) is invalidate!\n", SENSOR_NAME_STRING(),pix->pixelformat);
1976 set_h = pix->height;
1978 if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
1980 winseqe_set_addr = sensor_qcif;
1984 else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
1986 winseqe_set_addr = sensor_qvga;
1990 else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
1992 winseqe_set_addr = sensor_cif;
1996 else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
1998 winseqe_set_addr = sensor_vga;
2002 else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
2004 winseqe_set_addr = sensor_svga;
2008 else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
2010 winseqe_set_addr = sensor_xga;
2014 else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
2016 winseqe_set_addr = sensor_sxga;
2020 else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
2022 winseqe_set_addr = sensor_uxga;
2028 winseqe_set_addr = SENSOR_INIT_WINSEQADR; /* ddl@rock-chips.com : Sensor output smallest size if isn't support app */
2029 set_w = SENSOR_INIT_WIDTH;
2030 set_h = SENSOR_INIT_HEIGHT;
2031 SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,pix->width,pix->height);
2034 if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr) {
2035 #if CONFIG_SENSOR_Flash
2036 if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */
2037 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
2038 sensor_ioctrl(icd, Sensor_Flash, Flash_On);
2039 SENSOR_DG("%s flash on in capture!\n", SENSOR_NAME_STRING());
2041 } else { /* ddl@rock-chips.com : Video */
2042 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
2043 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2044 SENSOR_DG("%s flash off in preivew!\n", SENSOR_NAME_STRING());
2048 ret |= sensor_write_array(client, winseqe_set_addr);
2050 SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
2051 #if CONFIG_SENSOR_Flash
2052 if (sensor_fmt_capturechk(sd,f) == true) {
2053 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
2054 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2055 SENSOR_TR("%s Capture format set fail, flash off !\n", SENSOR_NAME_STRING());
2059 goto sensor_s_fmt_end;
2062 sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
2064 if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */
2065 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
2066 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
2067 if (sensor->info_priv.whiteBalance != 0) {
2068 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
2069 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
2071 sensor->info_priv.snap2preview = true;
2072 } else if (sensor_fmt_videochk(sd,f) == true) { /* ddl@rock-chips.com : Video */
2073 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
2074 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
2075 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
2076 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
2077 sensor->info_priv.video2preview = true;
2078 } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) {
2079 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
2080 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
2081 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
2082 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
2084 sensor->info_priv.video2preview = false;
2085 sensor->info_priv.snap2preview = false;
2087 SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
2091 SENSOR_DG("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);
2095 pix->height = set_h;
2101 static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
2103 struct v4l2_pix_format *pix = &f->fmt.pix;
2104 bool bayer = pix->pixelformat == V4L2_PIX_FMT_UYVY ||
2105 pix->pixelformat == V4L2_PIX_FMT_YUYV;
2108 * With Bayer format enforce even side lengths, but let the user play
2109 * with the starting pixel
2112 if (pix->height > SENSOR_MAX_HEIGHT)
2113 pix->height = SENSOR_MAX_HEIGHT;
2114 else if (pix->height < SENSOR_MIN_HEIGHT)
2115 pix->height = SENSOR_MIN_HEIGHT;
2117 pix->height = ALIGN(pix->height, 2);
2119 if (pix->width > SENSOR_MAX_WIDTH)
2120 pix->width = SENSOR_MAX_WIDTH;
2121 else if (pix->width < SENSOR_MIN_WIDTH)
2122 pix->width = SENSOR_MIN_WIDTH;
2124 pix->width = ALIGN(pix->width, 2);
2129 static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
2131 struct i2c_client *client = sd->priv;
2133 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
2136 if (id->match.addr != client->addr)
2139 id->ident = SENSOR_V4L2_IDENT; /* ddl@rock-chips.com : Return OV2655 identifier */
2144 #if CONFIG_SENSOR_Brightness
2145 static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2147 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2149 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2151 if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)
2153 if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)
2155 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2158 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2162 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2166 #if CONFIG_SENSOR_Effect
2167 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2169 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2171 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2173 if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)
2175 if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)
2177 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2180 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2184 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2188 #if CONFIG_SENSOR_Exposure
2189 static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2191 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2193 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2195 if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)
2197 if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)
2199 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2202 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2206 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2210 #if CONFIG_SENSOR_Saturation
2211 static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2213 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2215 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2217 if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)
2219 if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)
2221 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2224 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2228 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2232 #if CONFIG_SENSOR_Contrast
2233 static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2235 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2237 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2239 if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)
2241 if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)
2243 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2246 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2250 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2254 #if CONFIG_SENSOR_Mirror
2255 static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2257 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2259 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2261 if (sensor_MirrorSeqe[value - qctrl->minimum] != NULL)
2263 if (sensor_write_array(client, sensor_MirrorSeqe[value - qctrl->minimum]) != 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);
2272 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2276 #if CONFIG_SENSOR_Flip
2277 static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2279 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2281 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2283 if (sensor_FlipSeqe[value - qctrl->minimum] != NULL)
2285 if (sensor_write_array(client, sensor_FlipSeqe[value - qctrl->minimum]) != 0)
2287 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2290 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2294 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2298 #if CONFIG_SENSOR_Scene
2299 static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2301 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2303 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2305 if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)
2307 if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)
2309 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2312 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2316 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2320 #if CONFIG_SENSOR_WhiteBalance
2321 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2323 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2325 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2327 if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
2329 if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
2331 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2334 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2338 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2342 #if CONFIG_SENSOR_DigitalZoom
2343 static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)
2345 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2346 struct sensor *sensor = to_sensor(client);
2347 const struct v4l2_queryctrl *qctrl_info;
2348 int digitalzoom_cur, digitalzoom_total;
2350 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
2354 digitalzoom_cur = sensor->info_priv.digitalzoom;
2355 digitalzoom_total = qctrl_info->maximum;
2357 if ((*value > 0) && (digitalzoom_cur >= digitalzoom_total))
2359 SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2363 if ((*value < 0) && (digitalzoom_cur <= qctrl_info->minimum))
2365 SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2369 if ((*value > 0) && ((digitalzoom_cur + *value) > digitalzoom_total))
2371 *value = digitalzoom_total - digitalzoom_cur;
2374 if ((*value < 0) && ((digitalzoom_cur + *value) < 0))
2376 *value = 0 - digitalzoom_cur;
2379 digitalzoom_cur += *value;
2381 if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)
2383 if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)
2385 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2388 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, *value);
2395 #if CONFIG_SENSOR_Flash
2396 static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2398 if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {
2399 if (value == 3) { /* ddl@rock-chips.com: torch */
2400 sensor_ioctrl(icd, Sensor_Flash, Flash_Torch); /* Flash On */
2402 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2404 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2408 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2413 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2415 struct i2c_client *client = sd->priv;
2416 struct sensor *sensor = to_sensor(client);
2417 const struct v4l2_queryctrl *qctrl;
2419 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2423 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2429 case V4L2_CID_BRIGHTNESS:
2431 ctrl->value = sensor->info_priv.brightness;
2434 case V4L2_CID_SATURATION:
2436 ctrl->value = sensor->info_priv.saturation;
2439 case V4L2_CID_CONTRAST:
2441 ctrl->value = sensor->info_priv.contrast;
2444 case V4L2_CID_DO_WHITE_BALANCE:
2446 ctrl->value = sensor->info_priv.whiteBalance;
2449 case V4L2_CID_EXPOSURE:
2451 ctrl->value = sensor->info_priv.exposure;
2454 case V4L2_CID_HFLIP:
2456 ctrl->value = sensor->info_priv.mirror;
2459 case V4L2_CID_VFLIP:
2461 ctrl->value = sensor->info_priv.flip;
2472 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2474 struct i2c_client *client = sd->priv;
2475 struct sensor *sensor = to_sensor(client);
2476 struct soc_camera_device *icd = client->dev.platform_data;
2477 const struct v4l2_queryctrl *qctrl;
2480 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2484 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2490 #if CONFIG_SENSOR_Brightness
2491 case V4L2_CID_BRIGHTNESS:
2493 if (ctrl->value != sensor->info_priv.brightness)
2495 if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)
2499 sensor->info_priv.brightness = ctrl->value;
2504 #if CONFIG_SENSOR_Exposure
2505 case V4L2_CID_EXPOSURE:
2507 if (ctrl->value != sensor->info_priv.exposure)
2509 if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)
2513 sensor->info_priv.exposure = ctrl->value;
2518 #if CONFIG_SENSOR_Saturation
2519 case V4L2_CID_SATURATION:
2521 if (ctrl->value != sensor->info_priv.saturation)
2523 if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)
2527 sensor->info_priv.saturation = ctrl->value;
2532 #if CONFIG_SENSOR_Contrast
2533 case V4L2_CID_CONTRAST:
2535 if (ctrl->value != sensor->info_priv.contrast)
2537 if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)
2541 sensor->info_priv.contrast = ctrl->value;
2546 #if CONFIG_SENSOR_WhiteBalance
2547 case V4L2_CID_DO_WHITE_BALANCE:
2549 if (ctrl->value != sensor->info_priv.whiteBalance)
2551 if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
2555 sensor->info_priv.whiteBalance = ctrl->value;
2560 #if CONFIG_SENSOR_Mirror
2561 case V4L2_CID_HFLIP:
2563 if (ctrl->value != sensor->info_priv.mirror)
2565 if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)
2567 sensor->info_priv.mirror = ctrl->value;
2572 #if CONFIG_SENSOR_Flip
2573 case V4L2_CID_VFLIP:
2575 if (ctrl->value != sensor->info_priv.flip)
2577 if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)
2579 sensor->info_priv.flip = ctrl->value;
2590 static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
2592 const struct v4l2_queryctrl *qctrl;
2593 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2594 struct sensor *sensor = to_sensor(client);
2596 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
2600 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
2604 switch (ext_ctrl->id)
2606 case V4L2_CID_SCENE:
2608 ext_ctrl->value = sensor->info_priv.scene;
2611 case V4L2_CID_EFFECT:
2613 ext_ctrl->value = sensor->info_priv.effect;
2616 case V4L2_CID_ZOOM_ABSOLUTE:
2618 ext_ctrl->value = sensor->info_priv.digitalzoom;
2621 case V4L2_CID_ZOOM_RELATIVE:
2625 case V4L2_CID_FOCUS_ABSOLUTE:
2627 ext_ctrl->value = sensor->info_priv.focus;
2630 case V4L2_CID_FOCUS_RELATIVE:
2634 case V4L2_CID_FLASH:
2636 ext_ctrl->value = sensor->info_priv.flash;
2644 static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
2646 const struct v4l2_queryctrl *qctrl;
2647 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2648 struct sensor *sensor = to_sensor(client);
2651 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
2655 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
2660 switch (ext_ctrl->id)
2662 #if CONFIG_SENSOR_Scene
2663 case V4L2_CID_SCENE:
2665 if (ext_ctrl->value != sensor->info_priv.scene)
2667 if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)
2669 sensor->info_priv.scene = ext_ctrl->value;
2674 #if CONFIG_SENSOR_Effect
2675 case V4L2_CID_EFFECT:
2677 if (ext_ctrl->value != sensor->info_priv.effect)
2679 if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)
2681 sensor->info_priv.effect= ext_ctrl->value;
2686 #if CONFIG_SENSOR_DigitalZoom
2687 case V4L2_CID_ZOOM_ABSOLUTE:
2689 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
2692 if (ext_ctrl->value != sensor->info_priv.digitalzoom)
2694 val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;
2696 if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)
2698 sensor->info_priv.digitalzoom += val_offset;
2700 SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
2705 case V4L2_CID_ZOOM_RELATIVE:
2707 if (ext_ctrl->value)
2709 if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
2711 sensor->info_priv.digitalzoom += ext_ctrl->value;
2713 SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
2718 #if CONFIG_SENSOR_Focus
2719 case V4L2_CID_FOCUS_ABSOLUTE:
2721 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
2724 if (ext_ctrl->value != sensor->info_priv.focus)
2726 val_offset = ext_ctrl->value -sensor->info_priv.focus;
2728 sensor->info_priv.focus += val_offset;
2733 case V4L2_CID_FOCUS_RELATIVE:
2735 if (ext_ctrl->value)
2737 sensor->info_priv.focus += ext_ctrl->value;
2739 SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);
2744 #if CONFIG_SENSOR_Flash
2745 case V4L2_CID_FLASH:
2747 if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)
2749 sensor->info_priv.flash = ext_ctrl->value;
2751 SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
2762 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
2764 struct i2c_client *client = sd->priv;
2765 struct soc_camera_device *icd = client->dev.platform_data;
2766 int i, error_cnt=0, error_idx=-1;
2769 for (i=0; i<ext_ctrl->count; i++) {
2770 if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
2777 error_idx = ext_ctrl->count;
2779 if (error_idx != -1) {
2780 ext_ctrl->error_idx = error_idx;
2787 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
2789 struct i2c_client *client = sd->priv;
2790 struct soc_camera_device *icd = client->dev.platform_data;
2791 int i, error_cnt=0, error_idx=-1;
2794 for (i=0; i<ext_ctrl->count; i++) {
2795 if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
2802 error_idx = ext_ctrl->count;
2804 if (error_idx != -1) {
2805 ext_ctrl->error_idx = error_idx;
2812 /* Interface active, can use i2c. If it fails, it can indeed mean, that
2813 * this wasn't our capture interface, so, we wait for the right one */
2814 static int sensor_video_probe(struct soc_camera_device *icd,
2815 struct i2c_client *client)
2819 struct sensor *sensor = to_sensor(client);
2821 /* We must have a parent by now. And it cannot be a wrong one.
2822 * So this entire test is completely redundant. */
2823 if (!icd->dev.parent ||
2824 to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
2827 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
2829 goto sensor_video_probe_err;
2833 ret = sensor_write(client, 0x3012, 0x80);
2836 SENSOR_TR("soft reset %s failed\n",SENSOR_NAME_STRING());
2838 goto sensor_video_probe_err;
2840 mdelay(5); //delay 5 microseconds
2842 /* check if it is an sensor sensor */
2843 ret = sensor_read(client, 0x300a, &value);
2845 SENSOR_TR("read chip id high byte failed\n");
2847 goto sensor_video_probe_err;
2850 pid |= (value << 8);
2852 ret = sensor_read(client, 0x300b, &value);
2854 SENSOR_TR("read chip id low byte failed\n");
2856 goto sensor_video_probe_err;
2859 pid |= (value & 0xff);
2860 SENSOR_DG("\n %s pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
2861 if (pid == SENSOR_ID) {
2862 sensor->model = SENSOR_V4L2_IDENT;
2864 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
2866 goto sensor_video_probe_err;
2869 icd->formats = sensor_colour_formats;
2870 icd->num_formats = ARRAY_SIZE(sensor_colour_formats);
2873 sensor_video_probe_err:
2876 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
2878 struct i2c_client *client = sd->priv;
2879 struct soc_camera_device *icd = client->dev.platform_data;
2880 struct sensor *sensor = to_sensor(client);
2883 SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
2886 case RK29_CAM_SUBDEV_DEACTIVATE:
2888 sensor_deactivate(client);
2892 case RK29_CAM_SUBDEV_IOREQUEST:
2894 sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
2895 if (sensor->sensor_io_request != NULL) {
2896 if (sensor->sensor_io_request->gpio_res[0].dev_name &&
2897 (strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
2898 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
2899 } else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
2900 (strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
2901 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
2904 SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
2906 goto sensor_ioctl_end;
2908 /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
2910 #if CONFIG_SENSOR_Flash
2911 if (sensor->sensor_gpio_res) {
2912 if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
2913 for (i = 0; i < icd->ops->num_controls; i++) {
2914 if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
2915 memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));
2918 sensor->info_priv.flash = 0xff;
2919 SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
2927 SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
2936 static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
2937 .init = sensor_init,
2938 .g_ctrl = sensor_g_control,
2939 .s_ctrl = sensor_s_control,
2940 .g_ext_ctrls = sensor_g_ext_controls,
2941 .s_ext_ctrls = sensor_s_ext_controls,
2942 .g_chip_ident = sensor_g_chip_ident,
2943 .ioctl = sensor_ioctl,
2946 static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
2947 .s_fmt = sensor_s_fmt,
2948 .g_fmt = sensor_g_fmt,
2949 .try_fmt = sensor_try_fmt,
2952 static struct v4l2_subdev_ops sensor_subdev_ops = {
2953 .core = &sensor_subdev_core_ops,
2954 .video = &sensor_subdev_video_ops,
2957 static int sensor_probe(struct i2c_client *client,
2958 const struct i2c_device_id *did)
2960 struct sensor *sensor;
2961 struct soc_camera_device *icd = client->dev.platform_data;
2962 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
2963 struct soc_camera_link *icl;
2966 SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);
2968 dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());
2972 icl = to_soc_camera_link(icd);
2974 dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());
2978 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
2979 dev_warn(&adapter->dev,
2980 "I2C-Adapter doesn't support I2C_FUNC_I2C\n");
2984 sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);
2988 v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);
2990 /* Second stage probe - when a capture adapter is there */
2991 icd->ops = &sensor_ops;
2992 icd->y_skip_top = 0;
2993 #if CONFIG_SENSOR_I2C_NOSCHED
2994 atomic_set(&sensor->tasklock_cnt,0);
2997 ret = sensor_video_probe(icd, client);
3000 i2c_set_clientdata(client, NULL);
3004 SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
3008 static int sensor_remove(struct i2c_client *client)
3010 struct sensor *sensor = to_sensor(client);
3011 struct soc_camera_device *icd = client->dev.platform_data;
3014 i2c_set_clientdata(client, NULL);
3015 client->driver = NULL;
3021 static const struct i2c_device_id sensor_id[] = {
3022 {SENSOR_NAME_STRING(), 0 },
3025 MODULE_DEVICE_TABLE(i2c, sensor_id);
3027 static struct i2c_driver sensor_i2c_driver = {
3029 .name = SENSOR_NAME_STRING(),
3031 .probe = sensor_probe,
3032 .remove = sensor_remove,
3033 .id_table = sensor_id,
3036 static int __init sensor_mod_init(void)
3038 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
3039 return i2c_add_driver(&sensor_i2c_driver);
3042 static void __exit sensor_mod_exit(void)
3044 i2c_del_driver(&sensor_i2c_driver);
3047 device_initcall_sync(sensor_mod_init);
3048 module_exit(sensor_mod_exit);
3050 MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
3051 MODULE_AUTHOR("ddl <kernel@rock-chips>");
3052 MODULE_LICENSE("GPL");