Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Dec 2012 00:55:44 +0000 (UTC)
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r244755 - head/sys/arm/versatile
Message-ID:  <201212280055.qBS0tikE015308@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gonzo
Date: Fri Dec 28 00:55:43 2012
New Revision: 244755
URL: http://svnweb.freebsd.org/changeset/base/244755

Log:
  Add custom renderer for poor man's cursor support for framebuffer console

Modified:
  head/sys/arm/versatile/versatile_clcd.c

Modified: head/sys/arm/versatile/versatile_clcd.c
==============================================================================
--- head/sys/arm/versatile/versatile_clcd.c	Thu Dec 27 22:15:22 2012	(r244754)
+++ head/sys/arm/versatile/versatile_clcd.c	Fri Dec 28 00:55:43 2012	(r244755)
@@ -194,6 +194,12 @@ static struct argb versatilefb_palette[1
 	{0x00, 0xff, 0xff, 0xff}
 };
 
+/* mouse pointer from dev/syscons/scgfbrndr.c */
+static u_char mouse_pointer[16] = {
+        0x00, 0x40, 0x60, 0x70, 0x78, 0x7c, 0x7e, 0x68,
+        0x0c, 0x0c, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00
+};
+
 #define FB_WIDTH		640
 #define FB_HEIGHT		480
 #define FB_DEPTH		16
@@ -450,10 +456,131 @@ static video_switch_t versatilefbvidsw =
 
 VIDEO_DRIVER(versatilefb, versatilefbvidsw, versatilefb_configure);
 
-extern sc_rndr_sw_t txtrndrsw;
-RENDERER(versatilefb, 0, txtrndrsw, gfb_set);
+static vr_init_t clcdr_init;
+static vr_clear_t clcdr_clear;
+static vr_draw_border_t clcdr_draw_border;
+static vr_draw_t clcdr_draw;
+static vr_set_cursor_t clcdr_set_cursor;
+static vr_draw_cursor_t clcdr_draw_cursor;
+static vr_blink_cursor_t clcdr_blink_cursor;
+static vr_set_mouse_t clcdr_set_mouse;
+static vr_draw_mouse_t clcdr_draw_mouse;
+
+/*
+ * We use our own renderer; this is because we must emulate a hardware
+ * cursor.
+ */
+static sc_rndr_sw_t clcdrend = {
+	clcdr_init,
+	clcdr_clear,
+	clcdr_draw_border,
+	clcdr_draw,
+	clcdr_set_cursor,
+	clcdr_draw_cursor,
+	clcdr_blink_cursor,
+	clcdr_set_mouse,
+	clcdr_draw_mouse
+};
+
+RENDERER(versatilefb, 0, clcdrend, gfb_set);
 RENDERER_MODULE(versatilefb, gfb_set);
 
+static void
+clcdr_init(scr_stat* scp)
+{
+}
+
+static void
+clcdr_clear(scr_stat* scp, int c, int attr)
+{
+}
+
+static void
+clcdr_draw_border(scr_stat* scp, int color)
+{
+}
+
+static void
+clcdr_draw(scr_stat* scp, int from, int count, int flip)
+{
+	video_adapter_t* adp = scp->sc->adp;
+	int i, c, a;
+
+	if (!flip) {
+		/* Normal printing */
+		vidd_puts(adp, from, (uint16_t*)sc_vtb_pointer(&scp->vtb, from), count);
+	} else {	
+		/* This is for selections and such: invert the color attribute */
+		for (i = count; i-- > 0; ++from) {
+			c = sc_vtb_getc(&scp->vtb, from);
+			a = sc_vtb_geta(&scp->vtb, from) >> 8;
+			vidd_putc(adp, from, c, (a >> 4) | ((a & 0xf) << 4));
+		}
+	}
+}
+
+static void
+clcdr_set_cursor(scr_stat* scp, int base, int height, int blink)
+{
+}
+
+static void
+clcdr_draw_cursor(scr_stat* scp, int off, int blink, int on, int flip)
+{
+	video_adapter_t* adp = scp->sc->adp;
+	struct video_adapter_softc *sc;
+	int row, col;
+	uint8_t *addr;
+	int i,j;
+
+	sc = (struct video_adapter_softc *)adp;
+
+	if (scp->curs_attr.height <= 0)
+		return;
+
+	if (sc->fb_addr == 0)
+		return;
+
+	if (off >= adp->va_info.vi_width * adp->va_info.vi_height)
+		return;
+
+	/* calculate the coordinates in the video buffer */
+	row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight;
+	col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
+
+	addr = (uint8_t *)sc->fb_addr
+	    + (row + sc->ymargin)*(sc->stride)
+	    + (sc->depth/8) * (col + sc->xmargin);
+
+	/* our cursor consists of simply inverting the char under it */
+	for (i = 0; i < adp->va_info.vi_cheight; i++) {
+		for (j = 0; j < adp->va_info.vi_cwidth; j++) {
+
+			addr[2*j] ^= 0xff;
+			addr[2*j + 1] ^= 0xff;
+		}
+
+		addr += sc->stride;
+	}
+}
+
+static void
+clcdr_blink_cursor(scr_stat* scp, int at, int flip)
+{
+}
+
+static void
+clcdr_set_mouse(scr_stat* scp)
+{
+}
+
+static void
+clcdr_draw_mouse(scr_stat* scp, int x, int y, int on)
+{
+	vidd_putm(scp->sc->adp, x, y, mouse_pointer, 0xffffffff, 16, 8);
+
+}
+
 static uint16_t versatilefb_static_window[ROW*COL];
 extern u_char dflt_font_16[];
 
@@ -629,6 +756,7 @@ versatilefb_read_hw_cursor(video_adapter
 static int
 versatilefb_set_hw_cursor(video_adapter_t *adp, int col, int row)
 {
+
 	return (0);
 }
 
@@ -753,6 +881,9 @@ versatilefb_putc(video_adapter_t *adp, v
 	if (sc->fb_addr == 0)
 		return (0);
 
+	if (off >= adp->va_info.vi_width * adp->va_info.vi_height)
+		return (0);
+
 	row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight;
 	col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
 	p = sc->font + c*VERSATILE_FONT_HEIGHT;



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