Home | History | Annotate | Line # | Download | only in dev
grfabs_reg.h revision 1.7
      1 /*	$NetBSD: grfabs_reg.h,v 1.7 1996/09/16 06:43:35 leo Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1995 Leo Weppelman
      5  * Copyright (c) 1994 Christian E. Hopps
      6  * All rights reserved.
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by Christian E. Hopps.
     18  * 4. The name of the author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #ifndef _GRFABS_REG_H
     34 #define _GRFABS_REG_H
     35 
     36 struct point {
     37     long	x;
     38     long	y;
     39 };
     40 typedef struct point point_t;
     41 
     42 struct dimension {
     43     u_long	width;
     44     u_long	height;
     45 };
     46 typedef struct dimension dimen_t;
     47 
     48 struct box {
     49     long	x;
     50     long	y;
     51     u_long	width;
     52     u_long	height;
     53 };
     54 typedef struct box box_t;
     55 
     56 struct rectangle {
     57     long	left;
     58     long	top;
     59     long	right;
     60     long	bottom;
     61 };
     62 typedef struct rectangle rect_t;
     63 
     64 typedef struct bitmap bmap_t;
     65 typedef struct colormap colormap_t;
     66 typedef struct display_mode dmode_t;
     67 
     68 /*
     69  * View stuff.
     70  */
     71 
     72 struct view {
     73     bmap_t	*bitmap;	/* bitmap.				*/
     74     box_t	display;	/* viewable area.			*/
     75     dmode_t	*mode;		/* the mode for this view		*/
     76     colormap_t	*colormap;	/* the colormap for this view		*/
     77     int		flags;
     78 };
     79 typedef struct view view_t;
     80 
     81 /* View-flags: */
     82 #define	VF_DISPLAY	1	/* view is on the air now		*/
     83 
     84 /*
     85  * Bitmap stuff.
     86  */
     87 struct bitmap {
     88     u_short	bytes_per_row;	/* number of bytes per display row.	*/
     89     u_short	rows;		/* number of display rows.		*/
     90     u_short	depth;		/* depth of bitmap.			*/
     91     u_char	*plane;		/* plane data for bitmap.		*/
     92     u_char	*hw_address;	/* mappable bitplane pointer.		*/
     93     u_char	*regs;		/* where the registers are		*/
     94     u_char	*hw_regs;	/* mappable registers			*/
     95     u_short	reg_size;	/* size of the register area		*/
     96 };
     97 
     98 /*
     99  * Colormap stuff.
    100  */
    101 struct colormap {
    102     u_char	type;		/* what type of entries these are.	*/
    103     union {
    104         u_char	grey;		/* CM_GREYSCALE				*/
    105         struct {		/* CM_COLOR				*/
    106             u_char	red;
    107             u_char	green;
    108             u_char	blue;
    109         } rgb_mask;
    110     } valid_mask;
    111     u_short	first;		/* color register entry[0] refers to	*/
    112     u_short	size;		/* number of entries			*/
    113     u_long	*entry;		/* the table of actual color values	*/
    114 };
    115 
    116 /*
    117  * Mask short-hands
    118  */
    119 #define grey_mask  valid_mask.grey
    120 #define red_mask   valid_mask.rgb_mask.red
    121 #define green_mask valid_mask.rgb_mask.green
    122 #define blue_mask  valid_mask.rgb_mask.blue
    123 
    124 enum colormap_type {
    125 	CM_MONO,		/* only on or off allowed		*/
    126 	CM_GREYSCALE,		/* grey values				*/
    127 	CM_COLOR		/* RGB values				*/
    128 };
    129 
    130 #define	MAX_CENTRIES		256		/* that all there is	*/
    131 /*
    132  * Create a colormap entry
    133  */
    134 #define	MAKE_COLOR_ENTRY(r,g,b)	(((r & 0xff)<<16)|((g & 0xff)<<8)|(b & 0xff))
    135 #define MAKE_MONO_ENTRY(x)	((x) ? 1 : 0)
    136 #define MAKE_GREY_ENTRY(l)	(l & 0xff)
    137 
    138 struct grfabs_sw {
    139 	void	 (*display_view) __P((view_t*));
    140 	view_t	* (*alloc_view) __P((dmode_t *, dimen_t *, u_char));
    141 	void	 (*free_view) __P((view_t *));
    142 	void	 (*remove_view) __P((view_t *));
    143 	int 	 (*use_colormap) __P((view_t *, colormap_t *));
    144 };
    145 
    146 /* display mode */
    147 struct display_mode {
    148     LIST_ENTRY(display_mode)	link;
    149     u_char			*name;		/* logical name for mode. */
    150     dimen_t			size;		/* screen size		  */
    151     u_char			depth;		/* screen depth		  */
    152     void			*data;		/* opaque driver data	  */
    153     struct grfabs_sw		*grfabs_funcs;	/* hardware switch table  */
    154     view_t			*current_view;	/* view displaying me	  */
    155 };
    156 
    157 /*
    158  * Definition of available graphic mode list.
    159  */
    160 typedef LIST_HEAD(modelist, display_mode) MODES;
    161 
    162 /*
    163  * Misc draw related macros.
    164  */
    165 #define INIT_BOX(b,xx,yy,ww,hh)						\
    166 	do {								\
    167 		(b)->x = xx;						\
    168 		(b)->y = yy;						\
    169 		(b)->width = ww;					\
    170 		(b)->height = hh;					\
    171 	} while(0)
    172 
    173 
    174 /*
    175  * Prototype for the probe function
    176  */
    177 typedef void (*grf_probe_t) __P((MODES *));
    178 
    179 /*
    180  * Common variables
    181  */
    182 extern view_t		gra_con_view;
    183 extern colormap_t	gra_con_cmap;
    184 extern long		gra_con_colors[MAX_CENTRIES];
    185 extern u_long		gra_def_color16[16];
    186 
    187 /*
    188  * Prototypes:
    189  */
    190 int	grfabs_probe __P((grf_probe_t));
    191 view_t	*grf_alloc_view __P((dmode_t *d, dimen_t *dim, u_char depth));
    192 dmode_t	*grf_get_best_mode __P((dimen_t *dim, u_char depth));
    193 void	grf_display_view __P((view_t *v));
    194 void	grf_remove_view __P((view_t *v));
    195 void	grf_free_view __P((view_t *v));
    196 int	grf_get_colormap __P((view_t *, colormap_t *));
    197 int	grf_use_colormap __P((view_t *, colormap_t *));
    198 
    199 #endif /* _GRFABS_REG_H */
    200