mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	AudioCore: Refactor DSP interrupt handling (#7026)
This commit is contained in:
		
							parent
							
								
									0ce956ba00
								
							
						
					
					
						commit
						72ff0c5337
					
				
					 9 changed files with 61 additions and 97 deletions
				
			
		|  | @ -12,7 +12,7 @@ | |||
| #include "core/hle/service/dsp/dsp_dsp.h" | ||||
| 
 | ||||
| using DspPipe = AudioCore::DspPipe; | ||||
| using InterruptType = Service::DSP::DSP_DSP::InterruptType; | ||||
| using InterruptType = Service::DSP::InterruptType; | ||||
| 
 | ||||
| SERIALIZE_EXPORT_IMPL(Service::DSP::DSP_DSP) | ||||
| SERVICE_CONSTRUCT_IMPL(Service::DSP::DSP_DSP) | ||||
|  | @ -235,7 +235,8 @@ void DSP_DSP::RegisterInterruptEvents(Kernel::HLERequestContext& ctx) { | |||
|     const u32 channel = rp.Pop<u32>(); | ||||
|     auto event = rp.PopObject<Kernel::Event>(); | ||||
| 
 | ||||
|     ASSERT_MSG(interrupt < NUM_INTERRUPT_TYPE && channel < AudioCore::num_dsp_pipe, | ||||
|     ASSERT_MSG(interrupt < static_cast<u32>(InterruptType::Count) && | ||||
|                    channel < AudioCore::num_dsp_pipe, | ||||
|                "Invalid type or pipe: interrupt = {}, channel = {}", interrupt, channel); | ||||
| 
 | ||||
|     const InterruptType type = static_cast<InterruptType>(interrupt); | ||||
|  | @ -326,6 +327,9 @@ std::shared_ptr<Kernel::Event>& DSP_DSP::GetInterruptEvent(InterruptType type, D | |||
|         ASSERT(pipe_index < AudioCore::num_dsp_pipe); | ||||
|         return pipes[pipe_index]; | ||||
|     } | ||||
|     case InterruptType::Count: | ||||
|     default: | ||||
|         break; | ||||
|     } | ||||
|     UNREACHABLE_MSG("Invalid interrupt type = {}", type); | ||||
| } | ||||
|  | @ -401,7 +405,12 @@ void InstallInterfaces(Core::System& system) { | |||
|     auto& service_manager = system.ServiceManager(); | ||||
|     auto dsp = std::make_shared<DSP_DSP>(system); | ||||
|     dsp->InstallAsService(service_manager); | ||||
|     system.DSP().SetServiceToInterrupt(std::move(dsp)); | ||||
|     system.DSP().SetInterruptHandler( | ||||
|         [dsp_ref = std::weak_ptr<DSP_DSP>(dsp)](InterruptType type, DspPipe pipe) { | ||||
|             if (auto locked = dsp_ref.lock()) { | ||||
|                 locked->SignalInterrupt(type, pipe); | ||||
|             } | ||||
|         }); | ||||
| } | ||||
| 
 | ||||
| } // namespace Service::DSP
 | ||||
|  |  | |||
|  | @ -19,15 +19,14 @@ class System; | |||
| 
 | ||||
| namespace Service::DSP { | ||||
| 
 | ||||
| /// There are three types of interrupts
 | ||||
| enum class InterruptType : u32 { Zero = 0, One = 1, Pipe = 2, Count }; | ||||
| 
 | ||||
| class DSP_DSP final : public ServiceFramework<DSP_DSP> { | ||||
| public: | ||||
|     explicit DSP_DSP(Core::System& system); | ||||
|     ~DSP_DSP(); | ||||
| 
 | ||||
|     /// There are three types of interrupts
 | ||||
|     static constexpr std::size_t NUM_INTERRUPT_TYPE = 3; | ||||
|     enum class InterruptType : u32 { Zero = 0, One = 1, Pipe = 2 }; | ||||
| 
 | ||||
|     /// Actual service implementation only has 6 'slots' for interrupts.
 | ||||
|     static constexpr std::size_t max_number_of_interrupt_events = 6; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue