From owner-p4-projects@FreeBSD.ORG Fri May 13 21:52:14 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E619816A4D1; Fri, 13 May 2005 21:52:13 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C25D416A4CE for ; Fri, 13 May 2005 21:52:13 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A125A43D75 for ; Fri, 13 May 2005 21:52:13 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j4DLqDNW019004 for ; Fri, 13 May 2005 21:52:13 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j4DLqDx9019001 for perforce@freebsd.org; Fri, 13 May 2005 21:52:13 GMT (envelope-from marcel@freebsd.org) Date: Fri, 13 May 2005 21:52:13 GMT Message-Id: <200505132152.j4DLqDx9019001@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 76946 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 May 2005 21:52:14 -0000 http://perforce.freebsd.org/chv.cgi?CH=76946 Change 76946 by marcel@marcel_nfs on 2005/05/13 21:51:51 Implement BitBlt operations CTOFB, FBTOFB and H1TOFB. Both CTOFB and FBTOFB use write mode 0. H1TOFB uses write mode 3. The implementation is not feature complete. It is assumed for now that the width is always a multiple of 8 bits and that the bit offset is also a multiple of 8. Some VGA magic with masks and rotate registers is needed to handle all possible cases. As long as we're using fonts of width 8, this is not an issue so we're good for now. Affected files ... .. //depot/projects/tty/sys/dev/vga/vga.c#11 edit Differences ... ==== //depot/projects/tty/sys/dev/vga/vga.c#11 (text+ko) ==== @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -186,7 +187,7 @@ REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_SET_RESET); REG_WRITE(sc, VGA_GC_DATA, 0); REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_ENABLE_SET_RESET); - REG_WRITE(sc, VGA_GC_DATA, 0); + REG_WRITE(sc, VGA_GC_DATA, 0x0f); REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_COLOR_COMPARE); REG_WRITE(sc, VGA_GC_DATA, 0); REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_DATA_ROTATE); @@ -267,12 +268,133 @@ return (0); } +static __inline int +vga_bitblt_ctofb(struct vga_softc *sc, u_long c, u_long dst, int width, + int height) +{ + int w; + + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_MODE); + REG_WRITE(sc, VGA_GC_DATA, 0); + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_ENABLE_SET_RESET); + REG_WRITE(sc, VGA_GC_DATA, 0x0f); + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_SET_RESET); + REG_WRITE(sc, VGA_GC_DATA, c & 0x0f); + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_DATA_ROTATE); + REG_WRITE(sc, VGA_GC_DATA, 0); + dst >>= 3; + while (height > 0) { + for (w = 0; w < width; w += 8) { + MEM_READ(sc, dst); + MEM_WRITE(sc, dst++, 0); + } + dst += (640 - w) >> 3; + height--; + } + return (0); +} + +static __inline int +vga_bitblt_fbtofb(struct vga_softc *sc, u_long src, u_long dst, int width, + int height) +{ + int w; + + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_MODE); + REG_WRITE(sc, VGA_GC_DATA, 0); + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_ENABLE_SET_RESET); + REG_WRITE(sc, VGA_GC_DATA, 0x0f); + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_SET_RESET); + REG_WRITE(sc, VGA_GC_DATA, 0); + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_DATA_ROTATE); + REG_WRITE(sc, VGA_GC_DATA, VGA_GC_DR_FS_OR); + dst >>= 3; + src >>= 3; + while (height > 0) { + for (w = 0; w < width; w += 8) { + MEM_READ(sc, src++); + MEM_WRITE(sc, dst++, 0); + } + src += (640 - w) >> 3; + dst += (640 - w) >> 3; + height--; + } + return (0); +} + +static __inline int +vga_bitblt_h1tofb(struct vga_softc *sc, uint8_t *src, u_long dst, int width, + int height, int bgclr, int fgclr) +{ + int c, w; + uint8_t b; + + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_MODE); + REG_WRITE(sc, VGA_GC_DATA, 3); + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_ENABLE_SET_RESET); + REG_WRITE(sc, VGA_GC_DATA, 0x0f); + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_SET_RESET); + REG_WRITE(sc, VGA_GC_DATA, fgclr); + REG_WRITE(sc, VGA_GC_ADDRESS, VGA_GC_DATA_ROTATE); + REG_WRITE(sc, VGA_GC_DATA, 0); + c = fgclr; + dst >>= 3; + while (height > 0) { + for (w = 0; w < width; w += 8) { + b = *src++; + if (b != 0) { + if (c != fgclr) { + REG_WRITE(sc, VGA_GC_ADDRESS, + VGA_GC_SET_RESET); + REG_WRITE(sc, VGA_GC_DATA, fgclr); + c = fgclr; + } + MEM_READ(sc, dst); + MEM_WRITE(sc, dst, b); + } + if (b != 0xff) { + if (c != bgclr) { + REG_WRITE(sc, VGA_GC_ADDRESS, + VGA_GC_SET_RESET); + REG_WRITE(sc, VGA_GC_DATA, bgclr); + c = bgclr; + } + MEM_READ(sc, dst); + MEM_WRITE(sc, dst, ~b); + } + dst++; + } + dst += (640 - w) >> 3; + height--; + } + return (0); +} + int -vga_vbitblt(struct vga_softc *sc, int op, uintptr_t dst, uintptr_t src, +vga_vbitblt(struct vga_softc *sc, int op, uintptr_t src, uintptr_t dst, int width, int height, va_list ap) { + int bgclr, fgclr; + int error; - return (0); + switch (op) { + case BITBLT_FBTOFB: + error = vga_bitblt_fbtofb(sc, src, dst, width, height); + break; + case BITBLT_H1TOFB: + bgclr = va_arg(ap, int); + fgclr = va_arg(ap, int); + error = vga_bitblt_h1tofb(sc, (uint8_t *)src, dst, width, + height, bgclr, fgclr); + break; + case BITBLT_CTOFB: + error = vga_bitblt_ctofb(sc, src, dst, width, height); + break; + default: + error = EINVAL; + break; + } + return (error); } int