diff options
author | Christopher Pascoe <pascoe@cvs.openbsd.org> | 2005-04-30 23:13:48 +0000 |
---|---|---|
committer | Christopher Pascoe <pascoe@cvs.openbsd.org> | 2005-04-30 23:13:48 +0000 |
commit | 9479c2e19a026a1ee0fbc8ee0500110d30d22f00 (patch) | |
tree | 4d7349d8665c9c961bab2fde87bce6754bf79d91 /sys | |
parent | cf695b9e1ee8636d79af8e0aefc96286e2ebaffe (diff) |
Temporary hack to (un)rotate the Zaurus console until a proper rasops
rotation framework is ready.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/arm/xscale/pxa2x0_lcd.c | 7 | ||||
-rw-r--r-- | sys/dev/rasops/rasops.c | 146 | ||||
-rw-r--r-- | sys/dev/rasops/rasops.h | 7 | ||||
-rw-r--r-- | sys/dev/wsfont/wsfont.c | 72 |
4 files changed, 228 insertions, 4 deletions
diff --git a/sys/arch/arm/xscale/pxa2x0_lcd.c b/sys/arch/arm/xscale/pxa2x0_lcd.c index c32df339e3e..dc70d78c0a8 100644 --- a/sys/arch/arm/xscale/pxa2x0_lcd.c +++ b/sys/arch/arm/xscale/pxa2x0_lcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pxa2x0_lcd.c,v 1.17 2005/04/11 03:32:48 uwe Exp $ */ +/* $OpenBSD: pxa2x0_lcd.c,v 1.18 2005/04/30 23:13:47 pascoe Exp $ */ /* $NetBSD: pxa2x0_lcd.c,v 1.8 2003/10/03 07:24:05 bsh Exp $ */ /* @@ -591,7 +591,12 @@ pxa2x0_lcd_setup_rasops(struct rasops_info *rinfo, descr->c.capabilities = rinfo->ri_caps; descr->c.textops = &rinfo->ri_ops; } else +#ifndef __zaurus__ rasops_init(rinfo, descr->c.nrows, descr->c.ncols); +#else + /* XXX swap rows/cols for second call because of rotation */ + rasops_init(rinfo, descr->c.ncols, descr->c.nrows); +#endif } /* diff --git a/sys/dev/rasops/rasops.c b/sys/dev/rasops/rasops.c index 13d615a504a..d77fd63c5c3 100644 --- a/sys/dev/rasops/rasops.c +++ b/sys/dev/rasops/rasops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rasops.c,v 1.9 2003/12/17 11:21:08 miod Exp $ */ +/* $OpenBSD: rasops.c,v 1.10 2005/04/30 23:13:47 pascoe Exp $ */ /* $NetBSD: rasops.c,v 1.35 2001/02/02 06:01:01 marcus Exp $ */ /*- @@ -147,6 +147,55 @@ int rasops_alloc_cattr(void *, int, int, int, long *); int rasops_alloc_mattr(void *, int, int, int, long *); void rasops_do_cursor(struct rasops_info *); void rasops_init_devcmap(struct rasops_info *); +#ifdef __zaurus__ +void rasops_copychar(void *, int, int, int, int); +void rasops_putchar_rotated(void *, int, int, u_int, long); + +void +rasops_copychar(cookie, srcrow, dstrow, srccol, dstcol) + void *cookie; + int srcrow, dstrow, srccol, dstcol; +{ + struct rasops_info *ri; + u_char *sp, *dp; + int height; + int r_srcrow, r_dstrow, r_srccol, r_dstcol; + + ri = (struct rasops_info *)cookie; + + r_srcrow = srccol; + r_dstrow = dstcol; + r_srccol = ri->ri_rows - srcrow - 1; + r_dstcol = ri->ri_rows - dstrow - 1; + + r_srcrow *= ri->ri_yscale; + r_dstrow *= ri->ri_yscale; + height = ri->ri_font->fontheight; + + sp = ri->ri_bits + r_srcrow + r_srccol * ri->ri_xscale; + dp = ri->ri_bits + r_dstrow + r_dstcol * ri->ri_xscale; + + while (height--) { + ovbcopy(sp, dp, ri->ri_xscale); + dp += ri->ri_stride; + sp += ri->ri_stride; + } +} + +void +rasops_putchar_rotated(cookie, row, col, uc, attr) + void *cookie; + int row, col; + u_int uc; + long attr; +{ + struct rasops_info *ri; + + ri = (struct rasops_info *)cookie; + + ri->ri_real_ops.putchar(cookie, col, ri->ri_rows - row - 1, uc, attr); +} +#endif /* * Initialize a 'rasops_info' descriptor. @@ -166,10 +215,18 @@ rasops_init(ri, wantrows, wantcols) if (ri->ri_width > 80*12) /* High res screen, choose a big font */ +#ifndef __zaurus__ cookie = wsfont_find(NULL, 12, 0, 0); +#else + cookie = wsfont_find(NULL, 0, 12, 0); +#endif else /* lower res, choose a 8 pixel wide font */ +#ifndef __zaurus__ cookie = wsfont_find(NULL, 8, 0, 0); +#else + cookie = wsfont_find(NULL, 0, 8, 0); +#endif if (cookie <= 0) cookie = wsfont_find(NULL, 0, 0, 0); @@ -251,8 +308,13 @@ rasops_reconfig(ri, wantrows, wantcols) while ((ri->ri_emuwidth * bpp & 31) != 0) ri->ri_emuwidth--; +#ifndef __zaurus__ ri->ri_cols = ri->ri_emuwidth / ri->ri_font->fontwidth; ri->ri_rows = ri->ri_emuheight / ri->ri_font->fontheight; +#else + ri->ri_rows = ri->ri_emuwidth / ri->ri_font->fontwidth; + ri->ri_cols = ri->ri_emuheight / ri->ri_font->fontheight; +#endif ri->ri_emustride = ri->ri_emuwidth * bpp >> 3; ri->ri_delta = ri->ri_stride - ri->ri_emustride; ri->ri_ccol = 0; @@ -352,6 +414,11 @@ rasops_reconfig(ri, wantrows, wantcols) return (-1); } +#ifdef __zaurus__ + ri->ri_real_ops = ri->ri_ops; + ri->ri_ops.putchar = rasops_putchar_rotated; +#endif + ri->ri_flg |= RI_CFGDONE; splx(s); return (0); @@ -470,6 +537,7 @@ rasops_alloc_mattr(cookie, fg, bg, flg, attr) return (0); } +#ifndef __zaurus__ /* * Copy rows. */ @@ -606,6 +674,41 @@ rasops_copycols(cookie, row, src, dst, num) sp += ri->ri_stride; } } +#else +/* XXX: these could likely be optimised somewhat. */ +void +rasops_copyrows(cookie, src, dst, num) + void *cookie; + int src, dst, num; +{ + struct rasops_info *ri = (struct rasops_info *)cookie; + int col, roff; + + if (src > dst) + for (roff = 0; roff < num; roff++) + for (col = 0; col < ri->ri_cols; col++) + rasops_copychar(cookie, src + roff, dst + roff, col, col); + else + for (roff = num - 1; roff >= 0; roff--) + for (col = 0; col < ri->ri_cols; col++) + rasops_copychar(cookie, src + roff, dst + roff, col, col); +} + +void +rasops_copycols(cookie, row, src, dst, num) + void *cookie; + int row, src, dst, num; +{ + int coff; + + if (src > dst) + for (coff = 0; coff < num; coff++) + rasops_copychar(cookie, row, row, src + coff, dst + coff); + else + for (coff = num - 1; coff >= 0; coff--) + rasops_copychar(cookie, row, row, src + coff, dst + coff); +} +#endif /* * Turn cursor off/on. @@ -740,6 +843,7 @@ rasops_unpack_attr(attr, fg, bg, underline) /* * Erase rows */ +#ifndef __zaurus__ void rasops_eraserows(cookie, row, num, attr) void *cookie; @@ -808,6 +912,23 @@ rasops_eraserows(cookie, row, num, attr) DELTA(dp, delta, int32_t *); } } +#else +void +rasops_eraserows(cookie, row, num, attr) + void *cookie; + int row, num; + long attr; +{ + struct rasops_info *ri; + int col, rn; + + ri = (struct rasops_info *)cookie; + + for (rn = row; rn < row + num; rn++) + for (col = 0; col < ri->ri_cols; col++) + ri->ri_ops.putchar(cookie, rn, col, ' ', attr); +} +#endif /* * Actually turn the cursor on or off. This does the dirty work for @@ -820,8 +941,14 @@ rasops_do_cursor(ri) int full1, height, cnt, slop1, slop2, row, col; u_char *dp, *rp; +#ifndef __zaurus__ row = ri->ri_crow; col = ri->ri_ccol; +#else + /* Rotate rows/columns */ + row = ri->ri_ccol; + col = ri->ri_rows - ri->ri_crow - 1; +#endif rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale; height = ri->ri_font->fontheight; @@ -875,6 +1002,7 @@ rasops_do_cursor(ri) /* * Erase columns. */ +#ifndef __zaurus__ void rasops_erasecols(cookie, row, col, num, attr) void *cookie; @@ -1000,3 +1128,19 @@ rasops_erasecols(cookie, row, col, num, attr) *(int16_t *)dp = clr; } } +#else +void +rasops_erasecols(cookie, row, col, num, attr) + void *cookie; + int row, col, num; + long attr; +{ + struct rasops_info *ri; + int i; + + ri = (struct rasops_info *)cookie; + + for (i = col; i < col + num; i++) + ri->ri_ops.putchar(cookie, row, i, ' ', attr); +} +#endif diff --git a/sys/dev/rasops/rasops.h b/sys/dev/rasops/rasops.h index 825d65bd4e0..33fb89d5b0c 100644 --- a/sys/dev/rasops/rasops.h +++ b/sys/dev/rasops/rasops.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rasops.h,v 1.5 2002/08/12 02:31:01 jason Exp $ */ +/* $OpenBSD: rasops.h,v 1.6 2005/04/30 23:13:47 pascoe Exp $ */ /* $NetBSD: rasops.h,v 1.13 2000/06/13 13:36:54 ad Exp $ */ /*- @@ -110,6 +110,11 @@ struct rasops_info { /* Callbacks so we can share some code */ void (*ri_do_cursor)(struct rasops_info *); void (*ri_updatecursor)(struct rasops_info *); + +#ifdef __zaurus__ + /* Used to intercept putchar to permit display rotation */ + struct wsdisplay_emulops ri_real_ops; +#endif }; #define DELTA(p, d, cast) ((p) = (cast)((caddr_t)(p) + (d))) diff --git a/sys/dev/wsfont/wsfont.c b/sys/dev/wsfont/wsfont.c index 97c471bdab3..db69365f0cb 100644 --- a/sys/dev/wsfont/wsfont.c +++ b/sys/dev/wsfont/wsfont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsfont.c,v 1.11 2005/04/15 02:19:24 pascoe Exp $ */ +/* $OpenBSD: wsfont.c,v 1.12 2005/04/30 23:13:47 pascoe Exp $ */ /* $NetBSD: wsfont.c,v 1.17 2001/02/07 13:59:24 ad Exp $ */ /*- @@ -126,6 +126,9 @@ #include <dev/wsfont/gallant12x22.h> #endif +#ifdef __zaurus__ +void wsfont_rotate(struct wsdisplay_font *, int); +#endif /* Placeholder struct used for linked list */ struct font { @@ -283,6 +286,64 @@ wsfont_enum(cb) splx(s); } +#ifdef __zaurus__ +void wsfont_rotate(struct wsdisplay_font *font, int static_orig) +{ + int b, n, r, newstride; + char *newfont; + + /* Allocate a buffer big enough for the rotated font. */ + newstride = (font->fontheight + 7) / 8; + newfont = malloc(newstride * font->fontwidth * font->numchars, + M_DEVBUF, M_WAITOK); + if (newfont == NULL) + return; + bzero(newfont, newstride * font->fontwidth * font->numchars); + + /* Rotate the font a bit at a time. */ + for (n = 0; n < font->numchars; n++) { + char *ch = font->data + (n * font->stride * font->fontheight); + + for (r = 0; r < font->fontheight; r++) { + for (b = 0; b < font->fontwidth; b++) { + unsigned char *rb; + + rb = ch + (font->stride * r) + (b / 8); + if (*rb & (0x80 >> (b % 8))) { + unsigned char *rrb; + + rrb = newfont + newstride - 1 - (r / 8) + + (n * newstride * font->fontwidth) + + (newstride * b); + *rrb |= (1 << (r % 8)); + } + } + } + } + + /* + * If the rotated font will fit into the memory the font originally + * used, copy it into there, otherwise use our new buffer. + */ + if ((newstride * font->fontwidth * font->numchars) <= + (font->stride * font->fontheight * font->numchars)) { + memcpy(font->data, newfont, newstride * + font->fontwidth * font->numchars); + free(newfont, M_DEVBUF); + } else { + if (!static_orig) + free(font->data, M_DEVBUF); + font->data = newfont; + } + + /* Update font sizes. */ + font->stride = newstride; + newstride = font->fontwidth; /* temp */ + font->fontwidth = font->fontheight; + font->fontheight = newstride; +} +#endif + /* * Initialize list with WSFONT_BUILTIN fonts */ @@ -296,6 +357,11 @@ wsfont_init(void) return; again = 1; +#ifdef __zaurus__ + for (i = 0; builtin_fonts[i].font != NULL; i++) + wsfont_rotate(builtin_fonts[i].font, 1); +#endif + for (i = 0; builtin_fonts[i].font != NULL; i++) { builtin_fonts[i].next = list; list = &builtin_fonts[i]; @@ -396,6 +462,10 @@ wsfont_add(font, copy) memcpy(ent->font->data, font->data, size); ent->flg = 0; } + +#ifdef __zaurus__ + wsfont_rotate(ent->font, 0); +#endif /* Now link into the list and return */ list = ent; |