Re: Accesing vt(4) framebuffer
- Reply: Ahmad Khalifa : "Re: Accesing vt(4) framebuffer"
- In reply to: Eduardo Morrás : "Accesing vt(4) framebuffer"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 03 Sep 2025 15:23:05 UTC
hi!
We put code review requests in the tool at https://reviews.freebsd.org/ .
If you've not heard back about this
then please feel free to poke me directly.
Having direct fb access from userland would be great. I thought we already
did?!
-adrian
On Tue, 26 Aug 2025 at 07:10, Eduardo Morrás <emorras@emorras.eu> wrote:
>
> Hello, I'm developing a gui/widget over vt(4) framebuffer, no X11 nor
> Wayland.
>
> For this I have created a new ioctl that allows access to framebuffer
> information and change it's content. For this I modified
> /usr/src/sys/dev/vt/hw/fb/vt_fb.c and .h, patches at end of this mail.
>
> Is this a correct way? Should I do it different? Any security problems?
>
>
> Thanks, Good Day.
>
>
> --- vt_fb.h_ORIG 2025-08-21 19:01:01.192050000 +0200
> +++ vt_fb.h 2025-08-21 19:04:58.447415000 +0200
> @@ -49,4 +49,20 @@
> vd_fb_ioctl_t vt_fb_ioctl;
> vd_fb_mmap_t vt_fb_mmap;
>
> +#ifdef _KERNEL
> +#include <sys/ioccom.h>
> +#endif
> +
> +/* Struct to expose framebuffer to userland*/
> +struct vt_fb_userinfo {
> + uint32_t width;
> + uint32_t height;
> + uint32_t depth;
> + uint32_t stride;
> + uint32_t size;
> +};
> +
> +/* IOCTL code to work with vt_fb_userinfo */
> +#define VT_FB_GETINFO _IOR('v', 1, struct vt_fb_userinfo)
> +
> #endif /* _DEV_VT_HW_FB_VT_FB_H_ */
>
>
> --- vt_fb.c_ORIG 2025-08-21 19:01:07.096190000 +0200
> +++ vt_fb.c 2025-08-21 19:10:22.228787000 +0200
> @@ -42,6 +42,8 @@
> #include <vm/vm.h>
> #include <vm/pmap.h>
>
> +#include <sys/ioccom.h> /* Userland access framebuffer */
> +
> static struct vt_driver vt_fb_driver = {
> .vd_name = "fb",
> .vd_init = vt_fb_init,
> @@ -87,6 +89,24 @@
> *(uint32_t *)(sc->fb_vbase + o) = v;
> }
>
> +static int
> +vt_fb_userioctl(struct vt_device *vd, u_long cmd, caddr_t data)
> +{
> + struct vt_fb_userinfo *ui = (struct vt_fb_userinfo *)data;
> + struct fb_info *info = vd->vd_softc;
> +
> + if (cmd != VT_FB_GETINFO)
> + return (ENOIOCTL);
> +
> + ui->width = info->fb_width;
> + ui->height = info->fb_height;
> + ui->depth = info->fb_bpp * 8;
> + ui->stride = info->fb_stride;
> + ui->size = info->fb_size;
> +
> + return (0);
> +}
> +
> int
> vt_fb_ioctl(struct vt_device *vd, u_long cmd, caddr_t data, struct thread
> *td)
> {
> @@ -125,6 +145,10 @@
> return (ENOTTY);
> memcpy((struct fb_rgboffs *)data, &info->fb_rgboffs,
> sizeof(struct fb_rgboffs));
> + break;
> +
> + case VT_FB_GETINFO: /* userland framebuffer */
> + return vt_fb_userioctl(vd, cmd, data);
> break;
>
> default:
>
>
> --- ---
> Eduardo Morrás <emorras@emorras.eu>
>
>