From 932483b93428057135194cfbfd80cfcddaab2416 Mon Sep 17 00:00:00 2001 From: Fangal-Airbag <77993079+Fangal-Airbag@users.noreply.github.com> Date: Thu, 22 Sep 2022 18:05:30 -0400 Subject: [PATCH 1/4] Add Camera lib (camera.rpl) --- include/camera/camera.h | 158 ++++++++++++++++++ .../test_compile_headers_list.h | 1 + 2 files changed, 159 insertions(+) create mode 100644 include/camera/camera.h diff --git a/include/camera/camera.h b/include/camera/camera.h new file mode 100644 index 000000000..d85684e7a --- /dev/null +++ b/include/camera/camera.h @@ -0,0 +1,158 @@ +#pragma once +#include + +/** + * \defgroup cam Camera + * \ingroup cam + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define CAMERA_WIDTH 640 +#define CAMERA_PITCH 768 +#define CAMERA_HEIGHT 480 + +#define CAMERA_Y_BUFFER_SIZE (CAMERA_PITCH * CAMERA_HEIGHT) +#define CAMERA_UV_BUFFER_SIZE (CAMERA_PITCH * CAMERA_HEIGHT / 2) +#define CAMERA_YUV_BUFFER_SIZE (CAMERA_Y_BUFFER_SIZE + CAMERA_UV_BUFFER_SIZE) + +#define CAMERA_YUV_BUFFER_ALIGNMENT 256 + +#define CAM_THREAD_AFFINITY_ANY 0x00000007u + +typedef int CAMHandle; +typedef int CAMError; + +typedef struct _Camera_Event_Handler_Input _Camera_Event_Handler_Input; +typedef struct CAMMode CAMMode; +typedef struct CAMWorkMem CAMWorkMem; +typedef struct CAMStreamInfo CAMStreamInfo; +typedef struct CAMSetupInfo CAMSetupInfo; +typedef struct CAMSurface CAMSurface; + +typedef enum CamError +{ + CAMERA_ERROR_OK = 0, + CAMERA_ERROR_INVALID_ARG = -1, + CAMERA_ERROR_INVALID_HANDLE = -2, + CAMERA_ERROR_INSUFFICIENT_MEMORY = -5, + CAMERA_ERROR_NOT_READY = -6, + CAMERA_ERROR_UNIINITIALIZED = -8, + CAMERA_ERROR_UNKNOWN = -10, + CAMERA_ERROR_DEVICE_IN_USE = -12, + CAMERA_ERROR_SEGMENT_VIOLATION = -14 +} CamError; + +typedef enum CamFps +{ + CAMERA_FPS_15, + CAMERA_FPS_30 +} CamFps; + +typedef enum CamStreamType +{ + CAMERA_STREAM_TYPE_1 +} CamStreamType; + +struct _Camera_Event_Handler_Input +{ + CAMError err; + void *img; + void *arg; // user provided value ?? +}; +WUT_CHECK_SIZE(_Camera_Event_Handler_Input, 0x0C); + +typedef void(*CAMEventHandler)(_Camera_Event_Handler_Input*); + +struct CAMMode +{ + int unk_0x00; + CamFps fps; +}; +WUT_CHECK_OFFSET(CAMMode, 0x00, unk_0x00); +WUT_CHECK_OFFSET(CAMMode, 0x04, fps); +WUT_CHECK_SIZE(CAMMode, 0x08); + +struct CAMWorkMem +{ + int size; // size of the work mem + void *pMem; // pointer to the work mem +}; +WUT_CHECK_OFFSET(CAMWorkMem, 0x00, size); +WUT_CHECK_OFFSET(CAMWorkMem, 0x04, pMem); +WUT_CHECK_SIZE(CAMWorkMem, 0x08); + +struct CAMStreamInfo +{ + CamStreamType type; + int height; // stream height + int width; // stream width +}; +WUT_CHECK_OFFSET(CAMStreamInfo, 0x00, type); +WUT_CHECK_OFFSET(CAMStreamInfo, 0x04, height); +WUT_CHECK_OFFSET(CAMStreamInfo, 0x08, width); +WUT_CHECK_SIZE(CAMStreamInfo, 0x0C); + +struct CAMSetupInfo +{ + CAMStreamInfo streamInfo; + CAMWorkMem workMem; + WUT_UNKNOWN_BYTES(8); + CAMMode mode; + int threadAffinity; // which cpu core to run on, only known value is CAM_THREAD_AFFINITY_NONE + WUT_UNKNOWN_BYTES(0x10); +}; +WUT_CHECK_OFFSET(CAMSetupInfo, 0x00, streamInfo); +WUT_CHECK_OFFSET(CAMSetupInfo, 0x0C, workMem); +WUT_CHECK_OFFSET(CAMSetupInfo, 0x1C, mode); +WUT_CHECK_OFFSET(CAMSetupInfo, 0x24, threadAffinity); +WUT_CHECK_SIZE(CAMSetupInfo, 0x38); + +struct CAMSurface +{ + int surfaceSize; + void *surfaceBuffer; + int height; // surface height + int width; // surface width + int unk_0x10; // pitch related? + int alignment; // surface alignment + int unk_0x18; // surface tile mode related? + int unk_0x1C; +}; +WUT_CHECK_OFFSET(CAMSurface, 0x00, surfaceSize); +WUT_CHECK_OFFSET(CAMSurface, 0x04, surfaceBuffer); +WUT_CHECK_OFFSET(CAMSurface, 0x08, height); +WUT_CHECK_OFFSET(CAMSurface, 0x0C, width); +WUT_CHECK_OFFSET(CAMSurface, 0x10, unk_0x10); +WUT_CHECK_OFFSET(CAMSurface, 0x14, alignment); +WUT_CHECK_OFFSET(CAMSurface, 0x18, unk_0x18); +WUT_CHECK_OFFSET(CAMSurface, 0x1C, unk_0x1C); +WUT_CHECK_SIZE(CAMSurface, 0x20); + +CAMHandle +CAMInit(int instance, CAMSetupInfo *setupInfo, CAMError *err); + +void +CAMExit(CAMHandle handle); + +CAMError +CAMOpen(CAMHandle handle); + +CAMError +CAMClose(CAMHandle handle); + +CAMError +CAMGetMemReq(CAMStreamInfo *streamInfo); + +CAMError +CAMSubmitTargetSurface(CAMHandle handle, CAMSurface *surface); + +CAMError +CAMCheckMemSegmentation(void *pMem, unsigned int size); + +#ifdef __cplusplus +} +#endif diff --git a/tests/test_compile_headers_common/test_compile_headers_list.h b/tests/test_compile_headers_common/test_compile_headers_list.h index 14e740c04..e05deb6aa 100644 --- a/tests/test_compile_headers_common/test_compile_headers_list.h +++ b/tests/test_compile_headers_common/test_compile_headers_list.h @@ -1,4 +1,5 @@ #include +#include #include #include #include From 38c1db54e5d79d998e38bc48fd348be5fb9f67f0 Mon Sep 17 00:00:00 2001 From: Fangal-Airbag <77993079+Fangal-Airbag@users.noreply.github.com> Date: Thu, 22 Sep 2022 18:10:38 -0400 Subject: [PATCH 2/4] Update camera.h --- include/camera/camera.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/camera/camera.h b/include/camera/camera.h index d85684e7a..9d06e03cb 100644 --- a/include/camera/camera.h +++ b/include/camera/camera.h @@ -102,7 +102,7 @@ struct CAMSetupInfo CAMWorkMem workMem; WUT_UNKNOWN_BYTES(8); CAMMode mode; - int threadAffinity; // which cpu core to run on, only known value is CAM_THREAD_AFFINITY_NONE + int threadAffinity; // which cpu core to run on, only known value is CAM_THREAD_AFFINITY_ANY WUT_UNKNOWN_BYTES(0x10); }; WUT_CHECK_OFFSET(CAMSetupInfo, 0x00, streamInfo); From 0d362cc6caeb5977a40c491195951832357a1236 Mon Sep 17 00:00:00 2001 From: Fangal-Airbag <77993079+Fangal-Airbag@users.noreply.github.com> Date: Sun, 30 Oct 2022 16:30:52 -0400 Subject: [PATCH 3/4] Update camera.h --- include/camera/camera.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/include/camera/camera.h b/include/camera/camera.h index 9d06e03cb..f2bf2485e 100644 --- a/include/camera/camera.h +++ b/include/camera/camera.h @@ -1,5 +1,6 @@ #pragma once #include +#include /** * \defgroup cam Camera @@ -21,12 +22,10 @@ extern "C" { #define CAMERA_YUV_BUFFER_ALIGNMENT 256 -#define CAM_THREAD_AFFINITY_ANY 0x00000007u - typedef int CAMHandle; typedef int CAMError; -typedef struct _Camera_Event_Handler_Input _Camera_Event_Handler_Input; +typedef struct CAMEventData CAMEventData; typedef struct CAMMode CAMMode; typedef struct CAMWorkMem CAMWorkMem; typedef struct CAMStreamInfo CAMStreamInfo; @@ -57,15 +56,15 @@ typedef enum CamStreamType CAMERA_STREAM_TYPE_1 } CamStreamType; -struct _Camera_Event_Handler_Input +struct CAMEventData { CAMError err; void *img; void *arg; // user provided value ?? }; -WUT_CHECK_SIZE(_Camera_Event_Handler_Input, 0x0C); +WUT_CHECK_SIZE(CAMEventData, 0x0C); -typedef void(*CAMEventHandler)(_Camera_Event_Handler_Input*); +typedef void(*CAMEventHandler)(CAMEventData*); struct CAMMode { @@ -100,15 +99,17 @@ struct CAMSetupInfo { CAMStreamInfo streamInfo; CAMWorkMem workMem; - WUT_UNKNOWN_BYTES(8); + CAMEventHandler eventHandler; + WUT_UNKNOWN_BYTES(4); CAMMode mode; - int threadAffinity; // which cpu core to run on, only known value is CAM_THREAD_AFFINITY_ANY - WUT_UNKNOWN_BYTES(0x10); + OSThreadAttributes threadAttribute; + WUT_UNKNOWN_BYTES(0x13); }; WUT_CHECK_OFFSET(CAMSetupInfo, 0x00, streamInfo); WUT_CHECK_OFFSET(CAMSetupInfo, 0x0C, workMem); +WUT_CHECK_OFFSET(CAMSetupInfo, 0x14, eventHandler); WUT_CHECK_OFFSET(CAMSetupInfo, 0x1C, mode); -WUT_CHECK_OFFSET(CAMSetupInfo, 0x24, threadAffinity); +WUT_CHECK_OFFSET(CAMSetupInfo, 0x24, threadAttribute); WUT_CHECK_SIZE(CAMSetupInfo, 0x38); struct CAMSurface From 4824a80fabf0c861e7a0ab10aa48f0b6f591fe69 Mon Sep 17 00:00:00 2001 From: Fangal-Airbag <77993079+Fangal-Airbag@users.noreply.github.com> Date: Sun, 30 Oct 2022 17:22:10 -0400 Subject: [PATCH 4/4] Update camera.h --- include/camera/camera.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/camera/camera.h b/include/camera/camera.h index f2bf2485e..a50341f77 100644 --- a/include/camera/camera.h +++ b/include/camera/camera.h @@ -39,7 +39,7 @@ typedef enum CamError CAMERA_ERROR_INVALID_HANDLE = -2, CAMERA_ERROR_INSUFFICIENT_MEMORY = -5, CAMERA_ERROR_NOT_READY = -6, - CAMERA_ERROR_UNIINITIALIZED = -8, + CAMERA_ERROR_UNINITIALIZED = -8, CAMERA_ERROR_UNKNOWN = -10, CAMERA_ERROR_DEVICE_IN_USE = -12, CAMERA_ERROR_SEGMENT_VIOLATION = -14 @@ -102,14 +102,15 @@ struct CAMSetupInfo CAMEventHandler eventHandler; WUT_UNKNOWN_BYTES(4); CAMMode mode; - OSThreadAttributes threadAttribute; - WUT_UNKNOWN_BYTES(0x13); + //! See \link OS_THREAD_ATTRIB \endlink + uint32_t threadAffinity; + WUT_UNKNOWN_BYTES(0x10); }; WUT_CHECK_OFFSET(CAMSetupInfo, 0x00, streamInfo); WUT_CHECK_OFFSET(CAMSetupInfo, 0x0C, workMem); WUT_CHECK_OFFSET(CAMSetupInfo, 0x14, eventHandler); WUT_CHECK_OFFSET(CAMSetupInfo, 0x1C, mode); -WUT_CHECK_OFFSET(CAMSetupInfo, 0x24, threadAttribute); +WUT_CHECK_OFFSET(CAMSetupInfo, 0x24, threadAffinity); WUT_CHECK_SIZE(CAMSetupInfo, 0x38); struct CAMSurface @@ -152,7 +153,7 @@ CAMError CAMSubmitTargetSurface(CAMHandle handle, CAMSurface *surface); CAMError -CAMCheckMemSegmentation(void *pMem, unsigned int size); +CAMCheckMemSegmentation(void *pMem, uint32_t size); #ifdef __cplusplus }