SessionServer.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Ryujinx.Common.Logging;
  2. namespace Ryujinx.HLE.HOS.Services.Apm
  3. {
  4. class SessionServer : ISession
  5. {
  6. private readonly ServiceCtx _context;
  7. public SessionServer(ServiceCtx context) : base(context)
  8. {
  9. _context = context;
  10. }
  11. protected override ResultCode SetPerformanceConfiguration(PerformanceMode performanceMode, PerformanceConfiguration performanceConfiguration)
  12. {
  13. if (performanceMode > PerformanceMode.Boost)
  14. {
  15. return ResultCode.InvalidParameters;
  16. }
  17. switch (performanceMode)
  18. {
  19. case PerformanceMode.Default:
  20. _context.Device.System.PerformanceState.DefaultPerformanceConfiguration = performanceConfiguration;
  21. break;
  22. case PerformanceMode.Boost:
  23. _context.Device.System.PerformanceState.BoostPerformanceConfiguration = performanceConfiguration;
  24. break;
  25. default:
  26. Logger.Error?.Print(LogClass.ServiceApm, $"PerformanceMode isn't supported: {performanceMode}");
  27. break;
  28. }
  29. return ResultCode.Success;
  30. }
  31. protected override ResultCode GetPerformanceConfiguration(PerformanceMode performanceMode, out PerformanceConfiguration performanceConfiguration)
  32. {
  33. if (performanceMode > PerformanceMode.Boost)
  34. {
  35. performanceConfiguration = 0;
  36. return ResultCode.InvalidParameters;
  37. }
  38. performanceConfiguration = _context.Device.System.PerformanceState.GetCurrentPerformanceConfiguration(performanceMode);
  39. return ResultCode.Success;
  40. }
  41. protected override void SetCpuOverclockEnabled(bool enabled)
  42. {
  43. _context.Device.System.PerformanceState.CpuOverclockEnabled = enabled;
  44. // NOTE: This call seems to overclock the system, since we emulate it, it's fine to do nothing instead.
  45. }
  46. }
  47. }