diff options
author | Aleksandr Rybalko <ray@FreeBSD.org> | 2014-02-06 15:12:44 +0000 |
---|---|---|
committer | Aleksandr Rybalko <ray@FreeBSD.org> | 2014-02-06 15:12:44 +0000 |
commit | 9e497e7b044dcc9195f1d13903ddce7f8f057727 (patch) | |
tree | b69f299c6508d439e70b6563437fedc2616dca80 | |
parent | 0205ddeb44c1561d467a6afd411aa4f0f23a5f93 (diff) | |
download | src-9e497e7b044dcc9195f1d13903ddce7f8f057727.tar.gz src-9e497e7b044dcc9195f1d13903ddce7f8f057727.zip |
Add two new vt(9) driver methods: vd_drawrect and vd_setpixel.
Implement vd_drawrect and vd_setpixel for vt_fb driver.
Sponsored by: The FreeBSD Foundation
Notes
Notes:
svn path=/head/; revision=261552
-rw-r--r-- | sys/dev/vt/hw/fb/vt_fb.c | 55 | ||||
-rw-r--r-- | sys/dev/vt/vt.h | 5 |
2 files changed, 60 insertions, 0 deletions
diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c index 2f0ffcb5727b..7163bdc786ac 100644 --- a/sys/dev/vt/hw/fb/vt_fb.c +++ b/sys/dev/vt/hw/fb/vt_fb.c @@ -45,11 +45,16 @@ static int vt_fb_ioctl(struct vt_device *vd, u_long cmd, caddr_t data, struct thread *td); static int vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, vm_paddr_t *paddr, int prot, vm_memattr_t *memattr); +void vt_fb_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2, + int fill, term_color_t color); +void vt_fb_setpixel(struct vt_device *vd, int x, int y, term_color_t color); static struct vt_driver vt_fb_driver = { .vd_init = vt_fb_init, .vd_blank = vt_fb_blank, .vd_bitbltchr = vt_fb_bitbltchr, + .vd_drawrect = vt_fb_drawrect, + .vd_setpixel = vt_fb_setpixel, .vd_postswitch = vt_fb_postswitch, .vd_priority = VD_PRIORITY_GENERIC+10, .vd_fb_ioctl = vt_fb_ioctl, @@ -84,6 +89,56 @@ vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, vm_paddr_t *paddr, } void +vt_fb_setpixel(struct vt_device *vd, int x, int y, term_color_t color) +{ + struct fb_info *info; + uint32_t c; + u_int o; + + info = vd->vd_softc; + c = info->fb_cmap[color]; + o = info->fb_stride * y + x * FBTYPE_GET_BYTESPP(info); + + switch (FBTYPE_GET_BYTESPP(info)) { + case 1: + info->wr1(info, o, c); + break; + case 2: + info->wr2(info, o, c); + break; + case 3: + info->wr1(info, o, (c >> 16) & 0xff); + info->wr1(info, o + 1, (c >> 8) & 0xff); + info->wr1(info, o + 2, c & 0xff); + break; + case 4: + info->wr4(info, o, c); + break; + default: + /* panic? */ + return; + } + +} + +void +vt_fb_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2, int fill, + term_color_t color) +{ + int x, y; + + for (y = y1; y <= y2; y++) { + if (fill || (y == y1) || (y == y2)) { + for (x = x1; x <= x2; x++) + vt_fb_setpixel(vd, x, y, color); + } else { + vt_fb_setpixel(vd, x1, y, color); + vt_fb_setpixel(vd, x2, y, color); + } + } +} + +void vt_fb_blank(struct vt_device *vd, term_color_t color) { struct fb_info *info; diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index 85614177772d..9f175b8d3fe8 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -287,6 +287,9 @@ typedef void vd_putchar_t(struct vt_device *vd, term_char_t, 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 *); +typedef void vd_drawrect_t(struct vt_device *, int, int, int, int, int, + term_color_t); +typedef void vd_setpixel_t(struct vt_device *, int, int, term_color_t); struct vt_driver { /* Console attachment. */ @@ -295,6 +298,8 @@ struct vt_driver { /* Drawing. */ vd_blank_t *vd_blank; vd_bitbltchr_t *vd_bitbltchr; + vd_drawrect_t *vd_drawrect; + vd_setpixel_t *vd_setpixel; /* Framebuffer ioctls, if present. */ vd_fb_ioctl_t *vd_fb_ioctl; |