1 /* VGAlib version 1.2 - (c) 1993 Tommy Frandsen                    */
2 /*                                                                 */
3 /* This library is free software; you can redistribute it and/or   */
4 /* modify it without any restrictions. This library is distributed */
5 /* in the hope that it will be useful, but without any warranty.   */
6 
7 /* Multi-chipset support Copyright (c) 1993 Harm Hanemaayer */
8 /* partially copyrighted (C) 1993 by Hartmut Schirmer */
9 
10 #ifndef _DRIVER_H
11 #define _DRIVER_H
12 
13 #include <stdio.h>
14 #include <stdarg.h>
15 #include "vga.h"
16 #include "libvga.h"
17 #include "timing.h"
18 #include "accel.h"
19 
20 #define MAX_REGS 5000 /* VESA needs a lot of storage space */
21 
22 typedef struct {
23     void (*savepalette)(unsigned char *red, unsigned char *green, unsigned char *blue);
24     void (*restorepalette)(const unsigned char *red,
25 	    const unsigned char *green, const unsigned char *blue);
26     int  (*setpalette)(int index, int red, int green, int blue);
27     void (*getpalette)(int index, int *red, int *green, int *blue);
28     void (*savefont)(void);
29     void (*restorefont)(void);
30     int (*screenoff)(void);
31     int (*screenon)(void);
32     void (*waitretrace)(void);
33     } Emulation;
34 
35 typedef struct {
36 /* Basic functions. */
37     int (*saveregs) (unsigned char regs[]);
38     void (*setregs) (const unsigned char regs[], int mode);
39     void (*unlock) (void);
40     void (*lock) (void);
41     int (*test) (void);
42     int (*init) (int force, int par1, int par2);
43     void (*__svgalib_setpage) (int page);
44     void (*__svgalib_setrdpage) (int page);
45     void (*__svgalib_setwrpage) (int page);
46     int (*setmode) (int mode, int prv_mode);
47     int (*modeavailable) (int mode);
48     void (*setdisplaystart) (int address);
49     void (*setlogicalwidth) (int width);
50     void (*getmodeinfo) (int mode, vga_modeinfo * modeinfo);
51 /* Obsolete blit functions. */
52     void (*bitblt) (int srcaddr, int destaddr, int w, int h, int pitch);
53     void (*imageblt) (void *srcaddr, int destaddr, int w, int h, int pitch);
54     void (*fillblt) (int destaddr, int w, int h, int pitch, int c);
55     void (*hlinelistblt) (int ymin, int n, int *xmin, int *xmax, int pitch, int c);
56     void (*bltwait) (void);
57 /* Other functions. */
58     int (*ext_set) (unsigned what, va_list params);
59     int (*accel) (unsigned operation, va_list params);
60     int (*linear) (int op, int param);
61     AccelSpecs *accelspecs;
62     Emulation *emul;
63 } DriverSpecs;
64 
65 extern DriverSpecs __svgalib_vga_driverspecs;
66 extern DriverSpecs __svgalib_neo_driverspecs;
67 extern DriverSpecs __svgalib_cirrus_driverspecs;
68 extern DriverSpecs __svgalib_et4000_driverspecs;
69 extern DriverSpecs __svgalib_tvga8900_driverspecs;
70 extern DriverSpecs __svgalib_oak_driverspecs;
71 extern DriverSpecs __svgalib_ega_driverspecs;
72 extern DriverSpecs __svgalib_s3_driverspecs;
73 extern DriverSpecs __svgalib_mach32_driverspecs;
74 extern DriverSpecs __svgalib_et3000_driverspecs;
75 extern DriverSpecs __svgalib_gvga6400_driverspecs;
76 extern DriverSpecs __svgalib_ark_driverspecs;
77 extern DriverSpecs __svgalib_ati_driverspecs;
78 extern DriverSpecs __svgalib_ali_driverspecs;
79 extern DriverSpecs __svgalib_mach64_driverspecs;
80 extern DriverSpecs __svgalib_chips_driverspecs;
81 extern DriverSpecs __svgalib_apm_driverspecs;
82 extern DriverSpecs __svgalib_nv3_driverspecs;
83 extern DriverSpecs __svgalib_et6000_driverspecs;
84 extern DriverSpecs __svgalib_vesa_driverspecs;
85 extern DriverSpecs __svgalib_mx_driverspecs;
86 extern DriverSpecs __svgalib_paradise_driverspecs;
87 extern DriverSpecs __svgalib_rage_driverspecs;
88 extern DriverSpecs __svgalib_banshee_driverspecs;
89 extern DriverSpecs __svgalib_sis_driverspecs;
90 extern DriverSpecs __svgalib_i740_driverspecs;
91 extern DriverSpecs __svgalib_laguna_driverspecs;
92 extern DriverSpecs __svgalib_fbdev_driverspecs;
93 extern DriverSpecs __svgalib_g400_driverspecs;
94 extern DriverSpecs __svgalib_r128_driverspecs;
95 extern DriverSpecs __svgalib_savage_driverspecs;
96 
97 extern DriverSpecs *__svgalib_driverspecs;
98 extern DriverSpecs *__svgalib_driverspecslist[];
99 
100 enum {
101     CHIPSET_SAVEREGS = 0, CHIPSET_SETREGS, CHIPSET_UNLOCK, CHIPSET_LOCK,
102     CHIPSET_TEST, CHIPSET_INIT, CHIPSET_SETPAGE, CHIPSET_SETRDPAGE,
103     CHIPSET_SETWRPAGE, CHIPSET_SETMODE,
104     CHIPSET_MODEAVAILABLE, CHIPSET_SETDISPLAYSTART,
105     CHIPSET_SETLOGICALWIDTH, CHIPSET_GETMODEINFO,
106     CHIPSET_BITBLT, CHIPSET_IMAGEBLT, CHIPSET_FILLBLT,
107     CHIPSET_HLINELISTBLT, CHIPSET_BLTWAIT,
108     CHIPSET_EXT_SET, CHIPSET_ACCEL, CHIPSET_LINEAR
109 };
110 
111 enum {
112     LINEAR_QUERY_BASE, LINEAR_QUERY_GRANULARITY, LINEAR_QUERY_RANGE,
113     LINEAR_ENABLE, LINEAR_DISABLE
114 };
115 
116 typedef struct {
117 /* refresh ranges in Hz */
118     unsigned min;
119     unsigned max;
120 } RefreshRange;
121 
122 extern int __svgalib_CRT_I;
123 extern int __svgalib_CRT_D;
124 extern int __svgalib_IS1_R;
125 extern int __svgalib_driver_report;	/* driverreport */
126 extern int __svgalib_videomemoryused;	/* videomemoryused */
127 extern int __svgalib_critical;
128 extern int __svgalib_chipset;
129 extern RefreshRange __svgalib_horizsync;
130 extern RefreshRange __svgalib_vertrefresh;
131 extern int __svgalib_bandwidth;
132 extern int __svgalib_grayscale;
133 extern int __svgalib_modeinfo_linearset;
134 extern const int __svgalib_max_modes;
135 
136 void __svgalib_read_options(char **commands, char *(*func) (int ind, int mode));
137 
138 /* ----------------------------------------------------------------------
139    ** A modetable holds a pair of values
140    ** for each mode :
141    **
142    **    <mode number> <pointer to registers>
143    **
144    ** the last entry is marked by
145    **
146    **    <any number>  <NULL>
147  */
148 
149 typedef struct {
150     unsigned short mode_number;
151     const unsigned char *regs;
152 } ModeTable;
153 
154 #define DISABLE_MODE	  ((unsigned char *)1)
155 #define OneModeEntry(res) {G##res,g##res##_regs}
156 #define DisableEntry(res) {G##res,DISABLE_MODE}
157 #define END_OF_MODE_TABLE { 0, NULL }
158 
159 extern const unsigned char *__svgalib_mode_in_table(const ModeTable * modes, int mode);
160 #define LOOKUPMODE __svgalib_mode_in_table
161 
162 /* ---------------------------------------------------------------------- */
163 
164 extern int __svgalib_hicolor(int dac_type, int mode);
165 /* Enters hicolor mode - 0 for no hi, 1 for 15 bit, 2 for 16, 3 for 24 */
166 /* For any modes it doesn't know about, etc, it attempts to turn hicolor off. */
167 
168 
169 #define STD_DAC		0
170 #define HI15_DAC	1
171 #define HI16_DAC	2
172 #define TC24_DAC	3
173 
174 /* ----------------------------------------------------------------------
175    ** regextr.h  -  extract graphics modes and register information
176    **               from C source file
177  */
178 
179 extern void __svgalib_readmodes(FILE * inp, ModeTable ** modes, int *dac, unsigned *clocks);
180 
181 #endif
182