controller.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2019 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <map>
  6. #include "common/common_types.h"
  7. namespace Core::Timing {
  8. class CoreTiming;
  9. }
  10. namespace Service::APM {
  11. enum class PerformanceConfiguration : u32 {
  12. Config1 = 0x00010000,
  13. Config2 = 0x00010001,
  14. Config3 = 0x00010002,
  15. Config4 = 0x00020000,
  16. Config5 = 0x00020001,
  17. Config6 = 0x00020002,
  18. Config7 = 0x00020003,
  19. Config8 = 0x00020004,
  20. Config9 = 0x00020005,
  21. Config10 = 0x00020006,
  22. Config11 = 0x92220007,
  23. Config12 = 0x92220008,
  24. Config13 = 0x92220009,
  25. Config14 = 0x9222000A,
  26. Config15 = 0x9222000B,
  27. Config16 = 0x9222000C,
  28. };
  29. enum class CpuBoostMode : u32 {
  30. Disabled = 0,
  31. Full = 1, // CPU + GPU -> Config 13, 14, 15, or 16
  32. Partial = 2, // GPU Only -> Config 15 or 16
  33. };
  34. enum class PerformanceMode : u8 {
  35. Handheld = 0,
  36. Docked = 1,
  37. };
  38. // Class to manage the state and change of the emulated system performance.
  39. // Specifically, this deals with PerformanceMode, which corresponds to the system being docked or
  40. // undocked, and PerformanceConfig which specifies the exact CPU, GPU, and Memory clocks to operate
  41. // at. Additionally, this manages 'Boost Mode', which allows games to temporarily overclock the
  42. // system during times of high load -- this simply maps to different PerformanceConfigs to use.
  43. class Controller {
  44. public:
  45. explicit Controller(Core::Timing::CoreTiming& core_timing);
  46. ~Controller();
  47. void SetPerformanceConfiguration(PerformanceMode mode, PerformanceConfiguration config);
  48. void SetFromCpuBoostMode(CpuBoostMode mode);
  49. PerformanceMode GetCurrentPerformanceMode();
  50. PerformanceConfiguration GetCurrentPerformanceConfiguration(PerformanceMode mode);
  51. private:
  52. void SetClockSpeed(u32 mhz);
  53. [[maybe_unused]] Core::Timing::CoreTiming& core_timing;
  54. std::map<PerformanceMode, PerformanceConfiguration> configs;
  55. };
  56. } // namespace Service::APM