implemented sceVideoOutOpen

This commit is contained in:
georgemoralis 2023-08-22 23:59:59 +03:00
parent a8b020b153
commit 491e231770
8 changed files with 82 additions and 37 deletions

View File

@ -6,3 +6,7 @@ constexpr int SCE_KERNEL_ERROR_EFAULT = 0x8002000e; // Invalid address po
constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016; // null or invalid states constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016; // null or invalid states
constexpr int SCE_KERNEL_ERROR_EAGAIN = 0x80020023; // Memory cannot be allocated constexpr int SCE_KERNEL_ERROR_EAGAIN = 0x80020023; // Memory cannot be allocated
constexpr int SCE_KERNEL_ERROR_ENAMETOOLONG = 0x8002003f; // character strings exceeds valid size constexpr int SCE_KERNEL_ERROR_ENAMETOOLONG = 0x8002003f; // character strings exceeds valid size
// videoOut
constexpr int SCE_VIDEO_OUT_ERROR_INVALID_VALUE = 0x80290001; // invalid argument
constexpr int SCE_VIDEO_OUT_ERROR_RESOURCE_BUSY = 0x80290009; // already opened

View File

@ -3,12 +3,27 @@
namespace HLE::Graphics::Objects { namespace HLE::Graphics::Objects {
void VideoOutCtx::Init(u32 width, u32 height) { void VideoOutCtx::Init(u32 width, u32 height) {
for (auto& video_ctx : m_video_out_ctx) { m_video_out_ctx.m_resolution.fullWidth = width;
video_ctx.m_resolution.fullWidth = width; m_video_out_ctx.m_resolution.fullHeight = height;
video_ctx.m_resolution.fullHeight = height; m_video_out_ctx.m_resolution.paneWidth = width;
video_ctx.m_resolution.paneWidth = width; m_video_out_ctx.m_resolution.paneHeight = height;
video_ctx.m_resolution.paneHeight = height;
} }
int VideoOutCtx::Open() {
Lib::LockMutexGuard lock(m_mutex);
int handle = -1;
if (!m_video_out_ctx.isOpened) {
handle = 1;//positive return , should be more than 1 ?
}
m_video_out_ctx.isOpened = true;
m_video_out_ctx.m_flip_status = SceVideoOutFlipStatus();
m_video_out_ctx.m_flip_status.flipArg = -1;
m_video_out_ctx.m_flip_status.currentBuffer = -1;
m_video_out_ctx.m_flip_status.count = 0;
m_video_out_ctx.m_vblank_status = SceVideoOutVblankStatus();
return handle;
} }
void VideoOutCtx::Open() {}
}; // namespace HLE::Graphics::Objects }; // namespace HLE::Graphics::Objects

View File

@ -10,18 +10,19 @@ struct VideoConfigInternal {
Lib::Mutex m_mutex; Lib::Mutex m_mutex;
SceVideoOutResolutionStatus m_resolution; SceVideoOutResolutionStatus m_resolution;
bool isOpened = false; bool isOpened = false;
SceVideoOutFlipStatus m_flip_status;
SceVideoOutVblankStatus m_vblank_status;
}; };
class VideoOutCtx { class VideoOutCtx {
static constexpr int MAX_VIDEO_OUT = 2;
public: public:
VideoOutCtx() {} VideoOutCtx() {}
virtual ~VideoOutCtx() {} virtual ~VideoOutCtx() {}
void Init(u32 width, u32 height); void Init(u32 width, u32 height);
void Open(); int Open();
private: private:
Lib::Mutex m_mutex; Lib::Mutex m_mutex;
VideoConfigInternal m_video_out_ctx[MAX_VIDEO_OUT]; VideoConfigInternal m_video_out_ctx;
}; };
}; // namespace HLE::Graphics::Objects }; // namespace HLE::Graphics::Objects

View File

@ -7,10 +7,21 @@
#include <magic_enum.hpp> #include <magic_enum.hpp>
#include <string> #include <string>
#include "Objects/video_out_ctx.h"
#include "Util/Singleton.h"
#include <Core/PS4/HLE/UserManagement/UsrMngCodes.h>
#include <debug.h>
#include <Core/PS4/HLE/VideoOut/VideoOutCodes.h>
#include <Core/PS4/HLE/ErrorCodes.h>
namespace HLE::Libs::Graphics::VideoOut { namespace HLE::Libs::Graphics::VideoOut {
constexpr bool log_file_videoout = true; // disable it to disable logging constexpr bool log_file_videoout = true; // disable it to disable logging
void videoOutInit(u32 width, u32 height) {
auto* videoOut = Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
videoOut->Init(width, height);
}
std::string getPixelFormatString(s32 format) { std::string getPixelFormatString(s32 format) {
switch (format) { switch (format) {
case SCE_VIDEO_OUT_PIXEL_FORMAT_A8R8G8B8_SRGB: return "PIXEL_FORMAT_A8R8G8B8_SRGB"; case SCE_VIDEO_OUT_PIXEL_FORMAT_A8R8G8B8_SRGB: return "PIXEL_FORMAT_A8R8G8B8_SRGB";
@ -71,8 +82,7 @@ s32 PS4_SYSV_ABI sceVideoOutIsFlipPending(s32 handle) {
PRINT_DUMMY_FUNCTION_NAME(); PRINT_DUMMY_FUNCTION_NAME();
return 0; return 0;
} }
s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode, s64 flipArg) s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode, s64 flipArg) {
{
// BREAKPOINT(); // BREAKPOINT();
PRINT_DUMMY_FUNCTION_NAME(); PRINT_DUMMY_FUNCTION_NAME();
return 0; return 0;
@ -87,4 +97,29 @@ s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutio
PRINT_DUMMY_FUNCTION_NAME(); PRINT_DUMMY_FUNCTION_NAME();
return 0; return 0;
} }
s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 index, const void* param) {
PRINT_DUMMY_FUNCTION_NAME();
if (userId != SCE_USER_SERVICE_USER_ID_SYSTEM) {
BREAKPOINT();
}
if (busType != SCE_VIDEO_OUT_BUS_TYPE_MAIN) {
BREAKPOINT();
}
if (index != 0) {
LOG_TRACE_IF(log_file_videoout, "sceVideoOutOpen index!=0\n");
return SCE_VIDEO_OUT_ERROR_INVALID_VALUE;
}
if (param != nullptr) {
BREAKPOINT();
}
auto* videoOut = Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
int handle = videoOut->Open();
if (handle < 0) {
LOG_TRACE_IF(log_file_videoout, "sceVideoOutOpen all available handles are open\n");
return SCE_VIDEO_OUT_ERROR_RESOURCE_BUSY; //it is alreadyOpened
}
return handle;
}
} // namespace HLE::Libs::Graphics::VideoOut } // namespace HLE::Libs::Graphics::VideoOut

View File

@ -6,6 +6,8 @@
namespace HLE::Libs::Graphics::VideoOut { namespace HLE::Libs::Graphics::VideoOut {
using SceUserServiceUserId = s32; //TODO move it to proper place
// SceVideoOutRefreshRate // SceVideoOutRefreshRate
constexpr int SCE_VIDEO_OUT_REFRESH_RATE_UNKNOWN = 0; constexpr int SCE_VIDEO_OUT_REFRESH_RATE_UNKNOWN = 0;
constexpr int SCE_VIDEO_OUT_REFRESH_RATE_23_98HZ = 1; constexpr int SCE_VIDEO_OUT_REFRESH_RATE_23_98HZ = 1;
@ -77,6 +79,7 @@ struct SceVideoOutVblankStatus {
u08 pad1[7] = {}; u08 pad1[7] = {};
}; };
void videoOutInit(u32 width, u32 height);
std::string getPixelFormatString(s32 format); std::string getPixelFormatString(s32 format);
void PS4_SYSV_ABI sceVideoOutSetBufferAttribute(SceVideoOutBufferAttribute* attribute, u32 pixelFormat, u32 tilingMode, u32 aspectRatio, u32 width, void PS4_SYSV_ABI sceVideoOutSetBufferAttribute(SceVideoOutBufferAttribute* attribute, u32 pixelFormat, u32 tilingMode, u32 aspectRatio, u32 width,
@ -89,4 +92,6 @@ s32 PS4_SYSV_ABI sceVideoOutIsFlipPending(s32 handle);
s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode, s64 flipArg); s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode, s64 flipArg);
s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, SceVideoOutFlipStatus* status); s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, SceVideoOutFlipStatus* status);
s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutionStatus* status); s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutionStatus* status);
s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 index, const void* param);
} // namespace HLE::Libs::Graphics::VideoOut } // namespace HLE::Libs::Graphics::VideoOut

View File

@ -4,30 +4,13 @@
#include "../../../Util/Log.h" #include "../../../Util/Log.h"
#include "../Loader/Elf.h" #include "../Loader/Elf.h"
#include "Graphics/video_out.h"
#include "Libs.h" #include "Libs.h"
#include "UserManagement/UsrMngCodes.h" #include "UserManagement/UsrMngCodes.h"
#include "VideoOut/VideoOutCodes.h" #include "VideoOut/VideoOutCodes.h"
#include "Graphics/video_out.h"
namespace HLE::Libs::LibSceVideoOut { namespace HLE::Libs::LibSceVideoOut {
s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 index, const void* param) {
PRINT_DUMMY_FUNCTION_NAME();
if (userId != SCE_USER_SERVICE_USER_ID_SYSTEM) {
BREAKPOINT();
}
if (busType != SCE_VIDEO_OUT_BUS_TYPE_MAIN) {
BREAKPOINT();
}
if (index != 0) {
BREAKPOINT();
}
if (param != nullptr) {
BREAKPOINT();
}
return 1; // dummy return TODO
}
void LibSceVideoOut_Register(SymbolsResolver* sym) { void LibSceVideoOut_Register(SymbolsResolver* sym) {
LIB_FUNCTION("SbU3dwp80lQ", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutGetFlipStatus); LIB_FUNCTION("SbU3dwp80lQ", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutGetFlipStatus);
LIB_FUNCTION("U46NwOiJpys", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutSubmitFlip); LIB_FUNCTION("U46NwOiJpys", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutSubmitFlip);
@ -36,7 +19,7 @@ void LibSceVideoOut_Register(SymbolsResolver* sym) {
LIB_FUNCTION("CBiu4mCE1DA", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutSetFlipRate); LIB_FUNCTION("CBiu4mCE1DA", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutSetFlipRate);
LIB_FUNCTION("i6-sR91Wt-4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutSetBufferAttribute); LIB_FUNCTION("i6-sR91Wt-4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutSetBufferAttribute);
LIB_FUNCTION("6kPnj51T62Y", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutGetResolutionStatus); LIB_FUNCTION("6kPnj51T62Y", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutGetResolutionStatus);
LIB_FUNCTION("Up36PTk687E", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutOpen); LIB_FUNCTION("Up36PTk687E", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutOpen);
LIB_FUNCTION("zgXifHT9ErY", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutIsFlipPending); LIB_FUNCTION("zgXifHT9ErY", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, HLE::Libs::Graphics::VideoOut::sceVideoOutIsFlipPending);
} }

View File

@ -3,9 +3,6 @@
namespace HLE::Libs::LibSceVideoOut { namespace HLE::Libs::LibSceVideoOut {
using SceUserServiceUserId = s32; //TODO move it to proper place
void LibSceVideoOut_Register(SymbolsResolver* sym); void LibSceVideoOut_Register(SymbolsResolver* sym);
//functions
s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 index, const void* param);
}; // namespace HLE::Libs::LibSceVideoOut }; // namespace HLE::Libs::LibSceVideoOut

View File

@ -33,6 +33,8 @@
#include <emulator.h> #include <emulator.h>
#include "discord.h" #include "discord.h"
#include <Util/config.h> #include <Util/config.h>
#include <Core/PS4/HLE/Graphics/video_out.h>
// Main code // Main code
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
@ -42,10 +44,13 @@ int main(int argc, char* argv[])
} }
Config::load("config.toml"); Config::load("config.toml");
logging::init(true); // init logging logging::init(true); // init logging
auto width = Config::getScreenWidth();
auto height = Config::getScreenHeight();
HLE::Libs::Graphics::VideoOut::videoOutInit(width, height);
Emulator::emuInit(); Emulator::emuInit();
Lib::InitThreads(); Lib::InitThreads();
const char* const path = argv[1]; // argument 1 is the path of self file to boot
const char* const path = argv[1]; // argument 1 is the path of self file to boot
auto* linker = Singleton<Linker>::Instance(); auto* linker = Singleton<Linker>::Instance();
HLE::Libs::Init_HLE_Libs(linker->getHLESymbols()); HLE::Libs::Init_HLE_Libs(linker->getHLESymbols());
auto *module =linker->LoadModule(path);//load main executable auto *module =linker->LoadModule(path);//load main executable