diff --git a/README.md b/README.md index 04f0094..2d20e70 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,11 @@ on top of MinUI. - Add to Favorites - Clear "Recently Played" -- Battery efficiency improvements +- Power saving improvements - Performance improvements +- Multi-core CPU support - Battery reading adjustments +- Additional emulators (MAME) - Base and Extras are merged into one Full release - Native macOS installation instructions - Developer experience improvements @@ -52,14 +54,15 @@ on top of MinUI. ### Build project -Run `./start-toolchain.sh` and then `make all` in the Docker container shell. +Run `./start-toolchain.sh` and then run `make all` in the Docker container shell. -### TODO +### Debug project -- Improve battery capacity reading accuracy -- Show battery percentage number overlay -- Change boot logo -- [...things in the old todo?...](./todo.txt) +Create a file with the name `enableADB` on the `misc` disk to enable ADB. + +### Install release + +Update `DISK_PATH` and then run `./install-release.sh`. ## Disclaimer diff --git a/cores/makefile b/cores/makefile index 15aa89c..14f9d01 100644 --- a/cores/makefile +++ b/cores/makefile @@ -1,7 +1,7 @@ # this logic was broken out from picoarch's all-in-one makefile CORES = fceumm gambatte gpsp pcsx_rearmed picodrive snes9x2005_plus -CORES+= beetle-pce-fast beetle-vb mednafen_supafaust mgba pokemini # extras +CORES+= beetle-pce-fast beetle-vb fake-08 mednafen_supafaust mgba pokemini mame2003-plus race # extras ############################### @@ -19,13 +19,20 @@ beetle-pce-fast_CORE = mednafen_pce_fast_libretro.so beetle-vb_REPO = https://github.com/libretro/beetle-vb-libretro beetle-vb_CORE = mednafen_vb_libretro.so +fake-08_REPO = https://github.com/jtothebell/fake-08 +fake-08_CORE = fake08_libretro.so +fake-08_BUILD_PATH = fake-08/platform/libretro + fceumm_REPO = https://github.com/libretro/libretro-fceumm gambatte_REPO = https://github.com/libretro/gambatte-libretro +gpsp_HASH = 8745bf3 # last known working save states + mednafen_supafaust_REPO = https://github.com/libretro/supafaust pcsx_rearmed_MAKEFILE = Makefile.libretro +pcsx_rearmed_HASH = 672e715 # last known working build picodrive_REPO = https://github.com/irixxxx/picodrive picodrive_MAKEFILE = Makefile.libretro @@ -36,6 +43,9 @@ pokemini_MAKEFILE = Makefile.libretro snes9x2005_plus_REPO = https://github.com/libretro/snes9x2005 snes9x2005_plus_FLAGS = USE_BLARGG_APU=1 +mame2003-plus_REPO = https://github.com/libretro/mame2003-plus-libretro +mame2003-plus_CORE = mame2003_plus_libretro.so + ############################### PATCH = git apply diff --git a/cores/patches/fake-08.patch b/cores/patches/fake-08.patch new file mode 100755 index 0000000..dff15be --- /dev/null +++ b/cores/patches/fake-08.patch @@ -0,0 +1,34 @@ +diff --git forkSrcPrefix/platform/libretro/Makefile forkDstPrefix/platform/libretro/Makefile +index be0f1b46bb3ab10be4a9f896f5e8841dd630b35b..cc7a7249135bb690885e7f5fda09f9eb8fdeac22 100644 +--- forkSrcPrefix/platform/libretro/Makefile ++++ forkDstPrefix/platform/libretro/Makefile +@@ -123,7 +123,16 @@ else ifeq ($(platform), miyoomini) + CXXFLAGS += -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv7ve -D_NEED_FULL_PATH_ + fpic := -fPIC + SHARED := -shared -Wl,--version-script=link.T +- ++else ifeq ($(platform), rg35xx) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ STRIP = $(CROSS_COMPILE)strip ++ CXXFLAGS += -marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard -march=armv7-a ++ CXXFLAGS += -fomit-frame-pointer -ffast-math -fno-common -ftree-vectorize -funswitch-loops ++ fpic := -fPIC ++ SHARED := -shared -Wl,--version-script=link.T + else ifeq ($(platform), gcw0) + TARGET := $(TARGET_NAME)_libretro_gcw0.so + CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc +diff --git forkSrcPrefix/platform/libretro/libretro.cpp forkDstPrefix/platform/libretro/libretro.cpp +index d95ccb6cab52abfe7620ff84dd5cbb450bafe750..24687335ad410096aa48f29e13dcb479171a06fc 100644 +--- forkSrcPrefix/platform/libretro/libretro.cpp ++++ forkDstPrefix/platform/libretro/libretro.cpp +@@ -636,6 +636,7 @@ EXPORT bool retro_load_game(struct retro_game_info const *info) + else { + _vm->QueueCartChange(info->path); + } ++ _vm->UpdateAndDraw(); + + return true; + } diff --git a/cores/patches/mame2003-plus.patch b/cores/patches/mame2003-plus.patch new file mode 100644 index 0000000..fa90ad4 --- /dev/null +++ b/cores/patches/mame2003-plus.patch @@ -0,0 +1,35 @@ +diff --git a/Makefile b/Makefile +index 21129613..eaf61b92 100644 +--- a/Makefile ++++ b/Makefile +@@ -525,6 +525,30 @@ else ifeq ($(platform), miyoo) + PLATCFLAGS += -fomit-frame-pointer -march=armv5te -mtune=arm926ej-s -ffast-math + CXXFLAGS += -fno-rtti -fno-exceptions + ++# RG35XX ++else ifeq ($(platform), rg35xx) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ fpic := -fPIC ++ LDFLAGS += $(fpic) -shared -Wl,--version-script=link.T -Wl,-no-undefined ++ CFLAGS += -Ofast \ ++ -flto=4 -fwhole-program -fuse-linker-plugin \ ++ -fdata-sections -ffunction-sections -Wl,--gc-sections \ ++ -fno-stack-protector -fno-ident -fomit-frame-pointer \ ++ -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ ++ -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ ++ -fmerge-all-constants -fno-math-errno \ ++ -marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard ++ CXXFLAGS += $(CFLAGS) ++ CPPFLAGS += $(CFLAGS) ++ ASFLAGS += $(CFLAGS) ++ HAVE_NEON = 1 ++ ARCH = arm ++ CPU_ARCH := arm ++ ARM = 1 ++ + # Emscripten + else ifeq ($(platform), emscripten) + TARGET := $(TARGET_NAME)_libretro_$(platform).bc diff --git a/cores/patches/race.patch b/cores/patches/race.patch new file mode 100644 index 0000000..bf1af3d --- /dev/null +++ b/cores/patches/race.patch @@ -0,0 +1,23 @@ +diff --git forkSrcPrefix/Makefile forkDstPrefix/Makefile +index 792a6d82915c32edd3df6ceec541499f6ca25ac5..dc02b361d7db47e011b6d3addf89cfb31503575a 100644 +--- forkSrcPrefix/Makefile ++++ forkDstPrefix/Makefile +@@ -373,6 +373,18 @@ else ifeq ($(platform), miyoo) + CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s + CXXFLAGS += $(CFLAGS) + ++# RG35XX ++else ifeq ($(platform), rg35xx) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ fpic := -fPIC ++ SHARED := -shared -Wl,-version-script=$(LIBRETRO_DIR)/link.T ++ PLATFORM_DEFINES := -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS ++ CFLAGS += -fomit-frame-pointer -ffast-math -marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard -march=armv7-a ++ CXXFLAGS += $(CFLAGS) ++ + # Windows MSVC 2010 x64 + else ifeq ($(platform), windows_msvc2010_x64) + CC = cl.exe diff --git a/install-release.sh b/install-release.sh new file mode 100755 index 0000000..85e370a --- /dev/null +++ b/install-release.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -euo pipefail + +DISK_PATH="/dev/disk2" +FIRMWARE_NAME="35XX-64GB230309EN.IMG" +RELEASE_NAME="FinUI-*-0-full.zip" +WORKING_DIRECTORY="./releases/" + +echo "[*] PREPARING INSTALLATION" +cd $WORKING_DIRECTORY +echo + +echo "[*] INSTALLING FIRMWARE" +diskutil unmountDisk $DISK_PATH +sleep 3 + +sudo dd bs=1m if=$FIRMWARE_NAME of=$DISK_PATH +sleep 3 + +sudo diskutil eraseVolume FAT32 ROMS ${DISK_PATH}s4 +sleep 3 +echo + +echo "[*] INSTALLING FinUI" +unzip -o ${RELEASE_NAME[0]} + +cp -R dmenu.bin /Volumes/misc/ +cp -R MinUI.zip /Volumes/ROMS/ + +cp -R Bios/ /Volumes/ROMS/Bios +cp -R Emus/ /Volumes/ROMS/Emus +cp -R Roms/ /Volumes/ROMS/Roms +cp -R Saves/ /Volumes/ROMS/Saves +cp -R Tools/ /Volumes/ROMS/Tools +echo + +echo "[*] CLEANING FILES" +dot_clean -m /Volumes/misc +rm -fr /Volumes/misc/.fseventsd /Volumes/misc/.Spotlight-V100 /Volumes/misc/.Trashes /Volumes/misc/._.Trashes +mkdir /Volumes/misc/.fseventsd +touch /Volumes/misc/.fseventsd/no_log /Volumes/misc/.metadata_never_index /Volumes/misc/.Trashes + +dot_clean -m /Volumes/ROMS +rm -fr /Volumes/ROMS/.fseventsd /Volumes/ROMS/.Spotlight-V100 /Volumes/ROMS/.Trashes /Volumes/ROMS/._.Trashes +mkdir /Volumes/ROMS/.fseventsd +touch /Volumes/ROMS/.fseventsd/no_log /Volumes/ROMS/.metadata_never_index /Volumes/ROMS/.Trashes +echo diff --git a/makefile b/makefile index 5aca72c..7d19f19 100644 --- a/makefile +++ b/makefile @@ -14,7 +14,7 @@ endif BUILD_HASH!=git rev-parse --short HEAD -RELEASE_TIME!=date +%Y%m%d +RELEASE_TIME!=TZ=GMT date +%Y%m%d RELEASE_BASE=FinUI-$(RELEASE_TIME)b RELEASE_DOT!=find ./releases/. -regex ".*/$(RELEASE_BASE)-[0-9]+-base\.zip" -printf '.' | wc -m RELEASE_NAME=$(RELEASE_BASE)-$(RELEASE_DOT) @@ -26,7 +26,7 @@ endif # TODO: this needs to consider the different platforms, eg. rootfs.ext2 should only be copied in rg35xx-toolchain -all: lib sys all-cores tools bundle readmes zip report +all: lib sys all-cores tools dtb bundle readmes zip report repack: bundle readmes zip report @@ -49,6 +49,9 @@ tools: cd ./src/toggle_adb && make cd ./other/DinguxCommander && make -j +dtb: + cd ./src/dts/ && make + bundle: # ready build rm -rf ./build @@ -68,6 +71,9 @@ bundle: # populate system cp ~/buildroot/output/images/rootfs.ext2 ./build/SYSTEM/rg35xx + cp ./src/dts/kernel.dtb ./build/SYSTEM/rg35xx/dat + cp ./src/ramdisk/patched-ramdisk.img ./build/SYSTEM/rg35xx/dat/ramdisk.img + cp ./src/ramdisk/charging.png ./build/SYSTEM/rg35xx/dat/ cp ./src/libmsettings/libmsettings.so ./build/SYSTEM/rg35xx/lib cp ./src/keymon/keymon.elf ./build/SYSTEM/rg35xx/bin cp ./src/minarch/minarch.elf ./build/SYSTEM/rg35xx/bin @@ -86,12 +92,16 @@ bundle: cp ./cores/output/snes9x2005_plus_libretro.so ./build/SYSTEM/rg35xx/cores # extras + cp ./cores/output/mame2003_plus_libretro.so ./build/EXTRAS/Emus/rg35xx/MAME.pak + cp ./cores/output/fake08_libretro.so ./build/EXTRAS/Emus/rg35xx/P8.pak cp ./cores/output/mgba_libretro.so ./build/EXTRAS/Emus/rg35xx/MGBA.pak cp ./cores/output/mgba_libretro.so ./build/EXTRAS/Emus/rg35xx/SGB.pak cp ./cores/output/mednafen_pce_fast_libretro.so ./build/EXTRAS/Emus/rg35xx/PCE.pak cp ./cores/output/mednafen_supafaust_libretro.so ./build/EXTRAS/Emus/rg35xx/SUPA.pak cp ./cores/output/mednafen_vb_libretro.so ./build/EXTRAS/Emus/rg35xx/VB.pak cp ./cores/output/pokemini_libretro.so ./build/EXTRAS/Emus/rg35xx/PKM.pak + cp ./cores/output/race_libretro.so ./build/EXTRAS/Emus/rg35xx/NGP.pak + cp ./cores/output/race_libretro.so ./build/EXTRAS/Emus/rg35xx/NGPC.pak cp ./other/DinguxCommander/output/DinguxCommander ./build/EXTRAS/Tools/rg35xx/Files.pak cp -R ./other/DinguxCommander/res ./build/EXTRAS/Tools/rg35xx/Files.pak/ diff --git a/skeleton/EXTRAS/Roms/Game Gear (GG)/.keep b/skeleton/EXTRAS/Bios/MAME/.keep similarity index 100% rename from skeleton/EXTRAS/Roms/Game Gear (GG)/.keep rename to skeleton/EXTRAS/Bios/MAME/.keep diff --git a/skeleton/EXTRAS/Emus/rg35xx/GG.pak/default.cfg b/skeleton/EXTRAS/Emus/rg35xx/GG.pak/default.cfg index 393096e..2f3f583 100644 --- a/skeleton/EXTRAS/Emus/rg35xx/GG.pak/default.cfg +++ b/skeleton/EXTRAS/Emus/rg35xx/GG.pak/default.cfg @@ -17,4 +17,4 @@ bind Left = LEFT bind Right = RIGHT bind Button 1 = B bind Button 2 = A -bind Pause = START \ No newline at end of file +bind Pause = START diff --git a/skeleton/EXTRAS/Emus/rg35xx/MAME.pak/default.cfg b/skeleton/EXTRAS/Emus/rg35xx/MAME.pak/default.cfg new file mode 100644 index 0000000..0b21787 --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/MAME.pak/default.cfg @@ -0,0 +1,26 @@ +minarch_cpu_speed = Performance +minarch_prevent_tearing = Off + +mame2003-plus_skip_disclaimer = enabled +mame2003-plus_skip_warnings = enabled +-mame2003-plus_display_setup = disabled +-mame2003-plus_input_interface = retropad +-mame2003-plus_tate_mode = disabled +-mame2003-plus_xy_device = disabled +-mame2003-plus_display_artwork = disabled +-mame2003-plus_tate_mode = disabled + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Select = SELECT +bind Start = START +bind X Button = X +bind Y Button = Y +bind B Button = B +bind A Button = A +bind L1 Button = L1 +bind L2 Button = L2 +bind R1 Button = R1 +bind R2 Button = R2 diff --git a/skeleton/EXTRAS/Emus/rg35xx/MAME.pak/launch.sh b/skeleton/EXTRAS/Emus/rg35xx/MAME.pak/launch.sh new file mode 100755 index 0000000..a776940 --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/MAME.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=mame2003_plus +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" DMG &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/EXTRAS/Emus/rg35xx/NGP.pak/default.cfg b/skeleton/EXTRAS/Emus/rg35xx/NGP.pak/default.cfg new file mode 100644 index 0000000..bed4529 --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/NGP.pak/default.cfg @@ -0,0 +1,9 @@ +race_dark_filter_level = 50 + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind A Button = B +bind B Button = A +bind Option = START diff --git a/skeleton/EXTRAS/Emus/rg35xx/NGP.pak/launch.sh b/skeleton/EXTRAS/Emus/rg35xx/NGP.pak/launch.sh new file mode 100755 index 0000000..8e16b89 --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/NGP.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=race +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/EXTRAS/Emus/rg35xx/NGPC.pak/default.cfg b/skeleton/EXTRAS/Emus/rg35xx/NGPC.pak/default.cfg new file mode 100644 index 0000000..7f86f8e --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/NGPC.pak/default.cfg @@ -0,0 +1,8 @@ + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind A Button = B +bind B Button = A +bind Option = START diff --git a/skeleton/EXTRAS/Emus/rg35xx/NGPC.pak/launch.sh b/skeleton/EXTRAS/Emus/rg35xx/NGPC.pak/launch.sh new file mode 100755 index 0000000..8e16b89 --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/NGPC.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=race +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/EXTRAS/Emus/rg35xx/P8.pak/default.cfg b/skeleton/EXTRAS/Emus/rg35xx/P8.pak/default.cfg new file mode 100644 index 0000000..d74bfc7 --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/P8.pak/default.cfg @@ -0,0 +1,7 @@ +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind A Button = A +bind B Button = B +bind Start = START diff --git a/skeleton/EXTRAS/Emus/rg35xx/P8.pak/launch.sh b/skeleton/EXTRAS/Emus/rg35xx/P8.pak/launch.sh new file mode 100755 index 0000000..aac8158 --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/P8.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=fake08 +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/EXTRAS/Roms/Master System (SMS)/.keep b/skeleton/EXTRAS/Roms/Arcade (MAME)/.keep similarity index 100% rename from skeleton/EXTRAS/Roms/Master System (SMS)/.keep rename to skeleton/EXTRAS/Roms/Arcade (MAME)/.keep diff --git a/skeleton/EXTRAS/Roms/Neo Geo Pocket Color (NGPC)/.keep b/skeleton/EXTRAS/Roms/Neo Geo Pocket Color (NGPC)/.keep new file mode 100644 index 0000000..e69de29 diff --git a/skeleton/EXTRAS/Roms/Pico-8 (P8)/.keep b/skeleton/EXTRAS/Roms/Pico-8 (P8)/.keep new file mode 100644 index 0000000..e69de29 diff --git a/skeleton/EXTRAS/Roms/Sega Game Gear (GG)/.keep b/skeleton/EXTRAS/Roms/Sega Game Gear (GG)/.keep new file mode 100644 index 0000000..e69de29 diff --git a/skeleton/EXTRAS/Roms/Sega Master System (SMS)/.keep b/skeleton/EXTRAS/Roms/Sega Master System (SMS)/.keep new file mode 100644 index 0000000..e69de29 diff --git a/skeleton/EXTRAS/Saves/MAME/.keep b/skeleton/EXTRAS/Saves/MAME/.keep new file mode 100644 index 0000000..e69de29 diff --git a/skeleton/EXTRAS/Saves/P8/.keep b/skeleton/EXTRAS/Saves/P8/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/clear_recent/makefile b/src/clear_recent/makefile index 5fbc76d..c0d01f9 100644 --- a/src/clear_recent/makefile +++ b/src/clear_recent/makefile @@ -6,8 +6,8 @@ TARGET = clear_recent CC = $(CROSS_COMPILE)gcc CFLAGS = -Os -marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard -march=armv7-a -fomit-frame-pointer -CFLAGS += -I. -I../common -DPLATFORM=\"$(UNION_PLATFORM)\" -LDFLAGS = -ldl -lSDL -lSDL_image -lSDL_ttf -lmsettings -lpthread +CFLAGS += -I. -I../common -DPLATFORM=\"$(UNION_PLATFORM)\" -Ofast +LDFLAGS = -ldl -lSDL -lSDL_image -lSDL_ttf -lmsettings -lpthread -lm -lz all: $(CC) $(TARGET).c ../common/utils.c ../common/api.c -o $(TARGET).elf $(CFLAGS) $(LDFLAGS) diff --git a/src/clock/makefile b/src/clock/makefile index 71c416d..0497d92 100644 --- a/src/clock/makefile +++ b/src/clock/makefile @@ -6,8 +6,8 @@ TARGET = clock CC = $(CROSS_COMPILE)gcc CFLAGS = -Os -marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard -march=armv7-a -fomit-frame-pointer -CFLAGS += -I. -I../common -DPLATFORM=\"$(UNION_PLATFORM)\" -LDFLAGS = -ldl -lSDL -lSDL_image -lSDL_ttf -lmsettings -lpthread +CFLAGS += -I. -I../common -DPLATFORM=\"$(UNION_PLATFORM)\" -Ofast +LDFLAGS = -ldl -lSDL -lSDL_image -lSDL_ttf -lmsettings -lpthread -lm -lz all: $(CC) $(TARGET).c ../common/utils.c ../common/api.c -o $(TARGET).elf $(CFLAGS) $(LDFLAGS) diff --git a/src/common/api.c b/src/common/api.c index c816c16..212cbed 100644 --- a/src/common/api.c +++ b/src/common/api.c @@ -90,6 +90,7 @@ static void ion_alloc(int fd_ion, ion_alloc_info_t* info) { static void ion_free(int fd_ion, ion_alloc_info_t* info) { struct ion_handle_data ihd; munmap(info->vadd, info->size); + close(info->fd); ihd.handle = (uintptr_t)info->handle; if (ioctl(fd_ion, ION_IOC_FREE, &ihd)<0) fprintf(stderr, "ION_FREE failed %s\n",strerror(errno)); fflush(stdout); @@ -441,7 +442,12 @@ SDL_Surface* GFX_init(int mode) { font.medium = TTF_OpenFont(FONT_PATH, SCALE1(FONT_MEDIUM)); font.small = TTF_OpenFont(FONT_PATH, SCALE1(FONT_SMALL)); font.tiny = TTF_OpenFont(FONT_PATH, SCALE1(FONT_TINY)); - + + TTF_SetFontStyle(font.large, TTF_STYLE_BOLD); + TTF_SetFontStyle(font.medium, TTF_STYLE_BOLD); + TTF_SetFontStyle(font.small, TTF_STYLE_BOLD); + TTF_SetFontStyle(font.tiny, TTF_STYLE_BOLD); + return gfx.screen; } @@ -716,8 +722,8 @@ void GFX_blitClockAndBattery(SDL_Surface* dst, SDL_Rect* dst_rect) { clip.y = 0; GFX_blitAsset(percent<=20?ASSET_BATTERY_FILL_LOW:ASSET_BATTERY_FILL, &clip, dst, &(SDL_Rect){x+SCALE1(3)+clip.x,y+SCALE1(2)}); - } - + } + // Get the current time time_t currentTime = time(NULL); struct tm* timeinfo = localtime(¤tTime); @@ -1401,26 +1407,12 @@ static void POW_quitOverlay(void) { ioctl(gfx.fd_fb, OWLFB_OVERLAY_DISABLE, &pow.oargs); } -static int POW_readBatteryStatus(void) { - #define BATTERY_2100MAH 1 - #define BATTERY_2600MAH 2 - #define BATTERY_3500MAH 3 - #define UNKNOWN 9 +int POW_readBatteryStatus(void) { + #define READ_VOLTAGE 1 - int battery = BATTERY_2600MAH; // Default - int battery_txt = getInt(BATTERY_PATH); - if (battery_txt > 0) { - battery = battery_txt; - } - - int voltage_now = getInt("/sys/class/power_supply/battery/voltage_now"); - - if (battery == BATTERY_2100MAH) { + if (READ_VOLTAGE > 0) { + int voltage_now = getInt("/sys/class/power_supply/battery/voltage_now"); return ((voltage_now / 10000) - 310); // 310-410 - } else if (battery == BATTERY_2600MAH) { - return ((voltage_now / 10000) - 308); // 308-414? Seems incorrect... - } else if (battery == BATTERY_3500MAH) { - // ???-??? } // Fallback @@ -1560,22 +1552,20 @@ void POW_update(int* _dirty, int* _show_setting, POW_callback_t before_sleep, PO void POW_disablePowerOff(void) { pow.can_poweroff = 0; } -void POW_sync(char* msg) { - GFX_clear(gfx.screen); - GFX_blitMessage(font.large, msg, gfx.screen, NULL); - GFX_flip(gfx.screen); - - system("sync"); - system("echo s > /proc/sysrq-trigger"); - system("echo u > /proc/sysrq-trigger"); - system("sync"); - - sleep(2); -} void POW_powerOff(void) { if (pow.can_poweroff) { + GFX_resize(FIXED_WIDTH,FIXED_HEIGHT,FIXED_PITCH); + char* msg = exists(AUTO_RESUME_PATH) ? "Quicksave created,\npowering off" : "Powering off"; - POW_sync(msg); + GFX_blitMessage(font.large, msg, gfx.screen, NULL); + GFX_flip(gfx.screen); + + system("sync"); + system("echo s > /proc/sysrq-trigger"); + system("echo u > /proc/sysrq-trigger"); + system("sync"); + + sleep(2); // actual shutdown system("echo o > /proc/sysrq-trigger"); @@ -1583,12 +1573,11 @@ void POW_powerOff(void) { } void POW_reboot(void) { char* msg = "Rebooting"; - POW_sync(msg); - // trigger reboot + system("sync"); system("echo b > /proc/sysrq-trigger"); + system("sync"); } - #define BACKLIGHT_PATH "/sys/class/backlight/backlight.2/bl_power" void POW_setCPUSpeed(int speed) { diff --git a/src/common/defines.h b/src/common/defines.h index 9425713..9dbb8e3 100644 --- a/src/common/defines.h +++ b/src/common/defines.h @@ -59,7 +59,6 @@ #define FAVORITE_PATH USERDATA_PATH "/.minui/favorite.txt" #define FAUX_FAVORITE_PATH SDCARD_PATH "/Favorites" #define COLLECTIONS_PATH SDCARD_PATH "/Collections" -#define BATTERY_PATH SDCARD_PATH "/battery.txt" #define ADB_FLAG_PATH SDCARD_PATH "/enableADB" #define ALIASES_PATH SDCARD_PATH "/Roms/aliases.txt" diff --git a/src/dts/kernel.dts b/src/dts/kernel.dts new file mode 100644 index 0000000..0c98417 --- /dev/null +++ b/src/dts/kernel.dts @@ -0,0 +1,1463 @@ +/dts-v1/; + +/ { + #address-cells = <0x01>; + #size-cells = <0x01>; + compatible = "actions,gs705a\0actions,atm7059a"; + interrupt-parent = <0x01>; + model = "Actions GS705A board"; + + chosen { + bootargs = "earlyprintk clk_ignore_unused selinux=0"; + }; + + aliases { + serial0 = "/serial@b0120000"; + serial1 = "/serial@b0122000"; + serial2 = "/serial@b0124000"; + serial3 = "/serial@b0126000"; + serial4 = "/serial@b0128000"; + serial5 = "/serial@b012a000"; + serial6 = "/serial@b012c000"; + i2c0 = "/i2c@b0170000"; + i2c1 = "/i2c@b0174000"; + i2c2 = "/i2c@b0178000"; + i2c3 = "/i2c@b017c000"; + spi0 = "/spi@b0200000"; + spi1 = "/spi@b0204000"; + spi2 = "/spi@b0208000"; + spi3 = "/spi@b020c000"; + dcdc1 = "/i2c@b0174000/atc2603c@65/dcdc1"; + dcdc2 = "/i2c@b0174000/atc2603c@65/dcdc2"; + dcdc3 = "/i2c@b0174000/atc2603c@65/dcdc3"; + dcdc4 = "/i2c@b0174000/atc2603c@65/dcdc4"; + ldo1 = "/i2c@b0174000/atc2603c@65/ldo1"; + ldo2 = "/i2c@b0174000/atc2603c@65/ldo2"; + ldo3 = "/i2c@b0174000/atc2603c@65/ldo3"; + ldo4 = "/i2c@b0174000/atc2603c@65/ldo4"; + ldo5 = "/i2c@b0174000/atc2603c@65/ldo5"; + ldo6 = "/i2c@b0174000/atc2603c@65/ldo6"; + ldo7 = "/i2c@b0174000/atc2603c@65/ldo7"; + ldo8 = "/i2c@b0174000/atc2603c@65/ldo8"; + ldo9 = "/i2c@b0174000/atc2603c@65/ldo9"; + ldo10 = "/i2c@b0174000/atc2603c@65/ldo10"; + ldo11 = "/i2c@b0174000/atc2603c@65/ldo11"; + switch1 = "/i2c@b0174000/atc2603c@65/switch1"; + switch2 = "/i2c@b0174000/atc2603c@65/switch2"; + isp0 = "/isp@b0270000"; + sdboot = "/mmc@b0230000"; + mmc0 = "/mmc@b0230000"; + mmc1 = "/mmc@b0234000"; + mmc2 = "/mmc@b0238000"; + usb0 = "/usb@b0600000"; + usb1 = "/usb@b0700000"; + }; + + memory { + device_type = "memory"; + reg = <0x00 0x00>; + }; + + cpus { + #size-cells = <0x00>; + #address-cells = <0x01>; + + cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a9"; + reg = <0x00>; + transition-latency = <0xee6c>; + cpuvdd-supply = <0x02>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a9"; + reg = <0x01>; + }; + }; + + interrupt-controller@b0021000 { + compatible = "arm,cortex-a9-gic"; + interrupt-controller; + #interrupt-cells = <0x03>; + reg = <0xb0021000 0x1000 0xb0020100 0x100>; + linux,phandle = <0x01>; + phandle = <0x01>; + }; + + pmu { + compatible = "arm,cortex-a9-pmu"; + interrupts = <0x00 0x04 0x04 0x00 0x05 0x04 0x00 0x06 0x04 0x00 0x07 0x04>; + }; + + cache-controller@b0022000 { + compatible = "arm,pl310-cache"; + reg = <0xb0022000 0x1000>; + cache-unified; + cache-level = <0x02>; + interrupts = <0x00 0x37 0x04>; + arm,tag-latency = <0x03 0x03 0x02>; + arm,data-latency = <0x05 0x03 0x03>; + }; + + twd-watchdog@b0020600 { + compatible = "actions,atm7059-wdt"; + reg = <0xb0020600 0x100 0xb0160000 0x20>; + interrupts = <0x01 0x0e 0xf01>; + wd_type = "soft"; + status = "disabled"; + }; + + serial@b0120000 { + compatible = "actions,owl-uart\0actions,owl-uart-irc"; + reg = <0xb0120000 0x2000>; + interrupts = <0x00 0x1d 0x04>; + clock-frequency = <0x2dc6c00>; + pinctrl-names = "default"; + pinctrl-0 = <0x03>; + status = "okay"; + }; + + serial@b0122000 { + compatible = "actions,owl-uart"; + reg = <0xb0122000 0x2000>; + interrupts = <0x00 0x1e 0x04>; + clock-frequency = <0x2dc6c00>; + pinctrl-names = "default"; + pinctrl-0 = <0x04>; + status = "disabled"; + }; + + serial@b0124000 { + compatible = "actions,owl-uart"; + reg = <0xb0124000 0x2000>; + interrupts = <0x00 0x1f 0x04>; + clock-frequency = <0x2dc6c00>; + pinctrl-names = "default"; + pinctrl-0 = <0x05>; + status = "disabled"; + }; + + serial@b0126000 { + compatible = "actions,owl-uart"; + reg = <0xb0126000 0x2000>; + interrupts = <0x00 0x20 0x04>; + clock-frequency = <0x2dc6c00>; + pinctrl-names = "default"; + pinctrl-0 = <0x06>; + status = "okay"; + }; + + serial@b0128000 { + compatible = "actions,owl-uart"; + reg = <0xb0128000 0x2000>; + interrupts = <0x00 0x21 0x04>; + clock-frequency = <0x2dc6c00>; + pinctrl-names = "default"; + pinctrl-0 = <0x07>; + status = "disabled"; + }; + + serial@b012a000 { + compatible = "actions,owl-uart"; + reg = <0xb012a000 0x2000>; + interrupts = <0x00 0x22 0x04>; + clock-frequency = <0x2dc6c00>; + status = "okay"; + }; + + serial@b012c000 { + compatible = "actions,owl-uart"; + reg = <0xb012c000 0x2000>; + interrupts = <0x00 0x23 0x04>; + clock-frequency = <0x2dc6c00>; + pinctrl-names = "default"; + pinctrl-0 = <0x08>; + status = "disabled"; + }; + + i2c@b0170000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-i2c"; + reg = <0xb0170000 0x4000>; + interrupts = <0x00 0x19 0x04>; + }; + + i2c@b0174000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-i2c"; + reg = <0xb0174000 0x4000>; + interrupts = <0x00 0x1a 0x04>; + i2c_num = <0x01>; + clock-frequency = <0x61a80>; + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <0x09>; + + atc2603c@65 { + compatible = "actions,atc2603c"; + reg = <0x65>; + interrupt-parent = <0x0a>; + interrupts = <0x02 0x04>; + interrupt-controller; + #interrupt-cells = <0x01>; + losc_32k_output_enable = <0x01>; + losc_32k_output_voltage = <0x1f>; + + pm { + compatible = "actions,atc2603c-pm"; + }; + + onoff { + compatible = "actions,atc2603c-onoff"; + }; + + atc260x-pwm { + compatible = "actions,atc2603c-pwm"; + }; + + rtc { + compatible = "actions,atc2603c-rtc"; + }; + + atc260x_gpio { + compatible = "actions,atc2603c-gpio"; + gpio-controller; + #gpio-cells = <0x02>; + }; + + atc260x_sgpio { + compatible = "actions,atc2603c-sgpio"; + gpio-controller; + #gpio-cells = <0x02>; + interrupt-controller; + #interrupt-cells = <0x02>; + linux,phandle = <0x1f>; + phandle = <0x1f>; + }; + + atc260x-adckeypad { + keymapsize = <0x04>; + filter_dep = <0x03>; + variance = <0x0a>; + poll_interval = <0x0a>; + left_adc_val = <0x00 0x5a 0xaf 0x10e>; + right_adc_val = <0x1e 0x78 0xdc 0x140>; + key_val = <0x66 0x8b 0x73 0x72>; + adc_channel_name = "AUX0"; + compatible = "actions,atc2603c-adckeypad"; + status = "disabled"; + }; + + atc260x-audio { + compatible = "actions,atc2603c-audio"; + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <0x0b>; + earphone_detect_gpios = <0x0c 0x1c 0x00>; + earphone_detect2_gpios = <0x0c 0x51 0x01>; + speaker_en_gpios = <0x0c 0x28 0x01>; + earphone_output_mode = <0x01>; + mic_num = <0x01>; + mic0_gain = <0x07 0x07>; + speaker_gain = <0xb4 0xb4>; + earphone_gain = <0xbe 0xbe>; + mic_mode = <0x01>; + earphone_detect_method = <0x03>; + }; + + atc260x-hwmon { + compatible = "actions,atc2603c-hwmon"; + }; + + atc260x-power { + compatible = "actions,atc2603c-power"; + bl_on_usb_pc_max_charge_current = <0x64>; + bl_off_usb_pc_max_charge_current = <0x1f4>; + bl_on_usb_adp_max_charge_current = <0x3e8>; + bl_off_usb_adp_max_charge_current = <0x4b0>; + bl_on_wall_adp_max_charge_current = <0x3e8>; + bl_off_wall_adp_max_charge_current = <0x4b0>; + bl_on_voltage_diff = <0x15e>; + bl_off_voltage_diff = <0x190>; + support_adaptor_type = <0x01>; + usb_adapter_as_ac = <0x00>; + boot_cap_threshold = <0x00>; + ext_dcdc_exist = <0x00>; + pwms = <0x0d 0x02 0x7a120 0x01>; + pwm-names = "ext_moto"; + moto_pwm_gpio = <0x0c 0x27 0x01>; + ext_charger_exist = <0x00>; + charger_led_exist = <0x01>; + charger_led_ctl = <0x0c 0x16 0x00>; + charger_led2_ctl = <0x0c 0x4e 0x00>; + low_power_led_ctl = <0x0c 0x15 0x01>; + low_power_led2_ctl = <0x0c 0x4f 0x01>; + work_led_ctl = <0x0c 0x12 0x01>; + work_led2_ctl = <0x0c 0x50 0x01>; + myotg_id = <0x0c 0x6a 0x00>; + otg_1_ctl = <0x0c 0x17 0x00>; + otg_2_ctl = <0x0c 0x5f 0x00>; + no_screen = <0x01>; + temp_ctl_enable = <0x00>; + temp_shutdown_low = <0x3ed>; + temp_stop_low = <0x00>; + temp_shutdown_high = <0x32>; + temp_stop_high = <0x2d>; + temp_diff_restart = <0x02>; + }; + + atc260x-cap-gauge { + compatible = "actions,atc2603c-cap-gauge"; + icm_available = <0x01>; + icm_ohm_val = <0x14>; + taper_voltage = <0x1068>; + taper_current = <0x12c>; + min_over_chg_protect_voltage = <0x10b3>; + ch_resistor = <0x78>; + disch_resistor = <0xb4>; + terminal_voltage = <0xc80>; + suspend_current = <0x578>; + shutdown_current = <0x32>; + print_switch = <0x00>; + log_switch = <0x00>; + capacity = <0xa28>; + ocv_soc_00 = <0xc5c 0xc7f 0xc96 0xc9c 0xca8 0xccb 0xce2 0xce8 0xcee 0xcfa>; + ocv_soc_10 = <0xd05 0xd0b 0xd11 0xd17 0xd23 0xd29 0xd2f 0xd34 0xd3a 0xd46>; + ocv_soc_20 = <0xd4c 0xd52 0xd58 0xd63 0xd69 0xd6f 0xd75 0xd7b 0xd86 0xd8c>; + ocv_soc_30 = <0xd92 0xd98 0xda4 0xdaa 0xdaf 0xdb5 0xdbb 0xdc7 0xdcd 0xdd3>; + ocv_soc_40 = <0xdd8 0xde4 0xdea 0xdf0 0xdf6 0xdfc 0xe07 0xe0d 0xe13 0xe19>; + ocv_soc_50 = <0xe25 0xe2a 0xe36 0xe42 0xe48 0xe53 0xe59 0xe5f 0xe65 0xe6b>; + ocv_soc_60 = <0xe77 0xe7c 0xe82 0xe8e 0xe9a 0xea0 0xea6 0xeab 0xeb1 0xebd>; + ocv_soc_70 = <0xec3 0xec9 0xecf 0xee0 0xee6 0xeec 0xef2 0xef8 0xf0f 0xf15>; + ocv_soc_80 = <0xf1b 0xf21 0xf38 0xf3e 0xf44 0xf4a 0xf4f 0xf61 0xf67 0xf6d>; + ocv_soc_90 = <0xf73 0xf84 0xf8a 0xf90 0xfad 0xfb3 0xfbf 0xfc5 0xfdc 0xfe2>; + }; + + atc260x-backup { + compatible = "actions,atc2603c-backup"; + status = "disabled"; + }; + + dcdc1 { + compatible = "actions,atc2603c-dcdc1\0actions,atc2603c-dcdc"; + regulator-name = "dcdc1"; + regulator-min-microvolt = <0xaae60>; + regulator-max-microvolt = <0x155cc0>; + regulator-always-on; + linux,phandle = <0x02>; + phandle = <0x02>; + }; + + dcdc2 { + compatible = "actions,atc2603c-dcdc2\0actions,atc2603c-dcdc"; + regulator-name = "dcdc2"; + regulator-min-microvolt = <0x13d620>; + regulator-max-microvolt = <0x2191c0>; + regulator-always-on; + }; + + dcdc3 { + compatible = "actions,atc2603c-dcdc3\0actions,atc2603c-dcdc"; + regulator-name = "dcdc3"; + regulator-min-microvolt = <0x27ac40>; + regulator-max-microvolt = <0x325aa0>; + regulator-always-on; + }; + + dcdc4 { + status = "disabled"; + }; + + dcdc5 { + status = "disabled"; + }; + + ldo1 { + compatible = "actions,atc2603c-ldo1\0actions,atc2603c-ldo"; + regulator-name = "ldo1"; + regulator-min-microvolt = <0x2ab980>; + regulator-max-microvolt = <0x2ab980>; + regulator-always-on; + }; + + ldo2 { + compatible = "actions,atc2603c-ldo2\0actions,atc2603c-ldo"; + regulator-name = "ldo2"; + regulator-min-microvolt = <0x27ac40>; + regulator-max-microvolt = <0x325aa0>; + regulator-always-on; + }; + + ldo3 { + compatible = "actions,atc2603c-ldo3\0actions,atc2603c-ldo"; + regulator-name = "ldo3"; + regulator-min-microvolt = <0x16e360>; + regulator-max-microvolt = <0x1e8480>; + regulator-always-on; + }; + + ldo4 { + status = "disabled"; + }; + + ldo5 { + compatible = "actions,atc2603c-ldo5\0actions,atc2603c-ldo"; + regulator-name = "ldo5"; + regulator-min-microvolt = <0x2f4d60>; + regulator-max-microvolt = <0x325aa0>; + regulator-suspend-off; + }; + + ldo6 { + compatible = "actions,atc2603c-ldo6\0actions,atc2603c-ldo"; + regulator-name = "ldo6"; + regulator-min-microvolt = <0xaae60>; + regulator-max-microvolt = <0x155cc0>; + regulator-always-on; + }; + + ldo7 { + compatible = "actions,atc2603c-ldo7\0actions,atc2603c-ldo"; + regulator-name = "ldo7"; + regulator-min-microvolt = <0x1b7740>; + regulator-max-microvolt = <0x1b7740>; + regulator-suspend-off; + }; + + ldo8 { + compatible = "actions,atc2603c-ldo8\0actions,atc2603c-ldo"; + regulator-name = "ldo8"; + regulator-min-microvolt = <0x231860>; + regulator-max-microvolt = <0x325aa0>; + }; + + ldo9 { + status = "disabled"; + }; + + ldo10 { + status = "disabled"; + }; + + ldo11 { + compatible = "actions,atc2603c-ldo11\0actions,atc2603c-ldo"; + regulator-name = "ldo11"; + regulator-min-microvolt = <0x27ac40>; + regulator-max-microvolt = <0x325aa0>; + regulator-always-on; + }; + + switch1 { + compatible = "actions,atc2603c-switch1\0actions,atc2603c-switch"; + regulator-name = "switch1"; + regulator-min-microvolt = <0x2f4d60>; + regulator-max-microvolt = <0x325aa0>; + regulator-always-on; + }; + + switch2 { + status = "disabled"; + }; + }; + }; + + i2c@b0178000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-i2c"; + reg = <0xb0178000 0x4000>; + interrupts = <0x00 0x1b 0x04>; + i2c_num = <0x02>; + clock-frequency = <0x61a80>; + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <0x0e>; + linux,phandle = <0x1d>; + phandle = <0x1d>; + + hdmi_read_edid@30 { + compatible = "actions,hdmi_read_edid"; + reg = <0x30>; + }; + }; + + i2c@b017c000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-i2c"; + reg = <0xb017c000 0x4000>; + interrupts = <0x00 0x1c 0x04>; + i2c_num = <0x03>; + clock-frequency = <0x61a80>; + status = "disabled"; + pinctrl-names = "default"; + pinctrl-0 = <0x0f>; + + eg2801_eeprom@14 { + compatible = "actions,eg2801_eeprom"; + reg = <0x14>; + }; + + eg2801_ram@55 { + compatible = "actions,eg2801_ram"; + reg = <0x55>; + }; + }; + + spi@b0200000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-spi"; + reg = <0xb0200000 0x4000>; + interrupts = <0x00 0x13 0x04>; + status = "disabled"; + }; + + spi@b0204000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-spi"; + reg = <0xb0204000 0x4000>; + interrupts = <0x00 0x14 0x04>; + status = "disabled"; + }; + + spi@b0208000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-spi"; + reg = <0xb0208000 0x4000>; + interrupts = <0x00 0x15 0x04>; + }; + + spi@b020c000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-spi"; + reg = <0xb020c000 0x4000>; + interrupts = <0x00 0x16 0x04>; + }; + + gpio@b01b0000 { + compatible = "actions,atm7059a-gpio"; + reg = <0xb01b0000 0x40>; + interrupts = <0x00 0x24 0x04 0x00 0x25 0x04 0x00 0x26 0x04 0x00 0x27 0x04 0x00 0x28 0x04>; + #gpio-cells = <0x02>; + gpio-controller; + #interrupt-cells = <0x02>; + interrupt-controller; + status = "okay"; + linux,phandle = <0x0c>; + phandle = <0x0c>; + }; + + sirq@b01b0200 { + compatible = "actions,owl-sirq"; + reg = <0xb01b0200 0x04>; + interrupts = <0x00 0x0d 0x04 0x00 0x0e 0x04 0x00 0x0f 0x04>; + #interrupt-cells = <0x02>; + interrupt-controller; + linux,phandle = <0x0a>; + phandle = <0x0a>; + }; + + pwm@b01b0050 { + compatible = "actions,atm7059a-pwm"; + reg = <0xb01b0050 0x10>; + #pwm-cells = <0x03>; + linux,phandle = <0x0d>; + phandle = <0x0d>; + + pwm0 { + id = <0x00>; + pinctrl-names = "default"; + pinctrl-0 = <0x10>; + }; + + pwm1 { + id = <0x01>; + pinctrl-names = "default"; + pinctrl-0 = <0x11>; + }; + + pwm2 { + id = <0x02>; + pinctrl-names = "default"; + pinctrl-0 = <0x12>; + }; + + pwm3 { + id = <0x03>; + pinctrl-names = "default"; + pinctrl-0 = <0x13>; + }; + }; + + ethernet@b0310000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-ethernet"; + reg = <0xb0310000 0x10000>; + }; + + mmc@b0230000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-mmc"; + reg = <0xb0230000 0x38>; + pinctrl-names = "default\0share_uart2_5"; + pinctrl-0 = <0x14>; + pinctrl-1 = <0x15>; + card_type = "memory"; + card_detect_mode = "gpio"; + card_detect_gpios = <0x0c 0x29 0x00>; + interrupts = <0x00 0x2a 0x04>; + status = "okay"; + sd_vcc = "switch1"; + sdio3_0_not_supported; + }; + + mmc@b0234000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-mmc"; + reg = <0xb0234000 0x38>; + interrupts = <0x00 0x2b 0x04>; + pinctrl-names = "default"; + pinctrl-0 = <0x16>; + card_type = "wifi"; + status = "disabled"; + }; + + mmc@b0238000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-mmc"; + reg = <0xb0238000 0x38>; + interrupts = <0x00 0x2c 0x04>; + pinctrl-names = "default"; + pinctrl-0 = <0x17>; + card_type = "memory"; + card_detect_mode = "command"; + status = "okay"; + }; + + usb@b0600000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-usb-2.0-0"; + reg = <0xb0600000 0x1000>; + interrupts = <0x00 0x18 0x04>; + status = "disabled"; + }; + + usb@b0700000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,owl-usb-2.0-1"; + reg = <0xb0700000 0x1000>; + interrupts = <0x00 0x3d 0x04>; + status = "disabled"; + }; + + usb@b0400000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "actions,atm7059tc-usb"; + reg = <0xb0400000 0xcd00 0xb040cd00 0x59>; + interrupts = <0x00 0x17 0x04>; + usb_serialnumber_config = <0x01>; + usb_hs_output_strength = <0x02>; + status = "okay"; + }; + + isp@b0270000 { + #address-cells = <0x01>; + #size-cells = <0x01>; + compatible = "actions,owl-isp"; + reg = <0xb0270000 0x400 0xb0160020 0x04>; + interrupts = <0x00 0x0c 0x04>; + avdd-src = "regulator"; + avdd-regulator = "ldo1"; + avdd-regulator-scope = <0x2ab980 0x2ae090>; + dvdd-gpios = <0x0c 0x39 0x00>; + sensors = "rear"; + pwdn-rear-gpios = <0x0c 0x49 0x00>; + pwdn-front-gpios = <0x0c 0x46 0x00>; + rear-reset-gpios = <0x0c 0x72 0x01>; + status = "disabled"; + linux,phandle = <0x1c>; + phandle = <0x1c>; + }; + + pinctrl@b01b0040 { + compatible = "actions,atm7059a-pinctrl"; + pinctrl-names = "default"; + pinctrl-0 = <0x18>; + + pinctrl_default { + linux,phandle = <0x18>; + phandle = <0x18>; + }; + + serial0_default { + + serial_0 { + actions,groups = "mfp2_2_0\0mfp3_21_19"; + actions,function = "uart0"; + }; + }; + + serial0_d { + linux,phandle = <0x03>; + phandle = <0x03>; + + serial_d { + actions,groups = "mfp2_22\0mfp2_23"; + actions,function = "uart0"; + }; + }; + + serial1_default { + linux,phandle = <0x04>; + phandle = <0x04>; + + serial_1 { + actions,groups = "mfp2_13_11"; + actions,function = "uart1"; + }; + }; + + serial2_default { + linux,phandle = <0x05>; + phandle = <0x05>; + + serial_2 { + actions,groups = "mfp2_23\0mfp2_22\0uart2_dummy"; + actions,function = "uart2"; + }; + }; + + serial3_default { + linux,phandle = <0x06>; + phandle = <0x06>; + + serial_3 { + actions,groups = "mfp2_21\0mfp2_20\0uart3_dummy"; + actions,function = "uart3"; + }; + }; + + serial4_default { + linux,phandle = <0x07>; + phandle = <0x07>; + + serial_4 { + actions,groups = "uart4_dummy"; + actions,function = "uart4"; + }; + }; + + serial5_default { + + serial_5 { + actions,groups = "mfp2_19_17\0mfp2_16_14"; + actions,function = "uart5"; + }; + }; + + serial6_default { + linux,phandle = <0x08>; + phandle = <0x08>; + + serial_6 { + actions,groups = "mfp0_18_16_eth_txd0\0mfp0_18_16_eth_txd1"; + actions,function = "uart6"; + }; + }; + + ethernet_default { + + ethernet_smi { + actions,groups = "eth_smi_dummy"; + actions,function = "eth_rmii"; + }; + + ethernet_rmii_txd01 { + actions,groups = "mfp0_18_16_eth_txd0\0mfp0_18_16_eth_txd1"; + actions,function = "eth_rmii"; + }; + + ethernet_rmii_txen_rxer { + actions,groups = "mfp0_15_13_rmii_txen\0mfp0_15_13_rmii_rxen"; + actions,function = "eth_rmii"; + }; + + ethernet_rmii_crs_dv { + actions,groups = "mfp0_22_20"; + actions,function = "eth_rmii"; + }; + + ethernet_rmii_rxd10 { + actions,groups = "mfp0_10_8_rmii_rxd1\0mfp0_10_8_rmii_rxd0"; + actions,function = "eth_rmii"; + }; + + ethernet_rmii_ref_clk { + actions,groups = "mfp0_7_6"; + actions,function = "eth_rmii"; + }; + }; + + mmc_share_uart { + linux,phandle = <0x15>; + phandle = <0x15>; + + sd0_mfp_cmd_clk { + actions,groups = "mfp2_8_7\0mfp2_6_5"; + actions,function = "sd0"; + }; + + sd0_pull_d0_d3_cmd { + actions,pins = "P_SD0_CMD"; + actions,pull = <0x02>; + }; + + sd0_pull_clk { + actions,pins = "P_SD0_CLK"; + actions,pull = <0x00>; + }; + + sd0_d0_d3_cmd_clk_paddrv { + actions,groups = "paddrv1_19_18\0paddrv1_17_16"; + actions,paddrv = <0x01>; + }; + + serial_5 { + actions,groups = "mfp2_19_17\0mfp2_16_14"; + actions,function = "uart5"; + }; + }; + + mmc0_default { + linux,phandle = <0x14>; + phandle = <0x14>; + + sd0_mfp_d0_d3_cmd_clk { + actions,groups = "mfp2_19_17\0mfp2_16_14\0mfp2_13_11\0mfp2_8_7\0mfp2_6_5"; + actions,function = "sd0"; + }; + + sd0_pull_d0_d3_cmd { + actions,pins = "P_SD0_D0\0P_SD0_D1\0P_SD0_D2\0P_SD0_D3\0P_SD0_CMD"; + actions,pull = <0x02>; + }; + + sd0_pull_clk { + actions,pins = "P_SD0_CLK"; + actions,pull = <0x00>; + }; + + sd0_d0_d3_cmd_clk_paddrv { + actions,groups = "paddrv1_23_22\0paddrv1_19_18\0paddrv1_17_16"; + actions,paddrv = <0x01>; + }; + }; + + mmc1_default { + linux,phandle = <0x16>; + phandle = <0x16>; + + sd1_mfp_d0_d3_cmd_clk { + actions,groups = "mfp2_10_9\0mfp2_4_3\0sd1_dummy"; + actions,function = "sd1"; + }; + + sd1_pull_d0_d3_cmd { + actions,pins = "P_SD1_D0\0P_SD1_D1\0P_SD1_D2\0P_SD1_D3\0P_SD1_CMD"; + actions,pull = <0x02>; + }; + + sd1_d0_d3_cmd_clk_paddrv { + actions,groups = "paddrv1_21_20\0paddrv1_15_14\0paddrv1_13_12"; + actions,paddrv = <0x01>; + }; + }; + + mmc2_default { + linux,phandle = <0x17>; + phandle = <0x17>; + + sd2_mfp_d0_d3_cmd_clk { + actions,groups = "mfp3_3"; + actions,function = "sd2"; + }; + + sd2_pull_d0_d3_cmd { + actions,pins = "P_DNAND_D0\0P_DNAND_D1\0P_DNAND_D2\0P_DNAND_D3\0P_DNAND_D4\0P_DNAND_D5\0P_DNAND_D6\0P_DNAND_D7\0P_DNAND_RDBN"; + actions,pull = <0x02>; + }; + }; + + isp0_csi_dvp { + linux,phandle = <0x1e>; + phandle = <0x1e>; + + isp0_csi_dvp_mfp { + actions,groups = "mfp3_29_28\0mfp3_23_22\0mfp3_15_14\0mfp3_13_12"; + actions,function = "sens0"; + }; + + sens0_clk_out_pdrv { + actions,groups = "paddrv2_13_12"; + actions,paddrv = <0x00>; + }; + }; + + isp0_csi_mipi { + + isp0_csi_mipi_mfp { + actions,groups = "mfp3_29_28\0mfp3_15_14"; + actions,function = "mipi_csi"; + }; + + isp0_csi_mipi_clkout_mfp { + actions,groups = "mfp3_23_22"; + actions,function = "sens0"; + }; + }; + + spi0_dsi_d { + + spi0_mfp { + actions,groups = "mfp1_9_7\0mfp1_20_19\0mfp1_18_17\0mfp2_26_24"; + actions,function = "spi0"; + }; + + spi0_paddrv { + actions,groups = "paddrv1_25_24"; + actions,paddrv = <0x02>; + }; + }; + + i2c0_default { + + i2c0_default_mfp { + actions,groups = "mfp3_18_16"; + actions,function = "i2c0"; + }; + + i2c0_default_paddrv { + actions,groups = "paddrv2_24_23"; + actions,paddrv = <0x00>; + }; + + i2c0_default_pull_up { + actions,pins = "P_I2C0_SCLK\0P_I2C0_SDATA"; + actions,pull = <0x02>; + }; + }; + + i2c0_over_uart0 { + + i2c0_over_uart0_mfp { + actions,groups = "mfp2_2_0\0mfp3_21_19"; + actions,function = "i2c0"; + }; + + i2c0_over_uart0_paddrv { + actions,groups = "paddrv2_31_30\0paddrv2_29_28"; + actions,paddrv = <0x00>; + }; + + i2c0_over_uart0_pull_up { + actions,pins = "P_UART0_RX\0P_UART0_TX"; + actions,pull = <0x02>; + }; + }; + + i2c1_default { + linux,phandle = <0x09>; + phandle = <0x09>; + + i2c1_default_mfp { + actions,groups = "i2c1_dummy"; + actions,function = "i2c1"; + }; + + i2c1_default_paddrv { + actions,groups = "paddrv2_22_21"; + actions,paddrv = <0x00>; + }; + + i2c1_default_pull_up { + actions,pins = "P_I2C1_SCLK\0P_I2C1_SDATA"; + actions,pull = <0x00>; + }; + }; + + i2c2_default { + linux,phandle = <0x0e>; + phandle = <0x0e>; + + i2c2_default_mfp { + actions,groups = "i2c2_dummy"; + actions,function = "i2c2"; + }; + + i2c2_default_paddrv { + actions,groups = "paddrv2_22_21"; + actions,paddrv = <0x00>; + }; + + i2c2_default_pull_up { + actions,pins = "P_I2C2_SCLK\0P_I2C2_SDATA"; + actions,pull = <0x02>; + }; + }; + + i2c3_over_spi0 { + linux,phandle = <0x0f>; + phandle = <0x0f>; + + i2c3_over_spi0_mfp { + actions,groups = "mfp1_4_3"; + actions,function = "i2c3"; + }; + + i2c3_over_spi0_paddrv { + actions,groups = "paddrv1_11_10"; + actions,paddrv = <0x01>; + }; + + i2c3_over_spi0_pull_up { + actions,pins = "P_SPI0_SCLK\0P_SPI0_MOSI"; + actions,pull = <0x00>; + }; + }; + + spi0_default { + + spi0_mfp { + actions,groups = "mfp1_2_0\0mfp1_4_3"; + actions,function = "spi0"; + }; + }; + + spi2_nand_d { + linux,phandle = <0x1b>; + phandle = <0x1b>; + + spi2_mfp { + actions,groups = "mfp3_2"; + actions,function = "spi2"; + }; + }; + + pwm0_default { + linux,phandle = <0x10>; + phandle = <0x10>; + + pwm0_mfp { + actions,groups = "mfp1_31_29_ks_in2"; + actions,function = "pwm0"; + }; + }; + + pwm1_default { + linux,phandle = <0x11>; + phandle = <0x11>; + + pwm1_mfp { + actions,groups = "mfp1_28_26_ks_in3"; + actions,function = "pwm1"; + }; + }; + + pwm2_default { + linux,phandle = <0x12>; + phandle = <0x12>; + + pwm2_mfp { + actions,groups = "mfp1_28_26_ks_out0"; + actions,function = "pwm2"; + }; + }; + + pwm3_default { + linux,phandle = <0x13>; + phandle = <0x13>; + + pwm3_mfp { + actions,groups = "mfp1_28_26_ks_out1"; + actions,function = "pwm3"; + }; + }; + + lvds_default { + + lvds_mux { + actions,groups = "mfp1_22_21\0mfp1_6_5\0mfp2_28_27"; + actions,function = "lvds"; + }; + }; + + i2s0_default { + linux,phandle = <0x0b>; + phandle = <0x0b>; + + i2s0_default_mfp { + actions,groups = "mfp0_2_1_i2s0\0mfp0_4_3\0mfp0_5"; + actions,function = "i2s0"; + }; + }; + + rgb_default { + linux,phandle = <0x19>; + phandle = <0x19>; + + rgb_mux { + actions,groups = "mfp0_25_23\0mfp1_16_14\0mfp1_22_21\0mfp1_13_12\0mfp1_11_10\0mfp1_6_5\0mfp2_30_29\0mfp2_28_27"; + actions,function = "lcd0"; + }; + }; + + pcm0_spi0 { + + pcm0_spi0_mfp { + actions,groups = "mfp1_2_0\0mfp1_4_3"; + actions,function = "pcm0"; + }; + }; + + dsi_default { + + dsi_mux { + actions,groups = "mfp1_20_19\0mfp1_18_17\0mfp1_13_12\0mfp1_11_10\0mfp1_9_7\0mfp2_30_29"; + actions,function = "dsi"; + }; + }; + }; + + lcd0@b02a0000 { + compatible = "actions,owl-lcd"; + reg = <0xb02a0000 0x20c>; + interrupts = <0x00 0x2d 0x04>; + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <0x19>; + lcd_power_gpios = <0x0c 0x24 0x00>; + lcd_reset_gpios = <0x0c 0x23 0x00>; + lcd_spics_gpios = <0x0c 0x11 0x01>; + lcd_spics2_gpios = <0x0c 0x1f 0x01>; + lcd_spiclk_gpios = <0x0c 0x78 0x01>; + lcd_spidat_gpios = <0x0c 0x79 0x01>; + port_type = "rgb"; + data_width = <0x00>; + videomode-0 = <0x1a>; + vsync_inversion = <0x01>; + hsync_inversion = <0x01>; + dclk_inversion = <0x01>; + lde_inversion = <0x00>; + lightness = <0x80>; + saturation = <0x07>; + contrast = <0x05>; + + mode@640x480p60 { + refresh = <0x3c>; + xres = <0x280>; + yres = <0x1e0>; + pixclock = <0xc350>; + left_margin = <0x10>; + right_margin = <0x14>; + upper_margin = <0x0f>; + lower_margin = <0x05>; + hsync_len = <0x1e>; + vsync_len = <0x02>; + vmode = <0x00>; + linux,phandle = <0x1a>; + phandle = <0x1a>; + }; + }; + + dsi@b0220000 { + compatible = "actions,owl-dsi"; + reg = <0xb0220000 0x8c>; + interrupts = <0x00 0x33 0x04>; + status = "disabled"; + }; + + backlight { + compatible = "actions,owl-pwm-backlight"; + pwms = <0x0d 0x00 0xc350 0x00>; + total_steps = <0x400>; + min_brightness = <0x00>; + max_brightness = <0x400>; + dft_brightness = <0x190>; + delay_bf_pwm = <0xc8>; + delay_af_pwm = <0x0a>; + }; + + gpu@b0300000 { + compatible = "actions,atm7039c-gpu"; + reg = <0xb0300000 0x10000>; + interrupts = <0x00 0x03 0x04>; + normal_value = <0x02>; + status = "disabled"; + }; + + vde@b0280000 { + compatible = "actions,atm7059a-vde"; + reg = <0xb0280000 0x108>; + interrupts = <0x00 0x32 0x04>; + }; + + vce@b0288000 { + compatible = "actions,atm7059a-vce"; + reg = <0xb0288000 0x94>; + interrupts = <0x00 0x31 0x04>; + }; + + hdmi@b02c0000 { + compatible = "actions,atm7059a-hdmi"; + reg = <0xb02c0000 0x160>; + status = "okay"; + hdcp_onoff = <0x00>; + channel_invert = <0x00>; + bit_invert = <0x00>; + hotplugable = <0x01>; + bootable = <0x01>; + i2cbus = <0x02>; + bootrotate = <0x00>; + default_resolution = "1280x720p-60"; + }; + + hdmi_cec@b02c011c { + compatible = "actions,atm7059a-hdmi-cec"; + reg = <0xb02c0000 0x160>; + }; + + cvbs@b02b0000 { + compatible = "actions,atm7059a-cvbs"; + reg = <0xb02b0000 0x80>; + default_mode = "PAL"; + status = "disabled"; + }; + + de@b02e0000 { + compatible = "actions,atm7059a-de"; + reg = <0xb02e0000 0x100e 0xb0500108 0x04>; + }; + + nand@b0210000 { + #address-cells = <0x01>; + #size-cells = <0x01>; + compatible = "actions,atm7059a-nand"; + reg = <0xb0210000 0xb4 0xb0160000 0xfc 0xb01b0000 0x90 0xb0260000 0xd00>; + interrupts = <0x00 0x29 0x04>; + }; + + dma@b0260000 { + compatible = "actions,owl-dma"; + reg = <0xb0260000 0xd00>; + interrupts = <0x00 0x39 0x04 0x00 0x3a 0x04 0x00 0x3b 0x04 0x00 0x3c 0x04>; + }; + + thermal { + #address-cells = <0x01>; + #size-cells = <0x01>; + compatible = "actions,atm7059a-thermal"; + reg = <0xb01b00e8 0x08>; + }; + + reserved { + + tiny { + fb_heap_size = <0x09>; + kinfo_heap_size = <0x01>; + carveout_heap_size = <0x00>; + dma_heap_size = <0x20>; + }; + + normal { + fb_heap_size = <0x08>; + kinfo_heap_size = <0x01>; + carveout_heap_size = <0x40>; + dma_heap_size = <0x80>; + }; + }; + + dual_logo { + value = <0x00>; + }; + + spinand@b0208000 { + compatible = "actions,atm7059a-spinand"; + clock-frequency = <0x2faf080>; + pinctrl-names = "default"; + pinctrl-0 = <0x1b>; + status = "disabled"; + }; + + gl5203-audio-i2s { + #address-cells = <0x01>; + #size-cells = <0x01>; + compatible = "actions,owl-audio-i2s"; + reg = <0xb0100000 0x34 0xb0110000 0x8010>; + pcm = <0x00>; + }; + + usb@b02b8000 { + vbus-src = "gpio"; + vbus-regulator = "LDO1"; + regulator-scope = <0x325aa0 0x3567e0>; + status = "disabled"; + }; + + monitor { + compatible = "actions,atm7059tc-usbmonitor"; + detect_type = <0x03>; + idpin_type = <0x00>; + vbus_type = <0x02>; + vbus_otg_en_gpios = <0x0c 0x19 0x00>; + status = "okay"; + }; + + isp-sensor { + compatible = "sensor_common"; + rear_bus_type = "dvp"; + front_bus_type = "dvp"; + rear_data_type = "yuv"; + front_data_type = "yuv"; + host = <0x1c>; + rear_channel = <0x00>; + front_channel = <0x00>; + i2c_adapter = <0x1d>; + pinctrl-names = "default"; + pinctrl-0 = <0x1e>; + status = "disabled"; + }; + + sensor-detect { + compatible = "sensor_detect"; + status = "disabled"; + hot_plugin_enable = <0x00>; + + sensor_detect_list { + gc0308 = <0x01>; + gc0328 = <0x01>; + gc0329 = <0x01>; + gc0312 = <0x01>; + gc2035 = <0x01>; + gc2145 = <0x01>; + gc2155 = <0x01>; + hi708 = <0x01>; + hi257 = <0x01>; + ov2686 = <0x01>; + ov5640 = <0x01>; + sp0718 = <0x01>; + sp0a19 = <0x01>; + sp2519 = <0x01>; + siv121du = <0x01>; + soc5140 = <0x01>; + }; + }; + + matrix_keypad@0 { + compatible = "gpio-matrix-keypad"; + status = "disabled"; + debounce-delay-ms = <0x14>; + col-scan-delay-us = <0x0a>; + row-gpios = <0x0c 0x2d 0x00 0x0c 0x2e 0x00>; + col-gpios = <0x0c 0x32 0x00 0x0c 0x33 0x00 0x0c 0x30 0x00 0x0c 0x2f 0x00>; + linux,keymap = <0x8b 0x1009e 0x2009f 0x30069 0x1000080 0x1010077 0x1020078 0x1030079>; + }; + + framebuffer { + compatible = "actions,framebuffer"; + def_display = "lcd"; + xres = <0x280>; + yres = <0x1e0>; + bpp = <0x04>; + mode = <0x01>; + }; + + vibrator { + compatible = "actions,vibrator"; + status = "disabled"; + }; + + wifi_bt_power_ctl { + compatible = "wifi,bt,power,ctl"; + status = "disabled"; + wifi_bt_power_gpios = <0x1f 0x05 0x00>; + wifi_vol_range = <0x325aa0 0x325aa0>; + wifi_en_gpios = <0x0c 0x5a 0x00>; + bt_en_gpios = <0x0c 0x5b 0x00>; + wifi_wakeup_host_gpios = <0x0c 0x73 0x00>; + }; + + gsensor_detect { + compatible = "owl-gsensor-detect"; + status = "disabled"; + i2c_adapter_id = <0x02>; + + gsensor_detect_list { + compatible = "gsensor_detect_list"; + afa750 = <0x00>; + bma220 = <0x00>; + bma222 = <0x01>; + bma250 = <0x00>; + dmard10 = <0x00>; + kxtj9 = <0x00>; + lis3dh = <0x00>; + mc3210 = <0x00>; + mc3230 = <0x00>; + mc3232 = <0x01>; + mc3236 = <0x01>; + mma7660 = <0x00>; + mma8452 = <0x00>; + stk8312 = <0x01>; + stk8313 = <0x01>; + }; + }; + + ctp_detect { + compatible = "owl-ctp-detect"; + status = "disabled"; + i2c_adapter_id = <0x01>; + tp_vcc = "ldo5"; + reset_gpios = <0x0c 0x23 0x01>; + interrupt-parent = <0x0a>; + interrupts = <0x00 0x04>; + vol_range = <0x2f4d60 0x2f7470>; + + ctp_detect_list { + compatible = "ctp_detect_list"; + ICN83XX = <0x00>; + GSLX6X0 = <0x01>; + FT52-406 = <0x00>; + FT5606 = <0x00>; + GT813 = <0x00>; + AW5206 = <0x00>; + AW5209 = <0x00>; + CT36X = <0x00>; + HL3X06 = <0x00>; + ILITEK = <0x00>; + ili2672 = <0x00>; + ft5x06 = <0x00>; + MT395 = <0x00>; + NT1100X = <0x00>; + SSD254X = <0x00>; + }; + }; + + pcm-audio { + compatible = "actions,pcm-audio"; + status = "okay"; + }; +}; diff --git a/src/dts/makefile b/src/dts/makefile new file mode 100755 index 0000000..62efc2b --- /dev/null +++ b/src/dts/makefile @@ -0,0 +1,4 @@ +all: + dtc -O dtb -o kernel.dtb kernel.dts +clean: + rm -f kernel.dtb diff --git a/src/install/install.sh b/src/install/install.sh index ade8580..81dde15 100755 --- a/src/install/install.sh +++ b/src/install/install.sh @@ -13,7 +13,9 @@ if [ ! -f $FLAG_PATH ]; then echo "backing up" BAK_PATH=$TF1_PATH/bak mkdir -p $BAK_PATH - cp /misc/boot_logo.bmp.gz $BAK_PATH + cp /misc/boot_logo.bmp.gz $BAK_PATH + cp /misc/kernel.dtb $BAK_PATH + cp /misc/ramdisk.img $BAK_PATH fi was_updated() { @@ -27,6 +29,11 @@ was_updated() { continue fi + if [[ "$A_NAME" == "charging.png" ]]; then + # we don't care if the user has changed their charging image + continue + fi + if [ ! -f "$B_PATH" ]; then continue fi @@ -46,9 +53,13 @@ if [ ! -f $FLAG_PATH ] || was_updated; then echo "updating misc partition" mount -o remount,rw /dev/block/actb /misc cp $SYSTEM_PATH/dat/dmenu.bin /misc + cp $SYSTEM_PATH/dat/kernel.dtb /misc + cp $SYSTEM_PATH/dat/ramdisk.img /misc + + # graphics are only installed, never updated if [ ! -f $FLAG_PATH ]; then - # only replace boot logo on install not update! cp $SYSTEM_PATH/dat/boot_logo.bmp.gz /misc + cp $SYSTEM_PATH/dat/charging.png /misc fi touch $FLAG_PATH sync && reboot diff --git a/src/libmsettings/msettings.c b/src/libmsettings/msettings.c index 9f7a4fc..1ab223f 100644 --- a/src/libmsettings/msettings.c +++ b/src/libmsettings/msettings.c @@ -25,8 +25,8 @@ typedef struct Settings { } Settings; static Settings DefaultSettings = { .version = SETTINGS_VERSION, - .brightness = 2, - .headphones = 4, + .brightness = 4, + .headphones = 8, .speaker = 8, .jack = 0, }; @@ -47,12 +47,12 @@ void InitSettings(void) { shm_fd = shm_open(SHM_KEY, O_RDWR | O_CREAT | O_EXCL, 0644); // see if it exists if (shm_fd==-1 && errno==EEXIST) { // already exists - puts("Settings client"); + // puts("Settings client"); shm_fd = shm_open(SHM_KEY, O_RDWR, 0644); settings = mmap(NULL, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); } else { // host - puts("Settings host"); // keymon + // puts("Settings host"); // keymon is_host = 1; // we created it so set initial size and populate ftruncate(shm_fd, shm_size); @@ -72,7 +72,7 @@ void InitSettings(void) { // these shouldn't be persisted // settings->jack = 0; } - printf("brightness: %i\nspeaker: %i \n", settings->brightness, settings->speaker); + printf("brightness: %i\nspeaker: %i \nheadphones: %i \n", settings->brightness, settings->speaker, settings->headphones); SetVolume(GetVolume()); SetBrightness(GetBrightness()); diff --git a/src/minarch/makefile b/src/minarch/makefile index b417157..992b69c 100644 --- a/src/minarch/makefile +++ b/src/minarch/makefile @@ -6,8 +6,9 @@ TARGET = minarch CC = $(CROSS_COMPILE)gcc CFLAGS = -marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard -march=armv7-a -fomit-frame-pointer -CFLAGS += -I. -I../common -I./libretro-common/include -DPLATFORM=\"$(UNION_PLATFORM)\" -Ofast -LDFLAGS = -ldl -lSDL -lSDL_image -lSDL_ttf -lmsettings -lpthread -lz +CFLAGS += -I. -I../common -I./libretro-common/include -DPLATFORM=\"$(UNION_PLATFORM)\" -Ofast -std=gnu99 +CFLAGS += -Os -flto +LDFLAGS = -ldl -lSDL -lSDL_image -lSDL_ttf -lmsettings -lpthread -lm -lz # CFLAGS += -Wall -Wno-unused-variable -Wno-unused-function -Wno-format-overflow # CFLAGS += -fsanitize=address -fno-common # LDFLAGS += -lasan @@ -19,4 +20,4 @@ CFLAGS += -DBUILD_DATE=\"${BUILD_DATE}\" -DBUILD_HASH=\"${BUILD_HASH}\" all: $(CC) $(TARGET).c ../common/scaler_neon.c ../common/utils.c ../common/api.c -o $(TARGET).elf $(CFLAGS) $(LDFLAGS) clean: - rm -f $(TARGET).elf \ No newline at end of file + rm -f $(TARGET).elf diff --git a/src/minarch/minarch.c b/src/minarch/minarch.c index 48e5380..9edbd5a 100644 --- a/src/minarch/minarch.c +++ b/src/minarch/minarch.c @@ -47,7 +47,6 @@ enum { // default frontend options static int screen_scaling = SCALE_ASPECT; // aspect static int show_scanlines = 0; -static int optimize_text = 0; static int prevent_tearing = 1; // lenient static int show_debug = 0; static int max_ff_speed = 3; // 4x @@ -435,6 +434,55 @@ static void SRAM_write(void) { /////////////////////////////////////// +static void RTC_getPath(char* filename) { + sprintf(filename, "%s/%s.rtc", core.saves_dir, game.name); +} +static void RTC_read(void) { + size_t rtc_size = core.get_memory_size(RETRO_MEMORY_RTC); + if (!rtc_size) return; + + char filename[MAX_PATH]; + RTC_getPath(filename); + printf("rtc path (read): %s\n", filename); + + FILE *rtc_file = fopen(filename, "r"); + if (!rtc_file) return; + + void* rtc = core.get_memory_data(RETRO_MEMORY_RTC); + + if (!rtc || !fread(rtc, 1, rtc_size, rtc_file)) { + LOG_error("Error reading RTC data\n"); + } + + fclose(rtc_file); +} +static void RTC_write(void) { + size_t rtc_size = core.get_memory_size(RETRO_MEMORY_RTC); + if (!rtc_size) return; + + char filename[MAX_PATH]; + RTC_getPath(filename); + printf("rtc path (write) size(%u): %s\n", rtc_size, filename); + + FILE *rtc_file = fopen(filename, "w"); + if (!rtc_file) { + LOG_error("Error opening RTC file: %s\n", strerror(errno)); + return; + } + + void *rtc = core.get_memory_data(RETRO_MEMORY_RTC); + + if (!rtc || rtc_size != fwrite(rtc, 1, rtc_size, rtc_file)) { + LOG_error("Error writing RTC data to file\n"); + } + + fclose(rtc_file); + + sync(); +} + +/////////////////////////////////////// + static void Downsample(void* __restrict src, void* __restrict dst, uint32_t w, uint32_t h, uint32_t pitch, uint32_t dst_pitch) { uint32_t ox = 0; uint32_t oy = 0; @@ -461,6 +509,9 @@ static void State_read(void) { // from picoarch size_t state_size = core.serialize_size(); if (!state_size) return; + int was_ff = fast_forward; + fast_forward = 0; + void *state = calloc(1, state_size); if (!state) { LOG_error("Couldn't allocate memory for state\n"); @@ -478,7 +529,9 @@ static void State_read(void) { // from picoarch goto error; } - if (state_size != fread(state, 1, state_size, state_file)) { + // some cores report the wrong serialize size initially for some games, eg. mgba: Wario Land 4 + // so we allow a size mismatch as long as the actual size fits in the buffer we've allocated + if (state_size < fread(state, 1, state_size, state_file)) { LOG_error("Error reading state data from file: %s (%s)\n", filename, strerror(errno)); goto error; } @@ -491,11 +544,16 @@ static void State_read(void) { // from picoarch error: if (state) free(state); if (state_file) fclose(state_file); + + fast_forward = was_ff; } static void State_write(void) { // from picoarch size_t state_size = core.serialize_size(); if (!state_size) return; - + + int was_ff = fast_forward; + fast_forward = 0; + void *state = calloc(1, state_size); if (!state) { LOG_error("Couldn't allocate memory for state\n"); @@ -526,6 +584,8 @@ error: if (state_file) fclose(state_file); sync(); + + fast_forward = was_ff; } static void State_autosave(void) { int last_state_slot = state_slot; @@ -610,7 +670,6 @@ static char* max_ff_labels[] = { enum { FE_OPT_SCALING, FE_OPT_SCANLINES, - FE_OPT_TEXT, FE_OPT_TEARING, FE_OPT_OVERCLOCK, FE_OPT_DEBUG, @@ -797,16 +856,6 @@ static struct Config { .values = onoff_labels, .labels = onoff_labels, }, - [FE_OPT_TEXT] = { - .key = "minarch_optimize_text", - .name = "Optimize Text", - .desc = "Prioritize a consistent stroke width when upscaling single\npixel lines using nearest neighbor scaler. Increases CPU load.\nOnly applies to native scaling.", - .default_value = 0, - .value = 0, - .count = 2, - .values = onoff_labels, - .labels = onoff_labels, - }, [FE_OPT_TEARING] = { .key = "minarch_prevent_tearing", .name = "Prevent Tearing", @@ -900,7 +949,6 @@ static void Config_syncFrontend(int i, int value) { switch (i) { case FE_OPT_SCALING: screen_scaling = value; renderer.src_w = 0; break; case FE_OPT_SCANLINES: show_scanlines = value; renderer.src_w = 0; break; - case FE_OPT_TEXT: optimize_text = value; renderer.src_w = 0; break; case FE_OPT_TEARING: prevent_tearing = value; break; case FE_OPT_OVERCLOCK: overclock = value; break; case FE_OPT_DEBUG: show_debug = value; break; @@ -2355,125 +2403,6 @@ static void scaleNN_scanline(void* __restrict src, void* __restrict dst, uint32_ row += 1; } } -static void scaleNN_text(void* __restrict src, void* __restrict dst, uint32_t w, uint32_t h, uint32_t pitch, uint32_t dst_pitch) { - int dy = -renderer.dst_h; - unsigned lines = h; - bool copy = false; - - size_t cpy_w = renderer.dst_w * FIXED_BPP; - int screen_p = screen->pitch; - - int safe = w - 1; // don't look behind when there's nothing to see - uint16_t l1,l2; - while (lines) { - int dx = -renderer.dst_w; - const uint16_t *psrc16 = src; - uint16_t *pdst16 = dst; - l1 = l2 = 0x0; - - if (copy) { - copy = false; - memcpy(dst, dst - screen_p, cpy_w); - dst += screen_p; - dy += h; - } else if (dy < 0) { - int col = w; - while(col--) { - int d = 0; - if (col> 10) & 0x3E; - uint16_t g = (l1 >> 5) & 0x3F; - uint16_t b = (l1 << 1) & 0x3E; - uint16_t luma = (r * 218) + (g * 732) + (b * 74); - luma = (luma >> 10) + ((luma >> 9) & 1); // 0-63 - d = luma > 24; - } - - uint16_t s = *psrc16; - - while (dx < 0) { - *pdst16++ = d ? l1 : s; - dx += w; - - l2 = l1; - l1 = s; - d = 0; - } - - dx -= renderer.dst_w; - psrc16++; - } - - dst += screen_p; - dy += h; - } - - if (dy >= 0) { - dy -= renderer.dst_h; - src += pitch; - lines--; - } else { - copy = true; - } - } -} -static void scaleNN_text_scanline(void* __restrict src, void* __restrict dst, uint32_t w, uint32_t h, uint32_t pitch, uint32_t dst_pitch) { - int dy = -renderer.dst_h; - unsigned lines = h; - - int row = 0; - int safe = w - 1; // don't look behind when there's nothing to see - uint16_t l1,l2; - while (lines) { - int dx = -renderer.dst_w; - const uint16_t *psrc16 = src; - uint16_t *pdst16 = dst; - l1 = l2 = 0x0; - - if (row%2==0) { - int col = w; - while(col--) { - int d = 0; - if (col> 10) & 0x3E; - uint16_t g = (l1 >> 5) & 0x3F; - uint16_t b = (l1 << 1) & 0x3E; - uint16_t luma = (r * 218) + (g * 732) + (b * 74); - luma = (luma >> 10) + ((luma >> 9) & 1); // 0-63 - d = luma > 24; - } - - uint16_t s = *psrc16; - - while (dx < 0) { - *pdst16 = *(pdst16 + dst_pitch) = d ? l1 : s; - pdst16 += 1; - - dx += w; - - l2 = l1; - l1 = s; - d = 0; - } - - dx -= renderer.dst_w; - psrc16 += 1; - } - } - - dst += dst_pitch; - dy += h; - - if (dy >= 0) { - dy -= renderer.dst_h; - src += pitch; - lines--; - } - row += 1; - } -} static SDL_Surface* scaler_surface; static void selectScaler_PAR(int width, int height, int pitch) { @@ -2588,8 +2517,8 @@ static void selectScaler_PAR(int width, int height, int pitch) { renderer.dst_offset = (oy * device_pitch) + (ox * FIXED_BPP); if (use_nearest) - if (show_scanlines) renderer.scaler = optimize_text ? scaleNN_text_scanline : scaleNN_scanline; - else renderer.scaler = optimize_text ? scaleNN_text : scaleNN; + if (show_scanlines) renderer.scaler = scaleNN_scanline; + else renderer.scaler = scaleNN; else { sprintf(scaler_name, "%iX", scale); if (show_scanlines) { @@ -2646,7 +2575,7 @@ static void selectScaler_AR(int width, int height, int pitch) { // if (scale>6) scale = 6; // else - if (scale>2) scale = 4; // TODO: pillar/letterboxing at 3x produces vertical banding (some kind of alignment issue?) + if (scale>2) scale = 2; // TODO: pillar/letterboxing at 3x produces vertical banding (some kind of alignment issue?) // reduce scale if we don't have enough memory to accomodate it // scaled width and height can't be greater than our fixed page width or height @@ -2942,11 +2871,13 @@ void Core_load(void) { core.load_game(&game_info); SRAM_read(); + RTC_read(); // NOTE: must be called after core.load_game! struct retro_system_av_info av_info = {}; - core.get_system_av_info(&av_info); - + core.get_system_av_info(&av_info); + // FIX: some cores need configure a default controller. + core.set_controller_port_device(0, 1); core.fps = av_info.timing.fps; core.sample_rate = av_info.timing.sample_rate; double a = av_info.geometry.aspect_ratio; @@ -2964,6 +2895,7 @@ void Core_unload(void) { void Core_quit(void) { if (core.initialized) { SRAM_write(); + RTC_write(); core.unload_game(); core.deinit(); core.initialized = 0; @@ -3057,6 +2989,7 @@ void Menu_quit(void) { } void Menu_beforeSleep(void) { SRAM_write(); + RTC_write(); State_autosave(); putFile(AUTO_RESUME_PATH, game.path + strlen(SDCARD_PATH)); POW_setCPUSpeed(CPU_SPEED_MENU); @@ -3856,6 +3789,7 @@ static void Menu_loop(void) { } SRAM_write(); + RTC_write(); POW_warn(0); POW_setCPUSpeed(CPU_SPEED_MENU); // set Hz directly GFX_setVsync(VSYNC_STRICT); @@ -3863,7 +3797,6 @@ static void Menu_loop(void) { int rumble_strength = VIB_getStrength(); VIB_setStrength(0); - fast_forward = 0; POW_enableAutosleep(); PAD_reset(); @@ -4312,19 +4245,23 @@ static void trackFPS(void) { } static void limitFF(void) { + static uint64_t ff_frame_time = 0; static uint64_t last_time = 0; - const uint64_t now = getMicroseconds(); + static int last_max_speed = -1; + if (last_max_speed!=max_ff_speed) { + last_max_speed = max_ff_speed; + ff_frame_time = 1000000 / (core.fps * (max_ff_speed + 1)); + } + + uint64_t now = getMicroseconds(); if (fast_forward && max_ff_speed) { if (last_time == 0) last_time = now; int elapsed = now - last_time; if (elapsed>0 && elapsed<0x80000) { - uint64_t ff_frame_time = 1000000 / (core.fps * (max_ff_speed + 1)); // TODO: define this only when max_ff_speed changes if (elapsed0) { - // TODO: huh, this isn't causing the Tekken 3 hangs... - // printf("limitFF delay: %i\n", delay); fflush(stdout); + if (delay>0 && delay<17) { // don't allow a delay any greater than a frame SDL_Delay(delay); } } diff --git a/src/minui/makefile b/src/minui/makefile index 692350e..ccc41c1 100644 --- a/src/minui/makefile +++ b/src/minui/makefile @@ -6,8 +6,8 @@ TARGET = minui CC = $(CROSS_COMPILE)gcc CFLAGS = -Os -marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard -march=armv7-a -fomit-frame-pointer -CFLAGS += -I. -I../common -DPLATFORM=\"$(UNION_PLATFORM)\" -LDFLAGS = -ldl -lSDL -lSDL_image -lSDL_ttf -lmsettings -lpthread +CFLAGS += -I. -I../common -DPLATFORM=\"$(UNION_PLATFORM)\" -Ofast -std=gnu99 +LDFLAGS = -ldl -lSDL -lSDL_image -lSDL_ttf -lmsettings -lpthread -lm -lz # CFLAGS += -fsanitize=address -fno-common # LDFLAGS += -lasan diff --git a/src/minui/minui.c b/src/minui/minui.c index 6dde36b..68fa19d 100644 --- a/src/minui/minui.c +++ b/src/minui/minui.c @@ -283,7 +283,7 @@ static Directory* Directory_new(char* path, int selected) { else if (exactMatch(path, FAUX_FAVORITE_PATH)) { self->entries = getFavorites(); } - else if (!exactMatch(path, COLLECTIONS_PATH) && prefixMatch(COLLECTIONS_PATH, path)) { + else if (!exactMatch(path, COLLECTIONS_PATH) && prefixMatch(COLLECTIONS_PATH, path) && suffixMatch(".txt", path)) { self->entries = getCollection(path); } else if (suffixMatch(".m3u", path)) { diff --git a/src/ramdisk/charging.png b/src/ramdisk/charging.png new file mode 100644 index 0000000..bc8a67d Binary files /dev/null and b/src/ramdisk/charging.png differ diff --git a/src/ramdisk/patched-ramdisk.img b/src/ramdisk/patched-ramdisk.img new file mode 100644 index 0000000..8bd4fbc Binary files /dev/null and b/src/ramdisk/patched-ramdisk.img differ diff --git a/src/ramdisk/patched-ramdisk.meta b/src/ramdisk/patched-ramdisk.meta new file mode 100644 index 0000000..5656c2f --- /dev/null +++ b/src/ramdisk/patched-ramdisk.meta @@ -0,0 +1,3 @@ +patched version of ramdisk.img +from the official stock TF1 image +released on or around 2023-03-09 diff --git a/src/ramdisk/readme.txt b/src/ramdisk/readme.txt new file mode 100644 index 0000000..19659d4 --- /dev/null +++ b/src/ramdisk/readme.txt @@ -0,0 +1,35 @@ +can't just hexedit a ramdisk.img because of the internal CRC checksum + +make sure we have mkimage + + apt update && apt install u-boot-tools + +(the following steps are slow if performed in the shared workspace folder, +move ramdisk.img somewhere above that directory to do the work, eg. ~) + +strip the header from ramdisk.img + + dd bs=1 skip=64 if=ramdisk.img of=ramdisk-no-header.img + +unpack the image + + mkdir ramdisk && cd ramdisk + cpio -i --no-absolute-filenames < ../ramdisk-no-header.img + +patch charger to use /misc/charging.png for _every_ charging image :sweat_smile: + + sed -i 's,/res/images/%s.png,/misc/charging.png,' charger + +pack it up and recreate the image + + shopt -s dotglob + find . | cpio -H newc -o > ../ramdisk.cpio + mkimage -A arm -O linux -T ramdisk -n "Initial RAM Disk" -d ../ramdisk.cpio ../ramdisk.img.new + +based on + + https://boundarydevices.com/hacking-ram-disks/ + +--- + +if I decide to use this will need to copy charging.png and patched-ramdisk.img (as ramdisk.img) to /.system/rg35xx/dat diff --git a/toolchain/Dockerfile b/toolchain/Dockerfile index 3f75538..32a0cfd 100644 --- a/toolchain/Dockerfile +++ b/toolchain/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:buster-slim +FROM debian/eol:buster-slim ENV DEBIAN_FRONTEND noninteractive ENV TZ=America/New_York @@ -39,4 +39,4 @@ RUN cat ./setup-env.sh >> .bashrc VOLUME /root/workspace WORKDIR /root/workspace -CMD ["/bin/bash"] \ No newline at end of file +CMD ["/bin/bash"]