diff --git a/Dockerfile b/Dockerfile index 34826c70f9..fe5eaac4db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:jammy ARG DEBIAN_FRONTEND=noninteractive SHELL ["/usr/bin/bash", "-c"] -RUN apt-get update \ +RUN apt-get update --fix-missing\ && apt-get dist-upgrade -y \ && apt-get install -y locales sudo @@ -20,7 +20,7 @@ RUN adduser --disabled-password --gecos '' docker \ RUN apt-get install -y \ bc default-jre file gawk gcc git golang-go gperf libjson-perl libncurses5-dev \ libparse-yapp-perl libxml-parser-perl lzop make patchutils python-is-python3 \ - python3 parted unzip wget curl xfonts-utils xsltproc zip zstd + python3 parted unzip wget curl xfonts-utils xsltproc zip zstd rdfind ### Cross compiling on ARM RUN if [ "$(uname -m)" = "aarch64" ]; then apt-get install -y --no-install-recommends qemu-user-binfmt libc6-dev-amd64-cross; fi diff --git a/Makefile b/Makefile index 917d3f16a2..1f0467404d 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ src-pkg: docs: ./tools/foreach './scripts/clean emulators && ./scripts/build emulators' -world: RK3588 RK3566 RK3326 RK3399 S922X +world: RK3588 RK3566 RK3566-X55 RK3326 RK3399 S922X AMD64: unset DEVICE_ROOT @@ -46,10 +46,19 @@ S922X: PROJECT=Amlogic DEVICE=S922X ARCH=arm ./scripts/build_distro PROJECT=Amlogic DEVICE=S922X ARCH=aarch64 ./scripts/build_distro +S922X-PANFROST: + unset DEVICE_ROOT + PROJECT=Amlogic DEVICE=S922X ARCH=arm USE_MALI=no ./scripts/build_distro + PROJECT=Amlogic DEVICE=S922X ARCH=aarch64 USE_MALI=no ./scripts/build_distro + RK3566: unset DEVICE_ROOT - PROJECT=Rockchip DEVICE=RK3566 ARCH=arm ./scripts/build_distro - PROJECT=Rockchip DEVICE=RK3566 ARCH=aarch64 ./scripts/build_distro + DEVICE_ROOT=RK3566 PROJECT=Rockchip DEVICE=RK3566 ARCH=arm ./scripts/build_distro + DEVICE_ROOT=RK3566 PROJECT=Rockchip DEVICE=RK3566 ARCH=aarch64 ./scripts/build_distro + +RK3566-X55: + DEVICE_ROOT=RK3566 PROJECT=Rockchip DEVICE=RK3566-X55 ARCH=arm ./scripts/build_distro + DEVICE_ROOT=RK3566 PROJECT=Rockchip DEVICE=RK3566-X55 ARCH=aarch64 ./scripts/build_distro RK3326: unset DEVICE_ROOT diff --git a/config/emulators/segamodel3.conf b/config/emulators/segamodel3.conf new file mode 100644 index 0000000000..831b92a11d --- /dev/null +++ b/config/emulators/segamodel3.conf @@ -0,0 +1,10 @@ +SYSTEM_NAME="segamodel3" +SYSTEM_FULLNAME="Sega Model 3" +SYSTEM_MANUFACTURER="Sega" +SYSTEM_RELEASE="1996" +SYSTEM_HARDWARE="arcade" +SYSTEM_PATH="/storage/roms/segamodel3" +SYSTEM_EXTENSION=".zip" +SYSTEM_COMMAND="/usr/bin/runemu.sh %ROM% -P%SYSTEM% --core=%CORE% --emulator=%EMULATOR% --controllers=\"%CONTROLLERSCONFIG%\"" +SYSTEM_PLATFORM="arcade" +SYSTEM_THEME="model3" diff --git a/config/show_config b/config/show_config index 566d7edd6c..4fb4da1876 100644 --- a/config/show_config +++ b/config/show_config @@ -91,10 +91,6 @@ show_config() { config_message+="\n - SquashFS Compression Options: \t ${SQUASHFS_COMPRESSION_OPTION}" fi - for config_modules in $INITRAMFS_MODULES; do - config_message="${config_message}\n - Initramfs modules:\t\t\t $config_modules" - done - # Network service configuration config_message="${config_message}\n\n Network service configuration:" diff --git a/distributions/ROCKNIX/options b/distributions/ROCKNIX/options index 606b04595b..0a00eb1ed9 100644 --- a/distributions/ROCKNIX/options +++ b/distributions/ROCKNIX/options @@ -50,6 +50,10 @@ CLEAN_EMU_32BIT="lib32 box86 pcsx_rearmed-lr arm" # Sway depends on it, weston will use it if it's built but we don't want that. CLEAN_WESTON="libdisplay-info sway" +# Packages to clean for S922X platform - all vary based on VULKAN_SUPPORT + CLEAN_S922X="beetle-psx-lr dolphin-sa duckstation-sa fileman emulationstation flycast-lr flycast-sa" + CLEAN_S922X+=" gmu gzdoom-sa libplacebo lime3ds-sa linux mali-bifrost mesa moonlight parallel-n64-lr" + CLEAN_S922X+=" pipewire portmaster ppsspp-sa qt5 retroarch SDL2" # additional drivers to install: # for a list of additional drivers see packages/linux-drivers @@ -57,11 +61,22 @@ # e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2" # ADDITIONAL_DRIVERS="" +# build and install driver addons (yes / no) + DRIVER_ADDONS_SUPPORT="no" + +# driver addons to install: +# for a list of additinoal drivers see packages/linux-driver-addons +# Space separated list is supported, + DRIVER_ADDONS="" + +# Disable 32BIT support + ENABLE_32BIT="true" + # build and install bluetooth support (yes / no) BLUETOOTH_SUPPORT="yes" # build and install Avahi (Zeroconf) daemon (yes / no) - AVAHI_DAEMON="yes" + AVAHI_DAEMON="no" # build with NFS support (mounting nfs shares via the OS) (yes / no) NFS_SUPPORT="no" @@ -70,17 +85,20 @@ SAMBA_SUPPORT="no" # build and install Samba Server (yes / no) - SAMBA_SERVER="no" + SAMBA_SERVER="yes" # build and install SFTP Server (yes / no) SFTP_SERVER="yes" # build and install Simple HTTP Server (yes / no) - SIMPLE_HTTP_SERVER="no" + SIMPLE_HTTP_SERVER="yes" # build and install OpenVPN support (yes / no) OPENVPN_SUPPORT="no" +# build and install ZeroTier support (yes / no) + ZEROTIER_SUPPORT="yes" + # build and install WireGuard support (yes / no) WIREGUARD_SUPPORT="yes" @@ -93,10 +111,10 @@ EXFAT="yes" # build and install NTFS-3G fuse support (yes / no) - NTFS3G="yes" + NTFS3G="no" # build and install hfs filesystem utilities (yes / no) - HFSTOOLS="yes" + HFSTOOLS="no" # Target an emulation device EMULATION_DEVICE="${EMULATION_DEVICE:-yes}" @@ -141,6 +159,9 @@ # Space separated list is supported, # e.g. ADDITIONAL_PACKAGES="PACKAGE1 PACKAGE2" +# build and install CEC framework support (yes / no) + CEC_FRAMEWORK_SUPPORT="no" + # build with installer (yes / no) INSTALLER_SUPPORT="no" @@ -154,11 +175,14 @@ NANO_EDITOR="yes" # cron support (yes / no) - CRON_SUPPORT="yes" + CRON_SUPPORT="no" + +# htop tool (yes / no) + HTOP_TOOL="yes" # Distribution Specific source location DISTRO_MIRROR="" - DISTRO_SRC="https://github.com/JustEnoughLinuxOS" + DISTRO_SRC="https://github.com/ROCKNIX" # Default size of system partition, in MB, eg. 512 SYSTEM_SIZE=2048 @@ -173,7 +197,7 @@ GET_HANDLER_SUPPORT="archive git file" # Partition labels for USB/SD installation media - DISTRO_BOOTLABEL="JELOS" + DISTRO_BOOTLABEL="ROCKNIX" DISTRO_DISKLABEL="STORAGE" # Settings package name - blank if not required diff --git a/documentation/PER_DEVICE_DOCUMENTATION/RK3566-X55/SUPPORTED_EMULATORS_AND_CORES.md b/documentation/PER_DEVICE_DOCUMENTATION/RK3566-X55/SUPPORTED_EMULATORS_AND_CORES.md index b8112f8d14..27b3e09213 100644 --- a/documentation/PER_DEVICE_DOCUMENTATION/RK3566-X55/SUPPORTED_EMULATORS_AND_CORES.md +++ b/documentation/PER_DEVICE_DOCUMENTATION/RK3566-X55/SUPPORTED_EMULATORS_AND_CORES.md @@ -24,16 +24,16 @@ This document describes all available systems emulators and cores available for |Atari|Atari 7800 (atari7800)|1986|`atari7800`|.a78 .bin .zip .7z|**retroarch:** prosystem (default)
| |Atari|Atari 800 (atari800)|1979|`atari800`|.rom .xfd .atr .atx .cdm .cas .car .bin .a52 .xex .zip .7z|**retroarch:** atari800 (default)
| |Atari|Atari Jaguar (atarijaguar)|1993|`atarijaguar`|.j64 .jag .rom .abs .cof .bin .prg|**retroarch:** virtualjaguar (default)
| -|Atari|Atari Lynx (atarilynx)|1989|`atarilynx`|.lnx .lyx .o .zip .7z|**retroarch:** handy (default)
**retroarch:** beetle_lynx
| +|Atari|Atari Lynx (atarilynx)|1989|`atarilynx`|.lnx .lyx .o .zip .7z|**retroarch:** handy (default)
**retroarch:** beetle_lynx
**mednafen:** lynx
| |Atari|Atari ST (atarist)|1985|`atarist`|.st .msa .stx .dim .ipf .m3u .zip .7z|**retroarch:** hatari (default)
**hatarisa:** hatarisa
| |Bandai|SuFami Turbo (sufami)|1996|`sufami`|.st .zip .7z|**retroarch:** snes9x (default)
| -|Bandai|Wonderswan (wonderswan)|1999|`wonderswan`|.ws .zip .7z|**retroarch:** beetle_wswan (default)
| -|Bandai|Wonderswan Color (wonderswancolor)|2000|`wonderswancolor`|.wsc .zip .7z|**retroarch:** beetle_wswan (default)
| +|Bandai|Wonderswan (wonderswan)|1999|`wonderswan`|.ws .wsc .zip .7z|**retroarch:** beetle_wswan (default)
**mednafen:** wswan
| +|Bandai|Wonderswan Color (wonderswancolor)|2000|`wonderswancolor`|.ws .wsc .zip .7z|**retroarch:** beetle_wswan (default)
**mednafen:** wswan
| |belogic|Uzebox (uzebox)|2008|`uzebox`|.uze|**retroarch:** uzem (default)
| |Capcom|CPS-I (cps1)|1988|`cps1`|.zip .7z|**retroarch:** fbneo (default)
**retroarch:** mame2003_plus
**retroarch:** mame2010
**retroarch:** fbalpha2012
**AdvanceMame:** AdvanceMame
| |Capcom|CPS-II (cps2)|1993|`cps2`|.zip .7z|**retroarch:** fbneo (default)
**retroarch:** mame2003_plus
**retroarch:** mame2010
**retroarch:** fbalpha2012
**AdvanceMame:** AdvanceMame
| |Capcom|CPS-III (cps3)|1996|`cps3`|.zip .7z|**retroarch:** fbneo (default)
**retroarch:** mame2003_plus
**retroarch:** mame2010
**retroarch:** fbalpha2012
**AdvanceMame:** AdvanceMame
| -|Coleco|ColecoVision (colecovision)|1982|`coleco`|.bin .col .rom .zip .7z|**retroarch:** bluemsx (default)
**retroarch:** gearcoleco
**retroarch:** smsplus
| +|Coleco|ColecoVision (colecovision)|1982|`coleco`|.bin .col .rom .zip .7z|**retroarch:** gearcoleco (default)
**retroarch:** bluemsx
**retroarch:** smsplus
| |Commodore|Amiga (amiga)|1985|`amiga`|.zip .adf .uae .ipf .dms .adz .lha .m3u .hdf .hdz|**retroarch:** puae2021 (default)
**retroarch:** puae
**amiberry:** amiberry
**retroarch:** uae4arm
| |Commodore|Amiga CD32 (amigacd32)|1994|`amigacd32`|.iso .cue .lha .chd|**retroarch:** puae2021 (default)
**retroarch:** puae
**retroarch:** uae4arm
| |Commodore|Commodore 128 (c128)|1985|`c128`|.d64 .d71 .d80 .d81 .d82 .g64 .g41 .x64 .t64 .tap .prg .p00 .crt .bin .d6z .d7z .d8z .g6z .g4z .x6z .cmd .m3u .vsf .nib .nbz .zip|**retroarch:** vice_x128 (default)
**vicesa:** x128
| @@ -52,70 +52,73 @@ This document describes all available systems emulators and cores available for |Microsoft|DOS (pc)|1981|`pc`|.com .bat .exe .dosz|**retroarch:** dosbox_pure
**retroarch:** dosbox_svn
| |Microsoft|MSX (msx)|1983|`msx`|.dsk .mx1 .mx2 .rom .zip .7z .m3u|**retroarch:** bluemsx (default)
**retroarch:** fmsx
| |Microsoft|MSX 2 (msx2)|1988|`msx2`|.dsk .mx1 .mx2 .rom .zip .7z .m3u|**retroarch:** bluemsx (default)
**retroarch:** fmsx
| -|NEC|PC Engine (pcengine)|1987|`pcengine`|.pce .bin .zip .7z|**retroarch:** beetle_pce_fast (default)
**retroarch:** beetle_pce
**retroarch:** beetle_supergrafx
| -|NEC|PC Engine CD (pcenginecd)|1988|`pcenginecd`|.cue .ccd .chd .toc .m3u|**retroarch:** beetle_pce_fast (default)
**retroarch:** beetle_pce
**retroarch:** beetle_supergrafx
| -|NEC|PC-8800 (pc-8800)|1981|`pc88`|.d88 .m3u|**retroarch:** quasi88 (default)
| +|NEC|PC Engine (pcengine)|1987|`pcengine`|.pce .bin .zip .7z|**retroarch:** beetle_pce_fast (default)
**retroarch:** beetle_pce
**retroarch:** beetle_supergrafx
**mednafen:** pce
**mednafen:** pce_fast
| +|NEC|PC Engine CD (pcenginecd)|1988|`pcenginecd`|.cue .ccd .chd .toc .m3u|**retroarch:** beetle_pce_fast (default)
**retroarch:** beetle_pce
**retroarch:** beetle_supergrafx
**mednafen:** pce
**mednafen:** pce_fast
| +|NEC|PC-8800 (pc-8800)|1981|`pc88`|.d88 .u88 .m3u|**retroarch:** quasi88 (default)
| |NEC|PC-9800 (pc-9800)|1983|`pc98`|.d98 .zip .fdi .fdd .2hd .tfd .d88 .hdm .xdf .dup .hdi .thd .nhd .hdd .hdn|**retroarch:** np2kai (default)
| -|NEC|PC-FX (pcfx)|1994|`pcfx`|.chd .cue .ccd .toc|**retroarch:** beetle_pcfx (default)
| -|NEC|SuperGrafx (supergrafx)|1989|`sgfx`|.pce .sgx .cue .ccd .chd .zip .7z|**retroarch:** beetle_supergrafx
**retroarch:** beetle_pce
| -|NEC|TurboGrafx-16 (tg16)|1989|`tg16`|.pce .bin .zip .7z|**retroarch:** beetle_pce_fast (default)
**retroarch:** beetle_pce
**retroarch:** beetle_supergrafx
| -|NEC|TurboGrafx-CD (tg16cd)|1989|`tg16cd`|.cue .ccd .chd .toc .m3u|**retroarch:** beetle_pce_fast (default)
**retroarch:** beetle_pce
**retroarch:** beetle_supergrafx
| +|NEC|PC-FX (pcfx)|1994|`pcfx`|.chd .cue .ccd .toc|**retroarch:** beetle_pcfx (default)
**mednafen:** pcfx
| +|NEC|SuperGrafx (supergrafx)|1989|`sgfx`|.pce .sgx .cue .ccd .chd .zip .7z|**retroarch:** beetle_supergrafx
**retroarch:** beetle_pce
**mednafen:** pce
**mednafen:** pce_fast
| +|NEC|TurboGrafx-16 (tg16)|1989|`tg16`|.pce .bin .zip .7z|**retroarch:** beetle_pce_fast (default)
**retroarch:** beetle_pce
**retroarch:** beetle_supergrafx
**mednafen:** pce
**mednafen:** pce_fast
| +|NEC|TurboGrafx-CD (tg16cd)|1989|`tg16cd`|.cue .ccd .chd .toc .m3u|**retroarch:** beetle_pce_fast (default)
**retroarch:** beetle_pce
**retroarch:** beetle_supergrafx
**mednafen:** pce
**mednafen:** pce_fast
| |Nesbox|TIC-80 (tic-80)|2017|`tic-80`|.tic|**retroarch:** tic80 (default)
| -|Nintendo|Famicom (famicom)|1983|`famicom`|.nes .unif .unf .zip .7z|**retroarch:** nestopia (default)
**retroarch:** fceumm
**retroarch:** quicknes
**retroarch:** mesen
| -|Nintendo|Famicom Disk System (fds)|1986|`fds`|.fds .zip .7z|**retroarch:** nestopia (default)
**retroarch:** fceumm
**retroarch:** quicknes
**retroarch:** mesen
| +|Nintendo|Famicom (famicom)|1983|`famicom`|.nes .unif .unf .zip .7z|**retroarch:** nestopia (default)
**retroarch:** fceumm
**retroarch:** quicknes
**retroarch:** mesen
**mednafen:** nes
| +|Nintendo|Famicom Disk System (fds)|1986|`fds`|.fds .zip .7z|**retroarch:** nestopia (default)
**retroarch:** fceumm
**retroarch:** quicknes
**retroarch:** mesen
**mednafen:** nes
| |Nintendo|Game & Watch (gameandwatch)|1980|`gameandwatch`|.mgw .zip .7z|**retroarch:** gw
**retroarch:** mame
| -|Nintendo|Game Boy (gb)|1989|`gb`|.gb .gbc .zip .7z|**retroarch:** gambatte (default)
**retroarch:** sameboy
**retroarch:** gearboy
**retroarch:** tgbdual
**retroarch:** mgba
**retroarch:** vbam
| -|Nintendo|Game Boy (Hacks) (gbh)|1989|`gbh`|.gb .zip .7z|**retroarch:** gambatte (default)
**retroarch:** sameboy
**retroarch:** gearboy
**retroarch:** tgbdual
**retroarch:** mgba
**retroarch:** vbam
| -|Nintendo|Game Boy Advance (gba)|2001|`gba`|.gba .zip .7z|**retroarch:** mgba (default)
**retroarch:** gbsp
**retroarch:** vbam
**retroarch:** vba_next
**retroarch:** beetle_gba
**retroarch:** gpsp
| -|Nintendo|Game Boy Advance (Hacks) (gbah)|2001|`gbah`|.gba .zip .7z|**retroarch:** mgba (default)
**retroarch:** gbsp
**retroarch:** vbam
**retroarch:** vba_next
**retroarch:** beetle_gba
| -|Nintendo|Game Boy Color (gbc)|1998|`gbc`|.gb .gbc .zip .7z|**retroarch:** gambatte (default)
**retroarch:** sameboy
**retroarch:** gearboy
**retroarch:** tgbdual
**retroarch:** mgba
**retroarch:** vbam
| -|Nintendo|Game Boy Color (Hacks) (gbch)|1998|`gbch`|.gb .gbc .zip .7z|**retroarch:** gambatte (default)
**retroarch:** sameboy
**retroarch:** gearboy
**retroarch:** tgbdual
**retroarch:** mgba
**retroarch:** vbam
| -|Nintendo|NES (Hacks) (nesh)|1985|`nesh`|.nes .unif .unf .zip .7z|**retroarch:** nestopia (default)
**retroarch:** fceumm
**retroarch:** quicknes
**retroarch:** mesen
| +|Nintendo|Game Boy (gb)|1989|`gb`|.gb .gbc .zip .7z|**retroarch:** gambatte (default)
**retroarch:** sameboy
**retroarch:** gearboy
**retroarch:** tgbdual
**retroarch:** mgba
**retroarch:** vbam
**mednafen:** gb
| +|Nintendo|Game Boy (Hacks) (gbh)|1989|`gbh`|.gb .zip .7z|**retroarch:** gambatte (default)
**retroarch:** sameboy
**retroarch:** gearboy
**retroarch:** tgbdual
**retroarch:** mgba
**retroarch:** vbam
**mednafen:** gb
| +|Nintendo|Game Boy Advance (gba)|2001|`gba`|.gba .zip .7z|**retroarch:** mgba (default)
**retroarch:** gbsp
**retroarch:** vbam
**retroarch:** vba_next
**retroarch:** beetle_gba
**retroarch:** gpsp
**mednafen:** gba
| +|Nintendo|Game Boy Advance (Hacks) (gbah)|2001|`gbah`|.gba .zip .7z|**retroarch:** mgba (default)
**retroarch:** gbsp
**retroarch:** vbam
**retroarch:** vba_next
**retroarch:** beetle_gba
**mednafen:** gba
| +|Nintendo|Game Boy Color (gbc)|1998|`gbc`|.gb .gbc .zip .7z|**retroarch:** gambatte (default)
**retroarch:** sameboy
**retroarch:** gearboy
**retroarch:** tgbdual
**retroarch:** mgba
**retroarch:** vbam
**mednafen:** gb
| +|Nintendo|Game Boy Color (Hacks) (gbch)|1998|`gbch`|.gb .gbc .zip .7z|**retroarch:** gambatte (default)
**retroarch:** sameboy
**retroarch:** gearboy
**retroarch:** tgbdual
**retroarch:** mgba
**retroarch:** vbam
**mednafen:** gb
| +|Nintendo|NES (Hacks) (nesh)|1985|`nesh`|.nes .unif .unf .zip .7z|**retroarch:** nestopia (default)
**retroarch:** fceumm
**retroarch:** quicknes
**retroarch:** mesen
**mednafen:** nesh
| |Nintendo|Nintendo 64 (n64)|1996|`n64`|.z64 .n64 .v64 .zip .7z|**retroarch:** mupen64plus_next (default)
**retroarch:** mupen64plus
**retroarch:** parallel_n64
**mupen64plus:** mupen64plus-sa
| |Nintendo|Nintendo DS (nds)|2005|`nds`|.nds .zip .7z|**drastic:** drastic-sa (default)
**retroarch:** melonds
**retroarch:** desmume
| -|Nintendo|Nintendo Entertainment System (nes)|1985|`nes`|.nes .unif .unf .zip .7z|**retroarch:** nestopia (default)
**retroarch:** fceumm
**retroarch:** quicknes
**retroarch:** mesen
| +|Nintendo|Nintendo Entertainment System (nes)|1985|`nes`|.nes .unif .unf .zip .7z|**retroarch:** nestopia (default)
**retroarch:** fceumm
**retroarch:** quicknes
**retroarch:** mesen
**mednafen:** nes
| |Nintendo|Pokémon Mini (pokemini)|2001|`pokemini`|.min .zip .7z|**retroarch:** pokemini (default)
| |Nintendo|Satellaview (satellaview)|1995|`satellaview`|.smc .fig .bs .sfc .bsx .swc .zip .7z|**retroarch:** snes9x (default)
**retroarch:** snes9x2010
**retroarch:** snes9x2002
**retroarch:** snes9x2005_plus
| |Nintendo|Super Famicom (sfc)|1990|`sfc`|.smc .fig .sfc .swc .zip .7z|**retroarch:** snes9x (default)
**retroarch:** snes9x2010
**retroarch:** snes9x2002
**retroarch:** snes9x2005_plus
**retroarch:** beetle_supafaust
**retroarch:** bsnes_mercury_performance
| -|Nintendo|Super NES MSU-1 (snesmsu1)|2012|`snesmsu1`|.smc .fig .sfc .swc .zip .7z|**retroarch:** snes9x (default)
**retroarch:** beetle_supafaust
| -|Nintendo|Super Nintendo (Hacks) (snesh)|1991|`snesh`|.smc .fig .sfc .swc .zip .7z|**retroarch:** snes9x (default)
**retroarch:** snes9x2010
**retroarch:** snes9x2002
**retroarch:** snes9x2005_plus
**retroarch:** beetle_supafaust
**retroarch:** bsnes_mercury_performance
| -|Nintendo|Super Nintendo (snes)|1991|`snes`|.smc .fig .sfc .swc .zip .7z|**retroarch:** snes9x (default)
**retroarch:** snes9x2010
**retroarch:** snes9x2002
**retroarch:** snes9x2005_plus
**retroarch:** beetle_supafaust
**retroarch:** bsnes_mercury_performance
| -|Nintendo|Virtual Boy (virtualboy)|1995|`virtualboy`|.vb .zip .7z|**retroarch:** beetle_vb (default)
| +|Nintendo|Super NES MSU-1 (snesmsu1)|2012|`snesmsu1`|.smc .fig .sfc .swc .zip .7z|**retroarch:** snes9x (default)
**retroarch:** beetle_supafaust
**mednafen:** snes_faust
| +|Nintendo|Super Nintendo (Hacks) (snesh)|1991|`snesh`|.smc .fig .sfc .swc .zip .7z|**retroarch:** snes9x (default)
**retroarch:** snes9x2010
**retroarch:** snes9x2002
**retroarch:** snes9x2005_plus
**retroarch:** beetle_supafaust
**retroarch:** bsnes_mercury_performance
**mednafen:** snes_faust
| +|Nintendo|Super Nintendo (snes)|1991|`snes`|.smc .fig .sfc .swc .zip .7z|**retroarch:** snes9x (default)
**retroarch:** snes9x2010
**retroarch:** snes9x2002
**retroarch:** snes9x2005_plus
**retroarch:** beetle_supafaust
**retroarch:** bsnes_mercury_performance
**mednafen:** snes_faust
**mednafen:** snes_faust
| +|Nintendo|Virtual Boy (virtualboy)|1995|`virtualboy`|.vb .zip .7z|**retroarch:** beetle_vb (default)
**mednafen:** vb
| +|Palm, Inc.|Palm OS (palm)|1996|`palm`|.prc .pqa .img .pdb .zip|**retroarch:** mu (default)
| |Panasonic|3DO (3do)|1993|`3do`|.iso .bin .chd .cue|**retroarch:** opera (default)
| |Philips|CD-i (cdi)|1991|`cdi`|.chd .cue .iso|**retroarch:** same_cdi (default)
| |Philips|VideoPac (videopac)|1978|`videopac`|.bin .zip .7z|**retroarch:** o2em (default)
| |Sammy|Atomiswave (atomiswave)|2003|`atomiswave`|.lst .bin .dat .zip .7z|**retroarch:** flycast2021
**retroarch:** flycast
**flycast:** flycast-sa
| |Sega|Dreamcast (dreamcast)|1998|`dreamcast`|.cdi .gdi .chd .m3u .cue|**retroarch:** flycast2021
**retroarch:** flycast
**flycast:** flycast-sa
| -|Sega|Game Gear (gamegear)|1990|`gamegear`|.bin .gg .zip .7z|**retroarch:** gearsystem (default)
**retroarch:** genesis_plus_gx
**retroarch:** picodrive
**retroarch:** smsplus
| -|Sega|Game Gear (Hacks) (ggh)|1990|`gamegearh`|.bin .gg .zip .7z|**retroarch:** gearsystem (default)
**retroarch:** genesis_plus_gx
**retroarch:** picodrive
**retroarch:** smsplus
| -|Sega|Genesis (genesis)|1989|`genesis`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
| -|Sega|Genesis (Hacks) (genh)|1989|`genh`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
| -|Sega|Master System (mastersystem)|1985|`mastersystem`|.bin .sms .zip .7z|**retroarch:** gearsystem (default)
**retroarch:** genesis_plus_gx
**retroarch:** picodrive
**retroarch:** smsplus
| +|Sega|Game Gear (gamegear)|1990|`gamegear`|.bin .gg .zip .7z|**retroarch:** gearsystem (default)
**retroarch:** genesis_plus_gx
**retroarch:** picodrive
**retroarch:** smsplus
**mednafen:** gg
| +|Sega|Game Gear (Hacks) (ggh)|1990|`gamegearh`|.bin .gg .zip .7z|**retroarch:** gearsystem (default)
**retroarch:** genesis_plus_gx
**retroarch:** picodrive
**retroarch:** smsplus
**mednafen:** gg
| +|Sega|Genesis (genesis)|1989|`genesis`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
**mednafen:** md
| +|Sega|Genesis (Hacks) (genh)|1989|`genh`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
**mednafen:** md
| +|Sega|Master System (mastersystem)|1985|`mastersystem`|.bin .sms .zip .7z|**retroarch:** gearsystem (default)
**retroarch:** genesis_plus_gx
**retroarch:** picodrive
**retroarch:** smsplus
**mednafen:** sms
| |Sega|Mega CD (megacd)|1991|`megacd`|.chd .cue .iso .m3u|**retroarch:** genesis_plus_gx (default)
**retroarch:** picodrive
| -|Sega|Mega Drive (megadrive)|1990|`megadrive`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
| -|Sega|Mega Drive (megadrive-japan)|1988|`megadrive-japan`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
| +|Sega|Mega Drive (megadrive)|1990|`megadrive`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
**mednafen:** md
| +|Sega|Mega Drive (megadrive-japan)|1988|`megadrive-japan`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
**mednafen:** md
| |Sega|Naomi (naomi)|1998|`naomi`|.lst .bin .dat .zip .7z|**retroarch:** flycast2021
**retroarch:** flycast
**flycast:** flycast-sa
| |Sega|Saturn (saturn)|1994|`saturn`|.cue .chd .iso|**yabasanshiro:** yabasanshiro-sa (default)
**retroarch:** yabasanshiro
| |Sega|Sega 32X (sega32x)|1994|`sega32x`|.32x .smd .bin .md .zip .7z|**retroarch:** picodrive (default)
| |Sega|Sega CD (segacd)|1991|`segacd`|.chd .cue .iso .m3u|**retroarch:** genesis_plus_gx (default)
**retroarch:** picodrive
| |Sega|SG-1000 (sg-1000)|1983|`sg-1000`|.bin .sg .zip .7z|**retroarch:** gearsystem (default)
**retroarch:** genesis_plus_gx
**retroarch:** picodrive
| |Sega|ST-V (st-v)|1995|`st-v`|.zip .ZIP|| -|Sharp|X1 (x1)|1982|`x1`|.dx1 .2d .2hd .tfd .d88 .hdm .xdf .dup .tap .cmd .zip .7z|**retroarch:** x1 (default)
| +|Sharp|X1 (x1)|1982|`x1`|.dx1 .2d .2hd .tfd .d88 .88d .hdm .xdf .dup .tap .cmd .zip .7z|**retroarch:** x1 (default)
| |Sharp|x68000 (x68000)|1987|`x68000`|.dim .img .d88 .hdm .dup .2hd .xdf .hdf .cmd .m3u .zip .7z|**retroarch:** px68k (default)
| |Sinclair|ZX Spectrum (zxspectrum)|1982|`zxspectrum`|.tzx .tap .z80 .rzx .scl .trd .dsk .zip .7z|**retroarch:** fuse
| -|Sinclair|ZX81 (zx81)|1981|`zx81`|.tzx .p .zip .7z|**retroarch:** 81 (default)
| +|Sinclair|ZX81 (zx81)|1981|`zx81`|.tzx .p .t81 .zip .7z|**retroarch:** 81 (default)
| |Smith Engineering|Vectrex (vectrex)|1982|`vectrex`|.bin .gam .vec .zip .7z|**retroarch:** vecx (default)
| |SNK|Neo Geo (neogeo)|1990|`neogeo`|.7z .zip|**retroarch:** fbneo (default)
**retroarch:** mame2003_plus
**retroarch:** fbalpha2012
**retroarch:** fbalpha2019
**retroarch:** mame2010
**retroarch:** mame2015
**retroarch:** mame
| |SNK|Neo Geo CD (neocd)|1994|`neocd`|.cue .iso .chd|**retroarch:** neocd (default)
**retroarch:** fbneo
| -|SNK|Neo Geo Pocket (ngp)|1998|`ngp`|.ngc .ngp .zip .7z|**retroarch:** beetle_ngp (default)
**retroarch:** race
| -|SNK|Neo Geo Pocket Color (ngpc)|1999|`ngpc`|.ngc .zip .7z|**retroarch:** beetle_ngp (default)
**retroarch:** race
| +|SNK|Neo Geo Pocket (ngp)|1998|`ngp`|.ngp .ngc .zip .7z|**retroarch:** beetle_ngp (default)
**retroarch:** race
**mednafen:** ngp
| +|SNK|Neo Geo Pocket Color (ngpc)|1999|`ngpc`|.ngp .ngc .zip .7z|**retroarch:** beetle_ngp (default)
**retroarch:** race
**mednafen:** ngp
| |Sony|PlayStation (psx)|1994|`psx`|.bin .cue .img .mdf .pbp .toc .cbn .m3u .ccd .chd .iso|**retroarch:** pcsx_rearmed32 (default)
**retroarch:** pcsx_rearmed
**duckstation:** duckstation-sa
**retroarch:** duckstation
**retroarch:** swanstation
| |Sony|PlayStation Portable (psp)|2004|`psp`|.iso .cso .pbp .chd|**ppsspp:** ppsspp-sa (default)
| |Sony|PSP Minis (pspminis)|2004|`pspminis`|.iso .cso .pbp|**ppsspp:** ppsspp-sa (default)
**retroarch:** ppsspp
| |Sun Microsystems|J2ME (j2me)|2002|`j2me`|.jar|**retroarch:** freej2me (default)
| +|Thomson|MO/TO family (TO7, TO7/70, TO8, TO8D, TO9, TO9+, MO5 and MO6) (moto)|1982|`moto`|.fd .sap .k7 .m7 .m5 .rom|**retroarch:** theodore (default)
| |Various|CHIP-8 / S-CHIP / XO-CHIP (chip-8)|1978|`chip-8`|.ch8 .sc8 .xo8|**retroarch:** jaxe (default)
| |Various|EasyRPG (easyrpg)|2003|`easyrpg`|.zip .easyrpg .ldb|**retroarch:** easyrpg (default)
| |Various|OpenBOR (openbor)|2003|`openbor`|.pak|**OpenBOR:** OpenBOR (default)
| |Various|ScummVM (scummvm)|2001|`games`|.sh .svm .scummvm|**scummvmsa:** scummvm (default)
**retroarch:** scummvm
| +|Various|Vircon32 (vircon32)|2021|`vircon32`|.v32|**retroarch:** vircon32 (default)
| |Watara|Supervision (supervision)|1992|`supervision`|.sv .zip .7z|**retroarch:** potator (default)
| |Welback Holdings|Mega Duck (megaduck)|1993|`megaduck`|.bin .zip .7z|**retroarch:** sameduck (default)
| diff --git a/documentation/PER_DEVICE_DOCUMENTATION/RK3588/SUPPORTED_EMULATORS_AND_CORES.md b/documentation/PER_DEVICE_DOCUMENTATION/RK3588/SUPPORTED_EMULATORS_AND_CORES.md index ab4fb4c8c2..256413fe57 100644 --- a/documentation/PER_DEVICE_DOCUMENTATION/RK3588/SUPPORTED_EMULATORS_AND_CORES.md +++ b/documentation/PER_DEVICE_DOCUMENTATION/RK3588/SUPPORTED_EMULATORS_AND_CORES.md @@ -87,8 +87,8 @@ This document describes all available systems emulators and cores available for |Panasonic|3DO (3do)|1993|`3do`|.iso .bin .chd .cue|**retroarch:** opera (default)
| |Philips|CD-i (cdi)|1991|`cdi`|.chd .cue .iso|**retroarch:** same_cdi (default)
| |Philips|VideoPac (videopac)|1978|`videopac`|.bin .zip .7z|**retroarch:** o2em (default)
| -|Sammy|Atomiswave (atomiswave)|2003|`atomiswave`|.lst .bin .dat .zip .7z|**retroarch:** flycast2021
**retroarch:** flycast
**flycast:** flycast-sa
| -|Sega|Dreamcast (dreamcast)|1998|`dreamcast`|.cdi .gdi .chd .m3u .cue|**retroarch:** flycast2021
**retroarch:** flycast
**flycast:** flycast-sa
| +|Sammy|Atomiswave (atomiswave)|2003|`atomiswave`|.lst .bin .dat .zip .7z|**retroarch:** flycast2021 (default)
**flycast:** flycast-sa
| +|Sega|Dreamcast (dreamcast)|1998|`dreamcast`|.cdi .gdi .chd .m3u .cue|**retroarch:** flycast2021 (default)
**flycast:** flycast-sa
| |Sega|Game Gear (gamegear)|1990|`gamegear`|.bin .gg .zip .7z|**retroarch:** gearsystem (default)
**retroarch:** genesis_plus_gx
**retroarch:** picodrive
**retroarch:** smsplus
**mednafen:** gg
| |Sega|Game Gear (Hacks) (ggh)|1990|`gamegearh`|.bin .gg .zip .7z|**retroarch:** gearsystem (default)
**retroarch:** genesis_plus_gx
**retroarch:** picodrive
**retroarch:** smsplus
**mednafen:** gg
| |Sega|Genesis (genesis)|1989|`genesis`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
**mednafen:** md
| @@ -97,10 +97,11 @@ This document describes all available systems emulators and cores available for |Sega|Mega CD (megacd)|1991|`megacd`|.chd .cue .iso .m3u|**retroarch:** genesis_plus_gx (default)
**retroarch:** picodrive
| |Sega|Mega Drive (megadrive)|1990|`megadrive`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
**mednafen:** md
| |Sega|Mega Drive (megadrive-japan)|1988|`megadrive-japan`|.bin .gen .md .sg .smd .zip .7z|**retroarch:** genesis_plus_gx (default)
**retroarch:** genesis_plus_gx_wide
**retroarch:** picodrive
**mednafen:** md
| -|Sega|Naomi (naomi)|1998|`naomi`|.lst .bin .dat .zip .7z|**retroarch:** flycast2021
**retroarch:** flycast
**flycast:** flycast-sa
| +|Sega|Naomi (naomi)|1998|`naomi`|.lst .bin .dat .zip .7z|**retroarch:** flycast2021 (default)
**flycast:** flycast-sa
| |Sega|Saturn (saturn)|1994|`saturn`|.cue .chd .iso|**yabasanshiro:** yabasanshiro-sa (default)
**retroarch:** yabasanshiro
**retroarch:** beetle_saturn
| |Sega|Sega 32X (sega32x)|1994|`sega32x`|.32x .smd .bin .md .zip .7z|**retroarch:** picodrive (default)
| |Sega|Sega CD (segacd)|1991|`segacd`|.chd .cue .iso .m3u|**retroarch:** genesis_plus_gx (default)
**retroarch:** picodrive
| +|Sega|Sega Model 3 (segamodel3)|1996|`segamodel3`|.zip|**supermodel:** supermodel-sa (default)
| |Sega|SG-1000 (sg-1000)|1983|`sg-1000`|.bin .sg .zip .7z|**retroarch:** gearsystem (default)
**retroarch:** genesis_plus_gx
**retroarch:** picodrive
| |Sega|ST-V (st-v)|1995|`st-v`|.zip .ZIP|**retroarch:** beetle_saturn (default)
**mednafen:** ss
| |Sharp|X1 (x1)|1982|`x1`|.dx1 .2d .2hd .tfd .d88 .88d .hdm .xdf .dup .tap .cmd .zip .7z|**retroarch:** x1 (default)
| diff --git a/licenses/Supermodel.txt b/licenses/Supermodel.txt new file mode 100644 index 0000000000..c2d4747728 --- /dev/null +++ b/licenses/Supermodel.txt @@ -0,0 +1,699 @@ + + + #### ### ### + ## ## ## ## + ### ## ## ## ### #### ## ### ## ## #### ## #### ## + ### ## ## ## ## ## ## ### ## ####### ## ## ##### ## ## ## + ### ## ## ## ## ###### ## ## ####### ## ## ## ## ###### ## + ## ## ## ## ##### ## ## ## # ## ## ## ## ## ## ## + #### ### ## ## #### #### ## ## #### ### ## #### #### + #### + + A Sega Model 3 Arcade Emulator. + Copyright 2003-2022 The Supermodel Team + + + LICENSE AGREEMENT FOR SUPERMODEL + + +Supermodel is distributed as free software under the terms of the GNU General +Public License, included below. See README.txt for additional documentation. +The source code may be obtained from the official Supermodel web site: + + http://www.Supermodel3.com + + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/packages/apps/fileman/package.mk b/packages/apps/fileman/package.mk index b31db433b3..8a727ffef5 100644 --- a/packages/apps/fileman/package.mk +++ b/packages/apps/fileman/package.mk @@ -13,6 +13,7 @@ PKG_PRIORITY="optional" PKG_SECTION="tools" PKG_SHORTDESC="A Single panel file Manager." PKG_PATCH_DIRS="${DEVICE}" +[ "${DEVICE}" = "S922X" -a "${USE_MALI}" != "no" ] && PKG_PATCH_DIRS+=" S922X-MALI" make_target() { MAKEDEVICE=$(echo ${DEVICE^^} | sed "s#-#_##g") diff --git a/packages/apps/fileman/patches/S922X/000-sdl-vulkan.patch b/packages/apps/fileman/patches/S922X-MALI/000-sdl-vulkan.patch similarity index 100% rename from packages/apps/fileman/patches/S922X/000-sdl-vulkan.patch rename to packages/apps/fileman/patches/S922X-MALI/000-sdl-vulkan.patch diff --git a/packages/apps/gamecontrollerdb/config/gamecontrollerdb.txt b/packages/apps/gamecontrollerdb/config/gamecontrollerdb.txt index f4707042b5..2e993ebf38 100644 --- a/packages/apps/gamecontrollerdb/config/gamecontrollerdb.txt +++ b/packages/apps/gamecontrollerdb/config/gamecontrollerdb.txt @@ -1,4 +1,3 @@ -03001354474f2d556c74726120476100,GO-Ultra Gamepad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b12,guide:b13,start:b17,dpleft:b10,dpdown:b9,dpright:b11,dpup:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b14,rightstick:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3, 1900fcf27a65645f6a6f797374696300,zed_joystick,platform:Linux,x:b2,a:b0,b:b1,y:b3,back:b8,start:b9,dpleft:b15,dpdown:b14,dpright:b16,dpup:b13,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a2,righty:a3, 03002758091200000031000011010000,OpenSimHardware OSH PB Controller,platform:Linux,x:b2,a:b0,b:b1,y:b3,back:b7,start:b6,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b10,rightshoulder:b5,righttrigger:b11,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3, 19000226010000000100000001010000,odroidgo2_joypad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b10,start:b13,dpleft:b8,dpdown:b7,dpright:b9,dpup:b6,leftshoulder:b4,lefttrigger:b11,rightshoulder:b5,righttrigger:b12,leftx:a0,lefty:a1, @@ -12,3 +11,4 @@ 1900e7444b4800000111000034020000,rg552_joypad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b8,start:b9,dpleft:b15,dpdown:b14,dpright:b16,dpup:b13,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a2,righty:a3, 03001a3447616d65466f726365204100,GameForce ACE Gamepad,a:b1,b:b0,dpdown:b13,dpleft:b14,+lefty:-a1,-leftx:-a0,+leftx:+a0,-lefty:+a1,leftshoulder:b5,leftstick:b10,lefttrigger:-a2,dpright:b15,+righty:+a4,-rightx:-a3,+rightx:+a3,-righty:-a4,rightshoulder:b6,rightstick:b11,righttrigger:-a5,back:b7,guide:b9,start:b8,dpup:b12,x:b3,y:b4,platform:Linux, 1900c3ea010000000100000001010000,odroidgo3_joypad,a:b1,b:b0,dpdown:b13,dpleft:b14,+lefty:+a1,-leftx:-a0,+leftx:+a0,-lefty:-a1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,dpright:b15,+righty:+a3,-rightx:-a2,+rightx:+a2,-righty:-a3,rightshoulder:b5,rightstick:b11,righttrigger:b7,back:b8,start:b9,dpup:b12,x:b2,y:b3,platform:Linux, +03001354474f2d556c74726120476100,GO-Ultra Gamepad,a:b1,b:b0,dpdown:b15,dpleft:b16,guide:b11;+lefty:+a1,-leftx:-a0,+leftx:+a0,-lefty:-a1,leftshoulder:b5,leftstick:b12,lefttrigger:b7,dpright:b17,+righty:+a3,-rightx:-a2,+rightx:+a2,-righty:-a3,rightshoulder:b6,rightstick:b13,righttrigger:b8,back:b9,start:b10,dpup:b14,x:b3,y:b4,platform:Linux, diff --git a/packages/apps/portmaster/package.mk b/packages/apps/portmaster/package.mk index 65ba1d8c1b..08573a2639 100644 --- a/packages/apps/portmaster/package.mk +++ b/packages/apps/portmaster/package.mk @@ -2,7 +2,7 @@ # Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS) PKG_NAME="portmaster" -PKG_VERSION="8.5.23_0623" +PKG_VERSION="2024.04.07-0359" PKG_SITE="https://github.com/PortsMaster/PortMaster-GUI" PKG_URL="${PKG_SITE}/releases/download/${PKG_VERSION}/PortMaster.zip" COMPAT_URL="https://github.com/brooksytech/JelosAddOns/raw/main/compat.zip" @@ -12,7 +12,7 @@ PKG_DEPENDS_TARGET="toolchain rocknix-hotkey gamecontrollerdb wget oga_controls PKG_TOOLCHAIN="manual" PKG_LONGDESC="Portmaster - a simple tool that allows you to download various game ports" -if [ "${DEVICE}" = "S922X" ]; then +if [ "${DEVICE}" = "S922X" -a "${USE_MALI}" != "no" ]; then PKG_DEPENDS_TARGET+=" libegl" fi @@ -34,14 +34,12 @@ makeinstall_target() { } post_install() { - case ${DEVICE} in - S922X) - LIBEGL="export SDL_VIDEO_GL_DRIVER=\/usr\/lib\/egl\/libGL.so.1 SDL_VIDEO_EGL_DRIVER=\/usr\/lib\/egl\/libEGL.so.1" - ;; - *) - LIBEGL="" - ;; - esac - sed -e "s/@LIBEGL@/${LIBEGL}/g" \ - -i ${INSTALL}/usr/bin/start_portmaster.sh + if [ "${DEVICE}" = "S922X" -a "${USE_MALI}" != "no" ]; then + LIBEGL="export SDL_VIDEO_GL_DRIVER=\/usr\/lib\/egl\/libGL.so.1 SDL_VIDEO_EGL_DRIVER=\/usr\/lib\/egl\/libEGL.so.1" + else + LIBEGL="" + fi + + sed -e "s/@LIBEGL@/${LIBEGL}/g" \ + -i ${INSTALL}/usr/bin/start_portmaster.sh } diff --git a/packages/compat/box86/package.mk b/packages/compat/box86/package.mk index 3587820ff7..7a367a4558 100644 --- a/packages/compat/box86/package.mk +++ b/packages/compat/box86/package.mk @@ -7,7 +7,7 @@ PKG_ARCH="arm aarch64" PKG_LICENSE="MIT" PKG_SITE="https://github.com/ptitSeb/box86" PKG_URL="${PKG_SITE}.git" -PKG_DEPENDS_TARGET="toolchain ncurses SDL_sound wine" +PKG_DEPENDS_TARGET="toolchain ncurses SDL_sound" PKG_LONGDESC="Box86 lets you run x86 Linux programs (such as games) on non-x86 Linux systems, like ARM." PKG_TOOLCHAIN="cmake" diff --git a/packages/compress/xz/package.mk b/packages/compress/xz/package.mk index c6871e29e9..2c7c6f2415 100644 --- a/packages/compress/xz/package.mk +++ b/packages/compress/xz/package.mk @@ -6,8 +6,9 @@ PKG_NAME="xz" PKG_VERSION="5.4.4" PKG_LICENSE="GPL" -PKG_SITE="https://tukaani.org/xz/" -PKG_URL="https://tukaani.org/xz/${PKG_NAME}-${PKG_VERSION}.tar.xz" +PKG_SHA512="2b233a924b82190ff15e970c5a4a59f1c53a0b39a96bde228c9dfc9b103b4a3e5888f5024da4834e180f6010620ff23caf9f7135a38724eb2c8d01bff7a9a9e1" +PKG_SITE="https://src.fedoraproject.org/repo/pkgs/xz/" +PKG_URL="https://src.fedoraproject.org/repo/pkgs/xz/${PKG_NAME}-${PKG_VERSION}.tar.xz/sha512/${PKG_SHA512}/${PKG_NAME}-${PKG_VERSION}.tar.xz" PKG_DEPENDS_HOST="ccache:host" PKG_DEPENDS_TARGET="toolchain" PKG_LONGDESC="A free general-purpose data compression software with high compression ratio." diff --git a/packages/emulators/libretro/retroarch/retroarch-joypads/gamepads/GO-Ultra Gamepad.cfg b/packages/emulators/libretro/retroarch/retroarch-joypads/gamepads/GO-Ultra Gamepad.cfg index 3a445adef0..5bc2e5d0fe 100644 --- a/packages/emulators/libretro/retroarch/retroarch-joypads/gamepads/GO-Ultra Gamepad.cfg +++ b/packages/emulators/libretro/retroarch/retroarch-joypads/gamepads/GO-Ultra Gamepad.cfg @@ -3,23 +3,23 @@ input_driver = "udev" input_b_btn = "0" input_a_btn = "1" -input_x_btn = "2" -input_y_btn = "3" -input_l_btn = "4" -input_r_btn = "5" -input_l2_btn = "6" -input_r2_btn = "7" +input_x_btn = "3" +input_y_btn = "4" +input_l_btn = "5" +input_r_btn = "6" +input_l2_btn = "7" +input_r2_btn = "8" -input_up_btn = "8" -input_down_btn = "9" -input_left_btn = "10" -input_right_btn = "11" +input_up_btn = "14" +input_down_btn = "15" +input_left_btn = "16" +input_right_btn = "17" -input_select_btn = "12" -input_start_btn = "17" +input_select_btn = "9" +input_start_btn = "10" -input_l3_btn = "14" -input_r3_btn = "15" +input_l3_btn = "12" +input_r3_btn = "13" input_l_x_plus_axis = "+0" input_l_x_minus_axis = "-0" @@ -33,19 +33,19 @@ input_r_y_minus_axis = "-3" # Hotkeys -input_enable_hotkey_btn = "12" -input_exit_emulator_btn = "13" +input_enable_hotkey_btn = "11" +input_exit_emulator_btn = "10" input_screenshot_btn = "0" input_pause_toggle_btn = "1" -input_menu_toggle_btn = "2" -input_fps_toggle_btn = "3" +input_menu_toggle_btn = "3" +input_fps_toggle_btn = "4" -input_state_slot_increase_btn = "8" -input_state_slot_decrease_btn = "9" +input_state_slot_increase_btn = "14" +input_state_slot_decrease_btn = "15" -input_load_state_btn = "4" -input_save_state_btn = "5" +input_load_state_btn = "5" +input_save_state_btn = "6" -input_rewind_btn = "6" -input_toggle_fast_forward_btn = "7" +input_rewind_btn = "7" +input_toggle_fast_forward_btn = "8" diff --git a/packages/emulators/standalone/duckstation-sa/config/RK3566/RK3566 b/packages/emulators/libretro/retroarch/sources/RK3566-X55 similarity index 100% rename from packages/emulators/standalone/duckstation-sa/config/RK3566/RK3566 rename to packages/emulators/libretro/retroarch/sources/RK3566-X55 diff --git a/packages/emulators/libretro/retroarch/sources/RK3566/retroarch.cfg b/packages/emulators/libretro/retroarch/sources/RK3566/retroarch.cfg index 3fb42857a9..8f7db25814 100644 --- a/packages/emulators/libretro/retroarch/sources/RK3566/retroarch.cfg +++ b/packages/emulators/libretro/retroarch/sources/RK3566/retroarch.cfg @@ -448,7 +448,7 @@ menu_horizontal_animation = "true" menu_insert_disk_resume = "true" menu_left_thumbnails = "0" menu_linear_filter = "false" -menu_mouse_enable = "true" +menu_mouse_enable = "false" menu_navigation_browser_filter_supported_extensions_enable = "true" menu_navigation_wraparound_enable = "true" menu_pause_libretro = "true" @@ -500,7 +500,7 @@ menu_use_preferred_system_color_theme = "false" menu_wallpaper = "" menu_wallpaper_opacity = "1.000000" menu_widget_scale_auto = "false" -menu_widget_scale_factor = "1.000000" +menu_widget_scale_factor = "0.350000" menu_widget_scale_factor_windowed = "1.000000" menu_xmb_animation_horizontal_highlight = "0" menu_xmb_animation_move_up_down = "0" diff --git a/packages/emulators/standalone/aethersx2-sa/config/S922X/aethersx2/inis/PCSX2.ini b/packages/emulators/standalone/aethersx2-sa/config/S922X/aethersx2/inis/PCSX2.ini index bdfdba8ed5..f156a710fa 100644 --- a/packages/emulators/standalone/aethersx2-sa/config/S922X/aethersx2/inis/PCSX2.ini +++ b/packages/emulators/standalone/aethersx2-sa/config/S922X/aethersx2/inis/PCSX2.ini @@ -318,30 +318,29 @@ RawInput = false [Hotkeys] -ToggleFullscreen = +ToggleFullscreen = CycleAspectRatio = SDL-0/Guide & SDL-0/Y -CycleInterlaceMode = -CycleMipmapMode = -GSDumpMultiFrame = +CycleInterlaceMode = +CycleMipmapMode = +GSDumpMultiFrame = Screenshot = SDL-0/Guide & SDL-0/A -GSDumpSingleFrame = -ToggleSoftwareRendering = -ZoomIn = -ZoomOut = -InputRecToggleMode = +GSDumpSingleFrame = +ToggleSoftwareRendering = +ZoomIn = +ZoomOut = +InputRecToggleMode = LoadStateFromSlot = SDL-0/Guide & SDL-0/LeftShoulder SaveStateToSlot = SDL-0/Guide & SDL-0/RightShoulder -NextSaveStateSlot = -PreviousSaveStateSlot = +NextSaveStateSlot = +PreviousSaveStateSlot = OpenPauseMenu = SDL-0/Guide & SDL-0/X -ToggleFrameLimit = -TogglePause = -ToggleSlowMotion = +ToggleFrameLimit = +TogglePause = +ToggleSlowMotion = ToggleTurbo = SDL-0/Guide & SDL-0/+RightTrigger -HoldTurbo = +HoldTurbo = ResetVM = SDL-0/Guide & SDL-0/B - [Pad] MultitapPort1 = false MultitapPort2 = false diff --git a/packages/emulators/standalone/dolphin-sa/config/S922X/GCPadNew.ini.south b/packages/emulators/standalone/dolphin-sa/config/S922X/GCPadNew.ini.south index 7bab098d20..5b52dd6eeb 100644 --- a/packages/emulators/standalone/dolphin-sa/config/S922X/GCPadNew.ini.south +++ b/packages/emulators/standalone/dolphin-sa/config/S922X/GCPadNew.ini.south @@ -1,12 +1,12 @@ [GCPad1] Device = evdev/0/GO-Ultra Gamepad Buttons/A = Button 0 -Buttons/B = Button 3 -Buttons/Start = Button 13 +Buttons/B = Button 4 +Buttons/Start = Button 10 Buttons/X = Button 1 -Buttons/Y = Button 2 -Buttons/Z = Button 7 -Buttons/Hotkey = Button 17 +Buttons/Y = Button 3 +Buttons/Z = Button 8 +Buttons/Hotkey = Button 11 C-Stick/Dead Zone = 25.000000000000000 C-Stick/Down = Axis 3+ C-Stick/Left = Axis 2- @@ -14,10 +14,10 @@ C-Stick/Modifier = Control_L C-Stick/Modifier/Range = 50.000000000000000 C-Stick/Right = Axis 2+ C-Stick/Up = Axis 3- -D-Pad/Down = Button 9 -D-Pad/Left = Button 10 -D-Pad/Right = Button 11 -D-Pad/Up = Button 8 +D-Pad/Down = Button 15 +D-Pad/Left = Button 16 +D-Pad/Right = Button 17 +D-Pad/Up = Button 14 Main Stick/Dead Zone = 25.000000000000000 Main Stick/Down = Axis 1+ Main Stick/Left = Axis 0- @@ -25,5 +25,5 @@ Main Stick/Modifier = Shift_L Main Stick/Modifier/Range = 50.000000000000000 Main Stick/Right = Axis 0+ Main Stick/Up = Axis 1- -Triggers/L = Button 4 -Triggers/R = Button 5 +Triggers/L = Button 5 +Triggers/R = Button 6 diff --git a/packages/emulators/standalone/dolphin-sa/config/S922X/GCPadNew.ini.west b/packages/emulators/standalone/dolphin-sa/config/S922X/GCPadNew.ini.west index 2dde68b71f..a302693f69 100644 --- a/packages/emulators/standalone/dolphin-sa/config/S922X/GCPadNew.ini.west +++ b/packages/emulators/standalone/dolphin-sa/config/S922X/GCPadNew.ini.west @@ -2,11 +2,11 @@ Device = evdev/0/GO-Ultra Gamepad Buttons/A = Button 1 Buttons/B = Button 0 -Buttons/Start = Button 13 -Buttons/X = Button 2 -Buttons/Y = Button 3 -Buttons/Z = Button 7 -Buttons/Hotkey = Button 17 +Buttons/Start = Button 10 +Buttons/X = Button 3 +Buttons/Y = Button 4 +Buttons/Z = Button 8 +Buttons/Hotkey = Button 11 C-Stick/Dead Zone = 25.000000000000000 C-Stick/Down = Axis 3+ C-Stick/Left = Axis 2- @@ -14,10 +14,10 @@ C-Stick/Modifier = Control_L C-Stick/Modifier/Range = 50.000000000000000 C-Stick/Right = Axis 2+ C-Stick/Up = Axis 3- -D-Pad/Down = Button 9 -D-Pad/Left = Button 10 -D-Pad/Right = Button 11 -D-Pad/Up = Button 8 +D-Pad/Down = Button 15 +D-Pad/Left = Button 16 +D-Pad/Right = Button 17 +D-Pad/Up = Button 14 Main Stick/Dead Zone = 25.000000000000000 Main Stick/Down = Axis 1+ Main Stick/Left = Axis 0- @@ -25,5 +25,5 @@ Main Stick/Modifier = Shift_L Main Stick/Modifier/Range = 50.000000000000000 Main Stick/Right = Axis 0+ Main Stick/Up = Axis 1- -Triggers/L = Button 4 -Triggers/R = Button 5 +Triggers/L = Button 5 +Triggers/R = Button 6 diff --git a/packages/emulators/standalone/dolphin-sa/config/S922X/WiiControllerProfiles/classic.ini b/packages/emulators/standalone/dolphin-sa/config/S922X/WiiControllerProfiles/classic.ini index 408db60f31..c2f1146ba9 100644 --- a/packages/emulators/standalone/dolphin-sa/config/S922X/WiiControllerProfiles/classic.ini +++ b/packages/emulators/standalone/dolphin-sa/config/S922X/WiiControllerProfiles/classic.ini @@ -4,13 +4,13 @@ Extension = Classic Source = 1 Classic/Buttons/A = Button 1 Classic/Buttons/B = Button 0 -Classic/Buttons/X = Button 2 -Classic/Buttons/Y = Button 3 -Classic/Buttons/ZL = Button 6 -Classic/Buttons/ZR = Button 7 -Classic/Buttons/- = Button 12 -Classic/Buttons/+ = Button 17 -Classic/Buttons/Home = Button 8 +Classic/Buttons/X = Button 3 +Classic/Buttons/Y = Button 4 +Classic/Buttons/ZL = Button 7 +Classic/Buttons/ZR = Button 8 +Classic/Buttons/- = Button 9 +Classic/Buttons/+ = Button 10 +Classic/Buttons/Home = Button 11 Classic/Left Stick/Up = Axis 1- Classic/Left Stick/Down = Axis 1+ Classic/Left Stick/Left = Axis 0- @@ -19,9 +19,9 @@ Classic/Right Stick/Up = Axis 3- Classic/Right Stick/Down = Axis3+ Classic/Right Stick/Left = Axis 2- Classic/Right Stick/Right = Axis 2+ -Classic/Triggers/L = Button 4 -Classic/Triggers/R = Button 5 -Classic/D-Pad/Up = Button 8 -Classic/D-Pad/Down = Button 9 -Classic/D-Pad/Left = Button 10 -Classic/D-Pad/Right = Button 11 +Classic/Triggers/L = Button 5 +Classic/Triggers/R = Button 6 +Classic/D-Pad/Up = Button 14 +Classic/D-Pad/Down = Button 15 +Classic/D-Pad/Left = Button 16 +Classic/D-Pad/Right = Button 17 diff --git a/packages/emulators/standalone/dolphin-sa/package.mk b/packages/emulators/standalone/dolphin-sa/package.mk index bf0f62c789..2245ebc3a9 100644 --- a/packages/emulators/standalone/dolphin-sa/package.mk +++ b/packages/emulators/standalone/dolphin-sa/package.mk @@ -94,4 +94,8 @@ post_install() { -i ${INSTALL}/usr/bin/start_dolphin_gc.sh sed -e "s/@DOLPHIN_PLATFORM@/${DOLPHIN_PLATFORM}/g" \ -i ${INSTALL}/usr/bin/start_dolphin_wii.sh + + if [ "${DEVICE}" = "S922X" -a "${USE_MALI}" = "no" ]; then + sed -e "s/GFXBackend = Vulkan/GFXBackend =/g" -i ${INSTALL}/usr/config/dolphin-emu/Dolphin.ini + fi } diff --git a/packages/emulators/standalone/drastic-sa/config/RK3566-X55 b/packages/emulators/standalone/drastic-sa/config/RK3566-X55 new file mode 120000 index 0000000000..9207b5754b --- /dev/null +++ b/packages/emulators/standalone/drastic-sa/config/RK3566-X55 @@ -0,0 +1 @@ +RK3566 \ No newline at end of file diff --git a/packages/emulators/standalone/drastic-sa/config/S922X/drastic.cfg b/packages/emulators/standalone/drastic-sa/config/S922X/drastic.cfg index c621083ab1..8b9545fe79 100644 --- a/packages/emulators/standalone/drastic-sa/config/S922X/drastic.cfg +++ b/packages/emulators/standalone/drastic-sa/config/S922X/drastic.cfg @@ -51,7 +51,7 @@ controls_a[CONTROL_INDEX_TOUCH_CURSOR_DOWN] = 65535 controls_a[CONTROL_INDEX_TOUCH_CURSOR_LEFT] = 65535 controls_a[CONTROL_INDEX_TOUCH_CURSOR_RIGHT] = 65535 controls_a[CONTROL_INDEX_TOUCH_CURSOR_PRESS] = 65535 -controls_a[CONTROL_INDEX_MENU] = 65535 +controls_a[CONTROL_INDEX_MENU] = 1026 controls_a[CONTROL_INDEX_SAVE_STATE] = 65535 controls_a[CONTROL_INDEX_LOAD_STATE] = 65535 controls_a[CONTROL_INDEX_FAST_FORWARD] = 65535 @@ -61,48 +61,48 @@ controls_a[CONTROL_INDEX_SWAP_ORIENTATION_B] = 65535 controls_a[CONTROL_INDEX_LOAD_GAME] = 65535 controls_a[CONTROL_INDEX_QUIT] = 65535 controls_a[CONTROL_INDEX_FAKE_MICROPHONE] = 65535 -controls_a[CONTROL_INDEX_UI_UP] = 65535 -controls_a[CONTROL_INDEX_UI_DOWN] = 65535 -controls_a[CONTROL_INDEX_UI_LEFT] = 65535 -controls_a[CONTROL_INDEX_UI_RIGHT] = 65535 +controls_a[CONTROL_INDEX_UI_UP] = 1038 +controls_a[CONTROL_INDEX_UI_DOWN] = 1039 +controls_a[CONTROL_INDEX_UI_LEFT] = 1040 +controls_a[CONTROL_INDEX_UI_RIGHT] = 1041 controls_a[CONTROL_INDEX_UI_SELECT] = 65535 controls_a[CONTROL_INDEX_UI_BACK] = 65535 controls_a[CONTROL_INDEX_UI_EXIT] = 65535 controls_a[CONTROL_INDEX_UI_PAGE_UP] = 65535 controls_a[CONTROL_INDEX_UI_PAGE_DOWN] = 65535 controls_a[CONTROL_INDEX_UI_SWITCH] = 65535 -controls_b[CONTROL_INDEX_UP] = 1032 -controls_b[CONTROL_INDEX_DOWN] = 1033 -controls_b[CONTROL_INDEX_LEFT] = 1034 -controls_b[CONTROL_INDEX_RIGHT] = 1035 +controls_b[CONTROL_INDEX_UP] = 1038 +controls_b[CONTROL_INDEX_DOWN] = 1039 +controls_b[CONTROL_INDEX_LEFT] = 1040 +controls_b[CONTROL_INDEX_RIGHT] = 1041 controls_b[CONTROL_INDEX_A] = 1025 controls_b[CONTROL_INDEX_B] = 1024 -controls_b[CONTROL_INDEX_X] = 1026 -controls_b[CONTROL_INDEX_Y] = 1027 -controls_b[CONTROL_INDEX_L] = 1028 -controls_b[CONTROL_INDEX_R] = 1029 -controls_b[CONTROL_INDEX_START] = 1041 -controls_b[CONTROL_INDEX_SELECT] = 1036 +controls_b[CONTROL_INDEX_X] = 1027 +controls_b[CONTROL_INDEX_Y] = 1028 +controls_b[CONTROL_INDEX_L] = 1029 +controls_b[CONTROL_INDEX_R] = 1030 +controls_b[CONTROL_INDEX_START] = 1034 +controls_b[CONTROL_INDEX_SELECT] = 1033 controls_b[CONTROL_INDEX_HINGE] = 65535 controls_b[CONTROL_INDEX_TOUCH_CURSOR_UP] = 1219 controls_b[CONTROL_INDEX_TOUCH_CURSOR_DOWN] = 1155 controls_b[CONTROL_INDEX_TOUCH_CURSOR_LEFT] = 1218 controls_b[CONTROL_INDEX_TOUCH_CURSOR_RIGHT] = 1154 -controls_b[CONTROL_INDEX_TOUCH_CURSOR_PRESS] = 1039 -controls_b[CONTROL_INDEX_MENU] = 1037 -controls_b[CONTROL_INDEX_SAVE_STATE] = 1031 -controls_b[CONTROL_INDEX_LOAD_STATE] = 1030 -controls_b[CONTROL_INDEX_FAST_FORWARD] = 65535 -controls_b[CONTROL_INDEX_SWAP_SCREENS] = 65535 -controls_b[CONTROL_INDEX_SWAP_ORIENTATION_A] = 1038 -controls_b[CONTROL_INDEX_SWAP_ORIENTATION_B] = 1040 +controls_b[CONTROL_INDEX_TOUCH_CURSOR_PRESS] = 1037 +controls_b[CONTROL_INDEX_MENU] = 1026 +controls_b[CONTROL_INDEX_SAVE_STATE] = 115 +controls_b[CONTROL_INDEX_LOAD_STATE] = 108 +controls_b[CONTROL_INDEX_FAST_FORWARD] = 116 +controls_b[CONTROL_INDEX_SWAP_SCREENS] = 109 +controls_b[CONTROL_INDEX_SWAP_ORIENTATION_A] = 1031 +controls_b[CONTROL_INDEX_SWAP_ORIENTATION_B] = 1032 controls_b[CONTROL_INDEX_LOAD_GAME] = 65535 controls_b[CONTROL_INDEX_QUIT] = 65535 controls_b[CONTROL_INDEX_FAKE_MICROPHONE] = 65535 -controls_b[CONTROL_INDEX_UI_UP] = 1032 -controls_b[CONTROL_INDEX_UI_DOWN] = 1033 -controls_b[CONTROL_INDEX_UI_LEFT] = 1034 -controls_b[CONTROL_INDEX_UI_RIGHT] = 1035 +controls_b[CONTROL_INDEX_UI_UP] = 1217 +controls_b[CONTROL_INDEX_UI_DOWN] = 1153 +controls_b[CONTROL_INDEX_UI_LEFT] = 1216 +controls_b[CONTROL_INDEX_UI_RIGHT] = 1152 controls_b[CONTROL_INDEX_UI_SELECT] = 1025 controls_b[CONTROL_INDEX_UI_BACK] = 65535 controls_b[CONTROL_INDEX_UI_EXIT] = 1024 diff --git a/packages/emulators/standalone/duckstation-sa/config/RK3566-X55 b/packages/emulators/standalone/duckstation-sa/config/RK3566-X55 new file mode 120000 index 0000000000..9207b5754b --- /dev/null +++ b/packages/emulators/standalone/duckstation-sa/config/RK3566-X55 @@ -0,0 +1 @@ +RK3566 \ No newline at end of file diff --git a/packages/emulators/standalone/duckstation-sa/config/RK3566/settings.ini b/packages/emulators/standalone/duckstation-sa/config/RK3566/settings.ini index ccdb6737e5..047d98b5c8 100644 --- a/packages/emulators/standalone/duckstation-sa/config/RK3566/settings.ini +++ b/packages/emulators/standalone/duckstation-sa/config/RK3566/settings.ini @@ -87,7 +87,12 @@ Rotation = 0 [Hotkeys] - +OpenPauseMenu = SDL-0/Back & SDL-0/X +FastForward = SDL-0/Back & SDL-0/+RightTrigger +Screenshot = SDL-0/Back & SDL-0/A +LoadSelectedSaveState = SDL-0/Back & SDL-0/LeftShoulder +SaveSelectedSaveState = SDL-0/Back & SDL-0/RightShoulder +PowerOff = SDL-0/Back & SDL-0/Start [Logging] LogLevel = Error @@ -228,3 +233,30 @@ DumpVRAMWrites = false DumpVRAMWriteForceAlphaChannel = true DumpVRAMWriteWidthThreshold = 128 DumpVRAMWriteHeightThreshold = 128 + +[Pad1] +Up = SDL-0/DPadUp +Right = SDL-0/DPadRight +Down = SDL-0/DPadDown +Left = SDL-0/DPadLeft +Triangle = SDL-0/X +Circle = SDL-0/A +Cross = SDL-0/B +Square = SDL-0/Y +Select = SDL-0/Back +Start = SDL-0/Start +L1 = SDL-0/LeftShoulder +R1 = SDL-0/RightShoulder +L2 = SDL-0/+LeftTrigger +R2 = SDL-0/+RightTrigger +L3 = SDL-0/LeftStick +R3 = SDL-0/RightStick +LLeft = SDL-0/-LeftX +LRight = SDL-0/+LeftX +LDown = SDL-0/+LeftY +LUp = SDL-0/-LeftY +RLeft = SDL-0/+RightX +RRight = SDL-0/-RightX +RDown = SDL-0/+RightY +RUp = SDL-0/-RightY + diff --git a/packages/emulators/standalone/flycast-sa/config/RK3566-X55 b/packages/emulators/standalone/flycast-sa/config/RK3566-X55 new file mode 120000 index 0000000000..9207b5754b --- /dev/null +++ b/packages/emulators/standalone/flycast-sa/config/RK3566-X55 @@ -0,0 +1 @@ +RK3566 \ No newline at end of file diff --git a/packages/emulators/standalone/flycast-sa/config/S922X/mappings/SDL_GO-Ultra Gamepad.cfg b/packages/emulators/standalone/flycast-sa/config/S922X/mappings/SDL_GO-Ultra Gamepad.cfg index e3edf331ac..9e9113bfc8 100644 --- a/packages/emulators/standalone/flycast-sa/config/S922X/mappings/SDL_GO-Ultra Gamepad.cfg +++ b/packages/emulators/standalone/flycast-sa/config/S922X/mappings/SDL_GO-Ultra Gamepad.cfg @@ -11,20 +11,23 @@ bind7 = 3+:axis2_down [digital] bind0 = 0:btn_a bind1 = 1:btn_b -bind10 = 12:btn_menu -bind11 = 13:btn_dpad2_up -bind12 = 17:btn_start -bind2 = 2:btn_x -bind3 = 3:btn_y -bind4 = 4:btn_trigger_left -bind5 = 5:btn_trigger_right -bind6 = 8:btn_dpad1_up -bind7 = 9:btn_dpad1_down -bind8 = 10:btn_dpad1_left -bind9 = 11:btn_dpad1_right +bind10 = 13:btn_dpad2_up +bind11 = 14:btn_dpad1_up +bind12 = 15:btn_dpad1_down +bind13 = 16:btn_dpad1_left +bind14 = 17:btn_dpad1_right +bind2 = 3:btn_y +bind3 = 4:btn_x +bind4 = 5:btn_trigger_left +bind5 = 6:btn_trigger_right +bind6 = 7:btn_jump_state +bind7 = 8:btn_quick_save +bind8 = 10:btn_start +bind9 = 11:btn_menu [emulator] dead_zone = 10 mapping_name = GO-Ultra Gamepad rumble_power = 100 +saturation = 100 version = 3 diff --git a/packages/emulators/standalone/lime3ds-sa/config/S922X/sdl2-config.ini b/packages/emulators/standalone/lime3ds-sa/config/S922X/sdl2-config.ini index b44435ee60..d50dea5c92 100644 --- a/packages/emulators/standalone/lime3ds-sa/config/S922X/sdl2-config.ini +++ b/packages/emulators/standalone/lime3ds-sa/config/S922X/sdl2-config.ini @@ -19,20 +19,20 @@ # is smaller than the threshold button_a=button:1,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 button_b=button:0,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_x=button:2,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_y=button:3,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_up=button:8,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_down=button:9,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_left=button:10,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_right=button:11,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_l=button:4,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_r=button:5,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_start=button:17,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_select=button:12,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_x=button:3,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_y=button:4,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_up=button:14,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_down=button:15,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_left=button:16,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_right=button:17,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_l=button:5,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_r=button:6,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_start=button:10,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_select=button:9,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 button_debug= button_gpio14= -button_zl=button:6,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 -button_zr=button:7,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_zl=button:7,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 +button_zr=button:8,engine:sdl,guid:03001354474f2d556c74726120476100,port:0 button_home= # for analog input, the following devices are available: @@ -90,7 +90,7 @@ cpu_clock_percentage = 100 [Renderer] # Whether to render using OpenGL or Software -# 0: Software, 1: OpenGL (default) +# 0: Software, 1: OpenGL (default), 2: Vulkan graphics_api = 2 # Whether to render using GLES or OpenGL @@ -284,6 +284,10 @@ nand_directory = # 0: Old 3DS, 1: New 3DS (default) is_new_3ds = +# Whether to use LLE system applets, if installed +# 0 (default): No, 1: Yes +lle_applets = + # The system region that Lime3DS will use during emulation # -1: Auto-select (default), 0: Japan, 1: USA, 2: Europe, 3: Australia, 4: China, 5: Korea, 6: Taiwan region_value = @@ -297,6 +301,14 @@ init_clock = # Note: 3DS can only handle times later then Jan 1 2000 init_time = +# The system ticks count to use when Lime3DS starts +# 0: Random (default), 1: Fixed +init_ticks_type = + +# Tick count to use when init_ticks_type is set to Fixed. +# Defaults to 0. +init_ticks_override = + [Camera] # Which camera engine to use for the right outer camera # blank (default): a dummy camera that always returns black image @@ -339,9 +351,6 @@ renderer_debug = # To LLE a service module add "LLE\=true" [WebService] -# Whether or not to enable telemetry -# 0: No, 1 (default): Yes -enable_telemetry = 0 # URL for Web API web_api_url = https://api.citra-emu.org # Username and token for Lime3DS Web Service diff --git a/packages/emulators/standalone/lime3ds-sa/package.mk b/packages/emulators/standalone/lime3ds-sa/package.mk index e0522b9c13..a03ded2ef3 100644 --- a/packages/emulators/standalone/lime3ds-sa/package.mk +++ b/packages/emulators/standalone/lime3ds-sa/package.mk @@ -2,7 +2,7 @@ # Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) PKG_NAME="lime3ds-sa" -PKG_VERSION="6bd64d83b770ca5ee7d0faaba400693950367822" +PKG_VERSION="ff46656809278d797ff8d79514e0a1c6e57bf9be" PKG_LICENSE="GPL" PKG_SITE="https://github.com/Lime3DS/Lime3DS" PKG_URL="${PKG_SITE}.git" diff --git a/packages/emulators/standalone/mednafen/scripts/start_mednafen.sh b/packages/emulators/standalone/mednafen/scripts/start_mednafen.sh index 9e31d041b3..6e77e814bf 100644 --- a/packages/emulators/standalone/mednafen/scripts/start_mednafen.sh +++ b/packages/emulators/standalone/mednafen/scripts/start_mednafen.sh @@ -3,7 +3,7 @@ # Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) . /etc/profile - +set -x set_kill set "-9 mednafen" export MEDNAFEN_HOME=/storage/.config/mednafen @@ -46,6 +46,12 @@ sed -i "s/filesys.path_state.*/filesys.path_state \/storage\/roms\/savestates\/$ # Get command line switches FEATURES_CMDLINE="" +CORRECT_ASPECT=$(get_setting correct_aspect ${PLATFORM} "${GAME}") +CR="" +if [ ! -z "${CORRECT_ASPECT}" ] +then + CR=" -${CORE}.correct_aspect ${CORRECT_ASPECT}" +fi if [[ "${CORE}" =~ pce[_fast] ]] then if [ "$(get_setting nospritelimit ${PLATFORM} "${GAME}")" = "1" ] @@ -62,6 +68,7 @@ then fi if [ "${CORE}" = pce_fast ] then + FEATURES_CMDLINE+=$CR OCM=$(get_setting ocmultiplier ${PLATFORM} "${GAME}") if [ ${OCM} > 1 ] then @@ -96,6 +103,7 @@ then fi elif [ "${CORE}" = "nes" ] then + FEATURES_CMDLINE+=$CR if [ $(get_setting clipsides "${PLATFORM}" "${GAME}") = "1" ] then FEATURES_CMDLINE+=" -${CORE}.clipsides 1" @@ -110,6 +118,7 @@ then fi elif [ "${CORE}" = "snes_faust" ] then + FEATURES_CMDLINE+=$CR if [ $(get_setting spex "${PLATFORM}" "${GAME}") = "1" ] then FEATURES_CMDLINE+=" -${CORE}.spex 1" @@ -129,7 +138,7 @@ then else FEATURES_CMDLINE+=" -${CORE}.superfx.clock_rate 100" fi - if [ $(get_setting superfx.icache "${PLATFORM}" "${GAME}") = "1" ] + if [[ "$(get_setting superfx.icache ${PLATFORM} "${GAME}")" == "1" ]] then FEATURES_CMDLINE+=" -${CORE}.superfx.icache 1" else @@ -174,6 +183,7 @@ then fi elif [ "${CORE}" = "ss" ] then + FEATURES_CMDLINE+=$CR IP1=$(get_setting input.port1 "${PLATFORM}" "${GAME}") if [[ "${IP1}" =~ gamepad|3dpad|gun ]] then @@ -202,6 +212,9 @@ then else FEATURES_CMDLINE+=" -${CORE}.cart.auto_default none" fi +elif [ "${CORE}" = "md" ] +then + FEATURES_CMDLINE+=$CR fi #Run mednafen diff --git a/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-core/config/RK3566-X55 b/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-core/config/RK3566-X55 new file mode 120000 index 0000000000..9207b5754b --- /dev/null +++ b/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-core/config/RK3566-X55 @@ -0,0 +1 @@ +RK3566 \ No newline at end of file diff --git a/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-core/config/S922X/mupen64plus.cfg b/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-core/config/S922X/mupen64plus.cfg index 6352b7c6ff..1761599f1e 100644 --- a/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-core/config/S922X/mupen64plus.cfg +++ b/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-core/config/S922X/mupen64plus.cfg @@ -110,23 +110,23 @@ Kbd Mapping Frame Advance = 47 # SDL keysym for pressing the game shark button Kbd Mapping Gameshark = 103 # Joystick event string for stopping the emulator -Joy Mapping Stop = "J0B12/B17" +Joy Mapping Stop = "J0B11/B10" # Joystick event string for switching between fullscreen/windowed modes Joy Mapping Fullscreen = "" # Joystick event string for saving the emulator state -Joy Mapping Save State = "J0B12/B5" +Joy Mapping Save State = "J0B11/B6" # Joystick event string for loading the emulator state -Joy Mapping Load State = "J0B12/B4" +Joy Mapping Load State = "J0B11/B5" # Joystick event string for advancing the save state slot Joy Mapping Increment Slot = "" # Joystick event string for resetting the emulator -Joy Mapping Reset = "J0B12/B0" +Joy Mapping Reset = "J0B11/B0" # Joystick event string for slowing down the emulator Joy Mapping Speed Down = "" # Joystick event string for speeding up the emulator Joy Mapping Speed Up = "" # Joystick event string for taking a screenshot -Joy Mapping Screenshot = "J0B12/B1" +Joy Mapping Screenshot = "J0B11/B1" # Joystick event string for pausing the emulator Joy Mapping Pause = "J0B6/B0" # Joystick event string for muting/unmuting the sound @@ -186,24 +186,22 @@ AnalogDeadzone = "0,0" # An absolute value of the SDL joystick axis >= AnalogPeak will saturate the N64 controller axis value (at 80). For X, Y axes. For each axis, this must be greater than the corresponding AnalogDeadzone value AnalogPeak = "32768,32768" # Digital button configuration mappings -AnalogDeadzone = 4096,4096 +AnalogDeadzone = 0,0 AnalogPeak = 32768,32768 -DPad R = hat(0 Right) -DPad L = hat(0 Left) -DPad D = hat(0 Down) -DPad U = hat(0 Up) -Start = button(7) -Z Trig = axis(2+) -B Button = button(2) +DPad R = button(16) +DPad L = button(17) +DPad D = button(15) +DPad U = button(14) +Start = button(10) +Z Trig = button(5) button(8) +B Button = button(4) A Button = button(0) -C Button R = axis(3+,24000) -C Button L = axis(3-,24000) button(3) -C Button D = axis(4+,24000) button(1) -C Button U = axis(4-,24000) -R Trig = axis(5+) button(5) -L Trig = button(4) -Mempak switch = -Rumblepak switch = +C Button R = axis(2+) +C Button L = axis(2-) button (2) +C Button D = axis(3+) button (1) +C Button U = axis(3-) +R Trig = button(6) +L Trig = button(7) X Axis = axis(0-,0+) Y Axis = axis(1-,1+) diff --git a/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-input-sdl/config/RK3566-X55 b/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-input-sdl/config/RK3566-X55 new file mode 120000 index 0000000000..9207b5754b --- /dev/null +++ b/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-input-sdl/config/RK3566-X55 @@ -0,0 +1 @@ +RK3566 \ No newline at end of file diff --git a/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-input-sdl/config/S922X/default.ini b/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-input-sdl/config/S922X/default.ini index c8ec4fab1d..5690881b08 100644 --- a/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-input-sdl/config/S922X/default.ini +++ b/packages/emulators/standalone/mupen64plus-sa/mupen64plus-sa-input-sdl/config/S922X/default.ini @@ -3,19 +3,19 @@ plugged = True mouse = False AnalogDeadzone = 0,0 AnalogPeak = 32768,32768 -DPad R = button(11) -DPad L = button(10) -DPad D = button(9) -DPad U = button(8) -Start = button(17) -Z Trig = button(4) button(7) -B Button = button(3) +DPad R = button(16) +DPad L = button(17) +DPad D = button(15) +DPad U = button(14) +Start = button(10) +Z Trig = button(5) button(8) +B Button = button(4) A Button = button(0) C Button R = axis(2+) C Button L = axis(2-) button (2) C Button D = axis(3+) button (1) C Button U = axis(3-) -R Trig = button(5) -L Trig = button(6) +R Trig = button(6) +L Trig = button(7) X Axis = axis(0-,0+) Y Axis = axis(1-,1+) diff --git a/packages/emulators/standalone/ppsspp-sa/sources/RK3566-X55 b/packages/emulators/standalone/ppsspp-sa/sources/RK3566-X55 new file mode 120000 index 0000000000..9207b5754b --- /dev/null +++ b/packages/emulators/standalone/ppsspp-sa/sources/RK3566-X55 @@ -0,0 +1 @@ +RK3566 \ No newline at end of file diff --git a/packages/emulators/standalone/ppsspp-sa/sources/S922X/controls.ini b/packages/emulators/standalone/ppsspp-sa/sources/S922X/controls.ini index fc3a607fe7..cfd01a7f7b 100755 --- a/packages/emulators/standalone/ppsspp-sa/sources/S922X/controls.ini +++ b/packages/emulators/standalone/ppsspp-sa/sources/S922X/controls.ini @@ -17,9 +17,8 @@ An.Left = 10-4001 An.Right = 10-4000 Analog limiter = 1-60 RapidFire = 1-59 -Fast-forward = 1-61 SpeedToggle = 1-68 -Pause = 1-111,10-109,10-104 +Pause = 1-111,10-106,10-104 Rewind = 1-67 Save State = 10-4010 Load State = 10-4008 diff --git a/packages/emulators/standalone/supermodel-sa/config/RK3588/Supermodel.ini b/packages/emulators/standalone/supermodel-sa/config/RK3588/Supermodel.ini new file mode 100644 index 0000000000..5895643bfa --- /dev/null +++ b/packages/emulators/standalone/supermodel-sa/config/RK3588/Supermodel.ini @@ -0,0 +1,443 @@ +;; +;; Supermodel Configuration File +;; Default settings. +;; + + +; +; Quick Overview +; -------------- +; +; All settings are case sensitive. Numbers must be integers. Check your +; spelling carefully because invalid settings are silently ignored. To verify +; that your settings are being parsed correctly, check the contents of +; Supermodel.log. +; +; Global options apply to all games. To create configuration profiles for +; individual games, place settings under sections with the same name as the +; corresponding MAME ROM set, like so: +; +; ; Scud Race +; [ scud ] +; +; SoundVolume = 50 +; MusicVolume = 200 +; ; ... etc. ... +; +; For a list of all valid settings, please consult README.txt. Only default +; inputs are assigned here. +; + + +[ Global ] + +; Graphics +New3DEngine = false +QuadRendering = false +WideScreen = false +Stretch = false +WideBackground = false +XResolution = 1920 +YResolution = 1080 +Fullscreen = 1 +ForceFeedback = 1 +Throttle = 1 + +; Refresh rate (milliHertz accuracy). Actual Model 3 refresh rate is 57.524 Hz +; but this can cause judder so we use 60 Hz by default. +RefreshRate = 60.000 + +; Legacy SCSP DSP implementation for games that do not play well with the newer +; one (e.g., Fighting Vipers 2) +LegacySoundDSP = false + +; Network board +Network = false +SimulateNet = true +PortIn = 1970 +PortOut = 1971 +AddressOut = "127.0.0.1" + +;InputJoyXSaturation=115 ; Affects Sensitivity (Value range 1-200 Default: 100). A value of 50 means that the joystick only needs to be moved halfway in order for Supermodel to see it as fully extended. +;InputJoyYSaturation=115 +;InputJoyRXSaturation=115 +;InputJoyRYSaturation=115 + +;InputJoyXDeadZone=1 +;InputJoyYDeadZone=1 +;InputJoyRXDeadZone=1 +;InputJoyRYDeadZone=1 + +; Common +InputUIExit = "KEY_ESCAPE,JOY1_BUTTON10+JOY1_BUTTON9" +InputUIPause = "JOY1_BUTTON10+JOY1_BUTTON8" +InputUISelectCrosshairs = "JOY1_BUTTON10+JOY1_BUTTON2" +InputUISaveState = "KEY_9,JOY1_BUTTON10+JOY1_BUTTON7" +InputUILoadState = "KEY_0,JOY1_BUTTON10+JOY1_BUTTON6" +InputStart1 = "KEY_1,JOY1_BUTTON9" +InputStart2 = "KEY_2,JOY2_BUTTON10" +InputCoin1 = "KEY_3,KEY_ALT,JOY1_BUTTON8" +InputCoin2 = "KEY_4,JOY2_BUTTON9" +InputServiceA = "KEY_5,JOY1_BUTTON10+JOY1_BUTTON5" +InputServiceB = "KEY_7,JOY1_BUTTON10+JOY1_BUTTON1" +InputTestA = "KEY_6,JOY1_BUTTON10+JOY1_BUTTON4" +InputTestB = "KEY_8,JOY1_BUTTON10+JOY1_BUTTON2" + +; 4-way digital joysticks +InputJoyUp = "KEY_UP,JOY1_UP" +InputJoyDown = "KEY_DOWN,JOY1_DOWN" +InputJoyLeft = "KEY_LEFT,JOY1_LEFT" +InputJoyRight = "KEY_RIGHT,JOY1_RIGHT" +InputJoyUp2 = "JOY2_UP" +InputJoyDown2 = "JOY2_DOWN" +InputJoyLeft2 = "JOY2_LEFT" +InputJoyRight2 = "JOY2_RIGHT" + +; Fighting game buttons +InputPunch = "KEY_A,JOY1_BUTTON1" +InputKick = "KEY_S,JOY1_BUTTON2" +InputGuard = "KEY_D,JOY1_BUTTON4" +InputEscape = "KEY_F,JOY1_BUTTON5" +InputPunch2 = "JOY2_BUTTON1" +InputKick2 = "JOY2_BUTTON2" +InputGuard2 = "JOY2_BUTTON3" +InputEscape2 = "JOY2_BUTTON4" + +; Spikeout buttons +InputShift = "KEY_A,JOY1_BUTTON1" +InputBeat = "KEY_S,JOY1_BUTTON2" +InputCharge = "KEY_D,JOY1_BUTTON4" +InputJump = "KEY_F,JOY1_BUTTON5" + +; Virtua Striker buttons +InputShortPass = "KEY_A,JOY1_BUTTON1" +InputLongPass = "KEY_S,JOY1_BUTTON2" +InputShoot = "KEY_D,JOY1_BUTTON4" +InputShortPass2 = "JOY2_BUTTON1" +InputLongPass2 = "JOY2_BUTTON2" +InputShoot2 = "JOY2_BUTTON3" + +; Steering wheel +InputSteeringLeft = "KEY_LEFT" ; digital, turn wheel left +InputSteeringRight = "KEY_RIGHT" ; digital, turn wheel right +InputSteering = "JOY1_YAXIS" ; analog, full steering range + +; Pedals +InputAccelerator = "KEY_UP,JOY1_RZAXIS_NEG" +InputBrake = "KEY_DOWN,JOY1_ZAXIS_NEG" + +; Up/down shifter manual transmission (all racers) +InputGearShiftUp = "KEY_Y,JOY1_BUTTON6" ; sequential shift up +InputGearShiftDown = "KEY_H,JOY1_BUTTON7" ; sequential shift down + +; 4-Speed manual transmission (Daytona 2, Sega Rally 2, Scud Race) +InputGearShift1 = "KEY_Q,JOY1_RYAXIS_NEG" +InputGearShift2 = "KEY_W,JOY1_RYAXIS_POS" +InputGearShift3 = "KEY_E,JOY1_RXAXIS_NEG" +InputGearShift4 = "KEY_R,JOY1_RXAXIS_POS" +InputGearShiftN = "KEY_T" + +; VR4 view change buttons (Daytona 2, Le Mans 24, Scud Race) +InputVR1 = "KEY_A,JOY1_BUTTON1" +InputVR2 = "KEY_S,JOY1_BUTTON2" +InputVR3 = "KEY_D,JOY1_BUTTON4" +InputVR4 = "KEY_F,JOY1_BUTTON5" + +; Single view change button (Dirt Devils, ECA, Harley-Davidson, Sega Rally 2) +InputViewChange = "KEY_A,JOY1_BUTTON1" + +; Handbrake (Dirt Devils, Sega Rally 2) +InputHandBrake = "KEY_S,JOY1_BUTTON2" + +; Harley-Davidson controls +InputRearBrake = "KEY_S,JOY1_BUTTON2" +InputMusicSelect = "KEY_D,JOY1_BUTTON4" + +; Virtual On macros +InputTwinJoyTurnLeft = "KEY_Q,JOY1_RXAXIS_NEG" +InputTwinJoyTurnRight = "KEY_W,JOY1_RXAXIS_POS" +InputTwinJoyForward = "KEY_UP,JOY1_XAXIS_POS" +InputTwinJoyReverse = "KEY_DOWN,JOY1_XAXIS_NEG" +InputTwinJoyStrafeLeft = "KEY_LEFT,JOY1_YAXIS_NEG" +InputTwinJoyStrafeRight = "KEY_RIGHT,JOY1_YAXIS_POS" +InputTwinJoyJump = "KEY_E,JOY1_BUTTON1" +InputTwinJoyCrouch = "KEY_R,JOY1_BUTTON2" + +; Virtual On individual joystick mapping +InputTwinJoyLeft1 = "NONE" +InputTwinJoyLeft2 = "NONE" +InputTwinJoyRight1 = "NONE" +InputTwinJoyRight2 = "NONE" +InputTwinJoyUp1 = "NONE" +InputTwinJoyUp2 = "NONE" +InputTwinJoyDown1 = "NONE" +InputTwinJoyDown2 = "NONE" + +; Virtual On buttons +InputTwinJoyShot1 = "KEY_A,JOY1_ZAXIS_NEG" +InputTwinJoyShot2 = "KEY_S,JOY1_RZAXIS_NEG" +InputTwinJoyTurbo1 = "KEY_Z,JOY1_BUTTON6" +InputTwinJoyTurbo2 = "KEY_X,JOY1_BUTTON7" + +; Analog joystick (Star Wars Trilogy) +InputAnalogJoyLeft = "KEY_LEFT" ; digital, move left +InputAnalogJoyRight = "KEY_RIGHT" ; digital, move right +InputAnalogJoyUp = "KEY_UP" ; digital, move up +InputAnalogJoyDown = "KEY_DOWN" ; digital, move down +InputAnalogJoyX = "JOY1_YAXIS" ; analog, full X axis +InputAnalogJoyY = "JOY1_XAXIS_INV" ; analog, full Y axis +InputAnalogJoyTrigger = "KEY_A,JOY1_BUTTON1" +InputAnalogJoyEvent = "KEY_S,JOY1_BUTTON2" +InputAnalogJoyTrigger2 = "KEY_D,JOY1_BUTTON5" +InputAnalogJoyEvent2 = "JOY1_BUTTON4" + +; Light guns (Lost World) +InputGunLeft = "KEY_LEFT" ; digital, move gun left +InputGunRight = "KEY_RIGHT" ; digital, move gun right +InputGunUp = "KEY_UP" ; digital, move gun up +InputGunDown = "KEY_DOWN" ; digital, move gun down +InputGunX = "JOY1_YAXIS" ; analog, full X axis +InputGunY = "JOY1_XAXIS_INV" ; analog, full Y axis +InputTrigger = "KEY_A,JOY1_BUTTON1" +InputOffscreen = "KEY_S,JOY1_BUTTON2" ; point off-screen +InputAutoTrigger = 1 ; automatic reload when off-screen +InputGunLeft2 = "NONE" +InputGunRight2 = "NONE" +InputGunUp2 = "NONE" +InputGunDown2 = "NONE" +InputGunX2 = "JOY2_XAXIS,MOUSE2_XAXIS" +InputGunY2 = "JOY2_YAXIS,MOUSE2_YAXIS" +InputTrigger2 = "JOY2_BUTTON1,MOUSE2_LEFT_BUTTON" +InputOffscreen2 = "JOY2_BUTTON2,MOUSE2_RIGHT_BUTTON" +InputAutoTrigger2 = 1 + +; Analog guns (Ocean Hunter, LA Machineguns) +InputAnalogGunLeft = "KEY_LEFT" ; digital, move gun left +InputAnalogGunRight = "KEY_RIGHT" ; digital, move gun right +InputAnalogGunUp = "KEY_UP" ; digital, move gun up +InputAnalogGunDown = "KEY_DOWN" ; digital, move gun down +InputAnalogGunX = "JOY1_YAXIS" ; analog, full X axis +InputAnalogGunY = "JOY1_XAXIS_INV" ; analog, full Y axis +InputAnalogTriggerLeft = "KEY_A,JOY1_BUTTON1" +InputAnalogTriggerRight = "KEY_S,JOY1_BUTTON2" +InputAnalogGunLeft2 = "NONE" +InputAnalogGunRight2 = "NONE" +InputAnalogGunUp2 = "NONE" +InputAnalogGunDown2 = "NONE" +InputAnalogGunX2 = "MOUSE2_XAXIS" +InputAnalogGunY2 = "MOUSE2_YAXIS" +InputAnalogTriggerLeft2 = "MOUSE2_LEFT_BUTTON" +InputAnalogTriggerRight2 = "MOUSE2_RIGHT_BUTTON" + +; Ski Champ controls +InputSkiLeft = "KEY_LEFT" +InputSkiRight = "KEY_RIGHT" +InputSkiUp = "KEY_UP" +InputSkiDown = "KEY_DOWN" +InputSkiX = "JOY1_YAXIS" +InputSkiY = "JOY1_XAXIS_INV" +InputSkiPollLeft = "KEY_A,JOY1_ZAXIS_NEG" +InputSkiPollRight = "KEY_S,JOY1_RZAXIS_NEG" +InputSkiSelect1 = "KEY_Q,JOY1_BUTTON1" +InputSkiSelect2 = "KEY_W,JOY1_BUTTON2" +InputSkiSelect3 = "KEY_E,JOY1_BUTTON4" + +; Magical Truck Adventure controls +InputMagicalLeverUp1 = "KEY_UP" +InputMagicalLeverDown1 = "KEY_DOWN" +InputMagicalLeverUp2 = "NONE" +InputMagicalLeverDown2 = "NONE" +InputMagicalLever1 = "JOY1_XAXIS" +InputMagicalLever2 = "JOY2_YAXIS" +InputMagicalPedal1 = "KEY_A,JOY1_BUTTON1" +InputMagicalPedal2 = "KEY_S,JOY2_BUTTON1" + +; Sega Bass Fishing / Get Bass controls +InputFishingRodLeft = "KEY_LEFT" +InputFishingRodRight = "KEY_RIGHT" +InputFishingRodUp = "KEY_UP" +InputFishingRodDown = "KEY_DOWN" +InputFishingStickLeft = "KEY_A" +InputFishingStickRight = "KEY_D" +InputFishingStickUp = "KEY_W" +InputFishingStickDown = "KEY_S" +InputFishingRodX = "JOY1_YAXIS" +InputFishingRodY = "JOY1_XAXIS_INV" +InputFishingStickX = "JOY1_RXAXIS" +InputFishingStickY = "JOY1_RYAXIS" +InputFishingReel = "KEY_SPACE,JOY1_ZAXIS_NEG" +InputFishingCast = "KEY_Z,JOY1_BUTTON1" +InputFishingSelect = "KEY_X,JOY1_BUTTON2" +InputFishingTension = "KEY_T,JOY1_RZAXIS_NEG" + + ;Our non input settings... + +; Game specific settings +;daytona 2 power edition + [ dayto2pe ] +PowerPCFrequency = 90 +EmulateDSB = 1 +;daytona 2: battle to the edge + [ daytona2 ] +PowerPCFrequency = 90 +EmulateDSB = 1 + ;Dirt Devils (Export, Revision A) + [ dirtdvls ] +PowerPCFrequency = 60 +;Dirt Devils (Australia, Revision A) + [ dirtdvlsa ] +PowerPCFrequency = 60 +;Dirt Devils (German) + [ dirtdvlsg ] +PowerPCFrequency = 60 +;Dirt Devils (Japan, Revision A) + [ dirtdvlsj ] +PowerPCFrequency = 60 +;Emergency Call Ambulance (Export) - NOT WORKING PI + [ eca ] +;Emergency Call Ambulance (Japan) - NOIT WORKING PI + [ ecaj ] +;Emergency Call Ambulance (US location test?) - NOT WORKING PI + [ ecap ] +;Emergency Call Ambulance (USA) - NOT WORKING PI + [ ecau ] +;Fighting Vipers 2 (Japan, Revision A) + [ fvipers2 ] +PowerPCFrequency = 55 +;Fighting Vipers 2 (?) + [ fvipers2o ] +PowerPCFrequency = 48 +;Get Bass (?) + [ getbass ] +PowerPCFrequency = 30 +;Harley-Davidson and L.A. Riders (Revision B) - pi too slow + [ harley ] +PowerPCFrequency = 166 +;Harley-Davidson and L.A. Riders (Revision A) - pi too slow + [ harleya ] +PowerPCFrequency = 166 +;L.A. Machineguns: Rage of the Machines (Japan) + [ lamachin ] +PowerPCFrequency = 40 +;Le Mans 24 (Revision B) + [ lemans24 ] + ;The Lost World (Japan, Revision A) + [ lostwsga ];The Lost World (Original Revision) +PowerPCFrequency = 33 + [ lostwsgo ] +PowerPCFrequency = 33 +;Magical Truck Adventure (Japan) + [ magtruck ] +PowerPCFrequency = 40 +;The Ocean Hunter - Default works fine on pi + [ oceanhun ] +MusicVolume = 200 +SoundVolume = 200 + [ oceanhuna ] +MusicVolume = 200 +SoundVolume = 200 +;Scud Race (Australia, Twin) + [ scud ] +PowerPCFrequency = 35 +MusicVolume = 200 +EmulateDSB = 1 +;Scud Race (Export, Twin) + [ scuda ] +PowerPCFrequency = 35 +MusicVolume = 200 +EmulateDSB = 1 +;Scud Race (Japan, Deluxe) + [ scudj ] +PowerPCFrequency = 35 +MusicVolume = 200 +EmulateDSB = 1 +;Scud Race Plus (Revision A) + [ scudplus ] +PowerPCFrequency = 35 +MusicVolume = 200 +EmulateDSB = 1 +;Scud Race Plus (?) + [ scudplusa ] +PowerPCFrequency = 35 +MusicVolume = 200 +EmulateDSB = 1 +;Ski Champ (Japan) + [ skichamp ] +;PowerPCFrequency = 43 +PowerPCFrequency = 60 +;Spikeout Final Edition (?) - too slow on pi + [ spikeofe ] +PowerPCFrequency = 100 +EmulateDSB = 1 +;Spikeout (Revision C) + [ spikeout ] +;PowerPCFrequency = 35 +PowerPCFrequency = 55 +EmulateDSB = 1 +;Sega Rally 2 (?) + [ srally2 ] +EmulateDSB = 1 +PowerPCFrequency = 60 +;Sega Rally 2 (Prototype) + [ srally2p ] +PowerPCFrequency = 48 +EmulateDSB = 1 +;Sega Rally 2 (Prototype Version A) + [ srally2pa ] +PowerPCFrequency = 48 +EmulateDSB = 1 +;Sega Rally 2 (Deluxe) + [ srally2x ] +;Playable on pi but more slower down than srally2 +PowerPCFrequency = 100 +EmulateDSB = 1 +;Star Wars Trilogy Arcade - Default works fine on pi + [ swtrilgy ] +;Star Wars Trilogy Arcade (?) + [ swtrilgya ] +;Star Wars Trilogy Arcade (?) + [ swtrilgyp ] +;Virtua Fighter 3 (Revision D) + [ vf3 ] +PowerPCFrequency = 40 +;PowerPCFrequency = 100 +;Virtua Fighter 3 (Revision A) + [ vf3a ] +PowerPCFrequency = 40 +;Virtua Fighter 3 (Revision C) + [ vf3c ] +PowerPCFrequency = 40 +;Virtua Fighter 3 Team Battle (?) + [ vf3tb ] +PowerPCFrequency = 40 +;Virtual On 2: Oratorio Tangram (Revision B) + [ von2 ] +PowerPCFrequency = 30 +;Virtual On 2: Oratorio Tangram (Ver 5.4g) + [ von254g ] +PowerPCFrequency = 30 +;Virtual On 2: Oratorio Tangram (Revision A) + [ von2a ] +PowerPCFrequency = 30 +;Virtual On 2: Oratorio Tangram (?) + [ von2o ] +PowerPCFrequency = 35 +;Virtua Striker 2 (Step 2.0) - no special settings + [ vs2 ] +;Virtua Striker 2 (Step 1.5) - no special settings + [ vs215 ] +;Virtua Striker 2 (Step 1.5, older) - no special settings + [ vs215o ] +;Virtua Striker 2 '98 (Step 2.0) - no special settings + [ vs298 ] +;Virtua Striker 2 '98 (Step 1.5) - no special settings + [ vs29815 ] +;Virtua Striker 2 '99 (?) + [ vs299 ] +;Virtua Striker 2 '99 (Step 1.5) + [ vs29915 ] +;Virtua Striker 2 '99 (Revision A) + [ vs299a ] +;Virtua Striker 2 '99 (Revision B) + [ vs299b ] +;Virtua Striker 2 '99.1 (Revision B) diff --git a/packages/emulators/standalone/supermodel-sa/package.mk b/packages/emulators/standalone/supermodel-sa/package.mk new file mode 100644 index 0000000000..b8d9d4ed45 --- /dev/null +++ b/packages/emulators/standalone/supermodel-sa/package.mk @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) + +PKG_NAME="supermodel-sa" +PKG_LICENSE="GPLv3" +PKG_SITE="https://github.com/DirtBagXon/model3emu-code-sinden" +PKG_ARCH="any" +PKG_URL="${PKG_SITE}.git" +PKG_DEPENDS_TARGET="${OPENGL} ${OPENGLES} glu toolchain SDL2 SDL2_net zlib" +PKG_LONGDESC="Supermodel is a Sega Model 3 arcade emulator" +PKG_TOOLCHAIN="make" +GET_HANDLER_SUPPORT="git" + +case ${TARGET_ARCH} in + aarch64|arm) + PKG_VERSION="f94232e45e17f74ea510c7b754eec73529f06f58" + PKG_GIT_CLONE_BRANCH="arm" + ;; + *) + PKG_VERSION="f3f12a72c0e91e8e6bfabb1f1c6a039e926ac186" + PKG_GIT_CLONE_BRANCH="main" + ;; +esac + +PKG_MAKE_OPTS="NET_BOARD=1" + +pre_patch() { + cp ${PKG_BUILD}/Makefiles/Makefile.UNIX ${PKG_BUILD}/Makefile +} + +post_patch() { + # Add proper include directory + sed -e "s+MUSASHI_CFLAGS =+MUSASHI_CFLAGS = -I${SYSROOT_PREFIX}/usr/include+g" -i ${PKG_BUILD}/Makefiles/Rules.inc +} + +makeinstall_target() { + mkdir -p ${INSTALL}/usr/bin + cp -a ${PKG_BUILD}/bin/supermodel ${INSTALL}/usr/bin/supermodel + cp -a ${PKG_DIR}/scripts/start_supermodel.sh ${INSTALL}/usr/bin + chmod 0755 ${INSTALL}/usr/bin/start_supermodel.sh + mkdir -p ${INSTALL}/usr/config/supermodel + mkdir -p ${INSTALL}/usr/config/supermodel/Config + cp ${PKG_BUILD}/Config/Games.xml ${INSTALL}/usr/config/supermodel/Config + cp -r ${PKG_DIR}/config/${DEVICE}/* ${INSTALL}/usr/config/supermodel/Config +} diff --git a/packages/emulators/standalone/supermodel-sa/patches/01-glew.patch b/packages/emulators/standalone/supermodel-sa/patches/01-glew.patch new file mode 100644 index 0000000000..b52ff784fd --- /dev/null +++ b/packages/emulators/standalone/supermodel-sa/patches/01-glew.patch @@ -0,0 +1,15 @@ +--- a/Src/OSD/SDL/Main.cpp 2024-04-04 17:30:55.333806373 -0400 ++++ b/Src/OSD/SDL/Main.cpp 2024-04-04 17:30:24.325773043 -0400 +@@ -237,11 +237,11 @@ + // Set the context as the current window context + SDL_GL_MakeCurrent(s_window, context); + + // Initialize GLEW, allowing us to use features beyond OpenGL 1.2 + err = glewInit(); +- if (GLEW_OK != err) ++ if (GLEW_OK != err && GLEW_ERROR_NO_GLX_DISPLAY != err) + { + ErrorLog("OpenGL initialization failed: %s\n", glewGetErrorString(err)); + return FAIL; + } + diff --git a/packages/emulators/standalone/supermodel-sa/patches/02-cross-compile-build-fix.patch b/packages/emulators/standalone/supermodel-sa/patches/02-cross-compile-build-fix.patch new file mode 100644 index 0000000000..dca4824d08 --- /dev/null +++ b/packages/emulators/standalone/supermodel-sa/patches/02-cross-compile-build-fix.patch @@ -0,0 +1,47 @@ +--- a/Makefile 2023-04-02 07:03:17.000000000 -0400 ++++ b/Makefile 2024-04-05 13:57:55.702281044 -0400 +@@ -47,9 +47,9 @@ + # + # Toolchain + # +-CC = gcc +-CXX = g++ +-LD = gcc ++ ++ ++ + + # + # SDL +--- a/Makefiles/Rules.inc 2024-04-05 13:49:40.615575984 -0400 ++++ b/Makefiles/Rules.inc 2024-04-05 13:13:09.405606344 -0400 +@@ -68,7 +68,7 @@ + # + # Compiler options + # +-ARCH = -march=native ++ARCH = -DSDL_DISABLE_IMMINTRIN_H + OPT = -O3 + WARN = -Wall + CSTD = -std=iso9899:2011 +@@ -242,7 +242,7 @@ + $(BIN_DIR)/$(OUTFILE): $(BIN_DIR) $(OBJ_DIR) $(OBJ_FILES) + $(info --------------------------------------------------------------------------------) + $(info Linking Supermodel : $(BIN_DIR)/$(OUTFILE)) +- $(SILENT)$(LD) $(OBJ_FILES) $(LDFLAGS) ++ $(SILENT)$(CC) $(OBJ_FILES) $(LDFLAGS) + $(info --------------------------------------------------------------------------------) + + $(BIN_DIR): +@@ -305,9 +305,9 @@ + $(MUSASHI_OUTFILE): Src/CPU/68K/Musashi/m68kmake.c Src/CPU/68K/Musashi/m68k_in.c + $(info --------------------------------------------------------------------------------) + $(info Compiling : $< -> $(OBJ_DIR)/m68kmake.o) +- $(SILENT)$(CC) $< $(CFLAGS) -o $(OBJ_DIR)/m68kmake.o ++ $(SILENT)gcc $< $(CFLAGS) -march=native -o $(OBJ_DIR)/m68kmake.o + $(info Linking : $(MUSASHI_OUTFILE)) +- $(SILENT)$(LD) $(MUSASHI_LDFLAGS) ++ $(SILENT)gcc $(MUSASHI_LDFLAGS) + + $(OBJ_DIR)/m68kops.h $(OBJ_DIR)/m68kops.c $(OBJ_DIR)/m68kopac.c $(OBJ_DIR)/m68kopdm.c $(OBJ_DIR)/m68kopnz.c: $(MUSASHI_OUTFILE) Src/CPU/68K/Musashi/m68k_in.c Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h + $(info Generating 68K emulator: $@) diff --git a/packages/emulators/standalone/supermodel-sa/scripts/start_supermodel.sh b/packages/emulators/standalone/supermodel-sa/scripts/start_supermodel.sh new file mode 100755 index 0000000000..ba08ad5a06 --- /dev/null +++ b/packages/emulators/standalone/supermodel-sa/scripts/start_supermodel.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) + +# Source predefined functions and variables +. /etc/profile +set_kill set "-9 supermodel" + +CONFIG_DIR="/storage/.config/supermodel" +SOURCE_DIR="/usr/config/supermodel" + +#Check if supermodel exists in .config +if [ ! -d "${CONFIG_DIR}" ]; then + mkdir -p "${CONFIG_DIR}" + cp -r "${SOURCE_DIR}" "/storage/.config/" +fi + +if [ ! -d "${CONFIG_DIR}/NVRAM" ]; then + mkdir -p "${CONFIG_DIR}/NVRAM" +fi + +if [ ! -d "${CONFIG_DIR}/Saves" ]; then + mkdir -p "${CONFIG_DIR}/Saves" +fi + +if [ ! -d "${CONFIG_DIR}/LocalConfig" ]; then + mkdir -p "${CONFIG_DIR}/LocalConfig" +fi + +#Set the cores to use +CORES=$(get_setting "cores" "${PLATFORM}" "${ROMNAME##*/}") +if [ "${CORES}" = "little" ] +then + EMUPERF="${SLOW_CORES}" +elif [ "${CORES}" = "big" ] +then + EMUPERF="${FAST_CORES}" +else + ### All.. + unset EMUPERF +fi + +#Emulation Station Features +GAME=$(echo "${1}"| sed "s#^/.*/##") +VSYNC=$(get_setting vsync segamodel3 "${GAME}") +RESOLUTION=$(get_setting resolution segamodel3 "${GAME}") +ENGINE=$(get_setting rendering_engine segamodel3 "${GAME}") + +OPTIONS= + +#VSYNC +if [ "$VSYNC" = "true" ] +then + OPTIONS+=" -vsync" +elif [ "$VSYNC" = "false" ] +then + OPTIONS+=" -no-vsync" +fi + +#ENGINE +if [ "$ENGINE" = "1" ] +then + OPTIONS+=" -new3d" +elif [ "$ENGINE" = "0" ] +then + OPTIONS+=" -legacy3d" +fi + +#RESOLUTION +if [ "$RESOLUTION" = "0" ] +then + OPTIONS+=" -res=1920,1080 -fullscreen" +elif [ "$RESOLUTION" = "1" ] +then + OPTIONS+=" -res=496,384" +elif [ "$RESOLUTION" = "2" ] +then + OPTIONS+=" -res=992,768" +fi + +cd ${CONFIG_DIR} +echo "Command: supermodel "${1}" ${OPTIONS}" >/var/log/exec.log 2>&1 +${EMUPERF} supermodel "${1}" ${OPTIONS} >>/var/log/exec.log 2>&1 ||: \ No newline at end of file diff --git a/packages/graphics/mesa/package.mk b/packages/graphics/mesa/package.mk index 3bcb27815e..71aa734aba 100644 --- a/packages/graphics/mesa/package.mk +++ b/packages/graphics/mesa/package.mk @@ -10,17 +10,18 @@ PKG_TOOLCHAIN="meson" PKG_PATCH_DIRS+=" ${DEVICE}" case ${DEVICE} in -# RK3588*) -# PKG_VERSION="120202c675749c5ef81ae4c8cdc30019b4de08f4" -# PKG_SITE="https://gitlab.com/panfork/mesa" -# PKG_URL="${PKG_SITE}.git" -# PKG_GIT_CLONE_BRANCH="csf" -# ;; - RK3*) #Using upstream dev for panfrost - PKG_VERSION="db29984c254f60f5daeec0ea4e6048b6ee7902f8" - PKG_SITE="https://gitlab.freedesktop.org/mesa/mesa" - PKG_URL="${PKG_SITE}.git" - PKG_PATCH_DIRS+=" panfrost" + RK3*|S922X) + if [ "${DEVICE}" = "S922X" -a "${USE_MALI}" != "no" ]; then + PKG_VERSION="24.0.4" + PKG_SITE="http://www.mesa3d.org/" + PKG_URL="https://gitlab.freedesktop.org/mesa/mesa/-/archive/mesa-${PKG_VERSION}/mesa-mesa-${PKG_VERSION}.tar.gz" + else + #Using upstream dev for panfrost + PKG_VERSION="7d4c23991a4cfa2cdc90315c736bf3f70a5f0238" + PKG_SITE="https://gitlab.freedesktop.org/mesa/mesa" + PKG_URL="${PKG_SITE}.git" + PKG_PATCH_DIRS+=" panfrost" + fi ;; *) PKG_VERSION="24.0.4" @@ -106,9 +107,7 @@ else fi post_makeinstall_target() { - case ${DEVICE} in - S922X) - rm -f ${INSTALL}/usr/lib/libvulkan_panfrost.so ${INSTALL}/usr/share/vulkan/icd.d/panfrost_icd.aarch64.json - ;; - esac + if [ "${DEVICE}" = "S922X" -a "${USE_MALI}" != "no" ]; then + rm -f ${INSTALL}/usr/lib/libvulkan_panfrost.so ${INSTALL}/usr/share/vulkan/icd.d/panfrost_icd.aarch64.json + fi } diff --git a/packages/hardware/quirks/devices/AYANEO AIR/bin/fancontrol b/packages/hardware/quirks/devices/AYANEO AIR/bin/fancontrol index 6faa6e15ea..c6e2debe14 100755 --- a/packages/hardware/quirks/devices/AYANEO AIR/bin/fancontrol +++ b/packages/hardware/quirks/devices/AYANEO AIR/bin/fancontrol @@ -4,7 +4,16 @@ . /etc/profile -DEBUG=false +### Enable logging +case $(get_setting system.loglevel) in + verbose) + DEBUG=true + ;; + *) + DEBUG=false + ;; +esac + COOLING_PROFILE=$(get_setting "cooling.profile") FAN_PWM="${DEVICE_PWM_FAN}" @@ -22,7 +31,7 @@ trap "set_control 0 && exit 0" SIGHUP SIGINT SIGQUIT SIGABRT if [ -e "/storage/.config/fancontrol.conf" ] && [ "${COOLING_PROFILE}" = "custom" ] then - log $0 "Loading configuration file" 2>/dev/null + $DEBUG && log $0 "Loading configuration file" 2>/dev/null source /storage/.config/fancontrol.conf if [ ! $? = 0 ] then @@ -37,17 +46,17 @@ if [ ! "${COOLING_PROFILE}" = "custom" ] then if [ "${COOLING_PROFILE}" = "aggressive" ] then - SPEEDS=(255 225 192) - TEMPS=(70000 65000 0) + SPEEDS=(192 225 255) + TEMPS=(45000 75000 85000) elif [ "${COOLING_PROFILE}" = "moderate" ] then - SPEEDS=(255 192 128 96) - TEMPS=(75000 70000 65000 0) + SPEEDS=(48 64 96 128 192 255) + TEMPS=(50000 55000 60000 70000 80000 90000) elif [ "${COOLING_PROFILE}" = "quiet" ] then # Quiet. - SPEEDS=(255 192 128 96 64 48 32) - TEMPS=(75000 70000 65000 60000 55000 50000 0) + SPEEDS=(32 48 64 96 128 192 255) + TEMPS=(50000 55000 60000 65000 70000 80000 90000) else # auto set_control 0 >/dev/null 2>&1 @@ -58,22 +67,41 @@ fi log $0 "Enabling fan control." set_control 1 >/dev/null 2>&1 +CURRENTSPEED=0 +TEMP=${TEMPS[0]} +declare -a HISTORY while true do INDEX=0 CPU_TEMP=$(printf "%.0f" $(awk '{ total += $1; count++ } END { print total/count }' ${DEVICE_TEMP_SENSOR})) - $DEBUG && log $0 "CPU TEMP: ${CPU_TEMP}" 2>/dev/null + + ### Keep a rolling history of CPU temps. + HISTORY+=(${CPU_TEMP}) + while (( ${#HISTORY[@]} > 10 )) + do + unset HISTORY[-0] + PRIOR_HISTORY=( ${HISTORY[*]} ) + HISTORY=( ${PRIOR_HISTORY[*]} ) + unset PRIOR_HISTORY + done + AVERAGE=$(echo $(IFS=+; echo "$((${HISTORY[*]}))") / ${#HISTORY[@]} | bc) + + $DEBUG && log $0 "Current/Average/Ceiling (Speed): ${CPU_TEMP}/${AVERAGE}/${TEMP} (${CURRENTSPEED})." for TEMP in "${TEMPS[@]}" do - if (( "${CPU_TEMP}" > "${TEMP}" )) && \ - [ ! "${LASTSPEED}" = "${SPEEDS[${INDEX}]}" ] + if (( "${CPU_TEMP}" >= "90000" )) || \ + (( "${AVERAGE}" <= "${TEMP}" )) then - $DEBUG && log $0 "Setting PWM FAN to ${SPEEDS[${INDEX}]} (${TEMP})" 2>/dev/null - echo ${SPEEDS[${INDEX}]} >${FAN_PWM} - LASTSPEED=${SPEEDS[${INDEX}]} + if (( ${CURRENTSPEED} != ${SPEEDS[${INDEX}]} )) + then + CURRENTSPEED=${SPEEDS[${INDEX}]} + echo ${SPEEDS[${INDEX}]} >${FAN_PWM} + $DEBUG && log $0 "Set fan to ${CURRENTSPEED}." + fi break + else + INDEX=$(( $INDEX + 1 )) fi - INDEX=$(( $INDEX + 1 )) done sleep 2 done diff --git a/packages/hardware/quirks/devices/GameForce ACE/bin/fancontrol b/packages/hardware/quirks/devices/GameForce ACE/bin/fancontrol index 54316ae222..22f44ea908 100755 --- a/packages/hardware/quirks/devices/GameForce ACE/bin/fancontrol +++ b/packages/hardware/quirks/devices/GameForce ACE/bin/fancontrol @@ -4,7 +4,16 @@ . /etc/profile -DEBUG=false +### Enable logging +case $(get_setting system.loglevel) in + verbose) + DEBUG=true + ;; + *) + DEBUG=false + ;; +esac + COOLING_PROFILE=$(get_setting "cooling.profile") FAN_PWM="${DEVICE_PWM_FAN}" @@ -38,17 +47,17 @@ if [ ! "${COOLING_PROFILE}" = "custom" ] then if [ "${COOLING_PROFILE}" = "aggressive" ] then - SPEEDS=(255 225 195) - TEMPS=(55000 45000 0) + SPEEDS=(195 225 255) + TEMPS=(45000 60000 80000) elif [ "${COOLING_PROFILE}" = "moderate" ] then - SPEEDS=(255 192 128 96) - TEMPS=(65000 55000 45000 0) + SPEEDS=(48 64 96 128 192 255) + TEMPS=(45000 55000 65000 75000 85000 90000) elif [ "${COOLING_PROFILE}" = "quiet" ] then # Quiet. - SPEEDS=(255 192 128 96 64 48 32) - TEMPS=(70000 60000 55000 50000 49000 47000 0) + SPEEDS=(32 48 64 96 128 192 255) + TEMPS=(45000 50000 55000 65000 75000 85000 90000) else # auto set_control 0 >/dev/null 2>&1 @@ -59,22 +68,41 @@ fi log $0 "Enabling fan control." set_control 1 >/dev/null 2>&1 +CURRENTSPEED=0 +TEMP=${TEMPS[0]} +declare -a HISTORY while true do INDEX=0 CPU_TEMP=$(printf "%.0f" $(awk '{ total += $1; count++ } END { print total/count }' ${DEVICE_TEMP_SENSOR})) - $DEBUG && log $0 "CPU TEMP: ${CPU_TEMP}" 2>/dev/null + + ### Keep a rolling history of CPU temps. + HISTORY+=(${CPU_TEMP}) + while (( ${#HISTORY[@]} > 10 )) + do + unset HISTORY[-0] + PRIOR_HISTORY=( ${HISTORY[*]} ) + HISTORY=( ${PRIOR_HISTORY[*]} ) + unset PRIOR_HISTORY + done + AVERAGE=$(echo $(IFS=+; echo "$((${HISTORY[*]}))") / ${#HISTORY[@]} | bc) + + $DEBUG && log $0 "Current/Average/Ceiling (Speed): ${CPU_TEMP}/${AVERAGE}/${TEMP} (${CURRENTSPEED})." for TEMP in "${TEMPS[@]}" do - if (( "${CPU_TEMP}" > "${TEMP}" )) && \ - [ ! "${LASTSPEED}" = "${SPEEDS[${INDEX}]}" ] + if (( "${CPU_TEMP}" >= "90000" )) || \ + (( "${AVERAGE}" <= "${TEMP}" )) then - $DEBUG && log $0 "Setting PWM FAN to ${SPEEDS[${INDEX}]} (${TEMP})" 2>/dev/null - echo ${SPEEDS[${INDEX}]} >${FAN_PWM} - LASTSPEED=${SPEEDS[${INDEX}]} + if (( ${CURRENTSPEED} != ${SPEEDS[${INDEX}]} )) + then + CURRENTSPEED=${SPEEDS[${INDEX}]} + echo ${SPEEDS[${INDEX}]} >${FAN_PWM} + $DEBUG && log $0 "Set fan to ${CURRENTSPEED}." + fi break + else + INDEX=$(( $INDEX + 1 )) fi - INDEX=$(( $INDEX + 1 )) done sleep 2 done diff --git a/packages/hardware/quirks/devices/Powkiddy RGB30/010-led_control b/packages/hardware/quirks/devices/Powkiddy RGB30/010-led_control index 23df101d41..e54be4fc32 100644 --- a/packages/hardware/quirks/devices/Powkiddy RGB30/010-led_control +++ b/packages/hardware/quirks/devices/Powkiddy RGB30/010-led_control @@ -3,4 +3,6 @@ # Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) cat </storage/.config/profile.d/010-led_control +echo 0 > /sys/class/leds/red\:charging/brightness +echo 1 > /sys/class/leds/green\:status/brightness EOF diff --git a/packages/hardware/quirks/devices/Powkiddy RGB30/bin/ledcontrol b/packages/hardware/quirks/devices/Powkiddy RGB30/bin/ledcontrol deleted file mode 100644 index e21654b46f..0000000000 --- a/packages/hardware/quirks/devices/Powkiddy RGB30/bin/ledcontrol +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (C) 2024 ROCKNIX (https://github.com/ROCKNIX) - -# Simple script to watch the battery capacity and -# turn the power LED to different states: -# 0-10% flashing green red -# 11-20% red -# 21+% green - -. /etc/profile - -function set_led() { - case $1 in - green) - echo 0 > /sys/class/leds/red\:charging/brightness - echo 1 > /sys/class/leds/green\:status/brightness - ;; - red) - echo 1 > /sys/class/leds/red\:charging/brightness - echo 0 > /sys/class/leds/green\:status/brightness - ;; - esac -} - - -while true -do - CAP=$(cat /sys/class/power_supply/battery/capacity) - STAT=$(cat /sys/class/power_supply/battery/status) - if [[ ${STAT} == "Discharging" ]] - then - if (( ${CAP} <= 10 )) - then - for ctr in $(seq 1 1 5) - do - set_led red - sleep .5 - set_led green - sleep .5 - done - continue - elif (( ${CAP} <= 20 )) - then - set_led red - else - set_led green - fi - fi - sleep 15 -done diff --git a/packages/hardware/quirks/devices/Powkiddy x55/001-device_config b/packages/hardware/quirks/devices/Powkiddy x55/001-device_config index b0c672b612..626cd09537 100755 --- a/packages/hardware/quirks/devices/Powkiddy x55/001-device_config +++ b/packages/hardware/quirks/devices/Powkiddy x55/001-device_config @@ -6,4 +6,5 @@ cat </storage/.config/profile.d/001-device_config DEVICE_FAKE_JACKSENSE="true" DEVICE_POWER_LED="false" DEVICE_BRIGHTNESS="128" +DEVICE_BATTERY_LED_STATUS="true" EOF diff --git a/packages/hardware/quirks/devices/ayn Loki Max/bin/fancontrol b/packages/hardware/quirks/devices/ayn Loki Max/bin/fancontrol index 50b74e57fc..91478d6790 100755 --- a/packages/hardware/quirks/devices/ayn Loki Max/bin/fancontrol +++ b/packages/hardware/quirks/devices/ayn Loki Max/bin/fancontrol @@ -4,7 +4,16 @@ . /etc/profile -DEBUG=false +### Enable logging +case $(get_setting system.loglevel) in + verbose) + DEBUG=true + ;; + *) + DEBUG=false + ;; +esac + COOLING_PROFILE=$(get_setting "cooling.profile") log $0 "Setting profile to ${COOLING_PROFILE}" @@ -34,16 +43,16 @@ if [ ! "${COOLING_PROFILE}" = "custom" ] then if [ "${COOLING_PROFILE}" = "aggressive" ] then - SPEEDS=(128 96 72) - TEMPS=(70000 65000 0) + SPEEDS=(72 96 128) + TEMPS=(45000 75000 85000) elif [ "${COOLING_PROFILE}" = "moderate" ] then - SPEEDS=(128 96 72 64 48) - TEMPS=(70000 65000 60000 55000 0) + SPEEDS=(32 48 64 72 96 128) + TEMPS=(50000 55000 60000 70000 80000 90000) elif [ "${COOLING_PROFILE}" = "quiet" ] then - SPEEDS=(128 96 64 48 32) - TEMPS=(70000 65000 60000 55000 0) + SPEEDS=(24 32 48 64 72 96 128) + TEMPS=(50000 55000 60000 65000 70000 80000 90000) else # auto set_control 0x01 >/dev/null 2>&1 @@ -51,25 +60,44 @@ then fi fi -log $0 "Enabling fan control." +$DEBUG && log $0 "Enabling fan control." set_control 0x00 >/dev/null 2>&1 +CURRENTSPEED=0 +TEMP=${TEMPS[0]} +declare -a HISTORY while true do INDEX=0 CPU_TEMP=$(printf "%.0f" $(awk '{ total += $1; count++ } END { print total/count }' ${DEVICE_TEMP_SENSOR})) - $DEBUG && log $0 "CPU TEMP: ${CPU_TEMP}" 2>/dev/null + + ### Keep a rolling history of CPU temps. + HISTORY+=(${CPU_TEMP}) + while (( ${#HISTORY[@]} > 10 )) + do + unset HISTORY[-0] + PRIOR_HISTORY=( ${HISTORY[*]} ) + HISTORY=( ${PRIOR_HISTORY[*]} ) + unset PRIOR_HISTORY + done + AVERAGE=$(echo $(IFS=+; echo "$((${HISTORY[*]}))") / ${#HISTORY[@]} | bc) + + $DEBUG && log $0 "Current/Average/Ceiling (Speed): ${CPU_TEMP}/${AVERAGE}/${TEMP} (${CURRENTSPEED})." for TEMP in "${TEMPS[@]}" do - if (( "${CPU_TEMP}" > "${TEMP}" )) && \ - [ ! "${LASTSPEED}" = "${SPEEDS[${INDEX}]}" ] + if (( "${CPU_TEMP}" >= "90000" )) || \ + (( "${AVERAGE}" <= "${TEMP}" )) then - $DEBUG && log $0 "Setting PWM FAN to ${SPEEDS[${INDEX}]} (${TEMP})" 2>/dev/null - ectool -w 0x11 -z $(printf '%x\n' ${SPEEDS[${INDEX}]}) >/dev/null 2>&1 - LASTSPEED=${SPEEDS[${INDEX}]} + if (( ${CURRENTSPEED} != ${SPEEDS[${INDEX}]} )) + then + CURRENTSPEED=${SPEEDS[${INDEX}]} + ectool -w 0x11 -z $(printf '%x\n' ${CURRENTSPEED}) >/dev/null 2>&1 + $DEBUG && log $0 "Set fan to ${CURRENTSPEED}." + fi break + else + INDEX=$(( $INDEX + 1 )) fi - INDEX=$(( $INDEX + 1 )) done sleep 2 done diff --git a/packages/hardware/quirks/platforms/RK3566-X55 b/packages/hardware/quirks/platforms/RK3566-X55 new file mode 120000 index 0000000000..9207b5754b --- /dev/null +++ b/packages/hardware/quirks/platforms/RK3566-X55 @@ -0,0 +1 @@ +RK3566 \ No newline at end of file diff --git a/packages/hardware/quirks/platforms/S922X/050-modifiers b/packages/hardware/quirks/platforms/S922X/050-modifiers index 9c906898fb..8c0961439c 100755 --- a/packages/hardware/quirks/platforms/S922X/050-modifiers +++ b/packages/hardware/quirks/platforms/S922X/050-modifiers @@ -3,8 +3,6 @@ # Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) cat </storage/.config/profile.d/050-modifiers -DEVICE_KEY_VOLUMEDOWN=114 -DEVICE_KEY_VOLUMEUP=115 -DEVICE_FUNC_KEYA_MODIFIER="BTN_TRIGGER_HAPPY2" -DEVICE_FUNC_KEYB_MODIFIER="BTN_TRIGGER_HAPPY5" +DEVICE_FUNC_KEYA_MODIFIER="BTN_SELECT" +DEVICE_FUNC_KEYB_MODIFIER="BTN_START" EOF diff --git a/packages/kernel/drivers/RTW89/package.mk b/packages/kernel/drivers/RTW89/package.mk index cfbed179f0..51c3a1851c 100644 --- a/packages/kernel/drivers/RTW89/package.mk +++ b/packages/kernel/drivers/RTW89/package.mk @@ -2,7 +2,7 @@ # Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) PKG_NAME="RTW89" -PKG_VERSION="48680abfeb843330d385384bd8edde259a241147" +PKG_VERSION="fce040c12fbf93bfd904ded48df60dea2c8d4423" PKG_ARCH="aarch64 x86_64" PKG_LICENSE="GPL" PKG_SITE="https://github.com/lwfinger/rtw89" diff --git a/packages/kernel/firmware/kernel-firmware/package.mk b/packages/kernel/firmware/kernel-firmware/package.mk index d261f88c82..dae1d91796 100644 --- a/packages/kernel/firmware/kernel-firmware/package.mk +++ b/packages/kernel/firmware/kernel-firmware/package.mk @@ -77,6 +77,13 @@ makeinstall_target() { ln -s "rtl8723bs_config-OBDA8723.bin" "${FW_TARGET_DIR}/rtl_bt/rtl8723bs_config.bin" fi + # Upstream doesn't name the files correctly so we need to symlink it + if [ -f "${FW_TARGET_DIR}/rtl_bt/rtl8723d_fw.bin" ]; then + ln -s "rtl8723d_fw.bin" "${FW_TARGET_DIR}/rtl_bt/rtl8723ds_fw.bin" + fi + if [ -f "${FW_TARGET_DIR}/rtl_bt/rtl8723d_config.bin" ]; then + ln -s "rtl8723d_config.bin" "${FW_TARGET_DIR}/rtl_bt/rtl8723ds_config.bin" + fi # The BSP kernel for RK3588 reformats the vendor firmware path for Realtek BT devices, # so symlink the firmware. if [ ${DEVICE} = "RK3588" ]; then diff --git a/packages/kernel/linux/package.mk b/packages/kernel/linux/package.mk index 653c5bdc89..039d8e8d3a 100644 --- a/packages/kernel/linux/package.mk +++ b/packages/kernel/linux/package.mk @@ -5,8 +5,8 @@ PKG_NAME="linux" PKG_LICENSE="GPL" PKG_SITE="http://www.kernel.org" -PKG_DEPENDS_HOST="ccache:host rdfind:host rsync:host openssl:host" -PKG_DEPENDS_TARGET="toolchain rdfind:host linux:host kmod:host cpio:host xz:host keyutils ncurses openssl:host wireless-regdb ${KERNEL_EXTRA_DEPENDS_TARGET}" +PKG_DEPENDS_HOST="ccache:host rsync:host openssl:host" +PKG_DEPENDS_TARGET="toolchain linux:host kmod:host cpio:host xz:host keyutils ncurses openssl:host ${KERNEL_EXTRA_DEPENDS_TARGET}" PKG_NEED_UNPACK="${LINUX_DEPENDS} $(get_pkg_directory initramfs) $(get_pkg_variable initramfs PKG_NEED_UNPACK)" PKG_LONGDESC="This package contains a precompiled kernel image and the modules." PKG_IS_KERNEL_PKG="yes" @@ -14,6 +14,10 @@ PKG_STAMP="${KERNEL_TARGET} ${KERNEL_MAKE_EXTRACMD}" PKG_PATCH_DIRS="${LINUX} ${DEVICE} default" +if [ "${DEVICE}" = "S922X" -a "${USE_MALI}" = "no" ]; then + PKG_PATCH_DIRS+=" S922X-PANFROST" +fi + case ${DEVICE} in RK3588*) PKG_VERSION="6a2f44f4d0ac3aa90ac5050138d08b46118da9cd" @@ -21,7 +25,7 @@ case ${DEVICE} in PKG_GIT_CLONE_BRANCH="rk-6.1-rkr1-panthor-v6" ;; *) - PKG_VERSION="6.8.2" + PKG_VERSION="6.8.4" PKG_URL="${PKG_SITE}/pub/linux/kernel/v6.x/${PKG_NAME}-${PKG_VERSION}.tar.xz" ;; esac @@ -72,24 +76,7 @@ make_init() { } makeinstall_init() { - if [ -n "${INITRAMFS_MODULES}" ]; then - mkdir -p ${INSTALL}/etc - mkdir -p ${INSTALL}/usr/lib/modules - - for i in ${INITRAMFS_MODULES}; do - module=`find .install_pkg/$(get_full_module_dir)/kernel -name ${i}.ko` - if [ -n "${module}" ]; then - echo ${i} >> ${INSTALL}/etc/modules - cp ${module} ${INSTALL}/usr/lib/modules/`basename ${module}` - fi - done - fi - - if [ "${UVESAFB_SUPPORT}" = yes ]; then - mkdir -p ${INSTALL}/usr/lib/modules - uvesafb=`find .install_pkg/$(get_full_module_dir)/kernel -name uvesafb.ko` - cp ${uvesafb} ${INSTALL}/usr/lib/modules/`basename ${uvesafb}` - fi + : } make_host() { @@ -153,6 +140,9 @@ pre_make_target() { ${PKG_BUILD}/scripts/config --disable CONFIG_ISCSI_IBFT fi + # enable panfrost for S922X if Mali is not being used + [ "${DEVICE}" = "S922X" -a "${USE_MALI}" = "no" ] && ${PKG_BUILD}/scripts/config --enable CONFIG_DRM_PANFROST + # disable lima/panfrost if libmali is configured if [ "${OPENGLES}" = "libmali" ]; then ${PKG_BUILD}/scripts/config --disable CONFIG_DRM_LIMA @@ -313,15 +303,3 @@ makeinstall_target() { fi makeinstall_host } - -post_install() { - if [ ! -d ${INSTALL}/$(get_full_firmware_dir) ] - then - mkdir -p ${INSTALL}/$(get_full_firmware_dir)/ - fi - - # regdb and signature is now loaded as firmware by 4.15+ - if grep -q ^CONFIG_CFG80211_REQUIRE_SIGNED_REGDB= ${PKG_BUILD}/.config; then - cp $(get_build_dir wireless-regdb)/regulatory.db{,.p7s} ${INSTALL}/$(get_full_firmware_dir) - fi -} diff --git a/packages/misc/modules/sources/Install ROCKNIX.sh b/packages/misc/modules/sources/Install ROCKNIX.sh index 58ca0306c1..900c5fc329 100755 --- a/packages/misc/modules/sources/Install ROCKNIX.sh +++ b/packages/misc/modules/sources/Install ROCKNIX.sh @@ -7,4 +7,4 @@ source /etc/profile set_kill set "installer" -weston-terminal -f --command "/usr/bin/installer" +/usr/bin/run "/usr/bin/installer" diff --git a/packages/misc/modules/sources/gamelist.xml b/packages/misc/modules/sources/gamelist.xml index 3cfb0e8a4f..7c5b0131dd 100755 --- a/packages/misc/modules/sources/gamelist.xml +++ b/packages/misc/modules/sources/gamelist.xml @@ -3,9 +3,9 @@ ./fileman.sh File Manager - Enables you to browse the JELOS filesystem and manage files directly on your device. You can also use this tool to copy files from external drives to your JELOS filesystem. - Tardigrade and JELOS - JELOS + Enables you to browse the ROCKNIX filesystem and manage files directly on your device. You can also use this tool to copy files from external drives to your ROCKNIX filesystem. + Tardigrade and ROCKNIX + ROCKNIX 5.0 2022 Tool @@ -13,11 +13,11 @@ ./images/file-manager.svg - ./Install JELOS.sh - Install JELOS - Use this utility to install JELOS to the local storage on your device. Note: This process will wipe the drive that you choose to install JELOS on. - JELOS - JELOS + ./Install ROCKNIX.sh + Install ROCKNIX + Use this utility to install ROCKNIX to the local storage on your device. Note: This process will wipe the drive that you choose to install ROCKNIX on. + ROCKNIX + ROCKNIX 5.0 2022 Tool @@ -27,9 +27,9 @@ ./Start PortMaster.sh PortMaster - PortMaster is a simple tool that allows you to download various game ports that are available for 351Elec, ArkOS, JelOS, RetroOZ, and TheRA for ARM based devices. You can find details at github.com/christianhaitian/PortMaster - JELOS - JELOS + PortMaster is a simple tool that allows you to download various game ports that are available for 351Elec, ArkOS, ROCKNIX, RetroOZ, and TheRA for ARM based devices. You can find details at github.com/christianhaitian/PortMaster + ROCKNIX + ROCKNIX 5.0 2022 Tool @@ -39,9 +39,9 @@ ./cloud_backup.sh RCLONE Backup - Backup your saves to a cloud drive using RCLONE. Please make sure you have followed the steps at rocknix.org to set up RCLONE first. - JELOS - JELOS + Backup your saves to a cloud drive using RCLONE. Please make sure you have followed the steps at jelos.org to set up RCLONE first. + ROCKNIX + ROCKNIX 5.0 2022 Script @@ -51,9 +51,9 @@ ./cloud_restore.sh RCLONE Restore - Restores your saves from a cloud drive using RCLONE. Please make sure you have followed the steps at rocknix.org to set up RCLONE first. - JELOS - JELOS + Restores your saves from a cloud drive using RCLONE. Please make sure you have followed the steps at jelos.org to set up RCLONE first. + ROCKNIX + ROCKNIX 5.0 2022 Script @@ -64,8 +64,8 @@ ./Remove ._ Files.sh Remove ._ Files This tool can be run to remove hidden ._ files created by the MacOS filesystem - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2021 Script @@ -76,8 +76,8 @@ ./Start CEMU.sh Start Cemu Opens the Cemu GUI (WiiU) to enable global configuration changes to be made directly to the emulator. It's recommended to have a mouse and keyboard available to modify settings. Software to emulate Wii U games and applications. - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2023 Emulator @@ -88,8 +88,8 @@ ./Start HATARISA.sh Start Hatari Opens the Hatari GUI to enable global configuration changes to be made directly. Hatari is an Atari ST/STE/TT/Falcon emulator for GNU/Linux, BSD, Mac OS X, Windows and other systems which are supported by the SDL library. The Atari ST was a 16/32 bit computer system which was first released by Atari in 1985. Using the Motorola 68000 CPU, it was a very popular computer having quite a lot of CPU power at that time. Unlike many other Atari ST emulators which try to give you a good environment for running GEM applications, Hatari tries to emulate the hardware of a ST as close as possible so that it is able to run most of the old ST games and demos. Hatari is open source software and is distributed under the terms of the GNU General Public License (GPL). - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2023 Emulator @@ -100,8 +100,8 @@ ./Start Moonlight.sh Start Moonlight Opens the Moonlight GUI to enable global configuration changes to be made directly. Moonlight (formerly Limelight) is an open source implementation of NVIDIA's GameStream protocol. We implemented the protocol used by the NVIDIA Shield and wrote a set of 3rd party clients. You can stream your collection of PC games from your GameStream-compatible PC to any supported device and play them remotely. Moonlight is perfect for gaming on the go without sacrificing the graphics and game selection available on PC. - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2023 Game Stream @@ -112,8 +112,8 @@ ./Start PCSX2.sh Start PCSX2 Opens the PCSX2 GUI (PS2) to enable global configuration changes to be made directly to the emulator. It's recommended to have a mouse and keyboard available to modify settings. PCSX2 is a free and open-source PlayStation 2 (PS2) emulator. Its purpose is to emulate the PS2's hardware, using a combination of MIPS CPU Interpreters, Recompilers and a Virtual Machine which manages hardware states and PS2 system memory. - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2021 Emulator @@ -124,8 +124,8 @@ ./Start PPSSPP.sh Start PPSSPP Opens the PPSSPP GUI (PSP) to enable global configuration changes to be made directly to the emulator. PPSSPP can run your PSP games on your PC or Android phone in full HD resolution or even higher. It can also upscale textures to make them sharper, and you can enable post-processing shaders to adjust color and brightness the way you like, and other effects. - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2021 Emulator @@ -136,8 +136,8 @@ ./Start 32bit Retroarch.sh Start RetroArch (32-bit) Opens the RetroArch GUI (32-bit version) to enable global configuration changes to be made directly to the emulator. RetroArch is a frontend for emulators, game engines and media players. - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2021 Emulator @@ -148,8 +148,8 @@ ./Start 64bit Retroarch.sh Start RetroArch (64-bit) Opens the RetroArch GUI (64-bit version) to enable global configuration changes to be made directly to the emulator. RetroArch is a frontend for emulators, game engines and media players. - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2021 Emulator @@ -162,8 +162,8 @@ Opens the RPCS3 GUI (PS3) to enable configuration changes to be made directly to the emulator. You can use this to set up firmware, update controls and install packages. It's recommended to have a mouse and keyboard available to modify settings. RPCS3 is a multi-platform open-source Sony PlayStation 3 emulator and debugger written in C++ for Windows, Linux, macOS and FreeBSD. - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2021 Emulator @@ -174,8 +174,8 @@ ./Start ScummVM.sh Start ScummVM Opens the ScummVM GUI to enable global configuration changes to be made directly to the emulator. It's recommended to have a mouse and keyboard available to modify settings. ScummVM is a program which allows you to run certain classic graphical adventure and role-playing games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed! ScummVM is a complete rewrite of these games' executables and is not an emulator. - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2021 Emulator @@ -186,8 +186,8 @@ ./Start Xemu.sh Start Xemu Opens the Xemu GUI (Xbox) to enable global configuration changes to be made directly to the emulator. It's recommended to have a mouse and keyboard available to modify settings. A free and open-source application that emulates the original Microsoft Xbox game console, enabling people to play their original Xbox games on Windows, macOS, and Linux systems. - JELOS - JELOS + ROCKNIX + ROCKNIX 5.0 2023 Emulator diff --git a/packages/rocknix/sources/post-update b/packages/rocknix/sources/post-update index 8c623d9403..de959aa968 100644 --- a/packages/rocknix/sources/post-update +++ b/packages/rocknix/sources/post-update @@ -77,3 +77,9 @@ fi ### Add items below this line that are safe to remove after a period of time. ################################################################################ + +# Remove forcepack setting for folks updating from jelos rk3326 and rk3399 +if echo ${HW_DEVICE} | grep RK33; then + echo "Removing" + rm -f /storage/.config/profile.d/041-panfrost +fi diff --git a/packages/rocknix/sources/scripts/run b/packages/rocknix/sources/scripts/run index 84afb357f9..e753a86130 100755 --- a/packages/rocknix/sources/scripts/run +++ b/packages/rocknix/sources/scripts/run @@ -22,9 +22,9 @@ elif echo "${UI_SERVICE}" | grep "sway"; then if [ -f "${*}" ] then RUN=$(echo ${*} | sed 's# #\\ #g') - foot ${RUN} + foot -F ${RUN} else - foot ${*} + foot -F ${*} fi else ui_state stop diff --git a/packages/sysutils/busybox/scripts/fs-resize b/packages/sysutils/busybox/scripts/fs-resize index e56c861908..a6d6b4c3bc 100755 --- a/packages/sysutils/busybox/scripts/fs-resize +++ b/packages/sysutils/busybox/scripts/fs-resize @@ -2,62 +2,70 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv) -# Copyright (C) 2018-present Team CoreELEC (https://coreelec.org) -# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) + +StartProgressLog() { + if [ "$1" = "spinner" ]; then + echo "*** $3" >>$LOG + fi + StartProgress "$@" +} if [ -e /storage/.please_resize_me ] ; then . /usr/lib/rocknix/functions hidecursor + mount -o remount,rw /flash + LOG=/flash/fs-resize.log + date -Iseconds >>$LOG + # this sh** was never intended to be used # on already installed and runing system - if [ -d /storage/.kodi -o -d /storage/.config -o -d /storage/.cache ] ; then + if [ -d /storage/.config -o -d /storage/.cache ] ; then rm -f /storage/.please_resize_me sync - echo "Resizing is not permitted - the system has already been initialised." - StartProgress countdown "Rebooting in 15s... " 15 "NOW" - reboot + echo "Resizing is not permitted - the system has already been initialised." | tee -a $LOG + mount -o remount,ro /flash + StartProgress countdown "Rebooting in 5s... " 5 "NOW" + reboot -f fi # get the disk. /storage on 2nd partition - PART=$(blkid | awk 'BEGIN {FS=":"} /'$(cat /proc/cmdline | sed -e 's#^.*disk=UUID=##g' -e 's#\ .*$##g')'/ {print $1}') - if [ "$(echo ${PART} | awk '/mmcblk/ || /nvme/ {print $1}')" ] - then - DISK=$(echo ${PART} | sed s/p[0-9]//g) - PARTNUM=$(echo ${PART} | sed "s#^.*[0-9]p##g") - else - DISK=$(echo ${PART} | sed s/[0-9]//g) - PARTNUM=$(echo ${PART} | sed "s#^.*sd[a-z]##g") - fi + echo $(grep "/storage " /proc/mounts) >>$LOG + PART=$(grep "/storage " /proc/mounts | cut -d" " -f1 | grep '2$') + + # get disk: /dev/sdx2 -> /dev/sdx, /dev/mmcblkxp2 -> /dev/mmcblkx + case $PART in + "/dev/mmcblk"*|"/dev/nvme"*) + DISK=$(echo $PART | sed s/p2$//g) + ;; + *) + DISK=$(echo $PART | sed s/2$//g) + ;; + esac + rm -f /storage/.please_resize_me sync + echo "DISK: $DISK PART: $PART" >>$LOG + # just in case - if [ ! -z "${DISK}" -a ! -z "${PART}" ] ; then - umount ${PART} + if [ ! -z "$DISK" -a ! -z "$PART" ] ; then + umount $PART - clear >/dev/console echo "PARTITION RESIZING IN PROGRESS" echo "" echo "Please do not reboot or turn off your @DISTRONAME@ device!" echo "" - # identify the partition scheme, and if gpt fix minor issues such as gpt header not at end of disk - SCHEME=$(blkid -s PTTYPE -o value ${DISK}) - if [ "$SCHEME" = "gpt" ]; then - StartProgress spinner "Checking layout... " "parted -fs ${DISK} print &>/dev/null" - fi - - StartProgress spinner "Resizing storage partition... " "parted -s -a optimal -m ${DISK} resizepart ${PARTNUM} 100% &>/dev/null" - StartProgress spinner "Checking storage file system... " "e2fsck -f -p ${PART} &>/dev/null" - StartProgress spinner "Resizing storage file system... " "resize2fs ${PART} &>/dev/null" - StartProgress spinner "Checking storage file system... " "e2fsck -f -p ${PART} &>/dev/null" - + StartProgressLog spinner "Resizing partition... " "parted -s -f -m $DISK resizepart 2 100% >>$LOG 2>&1" + StartProgressLog spinner "Checking file system... " "e2fsck -f -p $PART >>$LOG 2>&1" + StartProgressLog spinner "Resizing file system... " "resize2fs $PART >>$LOG 2>&1" StartProgress countdown "Rebooting in 5s... " 5 "NOW" + else + echo "Partition was not detected - resizing aborted." + StartProgress countdown "Rebooting in 5s... " 5 "NOW" fi + mount -o remount,ro /flash fi -sync &>/dev/null -sync &>/dev/null -sync &>/dev/null -reboot &>/dev/null +reboot -f &>/dev/null diff --git a/packages/sysutils/dosfstools/patches/dosfstools-01-silence_backup_boot_sector_diff.patch b/packages/sysutils/dosfstools/patches/dosfstools-01-silence_backup_boot_sector_diff.patch index 2fe329dc55..921a7f061a 100644 --- a/packages/sysutils/dosfstools/patches/dosfstools-01-silence_backup_boot_sector_diff.patch +++ b/packages/sysutils/dosfstools/patches/dosfstools-01-silence_backup_boot_sector_diff.patch @@ -1,23 +1,45 @@ - -Do not print backup boot sector diff in non interactive mode to avoid log spam. - ---- a/src/boot.c 2017-01-23 02:16:58.000000000 +0100 -+++ a/src/boot.c 2020-02-05 18:32:16.000000000 +0100 -@@ -174,6 +174,9 @@ static void check_backup_boot(DOS_FS * f - char buf[20]; +diff -rupN dosfstools.orig/src/boot.c dosfstools/src/boot.c +--- dosfstools.orig/src/boot.c 2024-04-08 14:07:58.287936209 +0000 ++++ dosfstools/src/boot.c 2024-04-08 14:49:01.814019776 +0000 +@@ -301,24 +301,24 @@ static void check_backup_boot(DOS_FS * f + int i, pos, first = 1; + char buf[32]; - printf("There are differences between boot sector and its backup.\n"); -+ if (!interactive) -+ printf("This is mostly harmless.\n"); -+ else { - printf("This is mostly harmless. Differences: (offset:original/backup)\n "); - pos = 2; - for (p = (uint8_t *) b, q = (uint8_t *) & b2, i = 0; i < sizeof(b2); -@@ -188,6 +191,7 @@ static void check_backup_boot(DOS_FS * f - first = 0; - } - } -+ } - printf("\n"); +- printf("There are differences between boot sector and its backup.\n"); +- printf("This is mostly harmless. Differences: (offset:original/backup)\n "); +- pos = 2; +- for (p = (uint8_t *) b, q = (uint8_t *) & b2, i = 0; i < sizeof(b2); +- ++p, ++q, ++i) { +- if (*p != *q) { +- sprintf(buf, "%s%u:%02x/%02x", first ? "" : ", ", +- (unsigned)(p - (uint8_t *) b), *p, *q); +- if (pos + strlen(buf) > 78) +- printf("\n "), pos = 2; +- printf("%s", buf); +- pos += strlen(buf); +- first = 0; +- } +- } +- printf("\n"); ++ //printf("There are differences between boot sector and its backup.\n"); ++ //printf("This is mostly harmless. Differences: (offset:original/backup)\n "); ++ //pos = 2; ++ //for (p = (uint8_t *) b, q = (uint8_t *) & b2, i = 0; i < sizeof(b2); ++ // ++p, ++q, ++i) { ++ // if (*p != *q) { ++ // sprintf(buf, "%s%u:%02x/%02x", first ? "" : ", ", ++ // (unsigned)(p - (uint8_t *) b), *p, *q); ++ // if (pos + strlen(buf) > 78) ++ // printf("\n "), pos = 2; ++ // printf("%s", buf); ++ // pos += strlen(buf); ++ // first = 0; ++ // } ++ //} ++ //printf("\n"); - if (interactive) +- switch (get_choice(3, " Not automatically fixing this.", ++ switch (get_choice(3, "", + 3, + 1, "Copy original to backup", + 2, "Copy backup to original", diff --git a/packages/sysutils/system-utils/sources/devices/AMD64/overclock b/packages/sysutils/system-utils/sources/devices/AMD64/overclock index 3cf0c19d06..f40a97e8f7 100755 --- a/packages/sysutils/system-utils/sources/devices/AMD64/overclock +++ b/packages/sysutils/system-utils/sources/devices/AMD64/overclock @@ -44,4 +44,4 @@ fi WATTS=$(echo "(${PROFILE%w} * 1000) / 1" | bc) -ryzenadj --tctl-temp=97 --stapm-limit=${WATTS} --fast-limit=${WATTS} --stapm-time=500 --slow-limit=${WATTS} --slow-time=30 --vrmmax-current=70000 +ryzenadj --tctl-temp=97 --stapm-limit=${WATTS} --fast-limit=${WATTS} --slow-limit=${WATTS} diff --git a/packages/tools/installer/config/installer.conf b/packages/tools/installer/config/installer.conf index 74505952fc..dfab1946d3 100644 --- a/packages/tools/installer/config/installer.conf +++ b/packages/tools/installer/config/installer.conf @@ -2,8 +2,8 @@ # Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv) # Disklabel for System and Storage partition - DISKLABEL_SYSTEM="boot" - DISKLABEL_STORAGE="storage" + DISKLABEL_SYSTEM="@DISTRO_BOOTLABEL@" + DISKLABEL_STORAGE="@DISTRO_DISKLABEL@" # Default size of system partition, in MB, eg. 512 PARTSIZE_SYSTEM="@SYSTEM_SIZE@" diff --git a/packages/tools/installer/package.mk b/packages/tools/installer/package.mk index 1ef4452f05..b4686d4c3b 100644 --- a/packages/tools/installer/package.mk +++ b/packages/tools/installer/package.mk @@ -17,11 +17,15 @@ post_install() { -e "s/@EXTRA_CMDLINE@/${EXTRA_CMDLINE}/g" \ -i ${INSTALL}/usr/bin/installer + chmod +x ${INSTALL}/usr/bin/installer + mkdir -p ${INSTALL}/etc cp ${PKG_DIR}/config/* ${INSTALL}/etc sed -e "s/@SYSTEM_SIZE@/${SYSTEM_SIZE}/g" \ -e "s/@SYSTEM_PART_START@/${SYSTEM_PART_START}/g" \ -e "s/@SYSLINUX_PARAMETERS@/${SYSLINUX_PARAMETERS}/g" \ + -e "s/@DISTRO_BOOTLABEL@/${DISTRO_BOOTLABEL}/g" \ + -e "s/@DISTRO_DISKLABEL@/${DISTRO_DISKLABEL}/g" \ -i ${INSTALL}/etc/installer.conf enable_service installer.service diff --git a/packages/tools/installer/scripts/installer b/packages/tools/installer/scripts/installer old mode 100755 new mode 100644 index 1417f81a48..7077dfedfc --- a/packages/tools/installer/scripts/installer +++ b/packages/tools/installer/scripts/installer @@ -225,23 +225,6 @@ do_install_quick() { printf "fix " | parted ---pretend-input-tty ${INSTALL_DEVICE} print >> $LOGFILE 2>&1 PART1=7 INSTALL_UBOOT=false - else - PART1=1 - msg_progress_install "8" "Creating uboot partition on ${INSTALL_DEVICE}${PARTID}${PART1}" - parted -s "${INSTALL_DEVICE}" unit s mkpart uboot 16384 24575 >> $LOGFILE 2>&1 - if [ -e "/usr/share/bootloader/trust.img" ] - then - TRUST_LABEL="trust" - elif [ -e "/usr/share/bootloader/resource.img" ] - then - TRUST_LABEL="resource" - fi - if [ -n "${TRUST_LABEL}" ] - then - PART1=$(( ${PART1} + 1 )) - msg_progress_install "8" "Creating ${TRUST_LABEL} partition on ${INSTALL_DEVICE}${PARTID}${PART1}" - parted -s "${INSTALL_DEVICE}" unit s mkpart ${TRUST_LABEL} 24576 32767 >> $LOGFILE 2>&1 - fi fi ;; *) @@ -262,7 +245,7 @@ do_install_quick() { PART1=$(( ${PART1} + 1 )) BOOT_PART=${PART1} - + msg_progress_install "10" "Creating flash partition on ${INSTALL_DEVICE}${PARTID}${PART1}" if [ "$GPT" = "1" ]; then parted -s ${INSTALL_DEVICE} unit s mkpart $DISKLABEL_SYSTEM fat32 -- $partsize_system_start $partsize_system_end >> $LOGFILE 2>&1 @@ -275,7 +258,7 @@ do_install_quick() { if [ "$GPT" = "1" ]; then parted -s ${INSTALL_DEVICE} unit s mkpart $DISKLABEL_STORAGE ext4 -- $partsize_storage_start $partsize_storage_end >> $LOGFILE 2>&1 else - parted - ${INSTALL_DEVICE} unit s mkpart storage ext4 -- $partsize_storage_start $partsize_storage_end >> $LOGFILE 2>&1 + parted -s ${INSTALL_DEVICE} unit s mkpart primary ext4 -- $partsize_storage_start $partsize_storage_end >> $LOGFILE 2>&1 fi msg_progress_install "16" "Setup bootflag on partition ${BOOT_PART} of ${INSTALL_DEVICE}" @@ -324,7 +307,7 @@ do_install_quick() { if [ ! "${INSTALL_UBOOT}" = false ] then msg_progress_install "50" "Installing bootloader to $TMPDIR/part1" - /usr/share/bootloader/update.sh "${INSTALL_DEVICE}" "${TMPDIR}/part1" "$UUID_SYSTEM" "$UUID_STORAGE" "$SYSLINUX_PARAMETERS" + BOOT_DISK="${INSTALL_DEVICE}" BOOT_ROOT="/flash" /usr/share/bootloader/update.sh mount -o remount,rw $TMPDIR/part1 fi ;; @@ -342,7 +325,7 @@ PROMPT 0 LABEL linux KERNEL /KERNEL - APPEND boot=UUID=$UUID_SYSTEM disk=UUID=$UUID_STORAGE $SYSLINUX_PARAMETERS rootwait quiet systemd.debug_shell=ttyFIQ0 earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty0 coherent_pool=2M fbcon=rotate:1 + APPEND boot=LABEL=${DISKLABEL_SYSTEM} disk=LABEL=${DISKLABEL_STORAGE} ${EXTRA_CMDLINE} EOF cat << EOF > $TMPDIR/part1/EFI/BOOT/grub.cfg @@ -351,7 +334,7 @@ set default="${DISTRO}" menuentry "${DISTRO}" { search --set -f /KERNEL - linux /KERNEL boot=UUID=$UUID_SYSTEM disk=UUID=$UUID_STORAGE rootwait quiet systemd.debug_shell=ttyFIQ0 earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty0 coherent_pool=2M fbcon=rotate:1 + linux /KERNEL boot=LABEL=${DISKLABEL_SYSTEM} disk=LABEL=${DISKLABEL_STORAGE} ${EXTRA_CMDLINE} } EOF @@ -363,11 +346,8 @@ EOF esac # install system files - msg_progress_install "60" "Installing Kernel" - cp "/flash/$IMAGE_KERNEL" $TMPDIR/part1/KERNEL >> $LOGFILE 2>&1 - - msg_progress_install "65" "Installing System" - cp "/flash/$IMAGE_SYSTEM" $TMPDIR/part1/SYSTEM >> $LOGFILE 2>&1 + msg_progress_install "60" "Installing boot files" + cp -r /flash/* $TMPDIR/part1/ >> $LOGFILE 2>&1 sync sync @@ -429,7 +409,7 @@ msg_progress_install() { prompt_gpt() { case ${HW_ARCH} in arm|aarch64) - BOOT_DEVICE=$(blkid | awk 'BEGIN {FS=":"} /'$(cat /proc/cmdline | sed -e 's~^.*disk=UUID=~~g; s~\ .*$~~g')'/ {print $1}' | sed 's~p[0-9].*$~~g') + BOOT_DEVICE=$(blkid | awk 'BEGIN {FS=":"} /'$(cat /proc/cmdline | sed -e 's~^.*disk=LABEL=~~g; s~\ .*$~~g')'/ {print $1}' | sed 's~p[0-9].*$~~g') BOOT_LABEL="$(blkid ${BOOT_DEVICE} | grep -Eo 'PTTYPE=".*"' | sed 's~PTTYPE=~~g; s~"~~g')" case ${BOOT_LABEL} in gpt) diff --git a/packages/tools/rdfind/package.mk b/packages/tools/rdfind/package.mk deleted file mode 100644 index e25f7067c9..0000000000 --- a/packages/tools/rdfind/package.mk +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) - -PKG_NAME="rdfind" -PKG_VERSION="1.6.0" -PKG_LICENSE="GPLv2" -PKG_SITE="https://github.com/pauldreik/rdfind" -PKG_URL="${PKG_SITE}/archive/refs/tags/releases/${PKG_VERSION}.tar.gz" -PKG_LONGDESC="A command line tool that finds duplicate files." -PKG_DEPENDS_HOST="nettle:host" -PKG_TOOLCHAIN="autotools" - -pre_configure_host() { - export LDFLAGS="${LDFLAGS} -L${TOOLCHAIN}/lib64" -} diff --git a/packages/ui/emulationstation/config/common/es_features.cfg b/packages/ui/emulationstation/config/common/es_features.cfg index 831f8a3734..a8df471336 100644 --- a/packages/ui/emulationstation/config/common/es_features.cfg +++ b/packages/ui/emulationstation/config/common/es_features.cfg @@ -45,6 +45,10 @@ + + + + @@ -69,6 +73,10 @@ + + + + @@ -110,11 +118,22 @@ - + + + + + + + + + + + + @@ -148,6 +167,10 @@ + + + + @@ -192,7 +215,14 @@ - + + + + + + + + @@ -946,4 +976,25 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/ui/emulationstation/config/common/es_input.cfg b/packages/ui/emulationstation/config/common/es_input.cfg index 28a1162615..23f5b36b9b 100644 --- a/packages/ui/emulationstation/config/common/es_input.cfg +++ b/packages/ui/emulationstation/config/common/es_input.cfg @@ -1115,33 +1115,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/ui/emulationstation/package.mk b/packages/ui/emulationstation/package.mk index a6d4384256..6145da15a7 100644 --- a/packages/ui/emulationstation/package.mk +++ b/packages/ui/emulationstation/package.mk @@ -3,7 +3,7 @@ # Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) PKG_NAME="emulationstation" -PKG_VERSION="05be12a48b637bb2c639a1cd917a45b92029633e" +PKG_VERSION="be669d916e9a3f393cf63c57929daf796ddec80d" PKG_GIT_CLONE_BRANCH="main" PKG_REV="1" PKG_ARCH="any" diff --git a/packages/ui/themes/es-theme-art-book-next/package.mk b/packages/ui/themes/es-theme-art-book-next/package.mk index 5762e8fd96..ae264f0050 100644 --- a/packages/ui/themes/es-theme-art-book-next/package.mk +++ b/packages/ui/themes/es-theme-art-book-next/package.mk @@ -4,7 +4,7 @@ # Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) PKG_NAME="es-theme-art-book-next" -PKG_VERSION="3c1df8c56cbe1ca476531da14c01af77aa9092a4" +PKG_VERSION="9709a73be65faab5cb18d38de5fc0298aec7fcd6" PKG_ARCH="any" PKG_LICENSE="CUSTOM" PKG_SITE="https://github.com/anthonycaccese/art-book-next-jelos" diff --git a/packages/virtual/emulators/package.mk b/packages/virtual/emulators/package.mk index b5df2dce26..01685be70c 100644 --- a/packages/virtual/emulators/package.mk +++ b/packages/virtual/emulators/package.mk @@ -8,68 +8,62 @@ PKG_SECTION="emulation" # Do not change to virtual or makeinstall_target will no PKG_LONGDESC="Emulation metapackage." PKG_TOOLCHAIN="manual" -PKG_EMUS="flycast-sa gzdoom-sa hatarisa hypseus-singe moonlight openbor pico-8 ppsspp-sa - vice-sa" - -PKG_RETROARCH="core-info libretro-database retroarch retroarch-assets retroarch-joypads retroarch-overlays \ - slang-shaders" - -LIBRETRO_CORES="81-lr a5200-lr arduous-lr atari800-lr beetle-gba-lr beetle-lynx-lr beetle-ngp-lr beetle-pce-lr beetle-pce-fast-lr \ - beetle-pcfx-lr bsnes-mercury-performance-lr beetle-supafaust-lr beetle-supergrafx-lr \ - beetle-vb-lr beetle-wswan-lr bluemsx-lr cap32-lr crocods-lr daphne-lr \ - dosbox-svn-lr dosbox-pure-lr duckstation-lr duckstation-sa easyrpg-lr emuscv-lr fake08-lr fbalpha2012-lr \ - fbalpha2019-lr fbneo-lr fceumm-lr flycast2021-lr fmsx-lr freechaf-lr freeintv-lr freej2me-lr fuse-lr \ - gambatte-lr gearboy-lr gearcoleco-lr gearsystem-lr genesis-plus-gx-lr genesis-plus-gx-wide-lr \ - gw-lr handy-lr hatari-lr idtech-lr jaxe-lr mame-lr mame2003-plus-lr mame2010-lr mame2015-lr melonds-lr \ - mesen-lr mgba-lr mojozork-lr mu-lr mupen64plus-lr mupen64plus-nx-lr neocd_lr nestopia-lr np2kai-lr \ - o2em-lr opera-lr parallel-n64-lr pcsx_rearmed-lr picodrive-lr pokemini-lr potator-lr \ - prosystem-lr puae-lr puae2021-lr px68k-lr quasi88-lr quicknes-lr race-lr same_cdi-lr \ - sameboy-lr sameduck-lr scummvm-lr smsplus-gx-lr snes9x-lr snes9x2002-lr snes9x2005_plus-lr snes9x2010-lr \ - stella-lr swanstation-lr tgbdual-lr theodore-lr tic80-lr uzem-lr vba-next-lr minivmac-lr \ - vbam-lr vecx-lr vice-lr vircon32-lr virtualjaguar-lr xmil-lr yabasanshiro-lr" +PKG_EMUS="amiberry flycast-sa gzdoom-sa hatarisa hypseus-singe moonlight mupen64plus-sa openbor pico-8 ppsspp-sa vice-sa" + +PKG_RETROARCH="core-info libretro-database retroarch retroarch-assets retroarch-joypads retroarch-overlays slang-shaders" + +LIBRETRO_CORES="81-lr a5200-lr arduous-lr atari800-lr beetle-gba-lr beetle-lynx-lr beetle-ngp-lr beetle-pce-lr beetle-pce-fast-lr \ + beetle-pcfx-lr bsnes-mercury-performance-lr beetle-supafaust-lr beetle-supergrafx-lr beetle-vb-lr beetle-wswan-lr \ + bluemsx-lr cap32-lr crocods-lr daphne-lr dosbox-svn-lr dosbox-pure-lr duckstation-lr duckstation-sa easyrpg-lr \ + emuscv-lr fake08-lr fbalpha2012-lr fbalpha2019-lr fbneo-lr fceumm-lr flycast2021-lr fmsx-lr freechaf-lr freeintv-lr \ + freej2me-lr fuse-lr gambatte-lr gearboy-lr gearcoleco-lr gearsystem-lr genesis-plus-gx-lr genesis-plus-gx-wide-lr \ + gw-lr handy-lr hatari-lr idtech-lr jaxe-lr mame-lr mame2003-plus-lr mame2010-lr mame2015-lr melonds-lr mesen-lr \ + mgba-lr minivmac-lr mojozork-lr mu-lr mupen64plus-lr mupen64plus-nx-lr neocd_lr nestopia-lr np2kai-lr o2em-lr \ + opera-lr parallel-n64-lr pcsx_rearmed-lr picodrive-lr pokemini-lr potator-lr prosystem-lr puae-lr puae2021-lr \ + px68k-lr quasi88-lr quicknes-lr race-lr same_cdi-lr sameboy-lr sameduck-lr scummvm-lr smsplus-gx-lr snes9x-lr \ + snes9x2002-lr snes9x2005_plus-lr snes9x2010-lr stella-lr swanstation-lr tgbdual-lr theodore-lr tic80-lr uzem-lr \ + vba-next-lr vbam-lr vecx-lr vice-lr vircon32-lr virtualjaguar-lr xmil-lr yabasanshiro-lr" ### Emulators or cores for specific devices case "${DEVICE}" in AMD64) - [ "${ENABLE_32BIT}" == "true" ] && EMUS_32BIT="lutris-wine" - PKG_EMUS+=" amiberry cemu-sa dolphin-sa mednafen melonds-sa minivmacsa mupen64plus-sa kronos-sa \ - nanoboyadvance-sa pcsx2-sa rpcs3-sa scummvmsa vita3k-sa xemu-sa" - LIBRETRO_CORES+=" beetle-psx-lr bsnes-lr bsnes-hd-lr desmume-lr dolphin-lr flycast-lr lrps2-lr \ - ppsspp-lr kronos-lr beetle-saturn-lr" + [ "${ENABLE_32BIT}" == "true" ] && EMUS_32BIT="wine" + PKG_EMUS+=" cemu-sa dolphin-sa lime3ds-sa mednafen melonds-sa minivmacsa mupen64plus-sa kronos-sa nanoboyadvance-sa pcsx2-sa \ + rpcs3-sa scummvmsa vita3k-sa xemu-sa" + LIBRETRO_CORES+=" beetle-psx-lr beetle-saturn-lr bsnes-lr bsnes-hd-lr desmume-lr dolphin-lr flycast-lr lrps2-lr ppsspp-lr \ + kronos-lr" ;; RK3588*) - [ "${ENABLE_32BIT}" == "true" ] && EMUS_32BIT="box86 desmume-lr gpsp-lr pcsx_rearmed-lr" - PKG_EMUS+=" amiberry aethersx2-sa dolphin-sa drastic-sa melonds-sa mupen64plus-sa nanoboyadvance-sa box64 scummvmsa \ - yabasanshiro-sa portmaster beetle-saturn-lr mednafen" - LIBRETRO_CORES+=" uae4arm beetle-psx-lr bsnes-lr bsnes-hd-lr dolphin-lr pcsx_rearmed-lr" + [ "${ENABLE_32BIT}" == "true" ] && EMUS_32BIT="box86 desmume-lr gpsp-lr pcsx_rearmed-lr wine" + PKG_EMUS+=" aethersx2-sa box64 dolphin-sa drastic-sa mednafen melonds-sa portmaster scummvmsa supermodel-sa yabasanshiro-sa" + LIBRETRO_CORES+=" beetle-psx-lr beetle-saturn-lr bsnes-lr bsnes-hd-lr dolphin-lr pcsx_rearmed-lr uae4arm" PKG_RETROARCH+=" retropie-shaders" ;; RK3399) [ "${ENABLE_32BIT}" == "true" ] && EMUS_32BIT="box86 desmume-lr gpsp-lr pcsx_rearmed-lr" - PKG_EMUS+=" amiberry aethersx2-sa dolphin-sa drastic-sa melonds-sa mupen64plus-sa box64 scummvmsa \ - yabasanshiro-sa portmaster nanoboyadvance-sa mednafen" - LIBRETRO_CORES+=" uae4arm beetle-psx-lr bsnes-lr bsnes-hd-lr dolphin-lr flycast-lr pcsx_rearmed-lr" + PKG_EMUS+=" aethersx2-sa box64 dolphin-sa drastic-sa mednafen melonds-sa nanoboyadvance-sa portmaster scummvmsa yabasanshiro-sa" + LIBRETRO_CORES+=" beetle-psx-lr bsnes-lr bsnes-hd-lr dolphin-lr flycast-lr pcsx_rearmed-lr uae4arm" PKG_RETROARCH+=" retropie-shaders" ;; RK356*) [ "${ENABLE_32BIT}" == "true" ] && EMUS_32BIT="box86 desmume-lr gpsp-lr pcsx_rearmed-lr" - PKG_DEPENDS_TARGET+=" common-shaders glsl-shaders mupen64plus-sa scummvmsa box64 portmaster mednafen" - PKG_EMUS+=" amiberry drastic-sa yabasanshiro-sa" - LIBRETRO_CORES+=" uae4arm flycast-lr" + PKG_DEPENDS_TARGET+=" common-shaders glsl-shaders" + PKG_EMUS+=" box64 drastic-sa mednafen portmaster scummvmsa yabasanshiro-sa" + LIBRETRO_CORES+=" flycast-lr uae4arm" PKG_RETROARCH+=" retropie-shaders" ;; S922X*) - [ "${ENABLE_32BIT}" == "true" ] && EMUS_32BIT="box86 pcsx_rearmed-lr" - PKG_EMUS+=" amiberry aethersx2-sa dolphin-sa drastic-sa lime3ds-sa mupen64plus-sa yabasanshiro-sa \ - box64 portmaster" - LIBRETRO_CORES+=" uae4arm beetle-psx-lr bsnes-lr bsnes-hd-lr dolphin-lr flycast-lr" + [ "${ENABLE_32BIT}" == "true" ] && EMUS_32BIT="box86 pcsx_rearmed-lr wine" + PKG_EMUS+=" aethersx2-sa box64 dolphin-sa drastic-sa portmaster yabasanshiro-sa" + LIBRETRO_CORES+=" beetle-psx-lr bsnes-lr bsnes-hd-lr dolphin-lr flycast-lr uae4arm" + [ "${USE_MALI}" != "no" ] && PKG_EMUS+=" lime3ds-sa" PKG_RETROARCH+=" retropie-shaders" ;; RK3326*) - [ "${ENABLE_32BIT}" == "true" ] && EMUS_32BIT="desmume-lr gpsp-lr pcsx_rearmed-lr" + [ "${ENABLE_32BIT}" == "true" ] && EMUS_32BIT="box86 desmume-lr gpsp-lr pcsx_rearmed-lr" PKG_DEPENDS_TARGET+=" common-shaders glsl-shaders" - PKG_EMUS+=" amiberry drastic-sa mupen64plus-sa scummvmsa yabasanshiro-sa portmaster mednafen" - LIBRETRO_CORES+=" uae4arm flycast-lr flycast2021-lr" + PKG_EMUS+=" box64 drastic-sa mednafen portmaster scummvmsa yabasanshiro-sa" + LIBRETRO_CORES+=" flycast-lr flycast2021-lr uae4arm" PKG_RETROARCH+=" retropie-shaders" ;; esac @@ -213,8 +207,12 @@ makeinstall_target() { ## Sammy Atomiswave case ${DEVICE} in - RK35*) - add_emu_core atomiswave retroarch flycast2021 false + RK3588*) + add_emu_core atomiswave retroarch flycast2021 true + add_emu_core atomiswave flycast flycast-sa false + ;; + RK3566*) + add_emu_core atomiswave retroarch flycast2021 true add_emu_core atomiswave retroarch flycast false add_emu_core atomiswave flycast flycast-sa false ;; @@ -312,8 +310,12 @@ makeinstall_target() { ### Sega Dreamcast case ${DEVICE} in - RK35*) - add_emu_core dreamcast retroarch flycast2021 false + RK3588*) + add_emu_core dreamcast retroarch flycast2021 true + add_emu_core dreamcast flycast flycast-sa false + ;; + RK3566*) + add_emu_core dreamcast retroarch flycast2021 true add_emu_core dreamcast retroarch flycast false add_emu_core dreamcast flycast flycast-sa false ;; @@ -588,6 +590,14 @@ makeinstall_target() { esac add_es_system megadrive-japan + ### Sega Model 3 + case ${DEVICE} in + RK3588) + add_emu_core segamodel3 supermodel supermodel-sa true + add_es_system segamodel3 + ;; + esac + ### Microsoft MS-DOS add_emu_core pc retroarch dosbox_pure add_emu_core pc retroarch dosbox_svn @@ -615,8 +625,12 @@ makeinstall_target() { ### Sega Naomi case ${DEVICE} in - RK35*) - add_emu_core naomi retroarch flycast2021 false + RK3588*) + add_emu_core naomi retroarch flycast2021 true + add_emu_core naomi flycast flycast-sa false + ;; + RK3566*) + add_emu_core naomi retroarch flycast2021 true add_emu_core naomi retroarch flycast false add_emu_core naomi flycast flycast-sa false ;; diff --git a/packages/virtual/network/package.mk b/packages/virtual/network/package.mk index 0e4d076970..388389142c 100644 --- a/packages/virtual/network/package.mk +++ b/packages/virtual/network/package.mk @@ -7,7 +7,7 @@ PKG_VERSION="" PKG_LICENSE="various" PKG_SITE="https://libreelec.tv" PKG_URL="" -PKG_DEPENDS_TARGET="toolchain connman rfkill hostapd netbase ethtool openssh iw rsync tailscale avahi miniupnpc nss-mdns bluetool speedtest-cli" +PKG_DEPENDS_TARGET="toolchain connman rfkill hostapd netbase ethtool openssh iw wireless-regdb rsync tailscale avahi miniupnpc nss-mdns bluetool speedtest-cli" PKG_SECTION="virtual" PKG_LONGDESC="Metapackage for various packages to install network support" diff --git a/packages/wayland/wayland-protocols/package.mk b/packages/wayland/wayland-protocols/package.mk index 48c1362448..2a17fcee3e 100644 --- a/packages/wayland/wayland-protocols/package.mk +++ b/packages/wayland/wayland-protocols/package.mk @@ -2,8 +2,7 @@ # Copyright (C) 2016-present Team LibreELEC (https://libreelec.tv) PKG_NAME="wayland-protocols" -PKG_VERSION="1.33" -PKG_SHA256="94f0c50b090d6e61a03f62048467b19abbe851be4e11ae7b36f65f8b98c3963a" +PKG_VERSION="1.34" PKG_LICENSE="OSS" PKG_SITE="https://wayland.freedesktop.org/" PKG_URL="https://gitlab.freedesktop.org/wayland/${PKG_NAME}/-/releases/${PKG_VERSION}/downloads/${PKG_NAME}-${PKG_VERSION}.tar.xz" diff --git a/post-update b/post-update index 40c7c94884..d5ffef1790 120000 --- a/post-update +++ b/post-update @@ -1 +1 @@ -packages/jelos/sources/post-update \ No newline at end of file +packages/rocknix/sources/post-update \ No newline at end of file diff --git a/projects/Amlogic/bootloader/boot.ini b/projects/Amlogic/bootloader/boot.ini index 70e20a8d34..0acd95c7ca 100644 --- a/projects/Amlogic/bootloader/boot.ini +++ b/projects/Amlogic/bootloader/boot.ini @@ -3,7 +3,7 @@ ROCKNIX-UBOOT-CONFIG setenv dtb_loadaddr "0x10000000" setenv loadaddr "0x1B00000" -setenv bootargs "boot=UUID=@UUID_SYSTEM@ disk=UUID=@UUID_STORAGE@ @EXTRA_CMDLINE@" +setenv bootargs "boot=LABEL=@DISTRO_BOOTLABEL@ disk=LABEL=@DISTRO_DISKLABEL@ @EXTRA_CMDLINE@" load mmc ${devno}:1 ${loadaddr} KERNEL load mmc ${devno}:1 ${dtb_loadaddr} ${fdtfile} diff --git a/projects/Amlogic/bootloader/extlinux/extlinux.conf b/projects/Amlogic/bootloader/extlinux/extlinux.conf index dcfac3fac1..6c075c65f4 100644 --- a/projects/Amlogic/bootloader/extlinux/extlinux.conf +++ b/projects/Amlogic/bootloader/extlinux/extlinux.conf @@ -1,4 +1,4 @@ LABEL ROCKNIX LINUX /KERNEL FDTDIR / - APPEND boot=UUID=@UUID_SYSTEM@ disk=UUID=@UUID_STORAGE@ @EXTRA_CMDLINE@ + APPEND boot=LABEL=@DISTRO_BOOTLABEL@ disk=LABEL=@DISTRO_DISKLABEL@ @EXTRA_CMDLINE@ diff --git a/projects/Amlogic/bootloader/mkimage b/projects/Amlogic/bootloader/mkimage index 2f74be8f66..c4fa6186fd 100644 --- a/projects/Amlogic/bootloader/mkimage +++ b/projects/Amlogic/bootloader/mkimage @@ -11,8 +11,8 @@ fi mkimage_bootini() { echo "image: copying boot.ini..." cp -p "${RELEASE_DIR}/3rdparty/bootloader/boot.ini" "${LE_TMP}/boot.ini" - sed -e "s/@UUID_SYSTEM@/${UUID_SYSTEM}/" \ - -e "s/@UUID_STORAGE@/${UUID_STORAGE}/" \ + sed -e "s/@DISTRO_BOOTLABEL@/${DISTRO_BOOTLABEL}/" \ + -e "s/@DISTRO_DISKLABEL@/${DISTRO_DISKLABEL}/" \ -e "s/@EXTRA_CMDLINE@/${EXTRA_CMDLINE}/" \ -i "${LE_TMP}/boot.ini" mcopy "${LE_TMP}/boot.ini" :: @@ -22,8 +22,8 @@ mkimage_extlinux() { echo "image: copying exlinux.conf..." mkdir -p "${LE_TMP}/extlinux" cp -p "${RELEASE_DIR}/3rdparty/bootloader/extlinux/extlinux.conf" "${LE_TMP}/extlinux/extlinux.conf" - sed -e "s/@UUID_SYSTEM@/${UUID_SYSTEM}/" \ - -e "s/@UUID_STORAGE@/${UUID_STORAGE}/" \ + sed -e "s/@DISTRO_BOOTLABEL@/${DISTRO_BOOTLABEL}/" \ + -e "s/@DISTRO_DISKLABEL@/${DISTRO_DISKLABEL}/" \ -e "s/@EXTRA_CMDLINE@/${EXTRA_CMDLINE}/" \ -i "${LE_TMP}/extlinux/extlinux.conf" mcopy "${LE_TMP}/extlinux" :: diff --git a/projects/Amlogic/bootloader/update.sh b/projects/Amlogic/bootloader/update.sh index 0837349caf..80d038c6ec 100755 --- a/projects/Amlogic/bootloader/update.sh +++ b/projects/Amlogic/bootloader/update.sh @@ -3,65 +3,22 @@ # Copyright (C) 2017-2021 Team LibreELEC (https://libreelec.tv) # Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) -if [ -z "${1}" ] -then - [ -z "$SYSTEM_ROOT" ] && SYSTEM_ROOT="" - [ -z "$BOOT_ROOT" ] && BOOT_ROOT="/flash" - [ -z "$BOOT_PART" ] && BOOT_PART=$(df "$BOOT_ROOT" | tail -1 | awk {' print $1 '}) - if [ -z "$BOOT_DISK" ]; then - case $BOOT_PART in - /dev/sd[a-z][0-9]*) - BOOT_DISK=$(echo $BOOT_PART | sed -e "s,[0-9]*,,g") - ;; - /dev/mmcblk*) - BOOT_DISK=$(echo $BOOT_PART | sed -e "s,p[0-9]*,,g") - ;; - esac - fi - - # mount $BOOT_ROOT r/w - mount -o remount,rw $BOOT_ROOT +[ -z "$SYSTEM_ROOT" ] && SYSTEM_ROOT="" +[ -z "$BOOT_ROOT" ] && BOOT_ROOT="/flash" +[ -z "$BOOT_PART" ] && BOOT_PART=$(df "$BOOT_ROOT" | tail -1 | awk {' print $1 '}) - - for arg in $(cat /proc/cmdline); do - case $arg in - boot=*) - boot="${arg#*=}" - case $boot in - /dev/mmc*) - UUID_SYSTEM="$(blkid $boot | sed 's/.* UUID="//;s/".*//g')" - ;; - UUID=*|LABEL=*) - UUID_SYSTEM="$(blkid | sed 's/"//g' | grep -m 1 -i " $boot " | sed 's/.* UUID=//;s/ .*//g')" - ;; - FOLDER=*) - UUID_SYSTEM="$(blkid ${boot#*=} | sed 's/.* UUID="//;s/".*//g')" - ;; - esac - ;; - disk=*) - disk="${arg#*=}" - case $disk in - /dev/mmc*) - UUID_STORAGE="$(blkid $disk | sed 's/.* UUID="//;s/".*//g')" - ;; - UUID=*|LABEL=*) - UUID_STORAGE="$(blkid | sed 's/"//g' | grep -m 1 -i " $disk " | sed 's/.* UUID=//;s/ .*//g')" - ;; - FOLDER=*) - UUID_STORAGE="$(blkid ${disk#*=} | sed 's/.* UUID="//;s/".*//g')" - ;; - esac +# identify the boot device +if [ -z "$BOOT_DISK" ]; then + case $BOOT_PART in + /dev/mmcblk*) + BOOT_DISK=$(echo $BOOT_PART | sed -e "s,p[0-9]*,,g") ;; - esac - done -else - BOOT_DISK="${1}" - BOOT_ROOT="${2}" - UUID_SYSTEM="${3}" - UUID_STORAGE="${4}" + esac fi +# mount $BOOT_ROOT rw +mount -o remount,rw $BOOT_ROOT + DT_ID=$($SYSTEM_ROOT/usr/bin/dtname) if [ -n "$DT_ID" ]; then @@ -86,27 +43,17 @@ for all_dtb in $BOOT_ROOT/*.dtb; do fi done -if [ -f $BOOT_ROOT/extlinux/extlinux.conf ] || [ -n "${1}" ]; then +if [ -f $BOOT_ROOT/extlinux/extlinux.conf ]; then if [ -f $SYSTEM_ROOT/usr/share/bootloader/extlinux/extlinux.conf ]; then echo "Updating extlinux.conf..." - if [ ! -d "${BOOT_ROOT}/extlinux" ] - then - mkdir "${BOOT_ROOT}/extlinux" - fi cp -p $SYSTEM_ROOT/usr/share/bootloader/extlinux/extlinux.conf $BOOT_ROOT/extlinux - sed -e "s/@UUID_SYSTEM@/$UUID_SYSTEM/" \ - -e "s/@UUID_STORAGE@/$UUID_STORAGE/" \ - -i $BOOT_ROOT/extlinux/extlinux.conf fi fi -if [ -f $BOOT_ROOT/boot.ini ] || [ -n "${1}" ]; then +if [ -f $BOOT_ROOT/boot.ini ]; then if [ -f /usr/share/bootloader/boot.ini ]; then echo "Updating boot.ini" cp -p /usr/share/bootloader/boot.ini $BOOT_ROOT/boot.ini - sed -e "s/@UUID_SYSTEM@/$UUID_SYSTEM/" \ - -e "s/@UUID_STORAGE@/$UUID_STORAGE/" \ - -i $BOOT_ROOT/boot.ini fi fi @@ -129,6 +76,11 @@ if [ -d $BOOT_ROOT/res ]; then fi fi -mount -o ro,remount $BOOT_ROOT +# Update system partition label to ROCKNIX +[ ! -z "$(blkid | grep JELOS)" ] && ${SYSTEM_ROOT}/usr/sbin/dosfslabel $BOOT_PART ROCKNIX + +# mount $BOOT_ROOT ro +sync +mount -o remount,ro $BOOT_ROOT echo "UPDATE" > /storage/.boot.hint diff --git a/projects/Amlogic/devices/S922X/options b/projects/Amlogic/devices/S922X/options index b48946d0f7..c3be20c0b1 100644 --- a/projects/Amlogic/devices/S922X/options +++ b/projects/Amlogic/devices/S922X/options @@ -38,7 +38,12 @@ HW_CPU="Amlogic S922X" # Mali GPU family - MALI_FAMILY="g52" + if [ "${USE_MALI}" != "no" ]; then + MALI_FAMILY="bifrost-g52" + else + MALI_FAMILY="g52" + fi + GRAPHIC_DRIVERS="panfrost" # OpenGL(X) implementation to use (mesa / no) @@ -48,10 +53,18 @@ OPENGLES="mesa" # Vulkan implementation to use (vulkan-loader / no) - VULKAN="vulkan-loader" + if [ "${USE_MALI}" != "no" ]; then + VULKAN="vulkan-loader" + else + VULKAN="no" + fi # VULKAN_SUPPORT - VULKAN_SUPPORT="yes" + if [ "${USE_MALI}" != "no" ]; then + VULKAN_SUPPORT="yes" + else + VULKAN_SUPPORT="no" + fi # Displayserver to use (weston / x11 / no) DISPLAYSERVER="wl" @@ -68,93 +81,34 @@ # additional Firmware to use ( ) # Space separated list is supported, # e.g. FIRMWARE="" - FIRMWARE="libmali-vulkan" + if [ "${USE_MALI}" != "no" ]; then + FIRMWARE="libmali-vulkan" + else + FIRMWARE="" + fi # additional drivers to install: # for a list of additional drivers see packages/linux-drivers # Space separated list is supported, # e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2" - ADDITIONAL_DRIVERS="mali-bifrost RTL8812AU RTL8821AU RTL8821CU RTL88x2BU" + ADDITIONAL_DRIVERS="RTL8812AU RTL8821AU RTL8821CU RTL88x2BU" + + if [ "${USE_MALI}" != "no" ]; then + ADDITIONAL_DRIVERS+=" mali-bifrost" + fi - # build and install driver addons (yes / no) - DRIVER_ADDONS_SUPPORT="no" - - # driver addons to install: - # for a list of additinoal drivers see packages/linux-driver-addons - # Space separated list is supported, - DRIVER_ADDONS="" - # debug tty path DEBUG_TTY="/dev/ttyAML0" # Disable 32BIT support - ENABLE_32BIT="false" + if [ "${USE_MALI}" != "no" ]; then + ENABLE_32BIT="false" + else + ENABLE_32BIT="true" + fi - # build and install bluetooth support (yes / no) - BLUETOOTH_SUPPORT="yes" - - # build and install Avahi (Zeroconf) daemon (yes / no) - AVAHI_DAEMON="no" - - # build with NFS support (mounting nfs shares via the OS) (yes / no) - NFS_SUPPORT="no" - - # build with Samba Client support (mounting samba shares via the OS) (yes / no) - SAMBA_SUPPORT="no" - - # build and install Samba Server (yes / no) - SAMBA_SERVER="yes" - - # build and install SFTP Server (yes / no) - SFTP_SERVER="yes" - - # build and install Simple HTTP Server (yes / no) - SIMPLE_HTTP_SERVER="yes" - - # build and install OpenVPN support (yes / no) - OPENVPN_SUPPORT="no" - - # build and install ZeroTier support (yes / no) - ZEROTIER_SUPPORT="yes" - - # build and install diskmounter support (udevil) - # this service provide auto mounting support for external drives in the - # mediacenter also automount internally drives at boottime via udev (yes / no) - UDEVIL="yes" - - # build and install exFAT fuse support (yes / no) - EXFAT="yes" - - # build and install NTFS-3G fuse support (yes / no) - NTFS3G="no" - - # build and install hfs filesystem utilities (yes / no) - HFSTOOLS="no" - - # Support for partitioning and formating disks in initramfs (yes / no) - # This adds support for parted and mkfs.ext3/4 to initramfs for OEM usage - INITRAMFS_PARTED_SUPPORT="no" - - # build with swap support (yes / no) - SWAP_SUPPORT="yes" - - # swap support enabled per default (yes / no) - SWAP_ENABLED_DEFAULT="yes" - - # swapfile size if SWAP_SUPPORT=yes in MB - SWAPFILESIZE="384" - # Some devices have internal storage. INSTALLER_SUPPORT="yes" - # cron support (yes / no) - CRON_SUPPORT="no" - - # Settings package name - blank if not required - DISTRO_PKG_SETTINGS="" - - # htop tool (yes / no) - HTOP_TOOL="yes" - # ROCKNIX Subdevices (supported devices: Odroid_GOU Odroid_N2 Odroid_N2L) SUBDEVICES="Odroid_GOU Odroid_N2 Odroid_N2L" diff --git a/projects/Amlogic/options b/projects/Amlogic/options index a82fe60047..b7f1b37f3f 100644 --- a/projects/Amlogic/options +++ b/projects/Amlogic/options @@ -43,9 +43,6 @@ # e.g. GRAPHIC_DRIVERS="i915 i965 r300 r600 radeonsi nvidia" GRAPHIC_DRIVERS="" - # Modules to install in initramfs for early boot - INITRAMFS_MODULES="" - # additional Firmware to use ( ) # Space separated list is supported, # e.g. FIRMWARE="" @@ -57,12 +54,6 @@ # build and install CEC framework support (yes / no) CEC_FRAMEWORK_SUPPORT="yes" - # build with installer (yes / no) - INSTALLER_SUPPORT="no" - - # build and install driver addons (yes / no) - DRIVER_ADDONS_SUPPORT="no" - # debug tty path DEBUG_TTY="/dev/ttyAML0" diff --git a/projects/Amlogic/packages/u-boot/package.mk b/projects/Amlogic/packages/u-boot/package.mk index 0457a55838..e8793bf3a4 100644 --- a/projects/Amlogic/packages/u-boot/package.mk +++ b/projects/Amlogic/packages/u-boot/package.mk @@ -29,13 +29,17 @@ makeinstall_target() { if find_file_path bootloader/boot.ini; then cp -av ${FOUND_PATH} $INSTALL/usr/share/bootloader - sed -e "s/@EXTRA_CMDLINE@/${EXTRA_CMDLINE}/" \ + sed -e "s/@DISTRO_BOOTLABEL@/${DISTRO_BOOTLABEL}/" \ + -e "s/@DISTRO_DISKLABEL@/${DISTRO_DISKLABEL}/" \ + -e "s/@EXTRA_CMDLINE@/${EXTRA_CMDLINE}/" \ -i "${INSTALL}/usr/share/bootloader/boot.ini" fi if find_dir_path bootloader/extlinux; then cp -av ${FOUND_PATH} $INSTALL/usr/share/bootloader - sed -e "s/@EXTRA_CMDLINE@/${EXTRA_CMDLINE}/" \ + sed -e "s/@DISTRO_BOOTLABEL@/${DISTRO_BOOTLABEL}/" \ + -e "s/@DISTRO_DISKLABEL@/${DISTRO_DISKLABEL}/" \ + -e "s/@EXTRA_CMDLINE@/${EXTRA_CMDLINE}/" \ -i "${INSTALL}/usr/share/bootloader/extlinux/extlinux.conf" fi diff --git a/projects/Amlogic/patches/linux/S922X-PANFROST/0001-Revert-arm64-meson-g12-common-add-mali-to-dts.patch b/projects/Amlogic/patches/linux/S922X-PANFROST/0001-Revert-arm64-meson-g12-common-add-mali-to-dts.patch new file mode 100644 index 0000000000..2a0c1decd5 --- /dev/null +++ b/projects/Amlogic/patches/linux/S922X-PANFROST/0001-Revert-arm64-meson-g12-common-add-mali-to-dts.patch @@ -0,0 +1,58 @@ +From 4de8ccca441813e778bec3494f8d3e6831eb6d3c Mon Sep 17 00:00:00 2001 +From: spycat88 +Date: Sat, 6 Apr 2024 13:55:49 +0100 +Subject: [PATCH] Revert "arm64: meson: g12-common: add mali to dts" + +This reverts commit f8404960bde38a0f1bdd50a032b1a1bb69ed826c. +--- + .../arm64/boot/dts/amlogic/meson-g12-common.dtsi | 16 +++++----------- + arch/arm64/boot/dts/amlogic/meson-g12b.dtsi | 3 +-- + 2 files changed, 6 insertions(+), 13 deletions(-) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +index 2631b19d8cf6..c45ad6d6ddc8 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +@@ -2464,20 +2464,14 @@ dwc3: usb@ff500000 { + }; + + mali: gpu@ffe40000 { +- compatible = "arm,mali-midgard"; +- reg = <0x0 0xffe40000 0x0 0x40000>, +- <0 0xFFD01000 0 0x01000>, +- <0 0xFF800000 0 0x01000>, +- <0 0xFF63c000 0 0x01000>, +- <0 0xFFD01000 0 0x01000>; +- ++ compatible = "amlogic,meson-g12a-mali", "arm,mali-bifrost"; ++ reg = <0x0 0xffe40000 0x0 0x40000>; + interrupt-parent = <&gic>; +- interrupts = , ++ interrupts = , + , +- ; +- interrupt-names = "GPU", "MMU", "JOB"; ++ ; ++ interrupt-names = "job", "mmu", "gpu"; + clocks = <&clkc CLKID_MALI>; +- clock-names = "clk_mali"; + resets = <&reset RESET_DVALIN_CAPB3>, <&reset RESET_DVALIN>; + operating-points-v2 = <&gpu_opp_table>; + #cooling-cells = <2>; +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi +index f22c27a1472c..86e6ceb31d5e 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi +@@ -139,8 +139,7 @@ map1 { + }; + + &mali { +- system-coherency = <0>; +- power_policy = "always_on"; ++ dma-coherent; + }; + + &pmu { +-- +2.34.1 + diff --git a/projects/Amlogic/patches/linux/S922X-PANFROST/100-panfrost-memory-shrinker.patch b/projects/Amlogic/patches/linux/S922X-PANFROST/100-panfrost-memory-shrinker.patch new file mode 100644 index 0000000000..eab5999678 --- /dev/null +++ b/projects/Amlogic/patches/linux/S922X-PANFROST/100-panfrost-memory-shrinker.patch @@ -0,0 +1,5235 @@ +* [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers +@ 2024-01-05 18:45 Dmitry Osipenko + 2024-01-05 18:45 ` [PATCH v19 01/30] drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names Dmitry Osipenko + ` (29 more replies) + 0 siblings, 30 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:45 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +This series: + + 1. Adds common drm-shmem memory shrinker + 2. Moves drm-shmem drivers to new SGT usage policy + 3. Enables shrinker for VirtIO-GPU driver + 4. Switches Panfrost driver to the common shrinker + 5. Fixes bugs and improves/refactors drm-shmem code + +Mesa: https://gitlab.freedesktop.org/digetx/mesa/-/commits/virgl-madvise +IGT: https://gitlab.freedesktop.org/digetx/igt-gpu-tools/-/commits/virtio-madvise + https://gitlab.freedesktop.org/digetx/igt-gpu-tools/-/commits/panfrost-madvise + +Changelog: + +v19:- Addressed v18 review comments from Boris Brezillon: + + - Improved bisectablity of Panfrost and drm-shmem patches by + fixing iterim warning splats related to shrinker changes. + + - Improved commit messages + + - Reworked Lima patch to avoid adding `put_pages` flag + + - Reworked Panfrost patch that switches driver to explicit + get/put pages by moving drm_gem_shmem_put_pages() into + gem_mapping_release() instead of gem_free_object(). + + - Updated Panfrost patch that switches driver to generic shrinker + with more comments and minor imporovemnts. + + - Added new Panfrost patch from Boris that fixes handling of + a partially mapped heap BOs. + + - Added link to the related Mesa MR to the commit msg of the patch + that adds new DRM_VIRTGPU_MADVISE ioctl, like was requested by + Gurchetan Singh. + + - Added ackes/r-b from Boris Brezillon and Maxime Ripard + + - New patches in v19: + + drm/gem: Document locking rule of vmap and evict callbacks + drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr() + + - Factored out couple code changes into these new separate patches: + + drm/shmem-helper: Avoid lockdep warning when pages are released + drm/shmem-helper: Turn warnings about imported GEM into errors + +v18:- Added new pathes that change sgt allocation policy. Previously once + sgt was allocated, it exsited till GEM was freed. Now sgt is destroyed + once pages are unpinned and drivers have to manage the pages' pinning + refcounting by themselves using get/put() and pin/unpin() pages. + This removes pages refcounting ambiguity from the drm-shmem core. + + - Dropped patch that changed drm_gem_shmem_vmap_locked() error handling, + like was requested by Boris Brezillon. + + - Added new patches that make minor improvements: + + - Optimize unlocked get_pages_sgt() + - Don't free refcounted GEM + + - Dropped t-b from the Panfrost shrinker patch that was given for older + patch version since code changed with the new sgt allocation policy. + +v17:- Dropped patches that added new drm-shmem sgt flags, fixing dma-buf UAF + in drm-prime error code path and preventing invalid page_count when GEM + is freed. Will revist them later on and then factor them out into a + seprate patchset. + + - Dropped patches that replaced drm_gem_shmem_free() with + drm_gem_object_put(), they not needed anymore after changing + drm_gem_shmem_free() to not touch reservation lock. + + - Addressed review comments from Boris Brezillon: + + - Added new patch to clean up error unwinding in + drm_gem_shmem_vmap_locked() + + - Added new __drm_gem_shmem_put_pages() to let the callers + to assert the held reservation lock themselves + + - Moved replacement of shmem->pages check with refcount_read() + in drm_gem_shmem_free() to the shrinker addition patch + + - Improved commit message of the vmap_use_count patch + + - Added r-bs from Boris Brezillon that he gave to v16 + +v16:- Added more comments to the code for the new drm-shmem flags + + - Added r-bs from Boris Brezillon + + - Fixed typos and made impovements pointed out by Boris Brezillon + + - Replaced kref with refcount_t as was suggested by Boris Brezillon + + - Corrected placement of got_sgt flag in the Lima driver, also renamed + flag to got_pages_sgt + + - Removed drm_gem_shmem_resv_assert_held() and made drm_gem_shmem_free() + to free pages without a new func that doesn't touch resv lock, as was + suggested by Boris Brezillon + + - Added pages_pin_count to drm_gem_shmem_print_info() + +v15:- Moved drm-shmem reference counters to use kref that allows to + optimize unlocked functions, like was suggested by Boris Brezillon. + + - Changed drm/gem/shmem function names to use _locked postfix and + dropped the _unlocked, making the naming scheme consistent across + DRM code, like was suggested by Boris Brezillon. + + - Added patch that fixes UAF in drm-shmem for drivers that import + dma-buf and then release buffer in the import error code path. + + - Added patch that makes drm-shmem use new flag for SGT's get_pages() + refcounting, preventing unbalanced refcounting when GEM is freed. + + - Fixed guest blob pinning in virtio-gpu driver that was missed + previously in the shrinker patch. + + - Moved VC4 and virtio-gpu drivers to use drm_gem_put() in + GEM-creation error code paths, which is now required by drm-shmem + and was missed in a previous patch versions. + + - Virtio-GPU now attaches shmem pages to host on first use and not + when BO is created. In older patch versions there was a potential + race condition in the BO creation code path where both + get_sgt()+object_attach() should've been made under same resv lock, + otherwise pages could be evicted before attachment is invoked. + + - Virtio-GPU and drm-shmem shrinker patches are split into smaller + ones. + +v14:- All the prerequisite reservation locking patches landed upstream, + previously were a part of this series in v13 and older. + + https://lore.kernel.org/dri-devel/20230529223935.2672495-1-dmitry.osipenko@collabora.com/ + + - Added patches to improve locked/unlocked function names, like was + suggested by Boris Brezillon for v13. + + - Made all exported drm-shmem symbols GPL, like was previously + discussed with Thomas Zimmermann on this series. + + - Improved virtio-gpu shrinker patch. Now it won't detach purged BO + when userspace closes GEM. Crosvm (and not qemu) checks res_id on + CMD_CTX_DETACH_RESOURCE and prints noisy error message if ID is + invalid, which wasn't noticed before. + +v13:- Updated virtio-gpu shrinker patch to use drm_gem_shmem_object_pin() + directly instead of drm_gem_pin() and dropped patch that exported + drm_gem_pin() functions, like was requested by Thomas Zimmermann in + v12. + +v12:- Fixed the "no previous prototype for function" warning reported by + kernel build bot for v11. + + - Fixed the missing reservation lock reported by Intel CI for VGEM + driver. Other drivers using drm-shmem were affected similarly to + VGEM. The problem was in the dma-buf attachment code path that led + to drm-shmem pinning function which assumed the held reservation lock + by drm_gem_pin(). In the past that code path was causing trouble for + i915 driver and we've changed the locking scheme for the attachment + code path in the dma-buf core to let exporters to handle the locking + themselves. After a closer investigation, I realized that my assumption + about testing of dma-buf export code path using Panfrost driver was + incorrect. Now I created additional local test to exrecise the Panfrost + export path. I also reproduced the issue reported by the Intel CI for + v10. It's all fixed now by making the drm_gem_shmem_pin() to take the + resv lock by itself. + + - Patches are based on top of drm-tip, CC'd intel-gfx CI for testing. + +v11:- Rebased on a recent linux-next. Added new patch as a result: + + drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked() + + It's needed by the virtio-gpu driver to swap-in/unevict shmem + object, previously get_pages_sgt() didn't use locking. + + - Separated the "Add memory shrinker" patch into smaller parts to ease + the reviewing, as was requested by Thomas Zimmermann: + + drm/shmem-helper: Factor out pages alloc/release from + drm_gem_shmem_get/put_pages() + drm/shmem-helper: Add pages_pin_count field + drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin + drm/shmem-helper: Factor out unpinning part from drm_gem_shmem_purge() + + - Addessed the v10 review comments from Thomas Zimmermann: return errno + instead of bool, sort code alphabetically, rename function and etc + minor changes. + + - Added new patch to remove the "map->is_iomem" from drm-shmem, as + was suggested by Thomas Zimmermann. + + - Added acks and r-b's that were given to v10. + +v10:- Was partially applied to misc-fixes/next. + + https://lore.kernel.org/dri-devel/6c16f303-81df-7ebe-85e9-51bb40a8b301@collabora.com/T/ + +Boris Brezillon (1): + drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr() + +Dmitry Osipenko (29): + drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function + names + drm/gem: Add _locked postfix to functions that have unlocked + counterpart + drm/gem: Document locking rule of vmap and evict callbacks + drm/shmem-helper: Make all exported symbols GPL + drm/shmem-helper: Refactor locked/unlocked functions + drm/shmem-helper: Remove obsoleted is_iomem test + drm/shmem-helper: Add and use pages_pin_count + drm/shmem-helper: Use refcount_t for pages_use_count + drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages() + drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin + drm/shmem-helper: Use refcount_t for vmap_use_count + drm/shmem-helper: Prepare drm_gem_shmem_free() to shrinker addition + drm/shmem-helper: Make drm_gem_shmem_get_pages() public + drm/shmem-helper: Add drm_gem_shmem_put_pages() + drm/shmem-helper: Avoid lockdep warning when pages are released + drm/lima: Explicitly get and put drm-shmem pages + drm/panfrost: Explicitly get and put drm-shmem pages + drm/virtio: Explicitly get and put drm-shmem pages + drm/v3d: Explicitly get and put drm-shmem pages + drm/shmem-helper: Change sgt allocation policy + drm/shmem-helper: Add common memory shrinker + drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked() + drm/shmem-helper: Optimize unlocked get_pages_sgt() + drm/shmem-helper: Don't free refcounted GEM + drm/shmem-helper: Turn warnings about imported GEM into errors + drm/virtio: Pin display framebuffer BO + drm/virtio: Attach shmem BOs dynamically + drm/virtio: Support shmem shrinking + drm/panfrost: Switch to generic memory shrinker + + drivers/gpu/drm/drm_client.c | 6 +- + drivers/gpu/drm/drm_gem.c | 26 +- + drivers/gpu/drm/drm_gem_framebuffer_helper.c | 6 +- + drivers/gpu/drm/drm_gem_shmem_helper.c | 663 +++++++++++++++--- + drivers/gpu/drm/drm_internal.h | 4 +- + drivers/gpu/drm/drm_prime.c | 4 +- + drivers/gpu/drm/lima/lima_gem.c | 23 +- + drivers/gpu/drm/lima/lima_sched.c | 4 +- + drivers/gpu/drm/panfrost/Makefile | 1 - + drivers/gpu/drm/panfrost/panfrost_device.h | 4 - + drivers/gpu/drm/panfrost/panfrost_drv.c | 31 +- + drivers/gpu/drm/panfrost/panfrost_dump.c | 4 +- + drivers/gpu/drm/panfrost/panfrost_gem.c | 110 ++- + drivers/gpu/drm/panfrost/panfrost_gem.h | 9 - + .../gpu/drm/panfrost/panfrost_gem_shrinker.c | 127 ---- + drivers/gpu/drm/panfrost/panfrost_job.c | 18 +- + drivers/gpu/drm/panfrost/panfrost_mmu.c | 39 +- + drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 6 +- + drivers/gpu/drm/v3d/v3d_bo.c | 11 +- + drivers/gpu/drm/virtio/virtgpu_drv.h | 22 +- + drivers/gpu/drm/virtio/virtgpu_gem.c | 85 +++ + drivers/gpu/drm/virtio/virtgpu_ioctl.c | 57 +- + drivers/gpu/drm/virtio/virtgpu_kms.c | 8 + + drivers/gpu/drm/virtio/virtgpu_object.c | 143 +++- + drivers/gpu/drm/virtio/virtgpu_plane.c | 17 +- + drivers/gpu/drm/virtio/virtgpu_submit.c | 15 +- + drivers/gpu/drm/virtio/virtgpu_vq.c | 40 ++ + include/drm/drm_device.h | 10 +- + include/drm/drm_gem.h | 15 +- + include/drm/drm_gem_shmem_helper.h | 117 +++- + include/uapi/drm/virtgpu_drm.h | 14 + + 31 files changed, 1216 insertions(+), 423 deletions(-) + delete mode 100644 drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c + +-- +2.43.0 + + +^ permalink raw reply [flat|nested] 31+ messages in thread +* [PATCH v19 01/30] drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko +@ 2024-01-05 18:45 ` Dmitry Osipenko + 2024-01-05 18:45 ` [PATCH v19 02/30] drm/gem: Add _locked postfix to functions that have unlocked counterpart Dmitry Osipenko + ` (28 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:45 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Make drm/gem API function names consistent by having locked function +use the _locked postfix in the name, while the unlocked variants don't +use the _unlocked postfix. Rename drm_gem_v/unmap() function names to +make them consistent with the rest of the API functions. + +Acked-by: Maxime Ripard +Reviewed-by: Boris Brezillon +Suggested-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_client.c | 6 +++--- + drivers/gpu/drm/drm_gem.c | 20 ++++++++++---------- + drivers/gpu/drm/drm_gem_framebuffer_helper.c | 6 +++--- + drivers/gpu/drm/drm_internal.h | 4 ++-- + drivers/gpu/drm/drm_prime.c | 4 ++-- + drivers/gpu/drm/lima/lima_sched.c | 4 ++-- + drivers/gpu/drm/panfrost/panfrost_dump.c | 4 ++-- + drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 6 +++--- + include/drm/drm_gem.h | 4 ++-- + 9 files changed, 29 insertions(+), 29 deletions(-) + +diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c +index 9403b3f576f7..7ee9baf46eaa 100644 +--- a/drivers/gpu/drm/drm_client.c ++++ b/drivers/gpu/drm/drm_client.c +@@ -255,7 +255,7 @@ void drm_client_dev_restore(struct drm_device *dev) + static void drm_client_buffer_delete(struct drm_client_buffer *buffer) + { + if (buffer->gem) { +- drm_gem_vunmap_unlocked(buffer->gem, &buffer->map); ++ drm_gem_vunmap(buffer->gem, &buffer->map); + drm_gem_object_put(buffer->gem); + } + +@@ -339,7 +339,7 @@ drm_client_buffer_vmap(struct drm_client_buffer *buffer, + * fd_install step out of the driver backend hooks, to make that + * final step optional for internal users. + */ +- ret = drm_gem_vmap_unlocked(buffer->gem, map); ++ ret = drm_gem_vmap(buffer->gem, map); + if (ret) + return ret; + +@@ -361,7 +361,7 @@ void drm_client_buffer_vunmap(struct drm_client_buffer *buffer) + { + struct iosys_map *map = &buffer->map; + +- drm_gem_vunmap_unlocked(buffer->gem, map); ++ drm_gem_vunmap(buffer->gem, map); + } + EXPORT_SYMBOL(drm_client_buffer_vunmap); + +diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c +index 44a948b80ee1..95327b003692 100644 +--- a/drivers/gpu/drm/drm_gem.c ++++ b/drivers/gpu/drm/drm_gem.c +@@ -1175,7 +1175,7 @@ void drm_gem_unpin(struct drm_gem_object *obj) + obj->funcs->unpin(obj); + } + +-int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map) ++int drm_gem_vmap_locked(struct drm_gem_object *obj, struct iosys_map *map) + { + int ret; + +@@ -1192,9 +1192,9 @@ int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map) + + return 0; + } +-EXPORT_SYMBOL(drm_gem_vmap); ++EXPORT_SYMBOL(drm_gem_vmap_locked); + +-void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map) ++void drm_gem_vunmap_locked(struct drm_gem_object *obj, struct iosys_map *map) + { + dma_resv_assert_held(obj->resv); + +@@ -1207,27 +1207,27 @@ void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map) + /* Always set the mapping to NULL. Callers may rely on this. */ + iosys_map_clear(map); + } +-EXPORT_SYMBOL(drm_gem_vunmap); ++EXPORT_SYMBOL(drm_gem_vunmap_locked); + +-int drm_gem_vmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map) ++int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map) + { + int ret; + + dma_resv_lock(obj->resv, NULL); +- ret = drm_gem_vmap(obj, map); ++ ret = drm_gem_vmap_locked(obj, map); + dma_resv_unlock(obj->resv); + + return ret; + } +-EXPORT_SYMBOL(drm_gem_vmap_unlocked); ++EXPORT_SYMBOL(drm_gem_vmap); + +-void drm_gem_vunmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map) ++void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map) + { + dma_resv_lock(obj->resv, NULL); +- drm_gem_vunmap(obj, map); ++ drm_gem_vunmap_locked(obj, map); + dma_resv_unlock(obj->resv); + } +-EXPORT_SYMBOL(drm_gem_vunmap_unlocked); ++EXPORT_SYMBOL(drm_gem_vunmap); + + /** + * drm_gem_lock_reservations - Sets up the ww context and acquires +diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c +index 3bdb6ba37ff4..3808f47310bf 100644 +--- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c ++++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c +@@ -362,7 +362,7 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct iosys_map *map, + ret = -EINVAL; + goto err_drm_gem_vunmap; + } +- ret = drm_gem_vmap_unlocked(obj, &map[i]); ++ ret = drm_gem_vmap(obj, &map[i]); + if (ret) + goto err_drm_gem_vunmap; + } +@@ -384,7 +384,7 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct iosys_map *map, + obj = drm_gem_fb_get_obj(fb, i); + if (!obj) + continue; +- drm_gem_vunmap_unlocked(obj, &map[i]); ++ drm_gem_vunmap(obj, &map[i]); + } + return ret; + } +@@ -411,7 +411,7 @@ void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct iosys_map *map) + continue; + if (iosys_map_is_null(&map[i])) + continue; +- drm_gem_vunmap_unlocked(obj, &map[i]); ++ drm_gem_vunmap(obj, &map[i]); + } + } + EXPORT_SYMBOL(drm_gem_fb_vunmap); +diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h +index 8e4faf0a28e6..227f58e5b232 100644 +--- a/drivers/gpu/drm/drm_internal.h ++++ b/drivers/gpu/drm/drm_internal.h +@@ -172,8 +172,8 @@ void drm_gem_print_info(struct drm_printer *p, unsigned int indent, + + int drm_gem_pin(struct drm_gem_object *obj); + void drm_gem_unpin(struct drm_gem_object *obj); +-int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map); +-void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map); ++int drm_gem_vmap_locked(struct drm_gem_object *obj, struct iosys_map *map); ++void drm_gem_vunmap_locked(struct drm_gem_object *obj, struct iosys_map *map); + + /* drm_debugfs.c drm_debugfs_crc.c */ + #if defined(CONFIG_DEBUG_FS) +diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c +index 834a5e28abbe..4a5935a400ec 100644 +--- a/drivers/gpu/drm/drm_prime.c ++++ b/drivers/gpu/drm/drm_prime.c +@@ -684,7 +684,7 @@ int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct iosys_map *map) + { + struct drm_gem_object *obj = dma_buf->priv; + +- return drm_gem_vmap(obj, map); ++ return drm_gem_vmap_locked(obj, map); + } + EXPORT_SYMBOL(drm_gem_dmabuf_vmap); + +@@ -700,7 +700,7 @@ void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map) + { + struct drm_gem_object *obj = dma_buf->priv; + +- drm_gem_vunmap(obj, map); ++ drm_gem_vunmap_locked(obj, map); + } + EXPORT_SYMBOL(drm_gem_dmabuf_vunmap); + +diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c +index c3bf8cda8498..3813f30480ba 100644 +--- a/drivers/gpu/drm/lima/lima_sched.c ++++ b/drivers/gpu/drm/lima/lima_sched.c +@@ -371,7 +371,7 @@ static void lima_sched_build_error_task_list(struct lima_sched_task *task) + } else { + buffer_chunk->size = lima_bo_size(bo); + +- ret = drm_gem_vmap_unlocked(&bo->base.base, &map); ++ ret = drm_gem_vmap(&bo->base.base, &map); + if (ret) { + kvfree(et); + goto out; +@@ -379,7 +379,7 @@ static void lima_sched_build_error_task_list(struct lima_sched_task *task) + + memcpy(buffer_chunk + 1, map.vaddr, buffer_chunk->size); + +- drm_gem_vunmap_unlocked(&bo->base.base, &map); ++ drm_gem_vunmap(&bo->base.base, &map); + } + + buffer_chunk = (void *)(buffer_chunk + 1) + buffer_chunk->size; +diff --git a/drivers/gpu/drm/panfrost/panfrost_dump.c b/drivers/gpu/drm/panfrost/panfrost_dump.c +index 47751302f1bc..4042afe2fbf4 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_dump.c ++++ b/drivers/gpu/drm/panfrost/panfrost_dump.c +@@ -209,7 +209,7 @@ void panfrost_core_dump(struct panfrost_job *job) + goto dump_header; + } + +- ret = drm_gem_vmap_unlocked(&bo->base.base, &map); ++ ret = drm_gem_vmap(&bo->base.base, &map); + if (ret) { + dev_err(pfdev->dev, "Panfrost Dump: couldn't map Buffer Object\n"); + iter.hdr->bomap.valid = 0; +@@ -228,7 +228,7 @@ void panfrost_core_dump(struct panfrost_job *job) + vaddr = map.vaddr; + memcpy(iter.data, vaddr, bo->base.base.size); + +- drm_gem_vunmap_unlocked(&bo->base.base, &map); ++ drm_gem_vunmap(&bo->base.base, &map); + + iter.hdr->bomap.valid = 1; + +diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c +index ba9b6e2b2636..52befead08c6 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c ++++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c +@@ -106,7 +106,7 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev, + goto err_close_bo; + } + +- ret = drm_gem_vmap_unlocked(&bo->base, &map); ++ ret = drm_gem_vmap(&bo->base, &map); + if (ret) + goto err_put_mapping; + perfcnt->buf = map.vaddr; +@@ -165,7 +165,7 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev, + return 0; + + err_vunmap: +- drm_gem_vunmap_unlocked(&bo->base, &map); ++ drm_gem_vunmap(&bo->base, &map); + err_put_mapping: + panfrost_gem_mapping_put(perfcnt->mapping); + err_close_bo: +@@ -195,7 +195,7 @@ static int panfrost_perfcnt_disable_locked(struct panfrost_device *pfdev, + GPU_PERFCNT_CFG_MODE(GPU_PERFCNT_CFG_MODE_OFF)); + + perfcnt->user = NULL; +- drm_gem_vunmap_unlocked(&perfcnt->mapping->obj->base.base, &map); ++ drm_gem_vunmap(&perfcnt->mapping->obj->base.base, &map); + perfcnt->buf = NULL; + panfrost_gem_close(&perfcnt->mapping->obj->base.base, file_priv); + panfrost_mmu_as_put(pfdev, perfcnt->mapping->mmu); +diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h +index 369505447acd..decb19ffb2c8 100644 +--- a/include/drm/drm_gem.h ++++ b/include/drm/drm_gem.h +@@ -527,8 +527,8 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj); + void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, + bool dirty, bool accessed); + +-int drm_gem_vmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map); +-void drm_gem_vunmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map); ++int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map); ++void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map); + + int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles, + int count, struct drm_gem_object ***objs_out); +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 02/30] drm/gem: Add _locked postfix to functions that have unlocked counterpart + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + 2024-01-05 18:45 ` [PATCH v19 01/30] drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names Dmitry Osipenko +@ 2024-01-05 18:45 ` Dmitry Osipenko + 2024-01-05 18:45 ` [PATCH v19 03/30] drm/gem: Document locking rule of vmap and evict callbacks Dmitry Osipenko + ` (27 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:45 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Add _locked postfix to drm_gem functions that have unlocked counterpart +functions to make GEM functions naming more consistent and intuitive in +regards to the locking requirements. + +Acked-by: Maxime Ripard +Reviewed-by: Boris Brezillon +Suggested-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem.c | 6 +++--- + include/drm/drm_gem.h | 2 +- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c +index 95327b003692..4523cd40fb2f 100644 +--- a/drivers/gpu/drm/drm_gem.c ++++ b/drivers/gpu/drm/drm_gem.c +@@ -1490,10 +1490,10 @@ drm_gem_lru_scan(struct drm_gem_lru *lru, + EXPORT_SYMBOL(drm_gem_lru_scan); + + /** +- * drm_gem_evict - helper to evict backing pages for a GEM object ++ * drm_gem_evict_locked - helper to evict backing pages for a GEM object + * @obj: obj in question + */ +-int drm_gem_evict(struct drm_gem_object *obj) ++int drm_gem_evict_locked(struct drm_gem_object *obj) + { + dma_resv_assert_held(obj->resv); + +@@ -1505,4 +1505,4 @@ int drm_gem_evict(struct drm_gem_object *obj) + + return 0; + } +-EXPORT_SYMBOL(drm_gem_evict); ++EXPORT_SYMBOL(drm_gem_evict_locked); +diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h +index decb19ffb2c8..f835fdee6a5e 100644 +--- a/include/drm/drm_gem.h ++++ b/include/drm/drm_gem.h +@@ -551,7 +551,7 @@ unsigned long drm_gem_lru_scan(struct drm_gem_lru *lru, + unsigned long *remaining, + bool (*shrink)(struct drm_gem_object *obj)); + +-int drm_gem_evict(struct drm_gem_object *obj); ++int drm_gem_evict_locked(struct drm_gem_object *obj); + + #ifdef CONFIG_LOCKDEP + /** +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 03/30] drm/gem: Document locking rule of vmap and evict callbacks + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + 2024-01-05 18:45 ` [PATCH v19 01/30] drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names Dmitry Osipenko + 2024-01-05 18:45 ` [PATCH v19 02/30] drm/gem: Add _locked postfix to functions that have unlocked counterpart Dmitry Osipenko +@ 2024-01-05 18:45 ` Dmitry Osipenko + 2024-01-05 18:45 ` [PATCH v19 04/30] drm/shmem-helper: Make all exported symbols GPL Dmitry Osipenko + ` (26 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:45 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +The vmap/vunmap/evict GEM callbacks are always invoked with a held GEM's +reservation lock. Document this locking rule for clarity. + +Signed-off-by: Dmitry Osipenko +--- + include/drm/drm_gem.h | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h +index f835fdee6a5e..021f64371056 100644 +--- a/include/drm/drm_gem.h ++++ b/include/drm/drm_gem.h +@@ -156,7 +156,8 @@ struct drm_gem_object_funcs { + * @vmap: + * + * Returns a virtual address for the buffer. Used by the +- * drm_gem_dmabuf_vmap() helper. ++ * drm_gem_dmabuf_vmap() helper. Called with a held GEM reservation ++ * lock. + * + * This callback is optional. + */ +@@ -166,7 +167,8 @@ struct drm_gem_object_funcs { + * @vunmap: + * + * Releases the address previously returned by @vmap. Used by the +- * drm_gem_dmabuf_vunmap() helper. ++ * drm_gem_dmabuf_vunmap() helper. Called with a held GEM reservation ++ * lock. + * + * This callback is optional. + */ +@@ -189,7 +191,8 @@ struct drm_gem_object_funcs { + * @evict: + * + * Evicts gem object out from memory. Used by the drm_gem_object_evict() +- * helper. Returns 0 on success, -errno otherwise. ++ * helper. Returns 0 on success, -errno otherwise. Called with a held ++ * GEM reservation lock. + * + * This callback is optional. + */ +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 04/30] drm/shmem-helper: Make all exported symbols GPL + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (2 preceding siblings ...) + 2024-01-05 18:45 ` [PATCH v19 03/30] drm/gem: Document locking rule of vmap and evict callbacks Dmitry Osipenko +@ 2024-01-05 18:45 ` Dmitry Osipenko + 2024-01-05 18:45 ` [PATCH v19 05/30] drm/shmem-helper: Refactor locked/unlocked functions Dmitry Osipenko + ` (25 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:45 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Make all drm-shmem exported symbols GPL to make them consistent with +the rest of drm-shmem symbols. + +Acked-by: Maxime Ripard +Reviewed-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index e435f986cd13..0d61f2b3e213 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -226,7 +226,7 @@ void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem) + shmem->pages_mark_accessed_on_put); + shmem->pages = NULL; + } +-EXPORT_SYMBOL(drm_gem_shmem_put_pages); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages); + + static int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem) + { +@@ -271,7 +271,7 @@ int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem) + + return ret; + } +-EXPORT_SYMBOL(drm_gem_shmem_pin); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_pin); + + /** + * drm_gem_shmem_unpin - Unpin backing pages for a shmem GEM object +@@ -290,7 +290,7 @@ void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem) + drm_gem_shmem_unpin_locked(shmem); + dma_resv_unlock(shmem->base.resv); + } +-EXPORT_SYMBOL(drm_gem_shmem_unpin); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_unpin); + + /* + * drm_gem_shmem_vmap - Create a virtual mapping for a shmem GEM object +@@ -360,7 +360,7 @@ int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, + + return ret; + } +-EXPORT_SYMBOL(drm_gem_shmem_vmap); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_vmap); + + /* + * drm_gem_shmem_vunmap - Unmap a virtual mapping for a shmem GEM object +@@ -396,7 +396,7 @@ void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, + + shmem->vaddr = NULL; + } +-EXPORT_SYMBOL(drm_gem_shmem_vunmap); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_vunmap); + + static int + drm_gem_shmem_create_with_handle(struct drm_file *file_priv, +@@ -435,7 +435,7 @@ int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv) + + return (madv >= 0); + } +-EXPORT_SYMBOL(drm_gem_shmem_madvise); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_madvise); + + void drm_gem_shmem_purge(struct drm_gem_shmem_object *shmem) + { +@@ -467,7 +467,7 @@ void drm_gem_shmem_purge(struct drm_gem_shmem_object *shmem) + + invalidate_mapping_pages(file_inode(obj->filp)->i_mapping, 0, (loff_t)-1); + } +-EXPORT_SYMBOL(drm_gem_shmem_purge); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_purge); + + /** + * drm_gem_shmem_dumb_create - Create a dumb shmem buffer object +@@ -642,7 +642,7 @@ void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem, + drm_printf_indent(p, indent, "vmap_use_count=%u\n", shmem->vmap_use_count); + drm_printf_indent(p, indent, "vaddr=%p\n", shmem->vaddr); + } +-EXPORT_SYMBOL(drm_gem_shmem_print_info); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_print_info); + + /** + * drm_gem_shmem_get_sg_table - Provide a scatter/gather table of pinned +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 05/30] drm/shmem-helper: Refactor locked/unlocked functions + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (3 preceding siblings ...) + 2024-01-05 18:45 ` [PATCH v19 04/30] drm/shmem-helper: Make all exported symbols GPL Dmitry Osipenko +@ 2024-01-05 18:45 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 06/30] drm/shmem-helper: Remove obsoleted is_iomem test Dmitry Osipenko + ` (24 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:45 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Add locked and remove unlocked postfixes from drm-shmem function names, +making names consistent with the drm/gem core code. + +Reviewed-by: Boris Brezillon +Suggested-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 60 +++++++++---------- + drivers/gpu/drm/lima/lima_gem.c | 6 +- + drivers/gpu/drm/panfrost/panfrost_drv.c | 2 +- + drivers/gpu/drm/panfrost/panfrost_gem.c | 2 +- + .../gpu/drm/panfrost/panfrost_gem_shrinker.c | 2 +- + drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 +- + include/drm/drm_gem_shmem_helper.h | 28 ++++----- + 7 files changed, 51 insertions(+), 51 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 0d61f2b3e213..043e8e3b129c 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -153,7 +153,7 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem) + kfree(shmem->sgt); + } + if (shmem->pages) +- drm_gem_shmem_put_pages(shmem); ++ drm_gem_shmem_put_pages_locked(shmem); + + drm_WARN_ON(obj->dev, shmem->pages_use_count); + +@@ -165,7 +165,7 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem) + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_free); + +-static int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem) ++static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object *shmem) + { + struct drm_gem_object *obj = &shmem->base; + struct page **pages; +@@ -199,12 +199,12 @@ static int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem) + } + + /* +- * drm_gem_shmem_put_pages - Decrease use count on the backing pages for a shmem GEM object ++ * drm_gem_shmem_put_pages_locked - Decrease use count on the backing pages for a shmem GEM object + * @shmem: shmem GEM object + * + * This function decreases the use count and puts the backing pages when use drops to zero. + */ +-void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem) ++void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem) + { + struct drm_gem_object *obj = &shmem->base; + +@@ -226,7 +226,7 @@ void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem) + shmem->pages_mark_accessed_on_put); + shmem->pages = NULL; + } +-EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages_locked); + + static int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem) + { +@@ -234,7 +234,7 @@ static int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem) + + dma_resv_assert_held(shmem->base.resv); + +- ret = drm_gem_shmem_get_pages(shmem); ++ ret = drm_gem_shmem_get_pages_locked(shmem); + + return ret; + } +@@ -243,7 +243,7 @@ static void drm_gem_shmem_unpin_locked(struct drm_gem_shmem_object *shmem) + { + dma_resv_assert_held(shmem->base.resv); + +- drm_gem_shmem_put_pages(shmem); ++ drm_gem_shmem_put_pages_locked(shmem); + } + + /** +@@ -293,7 +293,7 @@ void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem) + EXPORT_SYMBOL_GPL(drm_gem_shmem_unpin); + + /* +- * drm_gem_shmem_vmap - Create a virtual mapping for a shmem GEM object ++ * drm_gem_shmem_vmap_locked - Create a virtual mapping for a shmem GEM object + * @shmem: shmem GEM object + * @map: Returns the kernel virtual address of the SHMEM GEM object's backing + * store. +@@ -302,13 +302,13 @@ EXPORT_SYMBOL_GPL(drm_gem_shmem_unpin); + * exists for the buffer backing the shmem GEM object. It hides the differences + * between dma-buf imported and natively allocated objects. + * +- * Acquired mappings should be cleaned up by calling drm_gem_shmem_vunmap(). ++ * Acquired mappings should be cleaned up by calling drm_gem_shmem_vunmap_locked(). + * + * Returns: + * 0 on success or a negative error code on failure. + */ +-int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, +- struct iosys_map *map) ++int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, ++ struct iosys_map *map) + { + struct drm_gem_object *obj = &shmem->base; + int ret = 0; +@@ -331,7 +331,7 @@ int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, + return 0; + } + +- ret = drm_gem_shmem_get_pages(shmem); ++ ret = drm_gem_shmem_get_pages_locked(shmem); + if (ret) + goto err_zero_use; + +@@ -354,28 +354,28 @@ int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, + + err_put_pages: + if (!obj->import_attach) +- drm_gem_shmem_put_pages(shmem); ++ drm_gem_shmem_put_pages_locked(shmem); + err_zero_use: + shmem->vmap_use_count = 0; + + return ret; + } +-EXPORT_SYMBOL_GPL(drm_gem_shmem_vmap); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_vmap_locked); + + /* +- * drm_gem_shmem_vunmap - Unmap a virtual mapping for a shmem GEM object ++ * drm_gem_shmem_vunmap_locked - Unmap a virtual mapping for a shmem GEM object + * @shmem: shmem GEM object + * @map: Kernel virtual address where the SHMEM GEM object was mapped + * + * This function cleans up a kernel virtual address mapping acquired by +- * drm_gem_shmem_vmap(). The mapping is only removed when the use count drops to +- * zero. ++ * drm_gem_shmem_vmap_locked(). The mapping is only removed when the use count ++ * drops to zero. + * + * This function hides the differences between dma-buf imported and natively + * allocated objects. + */ +-void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, +- struct iosys_map *map) ++void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem, ++ struct iosys_map *map) + { + struct drm_gem_object *obj = &shmem->base; + +@@ -391,12 +391,12 @@ void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, + return; + + vunmap(shmem->vaddr); +- drm_gem_shmem_put_pages(shmem); ++ drm_gem_shmem_put_pages_locked(shmem); + } + + shmem->vaddr = NULL; + } +-EXPORT_SYMBOL_GPL(drm_gem_shmem_vunmap); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_vunmap_locked); + + static int + drm_gem_shmem_create_with_handle(struct drm_file *file_priv, +@@ -424,7 +424,7 @@ drm_gem_shmem_create_with_handle(struct drm_file *file_priv, + /* Update madvise status, returns true if not purged, else + * false or -errno. + */ +-int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv) ++int drm_gem_shmem_madvise_locked(struct drm_gem_shmem_object *shmem, int madv) + { + dma_resv_assert_held(shmem->base.resv); + +@@ -435,9 +435,9 @@ int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv) + + return (madv >= 0); + } +-EXPORT_SYMBOL_GPL(drm_gem_shmem_madvise); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_madvise_locked); + +-void drm_gem_shmem_purge(struct drm_gem_shmem_object *shmem) ++void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem) + { + struct drm_gem_object *obj = &shmem->base; + struct drm_device *dev = obj->dev; +@@ -451,7 +451,7 @@ void drm_gem_shmem_purge(struct drm_gem_shmem_object *shmem) + kfree(shmem->sgt); + shmem->sgt = NULL; + +- drm_gem_shmem_put_pages(shmem); ++ drm_gem_shmem_put_pages_locked(shmem); + + shmem->madv = -1; + +@@ -467,7 +467,7 @@ void drm_gem_shmem_purge(struct drm_gem_shmem_object *shmem) + + invalidate_mapping_pages(file_inode(obj->filp)->i_mapping, 0, (loff_t)-1); + } +-EXPORT_SYMBOL_GPL(drm_gem_shmem_purge); ++EXPORT_SYMBOL_GPL(drm_gem_shmem_purge_locked); + + /** + * drm_gem_shmem_dumb_create - Create a dumb shmem buffer object +@@ -564,7 +564,7 @@ static void drm_gem_shmem_vm_close(struct vm_area_struct *vma) + struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); + + dma_resv_lock(shmem->base.resv, NULL); +- drm_gem_shmem_put_pages(shmem); ++ drm_gem_shmem_put_pages_locked(shmem); + dma_resv_unlock(shmem->base.resv); + + drm_gem_vm_close(vma); +@@ -611,7 +611,7 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct + } + + dma_resv_lock(shmem->base.resv, NULL); +- ret = drm_gem_shmem_get_pages(shmem); ++ ret = drm_gem_shmem_get_pages_locked(shmem); + dma_resv_unlock(shmem->base.resv); + + if (ret) +@@ -679,7 +679,7 @@ static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_ + + drm_WARN_ON(obj->dev, obj->import_attach); + +- ret = drm_gem_shmem_get_pages(shmem); ++ ret = drm_gem_shmem_get_pages_locked(shmem); + if (ret) + return ERR_PTR(ret); + +@@ -701,7 +701,7 @@ static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_ + sg_free_table(sgt); + kfree(sgt); + err_put_pages: +- drm_gem_shmem_put_pages(shmem); ++ drm_gem_shmem_put_pages_locked(shmem); + return ERR_PTR(ret); + } + +diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c +index 4f9736e5f929..433bda72e59b 100644 +--- a/drivers/gpu/drm/lima/lima_gem.c ++++ b/drivers/gpu/drm/lima/lima_gem.c +@@ -180,7 +180,7 @@ static int lima_gem_pin(struct drm_gem_object *obj) + if (bo->heap_size) + return -EINVAL; + +- return drm_gem_shmem_pin(&bo->base); ++ return drm_gem_shmem_object_pin(obj); + } + + static int lima_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map) +@@ -190,7 +190,7 @@ static int lima_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map) + if (bo->heap_size) + return -EINVAL; + +- return drm_gem_shmem_vmap(&bo->base, map); ++ return drm_gem_shmem_object_vmap(obj, map); + } + + static int lima_gem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) +@@ -200,7 +200,7 @@ static int lima_gem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) + if (bo->heap_size) + return -EINVAL; + +- return drm_gem_shmem_mmap(&bo->base, vma); ++ return drm_gem_shmem_object_mmap(obj, vma); + } + + static const struct drm_gem_object_funcs lima_gem_funcs = { +diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c +index a926d71e8131..a15d62f19afb 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_drv.c ++++ b/drivers/gpu/drm/panfrost/panfrost_drv.c +@@ -438,7 +438,7 @@ static int panfrost_ioctl_madvise(struct drm_device *dev, void *data, + } + } + +- args->retained = drm_gem_shmem_madvise(&bo->base, args->madv); ++ args->retained = drm_gem_shmem_madvise_locked(&bo->base, args->madv); + + if (args->retained) { + if (args->madv == PANFROST_MADV_DONTNEED) +diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c +index d47b40b82b0b..f268bd5c2884 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_gem.c ++++ b/drivers/gpu/drm/panfrost/panfrost_gem.c +@@ -192,7 +192,7 @@ static int panfrost_gem_pin(struct drm_gem_object *obj) + if (bo->is_heap) + return -EINVAL; + +- return drm_gem_shmem_pin(&bo->base); ++ return drm_gem_shmem_object_pin(obj); + } + + static enum drm_gem_object_status panfrost_gem_status(struct drm_gem_object *obj) +diff --git a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +index 3d9f51bd48b6..02b60ea1433a 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c ++++ b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +@@ -51,7 +51,7 @@ static bool panfrost_gem_purge(struct drm_gem_object *obj) + goto unlock_mappings; + + panfrost_gem_teardown_mappings_locked(bo); +- drm_gem_shmem_purge(&bo->base); ++ drm_gem_shmem_purge_locked(&bo->base); + ret = true; + + dma_resv_unlock(shmem->base.resv); +diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c +index f38385fe76bb..1ab081bd81a8 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_mmu.c ++++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c +@@ -538,7 +538,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, + err_map: + sg_free_table(sgt); + err_pages: +- drm_gem_shmem_put_pages(&bo->base); ++ drm_gem_shmem_put_pages_locked(&bo->base); + err_unlock: + dma_resv_unlock(obj->resv); + err_bo: +diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h +index bf0c31aa8fbe..9e83212becbb 100644 +--- a/include/drm/drm_gem_shmem_helper.h ++++ b/include/drm/drm_gem_shmem_helper.h +@@ -99,16 +99,16 @@ struct drm_gem_shmem_object { + struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t size); + void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem); + +-void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem); ++void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem); + int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem); + void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem); +-int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, +- struct iosys_map *map); +-void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, +- struct iosys_map *map); ++int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, ++ struct iosys_map *map); ++void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem, ++ struct iosys_map *map); + int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct *vma); + +-int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv); ++int drm_gem_shmem_madvise_locked(struct drm_gem_shmem_object *shmem, int madv); + + static inline bool drm_gem_shmem_is_purgeable(struct drm_gem_shmem_object *shmem) + { +@@ -117,7 +117,7 @@ static inline bool drm_gem_shmem_is_purgeable(struct drm_gem_shmem_object *shmem + !shmem->base.dma_buf && !shmem->base.import_attach; + } + +-void drm_gem_shmem_purge(struct drm_gem_shmem_object *shmem); ++void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem); + + struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem); + struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem); +@@ -208,12 +208,12 @@ static inline struct sg_table *drm_gem_shmem_object_get_sg_table(struct drm_gem_ + } + + /* +- * drm_gem_shmem_object_vmap - GEM object function for drm_gem_shmem_vmap() ++ * drm_gem_shmem_object_vmap - GEM object function for drm_gem_shmem_vmap_locked() + * @obj: GEM object + * @map: Returns the kernel virtual address of the SHMEM GEM object's backing store. + * +- * This function wraps drm_gem_shmem_vmap(). Drivers that employ the shmem helpers should +- * use it as their &drm_gem_object_funcs.vmap handler. ++ * This function wraps drm_gem_shmem_vmap_locked(). Drivers that employ the shmem ++ * helpers should use it as their &drm_gem_object_funcs.vmap handler. + * + * Returns: + * 0 on success or a negative error code on failure. +@@ -223,7 +223,7 @@ static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj, + { + struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); + +- return drm_gem_shmem_vmap(shmem, map); ++ return drm_gem_shmem_vmap_locked(shmem, map); + } + + /* +@@ -231,15 +231,15 @@ static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj, + * @obj: GEM object + * @map: Kernel virtual address where the SHMEM GEM object was mapped + * +- * This function wraps drm_gem_shmem_vunmap(). Drivers that employ the shmem helpers should +- * use it as their &drm_gem_object_funcs.vunmap handler. ++ * This function wraps drm_gem_shmem_vunmap_locked(). Drivers that employ the shmem ++ * helpers should use it as their &drm_gem_object_funcs.vunmap handler. + */ + static inline void drm_gem_shmem_object_vunmap(struct drm_gem_object *obj, + struct iosys_map *map) + { + struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); + +- drm_gem_shmem_vunmap(shmem, map); ++ drm_gem_shmem_vunmap_locked(shmem, map); + } + + /** +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 06/30] drm/shmem-helper: Remove obsoleted is_iomem test + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (4 preceding siblings ...) + 2024-01-05 18:45 ` [PATCH v19 05/30] drm/shmem-helper: Refactor locked/unlocked functions Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 07/30] drm/shmem-helper: Add and use pages_pin_count Dmitry Osipenko + ` (23 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Everything that uses the mapped buffer should be agnostic to is_iomem. +The only reason for the is_iomem test is that we're setting shmem->vaddr +to the returned map->vaddr. Now that the shmem->vaddr code is gone, remove +the obsoleted is_iomem test to clean up the code. + +Acked-by: Maxime Ripard +Suggested-by: Thomas Zimmermann +Reviewed-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 043e8e3b129c..1f0a66386415 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -315,12 +315,6 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, + + if (obj->import_attach) { + ret = dma_buf_vmap(obj->import_attach->dmabuf, map); +- if (!ret) { +- if (drm_WARN_ON(obj->dev, map->is_iomem)) { +- dma_buf_vunmap(obj->import_attach->dmabuf, map); +- return -EIO; +- } +- } + } else { + pgprot_t prot = PAGE_KERNEL; + +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 07/30] drm/shmem-helper: Add and use pages_pin_count + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (5 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 06/30] drm/shmem-helper: Remove obsoleted is_iomem test Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 08/30] drm/shmem-helper: Use refcount_t for pages_use_count Dmitry Osipenko + ` (22 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Add separate pages_pin_count for tracking of whether drm-shmem pages are +moveable or not. With the addition of memory shrinker support to drm-shmem, +the pages_use_count will no longer determine whether pages are hard-pinned +in memory, but whether pages exist and are soft-pinned (and could be swapped +out). The pages_pin_count > 1 will hard-pin pages in memory. + +Acked-by: Maxime Ripard +Reviewed-by: Boris Brezillon +Suggested-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 25 +++++++++++++++++-------- + include/drm/drm_gem_shmem_helper.h | 11 +++++++++++ + 2 files changed, 28 insertions(+), 8 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 1f0a66386415..55b9dd3d4b18 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -156,6 +156,7 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem) + drm_gem_shmem_put_pages_locked(shmem); + + drm_WARN_ON(obj->dev, shmem->pages_use_count); ++ drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_pin_count)); + + dma_resv_unlock(shmem->base.resv); + } +@@ -234,18 +235,16 @@ static int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem) + + dma_resv_assert_held(shmem->base.resv); + ++ if (refcount_inc_not_zero(&shmem->pages_pin_count)) ++ return 0; ++ + ret = drm_gem_shmem_get_pages_locked(shmem); ++ if (!ret) ++ refcount_set(&shmem->pages_pin_count, 1); + + return ret; + } + +-static void drm_gem_shmem_unpin_locked(struct drm_gem_shmem_object *shmem) +-{ +- dma_resv_assert_held(shmem->base.resv); +- +- drm_gem_shmem_put_pages_locked(shmem); +-} +- + /** + * drm_gem_shmem_pin - Pin backing pages for a shmem GEM object + * @shmem: shmem GEM object +@@ -263,6 +262,9 @@ int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem) + + drm_WARN_ON(obj->dev, obj->import_attach); + ++ if (refcount_inc_not_zero(&shmem->pages_pin_count)) ++ return 0; ++ + ret = dma_resv_lock_interruptible(shmem->base.resv, NULL); + if (ret) + return ret; +@@ -286,8 +288,14 @@ void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem) + + drm_WARN_ON(obj->dev, obj->import_attach); + ++ if (refcount_dec_not_one(&shmem->pages_pin_count)) ++ return; ++ + dma_resv_lock(shmem->base.resv, NULL); +- drm_gem_shmem_unpin_locked(shmem); ++ ++ if (refcount_dec_and_test(&shmem->pages_pin_count)) ++ drm_gem_shmem_put_pages_locked(shmem); ++ + dma_resv_unlock(shmem->base.resv); + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_unpin); +@@ -632,6 +640,7 @@ void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem, + if (shmem->base.import_attach) + return; + ++ drm_printf_indent(p, indent, "pages_pin_count=%u\n", refcount_read(&shmem->pages_pin_count)); + drm_printf_indent(p, indent, "pages_use_count=%u\n", shmem->pages_use_count); + drm_printf_indent(p, indent, "vmap_use_count=%u\n", shmem->vmap_use_count); + drm_printf_indent(p, indent, "vaddr=%p\n", shmem->vaddr); +diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h +index 9e83212becbb..c708a9f45cbd 100644 +--- a/include/drm/drm_gem_shmem_helper.h ++++ b/include/drm/drm_gem_shmem_helper.h +@@ -39,6 +39,17 @@ struct drm_gem_shmem_object { + */ + unsigned int pages_use_count; + ++ /** ++ * @pages_pin_count: ++ * ++ * Reference count on the pinned pages table. ++ * ++ * Pages are hard-pinned and reside in memory if count ++ * greater than zero. Otherwise, when count is zero, the pages are ++ * allowed to be evicted and purged by memory shrinker. ++ */ ++ refcount_t pages_pin_count; ++ + /** + * @madv: State for madvise + * +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 08/30] drm/shmem-helper: Use refcount_t for pages_use_count + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (6 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 07/30] drm/shmem-helper: Add and use pages_pin_count Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 09/30] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages() Dmitry Osipenko + ` (21 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Use atomic refcount_t helper for pages_use_count to optimize pin/unpin +functions by skipping reservation locking while GEM's pin refcount > 1. + +Acked-by: Maxime Ripard +Reviewed-by: Boris Brezillon +Suggested-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 33 +++++++++++-------------- + drivers/gpu/drm/lima/lima_gem.c | 2 +- + drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 +- + include/drm/drm_gem_shmem_helper.h | 2 +- + 4 files changed, 18 insertions(+), 21 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 55b9dd3d4b18..cacf0f8c42e2 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -155,7 +155,7 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem) + if (shmem->pages) + drm_gem_shmem_put_pages_locked(shmem); + +- drm_WARN_ON(obj->dev, shmem->pages_use_count); ++ drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_use_count)); + drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_pin_count)); + + dma_resv_unlock(shmem->base.resv); +@@ -173,14 +173,13 @@ static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object *shmem) + + dma_resv_assert_held(shmem->base.resv); + +- if (shmem->pages_use_count++ > 0) ++ if (refcount_inc_not_zero(&shmem->pages_use_count)) + return 0; + + pages = drm_gem_get_pages(obj); + if (IS_ERR(pages)) { + drm_dbg_kms(obj->dev, "Failed to get pages (%ld)\n", + PTR_ERR(pages)); +- shmem->pages_use_count = 0; + return PTR_ERR(pages); + } + +@@ -196,6 +195,8 @@ static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object *shmem) + + shmem->pages = pages; + ++ refcount_set(&shmem->pages_use_count, 1); ++ + return 0; + } + +@@ -211,21 +212,17 @@ void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem) + + dma_resv_assert_held(shmem->base.resv); + +- if (drm_WARN_ON_ONCE(obj->dev, !shmem->pages_use_count)) +- return; +- +- if (--shmem->pages_use_count > 0) +- return; +- ++ if (refcount_dec_and_test(&shmem->pages_use_count)) { + #ifdef CONFIG_X86 +- if (shmem->map_wc) +- set_pages_array_wb(shmem->pages, obj->size >> PAGE_SHIFT); ++ if (shmem->map_wc) ++ set_pages_array_wb(shmem->pages, obj->size >> PAGE_SHIFT); + #endif + +- drm_gem_put_pages(obj, shmem->pages, +- shmem->pages_mark_dirty_on_put, +- shmem->pages_mark_accessed_on_put); +- shmem->pages = NULL; ++ drm_gem_put_pages(obj, shmem->pages, ++ shmem->pages_mark_dirty_on_put, ++ shmem->pages_mark_accessed_on_put); ++ shmem->pages = NULL; ++ } + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages_locked); + +@@ -552,8 +549,8 @@ static void drm_gem_shmem_vm_open(struct vm_area_struct *vma) + * mmap'd, vm_open() just grabs an additional reference for the new + * mm the vma is getting copied into (ie. on fork()). + */ +- if (!drm_WARN_ON_ONCE(obj->dev, !shmem->pages_use_count)) +- shmem->pages_use_count++; ++ drm_WARN_ON_ONCE(obj->dev, ++ !refcount_inc_not_zero(&shmem->pages_use_count)); + + dma_resv_unlock(shmem->base.resv); + +@@ -641,7 +638,7 @@ void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem, + return; + + drm_printf_indent(p, indent, "pages_pin_count=%u\n", refcount_read(&shmem->pages_pin_count)); +- drm_printf_indent(p, indent, "pages_use_count=%u\n", shmem->pages_use_count); ++ drm_printf_indent(p, indent, "pages_use_count=%u\n", refcount_read(&shmem->pages_use_count)); + drm_printf_indent(p, indent, "vmap_use_count=%u\n", shmem->vmap_use_count); + drm_printf_indent(p, indent, "vaddr=%p\n", shmem->vaddr); + } +diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c +index 433bda72e59b..2a97aa85416b 100644 +--- a/drivers/gpu/drm/lima/lima_gem.c ++++ b/drivers/gpu/drm/lima/lima_gem.c +@@ -47,7 +47,7 @@ int lima_heap_alloc(struct lima_bo *bo, struct lima_vm *vm) + } + + bo->base.pages = pages; +- bo->base.pages_use_count = 1; ++ refcount_set(&bo->base.pages_use_count, 1); + + mapping_set_unevictable(mapping); + } +diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c +index 1ab081bd81a8..bd5a0073009d 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_mmu.c ++++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c +@@ -489,7 +489,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, + goto err_unlock; + } + bo->base.pages = pages; +- bo->base.pages_use_count = 1; ++ refcount_set(&bo->base.pages_use_count, 1); + } else { + pages = bo->base.pages; + if (pages[page_offset]) { +diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h +index c708a9f45cbd..2c5dc62df20c 100644 +--- a/include/drm/drm_gem_shmem_helper.h ++++ b/include/drm/drm_gem_shmem_helper.h +@@ -37,7 +37,7 @@ struct drm_gem_shmem_object { + * Reference count on the pages table. + * The pages are put when the count reaches zero. + */ +- unsigned int pages_use_count; ++ refcount_t pages_use_count; + + /** + * @pages_pin_count: +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 09/30] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages() + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (7 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 08/30] drm/shmem-helper: Use refcount_t for pages_use_count Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 10/30] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin Dmitry Osipenko + ` (20 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Add lockless drm_gem_shmem_get_pages() helper that skips taking reservation +lock if pages_use_count is non-zero, leveraging from atomicity of the +refcount_t. Make drm_gem_shmem_mmap() to utilize the new helper. + +Acked-by: Maxime Ripard +Reviewed-by: Boris Brezillon +Suggested-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index cacf0f8c42e2..1c032513abf1 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -226,6 +226,20 @@ void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem) + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages_locked); + ++static int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem) ++{ ++ int ret; ++ ++ if (refcount_inc_not_zero(&shmem->pages_use_count)) ++ return 0; ++ ++ dma_resv_lock(shmem->base.resv, NULL); ++ ret = drm_gem_shmem_get_pages_locked(shmem); ++ dma_resv_unlock(shmem->base.resv); ++ ++ return ret; ++} ++ + static int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem) + { + int ret; +@@ -609,10 +623,7 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct + return ret; + } + +- dma_resv_lock(shmem->base.resv, NULL); +- ret = drm_gem_shmem_get_pages_locked(shmem); +- dma_resv_unlock(shmem->base.resv); +- ++ ret = drm_gem_shmem_get_pages(shmem); + if (ret) + return ret; + +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 10/30] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (8 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 09/30] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages() Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 11/30] drm/shmem-helper: Use refcount_t for vmap_use_count Dmitry Osipenko + ` (19 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +The vmapped pages shall be pinned in memory and previously get/put_pages() +were implicitly hard-pinning/unpinning the pages. This will no longer be +the case with addition of memory shrinker because pages_use_count > 0 won't +determine anymore whether pages are hard-pinned (they will be soft-pinned), +while the new pages_pin_count will do the hard-pinning. Switch the +vmap/vunmap() to use pin/unpin() functions in a preparation of addition +of the memory shrinker support to drm-shmem. + +Acked-by: Maxime Ripard +Reviewed-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 19 ++++++++++++------- + include/drm/drm_gem_shmem_helper.h | 2 +- + 2 files changed, 13 insertions(+), 8 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 1c032513abf1..9c89183f81b7 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -256,6 +256,14 @@ static int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem) + return ret; + } + ++static void drm_gem_shmem_unpin_locked(struct drm_gem_shmem_object *shmem) ++{ ++ dma_resv_assert_held(shmem->base.resv); ++ ++ if (refcount_dec_and_test(&shmem->pages_pin_count)) ++ drm_gem_shmem_put_pages_locked(shmem); ++} ++ + /** + * drm_gem_shmem_pin - Pin backing pages for a shmem GEM object + * @shmem: shmem GEM object +@@ -303,10 +311,7 @@ void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem) + return; + + dma_resv_lock(shmem->base.resv, NULL); +- +- if (refcount_dec_and_test(&shmem->pages_pin_count)) +- drm_gem_shmem_put_pages_locked(shmem); +- ++ drm_gem_shmem_unpin_locked(shmem); + dma_resv_unlock(shmem->base.resv); + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_unpin); +@@ -344,7 +349,7 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, + return 0; + } + +- ret = drm_gem_shmem_get_pages_locked(shmem); ++ ret = drm_gem_shmem_pin_locked(shmem); + if (ret) + goto err_zero_use; + +@@ -367,7 +372,7 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, + + err_put_pages: + if (!obj->import_attach) +- drm_gem_shmem_put_pages_locked(shmem); ++ drm_gem_shmem_unpin_locked(shmem); + err_zero_use: + shmem->vmap_use_count = 0; + +@@ -404,7 +409,7 @@ void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem, + return; + + vunmap(shmem->vaddr); +- drm_gem_shmem_put_pages_locked(shmem); ++ drm_gem_shmem_unpin_locked(shmem); + } + + shmem->vaddr = NULL; +diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h +index 2c5dc62df20c..80623b897803 100644 +--- a/include/drm/drm_gem_shmem_helper.h ++++ b/include/drm/drm_gem_shmem_helper.h +@@ -124,7 +124,7 @@ int drm_gem_shmem_madvise_locked(struct drm_gem_shmem_object *shmem, int madv); + static inline bool drm_gem_shmem_is_purgeable(struct drm_gem_shmem_object *shmem) + { + return (shmem->madv > 0) && +- !shmem->vmap_use_count && shmem->sgt && ++ !refcount_read(&shmem->pages_pin_count) && shmem->sgt && + !shmem->base.dma_buf && !shmem->base.import_attach; + } + +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 11/30] drm/shmem-helper: Use refcount_t for vmap_use_count + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (9 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 10/30] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 12/30] drm/shmem-helper: Prepare drm_gem_shmem_free() to shrinker addition Dmitry Osipenko + ` (18 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Use refcount_t helper for vmap_use_count to make refcounting consistent +with pages_use_count and pages_pin_count that use refcount_t. This also +makes vmapping to benefit from the refcount_t's overflow checks. + +Acked-by: Maxime Ripard +Reviewed-by: Boris Brezillon +Suggested-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 28 +++++++++++--------------- + include/drm/drm_gem_shmem_helper.h | 2 +- + 2 files changed, 13 insertions(+), 17 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 9c89183f81b7..3403700780c3 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -144,7 +144,7 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem) + } else { + dma_resv_lock(shmem->base.resv, NULL); + +- drm_WARN_ON(obj->dev, shmem->vmap_use_count); ++ drm_WARN_ON(obj->dev, refcount_read(&shmem->vmap_use_count)); + + if (shmem->sgt) { + dma_unmap_sgtable(obj->dev->dev, shmem->sgt, +@@ -344,23 +344,25 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, + + dma_resv_assert_held(shmem->base.resv); + +- if (shmem->vmap_use_count++ > 0) { ++ if (refcount_inc_not_zero(&shmem->vmap_use_count)) { + iosys_map_set_vaddr(map, shmem->vaddr); + return 0; + } + + ret = drm_gem_shmem_pin_locked(shmem); + if (ret) +- goto err_zero_use; ++ return ret; + + if (shmem->map_wc) + prot = pgprot_writecombine(prot); + shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT, + VM_MAP, prot); +- if (!shmem->vaddr) ++ if (!shmem->vaddr) { + ret = -ENOMEM; +- else ++ } else { + iosys_map_set_vaddr(map, shmem->vaddr); ++ refcount_set(&shmem->vmap_use_count, 1); ++ } + } + + if (ret) { +@@ -373,8 +375,6 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, + err_put_pages: + if (!obj->import_attach) + drm_gem_shmem_unpin_locked(shmem); +-err_zero_use: +- shmem->vmap_use_count = 0; + + return ret; + } +@@ -402,14 +402,10 @@ void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem, + } else { + dma_resv_assert_held(shmem->base.resv); + +- if (drm_WARN_ON_ONCE(obj->dev, !shmem->vmap_use_count)) +- return; +- +- if (--shmem->vmap_use_count > 0) +- return; +- +- vunmap(shmem->vaddr); +- drm_gem_shmem_unpin_locked(shmem); ++ if (refcount_dec_and_test(&shmem->vmap_use_count)) { ++ vunmap(shmem->vaddr); ++ drm_gem_shmem_unpin_locked(shmem); ++ } + } + + shmem->vaddr = NULL; +@@ -655,7 +651,7 @@ void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem, + + drm_printf_indent(p, indent, "pages_pin_count=%u\n", refcount_read(&shmem->pages_pin_count)); + drm_printf_indent(p, indent, "pages_use_count=%u\n", refcount_read(&shmem->pages_use_count)); +- drm_printf_indent(p, indent, "vmap_use_count=%u\n", shmem->vmap_use_count); ++ drm_printf_indent(p, indent, "vmap_use_count=%u\n", refcount_read(&shmem->vmap_use_count)); + drm_printf_indent(p, indent, "vaddr=%p\n", shmem->vaddr); + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_print_info); +diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h +index 80623b897803..18020f653d7e 100644 +--- a/include/drm/drm_gem_shmem_helper.h ++++ b/include/drm/drm_gem_shmem_helper.h +@@ -82,7 +82,7 @@ struct drm_gem_shmem_object { + * Reference count on the virtual address. + * The address are un-mapped when the count reaches zero. + */ +- unsigned int vmap_use_count; ++ refcount_t vmap_use_count; + + /** + * @pages_mark_dirty_on_put: +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 12/30] drm/shmem-helper: Prepare drm_gem_shmem_free() to shrinker addition + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (10 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 11/30] drm/shmem-helper: Use refcount_t for vmap_use_count Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 13/30] drm/shmem-helper: Make drm_gem_shmem_get_pages() public Dmitry Osipenko + ` (17 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Prepare drm_gem_shmem_free() to addition of memory shrinker support +to drm-shmem by adding and using variant of put_pages() that doesn't +touch reservation lock. Reservation shouldn't be touched because lockdep +will trigger a bogus warning about locking contention with fs_reclaim +code paths that can't happen during the time when GEM is freed and +lockdep doesn't know about that. + +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 40 ++++++++++++++------------ + 1 file changed, 21 insertions(+), 19 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 3403700780c3..799a3c5015ad 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -128,6 +128,22 @@ struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_create); + ++static void ++drm_gem_shmem_free_pages(struct drm_gem_shmem_object *shmem) ++{ ++ struct drm_gem_object *obj = &shmem->base; ++ ++#ifdef CONFIG_X86 ++ if (shmem->map_wc) ++ set_pages_array_wb(shmem->pages, obj->size >> PAGE_SHIFT); ++#endif ++ ++ drm_gem_put_pages(obj, shmem->pages, ++ shmem->pages_mark_dirty_on_put, ++ shmem->pages_mark_accessed_on_put); ++ shmem->pages = NULL; ++} ++ + /** + * drm_gem_shmem_free - Free resources associated with a shmem GEM object + * @shmem: shmem GEM object to free +@@ -142,8 +158,6 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem) + if (obj->import_attach) { + drm_prime_gem_destroy(obj, shmem->sgt); + } else { +- dma_resv_lock(shmem->base.resv, NULL); +- + drm_WARN_ON(obj->dev, refcount_read(&shmem->vmap_use_count)); + + if (shmem->sgt) { +@@ -152,13 +166,12 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem) + sg_free_table(shmem->sgt); + kfree(shmem->sgt); + } +- if (shmem->pages) +- drm_gem_shmem_put_pages_locked(shmem); ++ if (shmem->pages && ++ refcount_dec_and_test(&shmem->pages_use_count)) ++ drm_gem_shmem_free_pages(shmem); + + drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_use_count)); + drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_pin_count)); +- +- dma_resv_unlock(shmem->base.resv); + } + + drm_gem_object_release(obj); +@@ -208,21 +221,10 @@ static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object *shmem) + */ + void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem) + { +- struct drm_gem_object *obj = &shmem->base; +- + dma_resv_assert_held(shmem->base.resv); + +- if (refcount_dec_and_test(&shmem->pages_use_count)) { +-#ifdef CONFIG_X86 +- if (shmem->map_wc) +- set_pages_array_wb(shmem->pages, obj->size >> PAGE_SHIFT); +-#endif +- +- drm_gem_put_pages(obj, shmem->pages, +- shmem->pages_mark_dirty_on_put, +- shmem->pages_mark_accessed_on_put); +- shmem->pages = NULL; +- } ++ if (refcount_dec_and_test(&shmem->pages_use_count)) ++ drm_gem_shmem_free_pages(shmem); + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages_locked); + +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 13/30] drm/shmem-helper: Make drm_gem_shmem_get_pages() public + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (11 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 12/30] drm/shmem-helper: Prepare drm_gem_shmem_free() to shrinker addition Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 14/30] drm/shmem-helper: Add drm_gem_shmem_put_pages() Dmitry Osipenko + ` (16 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +We're going to move away from having implicit get_pages() done by +get_pages_sgt() to simplify refcnt handling. Drivers will manage +get/put_pages() by themselves. Expose the drm_gem_shmem_get_pages() +in a public drm-shmem API. + +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 10 +++++++++- + include/drm/drm_gem_shmem_helper.h | 1 + + 2 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 799a3c5015ad..dc416a4bce1b 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -228,7 +228,14 @@ void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem) + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages_locked); + +-static int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem) ++/* ++ * drm_gem_shmem_get_pages - Increase use count on the backing pages for a shmem GEM object ++ * @shmem: shmem GEM object ++ * ++ * This function Increases the use count and allocates the backing pages if ++ * use-count equals to zero. ++ */ ++int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem) + { + int ret; + +@@ -241,6 +248,7 @@ static int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem) + + return ret; + } ++EXPORT_SYMBOL_GPL(drm_gem_shmem_get_pages); + + static int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem) + { +diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h +index 18020f653d7e..6dedc0739fbc 100644 +--- a/include/drm/drm_gem_shmem_helper.h ++++ b/include/drm/drm_gem_shmem_helper.h +@@ -110,6 +110,7 @@ struct drm_gem_shmem_object { + struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t size); + void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem); + ++int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem); + void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem); + int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem); + void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem); +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 14/30] drm/shmem-helper: Add drm_gem_shmem_put_pages() + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (12 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 13/30] drm/shmem-helper: Make drm_gem_shmem_get_pages() public Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 15/30] drm/shmem-helper: Avoid lockdep warning when pages are released Dmitry Osipenko + ` (15 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +We're going to move away from having implicit get_pages() done by +get_pages_sgt() to ease simplify refcnt handling. Drivers will manage +get/put_pages() by themselves. Add drm_gem_shmem_put_pages(). + +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 20 ++++++++++++++++++++ + include/drm/drm_gem_shmem_helper.h | 1 + + 2 files changed, 21 insertions(+) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index dc416a4bce1b..f5ed64f78648 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -218,6 +218,7 @@ static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object *shmem) + * @shmem: shmem GEM object + * + * This function decreases the use count and puts the backing pages when use drops to zero. ++ * Caller must hold GEM's reservation lock. + */ + void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem) + { +@@ -228,6 +229,25 @@ void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem) + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages_locked); + ++/* ++ * drm_gem_shmem_put_pages - Decrease use count on the backing pages for a shmem GEM object ++ * @shmem: shmem GEM object ++ * ++ * This function decreases the use count and puts the backing pages when use drops to zero. ++ * It's unlocked version of drm_gem_shmem_put_pages_locked(), caller must not hold ++ * GEM's reservation lock. ++ */ ++void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem) ++{ ++ if (refcount_dec_not_one(&shmem->pages_use_count)) ++ return; ++ ++ dma_resv_lock(shmem->base.resv, NULL); ++ drm_gem_shmem_put_pages_locked(shmem); ++ dma_resv_unlock(shmem->base.resv); ++} ++EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages); ++ + /* + * drm_gem_shmem_get_pages - Increase use count on the backing pages for a shmem GEM object + * @shmem: shmem GEM object +diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h +index 6dedc0739fbc..525480488451 100644 +--- a/include/drm/drm_gem_shmem_helper.h ++++ b/include/drm/drm_gem_shmem_helper.h +@@ -111,6 +111,7 @@ struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t + void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem); + + int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem); ++void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem); + void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem); + int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem); + void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem); +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 15/30] drm/shmem-helper: Avoid lockdep warning when pages are released + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (13 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 14/30] drm/shmem-helper: Add drm_gem_shmem_put_pages() Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 16/30] drm/lima: Explicitly get and put drm-shmem pages Dmitry Osipenko + ` (14 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +All drivers will be moved to get/put pages explicitly and then the last +put_pages() will be invoked during gem_free() time by some drivers. +We can't touch reservation lock when GEM is freed because that will cause +a spurious warning from lockdep when shrinker support will be added. +Lockdep doesn't know that fs_reclaim isn't functioning for a freed object, +and thus, can't deadlock. Release pages directly without taking reservation +lock if GEM is freed and its refcount is zero. + +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index f5ed64f78648..c7357110ca76 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -242,6 +242,22 @@ void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem) + if (refcount_dec_not_one(&shmem->pages_use_count)) + return; + ++ /* ++ * Destroying the object is a special case because acquiring ++ * the obj lock can cause a locking order inversion between ++ * reservation_ww_class_mutex and fs_reclaim. ++ * ++ * This deadlock is not actually possible, because no one should ++ * be already holding the lock when GEM is released. Unfortunately ++ * lockdep is not aware of this detail. So when the refcount drops ++ * to zero, we pretend it is already locked. ++ */ ++ if (!kref_read(&shmem->base.refcount)) { ++ if (refcount_dec_and_test(&shmem->pages_use_count)) ++ drm_gem_shmem_free_pages(shmem); ++ return; ++ } ++ + dma_resv_lock(shmem->base.resv, NULL); + drm_gem_shmem_put_pages_locked(shmem); + dma_resv_unlock(shmem->base.resv); +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 16/30] drm/lima: Explicitly get and put drm-shmem pages + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (14 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 15/30] drm/shmem-helper: Avoid lockdep warning when pages are released Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 17/30] drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr() Dmitry Osipenko + ` (13 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +To simplify the drm-shmem refcnt handling, we're moving away from +the implicit get_pages() that is used by get_pages_sgt(). From now on +drivers will have to pin pages while they use sgt. Lima driver doesn't +have shrinker, hence pages are pinned and sgt is valid as long as pages' +use-count > 0. + +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/lima/lima_gem.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c +index 2a97aa85416b..9c3e34a7fbed 100644 +--- a/drivers/gpu/drm/lima/lima_gem.c ++++ b/drivers/gpu/drm/lima/lima_gem.c +@@ -115,6 +115,7 @@ int lima_gem_create_handle(struct drm_device *dev, struct drm_file *file, + return PTR_ERR(shmem); + + obj = &shmem->base; ++ bo = to_lima_bo(obj); + + /* Mali Utgard GPU can only support 32bit address space */ + mask = mapping_gfp_mask(obj->filp->f_mapping); +@@ -123,13 +124,17 @@ int lima_gem_create_handle(struct drm_device *dev, struct drm_file *file, + mapping_set_gfp_mask(obj->filp->f_mapping, mask); + + if (is_heap) { +- bo = to_lima_bo(obj); + err = lima_heap_alloc(bo, NULL); + if (err) + goto out; + } else { +- struct sg_table *sgt = drm_gem_shmem_get_pages_sgt(shmem); ++ struct sg_table *sgt; + ++ err = drm_gem_shmem_get_pages(shmem); ++ if (err) ++ goto out; ++ ++ sgt = drm_gem_shmem_get_pages_sgt(shmem); + if (IS_ERR(sgt)) { + err = PTR_ERR(sgt); + goto out; +@@ -139,6 +144,9 @@ int lima_gem_create_handle(struct drm_device *dev, struct drm_file *file, + err = drm_gem_handle_create(file, obj, handle); + + out: ++ if (err && refcount_read(&bo->base.pages_use_count)) ++ drm_gem_shmem_put_pages(shmem); ++ + /* drop reference from allocate - handle holds it now */ + drm_gem_object_put(obj); + +@@ -152,6 +160,9 @@ static void lima_gem_free_object(struct drm_gem_object *obj) + if (!list_empty(&bo->va)) + dev_err(obj->dev->dev, "lima gem free bo still has va\n"); + ++ if (refcount_read(&bo->base.pages_use_count)) ++ drm_gem_shmem_put_pages(&bo->base); ++ + drm_gem_shmem_free(&bo->base); + } + +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 17/30] drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr() + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (15 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 16/30] drm/lima: Explicitly get and put drm-shmem pages Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 18/30] drm/panfrost: Explicitly get and put drm-shmem pages Dmitry Osipenko + ` (12 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +From: Boris Brezillon + +If some the pages or sgt allocation failed, we shouldn't release the +pages ref we got earlier, otherwise we will end up with unbalanced +get/put_pages() calls. We should instead leave everything in place +and let the BO release function deal with extra cleanup when the object +is destroyed, or let the fault handler try again next time it's called. + +Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations") +Cc: +Signed-off-by: Boris Brezillon +Co-developed-by: Dmitry Osipenko +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/panfrost/panfrost_mmu.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c +index bd5a0073009d..4a0b4bf03f1a 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_mmu.c ++++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c +@@ -502,11 +502,18 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, + mapping_set_unevictable(mapping); + + for (i = page_offset; i < page_offset + NUM_FAULT_PAGES; i++) { ++ /* Can happen if the last fault only partially filled this ++ * section of the pages array before failing. In that case ++ * we skip already filled pages. ++ */ ++ if (pages[i]) ++ continue; ++ + pages[i] = shmem_read_mapping_page(mapping, i); + if (IS_ERR(pages[i])) { + ret = PTR_ERR(pages[i]); + pages[i] = NULL; +- goto err_pages; ++ goto err_unlock; + } + } + +@@ -514,7 +521,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, + ret = sg_alloc_table_from_pages(sgt, pages + page_offset, + NUM_FAULT_PAGES, 0, SZ_2M, GFP_KERNEL); + if (ret) +- goto err_pages; ++ goto err_unlock; + + ret = dma_map_sgtable(pfdev->dev, sgt, DMA_BIDIRECTIONAL, 0); + if (ret) +@@ -537,8 +544,6 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, + + err_map: + sg_free_table(sgt); +-err_pages: +- drm_gem_shmem_put_pages_locked(&bo->base); + err_unlock: + dma_resv_unlock(obj->resv); + err_bo: +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 18/30] drm/panfrost: Explicitly get and put drm-shmem pages + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (16 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 17/30] drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr() Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 19/30] drm/virtio: " Dmitry Osipenko + ` (11 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +To simplify the drm-shmem refcnt handling, we're moving away from +the implicit get_pages() that is used by get_pages_sgt(). From now on +drivers will have to pin pages while they use sgt. Panfrost's shrinker +doesn't support swapping out BOs, hence pages are pinned and sgt is valid +as long as pages' use-count > 0. + +In Panfrost, panfrost_gem_mapping, which is the object representing a +GPU mapping of a BO, owns a pages ref. This guarantees that any BO being +mapped GPU side has its pages retained till the mapping is destroyed. + +Since pages are no longer guaranteed to stay pinned for the BO lifetime, +and MADVISE(DONT_NEED) flagging remains after the GEM handle has been +destroyed, we need to add an extra 'is_purgeable' check in +panfrost_gem_purge(), to make sure we're not trying to purge a BO that +already had its pages released. + +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/panfrost/panfrost_gem.c | 63 ++++++++++++++----- + .../gpu/drm/panfrost/panfrost_gem_shrinker.c | 6 ++ + 2 files changed, 52 insertions(+), 17 deletions(-) + +diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c +index f268bd5c2884..7edfc12f7c1f 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_gem.c ++++ b/drivers/gpu/drm/panfrost/panfrost_gem.c +@@ -35,20 +35,6 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj) + */ + WARN_ON_ONCE(!list_empty(&bo->mappings.list)); + +- if (bo->sgts) { +- int i; +- int n_sgt = bo->base.base.size / SZ_2M; +- +- for (i = 0; i < n_sgt; i++) { +- if (bo->sgts[i].sgl) { +- dma_unmap_sgtable(pfdev->dev, &bo->sgts[i], +- DMA_BIDIRECTIONAL, 0); +- sg_free_table(&bo->sgts[i]); +- } +- } +- kvfree(bo->sgts); +- } +- + drm_gem_shmem_free(&bo->base); + } + +@@ -85,11 +71,40 @@ panfrost_gem_teardown_mapping(struct panfrost_gem_mapping *mapping) + + static void panfrost_gem_mapping_release(struct kref *kref) + { +- struct panfrost_gem_mapping *mapping; +- +- mapping = container_of(kref, struct panfrost_gem_mapping, refcount); ++ struct panfrost_gem_mapping *mapping = ++ container_of(kref, struct panfrost_gem_mapping, refcount); ++ struct panfrost_gem_object *bo = mapping->obj; ++ struct panfrost_device *pfdev = bo->base.base.dev->dev_private; + + panfrost_gem_teardown_mapping(mapping); ++ ++ /* On heap BOs, release the sgts created in the fault handler path. */ ++ if (bo->sgts) { ++ int i, n_sgt = bo->base.base.size / SZ_2M; ++ ++ for (i = 0; i < n_sgt; i++) { ++ if (bo->sgts[i].sgl) { ++ dma_unmap_sgtable(pfdev->dev, &bo->sgts[i], ++ DMA_BIDIRECTIONAL, 0); ++ sg_free_table(&bo->sgts[i]); ++ } ++ } ++ kvfree(bo->sgts); ++ } ++ ++ /* Pages ref is owned by the panfrost_gem_mapping object. We must ++ * release our pages ref (if any), before releasing the object ++ * ref. ++ * Non-heap BOs acquired the pages at panfrost_gem_mapping creation ++ * time, and heap BOs may have acquired pages if the fault handler ++ * was called, in which case bo->sgts should be non-NULL. ++ */ ++ if (!bo->base.base.import_attach && (!bo->is_heap || bo->sgts) && ++ bo->base.madv >= 0) { ++ drm_gem_shmem_put_pages(&bo->base); ++ bo->sgts = NULL; ++ } ++ + drm_gem_object_put(&mapping->obj->base.base); + panfrost_mmu_ctx_put(mapping->mmu); + kfree(mapping); +@@ -125,6 +140,20 @@ int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_priv) + if (!mapping) + return -ENOMEM; + ++ if (!bo->is_heap && !bo->base.base.import_attach) { ++ /* Pages ref is owned by the panfrost_gem_mapping object. ++ * For non-heap BOs, we request pages at mapping creation ++ * time, such that the panfrost_mmu_map() call, further down in ++ * this function, is guaranteed to have pages_use_count > 0 ++ * when drm_gem_shmem_get_pages_sgt() is called. ++ */ ++ ret = drm_gem_shmem_get_pages(&bo->base); ++ if (ret) { ++ kfree(mapping); ++ return ret; ++ } ++ } ++ + INIT_LIST_HEAD(&mapping->node); + kref_init(&mapping->refcount); + drm_gem_object_get(obj); +diff --git a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +index 02b60ea1433a..d4fb0854cf2f 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c ++++ b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +@@ -50,6 +50,12 @@ static bool panfrost_gem_purge(struct drm_gem_object *obj) + if (!dma_resv_trylock(shmem->base.resv)) + goto unlock_mappings; + ++ /* BO might have become unpurgeable if the last pages_use_count ref ++ * was dropped, but the BO hasn't been destroyed yet. ++ */ ++ if (!drm_gem_shmem_is_purgeable(shmem)) ++ goto unlock_mappings; ++ + panfrost_gem_teardown_mappings_locked(bo); + drm_gem_shmem_purge_locked(&bo->base); + ret = true; +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 19/30] drm/virtio: Explicitly get and put drm-shmem pages + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (17 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 18/30] drm/panfrost: Explicitly get and put drm-shmem pages Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 20/30] drm/v3d: " Dmitry Osipenko + ` (10 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +We're moving away from implicit get_pages() that is done by +get_pages_sgt() to simplify the refcnt handling. Drivers will have +to pin pages while they use sgt. VirtIO-GPU doesn't support shrinker, +hence pages are pinned and sgt is valid as long as pages' use-count > 0. + +Reviewed-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/virtio/virtgpu_object.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c +index c7e74cf13022..e58528c562ef 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_object.c ++++ b/drivers/gpu/drm/virtio/virtgpu_object.c +@@ -67,6 +67,7 @@ void virtio_gpu_cleanup_object(struct virtio_gpu_object *bo) + + virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle); + if (virtio_gpu_is_shmem(bo)) { ++ drm_gem_shmem_put_pages(&bo->base); + drm_gem_shmem_free(&bo->base); + } else if (virtio_gpu_is_vram(bo)) { + struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo); +@@ -196,9 +197,13 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, + return PTR_ERR(shmem_obj); + bo = gem_to_virtio_gpu_obj(&shmem_obj->base); + ++ ret = drm_gem_shmem_get_pages(shmem_obj); ++ if (ret) ++ goto err_free_gem; ++ + ret = virtio_gpu_resource_id_get(vgdev, &bo->hw_res_handle); + if (ret < 0) +- goto err_free_gem; ++ goto err_put_pages; + + bo->dumb = params->dumb; + +@@ -243,6 +248,8 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, + kvfree(ents); + err_put_id: + virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle); ++err_put_pages: ++ drm_gem_shmem_put_pages(shmem_obj); + err_free_gem: + drm_gem_shmem_free(shmem_obj); + return ret; +-- +2.43.0 + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 21/30] drm/shmem-helper: Change sgt allocation policy + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (19 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 20/30] drm/v3d: " Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker Dmitry Osipenko + ` (8 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +In a preparation to addition of drm-shmem memory shrinker support, change +the SGT allocation policy in this way: + +1. SGT can be allocated only if shmem pages are pinned at the +time of allocation, otherwise allocation fails. + +2. Drivers must ensure that pages are pinned during the time of SGT usage +and should get new SGT if pages were unpinned. + +This new policy is required by the shrinker because it will move pages +to/from SWAP unless pages are pinned, invalidating SGT pointer once pages +are relocated. + +Previous patches prepared drivers to the new policy. + +Reviewed-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 55 ++++++++++++++------------ + 1 file changed, 29 insertions(+), 26 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index c7357110ca76..ff5437ab2c95 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -133,6 +133,14 @@ drm_gem_shmem_free_pages(struct drm_gem_shmem_object *shmem) + { + struct drm_gem_object *obj = &shmem->base; + ++ if (shmem->sgt) { ++ dma_unmap_sgtable(obj->dev->dev, shmem->sgt, ++ DMA_BIDIRECTIONAL, 0); ++ sg_free_table(shmem->sgt); ++ kfree(shmem->sgt); ++ shmem->sgt = NULL; ++ } ++ + #ifdef CONFIG_X86 + if (shmem->map_wc) + set_pages_array_wb(shmem->pages, obj->size >> PAGE_SHIFT); +@@ -155,24 +163,12 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem) + { + struct drm_gem_object *obj = &shmem->base; + +- if (obj->import_attach) { ++ if (obj->import_attach) + drm_prime_gem_destroy(obj, shmem->sgt); +- } else { +- drm_WARN_ON(obj->dev, refcount_read(&shmem->vmap_use_count)); + +- if (shmem->sgt) { +- dma_unmap_sgtable(obj->dev->dev, shmem->sgt, +- DMA_BIDIRECTIONAL, 0); +- sg_free_table(shmem->sgt); +- kfree(shmem->sgt); +- } +- if (shmem->pages && +- refcount_dec_and_test(&shmem->pages_use_count)) +- drm_gem_shmem_free_pages(shmem); +- +- drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_use_count)); +- drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_pin_count)); +- } ++ drm_WARN_ON(obj->dev, refcount_read(&shmem->vmap_use_count)); ++ drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_use_count)); ++ drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_pin_count)); + + drm_gem_object_release(obj); + kfree(shmem); +@@ -722,6 +718,9 @@ struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem) + + drm_WARN_ON(obj->dev, obj->import_attach); + ++ if (drm_WARN_ON(obj->dev, !shmem->pages)) ++ return ERR_PTR(-ENOMEM); ++ + return drm_prime_pages_to_sg(obj->dev, shmem->pages, obj->size >> PAGE_SHIFT); + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table); +@@ -737,15 +736,10 @@ static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_ + + drm_WARN_ON(obj->dev, obj->import_attach); + +- ret = drm_gem_shmem_get_pages_locked(shmem); +- if (ret) +- return ERR_PTR(ret); +- + sgt = drm_gem_shmem_get_sg_table(shmem); +- if (IS_ERR(sgt)) { +- ret = PTR_ERR(sgt); +- goto err_put_pages; +- } ++ if (IS_ERR(sgt)) ++ return sgt; ++ + /* Map the pages for use by the h/w. */ + ret = dma_map_sgtable(obj->dev->dev, sgt, DMA_BIDIRECTIONAL, 0); + if (ret) +@@ -758,8 +752,6 @@ static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_ + err_free_sgt: + sg_free_table(sgt); + kfree(sgt); +-err_put_pages: +- drm_gem_shmem_put_pages_locked(shmem); + return ERR_PTR(ret); + } + +@@ -776,6 +768,17 @@ static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_ + * and difference between dma-buf imported and natively allocated objects. + * drm_gem_shmem_get_sg_table() should not be directly called by drivers. + * ++ * Drivers should adhere to these SGT usage rules: ++ * ++ * 1. SGT should be allocated only if shmem pages are pinned at the ++ * time of allocation, otherwise allocation will fail. ++ * ++ * 2. Drivers should ensure that pages are pinned during the time of ++ * SGT usage and should get new SGT if pages were unpinned. ++ * ++ * Drivers don't own returned SGT and must take care of the SGT pointer ++ * lifetime. SGT is valid as long as GEM pages that backing SGT are pinned. ++ * + * Returns: + * A pointer to the scatter/gather table of pinned pages or errno on failure. + */ +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (20 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 21/30] drm/shmem-helper: Change sgt allocation policy Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 23/30] drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked() Dmitry Osipenko + ` (7 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Introduce common drm-shmem shrinker for DRM drivers. + +To start using drm-shmem shrinker drivers should do the following: + +1. Implement evict() callback of GEM object where driver should check + whether object is purgeable or evictable using drm-shmem helpers and + perform the shrinking action + +2. Initialize drm-shmem internals using drmm_gem_shmem_init(drm_device), + which will register drm-shmem shrinker + +3. Implement madvise IOCTL that will use drm_gem_shmem_madvise() + +Signed-off-by: Daniel Almeida +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 365 +++++++++++++++++- + drivers/gpu/drm/panfrost/panfrost_gem.c | 3 +- + .../gpu/drm/panfrost/panfrost_gem_shrinker.c | 13 +- + include/drm/drm_device.h | 10 +- + include/drm/drm_gem_shmem_helper.h | 68 +++- + 5 files changed, 433 insertions(+), 26 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index ff5437ab2c95..59cebd1e35af 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -128,11 +129,49 @@ struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_create); + ++static bool drm_gem_shmem_is_evictable(struct drm_gem_shmem_object *shmem) ++{ ++ return (shmem->madv >= 0) && shmem->base.funcs->evict && ++ refcount_read(&shmem->pages_use_count) && ++ !refcount_read(&shmem->pages_pin_count) && ++ !shmem->base.dma_buf && !shmem->base.import_attach && ++ !shmem->evicted; ++} ++ ++static void ++drm_gem_shmem_shrinker_update_lru_locked(struct drm_gem_shmem_object *shmem) ++{ ++ struct drm_gem_object *obj = &shmem->base; ++ struct drm_gem_shmem *shmem_mm = obj->dev->shmem_mm; ++ struct drm_gem_shmem_shrinker *shmem_shrinker = &shmem_mm->shrinker; ++ ++ dma_resv_assert_held(shmem->base.resv); ++ ++ if (!shmem_shrinker || obj->import_attach) ++ return; ++ ++ if (shmem->madv < 0) ++ drm_gem_lru_remove(&shmem->base); ++ else if (drm_gem_shmem_is_evictable(shmem) || drm_gem_shmem_is_purgeable(shmem)) ++ drm_gem_lru_move_tail(&shmem_shrinker->lru_evictable, &shmem->base); ++ else if (shmem->evicted) ++ drm_gem_lru_move_tail(&shmem_shrinker->lru_evicted, &shmem->base); ++ else if (!shmem->pages) ++ drm_gem_lru_remove(&shmem->base); ++ else ++ drm_gem_lru_move_tail(&shmem_shrinker->lru_pinned, &shmem->base); ++} ++ + static void + drm_gem_shmem_free_pages(struct drm_gem_shmem_object *shmem) + { + struct drm_gem_object *obj = &shmem->base; + ++ if (!shmem->pages) { ++ drm_WARN_ON(obj->dev, !shmem->evicted && shmem->madv >= 0); ++ return; ++ } ++ + if (shmem->sgt) { + dma_unmap_sgtable(obj->dev->dev, shmem->sgt, + DMA_BIDIRECTIONAL, 0); +@@ -175,15 +214,26 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem) + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_free); + +-static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object *shmem) ++static int ++drm_gem_shmem_acquire_pages(struct drm_gem_shmem_object *shmem) + { + struct drm_gem_object *obj = &shmem->base; + struct page **pages; + ++ if (drm_WARN_ON(obj->dev, obj->import_attach)) ++ return -EINVAL; ++ + dma_resv_assert_held(shmem->base.resv); + +- if (refcount_inc_not_zero(&shmem->pages_use_count)) ++ if (shmem->madv < 0) { ++ drm_WARN_ON(obj->dev, shmem->pages); ++ return -ENOMEM; ++ } ++ ++ if (shmem->pages) { ++ drm_WARN_ON(obj->dev, !shmem->evicted); + return 0; ++ } + + pages = drm_gem_get_pages(obj); + if (IS_ERR(pages)) { +@@ -204,8 +254,29 @@ static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object *shmem) + + shmem->pages = pages; + ++ return 0; ++} ++ ++static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object *shmem) ++{ ++ int err; ++ ++ dma_resv_assert_held(shmem->base.resv); ++ ++ if (shmem->madv < 0) ++ return -ENOMEM; ++ ++ if (refcount_inc_not_zero(&shmem->pages_use_count)) ++ return 0; ++ ++ err = drm_gem_shmem_acquire_pages(shmem); ++ if (err) ++ return err; ++ + refcount_set(&shmem->pages_use_count, 1); + ++ drm_gem_shmem_shrinker_update_lru_locked(shmem); ++ + return 0; + } + +@@ -222,6 +293,8 @@ void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem) + + if (refcount_dec_and_test(&shmem->pages_use_count)) + drm_gem_shmem_free_pages(shmem); ++ ++ drm_gem_shmem_shrinker_update_lru_locked(shmem); + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages_locked); + +@@ -266,6 +339,11 @@ EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages); + * + * This function Increases the use count and allocates the backing pages if + * use-count equals to zero. ++ * ++ * Note that this function doesn't pin pages in memory. If your driver ++ * uses drm-shmem shrinker, then it's free to relocate pages to swap. ++ * Getting pages only guarantees that pages are allocated, and not that ++ * pages reside in memory. In order to pin pages use drm_gem_shmem_pin(). + */ + int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem) + { +@@ -291,6 +369,10 @@ static int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem) + if (refcount_inc_not_zero(&shmem->pages_pin_count)) + return 0; + ++ ret = drm_gem_shmem_swapin_locked(shmem); ++ if (ret) ++ return ret; ++ + ret = drm_gem_shmem_get_pages_locked(shmem); + if (!ret) + refcount_set(&shmem->pages_pin_count, 1); +@@ -489,29 +571,48 @@ int drm_gem_shmem_madvise_locked(struct drm_gem_shmem_object *shmem, int madv) + + madv = shmem->madv; + ++ drm_gem_shmem_shrinker_update_lru_locked(shmem); ++ + return (madv >= 0); + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_madvise_locked); + +-void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem) ++int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv) + { + struct drm_gem_object *obj = &shmem->base; +- struct drm_device *dev = obj->dev; ++ int ret; + +- dma_resv_assert_held(shmem->base.resv); ++ ret = dma_resv_lock_interruptible(obj->resv, NULL); ++ if (ret) ++ return ret; + +- drm_WARN_ON(obj->dev, !drm_gem_shmem_is_purgeable(shmem)); ++ ret = drm_gem_shmem_madvise_locked(shmem, madv); ++ dma_resv_unlock(obj->resv); + +- dma_unmap_sgtable(dev->dev, shmem->sgt, DMA_BIDIRECTIONAL, 0); +- sg_free_table(shmem->sgt); +- kfree(shmem->sgt); +- shmem->sgt = NULL; ++ return ret; ++} ++EXPORT_SYMBOL_GPL(drm_gem_shmem_madvise); + +- drm_gem_shmem_put_pages_locked(shmem); ++static void ++drm_gem_shmem_shrinker_put_pages_locked(struct drm_gem_shmem_object *shmem) ++{ ++ struct drm_gem_object *obj = &shmem->base; ++ struct drm_device *dev = obj->dev; + +- shmem->madv = -1; ++ dma_resv_assert_held(shmem->base.resv); + ++ if (shmem->evicted) ++ return; ++ ++ drm_gem_shmem_free_pages(shmem); + drm_vma_node_unmap(&obj->vma_node, dev->anon_inode->i_mapping); ++} ++ ++void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem) ++{ ++ struct drm_gem_object *obj = &shmem->base; ++ ++ drm_gem_shmem_shrinker_put_pages_locked(shmem); + drm_gem_free_mmap_offset(obj); + + /* Our goal here is to return as much of the memory as +@@ -522,9 +623,45 @@ void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem) + shmem_truncate_range(file_inode(obj->filp), 0, (loff_t)-1); + + invalidate_mapping_pages(file_inode(obj->filp)->i_mapping, 0, (loff_t)-1); ++ ++ shmem->madv = -1; ++ shmem->evicted = false; ++ drm_gem_shmem_shrinker_update_lru_locked(shmem); + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_purge_locked); + ++/** ++ * drm_gem_shmem_swapin_locked() - Moves shmem GEM back to memory and enables ++ * hardware access to the memory. ++ * @shmem: shmem GEM object ++ * ++ * This function moves shmem GEM back to memory if it was previously evicted ++ * by the memory shrinker. The GEM is ready to use on success. ++ * ++ * Returns: ++ * 0 on success or a negative error code on failure. ++ */ ++int drm_gem_shmem_swapin_locked(struct drm_gem_shmem_object *shmem) ++{ ++ int err; ++ ++ dma_resv_assert_held(shmem->base.resv); ++ ++ if (!shmem->evicted) ++ return 0; ++ ++ err = drm_gem_shmem_acquire_pages(shmem); ++ if (err) ++ return err; ++ ++ shmem->evicted = false; ++ ++ drm_gem_shmem_shrinker_update_lru_locked(shmem); ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(drm_gem_shmem_swapin_locked); ++ + /** + * drm_gem_shmem_dumb_create - Create a dumb shmem buffer object + * @file: DRM file structure to create the dumb buffer for +@@ -571,22 +708,32 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf) + vm_fault_t ret; + struct page *page; + pgoff_t page_offset; ++ int err; + + /* We don't use vmf->pgoff since that has the fake offset */ + page_offset = (vmf->address - vma->vm_start) >> PAGE_SHIFT; + + dma_resv_lock(shmem->base.resv, NULL); + +- if (page_offset >= num_pages || +- drm_WARN_ON_ONCE(obj->dev, !shmem->pages) || +- shmem->madv < 0) { ++ err = drm_gem_shmem_swapin_locked(shmem); ++ if (err) { ++ ret = VM_FAULT_OOM; ++ goto unlock; ++ } ++ ++ if (page_offset >= num_pages || !shmem->pages) { + ret = VM_FAULT_SIGBUS; + } else { ++ /* ++ * shmem->pages is guaranteed to be valid while reservation ++ * lock is held and drm_gem_shmem_swapin_locked() succeeds. ++ */ + page = shmem->pages[page_offset]; + + ret = vmf_insert_pfn(vma, vmf->address, page_to_pfn(page)); + } + ++unlock: + dma_resv_unlock(shmem->base.resv); + + return ret; +@@ -609,6 +756,7 @@ static void drm_gem_shmem_vm_open(struct vm_area_struct *vma) + drm_WARN_ON_ONCE(obj->dev, + !refcount_inc_not_zero(&shmem->pages_use_count)); + ++ drm_gem_shmem_shrinker_update_lru_locked(shmem); + dma_resv_unlock(shmem->base.resv); + + drm_gem_vm_open(vma); +@@ -694,7 +842,9 @@ void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem, + drm_printf_indent(p, indent, "pages_pin_count=%u\n", refcount_read(&shmem->pages_pin_count)); + drm_printf_indent(p, indent, "pages_use_count=%u\n", refcount_read(&shmem->pages_use_count)); + drm_printf_indent(p, indent, "vmap_use_count=%u\n", refcount_read(&shmem->vmap_use_count)); ++ drm_printf_indent(p, indent, "evicted=%d\n", shmem->evicted); + drm_printf_indent(p, indent, "vaddr=%p\n", shmem->vaddr); ++ drm_printf_indent(p, indent, "madv=%d\n", shmem->madv); + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_print_info); + +@@ -784,8 +934,13 @@ static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_ + */ + struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem) + { +- int ret; ++ struct drm_gem_object *obj = &shmem->base; + struct sg_table *sgt; ++ int ret; ++ ++ if (drm_WARN_ON(obj->dev, drm_gem_shmem_is_evictable(shmem)) || ++ drm_WARN_ON(obj->dev, drm_gem_shmem_is_purgeable(shmem))) ++ return ERR_PTR(-EBUSY); + + ret = dma_resv_lock_interruptible(shmem->base.resv, NULL); + if (ret) +@@ -832,6 +987,184 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device *dev, + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_sg_table); + ++static unsigned long ++drm_gem_shmem_shrinker_count_objects(struct shrinker *shrinker, ++ struct shrink_control *sc) ++{ ++ struct drm_gem_shmem_shrinker *shmem_shrinker = shrinker->private_data; ++ unsigned long count = shmem_shrinker->lru_evictable.count; ++ ++ if (count >= SHRINK_EMPTY) ++ return SHRINK_EMPTY - 1; ++ ++ return count ?: SHRINK_EMPTY; ++} ++ ++void drm_gem_shmem_evict_locked(struct drm_gem_shmem_object *shmem) ++{ ++ struct drm_gem_object *obj = &shmem->base; ++ ++ drm_WARN_ON(obj->dev, !drm_gem_shmem_is_evictable(shmem)); ++ drm_WARN_ON(obj->dev, shmem->evicted); ++ ++ drm_gem_shmem_shrinker_put_pages_locked(shmem); ++ ++ shmem->evicted = true; ++ drm_gem_shmem_shrinker_update_lru_locked(shmem); ++} ++EXPORT_SYMBOL_GPL(drm_gem_shmem_evict_locked); ++ ++static bool drm_gem_shmem_shrinker_evict_locked(struct drm_gem_object *obj) ++{ ++ struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); ++ int err; ++ ++ if (!drm_gem_shmem_is_evictable(shmem) || ++ get_nr_swap_pages() < obj->size >> PAGE_SHIFT) ++ return false; ++ ++ err = drm_gem_evict_locked(obj); ++ if (err) ++ return false; ++ ++ return true; ++} ++ ++static bool drm_gem_shmem_shrinker_purge_locked(struct drm_gem_object *obj) ++{ ++ struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); ++ int err; ++ ++ if (!drm_gem_shmem_is_purgeable(shmem)) ++ return false; ++ ++ err = drm_gem_evict_locked(obj); ++ if (err) ++ return false; ++ ++ return true; ++} ++ ++static unsigned long ++drm_gem_shmem_shrinker_scan_objects(struct shrinker *shrinker, ++ struct shrink_control *sc) ++{ ++ struct drm_gem_shmem_shrinker *shmem_shrinker = shrinker->private_data; ++ unsigned long nr_to_scan = sc->nr_to_scan; ++ unsigned long remaining = 0; ++ unsigned long freed = 0; ++ ++ /* purge as many objects as we can */ ++ freed += drm_gem_lru_scan(&shmem_shrinker->lru_evictable, ++ nr_to_scan, &remaining, ++ drm_gem_shmem_shrinker_purge_locked); ++ ++ /* evict as many objects as we can */ ++ if (freed < nr_to_scan) ++ freed += drm_gem_lru_scan(&shmem_shrinker->lru_evictable, ++ nr_to_scan - freed, &remaining, ++ drm_gem_shmem_shrinker_evict_locked); ++ ++ return (freed > 0 && remaining > 0) ? freed : SHRINK_STOP; ++} ++ ++static int drm_gem_shmem_shrinker_init(struct drm_gem_shmem *shmem_mm, ++ const char *shrinker_name) ++{ ++ struct drm_gem_shmem_shrinker *shmem_shrinker = &shmem_mm->shrinker; ++ struct shrinker *shrinker; ++ ++ shrinker = shrinker_alloc(0, shrinker_name); ++ if (!shrinker) ++ return -ENOMEM; ++ ++ shrinker->count_objects = drm_gem_shmem_shrinker_count_objects; ++ shrinker->scan_objects = drm_gem_shmem_shrinker_scan_objects; ++ shrinker->private_data = shmem_shrinker; ++ shrinker->seeks = DEFAULT_SEEKS; ++ ++ mutex_init(&shmem_shrinker->lock); ++ shmem_shrinker->shrinker = shrinker; ++ drm_gem_lru_init(&shmem_shrinker->lru_evictable, &shmem_shrinker->lock); ++ drm_gem_lru_init(&shmem_shrinker->lru_evicted, &shmem_shrinker->lock); ++ drm_gem_lru_init(&shmem_shrinker->lru_pinned, &shmem_shrinker->lock); ++ ++ shrinker_register(shrinker); ++ ++ return 0; ++} ++ ++static void drm_gem_shmem_shrinker_release(struct drm_device *dev, ++ struct drm_gem_shmem *shmem_mm) ++{ ++ struct drm_gem_shmem_shrinker *shmem_shrinker = &shmem_mm->shrinker; ++ ++ shrinker_free(shmem_shrinker->shrinker); ++ drm_WARN_ON(dev, !list_empty(&shmem_shrinker->lru_evictable.list)); ++ drm_WARN_ON(dev, !list_empty(&shmem_shrinker->lru_evicted.list)); ++ drm_WARN_ON(dev, !list_empty(&shmem_shrinker->lru_pinned.list)); ++ mutex_destroy(&shmem_shrinker->lock); ++} ++ ++static int drm_gem_shmem_init(struct drm_device *dev) ++{ ++ int err; ++ ++ if (drm_WARN_ON(dev, dev->shmem_mm)) ++ return -EBUSY; ++ ++ dev->shmem_mm = kzalloc(sizeof(*dev->shmem_mm), GFP_KERNEL); ++ if (!dev->shmem_mm) ++ return -ENOMEM; ++ ++ err = drm_gem_shmem_shrinker_init(dev->shmem_mm, dev->unique); ++ if (err) ++ goto free_gem_shmem; ++ ++ return 0; ++ ++free_gem_shmem: ++ kfree(dev->shmem_mm); ++ dev->shmem_mm = NULL; ++ ++ return err; ++} ++ ++static void drm_gem_shmem_release(struct drm_device *dev, void *ptr) ++{ ++ struct drm_gem_shmem *shmem_mm = dev->shmem_mm; ++ ++ drm_gem_shmem_shrinker_release(dev, shmem_mm); ++ dev->shmem_mm = NULL; ++ kfree(shmem_mm); ++} ++ ++/** ++ * drmm_gem_shmem_init() - Initialize drm-shmem internals ++ * @dev: DRM device ++ * ++ * Cleanup is automatically managed as part of DRM device releasing. ++ * Calling this function multiple times will result in a error. ++ * ++ * Returns: ++ * 0 on success or a negative error code on failure. ++ */ ++int drmm_gem_shmem_init(struct drm_device *dev) ++{ ++ int err; ++ ++ err = drm_gem_shmem_init(dev); ++ if (err) ++ return err; ++ ++ err = drmm_add_action_or_reset(dev, drm_gem_shmem_release, NULL); ++ if (err) ++ return err; ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(drmm_gem_shmem_init); ++ + MODULE_DESCRIPTION("DRM SHMEM memory-management helpers"); + MODULE_IMPORT_NS(DMA_BUF); + MODULE_LICENSE("GPL v2"); +diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c +index 7edfc12f7c1f..8c26b7e41b95 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_gem.c ++++ b/drivers/gpu/drm/panfrost/panfrost_gem.c +@@ -99,8 +99,7 @@ static void panfrost_gem_mapping_release(struct kref *kref) + * time, and heap BOs may have acquired pages if the fault handler + * was called, in which case bo->sgts should be non-NULL. + */ +- if (!bo->base.base.import_attach && (!bo->is_heap || bo->sgts) && +- bo->base.madv >= 0) { ++ if (!bo->base.base.import_attach && (!bo->is_heap || bo->sgts)) { + drm_gem_shmem_put_pages(&bo->base); + bo->sgts = NULL; + } +diff --git a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +index d4fb0854cf2f..7b4deba803ed 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c ++++ b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +@@ -15,6 +15,13 @@ + #include "panfrost_gem.h" + #include "panfrost_mmu.h" + ++static bool panfrost_gem_shmem_is_purgeable(struct drm_gem_shmem_object *shmem) ++{ ++ return (shmem->madv > 0) && ++ !refcount_read(&shmem->pages_pin_count) && shmem->sgt && ++ !shmem->base.dma_buf && !shmem->base.import_attach; ++} ++ + static unsigned long + panfrost_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc) + { +@@ -26,7 +33,7 @@ panfrost_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc + return 0; + + list_for_each_entry(shmem, &pfdev->shrinker_list, madv_list) { +- if (drm_gem_shmem_is_purgeable(shmem)) ++ if (panfrost_gem_shmem_is_purgeable(shmem)) + count += shmem->base.size >> PAGE_SHIFT; + } + +@@ -53,7 +60,7 @@ static bool panfrost_gem_purge(struct drm_gem_object *obj) + /* BO might have become unpurgeable if the last pages_use_count ref + * was dropped, but the BO hasn't been destroyed yet. + */ +- if (!drm_gem_shmem_is_purgeable(shmem)) ++ if (!panfrost_gem_shmem_is_purgeable(shmem)) + goto unlock_mappings; + + panfrost_gem_teardown_mappings_locked(bo); +@@ -80,7 +87,7 @@ panfrost_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc) + list_for_each_entry_safe(shmem, tmp, &pfdev->shrinker_list, madv_list) { + if (freed >= sc->nr_to_scan) + break; +- if (drm_gem_shmem_is_purgeable(shmem) && ++ if (panfrost_gem_shmem_is_purgeable(shmem) && + panfrost_gem_purge(&shmem->base)) { + freed += shmem->base.size >> PAGE_SHIFT; + list_del_init(&shmem->madv_list); +diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h +index 63767cf24371..6e729e716505 100644 +--- a/include/drm/drm_device.h ++++ b/include/drm/drm_device.h +@@ -15,6 +15,7 @@ struct drm_vblank_crtc; + struct drm_vma_offset_manager; + struct drm_vram_mm; + struct drm_fb_helper; ++struct drm_gem_shmem_shrinker; + + struct inode; + +@@ -289,8 +290,13 @@ struct drm_device { + /** @vma_offset_manager: GEM information */ + struct drm_vma_offset_manager *vma_offset_manager; + +- /** @vram_mm: VRAM MM memory manager */ +- struct drm_vram_mm *vram_mm; ++ union { ++ /** @vram_mm: VRAM MM memory manager */ ++ struct drm_vram_mm *vram_mm; ++ ++ /** @shmem_mm: SHMEM GEM memory manager */ ++ struct drm_gem_shmem *shmem_mm; ++ }; + + /** + * @switch_power_state: +diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h +index 525480488451..df97c11fc99a 100644 +--- a/include/drm/drm_gem_shmem_helper.h ++++ b/include/drm/drm_gem_shmem_helper.h +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -13,6 +14,7 @@ + #include + + struct dma_buf_attachment; ++struct drm_device; + struct drm_mode_create_dumb; + struct drm_printer; + struct sg_table; +@@ -54,8 +56,8 @@ struct drm_gem_shmem_object { + * @madv: State for madvise + * + * 0 is active/inuse. ++ * 1 is not-needed/can-be-purged + * A negative value is the object is purged. +- * Positive values are driver specific and not used by the helpers. + */ + int madv; + +@@ -102,6 +104,14 @@ struct drm_gem_shmem_object { + * @map_wc: map object write-combined (instead of using shmem defaults). + */ + bool map_wc : 1; ++ ++ /** ++ * @evicted: True if shmem pages are evicted by the memory shrinker. ++ * Used internally by memory shrinker. The evicted pages can be ++ * moved back to memory using drm_gem_shmem_swapin_locked(), unlike ++ * the purged pages (madv < 0) that are destroyed permanently. ++ */ ++ bool evicted : 1; + }; + + #define to_drm_gem_shmem_obj(obj) \ +@@ -122,14 +132,19 @@ void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem, + int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct *vma); + + int drm_gem_shmem_madvise_locked(struct drm_gem_shmem_object *shmem, int madv); ++int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv); + + static inline bool drm_gem_shmem_is_purgeable(struct drm_gem_shmem_object *shmem) + { +- return (shmem->madv > 0) && +- !refcount_read(&shmem->pages_pin_count) && shmem->sgt && ++ return (shmem->madv > 0) && shmem->base.funcs->evict && ++ refcount_read(&shmem->pages_use_count) && ++ !refcount_read(&shmem->pages_pin_count) && + !shmem->base.dma_buf && !shmem->base.import_attach; + } + ++int drm_gem_shmem_swapin_locked(struct drm_gem_shmem_object *shmem); ++ ++void drm_gem_shmem_evict_locked(struct drm_gem_shmem_object *shmem); + void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem); + + struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem); +@@ -273,6 +288,53 @@ static inline int drm_gem_shmem_object_mmap(struct drm_gem_object *obj, struct v + return drm_gem_shmem_mmap(shmem, vma); + } + ++/** ++ * drm_gem_shmem_object_madvise - unlocked GEM object function for drm_gem_shmem_madvise_locked() ++ * @obj: GEM object ++ * @madv: Madvise value ++ * ++ * This function wraps drm_gem_shmem_madvise_locked(), providing unlocked variant. ++ * ++ * Returns: ++ * 0 on success or a negative error code on failure. ++ */ ++static inline int drm_gem_shmem_object_madvise(struct drm_gem_object *obj, int madv) ++{ ++ struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); ++ ++ return drm_gem_shmem_madvise(shmem, madv); ++} ++ ++/** ++ * struct drm_gem_shmem_shrinker - Memory shrinker of GEM shmem memory manager ++ */ ++struct drm_gem_shmem_shrinker { ++ /** @lock: Protects @lru_* */ ++ struct mutex lock; ++ ++ /** @shrinker: Shrinker for purging shmem GEM objects */ ++ struct shrinker *shrinker; ++ ++ /** @lru_pinned: List of pinned shmem GEM objects */ ++ struct drm_gem_lru lru_pinned; ++ ++ /** @lru_evictable: List of shmem GEM objects to be evicted */ ++ struct drm_gem_lru lru_evictable; ++ ++ /** @lru_evicted: List of evicted shmem GEM objects */ ++ struct drm_gem_lru lru_evicted; ++}; ++ ++/** ++ * struct drm_gem_shmem - GEM shmem memory manager ++ */ ++struct drm_gem_shmem { ++ /** @shrinker: GEM shmem shrinker */ ++ struct drm_gem_shmem_shrinker shrinker; ++}; ++ ++int drmm_gem_shmem_init(struct drm_device *dev); ++ + /* + * Driver ops + */ +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 23/30] drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked() + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (21 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 24/30] drm/shmem-helper: Optimize unlocked get_pages_sgt() Dmitry Osipenko + ` (6 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Export drm_gem_shmem_get_pages_sgt_locked() that will be used by virtio-gpu +shrinker during GEM swap-in operation done under the held reservation lock. + +Reviewed-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 22 +++++++++++++++++++++- + include/drm/drm_gem_shmem_helper.h | 1 + + 2 files changed, 22 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 59cebd1e35af..8fd7851c088b 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -875,12 +875,31 @@ struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem) + } + EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table); + +-static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_object *shmem) ++/** ++ * drm_gem_shmem_get_pages_sgt_locked - Provide a scatter/gather table of pinned ++ * pages for a shmem GEM object ++ * @shmem: shmem GEM object ++ * ++ * This is a locked version of @drm_gem_shmem_get_sg_table that exports a ++ * scatter/gather table suitable for PRIME usage by calling the standard ++ * DMA mapping API. ++ * ++ * Drivers must hold GEM's reservation lock when using this function. ++ * ++ * Drivers who need to acquire an scatter/gather table for objects need to call ++ * drm_gem_shmem_get_pages_sgt() instead. ++ * ++ * Returns: ++ * A pointer to the scatter/gather table of pinned pages or error pointer on failure. ++ */ ++struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_object *shmem) + { + struct drm_gem_object *obj = &shmem->base; + int ret; + struct sg_table *sgt; + ++ dma_resv_assert_held(shmem->base.resv); ++ + if (shmem->sgt) + return shmem->sgt; + +@@ -904,6 +923,7 @@ static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_ + kfree(sgt); + return ERR_PTR(ret); + } ++EXPORT_SYMBOL_GPL(drm_gem_shmem_get_pages_sgt_locked); + + /** + * drm_gem_shmem_get_pages_sgt - Pin pages, dma map them, and return a +diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h +index df97c11fc99a..167f00f089de 100644 +--- a/include/drm/drm_gem_shmem_helper.h ++++ b/include/drm/drm_gem_shmem_helper.h +@@ -149,6 +149,7 @@ void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem); + + struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem); + struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem); ++struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_object *shmem); + + void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem, + struct drm_printer *p, unsigned int indent); +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 24/30] drm/shmem-helper: Optimize unlocked get_pages_sgt() + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (22 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 23/30] drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked() Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 25/30] drm/shmem-helper: Don't free refcounted GEM Dmitry Osipenko + ` (5 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +SGT isn't refcounted. Once SGT pointer has been obtained, it remains the +same for both locked and unlocked get_pages_sgt(). Return cached SGT +directly without taking a potentially expensive lock. + +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 8fd7851c088b..e6e6e693ab95 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -962,6 +962,18 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem) + drm_WARN_ON(obj->dev, drm_gem_shmem_is_purgeable(shmem))) + return ERR_PTR(-EBUSY); + ++ /* ++ * Drivers that use shrinker should take into account that shrinker ++ * may relocate BO, thus invalidating the returned SGT pointer. ++ * Such drivers should pin GEM while they use SGT. ++ * ++ * Drivers that don't use shrinker should take into account that ++ * SGT is released together with the GEM pages. Pages should be kept ++ * alive while SGT is used. ++ */ ++ if (shmem->sgt) ++ return shmem->sgt; ++ + ret = dma_resv_lock_interruptible(shmem->base.resv, NULL); + if (ret) + return ERR_PTR(ret); +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 25/30] drm/shmem-helper: Don't free refcounted GEM + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (23 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 24/30] drm/shmem-helper: Optimize unlocked get_pages_sgt() Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 26/30] drm/shmem-helper: Turn warnings about imported GEM into errors Dmitry Osipenko + ` (4 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Don't free shmem object if it has pages that are in use at the time of +the GEM's freeing if DRM driver doesn't manage GEM/pages lifetime properly. +This prevents memory corruption due to the use-after-free bug in exchange +to leaking GEM. + +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index e6e6e693ab95..0d95d723b90d 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -205,9 +205,15 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem) + if (obj->import_attach) + drm_prime_gem_destroy(obj, shmem->sgt); + +- drm_WARN_ON(obj->dev, refcount_read(&shmem->vmap_use_count)); +- drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_use_count)); +- drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_pin_count)); ++ /* ++ * Prevent memory corruption caused by the use-after-free bug in a ++ * case where shmem user erroneously holds reference to pages while ++ * GEM is freed by leaking the GEM. ++ */ ++ if (drm_WARN_ON(obj->dev, refcount_read(&shmem->vmap_use_count)) || ++ drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_use_count)) || ++ drm_WARN_ON(obj->dev, refcount_read(&shmem->pages_pin_count))) ++ return; + + drm_gem_object_release(obj); + kfree(shmem); +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 26/30] drm/shmem-helper: Turn warnings about imported GEM into errors + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (24 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 25/30] drm/shmem-helper: Don't free refcounted GEM Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 27/30] drm/virtio: Pin display framebuffer BO Dmitry Osipenko + ` (3 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Turn sanity warnings about DRM-SHMEM API misuse into a error conditions +for cases where imported GEM is used when it shouldn't be used. + +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 0d95d723b90d..7d2fe12bd793 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -409,7 +409,8 @@ int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem) + struct drm_gem_object *obj = &shmem->base; + int ret; + +- drm_WARN_ON(obj->dev, obj->import_attach); ++ if (drm_WARN_ON(obj->dev, obj->import_attach)) ++ return -EINVAL; + + if (refcount_inc_not_zero(&shmem->pages_pin_count)) + return 0; +@@ -872,7 +873,8 @@ struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem) + { + struct drm_gem_object *obj = &shmem->base; + +- drm_WARN_ON(obj->dev, obj->import_attach); ++ if (drm_WARN_ON(obj->dev, obj->import_attach)) ++ return ERR_PTR(-EINVAL); + + if (drm_WARN_ON(obj->dev, !shmem->pages)) + return ERR_PTR(-ENOMEM); +@@ -909,7 +911,8 @@ struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_object + if (shmem->sgt) + return shmem->sgt; + +- drm_WARN_ON(obj->dev, obj->import_attach); ++ if (drm_WARN_ON(obj->dev, obj->import_attach)) ++ return ERR_PTR(-EINVAL); + + sgt = drm_gem_shmem_get_sg_table(shmem); + if (IS_ERR(sgt)) +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 27/30] drm/virtio: Pin display framebuffer BO + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (25 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 26/30] drm/shmem-helper: Turn warnings about imported GEM into errors Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 28/30] drm/virtio: Attach shmem BOs dynamically Dmitry Osipenko + ` (2 subsequent siblings) + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Prepare to addition of memory shrinker support by pinning display +framebuffer BO pages in memory while they are in use by display on host. +Shrinker is free to relocate framebuffer BO pages if it doesn't know that +pages are in use, thus pin the pages to disallow shrinker to move them. + +Acked-by: Gerd Hoffmann +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ + drivers/gpu/drm/virtio/virtgpu_gem.c | 19 +++++++++++++++++++ + drivers/gpu/drm/virtio/virtgpu_plane.c | 17 +++++++++++++++-- + 3 files changed, 36 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h +index bb7d86a0c6a1..83d1e4622292 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_drv.h ++++ b/drivers/gpu/drm/virtio/virtgpu_drv.h +@@ -318,6 +318,8 @@ void virtio_gpu_array_put_free(struct virtio_gpu_object_array *objs); + void virtio_gpu_array_put_free_delayed(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object_array *objs); + void virtio_gpu_array_put_free_work(struct work_struct *work); ++int virtio_gpu_gem_pin(struct virtio_gpu_object *bo); ++void virtio_gpu_gem_unpin(struct virtio_gpu_object *bo); + + /* virtgpu_vq.c */ + int virtio_gpu_alloc_vbufs(struct virtio_gpu_device *vgdev); +diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c +index 7db48d17ee3a..625c05d625bf 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_gem.c ++++ b/drivers/gpu/drm/virtio/virtgpu_gem.c +@@ -294,3 +294,22 @@ void virtio_gpu_array_put_free_work(struct work_struct *work) + } + spin_unlock(&vgdev->obj_free_lock); + } ++ ++int virtio_gpu_gem_pin(struct virtio_gpu_object *bo) ++{ ++ int err; ++ ++ if (virtio_gpu_is_shmem(bo)) { ++ err = drm_gem_shmem_pin(&bo->base); ++ if (err) ++ return err; ++ } ++ ++ return 0; ++} ++ ++void virtio_gpu_gem_unpin(struct virtio_gpu_object *bo) ++{ ++ if (virtio_gpu_is_shmem(bo)) ++ drm_gem_shmem_unpin(&bo->base); ++} +diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c +index a72a2dbda031..162fb8a44d71 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_plane.c ++++ b/drivers/gpu/drm/virtio/virtgpu_plane.c +@@ -248,20 +248,28 @@ static int virtio_gpu_plane_prepare_fb(struct drm_plane *plane, + struct virtio_gpu_device *vgdev = dev->dev_private; + struct virtio_gpu_framebuffer *vgfb; + struct virtio_gpu_object *bo; ++ int err; + + if (!new_state->fb) + return 0; + + vgfb = to_virtio_gpu_framebuffer(new_state->fb); + bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]); +- if (!bo || (plane->type == DRM_PLANE_TYPE_PRIMARY && !bo->guest_blob)) ++ ++ err = virtio_gpu_gem_pin(bo); ++ if (err) ++ return err; ++ ++ if (plane->type == DRM_PLANE_TYPE_PRIMARY && !bo->guest_blob) + return 0; + + if (bo->dumb && (plane->state->fb != new_state->fb)) { + vgfb->fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context, + 0); +- if (!vgfb->fence) ++ if (!vgfb->fence) { ++ virtio_gpu_gem_unpin(bo); + return -ENOMEM; ++ } + } + + return 0; +@@ -271,15 +279,20 @@ static void virtio_gpu_plane_cleanup_fb(struct drm_plane *plane, + struct drm_plane_state *state) + { + struct virtio_gpu_framebuffer *vgfb; ++ struct virtio_gpu_object *bo; + + if (!state->fb) + return; + + vgfb = to_virtio_gpu_framebuffer(state->fb); ++ bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]); ++ + if (vgfb->fence) { + dma_fence_put(&vgfb->fence->f); + vgfb->fence = NULL; + } ++ ++ virtio_gpu_gem_unpin(bo); + } + + static void virtio_gpu_cursor_plane_update(struct drm_plane *plane, +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 28/30] drm/virtio: Attach shmem BOs dynamically + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (26 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 27/30] drm/virtio: Pin display framebuffer BO Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 29/30] drm/virtio: Support shmem shrinking Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 30/30] drm/panfrost: Switch to generic memory shrinker Dmitry Osipenko + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Prepare for addition of memory shrinker support by attaching shmem pages +to host dynamically on first use. Previously the attachment vq command +wasn't fenced and there was no vq kick made in the BO creation code path, +hence the attachment already was happening dynamically, but implicitly. +Making attachment explicitly dynamic will allow to simplify and reuse more +code when shrinker will be added. The virtio_gpu_object_shmem_init() now +works under the held reservation lock, which will be important to have for +shrinker to avoid moving pages while they are in active use by the driver. + +Acked-by: Gerd Hoffmann +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/virtio/virtgpu_drv.h | 7 +++ + drivers/gpu/drm/virtio/virtgpu_gem.c | 26 +++++++++ + drivers/gpu/drm/virtio/virtgpu_ioctl.c | 32 +++++++---- + drivers/gpu/drm/virtio/virtgpu_object.c | 73 ++++++++++++++++++++----- + drivers/gpu/drm/virtio/virtgpu_submit.c | 15 ++++- + 5 files changed, 125 insertions(+), 28 deletions(-) + +diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h +index 83d1e4622292..1837dc7ea9fb 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_drv.h ++++ b/drivers/gpu/drm/virtio/virtgpu_drv.h +@@ -92,6 +92,7 @@ struct virtio_gpu_object { + uint32_t hw_res_handle; + bool dumb; + bool created; ++ bool detached; + bool host3d_blob, guest_blob; + uint32_t blob_mem, blob_flags; + +@@ -318,6 +319,8 @@ void virtio_gpu_array_put_free(struct virtio_gpu_object_array *objs); + void virtio_gpu_array_put_free_delayed(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object_array *objs); + void virtio_gpu_array_put_free_work(struct work_struct *work); ++int virtio_gpu_array_prepare(struct virtio_gpu_device *vgdev, ++ struct virtio_gpu_object_array *objs); + int virtio_gpu_gem_pin(struct virtio_gpu_object *bo); + void virtio_gpu_gem_unpin(struct virtio_gpu_object *bo); + +@@ -458,6 +461,10 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, + + bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo); + ++int virtio_gpu_reattach_shmem_object_locked(struct virtio_gpu_object *bo); ++ ++int virtio_gpu_reattach_shmem_object(struct virtio_gpu_object *bo); ++ + int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev, + uint32_t *resid); + /* virtgpu_prime.c */ +diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c +index 625c05d625bf..97e67064c97e 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_gem.c ++++ b/drivers/gpu/drm/virtio/virtgpu_gem.c +@@ -295,6 +295,26 @@ void virtio_gpu_array_put_free_work(struct work_struct *work) + spin_unlock(&vgdev->obj_free_lock); + } + ++int virtio_gpu_array_prepare(struct virtio_gpu_device *vgdev, ++ struct virtio_gpu_object_array *objs) ++{ ++ struct virtio_gpu_object *bo; ++ int ret = 0; ++ u32 i; ++ ++ for (i = 0; i < objs->nents; i++) { ++ bo = gem_to_virtio_gpu_obj(objs->objs[i]); ++ ++ if (virtio_gpu_is_shmem(bo) && bo->detached) { ++ ret = virtio_gpu_reattach_shmem_object_locked(bo); ++ if (ret) ++ break; ++ } ++ } ++ ++ return ret; ++} ++ + int virtio_gpu_gem_pin(struct virtio_gpu_object *bo) + { + int err; +@@ -303,6 +323,12 @@ int virtio_gpu_gem_pin(struct virtio_gpu_object *bo) + err = drm_gem_shmem_pin(&bo->base); + if (err) + return err; ++ ++ err = virtio_gpu_reattach_shmem_object(bo); ++ if (err) { ++ drm_gem_shmem_unpin(&bo->base); ++ return err; ++ } + } + + return 0; +diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c +index e4f76f315550..c7da22006149 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c ++++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c +@@ -256,6 +256,10 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev, + if (ret != 0) + goto err_put_free; + ++ ret = virtio_gpu_array_prepare(vgdev, objs); ++ if (ret) ++ goto err_unlock; ++ + fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context, 0); + if (!fence) { + ret = -ENOMEM; +@@ -298,11 +302,25 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, + goto err_put_free; + } + ++ ret = virtio_gpu_array_lock_resv(objs); ++ if (ret != 0) ++ goto err_put_free; ++ ++ ret = virtio_gpu_array_prepare(vgdev, objs); ++ if (ret) ++ goto err_unlock; ++ ++ fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context, 0); ++ if (!fence) { ++ ret = -ENOMEM; ++ goto err_unlock; ++ } ++ + if (!vgdev->has_virgl_3d) { + virtio_gpu_cmd_transfer_to_host_2d + (vgdev, offset, + args->box.w, args->box.h, args->box.x, args->box.y, +- objs, NULL); ++ objs, fence); + } else { + virtio_gpu_create_context(dev, file); + +@@ -311,23 +329,13 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, + goto err_put_free; + } + +- ret = virtio_gpu_array_lock_resv(objs); +- if (ret != 0) +- goto err_put_free; +- +- ret = -ENOMEM; +- fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context, +- 0); +- if (!fence) +- goto err_unlock; +- + virtio_gpu_cmd_transfer_to_host_3d + (vgdev, + vfpriv ? vfpriv->ctx_id : 0, offset, args->level, + args->stride, args->layer_stride, &args->box, objs, + fence); +- dma_fence_put(&fence->f); + } ++ dma_fence_put(&fence->f); + virtio_gpu_notify(vgdev); + return 0; + +diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c +index e58528c562ef..de347aa3b9a8 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_object.c ++++ b/drivers/gpu/drm/virtio/virtgpu_object.c +@@ -143,7 +143,7 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev, + struct sg_table *pages; + int si; + +- pages = drm_gem_shmem_get_pages_sgt(&bo->base); ++ pages = drm_gem_shmem_get_pages_sgt_locked(&bo->base); + if (IS_ERR(pages)) + return PTR_ERR(pages); + +@@ -177,6 +177,40 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev, + return 0; + } + ++int virtio_gpu_reattach_shmem_object_locked(struct virtio_gpu_object *bo) ++{ ++ struct virtio_gpu_device *vgdev = bo->base.base.dev->dev_private; ++ struct virtio_gpu_mem_entry *ents; ++ unsigned int nents; ++ int err; ++ ++ if (!bo->detached) ++ return 0; ++ ++ err = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents); ++ if (err) ++ return err; ++ ++ virtio_gpu_object_attach(vgdev, bo, ents, nents); ++ ++ bo->detached = false; ++ ++ return 0; ++} ++ ++int virtio_gpu_reattach_shmem_object(struct virtio_gpu_object *bo) ++{ ++ int ret; ++ ++ ret = dma_resv_lock_interruptible(bo->base.base.resv, NULL); ++ if (ret) ++ return ret; ++ ret = virtio_gpu_reattach_shmem_object_locked(bo); ++ dma_resv_unlock(bo->base.base.resv); ++ ++ return ret; ++} ++ + int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object_params *params, + struct virtio_gpu_object **bo_ptr, +@@ -207,45 +241,56 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, + + bo->dumb = params->dumb; + +- ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents); +- if (ret != 0) +- goto err_put_id; ++ if (bo->blob_mem == VIRTGPU_BLOB_MEM_GUEST) ++ bo->guest_blob = true; + + if (fence) { + ret = -ENOMEM; + objs = virtio_gpu_array_alloc(1); + if (!objs) +- goto err_free_entry; ++ goto err_put_id; + virtio_gpu_array_add_obj(objs, &bo->base.base); + + ret = virtio_gpu_array_lock_resv(objs); + if (ret != 0) + goto err_put_objs; ++ } else { ++ ret = dma_resv_lock(bo->base.base.resv, NULL); ++ if (ret) ++ goto err_put_id; + } + + if (params->blob) { +- if (params->blob_mem == VIRTGPU_BLOB_MEM_GUEST) +- bo->guest_blob = true; ++ ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents); ++ if (ret) ++ goto err_unlock_objs; ++ } else { ++ bo->detached = true; ++ } + ++ if (params->blob) + virtio_gpu_cmd_resource_create_blob(vgdev, bo, params, + ents, nents); +- } else if (params->virgl) { ++ else if (params->virgl) + virtio_gpu_cmd_resource_create_3d(vgdev, bo, params, + objs, fence); +- virtio_gpu_object_attach(vgdev, bo, ents, nents); +- } else { ++ else + virtio_gpu_cmd_create_resource(vgdev, bo, params, + objs, fence); +- virtio_gpu_object_attach(vgdev, bo, ents, nents); +- } ++ ++ if (!fence) ++ dma_resv_unlock(bo->base.base.resv); + + *bo_ptr = bo; + return 0; + ++err_unlock_objs: ++ if (fence) ++ virtio_gpu_array_unlock_resv(objs); ++ else ++ dma_resv_unlock(bo->base.base.resv); + err_put_objs: + virtio_gpu_array_put_free(objs); +-err_free_entry: +- kvfree(ents); + err_put_id: + virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle); + err_put_pages: +diff --git a/drivers/gpu/drm/virtio/virtgpu_submit.c b/drivers/gpu/drm/virtio/virtgpu_submit.c +index 5c514946bbad..6e4ef2593e8f 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_submit.c ++++ b/drivers/gpu/drm/virtio/virtgpu_submit.c +@@ -464,8 +464,19 @@ static void virtio_gpu_install_out_fence_fd(struct virtio_gpu_submit *submit) + + static int virtio_gpu_lock_buflist(struct virtio_gpu_submit *submit) + { +- if (submit->buflist) +- return virtio_gpu_array_lock_resv(submit->buflist); ++ int err; ++ ++ if (submit->buflist) { ++ err = virtio_gpu_array_lock_resv(submit->buflist); ++ if (err) ++ return err; ++ ++ err = virtio_gpu_array_prepare(submit->vgdev, submit->buflist); ++ if (err) { ++ virtio_gpu_array_unlock_resv(submit->buflist); ++ return err; ++ } ++ } + + return 0; + } +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 29/30] drm/virtio: Support shmem shrinking + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (27 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 28/30] drm/virtio: Attach shmem BOs dynamically Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 2024-01-05 18:46 ` [PATCH v19 30/30] drm/panfrost: Switch to generic memory shrinker Dmitry Osipenko + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Support generic drm-shmem memory shrinker and add new madvise IOCTL to +the VirtIO-GPU driver. BO cache manager of Mesa driver will mark BOs as +"don't need" using the new IOCTL to let shrinker purge the marked BOs on +OOM, the shrinker will also evict unpurgeable shmem BOs from memory if +guest supports SWAP file or partition. + +Link: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15278 +Acked-by: Gerd Hoffmann +Signed-off-by: Daniel Almeida +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/virtio/virtgpu_drv.h | 13 +++++- + drivers/gpu/drm/virtio/virtgpu_gem.c | 48 +++++++++++++++++-- + drivers/gpu/drm/virtio/virtgpu_ioctl.c | 25 ++++++++++ + drivers/gpu/drm/virtio/virtgpu_kms.c | 8 ++++ + drivers/gpu/drm/virtio/virtgpu_object.c | 61 +++++++++++++++++++++++++ + drivers/gpu/drm/virtio/virtgpu_vq.c | 40 ++++++++++++++++ + include/uapi/drm/virtgpu_drm.h | 14 ++++++ + 7 files changed, 204 insertions(+), 5 deletions(-) + +diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h +index 1837dc7ea9fb..37188c00e161 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_drv.h ++++ b/drivers/gpu/drm/virtio/virtgpu_drv.h +@@ -283,7 +283,7 @@ struct virtio_gpu_fpriv { + }; + + /* virtgpu_ioctl.c */ +-#define DRM_VIRTIO_NUM_IOCTLS 12 ++#define DRM_VIRTIO_NUM_IOCTLS 13 + extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS]; + void virtio_gpu_create_context(struct drm_device *dev, struct drm_file *file); + +@@ -321,6 +321,8 @@ void virtio_gpu_array_put_free_delayed(struct virtio_gpu_device *vgdev, + void virtio_gpu_array_put_free_work(struct work_struct *work); + int virtio_gpu_array_prepare(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object_array *objs); ++int virtio_gpu_gem_host_mem_release(struct virtio_gpu_object *bo); ++int virtio_gpu_gem_madvise(struct virtio_gpu_object *obj, int madv); + int virtio_gpu_gem_pin(struct virtio_gpu_object *bo); + void virtio_gpu_gem_unpin(struct virtio_gpu_object *bo); + +@@ -334,6 +336,8 @@ void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev, + struct virtio_gpu_fence *fence); + void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object *bo); ++int virtio_gpu_cmd_release_resource(struct virtio_gpu_device *vgdev, ++ struct virtio_gpu_object *bo); + void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev, + uint64_t offset, + uint32_t width, uint32_t height, +@@ -354,6 +358,9 @@ void virtio_gpu_object_attach(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object *obj, + struct virtio_gpu_mem_entry *ents, + unsigned int nents); ++void virtio_gpu_object_detach(struct virtio_gpu_device *vgdev, ++ struct virtio_gpu_object *obj, ++ struct virtio_gpu_fence *fence); + void virtio_gpu_cursor_ping(struct virtio_gpu_device *vgdev, + struct virtio_gpu_output *output); + int virtio_gpu_cmd_get_display_info(struct virtio_gpu_device *vgdev); +@@ -497,4 +504,8 @@ void virtio_gpu_vram_unmap_dma_buf(struct device *dev, + int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, + struct drm_file *file); + ++/* virtgpu_gem_shrinker.c */ ++int virtio_gpu_gem_shrinker_init(struct virtio_gpu_device *vgdev); ++void virtio_gpu_gem_shrinker_fini(struct virtio_gpu_device *vgdev); ++ + #endif +diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c +index 97e67064c97e..68d27ae582ba 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_gem.c ++++ b/drivers/gpu/drm/virtio/virtgpu_gem.c +@@ -147,10 +147,20 @@ void virtio_gpu_gem_object_close(struct drm_gem_object *obj, + struct virtio_gpu_device *vgdev = obj->dev->dev_private; + struct virtio_gpu_fpriv *vfpriv = file->driver_priv; + struct virtio_gpu_object_array *objs; ++ struct virtio_gpu_object *bo; + + if (!vgdev->has_virgl_3d) + return; + ++ bo = gem_to_virtio_gpu_obj(obj); ++ ++ /* ++ * Purged BO was already detached and released, the resource ID ++ * is invalid by now. ++ */ ++ if (!virtio_gpu_gem_madvise(bo, VIRTGPU_MADV_WILLNEED)) ++ return; ++ + objs = virtio_gpu_array_alloc(1); + if (!objs) + return; +@@ -305,16 +315,46 @@ int virtio_gpu_array_prepare(struct virtio_gpu_device *vgdev, + for (i = 0; i < objs->nents; i++) { + bo = gem_to_virtio_gpu_obj(objs->objs[i]); + +- if (virtio_gpu_is_shmem(bo) && bo->detached) { +- ret = virtio_gpu_reattach_shmem_object_locked(bo); +- if (ret) +- break; ++ if (virtio_gpu_is_shmem(bo)) { ++ if (bo->base.madv) ++ return -EINVAL; ++ ++ if (bo->detached) { ++ ret = virtio_gpu_reattach_shmem_object_locked(bo); ++ if (ret) ++ break; ++ } + } + } + + return ret; + } + ++int virtio_gpu_gem_madvise(struct virtio_gpu_object *bo, int madv) ++{ ++ if (virtio_gpu_is_shmem(bo)) ++ return drm_gem_shmem_object_madvise(&bo->base.base, madv); ++ ++ return 1; ++} ++ ++int virtio_gpu_gem_host_mem_release(struct virtio_gpu_object *bo) ++{ ++ struct virtio_gpu_device *vgdev = bo->base.base.dev->dev_private; ++ int err; ++ ++ if (bo->created) { ++ err = virtio_gpu_cmd_release_resource(vgdev, bo); ++ if (err) ++ return err; ++ ++ virtio_gpu_notify(vgdev); ++ bo->created = false; ++ } ++ ++ return 0; ++} ++ + int virtio_gpu_gem_pin(struct virtio_gpu_object *bo) + { + int err; +diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c +index c7da22006149..a42799146090 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c ++++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c +@@ -701,6 +701,28 @@ static int virtio_gpu_context_init_ioctl(struct drm_device *dev, + return ret; + } + ++static int virtio_gpu_madvise_ioctl(struct drm_device *dev, ++ void *data, ++ struct drm_file *file) ++{ ++ struct drm_virtgpu_madvise *args = data; ++ struct virtio_gpu_object *bo; ++ struct drm_gem_object *obj; ++ ++ if (args->madv > VIRTGPU_MADV_DONTNEED) ++ return -EOPNOTSUPP; ++ ++ obj = drm_gem_object_lookup(file, args->bo_handle); ++ if (!obj) ++ return -ENOENT; ++ ++ bo = gem_to_virtio_gpu_obj(obj); ++ args->retained = virtio_gpu_gem_madvise(bo, args->madv); ++ drm_gem_object_put(obj); ++ ++ return 0; ++} ++ + struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS] = { + DRM_IOCTL_DEF_DRV(VIRTGPU_MAP, virtio_gpu_map_ioctl, + DRM_RENDER_ALLOW), +@@ -740,4 +762,7 @@ struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS] = { + + DRM_IOCTL_DEF_DRV(VIRTGPU_CONTEXT_INIT, virtio_gpu_context_init_ioctl, + DRM_RENDER_ALLOW), ++ ++ DRM_IOCTL_DEF_DRV(VIRTGPU_MADVISE, virtio_gpu_madvise_ioctl, ++ DRM_RENDER_ALLOW), + }; +diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c +index 5a3b5aaed1f3..43e237082cec 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_kms.c ++++ b/drivers/gpu/drm/virtio/virtgpu_kms.c +@@ -245,6 +245,12 @@ int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev) + goto err_scanouts; + } + ++ ret = drmm_gem_shmem_init(dev); ++ if (ret) { ++ DRM_ERROR("shmem init failed\n"); ++ goto err_modeset; ++ } ++ + virtio_device_ready(vgdev->vdev); + + if (num_capsets) +@@ -259,6 +265,8 @@ int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev) + } + return 0; + ++err_modeset: ++ virtio_gpu_modeset_fini(vgdev); + err_scanouts: + virtio_gpu_free_vbufs(vgdev); + err_vbufs: +diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c +index de347aa3b9a8..86888c1ae5d4 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_object.c ++++ b/drivers/gpu/drm/virtio/virtgpu_object.c +@@ -98,6 +98,60 @@ static void virtio_gpu_free_object(struct drm_gem_object *obj) + virtio_gpu_cleanup_object(bo); + } + ++static int virtio_gpu_detach_object_fenced(struct virtio_gpu_object *bo) ++{ ++ struct virtio_gpu_device *vgdev = bo->base.base.dev->dev_private; ++ struct virtio_gpu_fence *fence; ++ ++ if (bo->detached) ++ return 0; ++ ++ fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context, 0); ++ if (!fence) ++ return -ENOMEM; ++ ++ virtio_gpu_object_detach(vgdev, bo, fence); ++ virtio_gpu_notify(vgdev); ++ ++ dma_fence_wait(&fence->f, false); ++ dma_fence_put(&fence->f); ++ ++ bo->detached = true; ++ ++ return 0; ++} ++ ++static int virtio_gpu_shmem_evict(struct drm_gem_object *obj) ++{ ++ struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj); ++ int err; ++ ++ /* blob is not movable, it's impossible to detach it from host */ ++ if (bo->blob_mem) ++ return -EBUSY; ++ ++ /* ++ * At first tell host to stop using guest's memory to ensure that ++ * host won't touch the released guest's memory once it's gone. ++ */ ++ err = virtio_gpu_detach_object_fenced(bo); ++ if (err) ++ return err; ++ ++ if (drm_gem_shmem_is_purgeable(&bo->base)) { ++ err = virtio_gpu_gem_host_mem_release(bo); ++ if (err) ++ return err; ++ ++ drm_gem_shmem_purge_locked(&bo->base); ++ } else { ++ bo->base.pages_mark_dirty_on_put = 1; ++ drm_gem_shmem_evict_locked(&bo->base); ++ } ++ ++ return 0; ++} ++ + static const struct drm_gem_object_funcs virtio_gpu_shmem_funcs = { + .free = virtio_gpu_free_object, + .open = virtio_gpu_gem_object_open, +@@ -111,6 +165,7 @@ static const struct drm_gem_object_funcs virtio_gpu_shmem_funcs = { + .vunmap = drm_gem_shmem_object_vunmap, + .mmap = drm_gem_shmem_object_mmap, + .vm_ops = &drm_gem_shmem_vm_ops, ++ .evict = virtio_gpu_shmem_evict, + }; + + bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo) +@@ -187,6 +242,10 @@ int virtio_gpu_reattach_shmem_object_locked(struct virtio_gpu_object *bo) + if (!bo->detached) + return 0; + ++ err = drm_gem_shmem_swapin_locked(&bo->base); ++ if (err) ++ return err; ++ + err = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents); + if (err) + return err; +@@ -240,6 +299,8 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, + goto err_put_pages; + + bo->dumb = params->dumb; ++ bo->blob_mem = params->blob_mem; ++ bo->blob_flags = params->blob_flags; + + if (bo->blob_mem == VIRTGPU_BLOB_MEM_GUEST) + bo->guest_blob = true; +diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c +index b1a00c0c25a7..14ab470f413a 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_vq.c ++++ b/drivers/gpu/drm/virtio/virtgpu_vq.c +@@ -545,6 +545,21 @@ void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev, + virtio_gpu_cleanup_object(bo); + } + ++int virtio_gpu_cmd_release_resource(struct virtio_gpu_device *vgdev, ++ struct virtio_gpu_object *bo) ++{ ++ struct virtio_gpu_resource_unref *cmd_p; ++ struct virtio_gpu_vbuffer *vbuf; ++ ++ cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); ++ memset(cmd_p, 0, sizeof(*cmd_p)); ++ ++ cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_UNREF); ++ cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle); ++ ++ return virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); ++} ++ + void virtio_gpu_cmd_set_scanout(struct virtio_gpu_device *vgdev, + uint32_t scanout_id, uint32_t resource_id, + uint32_t width, uint32_t height, +@@ -645,6 +660,23 @@ virtio_gpu_cmd_resource_attach_backing(struct virtio_gpu_device *vgdev, + virtio_gpu_queue_fenced_ctrl_buffer(vgdev, vbuf, fence); + } + ++static void ++virtio_gpu_cmd_resource_detach_backing(struct virtio_gpu_device *vgdev, ++ u32 resource_id, ++ struct virtio_gpu_fence *fence) ++{ ++ struct virtio_gpu_resource_attach_backing *cmd_p; ++ struct virtio_gpu_vbuffer *vbuf; ++ ++ cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); ++ memset(cmd_p, 0, sizeof(*cmd_p)); ++ ++ cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING); ++ cmd_p->resource_id = cpu_to_le32(resource_id); ++ ++ virtio_gpu_queue_fenced_ctrl_buffer(vgdev, vbuf, fence); ++} ++ + static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev, + struct virtio_gpu_vbuffer *vbuf) + { +@@ -1107,6 +1139,14 @@ void virtio_gpu_object_attach(struct virtio_gpu_device *vgdev, + ents, nents, NULL); + } + ++void virtio_gpu_object_detach(struct virtio_gpu_device *vgdev, ++ struct virtio_gpu_object *obj, ++ struct virtio_gpu_fence *fence) ++{ ++ virtio_gpu_cmd_resource_detach_backing(vgdev, obj->hw_res_handle, ++ fence); ++} ++ + void virtio_gpu_cursor_ping(struct virtio_gpu_device *vgdev, + struct virtio_gpu_output *output) + { +diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h +index c2ce71987e9b..78255060bc9a 100644 +--- a/include/uapi/drm/virtgpu_drm.h ++++ b/include/uapi/drm/virtgpu_drm.h +@@ -48,6 +48,7 @@ extern "C" { + #define DRM_VIRTGPU_GET_CAPS 0x09 + #define DRM_VIRTGPU_RESOURCE_CREATE_BLOB 0x0a + #define DRM_VIRTGPU_CONTEXT_INIT 0x0b ++#define DRM_VIRTGPU_MADVISE 0x0c + + #define VIRTGPU_EXECBUF_FENCE_FD_IN 0x01 + #define VIRTGPU_EXECBUF_FENCE_FD_OUT 0x02 +@@ -213,6 +214,15 @@ struct drm_virtgpu_context_init { + __u64 ctx_set_params; + }; + ++#define VIRTGPU_MADV_WILLNEED 0 ++#define VIRTGPU_MADV_DONTNEED 1 ++struct drm_virtgpu_madvise { ++ __u32 bo_handle; ++ __u32 retained; /* out, non-zero if BO can be used */ ++ __u32 madv; ++ __u32 pad; ++}; ++ + /* + * Event code that's given when VIRTGPU_CONTEXT_PARAM_POLL_RINGS_MASK is in + * effect. The event size is sizeof(drm_event), since there is no additional +@@ -263,6 +273,10 @@ struct drm_virtgpu_context_init { + DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_CONTEXT_INIT, \ + struct drm_virtgpu_context_init) + ++#define DRM_IOCTL_VIRTGPU_MADVISE \ ++ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MADVISE, \ ++ struct drm_virtgpu_madvise) ++ + #if defined(__cplusplus) + } + #endif +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +* [PATCH v19 30/30] drm/panfrost: Switch to generic memory shrinker + 2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko + ` (28 preceding siblings ...) + 2024-01-05 18:46 ` [PATCH v19 29/30] drm/virtio: Support shmem shrinking Dmitry Osipenko +@ 2024-01-05 18:46 ` Dmitry Osipenko + 29 siblings, 0 replies; 31+ messages in thread +From: Dmitry Osipenko @ 2024-01-05 18:46 UTC (permalink / raw) + To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, + Daniel Vetter, Maarten Lankhorst, Maxime Ripard, + Thomas Zimmermann, Christian König, Qiang Yu, Steven Price, + Boris Brezillon, Emma Anholt, Melissa Wen + Cc: dri-devel, linux-kernel, kernel, virtualization + +Replace Panfrost's custom memory shrinker with a common drm-shmem +memory shrinker. + +Co-developed-by: Boris Brezillon +Signed-off-by: Boris Brezillon +Signed-off-by: Dmitry Osipenko +--- + drivers/gpu/drm/drm_gem_shmem_helper.c | 4 +- + drivers/gpu/drm/panfrost/Makefile | 1 - + drivers/gpu/drm/panfrost/panfrost_device.h | 4 - + drivers/gpu/drm/panfrost/panfrost_drv.c | 29 ++-- + drivers/gpu/drm/panfrost/panfrost_gem.c | 60 ++++---- + drivers/gpu/drm/panfrost/panfrost_gem.h | 9 -- + .../gpu/drm/panfrost/panfrost_gem_shrinker.c | 140 ------------------ + drivers/gpu/drm/panfrost/panfrost_job.c | 18 ++- + drivers/gpu/drm/panfrost/panfrost_mmu.c | 24 ++- + include/drm/drm_gem_shmem_helper.h | 7 - + 10 files changed, 83 insertions(+), 213 deletions(-) + delete mode 100644 drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c + +diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c +index 7d2fe12bd793..56e88378079b 100644 +--- a/drivers/gpu/drm/drm_gem_shmem_helper.c ++++ b/drivers/gpu/drm/drm_gem_shmem_helper.c +@@ -89,8 +89,6 @@ __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private) + if (ret) + goto err_release; + +- INIT_LIST_HEAD(&shmem->madv_list); +- + if (!private) { + /* + * Our buffers are kept pinned, so allocating them +@@ -619,6 +617,8 @@ void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem) + { + struct drm_gem_object *obj = &shmem->base; + ++ drm_WARN_ON_ONCE(obj->dev, !drm_gem_shmem_is_purgeable(shmem)); ++ + drm_gem_shmem_shrinker_put_pages_locked(shmem); + drm_gem_free_mmap_offset(obj); + +diff --git a/drivers/gpu/drm/panfrost/Makefile b/drivers/gpu/drm/panfrost/Makefile +index 2c01c1e7523e..f2cb1ab0a32d 100644 +--- a/drivers/gpu/drm/panfrost/Makefile ++++ b/drivers/gpu/drm/panfrost/Makefile +@@ -5,7 +5,6 @@ panfrost-y := \ + panfrost_device.o \ + panfrost_devfreq.o \ + panfrost_gem.o \ +- panfrost_gem_shrinker.o \ + panfrost_gpu.o \ + panfrost_job.o \ + panfrost_mmu.o \ +diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h +index 62f7e3527385..cea6df9cd650 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_device.h ++++ b/drivers/gpu/drm/panfrost/panfrost_device.h +@@ -140,10 +140,6 @@ struct panfrost_device { + atomic_t pending; + } reset; + +- struct mutex shrinker_lock; +- struct list_head shrinker_list; +- struct shrinker *shrinker; +- + struct panfrost_devfreq pfdevfreq; + + struct { +diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c +index a15d62f19afb..5c730d15a24d 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_drv.c ++++ b/drivers/gpu/drm/panfrost/panfrost_drv.c +@@ -171,7 +171,6 @@ panfrost_lookup_bos(struct drm_device *dev, + break; + } + +- atomic_inc(&bo->gpu_usecount); + job->mappings[i] = mapping; + } + +@@ -397,7 +396,6 @@ static int panfrost_ioctl_madvise(struct drm_device *dev, void *data, + { + struct panfrost_file_priv *priv = file_priv->driver_priv; + struct drm_panfrost_madvise *args = data; +- struct panfrost_device *pfdev = dev->dev_private; + struct drm_gem_object *gem_obj; + struct panfrost_gem_object *bo; + int ret = 0; +@@ -410,11 +408,15 @@ static int panfrost_ioctl_madvise(struct drm_device *dev, void *data, + + bo = to_panfrost_bo(gem_obj); + ++ if (bo->is_heap) { ++ args->retained = 1; ++ goto out_put_object; ++ } ++ + ret = dma_resv_lock_interruptible(bo->base.base.resv, NULL); + if (ret) + goto out_put_object; + +- mutex_lock(&pfdev->shrinker_lock); + mutex_lock(&bo->mappings.lock); + if (args->madv == PANFROST_MADV_DONTNEED) { + struct panfrost_gem_mapping *first; +@@ -440,17 +442,8 @@ static int panfrost_ioctl_madvise(struct drm_device *dev, void *data, + + args->retained = drm_gem_shmem_madvise_locked(&bo->base, args->madv); + +- if (args->retained) { +- if (args->madv == PANFROST_MADV_DONTNEED) +- list_move_tail(&bo->base.madv_list, +- &pfdev->shrinker_list); +- else if (args->madv == PANFROST_MADV_WILLNEED) +- list_del_init(&bo->base.madv_list); +- } +- + out_unlock_mappings: + mutex_unlock(&bo->mappings.lock); +- mutex_unlock(&pfdev->shrinker_lock); + dma_resv_unlock(bo->base.base.resv); + out_put_object: + drm_gem_object_put(gem_obj); +@@ -635,9 +628,6 @@ static int panfrost_probe(struct platform_device *pdev) + ddev->dev_private = pfdev; + pfdev->ddev = ddev; + +- mutex_init(&pfdev->shrinker_lock); +- INIT_LIST_HEAD(&pfdev->shrinker_list); +- + err = panfrost_device_init(pfdev); + if (err) { + if (err != -EPROBE_DEFER) +@@ -659,13 +649,13 @@ static int panfrost_probe(struct platform_device *pdev) + if (err < 0) + goto err_out1; + +- err = panfrost_gem_shrinker_init(ddev); +- if (err) +- goto err_out2; ++ err = drmm_gem_shmem_init(ddev); ++ if (err < 0) ++ goto err_unregister_dev; + + return 0; + +-err_out2: ++err_unregister_dev: + drm_dev_unregister(ddev); + err_out1: + pm_runtime_disable(pfdev->dev); +@@ -682,7 +672,6 @@ static void panfrost_remove(struct platform_device *pdev) + struct drm_device *ddev = pfdev->ddev; + + drm_dev_unregister(ddev); +- panfrost_gem_shrinker_cleanup(ddev); + + pm_runtime_get_sync(pfdev->dev); + pm_runtime_disable(pfdev->dev); +diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c +index 8c26b7e41b95..05eb5a89c4ed 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_gem.c ++++ b/drivers/gpu/drm/panfrost/panfrost_gem.c +@@ -17,17 +17,6 @@ + static void panfrost_gem_free_object(struct drm_gem_object *obj) + { + struct panfrost_gem_object *bo = to_panfrost_bo(obj); +- struct panfrost_device *pfdev = obj->dev->dev_private; +- +- /* +- * Make sure the BO is no longer inserted in the shrinker list before +- * taking care of the destruction itself. If we don't do that we have a +- * race condition between this function and what's done in +- * panfrost_gem_shrinker_scan(). +- */ +- mutex_lock(&pfdev->shrinker_lock); +- list_del_init(&bo->base.madv_list); +- mutex_unlock(&pfdev->shrinker_lock); + + /* + * If we still have mappings attached to the BO, there's a problem in +@@ -57,26 +46,23 @@ panfrost_gem_mapping_get(struct panfrost_gem_object *bo, + return mapping; + } + +-static void +-panfrost_gem_teardown_mapping(struct panfrost_gem_mapping *mapping) ++static void panfrost_gem_mapping_release(struct kref *kref) + { ++ struct panfrost_gem_mapping *mapping = ++ container_of(kref, struct panfrost_gem_mapping, refcount); ++ struct panfrost_gem_object *bo = mapping->obj; ++ struct panfrost_device *pfdev = bo->base.base.dev->dev_private; ++ ++ /* Shrinker may purge the mapping at the same time. */ ++ dma_resv_lock(mapping->obj->base.base.resv, NULL); + if (mapping->active) + panfrost_mmu_unmap(mapping); ++ dma_resv_unlock(mapping->obj->base.base.resv); + + spin_lock(&mapping->mmu->mm_lock); + if (drm_mm_node_allocated(&mapping->mmnode)) + drm_mm_remove_node(&mapping->mmnode); + spin_unlock(&mapping->mmu->mm_lock); +-} +- +-static void panfrost_gem_mapping_release(struct kref *kref) +-{ +- struct panfrost_gem_mapping *mapping = +- container_of(kref, struct panfrost_gem_mapping, refcount); +- struct panfrost_gem_object *bo = mapping->obj; +- struct panfrost_device *pfdev = bo->base.base.dev->dev_private; +- +- panfrost_gem_teardown_mapping(mapping); + + /* On heap BOs, release the sgts created in the fault handler path. */ + if (bo->sgts) { +@@ -117,12 +103,14 @@ void panfrost_gem_mapping_put(struct panfrost_gem_mapping *mapping) + kref_put(&mapping->refcount, panfrost_gem_mapping_release); + } + +-void panfrost_gem_teardown_mappings_locked(struct panfrost_gem_object *bo) ++void panfrost_gem_evict_mappings_locked(struct panfrost_gem_object *bo) + { + struct panfrost_gem_mapping *mapping; + +- list_for_each_entry(mapping, &bo->mappings.list, node) +- panfrost_gem_teardown_mapping(mapping); ++ list_for_each_entry(mapping, &bo->mappings.list, node) { ++ if (mapping->active) ++ panfrost_mmu_unmap(mapping); ++ } + } + + int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_priv) +@@ -251,6 +239,25 @@ static size_t panfrost_gem_rss(struct drm_gem_object *obj) + return 0; + } + ++static int panfrost_shmem_evict(struct drm_gem_object *obj) ++{ ++ struct panfrost_gem_object *bo = to_panfrost_bo(obj); ++ ++ if (!drm_gem_shmem_is_purgeable(&bo->base)) ++ return -EBUSY; ++ ++ if (!mutex_trylock(&bo->mappings.lock)) ++ return -EBUSY; ++ ++ panfrost_gem_evict_mappings_locked(bo); ++ ++ drm_gem_shmem_purge_locked(&bo->base); ++ ++ mutex_unlock(&bo->mappings.lock); ++ ++ return 0; ++} ++ + static const struct drm_gem_object_funcs panfrost_gem_funcs = { + .free = panfrost_gem_free_object, + .open = panfrost_gem_open, +@@ -265,6 +272,7 @@ static const struct drm_gem_object_funcs panfrost_gem_funcs = { + .status = panfrost_gem_status, + .rss = panfrost_gem_rss, + .vm_ops = &drm_gem_shmem_vm_ops, ++ .evict = panfrost_shmem_evict, + }; + + /** +diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.h b/drivers/gpu/drm/panfrost/panfrost_gem.h +index 7516b7ecf7fe..8ddc2d310d29 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_gem.h ++++ b/drivers/gpu/drm/panfrost/panfrost_gem.h +@@ -30,12 +30,6 @@ struct panfrost_gem_object { + struct mutex lock; + } mappings; + +- /* +- * Count the number of jobs referencing this BO so we don't let the +- * shrinker reclaim this object prematurely. +- */ +- atomic_t gpu_usecount; +- + /* + * Object chunk size currently mapped onto physical memory + */ +@@ -86,7 +80,4 @@ panfrost_gem_mapping_get(struct panfrost_gem_object *bo, + void panfrost_gem_mapping_put(struct panfrost_gem_mapping *mapping); + void panfrost_gem_teardown_mappings_locked(struct panfrost_gem_object *bo); + +-int panfrost_gem_shrinker_init(struct drm_device *dev); +-void panfrost_gem_shrinker_cleanup(struct drm_device *dev); +- + #endif /* __PANFROST_GEM_H__ */ +diff --git a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +deleted file mode 100644 +index 7b4deba803ed..000000000000 +--- a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c ++++ /dev/null +@@ -1,140 +0,0 @@ +-// SPDX-License-Identifier: GPL-2.0 +-/* Copyright (C) 2019 Arm Ltd. +- * +- * Based on msm_gem_freedreno.c: +- * Copyright (C) 2016 Red Hat +- * Author: Rob Clark +- */ +- +-#include +- +-#include +-#include +- +-#include "panfrost_device.h" +-#include "panfrost_gem.h" +-#include "panfrost_mmu.h" +- +-static bool panfrost_gem_shmem_is_purgeable(struct drm_gem_shmem_object *shmem) +-{ +- return (shmem->madv > 0) && +- !refcount_read(&shmem->pages_pin_count) && shmem->sgt && +- !shmem->base.dma_buf && !shmem->base.import_attach; +-} +- +-static unsigned long +-panfrost_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc) +-{ +- struct panfrost_device *pfdev = shrinker->private_data; +- struct drm_gem_shmem_object *shmem; +- unsigned long count = 0; +- +- if (!mutex_trylock(&pfdev->shrinker_lock)) +- return 0; +- +- list_for_each_entry(shmem, &pfdev->shrinker_list, madv_list) { +- if (panfrost_gem_shmem_is_purgeable(shmem)) +- count += shmem->base.size >> PAGE_SHIFT; +- } +- +- mutex_unlock(&pfdev->shrinker_lock); +- +- return count; +-} +- +-static bool panfrost_gem_purge(struct drm_gem_object *obj) +-{ +- struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); +- struct panfrost_gem_object *bo = to_panfrost_bo(obj); +- bool ret = false; +- +- if (atomic_read(&bo->gpu_usecount)) +- return false; +- +- if (!mutex_trylock(&bo->mappings.lock)) +- return false; +- +- if (!dma_resv_trylock(shmem->base.resv)) +- goto unlock_mappings; +- +- /* BO might have become unpurgeable if the last pages_use_count ref +- * was dropped, but the BO hasn't been destroyed yet. +- */ +- if (!panfrost_gem_shmem_is_purgeable(shmem)) +- goto unlock_mappings; +- +- panfrost_gem_teardown_mappings_locked(bo); +- drm_gem_shmem_purge_locked(&bo->base); +- ret = true; +- +- dma_resv_unlock(shmem->base.resv); +- +-unlock_mappings: +- mutex_unlock(&bo->mappings.lock); +- return ret; +-} +- +-static unsigned long +-panfrost_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc) +-{ +- struct panfrost_device *pfdev = shrinker->private_data; +- struct drm_gem_shmem_object *shmem, *tmp; +- unsigned long freed = 0; +- +- if (!mutex_trylock(&pfdev->shrinker_lock)) +- return SHRINK_STOP; +- +- list_for_each_entry_safe(shmem, tmp, &pfdev->shrinker_list, madv_list) { +- if (freed >= sc->nr_to_scan) +- break; +- if (panfrost_gem_shmem_is_purgeable(shmem) && +- panfrost_gem_purge(&shmem->base)) { +- freed += shmem->base.size >> PAGE_SHIFT; +- list_del_init(&shmem->madv_list); +- } +- } +- +- mutex_unlock(&pfdev->shrinker_lock); +- +- if (freed > 0) +- pr_info_ratelimited("Purging %lu bytes\n", freed << PAGE_SHIFT); +- +- return freed; +-} +- +-/** +- * panfrost_gem_shrinker_init - Initialize panfrost shrinker +- * @dev: DRM device +- * +- * This function registers and sets up the panfrost shrinker. +- */ +-int panfrost_gem_shrinker_init(struct drm_device *dev) +-{ +- struct panfrost_device *pfdev = dev->dev_private; +- +- pfdev->shrinker = shrinker_alloc(0, "drm-panfrost"); +- if (!pfdev->shrinker) +- return -ENOMEM; +- +- pfdev->shrinker->count_objects = panfrost_gem_shrinker_count; +- pfdev->shrinker->scan_objects = panfrost_gem_shrinker_scan; +- pfdev->shrinker->private_data = pfdev; +- +- shrinker_register(pfdev->shrinker); +- +- return 0; +-} +- +-/** +- * panfrost_gem_shrinker_cleanup - Clean up panfrost shrinker +- * @dev: DRM device +- * +- * This function unregisters the panfrost shrinker. +- */ +-void panfrost_gem_shrinker_cleanup(struct drm_device *dev) +-{ +- struct panfrost_device *pfdev = dev->dev_private; +- +- if (pfdev->shrinker) +- shrinker_free(pfdev->shrinker); +-} +diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c +index 0c2dbf6ef2a5..9e26cb013191 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_job.c ++++ b/drivers/gpu/drm/panfrost/panfrost_job.c +@@ -289,6 +289,19 @@ static void panfrost_attach_object_fences(struct drm_gem_object **bos, + dma_resv_add_fence(bos[i]->resv, fence, DMA_RESV_USAGE_WRITE); + } + ++static int panfrost_objects_prepare(struct drm_gem_object **bos, int bo_count) ++{ ++ struct panfrost_gem_object *bo; ++ int ret = 0; ++ ++ while (!ret && bo_count--) { ++ bo = to_panfrost_bo(bos[bo_count]); ++ ret = bo->base.madv != PANFROST_MADV_WILLNEED ? -EINVAL : 0; ++ } ++ ++ return ret; ++} ++ + int panfrost_job_push(struct panfrost_job *job) + { + struct panfrost_device *pfdev = job->pfdev; +@@ -300,6 +313,10 @@ int panfrost_job_push(struct panfrost_job *job) + if (ret) + return ret; + ++ ret = panfrost_objects_prepare(job->bos, job->bo_count); ++ if (ret) ++ goto unlock; ++ + mutex_lock(&pfdev->sched_lock); + drm_sched_job_arm(&job->base); + +@@ -341,7 +358,6 @@ static void panfrost_job_cleanup(struct kref *ref) + if (!job->mappings[i]) + break; + +- atomic_dec(&job->mappings[i]->obj->gpu_usecount); + panfrost_gem_mapping_put(job->mappings[i]); + } + kvfree(job->mappings); +diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c +index 4a0b4bf03f1a..22e18f7986e7 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_mmu.c ++++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c +@@ -328,6 +328,7 @@ int panfrost_mmu_map(struct panfrost_gem_mapping *mapping) + struct panfrost_device *pfdev = to_panfrost_device(obj->dev); + struct sg_table *sgt; + int prot = IOMMU_READ | IOMMU_WRITE; ++ int ret = 0; + + if (WARN_ON(mapping->active)) + return 0; +@@ -335,15 +336,32 @@ int panfrost_mmu_map(struct panfrost_gem_mapping *mapping) + if (bo->noexec) + prot |= IOMMU_NOEXEC; + ++ if (!obj->import_attach) { ++ /* ++ * Don't allow shrinker to move pages while pages are mapped. ++ * It's fine to move pages afterwards because shrinker will ++ * take care of unmapping pages during eviction. ++ */ ++ ret = drm_gem_shmem_pin(shmem); ++ if (ret) ++ return ret; ++ } ++ + sgt = drm_gem_shmem_get_pages_sgt(shmem); +- if (WARN_ON(IS_ERR(sgt))) +- return PTR_ERR(sgt); ++ if (WARN_ON(IS_ERR(sgt))) { ++ ret = PTR_ERR(sgt); ++ goto unpin; ++ } + + mmu_map_sg(pfdev, mapping->mmu, mapping->mmnode.start << PAGE_SHIFT, + prot, sgt); + mapping->active = true; + +- return 0; ++unpin: ++ if (!obj->import_attach) ++ drm_gem_shmem_unpin(shmem); ++ ++ return ret; + } + + void panfrost_mmu_unmap(struct panfrost_gem_mapping *mapping) +diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h +index 167f00f089de..9c6bb00260fc 100644 +--- a/include/drm/drm_gem_shmem_helper.h ++++ b/include/drm/drm_gem_shmem_helper.h +@@ -61,13 +61,6 @@ struct drm_gem_shmem_object { + */ + int madv; + +- /** +- * @madv_list: List entry for madvise tracking +- * +- * Typically used by drivers to track purgeable objects +- */ +- struct list_head madv_list; +- + /** + * @sgt: Scatter/gather table for imported PRIME buffers + */ +-- +2.43.0 + + +^ permalink raw reply related [flat|nested] 31+ messages in thread +end of thread, other threads:[~2024-01-05 18:47 UTC | newest] + +Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed) +-- links below jump to the message on this page -- +2024-01-05 18:45 [PATCH v19 00/30] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko +2024-01-05 18:45 ` [PATCH v19 01/30] drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names Dmitry Osipenko +2024-01-05 18:45 ` [PATCH v19 02/30] drm/gem: Add _locked postfix to functions that have unlocked counterpart Dmitry Osipenko +2024-01-05 18:45 ` [PATCH v19 03/30] drm/gem: Document locking rule of vmap and evict callbacks Dmitry Osipenko +2024-01-05 18:45 ` [PATCH v19 04/30] drm/shmem-helper: Make all exported symbols GPL Dmitry Osipenko +2024-01-05 18:45 ` [PATCH v19 05/30] drm/shmem-helper: Refactor locked/unlocked functions Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 06/30] drm/shmem-helper: Remove obsoleted is_iomem test Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 07/30] drm/shmem-helper: Add and use pages_pin_count Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 08/30] drm/shmem-helper: Use refcount_t for pages_use_count Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 09/30] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages() Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 10/30] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 11/30] drm/shmem-helper: Use refcount_t for vmap_use_count Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 12/30] drm/shmem-helper: Prepare drm_gem_shmem_free() to shrinker addition Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 13/30] drm/shmem-helper: Make drm_gem_shmem_get_pages() public Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 14/30] drm/shmem-helper: Add drm_gem_shmem_put_pages() Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 15/30] drm/shmem-helper: Avoid lockdep warning when pages are released Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 16/30] drm/lima: Explicitly get and put drm-shmem pages Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 17/30] drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr() Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 18/30] drm/panfrost: Explicitly get and put drm-shmem pages Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 19/30] drm/virtio: " Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 20/30] drm/v3d: " Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 21/30] drm/shmem-helper: Change sgt allocation policy Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 23/30] drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked() Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 24/30] drm/shmem-helper: Optimize unlocked get_pages_sgt() Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 25/30] drm/shmem-helper: Don't free refcounted GEM Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 26/30] drm/shmem-helper: Turn warnings about imported GEM into errors Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 27/30] drm/virtio: Pin display framebuffer BO Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 28/30] drm/virtio: Attach shmem BOs dynamically Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 29/30] drm/virtio: Support shmem shrinking Dmitry Osipenko +2024-01-05 18:46 ` [PATCH v19 30/30] drm/panfrost: Switch to generic memory shrinker Dmitry Osipenko +This is a public inbox, see mirroring instructions +for how to clone and mirror all data and code used for this inbox; +as well as URLs for NNTP newsgroup(s). diff --git a/projects/Amlogic/patches/linux/S922X/0001-clk-meson-add-vclk-driver.patch b/projects/Amlogic/patches/linux/S922X/0001-clk-meson-add-vclk-driver.patch index 99ba4c5466..a243a2a515 100644 --- a/projects/Amlogic/patches/linux/S922X/0001-clk-meson-add-vclk-driver.patch +++ b/projects/Amlogic/patches/linux/S922X/0001-clk-meson-add-vclk-driver.patch @@ -1,11 +1,11 @@ -From 5148f675093813c51517e77adefe40e835fb1d27 Mon Sep 17 00:00:00 2001 +From 801ce8505a73f0b9f1e66ca84b1ae8a0e56d212c Mon Sep 17 00:00:00 2001 From: Neil Armstrong -Date: Fri, 24 Nov 2023 09:41:18 +0100 -Subject: [PATCH 01/46] clk: meson: add vclk driver +Date: Wed, 3 Apr 2024 09:46:33 +0200 +Subject: [PATCH 01/44] clk: meson: add vclk driver The VCLK and VCLK_DIV clocks have supplementary bits. -The VCLK has a "SOFT RESET" bit to toggle after the whole +The VCLK gate has a "SOFT RESET" bit to toggle after the whole VCLK sub-tree rate has been set, this is implemented in the gate enable callback. @@ -19,16 +19,16 @@ the divider is correctly set. Signed-off-by: Neil Armstrong --- - drivers/clk/meson/Kconfig | 5 ++ + drivers/clk/meson/Kconfig | 4 ++ drivers/clk/meson/Makefile | 1 + drivers/clk/meson/vclk.c | 141 +++++++++++++++++++++++++++++++++++++ drivers/clk/meson/vclk.h | 51 ++++++++++++++ - 4 files changed, 198 insertions(+) + 4 files changed, 197 insertions(+) create mode 100644 drivers/clk/meson/vclk.c create mode 100644 drivers/clk/meson/vclk.h diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig -index 29ffd14d267b..59a40a49f8e1 100644 +index 29ffd14d267b..8a9823789fa3 100644 --- a/drivers/clk/meson/Kconfig +++ b/drivers/clk/meson/Kconfig @@ -30,6 +30,10 @@ config COMMON_CLK_MESON_VID_PLL_DIV @@ -42,14 +42,6 @@ index 29ffd14d267b..59a40a49f8e1 100644 config COMMON_CLK_MESON_CLKC_UTILS tristate -@@ -140,6 +144,7 @@ config COMMON_CLK_G12A - select COMMON_CLK_MESON_EE_CLKC - select COMMON_CLK_MESON_CPU_DYNDIV - select COMMON_CLK_MESON_VID_PLL_DIV -+ select COMMON_CLK_MESON_VCLK - select MFD_SYSCON - help - Support for the clock controller on Amlogic S905D2, S905X2 and S905Y2 diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile index 9ee4b954c896..9ba43fe7a07a 100644 --- a/drivers/clk/meson/Makefile @@ -64,13 +56,13 @@ index 9ee4b954c896..9ba43fe7a07a 100644 diff --git a/drivers/clk/meson/vclk.c b/drivers/clk/meson/vclk.c new file mode 100644 -index 000000000000..47f08a52b49f +index 000000000000..45dc216941ea --- /dev/null +++ b/drivers/clk/meson/vclk.c @@ -0,0 +1,141 @@ +// SPDX-License-Identifier: GPL-2.0 +/* -+ * Copyright (c) 2023 Neil Armstrong ++ * Copyright (c) 2024 Neil Armstrong + */ + +#include @@ -78,16 +70,16 @@ index 000000000000..47f08a52b49f + +/* The VCLK gate has a supplementary reset bit to pulse after ungating */ + -+static inline struct clk_regmap_vclk_data * -+clk_get_regmap_vclk_data(struct clk_regmap *clk) ++static inline struct meson_vclk_gate_data * ++clk_get_meson_vclk_gate_data(struct clk_regmap *clk) +{ -+ return (struct clk_regmap_vclk_data *)clk->data; ++ return (struct meson_vclk_gate_data *)clk->data; +} + -+static int clk_regmap_vclk_enable(struct clk_hw *hw) ++static int meson_vclk_gate_enable(struct clk_hw *hw) +{ + struct clk_regmap *clk = to_clk_regmap(hw); -+ struct clk_regmap_vclk_data *vclk = clk_get_regmap_vclk_data(clk); ++ struct meson_vclk_gate_data *vclk = clk_get_meson_vclk_gate_data(clk); + + meson_parm_write(clk->map, &vclk->enable, 1); + @@ -98,62 +90,62 @@ index 000000000000..47f08a52b49f + return 0; +} + -+static void clk_regmap_vclk_disable(struct clk_hw *hw) ++static void meson_vclk_gate_disable(struct clk_hw *hw) +{ + struct clk_regmap *clk = to_clk_regmap(hw); -+ struct clk_regmap_vclk_data *vclk = clk_get_regmap_vclk_data(clk); ++ struct meson_vclk_gate_data *vclk = clk_get_meson_vclk_gate_data(clk); + + meson_parm_write(clk->map, &vclk->enable, 0); +} + -+static int clk_regmap_vclk_is_enabled(struct clk_hw *hw) ++static int meson_vclk_gate_is_enabled(struct clk_hw *hw) +{ + struct clk_regmap *clk = to_clk_regmap(hw); -+ struct clk_regmap_vclk_data *vclk = clk_get_regmap_vclk_data(clk); ++ struct meson_vclk_gate_data *vclk = clk_get_meson_vclk_gate_data(clk); + + return meson_parm_read(clk->map, &vclk->enable); +} + -+const struct clk_ops clk_regmap_vclk_ops = { -+ .enable = clk_regmap_vclk_enable, -+ .disable = clk_regmap_vclk_disable, -+ .is_enabled = clk_regmap_vclk_is_enabled, ++const struct clk_ops meson_vclk_gate_ops = { ++ .enable = meson_vclk_gate_enable, ++ .disable = meson_vclk_gate_disable, ++ .is_enabled = meson_vclk_gate_is_enabled, +}; -+EXPORT_SYMBOL_GPL(clk_regmap_vclk_ops); ++EXPORT_SYMBOL_GPL(meson_vclk_gate_ops); + +/* The VCLK Divider has supplementary reset & enable bits */ + -+static inline struct clk_regmap_vclk_div_data * -+clk_get_regmap_vclk_div_data(struct clk_regmap *clk) ++static inline struct meson_vclk_div_data * ++clk_get_meson_vclk_div_data(struct clk_regmap *clk) +{ -+ return (struct clk_regmap_vclk_div_data *)clk->data; ++ return (struct meson_vclk_div_data *)clk->data; +} + -+static unsigned long clk_regmap_vclk_div_recalc_rate(struct clk_hw *hw, -+ unsigned long prate) ++static unsigned long meson_vclk_div_recalc_rate(struct clk_hw *hw, ++ unsigned long prate) +{ + struct clk_regmap *clk = to_clk_regmap(hw); -+ struct clk_regmap_vclk_div_data *vclk = clk_get_regmap_vclk_div_data(clk); ++ struct meson_vclk_div_data *vclk = clk_get_meson_vclk_div_data(clk); + + return divider_recalc_rate(hw, prate, meson_parm_read(clk->map, &vclk->div), + vclk->table, vclk->flags, vclk->div.width); +} + -+static int clk_regmap_vclk_div_determine_rate(struct clk_hw *hw, -+ struct clk_rate_request *req) ++static int meson_vclk_div_determine_rate(struct clk_hw *hw, ++ struct clk_rate_request *req) +{ + struct clk_regmap *clk = to_clk_regmap(hw); -+ struct clk_regmap_vclk_div_data *vclk = clk_get_regmap_vclk_div_data(clk); ++ struct meson_vclk_div_data *vclk = clk_get_meson_vclk_div_data(clk); + + return divider_determine_rate(hw, req, vclk->table, vclk->div.width, + vclk->flags); +} + -+static int clk_regmap_vclk_div_set_rate(struct clk_hw *hw, unsigned long rate, -+ unsigned long parent_rate) ++static int meson_vclk_div_set_rate(struct clk_hw *hw, unsigned long rate, ++ unsigned long parent_rate) +{ + struct clk_regmap *clk = to_clk_regmap(hw); -+ struct clk_regmap_vclk_div_data *vclk = clk_get_regmap_vclk_div_data(clk); ++ struct meson_vclk_div_data *vclk = clk_get_meson_vclk_div_data(clk); + int ret; + + ret = divider_get_val(rate, parent_rate, vclk->table, vclk->div.width, @@ -166,10 +158,10 @@ index 000000000000..47f08a52b49f + return 0; +}; + -+static int clk_regmap_vclk_div_enable(struct clk_hw *hw) ++static int meson_vclk_div_enable(struct clk_hw *hw) +{ + struct clk_regmap *clk = to_clk_regmap(hw); -+ struct clk_regmap_vclk_div_data *vclk = clk_get_regmap_vclk_div_data(clk); ++ struct meson_vclk_div_data *vclk = clk_get_meson_vclk_div_data(clk); + + /* Unreset the divider when ungating */ + meson_parm_write(clk->map, &vclk->reset, 0); @@ -178,46 +170,46 @@ index 000000000000..47f08a52b49f + return 0; +} + -+static void clk_regmap_vclk_div_disable(struct clk_hw *hw) ++static void meson_vclk_div_disable(struct clk_hw *hw) +{ + struct clk_regmap *clk = to_clk_regmap(hw); -+ struct clk_regmap_vclk_div_data *vclk = clk_get_regmap_vclk_div_data(clk); ++ struct meson_vclk_div_data *vclk = clk_get_meson_vclk_div_data(clk); + + /* Reset the divider when gating */ + meson_parm_write(clk->map, &vclk->enable, 0); + meson_parm_write(clk->map, &vclk->reset, 1); +} + -+static int clk_regmap_vclk_div_is_enabled(struct clk_hw *hw) ++static int meson_vclk_div_is_enabled(struct clk_hw *hw) +{ + struct clk_regmap *clk = to_clk_regmap(hw); -+ struct clk_regmap_vclk_div_data *vclk = clk_get_regmap_vclk_div_data(clk); ++ struct meson_vclk_div_data *vclk = clk_get_meson_vclk_div_data(clk); + + return meson_parm_read(clk->map, &vclk->enable); +} + -+const struct clk_ops clk_regmap_vclk_div_ops = { -+ .recalc_rate = clk_regmap_vclk_div_recalc_rate, -+ .determine_rate = clk_regmap_vclk_div_determine_rate, -+ .set_rate = clk_regmap_vclk_div_set_rate, -+ .enable = clk_regmap_vclk_div_enable, -+ .disable = clk_regmap_vclk_div_disable, -+ .is_enabled = clk_regmap_vclk_div_is_enabled, ++const struct clk_ops meson_vclk_div_ops = { ++ .recalc_rate = meson_vclk_div_recalc_rate, ++ .determine_rate = meson_vclk_div_determine_rate, ++ .set_rate = meson_vclk_div_set_rate, ++ .enable = meson_vclk_div_enable, ++ .disable = meson_vclk_div_disable, ++ .is_enabled = meson_vclk_div_is_enabled, +}; -+EXPORT_SYMBOL_GPL(clk_regmap_vclk_div_ops); ++EXPORT_SYMBOL_GPL(meson_vclk_div_ops); + +MODULE_DESCRIPTION("Amlogic vclk clock driver"); +MODULE_AUTHOR("Neil Armstrong "); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/clk/meson/vclk.h b/drivers/clk/meson/vclk.h new file mode 100644 -index 000000000000..4f25d7ad2717 +index 000000000000..20b0b181db09 --- /dev/null +++ b/drivers/clk/meson/vclk.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* -+ * Copyright (c) 2023 Neil Armstrong ++ * Copyright (c) 2024 Neil Armstrong + */ + +#ifndef __VCLK_H @@ -227,7 +219,7 @@ index 000000000000..4f25d7ad2717 +#include "parm.h" + +/** -+ * struct clk_regmap_vclk_data - vclk regmap backed specific data ++ * struct meson_vclk_gate_data - vclk_gate regmap backed specific data + * + * @enable: vclk enable field + * @reset: vclk reset field @@ -236,16 +228,16 @@ index 000000000000..4f25d7ad2717 + * Flags: + * Same as clk_gate except CLK_GATE_HIWORD_MASK which is ignored + */ -+struct clk_regmap_vclk_data { ++struct meson_vclk_gate_data { + struct parm enable; + struct parm reset; + u8 flags; +}; + -+extern const struct clk_ops clk_regmap_vclk_ops; ++extern const struct clk_ops meson_vclk_gate_ops; + +/** -+ * struct clk_regmap_vclk_div_data - vclk_div regmap back specific data ++ * struct meson_vclk_div_data - vclk_div regmap back specific data + * + * @div: divider field + * @enable: vclk divider enable field @@ -255,7 +247,7 @@ index 000000000000..4f25d7ad2717 + * Flags: + * Same as clk_divider except CLK_DIVIDER_HIWORD_MASK which is ignored + */ -+struct clk_regmap_vclk_div_data { ++struct meson_vclk_div_data { + struct parm div; + struct parm enable; + struct parm reset; @@ -263,7 +255,7 @@ index 000000000000..4f25d7ad2717 + u8 flags; +}; + -+extern const struct clk_ops clk_regmap_vclk_div_ops; ++extern const struct clk_ops meson_vclk_div_ops; + +#endif /* __VCLK_H */ -- diff --git a/projects/Amlogic/patches/linux/S922X/0002-clk-meson-g12a-make-VCLK2-and-ENCL-clock-path-config.patch b/projects/Amlogic/patches/linux/S922X/0002-clk-meson-g12a-make-VCLK2-and-ENCL-clock-path-config.patch index 5b7126932c..633e0f7859 100644 --- a/projects/Amlogic/patches/linux/S922X/0002-clk-meson-g12a-make-VCLK2-and-ENCL-clock-path-config.patch +++ b/projects/Amlogic/patches/linux/S922X/0002-clk-meson-g12a-make-VCLK2-and-ENCL-clock-path-config.patch @@ -1,7 +1,7 @@ -From 82025570aabeb66146bd4b9e38f03d9b920ef20d Mon Sep 17 00:00:00 2001 +From 024103a845d9efb602225f975175ed2b678578e7 Mon Sep 17 00:00:00 2001 From: Neil Armstrong -Date: Fri, 24 Nov 2023 09:41:19 +0100 -Subject: [PATCH 02/46] clk: meson: g12a: make VCLK2 and ENCL clock path +Date: Wed, 3 Apr 2024 09:46:34 +0200 +Subject: [PATCH 02/44] clk: meson: g12a: make VCLK2 and ENCL clock path configurable by CCF In order to setup the DSI clock, let's make the unused VCLK2 clock path @@ -30,7 +30,7 @@ In order to set a rate on cts_encl via the vclk2 clock path, the NO_REPARENT flag is set on cts_encl_sel & vclk2_sel in order to keep CCF from selection a parent. The parents of cts_encl_sel & vclk2_sel are expected to be defined -in DT. +in DT or manually set by the display driver at some point. The following clock scheme is to be used for DSI: @@ -48,16 +48,33 @@ xtal \_ mipi_dsi_pxclk_div \_ mipi_dsi_pxclk -> to DSI controller -The mipi_dsi_pxclk_div is set as RO in order to use the same GP0 -for mipi_dsi_pxclk and vclk2_input. +The mipi_dsi_pxclk_div is set as bypass with a single /1 entry in div_table +in order to use the same GP0 for mipi_dsi_pxclk and vclk2_input. + +The SET_RATE_PARENT is only set on the mipi_dsi_pxclk_sel clock so the +DSI bitclock is the reference base clock to calculate the vclk2_div value +when pixel clock is set on the cts_encl endpoint. Signed-off-by: Neil Armstrong --- - drivers/clk/meson/g12a.c | 68 +++++++++++++++++++++++++++------------- - 1 file changed, 47 insertions(+), 21 deletions(-) + drivers/clk/meson/Kconfig | 1 + + drivers/clk/meson/g12a.c | 76 ++++++++++++++++++++++++++++----------- + 2 files changed, 57 insertions(+), 20 deletions(-) +diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig +index 8a9823789fa3..59a40a49f8e1 100644 +--- a/drivers/clk/meson/Kconfig ++++ b/drivers/clk/meson/Kconfig +@@ -144,6 +144,7 @@ config COMMON_CLK_G12A + select COMMON_CLK_MESON_EE_CLKC + select COMMON_CLK_MESON_CPU_DYNDIV + select COMMON_CLK_MESON_VID_PLL_DIV ++ select COMMON_CLK_MESON_VCLK + select MFD_SYSCON + help + Support for the clock controller on Amlogic S905D2, S905X2 and S905Y2 diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c -index 90f4c6103014..078ef5cd026c 100644 +index 90f4c6103014..df7e17c850d8 100644 --- a/drivers/clk/meson/g12a.c +++ b/drivers/clk/meson/g12a.c @@ -22,6 +22,7 @@ @@ -73,20 +90,19 @@ index 90f4c6103014..078ef5cd026c 100644 .parent_hws = g12a_vclk_parent_hws, .num_parents = ARRAY_SIZE(g12a_vclk_parent_hws), - .flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE, -+ .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT, ++ .flags = CLK_SET_RATE_NO_REPARENT, }, }; -@@ -3193,7 +3194,7 @@ static struct clk_regmap g12a_vclk2_input = { +@@ -3193,7 +3194,6 @@ static struct clk_regmap g12a_vclk2_input = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2_sel.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, -+ .flags = CLK_SET_RATE_PARENT, }, }; -@@ -3215,19 +3216,32 @@ static struct clk_regmap g12a_vclk_div = { +@@ -3215,19 +3215,32 @@ static struct clk_regmap g12a_vclk_div = { }; static struct clk_regmap g12a_vclk2_div = { @@ -94,7 +110,7 @@ index 90f4c6103014..078ef5cd026c 100644 - .offset = HHI_VIID_CLK_DIV, - .shift = 0, - .width = 8, -+ .data = &(struct clk_regmap_vclk_div_data){ ++ .data = &(struct meson_vclk_div_data){ + .div = { + .reg_off = HHI_VIID_CLK_DIV, + .shift = 0, @@ -115,24 +131,24 @@ index 90f4c6103014..078ef5cd026c 100644 .hw.init = &(struct clk_init_data){ .name = "vclk2_div", - .ops = &clk_regmap_divider_ops, -+ .ops = &clk_regmap_vclk_div_ops, ++ .ops = &meson_vclk_div_ops, .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2_input.hw }, .num_parents = 1, - .flags = CLK_GET_RATE_NOCACHE, -+ .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, ++ .flags = CLK_SET_RATE_GATE, }, }; -@@ -3246,16 +3260,24 @@ static struct clk_regmap g12a_vclk = { +@@ -3246,16 +3259,24 @@ static struct clk_regmap g12a_vclk = { }; static struct clk_regmap g12a_vclk2 = { - .data = &(struct clk_regmap_gate_data){ - .offset = HHI_VIID_CLK_CNTL, - .bit_idx = 19, -+ .data = &(struct clk_regmap_vclk_data){ ++ .data = &(struct meson_vclk_gate_data){ + .enable = { + .reg_off = HHI_VIID_CLK_CNTL, + .shift = 19, @@ -147,15 +163,15 @@ index 90f4c6103014..078ef5cd026c 100644 .hw.init = &(struct clk_init_data) { .name = "vclk2", - .ops = &clk_regmap_gate_ops, -+ .ops = &clk_regmap_vclk_ops, ++ .ops = &meson_vclk_gate_ops, .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, -+ .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, ++ .flags = CLK_SET_RATE_PARENT, }, }; -@@ -3339,7 +3361,7 @@ static struct clk_regmap g12a_vclk2_div1 = { +@@ -3339,7 +3360,7 @@ static struct clk_regmap g12a_vclk2_div1 = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw }, .num_parents = 1, @@ -164,7 +180,7 @@ index 90f4c6103014..078ef5cd026c 100644 }, }; -@@ -3353,7 +3375,7 @@ static struct clk_regmap g12a_vclk2_div2_en = { +@@ -3353,7 +3374,7 @@ static struct clk_regmap g12a_vclk2_div2_en = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw }, .num_parents = 1, @@ -173,7 +189,7 @@ index 90f4c6103014..078ef5cd026c 100644 }, }; -@@ -3367,7 +3389,7 @@ static struct clk_regmap g12a_vclk2_div4_en = { +@@ -3367,7 +3388,7 @@ static struct clk_regmap g12a_vclk2_div4_en = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw }, .num_parents = 1, @@ -182,7 +198,7 @@ index 90f4c6103014..078ef5cd026c 100644 }, }; -@@ -3381,7 +3403,7 @@ static struct clk_regmap g12a_vclk2_div6_en = { +@@ -3381,7 +3402,7 @@ static struct clk_regmap g12a_vclk2_div6_en = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw }, .num_parents = 1, @@ -191,7 +207,7 @@ index 90f4c6103014..078ef5cd026c 100644 }, }; -@@ -3395,7 +3417,7 @@ static struct clk_regmap g12a_vclk2_div12_en = { +@@ -3395,7 +3416,7 @@ static struct clk_regmap g12a_vclk2_div12_en = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw }, .num_parents = 1, @@ -200,7 +216,7 @@ index 90f4c6103014..078ef5cd026c 100644 }, }; -@@ -3461,6 +3483,7 @@ static struct clk_fixed_factor g12a_vclk2_div2 = { +@@ -3461,6 +3482,7 @@ static struct clk_fixed_factor g12a_vclk2_div2 = { &g12a_vclk2_div2_en.hw }, .num_parents = 1, @@ -208,7 +224,7 @@ index 90f4c6103014..078ef5cd026c 100644 }, }; -@@ -3474,6 +3497,7 @@ static struct clk_fixed_factor g12a_vclk2_div4 = { +@@ -3474,6 +3496,7 @@ static struct clk_fixed_factor g12a_vclk2_div4 = { &g12a_vclk2_div4_en.hw }, .num_parents = 1, @@ -216,7 +232,7 @@ index 90f4c6103014..078ef5cd026c 100644 }, }; -@@ -3487,6 +3511,7 @@ static struct clk_fixed_factor g12a_vclk2_div6 = { +@@ -3487,6 +3510,7 @@ static struct clk_fixed_factor g12a_vclk2_div6 = { &g12a_vclk2_div6_en.hw }, .num_parents = 1, @@ -224,7 +240,7 @@ index 90f4c6103014..078ef5cd026c 100644 }, }; -@@ -3500,6 +3525,7 @@ static struct clk_fixed_factor g12a_vclk2_div12 = { +@@ -3500,6 +3524,7 @@ static struct clk_fixed_factor g12a_vclk2_div12 = { &g12a_vclk2_div12_en.hw }, .num_parents = 1, @@ -232,7 +248,7 @@ index 90f4c6103014..078ef5cd026c 100644 }, }; -@@ -3561,7 +3587,7 @@ static struct clk_regmap g12a_cts_encl_sel = { +@@ -3561,7 +3586,7 @@ static struct clk_regmap g12a_cts_encl_sel = { .ops = &clk_regmap_mux_ops, .parent_hws = g12a_cts_parent_hws, .num_parents = ARRAY_SIZE(g12a_cts_parent_hws), @@ -241,24 +257,34 @@ index 90f4c6103014..078ef5cd026c 100644 }, }; -@@ -3717,7 +3743,7 @@ static struct clk_regmap g12a_mipi_dsi_pxclk_sel = { +@@ -3717,15 +3742,26 @@ static struct clk_regmap g12a_mipi_dsi_pxclk_sel = { .ops = &clk_regmap_mux_ops, .parent_hws = g12a_mipi_dsi_pxclk_parent_hws, .num_parents = ARRAY_SIZE(g12a_mipi_dsi_pxclk_parent_hws), - .flags = CLK_SET_RATE_NO_REPARENT, -+ .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT, ++ .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, }, }; -@@ -3729,7 +3755,7 @@ static struct clk_regmap g12a_mipi_dsi_pxclk_div = { ++/* ++ * FIXME: Force as bypass by forcing a single /1 table entry, and doensn't on boot value ++ * when setting a clock whith this node in the clock path, but doesn't garantee the divider ++ * is at /1 at boot until a rate is set. ++ */ ++static const struct clk_div_table g12a_mipi_dsi_pxclk_div_table[] = { ++ { .val = 0, .div = 1 }, ++ { /* sentinel */ }, ++}; ++ + static struct clk_regmap g12a_mipi_dsi_pxclk_div = { + .data = &(struct clk_regmap_div_data){ + .offset = HHI_MIPIDSI_PHY_CLK_CNTL, + .shift = 0, + .width = 7, ++ .table = g12a_mipi_dsi_pxclk_div_table, }, .hw.init = &(struct clk_init_data){ .name = "mipi_dsi_pxclk_div", -- .ops = &clk_regmap_divider_ops, -+ .ops = &clk_regmap_divider_ro_ops, - .parent_hws = (const struct clk_hw *[]) { - &g12a_mipi_dsi_pxclk_sel.hw - }, -- 2.34.1 diff --git a/projects/Amlogic/patches/linux/S922X/0003-drm-meson-gate-px_clk-when-setting-rate.patch b/projects/Amlogic/patches/linux/S922X/0003-drm-meson-gate-px_clk-when-setting-rate.patch index 7bf5958062..505aa42c0c 100644 --- a/projects/Amlogic/patches/linux/S922X/0003-drm-meson-gate-px_clk-when-setting-rate.patch +++ b/projects/Amlogic/patches/linux/S922X/0003-drm-meson-gate-px_clk-when-setting-rate.patch @@ -1,7 +1,7 @@ -From c041e0aabb0a55d2887e44fe7c61cb7ead478c36 Mon Sep 17 00:00:00 2001 +From c69702647174a36a3bbaa928d4879f4562123372 Mon Sep 17 00:00:00 2001 From: Neil Armstrong -Date: Fri, 24 Nov 2023 09:41:20 +0100 -Subject: [PATCH 03/46] drm/meson: gate px_clk when setting rate +Date: Wed, 3 Apr 2024 09:46:35 +0200 +Subject: [PATCH 03/44] drm/meson: gate px_clk when setting rate Disable the px_clk when setting the rate to recover a fully configured and correctly reset VCLK clock tree after the rate diff --git a/projects/Amlogic/patches/linux/S922X/0004-arm64-meson-g12-common-add-the-MIPI-DSI-nodes.patch b/projects/Amlogic/patches/linux/S922X/0004-arm64-meson-g12-common-add-the-MIPI-DSI-nodes.patch index fc67cfa7a5..4919b90854 100644 --- a/projects/Amlogic/patches/linux/S922X/0004-arm64-meson-g12-common-add-the-MIPI-DSI-nodes.patch +++ b/projects/Amlogic/patches/linux/S922X/0004-arm64-meson-g12-common-add-the-MIPI-DSI-nodes.patch @@ -1,7 +1,7 @@ -From 421f6f95cd3957a2d50f8207e29922161d26d7e8 Mon Sep 17 00:00:00 2001 +From b584fdbb6a339fdf28ab8c1eb031262c0c66b5e2 Mon Sep 17 00:00:00 2001 From: Neil Armstrong -Date: Fri, 24 Nov 2023 09:41:21 +0100 -Subject: [PATCH 04/46] arm64: meson: g12-common: add the MIPI DSI nodes +Date: Wed, 3 Apr 2024 09:46:36 +0200 +Subject: [PATCH 04/44] arm64: meson: g12-common: add the MIPI DSI nodes Add the MIPI DSI Analog & Digital PHY nodes and the DSI control nodes with proper port endpoint to the VPU. diff --git a/projects/Amlogic/patches/linux/S922X/0005-drm-panel-st7701-add-odroid-go-ultra-panel-support.patch b/projects/Amlogic/patches/linux/S922X/0005-drm-panel-st7701-add-odroid-go-ultra-panel-support.patch index 4e74cd208f..e5b104cf2c 100644 --- a/projects/Amlogic/patches/linux/S922X/0005-drm-panel-st7701-add-odroid-go-ultra-panel-support.patch +++ b/projects/Amlogic/patches/linux/S922X/0005-drm-panel-st7701-add-odroid-go-ultra-panel-support.patch @@ -1,7 +1,7 @@ -From d082804fbe171c98bc5222140b59649eb59716b1 Mon Sep 17 00:00:00 2001 -From: adamg +From ee573e00af321704d2bd093efd8d7cb3976b11a3 Mon Sep 17 00:00:00 2001 +From: spycat88 Date: Tue, 23 Jan 2024 23:28:55 +0000 -Subject: [PATCH 05/46] drm: panel: st7701: add odroid-go-ultra panel support +Subject: [PATCH 05/44] drm: panel: st7701: add odroid-go-ultra panel support --- drivers/gpu/drm/panel/panel-sitronix-st7701.c | 162 +++++++++++++++++- diff --git a/projects/Amlogic/patches/linux/S922X/0006-arm64-meson-odroid-go-ultra-add-DSI-panel.patch b/projects/Amlogic/patches/linux/S922X/0006-arm64-meson-odroid-go-ultra-add-DSI-panel.patch index 5e725e2900..6e656088d9 100644 --- a/projects/Amlogic/patches/linux/S922X/0006-arm64-meson-odroid-go-ultra-add-DSI-panel.patch +++ b/projects/Amlogic/patches/linux/S922X/0006-arm64-meson-odroid-go-ultra-add-DSI-panel.patch @@ -1,7 +1,7 @@ -From cfaadfa315974aec501a9fe6537737925a5dd24a Mon Sep 17 00:00:00 2001 -From: adamg +From 157e64dad5bd6b9965089b764850930404c88e8e Mon Sep 17 00:00:00 2001 +From: spycat88 Date: Tue, 23 Jan 2024 23:41:40 +0000 -Subject: [PATCH 06/46] arm64: meson: odroid-go-ultra: add DSI panel +Subject: [PATCH 06/44] arm64: meson: odroid-go-ultra: add DSI panel --- .../amlogic/meson-g12b-odroid-go-ultra.dts | 66 +++++++++++++++++++ diff --git a/projects/Amlogic/patches/linux/S922X/0008-arm64-meson-odroid-go-ultra-correct-voltages.patch b/projects/Amlogic/patches/linux/S922X/0007-arm64-meson-odroid-go-ultra-correct-voltages.patch similarity index 94% rename from projects/Amlogic/patches/linux/S922X/0008-arm64-meson-odroid-go-ultra-correct-voltages.patch rename to projects/Amlogic/patches/linux/S922X/0007-arm64-meson-odroid-go-ultra-correct-voltages.patch index c8bfd25264..d2b706ba20 100644 --- a/projects/Amlogic/patches/linux/S922X/0008-arm64-meson-odroid-go-ultra-correct-voltages.patch +++ b/projects/Amlogic/patches/linux/S922X/0007-arm64-meson-odroid-go-ultra-correct-voltages.patch @@ -1,7 +1,7 @@ -From a6a3911c184fbc0841ec0e7e6c03f13fd85275a3 Mon Sep 17 00:00:00 2001 +From 263c479a06698696adc7ababb97bf312022fcdaf Mon Sep 17 00:00:00 2001 From: "Mauro (mdrjr) Ribeiro" Date: Tue, 23 Jan 2024 23:53:24 +0000 -Subject: [PATCH 08/46] arm64: meson: odroid-go-ultra: correct voltages +Subject: [PATCH 07/44] arm64: meson: odroid-go-ultra: correct voltages --- .../dts/amlogic/meson-g12b-odroid-go-ultra.dts | 16 +++++++--------- diff --git a/projects/Amlogic/patches/linux/S922X/0007-clk-meson-g12a-fix-mipi-display-output-for-odroid-go.patch b/projects/Amlogic/patches/linux/S922X/0007-clk-meson-g12a-fix-mipi-display-output-for-odroid-go.patch deleted file mode 100644 index ad3812fcba..0000000000 --- a/projects/Amlogic/patches/linux/S922X/0007-clk-meson-g12a-fix-mipi-display-output-for-odroid-go.patch +++ /dev/null @@ -1,44 +0,0 @@ -From a2cc1f351fae19b8421e03cd5f23fd46dd89147d Mon Sep 17 00:00:00 2001 -From: "Mauro (mdrjr) Ribeiro" -Date: Tue, 23 Jan 2024 23:56:49 +0000 -Subject: [PATCH 07/46] clk: meson: g12a: fix mipi display output for - odroid-go-ultra - ---- - drivers/clk/meson/g12a.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c -index 078ef5cd026c..cdecb43e04c4 100644 ---- a/drivers/clk/meson/g12a.c -+++ b/drivers/clk/meson/g12a.c -@@ -3151,7 +3151,7 @@ static struct clk_regmap g12a_vclk_sel = { - .ops = &clk_regmap_mux_ops, - .parent_hws = g12a_vclk_parent_hws, - .num_parents = ARRAY_SIZE(g12a_vclk_parent_hws), -- .flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE, -+ .flags = CLK_SET_RATE_NO_REPARENT, - }, - }; - -@@ -3180,7 +3180,7 @@ static struct clk_regmap g12a_vclk_input = { - .ops = &clk_regmap_gate_ops, - .parent_hws = (const struct clk_hw *[]) { &g12a_vclk_sel.hw }, - .num_parents = 1, -- .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, -+ //.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, - }, - }; - -@@ -3743,7 +3743,7 @@ static struct clk_regmap g12a_mipi_dsi_pxclk_sel = { - .ops = &clk_regmap_mux_ops, - .parent_hws = g12a_mipi_dsi_pxclk_parent_hws, - .num_parents = ARRAY_SIZE(g12a_mipi_dsi_pxclk_parent_hws), -- .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT, -+ .flags = CLK_SET_RATE_NO_REPARENT, - }, - }; - --- -2.34.1 - diff --git a/projects/Amlogic/patches/linux/S922X/0009-arm64-meson-odroid-go-ultra-add-over-clocking-freque.patch b/projects/Amlogic/patches/linux/S922X/0008-arm64-meson-odroid-go-ultra-add-over-clocking-freque.patch similarity index 52% rename from projects/Amlogic/patches/linux/S922X/0009-arm64-meson-odroid-go-ultra-add-over-clocking-freque.patch rename to projects/Amlogic/patches/linux/S922X/0008-arm64-meson-odroid-go-ultra-add-over-clocking-freque.patch index 1cc92c9b47..b024c4fbc3 100644 --- a/projects/Amlogic/patches/linux/S922X/0009-arm64-meson-odroid-go-ultra-add-over-clocking-freque.patch +++ b/projects/Amlogic/patches/linux/S922X/0008-arm64-meson-odroid-go-ultra-add-over-clocking-freque.patch @@ -1,18 +1,19 @@ -From 40f0c572000dc88b972486b1aa5a014f7fb93dd2 Mon Sep 17 00:00:00 2001 -From: "Mauro (mdrjr) Ribeiro" -Date: Wed, 24 Jan 2024 10:56:00 +0000 -Subject: [PATCH 09/46] arm64: meson: odroid-go-ultra: add over-clocking - frequencies +From 0869f9c56b47e2c63be274d72c97c51e227c18e4 Mon Sep 17 00:00:00 2001 +From: spycat88 +Date: Wed, 24 Jan 2024 11:37:48 +0000 +Subject: [PATCH 08/44] arm64: meson: odroid-go-ultra: add over-clocking + frequencies, specify as turbo mode so they are disabled by default and + increase vddcpu_a voltage regulator as needed --- - .../amlogic/meson-g12b-odroid-go-ultra.dts | 26 ++++++++++++++++++- - 1 file changed, 25 insertions(+), 1 deletion(-) + .../amlogic/meson-g12b-odroid-go-ultra.dts | 31 +++++++++++++++++-- + 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -index 571a0393e148..1fcfe421ec73 100644 +index 571a0393e148..c3af3954a1e7 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts +++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -@@ -347,7 +347,11 @@ opp-1896000000 { +@@ -347,7 +347,12 @@ opp-1896000000 { opp-microvolt = <987500>; }; opp-1992000000 { @@ -22,10 +23,11 @@ index 571a0393e148..1fcfe421ec73 100644 + opp-2016000000 { + opp-hz = /bits/ 64 <2016000000>; + opp-microvolt = <1050000>; ++ turbo-mode; }; }; -@@ -377,6 +381,26 @@ opp-1800000000 { +@@ -377,6 +382,28 @@ opp-1800000000 { opp-1908000000 { opp-microvolt = <1025000>; }; @@ -44,14 +46,25 @@ index 571a0393e148..1fcfe421ec73 100644 + opp-2304000000 { + opp-hz = /bits/ 64 <2304000000>; + opp-microvolt = <1050000>; ++ turbo-mode; + }; + opp-2400000000 { + opp-hz = /bits/ 64 <2400000000>; + opp-microvolt = <1050000>; ++ turbo-mode; + }; }; &i2c_AO { +@@ -407,7 +434,7 @@ vddcpu_a: DCDC_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <775000>; +- regulator-max-microvolt = <1025000>; ++ regulator-max-microvolt = <1050000>; + regulator-ramp-delay = <6001>; + regulator-state-mem { + regulator-on-in-suspend; -- 2.34.1 diff --git a/projects/Amlogic/patches/linux/S922X/0013-gpiolib-of-revert-api-changes-needed-for-joypad-driv.patch b/projects/Amlogic/patches/linux/S922X/0009-gpiolib-of-revert-api-changes-needed-for-joypad-driv.patch similarity index 98% rename from projects/Amlogic/patches/linux/S922X/0013-gpiolib-of-revert-api-changes-needed-for-joypad-driv.patch rename to projects/Amlogic/patches/linux/S922X/0009-gpiolib-of-revert-api-changes-needed-for-joypad-driv.patch index 1655f0b034..5428878b08 100644 --- a/projects/Amlogic/patches/linux/S922X/0013-gpiolib-of-revert-api-changes-needed-for-joypad-driv.patch +++ b/projects/Amlogic/patches/linux/S922X/0009-gpiolib-of-revert-api-changes-needed-for-joypad-driv.patch @@ -1,7 +1,7 @@ -From 5f535c4284b43edb588ac2fd6b8e7ffcdc0696ff Mon Sep 17 00:00:00 2001 +From a2a47a8b3f3235dded76dfc1e10052d1ea8f89fc Mon Sep 17 00:00:00 2001 From: brooksytech <1673861+brooksytech@users.noreply.github.com> Date: Wed, 24 Jan 2024 22:12:01 +0000 -Subject: [PATCH 13/46] gpiolib: of: revert api changes needed for joypad +Subject: [PATCH 09/44] gpiolib: of: revert api changes needed for joypad driver --- diff --git a/projects/Amlogic/patches/linux/S922X/0010-arm64-meson-odroid-go-ultra-specify-overclocking-fre.patch b/projects/Amlogic/patches/linux/S922X/0010-arm64-meson-odroid-go-ultra-specify-overclocking-fre.patch deleted file mode 100644 index fb095bfef6..0000000000 --- a/projects/Amlogic/patches/linux/S922X/0010-arm64-meson-odroid-go-ultra-specify-overclocking-fre.patch +++ /dev/null @@ -1,38 +0,0 @@ -From b422792a31cab22b2ce9c519246eedc9cde594f9 Mon Sep 17 00:00:00 2001 -From: adamg -Date: Wed, 24 Jan 2024 11:37:48 +0000 -Subject: [PATCH 10/46] arm64: meson: odroid-go-ultra: specify overclocking - frequencies as turbo mode - ---- - arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -index 1fcfe421ec73..74e1a315bfb1 100644 ---- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -@@ -352,6 +352,7 @@ opp-1992000000 { - opp-2016000000 { - opp-hz = /bits/ 64 <2016000000>; - opp-microvolt = <1050000>; -+ turbo-mode; - }; - }; - -@@ -396,10 +397,12 @@ opp-2208000000 { - opp-2304000000 { - opp-hz = /bits/ 64 <2304000000>; - opp-microvolt = <1050000>; -+ turbo-mode; - }; - opp-2400000000 { - opp-hz = /bits/ 64 <2400000000>; - opp-microvolt = <1050000>; -+ turbo-mode; - }; - }; - --- -2.34.1 - diff --git a/projects/Amlogic/patches/linux/S922X/0014-input-add-input-polldev-driver.patch b/projects/Amlogic/patches/linux/S922X/0010-input-add-input-polldev-driver.patch similarity index 99% rename from projects/Amlogic/patches/linux/S922X/0014-input-add-input-polldev-driver.patch rename to projects/Amlogic/patches/linux/S922X/0010-input-add-input-polldev-driver.patch index b43d7ca613..cf06685e24 100644 --- a/projects/Amlogic/patches/linux/S922X/0014-input-add-input-polldev-driver.patch +++ b/projects/Amlogic/patches/linux/S922X/0010-input-add-input-polldev-driver.patch @@ -1,7 +1,7 @@ -From bb62799748bd5492d80e9ebee4ac6b5702fb037e Mon Sep 17 00:00:00 2001 +From 2f3e05182321bd7e6b8ad2335f1ed0751f006918 Mon Sep 17 00:00:00 2001 From: brooksytech <1673861+brooksytech@users.noreply.github.com> Date: Wed, 24 Jan 2024 21:50:05 +0000 -Subject: [PATCH 14/46] input: add input-polldev driver +Subject: [PATCH 10/44] input: add input-polldev driver --- drivers/input/Kconfig | 13 ++ diff --git a/projects/Amlogic/patches/linux/S922X/0011-arm64-meson-odroid-go-ultra-remove-adc-joystick.patch b/projects/Amlogic/patches/linux/S922X/0011-arm64-meson-odroid-go-ultra-remove-adc-joystick.patch deleted file mode 100644 index db94c47373..0000000000 --- a/projects/Amlogic/patches/linux/S922X/0011-arm64-meson-odroid-go-ultra-remove-adc-joystick.patch +++ /dev/null @@ -1,69 +0,0 @@ -From c74c64709ce2d46e1431558bdfd74f0b3f0a8e40 Mon Sep 17 00:00:00 2001 -From: "Mauro (mdrjr) Ribeiro" -Date: Wed, 24 Jan 2024 12:08:19 +0000 -Subject: [PATCH 11/46] arm64: meson: odroid-go-ultra: remove adc joystick - ---- - .../amlogic/meson-g12b-odroid-go-ultra.dts | 46 ------------------- - 1 file changed, 46 deletions(-) - -diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -index 74e1a315bfb1..30c48311f165 100644 ---- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -@@ -21,52 +21,6 @@ aliases { - rtc0 = &vrtc; - }; - -- adc-joystick-left { -- compatible = "adc-joystick"; -- io-channels = <&saradc 2>, <&saradc 3>; -- poll-interval = <10>; -- #address-cells = <1>; -- #size-cells = <0>; -- -- axis@0 { -- reg = <0>; -- linux,code = ; -- abs-range = <3150 950>; -- abs-fuzz = <32>; -- abs-flat = <64>; -- }; -- axis@1 { -- reg = <1>; -- linux,code = ; -- abs-range = <700 2900>; -- abs-fuzz = <32>; -- abs-flat = <64>; -- }; -- }; -- -- adc-joystick-right { -- compatible = "adc-joystick"; -- io-channels = <&saradc 0>, <&saradc 1>; -- poll-interval = <10>; -- #address-cells = <1>; -- #size-cells = <0>; -- -- axis@0 { -- reg = <0>; -- linux,code = ; -- abs-range = <3150 950>; -- abs-fuzz = <32>; -- abs-flat = <64>; -- }; -- axis@1 { -- reg = <1>; -- linux,code = ; -- abs-range = <800 3000>; -- abs-fuzz = <32>; -- abs-flat = <64>; -- }; -- }; -- - chosen { - stdout-path = "serial0:115200n8"; - }; --- -2.34.1 - diff --git a/projects/Amlogic/patches/linux/S922X/0015-input-joystick-add-odroid-go-ultra-joypad-driver.patch b/projects/Amlogic/patches/linux/S922X/0011-input-joystick-add-odroid-go-ultra-joypad-driver.patch similarity index 99% rename from projects/Amlogic/patches/linux/S922X/0015-input-joystick-add-odroid-go-ultra-joypad-driver.patch rename to projects/Amlogic/patches/linux/S922X/0011-input-joystick-add-odroid-go-ultra-joypad-driver.patch index c6aa41f83b..b457bd06f0 100644 --- a/projects/Amlogic/patches/linux/S922X/0015-input-joystick-add-odroid-go-ultra-joypad-driver.patch +++ b/projects/Amlogic/patches/linux/S922X/0011-input-joystick-add-odroid-go-ultra-joypad-driver.patch @@ -1,7 +1,7 @@ -From c120f496cb69a1e0ad9644667f22333421e04e66 Mon Sep 17 00:00:00 2001 +From 8321fa2704f8e4a8a916994d3564995034190357 Mon Sep 17 00:00:00 2001 From: brooksytech <1673861+brooksytech@users.noreply.github.com> Date: Wed, 24 Jan 2024 21:55:38 +0000 -Subject: [PATCH 15/46] input: joystick: add odroid-go ultra-joypad driver +Subject: [PATCH 11/44] input: joystick: add odroid-go ultra-joypad driver --- drivers/input/joystick/Kconfig | 6 + diff --git a/projects/Amlogic/patches/linux/S922X/0016-arm64-meson-odroid-go-ultra-add-joypad.patch b/projects/Amlogic/patches/linux/S922X/0012-arm64-meson-odroid-go-ultra-add-joypad.patch similarity index 76% rename from projects/Amlogic/patches/linux/S922X/0016-arm64-meson-odroid-go-ultra-add-joypad.patch rename to projects/Amlogic/patches/linux/S922X/0012-arm64-meson-odroid-go-ultra-add-joypad.patch index 0c1e605a59..3d5bded51c 100644 --- a/projects/Amlogic/patches/linux/S922X/0016-arm64-meson-odroid-go-ultra-add-joypad.patch +++ b/projects/Amlogic/patches/linux/S922X/0012-arm64-meson-odroid-go-ultra-add-joypad.patch @@ -1,17 +1,70 @@ -From 680d720e515ee3f189f6d0320a2a5070fac02a10 Mon Sep 17 00:00:00 2001 +From 8ec3462157e94af211573c3706d54d225ceec576 Mon Sep 17 00:00:00 2001 From: brooksytech <1673861+brooksytech@users.noreply.github.com> Date: Wed, 24 Jan 2024 21:57:34 +0000 -Subject: [PATCH 16/46] arm64: meson: odroid-go-ultra: add joypad +Subject: [PATCH 12/44] arm64: meson: odroid-go-ultra: add joypad --- - .../amlogic/meson-g12b-odroid-go-ultra.dts | 156 +++++++++++------- - 1 file changed, 93 insertions(+), 63 deletions(-) + .../amlogic/meson-g12b-odroid-go-ultra.dts | 202 ++++++++---------- + 1 file changed, 93 insertions(+), 109 deletions(-) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -index 30c48311f165..595b2a76157e 100644 +index c3af3954a1e7..206044f8456b 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts +++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -@@ -34,9 +34,8 @@ codec_clk: codec-clk { +@@ -21,52 +21,6 @@ aliases { + rtc0 = &vrtc; + }; + +- adc-joystick-left { +- compatible = "adc-joystick"; +- io-channels = <&saradc 2>, <&saradc 3>; +- poll-interval = <10>; +- #address-cells = <1>; +- #size-cells = <0>; +- +- axis@0 { +- reg = <0>; +- linux,code = ; +- abs-range = <3150 950>; +- abs-fuzz = <32>; +- abs-flat = <64>; +- }; +- axis@1 { +- reg = <1>; +- linux,code = ; +- abs-range = <700 2900>; +- abs-fuzz = <32>; +- abs-flat = <64>; +- }; +- }; +- +- adc-joystick-right { +- compatible = "adc-joystick"; +- io-channels = <&saradc 0>, <&saradc 1>; +- poll-interval = <10>; +- #address-cells = <1>; +- #size-cells = <0>; +- +- axis@0 { +- reg = <0>; +- linux,code = ; +- abs-range = <3150 950>; +- abs-fuzz = <32>; +- abs-flat = <64>; +- }; +- axis@1 { +- reg = <1>; +- linux,code = ; +- abs-range = <800 3000>; +- abs-fuzz = <32>; +- abs-flat = <64>; +- }; +- }; +- + chosen { + stdout-path = "serial0:115200n8"; + }; +@@ -80,9 +34,8 @@ codec_clk: codec-clk { gpio-keys { compatible = "gpio-keys-polled"; @@ -23,7 +76,7 @@ index 30c48311f165..595b2a76157e 100644 volume-up-button { label = "VOLUME-UP"; -@@ -48,95 +47,126 @@ volume-down-button { +@@ -94,95 +47,126 @@ volume-down-button { linux,code = ; gpios = <&gpio GPIOX_9 GPIO_ACTIVE_LOW>; }; @@ -133,7 +186,7 @@ index 30c48311f165..595b2a76157e 100644 + sw11 { gpios = <&gpio GPIOX_10 GPIO_ACTIVE_LOW>; + label = "GPIO F2"; -+ linux,code = ; // 0x2c2 ++ linux,code = ; // 0x2c2 }; - f3-button { - label = "F3"; @@ -141,7 +194,7 @@ index 30c48311f165..595b2a76157e 100644 + sw12 { gpios = <&gpio GPIOX_11 GPIO_ACTIVE_LOW>; + label = "GPIO F3"; -+ linux,code = ; // 0x2c3 ++ linux,code = ; // 0x2c3 }; - f4-button { - label = "F4"; @@ -149,7 +202,7 @@ index 30c48311f165..595b2a76157e 100644 + sw13 { gpios = <&gpio GPIOX_12 GPIO_ACTIVE_LOW>; + label = "GPIO F4"; -+ linux,code = ; // 0x2c4 ++ linux,code = ; // 0x2c4 }; - f5-button { - label = "F5"; @@ -157,7 +210,7 @@ index 30c48311f165..595b2a76157e 100644 + sw14 { gpios = <&gpio GPIOX_13 GPIO_ACTIVE_LOW>; + label = "GPIO F5"; -+ linux,code = ; // 0x13c ++ linux,code = ; // 0x13c }; - f6-button { - label = "F6"; @@ -191,12 +244,12 @@ index 30c48311f165..595b2a76157e 100644 + sw17 { + gpios = <&gpio GPIOX_16 GPIO_ACTIVE_LOW>; + label = "GPIO F6"; -+ linux,code = ; ++ linux,code = ; + }; + sw18 { + gpios = <&gpio GPIOX_17 GPIO_ACTIVE_LOW>; + label = "GPIO F1"; -+ linux,code = ; ++ linux,code = ; + }; + sw19 { gpios = <&gpio GPIOX_18 GPIO_ACTIVE_LOW>; diff --git a/projects/Amlogic/patches/linux/S922X/0012-drm-meson-venc-HACK-panic-when-gamma-is-not-set-corr.patch b/projects/Amlogic/patches/linux/S922X/0012-drm-meson-venc-HACK-panic-when-gamma-is-not-set-corr.patch deleted file mode 100644 index 3bbf9d05f5..0000000000 --- a/projects/Amlogic/patches/linux/S922X/0012-drm-meson-venc-HACK-panic-when-gamma-is-not-set-corr.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 5e6f57c6bcd6d0603e0d9f1e5aa3cc60dc81a2f0 Mon Sep 17 00:00:00 2001 -From: brooksytech <1673861+brooksytech@users.noreply.github.com> -Date: Wed, 24 Jan 2024 16:18:45 +0000 -Subject: [PATCH 12/46] drm: meson: venc: HACK: panic when gamma is not set - correctly - ---- - drivers/gpu/drm/meson/meson_venc.c | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -diff --git a/drivers/gpu/drm/meson/meson_venc.c b/drivers/gpu/drm/meson/meson_venc.c -index 3bf0d6e4fc30..ace2e6c21f69 100644 ---- a/drivers/gpu/drm/meson/meson_venc.c -+++ b/drivers/gpu/drm/meson/meson_venc.c -@@ -1590,7 +1590,8 @@ static void meson_encl_set_gamma_table(struct meson_drm *priv, u16 *data, - ret = readl_relaxed_poll_timeout(priv->io_base + _REG(L_GAMMA_CNTL_PORT), - reg, reg & L_GAMMA_CNTL_PORT_ADR_RDY, 10, 10000); - if (ret) -- pr_warn("%s: GAMMA ADR_RDY timeout\n", __func__); -+ //pr_warn("%s: GAMMA ADR_RDY timeout\n", __func__); -+ panic("NOT ENOUGH SALT, GAMMA NOT SET"); - - writel_relaxed(L_GAMMA_ADDR_PORT_AUTO_INC | rgb_mask | - FIELD_PREP(L_GAMMA_ADDR_PORT_ADDR, 0), -@@ -1601,7 +1602,8 @@ static void meson_encl_set_gamma_table(struct meson_drm *priv, u16 *data, - reg, reg & L_GAMMA_CNTL_PORT_WR_RDY, - 10, 10000); - if (ret) -- pr_warn_once("%s: GAMMA WR_RDY timeout\n", __func__); -+ //pr_warn_once("%s: GAMMA WR_RDY timeout\n", __func__); -+ panic("NOT ENOUGH SALT, GAMMA NOT SET"); - - writel_relaxed(data[i], priv->io_base + _REG(L_GAMMA_DATA_PORT)); - } -@@ -1609,7 +1611,8 @@ static void meson_encl_set_gamma_table(struct meson_drm *priv, u16 *data, - ret = readl_relaxed_poll_timeout(priv->io_base + _REG(L_GAMMA_CNTL_PORT), - reg, reg & L_GAMMA_CNTL_PORT_ADR_RDY, 10, 10000); - if (ret) -- pr_warn("%s: GAMMA ADR_RDY timeout\n", __func__); -+ //pr_warn("%s: GAMMA ADR_RDY timeout\n", __func__); -+ panic("NOT ENOUGH SALT, GAMMA NOT SET"); - - writel_relaxed(L_GAMMA_ADDR_PORT_AUTO_INC | rgb_mask | - FIELD_PREP(L_GAMMA_ADDR_PORT_ADDR, 0x23), --- -2.34.1 - diff --git a/projects/Amlogic/patches/linux/S922X/0017-arm64-meson-odroid-disable-heartbeat.patch b/projects/Amlogic/patches/linux/S922X/0013-arm64-meson-odroid-disable-heartbeat.patch similarity index 84% rename from projects/Amlogic/patches/linux/S922X/0017-arm64-meson-odroid-disable-heartbeat.patch rename to projects/Amlogic/patches/linux/S922X/0013-arm64-meson-odroid-disable-heartbeat.patch index 507c7ba534..ca8ade5604 100644 --- a/projects/Amlogic/patches/linux/S922X/0017-arm64-meson-odroid-disable-heartbeat.patch +++ b/projects/Amlogic/patches/linux/S922X/0013-arm64-meson-odroid-disable-heartbeat.patch @@ -1,7 +1,7 @@ -From e64757346ce9b6f92bf0cfcb734ef0e42ad326fe Mon Sep 17 00:00:00 2001 -From: adamg +From badcabb07a6e4f056834443039d054072f23d9e1 Mon Sep 17 00:00:00 2001 +From: spycat88 Date: Wed, 24 Jan 2024 22:22:49 +0000 -Subject: [PATCH 17/46] arm64: meson: odroid: disable heartbeat +Subject: [PATCH 13/44] arm64: meson: odroid: disable heartbeat --- arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts | 2 +- @@ -9,7 +9,7 @@ Subject: [PATCH 17/46] arm64: meson: odroid: disable heartbeat 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -index 595b2a76157e..40820c49aacc 100644 +index 206044f8456b..1d26387776e6 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts +++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts @@ -194,7 +194,7 @@ leds { diff --git a/projects/Amlogic/patches/linux/S922X/0018-arm64-meson-g12-common-add-mali-to-dts.patch b/projects/Amlogic/patches/linux/S922X/0014-arm64-meson-g12-common-add-mali-to-dts.patch similarity index 93% rename from projects/Amlogic/patches/linux/S922X/0018-arm64-meson-g12-common-add-mali-to-dts.patch rename to projects/Amlogic/patches/linux/S922X/0014-arm64-meson-g12-common-add-mali-to-dts.patch index 3e3d1e6cc1..d100f0e9bc 100644 --- a/projects/Amlogic/patches/linux/S922X/0018-arm64-meson-g12-common-add-mali-to-dts.patch +++ b/projects/Amlogic/patches/linux/S922X/0014-arm64-meson-g12-common-add-mali-to-dts.patch @@ -1,7 +1,7 @@ -From 16f5c47a7c9e681ccbd6a8bf0b4d31087b814112 Mon Sep 17 00:00:00 2001 +From 1de7a39ee1c2b6ec6c5ce375d6774ac703cc02a7 Mon Sep 17 00:00:00 2001 From: brooksytech <1673861+brooksytech@users.noreply.github.com> Date: Wed, 24 Jan 2024 23:56:58 +0000 -Subject: [PATCH 18/46] arm64: meson: g12-common: add mali to dts +Subject: [PATCH 14/44] arm64: meson: g12-common: add mali to dts --- .../arm64/boot/dts/amlogic/meson-g12-common.dtsi | 16 +++++++++++----- diff --git a/projects/Amlogic/patches/linux/S922X/0020-arm64-meson-add-dt-for-powkiddy-rgb10-max-3-pro.patch b/projects/Amlogic/patches/linux/S922X/0015-arm64-meson-add-dt-for-powkiddy-rgb10-max-3-pro.patch similarity index 90% rename from projects/Amlogic/patches/linux/S922X/0020-arm64-meson-add-dt-for-powkiddy-rgb10-max-3-pro.patch rename to projects/Amlogic/patches/linux/S922X/0015-arm64-meson-add-dt-for-powkiddy-rgb10-max-3-pro.patch index 399902aef2..447b69a74c 100644 --- a/projects/Amlogic/patches/linux/S922X/0020-arm64-meson-add-dt-for-powkiddy-rgb10-max-3-pro.patch +++ b/projects/Amlogic/patches/linux/S922X/0015-arm64-meson-add-dt-for-powkiddy-rgb10-max-3-pro.patch @@ -1,7 +1,7 @@ -From b8a3b313627511625e5fa10967687d4f4fe27ae5 Mon Sep 17 00:00:00 2001 -From: adamg +From 7d53adc4da9bb4dc992b4247e9cf528e1c6fb288 Mon Sep 17 00:00:00 2001 +From: spycat88 Date: Fri, 26 Jan 2024 17:55:02 +0000 -Subject: [PATCH 20/46] arm64: meson: add dt for powkiddy-rgb10-max-3-pro +Subject: [PATCH 15/44] arm64: meson: add dt for powkiddy-rgb10-max-3-pro --- .../meson-g12b-powkiddy-rgb10-max-3-pro.dts | 54 +++++++++++++++++++ diff --git a/projects/Amlogic/patches/linux/S922X/0016-power-rk818-Configure-rk808-clkout2-function.patch b/projects/Amlogic/patches/linux/S922X/0016-power-rk818-Configure-rk808-clkout2-function.patch new file mode 100644 index 0000000000..50725e63b3 --- /dev/null +++ b/projects/Amlogic/patches/linux/S922X/0016-power-rk818-Configure-rk808-clkout2-function.patch @@ -0,0 +1,44 @@ +From fff6d5ad0f054463f0fc67485b596e6239e13516 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= +Date: Mon, 4 Jan 2021 17:57:49 +0100 +Subject: [PATCH 16/44] power: rk818: Configure `rk808-clkout2` function +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +??? + +Signed-of-by: Kamil Trzciński +--- + drivers/mfd/rk8xx-core.c | 1 + + include/linux/mfd/rk808.h | 2 ++ + 2 files changed, 3 insertions(+) + +diff --git a/drivers/mfd/rk8xx-core.c b/drivers/mfd/rk8xx-core.c +index b1ffc3b9e2be..2747a296a0a6 100644 +--- a/drivers/mfd/rk8xx-core.c ++++ b/drivers/mfd/rk8xx-core.c +@@ -250,6 +250,7 @@ static const struct rk808_reg_data rk818_pre_init_reg[] = { + { RK818_H5V_EN_REG, BIT(0), RK818_H5V_EN }, + { RK808_VB_MON_REG, MASK_ALL, VB_LO_ACT | + VB_LO_SEL_3500MV }, ++ { RK808_CLK32OUT_REG, CLK32KOUT2_FUNC_MASK, CLK32KOUT2_FUNC }, + }; + + static const struct regmap_irq rk805_irqs[] = { +diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h +index 78e167a92483..4a44e8744331 100644 +--- a/include/linux/mfd/rk808.h ++++ b/include/linux/mfd/rk808.h +@@ -790,6 +790,8 @@ enum rk806_dvs_mode { + + #define VOUT_LO_INT BIT(0) + #define CLK32KOUT2_EN BIT(0) ++#define CLK32KOUT2_FUNC (0 << 1) ++#define CLK32KOUT2_FUNC_MASK BIT(1) + + #define TEMP115C 0x0c + #define TEMP_HOTDIE_MSK 0x0c +-- +2.34.1 + diff --git a/projects/Amlogic/patches/linux/S922X/0021-power-supply-rk818-battery-Add-battery-driver-for-RK.patch b/projects/Amlogic/patches/linux/S922X/0017-power-supply-rk818-battery-Add-battery-driver-for-RK.patch similarity index 99% rename from projects/Amlogic/patches/linux/S922X/0021-power-supply-rk818-battery-Add-battery-driver-for-RK.patch rename to projects/Amlogic/patches/linux/S922X/0017-power-supply-rk818-battery-Add-battery-driver-for-RK.patch index a2637270fd..381a81209a 100644 --- a/projects/Amlogic/patches/linux/S922X/0021-power-supply-rk818-battery-Add-battery-driver-for-RK.patch +++ b/projects/Amlogic/patches/linux/S922X/0017-power-supply-rk818-battery-Add-battery-driver-for-RK.patch @@ -1,7 +1,7 @@ -From b7161f5d7aeee84655312d54bdf0bf70e05a47c6 Mon Sep 17 00:00:00 2001 +From 302adba82133c44efee29d357bab89462d7cd52c Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Sun, 11 Jun 2023 18:29:24 +0200 -Subject: [PATCH 21/46] power: supply: rk818-battery: Add battery driver for +Subject: [PATCH 17/44] power: supply: rk818-battery: Add battery driver for RK818 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 @@ -11,29 +11,25 @@ This is forward ported driver from Rockchip BSP. Signed-of-by: Kamil Trzciński --- - drivers/mfd/rk8xx-core.c | 6 +- + drivers/mfd/rk8xx-core.c | 2 + drivers/mfd/rk8xx-i2c.c | 38 +- - drivers/power/supply/Kconfig | 17 + + drivers/power/supply/Kconfig | 8 + drivers/power/supply/Makefile | 1 + drivers/power/supply/rk818_battery.c | 3568 ++++++++++++++++++++++++++ drivers/power/supply/rk818_battery.h | 168 ++ include/linux/mfd/rk808.h | 81 +- - 7 files changed, 3874 insertions(+), 5 deletions(-) + 7 files changed, 3863 insertions(+), 3 deletions(-) create mode 100644 drivers/power/supply/rk818_battery.c create mode 100644 drivers/power/supply/rk818_battery.h diff --git a/drivers/mfd/rk8xx-core.c b/drivers/mfd/rk8xx-core.c -index b1ffc3b9e2be..05175284079e 100644 +index 2747a296a0a6..64b6e0e59e15 100644 --- a/drivers/mfd/rk8xx-core.c +++ b/drivers/mfd/rk8xx-core.c -@@ -109,8 +109,10 @@ static const struct mfd_cell rk817s[] = { - }; - +@@ -111,6 +111,8 @@ static const struct mfd_cell rk817s[] = { static const struct mfd_cell rk818s[] = { -- { .name = "rk808-clkout", }, -- { .name = "rk808-regulator", }, -+ { .name = "rk808-clkout", .id = PLATFORM_DEVID_NONE, }, -+ { .name = "rk808-regulator", .id = PLATFORM_DEVID_NONE, }, + { .name = "rk808-clkout", }, + { .name = "rk808-regulator", }, + { .name = "rk818-battery", .of_compatible = "rockchip,rk818-battery", }, + { .name = "rk818-charger", .of_compatible = "rockchip,rk818-charger", }, { @@ -94,22 +90,13 @@ index 75b5cf09d5a0..3d9632fb3554 100644 static const struct regmap_config rk805_regmap_config = { diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig -index f21cb05815ec..1722fc1ee7ec 100644 +index 3e31375491d5..6ad47fe5f089 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig -@@ -984,4 +984,21 @@ config FUEL_GAUGE_MM8013 +@@ -985,4 +985,12 @@ config FUEL_GAUGE_MM8013 the state of charge, temperature, cycle count, actual and design capacity, etc. -+config FUEL_GAUGE_MM8013 -+ tristate "Mitsumi MM8013 fuel gauge driver" -+ depends on I2C -+ help -+ Say Y here to enable the Mitsumi MM8013 fuel gauge driver. -+ It enables the monitoring of many battery parameters, including -+ the state of charge, temperature, cycle count, actual and design -+ capacity, etc. -+ +config BATTERY_RK818 + bool "RK818 Battery driver" + depends on MFD_RK808 @@ -3879,7 +3866,7 @@ index 000000000000..2f4430a98167 +#endif \ No newline at end of file diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h -index 78e167a92483..05d61ae8a0f5 100644 +index 4a44e8744331..e06ecffaf6bc 100644 --- a/include/linux/mfd/rk808.h +++ b/include/linux/mfd/rk808.h @@ -138,6 +138,8 @@ enum rk818_reg { diff --git a/projects/Amlogic/patches/linux/S922X/0022-power-supply-rk818-battery-Use-a-more-propper-compat.patch b/projects/Amlogic/patches/linux/S922X/0018-power-supply-rk818-battery-Use-a-more-propper-compat.patch similarity index 88% rename from projects/Amlogic/patches/linux/S922X/0022-power-supply-rk818-battery-Use-a-more-propper-compat.patch rename to projects/Amlogic/patches/linux/S922X/0018-power-supply-rk818-battery-Use-a-more-propper-compat.patch index e590cebd27..d126a99526 100644 --- a/projects/Amlogic/patches/linux/S922X/0022-power-supply-rk818-battery-Use-a-more-propper-compat.patch +++ b/projects/Amlogic/patches/linux/S922X/0018-power-supply-rk818-battery-Use-a-more-propper-compat.patch @@ -1,7 +1,7 @@ -From 5b7117f8108d7aec2268b3a8cf2fefad394d8e1a Mon Sep 17 00:00:00 2001 +From aebc99b0f9145bb9d47c73ce64693ef723c63705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= Date: Sun, 7 Nov 2021 19:30:07 +0100 -Subject: [PATCH 22/46] power: supply: rk818-battery: Use a more propper +Subject: [PATCH 18/44] power: supply: rk818-battery: Use a more propper compatible string Prefix with vendor name. diff --git a/projects/Amlogic/patches/linux/S922X/0019-arm64-meson-odroid-go-ultra-increase-vddcpu_a-voltag.patch b/projects/Amlogic/patches/linux/S922X/0019-arm64-meson-odroid-go-ultra-increase-vddcpu_a-voltag.patch deleted file mode 100644 index 37753b609e..0000000000 --- a/projects/Amlogic/patches/linux/S922X/0019-arm64-meson-odroid-go-ultra-increase-vddcpu_a-voltag.patch +++ /dev/null @@ -1,26 +0,0 @@ -From f458965deba2fe8133b686ec7edae7df42a98e4a Mon Sep 17 00:00:00 2001 -From: adamg -Date: Thu, 25 Jan 2024 00:32:40 +0000 -Subject: [PATCH 19/46] arm64: meson: odroid-go-ultra: increase vddcpu_a - voltage for overclock - ---- - arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -index 40820c49aacc..05b3f3fe3867 100644 ---- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -@@ -418,7 +418,7 @@ vddcpu_a: DCDC_REG1 { - regulator-always-on; - regulator-boot-on; - regulator-min-microvolt = <775000>; -- regulator-max-microvolt = <1025000>; -+ regulator-max-microvolt = <1050000>; - regulator-ramp-delay = <6001>; - regulator-state-mem { - regulator-on-in-suspend; --- -2.34.1 - diff --git a/projects/Amlogic/patches/linux/S922X/0023-power-supply-rk818-charger-Implement-charger-driver-.patch b/projects/Amlogic/patches/linux/S922X/0019-power-supply-rk818-charger-Implement-charger-driver-.patch similarity index 97% rename from projects/Amlogic/patches/linux/S922X/0023-power-supply-rk818-charger-Implement-charger-driver-.patch rename to projects/Amlogic/patches/linux/S922X/0019-power-supply-rk818-charger-Implement-charger-driver-.patch index 40d4c6c137..f6658a6b7a 100644 --- a/projects/Amlogic/patches/linux/S922X/0023-power-supply-rk818-charger-Implement-charger-driver-.patch +++ b/projects/Amlogic/patches/linux/S922X/0019-power-supply-rk818-charger-Implement-charger-driver-.patch @@ -1,7 +1,7 @@ -From 17b6fcf4a10b4f874bc3e82004002f353f6f641d Mon Sep 17 00:00:00 2001 +From e642f1bae35b8ab7f6db133d152e424bb1913e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= Date: Sun, 7 Nov 2021 20:09:02 +0100 -Subject: [PATCH 23/46] power: supply: rk818-charger: Implement charger driver +Subject: [PATCH 19/44] power: supply: rk818-charger: Implement charger driver for RK818 PMIC For now this driver is just meant to watch Type-C power supply @@ -12,15 +12,15 @@ Signed-off-by: Ondrej Jirman --- drivers/power/supply/Kconfig | 8 + drivers/power/supply/Makefile | 1 + - drivers/power/supply/rk818_charger.c | 650 +++++++++++++++++++++++++++ - 3 files changed, 659 insertions(+) + drivers/power/supply/rk818_charger.c | 651 +++++++++++++++++++++++++++ + 3 files changed, 660 insertions(+) create mode 100644 drivers/power/supply/rk818_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig -index 1722fc1ee7ec..a8f03555188f 100644 +index 6ad47fe5f089..7813b6e057fd 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig -@@ -1001,4 +1001,12 @@ config BATTERY_RK818 +@@ -993,4 +993,12 @@ config BATTERY_RK818 If you say yes here you will get support for the battery of RK818 PMIC. This driver can give support for Rk818 Battery Charge Interface. @@ -44,10 +44,10 @@ index aa3de47be2c5..5a2480aca754 100644 +obj-$(CONFIG_CHARGER_RK818) += rk818_charger.o diff --git a/drivers/power/supply/rk818_charger.c b/drivers/power/supply/rk818_charger.c new file mode 100644 -index 000000000000..00fe5d8f4785 +index 000000000000..7b4dd9291d3e --- /dev/null +++ b/drivers/power/supply/rk818_charger.c -@@ -0,0 +1,650 @@ +@@ -0,0 +1,651 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * rk818 usb power driver @@ -57,6 +57,7 @@ index 000000000000..00fe5d8f4785 +#include +#include +#include ++#include +#include +#include +#include diff --git a/projects/Amlogic/patches/linux/S922X/0024-power-supply-rk818-charger-Change-charger-type-to-MA.patch b/projects/Amlogic/patches/linux/S922X/0020-power-supply-rk818-charger-Change-charger-type-to-MA.patch similarity index 77% rename from projects/Amlogic/patches/linux/S922X/0024-power-supply-rk818-charger-Change-charger-type-to-MA.patch rename to projects/Amlogic/patches/linux/S922X/0020-power-supply-rk818-charger-Change-charger-type-to-MA.patch index 57c274c2d1..b4aa028a6a 100644 --- a/projects/Amlogic/patches/linux/S922X/0024-power-supply-rk818-charger-Change-charger-type-to-MA.patch +++ b/projects/Amlogic/patches/linux/S922X/0020-power-supply-rk818-charger-Change-charger-type-to-MA.patch @@ -1,7 +1,7 @@ -From 33c88091c655b914399d61612dfc72e732bf6aaf Mon Sep 17 00:00:00 2001 +From 3c1508046c0054680475d856f461af47e47b7a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= Date: Thu, 13 Jan 2022 13:53:03 +0100 -Subject: [PATCH 24/46] power: supply: rk818-charger: Change charger type to +Subject: [PATCH 20/44] power: supply: rk818-charger: Change charger type to MAINS To un-confuse userspace. @@ -12,10 +12,10 @@ Signed-off-by: Ondrej Jirman 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/rk818_charger.c b/drivers/power/supply/rk818_charger.c -index 00fe5d8f4785..6a9f2d1a7086 100644 +index 7b4dd9291d3e..27574c061f83 100644 --- a/drivers/power/supply/rk818_charger.c +++ b/drivers/power/supply/rk818_charger.c -@@ -535,7 +535,7 @@ static enum power_supply_property rk818_charger_props[] = { +@@ -536,7 +536,7 @@ static enum power_supply_property rk818_charger_props[] = { */ static const struct power_supply_desc rk818_charger_desc = { .name = "rk818-charger", diff --git a/projects/Amlogic/patches/linux/S922X/0025-power-supply-rk818-battery-Report-charging-status-ba.patch b/projects/Amlogic/patches/linux/S922X/0021-power-supply-rk818-battery-Report-charging-status-ba.patch similarity index 94% rename from projects/Amlogic/patches/linux/S922X/0025-power-supply-rk818-battery-Report-charging-status-ba.patch rename to projects/Amlogic/patches/linux/S922X/0021-power-supply-rk818-battery-Report-charging-status-ba.patch index d9abcd9c99..2ad37fdf7c 100644 --- a/projects/Amlogic/patches/linux/S922X/0025-power-supply-rk818-battery-Report-charging-status-ba.patch +++ b/projects/Amlogic/patches/linux/S922X/0021-power-supply-rk818-battery-Report-charging-status-ba.patch @@ -1,7 +1,7 @@ -From dd940ddcaad239f4f5ec159e71953c76a6a12ac1 Mon Sep 17 00:00:00 2001 +From c1f960ec0b5e110aa7029b147d070114902e37ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= Date: Fri, 21 Jan 2022 11:38:00 +0100 -Subject: [PATCH 25/46] power: supply: rk818-battery: Report charging status +Subject: [PATCH 21/44] power: supply: rk818-battery: Report charging status based on charging current If the current is positive, battery is charging, if negative the battery diff --git a/projects/Amlogic/patches/linux/S922X/0026-power-supply-rk818-battery-Drop-dependency-on-frameb.patch b/projects/Amlogic/patches/linux/S922X/0022-power-supply-rk818-battery-Drop-dependency-on-frameb.patch similarity index 97% rename from projects/Amlogic/patches/linux/S922X/0026-power-supply-rk818-battery-Drop-dependency-on-frameb.patch rename to projects/Amlogic/patches/linux/S922X/0022-power-supply-rk818-battery-Drop-dependency-on-frameb.patch index c5f1bb8987..4409088300 100644 --- a/projects/Amlogic/patches/linux/S922X/0026-power-supply-rk818-battery-Drop-dependency-on-frameb.patch +++ b/projects/Amlogic/patches/linux/S922X/0022-power-supply-rk818-battery-Drop-dependency-on-frameb.patch @@ -1,7 +1,7 @@ -From 8e8f25514fa165c84614552edccbee47a2ea5892 Mon Sep 17 00:00:00 2001 +From 7c930b83aee90136a3061bdd0626f3a75c42a357 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Tue, 17 May 2022 23:30:46 +0200 -Subject: [PATCH 26/46] power: supply: rk818-battery: Drop dependency on +Subject: [PATCH 22/44] power: supply: rk818-battery: Drop dependency on framebuffer It was bizarre anyway. Framebuffer is barely used on Linux anyway, diff --git a/projects/Amlogic/patches/linux/S922X/0027-power-supply-rk818-charger-Unify-rk818-charger-and-r.patch b/projects/Amlogic/patches/linux/S922X/0023-power-supply-rk818-charger-Unify-rk818-charger-and-r.patch similarity index 93% rename from projects/Amlogic/patches/linux/S922X/0027-power-supply-rk818-charger-Unify-rk818-charger-and-r.patch rename to projects/Amlogic/patches/linux/S922X/0023-power-supply-rk818-charger-Unify-rk818-charger-and-r.patch index 8e488b2672..3ef5b7c8d7 100644 --- a/projects/Amlogic/patches/linux/S922X/0027-power-supply-rk818-charger-Unify-rk818-charger-and-r.patch +++ b/projects/Amlogic/patches/linux/S922X/0023-power-supply-rk818-charger-Unify-rk818-charger-and-r.patch @@ -1,7 +1,7 @@ -From 296659e7939fc45907c35699482261f0cc33d8f0 Mon Sep 17 00:00:00 2001 +From 6a15e3e0c411654229eef72be04a19a61bc6ef07 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Sat, 4 Nov 2023 18:25:03 +0100 -Subject: [PATCH 27/46] power: supply: rk818-charger: Unify rk818-charger and +Subject: [PATCH 23/44] power: supply: rk818-charger: Unify rk818-charger and rk818-battery The BSP driver is still used, but there is now a one device handling @@ -17,10 +17,10 @@ Signed-off-by: Ondrej Jirman 4 files changed, 95 insertions(+), 33 deletions(-) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig -index a8f03555188f..b058d033fbf4 100644 +index 7813b6e057fd..f8ef90ef48c0 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig -@@ -993,14 +993,6 @@ config FUEL_GAUGE_MM8013 +@@ -985,14 +985,6 @@ config FUEL_GAUGE_MM8013 the state of charge, temperature, cycle count, actual and design capacity, etc. @@ -145,10 +145,10 @@ index cc409b7aafb5..e0e5ed0e3d2a 100644 } diff --git a/drivers/power/supply/rk818_charger.c b/drivers/power/supply/rk818_charger.c -index 6a9f2d1a7086..16bc4686b547 100644 +index 27574c061f83..9cbb0790fe37 100644 --- a/drivers/power/supply/rk818_charger.c +++ b/drivers/power/supply/rk818_charger.c -@@ -355,14 +355,36 @@ static int rk818_charger_get_voltage_max(struct rk818_charger *cg, int *val) +@@ -356,14 +356,36 @@ static int rk818_charger_get_voltage_max(struct rk818_charger *cg, int *val) return 0; } @@ -185,7 +185,7 @@ index 6a9f2d1a7086..16bc4686b547 100644 switch (psp) { case POWER_SUPPLY_PROP_ONLINE: ret = regmap_read(cg->regmap, RK818_CHRG_CTRL_REG1, ®); -@@ -374,6 +396,20 @@ static int rk818_charger_get_property(struct power_supply *psy, +@@ -375,6 +397,20 @@ static int rk818_charger_get_property(struct power_supply *psy, val->intval = !!(reg & RK818_CHRG_CTRL_REG1_CHRG_EN); break; @@ -206,7 +206,7 @@ index 6a9f2d1a7086..16bc4686b547 100644 case POWER_SUPPLY_PROP_STATUS: ret = regmap_read(cg->regmap, RK818_SUP_STS_REG, ®); if (ret) -@@ -480,14 +516,18 @@ static int rk818_charger_set_property(struct power_supply *psy, +@@ -481,14 +517,18 @@ static int rk818_charger_set_property(struct power_supply *psy, int ret; switch (psp) { @@ -233,7 +233,7 @@ index 6a9f2d1a7086..16bc4686b547 100644 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: return rk818_charger_set_voltage_max(cg, val->intval); -@@ -506,7 +546,7 @@ static int rk818_charger_prop_writeable(struct power_supply *psy, +@@ -507,7 +547,7 @@ static int rk818_charger_prop_writeable(struct power_supply *psy, switch (psp) { case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: @@ -242,7 +242,7 @@ index 6a9f2d1a7086..16bc4686b547 100644 return 1; default: -@@ -518,6 +558,7 @@ static enum power_supply_property rk818_charger_props[] = { +@@ -519,6 +559,7 @@ static enum power_supply_property rk818_charger_props[] = { POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_STATUS, @@ -250,7 +250,7 @@ index 6a9f2d1a7086..16bc4686b547 100644 POWER_SUPPLY_PROP_CHARGE_TYPE, POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT, POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, -@@ -525,17 +566,25 @@ static enum power_supply_property rk818_charger_props[] = { +@@ -526,17 +567,25 @@ static enum power_supply_property rk818_charger_props[] = { POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, POWER_SUPPLY_PROP_PRECHARGE_CURRENT, diff --git a/projects/Amlogic/patches/linux/S922X/0028-power-supply-rk818-battery-Speed-up-battery-current-.patch b/projects/Amlogic/patches/linux/S922X/0024-power-supply-rk818-battery-Speed-up-battery-current-.patch similarity index 90% rename from projects/Amlogic/patches/linux/S922X/0028-power-supply-rk818-battery-Speed-up-battery-current-.patch rename to projects/Amlogic/patches/linux/S922X/0024-power-supply-rk818-battery-Speed-up-battery-current-.patch index 9cecfaea9f..905cd5df8e 100644 --- a/projects/Amlogic/patches/linux/S922X/0028-power-supply-rk818-battery-Speed-up-battery-current-.patch +++ b/projects/Amlogic/patches/linux/S922X/0024-power-supply-rk818-battery-Speed-up-battery-current-.patch @@ -1,7 +1,7 @@ -From 01df628df972b57febba04e26bcd74525b02003c Mon Sep 17 00:00:00 2001 +From a2d1c9fda708dfae3576bfdf68d296d83525422c Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Fri, 27 May 2022 03:07:54 +0200 -Subject: [PATCH 28/46] power: supply: rk818-battery: Speed up battery current +Subject: [PATCH 24/44] power: supply: rk818-battery: Speed up battery current readout PMIC does averaging, driver does averaging on top of that averaging, diff --git a/projects/Amlogic/patches/linux/S922X/0029-power-supply-rk818-charger-Delay-applying-input-curr.patch b/projects/Amlogic/patches/linux/S922X/0025-power-supply-rk818-charger-Delay-applying-input-curr.patch similarity index 83% rename from projects/Amlogic/patches/linux/S922X/0029-power-supply-rk818-charger-Delay-applying-input-curr.patch rename to projects/Amlogic/patches/linux/S922X/0025-power-supply-rk818-charger-Delay-applying-input-curr.patch index c12b53af9b..0c31d5ab94 100644 --- a/projects/Amlogic/patches/linux/S922X/0029-power-supply-rk818-charger-Delay-applying-input-curr.patch +++ b/projects/Amlogic/patches/linux/S922X/0025-power-supply-rk818-charger-Delay-applying-input-curr.patch @@ -1,7 +1,7 @@ -From 7eae5e22e808f21aba911c5ddcae545957a02143 Mon Sep 17 00:00:00 2001 +From fc405dd4c01211adc53a264b3a7f36be33164d89 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Tue, 2 Aug 2022 09:37:05 +0200 -Subject: [PATCH 29/46] power: supply: rk818-charger: Delay applying input +Subject: [PATCH 25/44] power: supply: rk818-charger: Delay applying input current limit until first BC detection finishes When the phone boots for the first time, we only want to react to @@ -18,10 +18,10 @@ Signed-off-by: Ondrej Jirman 1 file changed, 17 insertions(+) diff --git a/drivers/power/supply/rk818_charger.c b/drivers/power/supply/rk818_charger.c -index 16bc4686b547..979165c98e5a 100644 +index 9cbb0790fe37..41e2cbd5ecc2 100644 --- a/drivers/power/supply/rk818_charger.c +++ b/drivers/power/supply/rk818_charger.c -@@ -51,6 +51,8 @@ struct rk818_charger { +@@ -52,6 +52,8 @@ struct rk818_charger { struct power_supply *usb_psy; struct power_supply *charger_psy; @@ -30,7 +30,7 @@ index 16bc4686b547..979165c98e5a 100644 }; // {{{ USB supply -@@ -72,6 +74,8 @@ static int rk818_usb_set_input_current_max(struct rk818_charger *cg, +@@ -73,6 +75,8 @@ static int rk818_usb_set_input_current_max(struct rk818_charger *cg, else reg = 11; @@ -39,7 +39,7 @@ index 16bc4686b547..979165c98e5a 100644 ret = regmap_update_bits(cg->regmap, RK818_USB_CTRL_REG, RK818_USB_CTRL_USB_ILIM_MASK, reg); if (ret) -@@ -242,6 +246,19 @@ static void rk818_usb_power_external_power_changed(struct power_supply *psy) +@@ -243,6 +247,19 @@ static void rk818_usb_power_external_power_changed(struct power_supply *psy) if (ret) return; diff --git a/projects/Amlogic/patches/linux/S922X/0030-power-supply-rk818-battery-Don-t-auto-poweroff-the-P.patch b/projects/Amlogic/patches/linux/S922X/0026-power-supply-rk818-battery-Don-t-auto-poweroff-the-P.patch similarity index 94% rename from projects/Amlogic/patches/linux/S922X/0030-power-supply-rk818-battery-Don-t-auto-poweroff-the-P.patch rename to projects/Amlogic/patches/linux/S922X/0026-power-supply-rk818-battery-Don-t-auto-poweroff-the-P.patch index 8b64fd361a..15c67627a6 100644 --- a/projects/Amlogic/patches/linux/S922X/0030-power-supply-rk818-battery-Don-t-auto-poweroff-the-P.patch +++ b/projects/Amlogic/patches/linux/S922X/0026-power-supply-rk818-battery-Don-t-auto-poweroff-the-P.patch @@ -1,7 +1,7 @@ -From c579cce2425152fd0b8e4ae2d3d89175fd1fa4b3 Mon Sep 17 00:00:00 2001 +From f869d08e5c748e58cd0a14122d64301dac62b9b2 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Thu, 10 Nov 2022 20:03:47 +0100 -Subject: [PATCH 30/46] power: supply: rk818-battery: Don't auto-poweroff the +Subject: [PATCH 26/44] power: supply: rk818-battery: Don't auto-poweroff the PMIC on low battery Just raise the interrupt. This avoids undervoltage shutdowns when diff --git a/projects/Amlogic/patches/linux/S922X/0031-power-supply-rk818-charger-Add-support-for-POWER_SUP.patch b/projects/Amlogic/patches/linux/S922X/0027-power-supply-rk818-charger-Add-support-for-POWER_SUP.patch similarity index 77% rename from projects/Amlogic/patches/linux/S922X/0031-power-supply-rk818-charger-Add-support-for-POWER_SUP.patch rename to projects/Amlogic/patches/linux/S922X/0027-power-supply-rk818-charger-Add-support-for-POWER_SUP.patch index 348870f331..d26ba37829 100644 --- a/projects/Amlogic/patches/linux/S922X/0031-power-supply-rk818-charger-Add-support-for-POWER_SUP.patch +++ b/projects/Amlogic/patches/linux/S922X/0027-power-supply-rk818-charger-Add-support-for-POWER_SUP.patch @@ -1,7 +1,7 @@ -From f0ac6909515be6bec3d65d148360ed8045fa876d Mon Sep 17 00:00:00 2001 +From 2a71f1bbe3a392604aa153853d76df8170800df9 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Thu, 10 Nov 2022 20:05:16 +0100 -Subject: [PATCH 31/46] power: supply: rk818-charger: Add support for +Subject: [PATCH 27/44] power: supply: rk818-charger: Add support for POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN Report total battery capacity. @@ -12,10 +12,10 @@ Signed-off-by: Ondrej Jirman 1 file changed, 10 insertions(+) diff --git a/drivers/power/supply/rk818_charger.c b/drivers/power/supply/rk818_charger.c -index 979165c98e5a..cdef0dcd1f8c 100644 +index 41e2cbd5ecc2..7674c6398a4d 100644 --- a/drivers/power/supply/rk818_charger.c +++ b/drivers/power/supply/rk818_charger.c -@@ -518,6 +518,14 @@ static int rk818_charger_get_property(struct power_supply *psy, +@@ -519,6 +519,14 @@ static int rk818_charger_get_property(struct power_supply *psy, val->intval = 3000000; break; @@ -30,7 +30,7 @@ index 979165c98e5a..cdef0dcd1f8c 100644 default: return -EINVAL; } -@@ -583,6 +591,8 @@ static enum power_supply_property rk818_charger_props[] = { +@@ -584,6 +592,8 @@ static enum power_supply_property rk818_charger_props[] = { POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, POWER_SUPPLY_PROP_PRECHARGE_CURRENT, diff --git a/projects/Amlogic/patches/linux/S922X/0032-power-supply-rk818-battery-Don-t-reset-dsoc-to-0-on-.patch b/projects/Amlogic/patches/linux/S922X/0028-power-supply-rk818-battery-Don-t-reset-dsoc-to-0-on-.patch similarity index 86% rename from projects/Amlogic/patches/linux/S922X/0032-power-supply-rk818-battery-Don-t-reset-dsoc-to-0-on-.patch rename to projects/Amlogic/patches/linux/S922X/0028-power-supply-rk818-battery-Don-t-reset-dsoc-to-0-on-.patch index 927564afe6..f5d7d887e9 100644 --- a/projects/Amlogic/patches/linux/S922X/0032-power-supply-rk818-battery-Don-t-reset-dsoc-to-0-on-.patch +++ b/projects/Amlogic/patches/linux/S922X/0028-power-supply-rk818-battery-Don-t-reset-dsoc-to-0-on-.patch @@ -1,7 +1,7 @@ -From 76efdf8fea4958c153da561eccc69911c3bb68c6 Mon Sep 17 00:00:00 2001 +From a4ca64019fc8d430163729a93cee36fff199492f Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Sun, 11 Dec 2022 10:39:22 +0100 -Subject: [PATCH 32/46] power: supply: rk818-battery: Don't reset dsoc to 0 on +Subject: [PATCH 28/44] power: supply: rk818-battery: Don't reset dsoc to 0 on rk818_vb_low_irq The interrupt fires at 3.4V vbat which is not equivalent to 0% charge. diff --git a/projects/Amlogic/patches/linux/S922X/0033-supply-rk817-Fix-battery-capacity-sanity-check-calcu.patch b/projects/Amlogic/patches/linux/S922X/0029-supply-rk817-Fix-battery-capacity-sanity-check-calcu.patch similarity index 91% rename from projects/Amlogic/patches/linux/S922X/0033-supply-rk817-Fix-battery-capacity-sanity-check-calcu.patch rename to projects/Amlogic/patches/linux/S922X/0029-supply-rk817-Fix-battery-capacity-sanity-check-calcu.patch index c65610dc6b..3ebc673930 100644 --- a/projects/Amlogic/patches/linux/S922X/0033-supply-rk817-Fix-battery-capacity-sanity-check-calcu.patch +++ b/projects/Amlogic/patches/linux/S922X/0029-supply-rk817-Fix-battery-capacity-sanity-check-calcu.patch @@ -1,7 +1,7 @@ -From cf94fe4688b273996b71363f1fb231e06d0cb5d8 Mon Sep 17 00:00:00 2001 +From f8588c99783f2aa80679d1b47f058a80994efb38 Mon Sep 17 00:00:00 2001 From: Alexander Warnecke Date: Thu, 29 Jun 2023 19:52:42 +1000 -Subject: [PATCH 33/46] supply: rk817: Fix battery capacity sanity check +Subject: [PATCH 29/44] supply: rk817: Fix battery capacity sanity check calculation If the nvram variable is corrupted in a way that multiplying it by 1000 causes an integer overflow and wraps around to a number within or below the sanity check bounds, the check fails and capacity is reported incorrectly. diff --git a/projects/Amlogic/patches/linux/S922X/0034-power-supply-rk817-charger-Add-input-current-limit-s.patch b/projects/Amlogic/patches/linux/S922X/0030-power-supply-rk817-charger-Add-input-current-limit-s.patch similarity index 97% rename from projects/Amlogic/patches/linux/S922X/0034-power-supply-rk817-charger-Add-input-current-limit-s.patch rename to projects/Amlogic/patches/linux/S922X/0030-power-supply-rk817-charger-Add-input-current-limit-s.patch index 547fd2e405..d1169a0549 100644 --- a/projects/Amlogic/patches/linux/S922X/0034-power-supply-rk817-charger-Add-input-current-limit-s.patch +++ b/projects/Amlogic/patches/linux/S922X/0030-power-supply-rk817-charger-Add-input-current-limit-s.patch @@ -1,7 +1,7 @@ -From 3ba20bb0db91508bc7b31222fff1e4b67b57064b Mon Sep 17 00:00:00 2001 +From 6c89b0c7be95632079c3b63954248bac6190d3bc Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Sun, 6 Aug 2023 02:55:22 +0200 -Subject: [PATCH 34/46] power: supply: rk817-charger: Add input current limit +Subject: [PATCH 30/44] power: supply: rk817-charger: Add input current limit setting This is useful for proper USB input current limiting. diff --git a/projects/Amlogic/patches/linux/S922X/0035-power-supply-rk817-charger-Take-input-current-limit-.patch b/projects/Amlogic/patches/linux/S922X/0031-power-supply-rk817-charger-Take-input-current-limit-.patch similarity index 95% rename from projects/Amlogic/patches/linux/S922X/0035-power-supply-rk817-charger-Take-input-current-limit-.patch rename to projects/Amlogic/patches/linux/S922X/0031-power-supply-rk817-charger-Take-input-current-limit-.patch index d046c16f5a..0d509a8588 100644 --- a/projects/Amlogic/patches/linux/S922X/0035-power-supply-rk817-charger-Take-input-current-limit-.patch +++ b/projects/Amlogic/patches/linux/S922X/0031-power-supply-rk817-charger-Take-input-current-limit-.patch @@ -1,7 +1,7 @@ -From 5e811764c0ef6663312887dcef339b3d098740b1 Mon Sep 17 00:00:00 2001 +From 3c8b1445f2997c7913609430eee8d30856fa2e13 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Thu, 7 Sep 2023 17:37:59 +0200 -Subject: [PATCH 35/46] power: supply: rk817-charger: Take input current limit +Subject: [PATCH 31/44] power: supply: rk817-charger: Take input current limit from parent supply This allows automatic input current limit setting based on USB PD. diff --git a/projects/Amlogic/patches/linux/S922X/0036-power-supply-rk817-charger-Propagate-proper-errors.patch b/projects/Amlogic/patches/linux/S922X/0032-power-supply-rk817-charger-Propagate-proper-errors.patch similarity index 90% rename from projects/Amlogic/patches/linux/S922X/0036-power-supply-rk817-charger-Propagate-proper-errors.patch rename to projects/Amlogic/patches/linux/S922X/0032-power-supply-rk817-charger-Propagate-proper-errors.patch index da66de954e..15f31962fe 100644 --- a/projects/Amlogic/patches/linux/S922X/0036-power-supply-rk817-charger-Propagate-proper-errors.patch +++ b/projects/Amlogic/patches/linux/S922X/0032-power-supply-rk817-charger-Propagate-proper-errors.patch @@ -1,7 +1,7 @@ -From 115389a51176825c504ff8b14da3989f02a3b8fc Mon Sep 17 00:00:00 2001 +From c9413ff87ad76b2384cf9031510f819e586fae71 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Thu, 7 Sep 2023 17:43:00 +0200 -Subject: [PATCH 36/46] power: supply: rk817-charger: Propagate proper errors +Subject: [PATCH 32/44] power: supply: rk817-charger: Propagate proper errors Without propagating the correct error code, defered probe doesn't work. diff --git a/projects/Amlogic/patches/linux/S922X/0033-power-supply-rk817-charger-Add-support-for-runtime-c.patch b/projects/Amlogic/patches/linux/S922X/0033-power-supply-rk817-charger-Add-support-for-runtime-c.patch new file mode 100644 index 0000000000..5439370abe --- /dev/null +++ b/projects/Amlogic/patches/linux/S922X/0033-power-supply-rk817-charger-Add-support-for-runtime-c.patch @@ -0,0 +1,167 @@ +From b4612269aff943bce08b81ddd72707cbaebb36d9 Mon Sep 17 00:00:00 2001 +From: Ondrej Jirman +Date: Sat, 13 Jan 2024 16:41:44 +0100 +Subject: [PATCH 33/44] power: supply: rk817-charger: Add support for runtime + change of charger limits + +This is useful for speeding up, or slowing down charging or for dealing +with lesser quality PSUs or cabling. + +Signed-off-by: Ondrej Jirman +--- + drivers/power/supply/rk817_charger.c | 86 +++++++++++++++++++++++++++- + 1 file changed, 85 insertions(+), 1 deletion(-) + +diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c +index 241fff9bc2ab..d7acb998a140 100644 +--- a/drivers/power/supply/rk817_charger.c ++++ b/drivers/power/supply/rk817_charger.c +@@ -557,6 +557,69 @@ static int rk817_bat_get_prop(struct power_supply *ps, + return 0; + } + ++static int rk817_battery_prop_writeable(struct power_supply *psy, ++ enum power_supply_property psp) ++{ ++ switch (psp) { ++ case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: ++ case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: ++ return 1; ++ default: ++ return 0; ++ } ++} ++ ++static int rk817_bat_set_prop(struct power_supply *ps, ++ enum power_supply_property prop, ++ const union power_supply_propval *val) ++{ ++ struct rk817_charger *charger = power_supply_get_drvdata(ps); ++ int ret, reg; ++ ++ switch (prop) { ++ case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: ++ reg = rk817_chg_cur_to_reg(val->intval / 1000); ++ if (reg < 0) { ++ dev_err(charger->dev, ++ "invalid max charger current, value %d unsupported\n", ++ val->intval); ++ return -EINVAL; ++ } ++ ++ ret = regmap_write_bits(charger->rk808->regmap, RK817_PMIC_CHRG_OUT, ++ RK817_CHRG_CUR_SEL, reg); ++ if (ret) { ++ dev_err(charger->dev, ++ "Unable to set max charger current (%d)\n", ret); ++ return ret; ++ } ++ break; ++ case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: ++ reg = (val->intval / 1000 - 4100) / 50; ++ if (reg < 0 || reg > 7) { ++ dev_err(charger->dev, ++ "invalid max charger voltage, value %d unsupported\n", ++ val->intval); ++ return -EINVAL; ++ } ++ ++ ret = regmap_write_bits(charger->rk808->regmap, RK817_PMIC_CHRG_OUT, ++ RK817_CHRG_VOL_SEL, (reg << 4)); ++ if (ret) { ++ dev_err(charger->dev, ++ "Unable to set max charger voltage (%d)\n", ret); ++ return ret; ++ } ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ cancel_delayed_work_sync(&charger->work); ++ queue_delayed_work(system_wq, &charger->work, msecs_to_jiffies(50)); ++ return 0; ++} ++ + static const int rk817_usb_input_current_limits[] = { + 1, 80000, + 0, 450000, +@@ -622,6 +685,7 @@ static int rk817_chg_get_prop(struct power_supply *ps, + union power_supply_propval *val) + { + struct rk817_charger *charger = power_supply_get_drvdata(ps); ++ unsigned int reg; + int ret; + + switch (prop) { +@@ -644,6 +708,13 @@ static int rk817_chg_get_prop(struct power_supply *ps, + if (ret) + return ret; + break; ++ case POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT: ++ ret = regmap_read(charger->rk808->regmap, RK817_PMIC_CHRG_IN, ®); ++ if (ret < 0) ++ return ret; ++ ++ val->intval = 4000000 + 100000 * ((reg & RK817_USB_VLIM_SEL) >> 4); ++ break; + /* + * While it's possible that other implementations could use different + * USB types, the current implementation for this PMIC (the Odroid Go +@@ -663,7 +734,7 @@ static int rk817_chg_set_prop(struct power_supply *ps, + const union power_supply_propval *val) + { + struct rk817_charger *charger = power_supply_get_drvdata(ps); +- int ret; ++ int ret, reg; + + switch (prop) { + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: +@@ -671,9 +742,18 @@ static int rk817_chg_set_prop(struct power_supply *ps, + if (ret) + return ret; + break; ++ case POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT: ++ // 0 = 4.0V - 7 = 4.7V, 0.1V step ++ reg = (clamp(val->intval, 4000000, 4700000) - 4000000) / 100000; ++ ret = regmap_write_bits(charger->rk808->regmap, RK817_PMIC_CHRG_IN, ++ RK817_USB_VLIM_SEL, (reg << 4)); ++ if (ret) ++ return ret; ++ break; + default: + return -EINVAL; + } ++ + return 0; + + } +@@ -762,6 +842,7 @@ static int rk817_charger_prop_writeable(struct power_supply *psy, + { + switch (psp) { + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: ++ case POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT: + return 1; + default: + return 0; +@@ -792,6 +873,7 @@ static enum power_supply_property rk817_chg_props[] = { + POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, + POWER_SUPPLY_PROP_VOLTAGE_AVG, + POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, ++ POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT, + }; + + static enum power_supply_usb_type rk817_usb_type[] = { +@@ -804,7 +886,9 @@ static const struct power_supply_desc rk817_bat_desc = { + .type = POWER_SUPPLY_TYPE_BATTERY, + .properties = rk817_bat_props, + .num_properties = ARRAY_SIZE(rk817_bat_props), ++ .property_is_writeable = rk817_battery_prop_writeable, + .get_property = rk817_bat_get_prop, ++ .set_property = rk817_bat_set_prop, + }; + + static const struct power_supply_desc rk817_chg_desc = { +-- +2.34.1 + diff --git a/projects/Amlogic/patches/linux/S922X/0037-power-supply-rk818-battery-charger-clear-unused-vari.patch b/projects/Amlogic/patches/linux/S922X/0034-power-supply-rk818-battery-charger-clear-unused-vari.patch similarity index 83% rename from projects/Amlogic/patches/linux/S922X/0037-power-supply-rk818-battery-charger-clear-unused-vari.patch rename to projects/Amlogic/patches/linux/S922X/0034-power-supply-rk818-battery-charger-clear-unused-vari.patch index f611099f2f..84737ab005 100644 --- a/projects/Amlogic/patches/linux/S922X/0037-power-supply-rk818-battery-charger-clear-unused-vari.patch +++ b/projects/Amlogic/patches/linux/S922X/0034-power-supply-rk818-battery-charger-clear-unused-vari.patch @@ -1,7 +1,7 @@ -From 57a68c4f0858e698587b8cd580242c16dfaa76a8 Mon Sep 17 00:00:00 2001 +From 37f568856e1139a8304d975318e8297c7d82a1fe Mon Sep 17 00:00:00 2001 From: "Mauro (mdrjr) Ribeiro" Date: Wed, 31 Jan 2024 11:59:50 -0300 -Subject: [PATCH 37/46] power: supply: rk818-battery/charger: clear unused +Subject: [PATCH 34/44] power: supply: rk818-battery/charger: clear unused variables --- @@ -23,10 +23,10 @@ index b62d59a4b228..ac8369f09d3e 100644 di->s2r = true; di->current_avg = rk818_bat_get_avg_current(di); diff --git a/drivers/power/supply/rk818_charger.c b/drivers/power/supply/rk818_charger.c -index cdef0dcd1f8c..a081fdfee31d 100644 +index 7674c6398a4d..09fe6e02215a 100644 --- a/drivers/power/supply/rk818_charger.c +++ b/drivers/power/supply/rk818_charger.c -@@ -538,7 +538,6 @@ static int rk818_charger_set_property(struct power_supply *psy, +@@ -539,7 +539,6 @@ static int rk818_charger_set_property(struct power_supply *psy, const union power_supply_propval *val) { struct rk818_charger *cg = power_supply_get_drvdata(psy); diff --git a/projects/Amlogic/patches/linux/S922X/0038-arm64-meson-odroid-go-ultra-add-battery-and-charger-.patch b/projects/Amlogic/patches/linux/S922X/0035-arm64-meson-odroid-go-ultra-add-battery-and-charger-.patch similarity index 93% rename from projects/Amlogic/patches/linux/S922X/0038-arm64-meson-odroid-go-ultra-add-battery-and-charger-.patch rename to projects/Amlogic/patches/linux/S922X/0035-arm64-meson-odroid-go-ultra-add-battery-and-charger-.patch index 956266e6f9..8e74f25a48 100644 --- a/projects/Amlogic/patches/linux/S922X/0038-arm64-meson-odroid-go-ultra-add-battery-and-charger-.patch +++ b/projects/Amlogic/patches/linux/S922X/0035-arm64-meson-odroid-go-ultra-add-battery-and-charger-.patch @@ -1,7 +1,7 @@ -From 49332adc404ceffba5c7fb17fcd42b54bd6d8c1e Mon Sep 17 00:00:00 2001 +From 6339706441d1479708df3294877d55b6805cdcc2 Mon Sep 17 00:00:00 2001 From: "Mauro (mdrjr) Ribeiro" Date: Wed, 31 Jan 2024 18:36:49 +0000 -Subject: [PATCH 38/46] arm64: meson: odroid-go-ultra: add battery and charger +Subject: [PATCH 35/44] arm64: meson: odroid-go-ultra: add battery and charger nodes --- @@ -9,7 +9,7 @@ Subject: [PATCH 38/46] arm64: meson: odroid-go-ultra: add battery and charger 1 file changed, 52 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -index 05b3f3fe3867..fd87e386a160 100644 +index 1d26387776e6..f45991a499c3 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts +++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts @@ -25,6 +25,26 @@ chosen { diff --git a/projects/Amlogic/patches/linux/S922X/0039-ASoC-meson-axg-card-limit-the-volume-to-prevent-clip.patch b/projects/Amlogic/patches/linux/S922X/0036-ASoC-meson-axg-card-limit-the-volume-to-prevent-clip.patch similarity index 87% rename from projects/Amlogic/patches/linux/S922X/0039-ASoC-meson-axg-card-limit-the-volume-to-prevent-clip.patch rename to projects/Amlogic/patches/linux/S922X/0036-ASoC-meson-axg-card-limit-the-volume-to-prevent-clip.patch index da04c35692..ffaa62810f 100644 --- a/projects/Amlogic/patches/linux/S922X/0039-ASoC-meson-axg-card-limit-the-volume-to-prevent-clip.patch +++ b/projects/Amlogic/patches/linux/S922X/0036-ASoC-meson-axg-card-limit-the-volume-to-prevent-clip.patch @@ -1,7 +1,7 @@ -From 3d72e4d9763088181128c655100b8c3e75e1058f Mon Sep 17 00:00:00 2001 +From 6f4ac5c34912fd8fe6b453e0e402a5dc8f4e64a4 Mon Sep 17 00:00:00 2001 From: ckkim Date: Thu, 20 Apr 2023 16:18:40 +0900 -Subject: [PATCH 39/46] ASoC: meson: axg-card: limit the volume to prevent +Subject: [PATCH 36/44] ASoC: meson: axg-card: limit the volume to prevent clipping of output signal --- diff --git a/projects/Amlogic/patches/linux/S922X/0040-power-supply-rk818_charger-change-syfs-node-name-so-.patch b/projects/Amlogic/patches/linux/S922X/0037-power-supply-rk818_charger-change-syfs-node-name-so-.patch similarity index 70% rename from projects/Amlogic/patches/linux/S922X/0040-power-supply-rk818_charger-change-syfs-node-name-so-.patch rename to projects/Amlogic/patches/linux/S922X/0037-power-supply-rk818_charger-change-syfs-node-name-so-.patch index 32e0bd7027..33c93d28ce 100644 --- a/projects/Amlogic/patches/linux/S922X/0040-power-supply-rk818_charger-change-syfs-node-name-so-.patch +++ b/projects/Amlogic/patches/linux/S922X/0037-power-supply-rk818_charger-change-syfs-node-name-so-.patch @@ -1,7 +1,7 @@ -From 8094cad398334bac76e0a3a723c95558c5d28097 Mon Sep 17 00:00:00 2001 -From: adamg +From c21702b1d3506071635539c0fd8bee17ffb272e3 Mon Sep 17 00:00:00 2001 +From: spycat88 Date: Wed, 31 Jan 2024 20:18:22 +0000 -Subject: [PATCH 40/46] power: supply: rk818_charger: change syfs node name so +Subject: [PATCH 37/44] power: supply: rk818_charger: change syfs node name so ES can read battery status --- @@ -9,10 +9,10 @@ Subject: [PATCH 40/46] power: supply: rk818_charger: change syfs node name so 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/rk818_charger.c b/drivers/power/supply/rk818_charger.c -index a081fdfee31d..6956d093c672 100644 +index 09fe6e02215a..af9b2efbc94e 100644 --- a/drivers/power/supply/rk818_charger.c +++ b/drivers/power/supply/rk818_charger.c -@@ -609,7 +609,7 @@ static enum power_supply_property rk818_charger_props[] = { +@@ -610,7 +610,7 @@ static enum power_supply_property rk818_charger_props[] = { * but not me, not now. :) */ static const struct power_supply_desc rk818_charger_desc = { diff --git a/projects/Amlogic/patches/linux/S922X/0041-arm64-meson-odroid-go-ultra-add-headphone-detection.patch b/projects/Amlogic/patches/linux/S922X/0038-arm64-meson-odroid-go-ultra-add-headphone-detection.patch similarity index 83% rename from projects/Amlogic/patches/linux/S922X/0041-arm64-meson-odroid-go-ultra-add-headphone-detection.patch rename to projects/Amlogic/patches/linux/S922X/0038-arm64-meson-odroid-go-ultra-add-headphone-detection.patch index d241cdfcd7..9bd0d76ecc 100644 --- a/projects/Amlogic/patches/linux/S922X/0041-arm64-meson-odroid-go-ultra-add-headphone-detection.patch +++ b/projects/Amlogic/patches/linux/S922X/0038-arm64-meson-odroid-go-ultra-add-headphone-detection.patch @@ -1,14 +1,14 @@ -From b5c924f1e9aa06c64d5f4e742bca3cdc6ff3d8fd Mon Sep 17 00:00:00 2001 +From 4b8d36069dbe393e882da689d1816ba241d087c3 Mon Sep 17 00:00:00 2001 From: "Mauro (mdrjr) Ribeiro" Date: Wed, 31 Jan 2024 20:56:40 +0000 -Subject: [PATCH 41/46] arm64: meson: odroid-go-ultra: add headphone detection +Subject: [PATCH 38/44] arm64: meson: odroid-go-ultra: add headphone detection --- .../arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -index fd87e386a160..228bc042d284 100644 +index f45991a499c3..9d6f3be69321 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts +++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts @@ -67,6 +67,14 @@ volume-down-button { diff --git a/projects/Amlogic/patches/linux/S922X/0042-arm64-dts-amlogic-odroid-go-ultra-Improve-sound-outp.patch b/projects/Amlogic/patches/linux/S922X/0039-arm64-dts-amlogic-odroid-go-ultra-Improve-sound-outp.patch similarity index 94% rename from projects/Amlogic/patches/linux/S922X/0042-arm64-dts-amlogic-odroid-go-ultra-Improve-sound-outp.patch rename to projects/Amlogic/patches/linux/S922X/0039-arm64-dts-amlogic-odroid-go-ultra-Improve-sound-outp.patch index 460bb6c1a4..75c507bb39 100644 --- a/projects/Amlogic/patches/linux/S922X/0042-arm64-dts-amlogic-odroid-go-ultra-Improve-sound-outp.patch +++ b/projects/Amlogic/patches/linux/S922X/0039-arm64-dts-amlogic-odroid-go-ultra-Improve-sound-outp.patch @@ -1,7 +1,7 @@ -From f369984b8aa72b523bcacca4ca8777727f691a32 Mon Sep 17 00:00:00 2001 +From b95234b4178cab46d6eb171c2a7cd56c242a3f74 Mon Sep 17 00:00:00 2001 From: ckkim Date: Thu, 20 Apr 2023 16:21:09 +0900 -Subject: [PATCH 42/46] arm64: dts: amlogic: odroid-go ultra: Improve sound +Subject: [PATCH 39/44] arm64: dts: amlogic: odroid-go ultra: Improve sound output quality --- @@ -9,7 +9,7 @@ Subject: [PATCH 42/46] arm64: dts: amlogic: odroid-go ultra: Improve sound 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts -index 228bc042d284..2a791145057c 100644 +index 9d6f3be69321..dd64c97df5bd 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts +++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-go-ultra.dts @@ -237,22 +237,9 @@ vdd_sys: regulator-vdd-sys { diff --git a/projects/Amlogic/patches/linux/S922X/0043-arm64-meson-g12-common-remove-lower-freq-gpu-opps.patch b/projects/Amlogic/patches/linux/S922X/0040-arm64-meson-g12-common-remove-lower-freq-gpu-opps.patch similarity index 88% rename from projects/Amlogic/patches/linux/S922X/0043-arm64-meson-g12-common-remove-lower-freq-gpu-opps.patch rename to projects/Amlogic/patches/linux/S922X/0040-arm64-meson-g12-common-remove-lower-freq-gpu-opps.patch index b922291ee3..a06ad50010 100644 --- a/projects/Amlogic/patches/linux/S922X/0043-arm64-meson-g12-common-remove-lower-freq-gpu-opps.patch +++ b/projects/Amlogic/patches/linux/S922X/0040-arm64-meson-g12-common-remove-lower-freq-gpu-opps.patch @@ -1,7 +1,7 @@ -From 02c115905fc0a36a98ff0ebec098112185f61f26 Mon Sep 17 00:00:00 2001 +From 184ec78821692f7a5c5b59f9e16df36d1959c4bd Mon Sep 17 00:00:00 2001 From: brooksytech <1673861+brooksytech@users.noreply.github.com> Date: Thu, 1 Feb 2024 19:03:03 +0000 -Subject: [PATCH 43/46] arm64: meson: g12-common: remove lower freq gpu opps +Subject: [PATCH 40/44] arm64: meson: g12-common: remove lower freq gpu opps --- arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 12 ------------ diff --git a/projects/Amlogic/patches/linux/S922X/0044-LOCAL-ALSA-Assign-internal-PCM-chmap-ELD-IEC958-kctl.patch b/projects/Amlogic/patches/linux/S922X/0041-LOCAL-ALSA-Assign-internal-PCM-chmap-ELD-IEC958-kctl.patch similarity index 94% rename from projects/Amlogic/patches/linux/S922X/0044-LOCAL-ALSA-Assign-internal-PCM-chmap-ELD-IEC958-kctl.patch rename to projects/Amlogic/patches/linux/S922X/0041-LOCAL-ALSA-Assign-internal-PCM-chmap-ELD-IEC958-kctl.patch index a513db4083..17b1082634 100644 --- a/projects/Amlogic/patches/linux/S922X/0044-LOCAL-ALSA-Assign-internal-PCM-chmap-ELD-IEC958-kctl.patch +++ b/projects/Amlogic/patches/linux/S922X/0041-LOCAL-ALSA-Assign-internal-PCM-chmap-ELD-IEC958-kctl.patch @@ -1,7 +1,7 @@ -From 20feee211d45148391b0a889ffa91d49bf02335f Mon Sep 17 00:00:00 2001 +From 83b4a5d121788f8ff47794dd945ac82cea346570 Mon Sep 17 00:00:00 2001 From: Anssi Hannula Date: Sun, 17 Apr 2022 04:37:48 +0000 -Subject: [PATCH 44/46] LOCAL: ALSA: Assign internal PCM chmap/ELD/IEC958 kctls +Subject: [PATCH 41/44] LOCAL: ALSA: Assign internal PCM chmap/ELD/IEC958 kctls to device 0 On SoC sound devices utilizing codec2codec DAI links with a HDMI codec diff --git a/projects/Amlogic/patches/linux/S922X/0045-arm64-meson-odroid-n2-add-support-for-overclocking.patch b/projects/Amlogic/patches/linux/S922X/0042-arm64-meson-odroid-n2-add-support-for-overclocking.patch similarity index 93% rename from projects/Amlogic/patches/linux/S922X/0045-arm64-meson-odroid-n2-add-support-for-overclocking.patch rename to projects/Amlogic/patches/linux/S922X/0042-arm64-meson-odroid-n2-add-support-for-overclocking.patch index 3251565bb4..4d28c3f633 100644 --- a/projects/Amlogic/patches/linux/S922X/0045-arm64-meson-odroid-n2-add-support-for-overclocking.patch +++ b/projects/Amlogic/patches/linux/S922X/0042-arm64-meson-odroid-n2-add-support-for-overclocking.patch @@ -1,7 +1,7 @@ -From 656950aff1e7958af62a2508d950de486fc2f4ea Mon Sep 17 00:00:00 2001 -From: adamg +From 56283996bde298454c0e83a6d8cafc232343b0f4 Mon Sep 17 00:00:00 2001 +From: spycat88 Date: Sun, 4 Feb 2024 09:48:31 +0000 -Subject: [PATCH 45/46] arm64: meson: odroid-n2*: add support for overclocking +Subject: [PATCH 42/44] arm64: meson: odroid-n2*: add support for overclocking --- .../dts/amlogic/meson-g12b-odroid-n2-plus.dts | 24 ++++++++++++++++++ diff --git a/projects/Amlogic/patches/linux/S922X/0047-power-reset-add-the-Powkiddy-RGB10-Max-3-Pro-to-the-.patch b/projects/Amlogic/patches/linux/S922X/0043-power-reset-add-the-Powkiddy-RGB10-Max-3-Pro-to-the-.patch similarity index 82% rename from projects/Amlogic/patches/linux/S922X/0047-power-reset-add-the-Powkiddy-RGB10-Max-3-Pro-to-the-.patch rename to projects/Amlogic/patches/linux/S922X/0043-power-reset-add-the-Powkiddy-RGB10-Max-3-Pro-to-the-.patch index 8c6e0a6503..a835542be1 100644 --- a/projects/Amlogic/patches/linux/S922X/0047-power-reset-add-the-Powkiddy-RGB10-Max-3-Pro-to-the-.patch +++ b/projects/Amlogic/patches/linux/S922X/0043-power-reset-add-the-Powkiddy-RGB10-Max-3-Pro-to-the-.patch @@ -1,15 +1,15 @@ -From db7441026e9bab24e537c74692020270ca61963e Mon Sep 17 00:00:00 2001 -From: salty cat +From 1ec813703b6ac258893753b9134c1c0856ac119a Mon Sep 17 00:00:00 2001 +From: spycat88 Date: Wed, 6 Mar 2024 19:40:45 +0000 -Subject: [PATCH] power: reset: add the Powkiddy RGB10-Max-3-Pro to the Odroid - Go Ultra poweroff driver +Subject: [PATCH 43/44] power: reset: add the Powkiddy RGB10-Max-3-Pro to the + Odroid Go Ultra poweroff driver --- drivers/power/reset/odroid-go-ultra-poweroff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/power/reset/odroid-go-ultra-poweroff.c b/drivers/power/reset/odroid-go-ultra-poweroff.c -index 9cac7aef77f0..9e48a34cee79 100644 +index 9cac7aef77f0..2ec3af0be0a5 100644 --- a/drivers/power/reset/odroid-go-ultra-poweroff.c +++ b/drivers/power/reset/odroid-go-ultra-poweroff.c @@ -142,7 +142,8 @@ static int __init odroid_go_ultra_poweroff_init(void) diff --git a/projects/Amlogic/patches/linux/S922X/0048-arm64-dts-amlogic-meson-g12b-odroid-n2-add-support-f.patch b/projects/Amlogic/patches/linux/S922X/0044-arm64-dts-amlogic-meson-g12b-odroid-n2-add-support-f.patch similarity index 79% rename from projects/Amlogic/patches/linux/S922X/0048-arm64-dts-amlogic-meson-g12b-odroid-n2-add-support-f.patch rename to projects/Amlogic/patches/linux/S922X/0044-arm64-dts-amlogic-meson-g12b-odroid-n2-add-support-f.patch index 231917934c..3ff6f2e532 100644 --- a/projects/Amlogic/patches/linux/S922X/0048-arm64-dts-amlogic-meson-g12b-odroid-n2-add-support-f.patch +++ b/projects/Amlogic/patches/linux/S922X/0044-arm64-dts-amlogic-meson-g12b-odroid-n2-add-support-f.patch @@ -1,8 +1,8 @@ -From 7023d5b29957ffaec48c2cf1f5a3a2288c576deb Mon Sep 17 00:00:00 2001 -From: Adam Green +From 3ee121405282bec089601d521371e9df6409c991 Mon Sep 17 00:00:00 2001 +From: spycat88 Date: Fri, 15 Mar 2024 19:49:19 +0000 -Subject: [PATCH] arm64: dts: amlogic: meson-g12b-odroid-n2: add support for - gpio power off +Subject: [PATCH 44/44] arm64: dts: amlogic: meson-g12b-odroid-n2: add support + for gpio power off --- arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dtsi | 11 +++++++++++ diff --git a/projects/Amlogic/patches/linux/S922X/0046-power-supply-rk818_charger-fix-compiling-driver-on-6.patch b/projects/Amlogic/patches/linux/S922X/0046-power-supply-rk818_charger-fix-compiling-driver-on-6.patch deleted file mode 100644 index c1e59453b2..0000000000 --- a/projects/Amlogic/patches/linux/S922X/0046-power-supply-rk818_charger-fix-compiling-driver-on-6.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 5dfbb3c0d3b148c632785e864a108fbce7004541 Mon Sep 17 00:00:00 2001 -From: adamg -Date: Tue, 6 Feb 2024 17:50:09 +0000 -Subject: [PATCH 46/46] power: supply: rk818_charger: fix compiling driver on - 6.8 - ---- - drivers/power/supply/rk818_charger.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/drivers/power/supply/rk818_charger.c b/drivers/power/supply/rk818_charger.c -index 6956d093c672..5cbdc1b46c5c 100644 ---- a/drivers/power/supply/rk818_charger.c -+++ b/drivers/power/supply/rk818_charger.c -@@ -8,7 +8,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include -@@ -705,6 +705,7 @@ static const struct of_device_id rk818_charger_of_match[] = { - { .compatible = "rockchip,rk818-charger", }, - { }, - }; -+MODULE_DEVICE_TABLE(of, rk818_charger_of_match); - - static struct platform_driver rk818_charger_driver = { - .probe = rk818_charger_probe, --- -2.34.1 - diff --git a/projects/PC/devices/AMD64/options b/projects/PC/devices/AMD64/options index 9582fc0b96..b6f99c211a 100644 --- a/projects/PC/devices/AMD64/options +++ b/projects/PC/devices/AMD64/options @@ -60,79 +60,18 @@ # ADDITIONAL_DRIVERS="" ADDITIONAL_DRIVERS="RTL8812AU RTL8814AU RTL8821AU RTL8821CU RTL88x2BU ryzensmu ayn-platform" - # build and install driver addons (yes / no) - DRIVER_ADDONS_SUPPORT="no" - - # driver addons to install: - # for a list of additinoal drivers see packages/linux-driver-addons - # Space separated list is supported, - DRIVER_ADDONS="" - # debug tty path DEBUG_TTY="/dev/ttyFIQ0" # Disable 32BIT support ENABLE_32BIT="false" - # build and install bluetooth support (yes / no) - BLUETOOTH_SUPPORT="yes" - - # build and install Avahi (Zeroconf) daemon (yes / no) - AVAHI_DAEMON="no" - - # build with NFS support (mounting nfs shares via the OS) (yes / no) - NFS_SUPPORT="no" - - # build with Samba Client support (mounting samba shares via the OS) (yes / no) - SAMBA_SUPPORT="no" - - # build and install Samba Server (yes / no) - SAMBA_SERVER="yes" - - # build and install SFTP Server (yes / no) - SFTP_SERVER="yes" - - # build and install Simple HTTP Server (yes / no) - SIMPLE_HTTP_SERVER="yes" - - # build and install OpenVPN support (yes / no) - OPENVPN_SUPPORT="no" - - # build and install ZeroTier support (yes / no) - ZEROTIER_SUPPORT="yes" - - # build and install diskmounter support (udevil) - # this service provide auto mounting support for external drives in the - # mediacenter also automount internally drives at boottime via udev (yes / no) - UDEVIL="yes" - - # build and install exFAT fuse support (yes / no) - EXFAT="yes" - # build and install NTFS-3G fuse support (yes / no) NTFS3G="yes" - # build and install hfs filesystem utilities (yes / no) - HFSTOOLS="no" - # Support for partitioning and formating disks in initramfs (yes / no) # This adds support for parted and mkfs.ext3/4 to initramfs for OEM usage INITRAMFS_PARTED_SUPPORT="yes" - # build with swap support (yes / no) - SWAP_SUPPORT="yes" - - # swap support enabled per default (yes / no) - SWAP_ENABLED_DEFAULT="yes" - # swapfile size if SWAP_SUPPORT=yes in MB SWAPFILESIZE="1024" - - # cron support (yes / no) - CRON_SUPPORT="no" - - # Settings package name - blank if not required - DISTRO_PKG_SETTINGS="" - - # htop tool (yes / no) - HTOP_TOOL="yes" diff --git a/projects/PC/options b/projects/PC/options index ab27b71b9d..61465888f8 100644 --- a/projects/PC/options +++ b/projects/PC/options @@ -45,14 +45,6 @@ # e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2" ADDITIONAL_DRIVERS="" - # build and install driver addons (yes / no) - DRIVER_ADDONS_SUPPORT="no" - - # driver addons to install: - # for a list of additional drivers see packages/linux-driver-addons - # Space separated list is supported, - DRIVER_ADDONS="crazycat digital_devices dvb-latest" - # Installation support INSTALLER_SUPPORT="yes" diff --git a/projects/Rockchip/bootloader/canupdate.sh b/projects/Rockchip/bootloader/canupdate.sh deleted file mode 100755 index b9b32ca914..0000000000 --- a/projects/Rockchip/bootloader/canupdate.sh +++ /dev/null @@ -1,9 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv) - -# Allow upgrades between arm and aarch64 -if [ "$1" = "@PROJECT@.arm" -o "$1" = "@PROJECT@.aarch64" ]; then - exit 0 -else - exit 1 -fi diff --git a/projects/Rockchip/bootloader/install b/projects/Rockchip/bootloader/install index 4e2becf9b9..499da86899 100755 --- a/projects/Rockchip/bootloader/install +++ b/projects/Rockchip/bootloader/install @@ -6,42 +6,19 @@ PKG_RKBIN="$(get_build_dir rkbin)" PKG_UBOOT="$(get_build_dir u-boot)" source ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/options -RKSPI_LOADER=${INSTALL}/usr/share/bootloader/rkspi_loader.img - -generate_rkspi_loader() { - echo "spi: create rkspi_loader.img..." - dd if=/dev/zero of=$RKSPI_LOADER bs=1M count=0 seek=16 - # When running as a non-root user, /sbin & /usr/sbin are excluded from $PATH - PATH=/sbin:/usr/sbin:$PATH PARTED_CMD="$(which parted)" - ${PARTED_CMD} -s $RKSPI_LOADER mklabel gpt - ${PARTED_CMD} -s $RKSPI_LOADER unit s mkpart idbloader 64 7167 - ${PARTED_CMD} -s $RKSPI_LOADER unit s mkpart vnvm 7168 7679 - ${PARTED_CMD} -s $RKSPI_LOADER unit s mkpart reserved_space 7680 8063 - ${PARTED_CMD} -s $RKSPI_LOADER unit s mkpart reserved1 8064 8127 - ${PARTED_CMD} -s $RKSPI_LOADER unit s mkpart uboot_env 8128 8191 - ${PARTED_CMD} -s $RKSPI_LOADER unit s mkpart reserved2 8192 16383 - ${PARTED_CMD} -s $RKSPI_LOADER unit s mkpart uboot 16384 32734 - echo "spi: write idbloader.img to rkspi_loader.img..." - dd if=${PKG_BUILD}/idbloader.img of=$RKSPI_LOADER seek=64 conv=notrunc - echo "spi: write uboot.itb to rkspi_loader.img..." - dd if=${PKG_BUILD}/u-boot.itb of=$RKSPI_LOADER seek=16384 conv=notrunc -} - - - if [ -n "${PKG_DATAFILE}" -a -n "${PKG_LOADER}" ]; then echo "loader: Make idbloader.img from ${PKG_DATAFILE}:${PKG_LOADER}..." case "${PKG_SOC}" in rk35*) tools/mkimage -n ${PKG_SOC} -T rksd -d ${PKG_DATAFILE}:${PKG_LOADER} -C bzip2 idbloader.img - ;; + ;; rk3399) ${PKG_RKBIN}/tools/mkimage -n "${PKG_SOC}" -T rksd -d ${PKG_DATAFILE}:${PKG_LOADER} idbloader.img.rk || exit 1 - ;; + ;; *) tools/mkimage -n ${PKG_SOC} -T rksd -d "${PKG_DATAFILE}" -C bzip2 idbloader.img cat "${PKG_LOADER}" >> idbloader.img - ;; + ;; esac fi @@ -49,7 +26,7 @@ case "${PKG_SOC}" in rk35*|px30) echo "uboot: copy idbloader.img image to ${INSTALL}/usr/share/bootloader..." cp -av idbloader.img ${INSTALL}/usr/share/bootloader - ;; + ;; esac if [ ! -n "${PKG_LOAD_ADDR}" ]; then @@ -58,15 +35,14 @@ fi case "${PKG_SOC}" in rk35*) - for BOOT_IMAGE in u-boot.itb u-boot.img u-boot.img - do + for BOOT_IMAGE in u-boot.itb u-boot.img u-boot.img; do if [ -f "${BOOT_IMAGE}" ]; then echo "uboot: copy ${BOOT_IMAGE} image to ${INSTALL}/usr/share/bootloader..." cp -av ${BOOT_IMAGE} ${INSTALL}/usr/share/bootloader/${BOOT_IMAGE} break fi done - ;; + ;; rk3399) PKG_ATF_INI="${PKG_RKBIN}"/RKTRUST/"${DEVICE}"TRUST.ini echo "uboot: building ${UBOOT_FIT_IMAGE}..." @@ -78,19 +54,19 @@ case "${PKG_SOC}" in echo "uboot: copy ${UBOOT_FIT_IMAGE} to ${INSTALL}/usr/share/bootloader..." cp -av ${UBOOT_FIT_IMAGE} ${INSTALL}/usr/share/bootloader - ;; + ;; *) echo "uboot: build loader image u-boot.img at ${PKG_LOAD_ADDR}..." ${PKG_UBOOT}/tools/loaderimage --pack --uboot u-boot-dtb.bin u-boot.img ${PKG_LOAD_ADDR} ||: cp -av u-boot.img ${INSTALL}/usr/share/bootloader - ;; + ;; esac case "${DEVICE}" in RK3326) -if [ -n "${PKG_BL31}" ]; then - echo "trust: create trust.ini..." - cat >trust.ini <trust.ini < "${INSTALL}/usr/share/bootloader/extlinux/extlinux.conf" + cat << EOF > "${INSTALL}/usr/share/bootloader/extlinux/extlinux.conf" LABEL ${DISTRO} LINUX /${KERNEL_NAME} ${FDTMODE} - APPEND boot=UUID=@UUID_SYSTEM@ disk=UUID=@UUID_STORAGE@ ${EXTRA_CMDLINE} + APPEND boot=LABEL=${DISTRO_BOOTLABEL} disk=LABEL=${DISTRO_DISKLABEL} ${EXTRA_CMDLINE} EOF fi diff --git a/projects/Rockchip/bootloader/mkimage b/projects/Rockchip/bootloader/mkimage index a642e175ca..290a9142c8 100755 --- a/projects/Rockchip/bootloader/mkimage +++ b/projects/Rockchip/bootloader/mkimage @@ -7,10 +7,10 @@ source ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/options case "${PKG_SOC}" in rk35*|rk3399) IDBSEEK="bs=512 seek=64" - ;; + ;; *) IDBSEEK="bs=32k seek=1" - ;; + ;; esac if [ -f "${RELEASE_DIR}/3rdparty/bootloader/idbloader.img" ]; then @@ -18,12 +18,9 @@ if [ -f "${RELEASE_DIR}/3rdparty/bootloader/idbloader.img" ]; then dd if="${RELEASE_DIR}/3rdparty/bootloader/idbloader.img" of="$DISK" ${IDBSEEK} conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error fi - - case "${PKG_SOC}" in rk35*) - for BOOT_IMAGE in u-boot.itb u-boot.img - do + for BOOT_IMAGE in u-boot.itb u-boot.img; do if [ -f "${RELEASE_DIR}/3rdparty/bootloader/${BOOT_IMAGE}" ]; then echo "image: burn ${BOOT_IMAGE} to image..." dd if="${RELEASE_DIR}/3rdparty/bootloader/${BOOT_IMAGE}" of="${DISK}" bs=512 seek=16384 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error @@ -37,16 +34,15 @@ case "${PKG_SOC}" in echo "image: burn resource.img to image..." dd if="${RELEASE_DIR}/3rdparty/bootloader/resource.img" of="${DISK}" bs=512 seek=24576 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error fi - ;; + ;; rk3399) if [ -f "${RELEASE_DIR}/3rdparty/bootloader/rk3399-uboot.bin" ]; then echo "image: burn u-boot.bin to image..." dd if="${RELEASE_DIR}/3rdparty/bootloader/rk3399-uboot.bin" of="${DISK}" bs=512 seek=64 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error fi - ;; + ;; *) - for BOOT_IMAGE in u-boot.itb u-boot.img - do + for BOOT_IMAGE in u-boot.itb u-boot.img; do if [ -f "${RELEASE_DIR}/3rdparty/bootloader/${BOOT_IMAGE}" ]; then echo "image: burn ${BOOT_IMAGE} to image..." dd if="${RELEASE_DIR}/3rdparty/bootloader/${BOOT_IMAGE}" of="${DISK}" bs=512 seek=16384 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error @@ -57,19 +53,19 @@ case "${PKG_SOC}" in echo "image: burn trust.img to image..." dd if="${RELEASE_DIR}/3rdparty/bootloader/trust.img" of="$DISK" bs=512 seek=24576 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error fi - ;; + ;; esac #Create boot.ini -if [ "${BOOT_INI}" == true ] -then +if [ "${BOOT_INI}" == true ]; then echo "boot: create boot.ini..." - if [ -e "${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/boot/boot.ini" ] - then + if [ -e "${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/boot/boot.ini" ]; then cp -f ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/boot/boot.ini ${LE_TMP}/boot.ini - sed -i "s~@UUID_SYSTEM@~${UUID_SYSTEM}~g" ${LE_TMP}/boot.ini - sed -i "s~@UUID_STORAGE@~${UUID_STORAGE}~g" ${LE_TMP}/boot.ini - sed -i "s~@EXTRA_CMDLINE@~${EXTRA_CMDLINE}~g" ${LE_TMP}/boot.ini + sed -e "s/@DISTRO_BOOTLABEL@/${DISTRO_BOOTLABEL}/" \ + -e "s/@DISTRO_DISKLABEL@/${DISTRO_DISKLABEL}/" \ + -e "s/@EXTRA_CMDLINE@/${EXTRA_CMDLINE}/" \ + -i "${LE_TMP}/boot.ini" + mcopy -so "${LE_TMP}/boot.ini" :: else echo "ERROR: No boot.ini found in ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/boot/." @@ -80,36 +76,31 @@ fi mkdir -p "${LE_TMP}/extlinux" # copy device trees to part1 -for DTB in ${DEVICE_DTB[@]} -do - if [ -e "${DTB}.dtb" ] - then +for DTB in ${DEVICE_DTB[@]}; do + if [ -e "${DTB}.dtb" ]; then echo "image: copy device trees to image..." mcopy -o "${DTB}.dtb" :: fi done -if [ "${EXT_LINUX_CONF}" == true ] -then -mkdir -p "${LE_TMP}/extlinux" +if [ "${EXT_LINUX_CONF}" == true ]; then + mkdir -p "${LE_TMP}/extlinux" -if [[ "${PKG_SOC}" != "rk3588" ]] && \ - [[ "${TRUST_LABEL}" = "resource" || "${#DEVICE_DTB[@]}" -gt 1 ]] -then - echo "image: Set FDTDIR to /..." - FDTMODE="FDTDIR /" -else - echo "image: Set FDT to ${DEVICE_DTB}..." - FDTMODE="FDT /${DEVICE_DTB}.dtb" -fi + if [[ "${PKG_SOC}" != "rk3588" ]] && [[ "${TRUST_LABEL}" = "resource" || "${#DEVICE_DTB[@]}" -gt 1 ]]; then + echo "image: Set FDTDIR to /..." + FDTMODE="FDTDIR /" + else + echo "image: Set FDT to ${DEVICE_DTB}..." + FDTMODE="FDT /${DEVICE_DTB}.dtb" + fi -echo "image: Set extlinux.conf..." -cat << EOF > "${LE_TMP}/extlinux/extlinux.conf" + echo "image: Set extlinux.conf..." + cat << EOF > "${LE_TMP}/extlinux/extlinux.conf" LABEL ${DISTRO} LINUX /${KERNEL_NAME} ${FDTMODE} - APPEND boot=UUID=${UUID_SYSTEM} disk=UUID=${UUID_STORAGE} ${EXTRA_CMDLINE} + APPEND boot=LABEL=${DISTRO_BOOTLABEL} disk=LABEL=${DISTRO_DISKLABEL} ${EXTRA_CMDLINE} EOF -mcopy -so "${LE_TMP}/extlinux" :: + mcopy -so "${LE_TMP}/extlinux" :: fi diff --git a/projects/Rockchip/bootloader/release b/projects/Rockchip/bootloader/release index 074bc3abde..565412e483 100755 --- a/projects/Rockchip/bootloader/release +++ b/projects/Rockchip/bootloader/release @@ -11,8 +11,7 @@ if [ -n "${UBOOT_CONFIG}" ]; then fi case "${PKG_SOC}" in rk35*) - for BOOT_IMAGE in u-boot.itb u-boot.img - do + for BOOT_IMAGE in u-boot.itb u-boot.img; do if [ -f "${BOOTLOADER_DIR}/${BOOT_IMAGE}" ]; then cp -a ${BOOTLOADER_DIR}/${BOOT_IMAGE} ${RELEASE_DIR}/3rdparty/bootloader break @@ -21,15 +20,14 @@ if [ -n "${UBOOT_CONFIG}" ]; then if [ -f ${KERNEL_DIR}/resource.img ]; then cp -a ${KERNEL_DIR}/resource.img ${RELEASE_DIR}/3rdparty/bootloader fi - ;; + ;; rk3399) if [ -f ${BOOTLOADER_DIR}/rk3399-uboot.bin ]; then cp -a ${BOOTLOADER_DIR}/rk3399-uboot.bin ${RELEASE_DIR}/3rdparty/bootloader fi - ;; + ;; *) - for BOOT_IMAGE in u-boot.itb u-boot.img - do + for BOOT_IMAGE in u-boot.itb u-boot.img; do if [ -f "${BOOTLOADER_DIR}/${BOOT_IMAGE}" ]; then cp -a ${BOOTLOADER_DIR}/${BOOT_IMAGE} ${RELEASE_DIR}/3rdparty/bootloader break @@ -38,6 +36,7 @@ if [ -n "${UBOOT_CONFIG}" ]; then if [ -f ${BOOTLOADER_DIR}/trust.img ]; then cp -a ${BOOTLOADER_DIR}/trust.img ${RELEASE_DIR}/3rdparty/bootloader fi + ;; esac fi @@ -50,7 +49,7 @@ if [ -f ${INSTALL}/usr/share/bootloader/boot.scr ]; then fi LINUX_DTS_DIR=$(get_build_dir linux)/arch/${TARGET_KERNEL_ARCH}/boot/dts/ -for dtb in $(find ${LINUX_DTS_DIR} -name "*.dtb") ; do +for dtb in $(find ${LINUX_DTS_DIR} -name "*.dtb"); do if [ -f $dtb ]; then cp -a $dtb ${RELEASE_DIR}/3rdparty/bootloader fi diff --git a/projects/Rockchip/bootloader/update.sh b/projects/Rockchip/bootloader/update.sh index ab99a9c09b..0e5dd1320e 100755 --- a/projects/Rockchip/bootloader/update.sh +++ b/projects/Rockchip/bootloader/update.sh @@ -3,176 +3,118 @@ # Copyright (C) 2017-2021 Team LibreELEC (https://libreelec.tv) # Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) - -if [ -z "${1}" ] -then - [ -z "$SYSTEM_ROOT" ] && SYSTEM_ROOT="" - [ -z "$BOOT_ROOT" ] && BOOT_ROOT="/flash" - [ -z "$BOOT_PART" ] && BOOT_PART=$(df "$BOOT_ROOT" | tail -1 | awk {' print $1 '}) - if [ -z "$BOOT_DISK" ]; then - case $BOOT_PART in - /dev/sd[a-z][0-9]*) - BOOT_DISK=$(echo $BOOT_PART | sed -e "s,[0-9]*,,g") - ;; - /dev/mmcblk*) - BOOT_DISK=$(echo $BOOT_PART | sed -e "s,p[0-9]*,,g") - ;; - esac - fi - - # mount $BOOT_ROOT r/w - mount -o remount,rw $BOOT_ROOT - - for arg in $(cat /proc/cmdline); do - case $arg in - boot=*) - boot="${arg#*=}" - case $boot in - /dev/mmc*) - UUID_SYSTEM="$(blkid $boot | sed 's/.* UUID="//;s/".*//g')" - ;; - UUID=*|LABEL=*) - UUID_SYSTEM="$(blkid | sed 's/"//g' | grep -m 1 -i " $boot " | sed 's/.* UUID=//;s/ .*//g')" - ;; - FOLDER=*) - UUID_SYSTEM="$(blkid ${boot#*=} | sed 's/.* UUID="//;s/".*//g')" - ;; - esac - ;; - disk=*) - disk="${arg#*=}" - case $disk in - /dev/mmc*) - UUID_STORAGE="$(blkid $disk | sed 's/.* UUID="//;s/".*//g')" - ;; - UUID=*|LABEL=*) - UUID_STORAGE="$(blkid | sed 's/"//g' | grep -m 1 -i " $disk " | sed 's/.* UUID=//;s/ .*//g')" - ;; - FOLDER=*) - UUID_STORAGE="$(blkid ${disk#*=} | sed 's/.* UUID="//;s/".*//g')" - ;; - esac +[ -z "$SYSTEM_ROOT" ] && SYSTEM_ROOT="" +[ -z "$BOOT_ROOT" ] && BOOT_ROOT="/flash" +[ -z "$BOOT_PART" ] && BOOT_PART=$(df "$BOOT_ROOT" | tail -1 | awk {' print $1 '}) + +# identify the boot device +if [ -z "$BOOT_DISK" ]; then + case $BOOT_PART in + /dev/mmcblk*) + BOOT_DISK=$(echo $BOOT_PART | sed -e "s,p[0-9]*,,g") ;; - esac - done -else - BOOT_DISK="${1}" - BOOT_ROOT="${2}" - UUID_SYSTEM="${3}" - UUID_STORAGE="${4}" + esac fi -CONFS=$SYSTEM_ROOT/usr/share/bootloader/extlinux/*.conf +# mount $BOOT_ROOT rw +mount -o remount,rw $BOOT_ROOT -for all_conf in $CONFS; do - conf="$(basename ${all_conf})" - echo "Updating ${conf}..." - if [ ! -d "${BOOT_ROOT}/extlinux" ] - then - mkdir "${BOOT_ROOT}/extlinux" +for all_dtb in $BOOT_ROOT/*.dtb; do + dtb=$(basename $all_dtb) + if [ -f $SYSTEM_ROOT/usr/share/bootloader/$dtb ]; then + echo "Updating $dtb..." + cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT fi - cp -p $SYSTEM_ROOT/usr/share/bootloader/extlinux/${conf} $BOOT_ROOT/extlinux/${conf} &>/dev/null - sed -e "s/@UUID_SYSTEM@/${UUID_SYSTEM}/" \ - -e "s/@UUID_STORAGE@/${UUID_STORAGE}/" \ - -i $BOOT_ROOT/extlinux/${conf} done -# Set correct FDT boot dtb for RK3588 -DT_ID=$($SYSTEM_ROOT/usr/bin/dtname) -if [ -n "${DT_ID}" ]; then - case ${DT_ID} in - *gameforce,ace) - echo "Setting boot FDT to GameForce Ace..." - sed -i '/FDT/c\ FDT /rk3588s-gameforce-ace.dtb' $BOOT_ROOT/extlinux/extlinux.conf - ;; - *orangepi-5) - echo "Setting boot FDT to Orange Pi 5..." - sed -i '/FDT/c\ FDT /rk3588s-orangepi-5.dtb' $BOOT_ROOT/extlinux/extlinux.conf - sed -i 's/ fbcon=rotate:1//' $BOOT_ROOT/extlinux/extlinux.conf - ;; - *rock-5) - echo "Setting boot FDT to Rock 5B..." - sed -i '/FDT/c\ FDT /rk3588-rock-5b.dtb' $BOOT_ROOT/extlinux/extlinux.conf - sed -i 's/ fbcon=rotate:1//' $BOOT_ROOT/extlinux/extlinux.conf - ;; - esac -fi +if [ -f $BOOT_ROOT/extlinux/extlinux.conf ]; then + if [ -f $SYSTEM_ROOT/usr/share/bootloader/extlinux/extlinux.conf ]; then + echo "Updating extlinux.conf..." + cp -p $SYSTEM_ROOT/usr/share/bootloader/extlinux/extlinux.conf $BOOT_ROOT/extlinux + fi -if [ -f $SYSTEM_ROOT/usr/share/bootloader/boot.ini ]; then - echo "Updating boot.ini..." - cp -p $SYSTEM_ROOT/usr/share/bootloader/boot.ini $BOOT_ROOT/boot.ini &>/dev/null - sed -e "s/@UUID_SYSTEM@/${UUID_SYSTEM}/" \ - -e "s/@UUID_STORAGE@/${UUID_STORAGE}/" \ - -i $BOOT_ROOT/boot.ini - - # Set correct R3xS dtb in boot.ini - DTB_NAME=$(cat $BOOT_ROOT/device.name) - if [ $DTB_NAME = 'R33S' ]; then - echo "Setting R33S dtb in boot.ini..." - sed -i '/rk3326-gameconsole-r3/c\ load mmc 1:1 ${dtb_loadaddr} rk3326-gameconsole-r33s.dtb' $BOOT_ROOT/boot.ini - elif [ $DTB_NAME = 'R36S' ]; then - echo "Setting R36S/R35S dtb in boot.ini..." - sed -i '/rk3326-gameconsole-r3/c\ load mmc 1:1 ${dtb_loadaddr} rk3326-gameconsole-r36s.dtb' $BOOT_ROOT/boot.ini + # Set correct FDT boot dtb for RK3588 + DT_ID=$($SYSTEM_ROOT/usr/bin/dtname) + if [ -n "${DT_ID}" ]; then + case ${DT_ID} in + *gameforce,ace) + echo "Setting boot FDT to GameForce Ace..." + sed -i '/FDT/c\ FDT /rk3588s-gameforce-ace.dtb' $BOOT_ROOT/extlinux/extlinux.conf + ;; + *orangepi-5) + echo "Setting boot FDT to Orange Pi 5..." + sed -i '/FDT/c\ FDT /rk3588s-orangepi-5.dtb' $BOOT_ROOT/extlinux/extlinux.conf + sed -i 's/ fbcon=rotate:1//' $BOOT_ROOT/extlinux/extlinux.conf + ;; + *rock-5) + echo "Setting boot FDT to Rock 5B..." + sed -i '/FDT/c\ FDT /rk3588-rock-5b.dtb' $BOOT_ROOT/extlinux/extlinux.conf + sed -i 's/ fbcon=rotate:1//' $BOOT_ROOT/extlinux/extlinux.conf + ;; + esac fi fi -# update device tree -for all_dtb in $SYSTEM_ROOT/usr/share/bootloader/*.dtb; do - dtb="$(basename ${all_dtb})" - echo -n "Updating $dtb... " - cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT &>/dev/null - echo "done" -done - -echo "UPDATE" > /storage/.boot.hint +if [ -f $BOOT_ROOT/boot.ini ]; then + if [ -f $SYSTEM_ROOT/usr/share/bootloader/boot.ini ]; then + echo "Updating boot.ini" + cp -p $SYSTEM_ROOT/usr/share/bootloader/boot.ini $BOOT_ROOT/boot.ini + + if [ -f $BOOT_ROOT/device.name ]; then + # Set correct R3xS dtb in boot.ini + DTB_NAME=$(cat $BOOT_ROOT/device.name) + case ${DTB_NAME} in + R33S) + echo "Setting R33S dtb in boot.ini..." + sed -i '/rk3326-gameconsole-r3/c\ load mmc 1:1 ${dtb_loadaddr} rk3326-gameconsole-r33s.dtb' $BOOT_ROOT/boot.ini + ;; + R36S) + echo "Setting R36S/R35S dtb in boot.ini..." + sed -i '/rk3326-gameconsole-r3/c\ load mmc 1:1 ${dtb_loadaddr} rk3326-gameconsole-r36s.dtb' $BOOT_ROOT/boot.ini + ;; + esac + fi + fi +fi # update bootloader - -MYDEV=$(awk '/^Hardware/ {print $4}' /proc/cpuinfo) -case ${MYDEV} in - RK35*) - IDBSEEK="bs=512 seek=64" - ;; - *) - IDBSEEK="bs=32k seek=1" - ;; +DT_SOC=$($SYSTEM_ROOT/usr/bin/dtsoc) +case ${DT_SOC} in + *rk35*) IDBSEEK="bs=512 seek=64";; + *) IDBSEEK="bs=32k seek=1";; esac if [ -f $SYSTEM_ROOT/usr/share/bootloader/idbloader.img ]; then - echo -n "Updating idbloader.img... " - dd if=$SYSTEM_ROOT/usr/share/bootloader/idbloader.img of=$BOOT_DISK ${IDBSEEK} conv=fsync &>/dev/null - echo "done" + echo -n "Updating idbloader.img on $BOOT_DISK... " + dd if=$SYSTEM_ROOT/usr/share/bootloader/idbloader.img of=$BOOT_DISK $IDBSEEK conv=fsync &>/dev/null fi -for BOOT_IMAGE in u-boot.itb u-boot.img -do +for BOOT_IMAGE in u-boot.itb u-boot.img; do if [ -f "$SYSTEM_ROOT/usr/share/bootloader/${BOOT_IMAGE}" ]; then - echo "Updating ${BOOT_IMAGE}..." - dd if=$SYSTEM_ROOT/usr/share/bootloader/${BOOT_IMAGE} of=$BOOT_DISK bs=512 seek=16384 conv=fsync &>/dev/null + echo -n "Updating $BOOT_IMAGE on $BOOT_DISK..." + dd if=$SYSTEM_ROOT/usr/share/bootloader/$BOOT_IMAGE of=$BOOT_DISK bs=512 seek=16384 conv=fsync &>/dev/null break fi done if [ -f $SYSTEM_ROOT/usr/share/bootloader/rk3399-uboot.bin ]; then - echo -n "Updating uboot.bin... " + echo -n "Updating rk3399-uboot.bin on $BOOT_DISK... " dd if=$SYSTEM_ROOT/usr/share/bootloader/rk3399-uboot.bin of=$BOOT_DISK bs=512 seek=64 conv=fsync &>/dev/null - echo "done" fi if [ -f $SYSTEM_ROOT/usr/share/bootloader/trust.img ]; then - echo -n "Updating trust.img... " + echo -n "Updating trust.img on $BOOT_DISK... " dd if=$SYSTEM_ROOT/usr/share/bootloader/trust.img of=$BOOT_DISK bs=512 seek=24576 conv=fsync &>/dev/null - parted $BOOT_DISK name 2 trust &>/dev/null ||: - echo "done" elif [ -f $SYSTEM_ROOT/usr/share/bootloader/resource.img ]; then - echo -n "Updating resource.img... " + echo -n "Updating resource.img on $BOOT_DISK... " dd if=$SYSTEM_ROOT/usr/share/bootloader/resource.img of=$BOOT_DISK bs=512 seek=24576 conv=fsync &>/dev/null - parted $BOOT_DISK name 2 resource &>/dev/null ||: - echo "done" fi -# mount $BOOT_ROOT r/o - sync - mount -o remount,ro $BOOT_ROOT &>/dev/null +# Update system partition label to ROCKNIX +[ ! -z "$(blkid | grep JELOS)" ] && ${SYSTEM_ROOT}/usr/sbin/dosfslabel $BOOT_PART ROCKNIX +# mount $BOOT_ROOT ro sync +mount -o remount,ro $BOOT_ROOT + +echo "UPDATE" > /storage/.boot.hint diff --git a/projects/Rockchip/devices/RK3326/boot/boot.ini b/projects/Rockchip/devices/RK3326/boot/boot.ini index 53b20bb9d3..4e0a7756e9 100644 --- a/projects/Rockchip/devices/RK3326/boot/boot.ini +++ b/projects/Rockchip/devices/RK3326/boot/boot.ini @@ -1,6 +1,6 @@ odroidgoa-uboot-config -setenv bootargs "boot=UUID=@UUID_SYSTEM@ disk=UUID=@UUID_STORAGE@ @EXTRA_CMDLINE@" +setenv bootargs "boot=LABEL=@DISTRO_BOOTLABEL@ disk=LABEL=@DISTRO_DISKLABEL@ @EXTRA_CMDLINE@" setenv loadaddr "0x02000000" setenv dtb_loadaddr "0x01f00000" diff --git a/projects/Rockchip/devices/RK3326/options b/projects/Rockchip/devices/RK3326/options index 82b8bc5289..88ed7ffc99 100644 --- a/projects/Rockchip/devices/RK3326/options +++ b/projects/Rockchip/devices/RK3326/options @@ -83,79 +83,5 @@ # e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2" ADDITIONAL_DRIVERS="RTL8812AU RTL8814AU RTL8821AU RTL8821CU RTL88x2BU RTL8723DS" - # build and install driver addons (yes / no) - DRIVER_ADDONS_SUPPORT="no" - - # driver addons to install: - # for a list of additinoal drivers see packages/linux-driver-addons - # Space separated list is supported, - DRIVER_ADDONS="" - # debug tty path DEBUG_TTY="/dev/ttyFIQ0" - - # Disable 32BIT support - ENABLE_32BIT="true" - - # build and install bluetooth support (yes / no) - BLUETOOTH_SUPPORT="yes" - - # build and install Avahi (Zeroconf) daemon (yes / no) - AVAHI_DAEMON="no" - - # build with NFS support (mounting nfs shares via the OS) (yes / no) - NFS_SUPPORT="no" - - # build with Samba Client support (mounting samba shares via the OS) (yes / no) - SAMBA_SUPPORT="no" - - # build and install Samba Server (yes / no) - SAMBA_SERVER="yes" - - # build and install SFTP Server (yes / no) - SFTP_SERVER="yes" - - # build and install Simple HTTP Server (yes / no) - SIMPLE_HTTP_SERVER="yes" - - # build and install OpenVPN support (yes / no) - OPENVPN_SUPPORT="no" - - # build and install ZeroTier support (yes / no) - ZEROTIER_SUPPORT="yes" - - # build and install diskmounter support (udevil) - # this service provide auto mounting support for external drives in the - # mediacenter also automount internally drives at boottime via udev (yes / no) - UDEVIL="yes" - - # build and install exFAT fuse support (yes / no) - EXFAT="yes" - - # build and install NTFS-3G fuse support (yes / no) - NTFS3G="no" - - # build and install hfs filesystem utilities (yes / no) - HFSTOOLS="no" - - # Support for partitioning and formating disks in initramfs (yes / no) - # This adds support for parted and mkfs.ext3/4 to initramfs for OEM usage - INITRAMFS_PARTED_SUPPORT="no" - - # build with swap support (yes / no) - SWAP_SUPPORT="yes" - - # swap support enabled per default (yes / no) - SWAP_ENABLED_DEFAULT="yes" - - # swapfile size if SWAP_SUPPORT=yes in MB - SWAPFILESIZE="384" - - # cron support (yes / no) - CRON_SUPPORT="no" - - # Settings package name - blank if not required - DISTRO_PKG_SETTINGS="" - - # htop tool (yes / no) - HTOP_TOOL="yes" diff --git a/projects/Rockchip/devices/RK3399/options b/projects/Rockchip/devices/RK3399/options index 753e30ef09..252c3d0a0a 100644 --- a/projects/Rockchip/devices/RK3399/options +++ b/projects/Rockchip/devices/RK3399/options @@ -85,76 +85,8 @@ # e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2" ADDITIONAL_DRIVERS="RTL8812AU RTL8821AU RTL8821CU RTL88x2BU" - # build and install driver addons (yes / no) - DRIVER_ADDONS_SUPPORT="no" - - # driver addons to install: - # for a list of additinoal drivers see packages/linux-driver-addons - # Space separated list is supported, - DRIVER_ADDONS="" - # debug tty path DEBUG_TTY="/dev/ttyFIQ0" - - # Disable 32BIT support - ENABLE_32BIT="true" - - # build and install bluetooth support (yes / no) - BLUETOOTH_SUPPORT="yes" - - # build and install Avahi (Zeroconf) daemon (yes / no) - AVAHI_DAEMON="no" - - # build with NFS support (mounting nfs shares via the OS) (yes / no) - NFS_SUPPORT="no" - - # build with Samba Client support (mounting samba shares via the OS) (yes / no) - SAMBA_SUPPORT="no" - - # build and install Samba Server (yes / no) - SAMBA_SERVER="yes" - - # build and install SFTP Server (yes / no) - SFTP_SERVER="yes" - - # build and install Simple HTTP Server (yes / no) - SIMPLE_HTTP_SERVER="yes" - - # build and install OpenVPN support (yes / no) - OPENVPN_SUPPORT="no" - - # build and install diskmounter support (udevil) - # this service provide auto mounting support for external drives in the - # mediacenter also automount internally drives at boottime via udev (yes / no) - UDEVIL="yes" - - # build and install exFAT fuse support (yes / no) - EXFAT="yes" - - # build and install NTFS-3G fuse support (yes / no) - NTFS3G="no" - - # build and install hfs filesystem utilities (yes / no) - HFSTOOLS="no" - - # Support for partitioning and formating disks in initramfs (yes / no) - # This adds support for parted and mkfs.ext3/4 to initramfs for OEM usage - INITRAMFS_PARTED_SUPPORT="no" - - # build with swap support (yes / no) - SWAP_SUPPORT="yes" - - # swap support enabled per default (yes / no) - SWAP_ENABLED_DEFAULT="yes" - - # swapfile size if SWAP_SUPPORT=yes in MB - SWAPFILESIZE="384" - - # cron support (yes / no) - CRON_SUPPORT="no" - - # Settings package name - blank if not required - DISTRO_PKG_SETTINGS="" - # htop tool (yes / no) - HTOP_TOOL="yes" + # Some devices have internal storage. + INSTALLER_SUPPORT="no" diff --git a/projects/Rockchip/devices/RK3566-X55/linux b/projects/Rockchip/devices/RK3566-X55/linux new file mode 120000 index 0000000000..221c630db8 --- /dev/null +++ b/projects/Rockchip/devices/RK3566-X55/linux @@ -0,0 +1 @@ +../RK3566/linux/ \ No newline at end of file diff --git a/projects/Rockchip/devices/RK3566-X55/options b/projects/Rockchip/devices/RK3566-X55/options new file mode 100644 index 0000000000..838e24502b --- /dev/null +++ b/projects/Rockchip/devices/RK3566-X55/options @@ -0,0 +1,93 @@ +################################################################################ +# setup device defaults +################################################################################ + + # The TARGET_CPU variable controls which processor should be targeted for + # generated code. + case ${TARGET_ARCH} in + aarch64) + TARGET_KERNEL_ARCH="arm64" + TARGET_PATCH_ARCH="aarch64" + TARGET_CPU="cortex-a55" + TARGET_CPU_FLAGS="+crc+crypto+fp+simd" + TARGET_FPU="fp-armv8" + TARGET_FLOAT="hard" + TARGET_FEATURES="64bit" + ;; + arm) + TARGET_KERNEL_ARCH="arm64" + TARGET_PATCH_ARCH="aarch64" + TARGET_CPU="cortex-a55" + TARGET_CPU_FLAGS="+crc" + TARGET_FPU="neon-fp-armv8" + TARGET_FLOAT="hard" + TARGET_FEATURES="32bit" + ;; + esac + + # Kernel target + DEVICE_NAME="RK3566" + KERNEL_TARGET="Image" + BOOTLOADER="u-boot" + PARTITION_TABLE="gpt" + UBOOT_LABEL="uboot" + TRUST_LABEL="trust" + DEVICE_DTB=("rk3566-powkiddy-x55") + UBOOT_DTB="rk3566" + UBOOT_CONFIG="powkiddy-x55-rk3566_defconfig" + PKG_SOC="rk3568" + PKG_DATAFILE="${PKG_RKBIN}/bin/rk35/rk3566_ddr_1056MHz_v1.18.bin" + PKG_LOADER="spl/u-boot-spl.bin" + PKG_BL31="${PKG_RKBIN}/bin/rk35/rk3568_bl31_v1.43.elf" + PKG_LOAD_ADDR="0x0a100000" + BOOT_INI=false + EXT_LINUX_CONF=true + + # Additional kernel make parameters (for example to specify the u-boot loadaddress) + KERNEL_MAKE_EXTRACMD=" $(for DTB in "${DEVICE_DTB[@]}"; do echo -n "rockchip/${DTB}.dtb "; done)" + KERNEL_EXTRA_DEPENDS_TARGET="zstd libcap libtraceevent" + + # Define the CPU + HW_CPU="Rockchip RK3566" + + # Mali GPU family + MALI_FAMILY="bifrost-g52" + GRAPHIC_DRIVERS="panfrost" + + # OpenGL(X) implementation to use (mesa / no) + OPENGL="mesa" + + # OpenGL-ES implementation to use (mesa / no) + OPENGLES="mesa" + + # Displayserver to use (weston / x11 / no) + DISPLAYSERVER="wl" + + # Windowmanager to use (fluxbox / weston / no) + WINDOWMANAGER="swaywm-env" + + # Pipewire audio support (yes / no) + PIPEWIRE_SUPPORT="yes" + + # debug tty path + DEBUG_TTY="/dev/ttyS2" + + # kernel serial console + EXTRA_CMDLINE="quiet rootwait earlycon=uart8250,mmio32,0xfe660000 console=ttyS2,1500000n8 console=tty1 ssh consoleblank=0 systemd.show_status=0 loglevel=0 panic=20" + + # additional packages to install + # ADDITIONAL_PACKAGES="" + + # additional Firmware to use ( ) + # Space separated list is supported, + # e.g. FIRMWARE="" + FIRMWARE="" + + # additional drivers to install: + # for a list of additional drivers see packages/linux-drivers + # Space separated list is supported, + # e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2" + # ADDITIONAL_DRIVERS="" + + # Some devices have internal storage. + INSTALLER_SUPPORT="no" diff --git a/projects/Rockchip/devices/RK3566/linux/linux.aarch64.conf b/projects/Rockchip/devices/RK3566/linux/linux.aarch64.conf index df58d8e556..d6fb8f98e2 100644 --- a/projects/Rockchip/devices/RK3566/linux/linux.aarch64.conf +++ b/projects/Rockchip/devices/RK3566/linux/linux.aarch64.conf @@ -2826,6 +2826,7 @@ CONFIG_INPUT_JOYSTICK=y # CONFIG_JOYSTICK_A3D is not set CONFIG_JOYSTICK_ADC=y CONFIG_JOYSTICK_SINGLEADCJOY=y +CONFIG_JOYSTICK_SINGLEADC_QUADSAR_JOY=y # CONFIG_JOYSTICK_ADI is not set # CONFIG_JOYSTICK_COBRA is not set # CONFIG_JOYSTICK_GF2K is not set diff --git a/projects/Rockchip/devices/RK3566/options b/projects/Rockchip/devices/RK3566/options index 3882179939..dbef8878d2 100644 --- a/projects/Rockchip/devices/RK3566/options +++ b/projects/Rockchip/devices/RK3566/options @@ -32,7 +32,7 @@ PARTITION_TABLE="gpt" UBOOT_LABEL="uboot" TRUST_LABEL="trust" - DEVICE_DTB=("rk3566-anbernic-rg353ps" "rk3566-anbernic-rg353vs" "rk3566-anbernic-rg503" "rk3566-anbernic-rg353p" "rk3566-anbernic-rg353v" "rk3566-powkiddy-rk2023" "rk3566-powkiddy-rgb30" "rk3566-powkiddy-rgb10max3") + DEVICE_DTB=("rk3566-anbernic-rg353ps" "rk3566-anbernic-rg353vs" "rk3566-anbernic-rg503" "rk3566-anbernic-rg353p" "rk3566-anbernic-rg353v" "rk3566-powkiddy-rk2023" "rk3566-powkiddy-rgb30" "rk3566-powkiddy-rgb10max3" "rk3566-powkiddy-rgb30r2") UBOOT_DTB="rk3566" UBOOT_CONFIG="anbernic-rgxx3-rk3566_defconfig" PKG_SOC="rk3568" @@ -83,83 +83,11 @@ # e.g. FIRMWARE="" FIRMWARE="" - # Modules to install in initramfs for early boot - INITRAMFS_MODULES="" - # additional drivers to install: # for a list of additional drivers see packages/linux-drivers # Space separated list is supported, # e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2" ADDITIONAL_DRIVERS="RTL8812AU RTL8814AU RTL8821AU RTL8821CU" - # build and install driver addons (yes / no) - DRIVER_ADDONS_SUPPORT="no" - - # driver addons to install: - # for a list of additinoal drivers see packages/linux-driver-addons - # Space separated list is supported, - DRIVER_ADDONS="" - - # build and install bluetooth support (yes / no) - BLUETOOTH_SUPPORT="yes" - - # build and install Avahi (Zeroconf) daemon (yes / no) - AVAHI_DAEMON="no" - - # build with NFS support (mounting nfs shares via the OS) (yes / no) - NFS_SUPPORT="no" - - # build with Samba Client support (mounting samba shares via the OS) (yes / no) - SAMBA_SUPPORT="no" - - # build and install Samba Server (yes / no) - SAMBA_SERVER="yes" - - # build and install SFTP Server (yes / no) - SFTP_SERVER="yes" - - # build and install OpenVPN support (yes / no) - OPENVPN_SUPPORT="no" - WIREGUARD_SUPPORT="no" - - # build and install ZeroTier support (yes / no) - ZEROTIER_SUPPORT="yes" - - # build and install diskmounter support (udevil) - # this service provide auto mounting support for external drives in the - # mediacenter also automount internally drives at boottime via udev (yes / no) - UDEVIL="yes" - - # build and install exFAT fuse support (yes / no) - EXFAT="yes" - - # build and install NTFS-3G fuse support (yes / no) - NTFS3G="no" - - # build and install hfs filesystem utilities (yes / no) - HFSTOOLS="no" - - # Support for partitioning and formating disks in initramfs (yes / no) - # This adds support for parted and mkfs.ext3/4 to initramfs for OEM usage - INITRAMFS_PARTED_SUPPORT="no" - - # build with swap support (yes / no) - SWAP_SUPPORT="yes" - # Some devices have internal storage. - INSTALLER_SUPPORT="yes" - - # swap support enabled per default (yes / no) - SWAP_ENABLED_DEFAULT="yes" - - # swapfile size if SWAP_SUPPORT=yes in MB - SWAPFILESIZE="384" - - # cron support (yes / no) - CRON_SUPPORT="no" - - # Settings package name - blank if not required - DISTRO_PKG_SETTINGS="" - - # htop tool (yes / no) - HTOP_TOOL="yes" + INSTALLER_SUPPORT="no" diff --git a/projects/Rockchip/devices/RK3588/options b/projects/Rockchip/devices/RK3588/options index 86590301c7..4ae5d1e4f8 100755 --- a/projects/Rockchip/devices/RK3588/options +++ b/projects/Rockchip/devices/RK3588/options @@ -83,84 +83,10 @@ # for a list of additional drivers see packages/linux-drivers # Space separated list is supported, # e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2" - ADDITIONAL_DRIVERS+="" - - # build and install driver addons (yes / no) - DRIVER_ADDONS_SUPPORT="no" - - # driver addons to install: - # for a list of additinoal drivers see packages/linux-driver-addons - # Space separated list is supported, - DRIVER_ADDONS="" + ADDITIONAL_DRIVERS="" # debug tty path DEBUG_TTY="/dev/ttyFIQ0" - # Disable 32BIT support - ENABLE_32BIT="true" - - # build and install bluetooth support (yes / no) - BLUETOOTH_SUPPORT="yes" - - # build and install Avahi (Zeroconf) daemon (yes / no) - AVAHI_DAEMON="no" - - # build with NFS support (mounting nfs shares via the OS) (yes / no) - NFS_SUPPORT="no" - - # build with Samba Client support (mounting samba shares via the OS) (yes / no) - SAMBA_SUPPORT="no" - - # build and install Samba Server (yes / no) - SAMBA_SERVER="yes" - - # build and install SFTP Server (yes / no) - SFTP_SERVER="yes" - - # build and install Simple HTTP Server (yes / no) - SIMPLE_HTTP_SERVER="yes" - - # build and install OpenVPN support (yes / no) - OPENVPN_SUPPORT="no" - - # build and install ZeroTier support (yes / no) - ZEROTIER_SUPPORT="yes" - - # build and install diskmounter support (udevil) - # this service provide auto mounting support for external drives in the - # mediacenter also automount internally drives at boottime via udev (yes / no) - UDEVIL="yes" - - # build and install exFAT fuse support (yes / no) - EXFAT="yes" - - # build and install NTFS-3G fuse support (yes / no) - NTFS3G="no" - - # build and install hfs filesystem utilities (yes / no) - HFSTOOLS="no" - - # Support for partitioning and formating disks in initramfs (yes / no) - # This adds support for parted and mkfs.ext3/4 to initramfs for OEM usage - INITRAMFS_PARTED_SUPPORT="no" - - # build with swap support (yes / no) - SWAP_SUPPORT="yes" - - # swap support enabled per default (yes / no) - SWAP_ENABLED_DEFAULT="yes" - - # swapfile size if SWAP_SUPPORT=yes in MB - SWAPFILESIZE="384" - # Some devices have internal storage. INSTALLER_SUPPORT="yes" - - # cron support (yes / no) - CRON_SUPPORT="no" - - # Settings package name - blank if not required - DISTRO_PKG_SETTINGS="" - - # htop tool (yes / no) - HTOP_TOOL="yes" diff --git a/projects/Rockchip/options b/projects/Rockchip/options index 5587c70a5b..7cf8bc2428 100755 --- a/projects/Rockchip/options +++ b/projects/Rockchip/options @@ -32,9 +32,6 @@ # OpenGL-ES implementation to use (no / mesa) OPENGLES="mesa" - # include uvesafb support (yes / no) - UVESAFB_SUPPORT="no" - # Displayserver to use (no / wl) DISPLAYSERVER="no" @@ -46,9 +43,6 @@ # e.g. GRAPHIC_DRIVERS="i915 i965 r300 r600 radeonsi nvidia" GRAPHIC_DRIVERS="" - # Modules to install in initramfs for early boot - INITRAMFS_MODULES="" - # additional Firmware to use ( ) # Space separated list is supported, # e.g. FIRMWARE="" @@ -60,20 +54,9 @@ # build and install CEC framework support (yes / no) CEC_FRAMEWORK_SUPPORT="yes" - # build with installer (yes / no) - INSTALLER_SUPPORT="no" - # Start boot partition at 16MiB, same as https://github.com/rockchip-linux/build images SYSTEM_PART_START=32768 - # build and install driver addons (yes / no) - DRIVER_ADDONS_SUPPORT="yes" - - # driver addons to install: - # for a list of additinoal drivers see packages/linux-driver-addons - # Space separated list is supported, - DRIVER_ADDONS="" - # debug tty path DEBUG_TTY="/dev/ttyS2" diff --git a/projects/Rockchip/packages/u-boot/package.mk b/projects/Rockchip/packages/u-boot/package.mk index 2a2f824882..39e7fdbee1 100644 --- a/projects/Rockchip/packages/u-boot/package.mk +++ b/projects/Rockchip/packages/u-boot/package.mk @@ -11,26 +11,28 @@ PKG_DEPENDS_TARGET="toolchain Python3 swig:host rkbin glibc pyelftools:host" PKG_LONGDESC="Rockchip U-Boot is a bootloader for embedded systems." PKG_PATCH_DIRS+="${DEVICE}" +PKG_NEED_UNPACK="$PROJECT_DIR/$PROJECT/bootloader" + case ${DEVICE} in RK3588*) PKG_VERSION="ad0cfba1ac51e8dd8b039f6c56b9c9f9a679df91" PKG_URL="${PKG_SITE}/rk3588-uboot/archive/${PKG_VERSION}.tar.gz" - ;; + ;; RK3566*) PKG_URL="https://github.com/u-boot/u-boot.git" - PKG_VERSION="e8f2404e093daf6cc3ac2b3233e3c6770d13e371" + PKG_VERSION="9cba29b19f43f9450117e8bc89e7dda691ed5ab5" PKG_GIT_CLONE_BRANCH="master" - ;; + ;; RK3399) PKG_DEPENDS_TARGET+=" atf openssl:host" - PKG_VERSION="2024.01" + PKG_VERSION="2024.04" PKG_URL="https://ftp.denx.de/pub/u-boot/${PKG_NAME}-${PKG_VERSION}.tar.bz2" - ;; + ;; RK3326) PKG_VERSION="0e26e35cb18a80005b7de45c95858c86a2f7f41e" PKG_URL="${PKG_SITE}/hardkernel-uboot/archive/${PKG_VERSION}.tar.gz" PKG_GIT_CLONE_BRANCH="RK3326" - ;; + ;; esac PKG_IS_KERNEL_PKG="yes" @@ -57,23 +59,18 @@ make_target() { if [ -z "${UBOOT_CONFIG}" ]; then echo "UBOOT_CONFIG must be set to build an image" else - if [ -e "${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/u-boot/${UBOOT_CONFIG}" ] - then + if [ -e "${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/u-boot/${UBOOT_CONFIG}" ]; then cp ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/u-boot/${UBOOT_CONFIG} configs fi [ "${BUILD_WITH_DEBUG}" = "yes" ] && PKG_DEBUG=1 || PKG_DEBUG=0 - if [[ "${PKG_BL31}" =~ ^/bin ]] - then + if [[ "${PKG_BL31}" =~ ^/bin ]]; then PKG_BL31="$(get_build_dir rkbin)/${PKG_BL31}" fi - if [[ "${PKG_LOADER}" =~ ^/bin ]] - then + if [[ "${PKG_LOADER}" =~ ^/bin ]]; then PKG_LOADER="$(get_build_dir rkbin)/${PKG_LOADER}" fi - if [[ "${PKG_SOC}" =~ "rk3568" ]] || \ - [[ "${PKG_SOC}" =~ "rk356x" ]] - then + if [[ "${PKG_SOC}" =~ "rk3568" ]] || [[ "${PKG_SOC}" =~ "rk356x" ]]; then # rk3566 device echo "Building for GPT (${UBOOT_DTB})..." echo "toolchain (${TOOLCHAIN})" @@ -85,8 +82,7 @@ make_target() { DEBUG=${PKG_DEBUG} CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" LDFLAGS="--lssl -lcrypto" ARCH=arm64 make ${UBOOT_CONFIG} ${PKG_LOADER} u-boot.dtb u-boot.img tools HOSTCC="${HOST_CC}" HOSTLDFLAGS="-L${TOOLCHAIN}/lib" HOSTCFLAGS="-I${TOOLCHAIN}/include" echo "end make" DEBUG=${PKG_DEBUG} CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" LDFLAGS="" ARCH=arm64 _python_sysroot="${TOOLCHAIN}" _python_prefix=/ _python_exec_prefix=/ make HOSTCC="${HOST_CC}" HOSTLDFLAGS="-L${TOOLCHAIN}/lib" HOSTCFLAGS="-I${TOOLCHAIN}/include" HOSTSTRIP="true" CONFIG_MKIMAGE_DTC_PATH="scripts/dtc/dtc" - elif [[ "${PKG_SOC}" =~ "rk3588" ]] - then + elif [[ "${PKG_SOC}" =~ "rk3588" ]]; then # rk3588 devices DEBUG=${PKG_DEBUG} CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" LDFLAGS="" ARCH=arm64 make mrproper DEBUG=${PKG_DEBUG} CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" LDFLAGS="" ARCH=arm64 make ${UBOOT_CONFIG} BL31=${PKG_BL31} ${PKG_LOADER} u-boot.dtb u-boot.itb CONFIG_MKIMAGE_DTC_PATH="scripts/dtc/dtc" diff --git a/projects/Rockchip/packages/u-boot/patches/RK3566-X55 b/projects/Rockchip/packages/u-boot/patches/RK3566-X55 new file mode 120000 index 0000000000..9207b5754b --- /dev/null +++ b/projects/Rockchip/packages/u-boot/patches/RK3566-X55 @@ -0,0 +1 @@ +RK3566 \ No newline at end of file diff --git a/projects/Rockchip/packages/u-boot/patches/RK3566/001-v3-add_additional_boards_and_features_to_rgxx3.patch b/projects/Rockchip/packages/u-boot/patches/RK3566/001-v3-add_additional_boards_and_features_to_rgxx3.patch index ace6886dd8..5c34ee00f5 100644 --- a/projects/Rockchip/packages/u-boot/patches/RK3566/001-v3-add_additional_boards_and_features_to_rgxx3.patch +++ b/projects/Rockchip/packages/u-boot/patches/RK3566/001-v3-add_additional_boards_and_features_to_rgxx3.patch @@ -100,7 +100,7 @@ index eb8f65ae4..d2308768b 100644 return 0; } diff --git a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c -index d05502f67..e12a85a02 100644 +index 099eea60c3..043769dfe0 100644 --- a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c +++ b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c @@ -5,6 +5,7 @@ @@ -109,24 +109,24 @@ index d05502f67..e12a85a02 100644 #include +#include #include + #include #include - #include -@@ -150,11 +151,14 @@ static const struct rg353_panel rg353_panel_details[] = { +@@ -220,12 +221,12 @@ void read_func_button(void) }; /* - * Start LED very early so user knows device is on. Set color +- * to red. + * Check if rockchip_dnl button is pressed and reboot into rockusb if -+ * true. Start LED very early so user knows device is on. Set color - * to red. ++ * true. Start LED very early so user knows device is on. Set color* */ void spl_board_init(void) { +- read_func_button(); + setup_boot_mode(); -+ + /* Set GPIO0_C5, GPIO0_C6, and GPIO0_C7 to output. */ writel(GPIO_WRITEMASK(GPIO_C7 | GPIO_C6 | GPIO_C5) | \ - (GPIO_C7 | GPIO_C6 | GPIO_C5), diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 6405374bc..bd3fe74fc 100644 --- a/common/spl/Kconfig @@ -146,80 +146,17 @@ index 6405374bc..bd3fe74fc 100644 bool "Support CACHE drivers" help diff --git a/configs/anbernic-rgxx3-rk3566_defconfig b/configs/anbernic-rgxx3-rk3566_defconfig -index ed6643d9d..4e72f7581 100644 +index c8c9238f96..923c05d130 100644 --- a/configs/anbernic-rgxx3-rk3566_defconfig +++ b/configs/anbernic-rgxx3-rk3566_defconfig -@@ -3,6 +3,7 @@ CONFIG_SKIP_LOWLEVEL_INIT=y - CONFIG_COUNTER_FREQUENCY=24000000 - CONFIG_ARCH_ROCKCHIP=y - CONFIG_TEXT_BASE=0x00a00000 -+CONFIG_SPL_GPIO=y - CONFIG_SPL_LIBCOMMON_SUPPORT=y - CONFIG_SPL_LIBGENERIC_SUPPORT=y - CONFIG_NR_DRAM_BANKS=2 -@@ -24,7 +25,9 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 - CONFIG_DEBUG_UART=y - CONFIG_FIT=y - CONFIG_FIT_VERBOSE=y -+CONFIG_SPL_FIT_SIGNATURE=y - CONFIG_SPL_LOAD_FIT=y -+CONFIG_LEGACY_IMAGE_FORMAT=y - CONFIG_OF_BOARD_SETUP=y - CONFIG_OF_STDOUT_VIA_ALIAS=y - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3566-anbernic-rgxx3.dtb" -@@ -32,7 +35,7 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3566-anbernic-rgxx3.dtb" - # CONFIG_DISPLAY_CPUINFO is not set - CONFIG_DISPLAY_BOARDINFO_LATE=y - CONFIG_BOARD_RNG_SEED=y --CONFIG_SPL_MAX_SIZE=0x20000 -+CONFIG_SPL_MAX_SIZE=0x40000 +@@ -31,6 +31,7 @@ CONFIG_SPL_MAX_SIZE=0x40000 CONFIG_SPL_PAD_TO=0x7f8000 - CONFIG_SPL_HAS_BSS_LINKER_SECTION=y - CONFIG_SPL_BSS_START_ADDR=0x4000000 -@@ -41,6 +44,8 @@ CONFIG_SPL_BOARD_INIT=y + CONFIG_SPL_BOARD_INIT=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set - # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set - CONFIG_SPL_STACK_R=y +CONFIG_SPL_ADC=y -+CONFIG_SPL_POWER=y + CONFIG_SPL_POWER=y CONFIG_SPL_ATF=y CONFIG_CMD_PWM=y - CONFIG_CMD_GPT=y -@@ -50,8 +55,10 @@ CONFIG_CMD_MMC=y - # CONFIG_SPL_DOS_PARTITION is not set - CONFIG_SPL_OF_CONTROL=y - CONFIG_OF_LIVE=y -+CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" - CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y - # CONFIG_NET is not set -+CONFIG_SPL_DM_SEQ_ALIAS=y - CONFIG_SPL_REGMAP=y - CONFIG_SPL_SYSCON=y - CONFIG_SPL_CLK=y -@@ -67,13 +74,13 @@ CONFIG_MMC_SDHCI=y - CONFIG_MMC_SDHCI_SDMA=y - CONFIG_MMC_SDHCI_ROCKCHIP=y - CONFIG_PHY_ROCKCHIP_INNO_DSIDPHY=y -+CONFIG_SPL_PINCTRL=y - CONFIG_DM_PMIC=y - CONFIG_DM_PMIC_FAN53555=y - CONFIG_PMIC_RK8XX=y --CONFIG_REGULATOR_PWM=y --CONFIG_DM_REGULATOR_GPIO=y -+CONFIG_SPL_DM_REGULATOR=y -+CONFIG_SPL_DM_REGULATOR_FIXED=y - CONFIG_REGULATOR_RK8XX=y --CONFIG_DM_REGULATOR_SCMI=y - CONFIG_PWM_ROCKCHIP=y - CONFIG_SPL_RAM=y - # CONFIG_RAM_ROCKCHIP_DEBUG is not set -@@ -89,5 +96,6 @@ CONFIG_VIDEO_ROCKCHIP=y - CONFIG_DISPLAY_ROCKCHIP_DW_MIPI=y - CONFIG_VIDEO_BRIDGE=y - CONFIG_REGEX=y -+# CONFIG_RSA is not set - CONFIG_ERRNO_STR=y - # CONFIG_EFI_LOADER is not set diff --git a/drivers/Makefile b/drivers/Makefile index bf73b7718..81ba2c534 100644 --- a/drivers/Makefile diff --git a/projects/Rockchip/packages/u-boot/patches/RK3566/002-v2-add-powkiddy-x55.patch b/projects/Rockchip/packages/u-boot/patches/RK3566/002-v2-add-powkiddy-x55.patch index 91f6bfaa1e..12a23616c9 100644 --- a/projects/Rockchip/packages/u-boot/patches/RK3566/002-v2-add-powkiddy-x55.patch +++ b/projects/Rockchip/packages/u-boot/patches/RK3566/002-v2-add-powkiddy-x55.patch @@ -56,17 +56,17 @@ Signed-off-by: Chris Morgan create mode 100644 include/configs/powkiddy-x55-rk3566.h diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile -index 5fc888680b..6e5cb7c3e9 100644 +index 2634bb4c9a..6d4df7bccc 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile -@@ -172,6 +172,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ - +@@ -148,6 +148,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ + dtb-$(CONFIG_ROCKCHIP_RK3568) += \ rk3566-anbernic-rgxx3.dtb \ + rk3566-powkiddy-x55.dtb \ + rk3566-pinetab2-v0.1.dtb \ + rk3566-pinetab2-v2.0.dtb \ rk3566-quartz64-a.dtb \ - rk3566-quartz64-b.dtb \ - rk3566-radxa-cm3-io.dtb \ diff --git a/arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi b/arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi new file mode 100644 index 0000000000..1a3089b598 diff --git a/projects/Rockchip/packages/u-boot/patches/RK3566/003-fix-dtb-and-vs.patch b/projects/Rockchip/packages/u-boot/patches/RK3566/003-fix-dtb-and-vs.patch index 5073a95098..fc68575516 100644 --- a/projects/Rockchip/packages/u-boot/patches/RK3566/003-fix-dtb-and-vs.patch +++ b/projects/Rockchip/packages/u-boot/patches/RK3566/003-fix-dtb-and-vs.patch @@ -1,10 +1,10 @@ diff --git a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c -index d05502f67..98b3bc145 100644 +index 043769dfe0..b44c0b63fe 100644 --- a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c +++ b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c -@@ -32,7 +32,7 @@ - - #define GPIO_WRITEMASK(bits) ((bits) << 16) +@@ -45,7 +45,7 @@ + #define SARADC_INPUT_SRC_MSK 0x7 + #define SARADC_POWER_CTRL BIT(3) -#define DTB_DIR "rockchip/" +#define DTB_DIR "" @@ -12,11 +12,11 @@ index d05502f67..98b3bc145 100644 struct rg3xx_model { const u16 adc_value; diff --git a/configs/anbernic-rgxx3-rk3566_defconfig b/configs/anbernic-rgxx3-rk3566_defconfig -index ed6643d9d..83e8358a0 100644 +index c8c9238f96..f26801f4eb 100644 --- a/configs/anbernic-rgxx3-rk3566_defconfig +++ b/configs/anbernic-rgxx3-rk3566_defconfig -@@ -27,7 +27,7 @@ CONFIG_FIT_VERBOSE=y - CONFIG_SPL_LOAD_FIT=y +@@ -22,7 +22,7 @@ CONFIG_SPL_LOAD_FIT=y + CONFIG_LEGACY_IMAGE_FORMAT=y CONFIG_OF_BOARD_SETUP=y CONFIG_OF_STDOUT_VIA_ALIAS=y -CONFIG_DEFAULT_FDT_FILE="rockchip/rk3566-anbernic-rgxx3.dtb" diff --git a/projects/Rockchip/packages/u-boot/patches/RK3566/004-rgb10max3.patch b/projects/Rockchip/packages/u-boot/patches/RK3566/004-rgb10max3.patch deleted file mode 100644 index da07cc5526..0000000000 --- a/projects/Rockchip/packages/u-boot/patches/RK3566/004-rgb10max3.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c -index 194605ff06..ee498631ba 100644 ---- a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c -+++ b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c -@@ -49,6 +49,7 @@ enum rgxx3_device_id { - RG353V, - RG503, - RGB30, -+ RGB10MAX3, - RK2023, - RGARCD, - /* Devices with duplicate ADC value */ -@@ -94,6 +95,13 @@ static const struct rg3xx_model rg3xx_model_details[] = { - .fdtfile = DTB_DIR "rk3566-powkiddy-rgb30.dtb", - .detect_panel = 0, - }, -+ [RGB10MAX3] = { -+ .adc_value = 765, /* Observed average from device */ -+ .board = "rk3566-powkiddy-rgb10max3", -+ .board_name = "RGB10MAX3", -+ .fdtfile = DTB_DIR "rk3566-powkiddy-rgb10max3.dtb", -+ .detect_panel = 0, -+ }, - [RK2023] = { - .adc_value = 635, /* Observed average from device */ - .board = "rk3566-powkiddy-rk2023", diff --git a/projects/Rockchip/patches/linux/RK3399/005-adc-revert.patch b/projects/Rockchip/patches/linux/RK3399/005-adc-revert.patch index 3e9e69490b..88bd17f8af 100644 --- a/projects/Rockchip/patches/linux/RK3399/005-adc-revert.patch +++ b/projects/Rockchip/patches/linux/RK3399/005-adc-revert.patch @@ -1,6 +1,6 @@ diff -rupN linux.orig/drivers/iio/adc/rockchip_saradc.c linux/drivers/iio/adc/rockchip_saradc.c ---- linux.orig/drivers/iio/adc/rockchip_saradc.c 2024-01-09 14:07:12.430393829 +0000 -+++ linux/drivers/iio/adc/rockchip_saradc.c 2024-01-09 16:30:43.561613614 +0000 +--- linux.orig/drivers/iio/adc/rockchip_saradc.c 2024-04-03 20:56:47.771012045 +0000 ++++ linux/drivers/iio/adc/rockchip_saradc.c 2024-04-03 20:57:33.115997084 +0000 @@ -4,13 +4,13 @@ * Copyright (C) 2014 ROCKCHIP, Inc. */ @@ -34,7 +34,7 @@ diff -rupN linux.orig/drivers/iio/adc/rockchip_saradc.c linux/drivers/iio/adc/ro -#define SARADC2_START BIT(4) -#define SARADC2_SINGLE_MODE BIT(5) - --#define SARADC2_CONV_CHANNELS GENMASK(15, 0) +-#define SARADC2_CONV_CHANNELS GENMASK(3, 0) - -struct rockchip_saradc; - @@ -73,12 +73,12 @@ diff -rupN linux.orig/drivers/iio/adc/rockchip_saradc.c linux/drivers/iio/adc/ro - writel_relaxed(0xc, info->regs + SARADC_T_DAS_SOC); - writel_relaxed(0x20, info->regs + SARADC_T_PD_SOC); - val = FIELD_PREP(SARADC2_EN_END_INT, 1); -- val |= val << 16; +- val |= SARADC2_EN_END_INT << 16; - writel_relaxed(val, info->regs + SARADC2_END_INT_EN); - val = FIELD_PREP(SARADC2_START, 1) | - FIELD_PREP(SARADC2_SINGLE_MODE, 1) | - FIELD_PREP(SARADC2_CONV_CHANNELS, chn); -- val |= val << 16; +- val |= (SARADC2_START | SARADC2_SINGLE_MODE | SARADC2_CONV_CHANNELS) << 16; - writel(val, info->regs + SARADC2_CONV_CON); -} - diff --git a/projects/Rockchip/patches/linux/RK3566-X55 b/projects/Rockchip/patches/linux/RK3566-X55 new file mode 120000 index 0000000000..9207b5754b --- /dev/null +++ b/projects/Rockchip/patches/linux/RK3566-X55 @@ -0,0 +1 @@ +RK3566 \ No newline at end of file diff --git a/projects/Rockchip/patches/linux/RK3566/028-fix-8821cs-sdio-errors-x55.patch b/projects/Rockchip/patches/linux/RK3566/028-fix-8821cs-sdio-errors-x55.patch new file mode 100644 index 0000000000..593e66584d --- /dev/null +++ b/projects/Rockchip/patches/linux/RK3566/028-fix-8821cs-sdio-errors-x55.patch @@ -0,0 +1,26 @@ +From faf18aead7af8e10a68c992ae02469144976b794 Mon Sep 17 00:00:00 2001 +From: Sparticuz +Date: Sat, 16 Mar 2024 01:40:49 +0400 +Subject: [PATCH 1/1] Fix 8821cs sdio errors + +--- + arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts b/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts +index 4786b19..10900d5 100644 +--- a/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts ++++ b/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts +@@ -838,6 +838,9 @@ + pinctrl-0 = <&sdmmc1_bus4>, <&sdmmc1_cmd>, <&sdmmc1_clk>; + pinctrl-names = "default"; + vmmc-supply = <&vcc_wifi>; ++ no-mmc; ++ no-sd; ++ sd-uhs-sdr50; + status = "okay"; + }; + +-- +2.34.1 + diff --git a/projects/Rockchip/patches/linux/RK3566/029-Overclock-powkiddy-x55-to-1.992GHz.patch b/projects/Rockchip/patches/linux/RK3566/029-Overclock-powkiddy-x55-to-1.992GHz.patch new file mode 100644 index 0000000000..175fefb8a1 --- /dev/null +++ b/projects/Rockchip/patches/linux/RK3566/029-Overclock-powkiddy-x55-to-1.992GHz.patch @@ -0,0 +1,30 @@ +0001-RK3566-X55-Overclock-powkiddy-x55-to-1.992GHz.patch +00:00:00 2001 +From: AnanJaser +Date: Mon, 18 Mar 2024 01:31:55 +0400 +Subject: [PATCH 1/1] RK3566-X55: Overclock powkiddy-x55 to 1.992GHz + +--- + arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts b/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts +index 10900d5..ab627cb 100644 +--- a/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts ++++ b/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts +@@ -927,3 +927,12 @@ + remote-endpoint = <&dsi0_in_vp1>; + }; + }; ++ ++&cpu0_opp_table { ++ opp-1992000000 { ++ opp-hz = /bits/ 64 <1992000000>; ++ opp-microvolt = <1150000 1150000 1150000>; ++ clock-latency-ns = <40000>; ++ }; ++}; ++ +-- +2.34.1 + diff --git a/projects/Rockchip/patches/linux/RK3566/029-singleadc-quadsar_adc-joypad-x55.patch b/projects/Rockchip/patches/linux/RK3566/029-singleadc-quadsar_adc-joypad-x55.patch new file mode 100644 index 0000000000..f3403be60f --- /dev/null +++ b/projects/Rockchip/patches/linux/RK3566/029-singleadc-quadsar_adc-joypad-x55.patch @@ -0,0 +1,2155 @@ +From 271086da26bad5312e0281cfdca9e4d0c6204b8e Mon Sep 17 00:00:00 2001 +From: AnanJaser +Date: Tue, 2 Apr 2024 04:09:38 +0400 +Subject: [PATCH 1/7] drivers: input: singleadc_quadsaradc joystick + +* Duplicate singleadc driver for modifications +--- + drivers/input/joystick/Kconfig | 5 + + drivers/input/joystick/Makefile | 3 +- + .../input/joystick/singleadc_quadsaradc_joy.c | 1087 +++++++++++++++++ + 3 files changed, 1094 insertions(+), 1 deletion(-) + create mode 100644 drivers/input/joystick/singleadc_quadsaradc_joy.c + +diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig +index 32982bd77..b9a6d626c 100644 +--- a/drivers/input/joystick/Kconfig ++++ b/drivers/input/joystick/Kconfig +@@ -398,6 +398,11 @@ config JOYSTICK_SINGLEADCJOY + help + The 1-in 4-out SARADC joypad driver. + ++config JOYSTICK_SINGLEADC_QUADSAR_JOY ++ tristate "Quad SARADC dual-joystick gamepad driver" ++ help ++ The 4-in 4-out SARADC joypad driver. ++ + config JOYSTICK_N64 + bool "N64 controller" + depends on MACH_NINTENDO64 +diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile +index f0c22c069..5d48aafad 100644 +--- a/drivers/input/joystick/Makefile ++++ b/drivers/input/joystick/Makefile +@@ -31,7 +31,8 @@ obj-$(CONFIG_JOYSTICK_QWIIC) += qwiic-joystick.o + obj-$(CONFIG_JOYSTICK_SEESAW) += adafruit-seesaw.o + obj-$(CONFIG_JOYSTICK_SENSEHAT) += sensehat-joystick.o + obj-$(CONFIG_JOYSTICK_SIDEWINDER) += sidewinder.o +-obj-$(CONFIG_JOYSTICK_SINGLEADCJOY) += singleadcjoy.o ++obj-$(CONFIG_JOYSTICK_SINGLEADCJOY) += singleadcjoy.o ++obj-$(CONFIG_JOYSTICK_SINGLEADC_QUADSAR_JOY) += singleadc_quadsaradc_joy.o + obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o + obj-$(CONFIG_JOYSTICK_SPACEORB) += spaceorb.o + obj-$(CONFIG_JOYSTICK_STINGER) += stinger.o +diff --git a/drivers/input/joystick/singleadc_quadsaradc_joy.c b/drivers/input/joystick/singleadc_quadsaradc_joy.c +new file mode 100644 +index 000000000..f8e7f04c2 +--- /dev/null ++++ b/drivers/input/joystick/singleadc_quadsaradc_joy.c +@@ -0,0 +1,1087 @@ ++/*----------------------------------------------------------------------------*/ ++ ++/* ++ * Copyright (c) 2008-2021 Anbernic ++ */ ++ ++/* ++ * Single SARADC dual-joystick gamepad driver ++ */ ++ ++/*----------------------------------------------------------------------------*/ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/*----------------------------------------------------------------------------*/ ++#define DRV_NAME "retrogame_joypad" ++#define __LEFT_JOYSTICK_INVERT__ ++#define __MURMUR__ ++/*----------------------------------------------------------------------------*/ ++#define ADC_MAX_VOLTAGE 1800 ++#define ADC_DATA_TUNING(x, p) ((x * p) / 100) ++#define ADC_TUNING_DEFAULT 180 ++ ++struct bt_adc { ++ /* report value (mV) */ ++ int value; ++ /* report type */ ++ int report_type; ++ /* input device init value (mV) */ ++ int max, min; ++ /* calibrated adc value */ ++ int cal; ++ /* adc scale value */ ++ int scale; ++ /* invert report */ ++ bool invert; ++ /* amux channel */ ++ int amux_ch; ++ /* adc data tuning value([percent), p = positive, n = negative */ ++ int tuning_p, tuning_n; ++}; ++ ++struct analog_mux { ++ /* IIO ADC Channel : amux connect channel */ ++ struct iio_channel *iio_ch; ++ /* analog mux select(a,b) gpio */ ++ int sel_a_gpio, sel_b_gpio; ++ /* analog mux enable gpio */ ++ int en_gpio; ++}; ++ ++struct bt_gpio { ++ /* GPIO Request label */ ++ const char *label; ++ /* GPIO Number */ ++ int num; ++ /* report type */ ++ int report_type; ++ /* report linux code */ ++ int linux_code; ++ /* prev button value */ ++ bool old_value; ++ /* button press level */ ++ bool active_level; ++}; ++ ++struct joypad { ++ struct device *dev; ++ int poll_interval; ++ ++ /* report enable/disable */ ++ bool enable; ++ ++ /* analog mux & joystick control */ ++ struct analog_mux *amux; ++ /* analog mux max count */ ++ int amux_count; ++ /* analog button */ ++ struct bt_adc *adcs; ++ ++ /* report interval (ms) */ ++ int bt_gpio_count; ++ struct bt_gpio *gpios; ++ ++ /* button auto repeat */ ++ int auto_repeat; ++ ++ /* report threshold (mV) */ ++ int bt_adc_fuzz, bt_adc_flat; ++ /* adc read value scale */ ++ int bt_adc_scale; ++ /* joystick deadzone control */ ++ int bt_adc_deadzone; ++ ++ struct mutex lock; ++ ++ /* amux debug channel */ ++ int debug_ch; ++}; ++ ++/*----------------------------------------------------------------------------*/ ++// ++// set to the value in the boot.ini file. (if exist) ++// ++/*----------------------------------------------------------------------------*/ ++static unsigned int g_button_adc_fuzz = 0; ++static unsigned int g_button_adc_flat = 0; ++static unsigned int g_button_adc_scale = 0; ++static unsigned int g_button_adc_deadzone = 0; ++ ++static int button_adc_fuzz(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ g_button_adc_fuzz = simple_strtoul(str, NULL, 10); ++ return 0; ++} ++__setup("button-adc-fuzz=", button_adc_fuzz); ++ ++static int button_adc_flat(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ g_button_adc_flat = simple_strtoul(str, NULL, 10); ++ return 0; ++} ++__setup("button-adc-flat=", button_adc_flat); ++ ++static int button_adc_scale(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ g_button_adc_scale = simple_strtoul(str, NULL, 10); ++ return 0; ++} ++__setup("button-adc-scale=", button_adc_scale); ++ ++static int button_adc_deadzone(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ g_button_adc_deadzone = simple_strtoul(str, NULL, 10); ++ return 0; ++} ++__setup("button-adc-deadzone=", button_adc_deadzone); ++ ++/*----------------------------------------------------------------------------*/ ++/*----------------------------------------------------------------------------*/ ++static int joypad_amux_select(struct analog_mux *amux, int channel) ++{ ++ /* select mux channel */ ++ gpio_set_value(amux->en_gpio, 0); ++ ++ switch(channel) { ++ case 0: /* EVENT (ABS_RY) */ ++ gpio_set_value(amux->sel_a_gpio, 0); ++ gpio_set_value(amux->sel_b_gpio, 0); ++ break; ++ case 1: /* EVENT (ABS_RX) */ ++ gpio_set_value(amux->sel_a_gpio, 0); ++ gpio_set_value(amux->sel_b_gpio, 1); ++ break; ++ case 2: /* EVENT (ABS_Y) */ ++ gpio_set_value(amux->sel_a_gpio, 1); ++ gpio_set_value(amux->sel_b_gpio, 0); ++ break; ++ case 3: /* EVENT (ABS_X) */ ++ gpio_set_value(amux->sel_a_gpio, 1); ++ gpio_set_value(amux->sel_b_gpio, 1); ++ break; ++ default: ++ /* amux disanle */ ++ gpio_set_value(amux->en_gpio, 1); ++ return -1; ++ } ++ /* mux swtiching speed : 35ns(on) / 9ns(off) */ ++ usleep_range(10, 20); ++ return 0; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static int joypad_adc_read(struct analog_mux *amux, struct bt_adc *adc) ++{ ++ int value; ++ ++ ++ if (joypad_amux_select(amux, adc->amux_ch)) ++ return 0; ++ ++ iio_read_channel_raw(amux->iio_ch, &value); ++ ++ value *= adc->scale; ++#ifdef __LEFT_JOYSTICK_INVERT__ ++ return value; ++#else ++ return (adc->invert ? (adc->max - value) : value); ++#endif ++} ++ ++/*----------------------------------------------------------------------------*/ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/retrogame_joypad/poll_interval [rw] ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_store_poll_interval(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, ++ size_t count) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ mutex_lock(&joypad->lock); ++ joypad->poll_interval = simple_strtoul(buf, NULL, 10); ++ mutex_unlock(&joypad->lock); ++ ++ return count; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_poll_interval(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ return sprintf(buf, "%d\n", joypad->poll_interval); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(poll_interval, S_IWUSR | S_IRUGO, ++ joypad_show_poll_interval, ++ joypad_store_poll_interval); ++ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/retrogame_joypad/adc_fuzz [r] ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_adc_fuzz(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ return sprintf(buf, "%d\n", joypad->bt_adc_fuzz); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(adc_fuzz, S_IWUSR | S_IRUGO, ++ joypad_show_adc_fuzz, ++ NULL); ++ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/retrogame_joypad/adc_flat [r] ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_adc_flat(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ return sprintf(buf, "%d\n", joypad->bt_adc_flat); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(adc_flat, S_IWUSR | S_IRUGO, ++ joypad_show_adc_flat, ++ NULL); ++ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/retrogame_joypad/enable [rw] ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_store_enable(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, ++ size_t count) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ mutex_lock(&joypad->lock); ++ joypad->enable = simple_strtoul(buf, NULL, 10); ++ mutex_unlock(&joypad->lock); ++ ++ return count; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_enable(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ return sprintf(buf, "%d\n", joypad->enable); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(enable, S_IWUSR | S_IRUGO, ++ joypad_show_enable, ++ joypad_store_enable); ++ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/retrogame_joypad/adc_cal [rw] ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_store_adc_cal(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, ++ size_t count) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ bool calibration; ++ ++ calibration = simple_strtoul(buf, NULL, 10); ++ ++ if (calibration) { ++ int nbtn; ++ ++ mutex_lock(&joypad->lock); ++ for (nbtn = 0; nbtn < joypad->amux_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ ++ adc->value = joypad_adc_read(joypad->amux, adc); ++ if (!adc->value) { ++ dev_err(joypad->dev, "%s : saradc channels[%d]!\n", ++ __func__, nbtn); ++ continue; ++ } ++ adc->cal = adc->value; ++ } ++ mutex_unlock(&joypad->lock); ++ } ++ return count; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_adc_cal(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ int nbtn; ++ ssize_t pos; ++ ++ for (nbtn = 0, pos = 0; nbtn < joypad->amux_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ pos += sprintf(&buf[pos], "adc[%d]->cal = %d\n", ++ nbtn, adc->cal); ++ } ++ pos += sprintf(&buf[pos], "adc scale = %d\n", joypad->bt_adc_scale); ++ return pos; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(adc_cal, S_IWUSR | S_IRUGO, ++ joypad_show_adc_cal, ++ joypad_store_adc_cal); ++ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/retrogame_joypad/amux_debug [rw] ++ * ++ * echo [debug channel] > amux_debug ++ * cat amux_debug : debug channel mux set & adc read ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_store_amux_debug(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, ++ size_t count) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ joypad->debug_ch = simple_strtoul(buf, NULL, 10); ++ ++ /* if error than default setting(debug_ch = 0) */ ++ if (joypad->debug_ch > joypad->amux_count) ++ joypad->debug_ch = 0; ++ ++ return count; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_amux_debug(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ struct analog_mux *amux = joypad->amux; ++ ssize_t pos; ++ int value; ++ ++ mutex_lock(&joypad->lock); ++ ++ /* disable poll driver */ ++ if (joypad->enable) ++ joypad->enable = false; ++ ++ if (joypad_amux_select(amux, joypad->debug_ch)) ++ goto err_out; ++ ++ if (iio_read_channel_processed(amux->iio_ch, &value)) ++ goto err_out; ++ ++ pos = sprintf(buf, "amux ch[%d], adc scale = %d, adc value = %d\n", ++ joypad->debug_ch, joypad->bt_adc_scale, ++ value * joypad->bt_adc_scale); ++ goto out; ++ ++err_out: ++ pos = sprintf(buf, "error : amux setup & adc read!\n"); ++out: ++ mutex_unlock(&joypad->lock); ++ return pos; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(amux_debug, S_IWUSR | S_IRUGO, ++ joypad_show_amux_debug, ++ joypad_store_amux_debug); ++ ++/*----------------------------------------------------------------------------*/ ++/*----------------------------------------------------------------------------*/ ++static struct attribute *joypad_attrs[] = { ++ &dev_attr_poll_interval.attr, ++ &dev_attr_adc_fuzz.attr, ++ &dev_attr_adc_flat.attr, ++ &dev_attr_enable.attr, ++ &dev_attr_adc_cal.attr, ++ &dev_attr_amux_debug.attr, ++ NULL, ++}; ++ ++static struct attribute_group joypad_attr_group = { ++ .attrs = joypad_attrs, ++}; ++ ++/*----------------------------------------------------------------------------*/ ++/*----------------------------------------------------------------------------*/ ++static void joypad_gpio_check(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ int nbtn, value; ++ ++ for (nbtn = 0; nbtn < joypad->bt_gpio_count; nbtn++) { ++ struct bt_gpio *gpio = &joypad->gpios[nbtn]; ++ ++ if (gpio_get_value_cansleep(gpio->num) < 0) { ++ dev_err(joypad->dev, "failed to get gpio state\n"); ++ continue; ++ } ++ value = gpio_get_value(gpio->num); ++ if (value != gpio->old_value) { ++ input_event(poll_dev->input, ++ gpio->report_type, ++ gpio->linux_code, ++ (value == gpio->active_level) ? 1 : 0); ++ gpio->old_value = value; ++ } ++ } ++ input_sync(poll_dev->input); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void joypad_adc_check(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ int nbtn; ++ ++ for (nbtn = 0; nbtn < joypad->amux_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ ++ adc->value = joypad_adc_read(joypad->amux, adc); ++ if (!adc->value) { ++ //dev_err(joypad->dev, "%s : saradc channels[%d]! adc->value : %d\n",__func__, nbtn, adc->value); ++ continue; ++ } ++ adc->value = adc->value - adc->cal; ++ ++ /* Joystick Deadzone check */ ++ if (joypad->bt_adc_deadzone) { ++ if (abs(adc->value) < joypad->bt_adc_deadzone) ++ adc->value = 0; ++ } ++ ++ /* adc data tuning */ ++ if (adc->tuning_n && adc->value < 0) ++ adc->value = ADC_DATA_TUNING(adc->value, adc->tuning_n); ++ if (adc->tuning_p && adc->value > 0) ++ adc->value = ADC_DATA_TUNING(adc->value, adc->tuning_p); ++ ++ adc->value = adc->value > adc->max ? adc->max : adc->value; ++ adc->value = adc->value < adc->min ? adc->min : adc->value; ++ ++ input_report_abs(poll_dev->input, ++ adc->report_type, ++ adc->invert ? adc->value * (-1) : adc->value); ++ } ++ input_sync(poll_dev->input); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void joypad_poll(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ ++ if (joypad->enable) { ++ joypad_adc_check(poll_dev); ++ joypad_gpio_check(poll_dev); ++ } ++ if (poll_dev->poll_interval != joypad->poll_interval) { ++ mutex_lock(&joypad->lock); ++ poll_dev->poll_interval = joypad->poll_interval; ++ mutex_unlock(&joypad->lock); ++ } ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void joypad_open(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ int nbtn; ++ ++ for (nbtn = 0; nbtn < joypad->bt_gpio_count; nbtn++) { ++ struct bt_gpio *gpio = &joypad->gpios[nbtn]; ++ gpio->old_value = gpio->active_level ? 0 : 1; ++ } ++ for (nbtn = 0; nbtn < joypad->amux_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ ++ adc->value = joypad_adc_read(joypad->amux, adc); ++ if (!adc->value) { ++ dev_err(joypad->dev, "%s : saradc channels[%d]!\n", ++ __func__, nbtn); ++ continue; ++ } ++ adc->cal = adc->value; ++ dev_info(joypad->dev, "%s : adc[%d] adc->cal = %d\n", ++ __func__, nbtn, adc->cal); ++ } ++ /* buttons status sync */ ++ joypad_adc_check(poll_dev); ++ joypad_gpio_check(poll_dev); ++ ++ /* button report enable */ ++ mutex_lock(&joypad->lock); ++ joypad->enable = true; ++ mutex_unlock(&joypad->lock); ++ ++ dev_info(joypad->dev, "%s : opened\n", __func__); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void joypad_close(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ ++ /* button report disable */ ++ mutex_lock(&joypad->lock); ++ joypad->enable = false; ++ mutex_unlock(&joypad->lock); ++ ++ dev_info(joypad->dev, "%s : closed\n", __func__); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static int joypad_amux_setup(struct device *dev, struct joypad *joypad) ++{ ++ struct analog_mux *amux; ++ enum iio_chan_type type; ++ enum of_gpio_flags flags; ++ int ret; ++ ++ /* analog mux control struct init */ ++ joypad->amux = devm_kzalloc(dev, sizeof(struct analog_mux), ++ GFP_KERNEL); ++ if (!joypad->amux) { ++ dev_err(dev, "%s amux devm_kzmalloc error!", __func__); ++ return -ENOMEM; ++ } ++ amux = joypad->amux; ++ amux->iio_ch = devm_iio_channel_get(dev, "amux_adc"); ++ if (PTR_ERR(amux->iio_ch) == -EPROBE_DEFER) ++ return -EPROBE_DEFER; ++ if (IS_ERR(amux->iio_ch)) { ++ dev_err(dev, "iio channel get error\n"); ++ return -EINVAL; ++ } ++ if (!amux->iio_ch->indio_dev) ++ return -ENXIO; ++ ++ if (iio_get_channel_type(amux->iio_ch, &type)) ++ return -EINVAL; ++ ++ if (type != IIO_VOLTAGE) { ++ dev_err(dev, "Incompatible channel type %d\n", type); ++ return -EINVAL; ++ } ++ ++ amux->sel_a_gpio = of_get_named_gpio_flags(dev->of_node, ++ "amux-a-gpios", 0, &flags); ++ if (gpio_is_valid(amux->sel_a_gpio)) { ++ ret = devm_gpio_request(dev, amux->sel_a_gpio, "amux-sel-a"); ++ if (ret < 0) { ++ dev_err(dev, "%s : failed to request amux-sel-a %d\n", ++ __func__, amux->sel_a_gpio); ++ goto err_out; ++ } ++ ret = gpio_direction_output(amux->sel_a_gpio, 0); ++ if (ret < 0) ++ goto err_out; ++ } ++ ++ amux->sel_b_gpio = of_get_named_gpio_flags(dev->of_node, ++ "amux-b-gpios", 0, &flags); ++ if (gpio_is_valid(amux->sel_b_gpio)) { ++ ret = devm_gpio_request(dev, amux->sel_b_gpio, "amux-sel-b"); ++ if (ret < 0) { ++ dev_err(dev, "%s : failed to request amux-sel-b %d\n", ++ __func__, amux->sel_b_gpio); ++ goto err_out; ++ } ++ ret = gpio_direction_output(amux->sel_b_gpio, 0); ++ if (ret < 0) ++ goto err_out; ++ } ++ ++ amux->en_gpio = of_get_named_gpio_flags(dev->of_node, ++ "amux-en-gpios", 0, &flags); ++ if (gpio_is_valid(amux->en_gpio)) { ++ ret = devm_gpio_request(dev, amux->en_gpio, "amux-en"); ++ if (ret < 0) { ++ dev_err(dev, "%s : failed to request amux-en %d\n", ++ __func__, amux->en_gpio); ++ goto err_out; ++ } ++ ret = gpio_direction_output(amux->en_gpio, 0); ++ if (ret < 0) ++ goto err_out; ++ } ++ return 0; ++err_out: ++ return ret; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static int joypad_adc_setup(struct device *dev, struct joypad *joypad) ++{ ++ int nbtn; ++ ++ /* adc button struct init */ ++ joypad->adcs = devm_kzalloc(dev, joypad->amux_count * ++ sizeof(struct bt_adc), GFP_KERNEL); ++ if (!joypad->adcs) { ++ dev_err(dev, "%s devm_kzmalloc error!", __func__); ++ return -ENOMEM; ++ } ++ ++ for (nbtn = 0; nbtn < joypad->amux_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ ++ adc->scale = joypad->bt_adc_scale; ++ ++ adc->max = (ADC_MAX_VOLTAGE / 2); ++ adc->min = (ADC_MAX_VOLTAGE / 2) * (-1); ++ if (adc->scale) { ++ adc->max *= adc->scale; ++ adc->min *= adc->scale; ++ } ++ adc->amux_ch = nbtn; ++ adc->invert = false; ++ ++ switch (nbtn) { ++ case 0: ++ adc->report_type = ABS_RY; ++ if (device_property_read_u32(dev, ++ "abs_ry-p-tuning", ++ &adc->tuning_p)) ++ adc->tuning_p = ADC_TUNING_DEFAULT; ++ if (device_property_read_u32(dev, ++ "abs_ry-n-tuning", ++ &adc->tuning_n)) ++ adc->tuning_n = ADC_TUNING_DEFAULT; ++ break; ++ case 1: ++ adc->report_type = ABS_RX; ++ if (device_property_read_u32(dev, ++ "abs_rx-p-tuning", ++ &adc->tuning_p)) ++ adc->tuning_p = ADC_TUNING_DEFAULT; ++ if (device_property_read_u32(dev, ++ "abs_rx-n-tuning", ++ &adc->tuning_n)) ++ adc->tuning_n = ADC_TUNING_DEFAULT; ++ break; ++ case 2: ++ #ifdef __LEFT_JOYSTICK_INVERT__ ++ adc->invert = true; ++ #endif ++ adc->report_type = ABS_Y; ++ if (device_property_read_u32(dev, ++ "abs_y-p-tuning", ++ &adc->tuning_p)) ++ adc->tuning_p = ADC_TUNING_DEFAULT; ++ if (device_property_read_u32(dev, ++ "abs_y-n-tuning", ++ &adc->tuning_n)) ++ adc->tuning_n = ADC_TUNING_DEFAULT; ++ break; ++ case 3: ++ #ifdef __LEFT_JOYSTICK_INVERT__ ++ adc->invert = true; ++ #endif ++ adc->report_type = ABS_X; ++ if (device_property_read_u32(dev, ++ "abs_x-p-tuning", ++ &adc->tuning_p)) ++ adc->tuning_p = ADC_TUNING_DEFAULT; ++ if (device_property_read_u32(dev, ++ "abs_x-n-tuning", ++ &adc->tuning_n)) ++ adc->tuning_n = ADC_TUNING_DEFAULT; ++ break; ++ default : ++ dev_err(dev, "%s amux count(%d) error!", ++ __func__, nbtn); ++ return -EINVAL; ++ } ++ } ++ return 0; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static int joypad_gpio_setup(struct device *dev, struct joypad *joypad) ++{ ++ struct device_node *node, *pp; ++ int nbtn; ++ ++ node = dev->of_node; ++ if (!node) ++ return -ENODEV; ++ ++ joypad->gpios = devm_kzalloc(dev, joypad->bt_gpio_count * ++ sizeof(struct bt_gpio), GFP_KERNEL); ++ ++ if (!joypad->gpios) { ++ dev_err(dev, "%s devm_kzmalloc error!", __func__); ++ return -ENOMEM; ++ } ++ ++ nbtn = 0; ++ for_each_child_of_node(node, pp) { ++ enum of_gpio_flags flags; ++ struct bt_gpio *gpio = &joypad->gpios[nbtn++]; ++ int error; ++ ++ gpio->num = of_get_gpio_flags(pp, 0, &flags); ++ if (gpio->num < 0) { ++ error = gpio->num; ++ dev_err(dev, "Failed to get gpio flags, error: %d\n", ++ error); ++ return error; ++ } ++ ++ /* gpio active level(key press level) */ ++ gpio->active_level = (flags & OF_GPIO_ACTIVE_LOW) ? 0 : 1; ++ ++ gpio->label = of_get_property(pp, "label", NULL); ++ ++ if (gpio_is_valid(gpio->num)) { ++ error = devm_gpio_request_one(dev, gpio->num, ++ GPIOF_IN, gpio->label); ++ if (error < 0) { ++ dev_err(dev, ++ "Failed to request GPIO %d, error %d\n", ++ gpio->num, error); ++ return error; ++ } ++ } ++ if (of_property_read_u32(pp, "linux,code", &gpio->linux_code)) { ++ dev_err(dev, "Button without keycode: 0x%x\n", ++ gpio->num); ++ return -EINVAL; ++ } ++ if (of_property_read_u32(pp, "linux,input-type", ++ &gpio->report_type)) ++ gpio->report_type = EV_KEY; ++ } ++ if (nbtn == 0) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++/*----------------------------------------------------------------------------*/ ++struct input_dev * joypad_input_g; ++ ++ ++void rk_send_key_f_key_up(void) ++{ ++ if (!joypad_input_g) ++ return; ++ ++ input_report_key(joypad_input_g, BTN_MODE, 1); ++ input_sync(joypad_input_g); ++} ++EXPORT_SYMBOL(rk_send_key_f_key_up); ++ ++ ++void rk_send_key_f_key_down(void) ++{ ++ if (!joypad_input_g) ++ return; ++ ++ input_report_key(joypad_input_g, BTN_MODE, 0); ++ input_sync(joypad_input_g); ++} ++EXPORT_SYMBOL(rk_send_key_f_key_down); ++ ++ ++static int joypad_input_setup(struct device *dev, struct joypad *joypad) ++{ ++ struct input_polled_dev *poll_dev; ++ struct input_dev *input; ++ int nbtn, error; ++ u32 joypad_revision = 0; ++ u32 joypad_product = 0; ++ ++ poll_dev = devm_input_allocate_polled_device(dev); ++ if (!poll_dev) { ++ dev_err(dev, "no memory for polled device\n"); ++ return -ENOMEM; ++ } ++ ++ poll_dev->private = joypad; ++ poll_dev->poll = joypad_poll; ++ poll_dev->poll_interval = joypad->poll_interval; ++ poll_dev->open = joypad_open; ++ poll_dev->close = joypad_close; ++ ++ input = poll_dev->input; ++ joypad_input_g=input; ++ ++ device_property_read_string(dev, "joypad-name", &input->name); ++ input->phys = DRV_NAME"/input0"; ++ ++ device_property_read_u32(dev, "joypad-revision", &joypad_revision); ++ device_property_read_u32(dev, "joypad-product", &joypad_product); ++ input->id.bustype = BUS_HOST; ++ input->id.vendor = 0x484B; ++ input->id.product = (u16)joypad_product; ++ input->id.version = (u16)joypad_revision; ++ ++ /* IIO ADC key setup (0 mv ~ 1800 mv) * adc->scale */ ++ __set_bit(EV_ABS, input->evbit); ++ for(nbtn = 0; nbtn < joypad->amux_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ input_set_abs_params(input, adc->report_type, ++ adc->min, adc->max, ++ joypad->bt_adc_fuzz, ++ joypad->bt_adc_flat); ++ dev_info(dev, ++ "%s : SCALE = %d, ABS min = %d, max = %d," ++ " fuzz = %d, flat = %d, deadzone = %d\n", ++ __func__, adc->scale, adc->min, adc->max, ++ joypad->bt_adc_fuzz, joypad->bt_adc_flat, ++ joypad->bt_adc_deadzone); ++ dev_info(dev, ++ "%s : adc tuning_p = %d, adc_tuning_n = %d\n\n", ++ __func__, adc->tuning_p, adc->tuning_n); ++ } ++ ++ /* GPIO key setup */ ++ __set_bit(EV_KEY, input->evbit); ++ for(nbtn = 0; nbtn < joypad->bt_gpio_count; nbtn++) { ++ struct bt_gpio *gpio = &joypad->gpios[nbtn]; ++ input_set_capability(input, gpio->report_type, ++ gpio->linux_code); ++ } ++ ++ if (joypad->auto_repeat) ++ __set_bit(EV_REP, input->evbit); ++ ++ joypad->dev = dev; ++ ++ error = input_register_polled_device(poll_dev); ++ if (error) { ++ dev_err(dev, "unable to register polled device, err=%d\n", ++ error); ++ return error; ++ } ++ return 0; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void joypad_setup_value_check(struct device *dev, struct joypad *joypad) ++{ ++ /* ++ fuzz: specifies fuzz value that is used to filter noise from ++ the event stream. ++ */ ++ if (g_button_adc_fuzz) ++ joypad->bt_adc_fuzz = g_button_adc_fuzz; ++ else ++ device_property_read_u32(dev, "button-adc-fuzz", ++ &joypad->bt_adc_fuzz); ++ /* ++ flat: values that are within this value will be discarded by ++ joydev interface and reported as 0 instead. ++ */ ++ if (g_button_adc_flat) ++ joypad->bt_adc_flat = g_button_adc_flat; ++ else ++ device_property_read_u32(dev, "button-adc-flat", ++ &joypad->bt_adc_flat); ++ ++ /* Joystick report value control */ ++ if (g_button_adc_scale) ++ joypad->bt_adc_scale = g_button_adc_scale; ++ else ++ device_property_read_u32(dev, "button-adc-scale", ++ &joypad->bt_adc_scale); ++ ++ /* Joystick deadzone value control */ ++ if (g_button_adc_deadzone) ++ joypad->bt_adc_deadzone = g_button_adc_deadzone; ++ else ++ device_property_read_u32(dev, "button-adc-deadzone", ++ &joypad->bt_adc_deadzone); ++ ++} ++ ++/*----------------------------------------------------------------------------*/ ++static int joypad_dt_parse(struct device *dev, struct joypad *joypad) ++{ ++ int error = 0; ++ ++ /* initialize value check from boot.ini */ ++ joypad_setup_value_check(dev, joypad); ++ ++ device_property_read_u32(dev, "amux-count", ++ &joypad->amux_count); ++ ++ device_property_read_u32(dev, "poll-interval", ++ &joypad->poll_interval); ++ ++ joypad->auto_repeat = device_property_present(dev, "autorepeat"); ++ ++ joypad->bt_gpio_count = device_get_child_node_count(dev); ++ ++ if ((joypad->amux_count == 0) || (joypad->bt_gpio_count == 0)) { ++ dev_err(dev, "adc key = %d, gpio key = %d error!", ++ joypad->amux_count, joypad->bt_gpio_count); ++ return -EINVAL; ++ } ++ ++ error = joypad_adc_setup(dev, joypad); ++ if (error) ++ return error; ++ ++ error = joypad_amux_setup(dev, joypad); ++ if (error) ++ return error; ++ ++ error = joypad_gpio_setup(dev, joypad); ++ if (error) ++ return error; ++ ++ dev_info(dev, "%s : adc key cnt = %d, gpio key cnt = %d\n", ++ __func__, joypad->amux_count, joypad->bt_gpio_count); ++ ++ return error; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static int joypad_probe(struct platform_device *pdev) ++{ ++ struct joypad *joypad; ++ struct device *dev = &pdev->dev; ++ int error; ++ ++ joypad = devm_kzalloc(dev, sizeof(struct joypad), GFP_KERNEL); ++ if (!joypad) { ++ dev_err(dev, "joypad devm_kzmalloc error!"); ++ return -ENOMEM; ++ } ++ ++ /* device tree data parse */ ++ error = joypad_dt_parse(dev, joypad); ++ if (error) { ++ dev_err(dev, "dt parse error!(err = %d)\n", error); ++ return error; ++ } ++ ++ mutex_init(&joypad->lock); ++ platform_set_drvdata(pdev, joypad); ++ ++ error = sysfs_create_group(&pdev->dev.kobj, &joypad_attr_group); ++ if (error) { ++ dev_err(dev, "create sysfs group fail, error: %d\n", ++ error); ++ return error; ++ } ++ ++ /* poll input device setup */ ++ error = joypad_input_setup(dev, joypad); ++ if (error) { ++ dev_err(dev, "input setup failed!(err = %d)\n", error); ++ return error; ++ } ++ dev_info(dev, "%s : probe success\n", __func__); ++ return 0; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static const struct of_device_id joypad_of_match[] = { ++ { .compatible = "singleadc-joypad", }, ++ {}, ++}; ++ ++MODULE_DEVICE_TABLE(of, joypad_of_match); ++ ++/*----------------------------------------------------------------------------*/ ++static struct platform_driver joypad_driver = { ++ .probe = joypad_probe, ++ .driver = { ++ .name = DRV_NAME, ++ .of_match_table = of_match_ptr(joypad_of_match), ++ }, ++}; ++ ++/*----------------------------------------------------------------------------*/ ++static int __init joypad_init(void) ++{ ++ return platform_driver_register(&joypad_driver); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void __exit joypad_exit(void) ++{ ++ platform_driver_unregister(&joypad_driver); ++} ++ ++/*----------------------------------------------------------------------------*/ ++late_initcall(joypad_init); ++module_exit(joypad_exit); +-- +2.34.1 + + +From 630503c2f1868970c00459f382576e2cd6e42565 Mon Sep 17 00:00:00 2001 +From: AnanJaser +Date: Tue, 2 Apr 2024 04:19:59 +0400 +Subject: [PATCH 2/7] drivers: input: joystick: yoink from odroidgo2-joypad.c + +* https://github.com/SummerSunGenius/RG351V_kernel/blob/master/drivers/input/joystick/odroidgo2-joypad.c +--- + .../input/joystick/singleadc_quadsaradc_joy.c | 470 +++++------------- + 1 file changed, 136 insertions(+), 334 deletions(-) + +diff --git a/drivers/input/joystick/singleadc_quadsaradc_joy.c b/drivers/input/joystick/singleadc_quadsaradc_joy.c +index f8e7f04c2..bca08a4c0 100644 +--- a/drivers/input/joystick/singleadc_quadsaradc_joy.c ++++ b/drivers/input/joystick/singleadc_quadsaradc_joy.c +@@ -5,7 +5,7 @@ + */ + + /* +- * Single SARADC dual-joystick gamepad driver ++ * Quad SARADC dual-joystick gamepad driver + */ + + /*----------------------------------------------------------------------------*/ +@@ -27,16 +27,14 @@ + + /*----------------------------------------------------------------------------*/ + #define DRV_NAME "retrogame_joypad" +-#define __LEFT_JOYSTICK_INVERT__ + #define __MURMUR__ + /*----------------------------------------------------------------------------*/ +-#define ADC_MAX_VOLTAGE 1800 +-#define ADC_DATA_TUNING(x, p) ((x * p) / 100) +-#define ADC_TUNING_DEFAULT 180 + + struct bt_adc { ++ /* IIO ADC Channel */ ++ struct iio_channel *channel; + /* report value (mV) */ +- int value; ++ int old_value; + /* report type */ + int report_type; + /* input device init value (mV) */ +@@ -47,19 +45,6 @@ struct bt_adc { + int scale; + /* invert report */ + bool invert; +- /* amux channel */ +- int amux_ch; +- /* adc data tuning value([percent), p = positive, n = negative */ +- int tuning_p, tuning_n; +-}; +- +-struct analog_mux { +- /* IIO ADC Channel : amux connect channel */ +- struct iio_channel *iio_ch; +- /* analog mux select(a,b) gpio */ +- int sel_a_gpio, sel_b_gpio; +- /* analog mux enable gpio */ +- int en_gpio; + }; + + struct bt_gpio { +@@ -84,31 +69,27 @@ struct joypad { + /* report enable/disable */ + bool enable; + +- /* analog mux & joystick control */ +- struct analog_mux *amux; +- /* analog mux max count */ +- int amux_count; +- /* analog button */ +- struct bt_adc *adcs; ++ /* report reference point */ ++ bool invert_absx; ++ bool invert_absy; + + /* report interval (ms) */ + int bt_gpio_count; + struct bt_gpio *gpios; +- + /* button auto repeat */ + int auto_repeat; + + /* report threshold (mV) */ + int bt_adc_fuzz, bt_adc_flat; ++ int bt_adc_x_range, bt_adc_y_range; + /* adc read value scale */ + int bt_adc_scale; + /* joystick deadzone control */ + int bt_adc_deadzone; ++ int bt_adc_count; ++ struct bt_adc *adcs; + + struct mutex lock; +- +- /* amux debug channel */ +- int debug_ch; + }; + + /*----------------------------------------------------------------------------*/ +@@ -116,11 +97,35 @@ struct joypad { + // set to the value in the boot.ini file. (if exist) + // + /*----------------------------------------------------------------------------*/ ++static unsigned int g_button_adc_x_range = 0; ++static unsigned int g_button_adc_y_range = 0; + static unsigned int g_button_adc_fuzz = 0; + static unsigned int g_button_adc_flat = 0; + static unsigned int g_button_adc_scale = 0; + static unsigned int g_button_adc_deadzone = 0; + ++static int __init button_adcx_range_setup(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ ++ g_button_adc_x_range = simple_strtoul(str, NULL, 10); ++ ++ return 0; ++} ++__setup("button-adc-x-range=", button_adcx_range_setup); ++ ++static int __init button_adcy_range_setup(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ ++ g_button_adc_y_range = simple_strtoul(str, NULL, 10); ++ ++ return 0; ++} ++__setup("button-adc-y-range=", button_adcy_range_setup); ++ + static int button_adc_fuzz(char *str) + { + if (!str) +@@ -159,55 +164,16 @@ __setup("button-adc-deadzone=", button_adc_deadzone); + + /*----------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------*/ +-static int joypad_amux_select(struct analog_mux *amux, int channel) +-{ +- /* select mux channel */ +- gpio_set_value(amux->en_gpio, 0); +- +- switch(channel) { +- case 0: /* EVENT (ABS_RY) */ +- gpio_set_value(amux->sel_a_gpio, 0); +- gpio_set_value(amux->sel_b_gpio, 0); +- break; +- case 1: /* EVENT (ABS_RX) */ +- gpio_set_value(amux->sel_a_gpio, 0); +- gpio_set_value(amux->sel_b_gpio, 1); +- break; +- case 2: /* EVENT (ABS_Y) */ +- gpio_set_value(amux->sel_a_gpio, 1); +- gpio_set_value(amux->sel_b_gpio, 0); +- break; +- case 3: /* EVENT (ABS_X) */ +- gpio_set_value(amux->sel_a_gpio, 1); +- gpio_set_value(amux->sel_b_gpio, 1); +- break; +- default: +- /* amux disanle */ +- gpio_set_value(amux->en_gpio, 1); +- return -1; +- } +- /* mux swtiching speed : 35ns(on) / 9ns(off) */ +- usleep_range(10, 20); +- return 0; +-} +- +-/*----------------------------------------------------------------------------*/ +-static int joypad_adc_read(struct analog_mux *amux, struct bt_adc *adc) ++static int joypad_adc_read(struct bt_adc *adc) + { + int value; + +- +- if (joypad_amux_select(amux, adc->amux_ch)) ++ if (iio_read_channel_processed(adc->channel, &value)) + return 0; + +- iio_read_channel_raw(amux->iio_ch, &value); +- + value *= adc->scale; +-#ifdef __LEFT_JOYSTICK_INVERT__ +- return value; +-#else ++ + return (adc->invert ? (adc->max - value) : value); +-#endif + } + + /*----------------------------------------------------------------------------*/ +@@ -353,16 +319,16 @@ static ssize_t joypad_store_adc_cal(struct device *dev, + int nbtn; + + mutex_lock(&joypad->lock); +- for (nbtn = 0; nbtn < joypad->amux_count; nbtn++) { ++ for (nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) { + struct bt_adc *adc = &joypad->adcs[nbtn]; + +- adc->value = joypad_adc_read(joypad->amux, adc); +- if (!adc->value) { ++ adc->cal = joypad_adc_read(adc); ++ if (!adc->cal) { + dev_err(joypad->dev, "%s : saradc channels[%d]!\n", + __func__, nbtn); + continue; + } +- adc->cal = adc->value; ++ adc->old_value = adc->cal; + } + mutex_unlock(&joypad->lock); + } +@@ -379,12 +345,12 @@ static ssize_t joypad_show_adc_cal(struct device *dev, + int nbtn; + ssize_t pos; + +- for (nbtn = 0, pos = 0; nbtn < joypad->amux_count; nbtn++) { ++ for (nbtn = 0, pos = 0; nbtn < joypad->bt_adc_count; nbtn++) { + struct bt_adc *adc = &joypad->adcs[nbtn]; +- pos += sprintf(&buf[pos], "adc[%d]->cal = %d\n", ++ pos += sprintf(&buf[pos], "adc[%d]->cal = %d ", + nbtn, adc->cal); + } +- pos += sprintf(&buf[pos], "adc scale = %d\n", joypad->bt_adc_scale); ++ pos += sprintf(&buf[pos], "\n"); + return pos; + } + +@@ -393,73 +359,6 @@ static DEVICE_ATTR(adc_cal, S_IWUSR | S_IRUGO, + joypad_show_adc_cal, + joypad_store_adc_cal); + +-/*----------------------------------------------------------------------------*/ +-/* +- * ATTRIBUTES: +- * +- * /sys/devices/platform/retrogame_joypad/amux_debug [rw] +- * +- * echo [debug channel] > amux_debug +- * cat amux_debug : debug channel mux set & adc read +- */ +-/*----------------------------------------------------------------------------*/ +-static ssize_t joypad_store_amux_debug(struct device *dev, +- struct device_attribute *attr, +- const char *buf, +- size_t count) +-{ +- struct platform_device *pdev = to_platform_device(dev); +- struct joypad *joypad = platform_get_drvdata(pdev); +- +- joypad->debug_ch = simple_strtoul(buf, NULL, 10); +- +- /* if error than default setting(debug_ch = 0) */ +- if (joypad->debug_ch > joypad->amux_count) +- joypad->debug_ch = 0; +- +- return count; +-} +- +-/*----------------------------------------------------------------------------*/ +-static ssize_t joypad_show_amux_debug(struct device *dev, +- struct device_attribute *attr, +- char *buf) +-{ +- struct platform_device *pdev = to_platform_device(dev); +- struct joypad *joypad = platform_get_drvdata(pdev); +- struct analog_mux *amux = joypad->amux; +- ssize_t pos; +- int value; +- +- mutex_lock(&joypad->lock); +- +- /* disable poll driver */ +- if (joypad->enable) +- joypad->enable = false; +- +- if (joypad_amux_select(amux, joypad->debug_ch)) +- goto err_out; +- +- if (iio_read_channel_processed(amux->iio_ch, &value)) +- goto err_out; +- +- pos = sprintf(buf, "amux ch[%d], adc scale = %d, adc value = %d\n", +- joypad->debug_ch, joypad->bt_adc_scale, +- value * joypad->bt_adc_scale); +- goto out; +- +-err_out: +- pos = sprintf(buf, "error : amux setup & adc read!\n"); +-out: +- mutex_unlock(&joypad->lock); +- return pos; +-} +- +-/*----------------------------------------------------------------------------*/ +-static DEVICE_ATTR(amux_debug, S_IWUSR | S_IRUGO, +- joypad_show_amux_debug, +- joypad_store_amux_debug); +- + /*----------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------*/ + static struct attribute *joypad_attrs[] = { +@@ -468,7 +367,6 @@ static struct attribute *joypad_attrs[] = { + &dev_attr_adc_flat.attr, + &dev_attr_enable.attr, + &dev_attr_adc_cal.attr, +- &dev_attr_amux_debug.attr, + NULL, + }; + +@@ -506,36 +404,40 @@ static void joypad_gpio_check(struct input_polled_dev *poll_dev) + static void joypad_adc_check(struct input_polled_dev *poll_dev) + { + struct joypad *joypad = poll_dev->private; +- int nbtn; ++ int nbtn, value; + +- for (nbtn = 0; nbtn < joypad->amux_count; nbtn++) { ++ for (nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) { + struct bt_adc *adc = &joypad->adcs[nbtn]; + +- adc->value = joypad_adc_read(joypad->amux, adc); +- if (!adc->value) { +- //dev_err(joypad->dev, "%s : saradc channels[%d]! adc->value : %d\n",__func__, nbtn, adc->value); ++ value = joypad_adc_read(adc); ++ if (!value) { ++ dev_err(joypad->dev, "%s : saradc channels[%d]!\n", ++ __func__, nbtn); + continue; + } +- adc->value = adc->value - adc->cal; + + /* Joystick Deadzone check */ + if (joypad->bt_adc_deadzone) { +- if (abs(adc->value) < joypad->bt_adc_deadzone) +- adc->value = 0; ++ if ((value < adc->cal + joypad->bt_adc_deadzone) && ++ (value > adc->cal - joypad->bt_adc_deadzone)) ++ value = adc->cal; + } +- +- /* adc data tuning */ +- if (adc->tuning_n && adc->value < 0) +- adc->value = ADC_DATA_TUNING(adc->value, adc->tuning_n); +- if (adc->tuning_p && adc->value > 0) +- adc->value = ADC_DATA_TUNING(adc->value, adc->tuning_p); +- +- adc->value = adc->value > adc->max ? adc->max : adc->value; +- adc->value = adc->value < adc->min ? adc->min : adc->value; +- +- input_report_abs(poll_dev->input, +- adc->report_type, +- adc->invert ? adc->value * (-1) : adc->value); ++ value = value - adc->cal; ++ value = value > adc->max ? adc->max : value; ++ value = value < adc->min ? adc->min : value; ++ ++ if (nbtn == 0) ++ { ++ // adc-x value is default inverted(h/w) ++ input_report_abs(poll_dev->input, ++ adc->report_type, value * (-1)); ++ } ++ else ++ { ++ input_report_abs(poll_dev->input, ++ adc->report_type, value); ++ } ++ adc->old_value = value; + } + input_sync(poll_dev->input); + } +@@ -566,16 +468,16 @@ static void joypad_open(struct input_polled_dev *poll_dev) + struct bt_gpio *gpio = &joypad->gpios[nbtn]; + gpio->old_value = gpio->active_level ? 0 : 1; + } +- for (nbtn = 0; nbtn < joypad->amux_count; nbtn++) { ++ for (nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) { + struct bt_adc *adc = &joypad->adcs[nbtn]; + +- adc->value = joypad_adc_read(joypad->amux, adc); +- if (!adc->value) { ++ adc->old_value = joypad_adc_read(adc); ++ if (!adc->old_value) { + dev_err(joypad->dev, "%s : saradc channels[%d]!\n", + __func__, nbtn); + continue; + } +- adc->cal = adc->value; ++ adc->cal = adc->old_value; + dev_info(joypad->dev, "%s : adc[%d] adc->cal = %d\n", + __func__, nbtn, adc->cal); + } +@@ -604,170 +506,64 @@ static void joypad_close(struct input_polled_dev *poll_dev) + dev_info(joypad->dev, "%s : closed\n", __func__); + } + +-/*----------------------------------------------------------------------------*/ +-static int joypad_amux_setup(struct device *dev, struct joypad *joypad) +-{ +- struct analog_mux *amux; +- enum iio_chan_type type; +- enum of_gpio_flags flags; +- int ret; +- +- /* analog mux control struct init */ +- joypad->amux = devm_kzalloc(dev, sizeof(struct analog_mux), +- GFP_KERNEL); +- if (!joypad->amux) { +- dev_err(dev, "%s amux devm_kzmalloc error!", __func__); +- return -ENOMEM; +- } +- amux = joypad->amux; +- amux->iio_ch = devm_iio_channel_get(dev, "amux_adc"); +- if (PTR_ERR(amux->iio_ch) == -EPROBE_DEFER) +- return -EPROBE_DEFER; +- if (IS_ERR(amux->iio_ch)) { +- dev_err(dev, "iio channel get error\n"); +- return -EINVAL; +- } +- if (!amux->iio_ch->indio_dev) +- return -ENXIO; +- +- if (iio_get_channel_type(amux->iio_ch, &type)) +- return -EINVAL; +- +- if (type != IIO_VOLTAGE) { +- dev_err(dev, "Incompatible channel type %d\n", type); +- return -EINVAL; +- } +- +- amux->sel_a_gpio = of_get_named_gpio_flags(dev->of_node, +- "amux-a-gpios", 0, &flags); +- if (gpio_is_valid(amux->sel_a_gpio)) { +- ret = devm_gpio_request(dev, amux->sel_a_gpio, "amux-sel-a"); +- if (ret < 0) { +- dev_err(dev, "%s : failed to request amux-sel-a %d\n", +- __func__, amux->sel_a_gpio); +- goto err_out; +- } +- ret = gpio_direction_output(amux->sel_a_gpio, 0); +- if (ret < 0) +- goto err_out; +- } +- +- amux->sel_b_gpio = of_get_named_gpio_flags(dev->of_node, +- "amux-b-gpios", 0, &flags); +- if (gpio_is_valid(amux->sel_b_gpio)) { +- ret = devm_gpio_request(dev, amux->sel_b_gpio, "amux-sel-b"); +- if (ret < 0) { +- dev_err(dev, "%s : failed to request amux-sel-b %d\n", +- __func__, amux->sel_b_gpio); +- goto err_out; +- } +- ret = gpio_direction_output(amux->sel_b_gpio, 0); +- if (ret < 0) +- goto err_out; +- } +- +- amux->en_gpio = of_get_named_gpio_flags(dev->of_node, +- "amux-en-gpios", 0, &flags); +- if (gpio_is_valid(amux->en_gpio)) { +- ret = devm_gpio_request(dev, amux->en_gpio, "amux-en"); +- if (ret < 0) { +- dev_err(dev, "%s : failed to request amux-en %d\n", +- __func__, amux->en_gpio); +- goto err_out; +- } +- ret = gpio_direction_output(amux->en_gpio, 0); +- if (ret < 0) +- goto err_out; +- } +- return 0; +-err_out: +- return ret; +-} +- + /*----------------------------------------------------------------------------*/ + static int joypad_adc_setup(struct device *dev, struct joypad *joypad) + { +- int nbtn; ++ int nbtn = 0; + +- /* adc button struct init */ +- joypad->adcs = devm_kzalloc(dev, joypad->amux_count * ++ joypad->adcs = devm_kzalloc(dev, joypad->bt_adc_count * + sizeof(struct bt_adc), GFP_KERNEL); ++ + if (!joypad->adcs) { + dev_err(dev, "%s devm_kzmalloc error!", __func__); + return -ENOMEM; + } + +- for (nbtn = 0; nbtn < joypad->amux_count; nbtn++) { ++ for (nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) { + struct bt_adc *adc = &joypad->adcs[nbtn]; ++ enum iio_chan_type type; + + adc->scale = joypad->bt_adc_scale; +- +- adc->max = (ADC_MAX_VOLTAGE / 2); +- adc->min = (ADC_MAX_VOLTAGE / 2) * (-1); +- if (adc->scale) { +- adc->max *= adc->scale; +- adc->min *= adc->scale; ++ if (nbtn) { ++ adc->channel = ++ devm_iio_channel_get(dev, "joy_y"); ++ adc->report_type = ABS_Y; ++ if (joypad->invert_absy) ++ adc->invert = true; ++ ++ adc->max = (joypad->bt_adc_y_range / 2) - 1; ++ adc->min = -(joypad->bt_adc_y_range / 2); + } +- adc->amux_ch = nbtn; +- adc->invert = false; +- +- switch (nbtn) { +- case 0: +- adc->report_type = ABS_RY; +- if (device_property_read_u32(dev, +- "abs_ry-p-tuning", +- &adc->tuning_p)) +- adc->tuning_p = ADC_TUNING_DEFAULT; +- if (device_property_read_u32(dev, +- "abs_ry-n-tuning", +- &adc->tuning_n)) +- adc->tuning_n = ADC_TUNING_DEFAULT; +- break; +- case 1: +- adc->report_type = ABS_RX; +- if (device_property_read_u32(dev, +- "abs_rx-p-tuning", +- &adc->tuning_p)) +- adc->tuning_p = ADC_TUNING_DEFAULT; +- if (device_property_read_u32(dev, +- "abs_rx-n-tuning", +- &adc->tuning_n)) +- adc->tuning_n = ADC_TUNING_DEFAULT; +- break; +- case 2: +- #ifdef __LEFT_JOYSTICK_INVERT__ +- adc->invert = true; +- #endif +- adc->report_type = ABS_Y; +- if (device_property_read_u32(dev, +- "abs_y-p-tuning", +- &adc->tuning_p)) +- adc->tuning_p = ADC_TUNING_DEFAULT; +- if (device_property_read_u32(dev, +- "abs_y-n-tuning", +- &adc->tuning_n)) +- adc->tuning_n = ADC_TUNING_DEFAULT; +- break; +- case 3: +- #ifdef __LEFT_JOYSTICK_INVERT__ +- adc->invert = true; +- #endif +- adc->report_type = ABS_X; +- if (device_property_read_u32(dev, +- "abs_x-p-tuning", +- &adc->tuning_p)) +- adc->tuning_p = ADC_TUNING_DEFAULT; +- if (device_property_read_u32(dev, +- "abs_x-n-tuning", +- &adc->tuning_n)) +- adc->tuning_n = ADC_TUNING_DEFAULT; +- break; +- default : +- dev_err(dev, "%s amux count(%d) error!", +- __func__, nbtn); +- return -EINVAL; ++ else { ++ adc->channel = ++ devm_iio_channel_get(dev, "joy_x"); ++ adc->report_type = ABS_X; ++ if (joypad->invert_absx) ++ adc->invert = true; ++ ++ adc->max = (joypad->bt_adc_x_range / 2) - 1; ++ adc->min = -(joypad->bt_adc_x_range / 2); ++ } ++ ++ if (IS_ERR(adc->channel)) { ++ dev_err(dev, "iio channel[%d] get error\n", nbtn); ++ return -EINVAL; ++ } ++ if (!adc->channel->indio_dev) ++ return -ENXIO; ++ ++ if (iio_get_channel_type(adc->channel, &type)) ++ return -EINVAL; ++ ++ if (type != IIO_VOLTAGE) { ++ dev_err(dev, "Incompatible channel %d type %d\n", ++ nbtn, type); ++ return -EINVAL; + } + } ++ if (nbtn == 0) ++ return -EINVAL; ++ + return 0; + } + +@@ -894,7 +690,7 @@ static int joypad_input_setup(struct device *dev, struct joypad *joypad) + + /* IIO ADC key setup (0 mv ~ 1800 mv) * adc->scale */ + __set_bit(EV_ABS, input->evbit); +- for(nbtn = 0; nbtn < joypad->amux_count; nbtn++) { ++ for(nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) { + struct bt_adc *adc = &joypad->adcs[nbtn]; + input_set_abs_params(input, adc->report_type, + adc->min, adc->max, +@@ -906,9 +702,6 @@ static int joypad_input_setup(struct device *dev, struct joypad *joypad) + __func__, adc->scale, adc->min, adc->max, + joypad->bt_adc_fuzz, joypad->bt_adc_flat, + joypad->bt_adc_deadzone); +- dev_info(dev, +- "%s : adc tuning_p = %d, adc_tuning_n = %d\n\n", +- __func__, adc->tuning_p, adc->tuning_n); + } + + /* GPIO key setup */ +@@ -969,6 +762,16 @@ static void joypad_setup_value_check(struct device *dev, struct joypad *joypad) + device_property_read_u32(dev, "button-adc-deadzone", + &joypad->bt_adc_deadzone); + ++ if (g_button_adc_x_range) ++ joypad->bt_adc_x_range = g_button_adc_x_range; ++ else ++ device_property_read_u32(dev, "button-adc-x-range", ++ &joypad->bt_adc_x_range); ++ if (g_button_adc_y_range) ++ joypad->bt_adc_y_range = g_button_adc_y_range; ++ else ++ device_property_read_u32(dev, "button-adc-y-range", ++ &joypad->bt_adc_y_range); + } + + /*----------------------------------------------------------------------------*/ +@@ -979,19 +782,25 @@ static int joypad_dt_parse(struct device *dev, struct joypad *joypad) + /* initialize value check from boot.ini */ + joypad_setup_value_check(dev, joypad); + +- device_property_read_u32(dev, "amux-count", +- &joypad->amux_count); ++ device_property_read_u32(dev, "button-adc-count", ++ &joypad->bt_adc_count); + + device_property_read_u32(dev, "poll-interval", + &joypad->poll_interval); + + joypad->auto_repeat = device_property_present(dev, "autorepeat"); + ++ /* change the report reference point? (ADC MAX - read value) */ ++ joypad->invert_absx = device_property_present(dev, "invert-absx"); ++ joypad->invert_absy = device_property_present(dev, "invert-absy"); ++ dev_info(dev, "%s : invert-absx = %d, inveret-absy = %d\n", ++ __func__, joypad->invert_absx, joypad->invert_absy); ++ + joypad->bt_gpio_count = device_get_child_node_count(dev); + +- if ((joypad->amux_count == 0) || (joypad->bt_gpio_count == 0)) { ++ if ((joypad->bt_adc_count == 0) || (joypad->bt_gpio_count == 0)) { + dev_err(dev, "adc key = %d, gpio key = %d error!", +- joypad->amux_count, joypad->bt_gpio_count); ++ joypad->bt_adc_count, joypad->bt_gpio_count); + return -EINVAL; + } + +@@ -999,17 +808,10 @@ static int joypad_dt_parse(struct device *dev, struct joypad *joypad) + if (error) + return error; + +- error = joypad_amux_setup(dev, joypad); +- if (error) +- return error; +- + error = joypad_gpio_setup(dev, joypad); + if (error) + return error; + +- dev_info(dev, "%s : adc key cnt = %d, gpio key cnt = %d\n", +- __func__, joypad->amux_count, joypad->bt_gpio_count); +- + return error; + } + +-- +2.34.1 + + +From bd92c3584e2aaea7b1f1767104b5b41933f45fe3 Mon Sep 17 00:00:00 2001 +From: AnanJaser +Date: Tue, 2 Apr 2024 04:33:56 +0400 +Subject: [PATCH 3/7] drivers: input: joystick: add all 4 channels + +* From Stock X55 BSP : +saradc 0 - ABS_X <15 1023>; +saradc 1 - ABS_Y <1023 15>; +saradc 2 - ABS_RX <15 1023>; +saradc 3 - ABS_RY <1023 15>; +--- + .../input/joystick/singleadc_quadsaradc_joy.c | 79 ++++++++++++++++--- + 1 file changed, 67 insertions(+), 12 deletions(-) + +diff --git a/drivers/input/joystick/singleadc_quadsaradc_joy.c b/drivers/input/joystick/singleadc_quadsaradc_joy.c +index bca08a4c0..5e23df657 100644 +--- a/drivers/input/joystick/singleadc_quadsaradc_joy.c ++++ b/drivers/input/joystick/singleadc_quadsaradc_joy.c +@@ -72,6 +72,8 @@ struct joypad { + /* report reference point */ + bool invert_absx; + bool invert_absy; ++ bool invert_absrx; ++ bool invert_absry; + + /* report interval (ms) */ + int bt_gpio_count; +@@ -81,7 +83,7 @@ struct joypad { + + /* report threshold (mV) */ + int bt_adc_fuzz, bt_adc_flat; +- int bt_adc_x_range, bt_adc_y_range; ++ int bt_adc_x_range, bt_adc_y_range, bt_adc_rx_range, bt_adc_ry_range; + /* adc read value scale */ + int bt_adc_scale; + /* joystick deadzone control */ +@@ -99,6 +101,8 @@ struct joypad { + /*----------------------------------------------------------------------------*/ + static unsigned int g_button_adc_x_range = 0; + static unsigned int g_button_adc_y_range = 0; ++static unsigned int g_button_adc_rx_range = 0; ++static unsigned int g_button_adc_ry_range = 0; + static unsigned int g_button_adc_fuzz = 0; + static unsigned int g_button_adc_flat = 0; + static unsigned int g_button_adc_scale = 0; +@@ -126,6 +130,28 @@ static int __init button_adcy_range_setup(char *str) + } + __setup("button-adc-y-range=", button_adcy_range_setup); + ++static int __init button_adcrx_range_setup(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ ++ g_button_adc_rx_range = simple_strtoul(str, NULL, 10); ++ ++ return 0; ++} ++__setup("button-adc-rx-range=", button_adcrx_range_setup); ++ ++static int __init button_adcry_range_setup(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ ++ g_button_adc_ry_range = simple_strtoul(str, NULL, 10); ++ ++ return 0; ++} ++__setup("button-adc-ry-range=", button_adcry_range_setup); ++ + static int button_adc_fuzz(char *str) + { + if (!str) +@@ -524,9 +550,18 @@ static int joypad_adc_setup(struct device *dev, struct joypad *joypad) + enum iio_chan_type type; + + adc->scale = joypad->bt_adc_scale; +- if (nbtn) { +- adc->channel = +- devm_iio_channel_get(dev, "joy_y"); ++ ++ if (nbtn == 0) { ++ adc->channel = devm_iio_channel_get(dev, "ABS_X"); ++ adc->report_type = ABS_X; ++ if (joypad->invert_absx) ++ adc->invert = true; ++ ++ adc->max = (joypad->bt_adc_x_range / 2) - 1; ++ adc->min = -(joypad->bt_adc_x_range / 2); ++ } ++ else if (nbtn == 1) { ++ adc->channel = devm_iio_channel_get(dev, "ABS_Y"); + adc->report_type = ABS_Y; + if (joypad->invert_absy) + adc->invert = true; +@@ -534,15 +569,23 @@ static int joypad_adc_setup(struct device *dev, struct joypad *joypad) + adc->max = (joypad->bt_adc_y_range / 2) - 1; + adc->min = -(joypad->bt_adc_y_range / 2); + } ++ else if (nbtn == 2) { ++ adc->channel = devm_iio_channel_get(dev, "ABS_RX"); ++ adc->report_type = ABS_RX; ++ if (joypad->invert_absrx) ++ adc->invert = true; ++ ++ adc->max = (joypad->bt_adc_rx_range / 2) - 1; ++ adc->min = -(joypad->bt_adc_rx_range / 2); ++ } + else { +- adc->channel = +- devm_iio_channel_get(dev, "joy_x"); +- adc->report_type = ABS_X; +- if (joypad->invert_absx) ++ adc->channel = devm_iio_channel_get(dev, "ABS_RY"); ++ adc->report_type = ABS_RY; ++ if (joypad->invert_absry) + adc->invert = true; + +- adc->max = (joypad->bt_adc_x_range / 2) - 1; +- adc->min = -(joypad->bt_adc_x_range / 2); ++ adc->max = (joypad->bt_adc_ry_range / 2) - 1; ++ adc->min = -(joypad->bt_adc_ry_range / 2); + } + + if (IS_ERR(adc->channel)) { +@@ -772,6 +815,16 @@ static void joypad_setup_value_check(struct device *dev, struct joypad *joypad) + else + device_property_read_u32(dev, "button-adc-y-range", + &joypad->bt_adc_y_range); ++ if (g_button_adc_rx_range) ++ joypad->bt_adc_rx_range = g_button_adc_rx_range; ++ else ++ device_property_read_u32(dev, "button-adc-rx-range", ++ &joypad->bt_adc_rx_range); ++ if (g_button_adc_ry_range) ++ joypad->bt_adc_ry_range = g_button_adc_ry_range; ++ else ++ device_property_read_u32(dev, "button-adc-ry-range", ++ &joypad->bt_adc_ry_range); + } + + /*----------------------------------------------------------------------------*/ +@@ -793,8 +846,10 @@ static int joypad_dt_parse(struct device *dev, struct joypad *joypad) + /* change the report reference point? (ADC MAX - read value) */ + joypad->invert_absx = device_property_present(dev, "invert-absx"); + joypad->invert_absy = device_property_present(dev, "invert-absy"); +- dev_info(dev, "%s : invert-absx = %d, inveret-absy = %d\n", +- __func__, joypad->invert_absx, joypad->invert_absy); ++ joypad->invert_absrx = device_property_present(dev, "invert-absrx"); ++ joypad->invert_absry = device_property_present(dev, "invert-absry"); ++ dev_info(dev, "%s : invert-absx = %d, inveret-absy = %d\n, inveret-absrx = %d\n, inveret-absry = %d\n", ++ __func__, joypad->invert_absx, joypad->invert_absy, joypad->invert_absrx, joypad->invert_absry); + + joypad->bt_gpio_count = device_get_child_node_count(dev); + +-- +2.34.1 + + +From 26241d4bf8e17a96aa30dace7267519f85d5e83e Mon Sep 17 00:00:00 2001 +From: AnanJaser +Date: Wed, 3 Apr 2024 00:31:14 +0400 +Subject: [PATCH 4/7] drivers: input: joystick: dont invert X axis + +--- + drivers/input/joystick/singleadc_quadsaradc_joy.c | 12 ++---------- + 1 file changed, 2 insertions(+), 10 deletions(-) + +diff --git a/drivers/input/joystick/singleadc_quadsaradc_joy.c b/drivers/input/joystick/singleadc_quadsaradc_joy.c +index 5e23df657..a13982375 100644 +--- a/drivers/input/joystick/singleadc_quadsaradc_joy.c ++++ b/drivers/input/joystick/singleadc_quadsaradc_joy.c +@@ -452,17 +452,9 @@ static void joypad_adc_check(struct input_polled_dev *poll_dev) + value = value > adc->max ? adc->max : value; + value = value < adc->min ? adc->min : value; + +- if (nbtn == 0) +- { +- // adc-x value is default inverted(h/w) +- input_report_abs(poll_dev->input, +- adc->report_type, value * (-1)); +- } +- else +- { +- input_report_abs(poll_dev->input, ++ input_report_abs(poll_dev->input, + adc->report_type, value); +- } ++ + adc->old_value = value; + } + input_sync(poll_dev->input); +-- +2.34.1 + + +From 7a18f03bc041db8ce7f2a8b84695fae98efa2fb4 Mon Sep 17 00:00:00 2001 +From: AnanJaser +Date: Tue, 9 Apr 2024 19:52:31 +0400 +Subject: [PATCH 5/7] drivers: input: singleadc: change device name + +--- + drivers/input/joystick/singleadc_quadsaradc_joy.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/input/joystick/singleadc_quadsaradc_joy.c b/drivers/input/joystick/singleadc_quadsaradc_joy.c +index a13982375..27af64a7d 100644 +--- a/drivers/input/joystick/singleadc_quadsaradc_joy.c ++++ b/drivers/input/joystick/singleadc_quadsaradc_joy.c +@@ -904,7 +904,7 @@ static int joypad_probe(struct platform_device *pdev) + + /*----------------------------------------------------------------------------*/ + static const struct of_device_id joypad_of_match[] = { +- { .compatible = "singleadc-joypad", }, ++ { .compatible = "singleadc-joypad-x55", }, + {}, + }; + +-- +2.34.1 + + +From 6071df09f533e9eaa82be8c283c025ce3ff0482f Mon Sep 17 00:00:00 2001 +From: AnanJaser +Date: Tue, 9 Apr 2024 20:29:33 +0400 +Subject: [PATCH 6/7] drivers: input: singleadc: fix definitions + +--- + .../input/joystick/singleadc_quadsaradc_joy.c | 24 +++++++++---------- + 1 file changed, 12 insertions(+), 12 deletions(-) + +diff --git a/drivers/input/joystick/singleadc_quadsaradc_joy.c b/drivers/input/joystick/singleadc_quadsaradc_joy.c +index 27af64a7d..542da74d9 100644 +--- a/drivers/input/joystick/singleadc_quadsaradc_joy.c ++++ b/drivers/input/joystick/singleadc_quadsaradc_joy.c +@@ -665,29 +665,29 @@ static int joypad_gpio_setup(struct device *dev, struct joypad *joypad) + } + + /*----------------------------------------------------------------------------*/ +-struct input_dev * joypad_input_g; ++struct input_dev * joypad_input_g_x55; + + +-void rk_send_key_f_key_up(void) ++void rk_send_key_f_key_up_x55(void) + { +- if (!joypad_input_g) ++ if (!joypad_input_g_x55) + return; + +- input_report_key(joypad_input_g, BTN_MODE, 1); +- input_sync(joypad_input_g); ++ input_report_key(joypad_input_g_x55, BTN_MODE, 1); ++ input_sync(joypad_input_g_x55); + } +-EXPORT_SYMBOL(rk_send_key_f_key_up); ++EXPORT_SYMBOL(rk_send_key_f_key_up_x55); + + +-void rk_send_key_f_key_down(void) ++void rk_send_key_f_key_down_x55(void) + { +- if (!joypad_input_g) ++ if (!joypad_input_g_x55) + return; + +- input_report_key(joypad_input_g, BTN_MODE, 0); +- input_sync(joypad_input_g); ++ input_report_key(joypad_input_g_x55, BTN_MODE, 0); ++ input_sync(joypad_input_g_x55); + } +-EXPORT_SYMBOL(rk_send_key_f_key_down); ++EXPORT_SYMBOL(rk_send_key_f_key_down_x55); + + + static int joypad_input_setup(struct device *dev, struct joypad *joypad) +@@ -711,7 +711,7 @@ static int joypad_input_setup(struct device *dev, struct joypad *joypad) + poll_dev->close = joypad_close; + + input = poll_dev->input; +- joypad_input_g=input; ++ joypad_input_g_x55=input; + + device_property_read_string(dev, "joypad-name", &input->name); + input->phys = DRV_NAME"/input0"; +-- +2.34.1 + + +From 02d9bf62d26a57408e9476d56e8ba8a8ea1a2cfe Mon Sep 17 00:00:00 2001 +From: AnanJaser +Date: Tue, 9 Apr 2024 21:18:30 +0400 +Subject: [PATCH 7/7] drivers: input: singleadc: change DRV name + +* Error: Driver 'retrogame_joypad' is already registered, aborting... +--- + drivers/input/joystick/singleadc_quadsaradc_joy.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/input/joystick/singleadc_quadsaradc_joy.c b/drivers/input/joystick/singleadc_quadsaradc_joy.c +index 542da74d9..67c9ade27 100644 +--- a/drivers/input/joystick/singleadc_quadsaradc_joy.c ++++ b/drivers/input/joystick/singleadc_quadsaradc_joy.c +@@ -26,7 +26,7 @@ + #include + + /*----------------------------------------------------------------------------*/ +-#define DRV_NAME "retrogame_joypad" ++#define DRV_NAME "retrogame_joypad_x55" + #define __MURMUR__ + /*----------------------------------------------------------------------------*/ + +-- +2.34.1 + diff --git a/projects/Rockchip/patches/linux/RK3566/030-powkiddy-x55-input.patch b/projects/Rockchip/patches/linux/RK3566/030-powkiddy-x55-input.patch new file mode 100644 index 0000000000..f3609bbad8 --- /dev/null +++ b/projects/Rockchip/patches/linux/RK3566/030-powkiddy-x55-input.patch @@ -0,0 +1,313 @@ +From ecf0713489cd02a29f9d0dd489408a3f3ee2cd1e Mon Sep 17 00:00:00 2001 +From: AnanJaser +Date: Tue, 9 Apr 2024 19:52:55 +0400 +Subject: [PATCH] dts: rk3566-x55: setup singleadc-joypad-x55 + +* Adjust joystick ranges to match stock +* change device id +--- + .../boot/dts/rockchip/rk3566-powkiddy-x55.dts | 274 +++++++++--------- + 1 file changed, 140 insertions(+), 134 deletions(-) + +diff --git a/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts b/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts +index ab627cb30..13509328c 100644 +--- a/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts ++++ b/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-x55.dts +@@ -24,45 +24,153 @@ chosen: chosen { + stdout-path = "serial2:1500000n8"; + }; + +- adc_joystick: adc-joystick { +- compatible = "adc-joystick"; ++ joypad: singleadc-joypad-x55 { ++ compatible = "singleadc-joypad-x55"; ++ hw_info = <0x01>; ++ ++ joypad-name = "retrogame_joypad"; ++ joypad-product = <0x1101>; ++ joypad-revision = <0x0100>; ++ ++ status = "okay"; ++ ++ /* gpio pincontrol setup */ ++ pinctrl-names = "default"; ++ pinctrl-0 = <&btn_pins_ctrl>; ++ ++ /* JOYSTICK Channel define */ ++ io-channel-names = "ABS_X", "ABS_Y", "ABS_RX", "ABS_RY"; + io-channels = <&saradc 0>, <&saradc 1>, + <&saradc 2>, <&saradc 3>; +- poll-interval = <60>; +- #address-cells = <1>; +- #size-cells = <0>; + +- axis@0 { +- reg = <0>; +- abs-flat = <30>; +- abs-fuzz = <20>; +- abs-range = <15 1023>; +- linux,code = ; +- }; ++ /* adc channel count */ ++ button-adc-count = <4>; + +- axis@1 { +- reg = <1>; +- abs-flat = <30>; +- abs-fuzz = <20>; +- abs-range = <1023 15>; +- linux,code = ; +- }; ++ /* adc calculate scale */ ++ button-adc-scale = <2>; + +- axis@2 { +- reg = <2>; +- abs-flat = <30>; +- abs-fuzz = <20>; +- abs-range = <15 1023>; +- linux,code = ; +- }; ++ /* adc deadzone range */ ++ button-adc-deadzone = <64>; ++ ++ /* ++ specifies fuzz value that is used to filter noise from ++ the event stream. ++ */ ++ button-adc-fuzz = <20>; ++ button-adc-flat = <30>; ++ ++ /* ++ joy-stick voltage range ++ /sys/devices/platform/ff288000.saradc/iio:device0 ++ adc-x : in_voltage1_raw ++ adc-y : in_voltage2_raw ++ adc-rx : in_voltage3_raw ++ adc-ry : in_voltage4_raw ++ ++ range calculate. ++ (adc raw max value - adc raw min value) * scale * 1.7515 + +- axis@3 { +- reg = <3>; +- abs-flat = <30>; +- abs-fuzz = <20>; +- abs-range = <1023 15>; +- linux,code = ; ++ This calculation outputs 3517 which feels wrong so instead do max - min * scale which gives us stock range ++ */ ++ ++ button-adc-x-range = <2016>; ++ button-adc-y-range = <2016>; ++ button-adc-rx-range = <2016>; ++ button-adc-ry-range = <2016>; ++ ++ /* poll device interval (ms), adc read interval */ ++ poll-interval = <60>; ++ ++ /* gpio button auto repeat set value : default disable */ ++ /* ++ autorepeat; ++ */ ++ sw1 { ++ gpios = <&gpio4 RK_PA0 GPIO_ACTIVE_LOW>; ++ label = "GPIO DPAD-UP"; ++ linux,code = ; ++ }; ++ sw2 { ++ gpios = <&gpio4 RK_PA1 GPIO_ACTIVE_LOW>; ++ label = "GPIO DPAD-DOWN"; ++ linux,code = ; ++ }; ++ sw3 { ++ gpios = <&gpio3 RK_PD6 GPIO_ACTIVE_LOW>; ++ label = "GPIO DPAD-LEFT"; ++ linux,code = ; ++ }; ++ sw4 { ++ gpios = <&gpio3 RK_PD7 GPIO_ACTIVE_LOW>; ++ label = "GPIO DPAD-RIGHT"; ++ linux,code = ; ++ }; ++ sw5 { ++ gpios = <&gpio3 RK_PD3 GPIO_ACTIVE_LOW>; ++ label = "GPIO KEY BTN-A"; ++ linux,code = ; ++ }; ++ sw6 { ++ gpios = <&gpio3 RK_PD2 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN-B"; ++ linux,code = ; ++ }; ++ sw7 { ++ gpios = <&gpio3 RK_PD5 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN-X"; ++ linux,code = ; ++ }; ++ sw8 { ++ gpios = <&gpio3 RK_PD4 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN-Y"; ++ linux,code = ; ++ }; ++ sw9 { ++ gpios = <&gpio4 RK_PA4 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN_SELECT"; ++ linux,code = ; ++ }; ++ sw10 { ++ gpios = <&gpio4 RK_PA2 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN_START"; ++ linux,code = ; ++ }; ++ sw11 { ++ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN_F"; ++ linux,code = ; ++ }; ++ sw12 { ++ gpios = <&gpio3 RK_PD0 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN_TL"; ++ linux,code = ; ++ }; ++ sw13 { ++ gpios = <&gpio3 RK_PC6 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN_TR"; ++ linux,code = ; ++ }; ++ sw14 { ++ gpios = <&gpio3 RK_PD1 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN_TL2"; ++ linux,code = ; ++ }; ++ sw15 { ++ gpios = <&gpio3 RK_PC7 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN_TR2"; ++ linux,code = ; ++ }; ++ sw16 { ++ gpios = <&gpio4 RK_PA7 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN_THUMBL"; ++ linux,code = ; ++ }; ++ sw17 { ++ gpios = <&gpio4 RK_PB0 GPIO_ACTIVE_LOW>; ++ label = "GPIO BTN_THUMBR"; ++ linux,code = ; + }; ++ + }; + + backlight: backlight { +@@ -90,108 +198,6 @@ battery: battery { + <3400000 0>; + }; + +- gpio_keys_control: gpio-keys-control { +- compatible = "gpio-keys"; +- pinctrl-0 = <&btn_pins_ctrl>; +- pinctrl-names = "default"; +- +- button-a { +- gpios = <&gpio3 RK_PD3 GPIO_ACTIVE_LOW>; +- label = "EAST"; +- linux,code = ; +- }; +- +- button-b { +- gpios = <&gpio3 RK_PD2 GPIO_ACTIVE_LOW>; +- label = "SOUTH"; +- linux,code = ; +- }; +- +- button-down { +- gpios = <&gpio4 RK_PA1 GPIO_ACTIVE_LOW>; +- label = "DPAD-DOWN"; +- linux,code = ; +- }; +- +- button-l1 { +- gpios = <&gpio3 RK_PD0 GPIO_ACTIVE_LOW>; +- label = "TL"; +- linux,code = ; +- }; +- +- button-l2 { +- gpios = <&gpio3 RK_PD1 GPIO_ACTIVE_LOW>; +- label = "TL2"; +- linux,code = ; +- }; +- +- button-left { +- gpios = <&gpio3 RK_PD6 GPIO_ACTIVE_LOW>; +- label = "DPAD-LEFT"; +- linux,code = ; +- }; +- +- button-right { +- gpios = <&gpio3 RK_PD7 GPIO_ACTIVE_LOW>; +- label = "DPAD-RIGHT"; +- linux,code = ; +- }; +- +- button-select { +- gpios = <&gpio4 RK_PA4 GPIO_ACTIVE_LOW>; +- label = "SELECT"; +- linux,code = ; +- }; +- +- button-start { +- gpios = <&gpio4 RK_PA2 GPIO_ACTIVE_LOW>; +- label = "START"; +- linux,code = ; +- }; +- +- button-thumbl { +- gpios = <&gpio4 RK_PA7 GPIO_ACTIVE_LOW>; +- label = "THUMBL"; +- linux,code = ; +- }; +- +- button-thumbr { +- gpios = <&gpio4 RK_PB0 GPIO_ACTIVE_LOW>; +- label = "THUMBR"; +- linux,code = ; +- }; +- +- button-r1 { +- gpios = <&gpio3 RK_PC6 GPIO_ACTIVE_LOW>; +- label = "TR"; +- linux,code = ; +- }; +- +- button-r2 { +- gpios = <&gpio3 RK_PC7 GPIO_ACTIVE_LOW>; +- label = "TR2"; +- linux,code = ; +- }; +- +- button-up { +- gpios = <&gpio4 RK_PA0 GPIO_ACTIVE_LOW>; +- label = "DPAD-UP"; +- linux,code = ; +- }; +- +- button-x { +- gpios = <&gpio3 RK_PD5 GPIO_ACTIVE_LOW>; +- label = "NORTH"; +- linux,code = ; +- }; +- +- button-y { +- gpios = <&gpio3 RK_PD4 GPIO_ACTIVE_LOW>; +- label = "WEST"; +- linux,code = ; +- }; +- }; +- + gpio_keys_vol: gpio-keys-vol { + compatible = "gpio-keys"; + autorepeat; +-- +2.34.1 + diff --git a/projects/Rockchip/patches/linux/RK3566/030-rgb30r2.patch b/projects/Rockchip/patches/linux/RK3566/030-rgb30r2.patch new file mode 100644 index 0000000000..84ac76ce49 --- /dev/null +++ b/projects/Rockchip/patches/linux/RK3566/030-rgb30r2.patch @@ -0,0 +1,46 @@ +diff --git a/arch/arm64/boot/dts/rockchip/Makefile b/arch/arm64/boot/dts/rockchip/Makefile +index f906a868b71a..bc30125a6764 100644 +--- a/arch/arm64/boot/dts/rockchip/Makefile ++++ b/arch/arm64/boot/dts/rockchip/Makefile +@@ -84,6 +84,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3566-pinetab2-v0.1.dtb + dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3566-pinetab2-v2.0.dtb + dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3566-powkiddy-rgb10max3.dtb + dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3566-powkiddy-rgb30.dtb ++dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3566-powkiddy-rgb30r2.dtb + dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3566-powkiddy-rk2023.dtb + dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3566-powkiddy-x55.dtb + dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3566-quartz64-a.dtb +diff --git a/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-rgb30r2.dts b/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-rgb30r2.dts +new file mode 100644 +index 000000000000..f584474b3eb6 +--- /dev/null ++++ b/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-rgb30r2.dts +@@ -0,0 +1,28 @@ ++// SPDX-License-Identifier: (GPL-2.0+ OR MIT) ++ ++/dts-v1/; ++ ++#include ++#include ++#include ++#include "rk3566-powkiddy-rgb30.dts" ++ ++/delete-node/ &vdd_cpu; ++ ++&i2c0 { ++ vdd_cpu: regulator@40 { ++ compatible = "fcs,fan53555"; ++ reg = <0x40>; ++ fcs,suspend-voltage-selector = <1>; ++ regulator-always-on; ++ regulator-boot-on; ++ regulator-min-microvolt = <712500>; ++ regulator-max-microvolt = <1390000>; ++ regulator-name = "vdd_cpu"; ++ regulator-ramp-delay = <2300>; ++ vin-supply = <&vcc_sys>; ++ regulator-state-mem { ++ regulator-off-in-suspend; ++ }; ++ }; ++}; diff --git a/scripts/build_distro b/scripts/build_distro index 7ab4466388..8cc185cb85 100755 --- a/scripts/build_distro +++ b/scripts/build_distro @@ -27,6 +27,8 @@ then PKG_CLEAN+=" ${CLEAN_WESTON}" fi +# When USE_MALI specified for S922X platform, clean packages that vary based on VULKAN_SUPPORT +[ "${DEVICE}" = "S922X" -a -n "${USE_MALI}" ] && PKG_CLEAN+=" ${CLEAN_S922X}" # If DEVICE_ROOT is defined and not the device being built, make sure that the # build folder is a link to root rather than a folder. diff --git a/scripts/checkdeps b/scripts/checkdeps index 51b5ce6a2d..e8ec9e4e39 100755 --- a/scripts/checkdeps +++ b/scripts/checkdeps @@ -69,6 +69,7 @@ dep_map=( [make]=make [patch]=patch [perl]=perl + [rdfind]=rdfind [sed]=sed [tar]=tar [unzip]=unzip diff --git a/scripts/mkimage b/scripts/mkimage index 966dbb2061..516c71a2aa 100755 --- a/scripts/mkimage +++ b/scripts/mkimage @@ -68,41 +68,22 @@ sync # create partitions echo "image: creating partitions..." -if [ "${PARTITION_TABLE}" = "gpt" ] && [ "${BOOTLOADER}" = "u-boot" ] -then - echo "image: creating SPL partition(s)." - parted -s "${DISK}" unit s mkpart ${UBOOT_LABEL} 16384 24575 >/dev/null 2>&1 - parted -s "${DISK}" unit s mkpart ${TRUST_LABEL} 24576 32767 >/dev/null 2>&1 -fi - SYSTEM_PART_END=$(( ${SYSTEM_PART_START} + (${SYSTEM_SIZE} * 1024 * 1024 / 512) - 1 )) STORAGE_PART_START=$(( ${SYSTEM_PART_END} + 1 )) STORAGE_PART_END=$(( ${STORAGE_PART_START} + (${STORAGE_SIZE} * 1024 * 1024 / 512) - 1 )) if [ "${PARTITION_TABLE}" = "gpt" ]; then echo "image: Create GPT boot partition." - parted -s "${DISK}" -a min unit s mkpart boot fat32 ${SYSTEM_PART_START} ${SYSTEM_PART_END} + parted -s "${DISK}" -a min unit s mkpart system fat32 ${SYSTEM_PART_START} ${SYSTEM_PART_END} + parted -s "${DISK}" -a min unit s mkpart storage ext4 ${STORAGE_PART_START} ${STORAGE_PART_END} + parted -s "${DISK}" set 1 legacy_boot on else echo "image: Create MBR boot partition." - parted -s "${DISK}" -a min unit s mkpart primary fat32 ${SYSTEM_PART_START} ${SYSTEM_PART_END} + parted -s "${DISK}" -a min unit s mkpart primary fat32 ${SYSTEM_PART_START} ${SYSTEM_PART_END} + parted -s "${DISK}" -a min unit s mkpart primary ext4 ${STORAGE_PART_START} ${STORAGE_PART_END} parted -s "${DISK}" set 1 boot on fi -if [ "${PARTITION_TABLE}" = "gpt" ]; then - echo "image: Create GPT storage partition." - parted -s "${DISK}" -a min unit s mkpart storage ext4 ${STORAGE_PART_START} ${STORAGE_PART_END} - else - echo "image: Create MBR Storage partition." - parted -s "${DISK}" -a min unit s mkpart primary ext4 ${STORAGE_PART_START} ${STORAGE_PART_END} -fi -sync - -if [ "${PARTITION_TABLE}" = "gpt" ] && [ "${BOOTLOADER}" = "u-boot" ]; then - echo "image: Set OS partition as boot" - parted -s "${DISK}" set 3 boot on -fi -sync - echo "image: creating sparse file for part2..." STORAGE_PART_COUNT=$(( ${STORAGE_PART_END} - ${STORAGE_PART_START} + 1 )) sync diff --git a/scripts/setEnv b/scripts/setEnv index 0ea2389ec0..7e31822edf 100644 --- a/scripts/setEnv +++ b/scripts/setEnv @@ -28,6 +28,12 @@ case "$1" in export DEVICE=RK3566 export ARCH=aarch64 ;; + "RK3566-X55") + export DEVICE_ROOT=RK3566 + export PROJECT=Rockchip + export DEVICE=RK3566-X55 + export ARCH=aarch64 + ;; "RK3326") unset DEVICE_ROOT export PROJECT=Rockchip @@ -58,6 +64,12 @@ case "$1" in export DEVICE=RK3566 export ARCH=arm ;; + "RK3566-X55-32") + export DEVICE_ROOT=RK3566 + export PROJECT=Rockchip + export DEVICE=RK3566-X55 + export ARCH=arm + ;; "RK3326-32") unset DEVICE_ROOT export PROJECT=Rockchip