From a02a2e8b51255f9b0e8d255c3eb78ecc017c8783 Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Tue, 23 Mar 2021 16:05:39 +0100 Subject: [PATCH] busybox: add script to dump edids of active DRM connectors The script dumps all edids of currently active connectors to .config/firmware/edid as edid-CONNECTORNAME.bin When run with the "-q" option informative messages are disabled and only the active connectors are returned so the output can be easily used by other scripts. Signed-off-by: Matthias Reichl --- packages/sysutils/busybox/package.mk | 6 ++- .../busybox/scripts/dump-active-edids-drm | 42 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 packages/sysutils/busybox/scripts/dump-active-edids-drm diff --git a/packages/sysutils/busybox/package.mk b/packages/sysutils/busybox/package.mk index 272aa4dc2f..59c1034f07 100644 --- a/packages/sysutils/busybox/package.mk +++ b/packages/sysutils/busybox/package.mk @@ -122,7 +122,11 @@ makeinstall_host() { makeinstall_target() { mkdir -p ${INSTALL}/usr/bin - [ ${TARGET_ARCH} = x86_64 ] && cp ${PKG_DIR}/scripts/getedid ${INSTALL}/usr/bin + if [ ${TARGET_ARCH} = x86_64 ]; then + cp ${PKG_DIR}/scripts/getedid ${INSTALL}/usr/bin + else + cp ${PKG_DIR}/scripts/dump-active-edids-drm ${INSTALL}/usr/bin/dump-active-edids + fi cp ${PKG_DIR}/scripts/create-edid-cpio ${INSTALL}/usr/bin/ cp ${PKG_DIR}/scripts/createlog ${INSTALL}/usr/bin/ cp ${PKG_DIR}/scripts/dthelper ${INSTALL}/usr/bin diff --git a/packages/sysutils/busybox/scripts/dump-active-edids-drm b/packages/sysutils/busybox/scripts/dump-active-edids-drm new file mode 100755 index 0000000000..2dd4af57c1 --- /dev/null +++ b/packages/sysutils/busybox/scripts/dump-active-edids-drm @@ -0,0 +1,42 @@ +#!/bin/sh + +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv) + +EDID_DIR="/storage/.config/firmware/edid" +CONNECTORS="" + +if [ "$1" = "-q" ]; then + VERBOSE=0 +else + VERBOSE=1 +fi + +info() { + [ "${VERBOSE}" = "1" ] && echo "$@" +} + +mkdir -p "${EDID_DIR}" + +for c in /sys/class/drm/card?-* ; do + [ ! -d "$c" ] && continue + [ ! -e "$c/status" ] && continue + + if [ $(cat $c/status 2>/dev/null) = "connected" ]; then + CONNECTOR=$(basename $c | cut -c 7-) + EDID_NAME="edid-${CONNECTOR}.bin" + cat $c/edid > "${EDID_DIR}/${EDID_NAME}" 2>/dev/null + if [ $? -eq 0 ]; then + [ -n "${CONNECTORS}" ] && CONNECTORS="${CONNECTORS} " + CONNECTORS="${CONNECTORS}${CONNECTOR}" + fi + fi +done + +if [ -z "${CONNECTORS}" ]; then + info "error: no active connectors found" + exit 1 +else + info "found active connector(s) ${CONNECTORS}" + [ "${VERBOSE}" = "0" ] && echo "${CONNECTORS}" +fi