Skip to content

Commit

Permalink
Implement some services from gsp::Lcd.
Browse files Browse the repository at this point in the history
  • Loading branch information
thedax committed Sep 30, 2015
1 parent 6590ed3 commit 7bad79e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libctru/include/3ds/services/gsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
35 changes: 35 additions & 0 deletions libctru/source/services/gsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

0 comments on commit 7bad79e

Please sign in to comment.