btdrv.cpp 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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/core.h"
  5. #include "core/hle/ipc_helpers.h"
  6. #include "core/hle/kernel/k_event.h"
  7. #include "core/hle/service/btdrv/btdrv.h"
  8. #include "core/hle/service/kernel_helpers.h"
  9. #include "core/hle/service/service.h"
  10. #include "core/hle/service/sm/sm.h"
  11. namespace Service::BtDrv {
  12. class Bt final : public ServiceFramework<Bt> {
  13. public:
  14. explicit Bt(Core::System& system_)
  15. : ServiceFramework{system_, "bt"}, service_context{system_, "bt"} {
  16. // clang-format off
  17. static const FunctionInfo functions[] = {
  18. {0, nullptr, "LeClientReadCharacteristic"},
  19. {1, nullptr, "LeClientReadDescriptor"},
  20. {2, nullptr, "LeClientWriteCharacteristic"},
  21. {3, nullptr, "LeClientWriteDescriptor"},
  22. {4, nullptr, "LeClientRegisterNotification"},
  23. {5, nullptr, "LeClientDeregisterNotification"},
  24. {6, nullptr, "SetLeResponse"},
  25. {7, nullptr, "LeSendIndication"},
  26. {8, nullptr, "GetLeEventInfo"},
  27. {9, &Bt::RegisterBleEvent, "RegisterBleEvent"},
  28. };
  29. // clang-format on
  30. RegisterHandlers(functions);
  31. register_event = service_context.CreateEvent("BT:RegisterEvent");
  32. }
  33. ~Bt() override {
  34. service_context.CloseEvent(register_event);
  35. }
  36. private:
  37. void RegisterBleEvent(Kernel::HLERequestContext& ctx) {
  38. LOG_WARNING(Service_BTM, "(STUBBED) called");
  39. IPC::ResponseBuilder rb{ctx, 2, 1};
  40. rb.Push(ResultSuccess);
  41. rb.PushCopyObjects(register_event->GetReadableEvent());
  42. }
  43. KernelHelpers::ServiceContext service_context;
  44. Kernel::KEvent* register_event;
  45. };
  46. class BtDrv final : public ServiceFramework<BtDrv> {
  47. public:
  48. explicit BtDrv(Core::System& system_) : ServiceFramework{system_, "btdrv"} {
  49. // clang-format off
  50. static const FunctionInfo functions[] = {
  51. {0, nullptr, "InitializeBluetoothDriver"},
  52. {1, nullptr, "InitializeBluetooth"},
  53. {2, nullptr, "EnableBluetooth"},
  54. {3, nullptr, "DisableBluetooth"},
  55. {4, nullptr, "FinalizeBluetooth"},
  56. {5, nullptr, "GetAdapterProperties"},
  57. {6, nullptr, "GetAdapterProperty"},
  58. {7, nullptr, "SetAdapterProperty"},
  59. {8, nullptr, "StartInquiry"},
  60. {9, nullptr, "StopInquiry"},
  61. {10, nullptr, "CreateBond"},
  62. {11, nullptr, "RemoveBond"},
  63. {12, nullptr, "CancelBond"},
  64. {13, nullptr, "RespondToPinRequest"},
  65. {14, nullptr, "RespondToSspRequest"},
  66. {15, nullptr, "GetEventInfo"},
  67. {16, nullptr, "InitializeHid"},
  68. {17, nullptr, "OpenHidConnection"},
  69. {18, nullptr, "CloseHidConnection"},
  70. {19, nullptr, "WriteHidData"},
  71. {20, nullptr, "WriteHidData2"},
  72. {21, nullptr, "SetHidReport"},
  73. {22, nullptr, "GetHidReport"},
  74. {23, nullptr, "TriggerConnection"},
  75. {24, nullptr, "AddPairedDeviceInfo"},
  76. {25, nullptr, "GetPairedDeviceInfo"},
  77. {26, nullptr, "FinalizeHid"},
  78. {27, nullptr, "GetHidEventInfo"},
  79. {28, nullptr, "SetTsi"},
  80. {29, nullptr, "EnableBurstMode"},
  81. {30, nullptr, "SetZeroRetransmission"},
  82. {31, nullptr, "EnableMcMode"},
  83. {32, nullptr, "EnableLlrScan"},
  84. {33, nullptr, "DisableLlrScan"},
  85. {34, nullptr, "EnableRadio"},
  86. {35, nullptr, "SetVisibility"},
  87. {36, nullptr, "EnableTbfcScan"},
  88. {37, nullptr, "RegisterHidReportEvent"},
  89. {38, nullptr, "GetHidReportEventInfo"},
  90. {39, nullptr, "GetLatestPlr"},
  91. {40, nullptr, "GetPendingConnections"},
  92. {41, nullptr, "GetChannelMap"},
  93. {42, nullptr, "EnableTxPowerBoostSetting"},
  94. {43, nullptr, "IsTxPowerBoostSettingEnabled"},
  95. {44, nullptr, "EnableAfhSetting"},
  96. {45, nullptr, "IsAfhSettingEnabled"},
  97. {46, nullptr, "InitializeBle"},
  98. {47, nullptr, "EnableBle"},
  99. {48, nullptr, "DisableBle"},
  100. {49, nullptr, "FinalizeBle"},
  101. {50, nullptr, "SetBleVisibility"},
  102. {51, nullptr, "SetBleConnectionParameter"},
  103. {52, nullptr, "SetBleDefaultConnectionParameter"},
  104. {53, nullptr, "SetBleAdvertiseData"},
  105. {54, nullptr, "SetBleAdvertiseParameter"},
  106. {55, nullptr, "StartBleScan"},
  107. {56, nullptr, "StopBleScan"},
  108. {57, nullptr, "AddBleScanFilterCondition"},
  109. {58, nullptr, "DeleteBleScanFilterCondition"},
  110. {59, nullptr, "DeleteBleScanFilter"},
  111. {60, nullptr, "ClearBleScanFilters"},
  112. {61, nullptr, "EnableBleScanFilter"},
  113. {62, nullptr, "RegisterGattClient"},
  114. {63, nullptr, "UnregisterGattClient"},
  115. {64, nullptr, "UnregisterAllGattClients"},
  116. {65, nullptr, "ConnectGattServer"},
  117. {66, nullptr, "CancelConnectGattServer"},
  118. {67, nullptr, "DisconnectGattServer"},
  119. {68, nullptr, "GetGattAttribute"},
  120. {69, nullptr, "GetGattService"},
  121. {70, nullptr, "ConfigureAttMtu"},
  122. {71, nullptr, "RegisterGattServer"},
  123. {72, nullptr, "UnregisterGattServer"},
  124. {73, nullptr, "ConnectGattClient"},
  125. {74, nullptr, "DisconnectGattClient"},
  126. {75, nullptr, "AddGattService"},
  127. {76, nullptr, "EnableGattService"},
  128. {77, nullptr, "AddGattCharacteristic"},
  129. {78, nullptr, "AddGattDescriptor"},
  130. {79, nullptr, "GetBleManagedEventInfo"},
  131. {80, nullptr, "GetGattFirstCharacteristic"},
  132. {81, nullptr, "GetGattNextCharacteristic"},
  133. {82, nullptr, "GetGattFirstDescriptor"},
  134. {83, nullptr, "GetGattNextDescriptor"},
  135. {84, nullptr, "RegisterGattManagedDataPath"},
  136. {85, nullptr, "UnregisterGattManagedDataPath"},
  137. {86, nullptr, "RegisterGattHidDataPath"},
  138. {87, nullptr, "UnregisterGattHidDataPath"},
  139. {88, nullptr, "RegisterGattDataPath"},
  140. {89, nullptr, "UnregisterGattDataPath"},
  141. {90, nullptr, "ReadGattCharacteristic"},
  142. {91, nullptr, "ReadGattDescriptor"},
  143. {92, nullptr, "WriteGattCharacteristic"},
  144. {93, nullptr, "WriteGattDescriptor"},
  145. {94, nullptr, "RegisterGattNotification"},
  146. {95, nullptr, "UnregisterGattNotification"},
  147. {96, nullptr, "GetLeHidEventInfo"},
  148. {97, nullptr, "RegisterBleHidEvent"},
  149. {98, nullptr, "SetBleScanParameter"},
  150. {99, nullptr, "MoveToSecondaryPiconet"},
  151. {100, nullptr, "IsBluetoothEnabled"},
  152. {128, nullptr, "AcquireAudioEvent"},
  153. {129, nullptr, "GetAudioEventInfo"},
  154. {130, nullptr, "OpenAudioConnection"},
  155. {131, nullptr, "CloseAudioConnection"},
  156. {132, nullptr, "OpenAudioOut"},
  157. {133, nullptr, "CloseAudioOut"},
  158. {134, nullptr, "AcquireAudioOutStateChangedEvent"},
  159. {135, nullptr, "StartAudioOut"},
  160. {136, nullptr, "StopAudioOut"},
  161. {137, nullptr, "GetAudioOutState"},
  162. {138, nullptr, "GetAudioOutFeedingCodec"},
  163. {139, nullptr, "GetAudioOutFeedingParameter"},
  164. {140, nullptr, "AcquireAudioOutBufferAvailableEvent"},
  165. {141, nullptr, "SendAudioData"},
  166. {142, nullptr, "AcquireAudioControlInputStateChangedEvent"},
  167. {143, nullptr, "GetAudioControlInputState"},
  168. {144, nullptr, "AcquireAudioConnectionStateChangedEvent"},
  169. {145, nullptr, "GetConnectedAudioDevice"},
  170. {146, nullptr, "CloseAudioControlInput"},
  171. {147, nullptr, "RegisterAudioControlNotification"},
  172. {148, nullptr, "SendAudioControlPassthroughCommand"},
  173. {149, nullptr, "SendAudioControlSetAbsoluteVolumeCommand"},
  174. {150, nullptr, "AcquireAudioSinkVolumeLocallyChangedEvent"},
  175. {151, nullptr, "AcquireAudioSinkVolumeUpdateRequestCompletedEvent"},
  176. {152, nullptr, "GetAudioSinkVolume"},
  177. {153, nullptr, "RequestUpdateAudioSinkVolume"},
  178. {154, nullptr, "IsAudioSinkVolumeSupported"},
  179. {256, nullptr, "IsManufacturingMode"},
  180. {257, nullptr, "EmulateBluetoothCrash"},
  181. {258, nullptr, "GetBleChannelMap"},
  182. };
  183. // clang-format on
  184. RegisterHandlers(functions);
  185. }
  186. };
  187. void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
  188. std::make_shared<BtDrv>(system)->InstallAsService(sm);
  189. std::make_shared<Bt>(system)->InstallAsService(sm);
  190. }
  191. } // namespace Service::BtDrv