diff --git a/libctru/include/3ds/services/gsp.h b/libctru/include/3ds/services/gsp.h index e65245d..e80effc 100644 --- a/libctru/include/3ds/services/gsp.h +++ b/libctru/include/3ds/services/gsp.h @@ -51,6 +51,9 @@ typedef enum Result gspInit(); void gspExit(); +Result gspLcdInit(); +void gspLcdExit(); + Result gspInitEventHandler(Handle gspEvent, vu8* gspSharedMem, u8 gspThreadId); void gspExitEventHandler(); void gspWaitForEvent(GSP_Event id, bool nextEvent); @@ -79,3 +82,7 @@ Result GSPGPU_RegisterInterruptRelayQueue(Handle *handle, Handle eventHandle, u3 Result GSPGPU_UnregisterInterruptRelayQueue(Handle* handle); Result GSPGPU_TriggerCmdReqQueue(Handle *handle); Result GSPGPU_SubmitGxCommand(u32* sharedGspCmdBuf, u32 gxCommand[0x8], Handle* handle); + +// 1 = top, 2 = bottom, 3 = both +Result GSPLCD_PowerOffBacklight(u32 screen); +Result GSPLCD_PowerOnBacklight(u32 screen); diff --git a/libctru/source/services/gsp.c b/libctru/source/services/gsp.c index 4dcfadf..881a8ef 100644 --- a/libctru/source/services/gsp.c +++ b/libctru/source/services/gsp.c @@ -12,6 +12,7 @@ #define GSP_EVENT_STACK_SIZE 0x1000 Handle gspGpuHandle=0; +Handle gspLcdHandle=0; Handle gspEvents[GSPEVENT_MAX]; vu32 gspEventCounts[GSPEVENT_MAX]; u64 gspEventStack[GSP_EVENT_STACK_SIZE/sizeof(u64)]; //u64 so that it's 8-byte aligned @@ -431,3 +432,37 @@ Result GSPGPU_SubmitGxCommand(u32* sharedGspCmdBuf, u32 gxCommand[0x8], Handle* if(totalCommands==1)return GSPGPU_TriggerCmdReqQueue(handle); return 0; } + +Result gspLcdInit() +{ + return srvGetServiceHandle(&gspLcdHandle, "gsp::Lcd"); +} + +void gspLcdExit() +{ + if(gspLcdHandle)svcCloseHandle(gspLcdHandle); +} + +Result GSPLCD_PowerOffBacklight(u32 screen) +{ + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = 0x00120040; + cmdbuf[1] = screen; + + Result ret = svcSendSyncRequest(gspLcdHandle); + + return ret; +} + +Result GSPLCD_PowerOnBacklight(u32 screen) +{ + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = 0x00110040; + cmdbuf[1] = screen; + + Result ret = svcSendSyncRequest(gspLcdHandle); + + return ret; +}