Commit 1c71bda0 authored by Alex Deucher's avatar Alex Deucher

drm/radeon/dpm: add infrastructure to properly handle bapm

bapm is a pm feature for sharing the power budget between
the GPU and the CPU on APUs.  It needs to be enabled or
disabled in certain circumstances.  For now, disable it
when on battery and enable it when on AC power.
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 64d03221
...@@ -1778,6 +1778,7 @@ struct radeon_asic { ...@@ -1778,6 +1778,7 @@ struct radeon_asic {
int (*force_performance_level)(struct radeon_device *rdev, enum radeon_dpm_forced_level level); int (*force_performance_level)(struct radeon_device *rdev, enum radeon_dpm_forced_level level);
bool (*vblank_too_short)(struct radeon_device *rdev); bool (*vblank_too_short)(struct radeon_device *rdev);
void (*powergate_uvd)(struct radeon_device *rdev, bool gate); void (*powergate_uvd)(struct radeon_device *rdev, bool gate);
void (*enable_bapm)(struct radeon_device *rdev, bool enable);
} dpm; } dpm;
/* pageflipping */ /* pageflipping */
struct { struct {
...@@ -2647,6 +2648,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v); ...@@ -2647,6 +2648,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
#define radeon_dpm_force_performance_level(rdev, l) rdev->asic->dpm.force_performance_level((rdev), (l)) #define radeon_dpm_force_performance_level(rdev, l) rdev->asic->dpm.force_performance_level((rdev), (l))
#define radeon_dpm_vblank_too_short(rdev) rdev->asic->dpm.vblank_too_short((rdev)) #define radeon_dpm_vblank_too_short(rdev) rdev->asic->dpm.vblank_too_short((rdev))
#define radeon_dpm_powergate_uvd(rdev, g) rdev->asic->dpm.powergate_uvd((rdev), (g)) #define radeon_dpm_powergate_uvd(rdev, g) rdev->asic->dpm.powergate_uvd((rdev), (g))
#define radeon_dpm_enable_bapm(rdev, e) rdev->asic->dpm.enable_bapm((rdev), (e))
/* Common functions */ /* Common functions */
/* AGP */ /* AGP */
......
...@@ -67,7 +67,16 @@ int radeon_pm_get_type_index(struct radeon_device *rdev, ...@@ -67,7 +67,16 @@ int radeon_pm_get_type_index(struct radeon_device *rdev,
void radeon_pm_acpi_event_handler(struct radeon_device *rdev) void radeon_pm_acpi_event_handler(struct radeon_device *rdev)
{ {
if (rdev->pm.pm_method == PM_METHOD_PROFILE) { if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled) {
mutex_lock(&rdev->pm.mutex);
if (power_supply_is_system_supplied() > 0)
rdev->pm.dpm.ac_power = true;
else
rdev->pm.dpm.ac_power = false;
if (rdev->asic->dpm.enable_bapm)
radeon_dpm_enable_bapm(rdev, rdev->pm.dpm.ac_power);
mutex_unlock(&rdev->pm.mutex);
} else if (rdev->pm.pm_method == PM_METHOD_PROFILE) {
if (rdev->pm.profile == PM_PROFILE_AUTO) { if (rdev->pm.profile == PM_PROFILE_AUTO) {
mutex_lock(&rdev->pm.mutex); mutex_lock(&rdev->pm.mutex);
radeon_pm_update_profile(rdev); radeon_pm_update_profile(rdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment