Date: Thu, 6 Feb 2014 15:12:44 +0000 (UTC) From: Aleksandr Rybalko <ray@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261552 - in head/sys/dev/vt: . hw/fb Message-ID: <201402061512.s16FCihd086890@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ray Date: Thu Feb 6 15:12:44 2014 New Revision: 261552 URL: http://svnweb.freebsd.org/changeset/base/261552 Log: 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 Modified: head/sys/dev/vt/hw/fb/vt_fb.c head/sys/dev/vt/vt.h Modified: head/sys/dev/vt/hw/fb/vt_fb.c ============================================================================== --- head/sys/dev/vt/hw/fb/vt_fb.c Thu Feb 6 13:28:06 2014 (r261551) +++ head/sys/dev/vt/hw/fb/vt_fb.c Thu Feb 6 15:12:44 2014 (r261552) @@ -45,11 +45,16 @@ static int vt_fb_ioctl(struct vt_device 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_ooff } 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; Modified: head/sys/dev/vt/vt.h ============================================================================== --- head/sys/dev/vt/vt.h Thu Feb 6 13:28:06 2014 (r261551) +++ head/sys/dev/vt/vt.h Thu Feb 6 15:12:44 2014 (r261552) @@ -287,6 +287,9 @@ typedef void vd_putchar_t(struct vt_devi 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402061512.s16FCihd086890>
