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