RetroPie-Setup/scriptmodules/supplementary/kmsxx.sh
cmitu f113a80f36 runcommand: add new 'kms' videomode utility
Replaced the `mesa-drm` scriptmodule and the `modetest` utility with a new program, based on the [kmsxx](https://github.com/tomba/kmsxx) project.

1. Added a new scriptmodule to install the new modesetting utilities:

 * kmsblank - blank screen(s)
 * kmstest - set modes and planes and show test pattern on crtcs/planes,
    and test page flips
 * kmsprint(-rp) - print information about DRM objects (connectors, encoders, video modes, crtcs)
 * fbtest - show info about the console framebuffer

It's based on https://github.com/tomba/kmsxx, forked to add a custom `kmsprint-rp` utility which we can use in `runcommand` instead of `modetest`.

Advantages over `modetest`:

 - it's based on a simpler standalone project and not part of Mesa, less code.
 - it's has a modularized C++ API for working with Cards/Encoders/Connectors/CRTCs/etc, modeled after the DRM API entities
 - works with any DRM/KMS card and doesn't have any card specific code like `modetest`
 - it's faster than modetest (both when KMS is enabled or disabled)
 - can print the analog video modes when the 'composite' output is enabled for RPI. I think `modetest` can be modified to support it, but with `kmsxx` is working without any special handling.

 Note that a Debian package of the `kmsxx` upstream project is packaged in Rasberry PI OS (as `kms++-utils`), but it's not part of Debian. Packaging it as part of RetroPie helps with:
   - integration with `runcommand`, since we can run our own custom query utility
   - resolution switching on other KMS platforms

2. Changes to `runcommand`:

  - replaced `modetest` with `kmsprint-rp`. The format for the modeline printing has changed a bit, to make it easier to parse and integrate the result in `runcommand`. In addition to the rounded/integral refresh rate, there's a new column to show a decimal refresh rate; the _[p|n][h|v]sync_ flags have been reformatted as _[h|v]sync[-|+]_.
  - simplified the modeline parsing for KMS, taking advantage of the new format
  - refresh rate (from KMS modeline) is now be a decimal number (.2f), supported by RetroArch
2024-01-23 16:58:31 +00:00

43 lines
1.3 KiB
Bash

#!/usr/bin/env bash
# This file is part of The RetroPie Project
#
# The RetroPie Project is the legal property of its developers, whose names are
# too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source.
#
# See the LICENSE.md file at the top-level directory of this distribution and
# at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md
#
rp_module_id="kmsxx"
rp_module_desc="library and utilities for Linux kernel mode setting"
rp_module_licence="MPL2 https://raw.githubusercontent.com/cmitu/kmsxx/master/LICENSE"
rp_module_repo="git https://github.com/cmitu/kmsxx retropie"
rp_module_section="depends"
rp_module_flags=""
function depends_kmsxx() {
getDepends meson ninja-build libdrm-dev libfmt-dev pkg-config
}
function sources_kmsxx() {
gitPullOrClone
}
function build_kmsxx() {
rm -fr build
meson setup --prefix="$md_inst" -Dbuildtype=release -Ddefault_library=static -Domap=disabled -Dpykms=disabled -Dkmscube=false build
ninja -C build
md_ret_require="$md_build/build/utils/kmsprint-rp"
}
function install_kmsxx() {
md_ret_files=(
build/utils/kmsprint-rp
build/utils/kmsprint
build/utils/kmsview
build/utils/kmsblank
build/utils/fbtest
)
}