1 
2 #ifndef ACCEL_H
3 #define ACCEL_H
4 
5 /*
6  * New accelerator interface sketch.
7  * As of svgalib 1.23, this isn't used yet.
8  *
9  * The main goal is to define functions that can be used as part of
10  * certain kinds of interesting graphical operations (not necessarily
11  * interesting primitives on their own). Obvious useful primitives
12  * in their own are FillBox, ScreenCopy, DrawHLineList (solid polygon),
13  * DrawLine.
14  *
15  * An interesting purpose is the fast drawing of color bitmaps, both
16  * straight and transparent (masked, certain color not written). For
17  * masked bitmaps ("sprites"), there is a number of possible methods,
18  * the availability of which depends on the chips. Caching in
19  * non-visible video memory is often useful. One way is to use a
20  * transparency color compare feature of a BITBLT chip, either
21  * transferring the image from system memory or cached in video memory.
22  * If transparency compare is not available, it may be possible to first
23  * clear (zeroes) the mask in the destination area, and then use BITBLT
24  * raster-operation to OR the image into the destination (this requires
25  * the mask color to be 0). A higher level (library) interface should
26  * control this kind of operation.
27  */
28 
29 
30 typedef struct {
31 /* Graphics mode-independent fields. */
32     int flags;
33     /*
34      * The following fields define lists of linewidths in pixel
35      * units that the accelerator supports for each depth. Each
36      * list is terminated by 0. These fields are only relevant
37      * if the ACCELERATE_ANY_LINEWIDTH flag is not set.
38      */
39     int *supportedLineWidths8bpp;
40     int *supportedLineWidths16bpp;
41     int *supportedLineWidths24bpp;
42     int *supportedLineWidths32bpp;
43     /*
44      * The following function sets up the accelerator interface for
45      * pixels of size bpp and scanline width of width_in_pixels.
46      */
47     void (*initAccelerator) (int bpp, int width_in_pixels);
48 /* Fields that are initialized after setting a graphics mode. */
49     /*
50      * The following field defines which accelerated primitives are
51      * available in the selected graphics mode.
52      */
53     int operations;
54     /*
55      * The following field defines which accelerated primitives are
56      * available with special raster-ops in the selected graphics mode.
57      */
58     int ropOperations;
59     /*
60      * The following field defines which special raster operations are
61      * available in the selected graphics mode.
62      */
63     int ropModes;
64     /*
65      * The following field defines which accelerated primitives are
66      * available with transparency in the selected graphics mode.
67      */
68     int transparencyOperations;
69     /*
70      * The following field defines which special transparency modes are
71      * available in the selected graphics mode.
72      */
73     int transparencyModes;
74 /* Acceleration primitive functions. */
75     void (*FillBox) (int x, int y, int width, int height);
76     void (*ScreenCopy) (int x1, int y1, int x2, int y2, int width,
77 			int height);
78     void (*PutImage) (int x, int y, int width, int height, void *image);
79     void (*DrawLine) (int x1, int y1, int x2, int y2);
80     void (*SetFGColor) (int c);
81     void (*SetBGColor) (int c);
82     void (*SetRasterOp) (int rop);
83     void (*SetTransparency) (int mode, int color);
84     void (*PutBitmap) (int x, int y, int w, int h, void *bitmap);
85     void (*ScreenCopyBitmap) (int x1, int y1, int x2, int y2, int width,
86 			      int height);
87     void (*DrawHLineList) (int ymin, int n, int *xmin, int *xmax);
88     void (*SetMode) (void);
89     void (*Sync) (void);
90 } AccelSpecs;
91 
92 /* Flags: */
93 /* Every programmable scanline width is supported by the accelerator. */
94 #define ACCELERATE_ANY_LINEWIDTH	0x1
95 /* Bitmap (1-bit-per-pixel) operations support transparency (bit = 0). */
96 #define BITMAP_TRANSPARENCY		0x2
97 /* For bitmaps (1 bpp) stored in video memory, the most-significant bit */
98 /* within a byte is the leftmost pixel. */
99 #define BITMAP_ORDER_MSB_FIRST		0x4
100 
101 /* Operation flags: see vga.h. */
102 
103 /*
104  * Acceleration primitive description:
105  *
106  * FillBox      Simple solid fill of rectangle with a single color.
107  * ScreenCopy   Screen-to-screen BLT (BitBlt), handles overlapping areas.
108  * PutImage     Straight image transfer (PutImage). Advantage over
109  *              framebuffer writes is mainly in alignment handling.
110  * DrawLine     Draw general line ("zero-pixel wide").
111  * SetFGColor   Set foreground color for some operations (FillBox, DrawLine,
112  *              PutBitmap).
113  * SetBGColor   Set background color for some operations (PutBitmap).
114  * SetRasterOp  Set the raster operation for drawing operations that support
115  *              raster ops as defined in ropOperations.
116  * SetTransparency
117  *              Set the transparency mode for some operations (enable/disable,
118  *              and the transparency pixel value). Source pixels equal to
119  *              the transparency color are not written. Operations supported
120  *              are ScreenCopy and PutImage, subject to their flags being set
121  *              in the transparencyOperations field.
122  * PutBitmap    Color-expand a bit-wise (bit-per-pixel, each byte is 8 pixels)
123  *              image to the screen with the foreground and background color.
124  *              The lowest order bit of each byte is leftmost on the screen
125  *              (contrary to the VGA tradition), irrespective of the bitmap
126  *              bit order flag. Each scanline is aligned to a multiple of
127  *              32-bits.
128  *              If the transparency mode is enabled (irrespective of the
129  *              transparency color), then bits that are zero in the bitmap
130  *              are not written (the background color is not used).
131  * ScreenCopyBitmap
132  *              Color-expand bit-wise bitmap stored in video memory
133  *              (may also support transparency).
134  * DrawHLineList
135  *              Draw a set of horizontal line segments from top to bottom
136  *              in the foreground color.
137  * SetMode      Set the acceleration mode, e.g. let blits go
138  *              on in the background (program must not access video memory
139  *              when blits can be running).
140  * Sync         Wait for any background blits to finish.
141  *
142  * It is not the intention to have alternative non-accelerated routines
143  * available for each possible operation (library functions should
144  * take advantage of accelerator functions, rather than the accelerator
145  * functions being primitives on their own right). If something like
146  * bit-order reversal is required to implement an accelerated primitive,
147  * it's still worthwhile if it's still much quicker than similar
148  * unaccelerated functionality would be.
149  *
150  * Strategy for accelerator registers in accelerated functions:
151  *      Foreground color, background color, raster operation and transparency
152  *      compare setting are preserved, source and destination pitch is always
153  *      set to screen pitch (may be temporarily changed and then restored).
154  */
155 
156 
157 /* Macros. */
158 
159 #define BLTBYTEADDRESS(x, y) \
160 	(y * __svgalib_accel_screenpitchinbytes + x * __svgalib_accel_bytesperpixel)
161 
162 #define BLTPIXADDRESS(x, y) \
163 	(y * __svgalib_accel_screenpitch + x)
164 
165 #define SIGNALBLOCK \
166     {								\
167          sigset_t sig2block;					\
168 	 sigemptyset(&sig2block); 				\
169 	 sigaddset(&sig2block,SIGINT); 				\
170 	 sigprocmask(SIG_BLOCK, &sig2block, (sigset_t *)NULL);	\
171      }
172 
173 #define SIGNALUNBLOCK \
174     {								\
175          sigset_t sig2block;					\
176 	 sigemptyset(&sig2block); 				\
177 	 sigaddset(&sig2block,SIGINT); 				\
178 	 sigprocmask(SIG_UNBLOCK, &sig2block, (sigset_t *)NULL);\
179      }
180 
181 /* Variables defined in accel.c */
182 
183 extern int __svgalib_accel_screenpitch;
184 extern int __svgalib_accel_bytesperpixel;
185 extern int __svgalib_accel_screenpitchinbytes;
186 extern int __svgalib_accel_mode;
187 extern int __svgalib_accel_bitmaptransparency;
188 
189 /*
190  * The following function should be called when the mode is set.
191  * This is currently done in the setmode driver functions.
192  */
193 
194 void __svgalib_InitializeAcceleratorInterface(ModeInfo * modeinfo);
195 
196 /*
197  * The following driver function fills in available accelerator
198  * primitives for a graphics mode (operations etc.). It could be part
199  * of the setmode driver function.
200  *
201  * void initOperations( AccelSpecs *accelspecs, int bpp, int width_in_pixels );
202  */
203 
204 #endif
205