From 07bae57a1633e3c054767adce8903db66af2d13a Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Tue, 19 Aug 2025 20:36:07 -0500 Subject: [PATCH] Libraries: Better libSceCamera stubs (#3434) * Initial work on improved stubs Simulates library behaviors for when a camera is not connected. * Get* functions complete I ended up leaving some stubs behind, but most of what I didn't do seem to be internal functions called by other libraries we'd be running HLE anyway. * Finished stubs Everything I can reasonably confirm the behavior of should behave as expected, emulating the behavior of a PS4 with no camera attached. * sceCameraStart firmware check This check only applies to higher eboot firmwares, since my previous test eboots used firmware 1.00 I completely missed this. * sceCameraGetAutoExposureGain fix When option is provided and valid, size is also set to 0. * Track opened handles Extremely basic for now, if the library was ever properly implemented this could be swapped for a map of some kind instead. * Fix errors for sceCameraStart The firmware-related parameter checks come after the library opened check. * Promote sceCameraIsAttached log to info Since you don't need to initialize the library to call this function, some games will call sceCameraIsAttached before anything else. --- src/core/libraries/camera/camera.cpp | 777 ++++++++++++++++++++++----- src/core/libraries/camera/camera.h | 152 ++++-- 2 files changed, 729 insertions(+), 200 deletions(-) diff --git a/src/core/libraries/camera/camera.cpp b/src/core/libraries/camera/camera.cpp index 5cfa92af3..8dbeceef6 100644 --- a/src/core/libraries/camera/camera.cpp +++ b/src/core/libraries/camera/camera.cpp @@ -1,41 +1,58 @@ // SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "common/elf_info.h" #include "common/logging/log.h" #include "core/libraries/camera/camera.h" #include "core/libraries/camera/camera_error.h" #include "core/libraries/error_codes.h" +#include "core/libraries/kernel/process.h" #include "core/libraries/libs.h" namespace Libraries::Camera { +static bool g_library_opened = false; +static s32 g_firmware_version = 0; +static s32 g_handles = 0; + s32 PS4_SYSV_ABI sceCameraAccGetData() { LOG_ERROR(Lib_Camera, "(STUBBED) called"); return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraAudioClose() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + LOG_DEBUG(Lib_Camera, "called"); + // Returns ORBIS_OK while internally failing return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraAudioGetData() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraAudioGetData(void* data) { + LOG_DEBUG(Lib_Camera, "called"); + if (data == nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + // Returns ORBIS_OK while internally failing return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraAudioGetData2() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraAudioGetData2(void* data) { + LOG_DEBUG(Lib_Camera, "called"); + if (data == nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + // Returns ORBIS_OK while internally failing return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraAudioOpen() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + LOG_DEBUG(Lib_Camera, "called"); + // Returns error fatal as a side effect of not having a camera attached. + return ORBIS_CAMERA_ERROR_FATAL; } s32 PS4_SYSV_ABI sceCameraAudioReset() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + LOG_DEBUG(Lib_Camera, "called"); + // Returns ORBIS_OK while internally failing return ORBIS_OK; } @@ -45,76 +62,223 @@ s32 PS4_SYSV_ABI sceCameraChangeAppModuleState() { } s32 PS4_SYSV_ABI sceCameraClose(s32 handle) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + // Decrement handles on close. + // If no handles remain, then the library itself is considered closed. + if (--g_handles == 0) { + g_library_opened = false; + } return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraCloseByHandle() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraCloseByHandle(s32 handle) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + // Decrement handles on close. + // If no handles remain, then the library itself is considered closed. + if (--g_handles == 0) { + g_library_opened = false; + } return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraDeviceOpen() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + // Stubbed on real hardware return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetAttribute(s32 handle, OrbisCameraAttribute* pAttribute) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraGetAttribute(s32 handle, OrbisCameraAttribute* attribute) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || attribute == nullptr || attribute->sizeThis != sizeof(OrbisCameraAttribute) || + attribute->channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + attribute->channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + auto channel = attribute->channel; + + // Set default attributes + memset(attribute, 0, sizeof(OrbisCameraAttribute)); + attribute->sizeThis = sizeof(OrbisCameraAttribute); + attribute->channel = channel; + attribute->exposureGain.exposure = 83; + attribute->exposureGain.gain = 100; + attribute->whiteBalance.gainRed = 768; + attribute->whiteBalance.gainBlue = 768; + attribute->whiteBalance.gainGreen = 512; + attribute->gamma.value = 4; + attribute->saturation = 64; + attribute->contrast = 32; + attribute->sharpness = 1; + attribute->hue = 1; + return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetAutoExposureGain(s32 handle, OrbisCameraChannel channel, u32* pEnable, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraGetAutoExposureGain(s32 handle, OrbisCameraChannel channel, u32* enable, + OrbisCameraAutoExposureGainTarget* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || enable == nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (option != nullptr && (g_firmware_version < Common::ElfInfo::FW_30 || + option->sizeThis != sizeof(OrbisCameraAutoExposureGainTarget))) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + *enable = 0; + if (option != nullptr) { + option->sizeThis = 0; + option->target = OrbisCameraAecAgcTarget::ORBIS_CAMERA_ATTRIBUTE_AECAGC_TARGET_DEF; + } return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetAutoWhiteBalance(s32 handle, OrbisCameraChannel channel, u32* pEnable, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraGetAutoWhiteBalance(s32 handle, OrbisCameraChannel channel, u32* enable, + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || enable == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + *enable = 0; return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraGetCalibData() { LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraGetCalibDataFromDevice() { LOG_ERROR(Lib_Camera, "(STUBBED) called"); + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; +} + +s32 PS4_SYSV_ABI sceCameraGetCalibrationData(const OrbisCameraGetCalibrationDataParameter* param, + OrbisCameraCalibrationData* calibration_data) { + LOG_DEBUG(Lib_Camera, "called"); + if (param == nullptr || calibration_data == nullptr || + param->size != sizeof(OrbisCameraGetCalibrationDataParameter) || param->format_type != 0 || + param->function_type < + OrbisCameraCalibrationDataFunctionType:: + ORBIS_CAMERA_CALIBRATION_DATA_FUNCTION_TYPE_IMAGE_RECTIFICATION || + param->function_type > + OrbisCameraCalibrationDataFunctionType:: + ORBIS_CAMERA_CALIBRATION_DATA_FUNCTION_TYPE_IMAGE_INVERSE_RECTIFICATION) { + return ORBIS_CAMERA_ERROR_PARAM; + } + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; +} + +s32 PS4_SYSV_ABI sceCameraGetConfig(s32 handle, OrbisCameraConfig* config) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || config == nullptr || config->sizeThis != sizeof(OrbisCameraConfig)) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + // Set default config + config->configType = ORBIS_CAMERA_CONFIG_TYPE1; + config->sizeThis = 0; + + OrbisCameraConfigExtention default_extension; + default_extension.format.formatLevel0 = ORBIS_CAMERA_FORMAT_YUV422; + default_extension.format.formatLevel1 = ORBIS_CAMERA_SCALE_FORMAT_Y8; + default_extension.format.formatLevel2 = ORBIS_CAMERA_SCALE_FORMAT_Y8; + default_extension.format.formatLevel3 = ORBIS_CAMERA_SCALE_FORMAT_Y8; + default_extension.resolution = ORBIS_CAMERA_RESOLUTION_1280X800; + default_extension.framerate = ORBIS_CAMERA_FRAMERATE_60; + default_extension.width = 0; + default_extension.height = 0; + default_extension.reserved1 = 0; + + memcpy(&config->configExtention[0], &default_extension, sizeof(OrbisCameraConfigExtention)); + memcpy(&config->configExtention[1], &default_extension, sizeof(OrbisCameraConfigExtention)); + return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetCalibrationData() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; -} +s32 PS4_SYSV_ABI sceCameraGetContrast(s32 handle, OrbisCameraChannel channel, u32* contrast, + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || contrast == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } -s32 PS4_SYSV_ABI sceCameraGetConfig(s32 handle, OrbisCameraConfig* pConfig) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; -} - -s32 PS4_SYSV_ABI sceCameraGetContrast(s32 handle, OrbisCameraChannel channel, u32* pContrast, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + *contrast = 32; return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraGetDefectivePixelCancellation(s32 handle, OrbisCameraChannel channel, - u32* pEnable, void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + u32* enable, void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || enable == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + *enable = 0; return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetDeviceConfig() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraGetDeviceConfig(s32 handle, OrbisCameraConfig* config) { + if (handle < 1 || config == nullptr || config->sizeThis != sizeof(OrbisCameraConfig)) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + memset(config, 0, sizeof(OrbisCameraConfig)); return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetDeviceConfigWithoutHandle() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraGetDeviceConfigWithoutHandle(OrbisCameraConfig* config) { + if (config == nullptr || config->sizeThis != sizeof(OrbisCameraConfig)) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + memset(config, 0, sizeof(OrbisCameraConfig)); return ORBIS_OK; } @@ -128,47 +292,123 @@ s32 PS4_SYSV_ABI sceCameraGetDeviceIDWithoutOpen() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetDeviceInfo(s32 reserved, OrbisCameraDeviceInfo* pDeviceInfo) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceCameraGetDeviceInfo(s32 reserved, OrbisCameraDeviceInfo* device_info) { + LOG_DEBUG(Lib_Camera, "called"); + if (reserved != 0 || device_info == nullptr || + device_info->sizeThis != sizeof(OrbisCameraDeviceInfo) || device_info->infoRevision != 1) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_INIT; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraGetExposureGain(s32 handle, OrbisCameraChannel channel, - OrbisCameraExposureGain* pExposureGain, void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + OrbisCameraExposureGain* exposure_gain, void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || exposure_gain == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + // Return default parameters + exposure_gain->exposureControl = 0; + exposure_gain->exposure = 83; + exposure_gain->gain = 100; + exposure_gain->mode = 0; return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetFrameData(int handle, OrbisCameraFrameData* pFrameData) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraGetFrameData(s32 handle, OrbisCameraFrameData* frame_data) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || frame_data == nullptr || frame_data->sizeThis > 584) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; +} + +s32 PS4_SYSV_ABI sceCameraGetGamma(s32 handle, OrbisCameraChannel channel, OrbisCameraGamma* gamma, + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || gamma == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + // Return default parameters + memset(gamma, 0, sizeof(OrbisCameraGamma)); + gamma->value = 4; return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetGamma(s32 handle, OrbisCameraChannel channel, OrbisCameraGamma* pGamma, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraGetHue(s32 handle, OrbisCameraChannel channel, s32* hue, void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || hue == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + *hue = 1; return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetHue(s32 handle, OrbisCameraChannel channel, s32* pHue, void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraGetLensCorrection(s32 handle, OrbisCameraChannel channel, u32* enable, + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || enable == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + *enable = 0; return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetLensCorrection(s32 handle, OrbisCameraChannel channel, u32* pEnable, - void* pOption) { +s32 PS4_SYSV_ABI sceCameraGetMmapConnectedCount(u32* count) { LOG_ERROR(Lib_Camera, "(STUBBED) called"); + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + if (count == nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + + *count = 0; return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetMmapConnectedCount() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; -} +s32 PS4_SYSV_ABI sceCameraGetProductInfo(void* product_info) { + LOG_DEBUG(Lib_Camera, "(STUBBED) called"); + if (product_info == nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_INIT; + } -s32 PS4_SYSV_ABI sceCameraGetProductInfo() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraGetRegister() { @@ -176,20 +416,47 @@ s32 PS4_SYSV_ABI sceCameraGetRegister() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetRegistryInfo() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraGetRegistryInfo(void* registry_info) { + LOG_DEBUG(Lib_Camera, "(STUBBED) called"); + if (registry_info == nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_INIT; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; +} + +s32 PS4_SYSV_ABI sceCameraGetSaturation(s32 handle, OrbisCameraChannel channel, u32* saturation, + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || saturation == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + *saturation = 64; return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraGetSaturation(s32 handle, OrbisCameraChannel channel, u32* pSaturation, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; -} +s32 PS4_SYSV_ABI sceCameraGetSharpness(s32 handle, OrbisCameraChannel channel, u32* sharpness, + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || sharpness == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } -s32 PS4_SYSV_ABI sceCameraGetSharpness(s32 handle, OrbisCameraChannel channel, u32* pSharpness, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + *sharpness = 1; return ORBIS_OK; } @@ -199,19 +466,40 @@ s32 PS4_SYSV_ABI sceCameraGetVrCaptureInfo() { } s32 PS4_SYSV_ABI sceCameraGetWhiteBalance(s32 handle, OrbisCameraChannel channel, - OrbisCameraWhiteBalance* pWhiteBalance, void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + OrbisCameraWhiteBalance* white_balance, void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel >= OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || white_balance == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + // Set default parameters + white_balance->whiteBalanceControl = 0; + white_balance->gainRed = 768; + white_balance->gainBlue = 768; + white_balance->gainGreen = 512; return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraInitializeRegistryCalibData() { LOG_ERROR(Lib_Camera, "(STUBBED) called"); + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_INIT; + } return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraIsAttached(s32 index) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + LOG_INFO(Lib_Camera, "called"); + if (index != 0) { + return ORBIS_CAMERA_ERROR_PARAM; + } + // 0 = disconnected, 1 = connected + return 0; } s32 PS4_SYSV_ABI sceCameraIsConfigChangeDone() { @@ -219,15 +507,28 @@ s32 PS4_SYSV_ABI sceCameraIsConfigChangeDone() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraIsValidFrameData(int handle, OrbisCameraFrameData* pFrameData) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraIsValidFrameData(s32 handle, OrbisCameraFrameData* frame_data) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || frame_data == nullptr || frame_data->sizeThis > 584) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraOpen(Libraries::UserService::OrbisUserServiceUserId userId, s32 type, - s32 index, OrbisCameraOpenParameter* pParam) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceCameraOpen(Libraries::UserService::OrbisUserServiceUserId user_id, s32 type, + s32 index, OrbisCameraOpenParameter* param) { + if (user_id != Libraries::UserService::ORBIS_USER_SERVICE_USER_ID_SYSTEM || type != 0 || + index != 0) { + return ORBIS_CAMERA_ERROR_PARAM; + } + LOG_WARNING(Lib_Camera, "Cameras are not supported yet"); + + g_library_opened = true; + return ++g_handles; } s32 PS4_SYSV_ABI sceCameraOpenByModuleId() { @@ -245,26 +546,61 @@ s32 PS4_SYSV_ABI sceCameraSetAppModuleFocus() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraSetAttribute(s32 handle, OrbisCameraAttribute* pAttribute) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceCameraSetAttribute(s32 handle, OrbisCameraAttribute* attribute) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || attribute == nullptr || attribute->sizeThis != sizeof(OrbisCameraAttribute) || + attribute->channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + attribute->channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraSetAttributeInternal() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + // Stubbed on real hardware return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraSetAutoExposureGain(s32 handle, OrbisCameraChannel channel, u32 enable, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + OrbisCameraAutoExposureGainTarget* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (option != nullptr) { + if (g_firmware_version < Common::ElfInfo::FW_30 || + option->sizeThis != sizeof(OrbisCameraAutoExposureGainTarget)) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (option->target % 2 == 1 || option->target < ORBIS_CAMERA_ATTRIBUTE_AECAGC_TARGET_DEF || + option->target > ORBIS_CAMERA_ATTRIBUTE_AECAGC_TARGET_2_0) { + return ORBIS_CAMERA_ERROR_PARAM; + } + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraSetAutoWhiteBalance(s32 handle, OrbisCameraChannel channel, u32 enable, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraSetCalibData() { @@ -272,42 +608,94 @@ s32 PS4_SYSV_ABI sceCameraSetCalibData() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraSetConfig(s32 handle, OrbisCameraConfig* pConfig) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceCameraSetConfig(s32 handle, OrbisCameraConfig* config) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || config == nullptr || config->sizeThis != sizeof(OrbisCameraConfig)) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } -s32 PS4_SYSV_ABI sceCameraSetConfigInternal() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceCameraSetConfigInternal(s32 handle, OrbisCameraConfig* config) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || config == nullptr || config->sizeThis != sizeof(OrbisCameraConfig)) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraSetContrast(s32 handle, OrbisCameraChannel channel, u32 contrast, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } -s32 PS4_SYSV_ABI sceCameraSetDebugStop() { +s32 PS4_SYSV_ABI sceCameraSetDebugStop(u32 debug_stop_enable) { LOG_ERROR(Lib_Camera, "(STUBBED) called"); + if (debug_stop_enable > 1) { + return ORBIS_CAMERA_ERROR_PARAM; + } return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraSetDefectivePixelCancellation(s32 handle, OrbisCameraChannel channel, - u32 enable, void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + u32 enable, void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || enable > 1 || option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } -s32 PS4_SYSV_ABI sceCameraSetDefectivePixelCancellationInternal() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceCameraSetDefectivePixelCancellationInternal(s32 handle, + OrbisCameraChannel channel, + u32 enable, void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || enable > 2 || option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraSetExposureGain(s32 handle, OrbisCameraChannel channel, - OrbisCameraExposureGain* pExposureGain, void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + OrbisCameraExposureGain* exposure_gain, void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || exposure_gain != nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraSetForceActivate() { @@ -315,26 +703,60 @@ s32 PS4_SYSV_ABI sceCameraSetForceActivate() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraSetGamma(s32 handle, OrbisCameraChannel channel, OrbisCameraGamma* pGamma, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceCameraSetGamma(s32 handle, OrbisCameraChannel channel, OrbisCameraGamma* gamma, + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || gamma != nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } -s32 PS4_SYSV_ABI sceCameraSetHue(s32 handle, OrbisCameraChannel channel, s32 hue, void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceCameraSetHue(s32 handle, OrbisCameraChannel channel, s32 hue, void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraSetLensCorrection(s32 handle, OrbisCameraChannel channel, u32 enable, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || enable > 1 || option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } -s32 PS4_SYSV_ABI sceCameraSetLensCorrectionInternal() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceCameraSetLensCorrectionInternal(s32 handle, OrbisCameraChannel channel, + u32 enable, void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || enable > 2 || option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraSetProcessFocus() { @@ -353,15 +775,34 @@ s32 PS4_SYSV_ABI sceCameraSetRegister() { } s32 PS4_SYSV_ABI sceCameraSetSaturation(s32 handle, OrbisCameraChannel channel, u32 saturation, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraSetSharpness(s32 handle, OrbisCameraChannel channel, u32 sharpness, - void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; + void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (g_firmware_version >= Common::ElfInfo::FW_35 && sharpness > 10) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; } s32 PS4_SYSV_ABI sceCameraSetTrackerMode() { @@ -374,43 +815,97 @@ s32 PS4_SYSV_ABI sceCameraSetUacModeInternal() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraSetVideoSync(s32 handle, OrbisCameraVideoSyncParameter* pVideoSync) { +s32 PS4_SYSV_ABI sceCameraSetVideoSync(s32 handle, OrbisCameraVideoSyncParameter* video_sync) { LOG_ERROR(Lib_Camera, "(STUBBED) called"); + if (handle < 1 || video_sync == nullptr || + video_sync->sizeThis != sizeof(OrbisCameraVideoSyncParameter) || + video_sync->videoSyncMode > 1 || video_sync->pModeOption != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraSetVideoSyncInternal() { +s32 PS4_SYSV_ABI sceCameraSetVideoSyncInternal(s32 handle, + OrbisCameraVideoSyncParameter* video_sync) { LOG_ERROR(Lib_Camera, "(STUBBED) called"); return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraSetWhiteBalance(s32 handle, OrbisCameraChannel channel, - OrbisCameraWhiteBalance* pWhiteBalance, void* pOption) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + OrbisCameraWhiteBalance* white_balance, void* option) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || channel > OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_BOTH || + channel < OrbisCameraChannel::ORBIS_CAMERA_CHANNEL_0 || white_balance == nullptr || + option != nullptr) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + + return ORBIS_CAMERA_ERROR_NOT_CONNECTED; +} + +s32 PS4_SYSV_ABI sceCameraStart(s32 handle, OrbisCameraStartParameter* param) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || param == nullptr || param->sizeThis != sizeof(OrbisCameraStartParameter)) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + if (g_firmware_version >= Common::ElfInfo::FW_25 && + (param->formatLevel[0] >= 0xf || param->formatLevel[1] >= 0xf || + (param->formatLevel[0] | param->formatLevel[1]) == 0)) { + return ORBIS_CAMERA_ERROR_FORMAT_UNKNOWN; + } + return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraStart(s32 handle, OrbisCameraStartParameter* pParam) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); - return ORBIS_OK; -} +s32 PS4_SYSV_ABI sceCameraStartByHandle(s32 handle, OrbisCameraStartParameter* param) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1 || param == nullptr || param->sizeThis != sizeof(OrbisCameraStartParameter)) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } -s32 PS4_SYSV_ABI sceCameraStartByHandle() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); return ORBIS_OK; } s32 PS4_SYSV_ABI sceCameraStop(s32 handle) { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + return ORBIS_OK; } -s32 PS4_SYSV_ABI sceCameraStopByHandle() { - LOG_ERROR(Lib_Camera, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceCameraStopByHandle(s32 handle) { + LOG_DEBUG(Lib_Camera, "called"); + if (handle < 1) { + return ORBIS_CAMERA_ERROR_PARAM; + } + if (!g_library_opened) { + return ORBIS_CAMERA_ERROR_NOT_OPEN; + } + return ORBIS_OK; } void RegisterLib(Core::Loader::SymbolsResolver* sym) { + Libraries::Kernel::sceKernelGetCompiledSdkVersion(&g_firmware_version); + LIB_FUNCTION("QhjrPkRPUZQ", "libSceCamera", 1, "libSceCamera", 1, 1, sceCameraAccGetData); LIB_FUNCTION("UFonL7xopFM", "libSceCamera", 1, "libSceCamera", 1, 1, sceCameraAudioClose); LIB_FUNCTION("fkZE7Hup2ro", "libSceCamera", 1, "libSceCamera", 1, 1, sceCameraAudioGetData); diff --git a/src/core/libraries/camera/camera.h b/src/core/libraries/camera/camera.h index 8eee94897..86bb12135 100644 --- a/src/core/libraries/camera/camera.h +++ b/src/core/libraries/camera/camera.h @@ -12,8 +12,9 @@ class SymbolsResolver; namespace Libraries::Camera { -constexpr int ORBIS_CAMERA_MAX_DEVICE_NUM = 2; -constexpr int ORBIS_CAMERA_MAX_FORMAT_LEVEL_NUM = 4; +constexpr s32 ORBIS_CAMERA_MAX_DEVICE_NUM = 2; +constexpr s32 ORBIS_CAMERA_MAX_FORMAT_LEVEL_NUM = 4; +constexpr s32 ORBIS_CAMERA_CALIBRATION_DATA_MESH_NUMBER_OF_TOTAL_VERTICIES = 1276; enum OrbisCameraChannel { ORBIS_CAMERA_CHANNEL_0 = 1, @@ -73,6 +74,11 @@ enum OrbisCameraScaleFormat { ORBIS_CAMERA_SCALE_FORMAT_UNKNOWN = 0xFF, }; +enum OrbisCameraCalibrationDataFunctionType { + ORBIS_CAMERA_CALIBRATION_DATA_FUNCTION_TYPE_IMAGE_RECTIFICATION = 0, + ORBIS_CAMERA_CALIBRATION_DATA_FUNCTION_TYPE_IMAGE_INVERSE_RECTIFICATION = 1, +}; + struct OrbisCameraFormat { OrbisCameraBaseFormat formatLevel0; OrbisCameraScaleFormat formatLevel1; @@ -206,103 +212,131 @@ struct OrbisCameraAttribute { u32 reserved4; }; +struct OrbisCameraGetCalibrationDataParameter { + u32 size; + u32 format_type; + OrbisCameraCalibrationDataFunctionType function_type; +}; + +struct OrbisCameraCalibrationDataElement { + u32 total_horizontal_verticies; + u32 total_vertical_verticies; + u32 left_margin; + u32 right_margin; + u32 top_margin; + u32 bottom_margin; + float x_table[ORBIS_CAMERA_CALIBRATION_DATA_MESH_NUMBER_OF_TOTAL_VERTICIES]; + float y_table[ORBIS_CAMERA_CALIBRATION_DATA_MESH_NUMBER_OF_TOTAL_VERTICIES]; +}; + +struct OrbisCameraCalibrationData { + u32 format_type; + OrbisCameraCalibrationDataFunctionType function_type; + OrbisCameraCalibrationDataElement data[2]; +}; + s32 PS4_SYSV_ABI sceCameraAccGetData(); s32 PS4_SYSV_ABI sceCameraAudioClose(); -s32 PS4_SYSV_ABI sceCameraAudioGetData(); -s32 PS4_SYSV_ABI sceCameraAudioGetData2(); +s32 PS4_SYSV_ABI sceCameraAudioGetData(void* data); +s32 PS4_SYSV_ABI sceCameraAudioGetData2(void* data); s32 PS4_SYSV_ABI sceCameraAudioOpen(); s32 PS4_SYSV_ABI sceCameraAudioReset(); s32 PS4_SYSV_ABI sceCameraChangeAppModuleState(); s32 PS4_SYSV_ABI sceCameraClose(s32 handle); -s32 PS4_SYSV_ABI sceCameraCloseByHandle(); +s32 PS4_SYSV_ABI sceCameraCloseByHandle(s32 handle); s32 PS4_SYSV_ABI sceCameraDeviceOpen(); -s32 PS4_SYSV_ABI sceCameraGetAttribute(s32 handle, OrbisCameraAttribute* pAttribute); -s32 PS4_SYSV_ABI sceCameraGetAutoExposureGain(s32 handle, OrbisCameraChannel channel, u32* pEnable, - void* pOption); -s32 PS4_SYSV_ABI sceCameraGetAutoWhiteBalance(s32 handle, OrbisCameraChannel channel, u32* pEnable, - void* pOption); +s32 PS4_SYSV_ABI sceCameraGetAttribute(s32 handle, OrbisCameraAttribute* attribute); +s32 PS4_SYSV_ABI sceCameraGetAutoExposureGain(s32 handle, OrbisCameraChannel channel, u32* enable, + OrbisCameraAutoExposureGainTarget* option); +s32 PS4_SYSV_ABI sceCameraGetAutoWhiteBalance(s32 handle, OrbisCameraChannel channel, u32* enable, + void* option); s32 PS4_SYSV_ABI sceCameraGetCalibData(); s32 PS4_SYSV_ABI sceCameraGetCalibDataFromDevice(); -s32 PS4_SYSV_ABI sceCameraGetCalibrationData(); -s32 PS4_SYSV_ABI sceCameraGetConfig(s32 handle, OrbisCameraConfig* pConfig); -s32 PS4_SYSV_ABI sceCameraGetContrast(s32 handle, OrbisCameraChannel channel, u32* pContrast, - void* pOption); +s32 PS4_SYSV_ABI sceCameraGetCalibrationData(const OrbisCameraGetCalibrationDataParameter* param, + OrbisCameraCalibrationData* calibration_data); +s32 PS4_SYSV_ABI sceCameraGetConfig(s32 handle, OrbisCameraConfig* config); +s32 PS4_SYSV_ABI sceCameraGetContrast(s32 handle, OrbisCameraChannel channel, u32* contrast, + void* option); s32 PS4_SYSV_ABI sceCameraGetDefectivePixelCancellation(s32 handle, OrbisCameraChannel channel, - u32* pEnable, void* pOption); -s32 PS4_SYSV_ABI sceCameraGetDeviceConfig(); -s32 PS4_SYSV_ABI sceCameraGetDeviceConfigWithoutHandle(); + u32* enable, void* option); +s32 PS4_SYSV_ABI sceCameraGetDeviceConfig(s32 handle, OrbisCameraConfig* config); +s32 PS4_SYSV_ABI sceCameraGetDeviceConfigWithoutHandle(OrbisCameraConfig* config); s32 PS4_SYSV_ABI sceCameraGetDeviceID(); s32 PS4_SYSV_ABI sceCameraGetDeviceIDWithoutOpen(); -s32 PS4_SYSV_ABI sceCameraGetDeviceInfo(s32 reserved, OrbisCameraDeviceInfo* pDeviceInfo); +s32 PS4_SYSV_ABI sceCameraGetDeviceInfo(s32 reserved, OrbisCameraDeviceInfo* device_info); s32 PS4_SYSV_ABI sceCameraGetExposureGain(s32 handle, OrbisCameraChannel channel, - OrbisCameraExposureGain* pExposureGain, void* pOption); -s32 PS4_SYSV_ABI sceCameraGetFrameData(int handle, OrbisCameraFrameData* pFrameData); -s32 PS4_SYSV_ABI sceCameraGetGamma(s32 handle, OrbisCameraChannel channel, OrbisCameraGamma* pGamma, - void* pOption); -s32 PS4_SYSV_ABI sceCameraGetHue(s32 handle, OrbisCameraChannel channel, s32* pHue, void* pOption); -s32 PS4_SYSV_ABI sceCameraGetLensCorrection(s32 handle, OrbisCameraChannel channel, u32* pEnable, - void* pOption); -s32 PS4_SYSV_ABI sceCameraGetMmapConnectedCount(); -s32 PS4_SYSV_ABI sceCameraGetProductInfo(); + OrbisCameraExposureGain* exposure_gain, void* option); +s32 PS4_SYSV_ABI sceCameraGetFrameData(s32 handle, OrbisCameraFrameData* frame_data); +s32 PS4_SYSV_ABI sceCameraGetGamma(s32 handle, OrbisCameraChannel channel, OrbisCameraGamma* gamma, + void* option); +s32 PS4_SYSV_ABI sceCameraGetHue(s32 handle, OrbisCameraChannel channel, s32* hue, void* option); +s32 PS4_SYSV_ABI sceCameraGetLensCorrection(s32 handle, OrbisCameraChannel channel, u32* enable, + void* option); +s32 PS4_SYSV_ABI sceCameraGetMmapConnectedCount(u32* count); +s32 PS4_SYSV_ABI sceCameraGetProductInfo(void* product_info); s32 PS4_SYSV_ABI sceCameraGetRegister(); -s32 PS4_SYSV_ABI sceCameraGetRegistryInfo(); -s32 PS4_SYSV_ABI sceCameraGetSaturation(s32 handle, OrbisCameraChannel channel, u32* pSaturation, - void* pOption); -s32 PS4_SYSV_ABI sceCameraGetSharpness(s32 handle, OrbisCameraChannel channel, u32* pSharpness, - void* pOption); +s32 PS4_SYSV_ABI sceCameraGetRegistryInfo(void* registry_info); +s32 PS4_SYSV_ABI sceCameraGetSaturation(s32 handle, OrbisCameraChannel channel, u32* saturation, + void* option); +s32 PS4_SYSV_ABI sceCameraGetSharpness(s32 handle, OrbisCameraChannel channel, u32* sharpness, + void* option); s32 PS4_SYSV_ABI sceCameraGetVrCaptureInfo(); s32 PS4_SYSV_ABI sceCameraGetWhiteBalance(s32 handle, OrbisCameraChannel channel, - OrbisCameraWhiteBalance* pWhiteBalance, void* pOption); + OrbisCameraWhiteBalance* white_balance, void* option); s32 PS4_SYSV_ABI sceCameraInitializeRegistryCalibData(); s32 PS4_SYSV_ABI sceCameraIsAttached(s32 index); s32 PS4_SYSV_ABI sceCameraIsConfigChangeDone(); -s32 PS4_SYSV_ABI sceCameraIsValidFrameData(int handle, OrbisCameraFrameData* pFrameData); -s32 PS4_SYSV_ABI sceCameraOpen(Libraries::UserService::OrbisUserServiceUserId userId, s32 type, - s32 index, OrbisCameraOpenParameter* pParam); +s32 PS4_SYSV_ABI sceCameraIsValidFrameData(s32 handle, OrbisCameraFrameData* frame_data); +s32 PS4_SYSV_ABI sceCameraOpen(Libraries::UserService::OrbisUserServiceUserId user_id, s32 type, + s32 index, OrbisCameraOpenParameter* param); s32 PS4_SYSV_ABI sceCameraOpenByModuleId(); s32 PS4_SYSV_ABI sceCameraRemoveAppModuleFocus(); s32 PS4_SYSV_ABI sceCameraSetAppModuleFocus(); -s32 PS4_SYSV_ABI sceCameraSetAttribute(s32 handle, OrbisCameraAttribute* pAttribute); +s32 PS4_SYSV_ABI sceCameraSetAttribute(s32 handle, OrbisCameraAttribute* attribute); s32 PS4_SYSV_ABI sceCameraSetAttributeInternal(); s32 PS4_SYSV_ABI sceCameraSetAutoExposureGain(s32 handle, OrbisCameraChannel channel, u32 enable, - void* pOption); + OrbisCameraAutoExposureGainTarget* option); s32 PS4_SYSV_ABI sceCameraSetAutoWhiteBalance(s32 handle, OrbisCameraChannel channel, u32 enable, - void* pOption); + void* option); s32 PS4_SYSV_ABI sceCameraSetCalibData(); -s32 PS4_SYSV_ABI sceCameraSetConfig(s32 handle, OrbisCameraConfig* pConfig); -s32 PS4_SYSV_ABI sceCameraSetConfigInternal(); +s32 PS4_SYSV_ABI sceCameraSetConfig(s32 handle, OrbisCameraConfig* config); +s32 PS4_SYSV_ABI sceCameraSetConfigInternal(s32 handle, OrbisCameraConfig* config); s32 PS4_SYSV_ABI sceCameraSetContrast(s32 handle, OrbisCameraChannel channel, u32 contrast, - void* pOption); -s32 PS4_SYSV_ABI sceCameraSetDebugStop(); + void* option); +s32 PS4_SYSV_ABI sceCameraSetDebugStop(u32 debug_stop_enable); s32 PS4_SYSV_ABI sceCameraSetDefectivePixelCancellation(s32 handle, OrbisCameraChannel channel, - u32 enable, void* pOption); -s32 PS4_SYSV_ABI sceCameraSetDefectivePixelCancellationInternal(); + u32 enable, void* option); +s32 PS4_SYSV_ABI sceCameraSetDefectivePixelCancellationInternal(s32 handle, + OrbisCameraChannel channel, + u32 enable, void* option); s32 PS4_SYSV_ABI sceCameraSetExposureGain(s32 handle, OrbisCameraChannel channel, - OrbisCameraExposureGain* pExposureGain, void* pOption); + OrbisCameraExposureGain* exposure_gain, void* option); s32 PS4_SYSV_ABI sceCameraSetForceActivate(); -s32 PS4_SYSV_ABI sceCameraSetGamma(s32 handle, OrbisCameraChannel channel, OrbisCameraGamma* pGamma, - void* pOption); -s32 PS4_SYSV_ABI sceCameraSetHue(s32 handle, OrbisCameraChannel channel, s32 hue, void* pOption); +s32 PS4_SYSV_ABI sceCameraSetGamma(s32 handle, OrbisCameraChannel channel, OrbisCameraGamma* gamma, + void* option); +s32 PS4_SYSV_ABI sceCameraSetHue(s32 handle, OrbisCameraChannel channel, s32 hue, void* option); s32 PS4_SYSV_ABI sceCameraSetLensCorrection(s32 handle, OrbisCameraChannel channel, u32 enable, - void* pOption); -s32 PS4_SYSV_ABI sceCameraSetLensCorrectionInternal(); + void* option); +s32 PS4_SYSV_ABI sceCameraSetLensCorrectionInternal(s32 handle, OrbisCameraChannel channel, + u32 enable, void* option); s32 PS4_SYSV_ABI sceCameraSetProcessFocus(); s32 PS4_SYSV_ABI sceCameraSetProcessFocusByHandle(); s32 PS4_SYSV_ABI sceCameraSetRegister(); s32 PS4_SYSV_ABI sceCameraSetSaturation(s32 handle, OrbisCameraChannel channel, u32 saturation, - void* pOption); + void* option); s32 PS4_SYSV_ABI sceCameraSetSharpness(s32 handle, OrbisCameraChannel channel, u32 sharpness, - void* pOption); + void* option); s32 PS4_SYSV_ABI sceCameraSetTrackerMode(); s32 PS4_SYSV_ABI sceCameraSetUacModeInternal(); -s32 PS4_SYSV_ABI sceCameraSetVideoSync(s32 handle, OrbisCameraVideoSyncParameter* pVideoSync); -s32 PS4_SYSV_ABI sceCameraSetVideoSyncInternal(); +s32 PS4_SYSV_ABI sceCameraSetVideoSync(s32 handle, OrbisCameraVideoSyncParameter* video_sync); +s32 PS4_SYSV_ABI sceCameraSetVideoSyncInternal(s32 handle, + OrbisCameraVideoSyncParameter* video_sync); s32 PS4_SYSV_ABI sceCameraSetWhiteBalance(s32 handle, OrbisCameraChannel channel, - OrbisCameraWhiteBalance* pWhiteBalance, void* pOption); -s32 PS4_SYSV_ABI sceCameraStart(s32 handle, OrbisCameraStartParameter* pParam); -s32 PS4_SYSV_ABI sceCameraStartByHandle(); + OrbisCameraWhiteBalance* white_balance, void* option); +s32 PS4_SYSV_ABI sceCameraStart(s32 handle, OrbisCameraStartParameter* param); +s32 PS4_SYSV_ABI sceCameraStartByHandle(s32 handle, OrbisCameraStartParameter* param); s32 PS4_SYSV_ABI sceCameraStop(s32 handle); -s32 PS4_SYSV_ABI sceCameraStopByHandle(); +s32 PS4_SYSV_ABI sceCameraStopByHandle(s32 handle); void RegisterLib(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::Camera \ No newline at end of file