Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 May 2005 04:38:40 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 76865 for review
Message-ID:  <200505120438.j4C4cepI030810@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=76865

Change 76865 by marcel@marcel_nfs on 2005/05/12 04:38:08

	Flesh out what's needed for low-level console output. This basically
	boils down to finding the right definition of the BitBlt operation.
	Ideally you want the hardware driver to take advantage of any hardware
	acceleration if possible.
	
	In short:
	o  Printing a character is a bitblt operation from host memory to the
	   frame buffer,
	o  Scrolling the screen is a bitblt operation from the frame buffer to
	   the frame buffer,
	o  Clearing a portion of the screen is a (pseudo) bitblt operation
	   where the source is a pixel color and the destination is the frame
	   buffer.
	
	Host originated bitmaps come in multiple variants of differing depths.
	Fonts typically are monochrome, so we need to have the ability to pass
	a background and foreground color to the bitblt function. Use stdarg
	to cover these variations.

Affected files ...

.. //depot/projects/tty/sys/dev/vga/vga.c#10 edit
.. //depot/projects/tty/sys/dev/vga/vga.h#6 edit
.. //depot/projects/tty/sys/dev/vga/vga_con.c#3 edit
.. //depot/projects/tty/sys/dev/vtc/vtc_con.c#3 edit
.. //depot/projects/tty/sys/dev/vtc/vtc_con.h#2 edit
.. //depot/projects/tty/sys/sys/vtc.h#1 add

Differences ...

==== //depot/projects/tty/sys/dev/vga/vga.c#10 (text+ko) ====

@@ -268,7 +268,8 @@
 }
 
 int
-vga_bitblt(struct vga_softc *sc, int x, int y)
+vga_vbitblt(struct vga_softc *sc, int op, uintptr_t dst, uintptr_t src,
+    int width, int height, va_list ap)
 {
 
 	return (0);

==== //depot/projects/tty/sys/dev/vga/vga.h#6 (text+ko) ====

@@ -29,6 +29,8 @@
 #ifndef _DEV_VGA_VGA_H_
 #define	_DEV_VGA_VGA_H_
 
+#include <machine/stdarg.h>
+
 struct vga_spc
 {
 	bus_space_tag_t		bst;
@@ -68,8 +70,9 @@
 extern char vga_device_name[];
 
 int vga_attach(device_t);
-int vga_bitblt(struct vga_softc *, int, int);
+int vga_vbitblt(struct vga_softc *, int, uintptr_t, uintptr_t, int, int,
+    va_list);
 int vga_init(struct vga_softc *);
 int vga_probe(struct vga_softc *);
 
-#endif /* _DEV_VGA_VGA_H_ */
+#endif /* !_DEV_VGA_VGA_H_ */

==== //depot/projects/tty/sys/dev/vga/vga_con.c#3 (text+ko) ====

@@ -46,7 +46,7 @@
 VTC_CONOUT(vga, vga_con_probe, vga_con_init, vga_con_bitblt);
 
 static int
-vga_con_probe()
+vga_con_probe(struct vtc_conout *co)
 {
 	struct vga_consdata cd;
 
@@ -61,20 +61,30 @@
 	if (!vga_probe(&vga_console))
 		return (-1);
 
+	co->vtc_con_cookie = &vga_console;
+	co->vtc_con_width = 640;
+	co->vtc_con_height = 480;
+	co->vtc_con_depth = 16;
 	return (0);
 }
 
 static void
-vga_con_init()
+vga_con_init(struct vtc_conout *co)
 {
+	struct vga_softc *sc = co->vtc_con_cookie;
 
-	if (vga_init(&vga_console) == 0)
-		vga_console.vga_console = 1;
+	if (vga_init(sc) == 0)
+		sc->vga_console = 1;
 }
 
 static void
-vga_con_bitblt(int x, int y)
+vga_con_bitblt(struct vtc_conout *co, int op, uintptr_t dst, uintptr_t src,
+    int width, int height, ...)
 {
+	struct vga_softc *sc = co->vtc_con_cookie;
+	va_list ap;
 
-	vga_bitblt(&vga_console, x, y);
+	va_start(ap, height);
+	vga_vbitblt(sc, op, dst, src, width, height, ap);
+	va_end(ap);
 }

==== //depot/projects/tty/sys/dev/vtc/vtc_con.c#3 (text+ko) ====

@@ -35,6 +35,7 @@
 #include <sys/cons.h>
 #include <sys/rman.h>
 #include <sys/tty.h>
+#include <sys/vtc.h>
 
 #include <dev/vtc/vtc_con.h>
 
@@ -62,7 +63,7 @@
 	cur_vc = NULL;
 	SET_FOREACH(iter, vtc_conout_set) {
 		vc = *iter;
-		pri = (vc->vtc_con_probe != NULL) ? vc->vtc_con_probe() : -1;
+		pri = (vc->vtc_con_probe != NULL) ? vc->vtc_con_probe(vc) : -1;
 		if (pri > cur_pri) {
 			cur_pri = pri;
 			cur_vc = vc;
@@ -78,7 +79,7 @@
 {
 	struct vtc_conout *vc = cp->cn_arg;
 
-	vc->vtc_con_init();
+	vc->vtc_con_init(vc);
 }
 
 static void
@@ -89,9 +90,34 @@
 static void
 vtc_cnputc(struct consdev *cp, int c)
 {
+	static int col = 0, row = 0;
+	static uint8_t bitmap[] = { 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, 0x10,
+				    0x10, 0x28, 0x28, 0x44, 0x44, 0x82, 0x82,
+				    0x00, 0x00, 0x00, 0x00, 0x00 };
 	struct vtc_conout *vc = cp->cn_arg;
 
-	vc->vtc_con_bitblt(0, 0);
+	switch (c) {
+	case 0x0a:
+		col = 0;
+		row++;
+		break;
+	default:
+		vc->vtc_con_bitblt(vc, BITBLT_H1TOFB, (uintptr_t)bitmap,
+		    vc->vtc_con_width * row * 10 + col * 8, 8, 19, 0, 7);
+		col++;
+		break;
+	}
+	if (col >= 80) {
+		col = 0;
+		row++;
+	}
+	if (row >= 24) {
+		vc->vtc_con_bitblt(vc, BITBLT_FBTOFB, vc->vtc_con_width * 19,
+		    0, vc->vtc_con_width, 23 * 19);
+		vc->vtc_con_bitblt(vc, BITBLT_CLRTOFB, 0, 23 * 19,
+		    vc->vtc_con_width, 19);
+		row = 0;
+	}
 }
 
 static int

==== //depot/projects/tty/sys/dev/vtc/vtc_con.h#2 (text+ko) ====

@@ -29,15 +29,22 @@
 #ifndef _DEV_VTC_CON_H_
 #define	_DEV_VTC_CON_H_
 
-typedef void vtc_con_bitblt_f(int, int);
-typedef void vtc_con_init_f(void);
-typedef int  vtc_con_probe_f(void);
+struct vtc_conout;
+
+typedef void vtc_con_bitblt_f(struct vtc_conout *, int, uintptr_t, uintptr_t,
+    int, int, ...);
+typedef void vtc_con_init_f(struct vtc_conout *);
+typedef int  vtc_con_probe_f(struct vtc_conout *);
 
 struct vtc_conout {
 	const char	*vtc_con_name;
 	vtc_con_probe_f	*vtc_con_probe;
 	vtc_con_init_f	*vtc_con_init;
 	vtc_con_bitblt_f *vtc_con_bitblt;
+	void *		vtc_con_cookie;
+	int		vtc_con_width;
+	int		vtc_con_height;
+	int		vtc_con_depth;
 };
 
 #define	VTC_CONOUT(name, probe, init, bitblt)			\
@@ -45,7 +52,11 @@
 		.vtc_con_name = #name,				\
 		.vtc_con_probe = probe,				\
 		.vtc_con_init = init,				\
-		.vtc_con_bitblt = bitblt			\
+		.vtc_con_bitblt = bitblt,			\
+		.vtc_con_cookie = NULL,				\
+		.vtc_con_width = -1,				\
+		.vtc_con_height = -1,				\
+		.vtc_con_depth = -1				\
 	};							\
 	DATA_SET(vtc_conout_set, name##_vtc_conout)
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505120438.j4C4cepI030810>