rockchip:midgard : update gpu dvfs & use new comment
authorxxm <xxm@rock-chips.com>
Sun, 4 May 2014 06:35:54 +0000 (14:35 +0800)
committerxxm <xxm@rock-chips.com>
Sun, 4 May 2014 06:36:19 +0000 (14:36 +0800)
drivers/gpu/arm/midgard/mali_kbase_core_linux.c
drivers/gpu/arm/midgard/platform/rk/mali_kbase_dvfs.c
drivers/gpu/arm/midgard/platform/rk/mali_kbase_platform.c
drivers/video/rockchip/rk_fb.c
include/linux/rk_fb.h

index 8c75f4bebfd78aacef39dbd6cb04507e11c10a88..1798c8a475df98aa7c737cd2cff2d04e2217865f 100755 (executable)
@@ -2609,8 +2609,9 @@ static int kbase_platform_device_probe(struct platform_device *pdev)
        kbase_platform_config *config;
        int attribute_count;
 
-//#ifdef CONFIG_MALI_PLATFORM_FAKE
-#if 1//defined(CONFIG_MALI_PLATFORM_FAKE) || defined(CONFIG_MALI_PLATFORM_FAKE_MODULE)
+/*#ifdef CONFIG_MALI_PLATFORM_FAKE*/
+#if 1
+/*defined(CONFIG_MALI_PLATFORM_FAKE) || defined(CONFIG_MALI_PLATFORM_FAKE_MODULE)*/
        config = kbase_get_platform_config();
        attribute_count = kbasep_get_config_attribute_count(config->attributes);
 
index 64615e302858289dbe5121b0d46b54c6594f1707..5e6c62926b4464b402ee36786a6594dcc727c58c 100755 (executable)
@@ -109,7 +109,7 @@ static void mali_dvfs_event_proc(struct work_struct *w)
        }
        platform = (struct rk_context *)dvfs_status->kbdev->platform_context;
        
-       fps = rk_get_real_fps();
+       fps = rk_get_real_fps(0);
 
        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) && (fps < LIMIT_FPS)) 
index 6abcd2ccd4b63a892d49e58031a0372e4c085af5..bf4a650c2c717cbd41481b8c42440d89bf5c23c9 100755 (executable)
@@ -66,7 +66,7 @@ int mali_dvfs_clk_set(struct dvfs_node *node,unsigned long rate)
 }
 static int kbase_platform_power_clock_init(kbase_device *kbdev)
 {
-       //struct device *dev = kbdev->dev;
+       /*struct device *dev = kbdev->dev;*/
        struct rk_context *platform;
 
        platform = (struct rk_context *)kbdev->platform_context;
@@ -613,11 +613,11 @@ static ssize_t set_dvfs(struct device *dev, struct device_attribute *attr, const
 #ifdef CONFIG_MALI_MIDGARD_DVFS
        platform = (struct rk_context *)kbdev->platform_context;
        if (sysfs_streq("off", buf)) {
-               //kbase_platform_dvfs_enable(false, MALI_DVFS_BL_CONFIG_FREQ);
+               /*kbase_platform_dvfs_enable(false, MALI_DVFS_BL_CONFIG_FREQ);*/
                kbase_platform_dvfs_enable(false, p_mali_dvfs_infotbl[MALI_DVFS_STEP-1].clock); 
                platform->dvfs_enabled = false;
        } else if (sysfs_streq("on", buf)) {
-               //kbase_platform_dvfs_enable(true, MALI_DVFS_START_FREQ);
+               /*kbase_platform_dvfs_enable(true, MALI_DVFS_START_FREQ);*/
                kbase_platform_dvfs_enable(true, p_mali_dvfs_infotbl[0].clock);
                platform->dvfs_enabled = true;
        } else {
@@ -649,7 +649,7 @@ static ssize_t show_upper_lock_dvfs(struct device *dev, struct device_attribute
                ret += snprintf(buf + ret, PAGE_SIZE - ret, "Current Upper Lock Level = %dMhz", locked_level);
        else
                ret += snprintf(buf + ret, PAGE_SIZE - ret, "Unset the Upper Lock Level");
-       //ret += snprintf(buf + ret, PAGE_SIZE - ret, "\nPossible settings : 400, 350,266, 160, 100, If you want to unlock : 600 or off");
+       /*ret += snprintf(buf + ret, PAGE_SIZE - ret, "\nPossible settings : 400, 350,266, 160, 100, If you want to unlock : 600 or off");*/
        ret += snprintf(buf + ret, PAGE_SIZE - ret, "\nPossible settings :");
        for(i=0;i<MALI_DVFS_STEP;i++)
                ret += snprintf(buf + ret, PAGE_SIZE - ret, "%d ",p_mali_dvfs_infotbl[i].clock/1000);
@@ -732,7 +732,7 @@ static ssize_t show_under_lock_dvfs(struct device *dev, struct device_attribute
                ret += snprintf(buf + ret, PAGE_SIZE - ret, "Current Under Lock Level = %dMhz", locked_level);
        else
                ret += snprintf(buf + ret, PAGE_SIZE - ret, "Unset the Under Lock Level");
-       //ret += snprintf(buf + ret, PAGE_SIZE - ret, "\nPossible settings : 600, 400, 350,266, 160, If you want to unlock : 100 or off");
+       /*ret += snprintf(buf + ret, PAGE_SIZE - ret, "\nPossible settings : 600, 400, 350,266, 160, If you want to unlock : 100 or off");*/
        ret += snprintf(buf + ret, PAGE_SIZE - ret, "\nPossible settings :");
        for(i=0;i<MALI_DVFS_STEP;i++)
                ret += snprintf(buf + ret, PAGE_SIZE - ret, "%d ",p_mali_dvfs_infotbl[i].clock/1000);
index d0cc4582400d0870957583e639ac71c26910e72b..9aff1558fa03233daf4aedc808f455b5df77285e 100755 (executable)
@@ -1618,22 +1618,67 @@ 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(void)
+
+#if 1
+static int cfgdone_distlist[10] = {0};
+static int cfgdone_index = 0;
+static int cfgdone_lasttime = 0;
+
+int rk_get_real_fps(int before)
 {
+    if(before > 100)      before = 100;
+    if(before < 0)        before = 0;
+
     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;
-       if(!interval_ms)
-               return 60;/*keep cpu clock*/
-       else
-               return 1000 / interval_ms;
+    int dist_curr = (now.tv_sec * 1000000 + now.tv_nsec/1000) - cfgdone_lasttime;
+    int dist_total = 0;
+    int dist_count = 0;
+    int dist_first = 0;
+
+    int index = cfgdone_index;
+    int i = 0, fps = 0;
+    int total = dist_curr;
+
+    /*
+       printk("fps: ");
+       */
+    for(i=0; i<10; i++) {
+        if(--index < 0)   index = 9;
+        total += cfgdone_distlist[index];
+        if(i==0)    dist_first = cfgdone_distlist[index];
+        if(total < (before*1000)) {
+            /*
+               printk("[%d:%d] ", dist_count, cfgdone_distlist[index]);
+               */
+            dist_total += cfgdone_distlist[index];
+            dist_count ++;
+        } else {
+            break;
+        }  
+    }
+
+    /*
+       printk("total %d, count %d, curr %d, ", dist_total, dist_count, dist_curr);
+       */
+    dist_curr = (dist_curr > dist_first) ? dist_curr : dist_first;
+    dist_total += dist_curr;
+    dist_count ++;
+
+    if(dist_total > 0)
+        fps = (1000000 * dist_count) / dist_total;
+    else
+        fps = 60;
+
+    /*
+       printk("curr2 %d, fps=%d\n", dist_curr, fps);
+       */
+    return fps;
 }
 EXPORT_SYMBOL(rk_get_real_fps);
 
+#endif
+
 static int rk_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
 {
        struct rk_fb *rk_fb = dev_get_drvdata(info->device);
@@ -1746,12 +1791,17 @@ 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;
+            int curr = 0;
+            struct timespec now;
+
+            getnstimeofday(&now);
+            curr = now.tv_sec * 1000000 + now.tv_nsec/1000;
+            cfgdone_distlist[cfgdone_index++] = curr - cfgdone_lasttime;
+            /*
+               printk("%d ", curr - cfgdone_lasttime);
+               */
+            cfgdone_lasttime = curr;
+            if(cfgdone_index>=10)   cfgdone_index = 0;
                }
                if(copy_from_user(&win_data,
                        (struct rk_fb_win_cfg_data __user *)argp,
index 235e41f3aaf12c8e47daa612534188182208f56b..a0d9cfb5a09e0e4db807c1dff9582a76a47190e5 100755 (executable)
@@ -575,5 +575,5 @@ extern int rkfb_create_sysfs(struct fb_info *fbi);
 extern char *get_format_string(enum data_format, char *fmt);
 extern int support_uboot_display(void);
 extern int  rk_fb_calc_fps(struct rk_screen * screen, u32 pixclock);
-extern int rk_get_real_fps(void);
+extern int rk_get_real_fps(int time);
 #endif