xref: /plan9/sys/src/cmd/gs/src/gdevsvga.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1989, 1995, 1998 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: gdevsvga.h,v 1.5 2002/06/16 07:25:26 lpd Exp $ */
18 /* Common definitions and procedures for SuperVGA drivers */
19 /* Requires gdevpcfb.h */
20 
21 #ifndef gdevsvga_INCLUDED
22 #  define gdevsvga_INCLUDED
23 
24 /* Common procedures */
25 
26 	/* See gxdevice.h for the definitions of the procedures. */
27 
28 dev_proc_close_device(svga_close);
29 dev_proc_map_rgb_color(svga_map_rgb_color);
30 dev_proc_map_color_rgb(svga_map_color_rgb);
31 dev_proc_fill_rectangle(svga_fill_rectangle);
32 dev_proc_copy_mono(svga_copy_mono);
33 dev_proc_copy_color(svga_copy_color);
34 dev_proc_get_params(svga_get_params);
35 dev_proc_put_params(svga_put_params);
36 dev_proc_get_bits(svga_get_bits);
37 dev_proc_copy_alpha(svga_copy_alpha);
38 
39 /* Table structure for looking up graphics modes. */
40 typedef struct {
41     int width, height;		/* "key" */
42     int mode;			/* "value" */
43 } mode_info;
44 
45 /* The device descriptor structure */
46 typedef struct gx_device_svga_s gx_device_svga;
47 struct gx_device_svga_s {
48     gx_device_common;
49     int (*get_mode) (void);
50     void (*set_mode) (int);
51     void (*set_page) (gx_device_svga * fbdev, int pnum, int wnum);
52     bool fixed_colors;		/* if true, used a fixed palette */
53     const mode_info *mode;	/* BIOS display mode info */
54     uint raster;		/* frame buffer bytes per line */
55     int current_page;		/* current page */
56     int wnum_read, wnum_write;	/* window #s for read vs. write */
57     /* Following are device-specific. */
58     union {
59 	struct {
60 	    void (*bios_set_page) (int, int);	/* set-page function */
61 	    int pn_shift;	/* log2(64K/granularity) */
62 	} vesa;
63 	struct {
64 	    int select_reg;	/* page-select register */
65 	} atiw;
66 	struct {
67 	    int et_model;	/* 4 for ET4000, */
68 	    /* 3 for ET3000 */
69 	} tseng;
70     } info;
71 };
72 
73 /* The initial parameters map an appropriate fraction of */
74 /* the screen to a full-page coordinate space. */
75 /* This may or may not be what is desired! */
76 #define svga_color_device(procs, name, depth, maxv, dither, get_mode, set_mode, set_page) {\
77 	std_device_color_body(gx_device_svga, &procs, name,\
78 	  640, 480,\
79 	  480 / PAGE_HEIGHT_INCHES, 480 / PAGE_HEIGHT_INCHES,\
80 	  /*dci_color(*/depth, maxv, dither/*)*/),\
81 	 { 0 },		/* std_procs */\
82 	get_mode, set_mode, set_page,\
83 	0 /*fixed_colors*/\
84    }
85 #define svga_device(procs, name, get_mode, set_mode, set_page)\
86   svga_color_device(procs, name, 8, 31, 4, get_mode, set_mode, set_page)
87 
88 /* Utility procedures */
89 void svga_init_colors(gx_device *);
90 int svga_find_mode(gx_device *, const mode_info *);
91 int svga_open(gx_device *);
92 
93 #endif /* gdevsvga_INCLUDED */
94