diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2005-09-15 20:23:11 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2005-09-15 20:23:11 +0000 |
commit | 6759b09d281d276d3b3d54ffbef1c9980df9d67f (patch) | |
tree | 4a4c5917557819414a798bb184a102c0bf525cef | |
parent | 64393cf110217509a46347626cda13bdde46cf22 (diff) |
Stop compiling the texte console rotation code #ifdef __zaurus__, but use
a flag in the rasops_info structure; drivers which may use it shall declare
a specific attribute for the config(8) machinery, so that the necessary code
is compiled in.
In addition to this, rotated font computation is now done on-demand, and a
list of unrotated-rotated font cookie pairs is kept, rather than rotating all
built-in wsfonts at initialization time.
No user-perceptible functional change.
Tested matthieu@ uwe@, ok uwe@
-rw-r--r-- | share/man/man9/rasops.9 | 42 | ||||
-rw-r--r-- | sys/arch/arm/xscale/files.pxa2x0 | 4 | ||||
-rw-r--r-- | sys/arch/arm/xscale/pxa2x0_lcd.c | 4 | ||||
-rw-r--r-- | sys/arch/arm/xscale/pxa2x0_lcd.h | 3 | ||||
-rw-r--r-- | sys/arch/zaurus/zaurus/zaurus_lcd.c | 7 | ||||
-rw-r--r-- | sys/conf/files | 3 | ||||
-rw-r--r-- | sys/dev/rasops/files.rasops | 7 | ||||
-rw-r--r-- | sys/dev/rasops/rasops.c | 381 | ||||
-rw-r--r-- | sys/dev/rasops/rasops.h | 25 | ||||
-rw-r--r-- | sys/dev/wsfont/files.wsfont | 10 | ||||
-rw-r--r-- | sys/dev/wsfont/wsfont.c | 112 | ||||
-rw-r--r-- | sys/dev/wsfont/wsfont.h | 3 |
12 files changed, 368 insertions, 233 deletions
diff --git a/share/man/man9/rasops.9 b/share/man/man9/rasops.9 index 5546a788913..76ea536f429 100644 --- a/share/man/man9/rasops.9 +++ b/share/man/man9/rasops.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rasops.9,v 1.4 2003/04/20 20:04:17 jmc Exp $ +.\" $OpenBSD: rasops.9,v 1.5 2005/09/15 20:23:08 miod Exp $ .\" $NetBSD: rasops.9,v 1.4 2002/02/13 08:18:50 ross Exp $ .\" .\" Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 7, 2001 +.Dd September 9, 2005 .Dt RASOPS 9 .Os .Sh NAME @@ -124,28 +124,41 @@ struct rasops_info { */ void (*ri_do_cursor)(struct rasops_info *); void (*ri_updatecursor)(struct rasops_info *); + +#if NRASOPS_ROTATION > 0 + /* Used to intercept putchar to permit display rotation */ + struct wsdisplay_emulops ri_real_ops; +#endif }; .Ed .Pp -Valid values for the +The value of the .Em ri_flg -member are: +member is formed by +.Tn OR Ns 'ing +the following values: .Pp .Bl -tag -offset indent -width RI_CURSORCLIP -compact .It RI_FULLCLEAR -eraserows() hack to clear full screen +Force eraserows() to clear the whole screen instead of only text lines, +when invoked with a +.Em nrows +paramete equal to the number of text lines. .It RI_FORCEMONO -monochrome output even if we can do color +Do not output coloured text, even if the display supports it. .It RI_BSWAP -framebuffer endianness doesn't match CPU +Specifies that the frame buffer endianness is different from the CPU's. .It RI_CURSOR -cursor is switched on +Set when the text cursor is enabled. .It RI_CLEAR -clear display on startup +Clear the display upon initialization. .It RI_CENTER -center onscreen output -.It RI_CURSORCLIP -cursor is currently clipped +Center the text area. +.\" Only honoured if option RASOPS_CLIPPING which we don't use. +.\" .It RI_CURSORCLIP +.\" Cursor is currently clipped +.It RI_ROTATE_CW +Rotate the text display quarter clockwise. .It RI_CFGDONE .Fn rasops_reconfig completed successfully @@ -214,3 +227,8 @@ The subsystem was written by .An Andrew Doran .Aq ad@NetBSD.org . +Display rotation was written by +.An Christopher Pascoe +.Aq pascoe@openbsd.org . +.Sh CAVEATS +Display rotation only works for 16bpp displays. diff --git a/sys/arch/arm/xscale/files.pxa2x0 b/sys/arch/arm/xscale/files.pxa2x0 index b416567cead..4ef2574ee58 100644 --- a/sys/arch/arm/xscale/files.pxa2x0 +++ b/sys/arch/arm/xscale/files.pxa2x0 @@ -1,4 +1,4 @@ -# $OpenBSD: files.pxa2x0,v 1.16 2005/07/01 23:51:55 uwe Exp $ +# $OpenBSD: files.pxa2x0,v 1.17 2005/09/15 20:23:10 miod Exp $ # $NetBSD: files.pxa2x0,v 1.6 2004/05/01 19:09:14 thorpej Exp $ # # Configuration info for Intel PXA2[51]0 CPU support @@ -56,7 +56,7 @@ attach ohci at pxaip with pxaohci file arch/arm/xscale/pxa2x0_ohci.c pxaohci # LCD controller -device lcd: wsemuldisplaydev, rasops16, rasops8, rasops4 +device lcd: wsemuldisplaydev, rasops16, rasops8, rasops4, rasops_rotation file arch/arm/xscale/pxa2x0_lcd.c lcd needs-flag # Inter-Integrated Circuit controller diff --git a/sys/arch/arm/xscale/pxa2x0_lcd.c b/sys/arch/arm/xscale/pxa2x0_lcd.c index d8854c58f81..fd2d2b2d0bd 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.19 2005/05/23 23:59:19 uwe Exp $ */ +/* $OpenBSD: pxa2x0_lcd.c,v 1.20 2005/09/15 20:23:10 miod Exp $ */ /* $NetBSD: pxa2x0_lcd.c,v 1.8 2003/10/03 07:24:05 bsh Exp $ */ /* @@ -563,7 +563,7 @@ pxa2x0_lcd_setup_rasops(struct rasops_info *rinfo, const struct lcd_panel_geometry *geom) { - rinfo->ri_flg = 0; + rinfo->ri_flg = descr->flags; rinfo->ri_depth = descr->depth; rinfo->ri_width = geom->panel_width; rinfo->ri_height = geom->panel_height; diff --git a/sys/arch/arm/xscale/pxa2x0_lcd.h b/sys/arch/arm/xscale/pxa2x0_lcd.h index 1e44f46cd6d..221769c0238 100644 --- a/sys/arch/arm/xscale/pxa2x0_lcd.h +++ b/sys/arch/arm/xscale/pxa2x0_lcd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pxa2x0_lcd.h,v 1.9 2005/04/11 03:32:48 uwe Exp $ */ +/* $OpenBSD: pxa2x0_lcd.h,v 1.10 2005/09/15 20:23:10 miod Exp $ */ /* $NetBSD: pxa2x0_lcd.h,v 1.2 2003/06/17 09:43:14 bsh Exp $ */ /* * Copyright (c) 2002 Genetec Corporation. All rights reserved. @@ -125,6 +125,7 @@ struct lcd_panel_geometry { struct pxa2x0_wsscreen_descr { struct wsscreen_descr c; /* standard descriptor */ int depth; /* bits per pixel */ + int flags; /* rasops flags */ }; void pxa2x0_lcd_attach_sub(struct pxa2x0_lcd_softc *, diff --git a/sys/arch/zaurus/zaurus/zaurus_lcd.c b/sys/arch/zaurus/zaurus/zaurus_lcd.c index 9827964edfa..536873e3b87 100644 --- a/sys/arch/zaurus/zaurus/zaurus_lcd.c +++ b/sys/arch/zaurus/zaurus/zaurus_lcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_lcd.c,v 1.16 2005/07/01 23:57:28 uwe Exp $ */ +/* $OpenBSD: zaurus_lcd.c,v 1.17 2005/09/15 20:23:10 miod Exp $ */ /* $NetBSD: lubbock_lcd.c,v 1.1 2003/08/09 19:38:53 bsh Exp $ */ /* @@ -60,6 +60,8 @@ #include <zaurus/dev/zaurus_scoopvar.h> #include <zaurus/dev/zaurus_sspvar.h> +#include <dev/rasops/rasops.h> + void lcd_attach(struct device *, struct device *, void *); int lcd_match(struct device *, void *, void *); int lcd_cnattach(void (*)(u_int, int)); @@ -72,7 +74,8 @@ lcd_bpp16_screen = { { "std" }, - 16 /* bits per pixel */ + 16, /* bits per pixel */ + RI_ROTATE_CW /* quarter clockwise rotation */ }; static const struct wsscreen_descr *lcd_scr_descr[] = { diff --git a/sys/conf/files b/sys/conf/files index d61d48c77f7..c2c230d3ccb 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.349 2005/09/08 09:11:07 jsg Exp $ +# $OpenBSD: files,v 1.350 2005/09/15 20:23:10 miod Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -47,6 +47,7 @@ define rasops15 define rasops16 define rasops24 define rasops32 +define rasops_rotation # net device attributes - we have generic code for arc(net), ether(net), # and fddi. diff --git a/sys/dev/rasops/files.rasops b/sys/dev/rasops/files.rasops index 977ce1b72be..53136074b5a 100644 --- a/sys/dev/rasops/files.rasops +++ b/sys/dev/rasops/files.rasops @@ -1,11 +1,12 @@ -# $OpenBSD: files.rasops,v 1.4 2005/03/08 20:00:25 tdeval Exp $ +# $OpenBSD: files.rasops,v 1.5 2005/09/15 20:23:10 miod Exp $ # $NetBSD: files.rasops,v 1.7 2001/01/21 13:50:59 takemura Exp $ # Note: `rasops_glue' is only here to force the header file's name # hence it must be mentioned first (shudder...) file dev/rasops/rasops.c ((rasops_glue | rasops1 | rasops2 | rasops4 | - rasops8 | rasops15 | rasops16 | rasops24 | - rasops32) & wsdisplay) needs-flag + rasops8 | rasops15 | rasops16 | rasops24 | + rasops32 | rasops_rotation) & + wsdisplay) needs-flag file dev/rasops/rasops_masks.c wsdisplay & (rasops1 | rasops2 | rasops4) file dev/rasops/rasops1.c wsdisplay & rasops1 diff --git a/sys/dev/rasops/rasops.c b/sys/dev/rasops/rasops.c index 598314d17ec..95eec9bc38c 100644 --- a/sys/dev/rasops/rasops.c +++ b/sys/dev/rasops/rasops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rasops.c,v 1.11 2005/05/01 11:49:31 pascoe Exp $ */ +/* $OpenBSD: rasops.c,v 1.12 2005/09/15 20:23:10 miod Exp $ */ /* $NetBSD: rasops.c,v 1.35 2001/02/02 06:01:01 marcus Exp $ */ /*- @@ -37,8 +37,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "rasops_glue.h" - #include <sys/param.h> #include <sys/systm.h> #include <sys/time.h> @@ -140,6 +138,7 @@ const u_char rasops_isgray[16] = { }; /* Generic functions */ +void rasops_copycols(void *, int, int, int, int); void rasops_copyrows(void *, int, int, int); int rasops_mapchar(void *, int, u_int *); void rasops_cursor(void *, int, int, int); @@ -147,73 +146,25 @@ 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__ + +#if NRASOPS_ROTATION > 0 void rasops_copychar(void *, int, int, int, int); +void rasops_copycols_rotated(void *, int, int, int, int); +void rasops_copyrows_rotated(void *, int, int, int); +void rasops_erasecols_rotated(void *, int, int, int, long); +void rasops_eraserows_rotated(void *, int, int, long); void rasops_putchar_rotated(void *, int, int, u_int, long); +void rasops_rotate_font(int *); -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; - u_char *rp; - int height; - - ri = (struct rasops_info *)cookie; - - /* Do rotated char sans (side)underline */ - ri->ri_real_ops.putchar(cookie, col, ri->ri_rows - row - 1, uc, - attr & ~1); - - /* Do rotated underline */ - rp = ri->ri_bits + col * ri->ri_yscale + (ri->ri_rows - row - 1) * - ri->ri_xscale; - height = ri->ri_font->fontheight; - - /* XXX this assumes 16-bit color depth */ - if ((attr & 1) != 0) { - int16_t c = (int16_t)ri->ri_devcmap[((u_int)attr >> 24) & 0xf]; - - while (height--) { - *(int16_t *)rp = c; - rp += ri->ri_stride; - } - } -} +/* + * List of all rotated fonts + */ +SLIST_HEAD(, rotatedfont) rotatedfonts = SLIST_HEAD_INITIALIZER(rotatedfonts); +struct rotatedfont { + SLIST_ENTRY(rotatedfont) rf_next; + int rf_cookie; + int rf_rotated; +}; #endif /* @@ -234,18 +185,10 @@ 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); @@ -255,6 +198,15 @@ rasops_init(ri, wantrows, wantcols) return (-1); } +#if NRASOPS_ROTATION > 0 + /* + * Pick the rotated version of this font. This will create it + * if necessary. + */ + if (ri->ri_flg & RI_ROTATE_CW) + rasops_rotate_font(&cookie); +#endif + if (wsfont_lock(cookie, &ri->ri_font, WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R) <= 0) { printf("rasops_init: couldn't lock font\n"); @@ -293,7 +245,7 @@ rasops_reconfig(ri, wantrows, wantcols) struct rasops_info *ri; int wantrows, wantcols; { - int bpp, s; + int l, bpp, s; s = splhigh(); @@ -327,13 +279,16 @@ 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; +#if NRASOPS_ROTATION > 0 + if (ri->ri_flg & RI_ROTATE_CW) { + ri->ri_rows = ri->ri_emuwidth / ri->ri_font->fontwidth; + ri->ri_cols = ri->ri_emuheight / ri->ri_font->fontheight; + } else #endif + { + ri->ri_cols = ri->ri_emuwidth / ri->ri_font->fontwidth; + ri->ri_rows = ri->ri_emuheight / ri->ri_font->fontheight; + } ri->ri_emustride = ri->ri_emuwidth * bpp >> 3; ri->ri_delta = ri->ri_stride - ri->ri_emustride; ri->ri_ccol = 0; @@ -349,8 +304,10 @@ rasops_reconfig(ri, wantrows, wantcols) panic("rasops_init: ri_delta not aligned on 32-bit boundary"); #endif /* Clear the entire display */ - if ((ri->ri_flg & RI_CLEAR) != 0) + if ((ri->ri_flg & RI_CLEAR) != 0) { memset(ri->ri_bits, 0, ri->ri_stride * ri->ri_height); + ri->ri_flg &= ~RI_CLEARMARGINS; + } /* Now centre our window if needs be */ ri->ri_origbits = ri->ri_bits; @@ -368,6 +325,18 @@ rasops_reconfig(ri, wantrows, wantcols) } else ri->ri_xorigin = ri->ri_yorigin = 0; + /* Clear the margins */ + if ((ri->ri_flg & RI_CLEARMARGINS) != 0) { + memset(ri->ri_origbits, 0, ri->ri_bits - ri->ri_origbits); + for (l = 0; l < ri->ri_emuheight; l++) + memset(ri->ri_bits + ri->ri_emustride + + l * ri->ri_stride, 0, + ri->ri_stride - ri->ri_emustride); + memset(ri->ri_bits + ri->ri_emuheight * ri->ri_stride, 0, + (ri->ri_origbits + ri->ri_height * ri->ri_stride) - + (ri->ri_bits + ri->ri_emuheight * ri->ri_stride)); + } + /* * Fill in defaults for operations set. XXX this nukes private * routines used by accelerated fb drivers. @@ -433,9 +402,15 @@ rasops_reconfig(ri, wantrows, wantcols) return (-1); } -#ifdef __zaurus__ - ri->ri_real_ops = ri->ri_ops; - ri->ri_ops.putchar = rasops_putchar_rotated; +#if NRASOPS_ROTATION > 0 + if (ri->ri_flg & RI_ROTATE_CW) { + ri->ri_real_ops = ri->ri_ops; + ri->ri_ops.copycols = rasops_copycols_rotated; + ri->ri_ops.copyrows = rasops_copyrows_rotated; + ri->ri_ops.erasecols = rasops_erasecols_rotated; + ri->ri_ops.eraserows = rasops_eraserows_rotated; + ri->ri_ops.putchar = rasops_putchar_rotated; + } #endif ri->ri_flg |= RI_CFGDONE; @@ -556,7 +531,6 @@ rasops_alloc_mattr(cookie, fg, bg, flg, attr) return (0); } -#ifndef __zaurus__ /* * Copy rows. */ @@ -693,41 +667,6 @@ 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. @@ -862,7 +801,6 @@ rasops_unpack_attr(attr, fg, bg, underline) /* * Erase rows */ -#ifndef __zaurus__ void rasops_eraserows(cookie, row, num, attr) void *cookie; @@ -931,23 +869,6 @@ 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 @@ -960,14 +881,17 @@ 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; +#if NRASOPS_ROTATION > 0 + if (ri->ri_flg & RI_ROTATE_CW) { + /* Rotate rows/columns */ + row = ri->ri_ccol; + col = ri->ri_rows - ri->ri_crow - 1; + } else #endif + { + row = ri->ri_crow; + col = ri->ri_ccol; + } rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale; height = ri->ri_font->fontheight; @@ -1021,7 +945,6 @@ rasops_do_cursor(ri) /* * Erase columns. */ -#ifndef __zaurus__ void rasops_erasecols(cookie, row, col, num, attr) void *cookie; @@ -1147,9 +1070,113 @@ rasops_erasecols(cookie, row, col, num, attr) *(int16_t *)dp = clr; } } -#else + +#if NRASOPS_ROTATION > 0 +/* + * Quarter clockwise rotation routines (originally intended for the + * built-in Zaurus C3x00 display in 16bpp). + */ + +#include <sys/malloc.h> + +void +rasops_rotate_font(int *cookie) +{ + struct rotatedfont *f; + int ncookie; + + SLIST_FOREACH(f, &rotatedfonts, rf_next) { + if (f->rf_cookie == *cookie) { + *cookie = f->rf_rotated; + return; + } + } + + /* + * We did not find a rotated version of this font. Ask the wsfont + * code to compute one for us. + */ + + f = malloc(sizeof(struct rotatedfont), M_DEVBUF, M_WAITOK); + if (f == NULL) + return; + + if ((ncookie = wsfont_rotate(*cookie)) == -1) + return; + + f->rf_cookie = *cookie; + f->rf_rotated = ncookie; + SLIST_INSERT_HEAD(&rotatedfonts, f, rf_next); + + *cookie = ncookie; +} + void -rasops_erasecols(cookie, row, col, num, attr) +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; + u_char *rp; + int height; + + ri = (struct rasops_info *)cookie; + + /* Do rotated char sans (side)underline */ + ri->ri_real_ops.putchar(cookie, col, ri->ri_rows - row - 1, uc, + attr & ~1); + + /* Do rotated underline */ + rp = ri->ri_bits + col * ri->ri_yscale + (ri->ri_rows - row - 1) * + ri->ri_xscale; + height = ri->ri_font->fontheight; + + /* XXX this assumes 16-bit color depth */ + if ((attr & 1) != 0) { + int16_t c = (int16_t)ri->ri_devcmap[((u_int)attr >> 24) & 0xf]; + + while (height--) { + *(int16_t *)rp = c; + rp += ri->ri_stride; + } + } +} + +void +rasops_erasecols_rotated(cookie, row, col, num, attr) void *cookie; int row, col, num; long attr; @@ -1162,4 +1189,56 @@ rasops_erasecols(cookie, row, col, num, attr) for (i = col; i < col + num; i++) ri->ri_ops.putchar(cookie, row, i, ' ', attr); } -#endif + +/* XXX: these could likely be optimised somewhat. */ +void +rasops_copyrows_rotated(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_rotated(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); +} + +void +rasops_eraserows_rotated(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 /* NRASOPS_ROTATION */ diff --git a/sys/dev/rasops/rasops.h b/sys/dev/rasops/rasops.h index 33fb89d5b0c..a26db058326 100644 --- a/sys/dev/rasops/rasops.h +++ b/sys/dev/rasops/rasops.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rasops.h,v 1.6 2005/04/30 23:13:47 pascoe Exp $ */ +/* $OpenBSD: rasops.h,v 1.7 2005/09/15 20:23:10 miod Exp $ */ /* $NetBSD: rasops.h,v 1.13 2000/06/13 13:36:54 ad Exp $ */ /*- @@ -44,17 +44,21 @@ #define RASOPS_SMALL #endif +#include "rasops_glue.h" + struct wsdisplay_font; /* For rasops_info::ri_flg */ -#define RI_FULLCLEAR 0x01 /* eraserows() hack to clear full screen */ -#define RI_FORCEMONO 0x02 /* monochrome output even if we can do color */ -#define RI_BSWAP 0x04 /* framebuffer endianness doesn't match CPU */ -#define RI_CURSOR 0x08 /* cursor is switched on */ -#define RI_CLEAR 0x10 /* clear display on startup */ -#define RI_CENTER 0x20 /* center onscreen output */ -#define RI_CURSORCLIP 0x40 /* cursor is currently clipped */ -#define RI_CFGDONE 0x80 /* rasops_reconfig() completed successfully */ +#define RI_FULLCLEAR 0x0001 /* eraserows() hack to clear full screen */ +#define RI_FORCEMONO 0x0002 /* monochrome output even if we can do color */ +#define RI_BSWAP 0x0004 /* framebuffer endianness doesn't match CPU */ +#define RI_CURSOR 0x0008 /* cursor is switched on */ +#define RI_CLEAR 0x0010 /* clear display on startup */ +#define RI_CLEARMARGINS 0x0020 /* clear display margins on startup */ +#define RI_CENTER 0x0040 /* center onscreen output */ +#define RI_CURSORCLIP 0x0080 /* cursor is currently clipped */ +#define RI_ROTATE_CW 0x0100 /* display is rotated, quarter clockwise */ +#define RI_CFGDONE 0x0200 /* rasops_reconfig() completed successfully */ struct rasops_info { /* These must be filled in by the caller */ @@ -111,7 +115,7 @@ struct rasops_info { void (*ri_do_cursor)(struct rasops_info *); void (*ri_updatecursor)(struct rasops_info *); -#ifdef __zaurus__ +#if NRASOPS_ROTATION > 0 /* Used to intercept putchar to permit display rotation */ struct wsdisplay_emulops ri_real_ops; #endif @@ -151,7 +155,6 @@ int rasops_reconfig(struct rasops_info *, int, int); void rasops_unpack_attr(long, int *, int *, int *); void rasops_eraserows(void *, int, int, long); void rasops_erasecols(void *, int, int, int, long); -void rasops_copycols(void *, int, int, int, int); extern const u_char rasops_isgray[16]; extern const u_char rasops_cmap[256*3]; diff --git a/sys/dev/wsfont/files.wsfont b/sys/dev/wsfont/files.wsfont index eeda2ba84e0..354a2c9882a 100644 --- a/sys/dev/wsfont/files.wsfont +++ b/sys/dev/wsfont/files.wsfont @@ -1,4 +1,10 @@ -# $OpenBSD: files.wsfont,v 1.2 2003/04/14 10:42:28 miod Exp $ +# $OpenBSD: files.wsfont,v 1.3 2005/09/15 20:23:10 miod Exp $ # $NetBSD: files.wsfont,v 1.7 2000/11/21 11:44:45 tsutsui Exp $ -file dev/wsfont/wsfont.c wsdisplay +# Note: `wsfont_glue' is only here to force the header file's name +# hence it must be mentioned first. +# This is similar to what rasops does - actually we are only interested +# in getting the rasops_rotation attribute, without having to depend +# on rasops being configured. +file dev/wsfont/wsfont.c ((wsfont_glue & rasops_rotation) | wsdisplay) + needs-flag diff --git a/sys/dev/wsfont/wsfont.c b/sys/dev/wsfont/wsfont.c index 2dfafcf1a81..28cd255d8dd 100644 --- a/sys/dev/wsfont/wsfont.c +++ b/sys/dev/wsfont/wsfont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsfont.c,v 1.13 2005/05/05 23:32:48 miod Exp $ */ +/* $OpenBSD: wsfont.c,v 1.14 2005/09/15 20:23:10 miod Exp $ */ /* $NetBSD: wsfont.c,v 1.17 2001/02/07 13:59:24 ad Exp $ */ /*- @@ -37,9 +37,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/cdefs.h> -//__KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1.17 2001/02/07 13:59:24 ad Exp $"); - #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> @@ -50,6 +47,8 @@ #include <dev/wscons/wsconsio.h> #include <dev/wsfont/wsfont.h> +#include "wsfont_glue.h" /* NRASOPS_ROTATION */ + #undef HAVE_FONT #ifdef FONT_QVSS8x15 @@ -129,10 +128,6 @@ #include <dev/wsfont/gallant12x22.h> #endif -#ifdef __zaurus__ -void wsfont_rotate(struct wsdisplay_font *, int); -#endif - /* Placeholder struct used for linked list */ struct font { struct font *next; @@ -217,7 +212,7 @@ static const u_char reverse[256] = { 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, }; -static struct font *wsfont_find0(int); +static struct font *wsfont_find0(int); static void wsfont_revbit(struct wsdisplay_font *); static void wsfont_revbyte(struct wsdisplay_font *); @@ -289,19 +284,35 @@ wsfont_enum(cb) splx(s); } -#ifdef __zaurus__ -void wsfont_rotate(struct wsdisplay_font *font, int static_orig) +#if NRASOPS_ROTATION > 0 + +struct wsdisplay_font *wsfont_rotate_internal(struct wsdisplay_font *); + +struct wsdisplay_font * +wsfont_rotate_internal(struct wsdisplay_font *font) { int b, n, r, newstride; - char *newfont; + struct wsdisplay_font *newfont; + char *newbits; + + /* Duplicate the existing font... */ + newfont = malloc(sizeof *font, M_DEVBUF, M_WAITOK); + if (newfont == NULL) + return (NULL); + + bcopy(font, newfont, sizeof *font); + newfont->cookie = NULL; /* Allocate a buffer big enough for the rotated font. */ newstride = (font->fontheight + 7) / 8; - newfont = malloc(newstride * font->fontwidth * font->numchars, + newbits = malloc(newstride * font->fontwidth * font->numchars, M_DEVBUF, M_WAITOK); - if (newfont == NULL) - return; - bzero(newfont, newstride * font->fontwidth * font->numchars); + if (newbits == NULL) { + free(newfont, M_DEVBUF); + return (NULL); + } + + bzero(newbits, newstride * font->fontwidth * font->numchars); /* Rotate the font a bit at a time. */ for (n = 0; n < font->numchars; n++) { @@ -315,7 +326,7 @@ void wsfont_rotate(struct wsdisplay_font *font, int static_orig) if (*rb & (0x80 >> (b % 8))) { unsigned char *rrb; - rrb = newfont + newstride - 1 - (r / 8) + rrb = newbits + newstride - 1 - (r / 8) + (n * newstride * font->fontwidth) + (newstride * b); *rrb |= (1 << (r % 8)); @@ -324,28 +335,48 @@ void wsfont_rotate(struct wsdisplay_font *font, int static_orig) } } - /* - * 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); + newfont->data = newbits; + + /* Update font sizes. */ + newfont->stride = newstride; + newfont->fontwidth = font->fontheight; + newfont->fontheight = font->fontwidth; + + if (wsfont_add(newfont, 0) != 0) { + /* + * If we seem to have rotated this font already, drop the + * new one... + */ + free(newbits, M_DEVBUF); free(newfont, M_DEVBUF); - } else { - if (!static_orig) - free(font->data, M_DEVBUF); - font->data = newfont; + newfont = NULL; } - /* Update font sizes. */ - font->stride = newstride; - newstride = font->fontwidth; /* temp */ - font->fontwidth = font->fontheight; - font->fontheight = newstride; + return (newfont); } -#endif + +int +wsfont_rotate(int cookie) +{ + int s, ncookie; + struct wsdisplay_font *font; + struct font *origfont; + + s = splhigh(); + origfont = wsfont_find0(cookie); + splx(s); + + font = wsfont_rotate_internal(origfont->font); + if (font == NULL) + return (-1); + + ncookie = wsfont_find(font->name, font->fontwidth, font->fontheight, + font->stride); + + return (ncookie); +} + +#endif /* NRASOPS_ROTATION */ /* * Initialize list with WSFONT_BUILTIN fonts @@ -360,11 +391,6 @@ 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]; @@ -466,16 +492,12 @@ wsfont_add(font, copy) ent->flg = 0; } -#ifdef __zaurus__ - wsfont_rotate(ent->font, 0); -#endif - /* Now link into the list and return */ list = ent; splx(s); return (0); } - + /* * Remove a font. */ diff --git a/sys/dev/wsfont/wsfont.h b/sys/dev/wsfont/wsfont.h index 2770e201410..000d53d1a42 100644 --- a/sys/dev/wsfont/wsfont.h +++ b/sys/dev/wsfont/wsfont.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsfont.h,v 1.3 2002/03/14 03:16:08 millert Exp $ */ +/* $OpenBSD: wsfont.h,v 1.4 2005/09/15 20:23:10 miod Exp $ */ /* $NetBSD: wsfont.h,v 1.12 2000/06/13 13:37:07 ad Exp $ */ /*- @@ -82,5 +82,6 @@ int wsfont_lock(int, struct wsdisplay_font **, int, int); int wsfont_unlock(int); int wsfont_getflg(int, int *, int *); int wsfont_map_unichar(struct wsdisplay_font *, int); +int wsfont_rotate(int); #endif /* !_WSFONT_H_ */ |