diff options
| author | 2016-09-23 13:47:34 +0300 | |
|---|---|---|
| committer | 2016-11-25 09:37:19 +0300 | |
| commit | d4cadf11fc351cfd1105a9ffcd5ac50741ab6f9a (patch) | |
| tree | f8a0f30326d833c25120a28a0daf33e0ef7b8826 /src | |
| parent | Merge pull request #2210 from jroweboy/pagetables (diff) | |
| download | yuzu-d4cadf11fc351cfd1105a9ffcd5ac50741ab6f9a.tar.gz yuzu-d4cadf11fc351cfd1105a9ffcd5ac50741ab6f9a.tar.xz yuzu-d4cadf11fc351cfd1105a9ffcd5ac50741ab6f9a.zip | |
MIC_U: Stub service funcions
Diffstat (limited to '')
| -rw-r--r-- | src/common/logging/backend.cpp | 1 | ||||
| -rw-r--r-- | src/common/logging/log.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/mic_u.cpp | 320 | ||||
| -rw-r--r-- | src/core/hle/service/mic_u.h | 1 |
4 files changed, 307 insertions, 16 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 88209081d..7fd397fe5 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -43,6 +43,7 @@ namespace Log { | |||
| 43 | SUB(Service, AM) \ | 43 | SUB(Service, AM) \ |
| 44 | SUB(Service, PTM) \ | 44 | SUB(Service, PTM) \ |
| 45 | SUB(Service, LDR) \ | 45 | SUB(Service, LDR) \ |
| 46 | SUB(Service, MIC) \ | ||
| 46 | SUB(Service, NDM) \ | 47 | SUB(Service, NDM) \ |
| 47 | SUB(Service, NIM) \ | 48 | SUB(Service, NIM) \ |
| 48 | SUB(Service, NWM) \ | 49 | SUB(Service, NWM) \ |
diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 8d3a2d03e..8011534b8 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h | |||
| @@ -60,6 +60,7 @@ enum class Class : ClassType { | |||
| 60 | Service_AM, ///< The AM (Application manager) service | 60 | Service_AM, ///< The AM (Application manager) service |
| 61 | Service_PTM, ///< The PTM (Power status & misc.) service | 61 | Service_PTM, ///< The PTM (Power status & misc.) service |
| 62 | Service_LDR, ///< The LDR (3ds dll loader) service | 62 | Service_LDR, ///< The LDR (3ds dll loader) service |
| 63 | Service_MIC, ///< The MIC (microphone) service | ||
| 63 | Service_NDM, ///< The NDM (Network daemon manager) service | 64 | Service_NDM, ///< The NDM (Network daemon manager) service |
| 64 | Service_NIM, ///< The NIM (Network interface manager) service | 65 | Service_NIM, ///< The NIM (Network interface manager) service |
| 65 | Service_NWM, ///< The NWM (Network wlan manager) service | 66 | Service_NWM, ///< The NWM (Network wlan manager) service |
diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp index edd1ea97b..3e1e2588c 100644 --- a/src/core/hle/service/mic_u.cpp +++ b/src/core/hle/service/mic_u.cpp | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/logging/log.h" | ||
| 6 | #include "core/hle/kernel/event.h" | ||
| 7 | #include "core/hle/kernel/shared_memory.h" | ||
| 5 | #include "core/hle/service/mic_u.h" | 8 | #include "core/hle/service/mic_u.h" |
| 6 | 9 | ||
| 7 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -9,23 +12,296 @@ | |||
| 9 | 12 | ||
| 10 | namespace MIC_U { | 13 | namespace MIC_U { |
| 11 | 14 | ||
| 15 | enum class Encoding : u8 { | ||
| 16 | PCM8 = 0, | ||
| 17 | PCM16 = 1, | ||
| 18 | PCM8Signed = 2, | ||
| 19 | PCM16Signed = 3, | ||
| 20 | }; | ||
| 21 | |||
| 22 | enum class SampleRate : u8 { | ||
| 23 | SampleRate32730 = 0, | ||
| 24 | SampleRate16360 = 1, | ||
| 25 | SampleRate10910 = 2, | ||
| 26 | SampleRate8180 = 3 | ||
| 27 | }; | ||
| 28 | |||
| 29 | static Kernel::SharedPtr<Kernel::Event> buffer_full_event; | ||
| 30 | static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory; | ||
| 31 | static u8 mic_gain = 0; | ||
| 32 | static bool mic_power = false; | ||
| 33 | static bool is_sampling = false; | ||
| 34 | static bool allow_shell_closed; | ||
| 35 | static bool clamp = false; | ||
| 36 | static Encoding encoding; | ||
| 37 | static SampleRate sample_rate; | ||
| 38 | static s32 audio_buffer_offset; | ||
| 39 | static u32 audio_buffer_size; | ||
| 40 | static bool audio_buffer_loop; | ||
| 41 | |||
| 42 | /** | ||
| 43 | * MIC::MapSharedMem service function | ||
| 44 | * Inputs: | ||
| 45 | * 0 : Header Code[0x00010042] | ||
| 46 | * 1 : Shared-mem size | ||
| 47 | * 2 : CopyHandleDesc | ||
| 48 | * 3 : Shared-mem handle | ||
| 49 | * Outputs: | ||
| 50 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 51 | */ | ||
| 52 | static void MapSharedMem(Service::Interface* self) { | ||
| 53 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 54 | u32 size = cmd_buff[1]; | ||
| 55 | Handle mem_handle = cmd_buff[3]; | ||
| 56 | shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(mem_handle); | ||
| 57 | if (shared_memory) { | ||
| 58 | shared_memory->name = "MIC_U:shared_memory"; | ||
| 59 | } | ||
| 60 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 61 | LOG_WARNING(Service_MIC, "called, size=0x%X, mem_handle=0x%08X", size, mem_handle); | ||
| 62 | } | ||
| 63 | |||
| 64 | /** | ||
| 65 | * MIC::UnmapSharedMem service function | ||
| 66 | * Inputs: | ||
| 67 | * 0 : Header Code[0x00020000] | ||
| 68 | * Outputs: | ||
| 69 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 70 | */ | ||
| 71 | static void UnmapSharedMem(Service::Interface* self) { | ||
| 72 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 73 | |||
| 74 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 75 | LOG_WARNING(Service_MIC, "called"); | ||
| 76 | } | ||
| 77 | |||
| 78 | /** | ||
| 79 | * MIC::StartSampling service function | ||
| 80 | * Inputs: | ||
| 81 | * 0 : Header Code[0x00030140] | ||
| 82 | * 1 : Encoding | ||
| 83 | * 2 : SampleRate | ||
| 84 | * 3 : Base offset for audio data in sharedmem | ||
| 85 | * 4 : Size of the audio data in sharedmem | ||
| 86 | * 5 : Loop at end of buffer | ||
| 87 | * Outputs: | ||
| 88 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 89 | */ | ||
| 90 | static void StartSampling(Service::Interface* self) { | ||
| 91 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 92 | |||
| 93 | encoding = static_cast<Encoding>(cmd_buff[1] & 0xFF); | ||
| 94 | sample_rate = static_cast<SampleRate>(cmd_buff[2] & 0xFF); | ||
| 95 | audio_buffer_offset = cmd_buff[3]; | ||
| 96 | audio_buffer_size = cmd_buff[4]; | ||
| 97 | audio_buffer_loop = static_cast<bool>(cmd_buff[5] & 0xFF); | ||
| 98 | |||
| 99 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 100 | is_sampling = true; | ||
| 101 | LOG_WARNING(Service_MIC, "(STUBBED) called"); | ||
| 102 | } | ||
| 103 | |||
| 104 | /** | ||
| 105 | * MIC::AdjustSampling service function | ||
| 106 | * Inputs: | ||
| 107 | * 0 : Header Code[0x00040040] | ||
| 108 | * 1 : SampleRate | ||
| 109 | * Outputs: | ||
| 110 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 111 | */ | ||
| 112 | static void AdjustSampling(Service::Interface* self) { | ||
| 113 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 114 | sample_rate = static_cast<SampleRate>(cmd_buff[1] & 0xFF); | ||
| 115 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 116 | LOG_WARNING(Service_MIC, "(STUBBED) called"); | ||
| 117 | } | ||
| 118 | |||
| 119 | /** | ||
| 120 | * MIC::StopSampling service function | ||
| 121 | * Inputs: | ||
| 122 | * 0 : Header Code[0x00050000] | ||
| 123 | * Outputs: | ||
| 124 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 125 | */ | ||
| 126 | static void StopSampling(Service::Interface* self) { | ||
| 127 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 128 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 129 | is_sampling = false; | ||
| 130 | LOG_WARNING(Service_MIC, "(STUBBED) called"); | ||
| 131 | } | ||
| 132 | |||
| 133 | /** | ||
| 134 | * MIC::IsSampling service function | ||
| 135 | * Inputs: | ||
| 136 | * 0 : Header Code[0x00060000] | ||
| 137 | * Outputs: | ||
| 138 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 139 | * 2 : 0 = sampling, non-zero = sampling | ||
| 140 | */ | ||
| 141 | static void IsSampling(Service::Interface* self) { | ||
| 142 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 143 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 144 | cmd_buff[2] = is_sampling; | ||
| 145 | LOG_WARNING(Service_MIC, "(STUBBED) called"); | ||
| 146 | } | ||
| 147 | |||
| 148 | /** | ||
| 149 | * MIC::GetBufferFullEvent service function | ||
| 150 | * Inputs: | ||
| 151 | * 0 : Header Code[0x00070000] | ||
| 152 | * Outputs: | ||
| 153 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 154 | * 3 : Event handle | ||
| 155 | */ | ||
| 156 | static void GetBufferFullEvent(Service::Interface* self) { | ||
| 157 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 158 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 159 | cmd_buff[3] = Kernel::g_handle_table.Create(buffer_full_event).MoveFrom(); | ||
| 160 | LOG_WARNING(Service_MIC, "(STUBBED) called"); | ||
| 161 | } | ||
| 162 | |||
| 163 | /** | ||
| 164 | * MIC::SetGain service function | ||
| 165 | * Inputs: | ||
| 166 | * 0 : Header Code[0x00080040] | ||
| 167 | * 1 : Gain | ||
| 168 | * Outputs: | ||
| 169 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 170 | */ | ||
| 171 | static void SetGain(Service::Interface* self) { | ||
| 172 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 173 | mic_gain = cmd_buff[1] & 0xFF; | ||
| 174 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 175 | LOG_WARNING(Service_MIC, "(STUBBED) called, gain = %d", mic_gain); | ||
| 176 | } | ||
| 177 | |||
| 178 | /** | ||
| 179 | * MIC::GetGain service function | ||
| 180 | * Inputs: | ||
| 181 | * 0 : Header Code[0x00090000] | ||
| 182 | * Outputs: | ||
| 183 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 184 | * 2 : Gain | ||
| 185 | */ | ||
| 186 | static void GetGain(Service::Interface* self) { | ||
| 187 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 188 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 189 | cmd_buff[2] = mic_gain; | ||
| 190 | LOG_WARNING(Service_MIC, "(STUBBED) called"); | ||
| 191 | } | ||
| 192 | |||
| 193 | /** | ||
| 194 | * MIC::SetPower service function | ||
| 195 | * Inputs: | ||
| 196 | * 0 : Header Code[0x000A0040] | ||
| 197 | * 1 : Power (0 = off, 1 = on) | ||
| 198 | * Outputs: | ||
| 199 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 200 | */ | ||
| 201 | static void SetPower(Service::Interface* self) { | ||
| 202 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 203 | mic_power = static_cast<bool>(cmd_buff[1] & 0xFF); | ||
| 204 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 205 | LOG_WARNING(Service_MIC, "(STUBBED) called, power = %u", mic_power); | ||
| 206 | } | ||
| 207 | |||
| 208 | /** | ||
| 209 | * MIC::GetPower service function | ||
| 210 | * Inputs: | ||
| 211 | * 0 : Header Code[0x000B0000] | ||
| 212 | * Outputs: | ||
| 213 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 214 | * 2 : Power | ||
| 215 | */ | ||
| 216 | static void GetPower(Service::Interface* self) { | ||
| 217 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 218 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 219 | cmd_buff[2] = mic_power; | ||
| 220 | LOG_WARNING(Service_MIC, "(STUBBED) called"); | ||
| 221 | } | ||
| 222 | |||
| 223 | /** | ||
| 224 | * MIC::SetIirFilterMic service function | ||
| 225 | * Inputs: | ||
| 226 | * 0 : Header Code[0x000C0042] | ||
| 227 | * 1 : Size | ||
| 228 | * 2 : (Size << 4) | 0xA | ||
| 229 | * 3 : Pointer to IIR Filter Data | ||
| 230 | * Outputs: | ||
| 231 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 232 | */ | ||
| 233 | static void SetIirFilterMic(Service::Interface* self) { | ||
| 234 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 235 | |||
| 236 | u32 size = cmd_buff[1]; | ||
| 237 | VAddr buffer = cmd_buff[3]; | ||
| 238 | |||
| 239 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 240 | LOG_WARNING(Service_MIC, "(STUBBED) called, size=0x%X, buffer=0x%08X", size, buffer); | ||
| 241 | } | ||
| 242 | |||
| 243 | /** | ||
| 244 | * MIC::SetClamp service function | ||
| 245 | * Inputs: | ||
| 246 | * 0 : Header Code[0x000D0040] | ||
| 247 | * 1 : Clamp (0 = don't clamp, non-zero = clamp) | ||
| 248 | * Outputs: | ||
| 249 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 250 | */ | ||
| 251 | static void SetClamp(Service::Interface* self) { | ||
| 252 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 253 | clamp = static_cast<bool>(cmd_buff[1] & 0xFF); | ||
| 254 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 255 | LOG_WARNING(Service_MIC, "(STUBBED) called, clamp=%u", clamp); | ||
| 256 | } | ||
| 257 | |||
| 258 | /** | ||
| 259 | * MIC::GetClamp service function | ||
| 260 | * Inputs: | ||
| 261 | * 0 : Header Code[0x000E0000] | ||
| 262 | * Outputs: | ||
| 263 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 264 | * 2 : Clamp (0 = don't clamp, non-zero = clamp) | ||
| 265 | */ | ||
| 266 | static void GetClamp(Service::Interface* self) { | ||
| 267 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 268 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 269 | cmd_buff[2] = clamp; | ||
| 270 | LOG_WARNING(Service_MIC, "(STUBBED) called"); | ||
| 271 | } | ||
| 272 | |||
| 273 | /** | ||
| 274 | * MIC::SetAllowShellClosed service function | ||
| 275 | * Inputs: | ||
| 276 | * 0 : Header Code[0x000D0040] | ||
| 277 | * 1 : Sampling allowed while shell closed (0 = disallow, non-zero = allow) | ||
| 278 | * Outputs: | ||
| 279 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 280 | */ | ||
| 281 | static void SetAllowShellClosed(Service::Interface* self) { | ||
| 282 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 283 | allow_shell_closed = static_cast<bool>(cmd_buff[1] & 0xFF); | ||
| 284 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 285 | LOG_WARNING(Service_MIC, "(STUBBED) called, allow_shell_closed=%u", allow_shell_closed); | ||
| 286 | } | ||
| 287 | |||
| 12 | const Interface::FunctionInfo FunctionTable[] = { | 288 | const Interface::FunctionInfo FunctionTable[] = { |
| 13 | {0x00010042, nullptr, "MapSharedMem"}, | 289 | {0x00010042, MapSharedMem, "MapSharedMem"}, |
| 14 | {0x00020000, nullptr, "UnmapSharedMem"}, | 290 | {0x00020000, UnmapSharedMem, "UnmapSharedMem"}, |
| 15 | {0x00030140, nullptr, "Initialize"}, | 291 | {0x00030140, StartSampling, "StartSampling"}, |
| 16 | {0x00040040, nullptr, "AdjustSampling"}, | 292 | {0x00040040, AdjustSampling, "AdjustSampling"}, |
| 17 | {0x00050000, nullptr, "StopSampling"}, | 293 | {0x00050000, StopSampling, "StopSampling"}, |
| 18 | {0x00060000, nullptr, "IsSampling"}, | 294 | {0x00060000, IsSampling, "IsSampling"}, |
| 19 | {0x00070000, nullptr, "GetEventHandle"}, | 295 | {0x00070000, GetBufferFullEvent, "GetBufferFullEvent"}, |
| 20 | {0x00080040, nullptr, "SetGain"}, | 296 | {0x00080040, SetGain, "SetGain"}, |
| 21 | {0x00090000, nullptr, "GetGain"}, | 297 | {0x00090000, GetGain, "GetGain"}, |
| 22 | {0x000A0040, nullptr, "SetPower"}, | 298 | {0x000A0040, SetPower, "SetPower"}, |
| 23 | {0x000B0000, nullptr, "GetPower"}, | 299 | {0x000B0000, GetPower, "GetPower"}, |
| 24 | {0x000C0042, nullptr, "size"}, | 300 | {0x000C0042, SetIirFilterMic, "SetIirFilterMic"}, |
| 25 | {0x000D0040, nullptr, "SetClamp"}, | 301 | {0x000D0040, SetClamp, "SetClamp"}, |
| 26 | {0x000E0000, nullptr, "GetClamp"}, | 302 | {0x000E0000, GetClamp, "GetClamp"}, |
| 27 | {0x000F0040, nullptr, "SetAllowShellClosed"}, | 303 | {0x000F0040, SetAllowShellClosed, "SetAllowShellClosed"}, |
| 28 | {0x00100040, nullptr, "unknown_input2"}, | 304 | {0x00100040, nullptr, "SetClientSDKVersion"}, |
| 29 | }; | 305 | }; |
| 30 | 306 | ||
| 31 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 307 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -33,6 +309,18 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 33 | 309 | ||
| 34 | Interface::Interface() { | 310 | Interface::Interface() { |
| 35 | Register(FunctionTable); | 311 | Register(FunctionTable); |
| 312 | shared_memory = nullptr; | ||
| 313 | buffer_full_event = | ||
| 314 | Kernel::Event::Create(Kernel::ResetType::OneShot, "MIC_U::buffer_full_event"); | ||
| 315 | mic_gain = 0; | ||
| 316 | mic_power = false; | ||
| 317 | is_sampling = false; | ||
| 318 | clamp = false; | ||
| 319 | } | ||
| 320 | |||
| 321 | Interface::~Interface() { | ||
| 322 | shared_memory = nullptr; | ||
| 323 | buffer_full_event = nullptr; | ||
| 36 | } | 324 | } |
| 37 | 325 | ||
| 38 | } // namespace | 326 | } // namespace |
diff --git a/src/core/hle/service/mic_u.h b/src/core/hle/service/mic_u.h index dc795d14c..1cff7390e 100644 --- a/src/core/hle/service/mic_u.h +++ b/src/core/hle/service/mic_u.h | |||
| @@ -16,6 +16,7 @@ namespace MIC_U { | |||
| 16 | class Interface : public Service::Interface { | 16 | class Interface : public Service::Interface { |
| 17 | public: | 17 | public: |
| 18 | Interface(); | 18 | Interface(); |
| 19 | ~Interface(); | ||
| 19 | 20 | ||
| 20 | std::string GetPortName() const override { | 21 | std::string GetPortName() const override { |
| 21 | return "mic:u"; | 22 | return "mic:u"; |