diff --git a/libctru/include/3ds/services/gsp.h b/libctru/include/3ds/services/gsp.h index e65245d..a0d8bed 100644 --- a/libctru/include/3ds/services/gsp.h +++ b/libctru/include/3ds/services/gsp.h @@ -48,9 +48,19 @@ typedef enum GSPEVENT_MAX, // used to know how many events there are } GSP_Event; +typedef enum +{ + GSPLCD_TOP = BIT(0), + GSPLCD_BOTTOM = BIT(1), + GSPLCD_BOTH = GSPLCD_TOP | GSPLCD_BOTTOM, +}GSPLCD_Screens; + 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 +89,6 @@ 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); + +Result GSPLCD_PowerOffBacklight(GSPLCD_Screens screen); +Result GSPLCD_PowerOnBacklight(GSPLCD_Screens screen); diff --git a/libctru/source/services/gsp.c b/libctru/source/services/gsp.c index 4dcfadf..c3a4461 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,39 @@ 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(GSPLCD_Screens screen) +{ + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = 0x00120040; + cmdbuf[1] = screen; + + Result ret=0; + if ((ret = svcSendSyncRequest(gspLcdHandle)))return ret; + + return cmdbuf[1]; +} + +Result GSPLCD_PowerOnBacklight(GSPLCD_Screens screen) +{ + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = 0x00110040; + cmdbuf[1] = screen; + + Result ret=0; + if ((ret = svcSendSyncRequest(gspLcdHandle)))return ret; + + return cmdbuf[1]; +}