/** * gpufreq_get_cur_state - callback function to get the current cooling state. * @cdev: thermal cooling device pointer. * @state: fill this variable with the current cooling state. * * Callback for the thermal cooling device to return the gpufreq * current cooling state. * * Return: 0 on success, an error code otherwise. */ static int gpufreq_get_cur_state(struct thermal_cooling_device *cdev, unsigned long *state) { struct gpufreq_cooling_device *gpufreq_device = cdev->devdata; unsigned long max_state = 0, temp = 0; /* *state = gpufreq_device->gpufreq_state; */ gpufreq_get_max_state(cdev, &max_state); if (gpufreq_device->get_gpu_current_max_level) { temp = gpufreq_device->get_gpu_current_max_level(); *state = ((max_state - 1) - temp); pr_debug("current max state=%ld\n", *state); } else return -EINVAL; return 0; }
/** * gpufreq_set_cur_state - callback function to set the current cooling state. * @cdev: thermal cooling device pointer. * @state: set this variable to the current cooling state. * * Callback for the thermal cooling device to change the gpufreq * current cooling state. * * Return: 0 on success, an error code otherwise. */ static int gpufreq_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { struct gpufreq_cooling_device *gpufreq_device = cdev->devdata; unsigned long max_state; int ret; printk(KERN_DEBUG "state=%ld,gpufreq_device->gpufreq_state=%d\n",state,gpufreq_device->gpufreq_state); //if (gpufreq_device->gpufreq_state == state) //return 0; gpufreq_device->gpufreq_state = state; ret=gpufreq_get_max_state(cdev,&max_state); state=max_state-1-state; printk(KERN_DEBUG "state=%ld,gpufreq_device->gpufreq_state=%d\n",state,gpufreq_device->gpufreq_state); if(state>=0 && state<=max_state){ if (gpufreq_device->set_gpu_freq_idx) gpufreq_device->set_gpu_freq_idx((unsigned int)state); } return 0; }