vt_fb.c (260953) | vt_fb.c (261552) |
---|---|
1/*- 2 * Copyright (c) 2013 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Aleksandr Rybalko under sponsorship from the 6 * FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2013 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Aleksandr Rybalko under sponsorship from the 6 * FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/dev/vt/hw/fb/vt_fb.c 260953 2014-01-20 23:36:16Z ray $ | 29 * $FreeBSD: head/sys/dev/vt/hw/fb/vt_fb.c 261552 2014-02-06 15:12:44Z ray $ |
30 */ 31 32#include <sys/cdefs.h> | 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/vt/hw/fb/vt_fb.c 260953 2014-01-20 23:36:16Z ray $"); | 33__FBSDID("$FreeBSD: head/sys/dev/vt/hw/fb/vt_fb.c 261552 2014-02-06 15:12:44Z ray $"); |
34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/malloc.h> 38#include <sys/queue.h> 39#include <sys/fbio.h> 40#include <dev/vt/vt.h> 41#include <dev/vt/hw/fb/vt_fb.h> 42#include <dev/vt/colors/vt_termcolors.h> 43 44static int vt_fb_ioctl(struct vt_device *vd, u_long cmd, caddr_t data, 45 struct thread *td); 46static int vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, 47 vm_paddr_t *paddr, int prot, vm_memattr_t *memattr); | 34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/malloc.h> 38#include <sys/queue.h> 39#include <sys/fbio.h> 40#include <dev/vt/vt.h> 41#include <dev/vt/hw/fb/vt_fb.h> 42#include <dev/vt/colors/vt_termcolors.h> 43 44static int vt_fb_ioctl(struct vt_device *vd, u_long cmd, caddr_t data, 45 struct thread *td); 46static int vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, 47 vm_paddr_t *paddr, int prot, vm_memattr_t *memattr); |
48void vt_fb_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2, 49 int fill, term_color_t color); 50void vt_fb_setpixel(struct vt_device *vd, int x, int y, term_color_t color); |
|
48 49static struct vt_driver vt_fb_driver = { 50 .vd_init = vt_fb_init, 51 .vd_blank = vt_fb_blank, 52 .vd_bitbltchr = vt_fb_bitbltchr, | 51 52static struct vt_driver vt_fb_driver = { 53 .vd_init = vt_fb_init, 54 .vd_blank = vt_fb_blank, 55 .vd_bitbltchr = vt_fb_bitbltchr, |
56 .vd_drawrect = vt_fb_drawrect, 57 .vd_setpixel = vt_fb_setpixel, |
|
53 .vd_postswitch = vt_fb_postswitch, 54 .vd_priority = VD_PRIORITY_GENERIC+10, 55 .vd_fb_ioctl = vt_fb_ioctl, 56 .vd_fb_mmap = vt_fb_mmap, 57}; 58 59static int 60vt_fb_ioctl(struct vt_device *vd, u_long cmd, caddr_t data, struct thread *td) --- 18 unchanged lines hidden (view full) --- 79 80 if (info->fb_ioctl == NULL) 81 return (ENXIO); 82 83 return (info->fb_mmap(info->fb_cdev, offset, paddr, prot, memattr)); 84} 85 86void | 58 .vd_postswitch = vt_fb_postswitch, 59 .vd_priority = VD_PRIORITY_GENERIC+10, 60 .vd_fb_ioctl = vt_fb_ioctl, 61 .vd_fb_mmap = vt_fb_mmap, 62}; 63 64static int 65vt_fb_ioctl(struct vt_device *vd, u_long cmd, caddr_t data, struct thread *td) --- 18 unchanged lines hidden (view full) --- 84 85 if (info->fb_ioctl == NULL) 86 return (ENXIO); 87 88 return (info->fb_mmap(info->fb_cdev, offset, paddr, prot, memattr)); 89} 90 91void |
92vt_fb_setpixel(struct vt_device *vd, int x, int y, term_color_t color) 93{ 94 struct fb_info *info; 95 uint32_t c; 96 u_int o; 97 98 info = vd->vd_softc; 99 c = info->fb_cmap[color]; 100 o = info->fb_stride * y + x * FBTYPE_GET_BYTESPP(info); 101 102 switch (FBTYPE_GET_BYTESPP(info)) { 103 case 1: 104 info->wr1(info, o, c); 105 break; 106 case 2: 107 info->wr2(info, o, c); 108 break; 109 case 3: 110 info->wr1(info, o, (c >> 16) & 0xff); 111 info->wr1(info, o + 1, (c >> 8) & 0xff); 112 info->wr1(info, o + 2, c & 0xff); 113 break; 114 case 4: 115 info->wr4(info, o, c); 116 break; 117 default: 118 /* panic? */ 119 return; 120 } 121 122} 123 124void 125vt_fb_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2, int fill, 126 term_color_t color) 127{ 128 int x, y; 129 130 for (y = y1; y <= y2; y++) { 131 if (fill || (y == y1) || (y == y2)) { 132 for (x = x1; x <= x2; x++) 133 vt_fb_setpixel(vd, x, y, color); 134 } else { 135 vt_fb_setpixel(vd, x1, y, color); 136 vt_fb_setpixel(vd, x2, y, color); 137 } 138 } 139} 140 141void |
|
87vt_fb_blank(struct vt_device *vd, term_color_t color) 88{ 89 struct fb_info *info; 90 uint32_t c; 91 u_int o; 92 93 info = vd->vd_softc; 94 c = info->fb_cmap[color]; --- 186 unchanged lines hidden --- | 142vt_fb_blank(struct vt_device *vd, term_color_t color) 143{ 144 struct fb_info *info; 145 uint32_t c; 146 u_int o; 147 148 info = vd->vd_softc; 149 c = info->fb_cmap[color]; --- 186 unchanged lines hidden --- |