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 <plat/rk_camera.h>
25 module_param(debug, int, S_IRUGO|S_IWUSR);
27 #define dprintk(level, fmt, arg...) do { \
29 printk(KERN_WARNING fmt , ## arg); } while (0)
31 #define SENSOR_TR(format, ...) printk(KERN_ERR format, ## __VA_ARGS__)
32 #define SENSOR_DG(format, ...) dprintk(1, format, ## __VA_ARGS__)
35 #define _CONS(a,b) a##b
36 #define CONS(a,b) _CONS(a,b)
39 #define _STR(x) __STR(x)
40 #define STR(x) _STR(x)
42 #define MIN(x,y) ((x<y) ? x: y)
43 #define MAX(x,y) ((x>y) ? x: y)
45 /* Sensor Driver Configuration */
46 #define SENSOR_NAME RK29_CAM_SENSOR_HI253
47 #define SENSOR_V4L2_IDENT V4L2_IDENT_HI253
48 #define SENSOR_ID 0x92
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 1600 /* Sensor pixel size for sensor_init_data array */
54 #define SENSOR_INIT_HEIGHT 1200
55 #define SENSOR_INIT_WINSEQADR sensor_uxga
56 #define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
58 #define CONFIG_SENSOR_WhiteBalance 1
59 #define CONFIG_SENSOR_Brightness 0
60 #define CONFIG_SENSOR_Contrast 0
61 #define CONFIG_SENSOR_Saturation 0
62 #define CONFIG_SENSOR_Effect 1
63 #define CONFIG_SENSOR_Scene 1
64 #define CONFIG_SENSOR_DigitalZoom 0
65 #define CONFIG_SENSOR_Focus 0
66 #define CONFIG_SENSOR_Exposure 0
67 #define CONFIG_SENSOR_Flash 0
68 #define CONFIG_SENSOR_Mirror 0
69 #define CONFIG_SENSOR_Flip 0
71 #define CONFIG_SENSOR_I2C_SPEED 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 0
76 #define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|\
77 SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |\
78 SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ)
80 #define COLOR_TEMPERATURE_CLOUDY_DN 6500
81 #define COLOR_TEMPERATURE_CLOUDY_UP 8000
82 #define COLOR_TEMPERATURE_CLEARDAY_DN 5000
83 #define COLOR_TEMPERATURE_CLEARDAY_UP 6500
84 #define COLOR_TEMPERATURE_OFFICE_DN 3500
85 #define COLOR_TEMPERATURE_OFFICE_UP 5000
86 #define COLOR_TEMPERATURE_HOME_DN 2500
87 #define COLOR_TEMPERATURE_HOME_UP 3500
89 #define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))
90 #define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)
92 #define SENSOR_AF_IS_ERR (0x00<<0)
93 #define SENSOR_AF_IS_OK (0x01<<0)
94 #define SENSOR_INIT_IS_ERR (0x00<<28)
95 #define SENSOR_INIT_IS_OK (0x01<<28)
104 //flash off in fixed time to prevent from too hot , zyc
106 struct soc_camera_device *icd;
107 struct hrtimer timer;
109 static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
111 static struct flash_timer flash_off_timer;
112 //for user defined if user want to customize the series , zyc
113 #ifdef CONFIG_HI253_USER_DEFINED_SERIES
114 #include "hi253_user_series.c"
116 /* init SVGA preview */
117 static struct reginfo sensor_init_data[] =
348 {0x11, 0x03}, //lxh,normal
390 {0x10, 0x7f},//lxh,3f
1156 /* 1600X1200 UXGA capture */
1157 static struct reginfo sensor_uxga[] =
1187 /* 1280X1024 SXGA */
1188 static struct reginfo sensor_sxga[] =
1192 static struct reginfo sensor_xga[] =
1197 /* 800X600 SVGA,30fps*/
1198 static struct reginfo sensor_svga[] =
1206 {0x03, 0x12}, //Function
1212 {0x03, 0x13}, //Function
1213 {0x80, 0xfd}, //Function
1240 static struct reginfo sensor_vga[] =
1246 static struct reginfo sensor_cif[] =
1250 static struct reginfo sensor_qvga[] =
1254 static struct reginfo sensor_qcif[] =
1258 static struct reginfo sensor_ClrFmt_YUYV[]=
1264 static struct reginfo sensor_ClrFmt_UYVY[]=
1270 #if CONFIG_SENSOR_WhiteBalance
1271 static struct reginfo sensor_WhiteB_Auto[]=
1285 /* Cloudy Colour Temperature : 6500K - 8000K */
1286 static struct reginfo sensor_WhiteB_Cloudy[]=
1300 /* ClearDay Colour Temperature : 5000K - 6500K */
1301 static struct reginfo sensor_WhiteB_ClearDay[]=
1315 /* Office Colour Temperature : 3500K - 5000K */
1316 static struct reginfo sensor_WhiteB_TungstenLamp1[]=
1331 /* Home Colour Temperature : 2500K - 3500K */
1332 static struct reginfo sensor_WhiteB_TungstenLamp2[]=
1346 static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
1347 sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
1351 #if CONFIG_SENSOR_Brightness
1352 static struct reginfo sensor_Brightness0[]=
1360 static struct reginfo sensor_Brightness1[]=
1368 static struct reginfo sensor_Brightness2[]=
1376 static struct reginfo sensor_Brightness3[]=
1384 static struct reginfo sensor_Brightness4[]=
1392 static struct reginfo sensor_Brightness5[]=
1399 static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
1400 sensor_Brightness4, sensor_Brightness5,NULL,
1405 #if CONFIG_SENSOR_Effect
1406 static struct reginfo sensor_Effect_Normal[] =
1415 static struct reginfo sensor_Effect_WandB[] =
1427 static struct reginfo sensor_Effect_Sepia[] =
1439 static struct reginfo sensor_Effect_Negative[] =
1452 static struct reginfo sensor_Effect_Bluish[] =
1465 static struct reginfo sensor_Effect_Green[] =
1477 static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
1478 sensor_Effect_Bluish, sensor_Effect_Green,NULL,
1481 #if CONFIG_SENSOR_Exposure
1482 static struct reginfo sensor_Exposure0[]=
1488 static struct reginfo sensor_Exposure1[]=
1495 static struct reginfo sensor_Exposure2[]=
1501 static struct reginfo sensor_Exposure3[]=
1507 static struct reginfo sensor_Exposure4[]=
1514 static struct reginfo sensor_Exposure5[]=
1520 static struct reginfo sensor_Exposure6[]=
1527 static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
1528 sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
1531 #if CONFIG_SENSOR_Saturation
1532 static struct reginfo sensor_Saturation0[]=
1538 static struct reginfo sensor_Saturation1[]=
1544 static struct reginfo sensor_Saturation2[]=
1548 static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
1551 #if CONFIG_SENSOR_Contrast
1552 static struct reginfo sensor_Contrast0[]=
1559 static struct reginfo sensor_Contrast1[]=
1566 static struct reginfo sensor_Contrast2[]=
1573 static struct reginfo sensor_Contrast3[]=
1580 static struct reginfo sensor_Contrast4[]=
1588 static struct reginfo sensor_Contrast5[]=
1595 static struct reginfo sensor_Contrast6[]=
1601 static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
1602 sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
1606 #if CONFIG_SENSOR_Mirror
1607 static struct reginfo sensor_MirrorOn[]=
1613 static struct reginfo sensor_MirrorOff[]=
1618 static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
1620 #if CONFIG_SENSOR_Flip
1621 static struct reginfo sensor_FlipOn[]=
1627 static struct reginfo sensor_FlipOff[]=
1632 static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
1635 #if CONFIG_SENSOR_Scene
1636 static struct reginfo sensor_SceneAuto[] =
1642 static struct reginfo sensor_SceneNight[] =
1647 static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
1650 #if CONFIG_SENSOR_DigitalZoom
1651 static struct reginfo sensor_Zoom0[] =
1656 static struct reginfo sensor_Zoom1[] =
1661 static struct reginfo sensor_Zoom2[] =
1667 static struct reginfo sensor_Zoom3[] =
1671 static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};
1673 static const struct v4l2_querymenu sensor_menus[] =
1675 #if CONFIG_SENSOR_WhiteBalance
1676 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 0, .name = "auto", .reserved = 0, }, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 1, .name = "incandescent", .reserved = 0,},
1677 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
1678 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
1681 #if CONFIG_SENSOR_Effect
1682 { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "mono", .reserved = 0,},
1683 { .id = V4L2_CID_EFFECT, .index = 2, .name = "negative", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "sepia", .reserved = 0,},
1684 { .id = V4L2_CID_EFFECT, .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT, .index = 5, .name = "aqua", .reserved = 0,},
1687 #if CONFIG_SENSOR_Scene
1688 { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
1691 #if CONFIG_SENSOR_Flash
1692 { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
1693 { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
1697 static struct v4l2_queryctrl sensor_controls[] =
1699 #if CONFIG_SENSOR_WhiteBalance
1701 .id = V4L2_CID_DO_WHITE_BALANCE,
1702 .type = V4L2_CTRL_TYPE_MENU,
1703 .name = "White Balance Control",
1711 #if CONFIG_SENSOR_Brightness
1713 .id = V4L2_CID_BRIGHTNESS,
1714 .type = V4L2_CTRL_TYPE_INTEGER,
1715 .name = "Brightness Control",
1723 #if CONFIG_SENSOR_Effect
1725 .id = V4L2_CID_EFFECT,
1726 .type = V4L2_CTRL_TYPE_MENU,
1727 .name = "Effect Control",
1735 #if CONFIG_SENSOR_Exposure
1737 .id = V4L2_CID_EXPOSURE,
1738 .type = V4L2_CTRL_TYPE_INTEGER,
1739 .name = "Exposure Control",
1747 #if CONFIG_SENSOR_Saturation
1749 .id = V4L2_CID_SATURATION,
1750 .type = V4L2_CTRL_TYPE_INTEGER,
1751 .name = "Saturation Control",
1759 #if CONFIG_SENSOR_Contrast
1761 .id = V4L2_CID_CONTRAST,
1762 .type = V4L2_CTRL_TYPE_INTEGER,
1763 .name = "Contrast Control",
1771 #if CONFIG_SENSOR_Mirror
1773 .id = V4L2_CID_HFLIP,
1774 .type = V4L2_CTRL_TYPE_BOOLEAN,
1775 .name = "Mirror Control",
1783 #if CONFIG_SENSOR_Flip
1785 .id = V4L2_CID_VFLIP,
1786 .type = V4L2_CTRL_TYPE_BOOLEAN,
1787 .name = "Flip Control",
1795 #if CONFIG_SENSOR_Scene
1797 .id = V4L2_CID_SCENE,
1798 .type = V4L2_CTRL_TYPE_MENU,
1799 .name = "Scene Control",
1807 #if CONFIG_SENSOR_DigitalZoom
1809 .id = V4L2_CID_ZOOM_RELATIVE,
1810 .type = V4L2_CTRL_TYPE_INTEGER,
1811 .name = "DigitalZoom Control",
1817 .id = V4L2_CID_ZOOM_ABSOLUTE,
1818 .type = V4L2_CTRL_TYPE_INTEGER,
1819 .name = "DigitalZoom Control",
1827 #if CONFIG_SENSOR_Focus
1829 .id = V4L2_CID_FOCUS_RELATIVE,
1830 .type = V4L2_CTRL_TYPE_INTEGER,
1831 .name = "Focus Control",
1837 .id = V4L2_CID_FOCUS_ABSOLUTE,
1838 .type = V4L2_CTRL_TYPE_INTEGER,
1839 .name = "Focus Control",
1843 .default_value = 125,
1847 #if CONFIG_SENSOR_Flash
1849 .id = V4L2_CID_FLASH,
1850 .type = V4L2_CTRL_TYPE_MENU,
1851 .name = "Flash Control",
1860 static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);
1861 static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
1862 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1863 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1864 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1865 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1866 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
1867 static int sensor_resume(struct soc_camera_device *icd);
1868 static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
1869 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
1870 #if CONFIG_SENSOR_Effect
1871 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1873 #if CONFIG_SENSOR_WhiteBalance
1874 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1876 static int sensor_deactivate(struct i2c_client *client);
1878 static struct soc_camera_ops sensor_ops =
1880 .suspend = sensor_suspend,
1881 .resume = sensor_resume,
1882 .set_bus_param = sensor_set_bus_param,
1883 .query_bus_param = sensor_query_bus_param,
1884 .controls = sensor_controls,
1885 .menus = sensor_menus,
1886 .num_controls = ARRAY_SIZE(sensor_controls),
1887 .num_menus = ARRAY_SIZE(sensor_menus),
1890 /* only one fixed colorspace per pixelcode */
1891 struct sensor_datafmt {
1892 enum v4l2_mbus_pixelcode code;
1893 enum v4l2_colorspace colorspace;
1896 /* Find a data format by a pixel code in an array */
1897 static const struct sensor_datafmt *sensor_find_datafmt(
1898 enum v4l2_mbus_pixelcode code, const struct sensor_datafmt *fmt,
1902 for (i = 0; i < n; i++)
1903 if (fmt[i].code == code)
1909 static const struct sensor_datafmt sensor_colour_fmts[] = {
1910 {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
1911 {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}
1914 typedef struct sensor_info_priv_s
1928 unsigned char mirror; /* HFLIP */
1929 unsigned char flip; /* VFLIP */
1930 unsigned int winseqe_cur_addr;
1931 struct sensor_datafmt fmt;
1932 unsigned int funmodule_state;
1934 } sensor_info_priv_t;
1938 struct v4l2_subdev subdev;
1939 struct i2c_client *client;
1940 sensor_info_priv_t info_priv;
1941 int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
1942 #if CONFIG_SENSOR_I2C_NOSCHED
1943 atomic_t tasklock_cnt;
1945 struct rk29camera_platform_data *sensor_io_request;
1946 struct rk29camera_gpio_res *sensor_gpio_res;
1949 static struct sensor* to_sensor(const struct i2c_client *client)
1951 return container_of(i2c_get_clientdata(client), struct sensor, subdev);
1954 static int sensor_task_lock(struct i2c_client *client, int lock)
1956 #if CONFIG_SENSOR_I2C_NOSCHED
1958 struct sensor *sensor = to_sensor(client);
1961 if (atomic_read(&sensor->tasklock_cnt) == 0) {
1962 while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {
1963 SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());
1967 if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {
1968 SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());
1969 goto sensor_task_lock_err;
1974 atomic_add(1, &sensor->tasklock_cnt);
1976 if (atomic_read(&sensor->tasklock_cnt) > 0) {
1977 atomic_sub(1, &sensor->tasklock_cnt);
1979 if (atomic_read(&sensor->tasklock_cnt) == 0)
1984 sensor_task_lock_err:
1991 static int sensor_write(struct i2c_client *client, u8 reg, u8 val)
1995 struct i2c_msg msg[1];
2000 msg->addr = client->addr;
2001 msg->flags = client->flags;
2003 msg->len = sizeof(buf);
2004 msg->scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
2005 msg->read_type = 0; /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
2010 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
2011 err = i2c_transfer(client->adapter, msg, 1);
2016 SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg, val);
2024 /* sensor register read */
2025 static int sensor_read(struct i2c_client *client, u8 reg, u8 *val)
2029 struct i2c_msg msg[2];
2033 msg[0].addr = client->addr;
2034 msg[0].flags = client->flags;
2036 msg[0].len = sizeof(buf);
2037 msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
2038 msg[0].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
2040 msg[1].addr = client->addr;
2041 msg[1].flags = client->flags|I2C_M_RD;
2044 msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
2045 msg[1].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
2049 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
2050 err = i2c_transfer(client->adapter, msg, 2);
2056 SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);
2065 /* write a array of registers */
2066 static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
2070 #if CONFIG_SENSOR_I2C_RDWRCHK
2075 if (sensor_task_lock(client, 1) < 0)
2076 goto sensor_write_array_end;
2077 while (regarray[i].reg != END_REG)
2079 err = sensor_write(client, regarray[i].reg, regarray[i].val);
2083 SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
2087 SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
2089 goto sensor_write_array_end;
2092 #if CONFIG_SENSOR_I2C_RDWRCHK
2094 sensor_read(client, regarray[i].reg, &valchk);
2095 if (valchk != regarray[i].val)
2096 SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
2102 sensor_write_array_end:
2103 sensor_task_lock(client,0);
2106 #if CONFIG_SENSOR_I2C_RDWRCHK
2107 static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)
2115 while (regarray[i].reg != 0)
2117 sensor_read(client, regarray[i].reg, &valchk);
2118 if (valchk != regarray[i].val)
2119 SENSOR_TR("%s Reg:0x%x read(0x%x, 0x%x) error\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
2126 static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)
2128 struct soc_camera_link *icl = to_soc_camera_link(icd);
2131 SENSOR_DG("%s %s cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);
2134 case Sensor_PowerDown:
2136 if (icl->powerdown) {
2137 ret = icl->powerdown(icd->pdev, on);
2138 if (ret == RK29_CAM_IO_SUCCESS) {
2142 icl->reset(icd->pdev);
2144 } else if (ret == RK29_CAM_EIO_REQUESTFAIL) {
2146 goto sensor_power_end;
2153 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2154 struct sensor *sensor = to_sensor(client);
2156 if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
2157 sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
2159 //flash off after 2 secs
2160 hrtimer_cancel(&(flash_off_timer.timer));
2161 hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
2168 SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
2176 static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
2177 struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
2178 sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
2179 SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
2183 static int sensor_init(struct v4l2_subdev *sd, u32 val)
2185 struct i2c_client *client = v4l2_get_subdevdata(sd);
2186 struct soc_camera_device *icd = client->dev.platform_data;
2187 struct sensor *sensor = to_sensor(client);
2188 const struct v4l2_queryctrl *qctrl;
2189 const struct sensor_datafmt *fmt;
2193 SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
2195 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
2197 goto sensor_INIT_ERR;
2201 if (sensor_task_lock(client,1)<0)
2202 goto sensor_INIT_ERR;
2204 ret = sensor_write(client, 0x01, 0xF9);
2207 SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
2209 goto sensor_INIT_ERR;
2212 mdelay(5); //delay 5 microseconds
2213 /* check if it is an sensor sensor */
2214 ret = sensor_read(client, 0x04, &value);
2216 SENSOR_TR("read chip id high byte failed\n");
2218 goto sensor_INIT_ERR;
2222 SENSOR_DG("\n %s pid = 0x%x\n", SENSOR_NAME_STRING(), value);
2223 if (value == SENSOR_ID) {
2224 sensor->model = SENSOR_V4L2_IDENT;
2226 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), value);
2228 goto sensor_INIT_ERR;
2231 ret = sensor_write_array(client, sensor_init_data);
2234 SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
2235 goto sensor_INIT_ERR;
2237 sensor_task_lock(client,0);
2238 sensor->info_priv.winseqe_cur_addr = (int)SENSOR_INIT_WINSEQADR;
2239 fmt = sensor_find_datafmt(SENSOR_INIT_PIXFMT,sensor_colour_fmts, ARRAY_SIZE(sensor_colour_fmts));
2241 SENSOR_TR("error: %s initial array colour fmts is not support!!",SENSOR_NAME_STRING());
2243 goto sensor_INIT_ERR;
2245 sensor->info_priv.fmt = *fmt;
2247 /* sensor sensor information for initialization */
2248 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
2250 sensor->info_priv.whiteBalance = qctrl->default_value;
2251 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);
2253 sensor->info_priv.brightness = qctrl->default_value;
2254 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
2256 sensor->info_priv.effect = qctrl->default_value;
2257 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);
2259 sensor->info_priv.exposure = qctrl->default_value;
2261 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);
2263 sensor->info_priv.saturation = qctrl->default_value;
2264 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);
2266 sensor->info_priv.contrast = qctrl->default_value;
2267 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);
2269 sensor->info_priv.mirror = qctrl->default_value;
2270 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);
2272 sensor->info_priv.flip = qctrl->default_value;
2273 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);
2275 sensor->info_priv.scene = qctrl->default_value;
2276 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
2278 sensor->info_priv.digitalzoom = qctrl->default_value;
2280 /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
2281 #if CONFIG_SENSOR_Focus
2283 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
2285 sensor->info_priv.focus = qctrl->default_value;
2288 #if CONFIG_SENSOR_Flash
2289 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
2291 sensor->info_priv.flash = qctrl->default_value;
2292 flash_off_timer.icd = icd;
2293 flash_off_timer.timer.function = flash_off_func;
2296 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);
2298 sensor->info_priv.funmodule_state |= SENSOR_INIT_IS_OK;
2301 sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
2302 sensor_task_lock(client,0);
2303 sensor_deactivate(client);
2307 static int sensor_deactivate(struct i2c_client *client)
2309 struct soc_camera_device *icd = client->dev.platform_data;
2310 struct sensor *sensor = to_sensor(client);
2311 SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);
2313 /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
2314 sensor_ioctrl(icd, Sensor_PowerDown, 1);
2316 /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */
2317 icd->user_width = SENSOR_INIT_WIDTH;
2318 icd->user_height = SENSOR_INIT_HEIGHT;
2320 sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
2324 static struct reginfo sensor_power_down_sequence[]=
2328 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
2331 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2333 if (pm_msg.event == PM_EVENT_SUSPEND) {
2334 SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());
2335 ret = sensor_write_array(client, sensor_power_down_sequence) ;
2337 SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
2340 ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);
2342 SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());
2347 SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
2353 static int sensor_resume(struct soc_camera_device *icd)
2357 ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);
2359 SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());
2363 SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());
2369 static int sensor_set_bus_param(struct soc_camera_device *icd,
2370 unsigned long flags)
2376 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
2378 struct soc_camera_link *icl = to_soc_camera_link(icd);
2379 unsigned long flags = SENSOR_BUS_PARAM;
2381 return soc_camera_apply_sensor_flags(icl, flags);
2384 static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2386 struct i2c_client *client = v4l2_get_subdevdata(sd);
2387 struct soc_camera_device *icd = client->dev.platform_data;
2388 struct sensor *sensor = to_sensor(client);
2390 mf->width = icd->user_width;
2391 mf->height = icd->user_height;
2392 mf->code = sensor->info_priv.fmt.code;
2393 mf->colorspace = sensor->info_priv.fmt.colorspace;
2394 mf->field = V4L2_FIELD_NONE;
2398 static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2402 if ((mf->width == 1024) && (mf->height == 768)) {
2404 } else if ((mf->width == 1280) && (mf->height == 1024)) {
2406 } else if ((mf->width == 1600) && (mf->height == 1200)) {
2408 } else if ((mf->width == 2048) && (mf->height == 1536)) {
2410 } else if ((mf->width == 2592) && (mf->height == 1944)) {
2415 SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, mf->width, mf->height);
2419 static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2423 if ((mf->width == 1280) && (mf->height == 720)) {
2425 } else if ((mf->width == 1920) && (mf->height == 1080)) {
2430 SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, mf->width, mf->height);
2433 static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2435 struct i2c_client *client = v4l2_get_subdevdata(sd);
2436 struct sensor *sensor = to_sensor(client);
2437 const struct sensor_datafmt *fmt;
2438 const struct v4l2_queryctrl *qctrl;
2439 struct soc_camera_device *icd = client->dev.platform_data;
2440 struct reginfo *winseqe_set_addr=NULL;
2441 int ret=0, set_w,set_h;
2443 fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
2444 ARRAY_SIZE(sensor_colour_fmts));
2447 goto sensor_s_fmt_end;
2450 if (sensor->info_priv.fmt.code != mf->code) {
2453 case V4L2_MBUS_FMT_YUYV8_2X8:
2455 winseqe_set_addr = sensor_ClrFmt_YUYV;
2458 case V4L2_MBUS_FMT_UYVY8_2X8:
2460 winseqe_set_addr = sensor_ClrFmt_UYVY;
2466 if (winseqe_set_addr != NULL) {
2467 sensor_write_array(client, winseqe_set_addr);
2468 sensor->info_priv.fmt.code = mf->code;
2469 sensor->info_priv.fmt.colorspace= mf->colorspace;
2470 SENSOR_DG("%s v4l2_mbus_code:%d set success!\n", SENSOR_NAME_STRING(),mf->code);
2472 SENSOR_TR("%s v4l2_mbus_code:%d is invalidate!\n", SENSOR_NAME_STRING(),mf->code);
2479 if (((set_w <= 176) && (set_h <= 144)) && (sensor_qcif[0].reg != END_REG))
2481 winseqe_set_addr = sensor_qcif;
2485 else if (((set_w <= 320) && (set_h <= 240)) && (sensor_qvga[0].reg != END_REG))
2487 winseqe_set_addr = sensor_qvga;
2491 else if (((set_w <= 352) && (set_h<= 288)) && (sensor_cif[0].reg != END_REG))
2493 winseqe_set_addr = sensor_cif;
2497 else if (((set_w <= 640) && (set_h <= 480)) && (sensor_vga[0].reg != END_REG))
2499 winseqe_set_addr = sensor_vga;
2503 else if (((set_w <= 800) && (set_h <= 600)) && (sensor_svga[0].reg != END_REG))
2505 winseqe_set_addr = sensor_svga;
2509 else if (((set_w <= 1024) && (set_h <= 768)) && (sensor_xga[0].reg != END_REG))
2511 winseqe_set_addr = sensor_xga;
2515 else if (((set_w <= 1280) && (set_h <= 1024)) && (sensor_sxga[0].reg != END_REG))
2517 winseqe_set_addr = sensor_sxga;
2521 else if (((set_w <= 1600) && (set_h <= 1200)) && (sensor_uxga[0].reg != END_REG))
2523 winseqe_set_addr = sensor_uxga;
2529 winseqe_set_addr = SENSOR_INIT_WINSEQADR; /* ddl@rock-chips.com : Sensor output smallest size if isn't support app */
2530 set_w = SENSOR_INIT_WIDTH;
2531 set_h = SENSOR_INIT_HEIGHT;
2533 SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,mf->width,mf->height);
2536 if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr) {
2537 #if CONFIG_SENSOR_Flash
2538 if (sensor_fmt_capturechk(sd,mf) == true) { /* ddl@rock-chips.com : Capture */
2539 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
2540 sensor_ioctrl(icd, Sensor_Flash, Flash_On);
2541 SENSOR_DG("%s flash on in capture!\n", SENSOR_NAME_STRING());
2543 } else { /* ddl@rock-chips.com : Video */
2544 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
2545 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2546 SENSOR_DG("%s flash off in preivew!\n", SENSOR_NAME_STRING());
2550 ret |= sensor_write_array(client, winseqe_set_addr);
2552 SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
2553 #if CONFIG_SENSOR_Flash
2554 if (sensor_fmt_capturechk(sd,f) == true) {
2555 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
2556 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2557 SENSOR_TR("%s Capture format set fail, flash off !\n", SENSOR_NAME_STRING());
2561 goto sensor_s_fmt_end;
2564 sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
2566 if (sensor_fmt_capturechk(sd,mf) == true) { /* ddl@rock-chips.com : Capture */
2567 #if CONFIG_SENSOR_Effect
2568 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
2569 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
2571 #if CONFIG_SENSOR_WhiteBalance
2572 if (sensor->info_priv.whiteBalance != 0) {
2573 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
2574 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
2577 sensor->info_priv.snap2preview = true;
2578 } else if (sensor_fmt_videochk(sd,mf) == true) { /* ddl@rock-chips.com : Video */
2579 #if CONFIG_SENSOR_Effect
2580 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
2581 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
2583 #if CONFIG_SENSOR_WhiteBalance
2584 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
2585 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
2587 sensor->info_priv.video2preview = true;
2588 } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) {
2589 #if CONFIG_SENSOR_Effect
2590 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
2591 sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
2593 #if CONFIG_SENSOR_WhiteBalance
2594 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
2595 sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
2597 sensor->info_priv.video2preview = false;
2598 sensor->info_priv.snap2preview = false;
2601 SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
2605 SENSOR_DG("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);
2615 static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2617 struct i2c_client *client = v4l2_get_subdevdata(sd);
2618 struct sensor *sensor = to_sensor(client);
2619 const struct sensor_datafmt *fmt;
2622 fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
2623 ARRAY_SIZE(sensor_colour_fmts));
2625 fmt = &sensor->info_priv.fmt;
2626 mf->code = fmt->code;
2629 if (mf->height > SENSOR_MAX_HEIGHT)
2630 mf->height = SENSOR_MAX_HEIGHT;
2631 else if (mf->height < SENSOR_MIN_HEIGHT)
2632 mf->height = SENSOR_MIN_HEIGHT;
2634 if (mf->width > SENSOR_MAX_WIDTH)
2635 mf->width = SENSOR_MAX_WIDTH;
2636 else if (mf->width < SENSOR_MIN_WIDTH)
2637 mf->width = SENSOR_MIN_WIDTH;
2639 mf->colorspace = fmt->colorspace;
2644 static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
2646 struct i2c_client *client = v4l2_get_subdevdata(sd);
2648 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
2651 if (id->match.addr != client->addr)
2654 id->ident = SENSOR_V4L2_IDENT; /* ddl@rock-chips.com : Return OV2655 identifier */
2659 #if CONFIG_SENSOR_Brightness
2660 static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2662 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2664 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2666 if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)
2668 if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)
2670 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2673 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2677 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2681 #if CONFIG_SENSOR_Effect
2682 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2684 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2686 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2688 if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)
2690 if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)
2692 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2695 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2699 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2703 #if CONFIG_SENSOR_Exposure
2704 static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2706 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2708 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2710 if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)
2712 if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)
2714 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2717 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2721 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2725 #if CONFIG_SENSOR_Saturation
2726 static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2728 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2730 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2732 if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)
2734 if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)
2736 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2739 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2743 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2747 #if CONFIG_SENSOR_Contrast
2748 static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2750 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2752 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2754 if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)
2756 if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)
2758 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2761 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2765 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2769 #if CONFIG_SENSOR_Mirror
2770 static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2772 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2774 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2776 if (sensor_MirrorSeqe[value - qctrl->minimum] != NULL)
2778 if (sensor_write_array(client, sensor_MirrorSeqe[value - qctrl->minimum]) != 0)
2780 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2783 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2787 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2791 #if CONFIG_SENSOR_Flip
2792 static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2794 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2796 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2798 if (sensor_FlipSeqe[value - qctrl->minimum] != NULL)
2800 if (sensor_write_array(client, sensor_FlipSeqe[value - qctrl->minimum]) != 0)
2802 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2805 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2809 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2813 #if CONFIG_SENSOR_Scene
2814 static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2816 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2818 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2820 if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)
2822 if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)
2824 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2827 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2831 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2835 #if CONFIG_SENSOR_WhiteBalance
2836 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2838 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2840 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2842 if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
2844 if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
2846 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2849 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2853 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2857 #if CONFIG_SENSOR_DigitalZoom
2858 static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2860 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2861 struct sensor *sensor = to_sensor(client);
2862 const struct v4l2_queryctrl *qctrl_info;
2863 int digitalzoom_cur, digitalzoom_total;
2865 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
2869 digitalzoom_cur = sensor->info_priv.digitalzoom;
2870 digitalzoom_total = qctrl_info->maximum;
2872 if ((value > 0) && (digitalzoom_cur >= digitalzoom_total))
2874 SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2878 if ((value < 0) && (digitalzoom_cur <= qctrl_info->minimum))
2880 SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2884 if ((value > 0) && ((digitalzoom_cur + value) > digitalzoom_total))
2886 *value = digitalzoom_total - digitalzoom_cur;
2889 if ((value < 0) && ((digitalzoom_cur + value) < 0))
2891 value = 0 - digitalzoom_cur;
2894 digitalzoom_cur += value;
2896 if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)
2898 if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)
2900 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2903 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2910 #if CONFIG_SENSOR_Flash
2911 static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2913 if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {
2914 if (value == 3) { /* ddl@rock-chips.com: torch */
2915 sensor_ioctrl(icd, Sensor_Flash, Flash_Torch); /* Flash On */
2917 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2919 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2923 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2928 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2930 struct i2c_client *client = v4l2_get_subdevdata(sd);
2931 struct sensor *sensor = to_sensor(client);
2932 const struct v4l2_queryctrl *qctrl;
2934 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2938 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2944 case V4L2_CID_BRIGHTNESS:
2946 ctrl->value = sensor->info_priv.brightness;
2949 case V4L2_CID_SATURATION:
2951 ctrl->value = sensor->info_priv.saturation;
2954 case V4L2_CID_CONTRAST:
2956 ctrl->value = sensor->info_priv.contrast;
2959 case V4L2_CID_DO_WHITE_BALANCE:
2961 ctrl->value = sensor->info_priv.whiteBalance;
2964 case V4L2_CID_EXPOSURE:
2966 ctrl->value = sensor->info_priv.exposure;
2969 case V4L2_CID_HFLIP:
2971 ctrl->value = sensor->info_priv.mirror;
2974 case V4L2_CID_VFLIP:
2976 ctrl->value = sensor->info_priv.flip;
2987 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2989 struct i2c_client *client = v4l2_get_subdevdata(sd);
2990 struct sensor *sensor = to_sensor(client);
2991 struct soc_camera_device *icd = client->dev.platform_data;
2992 const struct v4l2_queryctrl *qctrl;
2995 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2999 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
3005 #if CONFIG_SENSOR_Brightness
3006 case V4L2_CID_BRIGHTNESS:
3008 if (ctrl->value != sensor->info_priv.brightness)
3010 if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)
3014 sensor->info_priv.brightness = ctrl->value;
3019 #if CONFIG_SENSOR_Exposure
3020 case V4L2_CID_EXPOSURE:
3022 if (ctrl->value != sensor->info_priv.exposure)
3024 if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)
3028 sensor->info_priv.exposure = ctrl->value;
3033 #if CONFIG_SENSOR_Saturation
3034 case V4L2_CID_SATURATION:
3036 if (ctrl->value != sensor->info_priv.saturation)
3038 if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)
3042 sensor->info_priv.saturation = ctrl->value;
3047 #if CONFIG_SENSOR_Contrast
3048 case V4L2_CID_CONTRAST:
3050 if (ctrl->value != sensor->info_priv.contrast)
3052 if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)
3056 sensor->info_priv.contrast = ctrl->value;
3061 #if CONFIG_SENSOR_WhiteBalance
3062 case V4L2_CID_DO_WHITE_BALANCE:
3064 if (ctrl->value != sensor->info_priv.whiteBalance)
3066 if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
3070 sensor->info_priv.whiteBalance = ctrl->value;
3075 #if CONFIG_SENSOR_Mirror
3076 case V4L2_CID_HFLIP:
3078 if (ctrl->value != sensor->info_priv.mirror)
3080 if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)
3082 sensor->info_priv.mirror = ctrl->value;
3087 #if CONFIG_SENSOR_Flip
3088 case V4L2_CID_VFLIP:
3090 if (ctrl->value != sensor->info_priv.flip)
3092 if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)
3094 sensor->info_priv.flip = ctrl->value;
3105 static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
3107 const struct v4l2_queryctrl *qctrl;
3108 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3109 struct sensor *sensor = to_sensor(client);
3111 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
3115 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
3119 switch (ext_ctrl->id)
3121 case V4L2_CID_SCENE:
3123 ext_ctrl->value = sensor->info_priv.scene;
3126 case V4L2_CID_EFFECT:
3128 ext_ctrl->value = sensor->info_priv.effect;
3131 case V4L2_CID_ZOOM_ABSOLUTE:
3133 ext_ctrl->value = sensor->info_priv.digitalzoom;
3136 case V4L2_CID_ZOOM_RELATIVE:
3140 case V4L2_CID_FOCUS_ABSOLUTE:
3142 ext_ctrl->value = sensor->info_priv.focus;
3145 case V4L2_CID_FOCUS_RELATIVE:
3149 case V4L2_CID_FLASH:
3151 ext_ctrl->value = sensor->info_priv.flash;
3159 static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
3161 const struct v4l2_queryctrl *qctrl;
3162 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3163 struct sensor *sensor = to_sensor(client);
3166 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
3170 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
3175 switch (ext_ctrl->id)
3177 #if CONFIG_SENSOR_Scene
3178 case V4L2_CID_SCENE:
3180 if (ext_ctrl->value != sensor->info_priv.scene)
3182 if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)
3184 sensor->info_priv.scene = ext_ctrl->value;
3189 #if CONFIG_SENSOR_Effect
3190 case V4L2_CID_EFFECT:
3192 if (ext_ctrl->value != sensor->info_priv.effect)
3194 if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)
3196 sensor->info_priv.effect= ext_ctrl->value;
3201 #if CONFIG_SENSOR_DigitalZoom
3202 case V4L2_CID_ZOOM_ABSOLUTE:
3204 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
3207 if (ext_ctrl->value != sensor->info_priv.digitalzoom)
3209 val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;
3211 if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)
3213 sensor->info_priv.digitalzoom += val_offset;
3215 SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
3220 case V4L2_CID_ZOOM_RELATIVE:
3222 if (ext_ctrl->value)
3224 if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
3226 sensor->info_priv.digitalzoom += ext_ctrl->value;
3228 SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
3233 #if CONFIG_SENSOR_Focus
3234 case V4L2_CID_FOCUS_ABSOLUTE:
3236 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
3239 if (ext_ctrl->value != sensor->info_priv.focus)
3241 val_offset = ext_ctrl->value -sensor->info_priv.focus;
3243 sensor->info_priv.focus += val_offset;
3248 case V4L2_CID_FOCUS_RELATIVE:
3250 if (ext_ctrl->value)
3252 sensor->info_priv.focus += ext_ctrl->value;
3254 SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);
3259 #if CONFIG_SENSOR_Flash
3260 case V4L2_CID_FLASH:
3262 if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)
3264 sensor->info_priv.flash = ext_ctrl->value;
3266 SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
3277 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
3279 struct i2c_client *client = v4l2_get_subdevdata(sd);
3280 struct soc_camera_device *icd = client->dev.platform_data;
3281 int i, error_cnt=0, error_idx=-1;
3284 for (i=0; i<ext_ctrl->count; i++) {
3285 if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
3292 error_idx = ext_ctrl->count;
3294 if (error_idx != -1) {
3295 ext_ctrl->error_idx = error_idx;
3302 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
3304 struct i2c_client *client = v4l2_get_subdevdata(sd);
3305 struct soc_camera_device *icd = client->dev.platform_data;
3306 int i, error_cnt=0, error_idx=-1;
3309 for (i=0; i<ext_ctrl->count; i++) {
3310 if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
3317 error_idx = ext_ctrl->count;
3319 if (error_idx != -1) {
3320 ext_ctrl->error_idx = error_idx;
3327 /* Interface active, can use i2c. If it fails, it can indeed mean, that
3328 * this wasn't our capture interface, so, we wait for the right one */
3329 static int sensor_video_probe(struct soc_camera_device *icd,
3330 struct i2c_client *client)
3334 struct sensor *sensor = to_sensor(client);
3336 /* We must have a parent by now. And it cannot be a wrong one.
3337 * So this entire test is completely redundant. */
3338 if (!icd->dev.parent ||
3339 to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
3342 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
3344 goto sensor_video_probe_err;
3348 ret = sensor_write(client, 0x01, 0xf9);
3351 SENSOR_TR("soft reset %s failed\n",SENSOR_NAME_STRING());
3354 mdelay(5); //delay 5 microseconds
3356 /* check if it is an sensor sensor */
3357 ret = sensor_read(client, 0x04, &value);
3359 SENSOR_TR("read chip id high byte failed\n");
3361 goto sensor_video_probe_err;
3364 SENSOR_DG("\n %s pid = 0x%x\n", SENSOR_NAME_STRING(), value);
3365 if (value == SENSOR_ID) {
3366 sensor->model = SENSOR_V4L2_IDENT;
3368 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), value);
3370 goto sensor_video_probe_err;
3375 sensor_video_probe_err:
3379 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
3381 struct i2c_client *client = v4l2_get_subdevdata(sd);
3382 struct soc_camera_device *icd = client->dev.platform_data;
3383 struct sensor *sensor = to_sensor(client);
3385 #if CONFIG_SENSOR_Flash
3389 SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
3392 case RK29_CAM_SUBDEV_DEACTIVATE:
3394 sensor_deactivate(client);
3398 case RK29_CAM_SUBDEV_IOREQUEST:
3400 sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
3401 if (sensor->sensor_io_request != NULL) {
3402 if (sensor->sensor_io_request->gpio_res[0].dev_name &&
3403 (strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
3404 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
3405 } else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
3406 (strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
3407 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
3410 SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
3412 goto sensor_ioctl_end;
3414 /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
3416 #if CONFIG_SENSOR_Flash
3417 if (sensor->sensor_gpio_res) {
3418 if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
3419 for (i = 0; i < icd->ops->num_controls; i++) {
3420 if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
3421 //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));
3422 sensor_controls[i].id=0xffff;
3425 sensor->info_priv.flash = 0xff;
3426 SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
3427 }else{ //two cameras are the same,need to deal diffrently ,zyc
3428 for (i = 0; i < icd->ops->num_controls; i++) {
3429 if(0xffff == icd->ops->controls[i].id){
3430 sensor_controls[i].id=V4L2_CID_FLASH;
3440 SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
3448 static int sensor_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
3449 enum v4l2_mbus_pixelcode *code)
3451 if (index >= ARRAY_SIZE(sensor_colour_fmts))
3454 *code = sensor_colour_fmts[index].code;
3457 static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
3458 .init = sensor_init,
3459 .g_ctrl = sensor_g_control,
3460 .s_ctrl = sensor_s_control,
3461 .g_ext_ctrls = sensor_g_ext_controls,
3462 .s_ext_ctrls = sensor_s_ext_controls,
3463 .g_chip_ident = sensor_g_chip_ident,
3464 .ioctl = sensor_ioctl,
3468 static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
3469 .s_mbus_fmt = sensor_s_fmt,
3470 .g_mbus_fmt = sensor_g_fmt,
3471 .try_mbus_fmt = sensor_try_fmt,
3472 .enum_mbus_fmt = sensor_enum_fmt,
3475 static struct v4l2_subdev_ops sensor_subdev_ops = {
3476 .core = &sensor_subdev_core_ops,
3477 .video = &sensor_subdev_video_ops,
3480 static int sensor_probe(struct i2c_client *client,
3481 const struct i2c_device_id *did)
3483 struct sensor *sensor;
3484 struct soc_camera_device *icd = client->dev.platform_data;
3485 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
3486 struct soc_camera_link *icl;
3489 SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);
3491 dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());
3495 icl = to_soc_camera_link(icd);
3497 dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());
3501 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
3502 dev_warn(&adapter->dev,
3503 "I2C-Adapter doesn't support I2C_FUNC_I2C\n");
3507 sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);
3511 v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);
3513 /* Second stage probe - when a capture adapter is there */
3514 icd->ops = &sensor_ops;
3515 sensor->info_priv.fmt = sensor_colour_fmts[0];
3516 #if CONFIG_SENSOR_I2C_NOSCHED
3517 atomic_set(&sensor->tasklock_cnt,0);
3520 ret = sensor_video_probe(icd, client);
3523 i2c_set_clientdata(client, NULL);
3527 hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
3528 SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
3532 static int sensor_remove(struct i2c_client *client)
3534 struct sensor *sensor = to_sensor(client);
3535 struct soc_camera_device *icd = client->dev.platform_data;
3538 i2c_set_clientdata(client, NULL);
3539 client->driver = NULL;
3545 static const struct i2c_device_id sensor_id[] = {
3546 {SENSOR_NAME_STRING(), 0 },
3549 MODULE_DEVICE_TABLE(i2c, sensor_id);
3551 static struct i2c_driver sensor_i2c_driver = {
3553 .name = SENSOR_NAME_STRING(),
3555 .probe = sensor_probe,
3556 .remove = sensor_remove,
3557 .id_table = sensor_id,
3560 static int __init sensor_mod_init(void)
3562 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
3563 return i2c_add_driver(&sensor_i2c_driver);
3566 static void __exit sensor_mod_exit(void)
3568 i2c_del_driver(&sensor_i2c_driver);
3571 device_initcall_sync(sensor_mod_init);
3572 module_exit(sensor_mod_exit);
3574 MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
3575 MODULE_AUTHOR("lxh@wisky.com.cn");
3576 MODULE_LICENSE("GPL");