summaryrefslogtreecommitdiffstats
path: root/sys/arm
diff options
context:
space:
mode:
authorgonzo <gonzo@FreeBSD.org>2012-12-28 00:55:43 +0000
committergonzo <gonzo@FreeBSD.org>2012-12-28 00:55:43 +0000
commit6274b9f3de955fc75411db065ca9baacae0b0f1a (patch)
tree5b1f6c7946c683e764981df082e5836b4510a4e3 /sys/arm
parentf89408c03ebecabf267926dd2304436d3129e45c (diff)
downloadFreeBSD-src-6274b9f3de955fc75411db065ca9baacae0b0f1a.zip
FreeBSD-src-6274b9f3de955fc75411db065ca9baacae0b0f1a.tar.gz
Add custom renderer for poor man's cursor support for framebuffer console
Diffstat (limited to 'sys/arm')
-rw-r--r--sys/arm/versatile/versatile_clcd.c135
1 files changed, 133 insertions, 2 deletions
diff --git a/sys/arm/versatile/versatile_clcd.c b/sys/arm/versatile/versatile_clcd.c
index 9b1ceff..53226ff 100644
--- a/sys/arm/versatile/versatile_clcd.c
+++ b/sys/arm/versatile/versatile_clcd.c
@@ -194,6 +194,12 @@ static struct argb versatilefb_palette[16] = {
{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_t *adp, int *col, int *row)
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, vm_offset_t off, uint8_t c, uint8_t a)
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;
OpenPOWER on IntegriCloud