/* * Copyright 2015 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *
*/
ret = hwmgr->hwmgr_func->backend_init(hwmgr); if (ret) goto err1; /* make sure dc limits are valid */ if ((hwmgr->dyn_state.max_clock_voltage_on_dc.sclk == 0) ||
(hwmgr->dyn_state.max_clock_voltage_on_dc.mclk == 0))
hwmgr->dyn_state.max_clock_voltage_on_dc =
hwmgr->dyn_state.max_clock_voltage_on_ac;
ret = psm_init_power_state_table(hwmgr); if (ret) goto err2;
ret = phm_setup_asic(hwmgr); if (ret) goto err2;
ret = phm_enable_dynamic_state_management(hwmgr); if (ret) goto err2;
ret = phm_start_thermal_controller(hwmgr);
ret |= psm_set_performance_states(hwmgr); if (ret) goto err2;
if (hwmgr->hwmgr_func->backend_fini)
hwmgr->hwmgr_func->backend_fini(hwmgr); if (hwmgr->pptable_func->pptable_fini)
hwmgr->pptable_func->pptable_fini(hwmgr); return psm_fini_power_state_table(hwmgr);
}
int hwmgr_suspend(struct pp_hwmgr *hwmgr)
{ int ret = 0;
if (!hwmgr || !hwmgr->pm_en || !hwmgr->not_vf) return 0;
phm_disable_smc_firmware_ctf(hwmgr);
ret = psm_set_boot_states(hwmgr); if (ret) return ret;
ret = psm_adjust_power_state_dynamic(hwmgr, true, NULL); if (ret) return ret;
ret = phm_power_down_asic(hwmgr);
return ret;
}
int hwmgr_resume(struct pp_hwmgr *hwmgr)
{ int ret = 0;
if (!hwmgr) return -EINVAL;
if (!hwmgr->not_vf || !hwmgr->pm_en) return 0;
ret = phm_setup_asic(hwmgr); if (ret) return ret;
ret = phm_enable_dynamic_state_management(hwmgr); if (ret) return ret;
ret = phm_start_thermal_controller(hwmgr);
ret |= psm_set_performance_states(hwmgr); if (ret) return ret;
ret = psm_adjust_power_state_dynamic(hwmgr, false, NULL);
return ret;
}
staticenum PP_StateUILabel power_state_convert(enum amd_pm_state_type state)
{ switch (state) { case POWER_STATE_TYPE_BATTERY: return PP_StateUILabel_Battery; case POWER_STATE_TYPE_BALANCED: return PP_StateUILabel_Balanced; case POWER_STATE_TYPE_PERFORMANCE: return PP_StateUILabel_Performance; default: return PP_StateUILabel_None;
}
}
int hwmgr_handle_task(struct pp_hwmgr *hwmgr, enum amd_pp_task task_id, enum amd_pm_state_type *user_state)
{ int ret = 0;
if (hwmgr == NULL) return -EINVAL;
switch (task_id) { case AMD_PP_TASK_DISPLAY_CONFIG_CHANGE: if (!hwmgr->not_vf) return ret;
ret = phm_pre_display_configuration_changed(hwmgr); if (ret) return ret;
ret = phm_set_cpu_power_state(hwmgr); if (ret) return ret;
ret = psm_set_performance_states(hwmgr); if (ret) return ret;
ret = psm_adjust_power_state_dynamic(hwmgr, false, NULL); break; case AMD_PP_TASK_ENABLE_USER_STATE:
{ enum PP_StateUILabel requested_ui_label; struct pp_power_state *requested_ps = NULL;
if (!hwmgr->not_vf) return ret; if (user_state == NULL) {
ret = -EINVAL; break;
}
requested_ui_label = power_state_convert(*user_state);
ret = psm_set_user_performance_state(hwmgr, requested_ui_label, &requested_ps); if (ret) return ret;
ret = psm_adjust_power_state_dynamic(hwmgr, true, requested_ps); break;
} case AMD_PP_TASK_COMPLETE_INIT: case AMD_PP_TASK_READJUST_POWER_STATE:
ret = psm_adjust_power_state_dynamic(hwmgr, true, NULL); break; default: break;
} return ret;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.