mirror of
https://github.com/citra-mirror/citra.git
synced 2024-08-20 10:23:23 +02:00
DSP/HLE: move implementation of RecvData to audio_core, behind common interface
This commit is contained in:
parent
6d51d95d44
commit
7f568a3c19
@ -32,8 +32,13 @@ public:
|
|||||||
DspInterface& operator=(const DspInterface&) = delete;
|
DspInterface& operator=(const DspInterface&) = delete;
|
||||||
DspInterface& operator=(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`.
|
* Reads `length` bytes from the DSP pipe identified with `pipe_number`.
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
|
|
||||||
DspState GetDspState() const;
|
DspState GetDspState() const;
|
||||||
|
|
||||||
|
u16 RecvData(u32 register_number);
|
||||||
std::vector<u8> PipeRead(DspPipe pipe_number, u32 length);
|
std::vector<u8> PipeRead(DspPipe pipe_number, u32 length);
|
||||||
std::size_t GetPipeReadableSize(DspPipe pipe_number) const;
|
std::size_t GetPipeReadableSize(DspPipe pipe_number) const;
|
||||||
void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer);
|
void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer);
|
||||||
@ -93,6 +94,24 @@ DspState DspHle::Impl::GetDspState() const {
|
|||||||
return dsp_state;
|
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) {
|
std::vector<u8> DspHle::Impl::PipeRead(DspPipe pipe_number, u32 length) {
|
||||||
const std::size_t pipe_index = static_cast<std::size_t>(pipe_number);
|
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(Memory::MemorySystem& memory) : impl(std::make_unique<Impl>(*this, memory)) {}
|
||||||
DspHle::~DspHle() = default;
|
DspHle::~DspHle() = default;
|
||||||
|
|
||||||
DspState DspHle::GetDspState() const {
|
u16 DspHle::RecvData(u32 register_number) {
|
||||||
return impl->GetDspState();
|
return impl->RecvData(register_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> DspHle::PipeRead(DspPipe pipe_number, u32 length) {
|
std::vector<u8> DspHle::PipeRead(DspPipe pipe_number, u32 length) {
|
||||||
|
@ -24,8 +24,7 @@ public:
|
|||||||
explicit DspHle(Memory::MemorySystem& memory);
|
explicit DspHle(Memory::MemorySystem& memory);
|
||||||
~DspHle();
|
~DspHle();
|
||||||
|
|
||||||
DspState GetDspState() const override;
|
u16 RecvData(u32 register_number) override;
|
||||||
|
|
||||||
std::vector<u8> PipeRead(DspPipe pipe_number, u32 length) override;
|
std::vector<u8> PipeRead(DspPipe pipe_number, u32 length) override;
|
||||||
std::size_t GetPipeReadableSize(DspPipe pipe_number) const override;
|
std::size_t GetPipeReadableSize(DspPipe pipe_number) const override;
|
||||||
void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer) override;
|
void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer) override;
|
||||||
|
@ -24,26 +24,9 @@ void DSP_DSP::RecvData(Kernel::HLERequestContext& ctx) {
|
|||||||
IPC::RequestParser rp(ctx, 0x01, 1, 0);
|
IPC::RequestParser rp(ctx, 0x01, 1, 0);
|
||||||
const u32 register_number = rp.Pop<u32>();
|
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);
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push(system.DSP().RecvData(register_number));
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_DSP, "register_number={}", 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;
|
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[] = {
|
static const FunctionInfo functions[] = {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
{0x00010040, &DSP_DSP::RecvData, "RecvData"},
|
{0x00010040, &DSP_DSP::RecvData, "RecvData"},
|
||||||
|
@ -245,6 +245,8 @@ private:
|
|||||||
/// Checks if we are trying to register more than 6 events
|
/// Checks if we are trying to register more than 6 events
|
||||||
bool HasTooManyEventsRegistered() const;
|
bool HasTooManyEventsRegistered() const;
|
||||||
|
|
||||||
|
Core::System& system;
|
||||||
|
|
||||||
Kernel::SharedPtr<Kernel::Event> semaphore_event;
|
Kernel::SharedPtr<Kernel::Event> semaphore_event;
|
||||||
|
|
||||||
Kernel::SharedPtr<Kernel::Event> interrupt_zero = nullptr; /// Currently unknown purpose
|
Kernel::SharedPtr<Kernel::Event> interrupt_zero = nullptr; /// Currently unknown purpose
|
||||||
|
Loading…
Reference in New Issue
Block a user