diff --git a/Utilities/BEType.h b/Utilities/BEType.h index 688c9858ba..1195693178 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -2,17 +2,14 @@ #include "Utilities/GNU.h" -#define se16(x) const_se_t::value -#define se32(x) const_se_t::value -#define se64(x) const_se_t::value - template struct se_t; template struct se_t { static __forceinline void func(T& dst, const T src) { (u8&)dst = (u8&)src; } }; template struct se_t { static __forceinline void func(T& dst, const T src) { (u16&)dst = _byteswap_ushort((u16&)src); } }; template struct se_t { static __forceinline void func(T& dst, const T src) { (u32&)dst = _byteswap_ulong((u32&)src); } }; template struct se_t { static __forceinline void func(T& dst, const T src) { (u64&)dst = _byteswap_uint64((u64&)src); } }; -template struct const_se_t;; + +template struct const_se_t; template struct const_se_t { static const T value = (T)_value; @@ -52,6 +49,7 @@ class be_t T m_data; public: + typedef T type; be_t() noexcept = default; be_t(const T& value) @@ -89,6 +87,20 @@ public: se_t::func(m_data, value); } + static be_t MakeFromLE(const T value) + { + be_t res; + res.FromLE(value); + return res; + } + + static be_t MakeFromBE(const T value) + { + be_t res; + res.FromBE(value); + return res; + } + //template operator const T() const { @@ -152,4 +164,17 @@ public: template bool operator < (const be_t& right) const { return (T1)ToLE() < right.ToLE(); } template bool operator >= (const be_t& right) const { return (T1)ToLE() >= right.ToLE(); } template bool operator <= (const be_t& right) const { return (T1)ToLE() <= right.ToLE(); } + + be_t operator++ (int) { be_t res = *this; *this += 1; return res; } + be_t operator-- (int) { be_t res = *this; *this -= 1; return res; } + be_t& operator++ () { *this += 1; return *this; } + be_t& operator-- () { *this -= 1; return *this; } }; + +template struct _se : public const_se_t {}; +template struct _se, T1, value> : public const_se_t {}; + +#define se(t, x) _se::value +#define se16(x) _se::value +#define se32(x) _se::value +#define se64(x) _se::value diff --git a/Utilities/IdManager.h b/Utilities/IdManager.h index ff1185c415..d32f8a28ba 100644 --- a/Utilities/IdManager.h +++ b/Utilities/IdManager.h @@ -35,11 +35,11 @@ public: struct ID { std::string m_name; - u8 m_attr; + u32 m_attr; IDData* m_data; template - ID(const std::string& name, T* data, const u8 attr) + ID(const std::string& name, T* data, const u32 attr) : m_name(name) , m_attr(attr) { diff --git a/Utilities/SMutex.h b/Utilities/SMutex.h index 9cb03be3d9..2f934d4c96 100644 --- a/Utilities/SMutex.h +++ b/Utilities/SMutex.h @@ -35,6 +35,11 @@ public: { } + void initialize() + { + (T&)owner = free_value; + } + ~SMutexBase() { lock((T)dead_value); @@ -46,6 +51,16 @@ public: return (T&)owner; } + __forceinline T GetFreeValue() const + { + return (T)free_value; + } + + __forceinline T GetDeadValue() const + { + return (T)dead_value; + } + SMutexResult trylock(T tid) { if (Emu.IsStopped()) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index ad8633a6b6..f756027ba9 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -115,10 +115,11 @@ void thread::start(std::function func) { // got a crash related with strings m_thr = std::thread([this, func]() { + NamedThreadBase info(m_name); + g_tls_this_thread = &info; + try { - NamedThreadBase info(m_name); - g_tls_this_thread = &info; func(); } catch(...) diff --git a/rpcs3/Emu/Cell/PPUInterpreter.h b/rpcs3/Emu/Cell/PPUInterpreter.h index 6784e2d1b5..daba8dccef 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.h +++ b/rpcs3/Emu/Cell/PPUInterpreter.h @@ -2334,6 +2334,7 @@ private: } void MFOCRF(u32 a, u32 rd, u32 crm) { + /* if(a) { u32 n = 0, count = 0; @@ -2349,15 +2350,17 @@ private: if(count == 1) { //RD[32+4*n : 32+4*n+3] = CR[4*n : 4*n+3]; - CPU.GPR[rd] = (u64)CPU.GetCR(7 - n) << (n * 4); + u8 offset = n * 4; + CPU.GPR[rd] = (CPU.GPR[rd] & ~(0xf << offset)) | ((u32)CPU.GetCR(7 - n) << offset); } else CPU.GPR[rd] = 0; } else { - CPU.GPR[rd] = CPU.CR.CR; - } + */ + CPU.GPR[rd] = CPU.CR.CR; + //} } void LWARX(u32 rd, u32 ra, u32 rb) { @@ -2634,7 +2637,7 @@ private: if(count == 1) { //CR[4*n : 4*n+3] = RS[32+4*n : 32+4*n+3]; - CPU.SetCR(n, (CPU.GPR[rs] >> (4*n)) & 0xf); + CPU.SetCR(7 - n, (CPU.GPR[rs] >> (4*n)) & 0xf); } else CPU.CR.CR = 0; @@ -2645,7 +2648,7 @@ private: { if(crm & (1 << i)) { - CPU.SetCR(i, CPU.GPR[rs] & (0xf << i)); + CPU.SetCR(7 - i, CPU.GPR[rs] & (0xf << (i * 4))); } } } diff --git a/rpcs3/Emu/Cell/SPUInterpreter.h b/rpcs3/Emu/Cell/SPUInterpreter.h index 2f087d0fac..d90e8e0bed 100644 --- a/rpcs3/Emu/Cell/SPUInterpreter.h +++ b/rpcs3/Emu/Cell/SPUInterpreter.h @@ -32,12 +32,99 @@ private: //0 - 10 void STOP(u32 code) { - if (CPU.SPU.Out_MBox.GetCount()) // the real exit status is probably stored there - ConLog.Warning("STOP: 0x%x (message=0x%x)", code, CPU.SPU.Out_MBox.GetValue()); - else - ConLog.Warning("STOP: 0x%x (no message)", code); - CPU.SetExitStatus(code); - CPU.Stop(); + CPU.SetExitStatus(code); // exit code (not status) + + switch (code) + { + case 0x110: /* ===== sys_spu_thread_receive_event ===== */ + { + u32 spuq = 0; + if (!CPU.SPU.Out_MBox.Pop(spuq)) + { + ConLog.Error("sys_spu_thread_receive_event: cannot read Out_MBox"); + CPU.SPU.In_MBox.PushUncond(CELL_EINVAL); // ??? + return; + } + + if (CPU.SPU.In_MBox.GetCount()) + { + ConLog.Error("sys_spu_thread_receive_event(spuq=0x%x): In_MBox is not empty", spuq); + CPU.SPU.In_MBox.PushUncond(CELL_EBUSY); // ??? + return; + } + + if (Ini.HLELogging.GetValue()) + { + ConLog.Write("sys_spu_thread_receive_event(spuq=0x%x)", spuq); + } + + EventQueue* eq; + if (!CPU.SPUQs.GetEventQueue(FIX_SPUQ(spuq), eq)) + { + CPU.SPU.In_MBox.PushUncond(CELL_EINVAL); // TODO: check error value + return; + } + + u32 tid = GetCurrentSPUThread().GetId(); + + eq->sq.push(tid); // add thread to sleep queue + + while (true) + { + switch (eq->owner.trylock(tid)) + { + case SMR_OK: + if (!eq->events.count()) + { + eq->owner.unlock(tid); + break; + } + else + { + u32 next = (eq->protocol == SYS_SYNC_FIFO) ? eq->sq.pop() : eq->sq.pop_prio(); + if (next != tid) + { + eq->owner.unlock(tid, next); + break; + } + } + case SMR_SIGNAL: + { + sys_event_data event; + eq->events.pop(event); + eq->owner.unlock(tid); + CPU.SPU.In_MBox.PushUncond(CELL_OK); + CPU.SPU.In_MBox.PushUncond(event.data1); + CPU.SPU.In_MBox.PushUncond(event.data2); + CPU.SPU.In_MBox.PushUncond(event.data3); + return; + } + case SMR_FAILED: break; + default: eq->sq.invalidate(tid); CPU.SPU.In_MBox.PushUncond(CELL_ECANCELED); return; + } + + Sleep(1); + if (Emu.IsStopped()) + { + ConLog.Warning("sys_spu_thread_receive_event(spuq=0x%x) aborted", spuq); + eq->sq.invalidate(tid); + return; + } + } + } + break; + case 0x102: default: + if (!CPU.SPU.Out_MBox.GetCount()) // the real exit status + { + ConLog.Warning("STOP: 0x%x (no message)", code); + } + else if (Ini.HLELogging.GetValue() || code != 0x102) + { + ConLog.Warning("STOP: 0x%x (message=0x%x)", code, CPU.SPU.Out_MBox.GetValue()); + } + CPU.Stop(); + break; + } } void LNOP() { diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 6a0d8f5892..2e32989e08 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -95,3 +95,22 @@ void SPUThread::DoStop() delete m_dec; m_dec = nullptr; } + +void SPUThread::DoClose() +{ + // disconnect all event ports + if (Emu.IsStopped()) + { + return; + } + for (u32 i = 0; i < 64; i++) + { + EventPort& port = SPUPs[i]; + SMutexLocker lock(port.mutex); + if (port.eq) + { + port.eq->ports.remove(&port); + port.eq = nullptr; + } + } +} \ No newline at end of file diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index 89f39c32ce..fcaccd72c9 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -275,6 +275,9 @@ public: FPSCR FPSCR; SPU_SNRConfig_hdr cfg; //Signal Notification Registers Configuration (OR-mode enabled: 0x1 for SNR1, 0x2 for SNR2) + EventPort SPUPs[64]; // SPU Thread Event Ports + EventManager SPUQs; // SPU Queue Mapping + template class Channel { @@ -317,8 +320,13 @@ public: { return false; } - res = m_value[--m_index]; - m_value[m_index] = 0; + res = m_value[0]; + for (u32 i = 1; i < max_count; i++) // FIFO + { + m_value[i-1] = m_value[i]; + } + m_value[max_count-1] = 0; + m_index--; return true; } else @@ -479,7 +487,6 @@ public: struct { Channel<1> Out_MBox; - Channel<1> OutIntr_Mbox; Channel<4> In_MBox; Channel<1> MBox_Status; Channel<1> RunCntl; @@ -616,11 +623,14 @@ public: case SPU_WrOutIntrMbox: ConLog.Warning("GetChannelCount(%s) = 0", wxString(spu_ch_name[ch]).wx_str()); - return 0;//return SPU.OutIntr_Mbox.GetFreeCount(); + return 0; case MFC_RdTagStat: return Prxy.TagStatus.GetCount(); + case MFC_WrTagUpdate: + return Prxy.TagStatus.GetCount(); // hack + case SPU_RdSigNotify1: return SPU.SNR[0].GetCount(); @@ -646,12 +656,63 @@ public: switch(ch) { case SPU_WrOutIntrMbox: - ConLog.Warning("%s: %s = 0x%x", wxString(__FUNCTION__).wx_str(), wxString(spu_ch_name[ch]).wx_str(), v); - while (!SPU.OutIntr_Mbox.Push(v) && !Emu.IsStopped()) Sleep(1); + { + u8 code = v >> 24; + if (code < 64) + { + /* ===== sys_spu_thread_send_event ===== */ + + u8 spup = code & 63; + + u32 data; + if (!SPU.Out_MBox.Pop(data)) + { + ConLog.Error("sys_spu_thread_send_event(v=0x%x, spup=%d): Out_MBox is empty", v, spup); + return; + } + + if (SPU.In_MBox.GetCount()) + { + ConLog.Error("sys_spu_thread_send_event(v=0x%x, spup=%d): In_MBox is not empty", v, spup); + SPU.In_MBox.PushUncond(CELL_EBUSY); // ??? + return; + } + + if (Ini.HLELogging.GetValue()) + { + ConLog.Write("sys_spu_thread_send_event(spup=%d, data0=0x%x, data1=0x%x)", spup, v & 0x00ffffff, data); + } + + EventPort& port = SPUPs[spup]; + + SMutexLocker lock(port.mutex); + + if (!port.eq) + { + SPU.In_MBox.PushUncond(CELL_ENOTCONN); // check error passing + return; + } + + if (!port.eq->events.push(SYS_SPU_THREAD_EVENT_USER_KEY, lock.tid, ((u64)code << 32) | (v & 0x00ffffff), data)) + { + SPU.In_MBox.PushUncond(CELL_EBUSY); + return; + } + + SPU.In_MBox.PushUncond(CELL_OK); + return; + } + else + { + ConLog.Error("SPU_WrOutIntrMbox: unknown data (v=0x%x)", v); + SPU.In_MBox.PushUncond(CELL_EINVAL); // ??? + return; + } + } break; case SPU_WrOutMbox: - ConLog.Warning("%s: %s = 0x%x", wxString(__FUNCTION__).wx_str(), wxString(spu_ch_name[ch]).wx_str(), v); + //ConLog.Warning("%s: %s = 0x%x", wxString(__FUNCTION__).wx_str(), wxString(spu_ch_name[ch]).wx_str(), v); while (!SPU.Out_MBox.Push(v) && !Emu.IsStopped()) Sleep(1); break; @@ -707,7 +768,7 @@ public: { case SPU_RdInMbox: while (!SPU.In_MBox.Pop(v) && !Emu.IsStopped()) Sleep(1); - ConLog.Warning("%s: 0x%x = %s", wxString(__FUNCTION__).wx_str(), v, wxString(spu_ch_name[ch]).wx_str()); + //ConLog.Warning("%s: 0x%x = %s", wxString(__FUNCTION__).wx_str(), v, wxString(spu_ch_name[ch]).wx_str()); break; case MFC_RdTagStat: @@ -738,7 +799,7 @@ public: } bool IsGoodLSA(const u32 lsa) const { return Memory.IsGoodAddr(lsa + m_offset) && lsa < 0x40000; } - virtual u8 ReadLS8 (const u32 lsa) const { return Memory.Read8 (lsa + (m_offset & 0x3fffc)); } + virtual u8 ReadLS8 (const u32 lsa) const { return Memory.Read8 (lsa + m_offset); } // m_offset & 0x3fffc ????? virtual u16 ReadLS16 (const u32 lsa) const { return Memory.Read16 (lsa + m_offset); } virtual u32 ReadLS32 (const u32 lsa) const { return Memory.Read32 (lsa + m_offset); } virtual u64 ReadLS64 (const u32 lsa) const { return Memory.Read64 (lsa + m_offset); } @@ -805,6 +866,7 @@ protected: virtual void DoPause(); virtual void DoResume(); virtual void DoStop(); + virtual void DoClose(); }; SPUThread& GetCurrentSPUThread(); diff --git a/rpcs3/Emu/Event.cpp b/rpcs3/Emu/Event.cpp index d9efcc7267..e31e2601fa 100644 --- a/rpcs3/Emu/Event.cpp +++ b/rpcs3/Emu/Event.cpp @@ -26,6 +26,11 @@ bool EventManager::RegisterKey(EventQueue* data, u64 key) if (key_map.find(key) != key_map.end()) return false; + for (auto& v = key_map.begin(); v != key_map.end(); ++v) + { + if (v->second == data) return false; + } + key_map[key] = data; return true; @@ -58,4 +63,20 @@ bool EventManager::UnregisterKey(u64 key) return true; } return false; +} + +bool EventManager::SendEvent(u64 key, u64 source, u64 d1, u64 d2, u64 d3) +{ + if (!key) return false; + SMutexLocker lock(m_lock); + + auto f = key_map.find(key); + if (f == key_map.end()) + { + return false; + } + EventQueue* eq = f->second; + + eq->events.push(source, d1, d2, d3); + return true; } \ No newline at end of file diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index a96a62457b..48174ebe77 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -259,6 +259,8 @@ vfsDevice* VFS::GetDeviceLocal(const wxString& local_path, wxString& path) const void VFS::Init(const wxString& path) { + UnMountAll(); + Array entries; SaveLoadDevices(entries, true); diff --git a/rpcs3/Emu/FS/vfsDir.cpp b/rpcs3/Emu/FS/vfsDir.cpp index 7ce119601d..0d165c6ca5 100644 --- a/rpcs3/Emu/FS/vfsDir.cpp +++ b/rpcs3/Emu/FS/vfsDir.cpp @@ -56,7 +56,6 @@ const DirEntryInfo* vfsDir::Read() void vfsDir::Close() { m_stream.reset(); - return vfsDirBase::Close(); } wxString vfsDir::GetPath() const @@ -66,5 +65,5 @@ wxString vfsDir::GetPath() const bool vfsDir::IsOpened() const { - return m_stream && m_stream->IsOpened() && vfsDirBase::IsOpened(); + return m_stream && m_stream->IsOpened(); } diff --git a/rpcs3/Emu/FS/vfsDirBase.cpp b/rpcs3/Emu/FS/vfsDirBase.cpp index c7d1f65fb2..365d1effb6 100644 --- a/rpcs3/Emu/FS/vfsDirBase.cpp +++ b/rpcs3/Emu/FS/vfsDirBase.cpp @@ -13,7 +13,7 @@ vfsDirBase::~vfsDirBase() bool vfsDirBase::Open(const wxString& path) { - if(!IsOpened()) + if(IsOpened()) Close(); if(!IsExists(path)) diff --git a/rpcs3/Emu/FS/vfsDirBase.h b/rpcs3/Emu/FS/vfsDirBase.h index 05a9fb0a87..b6af8e1b62 100644 --- a/rpcs3/Emu/FS/vfsDirBase.h +++ b/rpcs3/Emu/FS/vfsDirBase.h @@ -2,9 +2,9 @@ enum DirEntryFlags { - DirEntry_TypeDir = 0x0, - DirEntry_TypeFile = 0x1, - DirEntry_TypeMask = 0x1, + DirEntry_TypeDir = 0x1, + DirEntry_TypeFile = 0x2, + DirEntry_TypeMask = 0x3, DirEntry_PermWritable = 0x20, DirEntry_PermReadable = 0x40, DirEntry_PermExecutable = 0x80, diff --git a/rpcs3/Emu/FS/vfsLocalDir.cpp b/rpcs3/Emu/FS/vfsLocalDir.cpp index d35de98a51..6ae8009a21 100644 --- a/rpcs3/Emu/FS/vfsLocalDir.cpp +++ b/rpcs3/Emu/FS/vfsLocalDir.cpp @@ -22,12 +22,12 @@ bool vfsLocalDir::Open(const wxString& path) wxString name; for(bool is_ok = dir.GetFirst(&name); is_ok; is_ok = dir.GetNext(&name)) { - wxString dir_path = path + wxFILE_SEP_PATH + name; + wxString dir_path = path + name; DirEntryInfo& info = m_entries[m_entries.Move(new DirEntryInfo())]; info.name = name; - info.flags |= wxDirExists(dir_path) ? DirEntry_TypeDir : DirEntry_TypeFile; + info.flags |= dir.Exists(dir_path) ? DirEntry_TypeDir : DirEntry_TypeFile; if(wxIsWritable(dir_path)) info.flags |= DirEntry_PermWritable; if(wxIsReadable(dir_path)) info.flags |= DirEntry_PermReadable; if(wxIsExecutable(dir_path)) info.flags |= DirEntry_PermExecutable; diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index b4c08c40c9..be30d8e121 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -655,6 +655,8 @@ void GLGSRender::OnInitThread() //glXSwapIntervalEXT(glXGetCurrentDisplay(), drawable, Ini.GSVSyncEnable.GetValue() ? 1 : 0); } #endif + glGenTextures(1, &g_depth_tex); + glGenTextures(1, &g_flip_tex); } void GLGSRender::OnExitThread() @@ -806,6 +808,8 @@ void GLGSRender::ExecCMD() checkForGlError("glColorMask"); } + //glFrontFace(m_front_face); + if(m_set_viewport_horizontal && m_set_viewport_vertical) { //glViewport(m_viewport_x, m_viewport_y, m_viewport_w, m_viewport_h); diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index b2c85a7920..7fb5238fb4 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -219,6 +219,10 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 { } break; + + case NV4097_SET_FRONT_FACE: + m_front_face = ARGS(0); + break; case_16(NV4097_SET_VERTEX_DATA4UB_M, 4): { @@ -658,7 +662,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 case NV4097_SET_SHADER_PROGRAM: { - m_cur_shader_prog = &m_shader_progs[m_cur_shader_prog_num++]; + m_cur_shader_prog = &m_shader_progs[/*m_cur_shader_prog_num++*/0]; u32 a0 = ARGS(0); m_cur_shader_prog->offset = a0 & ~0x3; m_cur_shader_prog->addr = GetAddress(m_cur_shader_prog->offset, (a0 & 0x3) - 1); @@ -1376,6 +1380,12 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 case 0x000002f8: break; + case NV0039_SET_CONTEXT_DMA_BUFFER_IN: + case NV0039_OFFSET_IN: + case NV0039_OFFSET_OUT: + //TODO + break; + case NV4097_SET_SURFACE_COLOR_AOFFSET: m_surface_offset_a = ARGS(0); break; @@ -1450,6 +1460,7 @@ void RSXThread::End() m_fragment_constants.Clear(); m_transform_constants.Clear(); m_cur_shader_prog_num = 0; + //m_cur_shader_prog = nullptr; m_clear_surface_mask = 0; m_begin_end = 0; diff --git a/rpcs3/Emu/GS/RSXThread.h b/rpcs3/Emu/GS/RSXThread.h index ca950e8d0c..c0e55d7871 100644 --- a/rpcs3/Emu/GS/RSXThread.h +++ b/rpcs3/Emu/GS/RSXThread.h @@ -91,7 +91,7 @@ class RSXThread : public ThreadBase public: static const uint m_textures_count = 16; static const uint m_vertex_count = 32; - static const uint m_fragment_count = 16; + static const uint m_fragment_count = 32; static const uint m_tiles_count = 15; protected: @@ -119,7 +119,6 @@ public: int m_debug_level; int m_frequency_mode; - u32 m_tiles_addr; u32 m_zculls_addr; u32 m_gcm_buffers_addr; @@ -378,6 +377,8 @@ public: u32 m_surface_colour_target; + u32 m_front_face; + u8 m_begin_end; bool m_read_buffer; @@ -425,6 +426,8 @@ protected: m_point_x = 0; m_point_y = 0; + m_front_face = 0x0901; + // Construct Textures for(int i=0; i<16; i++) { diff --git a/rpcs3/Emu/Memory/Memory.h b/rpcs3/Emu/Memory/Memory.h index b90be6a2d8..5e9ae0e863 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -400,18 +400,18 @@ public: extern MemoryBase Memory; -template +template class mem_base_t { protected: - u32 m_addr; + AT m_addr; public: - mem_base_t(u32 addr) : m_addr(addr) + mem_base_t(AT addr) : m_addr(addr) { } - __forceinline u32 GetAddr() const { return m_addr; } + __forceinline AT GetAddr() const { return m_addr; } __forceinline bool IsGood() const { @@ -434,16 +434,16 @@ public: } }; -template -class mem_ptr_t : public mem_base_t +template +class mem_ptr_t : public mem_base_t { public: - mem_ptr_t(u32 addr) : mem_base_t(addr) + mem_ptr_t(AT addr) : mem_base_t(addr) { } - template operator mem_ptr_t&() { return (mem_ptr_t&)*this; } - template operator const mem_ptr_t&() const { return (const mem_ptr_t&)*this; } + template operator mem_ptr_t&() { return (mem_ptr_t&)*this; } + template operator const mem_ptr_t&() const { return (const mem_ptr_t&)*this; } T* operator -> () { @@ -538,11 +538,11 @@ public: bool operator <= (T* right) const { return (T*)&Memory[this->m_addr] <= right; } }; -template<> -class mem_ptr_t : public mem_base_t +template +class mem_ptr_t : public mem_base_t { public: - mem_ptr_t(u32 addr) : mem_base_t(addr) + mem_ptr_t(AT addr) : mem_base_t(addr) { } @@ -571,10 +571,13 @@ template static bool operator < (T* left, mem_ptr_t right) { retu template static bool operator >= (T* left, mem_ptr_t right) { return left >= (T*)&Memory[right.GetAddr()]; } template static bool operator <= (T* left, mem_ptr_t right) { return left <= (T*)&Memory[right.GetAddr()]; } -template class mem_t : public mem_base_t +template +class mem_beptr_t : public mem_ptr_t> {}; + +template class mem_t : public mem_base_t { public: - mem_t(u32 addr) : mem_base_t(addr) + mem_t(AT addr) : mem_base_t(addr) { } @@ -607,7 +610,7 @@ public: mem_t& operator >>= (T right) { return *this = (*this) >> right; } }; -template class mem_list_ptr_t : public mem_base_t +template class mem_list_ptr_t : public mem_base_t { public: mem_list_ptr_t(u32 addr) : mem_base_t(addr) @@ -688,18 +691,18 @@ struct _func_arg }; template -struct _func_arg> +struct _func_arg> { - __forceinline static u64 get_value(const mem_base_t arg) + __forceinline static u64 get_value(const mem_base_t arg) { return arg.GetAddr(); } }; -template struct _func_arg> : public _func_arg> {}; -template<> struct _func_arg> : public _func_arg> {}; -template struct _func_arg> : public _func_arg> {}; -template struct _func_arg> : public _func_arg> {}; +template struct _func_arg> : public _func_arg> {}; +template<> struct _func_arg> : public _func_arg> {}; +template struct _func_arg> : public _func_arg> {}; +template struct _func_arg> : public _func_arg> {}; template struct _func_arg> @@ -936,10 +939,10 @@ public: } }; -typedef mem_t mem8_t; -typedef mem_t mem16_t; -typedef mem_t mem32_t; -typedef mem_t mem64_t; +typedef mem_t mem8_t; +typedef mem_t mem16_t; +typedef mem_t mem32_t; +typedef mem_t mem64_t; /* typedef mem_ptr_t> mem8_ptr_t; @@ -953,7 +956,7 @@ typedef mem_list_ptr_t mem32_lptr_t; typedef mem_list_ptr_t mem64_lptr_t; */ -typedef mem_list_ptr_t mem8_ptr_t; -typedef mem_list_ptr_t mem16_ptr_t; -typedef mem_list_ptr_t mem32_ptr_t; -typedef mem_list_ptr_t mem64_ptr_t; +typedef mem_list_ptr_t mem8_ptr_t; +typedef mem_list_ptr_t mem16_ptr_t; +typedef mem_list_ptr_t mem32_ptr_t; +typedef mem_list_ptr_t mem64_ptr_t; diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h index e7e9f28d7f..faef27d9b7 100644 --- a/rpcs3/Emu/SysCalls/Modules.h +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -73,6 +73,18 @@ public: return true; } + + template bool CheckId(u32 id, T*& data, u32& attr) + { + ID* id_data; + + if(!CheckID(id, id_data)) return false; + + data = id_data->m_data->get(); + attr = id_data->m_attr; + + return true; + } bool CheckID(u32 id, ID*& _id) const; template diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp index e24f361c62..5829ac0e29 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp @@ -1,71 +1,64 @@ #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" +#include "cellAdec.h" void cellAdec_init(); Module cellAdec(0x0006, cellAdec_init); -// Error Codes -enum +int cellAdecQueryAttr(mem_ptr_t type, mem_ptr_t attr) { - CELL_ADEC_ERROR_FATAL = 0x80610001, - CELL_ADEC_ERROR_SEQ = 0x80610002, - CELL_ADEC_ERROR_ARG = 0x80610003, - CELL_ADEC_ERROR_BUSY = 0x80610004, - CELL_ADEC_ERROR_EMPTY = 0x80610005, -}; - -int cellAdecQueryAttr() -{ - UNIMPLEMENTED_FUNC(cellAdec); + cellAdec.Error("cellAdecQueryAttr(type_addr=0x%x, attr_addr=0x%x)", type.GetAddr(), attr.GetAddr()); return CELL_OK; } -int cellAdecOpen() +int cellAdecOpen(mem_ptr_t type, mem_ptr_t res, mem_ptr_t cb, mem32_t handle) { - UNIMPLEMENTED_FUNC(cellAdec); + cellAdec.Error("cellAdecOpen(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", + type.GetAddr(), res.GetAddr(), cb.GetAddr(), handle.GetAddr()); return CELL_OK; } -int cellAdecOpenEx() +int cellAdecOpenEx(mem_ptr_t type, mem_ptr_t res, mem_ptr_t cb, mem32_t handle) { - UNIMPLEMENTED_FUNC(cellAdec); + cellAdec.Error("cellAdecOpenEx(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", + type.GetAddr(), res.GetAddr(), cb.GetAddr(), handle.GetAddr()); return CELL_OK; } -int cellAdecClose() +int cellAdecClose(u32 handle) { - UNIMPLEMENTED_FUNC(cellAdec); + cellAdec.Error("cellAdecClose(handle=0x%x)", handle); return CELL_OK; } -int cellAdecStartSeq() +int cellAdecStartSeq(u32 handle, u32 param_addr) { - UNIMPLEMENTED_FUNC(cellAdec); + cellAdec.Error("cellAdecStartSeq(handle=0x%x, param_addr=0x%x)", handle, param_addr); return CELL_OK; } -int cellAdecEndSeq() +int cellAdecEndSeq(u32 handle) { - UNIMPLEMENTED_FUNC(cellAdec); + cellAdec.Error("cellAdecEndSeq(handle=0x%x)", handle); return CELL_OK; } -int cellAdecDecodeAu() +int cellAdecDecodeAu(u32 handle, mem_ptr_t auInfo) { - UNIMPLEMENTED_FUNC(cellAdec); + cellAdec.Error("cellAdecDecodeAu(handle=0x%x, auInfo_addr=0x%x)", handle, auInfo.GetAddr()); return CELL_OK; } -int cellAdecGetPcm() +int cellAdecGetPcm(u32 handle, u32 outBuffer_addr) { - UNIMPLEMENTED_FUNC(cellAdec); + cellAdec.Error("cellAdecGetPcm(handle=0x%x, outBuffer_addr=0x%x)", handle, outBuffer_addr); return CELL_OK; } -int cellAdecGetPcmItem() +int cellAdecGetPcmItem(u32 handle, u32 pcmItem_ptr_addr) { - UNIMPLEMENTED_FUNC(cellAdec); + cellAdec.Error("cellAdecGetPcmItem(handle=0x%x, pcmItem_ptr_addr=0x%x)", handle, pcmItem_ptr_addr); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.h b/rpcs3/Emu/SysCalls/Modules/cellAdec.h new file mode 100644 index 0000000000..9f9e633110 --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.h @@ -0,0 +1,983 @@ +#pragma once +#include "cellPamf.h" + +// Error Codes +enum +{ + CELL_ADEC_ERROR_FATAL = 0x80610001, + CELL_ADEC_ERROR_SEQ = 0x80610002, + CELL_ADEC_ERROR_ARG = 0x80610003, + CELL_ADEC_ERROR_BUSY = 0x80610004, + CELL_ADEC_ERROR_EMPTY = 0x80610005, + + CELL_ADEC_ERROR_CELP_BUSY = 0x80612e01, + CELL_ADEC_ERROR_CELP_EMPTY = 0x80612e02, + CELL_ADEC_ERROR_CELP_ARG = 0x80612e03, + CELL_ADEC_ERROR_CELP_SEQ = 0x80612e04, + CELL_ADEC_ERROR_CELP_CORE_FATAL = 0x80612e81, + CELL_ADEC_ERROR_CELP_CORE_ARG = 0x80612e82, + CELL_ADEC_ERROR_CELP_CORE_SEQ = 0x80612e83, + + CELL_ADEC_ERROR_CELP8_BUSY = 0x80612ea1, + CELL_ADEC_ERROR_CELP8_EMPTY = 0x80612ea2, + CELL_ADEC_ERROR_CELP8_ARG = 0x80612ea3, + CELL_ADEC_ERROR_CELP8_SEQ = 0x80612ea4, + CELL_ADEC_ERROR_CELP8_CORE_FATAL = 0x80612eb1, + CELL_ADEC_ERROR_CELP8_CORE_ARG = 0x80612eb2, + CELL_ADEC_ERROR_CELP8_CORE_SEQ = 0x80612eb3, + + CELL_ADEC_ERROR_M4AAC_FATAL = 0x80612401, + CELL_ADEC_ERROR_M4AAC_SEQ = 0x80612402, + CELL_ADEC_ERROR_M4AAC_ARG = 0x80612403, + CELL_ADEC_ERROR_M4AAC_BUSY = 0x80612404, + CELL_ADEC_ERROR_M4AAC_EMPTY = 0x80612405, + CELL_ADEC_ERROR_M4AAC_BUFFER_OVERFLOW = 0x80612406, + CELL_ADEC_ERROR_M4AAC_END_OF_BITSTREAM = 0x80612407, + + /* Core */ + CELL_ADEC_ERROR_M4AAC_CH_CONFIG_INCONSISTENCY = 0x80612410, + CELL_ADEC_ERROR_M4AAC_NO_CH_DEFAULT_POS = 0x80612411, + CELL_ADEC_ERROR_M4AAC_INVALID_CH_POS = 0x80612412, + CELL_ADEC_ERROR_M4AAC_UNANTICIPATED_COUPLING_CH = 0x80612413, + CELL_ADEC_ERROR_M4AAC_INVALID_LAYER_ID = 0x80612414, + CELL_ADEC_ERROR_M4AAC_ADTS_SYNCWORD_ERROR = 0x80612415, + CELL_ADEC_ERROR_M4AAC_INVALID_ADTS_ID = 0x80612416, + CELL_ADEC_ERROR_M4AAC_CH_CHANGED = 0x80612417, + CELL_ADEC_ERROR_M4AAC_SAMPLING_FREQ_CHANGED = 0x80612418, + CELL_ADEC_ERROR_M4AAC_WRONG_SBR_CH = 0x80612419, + CELL_ADEC_ERROR_M4AAC_WRONG_SCALE_FACTOR = 0x8061241a, + CELL_ADEC_ERROR_M4AAC_INVALID_BOOKS = 0x8061241b, + CELL_ADEC_ERROR_M4AAC_INVALID_SECTION_DATA = 0x8061241c, + CELL_ADEC_ERROR_M4AAC_PULSE_IS_NOT_LONG = 0x8061241d, + CELL_ADEC_ERROR_M4AAC_GC_IS_NOT_SUPPORTED = 0x8061241e, + CELL_ADEC_ERROR_M4AAC_INVALID_ELEMENT_ID = 0x8061241f, + CELL_ADEC_ERROR_M4AAC_NO_CH_CONFIG = 0x80612420, + CELL_ADEC_ERROR_M4AAC_UNEXPECTED_OVERLAP_CRC = 0x80612421, + CELL_ADEC_ERROR_M4AAC_CRC_BUFFER_EXCEEDED = 0x80612422, + CELL_ADEC_ERROR_M4AAC_INVALID_CRC = 0x80612423, + CELL_ADEC_ERROR_M4AAC_BAD_WINDOW_CODE = 0x80612424, + CELL_ADEC_ERROR_M4AAC_INVALID_ADIF_HEADER_ID = 0x80612425, + CELL_ADEC_ERROR_M4AAC_NOT_SUPPORTED_PROFILE = 0x80612426, + CELL_ADEC_ERROR_M4AAC_PROG_NUMBER_NOT_FOUND = 0x80612427, + CELL_ADEC_ERROR_M4AAC_INVALID_SAMP_RATE_INDEX = 0x80612428, + CELL_ADEC_ERROR_M4AAC_UNANTICIPATED_CH_CONFIG = 0x80612429, + CELL_ADEC_ERROR_M4AAC_PULSE_OVERFLOWED = 0x8061242a, + CELL_ADEC_ERROR_M4AAC_CAN_NOT_UNPACK_INDEX = 0x8061242b, + CELL_ADEC_ERROR_M4AAC_DEINTERLEAVE_FAILED = 0x8061242c, + CELL_ADEC_ERROR_M4AAC_CALC_BAND_OFFSET_FAILED = 0x8061242d, + CELL_ADEC_ERROR_M4AAC_GET_SCALE_FACTOR_FAILED = 0x8061242e, + CELL_ADEC_ERROR_M4AAC_GET_CC_GAIN_FAILED = 0x8061242f, + CELL_ADEC_ERROR_M4AAC_MIX_COUPLING_CH_FAILED = 0x80612430, + CELL_ADEC_ERROR_M4AAC_GROUP_IS_INVALID = 0x80612431, + CELL_ADEC_ERROR_M4AAC_PREDICT_FAILED = 0x80612432, + CELL_ADEC_ERROR_M4AAC_INVALID_PREDICT_RESET_PATTERN = 0x80612433, + CELL_ADEC_ERROR_M4AAC_INVALID_TNS_FRAME_INFO = 0x80612434, + CELL_ADEC_ERROR_M4AAC_GET_MASK_FAILED = 0x80612435, + CELL_ADEC_ERROR_M4AAC_GET_GROUP_FAILED = 0x80612436, + CELL_ADEC_ERROR_M4AAC_GET_LPFLAG_FAILED = 0x80612437, + CELL_ADEC_ERROR_M4AAC_INVERSE_QUANTIZATION_FAILED = 0x80612438, + CELL_ADEC_ERROR_M4AAC_GET_CB_MAP_FAILED = 0x80612439, + CELL_ADEC_ERROR_M4AAC_GET_PULSE_FAILED = 0x8061243a, + CELL_ADEC_ERROR_M4AAC_MONO_MIXDOWN_ELEMENT_IS_NOT_SUPPORTED + = 0x8061243b, + CELL_ADEC_ERROR_M4AAC_STEREO_MIXDOWN_ELEMENT_IS_NOT_SUPPORTED + = 0x8061243c, + + CELL_ADEC_ERROR_M4AAC_SBR_CH_OVERFLOW = 0x80612480, + CELL_ADEC_ERROR_M4AAC_SBR_NOSYNCH = 0x80612481, + CELL_ADEC_ERROR_M4AAC_SBR_ILLEGAL_PROGRAM = 0x80612482, + CELL_ADEC_ERROR_M4AAC_SBR_ILLEGAL_TAG = 0x80612483, + CELL_ADEC_ERROR_M4AAC_SBR_ILLEGAL_CHN_CONFIG = 0x80612484, + CELL_ADEC_ERROR_M4AAC_SBR_ILLEGAL_SECTION = 0x80612485, + CELL_ADEC_ERROR_M4AAC_SBR_ILLEGAL_SCFACTORS = 0x80612486, + CELL_ADEC_ERROR_M4AAC_SBR_ILLEGAL_PULSE_DATA = 0x80612487, + CELL_ADEC_ERROR_M4AAC_SBR_MAIN_PROFILE_NOT_IMPLEMENTED = 0x80612488, + CELL_ADEC_ERROR_M4AAC_SBR_GC_NOT_IMPLEMENTED = 0x80612489, + CELL_ADEC_ERROR_M4AAC_SBR_ILLEGAL_PLUS_ELE_ID = 0x8061248a, + CELL_ADEC_ERROR_M4AAC_SBR_CREATE_ERROR = 0x8061248b, + CELL_ADEC_ERROR_M4AAC_SBR_NOT_INITIALIZED = 0x8061248c, + CELL_ADEC_ERROR_M4AAC_SBR_INVALID_ENVELOPE = 0x8061248d, + + + CELL_ADEC_ERROR_AC3_BUSY = 0x80612500, + CELL_ADEC_ERROR_AC3_EMPTY = 0x80612501, + CELL_ADEC_ERROR_AC3_PARAM = 0x80612502, + CELL_ADEC_ERROR_AC3_FRAME = 0x80612503, + + + CELL_ADEC_ERROR_AT3_OFFSET = 0x80612100, + CELL_ADEC_ERROR_AT3_OK = 0x80612100, + CELL_ADEC_ERROR_AT3_BUSY = 0x80612164, + CELL_ADEC_ERROR_AT3_EMPTY = 0x80612165, + CELL_ADEC_ERROR_AT3_ERROR = 0x80612180, + + + CELL_ADEC_ERROR_ATX_OFFSET = 0x80612200, + CELL_ADEC_ERROR_ATX_NONE = 0x80612200, + CELL_ADEC_ERROR_ATX_OK = 0x80612200, + CELL_ADEC_ERROR_ATX_BUSY = 0x80612264, + CELL_ADEC_ERROR_ATX_EMPTY = 0x80612265, + CELL_ADEC_ERROR_ATX_ATSHDR = 0x80612266, + CELL_ADEC_ERROR_ATX_NON_FATAL = 0x80612281, + CELL_ADEC_ERROR_ATX_NOT_IMPLE = 0x80612282, + CELL_ADEC_ERROR_ATX_PACK_CE_OVERFLOW = 0x80612283, + CELL_ADEC_ERROR_ATX_ILLEGAL_NPROCQUS = 0x80612284, + CELL_ADEC_ERROR_ATX_FATAL = 0x8061228c, + CELL_ADEC_ERROR_ATX_ENC_OVERFLOW = 0x8061228d, + CELL_ADEC_ERROR_ATX_PACK_CE_UNDERFLOW = 0x8061228e, + CELL_ADEC_ERROR_ATX_SYNTAX_IDCT = 0x8061228f, + CELL_ADEC_ERROR_ATX_SYNTAX_GAINADJ = 0x80612290, + CELL_ADEC_ERROR_ATX_SYNTAX_IDSF = 0x80612291, + CELL_ADEC_ERROR_ATX_SYNTAX_SPECTRA = 0x80612292, + CELL_ADEC_ERROR_ATX_SYNTAX_IDWL = 0x80612293, + CELL_ADEC_ERROR_ATX_SYNTAX_GHWAVE = 0x80612294, + CELL_ADEC_ERROR_ATX_SYNTAX_SHEADER = 0x80612295, + CELL_ADEC_ERROR_ATX_SYNTAX_IDWL_A = 0x80612296, + CELL_ADEC_ERROR_ATX_SYNTAX_IDWL_B = 0x80612297, + CELL_ADEC_ERROR_ATX_SYNTAX_IDWL_C = 0x80612298, + CELL_ADEC_ERROR_ATX_SYNTAX_IDWL_D = 0x80612299, + CELL_ADEC_ERROR_ATX_SYNTAX_IDWL_E = 0x8061229a, + CELL_ADEC_ERROR_ATX_SYNTAX_IDSF_A = 0x8061229b, + CELL_ADEC_ERROR_ATX_SYNTAX_IDSF_B = 0x8061229c, + CELL_ADEC_ERROR_ATX_SYNTAX_IDSF_C = 0x8061229d, + CELL_ADEC_ERROR_ATX_SYNTAX_IDSF_D = 0x8061229e, + CELL_ADEC_ERROR_ATX_SYNTAX_IDCT_A = 0x8061229f, + CELL_ADEC_ERROR_ATX_SYNTAX_GC_NGC = 0x806122a0, + CELL_ADEC_ERROR_ATX_SYNTAX_GC_IDLEV_A = 0x806122a1, + CELL_ADEC_ERROR_ATX_SYNTAX_GC_IDLOC_A = 0x806122a2, + CELL_ADEC_ERROR_ATX_SYNTAX_GC_IDLEV_B = 0x806122a3, + CELL_ADEC_ERROR_ATX_SYNTAX_GC_IDLOC_B = 0x806122a4, + CELL_ADEC_ERROR_ATX_SYNTAX_SN_NWVS = 0x806122a5, + CELL_ADEC_ERROR_ATX_FATAL_HANDLE = 0x806122aa, + CELL_ADEC_ERROR_ATX_ASSERT_SAMPLING_FREQ = 0x806122ab, + CELL_ADEC_ERROR_ATX_ASSERT_CH_CONFIG_INDEX = 0x806122ac, + CELL_ADEC_ERROR_ATX_ASSERT_NBYTES = 0x806122ad, + CELL_ADEC_ERROR_ATX_ASSERT_BLOCK_NUM = 0x806122ae, + CELL_ADEC_ERROR_ATX_ASSERT_BLOCK_ID = 0x806122af, + CELL_ADEC_ERROR_ATX_ASSERT_CHANNELS = 0x806122b0, + CELL_ADEC_ERROR_ATX_UNINIT_BLOCK_SPECIFIED = 0x806122b1, + CELL_ADEC_ERROR_ATX_POSCFG_PRESENT = 0x806122b2, + CELL_ADEC_ERROR_ATX_BUFFER_OVERFLOW = 0x806122b3, + CELL_ADEC_ERROR_ATX_ILL_BLK_TYPE_ID = 0x806122b4, + CELL_ADEC_ERROR_ATX_UNPACK_CHANNEL_BLK_FAILED = 0x806122b5, + CELL_ADEC_ERROR_ATX_ILL_BLK_ID_USED_1 = 0x806122b6, + CELL_ADEC_ERROR_ATX_ILL_BLK_ID_USED_2 = 0x806122b7, + CELL_ADEC_ERROR_ATX_ILLEGAL_ENC_SETTING = 0x806122b8, + CELL_ADEC_ERROR_ATX_ILLEGAL_DEC_SETTING = 0x806122b9, + CELL_ADEC_ERROR_ATX_ASSERT_NSAMPLES = 0x806122ba, + + CELL_ADEC_ERROR_ATX_ILL_SYNCWORD = 0x806122bb, + CELL_ADEC_ERROR_ATX_ILL_SAMPLING_FREQ = 0x806122bc, + CELL_ADEC_ERROR_ATX_ILL_CH_CONFIG_INDEX = 0x806122bd, + CELL_ADEC_ERROR_ATX_RAW_DATA_FRAME_SIZE_OVER = 0x806122be, + CELL_ADEC_ERROR_ATX_SYNTAX_ENHANCE_LENGTH_OVER = 0x806122bf, + CELL_ADEC_ERROR_ATX_SPU_INTERNAL_FAIL = 0x806122c8, + + + CELL_ADEC_ERROR_LPCM_FATAL = 0x80612001, + CELL_ADEC_ERROR_LPCM_SEQ = 0x80612002, + CELL_ADEC_ERROR_LPCM_ARG = 0x80612003, + CELL_ADEC_ERROR_LPCM_BUSY = 0x80612004, + CELL_ADEC_ERROR_LPCM_EMPTY = 0x80612005, + + + CELL_ADEC_ERROR_MP3_OFFSET = 0x80612700U, + CELL_ADEC_ERROR_MP3_OK = 0x80612700, + CELL_ADEC_ERROR_MP3_BUSY = 0x80612764, + CELL_ADEC_ERROR_MP3_EMPTY = 0x80612765, + CELL_ADEC_ERROR_MP3_ERROR = 0x80612781, + CELL_ADEC_ERROR_MP3_LOST_SYNC = 0x80612782, + CELL_ADEC_ERROR_MP3_NOT_L3 = 0x80612783, + CELL_ADEC_ERROR_MP3_BAD_BITRATE = 0x80612784, + CELL_ADEC_ERROR_MP3_BAD_SFREQ = 0x80612785, + CELL_ADEC_ERROR_MP3_BAD_EMPHASIS = 0x80612786, + CELL_ADEC_ERROR_MP3_BAD_BLKTYPE = 0x80612787, + CELL_ADEC_ERROR_MP3_BAD_VERSION = 0x8061278c, + CELL_ADEC_ERROR_MP3_BAD_MODE = 0x8061278d, + CELL_ADEC_ERROR_MP3_BAD_MODE_EXT = 0x8061278e, + CELL_ADEC_ERROR_MP3_HUFFMAN_NUM = 0x80612796, + CELL_ADEC_ERROR_MP3_HUFFMAN_CASE_ID = 0x80612797, + CELL_ADEC_ERROR_MP3_SCALEFAC_COMPRESS = 0x80612798, + CELL_ADEC_ERROR_MP3_HGETBIT = 0x80612799, + CELL_ADEC_ERROR_MP3_FLOATING_EXCEPTION = 0x8061279a, + CELL_ADEC_ERROR_MP3_ARRAY_OVERFLOW = 0x8061279b, + CELL_ADEC_ERROR_MP3_STEREO_PROCESSING = 0x8061279c, + CELL_ADEC_ERROR_MP3_JS_BOUND = 0x8061279d, + CELL_ADEC_ERROR_MP3_PCMOUT = 0x8061279e, + + + CELL_ADEC_ERROR_M2BC_FATAL = 0x80612b01, + CELL_ADEC_ERROR_M2BC_SEQ = 0x80612b02, + CELL_ADEC_ERROR_M2BC_ARG = 0x80612b03, + CELL_ADEC_ERROR_M2BC_BUSY = 0x80612b04, + CELL_ADEC_ERROR_M2BC_EMPTY = 0x80612b05, + + CELL_ADEC_ERROR_M2BC_SYNCF = 0x80612b11, + CELL_ADEC_ERROR_M2BC_LAYER = 0x80612b12, + CELL_ADEC_ERROR_M2BC_BITRATE = 0x80612b13, + CELL_ADEC_ERROR_M2BC_SAMPLEFREQ = 0x80612b14, + CELL_ADEC_ERROR_M2BC_VERSION = 0x80612b15, + CELL_ADEC_ERROR_M2BC_MODE_EXT = 0x80612b16, + CELL_ADEC_ERROR_M2BC_UNSUPPORT = 0x80612b17, + + CELL_ADEC_ERROR_M2BC_OPENBS_EX = 0x80612b21, + CELL_ADEC_ERROR_M2BC_SYNCF_EX = 0x80612b22, + CELL_ADEC_ERROR_M2BC_CRCGET_EX = 0x80612b23, + CELL_ADEC_ERROR_M2BC_CRC_EX = 0x80612b24, + + CELL_ADEC_ERROR_M2BC_CRCGET = 0x80612b31, + CELL_ADEC_ERROR_M2BC_CRC = 0x80612b32, + CELL_ADEC_ERROR_M2BC_BITALLOC = 0x80612b33, + CELL_ADEC_ERROR_M2BC_SCALE = 0x80612b34, + CELL_ADEC_ERROR_M2BC_SAMPLE = 0x80612b35, + CELL_ADEC_ERROR_M2BC_OPENBS = 0x80612b36, + + CELL_ADEC_ERROR_M2BC_MC_CRCGET = 0x80612b41, + CELL_ADEC_ERROR_M2BC_MC_CRC = 0x80612b42, + CELL_ADEC_ERROR_M2BC_MC_BITALLOC = 0x80612b43, + CELL_ADEC_ERROR_M2BC_MC_SCALE = 0x80612b44, + CELL_ADEC_ERROR_M2BC_MC_SAMPLE = 0x80612b45, + CELL_ADEC_ERROR_M2BC_MC_HEADER = 0x80612b46, + CELL_ADEC_ERROR_M2BC_MC_STATUS = 0x80612b47, + + CELL_ADEC_ERROR_M2BC_AG_CCRCGET = 0x80612b51, + CELL_ADEC_ERROR_M2BC_AG_CRC = 0x80612b52, + CELL_ADEC_ERROR_M2BC_AG_BITALLOC = 0x80612b53, + CELL_ADEC_ERROR_M2BC_AG_SCALE = 0x80612b54, + CELL_ADEC_ERROR_M2BC_AG_SAMPLE = 0x80612b55, + CELL_ADEC_ERROR_M2BC_AG_STATUS = 0x80612b57, +}; + +// Audio Codec Type +enum AudioCodecType +{ + CELL_ADEC_TYPE_RESERVED1, + CELL_ADEC_TYPE_LPCM_PAMF, + CELL_ADEC_TYPE_AC3, + CELL_ADEC_TYPE_ATRACX, + CELL_ADEC_TYPE_MP3, + CELL_ADEC_TYPE_ATRAC3, + CELL_ADEC_TYPE_MPEG_L2, + CELL_ADEC_TYPE_RESERVED5, + CELL_ADEC_TYPE_RESERVED6, + CELL_ADEC_TYPE_RESERVED7, + CELL_ADEC_TYPE_RESERVED8, + CELL_ADEC_TYPE_CELP, + CELL_ADEC_TYPE_RESERVED10, + CELL_ADEC_TYPE_ATRACX_2CH, + CELL_ADEC_TYPE_ATRACX_6CH, + CELL_ADEC_TYPE_ATRACX_8CH, + CELL_ADEC_TYPE_M4AAC, + CELL_ADEC_TYPE_RESERVED12, + CELL_ADEC_TYPE_RESERVED13, + CELL_ADEC_TYPE_RESERVED14, + CELL_ADEC_TYPE_RESERVED15, + CELL_ADEC_TYPE_RESERVED16, + CELL_ADEC_TYPE_RESERVED17, + CELL_ADEC_TYPE_RESERVED18, + CELL_ADEC_TYPE_RESERVED19, + CELL_ADEC_TYPE_CELP8, + CELL_ADEC_TYPE_RESERVED20, + CELL_ADEC_TYPE_RESERVED21, + CELL_ADEC_TYPE_RESERVED22, + CELL_ADEC_TYPE_RESERVED23, + CELL_ADEC_TYPE_RESERVED24, + CELL_ADEC_TYPE_RESERVED25, +}; + +// Output Channel Number +enum CellAdecChannel +{ + CELL_ADEC_CH_RESERVED1, + CELL_ADEC_CH_MONO, + CELL_ADEC_CH_RESERVED2, + CELL_ADEC_CH_STEREO, + CELL_ADEC_CH_3_0, + CELL_ADEC_CH_2_1, + CELL_ADEC_CH_3_1, + CELL_ADEC_CH_2_2, + CELL_ADEC_CH_3_2, + CELL_ADEC_CH_3_2_LFE, + CELL_ADEC_CH_3_4, + CELL_ADEC_CH_3_4_LFE, + CELL_ADEC_CH_RESERVED3, +}; + +// Sampling Rate +enum CellAdecSampleRate +{ + CELL_ADEC_FS_RESERVED1 = 0, + CELL_ADEC_FS_48kHz = 1, + CELL_ADEC_FS_16kHz = 2, + CELL_ADEC_FS_8kHz = 5, +}; + +enum CellAdecBitLength +{ + CELL_ADEC_BIT_LENGTH_RESERVED1, + CELL_ADEC_BIT_LENGTH_16, + CELL_ADEC_BIT_LENGTH_20, + CELL_ADEC_BIT_LENGTH_24, +}; + +struct CellAdecType +{ + be_t audioCodecType; +}; + +struct CellAdecAttr +{ + be_t workMemSize; + be_t adecVerUpper; + be_t adecVerLower; +}; + +struct CellAdecResource +{ + be_t totalMemSize; + be_t startAddr; + be_t ppuThreadPriority; + be_t spuThreadPriority; + be_t ppuThreadStackSize; +}; + +// Callback Messages +enum CellAdecMsgType +{ + CELL_ADEC_MSG_TYPE_AUDONE, + CELL_ADEC_MSG_TYPE_PCMOUT, + CELL_ADEC_MSG_TYPE_ERROR, + CELL_ADEC_MSG_TYPE_SEQDONE, +}; + +struct CellAdecCb +{ + be_t> cbFunc; + be_t cbArg_addr; +}; + +typedef CellCodecTimeStamp CellAdecTimeStamp; + +// AU Info +struct CellAdecAuInfo +{ + be_t startAddr; + be_t size; + CellCodecTimeStamp pts; + be_t userData; +}; + +// BSI Info +struct CellAdecPcmAttr +{ + be_t bsiInfo_addr; +}; + +struct CellAdecPcmItem +{ + be_t pcmHandle; + be_t status; + be_t startAddr; + be_t size; + CellAdecPcmAttr pcmAttr; + CellAdecAuInfo auInfo; +}; + +struct CellAdecParamLpcm +{ + be_t channelNumber; + be_t sampleRate; + be_t sizeOfWord; + be_t audioPayloadSize; +}; + +// LPCM BSI +struct CellAdecLpcmInfo +{ + be_t channelNumber; + be_t sampleRate; + be_t outputDataSize; +}; + +struct CellAdecResourceEx +{ + be_t totalMemSize; + be_t startAddr; + be_t ppuThreadPriority; + be_t ppuThreadStackSize; + be_t spurs_addr; + u8 priority[8]; + be_t maxContention; +}; + +// CELP Excitation Mode +enum CELP_ExcitationMode +{ + CELL_ADEC_CELP_EXCITATION_MODE_RPE = 1, +}; + +// CELP RPE Configuration +enum CELP_RPEConfig +{ + CELL_ADEC_CELP_RPE_CONFIG_0, + CELL_ADEC_CELP_RPE_CONFIG_1, + CELL_ADEC_CELP_RPE_CONFIG_2, + CELL_ADEC_CELP_RPE_CONFIG_3, +}; + +// CELP Word Size +enum CELP_WordSize +{ + CELL_ADEC_CELP_WORD_SZ_INT16_LE, + CELL_ADEC_CELP_WORD_SZ_FLOAT, +}; + +// CELP Parameters +struct CellAdecParamCelp +{ + be_t excitationMode; + be_t sampleRate; // CELL_ADEC_FS_16kHz + be_t configuration; + be_t wordSize; +}; + +// CELP BSI (same as CellAdecParamCelp ???) +struct CellAdecCelpInfo +{ + be_t excitationMode; + be_t sampleRate; // CELL_ADEC_FS_16kHz + be_t configuration; + be_t wordSize; +}; + +// CELP8 Excitation Mode +enum CELP8_ExcitationMode +{ + CELL_ADEC_CELP8_EXCITATION_MODE_MPE = 0, +}; + +// CELP8 MPE Configuration +enum CELP8_MPEConfig +{ + CELL_ADEC_CELP8_MPE_CONFIG_0 = 0, + CELL_ADEC_CELP8_MPE_CONFIG_2 = 2, + CELL_ADEC_CELP8_MPE_CONFIG_6 = 6, + CELL_ADEC_CELP8_MPE_CONFIG_9 = 9, + CELL_ADEC_CELP8_MPE_CONFIG_12 = 12, + CELL_ADEC_CELP8_MPE_CONFIG_15 = 15, + CELL_ADEC_CELP8_MPE_CONFIG_18 = 18, + CELL_ADEC_CELP8_MPE_CONFIG_21 = 21, + CELL_ADEC_CELP8_MPE_CONFIG_24 = 24, + CELL_ADEC_CELP8_MPE_CONFIG_26 = 26, +}; + +// CELP8 Word Size +enum CELP8_WordSize +{ + CELL_ADEC_CELP8_WORD_SZ_FLOAT, +}; + +// CELP8 Parameters +struct CellAdecParamCelp8 +{ + be_t excitationMode; + be_t sampleRate; // CELL_ADEC_FS_8kHz + be_t configuration; + be_t wordSize; +}; + +// CELP8 BSI +struct CellAdecCelp8Info +{ + be_t excitationMode; + be_t sampleRate; // CELL_ADEC_FS_8kHz + be_t configuration; + be_t wordSize; +}; + +enum MPEG4AAC_ConfigType +{ + ADIFHeader = 0, + ADTSHeader = 1, + RawDataBlockOnly = 2, +}; + +enum MPEG4AAC_SamplingFreq +{ + SF_96000 = 0, + SF_88200 = 1, + SF_64000 = 2, + SF_48000 = 3, + SF_44100 = 4, + SF_32000 = 5, + SF_24000 = 6, + SF_22050 = 7, + SF_16000 = 8, + SF_12000 = 9, + SF_11025 = 10, + SF_8000 = 11, +}; + +// MPEG4 AAC Parameters +struct CellAdecParamM4Aac +{ + be_t configNumber; + + union { + struct { struct + { + be_t adifProgramNumber; // 0 + } adifConfig; }; + + struct { struct + { + be_t samplingFreqIndex; + be_t profile; // LC profile (1) + } rawDataBlockConfig; }; + } configInfo; + + be_t enableDownmix; // enable downmix to 2.0 (if (enableDownmix)) +}; + +// MPEG4 AAC BSI +struct CellAdecM4AacInfo +{ + be_t samplingFreq; // [Hz] + be_t numberOfChannels; + be_t numberOfFrontChannels; + be_t numberOfFrontMonoChannels; + be_t numberOfSideChannels; + be_t numberOfBackChannels; + be_t numberOfLfeChannels; + be_t enableSBR; + be_t SBRUpsamplingFactor; + be_t isBsiValid; + be_t configNumber; + + be_t pad1; // TODO: check alignment + + union { + struct { struct + { + be_t copyrightIdPresent; + char copyrightId[9]; + be_t originalCopy; + be_t home; + be_t bitstreamType; + be_t bitrate; + be_t numberOfProgramConfigElements; + be_t bufferFullness; + } adif; }; + + struct { struct + { + be_t id; + be_t layer; + be_t protectionAbsent; + be_t profile; + be_t samplingFreqIndex; + be_t privateBit; + be_t channelConfiguration; + be_t originalCopy; + be_t home; + be_t copyrightIdBit; + be_t copyrightIdStart; + be_t frameLength; + be_t bufferFullness; + be_t numberOfRawDataBlocks; + be_t crcCheck; + } adts; }; + } bsi; + + be_t pad2; // TODO: check alignment + + struct + { + be_t matrixMixdownPresent; + be_t mixdownIndex; + be_t pseudoSurroundEnable; + } matrixMixdown; + + be_t reserved; +}; + +enum AC3_WordSize : u8 +{ + CELL_ADEC_AC3_WORD_SZ_INT16 = 0, + CELL_ADEC_AC3_WORD_SZ_FLOAT = 1, +}; + +enum AC3_OutputMode : u8 +{ + CELL_ADEC_AC3_OUTPUT_MODE_RESERVED = 0, + CELL_ADEC_AC3_OUTPUT_MODE_1_0 = 1, + CELL_ADEC_AC3_OUTPUT_MODE_2_0 = 2, + CELL_ADEC_AC3_OUTPUT_MODE_3_0 = 3, + CELL_ADEC_AC3_OUTPUT_MODE_2_1 = 4, + CELL_ADEC_AC3_OUTPUT_MODE_3_1 = 5, + CELL_ADEC_AC3_OUTPUT_MODE_2_2 = 6, + CELL_ADEC_AC3_OUTPUT_MODE_3_2 = 7, +}; + +enum AC3_LFE : u8 +{ + CELL_ADEC_AC3_LFE_NOT_PRESENT = 0, + CELL_ADEC_AC3_LFE_PRESENT = 1, +}; + +enum AC3_CompressionMode : u8 +{ + CELL_ADEC_AC3_COMPRESSION_MODE_CUSTOM_ANALOG = 0, + CELL_ADEC_AC3_COMPRESSION_MODE_CUSTOM_DIGITAL = 1, + CELL_ADEC_AC3_COMPRESSION_MODE_LINE_OUT = 2, + CELL_ADEC_AC3_COMPRESSION_MODE_RF_REMOD = 3, +}; + +enum AC3_StereoMode : u8 +{ + CELL_ADEC_AC3_STEREO_MODE_AUTO_DETECT = 0, + CELL_ADEC_AC3_STEREO_MODE_DOLBY_SURROUND_COMPATIBLE = 1, + CELL_ADEC_AC3_STEREO_MODE_STEREO = 2, +}; + +enum AC3_DualmonoMode : u8 +{ + CELL_ADEC_AC3_DUALMONO_MODE_STEREO = 0, + CELL_ADEC_AC3_DUALMONO_MODE_LEFT_MONO = 1, + CELL_ADEC_AC3_DUALMONO_MODE_RIGHT_MONO = 2, + CELL_ADEC_AC3_DUALMONO_MODE_MIXED_MONO = 3, +}; + +enum AC3_KaraokeCapableMode : u8 +{ + CELL_ADEC_AC3_KARAOKE_CAPABLE_MODE_NO_VOCAL = 0, + CELL_ADEC_AC3_KARAOKE_CAPABLE_MODE_LEFT_VOCAL = 1, + CELL_ADEC_AC3_KARAOKE_CAPABLE_MODE_RIGHT_VOCAL = 2, + CELL_ADEC_AC3_KARAOKE_CAPABLE_MODE_BOTH_VOCAL = 3, +}; + +enum AC3_InputChannel : u8 +{ + CELL_ADEC_AC3_INPUT_CHANNEL_L = 0, + CELL_ADEC_AC3_INPUT_CHANNEL_C = 1, + CELL_ADEC_AC3_INPUT_CHANNEL_R = 2, + CELL_ADEC_AC3_INPUT_CHANNEL_l = 3, + CELL_ADEC_AC3_INPUT_CHANNEL_r = 4, + CELL_ADEC_AC3_INPUT_CHANNEL_s = 5, +}; + +struct CellAdecParamAc3 +{ + AC3_WordSize wordSize; + AC3_OutputMode outputMode; + AC3_LFE outLfeOn; + + be_t drcCutScaleFactor; + be_t drcBoostScaleFactor; + + AC3_CompressionMode compressionMode; + AC3_InputChannel numberOfChannels; + AC3_StereoMode stereoMode; + AC3_DualmonoMode dualmonoMode; + AC3_KaraokeCapableMode karaokeCapableMode; + + be_t pcmScaleFactor; + + be_t channelPointer0; + be_t channelPointer1; + be_t channelPointer2; + be_t channelPointer3; + be_t channelPointer4; + be_t channelPointer5; +}; + +struct CellAdecBsiAc3 +{ + be_t codecType; + be_t versionInfo; + be_t totalCallCarryRun; + be_t totalCallNum; + be_t bitrateValue; + be_t pcmSize; + be_t esSizeBit; + be_t errorCode; + u8 libInfoFlag; + u8 validity; + u8 channelValue; + u8 fsIndex; + u8 outputQuantization; + u8 outputChannel; + u8 monoFlag; + be_t bsi[2]; + be_t frmSizeCod; + u8 acmod; + u8 lfeOn; + u8 karaokeMode; + u8 cmixlev; + u8 surmixlev; + u8 dsurmod; + u8 copyright; + u8 original; + u8 bsmod; + u8 bsid; + u8 xbsi1e; + u8 dmixmod; + u8 xbsi2e; + u8 dsurexmod; + u8 dheadphonmod; + u8 adconvtyp; + u8 crcErrorFlag; + u8 execDmixType; +}; + +enum ATRAC3_WordSize : s32 +{ + CELL_ADEC_ATRAC3_WORD_SZ_16BIT = 0x02, + CELL_ADEC_ATRAC3_WORD_SZ_24BIT = 0x03, + CELL_ADEC_ATRAC3_WORD_SZ_32BIT = 0x04, + CELL_ADEC_ATRAC3_WORD_SZ_FLOAT = 0x84, +}; + +enum ATRAC3_JointType : s32 +{ + ATRAC3_DUAL_STEREO = 0, + ATRAC3_JOINT_STEREO = 1, +}; + +struct CellAdecParamAtrac3 +{ + be_t nch; // channel count + be_t isJoint; + be_t nbytes; // byte count of single AU (???) + be_t bw_pcm; // bit length of output PCM sample +}; + +struct CellAdecAtrac3Info +{ + be_t nch; + be_t isJoint; + be_t nbytes; +}; + +enum ATRACX_WordSize : s32 +{ + CELL_ADEC_ATRACX_WORD_SZ_16BIT = 0x02, + CELL_ADEC_ATRACX_WORD_SZ_24BIT = 0x03, + CELL_ADEC_ATRACX_WORD_SZ_32BIT = 0x04, + CELL_ADEC_ATRACX_WORD_SZ_FLOAT = 0x84, +}; + +enum ATRACX_ATSHeaderInclude : u8 +{ + CELL_ADEC_ATRACX_ATS_HDR_NOTINC = 0, + CELL_ADEC_ATRACX_ATS_HDR_INC = 1, +}; + +enum ATRACX_DownmixFlag : u8 +{ + ATRACX_DOWNMIX_OFF = 0, + ATRACX_DOWNMIX_ON = 1, +}; + +struct CellAdecParamAtracX +{ + be_t sampling_freq; + be_t ch_config_idx; + be_t nch_out; + be_t nbytes; + u8 extra_config_data[4]; // downmix coefficients + be_t bw_pcm; + ATRACX_DownmixFlag downmix_flag; + ATRACX_ATSHeaderInclude au_includes_ats_hdr_flg; +}; + +struct CellAdecAtracXInfo +{ + be_t samplingFreq; // [Hz] + be_t channelConfigIndex; + be_t nbytes; +}; + +enum MP3_WordSize : s32 +{ + CELL_ADEC_MP3_WORD_SZ_16BIT = 3, + CELL_ADEC_MP3_WORD_SZ_FLOAT = 4, +}; + +enum MP3_ChannelMode : u8 +{ + MP3_STEREO = 0, + MP3_JOINT_STEREO = 1, + MP3_DUAL = 2, + MP3_MONO = 3, +}; + +enum MP3_CRCMode : u8 +{ + MP3_CRC = 0, + MP3_NO_CRC = 1, +}; + +struct CellAdecParamMP3 +{ + be_t bw_pcm; +}; + +struct CellAdecMP3Info +{ + be_t ui_header; + be_t ui_main_data_begin; + be_t ui_main_data_remain_size; + be_t ui_main_data_now_size; + MP3_CRCMode uc_crc; + MP3_ChannelMode uc_mode; + u8 uc_mode_extension; + u8 uc_copyright; + u8 uc_original; + u8 uc_emphasis; + u8 uc_crc_error_flag; + be_t i_error_code; +}; + +enum M2BC_SampleFrequency +{ + CELL_ADEC_BSI_M2BC_SAMPLE_FREQUENCY_44 = 0, + CELL_ADEC_BSI_M2BC_SAMPLE_FREQUENCY_48 = 1, + CELL_ADEC_BSI_M2BC_SAMPLE_FREQUENCY_32 = 2, +}; + +enum M2BC_ErrorProtection +{ + CELL_ADEC_BSI_M2BC_ERROR_PROTECTION_NONE = 0, + CELL_ADEC_BSI_M2BC_ERROR_PROTECTION_EXIST = 1, +}; + +enum M2BC_BitrateIndex +{ + CELL_ADEC_BSI_M2BC_BITRATE_32 = 1, + CELL_ADEC_BSI_M2BC_BITRATE_48 = 2, + CELL_ADEC_BSI_M2BC_BITRATE_56 = 3, + CELL_ADEC_BSI_M2BC_BITRATE_64 = 4, + CELL_ADEC_BSI_M2BC_BITRATE_80 = 5, + CELL_ADEC_BSI_M2BC_BITRATE_96 = 6, + CELL_ADEC_BSI_M2BC_BITRATE_112 = 7, + CELL_ADEC_BSI_M2BC_BITRATE_128 = 8, + CELL_ADEC_BSI_M2BC_BITRATE_160 = 9, + CELL_ADEC_BSI_M2BC_BITRATE_192 = 10, + CELL_ADEC_BSI_M2BC_BITRATE_224 = 11, + CELL_ADEC_BSI_M2BC_BITRATE_256 = 12, + CELL_ADEC_BSI_M2BC_BITRATE_320 = 13, + CELL_ADEC_BSI_M2BC_BITRATE_384 = 14, +}; + +enum M2BC_StereoMode +{ + CELL_ADEC_BSI_M2BC_STEREO_MODE_STERO = 0, + CELL_ADEC_BSI_M2BC_STEREO_MODE_JOINTSTERO = 1, + CELL_ADEC_BSI_M2BC_STEREO_MODE_DUAL = 2, + CELL_ADEC_BSI_M2BC_STEREO_MODE_MONO = 3, +}; + +enum M2BC_StereoModeEx +{ + CELL_ADEC_BSI_M2BC_STEREO_EXMODE_0 = 0, + CELL_ADEC_BSI_M2BC_STEREO_EXMODE_1 = 1, + CELL_ADEC_BSI_M2BC_STEREO_EXMODE_2 = 2, + CELL_ADEC_BSI_M2BC_STEREO_EXMODE_3 = 3, +}; + +enum M2BC_Emphasis +{ + CELL_ADEC_BSI_M2BC_EMPHASIS_NONE = 0, + CELL_ADEC_BSI_M2BC_EMPHASIS_50_15 = 1, + CELL_ADEC_BSI_M2BC_EMPHASIS_CCITT = 3, +}; + +enum M2BC_CopyrightBit +{ + CELL_ADEC_BSI_M2BC_COPYRIGHT_NONE = 0, + CELL_ADEC_BSI_M2BC_COPYRIGHT_ON = 1, +}; + +enum M2BC_OriginalBit +{ + CELL_ADEC_BSI_M2BC_ORIGINAL_COPY = 0, + CELL_ADEC_BSI_M2BC_ORIGINAL_ORIGINAL = 1, +}; + +enum M2BC_SurroundMode +{ + CELL_ADEC_BSI_M2BC_SURROUND_NONE = 0, + CELL_ADEC_BSI_M2BC_SURROUND_MONO = 1, + CELL_ADEC_BSI_M2BC_SURROUND_STEREO = 2, + CELL_ADEC_BSI_M2BC_SURROUND_SECOND = 3, +}; + +enum M2BC_CenterMode +{ + CELL_ADEC_BSI_M2BC_CENTER_NONE = 0, + CELL_ADEC_BSI_M2BC_CENTER_EXIST = 1, + CELL_ADEC_BSI_M2BC_CENTER_PHANTOM = 3, +}; + +enum M2BC_LFE +{ + CELL_ADEC_BSI_M2BC_LFE_NONE = 0, + CELL_ADEC_BSI_M2BC_LFE_EXIST = 1, +}; + +enum M2BC_AudioMixMode +{ + CELL_ADEC_BSI_M2BC_AUDIOMIX_LARGE = 0, + CELL_ADEC_BSI_M2BC_AUDIOMIX_SMALLE = 1, +}; + +enum M2BC_MCExtension +{ + CELL_ADEC_BSI_M2BC_MCEXTENSION_2CH = 0, + CELL_ADEC_BSI_M2BC_MCEXTENSION_5CH = 1, + CELL_ADEC_BSI_M2BC_MCEXTENSION_7CH = 2, +}; + +enum M2BC_ChannelConfig +{ + CELL_ADEC_BSI_M2BC_CH_CONFIG_MONO = 0, + CELL_ADEC_BSI_M2BC_CH_CONFIG_DUAL = 1, + CELL_ADEC_BSI_M2BC_CH_CONFIG_L_R = 2, + CELL_ADEC_BSI_M2BC_CH_CONFIG_L_R_S = 3, + CELL_ADEC_BSI_M2BC_CH_CONFIG_L_R_C = 4, + CELL_ADEC_BSI_M2BC_CH_CONFIG_L_R_LS_RS = 5, + CELL_ADEC_BSI_M2BC_CH_CONFIG_L_R_C_S = 6, + CELL_ADEC_BSI_M2BC_CH_CONFIG_L_R_C_LS_RS = 7, + CELL_ADEC_BSI_M2BC_CH_CONFIG_LL_RR_CC_LS_RS_LC_RC = 8, + CELL_ADEC_BSI_M2BC_CH_CONFIG_MONO_SECONDSTEREO = 9, + CELL_ADEC_BSI_M2BC_CH_CONFIG_L_R_SECONDSTEREO = 10, + CELL_ADEC_BSI_M2BC_CH_CONFIG_L_R_C_SECONDSTEREO = 11, +}; + +struct CellAdecParamMpmc +{ + be_t channelNumber; + be_t downmix; + be_t lfeUpSample; +}; + +struct CellAdecMpmcInfo +{ + be_t channelNumber; + be_t sampleFreq; + be_t errorPprotection; + be_t bitrateIndex; + be_t stereoMode; + be_t stereoModeEextention; + be_t emphasis; + be_t copyright; + be_t original; + be_t surroundMode; + be_t centerMode; + be_t audioMmix; + be_t outputFramSize; + be_t multiCodecMode; + be_t lfePresent; + be_t channelCoufiguration; +}; \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index 84a3b735c6..50290f9e97 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -135,66 +135,49 @@ struct CellAudioPortConfig struct AudioPortConfig { + bool m_is_audio_port_opened; bool m_is_audio_port_started; - bool m_is_audio_port_stopped; - CellAudioPortParam m_param; - - const u32 m_buffer; // 64 KB or 128 KB with 8x16 config - const u32 m_index; - - AudioPortConfig(); - - void finalize(); + u8 channel; + u8 block; + float level; + u64 attr; + u64 tag; + u64 counter; // copy of global counter }; struct AudioConfig //custom structure { - Array m_ports; + enum + { + AUDIO_PORT_COUNT = 8, + }; + AudioPortConfig m_ports[AUDIO_PORT_COUNT]; + u32 m_buffer; // 1 MB memory for audio ports + u32 m_indexes; // current block indexes and other info bool m_is_audio_initialized; + bool m_is_audio_finalized; u32 m_port_in_use; u64 event_key; + u64 counter; + u64 start_time; AudioConfig() : m_is_audio_initialized(false) + , m_is_audio_finalized(false) , m_port_in_use(0) , event_key(0) + , counter(0) { - m_ports.SetCount(8); - for (u32 i = 0; i < m_ports.GetCount(); i++) - m_ports[i] = nullptr; + memset(&m_ports, 0, sizeof(AudioPortConfig) * AUDIO_PORT_COUNT); } void Clear() { - for (u32 i = 0; i < m_ports.GetCount(); i++) - { - if (m_ports[i]) - { - delete m_ports[i]; - m_ports[i] = nullptr; - } - } + memset(&m_ports, 0, sizeof(AudioPortConfig) * AUDIO_PORT_COUNT); m_port_in_use = 0; } } m_config; -AudioPortConfig::AudioPortConfig() - : m_is_audio_port_started(false) - , m_buffer(Memory.Alloc(1024 * 128, 1024)) // max 128K size - , m_index(Memory.Alloc(16, 16)) // allocation for u64 value "read index" -{ - m_config.m_port_in_use++; - mem64_t index(m_index); - index = 0; -} - -void AudioPortConfig::finalize() -{ - m_config.m_port_in_use--; - Memory.Free(m_buffer); - Memory.Free(m_index); -} - //libmixer datatypes typedef void * CellAANHandle; @@ -307,6 +290,135 @@ int cellAudioInit() } m_config.m_is_audio_initialized = true; + m_config.counter = 0; + + // alloc memory + m_config.m_buffer = Memory.Alloc(128 * 1024 * m_config.AUDIO_PORT_COUNT, 1024); + memset(Memory + m_config.m_buffer, 0, 128 * 1024 * m_config.AUDIO_PORT_COUNT); + m_config.m_indexes = Memory.Alloc(sizeof(u64) * m_config.AUDIO_PORT_COUNT, 16); + memset(Memory + m_config.m_indexes, 0, sizeof(u64) * m_config.AUDIO_PORT_COUNT); + + thread t("AudioThread", []() + { + WAVHeader header(2); // WAV file header (stereo) + + static const wxString& output_name = "audio.wav"; + + wxFile output; // create output file + if (Ini.AudioDumpToFile.GetValue() && !output.Open(output_name, wxFile::write)) + { + ConLog.Error("Audio aborted: cannot create %s", output_name.wx_str()); + return; + } + + ConLog.Write("Audio started"); + + m_config.start_time = get_system_time(); + + if (Ini.AudioDumpToFile.GetValue()) + output.Write(&header, sizeof(header)); // write file header + + float buffer[2*256]; // buffer for 2 channels + be_t buffer2[8*256]; // buffer for 8 channels (max count) + memset(&buffer, 0, sizeof(buffer)); + memset(&buffer2, 0, sizeof(buffer2)); + + while (m_config.m_is_audio_initialized) + { + if (Emu.IsStopped()) + { + ConLog.Warning("Audio aborted"); + goto abort; + } + + // TODO: send beforemix event (in ~2,6 ms before mixing) + + // Sleep(5); // precise time of sleeping: 5,(3) ms (or 256/48000 sec) + if (m_config.counter * 256000000 / 48000 >= get_system_time() - m_config.start_time) + { + Sleep(1); + continue; + } + + m_config.counter++; + + if (Emu.IsPaused()) + { + continue; + } + + bool first_mix = true; + + // MIX: + for (u32 i = 0; i < m_config.AUDIO_PORT_COUNT; i++) + { + if (!m_config.m_ports[i].m_is_audio_port_started) continue; + + AudioPortConfig& port = m_config.m_ports[i]; + mem64_t index(m_config.m_indexes + i * sizeof(u64)); + + const u32 block_size = port.channel * 256; + + u32 position = port.tag % port.block; // old value + + u32 buf_addr = m_config.m_buffer + (i * 128 * 1024) + (position * block_size * sizeof(float)); + + memcpy(buffer2, Memory + buf_addr, block_size * sizeof(float)); + memset(Memory + buf_addr, 0, block_size * sizeof(float)); + + // TODO: atomic + port.counter = m_config.counter; + port.tag++; // absolute index of block that will be read + index = (position + 1) % port.block; // write new value + + if (first_mix) + { + for (u32 i = 0; i < (sizeof(buffer) / sizeof(float)); i++) + { + // reverse byte order (TODO: use port.m_param.level) + buffer[i] = buffer2[i]; + } + first_mix = false; + } + else + { + for (u32 i = 0; i < (sizeof(buffer) / sizeof(float)); i++) + { + buffer[i] = (buffer[i] + buffer2[i]) * 0.5; // TODO: valid mixing + } + } + } + + // send aftermix event (normal audio event) + // TODO: check event source + Emu.GetEventManager().SendEvent(m_config.event_key, 0x10103000e010e07, 0, 0, 0); + + if(Ini.AudioDumpToFile.GetValue()) + { + if (output.Write(&buffer, sizeof(buffer)) != sizeof(buffer)) // write file data + { + ConLog.Error("Port aborted: cannot write %s", output_name.wx_str()); + goto abort; + } + + header.Size += sizeof(buffer); // update file header + header.RIFF.Size += sizeof(buffer); + } + } + ConLog.Write("Audio finished"); +abort: + if(Ini.AudioDumpToFile.GetValue()) + { + output.Seek(0); + output.Write(&header, sizeof(header)); // write fixed file header + + output.Close(); + } + + m_config.m_is_audio_finalized = true; + }); + t.detach(); + return CELL_OK; } @@ -320,6 +432,19 @@ int cellAudioQuit() } m_config.m_is_audio_initialized = false; + + while (!m_config.m_is_audio_finalized) + { + Sleep(1); + if (Emu.IsStopped()) + { + ConLog.Warning("cellAudioQuit() aborted"); + return CELL_OK; + } + } + + Memory.Free(m_config.m_buffer); + Memory.Free(m_config.m_indexes); return CELL_OK; } @@ -332,26 +457,36 @@ int cellAudioPortOpen(mem_ptr_t audioParam, mem32_t portNum) return CELL_AUDIO_ERROR_PARAM; } - if (m_config.m_port_in_use >= m_config.m_ports.GetCount()) + if (audioParam->nChannel > 8 || audioParam->nBlock > 16) + { + return CELL_AUDIO_ERROR_PARAM; + } + + if (m_config.m_port_in_use >= m_config.AUDIO_PORT_COUNT) { return CELL_AUDIO_ERROR_PORT_FULL; } - for (u32 i = 0; i < m_config.m_ports.GetCount(); i++) + for (u32 i = 0; i < m_config.AUDIO_PORT_COUNT; i++) { - if (m_config.m_ports[i] == nullptr) + if (!m_config.m_ports[i].m_is_audio_port_opened) { - CellAudioPortParam& ref = (m_config.m_ports[i] = new AudioPortConfig)->m_param; + AudioPortConfig& port = m_config.m_ports[i]; - ref.nChannel = audioParam->nChannel; - ref.nBlock = audioParam->nBlock; - ref.attr = audioParam->attr; - ref.level = audioParam->level; + port.channel = audioParam->nChannel; + port.block = audioParam->nBlock; + port.attr = audioParam->attr; + port.level = audioParam->level; portNum = i; - cellAudio.Warning("*** audio port opened(nChannel=%lld, nBlock=0x%llx, attr=0x%llx, level=%f): port = %d", - (u64)ref.nChannel, (u64)ref.nBlock, (u64)ref.attr, (float)ref.level, portNum.GetValue()); - //TODO: implementation of ring buffer + cellAudio.Warning("*** audio port opened(nChannel=%d, nBlock=%d, attr=0x%llx, level=%f): port = %d", + port.channel, port.block, port.attr, port.level, i); + + port.m_is_audio_port_opened = true; + port.m_is_audio_port_started = false; + port.tag = 0; + + m_config.m_port_in_use++; return CELL_OK; } } @@ -363,35 +498,36 @@ int cellAudioGetPortConfig(u32 portNum, mem_ptr_t portConfi { cellAudio.Warning("cellAudioGetPortConfig(portNum=0x%x, portConfig_addr=0x%x)", portNum, portConfig.GetAddr()); - if (!portConfig.IsGood() || portNum >= m_config.m_ports.GetCount()) + if (!portConfig.IsGood() || portNum >= m_config.AUDIO_PORT_COUNT) { return CELL_AUDIO_ERROR_PARAM; } - if (!m_config.m_ports[portNum]) + if (!m_config.m_ports[portNum].m_is_audio_port_opened) { portConfig->status = CELL_AUDIO_STATUS_CLOSE; } - else if (m_config.m_ports[portNum]->m_is_audio_port_started) + else if (m_config.m_ports[portNum].m_is_audio_port_started) { portConfig->status = CELL_AUDIO_STATUS_RUN; } else { - CellAudioPortParam& ref = m_config.m_ports[portNum]->m_param; - portConfig->status = CELL_AUDIO_STATUS_READY; - portConfig->nChannel = ref.nChannel; - portConfig->nBlock = ref.nBlock; - portConfig->portSize = ref.nChannel * ref.nBlock * 256 * sizeof(float); - portConfig->portAddr = m_config.m_ports[portNum]->m_buffer; // 0x20020000 - portConfig->readIndexAddr = m_config.m_ports[portNum]->m_index; // 0x20010010 on ps3 - - ConLog.Write("*** nChannel=%d, nBlock=%d, portSize=0x%x, portAddr=0x%x, readIndexAddr=0x%x", - (u32)portConfig->nChannel, (u32)portConfig->nBlock, (u32)portConfig->portSize, (u32)portConfig->portAddr, (u32)portConfig->readIndexAddr); - // portAddr - readIndexAddr == 0xFFF0 on ps3 } + AudioPortConfig& port = m_config.m_ports[portNum]; + + portConfig->nChannel = port.channel; + portConfig->nBlock = port.block; + portConfig->portSize = port.channel * port.block * 256 * sizeof(float); + portConfig->portAddr = m_config.m_buffer + (128 * 1024 * portNum); // 0x20020000 + portConfig->readIndexAddr = m_config.m_indexes + (sizeof(u64) * portNum); // 0x20010010 on ps3 + + cellAudio.Log("*** port config: nChannel=%d, nBlock=%d, portSize=0x%x, portAddr=0x%x, readIndexAddr=0x%x", + (u32)portConfig->nChannel, (u32)portConfig->nBlock, (u32)portConfig->portSize, (u32)portConfig->portAddr, (u32)portConfig->readIndexAddr); + // portAddr - readIndexAddr == 0xFFF0 on ps3 + return CELL_OK; } @@ -399,120 +535,22 @@ int cellAudioPortStart(u32 portNum) { cellAudio.Warning("cellAudioPortStart(portNum=0x%x)", portNum); - if (portNum >= m_config.m_ports.GetCount()) + if (portNum >= m_config.AUDIO_PORT_COUNT) { return CELL_AUDIO_ERROR_PARAM; } - if (!m_config.m_ports[portNum]) + if (!m_config.m_ports[portNum].m_is_audio_port_opened) { return CELL_AUDIO_ERROR_PORT_OPEN; } - if (m_config.m_ports[portNum]->m_is_audio_port_started) + if (m_config.m_ports[portNum].m_is_audio_port_started) { return CELL_AUDIO_ERROR_PORT_ALREADY_RUN; } - m_config.m_ports[portNum]->m_is_audio_port_started = true; - m_config.m_ports[portNum]->m_is_audio_port_stopped = false; - - std::string t_name = "AudioPort0"; - t_name[9] += portNum; - - thread t(t_name, [portNum]() - { - AudioPortConfig& port = *m_config.m_ports[portNum]; - mem64_t index(port.m_index); // index storage - - if (port.m_param.nChannel > 8) - { - ConLog.Error("Port aborted: invalid channel count (%d)", port.m_param.nChannel); - port.m_is_audio_port_stopped = true; - return; - } - - WAVHeader header(port.m_param.nChannel); // WAV file header - - wxString output_name = "audioport0.wav"; - output_name[9] = '0' + portNum; - - wxFile output(output_name, wxFile::write); // create output file - if (!output.IsOpened()) - { - ConLog.Error("Port aborted: cannot create %s", output_name.wx_str()); - port.m_is_audio_port_stopped = true; - return; - } - - ConLog.Write("Port started"); - - u64 start_time = get_system_time(); - u64 counter = 0; - - output.Write(&header, sizeof(header)); // write file header - - const u32 block_size = port.m_param.nChannel * 256 * sizeof(float); - - float buffer[32*256]; // buffer for max channel count (8) - - while (port.m_is_audio_port_started) - { - if (Emu.IsStopped()) - { - ConLog.Warning("Port aborted"); - goto abort; - } - - // TODO: send beforemix event (in ~2,6 ms before mixing) - - // Sleep(5); // precise time of sleeping: 5,(3) ms (or 256/48000 sec) - if (counter * 256000000 / 48000 >= get_system_time() - start_time) - { - Sleep(1); - continue; - } - - counter++; - - if (Emu.IsPaused()) - { - continue; - } - - u32 position = index.GetValue(); // get old value - - memcpy(buffer, Memory + port.m_buffer + position * block_size, block_size); - memset(Memory + port.m_buffer + position * block_size, 0, block_size); - - index = (position + 1) % port.m_param.nBlock; // write new value - - // TODO: send aftermix event (normal audio event) - - for (u32 i = 0; i < block_size; i++) - { - // reverse byte order (TODO: use port.m_param.level) - buffer[i] = re(buffer[i]); - } - - if (output.Write(&buffer, block_size) != (size_t)block_size) // write file data - { - ConLog.Error("Port aborted: cannot write %s", output_name.wx_str()); - goto abort; - } - - header.Size += block_size; // update file header - header.RIFF.Size += block_size; - } - ConLog.Write("Port finished"); - abort: - output.Seek(0); - output.Write(&header, sizeof(header)); // write fixed file header - - output.Close(); - port.m_is_audio_port_stopped = true; - }); - t.detach(); + m_config.m_ports[portNum].m_is_audio_port_started = true; return CELL_OK; } @@ -521,18 +559,18 @@ int cellAudioPortClose(u32 portNum) { cellAudio.Warning("cellAudioPortClose(portNum=0x%x)", portNum); - if (portNum >= m_config.m_ports.GetCount()) + if (portNum >= m_config.AUDIO_PORT_COUNT) { return CELL_AUDIO_ERROR_PARAM; } - if (!m_config.m_ports[portNum]) + if (!m_config.m_ports[portNum].m_is_audio_port_opened) { return CELL_AUDIO_ERROR_PORT_NOT_OPEN; } - m_config.m_ports[portNum]->finalize(); - safe_delete(m_config.m_ports[portNum]); + m_config.m_ports[portNum].m_is_audio_port_started = false; + m_config.m_port_in_use--; return CELL_OK; } @@ -540,43 +578,92 @@ int cellAudioPortStop(u32 portNum) { cellAudio.Warning("cellAudioPortStop(portNum=0x%x)",portNum); - if (portNum >= m_config.m_ports.GetCount()) + if (portNum >= m_config.AUDIO_PORT_COUNT) { return CELL_AUDIO_ERROR_PARAM; } - if (!m_config.m_ports[portNum]) + if (!m_config.m_ports[portNum].m_is_audio_port_opened) { return CELL_AUDIO_ERROR_PORT_NOT_OPEN; } - if (!m_config.m_ports[portNum]->m_is_audio_port_started) + if (!m_config.m_ports[portNum].m_is_audio_port_started) { return CELL_AUDIO_ERROR_PORT_NOT_RUN; } - m_config.m_ports[portNum]->m_is_audio_port_started = false; - while (!m_config.m_ports[portNum]->m_is_audio_port_stopped) - { - Sleep(1); - if (Emu.IsStopped()) - { - ConLog.Warning("cellAudioPortStop(%d) aborted", portNum); - break; - } - } + m_config.m_ports[portNum].m_is_audio_port_started = false; return CELL_OK; } int cellAudioGetPortTimestamp(u32 portNum, u64 tag, mem64_t stamp) { - cellAudio.Error("cellAudioGetPortTimestamp(portNum=0x%x, tag=0x%llx, stamp_addr=0x%x)", portNum, tag, stamp.GetAddr()); + cellAudio.Warning("cellAudioGetPortTimestamp(portNum=0x%x, tag=0x%llx, stamp_addr=0x%x)", portNum, tag, stamp.GetAddr()); + + if (portNum >= m_config.AUDIO_PORT_COUNT) + { + return CELL_AUDIO_ERROR_PARAM; + } + + if (!m_config.m_ports[portNum].m_is_audio_port_opened) + { + return CELL_AUDIO_ERROR_PORT_NOT_OPEN; + } + + if (!m_config.m_ports[portNum].m_is_audio_port_started) + { + return CELL_AUDIO_ERROR_PORT_NOT_RUN; + } + + AudioPortConfig& port = m_config.m_ports[portNum]; + + // TODO: atomic + stamp = m_config.start_time + (port.counter + (tag - port.tag)) * 256000000 / 48000; + return CELL_OK; } int cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, mem64_t tag) { - cellAudio.Error("cellAudioGetPortBlockTag(portNum=0x%x, blockNo=0x%llx, tag_addr=0x%x)", portNum, blockNo, tag.GetAddr()); + cellAudio.Warning("cellAudioGetPortBlockTag(portNum=0x%x, blockNo=0x%llx, tag_addr=0x%x)", portNum, blockNo, tag.GetAddr()); + + if (portNum >= m_config.AUDIO_PORT_COUNT) + { + return CELL_AUDIO_ERROR_PARAM; + } + + if (!m_config.m_ports[portNum].m_is_audio_port_opened) + { + return CELL_AUDIO_ERROR_PORT_NOT_OPEN; + } + + if (!m_config.m_ports[portNum].m_is_audio_port_started) + { + return CELL_AUDIO_ERROR_PORT_NOT_RUN; + } + + AudioPortConfig& port = m_config.m_ports[portNum]; + + if (blockNo >= port.block) + { + cellAudio.Error("cellAudioGetPortBlockTag: wrong blockNo(%lld)", blockNo); + return CELL_AUDIO_ERROR_PARAM; + } + + // TODO: atomic + u64 tag_base = port.tag; + if (tag_base % port.block > blockNo) + { + tag_base &= ~(port.block-1); + tag_base += port.block; + } + else + { + tag_base &= ~(port.block-1); + } + tag = tag_base + blockNo; + return CELL_OK; } @@ -589,8 +676,24 @@ int cellAudioSetPortLevel(u32 portNum, float level) // Utility Functions int cellAudioCreateNotifyEventQueue(mem32_t id, mem64_t key) { - cellAudio.Error("cellAudioCreateNotifyEventQueue(id_addr=0x%x, key_addr=0x%x)", id.GetAddr(), key.GetAddr()); - key = 0x123456789ABCDEF0; + cellAudio.Warning("cellAudioCreateNotifyEventQueue(id_addr=0x%x, key_addr=0x%x)", id.GetAddr(), key.GetAddr()); + + if (Emu.GetEventManager().CheckKey(0x80004d494f323221)) + { + return CELL_AUDIO_ERROR_EVENT_QUEUE; + } + + EventQueue* eq = new EventQueue(SYS_SYNC_FIFO, SYS_PPU_QUEUE, 0x80004d494f323221, 0x80004d494f323221, 32); + + if (!Emu.GetEventManager().RegisterKey(eq, 0x80004d494f323221)) + { + delete eq; + return CELL_AUDIO_ERROR_EVENT_QUEUE; + } + + id = cellAudio.GetNewId(eq); + key = 0x80004d494f323221; + return CELL_OK; } @@ -609,11 +712,10 @@ int cellAudioSetNotifyEventQueue(u64 key) EventQueue* eq; if (!Emu.GetEventManager().GetEventQueue(key, eq)) { - //return CELL_AUDIO_ERROR_PARAM; - return CELL_OK; + return CELL_AUDIO_ERROR_PARAM; } - // eq->events.push(0, 0, 0, 0); + // TODO: connect port return CELL_OK; } @@ -626,7 +728,18 @@ int cellAudioSetNotifyEventQueueEx(u64 key, u32 iFlags) int cellAudioRemoveNotifyEventQueue(u64 key) { - cellAudio.Error("cellAudioRemoveNotifyEventQueue(key=0x%llx)", key); + cellAudio.Warning("cellAudioRemoveNotifyEventQueue(key=0x%llx)", key); + + EventQueue* eq; + if (!Emu.GetEventManager().GetEventQueue(key, eq)) + { + return CELL_AUDIO_ERROR_PARAM; + } + + m_config.event_key = 0; + + // TODO: disconnect port + return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp index 149076149d..84e54578c2 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp @@ -7,142 +7,142 @@ void cellDmux_init(); Module cellDmux(0x0007, cellDmux_init); -int cellDmuxQueryAttr(mem_ptr_t demuxerType, mem_ptr_t demuxerAttr) +int cellDmuxQueryAttr(const mem_ptr_t demuxerType, mem_ptr_t demuxerAttr) { cellDmux.Error("cellDmuxQueryAttr(demuxerType_addr=0x%x, demuxerAttr_addr=0x%x)", demuxerType.GetAddr(), demuxerAttr.GetAddr()); return CELL_OK; } -int cellDmuxQueryAttr2(mem_ptr_t demuxerType2, mem_ptr_t demuxerAttr) +int cellDmuxQueryAttr2(const mem_ptr_t demuxerType2, mem_ptr_t demuxerAttr) { cellDmux.Error("cellDmuxQueryAttr2(demuxerType2_addr=0x%x, demuxerAttr_addr=0x%x)", demuxerType2.GetAddr(), demuxerAttr.GetAddr()); return CELL_OK; } -int cellDmuxOpen(mem_ptr_t demuxerType, mem_ptr_t demuxerResource, - mem_ptr_t demuxerCb, u32 demuxerHandle_addr) +int cellDmuxOpen(const mem_ptr_t demuxerType, const mem_ptr_t demuxerResource, + const mem_ptr_t demuxerCb, mem32_t demuxerHandle) { cellDmux.Error("cellDmuxOpen(demuxerType_addr=0x%x, demuxerResource_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)", - demuxerType.GetAddr(), demuxerResource.GetAddr(), demuxerCb.GetAddr(), demuxerHandle_addr); + demuxerType.GetAddr(), demuxerResource.GetAddr(), demuxerCb.GetAddr(), demuxerHandle.GetAddr()); return CELL_OK; } -int cellDmuxOpenEx(mem_ptr_t demuxerType, mem_ptr_t demuxerResourceEx, - mem_ptr_t demuxerCb, u32 demuxerHandle_addr) +int cellDmuxOpenEx(const mem_ptr_t demuxerType, const mem_ptr_t demuxerResourceEx, + const mem_ptr_t demuxerCb, mem32_t demuxerHandle) { cellDmux.Error("cellDmuxOpenEx(demuxerType_addr=0x%x, demuxerResourceEx_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)", - demuxerType.GetAddr(), demuxerResourceEx.GetAddr(), demuxerCb.GetAddr(), demuxerHandle_addr); + demuxerType.GetAddr(), demuxerResourceEx.GetAddr(), demuxerCb.GetAddr(), demuxerHandle.GetAddr()); return CELL_OK; } -int cellDmuxOpen2(mem_ptr_t demuxerType2, mem_ptr_t demuxerResource2, - mem_ptr_t demuxerCb, u32 demuxerHandle_addr) +int cellDmuxOpen2(const mem_ptr_t demuxerType2, const mem_ptr_t demuxerResource2, + const mem_ptr_t demuxerCb, mem32_t demuxerHandle) { cellDmux.Error("cellDmuxOpen2(demuxerType2_addr=0x%x, demuxerResource2_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)", - demuxerType2.GetAddr(), demuxerResource2.GetAddr(), demuxerCb.GetAddr(), demuxerHandle_addr); + demuxerType2.GetAddr(), demuxerResource2.GetAddr(), demuxerCb.GetAddr(), demuxerHandle.GetAddr()); return CELL_OK; } -int cellDmuxClose(u32 demuxerHandle_addr) +int cellDmuxClose(u32 demuxerHandle) { - cellDmux.Error("cellDmuxClose(demuxerHandle_addr=0x%x)", demuxerHandle_addr); + cellDmux.Error("cellDmuxClose(demuxerHandle=0x%x)", demuxerHandle); return CELL_OK; } -int cellDmuxSetStream(u32 demuxerHandle_addr, u32 streamAddress, u32 streamSize, bool discontinuity, u64 userData) +int cellDmuxSetStream(u32 demuxerHandle, const u32 streamAddress, u32 streamSize, bool discontinuity, u64 userData) { - cellDmux.Error("cellDmuxSetStream(demuxerHandle_addr=0x%x, streamAddress=0x%x, streamSize=%d, discontinuity=%d, userData=0x%llx", - demuxerHandle_addr, streamAddress, streamSize, discontinuity, userData); + cellDmux.Error("cellDmuxSetStream(demuxerHandle=0x%x, streamAddress=0x%x, streamSize=%d, discontinuity=%d, userData=0x%llx", + demuxerHandle, streamAddress, streamSize, discontinuity, userData); return CELL_OK; } -int cellDmuxResetStream(u32 demuxerHandle_addr) +int cellDmuxResetStream(u32 demuxerHandle) { - cellDmux.Error("cellDmuxResetStream(demuxerHandle_addr=0x%x)", demuxerHandle_addr); + cellDmux.Error("cellDmuxResetStream(demuxerHandle=0x%x)", demuxerHandle); return CELL_OK; } -int cellDmuxResetStreamAndWaitDone(u32 demuxerHandle_addr) +int cellDmuxResetStreamAndWaitDone(u32 demuxerHandle) { - cellDmux.Error("cellDmuxResetStreamAndWaitDone(demuxerHandle_addr=0x%x)", demuxerHandle_addr); + cellDmux.Error("cellDmuxResetStreamAndWaitDone(demuxerHandle=0x%x)", demuxerHandle); return CELL_OK; } -int cellDmuxQueryEsAttr(mem_ptr_t demuxerType, mem_ptr_t esFilterId, - u32 esSpecificInfo_addr, mem_ptr_t esAttr) +int cellDmuxQueryEsAttr(const mem_ptr_t demuxerType, const mem_ptr_t esFilterId, + const u32 esSpecificInfo_addr, mem_ptr_t esAttr) { cellDmux.Error("cellDmuxQueryEsAttr(demuxerType_addr=0x%x, esFilterId_addr=0x%x, esSpecificInfo_addr=0x%x, esAttr_addr=0x%x)", demuxerType.GetAddr(), esFilterId.GetAddr(), esSpecificInfo_addr, esAttr.GetAddr()); return CELL_OK; } -int cellDmuxQueryEsAttr2(mem_ptr_t demuxerType2, mem_ptr_t esFilterId, - u32 esSpecificInfo_addr, mem_ptr_t esAttr) +int cellDmuxQueryEsAttr2(const mem_ptr_t demuxerType2, const mem_ptr_t esFilterId, + const u32 esSpecificInfo_addr, mem_ptr_t esAttr) { cellDmux.Error("cellDmuxQueryEsAttr2(demuxerType2_addr=0x%x, esFilterId_addr=0x%x, esSpecificInfo_addr=0x%x, esAttr_addr=0x%x)", demuxerType2.GetAddr(), esFilterId.GetAddr(), esSpecificInfo_addr, esAttr.GetAddr()); return CELL_OK; } -int cellDmuxEnableEs(u32 demuxerHandle_addr, mem_ptr_t esFilterId, - mem_ptr_t esResourceInfo, mem_ptr_t esCb, - u32 esSpecificInfo_addr, u32 esHandle_addr) +int cellDmuxEnableEs(u32 demuxerHandle, const mem_ptr_t esFilterId, + const mem_ptr_t esResourceInfo, const mem_ptr_t esCb, + const u32 esSpecificInfo_addr, mem32_t esHandle) { - cellDmux.Error("cellDmuxEnableEs(demuxerHandle_addr=0x%x, esFilterId_addr=0x%x, esResourceInfo_addr=0x%x, esCb_addr=0x%x, " - "esSpecificInfo_addr=0x%x, esHandle_addr=0x%x)", demuxerHandle_addr, esFilterId.GetAddr(), esResourceInfo.GetAddr(), - esCb.GetAddr(), esSpecificInfo_addr, esHandle_addr); + cellDmux.Error("cellDmuxEnableEs(demuxerHandle=0x%x, esFilterId_addr=0x%x, esResourceInfo_addr=0x%x, esCb_addr=0x%x, " + "esSpecificInfo_addr=0x%x, esHandle_addr=0x%x)", demuxerHandle, esFilterId.GetAddr(), esResourceInfo.GetAddr(), + esCb.GetAddr(), esSpecificInfo_addr, esHandle.GetAddr()); return CELL_OK; } -int cellDmuxDisableEs(u32 esHandle_addr) +int cellDmuxDisableEs(u32 esHandle) { - cellDmux.Error("cellDmuxDisableEs(esHandle_addr=0x%x)", esHandle_addr); + cellDmux.Error("cellDmuxDisableEs(esHandle=0x%x)", esHandle); return CELL_OK; } -int cellDmuxResetEs(u32 esHandle_addr) +int cellDmuxResetEs(u32 esHandle) { - cellDmux.Error("cellDmuxResetEs(esHandle_addr=0x%x)", esHandle_addr); + cellDmux.Error("cellDmuxResetEs(esHandle=0x%x)", esHandle); return CELL_OK; } -int cellDmuxGetAu(u32 esHandle_addr, u32 auInfo_ptr_addr, u32 auSpecificInfo_ptr_addr) +int cellDmuxGetAu(u32 esHandle, const u32 auInfo_ptr_addr, u32 auSpecificInfo_ptr_addr) { - cellDmux.Error("cellDmuxGetAu(esHandle_addr=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", - esHandle_addr, auInfo_ptr_addr, auSpecificInfo_ptr_addr); + cellDmux.Error("cellDmuxGetAu(esHandle=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", + esHandle, auInfo_ptr_addr, auSpecificInfo_ptr_addr); return CELL_OK; } -int cellDmuxPeekAu(u32 esHandle_addr, u32 auInfo_ptr_addr, u32 auSpecificInfo_ptr_addr) +int cellDmuxPeekAu(u32 esHandle, const u32 auInfo_ptr_addr, u32 auSpecificInfo_ptr_addr) { - cellDmux.Error("cellDmuxPeekAu(esHandle_addr=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", - esHandle_addr, auInfo_ptr_addr, auSpecificInfo_ptr_addr); + cellDmux.Error("cellDmuxPeekAu(esHandle=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", + esHandle, auInfo_ptr_addr, auSpecificInfo_ptr_addr); return CELL_OK; } -int cellDmuxGetAuEx(u32 esHandle_addr, u32 auInfoEx_ptr_addr, u32 auSpecificInfo_ptr_addr) +int cellDmuxGetAuEx(u32 esHandle, const u32 auInfoEx_ptr_addr, u32 auSpecificInfo_ptr_addr) { - cellDmux.Error("cellDmuxGetAuEx(esHandle_addr=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", - esHandle_addr, auInfoEx_ptr_addr, auSpecificInfo_ptr_addr); + cellDmux.Error("cellDmuxGetAuEx(esHandle=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", + esHandle, auInfoEx_ptr_addr, auSpecificInfo_ptr_addr); return CELL_OK; } -int cellDmuxPeekAuEx(u32 esHandle_addr, u32 auInfoEx_ptr_addr, u32 auSpecificInfo_ptr_addr) +int cellDmuxPeekAuEx(u32 esHandle, const u32 auInfoEx_ptr_addr, u32 auSpecificInfo_ptr_addr) { - cellDmux.Error("cellDmuxPeekAuEx(esHandle_addr=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", - esHandle_addr, auInfoEx_ptr_addr, auSpecificInfo_ptr_addr); + cellDmux.Error("cellDmuxPeekAuEx(esHandle=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", + esHandle, auInfoEx_ptr_addr, auSpecificInfo_ptr_addr); return CELL_OK; } -int cellDmuxReleaseAu(u32 esHandle_addr) +int cellDmuxReleaseAu(u32 esHandle) { - cellDmux.Error("cellDmuxReleaseAu(esHandle_addr=0x%x)", esHandle_addr); + cellDmux.Error("cellDmuxReleaseAu(esHandle=0x%x)", esHandle); return CELL_OK; } -int cellDmuxFlushEs(u32 esHandle_addr) +int cellDmuxFlushEs(u32 esHandle) { - cellDmux.Error("cellDmuxFlushEs(esHandle_addr=0x%x)", esHandle_addr); + cellDmux.Error("cellDmuxFlushEs(esHandle=0x%x)", esHandle); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp index c8a7dbe26d..1559788875 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp @@ -118,8 +118,8 @@ int cellPamfGetHeaderSize(mem_ptr_t pAddr, u64 fileSize, mem64_t pSi cellPamf.Warning("cellPamfGetHeaderSize(pAddr=0x%x, fileSize=%d, pSize_addr=0x%x)", pAddr.GetAddr(), fileSize, pSize.GetAddr()); - if ((u32)pAddr->magic != 0x464d4150) - return CELL_PAMF_ERROR_UNKNOWN_TYPE; + //if ((u32)pAddr->magic != 0x464d4150) + //return CELL_PAMF_ERROR_UNKNOWN_TYPE; const u64 offset = (u64)pAddr->data_offset << 11; pSize = offset /*? offset : 2048*/; //hack diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index 51c4165363..033dec04c5 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -469,6 +469,9 @@ int cellVideoOutGetResolutionAvailability(u32 videoOut, u32 resolutionId, u32 as return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT; } +extern std::atomic g_FsAioReadID; +extern std::atomic g_FsAioReadCur; + int cellSysutilCheckCallback() { cellSysutil.Log("cellSysutilCheckCallback()"); @@ -477,7 +480,7 @@ int cellSysutilCheckCallback() CPUThread& thr = Emu.GetCallbackThread(); - while (thr.IsAlive()) + while (thr.IsAlive() || (g_FsAioReadCur < g_FsAioReadID)) { Sleep(1); if (Emu.IsStopped()) diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp index 794d962251..74d3599841 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp @@ -1,83 +1,76 @@ #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" +#include "cellVdec.h" void cellVdec_init(); Module cellVdec(0x0005, cellVdec_init); -// Error Codes -enum +int cellVdecQueryAttr(const mem_ptr_t type, mem_ptr_t attr) { - CELL_VDEC_ERROR_ARG = 0x80610101, - CELL_VDEC_ERROR_SEQ = 0x80610102, - CELL_VDEC_ERROR_BUSY = 0x80610103, - CELL_VDEC_ERROR_EMPTY = 0x80610104, - CELL_VDEC_ERROR_FATAL = 0x80610180, -}; - -int cellVdecQueryAttr() -{ - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecQueryAttr(type_addr=0x%x, attr_addr=0x%x)", type.GetAddr(), attr.GetAddr()); return CELL_OK; } -int cellVdecQueryAttrEx() +int cellVdecQueryAttrEx(const mem_ptr_t type, mem_ptr_t attr) { - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecQueryAttrEx(type_addr=0x%x, attr_addr=0x%x)", type.GetAddr(), attr.GetAddr()); return CELL_OK; } -int cellVdecOpen() +int cellVdecOpen(const mem_ptr_t type, const mem_ptr_t res, const mem_ptr_t cb, mem32_t handle) { - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecOpen(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", + type.GetAddr(), res.GetAddr(), cb.GetAddr(), handle.GetAddr()); return CELL_OK; } -int cellVdecOpenEx() +int cellVdecOpenEx(const mem_ptr_t type, const mem_ptr_t res, const mem_ptr_t cb, mem32_t handle) { - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecOpenEx(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", + type.GetAddr(), res.GetAddr(), cb.GetAddr(), handle.GetAddr()); return CELL_OK; } -int cellVdecClose() +int cellVdecClose(u32 handle) { - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecClose(handle=0x%x)", handle); return CELL_OK; } -int cellVdecStartSeq() +int cellVdecStartSeq(u32 handle) { - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecStartSeq(handle=0x%x)", handle); return CELL_OK; } -int cellVdecEndSeq() +int cellVdecEndSeq(u32 handle) { - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecEndSeq(handle=0x%x)", handle); return CELL_OK; } -int cellVdecDecodeAu() +int cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, const mem_ptr_t auInfo) { - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecDecodeAu(handle=0x%x, mode=0x%x, auInfo_addr=0x%x)", handle, mode, auInfo.GetAddr()); return CELL_OK; } -int cellVdecGetPicture() +int cellVdecGetPicture(u32 handle, const mem_ptr_t format, u32 out_addr) { - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecGetPicture(handle=0x%x, format_addr=0x%x, out_addr=0x%x)", handle, format.GetAddr(), out_addr); return CELL_OK; } -int cellVdecGetPicItem() +int cellVdecGetPicItem(u32 handle, const u32 picItem_ptr_addr) { - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecGetPicItem(handle=0x%x, picItem_ptr_addr=0x%x)", handle, picItem_ptr_addr); return CELL_OK; } -int cellVdecSetFrameRate() +int cellVdecSetFrameRate(u32 handle, CellVdecFrameRate frc) { - UNIMPLEMENTED_FUNC(cellVdec); + cellVdec.Error("cellVdecSetFrameRate(handle=0x%x, frc=0x%x)", handle, frc); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.h b/rpcs3/Emu/SysCalls/Modules/cellVdec.h new file mode 100644 index 0000000000..771924fea5 --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.h @@ -0,0 +1,637 @@ +#pragma once +#include "cellPamf.h" + +// Error Codes +enum +{ + CELL_VDEC_ERROR_ARG = 0x80610101, + CELL_VDEC_ERROR_SEQ = 0x80610102, + CELL_VDEC_ERROR_BUSY = 0x80610103, + CELL_VDEC_ERROR_EMPTY = 0x80610104, + CELL_VDEC_ERROR_AU = 0x80610105, + CELL_VDEC_ERROR_PIC = 0x80610106, + CELL_VDEC_ERROR_FATAL = 0x80610180, +}; + +enum CellVdecCodecType +{ + CELL_VDEC_CODEC_TYPE_MPEG2 = 0x00000000, + CELL_VDEC_CODEC_TYPE_AVC = 0x00000001, + CELL_VDEC_CODEC_TYPE_DIVX = 0x00000005, +}; + +// Callback Messages +enum CellVdecMsgType +{ + CELL_VDEC_MSG_TYPE_AUDONE, // decoding finished + CELL_VDEC_MSG_TYPE_PICOUT, // picture done + CELL_VDEC_MSG_TYPE_SEQDONE, // finishing done + CELL_VDEC_MSG_TYPE_ERROR, +}; + +// Decoder Operation Mode +enum CellVdecDecodeMode +{ + CELL_VDEC_DEC_MODE_NORMAL, + CELL_VDEC_DEC_MODE_B_SKIP, + CELL_VDEC_DEC_MODE_PB_SKIP, +}; + +// Output Picture Format Type +enum CellVdecPicFormatType +{ + CELL_VDEC_PICFMT_ARGB32_ILV, + CELL_VDEC_PICFMT_RGBA32_ILV, + CELL_VDEC_PICFMT_UYVY422_ILV, + CELL_VDEC_PICFMT_YUV420_PLANAR, +}; + +// Output Color Matrix Coef +enum CellVdecColorMatrixType +{ + CELL_VDEC_COLOR_MATRIX_TYPE_BT601, + CELL_VDEC_COLOR_MATRIX_TYPE_BT709, +}; + +enum CellVdecPicAttr +{ + CELL_VDEC_PICITEM_ATTR_NORMAL, + CELL_VDEC_PICITEM_ATTR_SKIPPED, +}; + +// Universal Frame Rate Code +enum CellVdecFrameRate : u8 +{ + CELL_VDEC_FRC_24000DIV1001 = 0x80, + CELL_VDEC_FRC_24 = 0x81, + CELL_VDEC_FRC_25 = 0x82, + CELL_VDEC_FRC_30000DIV1001 = 0x83, + CELL_VDEC_FRC_30 = 0x84, + CELL_VDEC_FRC_50 = 0x85, + CELL_VDEC_FRC_60000DIV1001 = 0x86, + CELL_VDEC_FRC_60 = 0x87, +}; + +// Codec Type Information +struct CellVdecType +{ + be_t codecType; + be_t profileLevel; +}; + +// Extended Codec Type Information +struct CellVdecTypeEx +{ + be_t codecType; + be_t profileLevel; + be_t codecSpecificInfo_addr; +}; + +// Library Attributes +struct CellVdecAttr +{ + be_t memSize; // required memory + u8 cmdDepth; // command queue depth + be_t decoderVerUpper; + be_t decoderVerLower; +}; + +// Configurable Information +struct CellVdecResource +{ + be_t memAddr; + be_t memSize; + be_t ppuThreadPriority; + be_t ppuThreadStackSize; + be_t spuThreadPriority; + be_t numOfSpus; +}; + +// SPURS Information +struct CellVdecResourceSpurs +{ + be_t spursAddr; + u8 tasksetPriority[8]; + be_t tasksetMaxContention; +}; + +// Extended Configurable Information +struct CellVdecResourceEx +{ + be_t memAddr; + be_t memSize; + be_t ppuThreadPriority; + be_t ppuThreadStackSize; + be_t spuThreadPriority; + be_t numOfSpus; + be_t spursResource_addr; +}; + +// Presentation Time Stamp +typedef CellCodecTimeStamp CellVdecTimeStamp; + +// Access Unit Information +struct CellVdecAuInfo +{ + be_t startAddr; + be_t size; + CellCodecTimeStamp pts; + CellCodecTimeStamp dts; + be_t userData; + be_t codecSpecificData; +}; + +// Output Picture Information +struct CellVdecPicItem +{ + be_t codecType; + be_t startAddr; + be_t size; + u8 auNum; + CellCodecTimeStamp auPts[2]; + CellCodecTimeStamp auDts[2]; + be_t auUserData[2]; + be_t status; + be_t attr; + be_t picInfo_addr; +}; + +// Output Picture Format +struct CellVdecPicFormat +{ + be_t formatType; + be_t colorMatrixType; + u8 alpha; +}; + +// Callback Function Information +struct CellVdecCb +{ + be_t> cbFunc; + be_t cbArg_addr; +}; + +// Max CC Data Length +enum +{ + CELL_VDEC_AVC_CCD_MAX = 128, +}; + +enum AVC_level : u8 +{ + CELL_VDEC_AVC_LEVEL_1P0 = 10, + CELL_VDEC_AVC_LEVEL_1P1 = 11, + CELL_VDEC_AVC_LEVEL_1P2 = 12, + CELL_VDEC_AVC_LEVEL_1P3 = 13, + CELL_VDEC_AVC_LEVEL_2P0 = 20, + CELL_VDEC_AVC_LEVEL_2P1 = 21, + CELL_VDEC_AVC_LEVEL_2P2 = 22, + CELL_VDEC_AVC_LEVEL_3P0 = 30, + CELL_VDEC_AVC_LEVEL_3P1 = 31, + CELL_VDEC_AVC_LEVEL_3P2 = 32, + CELL_VDEC_AVC_LEVEL_4P0 = 40, + CELL_VDEC_AVC_LEVEL_4P1 = 41, + CELL_VDEC_AVC_LEVEL_4P2 = 42, +}; + +struct CellVdecAvcSpecificInfo +{ + be_t thisSize; + be_t maxDecodedFrameWidth; + be_t maxDecodedFrameHeight; + bool disableDeblockingFilter; + u8 numberOfDecodedFrameBuffer; +}; + +enum AVC_video_format : u8 +{ + CELL_VDEC_AVC_VF_COMPONENT = 0x00, + CELL_VDEC_AVC_VF_PAL = 0x01, + CELL_VDEC_AVC_VF_NTSC = 0x02, + CELL_VDEC_AVC_VF_SECAM = 0x03, + CELL_VDEC_AVC_VF_MAC = 0x04, + CELL_VDEC_AVC_VF_UNSPECIFIED = 0x05, +}; + +enum AVC_colour_primaries : u8 +{ + CELL_VDEC_AVC_CP_ITU_R_BT_709_5 = 0x01, + CELL_VDEC_AVC_CP_UNSPECIFIED = 0x02, + CELL_VDEC_AVC_CP_ITU_R_BT_470_6_SYS_M = 0x04, + CELL_VDEC_AVC_CP_ITU_R_BT_470_6_SYS_BG = 0x05, + CELL_VDEC_AVC_CP_SMPTE_170_M = 0x06, + CELL_VDEC_AVC_CP_SMPTE_240_M = 0x07, + CELL_VDEC_AVC_CP_GENERIC_FILM = 0x08, +}; + +enum AVC_transfer_characteristics : u8 +{ + CELL_VDEC_AVC_TC_ITU_R_BT_709_5 = 0x01, + CELL_VDEC_AVC_TC_UNSPECIFIED = 0x02, + CELL_VDEC_AVC_TC_ITU_R_BT_470_6_SYS_M = 0x04, + CELL_VDEC_AVC_TC_ITU_R_BT_470_6_SYS_BG = 0x05, + CELL_VDEC_AVC_TC_SMPTE_170_M = 0x06, + CELL_VDEC_AVC_TC_SMPTE_240_M = 0x07, + CELL_VDEC_AVC_TC_LINEAR = 0x08, + CELL_VDEC_AVC_TC_LOG_100_1 = 0x09, + CELL_VDEC_AVC_TC_LOG_316_1 = 0x0a, +}; + +enum AVC_matrix_coefficients : u8 +{ + CELL_VDEC_AVC_MXC_GBR = 0x00, + CELL_VDEC_AVC_MXC_ITU_R_BT_709_5 = 0x01, + CELL_VDEC_AVC_MXC_UNSPECIFIED = 0x02, + CELL_VDEC_AVC_MXC_FCC = 0x04, + CELL_VDEC_AVC_MXC_ITU_R_BT_470_6_SYS_BG = 0x05, + CELL_VDEC_AVC_MXC_SMPTE_170_M = 0x06, + CELL_VDEC_AVC_MXC_SMPTE_240_M = 0x07, + CELL_VDEC_AVC_MXC_YCGCO = 0x08, +}; + +enum AVC_FrameRateCode : u8 +{ + CELL_VDEC_AVC_FRC_24000DIV1001 = 0x00, + CELL_VDEC_AVC_FRC_24 = 0x01, + CELL_VDEC_AVC_FRC_25 = 0x02, + CELL_VDEC_AVC_FRC_30000DIV1001 = 0x03, + CELL_VDEC_AVC_FRC_30 = 0x04, + CELL_VDEC_AVC_FRC_50 = 0x05, + CELL_VDEC_AVC_FRC_60000DIV1001 = 0x06, + CELL_VDEC_AVC_FRC_60 = 0x07, +}; + +enum AVC_NulUnitPresentFlags : u16 +{ + CELL_VDEC_AVC_FLG_SPS = 0x0001, + CELL_VDEC_AVC_FLG_PPS = 0x0002, + CELL_VDEC_AVC_FLG_AUD = 0x0004, + CELL_VDEC_AVC_FLG_EO_SEQ = 0x0008, + CELL_VDEC_AVC_FLG_EO_STREAM = 0x0100, + CELL_VDEC_AVC_FLG_FILLER_DATA = 0x0200, + CELL_VDEC_AVC_FLG_PIC_TIMING_SEI = 0x0400, + CELL_VDEC_AVC_FLG_BUFF_PERIOD_SEI = 0x0800, + CELL_VDEC_AVC_FLG_USER_DATA_UNREG_SEI = 0x1000, +}; + +enum AVC_aspect_ratio_idc : u8 +{ + CELL_VDEC_AVC_ARI_SAR_UNSPECIFIED = 0x00, + CELL_VDEC_AVC_ARI_SAR_1_1 = 0x01, + CELL_VDEC_AVC_ARI_SAR_12_11 = 0x02, + CELL_VDEC_AVC_ARI_SAR_10_11 = 0x03, + CELL_VDEC_AVC_ARI_SAR_16_11 = 0x04, + CELL_VDEC_AVC_ARI_SAR_40_33 = 0x05, + CELL_VDEC_AVC_ARI_SAR_24_11 = 0x06, + CELL_VDEC_AVC_ARI_SAR_20_11 = 0x07, + CELL_VDEC_AVC_ARI_SAR_32_11 = 0x08, + CELL_VDEC_AVC_ARI_SAR_80_33 = 0x09, + CELL_VDEC_AVC_ARI_SAR_18_11 = 0x0a, + CELL_VDEC_AVC_ARI_SAR_15_11 = 0x0b, + CELL_VDEC_AVC_ARI_SAR_64_33 = 0x0c, + CELL_VDEC_AVC_ARI_SAR_160_99 = 0x0d, + CELL_VDEC_AVC_ARI_SAR_4_3 = 0x0e, + CELL_VDEC_AVC_ARI_SAR_3_2 = 0x0f, + CELL_VDEC_AVC_ARI_SAR_2_1 = 0x10, + CELL_VDEC_AVC_ARI_SAR_EXTENDED_SAR = 0xff, +}; + +enum AVC_PictureType : u8 +{ + CELL_VDEC_AVC_PCT_I = 0x00, + CELL_VDEC_AVC_PCT_P = 0x01, + CELL_VDEC_AVC_PCT_B = 0x02, + CELL_VDEC_AVC_PCT_UNKNOWN = 0x03, +}; + +enum AVC_pic_struct : u8 +{ + CELL_VDEC_AVC_PSTR_FRAME = 0x00, + CELL_VDEC_AVC_PSTR_FIELD_TOP = 0x01, + CELL_VDEC_AVC_PSTR_FIELD_BTM = 0x02, + CELL_VDEC_AVC_PSTR_FIELD_TOP_BTM = 0x03, + CELL_VDEC_AVC_PSTR_FIELD_BTM_TOP = 0x04, + CELL_VDEC_AVC_PSTR_FIELD_TOP_BTM_TOP = 0x05, + CELL_VDEC_AVC_PSTR_FIELD_BTM_TOP_BTM = 0x06, + CELL_VDEC_AVC_PSTR_FRAME_DOUBLING = 0x07, + CELL_VDEC_AVC_PSTR_FRAME_TRIPLING = 0x08, +}; + +struct CellVdecAvcInfo +{ + be_t horizontalSize; + be_t verticalSize; + AVC_PictureType pictureType[2]; + bool idrPictureFlag; + AVC_aspect_ratio_idc aspect_ratio_idc; + be_t sar_height; + be_t sar_width; + AVC_pic_struct pic_struct; + be_t picOrderCount[2]; + bool vui_parameters_present_flag; + bool frame_mbs_only_flag; + bool video_signal_type_present_flag; + AVC_video_format video_format; + bool video_full_range_flag; + bool colour_description_present_flag; + AVC_colour_primaries colour_primaries; + AVC_transfer_characteristics transfer_characteristics; + AVC_matrix_coefficients matrix_coefficients; + bool timing_info_present_flag; + CellVdecFrameRate frameRateCode; + bool fixed_frame_rate_flag; + bool low_delay_hrd_flag; + bool entropy_coding_mode_flag; + be_t nalUnitPresentFlags; + u8 ccDataLength[2]; + u8 ccData[2][CELL_VDEC_AVC_CCD_MAX]; + be_t reserved[2]; +}; + +// DIVX Profile +enum DIVX_level : u8 +{ + CELL_VDEC_DIVX_QMOBILE = 10, + CELL_VDEC_DIVX_MOBILE = 11, + CELL_VDEC_DIVX_HOME_THEATER = 12, + CELL_VDEC_DIVX_HD_720 = 13, + CELL_VDEC_DIVX_HD_1080 = 14, +}; + +struct CellVdecDivxSpecificInfo +{ + be_t thisSize; + be_t maxDecodedFrameWidth; + be_t maxDecodedFrameHeight; +}; + +struct CellVdecDivxSpecificInfo2 +{ + be_t thisSize; + be_t maxDecodedFrameWidth; + be_t maxDecodedFrameHeight; + be_t numberOfDecodedFrameBuffer; +}; + +enum DIVX_frameRateCode : u16 +{ + CELL_VDEC_DIVX_FRC_UNDEFINED = 0x00, + CELL_VDEC_DIVX_FRC_24000DIV1001 = 0x01, + CELL_VDEC_DIVX_FRC_24 = 0x02, + CELL_VDEC_DIVX_FRC_25 = 0x03, + CELL_VDEC_DIVX_FRC_30000DIV1001 = 0x04, + CELL_VDEC_DIVX_FRC_30 = 0x05, + CELL_VDEC_DIVX_FRC_50 = 0x06, + CELL_VDEC_DIVX_FRC_60000DIV1001 = 0x07, + CELL_VDEC_DIVX_FRC_60 = 0x08, +}; + +enum DIVX_pixelAspectRatio : u8 +{ + CELL_VDEC_DIVX_ARI_PAR_1_1 = 0x1, + CELL_VDEC_DIVX_ARI_PAR_12_11 = 0x2, + CELL_VDEC_DIVX_ARI_PAR_10_11 = 0x3, + CELL_VDEC_DIVX_ARI_PAR_16_11 = 0x4, + CELL_VDEC_DIVX_ARI_PAR_40_33 = 0x5, + CELL_VDEC_DIVX_ARI_PAR_EXTENDED_PAR = 0xF, +}; + +enum DIVX_pictureType : u8 +{ + CELL_VDEC_DIVX_VCT_I = 0x0, + CELL_VDEC_DIVX_VCT_P = 0x1, + CELL_VDEC_DIVX_VCT_B = 0x2, +}; + +enum DIVX_pictureStruct : u8 +{ + CELL_VDEC_DIVX_PSTR_FRAME = 0x0, + CELL_VDEC_DIVX_PSTR_TOP_BTM = 0x1, + CELL_VDEC_DIVX_PSTR_BTM_TOP = 0x2, +}; + +enum DIVX_colourPrimaries : u8 +{ + CELL_VDEC_DIVX_CP_ITU_R_BT_709 = 0x01, + CELL_VDEC_DIVX_CP_UNSPECIFIED = 0x02, + CELL_VDEC_DIVX_CP_ITU_R_BT_470_SYS_M = 0x04, + CELL_VDEC_DIVX_CP_ITU_R_BT_470_SYS_BG = 0x05, + CELL_VDEC_DIVX_CP_SMPTE_170_M = 0x06, + CELL_VDEC_DIVX_CP_SMPTE_240_M = 0x07, + CELL_VDEC_DIVX_CP_GENERIC_FILM = 0x08, +}; + +enum DIVX_transferCharacteristics : u8 +{ + CELL_VDEC_DIVX_TC_ITU_R_BT_709 = 0x01, + CELL_VDEC_DIVX_TC_UNSPECIFIED = 0x02, + CELL_VDEC_DIVX_TC_ITU_R_BT_470_SYS_M = 0x04, + CELL_VDEC_DIVX_TC_ITU_R_BT_470_SYS_BG = 0x05, + CELL_VDEC_DIVX_TC_SMPTE_170_M = 0x06, + CELL_VDEC_DIVX_TC_SMPTE_240_M = 0x07, + CELL_VDEC_DIVX_TC_LINEAR = 0x08, + CELL_VDEC_DIVX_TC_LOG_100_1 = 0x09, + CELL_VDEC_DIVX_TC_LOG_316_1 = 0x0a, +}; + +enum DIVX_matrixCoefficients : u8 +{ + CELL_VDEC_DIVX_MXC_ITU_R_BT_709 = 0x01, + CELL_VDEC_DIVX_MXC_UNSPECIFIED = 0x02, + CELL_VDEC_DIVX_MXC_FCC = 0x04, + CELL_VDEC_DIVX_MXC_ITU_R_BT_470_SYS_BG = 0x05, + CELL_VDEC_DIVX_MXC_SMPTE_170_M = 0x06, + CELL_VDEC_DIVX_MXC_SMPTE_240_M = 0x07, + CELL_VDEC_DIVX_MXC_YCGCO = 0x08, +}; + +struct CellVdecDivxInfo +{ + DIVX_pictureType pictureType; + be_t horizontalSize; + be_t verticalSize; + DIVX_pixelAspectRatio pixelAspectRatio; + u8 parWidth; + u8 parHeight; + bool colourDescription; + DIVX_colourPrimaries colourPrimaries; + DIVX_transferCharacteristics transferCharacteristics; + DIVX_matrixCoefficients matrixCoefficients; + DIVX_pictureStruct pictureStruct; + be_t frameRateCode; +}; + +enum MPEG2_level +{ + CELL_VDEC_MPEG2_MP_LL, + CELL_VDEC_MPEG2_MP_ML, + CELL_VDEC_MPEG2_MP_H14, + CELL_VDEC_MPEG2_MP_HL, +}; + +struct CellVdecMpeg2SpecificInfo +{ + be_t thisSize; + be_t maxDecodedFrameWidth; + be_t maxDecodedFrameHeight; +}; + +enum MPEG2_headerFlags : u32 +{ + CELL_VDEC_MPEG2_FLG_SEQ_HDR = 0x00000001, + CELL_VDEC_MPEG2_FLG_SEQ_EXT = 0x00000002, + CELL_VDEC_MPEG2_FLG_SEQ_DSP_EXT = 0x00000004, + CELL_VDEC_MPEG2_FLG_SEQ_USR_DAT = 0x00000008, + CELL_VDEC_MPEG2_FLG_SEQ_END = 0x00000010, + CELL_VDEC_MPEG2_FLG_GOP_HDR = 0x00000020, + CELL_VDEC_MPEG2_FLG_GOP_USR_DAT = 0x00000040, + CELL_VDEC_MPEG2_FLG_PIC_HDR_1 = 0x00000100, + CELL_VDEC_MPEG2_FLG_PIC_EXT_1 = 0x00000200, + CELL_VDEC_MPEG2_FLG_PIC_DSP_EXT_1 = 0x00000400, + CELL_VDEC_MPEG2_FLG_PIC_USR_DAT_1 = 0x00000800, + CELL_VDEC_MPEG2_FLG_PIC_HDR_2 = 0x00001000, + CELL_VDEC_MPEG2_FLG_PIC_EXT_2 = 0x00002000, + CELL_VDEC_MPEG2_FLG_PIC_DSP_EXT_2 = 0x00004000, + CELL_VDEC_MPEG2_FLG_PIC_USR_DAT_2 = 0x00008000, +}; + +enum MPEG2_aspectRatio : u8 +{ + CELL_VDEC_MPEG2_ARI_SAR_1_1 = 0x01, + CELL_VDEC_MPEG2_ARI_DAR_4_3 = 0x02, + CELL_VDEC_MPEG2_ARI_DAR_16_9 = 0x03, + CELL_VDEC_MPEG2_ARI_DAR_2P21_1 = 0x04, +}; + +enum MPEG1_aspectRatio : u8 +{ + CELL_VDEC_MPEG1_ARI_SAR_1P0 = 0x01, + CELL_VDEC_MPEG1_ARI_SAR_0P6735 = 0x02, + CELL_VDEC_MPEG1_ARI_SAR_0P7031 = 0x03, + CELL_VDEC_MPEG1_ARI_SAR_0P7615 = 0x04, + CELL_VDEC_MPEG1_ARI_SAR_0P8055 = 0x05, + CELL_VDEC_MPEG1_ARI_SAR_0P8437 = 0x06, + CELL_VDEC_MPEG1_ARI_SAR_0P8935 = 0x07, + CELL_VDEC_MPEG1_ARI_SAR_0P9157 = 0x08, + CELL_VDEC_MPEG1_ARI_SAR_0P9815 = 0x09, + CELL_VDEC_MPEG1_ARI_SAR_1P0255 = 0x0a, + CELL_VDEC_MPEG1_ARI_SAR_1P0695 = 0x0b, + CELL_VDEC_MPEG1_ARI_SAR_1P0950 = 0x0c, + CELL_VDEC_MPEG1_ARI_SAR_1P1575 = 0x0d, + CELL_VDEC_MPEG1_ARI_SAR_1P2015 = 0x0e, +}; + +enum MPEG2_frameRate : u8 +{ + CELL_VDEC_MPEG2_FRC_FORBIDDEN = 0x00, + CELL_VDEC_MPEG2_FRC_24000DIV1001 = 0x01, + CELL_VDEC_MPEG2_FRC_24 = 0x02, + CELL_VDEC_MPEG2_FRC_25 = 0x03, + CELL_VDEC_MPEG2_FRC_30000DIV1001 = 0x04, + CELL_VDEC_MPEG2_FRC_30 = 0x05, + CELL_VDEC_MPEG2_FRC_50 = 0x06, + CELL_VDEC_MPEG2_FRC_60000DIV1001 = 0x07, + CELL_VDEC_MPEG2_FRC_60 = 0x08, +}; + +enum MPEG2_videoFormat : u8 +{ + CELL_VDEC_MPEG2_VF_COMPONENT = 0x00, + CELL_VDEC_MPEG2_VF_PAL = 0x01, + CELL_VDEC_MPEG2_VF_NTSC = 0x02, + CELL_VDEC_MPEG2_VF_SECAM = 0x03, + CELL_VDEC_MPEG2_VF_MAC = 0x04, + CELL_VDEC_MPEG2_VF_UNSPECIFIED = 0x05, +}; + +enum MPEG2_colourPrimaries : u8 +{ + CELL_VDEC_MPEG2_CP_FORBIDDEN = 0x00, + CELL_VDEC_MPEG2_CP_ITU_R_BT_709 = 0x01, + CELL_VDEC_MPEG2_CP_UNSPECIFIED = 0x02, + CELL_VDEC_MPEG2_CP_ITU_R_BT_470_2_SYS_M = 0x04, + CELL_VDEC_MPEG2_CP_ITU_R_BT_470_2_SYS_BG = 0x05, + CELL_VDEC_MPEG2_CP_SMPTE_170_M = 0x06, + CELL_VDEC_MPEG2_CP_SMPTE_240_M = 0x07, +}; + +enum MPEG2_transferCharacteristics : u8 +{ + CELL_VDEC_MPEG2_TC_FORBIDDEN = 0x00, + CELL_VDEC_MPEG2_TC_ITU_R_BT_709 = 0x01, + CELL_VDEC_MPEG2_TC_UNSPECIFIED = 0x02, + CELL_VDEC_MPEG2_TC_ITU_R_BT_470_2_SYS_M = 0x04, + CELL_VDEC_MPEG2_TC_ITU_R_BT_470_2_SYS_BG = 0x05, + CELL_VDEC_MPEG2_TC_SMPTE_170_M = 0x06, + CELL_VDEC_MPEG2_TC_SMPTE_240_M = 0x07, + CELL_VDEC_MPEG2_TC_LINEAR = 0x08, + CELL_VDEC_MPEG2_TC_LOG_100_1 = 0x09, + CELL_VDEC_MPEG2_TC_LOG_316_1 = 0x0a, +}; + +enum MPEG2_matrixCoefficients : u8 +{ + CELL_VDEC_MPEG2_MXC_FORBIDDEN = 0x00, + CELL_VDEC_MPEG2_MXC_ITU_R_BT_709 = 0x01, + CELL_VDEC_MPEG2_MXC_UNSPECIFIED = 0x02, + CELL_VDEC_MPEG2_MXC_FCC = 0x04, + CELL_VDEC_MPEG2_MXC_ITU_R_BT_470_2_SYS_BG = 0x05, + CELL_VDEC_MPEG2_MXC_SMPTE_170_M = 0x06, + CELL_VDEC_MPEG2_MXC_SMPTE_240_M = 0x07, +}; + +enum MPEG2_pictureCodingType : u8 +{ + CELL_VDEC_MPEG2_PCT_FORBIDDEN = 0x00, + CELL_VDEC_MPEG2_PCT_I = 0x01, + CELL_VDEC_MPEG2_PCT_P = 0x02, + CELL_VDEC_MPEG2_PCT_B = 0x03, + CELL_VDEC_MPEG2_PCT_D = 0x04, +}; + +enum MPEG2_pictureStructure : u8 +{ + CELL_VDEC_MPEG2_PSTR_TOP_FIELD = 0x01, + CELL_VDEC_MPEG2_PSTR_BOTTOM_FIELD = 0x02, + CELL_VDEC_MPEG2_PSTR_FRAME = 0x03, +}; + +struct CellVdecMpeg2Info +{ + be_t horizontal_size; + be_t vertical_size; + union + { + MPEG2_aspectRatio aspect_ratio_information; + MPEG1_aspectRatio aspect_ratio_information1; + }; + MPEG2_frameRate frame_rate_code; + bool progressive_sequence; + bool low_delay; + MPEG2_videoFormat video_format; + bool colour_description; + MPEG2_colourPrimaries colour_primaries; + MPEG2_transferCharacteristics transfer_characteristics; + MPEG2_matrixCoefficients matrix_coefficients; + be_t temporal_reference[2]; + MPEG2_pictureCodingType picture_coding_type[2]; + MPEG2_pictureStructure picture_structure[2]; + bool top_field_first; + bool repeat_first_field; + bool progressive_frame; + be_t time_code; + bool closed_gop; + bool broken_link; + be_t vbv_delay[2]; + be_t display_horizontal_size; + be_t display_vertical_size; + u8 number_of_frame_centre_offsets[2]; + be_t frame_centre_horizontal_offset[2][3]; + be_t frame_centre_vertical_offset[2][3]; + be_t headerPresentFlags; + be_t headerRetentionFlags; + bool mpeg1Flag; + u8 ccDataLength[2]; + u8 ccData[2][128]; + be_t reserved[2]; +}; \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp index 27113ad092..0154af54c1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp @@ -1,174 +1,42 @@ #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" +#include "cellVpost.h" void cellVpost_init(); Module cellVpost(0x0008, cellVpost_init); -// Error Codes -enum +int cellVpostQueryAttr(const mem_ptr_t cfgParam, mem_ptr_t attr) { - CELL_VPOST_ERROR_Q_ARG_CFG_NULL = 0x80610410, - CELL_VPOST_ERROR_Q_ARG_CFG_INVALID = 0x80610411, - CELL_VPOST_ERROR_Q_ARG_ATTR_NULL = 0x80610412, - CELL_VPOST_ERROR_O_ARG_CFG_NULL = 0x80610440, - CELL_VPOST_ERROR_O_ARG_CFG_INVALID = 0x80610441, - CELL_VPOST_ERROR_O_ARG_RSRC_NULL = 0x80610442, - CELL_VPOST_ERROR_O_ARG_RSRC_INVALID = 0x80610443, - CELL_VPOST_ERROR_O_ARG_HDL_NULL = 0x80610444, - CELL_VPOST_ERROR_O_FATAL_QUERY_FAIL = 0x80610460, - CELL_VPOST_ERROR_O_FATAL_CREATEMON_FAIL = 0x80610461, - CELL_VPOST_ERROR_O_FATAL_INITSPURS_FAIL = 0x80610462, - CELL_VPOST_ERROR_C_ARG_HDL_NULL = 0x80610470, - CELL_VPOST_ERROR_C_ARG_HDL_INVALID = 0x80610471, - CELL_VPOST_ERROR_C_FATAL_LOCKMON_FAIL = 0x80610490, - CELL_VPOST_ERROR_C_FATAL_UNLOCKMON_FAIL = 0x80610491, - CELL_VPOST_ERROR_C_FATAL_DESTROYMON_FAIL = 0x80610492, - CELL_VPOST_ERROR_C_FATAL_FINSPURS_FAIL = 0x80610463, - CELL_VPOST_ERROR_E_ARG_HDL_NULL = 0x806104a0, - CELL_VPOST_ERROR_E_ARG_HDL_INVALID = 0x806104a1, - CELL_VPOST_ERROR_E_ARG_INPICBUF_NULL = 0x806104a2, - CELL_VPOST_ERROR_E_ARG_INPICBUF_INVALID = 0x806104a3, - CELL_VPOST_ERROR_E_ARG_CTRL_NULL = 0x806104a4, - CELL_VPOST_ERROR_E_ARG_CTRL_INVALID = 0x806104a5, - CELL_VPOST_ERROR_E_ARG_OUTPICBUF_NULL = 0x806104a6, - CELL_VPOST_ERROR_E_ARG_OUTPICBUF_INVALID = 0x806104a7, - CELL_VPOST_ERROR_E_ARG_PICINFO_NULL = 0x806104a8, - CELL_VPOST_ERROR_E_FATAL_LOCKMON_FAIL = 0x806104c0, - CELL_VPOST_ERROR_E_FATAL_UNLOCKMON_FAIL = 0x806104c1, - CELL_VPOST_ENT_ERROR_Q_ARG_ATTR_NULL = 0x80618110, - CELL_VPOST_ENT_ERROR_O_ARG_RSRC_NULL = 0x80618140, - CELL_VPOST_ENT_ERROR_O_ARG_RSRC_INVALID = 0x80618141, - CELL_VPOST_ENT_ERROR_O_ARG_HDL_NULL = 0x80618142, - CELL_VPOST_ENT_ERROR_O_FATAL_QUERY_FAIL = 0x80618160, - CELL_VPOST_ENT_ERROR_O_FATAL_CSPUCORE_FAIL = 0x80618161, - CELL_VPOST_ENT_ERROR_C_ARG_HDL_NULL = 0x80618170, - CELL_VPOST_ENT_ERROR_C_ARG_HDL_INVALID = 0x80618171, - CELL_VPOST_ENT_ERROR_C_FATAL_SNDCMD_FAIL = 0x80618190, - CELL_VPOST_ENT_ERROR_C_FATAL_RCVRES_FAIL = 0x80618191, - CELL_VPOST_ENT_ERROR_C_FATAL_DSPUCORE_FAIL = 0x80618192, - CELL_VPOST_ENT_ERROR_E_ARG_HDL_NULL = 0x806181a0, - CELL_VPOST_ENT_ERROR_E_ARG_HDL_INVALID = 0x806181a1, - CELL_VPOST_ENT_ERROR_E_ARG_INPICBUF_NULL = 0x806181a2, - CELL_VPOST_ENT_ERROR_E_ARG_INPICBUF_INVALID = 0x806181a3, - CELL_VPOST_ENT_ERROR_E_ARG_INPICINFO_NULL = 0x806181a4, - CELL_VPOST_ENT_ERROR_E_ARG_INPICINFO_INVALID = 0x806181a5, - CELL_VPOST_ENT_ERROR_E_ARG_CTRL_NULL = 0x806181a6, - CELL_VPOST_ENT_ERROR_E_ARG_CTRL_INVALID = 0x806181a7, - CELL_VPOST_ENT_ERROR_E_ARG_COMB_INVALID = 0x806181a8, - CELL_VPOST_ENT_ERROR_E_ARG_OUTPICBUF_NULL = 0x806181a9, - CELL_VPOST_ENT_ERROR_E_ARG_OUTPICBUF_INVALID = 0x806181aa, - CELL_VPOST_ENT_ERROR_E_ARG_OUTPICINFO_NULL = 0x806181ab, - CELL_VPOST_ENT_ERROR_E_FATAL_SNDCMD_FAIL = 0x806181c0, - CELL_VPOST_ENT_ERROR_E_FATAL_RCVRES_FAIL = 0x806181c1, - CELL_VPOST_ENT_ERROR_E_FATAL_SPUCORE_FAIL = 0x806181c2, - CELL_VPOST_IPC_ERROR_Q_ARG_ATTR_NULL = 0x80618210, - CELL_VPOST_IPC_ERROR_O_ARG_RSRC_NULL = 0x80618240, - CELL_VPOST_IPC_ERROR_O_ARG_RSRC_INVALID = 0x80618241, - CELL_VPOST_IPC_ERROR_O_ARG_HDL_NULL = 0x80618242, - CELL_VPOST_IPC_ERROR_O_FATAL_QUERY_FAIL = 0x80618260, - CELL_VPOST_IPC_ERROR_O_FATAL_CSPUCORE_FAIL = 0x80618261, - CELL_VPOST_IPC_ERROR_C_ARG_HDL_NULL = 0x80618270, - CELL_VPOST_IPC_ERROR_C_ARG_HDL_INVALID = 0x80618271, - CELL_VPOST_IPC_ERROR_C_FATAL_SNDCMD_FAIL = 0x80618290, - CELL_VPOST_IPC_ERROR_C_FATAL_RCVRES_FAIL = 0x80618291, - CELL_VPOST_IPC_ERROR_C_FATAL_DSPUCORE_FAIL = 0x80618292, - CELL_VPOST_IPC_ERROR_E_ARG_HDL_NULL = 0x806182a0, - CELL_VPOST_IPC_ERROR_E_ARG_HDL_INVALID = 0x806182a1, - CELL_VPOST_IPC_ERROR_E_ARG_INPICBUF_NULL = 0x806182a2, - CELL_VPOST_IPC_ERROR_E_ARG_INPICBUF_INVALID = 0x806182a3, - CELL_VPOST_IPC_ERROR_E_ARG_INPICINFO_NULL = 0x806182a4, - CELL_VPOST_IPC_ERROR_E_ARG_INPICINFO_INVALID = 0x806182a5, - CELL_VPOST_IPC_ERROR_E_ARG_CTRL_NULL = 0x806182a6, - CELL_VPOST_IPC_ERROR_E_ARG_CTRL_INVALID = 0x806182a7, - CELL_VPOST_IPC_ERROR_E_ARG_COMB_INVALID = 0x806182a8, - CELL_VPOST_IPC_ERROR_E_ARG_OUTPICBUF_NULL = 0x806182a9, - CELL_VPOST_IPC_ERROR_E_ARG_OUTPICBUF_INVALID = 0x806182aa, - CELL_VPOST_IPC_ERROR_E_ARG_OUTPICINFO_NULL = 0x806182ab, - CELL_VPOST_IPC_ERROR_E_FATAL_SNDCMD_FAIL = 0x806182c0, - CELL_VPOST_IPC_ERROR_E_FATAL_RCVRES_FAIL = 0x806182c1, - CELL_VPOST_IPC_ERROR_E_FATAL_SPUCORE_FAIL = 0x806182c2, - CELL_VPOST_VSC_ERROR_Q_ARG_ATTR_NULL = 0x80618310, - CELL_VPOST_VSC_ERROR_O_ARG_RSRC_NULL = 0x80618340, - CELL_VPOST_VSC_ERROR_O_ARG_RSRC_INVALID = 0x80618341, - CELL_VPOST_VSC_ERROR_O_ARG_HDL_NULL = 0x80618342, - CELL_VPOST_VSC_ERROR_O_FATAL_QUERY_FAIL = 0x80618360, - CELL_VPOST_VSC_ERROR_O_FATAL_CSPUCORE_FAIL = 0x80618361, - CELL_VPOST_VSC_ERROR_C_ARG_HDL_NULL = 0x80618370, - CELL_VPOST_VSC_ERROR_C_ARG_HDL_INVALID = 0x80618371, - CELL_VPOST_VSC_ERROR_C_FATAL_SNDCMD_FAIL = 0x80618390, - CELL_VPOST_VSC_ERROR_C_FATAL_RCVRES_FAIL = 0x80618391, - CELL_VPOST_VSC_ERROR_C_FATAL_DSPUCORE_FAIL = 0x80618392, - CELL_VPOST_VSC_ERROR_E_ARG_HDL_NULL = 0x806183a0, - CELL_VPOST_VSC_ERROR_E_ARG_HDL_INVALID = 0x806183a1, - CELL_VPOST_VSC_ERROR_E_ARG_INPICBUF_NULL = 0x806183a2, - CELL_VPOST_VSC_ERROR_E_ARG_INPICBUF_INVALID = 0x806183a3, - CELL_VPOST_VSC_ERROR_E_ARG_INPICINFO_NULL = 0x806183a4, - CELL_VPOST_VSC_ERROR_E_ARG_INPICINFO_INVALID = 0x806183a5, - CELL_VPOST_VSC_ERROR_E_ARG_CTRL_NULL = 0x806183a6, - CELL_VPOST_VSC_ERROR_E_ARG_CTRL_INVALID = 0x806183a7, - CELL_VPOST_VSC_ERROR_E_ARG_COMB_INVALID = 0x806183a8, - CELL_VPOST_VSC_ERROR_E_ARG_OUTPICBUF_NULL = 0x806183a9, - CELL_VPOST_VSC_ERROR_E_ARG_OUTPICBUF_INVALID = 0x806183aa, - CELL_VPOST_VSC_ERROR_E_ARG_OUTPICINFO_NULL = 0x806183ab, - CELL_VPOST_VSC_ERROR_E_FATAL_SNDCMD_FAIL = 0x806183c0, - CELL_VPOST_VSC_ERROR_E_FATAL_RCVRES_FAIL = 0x806183c1, - CELL_VPOST_VSC_ERROR_E_FATAL_SPUCORE_FAIL = 0x806183c2, - CELL_VPOST_CSC_ERROR_Q_ARG_ATTR_NULL = 0x80618410, - CELL_VPOST_CSC_ERROR_O_ARG_RSRC_NULL = 0x80618440, - CELL_VPOST_CSC_ERROR_O_ARG_RSRC_INVALID = 0x80618441, - CELL_VPOST_CSC_ERROR_O_ARG_HDL_NULL = 0x80618442, - CELL_VPOST_CSC_ERROR_O_FATAL_QUERY_FAIL = 0x80618460, - CELL_VPOST_CSC_ERROR_O_FATAL_CSPUCORE_FAIL = 0x80618461, - CELL_VPOST_CSC_ERROR_C_ARG_HDL_NULL = 0x80618470, - CELL_VPOST_CSC_ERROR_C_ARG_HDL_INVALID = 0x80618471, - CELL_VPOST_CSC_ERROR_C_FATAL_SNDCMD_FAIL = 0x80618490, - CELL_VPOST_CSC_ERROR_C_FATAL_RCVRES_FAIL = 0x80618491, - CELL_VPOST_CSC_ERROR_C_FATAL_DSPUCORE_FAIL = 0x80618492, - CELL_VPOST_CSC_ERROR_E_ARG_HDL_NULL = 0x806184a0, - CELL_VPOST_CSC_ERROR_E_ARG_HDL_INVALID = 0x806184a1, - CELL_VPOST_CSC_ERROR_E_ARG_INPICBUF_NULL = 0x806184a2, - CELL_VPOST_CSC_ERROR_E_ARG_INPICBUF_INVALID = 0x806184a3, - CELL_VPOST_CSC_ERROR_E_ARG_INPICINFO_NULL = 0x806184a4, - CELL_VPOST_CSC_ERROR_E_ARG_INPICINFO_INVALID = 0x806184a5, - CELL_VPOST_CSC_ERROR_E_ARG_CTRL_NULL = 0x806184a6, - CELL_VPOST_CSC_ERROR_E_ARG_CTRL_INVALID = 0x806184a7, - CELL_VPOST_CSC_ERROR_E_ARG_COMB_INVALID = 0x806184a8, - CELL_VPOST_CSC_ERROR_E_ARG_OUTPICBUF_NULL = 0x806184a9, - CELL_VPOST_CSC_ERROR_E_ARG_OUTPICBUF_INVALID = 0x806184aa, - CELL_VPOST_CSC_ERROR_E_ARG_OUTPICINFO_NULL = 0x806184ab, - CELL_VPOST_CSC_ERROR_E_FATAL_SNDCMD_FAIL = 0x806184c0, - CELL_VPOST_CSC_ERROR_E_FATAL_RCVRES_FAIL = 0x806184c1, - CELL_VPOST_CSC_ERROR_E_FATAL_SPUCORE_FAIL = 0x806184c2, -}; - -int cellVpostQueryAttr() -{ - UNIMPLEMENTED_FUNC(cellVpost); + cellVpost.Error("cellVpostQueryAttr(cfgParam_addr=0x%x, attr_addr=0x%x)", cfgParam.GetAddr(), attr.GetAddr()); return CELL_OK; } -int cellVpostOpen() +int cellVpostOpen(const mem_ptr_t cfgParam, const mem_ptr_t resource, mem32_t handle) { - UNIMPLEMENTED_FUNC(cellVpost); + cellVpost.Error("cellVpostOpen(cfgParam_addr=0x%x, resource_addr=0x%x, handle_addr=0x%x)", + cfgParam.GetAddr(), resource.GetAddr(), handle.GetAddr()); return CELL_OK; } -int cellVpostOpenEx() +int cellVpostOpenEx(const mem_ptr_t cfgParam, const mem_ptr_t resource, mem32_t handle) { - UNIMPLEMENTED_FUNC(cellVpost); + cellVpost.Error("cellVpostOpenEx(cfgParam_addr=0x%x, resource_addr=0x%x, handle_addr=0x%x)", + cfgParam.GetAddr(), resource.GetAddr(), handle.GetAddr()); return CELL_OK; } -int cellVpostClose() +int cellVpostClose(u32 handle) { - UNIMPLEMENTED_FUNC(cellVpost); + cellVpost.Error("cellVpostClose(handle=0x%x)", handle); return CELL_OK; } -int cellVpostExec() +int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t ctrlParam, + u32 outPicBuff_addr, mem_ptr_t picInfo) { - UNIMPLEMENTED_FUNC(cellVpost); + cellVpost.Error("cellVpostExec(handle=0x%x, inPicBuff_addr=0x%x, ctrlParam_addr=0x%x, outPicBuff_addr=0x%x, picInfo_addr=0x%x)", + handle, inPicBuff_addr, ctrlParam.GetAddr(), outPicBuff_addr, picInfo.GetAddr()); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellVpost.h b/rpcs3/Emu/SysCalls/Modules/cellVpost.h new file mode 100644 index 0000000000..3e54a55050 --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellVpost.h @@ -0,0 +1,317 @@ +#pragma once + +// Error Codes +enum +{ + CELL_VPOST_ERROR_Q_ARG_CFG_NULL = 0x80610410, + CELL_VPOST_ERROR_Q_ARG_CFG_INVALID = 0x80610411, + CELL_VPOST_ERROR_Q_ARG_ATTR_NULL = 0x80610412, + CELL_VPOST_ERROR_O_ARG_CFG_NULL = 0x80610440, + CELL_VPOST_ERROR_O_ARG_CFG_INVALID = 0x80610441, + CELL_VPOST_ERROR_O_ARG_RSRC_NULL = 0x80610442, + CELL_VPOST_ERROR_O_ARG_RSRC_INVALID = 0x80610443, + CELL_VPOST_ERROR_O_ARG_HDL_NULL = 0x80610444, + CELL_VPOST_ERROR_O_FATAL_QUERY_FAIL = 0x80610460, + CELL_VPOST_ERROR_O_FATAL_CREATEMON_FAIL = 0x80610461, + CELL_VPOST_ERROR_O_FATAL_INITSPURS_FAIL = 0x80610462, + CELL_VPOST_ERROR_C_ARG_HDL_NULL = 0x80610470, + CELL_VPOST_ERROR_C_ARG_HDL_INVALID = 0x80610471, + CELL_VPOST_ERROR_C_FATAL_LOCKMON_FAIL = 0x80610490, + CELL_VPOST_ERROR_C_FATAL_UNLOCKMON_FAIL = 0x80610491, + CELL_VPOST_ERROR_C_FATAL_DESTROYMON_FAIL = 0x80610492, + CELL_VPOST_ERROR_C_FATAL_FINSPURS_FAIL = 0x80610463, + CELL_VPOST_ERROR_E_ARG_HDL_NULL = 0x806104a0, + CELL_VPOST_ERROR_E_ARG_HDL_INVALID = 0x806104a1, + CELL_VPOST_ERROR_E_ARG_INPICBUF_NULL = 0x806104a2, + CELL_VPOST_ERROR_E_ARG_INPICBUF_INVALID = 0x806104a3, + CELL_VPOST_ERROR_E_ARG_CTRL_NULL = 0x806104a4, + CELL_VPOST_ERROR_E_ARG_CTRL_INVALID = 0x806104a5, + CELL_VPOST_ERROR_E_ARG_OUTPICBUF_NULL = 0x806104a6, + CELL_VPOST_ERROR_E_ARG_OUTPICBUF_INVALID = 0x806104a7, + CELL_VPOST_ERROR_E_ARG_PICINFO_NULL = 0x806104a8, + CELL_VPOST_ERROR_E_FATAL_LOCKMON_FAIL = 0x806104c0, + CELL_VPOST_ERROR_E_FATAL_UNLOCKMON_FAIL = 0x806104c1, + CELL_VPOST_ENT_ERROR_Q_ARG_ATTR_NULL = 0x80618110, + CELL_VPOST_ENT_ERROR_O_ARG_RSRC_NULL = 0x80618140, + CELL_VPOST_ENT_ERROR_O_ARG_RSRC_INVALID = 0x80618141, + CELL_VPOST_ENT_ERROR_O_ARG_HDL_NULL = 0x80618142, + CELL_VPOST_ENT_ERROR_O_FATAL_QUERY_FAIL = 0x80618160, + CELL_VPOST_ENT_ERROR_O_FATAL_CSPUCORE_FAIL = 0x80618161, + CELL_VPOST_ENT_ERROR_C_ARG_HDL_NULL = 0x80618170, + CELL_VPOST_ENT_ERROR_C_ARG_HDL_INVALID = 0x80618171, + CELL_VPOST_ENT_ERROR_C_FATAL_SNDCMD_FAIL = 0x80618190, + CELL_VPOST_ENT_ERROR_C_FATAL_RCVRES_FAIL = 0x80618191, + CELL_VPOST_ENT_ERROR_C_FATAL_DSPUCORE_FAIL = 0x80618192, + CELL_VPOST_ENT_ERROR_E_ARG_HDL_NULL = 0x806181a0, + CELL_VPOST_ENT_ERROR_E_ARG_HDL_INVALID = 0x806181a1, + CELL_VPOST_ENT_ERROR_E_ARG_INPICBUF_NULL = 0x806181a2, + CELL_VPOST_ENT_ERROR_E_ARG_INPICBUF_INVALID = 0x806181a3, + CELL_VPOST_ENT_ERROR_E_ARG_INPICINFO_NULL = 0x806181a4, + CELL_VPOST_ENT_ERROR_E_ARG_INPICINFO_INVALID = 0x806181a5, + CELL_VPOST_ENT_ERROR_E_ARG_CTRL_NULL = 0x806181a6, + CELL_VPOST_ENT_ERROR_E_ARG_CTRL_INVALID = 0x806181a7, + CELL_VPOST_ENT_ERROR_E_ARG_COMB_INVALID = 0x806181a8, + CELL_VPOST_ENT_ERROR_E_ARG_OUTPICBUF_NULL = 0x806181a9, + CELL_VPOST_ENT_ERROR_E_ARG_OUTPICBUF_INVALID = 0x806181aa, + CELL_VPOST_ENT_ERROR_E_ARG_OUTPICINFO_NULL = 0x806181ab, + CELL_VPOST_ENT_ERROR_E_FATAL_SNDCMD_FAIL = 0x806181c0, + CELL_VPOST_ENT_ERROR_E_FATAL_RCVRES_FAIL = 0x806181c1, + CELL_VPOST_ENT_ERROR_E_FATAL_SPUCORE_FAIL = 0x806181c2, + CELL_VPOST_IPC_ERROR_Q_ARG_ATTR_NULL = 0x80618210, + CELL_VPOST_IPC_ERROR_O_ARG_RSRC_NULL = 0x80618240, + CELL_VPOST_IPC_ERROR_O_ARG_RSRC_INVALID = 0x80618241, + CELL_VPOST_IPC_ERROR_O_ARG_HDL_NULL = 0x80618242, + CELL_VPOST_IPC_ERROR_O_FATAL_QUERY_FAIL = 0x80618260, + CELL_VPOST_IPC_ERROR_O_FATAL_CSPUCORE_FAIL = 0x80618261, + CELL_VPOST_IPC_ERROR_C_ARG_HDL_NULL = 0x80618270, + CELL_VPOST_IPC_ERROR_C_ARG_HDL_INVALID = 0x80618271, + CELL_VPOST_IPC_ERROR_C_FATAL_SNDCMD_FAIL = 0x80618290, + CELL_VPOST_IPC_ERROR_C_FATAL_RCVRES_FAIL = 0x80618291, + CELL_VPOST_IPC_ERROR_C_FATAL_DSPUCORE_FAIL = 0x80618292, + CELL_VPOST_IPC_ERROR_E_ARG_HDL_NULL = 0x806182a0, + CELL_VPOST_IPC_ERROR_E_ARG_HDL_INVALID = 0x806182a1, + CELL_VPOST_IPC_ERROR_E_ARG_INPICBUF_NULL = 0x806182a2, + CELL_VPOST_IPC_ERROR_E_ARG_INPICBUF_INVALID = 0x806182a3, + CELL_VPOST_IPC_ERROR_E_ARG_INPICINFO_NULL = 0x806182a4, + CELL_VPOST_IPC_ERROR_E_ARG_INPICINFO_INVALID = 0x806182a5, + CELL_VPOST_IPC_ERROR_E_ARG_CTRL_NULL = 0x806182a6, + CELL_VPOST_IPC_ERROR_E_ARG_CTRL_INVALID = 0x806182a7, + CELL_VPOST_IPC_ERROR_E_ARG_COMB_INVALID = 0x806182a8, + CELL_VPOST_IPC_ERROR_E_ARG_OUTPICBUF_NULL = 0x806182a9, + CELL_VPOST_IPC_ERROR_E_ARG_OUTPICBUF_INVALID = 0x806182aa, + CELL_VPOST_IPC_ERROR_E_ARG_OUTPICINFO_NULL = 0x806182ab, + CELL_VPOST_IPC_ERROR_E_FATAL_SNDCMD_FAIL = 0x806182c0, + CELL_VPOST_IPC_ERROR_E_FATAL_RCVRES_FAIL = 0x806182c1, + CELL_VPOST_IPC_ERROR_E_FATAL_SPUCORE_FAIL = 0x806182c2, + CELL_VPOST_VSC_ERROR_Q_ARG_ATTR_NULL = 0x80618310, + CELL_VPOST_VSC_ERROR_O_ARG_RSRC_NULL = 0x80618340, + CELL_VPOST_VSC_ERROR_O_ARG_RSRC_INVALID = 0x80618341, + CELL_VPOST_VSC_ERROR_O_ARG_HDL_NULL = 0x80618342, + CELL_VPOST_VSC_ERROR_O_FATAL_QUERY_FAIL = 0x80618360, + CELL_VPOST_VSC_ERROR_O_FATAL_CSPUCORE_FAIL = 0x80618361, + CELL_VPOST_VSC_ERROR_C_ARG_HDL_NULL = 0x80618370, + CELL_VPOST_VSC_ERROR_C_ARG_HDL_INVALID = 0x80618371, + CELL_VPOST_VSC_ERROR_C_FATAL_SNDCMD_FAIL = 0x80618390, + CELL_VPOST_VSC_ERROR_C_FATAL_RCVRES_FAIL = 0x80618391, + CELL_VPOST_VSC_ERROR_C_FATAL_DSPUCORE_FAIL = 0x80618392, + CELL_VPOST_VSC_ERROR_E_ARG_HDL_NULL = 0x806183a0, + CELL_VPOST_VSC_ERROR_E_ARG_HDL_INVALID = 0x806183a1, + CELL_VPOST_VSC_ERROR_E_ARG_INPICBUF_NULL = 0x806183a2, + CELL_VPOST_VSC_ERROR_E_ARG_INPICBUF_INVALID = 0x806183a3, + CELL_VPOST_VSC_ERROR_E_ARG_INPICINFO_NULL = 0x806183a4, + CELL_VPOST_VSC_ERROR_E_ARG_INPICINFO_INVALID = 0x806183a5, + CELL_VPOST_VSC_ERROR_E_ARG_CTRL_NULL = 0x806183a6, + CELL_VPOST_VSC_ERROR_E_ARG_CTRL_INVALID = 0x806183a7, + CELL_VPOST_VSC_ERROR_E_ARG_COMB_INVALID = 0x806183a8, + CELL_VPOST_VSC_ERROR_E_ARG_OUTPICBUF_NULL = 0x806183a9, + CELL_VPOST_VSC_ERROR_E_ARG_OUTPICBUF_INVALID = 0x806183aa, + CELL_VPOST_VSC_ERROR_E_ARG_OUTPICINFO_NULL = 0x806183ab, + CELL_VPOST_VSC_ERROR_E_FATAL_SNDCMD_FAIL = 0x806183c0, + CELL_VPOST_VSC_ERROR_E_FATAL_RCVRES_FAIL = 0x806183c1, + CELL_VPOST_VSC_ERROR_E_FATAL_SPUCORE_FAIL = 0x806183c2, + CELL_VPOST_CSC_ERROR_Q_ARG_ATTR_NULL = 0x80618410, + CELL_VPOST_CSC_ERROR_O_ARG_RSRC_NULL = 0x80618440, + CELL_VPOST_CSC_ERROR_O_ARG_RSRC_INVALID = 0x80618441, + CELL_VPOST_CSC_ERROR_O_ARG_HDL_NULL = 0x80618442, + CELL_VPOST_CSC_ERROR_O_FATAL_QUERY_FAIL = 0x80618460, + CELL_VPOST_CSC_ERROR_O_FATAL_CSPUCORE_FAIL = 0x80618461, + CELL_VPOST_CSC_ERROR_C_ARG_HDL_NULL = 0x80618470, + CELL_VPOST_CSC_ERROR_C_ARG_HDL_INVALID = 0x80618471, + CELL_VPOST_CSC_ERROR_C_FATAL_SNDCMD_FAIL = 0x80618490, + CELL_VPOST_CSC_ERROR_C_FATAL_RCVRES_FAIL = 0x80618491, + CELL_VPOST_CSC_ERROR_C_FATAL_DSPUCORE_FAIL = 0x80618492, + CELL_VPOST_CSC_ERROR_E_ARG_HDL_NULL = 0x806184a0, + CELL_VPOST_CSC_ERROR_E_ARG_HDL_INVALID = 0x806184a1, + CELL_VPOST_CSC_ERROR_E_ARG_INPICBUF_NULL = 0x806184a2, + CELL_VPOST_CSC_ERROR_E_ARG_INPICBUF_INVALID = 0x806184a3, + CELL_VPOST_CSC_ERROR_E_ARG_INPICINFO_NULL = 0x806184a4, + CELL_VPOST_CSC_ERROR_E_ARG_INPICINFO_INVALID = 0x806184a5, + CELL_VPOST_CSC_ERROR_E_ARG_CTRL_NULL = 0x806184a6, + CELL_VPOST_CSC_ERROR_E_ARG_CTRL_INVALID = 0x806184a7, + CELL_VPOST_CSC_ERROR_E_ARG_COMB_INVALID = 0x806184a8, + CELL_VPOST_CSC_ERROR_E_ARG_OUTPICBUF_NULL = 0x806184a9, + CELL_VPOST_CSC_ERROR_E_ARG_OUTPICBUF_INVALID = 0x806184aa, + CELL_VPOST_CSC_ERROR_E_ARG_OUTPICINFO_NULL = 0x806184ab, + CELL_VPOST_CSC_ERROR_E_FATAL_SNDCMD_FAIL = 0x806184c0, + CELL_VPOST_CSC_ERROR_E_FATAL_RCVRES_FAIL = 0x806184c1, + CELL_VPOST_CSC_ERROR_E_FATAL_SPUCORE_FAIL = 0x806184c2, +}; + +enum CellVpostPictureDepth +{ + CELL_VPOST_PIC_DEPTH_8, +}; + +enum CellVpostPictureFormatIn +{ + CELL_VPOST_PIC_FMT_IN_YUV420_PLANAR, +}; + +enum CellVpostPictureFormatOut +{ + CELL_VPOST_PIC_FMT_OUT_RGBA_ILV, + CELL_VPOST_PIC_FMT_OUT_YUV420_PLANAR, +}; + +enum CellVpostPictureStructure +{ + CELL_VPOST_PIC_STRUCT_PFRM, + CELL_VPOST_PIC_STRUCT_IFRM, + CELL_VPOST_PIC_STRUCT_ITOP, + CELL_VPOST_PIC_STRUCT_IBTM, +}; + +enum CellVpostExecType +{ + CELL_VPOST_EXEC_TYPE_PFRM_PFRM, + CELL_VPOST_EXEC_TYPE_PTOP_ITOP, + CELL_VPOST_EXEC_TYPE_PBTM_IBTM, + CELL_VPOST_EXEC_TYPE_ITOP_PFRM, + CELL_VPOST_EXEC_TYPE_IBTM_PFRM, + CELL_VPOST_EXEC_TYPE_IFRM_IFRM, + CELL_VPOST_EXEC_TYPE_ITOP_ITOP, + CELL_VPOST_EXEC_TYPE_IBTM_IBTM, +}; + +enum CellVpostChromaPositionType +{ + CELL_VPOST_CHROMA_POS_TYPE_A, + CELL_VPOST_CHROMA_POS_TYPE_B, +}; + +enum CellVpostScanType +{ + CELL_VPOST_SCAN_TYPE_P, + CELL_VPOST_SCAN_TYPE_I, +}; + +enum CellVpostQuantRange +{ + CELL_VPOST_QUANT_RANGE_FULL, + CELL_VPOST_QUANT_RANGE_BROADCAST, +}; + +enum CellVpostColorMatrix +{ + CELL_VPOST_COLOR_MATRIX_BT601, + CELL_VPOST_COLOR_MATRIX_BT709, +}; + +enum CellVpostScalerType +{ + CELL_VPOST_SCALER_TYPE_BILINEAR, + CELL_VPOST_SCALER_TYPE_LINEAR_SHARP, + CELL_VPOST_SCALER_TYPE_2X4TAP, + CELL_VPOST_SCALER_TYPE_8X4TAP, +}; + +enum CellVpostIpcType +{ + CELL_VPOST_IPC_TYPE_DOUBLING, + CELL_VPOST_IPC_TYPE_LINEAR, + CELL_VPOST_IPC_TYPE_MAVG, +}; + +struct CellVpostCfgParam +{ + be_t inMaxWidth; + be_t inMaxHeight; + be_t inDepth; + be_t inPicFmt; + + be_t outMaxWidth; + be_t outMaxHeight; + be_t outDepth; + be_t outPicFmt; + + be_t reserved1; + be_t reserved2; +}; + +struct CellVpostAttr +{ + be_t memSize; + u8 delay; + be_t vpostVerUpper; + be_t vpostVerLower; +}; + +struct CellVpostResource +{ + be_t memAddr; + be_t memSize; + be_t ppuThreadPriority; + be_t ppuThreadStackSize; + be_t spuThreadPriority; + be_t numOfSpus; +}; + +struct CellVpostResourceEx +{ + be_t memAddr; + be_t memSize; + be_t spurs_addr; + u8 priority[8]; + be_t maxContention; +}; + +struct CellVpostWindow +{ + be_t x; + be_t y; + be_t width; + be_t height; +}; + +struct CellVpostCtrlParam +{ + be_t execType; + + be_t scalerType; + be_t ipcType; + + be_t inWidth; + be_t inHeight; + be_t inChromaPosType; + be_t inQuantRange; + be_t inColorMatrix; + CellVpostWindow inWindow; + + be_t outWidth; + be_t outHeight; + CellVpostWindow outWindow; + u8 outAlpha; + + be_t userData; + + be_t reserved1; + be_t reserved2; +}; + +struct CellVpostPictureInfo +{ + be_t inWidth; + be_t inHeight; + be_t inDepth; + be_t inScanType; + be_t inPicFmt; + be_t inChromaPosType; + be_t inPicStruct; + be_t inQuantRange; + be_t inColorMatrix; + + be_t outWidth; + be_t outHeight; + be_t outDepth; + be_t outScanType; + be_t outPicFmt; + be_t outChromaPosType; + be_t outPicStruct; + be_t outQuantRange; + be_t outColorMatrix; + + be_t userData; + + be_t reserved1; + be_t reserved2; +}; diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index c840f18f57..9aefb67151 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -131,9 +131,9 @@ int cellFsSdataOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) std::atomic g_FsAioReadID( 0 ); std::atomic g_FsAioReadCur( 0 ); -bool aio_init; +bool aio_init = false; -void fsAioRead(u32 fd, mem_ptr_t aio, int xid, mem_func_ptr_t xaio, u32 error, int xid, u64 size)> func) +void fsAioRead(u32 fd, mem_ptr_t aio, int xid, mem_func_ptr_t xaio, int error, int xid, u64 size)> func) { while (g_FsAioReadCur != xid) { @@ -184,14 +184,26 @@ void fsAioRead(u32 fd, mem_ptr_t aio, int xid, mem_func_ptr_toffset, buf_addr, (u64)aio->size, res, xid, path.wx_str()); - //start callback thread - if(func) + if (func) // start callback thread + { func.async(aio, error, xid, res); + } + + CPUThread& thr = Emu.GetCallbackThread(); + while (thr.IsAlive()) + { + Sleep(1); + if (Emu.IsStopped()) + { + ConLog.Warning("fsAioRead() aborted"); + break; + } + } g_FsAioReadCur++; } -int cellFsAioRead(mem_ptr_t aio, mem32_t aio_id, mem_func_ptr_t xaio, u32 error, int xid, u64 size)> func) +int cellFsAioRead(mem_ptr_t aio, mem32_t aio_id, mem_func_ptr_t xaio, int error, int xid, u64 size)> func) { sys_fs.Warning("cellFsAioRead(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.GetAddr(), aio_id.GetAddr(), func.GetAddr()); @@ -202,7 +214,7 @@ int cellFsAioRead(mem_ptr_t aio, mem32_t aio_id, mem_func_ptr_t attr, u64 event_queue_key, int size); extern int sys_event_queue_destroy(u32 equeue_id, int mode); -extern int sys_event_queue_receive(u32 equeue_id, mem_ptr_t _event, u64 timeout); +extern int sys_event_queue_receive(u32 equeue_id, mem_ptr_t event, u64 timeout); extern int sys_event_queue_tryreceive(u32 equeue_id, mem_ptr_t event_array, int size, mem32_t number); extern int sys_event_queue_drain(u32 event_queue_id); extern int sys_event_port_create(mem32_t eport_id, int port_type, u64 name); diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Condition.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Condition.cpp index 650673abf9..e253a7a140 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Condition.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Condition.cpp @@ -128,7 +128,7 @@ int sys_cond_signal(u32 cond_id) Mutex* mutex = cond->mutex; u32 tid = GetCurrentPPUThread().GetId(); - if (u32 target = mutex->protocol == SYS_SYNC_PRIORITY ? mutex->m_queue.pop_prio() : mutex->m_queue.pop()) + if (u32 target = (mutex->protocol == SYS_SYNC_PRIORITY ? mutex->m_queue.pop_prio() : mutex->m_queue.pop())) { if (mutex->m_mutex.trylock(target) != SMR_OK) { @@ -159,7 +159,7 @@ int sys_cond_signal_all(u32 cond_id) Mutex* mutex = cond->mutex; u32 tid = GetCurrentPPUThread().GetId(); - while (u32 target = mutex->protocol == SYS_SYNC_PRIORITY ? mutex->m_queue.pop_prio() : mutex->m_queue.pop()) + while (u32 target = (mutex->protocol == SYS_SYNC_PRIORITY ? mutex->m_queue.pop_prio() : mutex->m_queue.pop())) { if (mutex->m_mutex.trylock(target) != SMR_OK) { diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp index 0aea42d6cf..2e0e9abc2b 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp @@ -74,18 +74,18 @@ int sys_event_queue_destroy(u32 equeue_id, int mode) u32 tid = GetCurrentPPUThread().GetId(); - eq->m_mutex.lock(tid); + eq->sq.m_mutex.lock(tid); eq->owner.lock(tid); // check if some threads are waiting for an event - if (!mode && eq->list.GetCount()) + if (!mode && eq->sq.list.GetCount()) { eq->owner.unlock(tid); - eq->m_mutex.unlock(tid); + eq->sq.m_mutex.unlock(tid); return CELL_EBUSY; } eq->owner.unlock(tid, ~0); - eq->m_mutex.unlock(tid); - while (eq->list.GetCount()) + eq->sq.m_mutex.unlock(tid); + while (eq->sq.list.GetCount()) { Sleep(1); if (Emu.IsStopped()) @@ -136,18 +136,18 @@ int sys_event_queue_tryreceive(u32 equeue_id, mem_ptr_t event_ar u32 tid = GetCurrentPPUThread().GetId(); - eq->m_mutex.lock(tid); + eq->sq.m_mutex.lock(tid); eq->owner.lock(tid); - if (eq->list.GetCount()) + if (eq->sq.list.GetCount()) { number = 0; eq->owner.unlock(tid); - eq->m_mutex.unlock(tid); + eq->sq.m_mutex.unlock(tid); return CELL_OK; } number = eq->events.pop_all((sys_event_data*)(Memory + event_array.GetAddr()), size); eq->owner.unlock(tid); - eq->m_mutex.unlock(tid); + eq->sq.m_mutex.unlock(tid); return CELL_OK; } @@ -174,7 +174,7 @@ int sys_event_queue_receive(u32 equeue_id, mem_ptr_t event, u64 u32 tid = GetCurrentPPUThread().GetId(); - eq->push(tid); // add thread to sleep queue + eq->sq.push(tid); // add thread to sleep queue timeout = timeout ? (timeout / 1000) : ~0; u64 counter = 0; @@ -190,7 +190,7 @@ int sys_event_queue_receive(u32 equeue_id, mem_ptr_t event, u64 } else { - u32 next = (eq->protocol == SYS_SYNC_FIFO) ? eq->pop() : eq->pop_prio(); + u32 next = (eq->protocol == SYS_SYNC_FIFO) ? eq->sq.pop() : eq->sq.pop_prio(); if (next != tid) { eq->owner.unlock(tid, next); @@ -199,80 +199,35 @@ int sys_event_queue_receive(u32 equeue_id, mem_ptr_t event, u64 } case SMR_SIGNAL: { - eq->events.pop(*(sys_event_data*)(Memory + event)); + eq->events.pop(*event); eq->owner.unlock(tid); + sys_event.Log(" *** event received: source=0x%llx, d1=0x%llx, d2=0x%llx, d3=0x%llx", + (u64)event->source, (u64)event->data1, (u64)event->data2, (u64)event->data3); + /* HACK: passing event data in registers */ + PPUThread& t = GetCurrentPPUThread(); + t.GPR[4] = event->source; + t.GPR[5] = event->data1; + t.GPR[6] = event->data2; + t.GPR[7] = event->data3; return CELL_OK; } case SMR_FAILED: break; - default: eq->invalidate(tid); return CELL_ECANCELED; + default: eq->sq.invalidate(tid); return CELL_ECANCELED; } Sleep(1); if (counter++ > timeout || Emu.IsStopped()) { if (Emu.IsStopped()) ConLog.Warning("sys_event_queue_receive(equeue=%d) aborted", equeue_id); - eq->invalidate(tid); + eq->sq.invalidate(tid); return CELL_ETIMEDOUT; } } - /* auto queue_receive = [&](int status) -> bool - { - if(status == CPUThread_Stopped) - { - result = CELL_ECANCELED; - return false; - } - - EventQueue* equeue; - if (!Emu.GetIdManager().GetIDData(equeue_id, equeue)) - { - result = CELL_ESRCH; - return false; - } - - for(int i=0; ipos; ++i) - { - if(!equeue->ports[i]->has_data && equeue->ports[i]->thread) - { - SPUThread* thr = (SPUThread*)equeue->ports[i]->thread; - if(thr->SPU.OutIntr_Mbox.GetCount()) - { - u32 val; - thr->SPU.OutIntr_Mbox.Pop(val); - if(!thr->SPU.Out_MBox.Pop(val)) val = 0; - equeue->ports[i]->data1 = val; - equeue->ports[i]->data2 = 0; - equeue->ports[i]->data3 = 0; - equeue->ports[i]->has_data = true; - } - } - } - - for(int i=0; ipos; i++) - { - if(equeue->ports[i]->has_data) - { - event->source = equeue->ports[i]->name; - event->data1 = equeue->ports[i]->data1; - event->data2 = equeue->ports[i]->data2; - event->data3 = equeue->ports[i]->data3; - - equeue->ports[i]->has_data = false; - - result = CELL_OK; - return false; - } - } - - return true; - }; - - GetCurrentPPUThread().WaitFor(queue_receive);*/ } int sys_event_queue_drain(u32 equeue_id) { - sys_event.Warning("sys_event_queue_drain(equeue_id=%d)", equeue_id); + sys_event.Log("sys_event_queue_drain(equeue_id=%d)", equeue_id); EventQueue* eq; if (!Emu.GetIdManager().GetIDData(equeue_id, eq)) @@ -401,14 +356,14 @@ int sys_event_port_disconnect(u32 eport_id) } eport->eq->ports.remove(eport); - eport->eq = 0; + eport->eq = nullptr; eport->mutex.unlock(tid); return CELL_OK; } int sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3) { - sys_event.Warning("sys_event_port_send(eport_id=%d, data1=0x%llx, data2=0x%llx, data3=0x%llx)", + sys_event.Log("sys_event_port_send(eport_id=%d, data1=0x%llx, data2=0x%llx, data3=0x%llx)", eport_id, data1, data2, data3); EventPort* eport; @@ -419,12 +374,13 @@ int sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3) SMutexLocker lock(eport->mutex); - if (!eport->eq) + EventQueue* eq = eport->eq; + if (!eq) { return CELL_ENOTCONN; } - if (!eport->eq->events.push(eport->name, data1, data2, data3)) + if (!eq->events.push(eport->name, data1, data2, data3)) { return CELL_EBUSY; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp index fde9c0f339..e688a46d74 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp @@ -4,6 +4,12 @@ extern Module sys_fs; +enum +{ + IDFlag_File = 1, + IDFlag_Dir = 2, +}; + int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) { const wxString& path = Memory.ReadString(path_addr); @@ -75,7 +81,7 @@ int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) return CELL_ENOENT; } - fd = sys_fs.GetNewId(stream, flags); + fd = sys_fs.GetNewId(stream, IDFlag_File); ConLog.Warning("*** cellFsOpen(path=\"%s\"): fd = %d", path.wx_str(), fd.GetValue()); return CELL_OK; @@ -148,7 +154,7 @@ int cellFsOpendir(u32 path_addr, mem32_t fd) return CELL_ENOENT; } - fd = sys_fs.GetNewId(dir); + fd = sys_fs.GetNewId(dir, IDFlag_Dir); return CELL_OK; } @@ -156,7 +162,7 @@ int cellFsReaddir(u32 fd, mem_ptr_t dir, mem64_t nread) { sys_fs.Log("cellFsReaddir(fd=%d, dir_addr=0x%x, nread_addr=0x%x)", fd, dir.GetAddr(), nread.GetAddr()); - vfsLocalDir* directory; + vfsDirBase* directory; if(!sys_fs.CheckId(fd, directory)) return CELL_ESRCH; if(!dir.IsGood() || !nread.IsGood()) @@ -205,56 +211,36 @@ int cellFsStat(const u32 path_addr, mem_ptr_t sb) sb->st_ctime_ = 0; //TODO sb->st_blksize = 4096; - // Check if path is a mount point. (TODO: Add information in sb_addr) - for(u32 i=0; ist_mode |= CELL_FS_S_IFDIR; return CELL_OK; } } - if (path == "/dev_bdvd/PS3_GAME/USRDIR") { - sys_fs.Warning("cellFsStat: /dev_bdvd/PS3_GAME/USRDIR mount point hack"); - sb->st_mode |= CELL_FS_S_IFDIR; - return CELL_OK; - } - - // TODO: Temporary solution until vfsDir is implemented - wxString real_path; - Emu.GetVFS().GetDevice(path, real_path); - struct stat s; - if(stat(real_path.c_str(), &s) == 0) - { - if(s.st_mode & S_IFDIR) + vfsFile f(path); + if(f.IsOpened()) { - sb->st_mode |= CELL_FS_S_IFDIR; - } - else if(s.st_mode & S_IFREG) - { - vfsFile f(path); sb->st_mode |= CELL_FS_S_IFREG; sb->st_size = f.GetSize(); + return CELL_OK; } } - else - { - sys_fs.Warning("cellFsStat: \"%s\" not found.", path.wx_str()); - return CELL_ENOENT; - } - return CELL_OK; + sys_fs.Warning("cellFsStat: \"%s\" not found.", path.wx_str()); + return CELL_ENOENT; } int cellFsFstat(u32 fd, mem_ptr_t sb) { sys_fs.Log("cellFsFstat(fd=%d, sb_addr: 0x%x)", fd, sb.GetAddr()); + u32 attr; vfsStream* file; - if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH; + if(!sys_fs.CheckId(fd, file, attr) || attr != IDFlag_File) return CELL_ESRCH; sb->st_mode = CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR | @@ -278,10 +264,12 @@ int cellFsMkdir(u32 path_addr, u32 mode) const wxString& ps3_path = Memory.ReadString(path_addr); sys_fs.Log("cellFsMkdir(path=\"%s\", mode=0x%x)", ps3_path.wx_str(), mode); - wxString localPath; - Emu.GetVFS().GetDevice(ps3_path, localPath); - if(wxDirExists(localPath)) return CELL_EEXIST; - if(!wxMkdir(localPath)) return CELL_EBUSY; + vfsDir dir; + if(dir.IsExists(ps3_path)) + return CELL_EEXIST; + if(!dir.Create(ps3_path)) + return CELL_EBUSY; + return CELL_OK; } @@ -289,16 +277,30 @@ int cellFsRename(u32 from_addr, u32 to_addr) { const wxString& ps3_from = Memory.ReadString(from_addr); const wxString& ps3_to = Memory.ReadString(to_addr); - wxString from; - wxString to; - Emu.GetVFS().GetDevice(ps3_from, from); - Emu.GetVFS().GetDevice(ps3_to, to); - sys_fs.Log("cellFsRename(from=\"%s\", to=\"%s\")", ps3_from.wx_str(), ps3_to.wx_str()); - if(!wxFileExists(from)) return CELL_ENOENT; - if(wxFileExists(to)) return CELL_EEXIST; - if(!wxRenameFile(from, to)) return CELL_EBUSY; // (TODO: RenameFile(a,b) = CopyFile(a,b) + RemoveFile(a), therefore file "a" will not be removed if it is opened) - return CELL_OK; + { + vfsDir dir; + if(dir.IsExists(ps3_from)) + { + if(!dir.Rename(ps3_from, ps3_to)) + return CELL_EBUSY; + + return CELL_OK; + } + } + + { + vfsFile f; + if(f.Exists(ps3_from)) + { + if(!f.Rename(ps3_from, ps3_to)) + return CELL_EBUSY; + + return CELL_OK; + } + } + + return CELL_ENOENT; } int cellFsRmdir(u32 path_addr) @@ -306,10 +308,13 @@ int cellFsRmdir(u32 path_addr) const wxString& ps3_path = Memory.ReadString(path_addr); sys_fs.Log("cellFsRmdir(path=\"%s\")", ps3_path.wx_str()); - wxString localPath; - Emu.GetVFS().GetDevice(ps3_path, localPath); - if(!wxDirExists(localPath)) return CELL_ENOENT; - if(!wxRmdir(localPath)) return CELL_EBUSY; // (TODO: Under certain conditions it is not able to delete the folder) + vfsDir d; + if(!d.IsExists(ps3_path)) + return CELL_ENOENT; + + if(!d.Remove(ps3_path)) + return CELL_EBUSY; + return CELL_OK; } @@ -318,9 +323,9 @@ int cellFsUnlink(u32 path_addr) const wxString& ps3_path = Memory.ReadString(path_addr); sys_fs.Warning("cellFsUnlink(path=\"%s\")", ps3_path.wx_str()); - wxString localPath; - Emu.GetVFS().GetDevice(ps3_path, localPath); - wxRemoveFile(localPath); + //wxString localPath; + //Emu.GetVFS().GetDevice(ps3_path, localPath); + //wxRemoveFile(localPath); return CELL_OK; } @@ -338,8 +343,9 @@ int cellFsLseek(u32 fd, s64 offset, u32 whence, mem64_t pos) return CELL_EINVAL; } + u32 attr; vfsStream* file; - if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH; + if(!sys_fs.CheckId(fd, file, attr) || attr != IDFlag_File) return CELL_ESRCH; pos = file->Seek(offset, seek_mode); return CELL_OK; } @@ -347,8 +353,9 @@ int cellFsLseek(u32 fd, s64 offset, u32 whence, mem64_t pos) int cellFsFtruncate(u32 fd, u64 size) { sys_fs.Log("cellFsFtruncate(fd=%d, size=%lld)", fd, size); + u32 attr; vfsStream* file; - if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH; + if(!sys_fs.CheckId(fd, file, attr) || attr != IDFlag_File) return CELL_ESRCH; u64 initialSize = file->GetSize(); if (initialSize < size) @@ -403,7 +410,10 @@ int cellFsTruncate(u32 path_addr, u64 size) int cellFsFGetBlockSize(u32 fd, mem64_t sector_size, mem64_t block_size) { sys_fs.Log("cellFsFGetBlockSize(fd=%d, sector_size_addr: 0x%x, block_size_addr: 0x%x)", fd, sector_size.GetAddr(), block_size.GetAddr()); - + + vfsStream* file; + if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH; + sector_size = 4096; // ? block_size = 4096; // ? diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp index 6a7524a88b..a07403532a 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp @@ -84,7 +84,7 @@ int sys_lwcond_signal(mem_ptr_t lwcond) mem_ptr_t mutex(lwcond->lwmutex); be_t tid = GetCurrentPPUThread().GetId(); - if (be_t target = mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()) + if (be_t target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop())) { if (mutex->vars.parts.owner.trylock(target) != SMR_OK) { @@ -120,7 +120,7 @@ int sys_lwcond_signal_all(mem_ptr_t lwcond) mem_ptr_t mutex(lwcond->lwmutex); be_t tid = GetCurrentPPUThread().GetId(); - while (be_t target = mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()) + while (be_t target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop())) { if (mutex->vars.parts.owner.trylock(target) != SMR_OK) { diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp index 9a2a900905..e08f0a34fb 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp @@ -29,6 +29,9 @@ int sys_lwmutex_create(mem_ptr_t lwmutex, mem_ptr_tattribute = attr->attr_protocol | attr->attr_recursive; lwmutex->vars.all_info = 0; + lwmutex->vars.all_info = 0; + lwmutex->vars.parts.owner.initialize(); + //lwmutex->waiter = lwmutex->owner.GetOwner(); lwmutex->pad = 0; lwmutex->recursive_count = 0; @@ -51,9 +54,10 @@ int sys_lwmutex_destroy(mem_ptr_t lwmutex) if (!Emu.GetIdManager().CheckID(sq_id)) return CELL_ESRCH; // try to make it unable to lock - switch (int res = lwmutex->trylock(~0)) + switch (int res = lwmutex->trylock(lwmutex->owner.GetDeadValue())) { case CELL_OK: + lwmutex->all_info = 0; lwmutex->attribute = 0; lwmutex->sleep_queue = 0; Emu.GetIdManager().RemoveID(sq_id); @@ -128,7 +132,7 @@ u32 SleepQueue::pop_prio() // SYS_SYNC_PRIORITY { if (list.GetCount()) { - u64 max_prio = 0; + u32 highest_prio = ~0; u32 sel = 0; for (u32 i = 0; i < list.GetCount(); i++) { @@ -140,9 +144,9 @@ u32 SleepQueue::pop_prio() // SYS_SYNC_PRIORITY break; } u64 prio = t->GetPrio(); - if (prio > max_prio) + if (prio < highest_prio) { - max_prio = prio; + highest_prio = prio; sel = i; } } @@ -245,8 +249,10 @@ int sys_lwmutex_t::unlock(be_t tid) SleepQueue* sq; if (!Emu.GetIdManager().GetIDData(sleep_queue, sq)) return CELL_ESRCH; target = attribute.ToBE() & se32(SYS_SYNC_FIFO) ? sq->pop() : sq->pop_prio(); - case se32(SYS_SYNC_RETRY): default: vars.parts.owner.unlock(tid, target); break; + case se32(SYS_SYNC_RETRY): break; } + if (target) vars.parts.owner.unlock(tid, target); + else owner.unlock(tid); } return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h index 2d569a7494..f60a520ed8 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h @@ -69,7 +69,7 @@ struct sys_lwmutex_t { struct sys_lwmutex_lock_info_t { - /* volatile */ SMutexBE owner; + /* volatile */ SMutexBase, 0xffffffff, 0> owner; /* volatile */ be_t waiter; // not used }parts; /* volatile */ be_t all_info; diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Mutex.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Mutex.cpp index 165bcf3896..4ae474631b 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Mutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Mutex.cpp @@ -91,8 +91,9 @@ int sys_mutex_lock(u32 mutex_id, u64 timeout) } u32 tid = GetCurrentPPUThread().GetId(); + u32 owner = mutex->m_mutex.GetOwner(); - if (mutex->m_mutex.GetOwner() == tid) + if (owner == tid) { if (mutex->is_recursive) { @@ -107,6 +108,13 @@ int sys_mutex_lock(u32 mutex_id, u64 timeout) return CELL_EDEADLK; } } + else if (owner && !Emu.GetIdManager().CheckID(owner)) + { + sys_mtx.Error("sys_mutex_lock(%d): deadlock on invalid thread(%d)", mutex_id, owner); + mutex->m_mutex.unlock(owner, tid); + mutex->recursive = 1; + return CELL_OK; + } switch (mutex->m_mutex.trylock(tid)) { @@ -119,16 +127,20 @@ int sys_mutex_lock(u32 mutex_id, u64 timeout) switch (mutex->m_mutex.lock(tid, timeout ? ((timeout < 1000) ? 1 : (timeout / 1000)) : 0)) { - case SMR_OK: mutex->m_queue.invalidate(tid); - case SMR_SIGNAL: mutex->recursive = 1; return CELL_OK; - case SMR_TIMEOUT: return CELL_ETIMEDOUT; - default: goto abort; + case SMR_OK: + mutex->m_queue.invalidate(tid); + case SMR_SIGNAL: + mutex->recursive = 1; return CELL_OK; + case SMR_TIMEOUT: + mutex->m_queue.invalidate(tid); return CELL_ETIMEDOUT; + default: + mutex->m_queue.invalidate(tid); goto abort; } abort: if (Emu.IsStopped()) { - ConLog.Warning("sys_mutex_lock(id=%d) aborted", mutex_id); + sys_mtx.Warning("sys_mutex_lock(id=%d) aborted", mutex_id); return CELL_OK; } return CELL_ESRCH; @@ -145,8 +157,9 @@ int sys_mutex_trylock(u32 mutex_id) } u32 tid = GetCurrentPPUThread().GetId(); + u32 owner = mutex->m_mutex.GetOwner(); - if (mutex->m_mutex.GetOwner() == tid) + if (owner == tid) { if (mutex->is_recursive) { @@ -161,6 +174,13 @@ int sys_mutex_trylock(u32 mutex_id) return CELL_EDEADLK; } } + else if (owner && !Emu.GetIdManager().CheckID(owner)) + { + sys_mtx.Error("sys_mutex_trylock(%d): deadlock on invalid thread(%d)", mutex_id, owner); + mutex->m_mutex.unlock(owner, tid); + mutex->recursive = 1; + return CELL_OK; + } switch (mutex->m_mutex.trylock(tid)) { @@ -184,6 +204,10 @@ int sys_mutex_unlock(u32 mutex_id) if (mutex->m_mutex.GetOwner() == tid) { + if (!mutex->recursive || (mutex->recursive > 1 && !mutex->is_recursive)) + { + sys_mtx.Warning("sys_mutex_unlock(%d): wrong recursive value (%d)", mutex_id, mutex->recursive); + } mutex->recursive--; if (!mutex->recursive) { diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Rwlock.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Rwlock.cpp index d8d9daa6fc..29a178f537 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Rwlock.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Rwlock.cpp @@ -12,10 +12,10 @@ int sys_rwlock_create(mem32_t rw_lock_id, mem_ptr_t attr switch (attr->attr_protocol.ToBE()) { - case se32(SYS_SYNC_PRIORITY): sys_rwlock.Warning("TODO: SYS_SYNC_PRIORITY attr"); break; - case se32(SYS_SYNC_RETRY): sys_rwlock.Error("Invalid SYS_SYNC_RETRY attr"); break; - case se32(SYS_SYNC_PRIORITY_INHERIT): sys_rwlock.Warning("TODO: SYS_SYNC_PRIORITY_INHERIT attr"); break; - case se32(SYS_SYNC_FIFO): break; + case se(attr->attr_protocol, SYS_SYNC_PRIORITY): sys_rwlock.Warning("TODO: SYS_SYNC_PRIORITY attr"); break; + case se(attr->attr_protocol, SYS_SYNC_RETRY): sys_rwlock.Error("Invalid SYS_SYNC_RETRY attr"); break; + case se(attr->attr_protocol, SYS_SYNC_PRIORITY_INHERIT): sys_rwlock.Warning("TODO: SYS_SYNC_PRIORITY_INHERIT attr"); break; + case se(attr->attr_protocol, SYS_SYNC_FIFO): break; default: return CELL_EINVAL; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp b/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp index a3adbb1270..4b3c858264 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp @@ -222,6 +222,8 @@ int sys_spu_thread_group_destroy(u32 id) for (u32 i = 0; i < group_info->list.GetCount(); i++) { + // TODO: disconnect all event ports + Emu.GetCPU().RemoveThread(group_info->list[i]); } @@ -255,7 +257,7 @@ int sys_spu_thread_group_start(u32 id) //174 int sys_spu_thread_group_suspend(u32 id) { - sc_spu.Warning("sys_spu_thread_group_suspend(id=%d)", id); + sc_spu.Log("sys_spu_thread_group_suspend(id=%d)", id); SpuGroupInfo* group_info; if(!Emu.GetIdManager().GetIDData(id, group_info)) @@ -550,6 +552,152 @@ int sys_spu_thread_group_disconnect_event(u32 id, u32 et) return CELL_OK; } +/* +SPU-Side functions: +int sys_spu_thread_receive_event(u32 spuq_num, mem32_t d1, mem32_t d2, mem32_t d3); +int sys_spu_thread_send_event(u8 spup, u24 data0, u32 data1); +int sys_spu_thread_throw_event(u8 spup, u24 data0, u32 data1); +int sys_spu_thread_tryreceive_event(u32 spuq_num, mem32_t d1, mem32_t d2, mem32_t d3); +*/ + +int sys_spu_thread_connect_event(u32 id, u32 eq_id, u32 et, u8 spup) +{ + sc_spu.Warning("sys_spu_thread_connect_event(id=%d, eq_id=%d, event_type=0x%x, spup=%d)", id, eq_id, et, spup); + + CPUThread* thr = Emu.GetCPU().GetThread(id); + + if(!thr || (thr->GetType() != CPU_THREAD_SPU && thr->GetType() != CPU_THREAD_RAW_SPU)) + { + return CELL_ESRCH; + } + + EventQueue* eq; + if (!Emu.GetIdManager().GetIDData(eq_id, eq)) + { + return CELL_ESRCH; + } + + if (spup > 63) + { + sc_spu.Error("sys_spu_thread_connect_event: invalid spup (%d)", spup); + return CELL_EINVAL; + } + + if (et != SYS_SPU_THREAD_EVENT_USER) + { + sc_spu.Error("sys_spu_thread_connect_event: unsupported event type (0x%x)", et); + return CELL_EINVAL; + } + + // TODO: check if can receive this events + + SPUThread& spu = *(SPUThread*)thr; + + EventPort& port = spu.SPUPs[spup]; + + SMutexLocker lock(port.mutex); + + if (port.eq) + { + return CELL_EISCONN; + } + + eq->ports.add(&port); + port.eq = eq; + + return CELL_OK; +} + +// +int sys_spu_thread_disconnect_event(u32 id, u32 et, u8 spup) +{ + sc_spu.Warning("sys_spu_thread_disconnect_event(id=%d, event_type=0x%x, spup=%d)", id, et, spup); + + CPUThread* thr = Emu.GetCPU().GetThread(id); + + if(!thr || (thr->GetType() != CPU_THREAD_SPU && thr->GetType() != CPU_THREAD_RAW_SPU)) + { + return CELL_ESRCH; + } + + if (spup > 63) + { + sc_spu.Error("sys_spu_thread_connect_event: invalid spup (%d)", spup); + return CELL_EINVAL; + } + + if (et != SYS_SPU_THREAD_EVENT_USER) + { + sc_spu.Error("sys_spu_thread_connect_event: unsupported event type (0x%x)", et); + return CELL_EINVAL; + } + + SPUThread& spu = *(SPUThread*)thr; + + EventPort& port = spu.SPUPs[spup]; + + SMutexLocker lock(port.mutex); + + if (!port.eq) + { + return CELL_ENOTCONN; + } + + port.eq->ports.remove(&port); + port.eq = nullptr; + + return CELL_OK; +} + +int sys_spu_thread_bind_queue(u32 id, u32 eq_id, u32 spuq_num) +{ + sc_spu.Warning("sys_spu_thread_bind_queue(id=%d, equeue_id=%d, spuq_num=0x%x)", id, eq_id, spuq_num); + + EventQueue* eq; + if (!Emu.GetIdManager().GetIDData(eq_id, eq)) + { + return CELL_ESRCH; + } + + if (eq->type != SYS_SPU_QUEUE) + { + return CELL_EINVAL; + } + + CPUThread* thr = Emu.GetCPU().GetThread(id); + + if(!thr || (thr->GetType() != CPU_THREAD_SPU && thr->GetType() != CPU_THREAD_RAW_SPU)) + { + return CELL_ESRCH; + } + + if (!(*(SPUThread*)thr).SPUQs.RegisterKey(eq, FIX_SPUQ(spuq_num))) + { + return CELL_EBUSY; + } + + return CELL_OK; +} + +int sys_spu_thread_unbind_queue(u32 id, u32 spuq_num) +{ + sc_spu.Warning("sys_spu_thread_unbind_queue(id=0x%x, spuq_num=0x%x)", id, spuq_num); + + CPUThread* thr = Emu.GetCPU().GetThread(id); + + if(!thr || (thr->GetType() != CPU_THREAD_SPU && thr->GetType() != CPU_THREAD_RAW_SPU)) + { + return CELL_ESRCH; + } + + if (!(*(SPUThread*)thr).SPUQs.UnregisterKey(FIX_SPUQ(spuq_num))) + { + return CELL_ESRCH; // may be CELL_EINVAL + } + + return CELL_OK; +} + int sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq, u64 req, u32 spup_addr) { sc_spu.Error("sys_spu_thread_group_connect_event_all_threads(id=%d, eq=%d, req=0x%llx, spup_addr=0x%x)", @@ -602,82 +750,4 @@ int sys_spu_thread_group_disconnect_event_all_threads(u32 id, u8 spup) sc_spu.Error("sys_spu_thread_group_disconnect_event_all_threads(id=%d, spup=%d)", id, spup); return CELL_OK; -} - -int sys_spu_thread_connect_event(u32 id, u32 eq, u32 et, u8 spup) -{ - sc_spu.Error("sys_spu_thread_connect_event(id=%d, eq=%d, et=0x%x, spup=%d)", id, eq, et, spup); - - EventQueue* equeue; - if(!sys_event.CheckId(eq, equeue)) - { - return CELL_ESRCH; - } - - if(spup > 63) - { - return CELL_EINVAL; - } - - CPUThread* thr = Emu.GetCPU().GetThread(id); - - if(!thr || (thr->GetType() != CPU_THREAD_SPU && thr->GetType() != CPU_THREAD_RAW_SPU)) - { - return CELL_ESRCH; - } - /* - for(int j=0; jpos; ++j) - { - if(!equeue->ports[j]->thread) - { - equeue->ports[j]->thread = thr; - return CELL_OK; - } - } - */ - - return CELL_EISCONN; -} - -// -int sys_spu_thread_disconnect_event(u32 id, u32 event_type, u8 spup) -{ - sc_spu.Error("sys_spu_thread_disconnect_event(id=%d, event_type=0x%x, spup=%d", id, event_type, spup); - - return CELL_OK; -} - -/* -SPU-Side functions: -int sys_spu_thread_receive_event(u32 spuq_num, mem32_t d1, mem32_t d2, mem32_t d3); -int sys_spu_thread_send_event(u8 spup, u24 data0, u32 data1); -int sys_spu_thread_throw_event(u8 spup, u24 data0, u32 data1); -int sys_spu_thread_tryreceive_event(u32 spuq_num, mem32_t d1, mem32_t d2, mem32_t d3); -*/ - -int sys_spu_thread_bind_queue(u32 id, u32 eq, u32 spuq_num) -{ - sc_spu.Error("sys_spu_thread_bind_queue(id=%d, equeue_id=%d, spuq_num=%d)", id, eq, spuq_num); - - EventQueue* equeue; - if(!sys_event.CheckId(eq, equeue)) - { - return CELL_ESRCH; - } - - CPUThread* thr = Emu.GetCPU().GetThread(id); - - if(!thr || (thr->GetType() != CPU_THREAD_SPU && thr->GetType() != CPU_THREAD_RAW_SPU)) - { - return CELL_ESRCH; - } - - return CELL_OK; -} - -int sys_spu_thread_unbind_queue(u32 id, u32 spuq_num) -{ - sc_spu.Error("sys_spu_thread_unbind_queue(id=0x%x, spuq_num=%d)", id, spuq_num); - - return CELL_OK; -} +} \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Time.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Time.cpp index 045a17172f..764b47f71e 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Time.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Time.cpp @@ -24,14 +24,14 @@ int sys_time_get_timezone(mem32_t timezone, mem32_t summertime) return CELL_OK; } -u64 get_system_time() +u64 get_time() { #ifdef _WIN32 LARGE_INTEGER cycle; LARGE_INTEGER freq; QueryPerformanceCounter(&cycle); QueryPerformanceFrequency(&freq); - return cycle.QuadPart * 1000000 / freq.QuadPart; + return cycle.QuadPart * 10000000 / freq.QuadPart; #else struct timespec ts; if (!clock_gettime(CLOCK_MONOTONIC, &ts)) @@ -39,14 +39,20 @@ u64 get_system_time() #endif } +u64 get_system_time() +{ + // returns some relative time in microseconds, don't change this fact + return get_time() / 10; +} + int sys_time_get_current_time(u32 sec_addr, u32 nsec_addr) { sys_time.Log("sys_time_get_current_time(sec_addr=0x%x, nsec_addr=0x%x)", sec_addr, nsec_addr); - u64 time = get_system_time(); + u64 time = get_time(); - Memory.Write64(sec_addr, time / 1000000); - Memory.Write64(nsec_addr, time % 1000000); + Memory.Write64(sec_addr, time / 10000000); + Memory.Write64(nsec_addr, (time % 10000000) * 100); return CELL_OK; } @@ -60,17 +66,5 @@ s64 sys_time_get_system_time() u64 sys_time_get_timebase_frequency() { sys_time.Log("sys_time_get_timebase_frequency()"); - return 1000000; - - /* -#ifdef _WIN32 - static LARGE_INTEGER frequency = {0ULL}; - - if(!frequency.QuadPart) QueryPerformanceFrequency(&frequency); - - return frequency.QuadPart; -#else return 10000000; -#endif - */ } diff --git a/rpcs3/Emu/event.h b/rpcs3/Emu/event.h index bcbccc6c85..76d3802672 100644 --- a/rpcs3/Emu/event.h +++ b/rpcs3/Emu/event.h @@ -1,6 +1,9 @@ #pragma once #include "Emu/SysCalls/lv2/SC_Lwmutex.h" +#define FIX_SPUQ(x) ((u64)x | 0x5350555100000000ULL) +// arbitrary code to prevent "special" zero value in key argument + enum EventQueueType { SYS_PPU_QUEUE = 1, @@ -158,6 +161,7 @@ public: SMutexLocker lock(m_lock); for (u32 i = 0; i < data.GetCount(); i++) { + SMutexLocker lock2(data[i]->mutex); data[i]->eq = nullptr; // force all ports to disconnect } data.Clear(); @@ -183,8 +187,9 @@ public: } }; -struct EventQueue : SleepQueue +struct EventQueue { + SleepQueue sq; EventPortList ports; EventRingBuffer events; SMutex owner; @@ -220,4 +225,5 @@ public: bool RegisterKey(EventQueue* data, u64 key); bool GetEventQueue(u64 key, EventQueue*& data); bool UnregisterKey(u64 key); + bool SendEvent(u64 key, u64 source, u64 d1, u64 d2, u64 d3); }; \ No newline at end of file diff --git a/rpcs3/Gui/GameViewer.cpp b/rpcs3/Gui/GameViewer.cpp index c665a39983..dbcf783118 100644 --- a/rpcs3/Gui/GameViewer.cpp +++ b/rpcs3/Gui/GameViewer.cpp @@ -8,7 +8,7 @@ GameViewer::GameViewer(wxWindow* parent) : wxListView(parent) LoadSettings(); m_columns.Show(this); - m_path = wxGetCwd() + "\\dev_hdd0\\game\\"; //TODO + m_path = "/dev_hdd0/game/"; Connect(GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(GameViewer::DClick)); @@ -27,17 +27,18 @@ void GameViewer::DoResize(wxSize size) void GameViewer::LoadGames() { - if(!wxDirExists(m_path)) return; + vfsDir dir(m_path); + ConLog.Write("path: %s", m_path.wx_str()); + if(!dir.IsOpened()) return; m_games.Clear(); - wxDir dir(m_path); - if(!dir.HasSubDirs()) return; - wxString buf; - for(bool ok = dir.GetFirst(&buf); ok; ok = dir.GetNext(&buf)) + for(const DirEntryInfo* info = dir.Read(); info; info = dir.Read()) { - if(wxDirExists(m_path + buf)) - m_games.Add(buf); + if(info->flags & DirEntry_TypeDir) + { + m_games.Add(info->name); + } } //ConLog.Write("path: %s", m_path.wx_str()); @@ -49,8 +50,8 @@ void GameViewer::LoadPSF() m_game_data.Clear(); for(uint i=0; iAppend("DisAsm"); @@ -398,8 +399,12 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) chbox_gs_dump_depth->SetValue(Ini.GSDumpDepthBuffer.GetValue()); chbox_gs_dump_color->SetValue(Ini.GSDumpColorBuffers.GetValue()); chbox_gs_vsync->SetValue(Ini.GSVSyncEnable.GetValue()); + chbox_audio_dump->SetValue(Ini.AudioDumpToFile.GetValue()); chbox_hle_logging->SetValue(Ini.HLELogging.GetValue()); + chbox_audio_dump->Enable(Emu.IsStopped()); + chbox_hle_logging->Enable(Emu.IsStopped()); + cbox_cpu_decoder->SetSelection(Ini.CPUDecoderMode.GetValue() ? Ini.CPUDecoderMode.GetValue() - 1 : 0); cbox_gs_render->SetSelection(Ini.GSRenderMode.GetValue()); cbox_gs_resolution->SetSelection(ResolutionIdToNum(Ini.GSResolution.GetValue()) - 1); @@ -432,6 +437,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) s_round_io->Add(s_round_io_mouse_handler, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_audio_out->Add(cbox_audio_out, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_audio_out->Add(chbox_audio_dump, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_audio->Add(s_round_audio_out, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_hle->Add(chbox_hle_logging, wxSizerFlags().Border(wxALL, 5).Expand()); @@ -470,6 +476,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) Ini.KeyboardHandlerMode.SetValue(cbox_keyboard_handler->GetSelection()); Ini.MouseHandlerMode.SetValue(cbox_mouse_handler->GetSelection()); Ini.AudioOutMode.SetValue(cbox_audio_out->GetSelection()); + Ini.AudioDumpToFile.SetValue(chbox_audio_dump->GetValue()); Ini.HLELogging.SetValue(chbox_hle_logging->GetValue()); Ini.Save(); @@ -632,7 +639,6 @@ void MainFrame::ConfigPad(wxCommandEvent& WXUNUSED(event)) s_subpanel4->Add(s_round_pad_shifts_r, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel5->Add(s_round_pad_buttons, wxSizerFlags().Border(wxALL, 5).Expand()); - s_panel->Add(s_subpanel1, wxSizerFlags().Border(wxALL, 5).Expand()); s_panel->Add(s_subpanel2, wxSizerFlags().Border(wxALL, 5).Expand()); s_panel->Add(s_subpanel3, wxSizerFlags().Border(wxALL, 5).Expand()); diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index 4542a6a525..dcfdee1176 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -105,6 +105,7 @@ public: IniEntry KeyboardHandlerMode; IniEntry MouseHandlerMode; IniEntry AudioOutMode; + IniEntry AudioDumpToFile; IniEntry HLELogging; IniEntry PadHandlerLeft; @@ -167,6 +168,7 @@ public: path = DefPath + "\\" + "Audio"; AudioOutMode.Init("AudioOutMode", path); + AudioDumpToFile.Init("AudioDumpToFile", path); path = DefPath + "\\" + "HLE"; HLELogging.Init("HLELogging", path); @@ -187,6 +189,7 @@ public: KeyboardHandlerMode.Load(0); MouseHandlerMode.Load(0); AudioOutMode.Load(0); + AudioDumpToFile.Load(0); HLELogging.Load(false); PadHandlerLeft.Load(static_cast('A')); @@ -222,6 +225,7 @@ public: KeyboardHandlerMode.Save(); MouseHandlerMode.Save(); AudioOutMode.Save(); + AudioDumpToFile.Save(); HLELogging.Save(); PadHandlerLeft.Save(); diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index e60df54659..7946c3f2db 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -279,6 +279,7 @@ + @@ -295,6 +296,8 @@ + + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 691c4365c9..93b68d3de7 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -406,6 +406,15 @@ Emu\FS + + Emu\SysCalls\Modules + + + Emu\SysCalls\Modules + + + Emu\SysCalls\Modules + Loader