git: 01215ffec65a - stable/14 - vt: Add vd_bitblt_argb
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 29 Jul 2024 16:38:32 UTC
The branch stable/14 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=01215ffec65ae607a0583c564158097b5d56e531 commit 01215ffec65ae607a0583c564158097b5d56e531 Author: Emmanuel Vadot <manu@FreeBSD.org> AuthorDate: 2024-07-09 12:35:12 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2024-07-29 16:37:12 +0000 vt: Add vd_bitblt_argb This blit an ARGB image on the dedicated vd. This also adds vt_fb_bitblt_argb which will works for most of the vt backends Differential Revision: https://reviews.freebsd.org/D45929 Reviewed by: tsoome Sponsored by: Beckhoff Automation GmbH & Co. KG (cherry picked from commit b93028d8cd3aafc883b5f0ecec65a8a2a30af7f3) --- sys/dev/virtio/gpu/virtio_gpu.c | 12 ++++++++++ sys/dev/vt/hw/efifb/efifb.c | 1 + sys/dev/vt/hw/fb/vt_early_fb.c | 1 + sys/dev/vt/hw/fb/vt_fb.c | 47 +++++++++++++++++++++++++++++++++++++++ sys/dev/vt/hw/fb/vt_fb.h | 1 + sys/dev/vt/hw/ofwfb/ofwfb.c | 12 ++++++++++ sys/dev/vt/hw/simplefb/simplefb.c | 12 ++++++++++ sys/dev/vt/hw/vbefb/vbefb.c | 1 + sys/dev/vt/hw/vga/vt_vga.c | 12 ++++++++++ sys/dev/vt/vt.h | 5 +++++ 10 files changed, 104 insertions(+) diff --git a/sys/dev/virtio/gpu/virtio_gpu.c b/sys/dev/virtio/gpu/virtio_gpu.c index 6209fe4beae1..ccb49a6b7695 100644 --- a/sys/dev/virtio/gpu/virtio_gpu.c +++ b/sys/dev/virtio/gpu/virtio_gpu.c @@ -102,6 +102,7 @@ static vd_bitblt_text_t vtgpu_fb_bitblt_text; static vd_bitblt_bmp_t vtgpu_fb_bitblt_bitmap; static vd_drawrect_t vtgpu_fb_drawrect; static vd_setpixel_t vtgpu_fb_setpixel; +static vd_bitblt_argb_t vtgpu_fb_bitblt_argb; static struct vt_driver vtgpu_fb_driver = { .vd_name = "virtio_gpu", @@ -111,6 +112,7 @@ static struct vt_driver vtgpu_fb_driver = { .vd_bitblt_text = vtgpu_fb_bitblt_text, .vd_invalidate_text = vt_fb_invalidate_text, .vd_bitblt_bmp = vtgpu_fb_bitblt_bitmap, + .vd_bitblt_argb = vtgpu_fb_bitblt_argb, .vd_drawrect = vtgpu_fb_drawrect, .vd_setpixel = vtgpu_fb_setpixel, .vd_postswitch = vt_fb_postswitch, @@ -180,6 +182,16 @@ vtgpu_fb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, vtgpu_resource_flush(sc, x, y, width, height); } +static int +vtgpu_fb_bitblt_argb(struct vt_device *vd, const struct vt_window *vw, + const uint8_t *argb, + unsigned int width, unsigned int height, + unsigned int x, unsigned int y) +{ + + return (EOPNOTSUPP); +} + static void vtgpu_fb_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2, int fill, term_color_t color) diff --git a/sys/dev/vt/hw/efifb/efifb.c b/sys/dev/vt/hw/efifb/efifb.c index 12909d836a24..3ba501c000cb 100644 --- a/sys/dev/vt/hw/efifb/efifb.c +++ b/sys/dev/vt/hw/efifb/efifb.c @@ -59,6 +59,7 @@ static struct vt_driver vt_efifb_driver = { .vd_bitblt_text = vt_fb_bitblt_text, .vd_invalidate_text = vt_fb_invalidate_text, .vd_bitblt_bmp = vt_fb_bitblt_bitmap, + .vd_bitblt_argb = vt_fb_bitblt_argb, .vd_drawrect = vt_fb_drawrect, .vd_setpixel = vt_fb_setpixel, .vd_fb_ioctl = vt_fb_ioctl, diff --git a/sys/dev/vt/hw/fb/vt_early_fb.c b/sys/dev/vt/hw/fb/vt_early_fb.c index 265a148ae556..920bfa05fd63 100644 --- a/sys/dev/vt/hw/fb/vt_early_fb.c +++ b/sys/dev/vt/hw/fb/vt_early_fb.c @@ -59,6 +59,7 @@ static struct vt_driver vt_fb_early_driver = { .vd_bitblt_text = vt_fb_bitblt_text, .vd_invalidate_text = vt_fb_invalidate_text, .vd_bitblt_bmp = vt_fb_bitblt_bitmap, + .vd_bitblt_argb = vt_fb_bitblt_argb, .vd_drawrect = vt_fb_drawrect, .vd_setpixel = vt_fb_setpixel, .vd_priority = VD_PRIORITY_GENERIC, diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c index 5f4173ab144f..87d0595a66f1 100644 --- a/sys/dev/vt/hw/fb/vt_fb.c +++ b/sys/dev/vt/hw/fb/vt_fb.c @@ -50,6 +50,7 @@ static struct vt_driver vt_fb_driver = { .vd_bitblt_text = vt_fb_bitblt_text, .vd_invalidate_text = vt_fb_invalidate_text, .vd_bitblt_bmp = vt_fb_bitblt_bitmap, + .vd_bitblt_argb = vt_fb_bitblt_argb, .vd_drawrect = vt_fb_drawrect, .vd_setpixel = vt_fb_setpixel, .vd_postswitch = vt_fb_postswitch, @@ -333,6 +334,52 @@ vt_fb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, } } +int +vt_fb_bitblt_argb(struct vt_device *vd, const struct vt_window *vw, + const uint8_t *argb, + unsigned int width, unsigned int height, + unsigned int x, unsigned int y) +{ + struct fb_info *info; + uint32_t o, cc; + int bpp, xi, yi; + + info = vd->vd_softc; + bpp = FBTYPE_GET_BYTESPP(info); + if (bpp != 4) + return (EOPNOTSUPP); + + if (info->fb_flags & FB_FLAG_NOWRITE) + return (0); + + KASSERT((info->fb_vbase != 0), ("Unmapped framebuffer")); + + /* Bound by right and bottom edges. */ + if (y + height > vw->vw_draw_area.tr_end.tp_row) { + if (y >= vw->vw_draw_area.tr_end.tp_row) + return (EINVAL); + height = vw->vw_draw_area.tr_end.tp_row - y; + } + if (x + width > vw->vw_draw_area.tr_end.tp_col) { + if (x >= vw->vw_draw_area.tr_end.tp_col) + return (EINVAL); + width = vw->vw_draw_area.tr_end.tp_col - x; + } + for (yi = 0; yi < height; yi++) { + for (xi = 0; xi < (width * 4); xi += 4) { + o = (y + yi) * info->fb_stride + (x + (xi / 4)) * bpp; + o += vd->vd_transpose; + cc = (argb[yi * width * 4 + xi] << 16) | + (argb[yi * width * 4 + xi + 1] << 8) | + (argb[yi * width * 4 + xi + 2]) | + (argb[yi * width * 4 + xi + 3] << 24); + vt_fb_mem_wr4(info, o, cc); + } + } + + return (0); +} + void vt_fb_bitblt_text(struct vt_device *vd, const struct vt_window *vw, const term_rect_t *area) diff --git a/sys/dev/vt/hw/fb/vt_fb.h b/sys/dev/vt/hw/fb/vt_fb.h index 54f7ba667eb1..fc3db42b2a15 100644 --- a/sys/dev/vt/hw/fb/vt_fb.h +++ b/sys/dev/vt/hw/fb/vt_fb.h @@ -42,6 +42,7 @@ vd_blank_t vt_fb_blank; vd_bitblt_text_t vt_fb_bitblt_text; vd_invalidate_text_t vt_fb_invalidate_text; vd_bitblt_bmp_t vt_fb_bitblt_bitmap; +vd_bitblt_argb_t vt_fb_bitblt_argb; vd_drawrect_t vt_fb_drawrect; vd_setpixel_t vt_fb_setpixel; vd_postswitch_t vt_fb_postswitch; diff --git a/sys/dev/vt/hw/ofwfb/ofwfb.c b/sys/dev/vt/hw/ofwfb/ofwfb.c index 0dc0c39f92cb..aca6b6faeae1 100644 --- a/sys/dev/vt/hw/ofwfb/ofwfb.c +++ b/sys/dev/vt/hw/ofwfb/ofwfb.c @@ -67,6 +67,7 @@ static vd_probe_t ofwfb_probe; static vd_init_t ofwfb_init; static vd_bitblt_text_t ofwfb_bitblt_text; static vd_bitblt_bmp_t ofwfb_bitblt_bitmap; +static vd_bitblt_argb_t ofwfb_bitblt_argb; static const struct vt_driver vt_ofwfb_driver = { .vd_name = "ofwfb", @@ -75,6 +76,7 @@ static const struct vt_driver vt_ofwfb_driver = { .vd_blank = vt_fb_blank, .vd_bitblt_text = ofwfb_bitblt_text, .vd_bitblt_bmp = ofwfb_bitblt_bitmap, + .vd_bitblt_argb = ofwfb_bitblt_argb, .vd_fb_ioctl = vt_fb_ioctl, .vd_fb_mmap = vt_fb_mmap, .vd_priority = VD_PRIORITY_GENERIC+1, @@ -243,6 +245,16 @@ ofwfb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, } } +static int +ofwfb_bitblt_argb(struct vt_device *vd, const struct vt_window *vw, + const uint8_t *argb, + unsigned int width, unsigned int height, + unsigned int x, unsigned int y) +{ + + return (EOPNOTSUPP); +} + void ofwfb_bitblt_text(struct vt_device *vd, const struct vt_window *vw, const term_rect_t *area) diff --git a/sys/dev/vt/hw/simplefb/simplefb.c b/sys/dev/vt/hw/simplefb/simplefb.c index c5f17e1b3d16..2f8fd6036ae3 100644 --- a/sys/dev/vt/hw/simplefb/simplefb.c +++ b/sys/dev/vt/hw/simplefb/simplefb.c @@ -50,6 +50,7 @@ static vd_init_t vt_simplefb_init; static vd_fini_t vt_simplefb_fini; static vd_probe_t vt_simplefb_probe; +static vd_bitblt_argb_t vt_simplefb_bitblt_argb; static struct vt_driver vt_simplefb_driver = { .vd_name = "simplefb", @@ -60,6 +61,7 @@ static struct vt_driver vt_simplefb_driver = { .vd_bitblt_text = vt_fb_bitblt_text, .vd_invalidate_text = vt_fb_invalidate_text, .vd_bitblt_bmp = vt_fb_bitblt_bitmap, + .vd_bitblt_argb = vt_simplefb_bitblt_argb, .vd_drawrect = vt_fb_drawrect, .vd_setpixel = vt_fb_setpixel, .vd_fb_ioctl = vt_fb_ioctl, @@ -222,3 +224,13 @@ vt_simplefb_fini(struct vt_device *vd, void *softc) vt_fb_fini(vd, softc); pmap_unmapdev((void *)sc->fb_vbase, sc->fb_size); } + +static int +vt_simplefb_bitblt_argb(struct vt_device *vd, const struct vt_window *vw, + const uint8_t *argb, + unsigned int width, unsigned int height, + unsigned int x, unsigned int y) +{ + + return (EOPNOTSUPP); +} diff --git a/sys/dev/vt/hw/vbefb/vbefb.c b/sys/dev/vt/hw/vbefb/vbefb.c index f7dce1be0832..4e65657639b4 100644 --- a/sys/dev/vt/hw/vbefb/vbefb.c +++ b/sys/dev/vt/hw/vbefb/vbefb.c @@ -59,6 +59,7 @@ static struct vt_driver vt_vbefb_driver = { .vd_bitblt_text = vt_fb_bitblt_text, .vd_invalidate_text = vt_fb_invalidate_text, .vd_bitblt_bmp = vt_fb_bitblt_bitmap, + .vd_bitblt_argb = vt_fb_bitblt_argb, .vd_drawrect = vt_fb_drawrect, .vd_setpixel = vt_fb_setpixel, .vd_fb_ioctl = vt_fb_ioctl, diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c index fdfbaebc0e79..51880ebb62e2 100644 --- a/sys/dev/vt/hw/vga/vt_vga.c +++ b/sys/dev/vt/hw/vga/vt_vga.c @@ -97,6 +97,7 @@ static vd_blank_t vga_blank; static vd_bitblt_text_t vga_bitblt_text; static vd_invalidate_text_t vga_invalidate_text; static vd_bitblt_bmp_t vga_bitblt_bitmap; +static vd_bitblt_argb_t vga_bitblt_argb; static vd_drawrect_t vga_drawrect; static vd_setpixel_t vga_setpixel; static vd_postswitch_t vga_postswitch; @@ -109,6 +110,7 @@ static const struct vt_driver vt_vga_driver = { .vd_bitblt_text = vga_bitblt_text, .vd_invalidate_text = vga_invalidate_text, .vd_bitblt_bmp = vga_bitblt_bitmap, + .vd_bitblt_argb = vga_bitblt_argb, .vd_drawrect = vga_drawrect, .vd_setpixel = vga_setpixel, .vd_postswitch = vga_postswitch, @@ -999,6 +1001,16 @@ vga_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, } } +static int +vga_bitblt_argb(struct vt_device *vd, const struct vt_window *vw, + const uint8_t *argb, + unsigned int width, unsigned int height, + unsigned int x, unsigned int y) +{ + + return (EOPNOTSUPP); +} + static void vga_initialize_graphics(struct vt_device *vd) { diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index 56a28c0420c7..8e35a81bc101 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -345,6 +345,10 @@ typedef void vd_bitblt_bmp_t(struct vt_device *vd, const struct vt_window *vw, const uint8_t *pattern, const uint8_t *mask, unsigned int width, unsigned int height, unsigned int x, unsigned int y, term_color_t fg, term_color_t bg); +typedef int vd_bitblt_argb_t(struct vt_device *vd, const struct vt_window *vw, + const uint8_t *argb, + unsigned int width, unsigned int height, + unsigned int x, unsigned int y); typedef int vd_fb_ioctl_t(struct vt_device *, u_long, caddr_t, struct thread *); typedef int vd_fb_mmap_t(struct vt_device *, vm_ooffset_t, vm_paddr_t *, int, vm_memattr_t *); @@ -368,6 +372,7 @@ struct vt_driver { vd_bitblt_text_t *vd_bitblt_text; vd_invalidate_text_t *vd_invalidate_text; vd_bitblt_bmp_t *vd_bitblt_bmp; + vd_bitblt_argb_t *vd_bitblt_argb; /* Framebuffer ioctls, if present. */ vd_fb_ioctl_t *vd_fb_ioctl;