From e3bdc356f1bc7a07ab67114982b780c9adf91717 Mon Sep 17 00:00:00 2001 From: devnoname120 Date: Tue, 11 Apr 2017 04:24:33 +0200 Subject: [PATCH] Semi-working Attempted to directly set the hardware registers but that doesn't work --- CMakeLists.txt | 3 +- extra/extra.yml | 9 +++ extra/libSceDisplayForDriver_stub.a | Bin 0 -> 1074 bytes main.c | 85 +++++++++++++++++++++++++--- 4 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 extra/extra.yml create mode 100644 extra/libSceDisplayForDriver_stub.a diff --git a/CMakeLists.txt b/CMakeLists.txt index 80f3968..2f72632 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ endif() project(vitabright) include("${VITASDK}/share/vita.cmake" REQUIRED) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -std=gnu99") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O0 -std=gnu99") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions") include_directories( @@ -28,6 +28,7 @@ add_executable(vitabright target_link_libraries(vitabright + ${CMAKE_SOURCE_DIR}/extra/libSceDisplayForDriver_stub.a taihenForKernel_stub SceIofilemgrForDriver_stub #k diff --git a/extra/extra.yml b/extra/extra.yml new file mode 100644 index 0000000..06fdb55 --- /dev/null +++ b/extra/extra.yml @@ -0,0 +1,9 @@ +modules: + SceDisplay: + nid: 0x3F05296F + libraries: + SceDisplayForDriver: + functions: + SceDisplayForDriver_0x9E3C6DC6: 0x9E3C6DC6 + kernel: true + nid: 0x9FED47AC diff --git a/extra/libSceDisplayForDriver_stub.a b/extra/libSceDisplayForDriver_stub.a new file mode 100644 index 0000000000000000000000000000000000000000..ded5e64827de8685ba87a5397415f69e6dec9e75 GIT binary patch literal 1074 zcmah{OH0E*5S|#THh54$5cCj1(1UDK45#FL_)SP*=Qu<)jl6dwhxwSFxO_A_ zD;Y*9J8{xgy^3n4Md+hY zW*?Vc@19QPZsE;*c1Mxs0rx}D1`!r2F7z0^Zl6}{$_i4DPnE>`hZ@&AP641pXSt4y zDmrw-kV>FGjDCN{b!SKd9SSg_FhiIROWs;z*K?N}-rmOg*3LFe9KZyJzgGaj;_DN^ zeY7G<>=7XmTnS(YTyS8190R)y1#g9?$Luf`7kT4h{_DD*Ex5G$wr8_K7b zZ`zZlB|FP&=)K3&JbJ<3@+L7)Zu`Hy>9ilsT|j>Tm4xsn64>jU_zeVO= 0; j -= 2) + { + turnon_oled(4, j); + for (int k = 0; k < 0x1000000; k++); + } +} + + + int get_max_brightness(uint *brightness) { int ret = TAI_CONTINUE(int, hook_get_max_brightness, brightness); @@ -23,22 +70,44 @@ int get_max_brightness(uint *brightness) int set_brightness(uint brightness) { - // Min: 21, Max: 65536 - uint mod_brightness = (brightness-15)*(65536)/(65536-15); - //uint mod_brightness = (brightness + 10000); - int ret = TAI_CONTINUE(uint, hook_set_brightness, mod_brightness); - LOG("set_brightness(%u) = %d, corrected to %u\n", brightness, ret, mod_brightness); - return ret; + uint mod_brightness; + + if (brightness < 100) + mod_brightness = 1; + else + mod_brightness = (brightness-19)*(65536)/(65536-19); + //int ret = TAI_CONTINUE(uint, hook_set_brightness, mod_brightness); + + //int intensity = (char)((brightness-20)*256/(65536-20)); + LOG("set_brightness(%u), corrected to %u\n", brightness, mod_brightness); + + SceDisplayForDriver_0x9E3C6DC6(0, mod_brightness); + + //brightness_adjust(); + //turnon_oled(4, intensity); + + return 0; } int module_start(SceSize argc, const void *args) { - log_reset(); + 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); + + if (ret < 0) + LOG("GetMemBlock ret=0x%08X", ret); + LOG("vitabright started...\n"); - int ret = taiHookFunctionExportForKernel(KERNEL_PID, &hook_get_max_brightness, + ret = taiHookFunctionExportForKernel(KERNEL_PID, &hook_get_max_brightness, "SceAVConfig", TAI_ANY_LIBRARY, 0x6ABA67F4,