godspeed1989 / fbv

framebuffer image viewer
Other
79 stars 39 forks source link

FBV not compatible with some framebuffer drivers on 6.1.13+ kernels #30

Open TJokiel opened 1 year ago

TJokiel commented 1 year ago

Hi Team,

As title says - I'm not able to use fbv on latest kernels with certain drivers.

Seems that kernel 6.1.13 (or maybe 6.2.0 and patches were backported to 6.1.x LTS kernel?) introduced changes the the framebuffer code which broke fbv: https://lkml.org/lkml/2023/2/20/511

According to my tests some drivers work: uvesafb efifb

and some do not: vboxvideo (VirtualBox) vmwgfx (VMware) hyperv-fb (Hyper-V gen1) hyperv-drm (Hyper-V gen2)

I have tested it using Ubuntu-22.10 and 6.1.13 kernel from ppa mainline.

On non-working platforms, sometimes I can get the picture displayed if i send the image to /dev/fb0 using fbv and then manually "refresh" the console using e.g dmesg command (image displays then on the right side of the screen).

Other framebuffer viewers like fim, fbi are not affected (but i prefer fbv due to its simplicity).

Any chance to get it fixed?

Thank you.

TJokiel commented 1 year ago

Here is a kernel commit which breaks fbv:

"Takashi Iwai tiwai@suse.de fbdev: Fix invalid page access after closing deferred I/O devices"

Reverting it makes the fbv working with latest kernels and all drivers.

After reading this thread: https://lore.kernel.org/lkml/7eee1f67-c429-a15d-807b-27f1d28c05c8@suse.de/T/

I dont think upstream is going to revert this commit as it fixes some other issues (kernel oops in certain situation). The proper way would be to update fbv code and make it compatible with latest kernels. This is out of my skills though ...

Fim/fbi works OK so it should be possible.

Thanks

m040601 commented 1 year ago

Interesting. I'm also curious about this. Also heard about some "kernel changes". Always get worried when I hear this.

Although I'm not apparently experiencing any problem myself, with kernel 6.2.1. The fbv version I use, builds from, http://s-tech.elsat.net.pl/fbv/, not this same github repo, https://github.com/godspeed1989/fbv/

I'm using fbv to both browse pictures and set a background image to my fbterm terminal.

I'm keeping an eye on this issue to see what is really happening, and leave my feedback. Maybe useful for others.

I'm a heavy user of the terminal and the framebuffer. I dont boot a desktop. I dont even boot X11. Fbv and other framebuffer programs have been serving me very well to watch movies and see pictures.

I'm on Archlinux,

uname -a

Linux gigabyty 6.2.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Sun, 26 Feb 2023 03:39:23 +0000 x86_64 GNU/Linux

pacman -Qi fbv

Name            : fbv
Version         : 1.0b-12
Description     : FrameBuffer image viewer
Architecture    : x86_64
URL             : http://s-tech.elsat.net.pl/fbv/
Licenses        : GPL
Groups          : None
Provides        : None
Depends On      : libpng  giflib  libjpeg
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 39.24 KiB
Packager        : kpcyrd <kpcyrd@archlinux.org>
Build Date      : Tue 15 Nov 2022 11:06:17 AM WET
Install Date    : Tue 15 Nov 2022 04:58:53 PM WET
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

I use fbv to set a background image with fbterm

wallpaper_fbterm.sh

#!/usr/bin/env sh 

# To set a wallpaper in fbterm, you'll need fbv package (framebuffer image viewer). Execute
# the following instructions right before launching fbterm (works in POSIX-compliant shell
# like dash):

# hide cursor
echo -ne "\e[?25l"
    # Finding wallpaper
    bg_wallpaper=${FBTMUX_WALLPAPER:-$(find "$HOME/Pictures" -name 'wallpaper.*' | head -1)}

    # Set wallpaper with fbv
    if command -v fbv > /dev/null 2>&1 && [ -n "$bg_wallpaper" ]; then
        bg_framebuffer=$bg_wallpaper
        # regenerate darkened image for framebuffer with convert
        if command -v convert > /dev/null 2>&1; then
            bg_framebuffer=/tmp/a1.framebuffer.${bg_wallpaper##*.}
            # Compare modified time, only update when needed
            # use stat instead of test -nt/-ot command which dereferences links
            script_time=$(stat -Lc %Y "$0")
            bg_wallpaper_time=$(stat -c %Y "$bg_wallpaper")
            [ -e "$bg_framebuffer" ] && bg_framebuffer_time=$(stat -c %Y "$bg_framebuffer")
            if [ ! -e "$bg_framebuffer" ] \
            || [ "$bg_framebuffer_time" -lt "$bg_wallpaper_time" ] \
            || [ "$bg_framebuffer_time" -lt "$script_time" ]; then
                # convert -modulate brightness,saturation
                convert "$bg_wallpaper" -modulate 10,20 -blur 0x4 "$bg_framebuffer"
            fi
        fi

        # start fbterm/yaft with background using fbv
        fbv -ciuker "$bg_framebuffer" << EOF
q
EOF
        export FBTERM_BACKGROUND_IMAGE=1
    fi

# use it like this to choose the font size,
# wallpaper_fbterm.sh 22
fbterm  -s "$1"

Links:

https://wiki.archlinux.org/title/Fbterm https://github.com/xlucn/dotfiles/tree/master/fbterm

TJokiel commented 1 year ago

@m040601

As stated previously only some drivers are affected. You should be able to recreate the problem if you boot your Archlinux distro in VirtualBox, VMware, Hyper-V.

Real hardware may work OK, I guess their drivers (i915, radeon, etc) do not use the code from:

 drivers/video/fbdev/core/fb_defio.c
 drivers/video/fbdev/core/fbmem.c

Thanks

0x76ADF1 commented 4 weeks ago

For everyone who searches for working solution on newest kernels I found a way to draw in framebuffer directly. Just use ImageMagick. Example:

convert-resize 640x640 -background black -gravity center -rotate 0 -extent 1920x1080 emoji.png bgra:/dev/fb0