From: Cody Xie Date: Mon, 28 Apr 2014 01:43:46 +0000 (+0800) Subject: rockchip midgard: 1. calculate fps in rk_fb; 2. limit fps to 60 for saving power X-Git-Tag: firefly_0821_release~5425 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f2c8edd96512967339fd34088b0daad55163cd10;p=firefly-linux-kernel-4.4.55.git rockchip midgard: 1. calculate fps in rk_fb; 2. limit fps to 60 for saving power --- diff --git a/drivers/gpu/arm/midgard/platform/rk/mali_kbase_dvfs.c b/drivers/gpu/arm/midgard/platform/rk/mali_kbase_dvfs.c index 5f06b76d6fe1..5e09f8a75200 100755 --- a/drivers/gpu/arm/midgard/platform/rk/mali_kbase_dvfs.c +++ b/drivers/gpu/arm/midgard/platform/rk/mali_kbase_dvfs.c @@ -87,7 +87,8 @@ static void update_time_in_state(int level); #endif /*dvfs status*/ static mali_dvfs_status mali_dvfs_status_current; - +extern int rk_get_real_fps(void); +#define limit_fps 60 static void mali_dvfs_event_proc(struct work_struct *w) { unsigned long flags; @@ -95,7 +96,7 @@ static void mali_dvfs_event_proc(struct work_struct *w) static int level_down_time = 0; static int level_up_time = 0; struct rk_context *platform; - + u32 fps=0; mutex_lock(&mali_enable_clock_lock); dvfs_status = &mali_dvfs_status_current; @@ -105,19 +106,21 @@ static void mali_dvfs_event_proc(struct work_struct *w) } platform = (struct rk_context *)dvfs_status->kbdev->platform_context; + fps = rk_get_real_fps(); + spin_lock_irqsave(&mali_dvfs_spinlock, flags); - if ((dvfs_status->utilisation > mali_dvfs_infotbl[dvfs_status->step].max_threshold) && (dvfs_status->step < MALI_DVFS_STEP-1)) + if ((dvfs_status->utilisation > mali_dvfs_infotbl[dvfs_status->step].max_threshold) && (dvfs_status->step < MALI_DVFS_STEP-1) && (fps < limit_fps)) { level_up_time++; if(level_up_time == MALI_DVFS_TIME_INTERVAL) { /* - printk("up,utilisation=%d,current clock=%d,",dvfs_status->utilisation,mali_dvfs_infotbl[dvfs_status->step].clock); + printk("up,utilisation=%d,current clock=%d,fps = %d",dvfs_status->utilisation,mali_dvfs_infotbl[dvfs_status->step].clock,fps); */ dvfs_status->step++; level_up_time = 0; /* - printk("next clock=%d\n",mali_dvfs_infotbl[dvfs_status->step].clock); + printk(" next clock=%d\n",mali_dvfs_infotbl[dvfs_status->step].clock); */ BUG_ON(dvfs_status->step >= MALI_DVFS_STEP); } @@ -131,7 +134,7 @@ static void mali_dvfs_event_proc(struct work_struct *w) if(level_down_time==MALI_DVFS_TIME_INTERVAL) { /* - printk("down,utilisation=%d,current clock=%d,",dvfs_status->utilisation,mali_dvfs_infotbl[dvfs_status->step].clock); + printk("down,utilisation=%d,current clock=%d,fps = %d",dvfs_status->utilisation,mali_dvfs_infotbl[dvfs_status->step].clock,fps); */ BUG_ON(dvfs_status->step <= 0); dvfs_status->step--; @@ -147,8 +150,8 @@ static void mali_dvfs_event_proc(struct work_struct *w) level_down_time = 0; level_up_time = 0; /* - printk("keep,utilisation=%d,current clock=%d\n",dvfs_status->utilisation,mali_dvfs_infotbl[dvfs_status->step].clock); - */ + printk("keep,utilisation=%d,current clock=%d,fps = %d\n",dvfs_status->utilisation,mali_dvfs_infotbl[dvfs_status->step].clock,fps); + */ } #ifdef CONFIG_MALI_MIDGARD_FREQ_LOCK if ((dvfs_status->upper_lock >= 0) && (dvfs_status->step > dvfs_status->upper_lock)) diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index 34c351c74d32..1e49675bb26e 100755 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -1618,6 +1618,18 @@ err: mutex_unlock(&dev_drv->output_lock); return ret; } +static int cfgdone_last_time_ms = 0; +static int cfgdone_interval_ms = 0; +int rk_get_real_fps() +{ + struct timespec now; + int interval_ms = 0; + getnstimeofday(&now); + interval_ms = (now.tv_sec *1000 + now.tv_nsec/1000000) - cfgdone_last_time_ms; + interval_ms = (interval_ms > cfgdone_interval_ms) ? interval_ms : cfgdone_interval_ms; + return 1000 / interval_ms; +} +EXPORT_SYMBOL(rk_get_real_fps); static int rk_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) { @@ -1730,6 +1742,14 @@ static int rk_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg } #endif case RK_FBIOSET_CONFIG_DONE: + { + struct timespec now; + int curr_time_ms = 0; + getnstimeofday(&now); + curr_time_ms = now.tv_sec *1000 + now.tv_nsec/1000000; + cfgdone_interval_ms = curr_time_ms - cfgdone_last_time_ms; + cfgdone_last_time_ms = curr_time_ms; + } if(copy_from_user(&win_data, (struct rk_fb_win_cfg_data __user *)argp, sizeof(win_data))){