audctl.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "common/logging/log.h"
  4. #include "core/hle/ipc_helpers.h"
  5. #include "core/hle/service/audio/audctl.h"
  6. namespace Service::Audio {
  7. AudCtl::AudCtl(Core::System& system_) : ServiceFramework{system_, "audctl"} {
  8. // clang-format off
  9. static const FunctionInfo functions[] = {
  10. {0, nullptr, "GetTargetVolume"},
  11. {1, nullptr, "SetTargetVolume"},
  12. {2, &AudCtl::GetTargetVolumeMin, "GetTargetVolumeMin"},
  13. {3, &AudCtl::GetTargetVolumeMax, "GetTargetVolumeMax"},
  14. {4, nullptr, "IsTargetMute"},
  15. {5, nullptr, "SetTargetMute"},
  16. {6, nullptr, "IsTargetConnected"},
  17. {7, nullptr, "SetDefaultTarget"},
  18. {8, nullptr, "GetDefaultTarget"},
  19. {9, nullptr, "GetAudioOutputMode"},
  20. {10, nullptr, "SetAudioOutputMode"},
  21. {11, nullptr, "SetForceMutePolicy"},
  22. {12, nullptr, "GetForceMutePolicy"},
  23. {13, nullptr, "GetOutputModeSetting"},
  24. {14, nullptr, "SetOutputModeSetting"},
  25. {15, nullptr, "SetOutputTarget"},
  26. {16, nullptr, "SetInputTargetForceEnabled"},
  27. {17, nullptr, "SetHeadphoneOutputLevelMode"},
  28. {18, nullptr, "GetHeadphoneOutputLevelMode"},
  29. {19, nullptr, "AcquireAudioVolumeUpdateEventForPlayReport"},
  30. {20, nullptr, "AcquireAudioOutputDeviceUpdateEventForPlayReport"},
  31. {21, nullptr, "GetAudioOutputTargetForPlayReport"},
  32. {22, nullptr, "NotifyHeadphoneVolumeWarningDisplayedEvent"},
  33. {23, nullptr, "SetSystemOutputMasterVolume"},
  34. {24, nullptr, "GetSystemOutputMasterVolume"},
  35. {25, nullptr, "GetAudioVolumeDataForPlayReport"},
  36. {26, nullptr, "UpdateHeadphoneSettings"},
  37. {27, nullptr, "SetVolumeMappingTableForDev"},
  38. {28, nullptr, "GetAudioOutputChannelCountForPlayReport"},
  39. {29, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"},
  40. {30, nullptr, "SetSpeakerAutoMuteEnabled"},
  41. {31, nullptr, "IsSpeakerAutoMuteEnabled"},
  42. {32, nullptr, "GetActiveOutputTarget"},
  43. {33, nullptr, "GetTargetDeviceInfo"},
  44. {34, nullptr, "AcquireTargetNotification"},
  45. {35, nullptr, "SetHearingProtectionSafeguardTimerRemainingTimeForDebug"},
  46. {36, nullptr, "GetHearingProtectionSafeguardTimerRemainingTimeForDebug"},
  47. {37, nullptr, "SetHearingProtectionSafeguardEnabled"},
  48. {38, nullptr, "IsHearingProtectionSafeguardEnabled"},
  49. {39, nullptr, "IsHearingProtectionSafeguardMonitoringOutputForDebug"},
  50. {40, nullptr, "GetSystemInformationForDebug"},
  51. {41, nullptr, "SetVolumeButtonLongPressTime"},
  52. {42, nullptr, "SetNativeVolumeForDebug"},
  53. {10000, nullptr, "NotifyAudioOutputTargetForPlayReport"},
  54. {10001, nullptr, "NotifyAudioOutputChannelCountForPlayReport"},
  55. {10002, nullptr, "NotifyUnsupportedUsbOutputDeviceAttachedForPlayReport"},
  56. {10100, nullptr, "GetAudioVolumeDataForPlayReport"},
  57. {10101, nullptr, "BindAudioVolumeUpdateEventForPlayReport"},
  58. {10102, nullptr, "BindAudioOutputTargetUpdateEventForPlayReport"},
  59. {10103, nullptr, "GetAudioOutputTargetForPlayReport"},
  60. {10104, nullptr, "GetAudioOutputChannelCountForPlayReport"},
  61. {10105, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"},
  62. {10106, nullptr, "GetDefaultAudioOutputTargetForPlayReport"},
  63. {50000, nullptr, "SetAnalogInputBoostGainForPrototyping"},
  64. };
  65. // clang-format on
  66. RegisterHandlers(functions);
  67. }
  68. AudCtl::~AudCtl() = default;
  69. void AudCtl::GetTargetVolumeMin(Kernel::HLERequestContext& ctx) {
  70. LOG_DEBUG(Audio, "called.");
  71. // This service function is currently hardcoded on the
  72. // actual console to this value (as of 8.0.0).
  73. constexpr s32 target_min_volume = 0;
  74. IPC::ResponseBuilder rb{ctx, 3};
  75. rb.Push(ResultSuccess);
  76. rb.Push(target_min_volume);
  77. }
  78. void AudCtl::GetTargetVolumeMax(Kernel::HLERequestContext& ctx) {
  79. LOG_DEBUG(Audio, "called.");
  80. // This service function is currently hardcoded on the
  81. // actual console to this value (as of 8.0.0).
  82. constexpr s32 target_max_volume = 15;
  83. IPC::ResponseBuilder rb{ctx, 3};
  84. rb.Push(ResultSuccess);
  85. rb.Push(target_max_volume);
  86. }
  87. } // namespace Service::Audio