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