Added proper support for the Raspberry Pi 4.

This commit is contained in:
Leon Styhre 2021-11-07 23:54:52 +01:00
parent c642848081
commit ac4710a18e
4 changed files with 64 additions and 32 deletions

View file

@ -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(CEC "Set to ON to enable CEC" ${CEC})
option(VLC_PLAYER "Set to ON to build the VLC-based video player" ${VLC_PLAYER}) 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(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) if(CLANG_TIDY)
find_program(CLANG_TIDY_BINARY NAMES clang-tidy) find_program(CLANG_TIDY_BINARY NAMES clang-tidy)
@ -58,14 +59,7 @@ endif()
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
# OpenGL setup. # OpenGL setup.
# Check if we're running on a Raspberry Pi. if(GLES)
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)
set(GLSYSTEM "Embedded OpenGL" CACHE STRING "The OpenGL system to be used") set(GLSYSTEM "Embedded OpenGL" CACHE STRING "The OpenGL system to be used")
else() else()
set(GLSYSTEM "Desktop OpenGL" CACHE STRING "The OpenGL system to be used") 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") 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. # Package dependencies.
@ -196,18 +216,22 @@ else()
add_definitions(-DUSE_OPENGLES_10) add_definitions(-DUSE_OPENGLES_10)
endif() endif()
if(RPI)
add_definitions(-D_RPI_)
endif()
if(VLC_PLAYER) if(VLC_PLAYER)
add_definitions(-DBUILD_VLC_PLAYER) add_definitions(-DBUILD_VLC_PLAYER)
endif() endif()
if(DEFINED BCMHOST OR RPI)
add_definitions(-D_RPI_)
endif()
if(DEFINED libCEC_FOUND) if(DEFINED libCEC_FOUND)
add_definitions(-DHAVE_LIBCEC) add_definitions(-DHAVE_LIBCEC)
endif() endif()
if(VIDEO_HW_DECODING)
add_definitions(-DVIDEO_HW_DECODING)
endif()
# GLM library options. # GLM library options.
add_definitions(-DGLM_FORCE_CXX17) add_definitions(-DGLM_FORCE_CXX17)
add_definitions(-DGLM_FORCE_XYZW_ONLY) add_definitions(-DGLM_FORCE_XYZW_ONLY)
@ -279,7 +303,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
list(APPEND COMMON_INCLUDE_DIRS ${ALSA_INCLUDE_DIRS}) list(APPEND COMMON_INCLUDE_DIRS ${ALSA_INCLUDE_DIRS})
endif() endif()
if(DEFINED BCMHOST OR RPI) if(RPI_32)
list(APPEND COMMON_INCLUDE_DIRS "${CMAKE_FIND_ROOT_PATH}/opt/vc/include" 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/vcos"
"${CMAKE_FIND_ROOT_PATH}/opt/vc/include/interface/vmcs_host/linux" "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/interface/vmcs_host/linux"
@ -358,9 +382,6 @@ endif()
# Add libCEC libraries. # Add libCEC libraries.
if(DEFINED libCEC_FOUND) 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}) list(APPEND COMMON_LIBRARIES dl ${libCEC_LIBRARIES})
endif() endif()
@ -369,14 +390,22 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
list(APPEND COMMON_LIBRARIES ${ALSA_LIBRARY}) list(APPEND COMMON_LIBRARIES ${ALSA_LIBRARY})
endif() endif()
# Raspberry Pi.
if(DEFINED BCMHOST) if(DEFINED BCMHOST)
list(APPEND COMMON_LIBRARIES bcm_host vchiq_arm)
if(RPI_32)
link_directories("${CMAKE_FIND_ROOT_PATH}/opt/vc/lib") link_directories("${CMAKE_FIND_ROOT_PATH}/opt/vc/lib")
list(APPEND COMMON_LIBRARIES bcm_host brcmEGL ${OPENGLES_LIBRARIES}) endif()
elseif(RPI) endif()
link_directories("${CMAKE_FIND_ROOT_PATH}/opt/vc/lib")
# 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}) list(APPEND COMMON_LIBRARIES ${OPENGLES_LIBRARIES})
endif() endif()
# OpenGL.
if(GLSYSTEM MATCHES "Desktop OpenGL") if(GLSYSTEM MATCHES "Desktop OpenGL")
list(APPEND COMMON_LIBRARIES ${OPENGL_LIBRARIES}) list(APPEND COMMON_LIBRARIES ${OPENGL_LIBRARIES})
else() else()

View file

@ -1010,7 +1010,7 @@ void GuiMenu::openOtherOptions()
} }
#endif #endif
#if !defined(_RPI_) #if defined(VIDEO_HW_DECODING)
// Whether to enable hardware decoding for the FFmpeg video player. // Whether to enable hardware decoding for the FFmpeg video player.
auto video_hardware_decoding = std::make_shared<SwitchComponent>(mWindow); auto video_hardware_decoding = std::make_shared<SwitchComponent>(mWindow);
video_hardware_decoding->setState(Settings::getInstance()->getBool("VideoHardwareDecoding")); video_hardware_decoding->setState(Settings::getInstance()->getBool("VideoHardwareDecoding"));

View file

@ -98,7 +98,7 @@ void Settings::setDefaults()
// Scraper. // Scraper.
mStringMap["Scraper"] = {"screenscraper", "screenscraper"}; mStringMap["Scraper"] = {"screenscraper", "screenscraper"};
mBoolMap["ScraperUseAccountScreenScraper"] = {false, false}; mBoolMap["ScraperUseAccountScreenScraper"] = {true, true};
mStringMap["ScraperUsernameScreenScraper"] = {"", ""}; mStringMap["ScraperUsernameScreenScraper"] = {"", ""};
mStringMap["ScraperPasswordScreenScraper"] = {"", ""}; mStringMap["ScraperPasswordScreenScraper"] = {"", ""};
@ -154,7 +154,11 @@ void Settings::setDefaults()
// UI settings -> media viewer settings. // UI settings -> media viewer settings.
mBoolMap["MediaViewerKeepVideoRunning"] = {true, true}; mBoolMap["MediaViewerKeepVideoRunning"] = {true, true};
mBoolMap["MediaViewerStretchVideos"] = {false, false}; mBoolMap["MediaViewerStretchVideos"] = {false, false};
#if defined(_RPI_)
mBoolMap["MediaViewerVideoScanlines"] = {false, false};
#else
mBoolMap["MediaViewerVideoScanlines"] = {true, true}; mBoolMap["MediaViewerVideoScanlines"] = {true, true};
#endif
mBoolMap["MediaViewerVideoBlur"] = {false, false}; mBoolMap["MediaViewerVideoBlur"] = {false, false};
mBoolMap["MediaViewerScreenshotScanlines"] = {true, true}; mBoolMap["MediaViewerScreenshotScanlines"] = {true, true};
@ -177,7 +181,11 @@ void Settings::setDefaults()
mIntMap["ScreensaverSwapVideoTimeout"] = {0, 0}; mIntMap["ScreensaverSwapVideoTimeout"] = {0, 0};
mBoolMap["ScreensaverStretchVideos"] = {false, false}; mBoolMap["ScreensaverStretchVideos"] = {false, false};
mBoolMap["ScreensaverVideoGameInfo"] = {true, true}; mBoolMap["ScreensaverVideoGameInfo"] = {true, true};
#if defined(_RPI_)
mBoolMap["ScreensaverVideoScanlines"] = {false, false};
#else
mBoolMap["ScreensaverVideoScanlines"] = {true, true}; mBoolMap["ScreensaverVideoScanlines"] = {true, true};
#endif
mBoolMap["ScreensaverVideoBlur"] = {false, false}; mBoolMap["ScreensaverVideoBlur"] = {false, false};
mBoolMap["MenuBlurBackground"] = {true, true}; mBoolMap["MenuBlurBackground"] = {true, true};
@ -199,8 +207,8 @@ void Settings::setDefaults()
mBoolMap["EnableMenuKidMode"] = {false, false}; mBoolMap["EnableMenuKidMode"] = {false, false};
// Sound settings. // Sound settings.
mIntMap["SoundVolumeNavigation"] = {80, 80}; mIntMap["SoundVolumeNavigation"] = {70, 70};
mIntMap["SoundVolumeVideos"] = {100, 100}; mIntMap["SoundVolumeVideos"] = {80, 80};
mBoolMap["GamelistVideoAudio"] = {true, true}; mBoolMap["GamelistVideoAudio"] = {true, true};
mBoolMap["MediaViewerVideoAudio"] = {true, true}; mBoolMap["MediaViewerVideoAudio"] = {true, true};
mBoolMap["ScreensaverVideoAudio"] = {false, false}; mBoolMap["ScreensaverVideoAudio"] = {false, false};
@ -221,7 +229,7 @@ void Settings::setDefaults()
// Other settings. // Other settings.
mStringMap["MediaDirectory"] = {"", ""}; mStringMap["MediaDirectory"] = {"", ""};
#if defined(_RPI_) #if defined(_RPI_)
mIntMap["MaxVRAM"] = {80, 80}; mIntMap["MaxVRAM"] = {180, 180};
#else #else
mIntMap["MaxVRAM"] = {256, 256}; mIntMap["MaxVRAM"] = {256, 256};
#endif #endif
@ -230,12 +238,7 @@ void Settings::setDefaults()
mStringMap["FullscreenMode"] = {"normal", "normal"}; mStringMap["FullscreenMode"] = {"normal", "normal"};
#endif #endif
#if defined(BUILD_VLC_PLAYER) #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"}; mStringMap["VideoPlayer"] = {"ffmpeg", "ffmpeg"};
#endif
#endif #endif
mStringMap["ExitButtonCombo"] = {"F4", "F4"}; mStringMap["ExitButtonCombo"] = {"F4", "F4"};
mStringMap["SaveGamelistsMode"] = {"always", "always"}; mStringMap["SaveGamelistsMode"] = {"always", "always"};
@ -246,7 +249,7 @@ void Settings::setDefaults()
#if defined(_WIN64) #if defined(_WIN64)
mBoolMap["LaunchWorkaround"] = {true, true}; mBoolMap["LaunchWorkaround"] = {true, true};
#endif #endif
#if !defined(_RPI_) #if !defined(VIDEO_HW_DECODING)
mBoolMap["VideoHardwareDecoding"] = {false, false}; mBoolMap["VideoHardwareDecoding"] = {false, false};
#endif #endif
mBoolMap["VideoUpscaleFrameRate"] = {false, false}; mBoolMap["VideoUpscaleFrameRate"] = {false, false};

View file

@ -1227,7 +1227,7 @@ void VideoFFmpegComponent::startVideo()
// Video stream setup. // Video stream setup.
#if defined(_RPI_) #if !defined(VIDEO_HW_DECODING)
bool hwDecoding = false; bool hwDecoding = false;
#else #else
bool hwDecoding = Settings::getInstance()->getBool("VideoHardwareDecoding"); bool hwDecoding = Settings::getInstance()->getBool("VideoHardwareDecoding");