Irs stylefix

This commit is contained in:
plutoo 2018-03-10 14:48:15 +01:00
parent 1d34db8497
commit 965c7cdd47
2 changed files with 35 additions and 35 deletions

View File

@ -23,7 +23,7 @@ typedef struct {
u8 unk_x1c; u8 unk_x1c;
u8 unk_x1d; u8 unk_x1d;
u8 pad2[2]; u8 pad2[2];
} PACKED irsPackedMomentProcessorConfig; } PACKED IrsPackedMomentProcessorConfig;
typedef struct { typedef struct {
u64 exposure; ///< IR Sensor exposure time in nanoseconds. u64 exposure; ///< IR Sensor exposure time in nanoseconds.
@ -32,7 +32,7 @@ typedef struct {
u8 color_invert; ///< Inverts the colors of the captured image. 0: Normal image, 1: Negative image. u8 color_invert; ///< Inverts the colors of the captured image. 0: Normal image, 1: Negative image.
u8 pad[7]; u8 pad[7];
u32 sensor_res; ///< IR Sensor resolution. 0: 240x320, 1: 120x160, 2: 60x80. u32 sensor_res; ///< IR Sensor resolution. 0: 240x320, 1: 120x160, 2: 60x80.
} irsImageTransferProcessorConfig; } IrsImageTransferProcessorConfig;
typedef struct { typedef struct {
u64 exposure; ///< IR Sensor exposure time in nanoseconds. u64 exposure; ///< IR Sensor exposure time in nanoseconds.
@ -43,11 +43,11 @@ typedef struct {
u32 unk_constant;//offset 0x10 u32 unk_constant;//offset 0x10
u8 sensor_res; ///< IR Sensor resolution. 0: 240x320, 1: 120x160, 2: 60x80. u8 sensor_res; ///< IR Sensor resolution. 0: 240x320, 1: 120x160, 2: 60x80.
u8 pad2[3]; u8 pad2[3];
} irsPackedImageTransferProcessorConfig; } IrsPackedImageTransferProcessorConfig;
typedef struct { typedef struct {
u8 unk_x0[0x10]; u8 unk_x0[0x10];
} PACKED irsImageTransferProcessorState; } PACKED IrsImageTransferProcessorState;
Result irsInitialize(void); Result irsInitialize(void);
void irsExit(void); void irsExit(void);
@ -67,9 +67,9 @@ Result irsGetIrCameraHandle(u32 *IrCameraHandle, HidControllerID id);
* @param[in] size Work-buffer size, must be 0x1000-byte aligned. * @param[in] size Work-buffer size, must be 0x1000-byte aligned.
* @note Do not use if already started. * @note Do not use if already started.
*/ */
Result irsRunImageTransferProcessor(u32 IrCameraHandle, irsImageTransferProcessorConfig *config, size_t size); Result irsRunImageTransferProcessor(u32 IrCameraHandle, IrsImageTransferProcessorConfig *config, size_t size);
Result irsGetImageTransferProcessorState(u32 IrCameraHandle, void* buffer, size_t size, irsImageTransferProcessorState *state); Result irsGetImageTransferProcessorState(u32 IrCameraHandle, void* buffer, size_t size, IrsImageTransferProcessorState *state);
/// Stop ImageTransferProcessor. Do not use if already stopped. /// Stop ImageTransferProcessor. Do not use if already stopped.
/// \ref irsExit calls this with all IrCameraHandles which were not already used with \ref irsStopImageProcessor. /// \ref irsExit calls this with all IrCameraHandles which were not already used with \ref irsStopImageProcessor.
@ -83,4 +83,4 @@ Result irsSuspendImageProcessor(u32 IrCameraHandle);
* Gets the default configuration for Image Transfer mode. * Gets the default configuration for Image Transfer mode.
* Defaults are exposure 300us, IR LEDs all ON, 8x digital gain, normal image and resolution 240 x 320. * Defaults are exposure 300us, IR LEDs all ON, 8x digital gain, normal image and resolution 240 x 320.
*/ */
void irsGetDefaultImageTransferProcessorConfig(irsImageTransferProcessorConfig *config); void irsGetDefaultImageTransferProcessorConfig(IrsImageTransferProcessorConfig *config);

View File

@ -14,14 +14,14 @@ typedef struct {
bool initialized; bool initialized;
u32 IrCameraHandle; u32 IrCameraHandle;
TransferMemory transfermem; TransferMemory transfermem;
} irsCameraEntry; } IrsCameraEntry;
static Service g_irsSrv; static Service g_irsSrv;
static u64 g_refCnt; static u64 g_refCnt;
static SharedMemory g_irsSharedmem; static SharedMemory g_irsSharedmem;
static bool g_irsSensorActivated; static bool g_irsSensorActivated;
static irsCameraEntry g_irsCameras[8]; static IrsCameraEntry g_irsCameras[8];
static Result _irsGetIrsensorSharedMemoryHandle(Handle* handle_out, u64 AppletResourceUserId); static Result _irsGetIrsensorSharedMemoryHandle(Handle* handle_out, u64 AppletResourceUserId);
@ -66,8 +66,8 @@ void irsExit(void)
{ {
if (atomicDecrement64(&g_refCnt) == 0) if (atomicDecrement64(&g_refCnt) == 0)
{ {
size_t entrycount = sizeof(g_irsCameras)/sizeof(irsCameraEntry); size_t entrycount = sizeof(g_irsCameras)/sizeof(IrsCameraEntry);
irsCameraEntry *entry; IrsCameraEntry *entry;
int i; int i;
for(i=0; i<entrycount; i++) { for(i=0; i<entrycount; i++) {
@ -83,11 +83,11 @@ void irsExit(void)
} }
} }
static Result _irsCameraEntryAlloc(u32 IrCameraHandle, irsCameraEntry **out_entry) { static Result _IrsCameraEntryAlloc(u32 IrCameraHandle, IrsCameraEntry **out_entry) {
int i; int i;
size_t entrycount = sizeof(g_irsCameras)/sizeof(irsCameraEntry); size_t entrycount = sizeof(g_irsCameras)/sizeof(IrsCameraEntry);
int empty_entry = -1; int empty_entry = -1;
irsCameraEntry *entry; IrsCameraEntry *entry;
if (out_entry) *out_entry = NULL; if (out_entry) *out_entry = NULL;
@ -114,10 +114,10 @@ static Result _irsCameraEntryAlloc(u32 IrCameraHandle, irsCameraEntry **out_entr
return 0; return 0;
} }
static Result _irsCameraEntryGet(u32 IrCameraHandle, irsCameraEntry **out_entry) { static Result _IrsCameraEntryGet(u32 IrCameraHandle, IrsCameraEntry **out_entry) {
int i; int i;
size_t entrycount = sizeof(g_irsCameras)/sizeof(irsCameraEntry); size_t entrycount = sizeof(g_irsCameras)/sizeof(IrsCameraEntry);
irsCameraEntry *entry; IrsCameraEntry *entry;
*out_entry = NULL; *out_entry = NULL;
for(i=0; i<entrycount; i++) { for(i=0; i<entrycount; i++) {
@ -131,9 +131,9 @@ static Result _irsCameraEntryGet(u32 IrCameraHandle, irsCameraEntry **out_entry)
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
} }
static void _irsCameraEntryFree(irsCameraEntry *entry) { static void _IrsCameraEntryFree(IrsCameraEntry *entry) {
tmemClose(&entry->transfermem); tmemClose(&entry->transfermem);
memset(entry, 0, sizeof(irsCameraEntry)); memset(entry, 0, sizeof(IrsCameraEntry));
} }
Service* irsGetSessionService(void) { Service* irsGetSessionService(void) {
@ -269,7 +269,7 @@ static Result _irsStopImageProcessor(u32 IrCameraHandle, u64 AppletResourceUserI
Result irsStopImageProcessor(u32 IrCameraHandle) { Result irsStopImageProcessor(u32 IrCameraHandle) {
Result rc=0; Result rc=0;
u64 AppletResourceUserId=0; u64 AppletResourceUserId=0;
irsCameraEntry *entry = NULL; IrsCameraEntry *entry = NULL;
if (!serviceIsActive(&g_irsSrv)) if (!serviceIsActive(&g_irsSrv))
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
@ -278,7 +278,7 @@ Result irsStopImageProcessor(u32 IrCameraHandle) {
if (R_FAILED(rc)) if (R_FAILED(rc))
return rc; return rc;
rc = _irsCameraEntryGet(IrCameraHandle, &entry); rc = _IrsCameraEntryGet(IrCameraHandle, &entry);
if (R_FAILED(rc)) if (R_FAILED(rc))
return rc; return rc;
@ -286,11 +286,11 @@ Result irsStopImageProcessor(u32 IrCameraHandle) {
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
rc = _irsStopImageProcessor(IrCameraHandle, AppletResourceUserId); rc = _irsStopImageProcessor(IrCameraHandle, AppletResourceUserId);
_irsCameraEntryFree(entry); _IrsCameraEntryFree(entry);
return rc; return rc;
} }
static Result _irsRunImageTransferProcessor(u32 IrCameraHandle, u64 AppletResourceUserId, irsPackedImageTransferProcessorConfig *config, Handle transfermem, u64 transfermem_size) { static Result _irsRunImageTransferProcessor(u32 IrCameraHandle, u64 AppletResourceUserId, IrsPackedImageTransferProcessorConfig *config, Handle transfermem, u64 transfermem_size) {
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
@ -299,7 +299,7 @@ static Result _irsRunImageTransferProcessor(u32 IrCameraHandle, u64 AppletResour
u64 cmd_id; u64 cmd_id;
u32 IrCameraHandle; u32 IrCameraHandle;
u64 AppletResourceUserId; u64 AppletResourceUserId;
irsPackedImageTransferProcessorConfig config; IrsPackedImageTransferProcessorConfig config;
u64 TransferMemory_size; u64 TransferMemory_size;
} *raw; } *raw;
@ -333,11 +333,11 @@ static Result _irsRunImageTransferProcessor(u32 IrCameraHandle, u64 AppletResour
return rc; return rc;
} }
Result irsRunImageTransferProcessor(u32 IrCameraHandle, irsImageTransferProcessorConfig *config, size_t size) { Result irsRunImageTransferProcessor(u32 IrCameraHandle, IrsImageTransferProcessorConfig *config, size_t size) {
Result rc=0; Result rc=0;
u64 AppletResourceUserId=0; u64 AppletResourceUserId=0;
irsCameraEntry *entry = NULL; IrsCameraEntry *entry = NULL;
irsPackedImageTransferProcessorConfig packed_config; IrsPackedImageTransferProcessorConfig packed_config;
memset(&packed_config, 0, sizeof(packed_config)); memset(&packed_config, 0, sizeof(packed_config));
@ -352,7 +352,7 @@ Result irsRunImageTransferProcessor(u32 IrCameraHandle, irsImageTransferProcesso
if (R_FAILED(rc)) if (R_FAILED(rc))
return rc; return rc;
rc = _irsCameraEntryAlloc(IrCameraHandle, &entry); rc = _IrsCameraEntryAlloc(IrCameraHandle, &entry);
if (R_FAILED(rc)) if (R_FAILED(rc))
return rc; return rc;
@ -361,12 +361,12 @@ Result irsRunImageTransferProcessor(u32 IrCameraHandle, irsImageTransferProcesso
rc = _irsRunImageTransferProcessor(IrCameraHandle, AppletResourceUserId, &packed_config, entry->transfermem.handle, size); rc = _irsRunImageTransferProcessor(IrCameraHandle, AppletResourceUserId, &packed_config, entry->transfermem.handle, size);
if (R_FAILED(rc)) _irsCameraEntryFree(entry); if (R_FAILED(rc)) _IrsCameraEntryFree(entry);
return rc; return rc;
} }
static Result _irsGetImageTransferProcessorState(u32 IrCameraHandle, u64 AppletResourceUserId, void* buffer, size_t size, irsImageTransferProcessorState *state) { static Result _irsGetImageTransferProcessorState(u32 IrCameraHandle, u64 AppletResourceUserId, void* buffer, size_t size, IrsImageTransferProcessorState *state) {
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
@ -396,19 +396,19 @@ static Result _irsGetImageTransferProcessorState(u32 IrCameraHandle, u64 AppletR
struct { struct {
u64 magic; u64 magic;
u64 result; u64 result;
irsImageTransferProcessorState state; IrsImageTransferProcessorState state;
} *resp = r.Raw; } *resp = r.Raw;
rc = resp->result; rc = resp->result;
if (R_SUCCEEDED(rc) && state) if (R_SUCCEEDED(rc) && state)
memcpy(state, &resp->state, sizeof(irsImageTransferProcessorState)); memcpy(state, &resp->state, sizeof(IrsImageTransferProcessorState));
} }
return rc; return rc;
} }
Result irsGetImageTransferProcessorState(u32 IrCameraHandle, void* buffer, size_t size, irsImageTransferProcessorState *state) { Result irsGetImageTransferProcessorState(u32 IrCameraHandle, void* buffer, size_t size, IrsImageTransferProcessorState *state) {
Result rc=0; Result rc=0;
u64 AppletResourceUserId=0; u64 AppletResourceUserId=0;
@ -420,8 +420,8 @@ Result irsGetImageTransferProcessorState(u32 IrCameraHandle, void* buffer, size_
return rc; return rc;
} }
void irsGetDefaultImageTransferProcessorConfig(irsImageTransferProcessorConfig *config) { void irsGetDefaultImageTransferProcessorConfig(IrsImageTransferProcessorConfig *config) {
memset(config, 0, sizeof(irsImageTransferProcessorConfig)); memset(config, 0, sizeof(IrsImageTransferProcessorConfig));
config->exposure = 300000; config->exposure = 300000;
config->ir_leds = 0; config->ir_leds = 0;