From 4add509b2062d745ec5cf1feb136785bd9dae7c6 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Thu, 6 Dec 2018 08:35:21 -0500 Subject: [PATCH] audio_core/hle: move implementation of LoadComponent --- src/audio_core/dsp_interface.h | 3 +++ src/audio_core/hle/hle.cpp | 12 ++++++++++++ src/audio_core/hle/hle.h | 2 ++ src/core/hle/service/dsp/dsp_dsp.cpp | 18 +++++------------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/audio_core/dsp_interface.h b/src/audio_core/dsp_interface.h index 5d7119cb6..eab08d5f8 100644 --- a/src/audio_core/dsp_interface.h +++ b/src/audio_core/dsp_interface.h @@ -88,6 +88,9 @@ public: /// Sets the dsp class that we trigger interrupts for virtual void SetServiceToInterrupt(std::weak_ptr dsp) = 0; + /// Loads the DSP program + virtual void LoadComponent(const std::vector& buffer) = 0; + /// Select the sink to use based on sink id. void SetSink(const std::string& sink_id, const std::string& audio_device); /// Get the current sink diff --git a/src/audio_core/hle/hle.cpp b/src/audio_core/hle/hle.cpp index c5f3d0f44..4b490d9bb 100644 --- a/src/audio_core/hle/hle.cpp +++ b/src/audio_core/hle/hle.cpp @@ -11,6 +11,7 @@ #include "audio_core/sink.h" #include "common/assert.h" #include "common/common_types.h" +#include "common/hash.h" #include "common/logging/log.h" #include "core/core.h" #include "core/core_timing.h" @@ -399,4 +400,15 @@ void DspHle::SetServiceToInterrupt(std::weak_ptr dsp) { impl->SetServiceToInterrupt(std::move(dsp)); } +void DspHle::LoadComponent(const std::vector& component_data) { + // HLE doesn't need DSP program. Only log some info here + LOG_INFO(Service_DSP, "Firmware hash: {:#018x}", + Common::ComputeHash64(component_data.data(), component_data.size())); + // Some versions of the firmware have the location of DSP structures listed here. + if (component_data.size() > 0x37C) { + LOG_INFO(Service_DSP, "Structures hash: {:#018x}", + Common::ComputeHash64(component_data.data() + 0x340, 60)); + } +} + } // namespace AudioCore diff --git a/src/audio_core/hle/hle.h b/src/audio_core/hle/hle.h index 1c756b60f..a472ca3c2 100644 --- a/src/audio_core/hle/hle.h +++ b/src/audio_core/hle/hle.h @@ -35,6 +35,8 @@ public: void SetServiceToInterrupt(std::weak_ptr dsp) override; + void LoadComponent(const std::vector& buffer) override; + private: struct Impl; friend struct Impl; diff --git a/src/core/hle/service/dsp/dsp_dsp.cpp b/src/core/hle/service/dsp/dsp_dsp.cpp index 30cab2f63..fec7ad7bf 100644 --- a/src/core/hle/service/dsp/dsp_dsp.cpp +++ b/src/core/hle/service/dsp/dsp_dsp.cpp @@ -4,7 +4,6 @@ #include "audio_core/audio_types.h" #include "common/assert.h" -#include "common/hash.h" #include "common/logging/log.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" @@ -173,23 +172,16 @@ void DSP_DSP::LoadComponent(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); - rb.Push(true); /// Pretend that we actually loaded the DSP firmware + rb.Push(true); rb.PushMappedBuffer(buffer); - // TODO(bunnei): Implement real DSP firmware loading - std::vector component_data(size); buffer.Read(component_data.data(), 0, size); - LOG_INFO(Service_DSP, "Firmware hash: {:#018x}", - Common::ComputeHash64(component_data.data(), component_data.size())); - // Some versions of the firmware have the location of DSP structures listed here. - if (size > 0x37C) { - LOG_INFO(Service_DSP, "Structures hash: {:#018x}", - Common::ComputeHash64(component_data.data() + 0x340, 60)); - } - LOG_WARNING(Service_DSP, "(STUBBED) called size=0x{:X}, prog_mask=0x{:08X}, data_mask=0x{:08X}", - size, prog_mask, data_mask); + system.DSP().LoadComponent(component_data); + + LOG_INFO(Service_DSP, "(STUBBED) called size=0x{:X}, prog_mask=0x{:08X}, data_mask=0x{:08X}", + size, prog_mask, data_mask); } void DSP_DSP::FlushDataCache(Kernel::HLERequestContext& ctx) {