1 /* $NetBSD: rasops.h,v 1.19 2006/02/18 13:57:33 jmcneill Exp $ */ 2 3 /*- 4 * Copyright (c) 1999 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Andrew Doran. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #ifndef _RASOPS_H_ 40 #define _RASOPS_H_ 1 41 42 struct wsdisplay_font; 43 44 /* For rasops_info::ri_flg */ 45 #define RI_FULLCLEAR 0x01 /* eraserows() hack to clear full screen */ 46 #define RI_FORCEMONO 0x02 /* monochrome output even if we can do color */ 47 #define RI_BSWAP 0x04 /* framebuffer endianness doesn't match CPU */ 48 #define RI_CURSOR 0x08 /* cursor is switched on */ 49 #define RI_CLEAR 0x10 /* clear display on startup */ 50 #define RI_CENTER 0x20 /* center onscreen output */ 51 #define RI_CURSORCLIP 0x40 /* cursor is currently clipped */ 52 #define RI_CFGDONE 0x80 /* rasops_reconfig() completed successfully */ 53 54 struct rasops_info { 55 /* These must be filled in by the caller */ 56 int ri_depth; /* depth in bits */ 57 u_char *ri_bits; /* ptr to bits */ 58 int ri_width; /* width (pels) */ 59 int ri_height; /* height (pels) */ 60 int ri_stride; /* stride in bytes */ 61 62 /* 63 * If you want shadow framebuffer support, point ri_hwbits 64 * to the real framebuffer, and ri_bits to the shadow framebuffer 65 */ 66 u_char *ri_hwbits; 67 68 /* 69 * These can optionally be left zeroed out. If you fill ri_font, 70 * but aren't using wsfont, set ri_wsfcookie to -1. 71 */ 72 struct wsdisplay_font *ri_font; 73 int ri_wsfcookie; /* wsfont cookie */ 74 void *ri_hw; /* driver private data; ignored by rasops */ 75 int ri_crow; /* cursor row */ 76 int ri_ccol; /* cursor column */ 77 int ri_flg; /* various operational flags */ 78 79 /* 80 * These are optional and will default if zero. Meaningless 81 * on depths other than 15, 16, 24 and 32 bits per pel. On 82 * 24 bit displays, ri_{r,g,b}num must be 8. 83 */ 84 u_char ri_rnum; /* number of bits for red */ 85 u_char ri_gnum; /* number of bits for green */ 86 u_char ri_bnum; /* number of bits for blue */ 87 u_char ri_rpos; /* which bit red starts at */ 88 u_char ri_gpos; /* which bit green starts at */ 89 u_char ri_bpos; /* which bit blue starts at */ 90 91 /* These are filled in by rasops_init() */ 92 int ri_emuwidth; /* width we actually care about */ 93 int ri_emuheight; /* height we actually care about */ 94 int ri_emustride; /* bytes per row we actually care about */ 95 int ri_rows; /* number of rows (characters, not pels) */ 96 int ri_cols; /* number of columns (characters, not pels) */ 97 int ri_delta; /* row delta in bytes */ 98 int ri_pelbytes; /* bytes per pel (may be zero) */ 99 int ri_fontscale; /* fontheight * fontstride */ 100 int ri_xscale; /* fontwidth * pelbytes */ 101 int ri_yscale; /* fontheight * stride */ 102 u_char *ri_origbits; /* where screen bits actually start */ 103 int ri_xorigin; /* where ri_bits begins (x) */ 104 int ri_yorigin; /* where ri_bits begins (y) */ 105 int32_t ri_devcmap[16]; /* color -> framebuffer data */ 106 107 /* The emulops you need to use, and the screen caps for wscons */ 108 struct wsdisplay_emulops ri_ops; 109 int ri_caps; 110 111 /* Callbacks so we can share some code */ 112 void (*ri_do_cursor)(struct rasops_info *); 113 }; 114 115 #define DELTA(p, d, cast) ((p) = (cast)((caddr_t)(p) + (d))) 116 117 #define CHAR_IN_FONT(c,font) \ 118 ((c) >= (font)->firstchar && \ 119 ((c) - (font)->firstchar) < (font)->numchars) 120 121 /* 122 * rasops_init(). 123 * 124 * Integer parameters are the number of rows and columns we'd *like*. 125 * 126 * In terms of optimization, fonts that are a multiple of 8 pixels wide 127 * work the best. 128 * 129 * rasops_init() takes care of rasops_reconfig(). The parameters to both 130 * are the same. If calling rasops_reconfig() to change the font and 131 * ri_wsfcookie >= 0, you must call wsfont_unlock() on it, and reset it 132 * to -1 (or a new, valid cookie). 133 */ 134 135 /* 136 * Per-depth initialization functions. These should not be called outside 137 * the rasops code. 138 */ 139 void rasops1_init(struct rasops_info *); 140 void rasops2_init(struct rasops_info *); 141 void rasops4_init(struct rasops_info *); 142 void rasops8_init(struct rasops_info *); 143 void rasops15_init(struct rasops_info *); 144 void rasops24_init(struct rasops_info *); 145 void rasops32_init(struct rasops_info *); 146 147 /* rasops.c */ 148 int rasops_init(struct rasops_info *, int, int); 149 int rasops_reconfig(struct rasops_info *, int, int); 150 void rasops_unpack_attr(long, int *, int *, int *); 151 void rasops_eraserows(void *, int, int, long); 152 void rasops_erasecols(void *, int, int, int, long); 153 void rasops_copycols(void *, int, int, int, int); 154 155 extern const u_char rasops_isgray[16]; 156 extern const u_char rasops_cmap[256*3]; 157 158 #endif /* _RASOPS_H_ */ 159