Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TJokiel opened this issue Feb 27, 2023 · 4 comments
Open

Comments

@TJokiel
Copy link

TJokiel commented Feb 27, 2023

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
Copy link
Author

TJokiel commented Feb 28, 2023

Here is a kernel commit which breaks fbv:

"Takashi Iwai [email protected]
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/[email protected]/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
Copy link

m040601 commented Mar 2, 2023

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 <[email protected]>
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
Copy link
Author

TJokiel commented Mar 4, 2023

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants