The branch main has been updated by manu:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b93028d8cd3aafc883b5f0ecec65a8a2a30af7f3

commit b93028d8cd3aafc883b5f0ecec65a8a2a30af7f3
Author:     Emmanuel Vadot <m...@freebsd.org>
AuthorDate: 2024-07-09 12:35:12 +0000
Commit:     Emmanuel Vadot <m...@freebsd.org>
CommitDate: 2024-07-11 06:47:17 +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
---
 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 f18eef985cc6..eac5b5db21b9 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 805b36d499ae..cac6f93b7af1 100644
--- a/sys/dev/vt/hw/efifb/efifb.c
+++ b/sys/dev/vt/hw/efifb/efifb.c
@@ -58,6 +58,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 52241038ce35..9d66f5cd1398 100644
--- a/sys/dev/vt/hw/fb/vt_early_fb.c
+++ b/sys/dev/vt/hw/fb/vt_early_fb.c
@@ -58,6 +58,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 c1eeb5e69e08..5031ab946203 100644
--- a/sys/dev/vt/hw/fb/vt_fb.c
+++ b/sys/dev/vt/hw/fb/vt_fb.c
@@ -49,6 +49,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,
@@ -332,6 +333,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 6469240ed303..f5653b5f3ff2 100644
--- a/sys/dev/vt/hw/ofwfb/ofwfb.c
+++ b/sys/dev/vt/hw/ofwfb/ofwfb.c
@@ -66,6 +66,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",
@@ -74,6 +75,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,
@@ -242,6 +244,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 c7381b102d3e..6983b41b3888 100644
--- a/sys/dev/vt/hw/simplefb/simplefb.c
+++ b/sys/dev/vt/hw/simplefb/simplefb.c
@@ -49,6 +49,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",
@@ -59,6 +60,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,
@@ -221,3 +223,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 bb4d88dd2ecf..2d6ada6002d0 100644
--- a/sys/dev/vt/hw/vbefb/vbefb.c
+++ b/sys/dev/vt/hw/vbefb/vbefb.c
@@ -58,6 +58,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 e2ae20894fc5..64039575c0ad 100644
--- a/sys/dev/vt/hw/vga/vt_vga.c
+++ b/sys/dev/vt/hw/vga/vt_vga.c
@@ -96,6 +96,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;
@@ -108,6 +109,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,
@@ -998,6 +1000,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;

Reply via email to