DSP/HLE: move implementation of RecvData to audio_core, behind common interface

This commit is contained in:
Weiyi Wang 2018-12-06 07:18:26 -05:00
parent 6d51d95d44
commit 7f568a3c19
5 changed files with 34 additions and 25 deletions

View File

@ -32,8 +32,13 @@ public:
DspInterface& operator=(const DspInterface&) = delete;
DspInterface& operator=(DspInterface&&) = delete;
/// Get the state of the DSP
virtual DspState GetDspState() const = 0;
/**
* Reads data from one of three DSP registers
* @note this function blocks until the data is available
* @param register_number the index of the register to read
* @returns the value of the register
*/
virtual u16 RecvData(u32 register_number) = 0;
/**
* Reads `length` bytes from the DSP pipe identified with `pipe_number`.

View File

@ -29,6 +29,7 @@ public:
DspState GetDspState() const;
u16 RecvData(u32 register_number);
std::vector<u8> PipeRead(DspPipe pipe_number, u32 length);
std::size_t GetPipeReadableSize(DspPipe pipe_number) const;
void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer);
@ -93,6 +94,24 @@ DspState DspHle::Impl::GetDspState() const {
return dsp_state;
}
u16 DspHle::Impl::RecvData(u32 register_number) {
ASSERT_MSG(register_number == 0, "Unknown register_number {}", register_number);
// Application reads this after requesting DSP shutdown, to verify the DSP has indeed shutdown
// or slept.
switch (GetDspState()) {
case AudioCore::DspState::On:
return 0;
case AudioCore::DspState::Off:
case AudioCore::DspState::Sleeping:
return 1;
default:
UNREACHABLE();
break;
}
}
std::vector<u8> DspHle::Impl::PipeRead(DspPipe pipe_number, u32 length) {
const std::size_t pipe_index = static_cast<std::size_t>(pipe_number);
@ -342,8 +361,8 @@ void DspHle::Impl::AudioTickCallback(s64 cycles_late) {
DspHle::DspHle(Memory::MemorySystem& memory) : impl(std::make_unique<Impl>(*this, memory)) {}
DspHle::~DspHle() = default;
DspState DspHle::GetDspState() const {
return impl->GetDspState();
u16 DspHle::RecvData(u32 register_number) {
return impl->RecvData(register_number);
}
std::vector<u8> DspHle::PipeRead(DspPipe pipe_number, u32 length) {

View File

@ -24,8 +24,7 @@ public:
explicit DspHle(Memory::MemorySystem& memory);
~DspHle();
DspState GetDspState() const override;
u16 RecvData(u32 register_number) override;
std::vector<u8> PipeRead(DspPipe pipe_number, u32 length) override;
std::size_t GetPipeReadableSize(DspPipe pipe_number) const override;
void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer) override;

View File

@ -24,26 +24,9 @@ void DSP_DSP::RecvData(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x01, 1, 0);
const u32 register_number = rp.Pop<u32>();
ASSERT_MSG(register_number == 0, "Unknown register_number {}", register_number);
// Application reads this after requesting DSP shutdown, to verify the DSP has indeed shutdown
// or slept.
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
switch (Core::DSP().GetDspState()) {
case AudioCore::DspState::On:
rb.Push<u32>(0);
break;
case AudioCore::DspState::Off:
case AudioCore::DspState::Sleeping:
rb.Push<u32>(1);
break;
default:
UNREACHABLE();
break;
}
rb.Push(system.DSP().RecvData(register_number));
LOG_DEBUG(Service_DSP, "register_number={}", register_number);
}
@ -350,7 +333,8 @@ bool DSP_DSP::HasTooManyEventsRegistered() const {
return number >= max_number_of_interrupt_events;
}
DSP_DSP::DSP_DSP(Core::System& system) : ServiceFramework("dsp::DSP", DefaultMaxSessions) {
DSP_DSP::DSP_DSP(Core::System& system)
: ServiceFramework("dsp::DSP", DefaultMaxSessions), system(system) {
static const FunctionInfo functions[] = {
// clang-format off
{0x00010040, &DSP_DSP::RecvData, "RecvData"},

View File

@ -245,6 +245,8 @@ private:
/// Checks if we are trying to register more than 6 events
bool HasTooManyEventsRegistered() const;
Core::System& system;
Kernel::SharedPtr<Kernel::Event> semaphore_event;
Kernel::SharedPtr<Kernel::Event> interrupt_zero = nullptr; /// Currently unknown purpose