#ifndef PMEM_CAM_SIZE\r
#ifdef CONFIG_VIDEO_RK29 \r
/*---------------- Camera Sensor Fixed Macro Begin ------------------------*/\r
-// Below Macro is fixed, programer don't change it!!!!!!
-#define _CONS(a,b) a##b
+// Below Macro is fixed, programer don't change it!!!!!!\r
+#define _CONS(a,b) a##b\r
#define CONS(a,b) _CONS(a,b)\r
\r
-#define __STR(x) #x
-#define _STR(x) __STR(x)
+#define __STR(x) #x\r
+#define _STR(x) __STR(x)\r
#define STR(x) _STR(x)\r
\r
-#if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
-#define PMEM_SENSOR_FULL_RESOLUTION_0 CONS(CONFIG_SENSOR_0,_FULL_RESOLUTION)
-#if !(PMEM_SENSOR_FULL_RESOLUTION_0)
-#undef PMEM_SENSOR_FULL_RESOLUTION_0
-#define PMEM_SENSOR_FULL_RESOLUTION_0 0x500000
-#endif
-#else
-#define PMEM_SENSOR_FULL_RESOLUTION_0 0x00
-#endif
-
-#if (CONFIG_SENSOR_IIC_ADDR_1 != 0x00)
-#define PMEM_SENSOR_FULL_RESOLUTION_1 CONS(CONFIG_SENSOR_1,_FULL_RESOLUTION)
-#if !(PMEM_SENSOR_FULL_RESOLUTION_1)
-#undef PMEM_SENSOR_FULL_RESOLUTION_1
-#define PMEM_SENSOR_FULL_RESOLUTION_1 0x500000
-#endif
-#else
-#define PMEM_SENSOR_FULL_RESOLUTION_1 0x00
-#endif
-
-#if (PMEM_SENSOR_FULL_RESOLUTION_0 > PMEM_SENSOR_FULL_RESOLUTION_1)
-#define PMEM_CAM_FULL_RESOLUTION PMEM_SENSOR_FULL_RESOLUTION_0
-#else
-#define PMEM_CAM_FULL_RESOLUTION PMEM_SENSOR_FULL_RESOLUTION_1
-#endif
-
-#if (PMEM_CAM_FULL_RESOLUTION == 0x500000)
+#if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)\r
+#define PMEM_SENSOR_FULL_RESOLUTION_0 CONS(CONFIG_SENSOR_0,_FULL_RESOLUTION)\r
+#if !(PMEM_SENSOR_FULL_RESOLUTION_0)\r
+#undef PMEM_SENSOR_FULL_RESOLUTION_0\r
+#define PMEM_SENSOR_FULL_RESOLUTION_0 0x500000\r
+#endif\r
+#else\r
+#define PMEM_SENSOR_FULL_RESOLUTION_0 0x00\r
+#endif\r
+ \r
+#if (CONFIG_SENSOR_IIC_ADDR_1 != 0x00)\r
+#define PMEM_SENSOR_FULL_RESOLUTION_1 CONS(CONFIG_SENSOR_1,_FULL_RESOLUTION)\r
+#if !(PMEM_SENSOR_FULL_RESOLUTION_1)\r
+#undef PMEM_SENSOR_FULL_RESOLUTION_1\r
+#define PMEM_SENSOR_FULL_RESOLUTION_1 0x500000\r
+#endif\r
+#else\r
+#define PMEM_SENSOR_FULL_RESOLUTION_1 0x00\r
+#endif\r
+\r
+#if (PMEM_SENSOR_FULL_RESOLUTION_0 > PMEM_SENSOR_FULL_RESOLUTION_1)\r
+#define PMEM_CAM_FULL_RESOLUTION PMEM_SENSOR_FULL_RESOLUTION_0\r
+#else\r
+#define PMEM_CAM_FULL_RESOLUTION PMEM_SENSOR_FULL_RESOLUTION_1\r
+#endif\r
+\r
+#if (PMEM_CAM_FULL_RESOLUTION == 0x500000)\r
#define PMEM_CAM_NECESSARY 0x1200000 /* 1280*720*1.5*4(preview) + 7.5M(capture raw) + 4M(jpeg encode output) */\r
-#elif (PMEM_CAM_FULL_RESOLUTION == 0x300000)
+#elif (PMEM_CAM_FULL_RESOLUTION == 0x300000)\r
#define PMEM_CAM_NECESSARY 0xe00000 /* 1280*720*1.5*4(preview) + 4.5M(capture raw) + 3M(jpeg encode output) */\r
#elif (PMEM_CAM_FULL_RESOLUTION == 0x200000) /* 1280*720*1.5*4(preview) + 3M(capture raw) + 3M(jpeg encode output) */\r
#define PMEM_CAM_NECESSARY 0xc00000\r
-#elif ((PMEM_CAM_FULL_RESOLUTION == 0x100000) || (PMEM_CAM_FULL_RESOLUTION == 0x130000))
+#elif ((PMEM_CAM_FULL_RESOLUTION == 0x100000) || (PMEM_CAM_FULL_RESOLUTION == 0x130000))\r
#define PMEM_CAM_NECESSARY 0x800000 /* 800*600*1.5*4(preview) + 2M(capture raw) + 2M(jpeg encode output) */\r
#elif (PMEM_CAM_FULL_RESOLUTION == 0x30000)\r
#define PMEM_CAM_NECESSARY 0x400000 /* 640*480*1.5*4(preview) + 1M(capture raw) + 1M(jpeg encode output) */\r
#endif\r
#else // #ifdef PMEM_CAM_SIZE\r
\r
-/*****************************************************************************************
- * camera devices
- * author: ddl@rock-chips.com
+/*****************************************************************************************\r
+ * camera devices\r
+ * author: ddl@rock-chips.com\r
*****************************************************************************************/\r
#ifdef CONFIG_VIDEO_RK29 \r
static int camera_debug;\r
module_param(camera_debug, int, S_IRUGO|S_IWUSR);\r
-
+\r
#define ddprintk(level, fmt, arg...) do { \\r
if (camera_debug >= level) \\r
printk(KERN_WARNING"rk29_cam_io: " fmt , ## arg); } while (0)\r
\r
#define dprintk(format, ...) ddprintk(1, format, ## __VA_ARGS__) \r
\r
-#define SENSOR_NAME_0 STR(CONFIG_SENSOR_0) /* back camera sensor */
-#define SENSOR_NAME_1 STR(CONFIG_SENSOR_1) /* front camera sensor */
-#define SENSOR_DEVICE_NAME_0 STR(CONS(CONFIG_SENSOR_0, _back))
-#define SENSOR_DEVICE_NAME_1 STR(CONS(CONFIG_SENSOR_1, _front))
-
-static int rk29_sensor_io_init(void);
-static int rk29_sensor_io_deinit(int sensor);
-static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
-
+#define SENSOR_NAME_0 STR(CONFIG_SENSOR_0) /* back camera sensor */\r
+#define SENSOR_NAME_1 STR(CONFIG_SENSOR_1) /* front camera sensor */\r
+#define SENSOR_DEVICE_NAME_0 STR(CONS(CONFIG_SENSOR_0, _back))\r
+#define SENSOR_DEVICE_NAME_1 STR(CONS(CONFIG_SENSOR_1, _front))\r
+\r
+static int rk29_sensor_io_init(void);\r
+static int rk29_sensor_io_deinit(int sensor);\r
+static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);\r
+\r
static struct rk29camera_platform_data rk29_camera_platform_data = {\r
- .io_init = rk29_sensor_io_init,
- .io_deinit = rk29_sensor_io_deinit,
- .sensor_ioctrl = rk29_sensor_ioctrl,
- .gpio_res = {
- {
- .gpio_reset = CONFIG_SENSOR_RESET_PIN_0,
- .gpio_power = CONFIG_SENSOR_POWER_PIN_0,
- .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_0,
- .gpio_flash = CONFIG_SENSOR_FALSH_PIN_0,
- .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_0|CONFIG_SENSOR_RESETACTIVE_LEVEL_0|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0|CONFIG_SENSOR_FLASHACTIVE_LEVEL_0),
- .gpio_init = 0,
- .dev_name = SENSOR_DEVICE_NAME_0,
- }, {
- .gpio_reset = CONFIG_SENSOR_RESET_PIN_1,
- .gpio_power = CONFIG_SENSOR_POWER_PIN_1,
- .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_1,
- .gpio_flash = CONFIG_SENSOR_FALSH_PIN_1,
- .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_1|CONFIG_SENSOR_RESETACTIVE_LEVEL_1|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1|CONFIG_SENSOR_FLASHACTIVE_LEVEL_1),
- .gpio_init = 0,
- .dev_name = SENSOR_DEVICE_NAME_1,
- }
- },
- #ifdef CONFIG_VIDEO_RK29_WORK_IPP
- .meminfo = {
- .name = "camera_ipp_mem",
- .start = MEM_CAMIPP_BASE,
- .size = MEM_CAMIPP_SIZE,
- }
- #endif
+ .io_init = rk29_sensor_io_init,\r
+ .io_deinit = rk29_sensor_io_deinit,\r
+ .sensor_ioctrl = rk29_sensor_ioctrl,\r
+ .gpio_res = {\r
+ {\r
+ .gpio_reset = CONFIG_SENSOR_RESET_PIN_0,\r
+ .gpio_power = CONFIG_SENSOR_POWER_PIN_0,\r
+ .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_0,\r
+ .gpio_flash = CONFIG_SENSOR_FALSH_PIN_0,\r
+ .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_0|CONFIG_SENSOR_RESETACTIVE_LEVEL_0|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0|CONFIG_SENSOR_FLASHACTIVE_LEVEL_0),\r
+ .gpio_init = 0,\r
+ .dev_name = SENSOR_DEVICE_NAME_0,\r
+ }, {\r
+ .gpio_reset = CONFIG_SENSOR_RESET_PIN_1,\r
+ .gpio_power = CONFIG_SENSOR_POWER_PIN_1,\r
+ .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_1,\r
+ .gpio_flash = CONFIG_SENSOR_FALSH_PIN_1,\r
+ .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_1|CONFIG_SENSOR_RESETACTIVE_LEVEL_1|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1|CONFIG_SENSOR_FLASHACTIVE_LEVEL_1),\r
+ .gpio_init = 0,\r
+ .dev_name = SENSOR_DEVICE_NAME_1,\r
+ }\r
+ },\r
+ #ifdef CONFIG_VIDEO_RK29_WORK_IPP\r
+ .meminfo = {\r
+ .name = "camera_ipp_mem",\r
+ .start = MEM_CAMIPP_BASE,\r
+ .size = MEM_CAMIPP_SIZE,\r
+ }\r
+ #endif\r
};\r
\r
-
+\r
\r
static int sensor_power_default_cb (struct rk29camera_gpio_res *res, int on)\r
{\r
int ret = 0;\r
\r
if (camera_power != INVALID_GPIO) {\r
- if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {\r
+ if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {\r
if (on) {\r
gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
dprintk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,res->dev_name, camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
}\r
\r
static int sensor_reset_default_cb (struct rk29camera_gpio_res *res, int on)\r
-{
+{\r
int camera_reset = res->gpio_reset;\r
int camera_ioflag = res->gpio_flag;\r
int camera_io_init = res->gpio_init; \r
}\r
\r
return ret;\r
-}
+}\r
\r
static int sensor_powerdown_default_cb (struct rk29camera_gpio_res *res, int on)\r
-{
+{\r
int camera_powerdown = res->gpio_powerdown;\r
int camera_ioflag = res->gpio_flag;\r
int camera_io_init = res->gpio_init; \r
ret = RK29_CAM_EIO_INVALID;\r
}\r
return ret;\r
-}
+}\r
+\r
\r
-
static int sensor_flash_default_cb (struct rk29camera_gpio_res *res, int on)\r
{\r
int camera_flash = res->gpio_flash;\r
return ret;\r
}\r
\r
-
-static int rk29_sensor_io_init(void)
-{
- int ret = 0, i;
- unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
- unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
- unsigned int camera_ioflag;
+\r
+static int rk29_sensor_io_init(void)\r
+{\r
+ int ret = 0, i;\r
+ unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;\r
+ unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;\r
+ unsigned int camera_ioflag;\r
\r
if (sensor_ioctl_cb.sensor_power_cb == NULL)\r
sensor_ioctl_cb.sensor_power_cb = sensor_power_default_cb;\r
if (sensor_ioctl_cb.sensor_flash_cb == NULL)\r
sensor_ioctl_cb.sensor_flash_cb = sensor_flash_default_cb;\r
\r
- for (i=0; i<2; i++) {
- camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
- camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
- camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
- camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
- camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
- rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
-
- if (camera_power != INVALID_GPIO) {
- ret = gpio_request(camera_power, "camera power");
- if (ret) {
+ for (i=0; i<2; i++) {\r
+ camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;\r
+ camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;\r
+ camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;\r
+ camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;\r
+ camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;\r
+ rk29_camera_platform_data.gpio_res[i].gpio_init = 0;\r
+\r
+ if (camera_power != INVALID_GPIO) {\r
+ ret = gpio_request(camera_power, "camera power");\r
+ if (ret) {\r
if (i == 0) {\r
- goto sensor_io_int_loop_end;
+ goto sensor_io_int_loop_end;\r
} else {\r
if (camera_power != rk29_camera_platform_data.gpio_res[0].gpio_power)\r
goto sensor_io_int_loop_end;\r
}\r
}\r
- rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
- gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
- gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
-
- dprintk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
-
- }
-
- if (camera_reset != INVALID_GPIO) {
- ret = gpio_request(camera_reset, "camera reset");
- if (ret)
- goto sensor_io_int_loop_end;
- rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
- gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
- gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
-
+\r
+ rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;\r
+ gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
+ gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
+\r
+ printk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
+\r
+ }\r
+\r
+ if (camera_reset != INVALID_GPIO) {\r
+ ret = gpio_request(camera_reset, "camera reset");\r
+ if (ret)\r
+ goto sensor_io_int_loop_end;\r
+ rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;\r
+ gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));\r
+ gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));\r
+\r
dprintk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));\r
-
- }
-
- if (camera_powerdown != INVALID_GPIO) {
- ret = gpio_request(camera_powerdown, "camera powerdown");
- if (ret)
- goto sensor_io_int_loop_end;
- rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
- gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
- gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
-
- dprintk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));\r
-
- }
-
- if (camera_flash != INVALID_GPIO) {
- ret = gpio_request(camera_flash, "camera flash");
- if (ret)
- goto sensor_io_int_loop_end;
- rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
+\r
+ }\r
+\r
+ if (camera_powerdown != INVALID_GPIO) {\r
+ ret = gpio_request(camera_powerdown, "camera powerdown");\r
+ if (ret)\r
+ goto sensor_io_int_loop_end;\r
+ rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;\r
+ gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));\r
+ gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));\r
+\r
+ printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));\r
+\r
+ }\r
+\r
+ if (camera_flash != INVALID_GPIO) {\r
+ ret = gpio_request(camera_flash, "camera flash");\r
+ if (ret)\r
+ goto sensor_io_int_loop_end;\r
+ rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;\r
gpio_set_value(camera_flash, ((~camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS)); /* falsh off */\r
gpio_direction_output(camera_flash, ((~camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));\r
-
+\r
dprintk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));\r
-
- }
- continue;
-sensor_io_int_loop_end:
- rk29_sensor_io_deinit(i);
- continue;
- }
-
- return 0;
-}
-
-static int rk29_sensor_io_deinit(int sensor)
-{
- unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
- unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
-
- camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
- camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
- camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
- camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
-
- if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
- if (camera_power != INVALID_GPIO) {
- gpio_direction_input(camera_power);
- gpio_free(camera_power);
- }
- }
-
- if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
- if (camera_reset != INVALID_GPIO) {
- gpio_direction_input(camera_reset);
- gpio_free(camera_reset);
- }
- }
-
- if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
- if (camera_powerdown != INVALID_GPIO) {
- gpio_direction_input(camera_powerdown);
- gpio_free(camera_powerdown);
- }
- }
-
- if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
- if (camera_flash != INVALID_GPIO) {
- gpio_direction_input(camera_flash);
- gpio_free(camera_flash);
- }
- }
-
- rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
- return 0;
-}
-static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
-{
+\r
+ }\r
+ continue;\r
+sensor_io_int_loop_end:\r
+ rk29_sensor_io_deinit(i);\r
+ continue;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+static int rk29_sensor_io_deinit(int sensor)\r
+{\r
+ unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;\r
+ unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;\r
+\r
+ camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;\r
+ camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;\r
+ camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;\r
+ camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;\r
+\r
+ if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {\r
+ if (camera_power != INVALID_GPIO) {\r
+ gpio_direction_input(camera_power);\r
+ gpio_free(camera_power);\r
+ }\r
+ }\r
+\r
+ if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {\r
+ if (camera_reset != INVALID_GPIO) {\r
+ gpio_direction_input(camera_reset);\r
+ gpio_free(camera_reset);\r
+ }\r
+ }\r
+\r
+ if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {\r
+ if (camera_powerdown != INVALID_GPIO) {\r
+ gpio_direction_input(camera_powerdown);\r
+ gpio_free(camera_powerdown);\r
+ }\r
+ }\r
+\r
+ if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {\r
+ if (camera_flash != INVALID_GPIO) {\r
+ gpio_direction_input(camera_flash);\r
+ gpio_free(camera_flash);\r
+ }\r
+ }\r
+\r
+ rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;\r
+ return 0;\r
+}\r
+static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)\r
+{\r
struct rk29camera_gpio_res *res = NULL; \r
- int ret = RK29_CAM_IO_SUCCESS;
-
- if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
+ int ret = RK29_CAM_IO_SUCCESS;\r
+\r
+ if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {\r
res = (struct rk29camera_gpio_res *)&rk29_camera_platform_data.gpio_res[0];\r
- } else if (rk29_camera_platform_data.gpio_res[1].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[1].dev_name, dev_name(dev)) == 0)) {
+ } else if (rk29_camera_platform_data.gpio_res[1].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[1].dev_name, dev_name(dev)) == 0)) {\r
res = (struct rk29camera_gpio_res *)&rk29_camera_platform_data.gpio_res[1];\r
} else {\r
printk(KERN_ERR "%s is not regisiterd in rk29_camera_platform_data!!\n",dev_name(dev));\r
ret = RK29_CAM_EIO_INVALID;\r
goto rk29_sensor_ioctrl_end;\r
}\r
-
- switch (cmd)
- {
- case Cam_Power:
- {
+\r
+ switch (cmd)\r
+ {\r
+ case Cam_Power:\r
+ {\r
if (sensor_ioctl_cb.sensor_power_cb) {\r
ret = sensor_ioctl_cb.sensor_power_cb(res, on);\r
} else {\r
printk(KERN_ERR "sensor_ioctl_cb.sensor_power_cb is NULL");\r
WARN_ON(1);\r
}\r
- break;
- }
- case Cam_Reset:
- {
+ break;\r
+ }\r
+ case Cam_Reset:\r
+ {\r
if (sensor_ioctl_cb.sensor_reset_cb) {\r
ret = sensor_ioctl_cb.sensor_reset_cb(res, on);\r
} else {\r
printk(KERN_ERR "sensor_ioctl_cb.sensor_reset_cb is NULL");\r
WARN_ON(1);\r
}\r
- break;
- }
-
- case Cam_PowerDown:
- {
+ break;\r
+ }\r
+\r
+ case Cam_PowerDown:\r
+ {\r
if (sensor_ioctl_cb.sensor_powerdown_cb) {\r
ret = sensor_ioctl_cb.sensor_powerdown_cb(res, on);\r
} else {\r
printk(KERN_ERR "sensor_ioctl_cb.sensor_powerdown_cb is NULL");\r
WARN_ON(1);\r
}\r
- break;
- }
-
- case Cam_Flash:
- {
+ break;\r
+ }\r
+\r
+ case Cam_Flash:\r
+ {\r
if (sensor_ioctl_cb.sensor_flash_cb) {\r
ret = sensor_ioctl_cb.sensor_flash_cb(res, on);\r
} else {\r
printk(KERN_ERR "sensor_ioctl_cb.sensor_flash_cb is NULL!");\r
WARN_ON(1);\r
}\r
- break;
- }
-
- default:
- {
- printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
- break;
- }
+ break;\r
+ }\r
+\r
+ default:\r
+ {\r
+ printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);\r
+ break;\r
+ }\r
}\r
rk29_sensor_ioctrl_end:\r
- return ret;
-}
-static int rk29_sensor_power(struct device *dev, int on)
-{
- rk29_sensor_ioctrl(dev,Cam_Power,on);
- return 0;
+ return ret;\r
+}\r
+static int rk29_sensor_power(struct device *dev, int on)\r
+{\r
+ rk29_sensor_ioctrl(dev,Cam_Power,on);\r
+ return 0;\r
}\r
#if 0\r
-static int rk29_sensor_reset(struct device *dev)
-{
- rk29_sensor_ioctrl(dev,Cam_Reset,1);
- msleep(2);
- rk29_sensor_ioctrl(dev,Cam_Reset,0);
- return 0;
+static int rk29_sensor_reset(struct device *dev)\r
+{\r
+ rk29_sensor_ioctrl(dev,Cam_Reset,1);\r
+ msleep(2);\r
+ rk29_sensor_ioctrl(dev,Cam_Reset,0);\r
+ return 0;\r
}\r
#endif\r
-static int rk29_sensor_powerdown(struct device *dev, int on)
-{
- return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
-}
-#if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
-static struct i2c_board_info rk29_i2c_cam_info_0[] = {
- {
- I2C_BOARD_INFO(SENSOR_NAME_0, CONFIG_SENSOR_IIC_ADDR_0>>1)
- },
-};
-
-static struct soc_camera_link rk29_iclink_0 = {
- .bus_id = RK29_CAM_PLATFORM_DEV_ID,
- .power = rk29_sensor_power,
- .powerdown = rk29_sensor_powerdown,
- .board_info = &rk29_i2c_cam_info_0[0],
- .i2c_adapter_id = CONFIG_SENSOR_IIC_ADAPTER_ID_0,
- .module_name = SENSOR_NAME_0,
-};
-
-/*platform_device : soc-camera need */
-static struct platform_device rk29_soc_camera_pdrv_0 = {
- .name = "soc-camera-pdrv",
- .id = 0,
- .dev = {
- .init_name = SENSOR_DEVICE_NAME_0,
- .platform_data = &rk29_iclink_0,
- },
-};
-#endif
-static struct i2c_board_info rk29_i2c_cam_info_1[] = {
- {
- I2C_BOARD_INFO(SENSOR_NAME_1, CONFIG_SENSOR_IIC_ADDR_1>>1)
- },
-};
-
-static struct soc_camera_link rk29_iclink_1 = {
- .bus_id = RK29_CAM_PLATFORM_DEV_ID,
- .power = rk29_sensor_power,
- .powerdown = rk29_sensor_powerdown,
- .board_info = &rk29_i2c_cam_info_1[0],
- .i2c_adapter_id = CONFIG_SENSOR_IIC_ADAPTER_ID_1,
- .module_name = SENSOR_NAME_1,
-};
-
-/*platform_device : soc-camera need */
-static struct platform_device rk29_soc_camera_pdrv_1 = {
- .name = "soc-camera-pdrv",
- .id = 1,
- .dev = {
- .init_name = SENSOR_DEVICE_NAME_1,
- .platform_data = &rk29_iclink_1,
- },
-};
-
-
-static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
-static struct resource rk29_camera_resource[] = {
- [0] = {
- .start = RK29_VIP_PHYS,
- .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = IRQ_VIP,
- .end = IRQ_VIP,
- .flags = IORESOURCE_IRQ,
- }
-};
-
-/*platform_device : */
-static struct platform_device rk29_device_camera = {
- .name = RK29_CAM_DRV_NAME,
- .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
- .num_resources = ARRAY_SIZE(rk29_camera_resource),
- .resource = rk29_camera_resource,
- .dev = {
- .dma_mask = &rockchip_device_camera_dmamask,
- .coherent_dma_mask = 0xffffffffUL,
- .platform_data = &rk29_camera_platform_data,
- }
-};
-
-static struct android_pmem_platform_data android_pmem_cam_pdata = {
- .name = "pmem_cam",
- .start = PMEM_CAM_BASE,
- .size = PMEM_CAM_SIZE,
- .no_allocator = 1,
- .cached = 1,
-};
-
-static struct platform_device android_pmem_cam_device = {
- .name = "android_pmem",
- .id = 1,
- .dev = {
- .platform_data = &android_pmem_cam_pdata,
- },
+static int rk29_sensor_powerdown(struct device *dev, int on)\r
+{\r
+ return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);\r
+}\r
+#if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)\r
+static struct i2c_board_info rk29_i2c_cam_info_0[] = {\r
+ {\r
+ I2C_BOARD_INFO(SENSOR_NAME_0, CONFIG_SENSOR_IIC_ADDR_0>>1)\r
+ },\r
+};\r
+\r
+static struct soc_camera_link rk29_iclink_0 = {\r
+ .bus_id = RK29_CAM_PLATFORM_DEV_ID,\r
+ .power = rk29_sensor_power,\r
+ .powerdown = rk29_sensor_powerdown,\r
+ .board_info = &rk29_i2c_cam_info_0[0],\r
+ .i2c_adapter_id = CONFIG_SENSOR_IIC_ADAPTER_ID_0,\r
+ .module_name = SENSOR_NAME_0,\r
+};\r
+\r
+/*platform_device : soc-camera need */\r
+static struct platform_device rk29_soc_camera_pdrv_0 = {\r
+ .name = "soc-camera-pdrv",\r
+ .id = 0,\r
+ .dev = {\r
+ .init_name = SENSOR_DEVICE_NAME_0,\r
+ .platform_data = &rk29_iclink_0,\r
+ },\r
+};\r
+#endif\r
+static struct i2c_board_info rk29_i2c_cam_info_1[] = {\r
+ {\r
+ I2C_BOARD_INFO(SENSOR_NAME_1, CONFIG_SENSOR_IIC_ADDR_1>>1)\r
+ },\r
+};\r
+\r
+static struct soc_camera_link rk29_iclink_1 = {\r
+ .bus_id = RK29_CAM_PLATFORM_DEV_ID,\r
+ .power = rk29_sensor_power,\r
+ .powerdown = rk29_sensor_powerdown,\r
+ .board_info = &rk29_i2c_cam_info_1[0],\r
+ .i2c_adapter_id = CONFIG_SENSOR_IIC_ADAPTER_ID_1,\r
+ .module_name = SENSOR_NAME_1,\r
+};\r
+\r
+/*platform_device : soc-camera need */\r
+static struct platform_device rk29_soc_camera_pdrv_1 = {\r
+ .name = "soc-camera-pdrv",\r
+ .id = 1,\r
+ .dev = {\r
+ .init_name = SENSOR_DEVICE_NAME_1,\r
+ .platform_data = &rk29_iclink_1,\r
+ },\r
+};\r
+\r
+\r
+static u64 rockchip_device_camera_dmamask = 0xffffffffUL;\r
+static struct resource rk29_camera_resource[] = {\r
+ [0] = {\r
+ .start = RK29_VIP_PHYS,\r
+ .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,\r
+ .flags = IORESOURCE_MEM,\r
+ },\r
+ [1] = {\r
+ .start = IRQ_VIP,\r
+ .end = IRQ_VIP,\r
+ .flags = IORESOURCE_IRQ,\r
+ }\r
+};\r
+\r
+/*platform_device : */\r
+static struct platform_device rk29_device_camera = {\r
+ .name = RK29_CAM_DRV_NAME,\r
+ .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */\r
+ .num_resources = ARRAY_SIZE(rk29_camera_resource),\r
+ .resource = rk29_camera_resource,\r
+ .dev = {\r
+ .dma_mask = &rockchip_device_camera_dmamask,\r
+ .coherent_dma_mask = 0xffffffffUL,\r
+ .platform_data = &rk29_camera_platform_data,\r
+ }\r
+};\r
+\r
+static struct android_pmem_platform_data android_pmem_cam_pdata = {\r
+ .name = "pmem_cam",\r
+ .start = PMEM_CAM_BASE,\r
+ .size = PMEM_CAM_SIZE,\r
+ .no_allocator = 1,\r
+ .cached = 1,\r
+};\r
+\r
+static struct platform_device android_pmem_cam_device = {\r
+ .name = "android_pmem",\r
+ .id = 1,\r
+ .dev = {\r
+ .platform_data = &android_pmem_cam_pdata,\r
+ },\r
};\r
\r
#endif\r