Last active
November 30, 2021 20:38
-
-
Save averne/4ff4af8074b1009f3195cf79693bd041 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <switch.h> | |
void __libnx_initheap(void) { } | |
void __appInit(void) { } | |
void __appExit(void) { } | |
#define DISP_IO_BASE 0x54200000 | |
#define DISP_IO_SIZE (8 * 0x1000) | |
#define DC_CMD_INT_ENABLE 0xe4 | |
# define CMU_LUT_CONFLICT_INT_ENABLE (1 << 22) | |
#define DC_CMD_STATE_CONTROL 0x104 | |
# define GENERAL_ACT_REQ (1 << 0) | |
# define WIN_A_ACT_REQ (1 << 1) | |
# define WIN_B_ACT_REQ (1 << 2) | |
# define WIN_C_ACT_REQ (1 << 3) | |
# define WIN_D_ACT_REQ (1 << 4) | |
# define CURSOR_ACT_REQ (1 << 7) | |
# define GENERAL_UPDATE (1 << 8) | |
# define WIN_A_UPDATE (1 << 9) | |
# define WIN_B_UPDATE (1 << 10) | |
# define WIN_C_UPDATE (1 << 11) | |
# define WIN_D_UPDATE (1 << 12) | |
# define CURSOR_UPDATE (1 << 15) | |
# define NC_HOST_TRIG_ENABLE (1 << 24) | |
#define DC_COM_CMU_CSC_KRR 0xca8 | |
#define DC_COM_CMU_CSC_KGR 0xcac | |
#define DC_COM_CMU_CSC_KBR 0xcb0 | |
#define DC_COM_CMU_CSC_KRG 0xcb4 | |
#define DC_COM_CMU_CSC_KGG 0xcb8 | |
#define DC_COM_CMU_CSC_KBG 0xcbc | |
#define DC_COM_CMU_CSC_KRB 0xcc0 | |
#define DC_COM_CMU_CSC_KGB 0xcc4 | |
#define DC_COM_CMU_CSC_KBB 0xcc8 | |
#define DC_DISP_DISP_COLOR_CONTROL 0x10c0 | |
# define DISP_COLOR_SWAP (1 << 16) | |
# define BLANK_COLOR (1 << 17) | |
# define NON_BASE_COLOR (1 << 18) | |
# define CMU_ENABLE (1 << 20) | |
int main(int argc, char **argv) { | |
Result rc; | |
uint64_t mmio_base, mmio_size; | |
rc = svcQueryIoMapping(&mmio_base, &mmio_size, DISP_IO_BASE, DISP_IO_SIZE); | |
if (R_FAILED(rc)) | |
diagAbortWithResult(rc); | |
rc = svcSetThreadPriority(CUR_THREAD_HANDLE, 0x3f); | |
if (R_FAILED(rc)) | |
diagAbortWithResult(rc); | |
while (true) { | |
svcSleepThread(1e9); | |
uint32_t interrupts = *(volatile uint32_t *)(mmio_base + DC_CMD_INT_ENABLE); | |
interrupts &= ~CMU_LUT_CONFLICT_INT_ENABLE; | |
*(volatile uint32_t *)(mmio_base + DC_CMD_INT_ENABLE) = interrupts; | |
uint32_t color_control = *(volatile uint32_t *)(mmio_base + DC_DISP_DISP_COLOR_CONTROL); | |
color_control &= ~CMU_ENABLE; | |
*(volatile uint32_t *)(mmio_base + DC_DISP_DISP_COLOR_CONTROL) = color_control; | |
*(volatile uint32_t *)(mmio_base + DC_CMD_STATE_CONTROL) = GENERAL_ACT_REQ; | |
for (int i = 0; i < 9; ++i) { | |
volatile uint32_t test = *(volatile uint32_t *)(mmio_base + DC_COM_CMU_CSC_KRR + i * sizeof(uint32_t)); | |
(void)test; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment