Skip to content

Instantly share code, notes, and snippets.

@devnoname120
Created July 12, 2017 17:47
Show Gist options
  • Save devnoname120/63c08f125258210899ddb31a6d43e02b to your computer and use it in GitHub Desktop.
Save devnoname120/63c08f125258210899ddb31a6d43e02b to your computer and use it in GitHub Desktop.
Yifan oled brightness
#define DEVICE_BASE (0xE0000000)
#define IFTU0_BASE (DEVICE_BASE + 0x5020000)
uint *iftu0_base = NULL;
static inline void turnon_oled(int a2, int a3)
{
if (a2 == 128)
{
*(iftu0_base + 0x2000 + 32) = 0;
*(iftu0_base + 0x2000 + 4) &= ~1;
}
else
{
*(iftu0_base + 0x2000 + 32) = a2;
*(iftu0_base + 0x2000 + 4) |= 1;
}
if (a3 == 256)
{
*(iftu0_base + 0x1000 + 160) = 1;
}
else
{
*(iftu0_base + 0x1000 + 140) = a3;
*(iftu0_base + 0x1000 + 160) = 0;
}
}
int brightness_adjust(void)
{
for (int j = 0; j < 256; j += 2)
{
turnon_oled(4, j);
for (int k = 0; k < 0x1000000; k++);
}
turnon_oled(128, 0);
for (int j = 254; j >= 0; j -= 2)
{
turnon_oled(4, j);
for (int k = 0; k < 0x1000000; k++);
}
}
int main() {
SceKernelAllocMemBlockKernelOpt opt = {0};
opt.size = sizeof(opt);
opt.attr = 2;
opt.paddr = IFTU0_BASE;
int payload_block = ksceKernelAllocMemBlock("hw_regs", 0x20100206, 0x3000, &opt); // Need 0x2032 but it has to be page-aligned so 0x3000
if (payload_block < 0)
LOG("AllocMemBlock ret=0x%08X", payload_block);
int ret = ksceKernelGetMemBlockBase(payload_block, (void**)&iftu0_base);
// Call the functions on the mapped address
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment