From ac4710a18ef820245db40c1666885d8a1b5274a6 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 7 Nov 2021 23:54:52 +0100 Subject: [PATCH] Added proper support for the Raspberry Pi 4. --- CMakeLists.txt | 69 +++++++++++++------ es-app/src/guis/GuiMenu.cpp | 2 +- es-core/src/Settings.cpp | 23 ++++--- .../src/components/VideoFFmpegComponent.cpp | 2 +- 4 files changed, 64 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08e7418a4..eafc59c04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ option(RPI "Set to ON to enable Raspberry Pi specific build" ${RPI}) option(CEC "Set to ON to enable CEC" ${CEC}) option(VLC_PLAYER "Set to ON to build the VLC-based video player" ${VLC_PLAYER}) option(CLANG_TIDY "Set to ON to build using the clang-tidy static analyzer" ${CLANG_TIDY}) +option(VIDEO_HW_DECODING "Set to OFF to disable FFmpeg HW decoding" ON) if(CLANG_TIDY) find_program(CLANG_TIDY_BINARY NAMES clang-tidy) @@ -58,14 +59,7 @@ endif() #--------------------------------------------------------------------------------------------------- # OpenGL setup. -# Check if we're running on a Raspberry Pi. -if(EXISTS "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/bcm_host.h") - message("-- Building on a Raspberry Pi (bcm_host.h found)") - # Setting BCMHOST seems to break OpenGL ES on the RPi 4 so set RPI instead. - #set(BCMHOST found) - set(RPI ON) - set(GLSYSTEM "Embedded OpenGL" CACHE STRING "The OpenGL system to be used") -elseif(GLES OR RPI) +if(GLES) set(GLSYSTEM "Embedded OpenGL" CACHE STRING "The OpenGL system to be used") else() set(GLSYSTEM "Desktop OpenGL" CACHE STRING "The OpenGL system to be used") @@ -73,6 +67,32 @@ endif() set_property(CACHE GLSYSTEM PROPERTY STRINGS "Desktop OpenGL" "Embedded OpenGL") +#--------------------------------------------------------------------------------------------------- +# Raspberry Pi setup. + +# If manually set to RPI (used for testing purposes). +if(RPI) + set(VIDEO_HW_DECODING OFF) +endif() + +# Raspberry Pi OS 32-bit (armv7l) +if(EXISTS "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/bcm_host.h") + set(RPI ON) + set(RPI_32 ON) + set(VIDEO_HW_DECODING OFF) + set(BCMHOST found) + message("-- Building on a Raspberry Pi (32-bit OS)") +endif() + +# Raspberry Pi OS 64-bit (aarch64) +if(EXISTS "/usr/include/bcm_host.h") + set(RPI ON) + set(RPI_64 ON) + set(VIDEO_HW_DECODING OFF) + set(BCMHOST found) + message("-- Building on a Raspberry Pi (64-bit OS)") +endif() + #--------------------------------------------------------------------------------------------------- # Package dependencies. @@ -196,18 +216,22 @@ else() add_definitions(-DUSE_OPENGLES_10) endif() +if(RPI) + add_definitions(-D_RPI_) +endif() + if(VLC_PLAYER) add_definitions(-DBUILD_VLC_PLAYER) endif() -if(DEFINED BCMHOST OR RPI) - add_definitions(-D_RPI_) -endif() - if(DEFINED libCEC_FOUND) add_definitions(-DHAVE_LIBCEC) endif() +if(VIDEO_HW_DECODING) + add_definitions(-DVIDEO_HW_DECODING) +endif() + # GLM library options. add_definitions(-DGLM_FORCE_CXX17) add_definitions(-DGLM_FORCE_XYZW_ONLY) @@ -279,7 +303,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux") list(APPEND COMMON_INCLUDE_DIRS ${ALSA_INCLUDE_DIRS}) endif() -if(DEFINED BCMHOST OR RPI) +if(RPI_32) list(APPEND COMMON_INCLUDE_DIRS "${CMAKE_FIND_ROOT_PATH}/opt/vc/include" "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/interface/vcos" "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/interface/vmcs_host/linux" @@ -358,9 +382,6 @@ endif() # Add libCEC libraries. if(DEFINED libCEC_FOUND) - if(DEFINED BCMHOST OR RPI) - list(APPEND COMMON_LIBRARIES bcm_host vchiq_arm) - endif() list(APPEND COMMON_LIBRARIES dl ${libCEC_LIBRARIES}) endif() @@ -369,14 +390,22 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux") list(APPEND COMMON_LIBRARIES ${ALSA_LIBRARY}) endif() +# Raspberry Pi. if(DEFINED BCMHOST) - link_directories("${CMAKE_FIND_ROOT_PATH}/opt/vc/lib") - list(APPEND COMMON_LIBRARIES bcm_host brcmEGL ${OPENGLES_LIBRARIES}) -elseif(RPI) - link_directories("${CMAKE_FIND_ROOT_PATH}/opt/vc/lib") + list(APPEND COMMON_LIBRARIES bcm_host vchiq_arm) + if(RPI_32) + link_directories("${CMAKE_FIND_ROOT_PATH}/opt/vc/lib") + endif() +endif() + +# Note: Building with GLES support on the Raspberry Pi currently seems to be broken. +if(GLES AND RPI_32) + list(APPEND COMMON_LIBRARIES brcmEGL ${OPENGLES_LIBRARIES}) +elseif(GLES AND RPI_64) list(APPEND COMMON_LIBRARIES ${OPENGLES_LIBRARIES}) endif() +# OpenGL. if(GLSYSTEM MATCHES "Desktop OpenGL") list(APPEND COMMON_LIBRARIES ${OPENGL_LIBRARIES}) else() diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 7ca851bb6..acb13f325 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -1010,7 +1010,7 @@ void GuiMenu::openOtherOptions() } #endif -#if !defined(_RPI_) +#if defined(VIDEO_HW_DECODING) // Whether to enable hardware decoding for the FFmpeg video player. auto video_hardware_decoding = std::make_shared(mWindow); video_hardware_decoding->setState(Settings::getInstance()->getBool("VideoHardwareDecoding")); diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index cd3879978..f066a4f76 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -98,7 +98,7 @@ void Settings::setDefaults() // Scraper. mStringMap["Scraper"] = {"screenscraper", "screenscraper"}; - mBoolMap["ScraperUseAccountScreenScraper"] = {false, false}; + mBoolMap["ScraperUseAccountScreenScraper"] = {true, true}; mStringMap["ScraperUsernameScreenScraper"] = {"", ""}; mStringMap["ScraperPasswordScreenScraper"] = {"", ""}; @@ -154,7 +154,11 @@ void Settings::setDefaults() // UI settings -> media viewer settings. mBoolMap["MediaViewerKeepVideoRunning"] = {true, true}; mBoolMap["MediaViewerStretchVideos"] = {false, false}; +#if defined(_RPI_) + mBoolMap["MediaViewerVideoScanlines"] = {false, false}; +#else mBoolMap["MediaViewerVideoScanlines"] = {true, true}; +#endif mBoolMap["MediaViewerVideoBlur"] = {false, false}; mBoolMap["MediaViewerScreenshotScanlines"] = {true, true}; @@ -177,7 +181,11 @@ void Settings::setDefaults() mIntMap["ScreensaverSwapVideoTimeout"] = {0, 0}; mBoolMap["ScreensaverStretchVideos"] = {false, false}; mBoolMap["ScreensaverVideoGameInfo"] = {true, true}; +#if defined(_RPI_) + mBoolMap["ScreensaverVideoScanlines"] = {false, false}; +#else mBoolMap["ScreensaverVideoScanlines"] = {true, true}; +#endif mBoolMap["ScreensaverVideoBlur"] = {false, false}; mBoolMap["MenuBlurBackground"] = {true, true}; @@ -199,8 +207,8 @@ void Settings::setDefaults() mBoolMap["EnableMenuKidMode"] = {false, false}; // Sound settings. - mIntMap["SoundVolumeNavigation"] = {80, 80}; - mIntMap["SoundVolumeVideos"] = {100, 100}; + mIntMap["SoundVolumeNavigation"] = {70, 70}; + mIntMap["SoundVolumeVideos"] = {80, 80}; mBoolMap["GamelistVideoAudio"] = {true, true}; mBoolMap["MediaViewerVideoAudio"] = {true, true}; mBoolMap["ScreensaverVideoAudio"] = {false, false}; @@ -221,7 +229,7 @@ void Settings::setDefaults() // Other settings. mStringMap["MediaDirectory"] = {"", ""}; #if defined(_RPI_) - mIntMap["MaxVRAM"] = {80, 80}; + mIntMap["MaxVRAM"] = {180, 180}; #else mIntMap["MaxVRAM"] = {256, 256}; #endif @@ -230,12 +238,7 @@ void Settings::setDefaults() mStringMap["FullscreenMode"] = {"normal", "normal"}; #endif #if defined(BUILD_VLC_PLAYER) -#if defined(_RPI_) - // As the FFmpeg video player is not HW accelerated, use VLC as default on this weak device. - mStringMap["VideoPlayer"] = {"vlc", "vlc"}; -#else mStringMap["VideoPlayer"] = {"ffmpeg", "ffmpeg"}; -#endif #endif mStringMap["ExitButtonCombo"] = {"F4", "F4"}; mStringMap["SaveGamelistsMode"] = {"always", "always"}; @@ -246,7 +249,7 @@ void Settings::setDefaults() #if defined(_WIN64) mBoolMap["LaunchWorkaround"] = {true, true}; #endif -#if !defined(_RPI_) +#if !defined(VIDEO_HW_DECODING) mBoolMap["VideoHardwareDecoding"] = {false, false}; #endif mBoolMap["VideoUpscaleFrameRate"] = {false, false}; diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index 45c499d67..9bb31a8f3 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -1227,7 +1227,7 @@ void VideoFFmpegComponent::startVideo() // Video stream setup. -#if defined(_RPI_) +#if !defined(VIDEO_HW_DECODING) bool hwDecoding = false; #else bool hwDecoding = Settings::getInstance()->getBool("VideoHardwareDecoding");