Change resolution using bash on rpi4?

  • I've been searching for some time for a way to set the resolution via bash on libreelec but cannot find anything. Is there a method for setting it?

    I've tried the following...

    Code
    LibreELEC:~ # echo U:1920x1200p-0 > /sys/class/graphics/fb0/mode
    sh: write error: Invalid argument
    Code
    LibreELEC:~ # tvservice -e "CEA 4"
    tvservice is not supported when using the vc4-kms-v3d driver.
    Similar features are available with standard linux tools
    such as modetest from libdrm-tests.
    Code
    LibreELEC:~ # xrandr -s 1920x1080
    -sh: xrandr: not found
    Code
    LibreELEC:~ # fbset -s
    
    mode "1920x1080-0"
            # D: 0.000 MHz, H: 0.000 kHz, V: 0.000 Hz
            geometry 1920 1080 1920 1080 16
            timings 0 0 0 0 0 0 0
            accel true
            rgba 5/11,6/5,5/0,0/0
    endmode

    Finally found some good documentation for modetest but that also fails with permission denied:

    DRM KMS overview - stm32mpu

    Code
    LibreELEC:~ # modetest -M vc4 -s 32@76:1280x720-50 -d
    setting mode 1280x720-50.00Hz on connectors 32, crtc 76
    failed to set mode: Permission denied

    This appears to be down to DRM. Is there a way to disable this?

    Linux/DRA718: How to enable color bar output on VOUT and HDMI? - Processors forum - Processors - TI E2E support forums

    Any ideas? I need a tool for an add on wrapper to launch script. Thanks!

    Edited 2 times, last by domb84 (December 29, 2021 at 10:55 PM).

  • You cannot switch resolutions like you can with xrandr (which doesn't work as we don't use X11) but you can force the intitial resolution used for boot by adding "video=HDMI-A-1:1920x1080M@60" to kernel boot params. On a Raspberry Pi this is in cmdline.txt in the root folder of the SD card. From SSH this is /flash/cmdline.txt but you will need to remount /flash in rw mode first to edit the file.

  • You cannot switch resolutions like you can with xrandr (which doesn't work as we don't use X11) but you can force the intitial resolution used for boot by adding "video=HDMI-A-1:1920x1080M@60" to kernel boot params. On a Raspberry Pi this is in cmdline.txt in the root folder of the SD card. From SSH this is /flash/cmdline.txt but you will need to remount /flash in rw mode first to edit the file.

    I'm already aware of the boot parameters but this doesn't suit my use case. I need different resolutions for different applications.

    Kodi already switches resolution and frame rate based on source material, can I emulate this some how? I've been searching through the source code but cannot find anything regarding how this is achieved (also my knowledge beyond bash and a bit of python is poor!).

    It seems modetest does actually work if I stop the kodi service, so I'll see if I can shoehorn that into a script somehow.