From b0c86fcac1c2e0366d3bd5633dfec0ec276d1f03 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 17 May 2012 11:22:59 +0800 Subject: [PATCH] camera rk30 : detect whether cif recevie data in two second's interval,wake up vb when no data. --- arch/arm/mach-rk30/board-rk30-sdk.c | 33 ++++++- drivers/media/video/gc0307.c | 4 +- drivers/media/video/gc0308.c | 4 +- drivers/media/video/gc0309.c | 4 +- drivers/media/video/gc2015.c | 4 +- drivers/media/video/gt2005.c | 4 +- drivers/media/video/hi253.c | 4 +- drivers/media/video/hi704.c | 4 +- drivers/media/video/mt9d112.c | 4 +- drivers/media/video/mt9d113.c | 4 +- drivers/media/video/mt9p111.c | 4 +- drivers/media/video/mt9t111.c | 4 +- drivers/media/video/nt99250.c | 4 +- drivers/media/video/ov2640_rk.c | 4 +- drivers/media/video/ov2655.c | 4 +- drivers/media/video/ov2659.c | 4 +- drivers/media/video/ov5640.c | 5 +- drivers/media/video/ov5642.c | 5 +- drivers/media/video/ov7675.c | 4 +- drivers/media/video/ov7690.c | 4 +- drivers/media/video/rk30_camera_oneframe.c | 100 ++++++++++----------- drivers/media/video/s5k6aa.c | 4 +- drivers/media/video/sid130B.c | 4 +- drivers/media/video/siv120b.c | 4 +- 24 files changed, 125 insertions(+), 98 deletions(-) mode change 100644 => 100755 drivers/media/video/ov2655.c diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index 412474f9e897..560deae7ad09 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -41,6 +41,7 @@ #include #include #include +#include #if defined(CONFIG_HDMI_RK30) #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h" #endif @@ -207,15 +208,43 @@ * author: ddl@rock-chips.com *****************************************************************************************/ #ifdef CONFIG_VIDEO_RK29 -#define CONFIG_SENSOR_POWER_IOCTL_USR 0 +#define CONFIG_SENSOR_POWER_IOCTL_USR 1 //define this refer to your board layout #define CONFIG_SENSOR_RESET_IOCTL_USR 0 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0 #define CONFIG_SENSOR_FLASH_IOCTL_USR 0 +static void rk_cif_power(int on) +{ + struct regulator *ldo_18,*ldo_28; + ldo_28 = regulator_get(NULL, "ldo7"); // vcc28_cif + ldo_18 = regulator_get(NULL, "ldo1"); // vcc18_cif + + if(on == 0){ + regulator_disable(ldo_28); + regulator_put(ldo_28); + regulator_disable(ldo_18); + regulator_put(ldo_18); + mdelay(500); + } + else{ + regulator_set_voltage(ldo_28, 2800000, 2800000); + regulator_enable(ldo_28); + // printk("%s set ldo7 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_28)); + regulator_put(ldo_28); + + regulator_set_voltage(ldo_18, 1800000, 1800000); + // regulator_set_suspend_voltage(ldo, 1800000); + regulator_enable(ldo_18); + // printk("%s set ldo1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo)); + regulator_put(ldo_18); + } +} + #if CONFIG_SENSOR_POWER_IOCTL_USR static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on) { - #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!"; + //#error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!"; + rk_cif_power(on); } #endif diff --git a/drivers/media/video/gc0307.c b/drivers/media/video/gc0307.c index 8a62bba16191..79c2ec36b6f4 100755 --- a/drivers/media/video/gc0307.c +++ b/drivers/media/video/gc0307.c @@ -109,7 +109,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_GC0307_USER_DEFINED_SERIES +#ifdef CONFIG_GC0307_USER_DEFINED_SERIES #include "gc0307_user_series.c" #else /* init 640X480 VGA */ @@ -1749,7 +1749,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -3026,6 +3025,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/gc0308.c b/drivers/media/video/gc0308.c index 4a8067514c85..1bc93fae7f02 100755 --- a/drivers/media/video/gc0308.c +++ b/drivers/media/video/gc0308.c @@ -110,7 +110,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_GC0308_USER_DEFINED_SERIES +#ifdef CONFIG_GC0308_USER_DEFINED_SERIES #include "gc0308_user_series.c" #else /* init 640X480 VGA */ @@ -1605,7 +1605,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -2866,6 +2865,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/gc0309.c b/drivers/media/video/gc0309.c index 4c1e6938f0d9..ddc21d9086f6 100755 --- a/drivers/media/video/gc0309.c +++ b/drivers/media/video/gc0309.c @@ -108,7 +108,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_GC0309_USER_DEFINED_SERIES +#ifdef CONFIG_GC0309_USER_DEFINED_SERIES #include "gc0309_user_series.c" #else /* init SVGA preview */ @@ -1574,7 +1574,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -2808,6 +2807,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/gc2015.c b/drivers/media/video/gc2015.c index b388c88e5657..1c3101fd0466 100755 --- a/drivers/media/video/gc2015.c +++ b/drivers/media/video/gc2015.c @@ -109,7 +109,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_GC2015_USER_DEFINED_SERIES +#ifdef CONFIG_GC2015_USER_DEFINED_SERIES #include "gc2015_user_series.c" #else /* init SVGA preview */ @@ -1741,7 +1741,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -3042,6 +3041,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/gt2005.c b/drivers/media/video/gt2005.c index 9658a4d09adb..d9915c3aebd1 100755 --- a/drivers/media/video/gt2005.c +++ b/drivers/media/video/gt2005.c @@ -109,7 +109,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_GT2005_USER_DEFINED_SERIES +#ifdef CONFIG_GT2005_USER_DEFINED_SERIES #include "gt2005_user_series.c" #else /* init 352X288 SVGA */ @@ -2386,7 +2386,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -3675,6 +3674,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/hi253.c b/drivers/media/video/hi253.c index 42a6724a748a..0588114773ea 100755 --- a/drivers/media/video/hi253.c +++ b/drivers/media/video/hi253.c @@ -110,7 +110,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_HI253_USER_DEFINED_SERIES +#ifdef CONFIG_HI253_USER_DEFINED_SERIES #include "hi253_user_series.c" #else /* init SVGA preview */ @@ -2289,7 +2289,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -3525,6 +3524,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/hi704.c b/drivers/media/video/hi704.c index 5470743c07fb..09ea70fb3a1f 100755 --- a/drivers/media/video/hi704.c +++ b/drivers/media/video/hi704.c @@ -110,7 +110,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_HI704_USER_DEFINED_SERIES +#ifdef CONFIG_HI704_USER_DEFINED_SERIES #include "hi704_user_series.c" #else /* init SVGA preview */ @@ -1767,7 +1767,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -2978,6 +2977,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/mt9d112.c b/drivers/media/video/mt9d112.c index 4cd7ed5414f4..4812dd227c2a 100755 --- a/drivers/media/video/mt9d112.c +++ b/drivers/media/video/mt9d112.c @@ -118,7 +118,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_MT9D112_USER_DEFINED_SERIES +#ifdef CONFIG_MT9D112_USER_DEFINED_SERIES #include "mt9d112_user_series.c" #else @@ -1920,7 +1920,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -3351,6 +3350,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/mt9d113.c b/drivers/media/video/mt9d113.c index fdb34d42015b..eea39a2955ea 100755 --- a/drivers/media/video/mt9d113.c +++ b/drivers/media/video/mt9d113.c @@ -117,7 +117,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_MT9D113_USER_DEFINED_SERIES +#ifdef CONFIG_MT9D113_USER_DEFINED_SERIES #include "mt9d113_user_series.c" #else /* init 800x600 SVGA */ @@ -1723,7 +1723,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -3095,6 +3094,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/mt9p111.c b/drivers/media/video/mt9p111.c index ff5682cba5cc..422896761941 100755 --- a/drivers/media/video/mt9p111.c +++ b/drivers/media/video/mt9p111.c @@ -126,7 +126,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_MT9P111_USER_DEFINED_SERIES +#ifdef CONFIG_MT9P111_USER_DEFINED_SERIES #include "mt9p111_user_series.c" #else @@ -3080,7 +3080,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -4808,6 +4807,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/mt9t111.c b/drivers/media/video/mt9t111.c index 02c27ab86816..6dffcddf6221 100755 --- a/drivers/media/video/mt9t111.c +++ b/drivers/media/video/mt9t111.c @@ -122,7 +122,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_MT9T111_USER_DEFINED_SERIES +#ifdef CONFIG_MT9T111_USER_DEFINED_SERIES #include "mt9t111_user_series.c" #else @@ -6845,7 +6845,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) { sensor->info_priv.flash = qctrl->default_value; } - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -8427,6 +8426,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/nt99250.c b/drivers/media/video/nt99250.c index 68a64ce19e79..8ba1261dca1f 100755 --- a/drivers/media/video/nt99250.c +++ b/drivers/media/video/nt99250.c @@ -109,7 +109,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_NT99250_USER_DEFINED_SERIES +#ifdef CONFIG_NT99250_USER_DEFINED_SERIES #include "NT99250_user_series.c" #else /* init 352X288 SVGA */ @@ -1590,7 +1590,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -2868,6 +2867,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/ov2640_rk.c b/drivers/media/video/ov2640_rk.c index af72cf5e581d..0229d657090d 100755 --- a/drivers/media/video/ov2640_rk.c +++ b/drivers/media/video/ov2640_rk.c @@ -99,7 +99,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_OV2640_USER_DEFINED_SERIES +#ifdef CONFIG_OV2640_USER_DEFINED_SERIES #include "ov2640_user_series.c" #else /* init 800*600 SVGA */ @@ -1775,7 +1775,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -3079,6 +3078,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/ov2655.c b/drivers/media/video/ov2655.c old mode 100644 new mode 100755 index c12a5a40c14d..f6b90b46dd3c --- a/drivers/media/video/ov2655.c +++ b/drivers/media/video/ov2655.c @@ -106,7 +106,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_OV2655_USER_DEFINED_SERIES +#ifdef CONFIG_OV2655_USER_DEFINED_SERIES #include "ov2655_user_series.c" #else @@ -1934,7 +1934,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -3239,6 +3238,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/ov2659.c b/drivers/media/video/ov2659.c index 943ffd824b1c..071f070b2404 100755 --- a/drivers/media/video/ov2659.c +++ b/drivers/media/video/ov2659.c @@ -105,7 +105,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_OV2659_USER_DEFINED_SERIES +#ifdef CONFIG_OV2659_USER_DEFINED_SERIES #include "ov2659_user_series.c" #else /* init 800*600 SVGA */ @@ -1720,7 +1720,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -3063,6 +3062,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/ov5640.c b/drivers/media/video/ov5640.c index 8bc9c96aceb9..609f56aa33fd 100755 --- a/drivers/media/video/ov5640.c +++ b/drivers/media/video/ov5640.c @@ -186,7 +186,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_OV5640_USER_DEFINED_SERIES +#ifdef CONFIG_OV5640_USER_DEFINED_SERIES #include "ov5640_user_series.c" #else @@ -2514,7 +2514,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -4040,7 +4039,7 @@ static int sensor_probe(struct i2c_client *client, mutex_init(&sensor->wq_lock); #endif } - + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/ov5642.c b/drivers/media/video/ov5642.c index 2749671bd8ad..783a7a63f7ae 100755 --- a/drivers/media/video/ov5642.c +++ b/drivers/media/video/ov5642.c @@ -172,7 +172,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_OV5642_USER_DEFINED_SERIES +#ifdef CONFIG_OV5642_USER_DEFINED_SERIES #include "ov5642_user_series.c" #else /* init 800X600 SVGA */ @@ -4463,7 +4463,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -6023,7 +6022,7 @@ static int sensor_probe(struct i2c_client *client, mutex_init(&sensor->wq_lock); #endif } - + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/ov7675.c b/drivers/media/video/ov7675.c index 9734410c9014..4c10b58ee8f4 100755 --- a/drivers/media/video/ov7675.c +++ b/drivers/media/video/ov7675.c @@ -105,7 +105,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_OV7675_USER_DEFINED_SERIES +#ifdef CONFIG_OV7675_USER_DEFINED_SERIES #include "ov7675_user_series.c" #else /* init 640X480 VGA */ @@ -1498,7 +1498,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -2768,6 +2767,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/ov7690.c b/drivers/media/video/ov7690.c index c4f567f841d1..2ef56d08c597 100755 --- a/drivers/media/video/ov7690.c +++ b/drivers/media/video/ov7690.c @@ -105,7 +105,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_OV7690_USER_DEFINED_SERIES +#ifdef CONFIG_OV7690_USER_DEFINED_SERIES #include "ov7690_user_series.c" #else @@ -1299,7 +1299,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -2545,6 +2544,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/rk30_camera_oneframe.c b/drivers/media/video/rk30_camera_oneframe.c index 5429c123cee7..172b8d48b8bd 100755 --- a/drivers/media/video/rk30_camera_oneframe.c +++ b/drivers/media/video/rk30_camera_oneframe.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -334,6 +333,8 @@ struct rk_camera_dev rk29_camera_sensor_cb_s icd_cb; struct rk_camera_frmivalinfo icd_frmival[2]; // atomic_t to_process_frames; + bool timer_get_fps; + struct videobuf_queue *video_vq; }; static const struct v4l2_queryctrl rk_camera_controls[] = @@ -356,34 +357,6 @@ static const char *rk_cam_driver_description = "RK_Camera"; static int rk_camera_s_stream(struct soc_camera_device *icd, int enable); -static void rk_cif_poweroff(struct rk_camera_dev *pcdev) -{ - struct regulator *ldo_18,*ldo_28; - ldo_28 = regulator_get(NULL, "ldo7"); // vcc28_cif - ldo_18 = regulator_get(NULL, "ldo1"); // vcc18_cif - - regulator_disable(ldo_28); - regulator_put(ldo_28); - regulator_disable(ldo_18); - regulator_put(ldo_18); - mdelay(500); -} -static void rk_cif_poweron(struct rk_camera_dev *pcdev) -{ - struct regulator *ldo_18,*ldo_28; - ldo_28 = regulator_get(NULL, "ldo7"); // vcc28_cif - ldo_18 = regulator_get(NULL, "ldo1"); // vcc18_cif - regulator_set_voltage(ldo_28, 2800000, 2800000); - regulator_enable(ldo_28); -// printk("%s set ldo7 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo)); - regulator_put(ldo_28); - - regulator_set_voltage(ldo_18, 1800000, 1800000); -// regulator_set_suspend_voltage(ldo, 1800000); - regulator_enable(ldo_18); -// printk("%s set ldo1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo)); - regulator_put(ldo_18); -} /* * Videobuf operations @@ -434,6 +407,7 @@ static int rk_videobuf_setup(struct videobuf_queue *vq, unsigned int *count, pcdev->camera_work_count = *count; } } + pcdev->video_vq = vq; RKCAMERA_DG("%s..%d.. videobuf size:%d, vipmem_buf size:%d, count:%d \n",__FUNCTION__,__LINE__, *size,pcdev->vipmem_size, *count); return 0; @@ -1794,7 +1768,11 @@ static void rk_camera_reinit_work(struct work_struct *work) struct rk_camera_work *camera_work = container_of(work, struct rk_camera_work, work); struct rk_camera_dev *pcdev = camera_work->pcdev; struct videobuf_buffer *tmp_vb; - sd = soc_camera_to_subdev(pcdev->icd); + struct soc_camera_link *tmp_soc_cam_link; + int index = 0; + unsigned long flags = 0; + sd = soc_camera_to_subdev(pcdev->icd); + tmp_soc_cam_link = to_soc_camera_link(pcdev->icd); //dump regs { RKCAMERA_DG("CIF_CIF_CTRL = 0x%x\n",read_cif_reg(pcdev->base,CIF_CIF_CTRL)); @@ -1814,19 +1792,35 @@ static void rk_camera_reinit_work(struct work_struct *work) RKCAMERA_DG("CIF_CIF_FRM0_ADDR_UV = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_FRM0_ADDR_UV)); RKCAMERA_DG("CIF_CIF_FRAME_STATUS = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_FRAME_STATUS)); } + write_cif_reg(pcdev->base,CIF_CIF_CTRL, (read_cif_reg(pcdev->base,CIF_CIF_CTRL)&(~ENABLE_CAPTURE))); + #if 0 while (!list_empty(&pcdev->capture)) { - printk("wake up video buffer!!!\n"); tmp_vb = list_entry(pcdev->capture.next, struct videobuf_buffer, queue); - if (tmp_vb && (tmp_vb->state == VIDEOBUF_QUEUED)) + if (tmp_vb/* && (tmp_vb->state == VIDEOBUF_QUEUED)*/) { - list_del_init(&(tmp_vb->queue)); + printk("wake up video buffer index = %d ,state = %d, !!!\n",tmp_vb->i,tmp_vb->state); tmp_vb->state = VIDEOBUF_ERROR; - - wake_up_all(&tmp_vb->done); + list_del_init(&(tmp_vb->queue)); + wake_up(&tmp_vb->done); } } - write_cif_reg(pcdev->base,CIF_CIF_CTRL, (read_cif_reg(pcdev->base,CIF_CIF_CTRL)&(~ENABLE_CAPTURE))); - rk_cif_poweroff(pcdev); + #else + spin_lock_irqsave(pcdev->video_vq->irqlock, flags); + for (index = 0; index < VIDEO_MAX_FRAME; index++) { + if (NULL == pcdev->video_vq->bufs[index]) + continue; + if (pcdev->video_vq->bufs[index]->state == VIDEOBUF_QUEUED) { + list_del_init(&pcdev->video_vq->bufs[index]->queue); + pcdev->video_vq->bufs[index]->state = VIDEOBUF_NEEDS_INIT; + wake_up_all(&pcdev->video_vq->bufs[index]->done); + printk("wake up video buffer index = %d !!!\n",index); + } + } + spin_unlock_irqrestore(pcdev->video_vq->irqlock, flags); + + #endif + // rk_cif_poweroff(pcdev); + tmp_soc_cam_link->power(pcdev->icd->pdev,0); if(IS_CIF0()){ // write_cru_reg(CRU_CIF_RST_REG30,(read_cru_reg(CRU_CIF_RST_REG30)|MASK_RST_CIF0|RQUEST_RST_CIF0 )); @@ -1834,7 +1828,7 @@ static void rk_camera_reinit_work(struct work_struct *work) pmu_set_idle_request(IDLE_REQ_VIO, true); cru_set_soft_reset(SOFT_RST_CIF0, true); - udelay(300); + udelay(50); cru_set_soft_reset(SOFT_RST_CIF0, false); pmu_set_idle_request(IDLE_REQ_VIO, false); @@ -1845,13 +1839,14 @@ static void rk_camera_reinit_work(struct work_struct *work) // write_cru_reg(CRU_CIF_RST_REG30,(read_cru_reg(CRU_CIF_RST_REG30)&(~RQUEST_RST_CIF1)) | MASK_RST_CIF1); pmu_set_idle_request(IDLE_REQ_VIO, true); cru_set_soft_reset(SOFT_RST_CIF1, true); - udelay(300); + udelay(50); cru_set_soft_reset(SOFT_RST_CIF1, false); pmu_set_idle_request(IDLE_REQ_VIO, false); } - rk_cif_poweron(pcdev); - + // rk_cif_poweron(pcdev); + tmp_soc_cam_link->power(pcdev->icd->pdev,1); + #if 0 control = to_soc_camera_control(pcdev->icd); sd = dev_get_drvdata(control); ret = v4l2_subdev_call(sd,core, init, 1); @@ -1864,9 +1859,7 @@ static void rk_camera_reinit_work(struct work_struct *work) ret |= v4l2_subdev_call(sd, video, s_mbus_fmt, &mf); write_cif_reg(pcdev->base,CIF_CIF_CTRL, (read_cif_reg(pcdev->base,CIF_CIF_CTRL)|ENABLE_CAPTURE)); - - - + #endif RKCAMERA_TR("Camera host haven't recevie data from sensor,Reinit sensor now! ret:0x%x\n",ret); } static enum hrtimer_restart rk_camera_fps_func(struct hrtimer *timer) @@ -1875,14 +1868,18 @@ static enum hrtimer_restart rk_camera_fps_func(struct hrtimer *timer) struct rk_camera_timer *fps_timer = container_of(timer, struct rk_camera_timer, timer); struct rk_camera_dev *pcdev = fps_timer->pcdev; int rec_flag,i; - + static unsigned int last_fps = 0; + struct soc_camera_link *tmp_soc_cam_link; + tmp_soc_cam_link = to_soc_camera_link(pcdev->icd); + RKCAMERA_DG("rk_camera_fps_func fps:0x%x\n",pcdev->fps); - if (pcdev->fps < 2) { + if ((pcdev->fps < 2) || (last_fps == pcdev->fps)) { RKCAMERA_TR("Camera host haven't recevie data from sensor,Reinit sensor delay!\n"); pcdev->camera_reinit_work.pcdev = pcdev; - INIT_WORK(&(pcdev->camera_reinit_work.work), rk_camera_reinit_work); + //INIT_WORK(&(pcdev->camera_reinit_work.work), rk_camera_reinit_work); queue_work(pcdev->camera_wq,&(pcdev->camera_reinit_work.work)); - } else { + } else if(!pcdev->timer_get_fps) { + pcdev->timer_get_fps = true; for (i=0; i<2; i++) { if (pcdev->icd == pcdev->icd_frmival[i].icd) { fival_nxt = pcdev->icd_frmival[i].fival_list; @@ -1942,8 +1939,10 @@ static enum hrtimer_restart rk_camera_fps_func(struct hrtimer *timer) } } } - - return HRTIMER_NORESTART; + last_fps = pcdev->fps ; + pcdev->fps_timer.timer.node.expires= ktime_add_us(pcdev->fps_timer.timer.node.expires, ktime_to_us(ktime_set(2, 0))); + //return HRTIMER_NORESTART; + return HRTIMER_RESTART; } static int rk_camera_s_stream(struct soc_camera_device *icd, int enable) { @@ -1959,6 +1958,7 @@ static int rk_camera_s_stream(struct soc_camera_device *icd, int enable) pcdev->fps = 0; hrtimer_cancel(&(pcdev->fps_timer.timer)); pcdev->fps_timer.pcdev = pcdev; + pcdev->timer_get_fps = false; // hrtimer_start(&(pcdev->fps_timer.timer),ktime_set(3, 0),HRTIMER_MODE_REL); cif_ctrl_val |= ENABLE_CAPTURE; write_cif_reg(pcdev->base,CIF_CIF_CTRL, cif_ctrl_val); diff --git a/drivers/media/video/s5k6aa.c b/drivers/media/video/s5k6aa.c index e8beae9d3462..a7fd2e6f1014 100755 --- a/drivers/media/video/s5k6aa.c +++ b/drivers/media/video/s5k6aa.c @@ -119,7 +119,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_S5K6AA_USER_DEFINED_SERIES +#ifdef CONFIG_S5K6AA_USER_DEFINED_SERIES #include "s5k6aa_user_series.c" #else @@ -3454,7 +3454,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; @@ -4759,6 +4758,7 @@ static int sensor_probe(struct i2c_client *client, i2c_set_clientdata(client, NULL); kfree(sensor); } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/sid130B.c b/drivers/media/video/sid130B.c index a3a9d62c4ec8..4028cf199d56 100755 --- a/drivers/media/video/sid130B.c +++ b/drivers/media/video/sid130B.c @@ -109,7 +109,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_SID130B_USER_DEFINED_SERIES +#ifdef CONFIG_SID130B_USER_DEFINED_SERIES #include "sid130B_user_series.c" #else /* init 352X288 SVGA */ @@ -1828,7 +1828,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -3127,6 +3126,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } diff --git a/drivers/media/video/siv120b.c b/drivers/media/video/siv120b.c index 854442006f2b..ea88fc90f2bc 100755 --- a/drivers/media/video/siv120b.c +++ b/drivers/media/video/siv120b.c @@ -109,7 +109,7 @@ static enum hrtimer_restart flash_off_func(struct hrtimer *timer); static struct flash_timer flash_off_timer; //for user defined if user want to customize the series , zyc -#if CONFIG_SIV120B_USER_DEFINED_SERIES +#ifdef CONFIG_SIV120B_USER_DEFINED_SERIES #include "siv120b_user_series.c" #else /* init 640X480 VGA */ @@ -1581,7 +1581,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH); if (qctrl) sensor->info_priv.flash = qctrl->default_value; - hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_off_timer.icd = icd; flash_off_timer.timer.function = flash_off_func; #endif @@ -2795,6 +2794,7 @@ static int sensor_probe(struct i2c_client *client, kfree(sensor); sensor = NULL; } + hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL); SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret); return ret; } -- 2.34.1