int mtk_thermal_get_gpu_info(
    int *nocores,
    int **gpufreq,
    int **gpuloading)
{
    //******************
    // GPU Index
    //******************
    THRML_LOG("[mtk_thermal_get_gpu_info] \n");

    if (nocores)
        *nocores = NO_GPU_CORES;

    if (gpufreq)
    {
        gpufreqs[0] = mt_gpufreq_get_cur_freq()/1000; // MHz
        *gpufreq = gpufreqs;
    }

    if (gpuloading)
    {
        unsigned int rd_gpu_loading = 0;
        if (mtk_get_gpu_loading(&rd_gpu_loading))
        {
            gpuloadings[0] = (int) rd_gpu_loading;
            *gpuloading = gpuloadings;
        }

    }

    return 0;
}
Пример #2
0
int mtk_thermal_get_gpu_info(
    int *nocores,
    int **gpufreq,
    int **gpuloading)
{
    //******************
    // GPU Index
    //******************
#if defined(CONFIG_ARCH_MT6582)
    if (nocores)
        *nocores = NO_GPU_CORES;

    if (gpufreq)
    {
        //gpufreqs[0] = mt_gpufreq_cur_freq()/1000; // the return value is KHz
        gpufreqs[0] = 500; // 500MHz
        *gpufreq = gpufreqs;
    }

#if 0
    if (gpuloading && (NULL != mtk_thermal_get_gpu_loading_fp))
    {
        gpuloadings[0] = (int) mtk_thermal_get_gpu_loading_fp();
        *gpuloading = gpuloadings;
    }
#else
    if (gpuloading)
    {
        unsigned int rd_gpu_loading = 0;
        if (mtk_get_gpu_loading(&rd_gpu_loading))
        {
            gpuloadings[0] = (int) rd_gpu_loading;
            *gpuloading = gpuloadings;
        }
    }
#endif
    

    return 0;

#else
    return -1;
#endif
}
static void mmdvfs_timer_callback(unsigned long data)
{
	mmdvfs_gpu_monitor_struct *gpu_monitor = (mmdvfs_gpu_monitor_struct *)data;
	
	unsigned int gpu_loading = 0;

	if (mtk_get_gpu_loading(&gpu_loading)) {
		// MMDVFSMSG("gpuload %d %ld\n", gpu_loading, jiffies_to_msecs(jiffies));
	}

	/* store gpu loading into the array */
	gpu_monitor->gpu_loadings[gpu_monitor->gpu_loading_index++] = gpu_loading;

	/* fire another timer until the end */
	if (gpu_monitor->gpu_loading_index < MMDVFS_GPU_LOADING_NUM - 1)
	{
		mod_timer(&gpu_monitor->timer, jiffies + msecs_to_jiffies(MMDVFS_GPU_LOADING_SAMPLE_DURATION_IN_MS));
	} else {
		/* the final timer */
		int i;
		int avg_loading;
		unsigned int sum = 0;

		for (i = MMDVFS_GPU_LOADING_START_INDEX; i < MMDVFS_GPU_LOADING_NUM; i++)
		{
			sum += gpu_monitor->gpu_loadings[i];
		}

		avg_loading = sum / MMDVFS_GPU_LOADING_NUM;

		MMDVFSMSG("gpuload %d AVG %d\n", jiffies_to_msecs(jiffies), avg_loading);

		/* drops to low step if the gpu loading is low */
		if (avg_loading <= MMDVFS_GPU_LOADING_THRESHOLD) {
			queue_work(gpu_monitor->work_queue, &gpu_monitor->work);
		}
	}
	
}
static int adp_fps_set_cur_state(struct thermal_cooling_device *cdev,
				unsigned long state)
{
	int gpu_loading;

	if ((state != 0) && (state != 1)) {
		mtk_cooler_fps_dprintk("[%s] invalid input (0: no thro; 1: adp fps thro on)\n", __func__);
		return 0;
	}

	mtk_cooler_fps_dprintk("[%s] %s %lu\n", __func__, cdev->type, state);
	cl_adp_fps_state = state;

	/* check the fps update from display */
	fps_update();

	set_sma_val(fps_history, fps_sma_len, &fps_history_idx, tm_input_fps);
	set_sma_val(tpcb_history, tpcb_sma_len, &tpcb_history_idx,
			mtk_thermal_get_temp(MTK_THERMAL_SENSOR_AP));

	if (!mtk_get_gpu_loading(&gpu_loading))
		gpu_loading = 0;

	set_sma_val(gpu_loading_history, gpu_loading_sma_len, &gpu_loading_history_idx,
			gpu_loading);
	/* 1. update the parameter of "cl_adp_fps_limit" */
	/* do we already leave game? */
	if (!in_consistent_scene())
		unlimit_fps_limit();

	cl_adp_fps_limit = adp_calc_fps_limit();

	/* 2. set the the limit */
	mtk_cl_fps_set_fps_limit();

	return 0;
}