Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
54 | pj | 1 | /* Written by Michael Weller and Harm Hanemaayer. */ |
2 | |||
3 | |||
4 | #include <stdarg.h> |
||
5 | #include "vga.h" |
||
6 | #include "driver.h" |
||
7 | #include "timing.h" |
||
8 | #include "accel.h" |
||
9 | |||
10 | |||
11 | /* |
||
12 | * This calls one of the acceleration interface functions. |
||
13 | */ |
||
14 | |||
15 | int vga_accel(unsigned operation,...) |
||
16 | { |
||
17 | va_list params; |
||
18 | |||
19 | va_start(params, operation); |
||
20 | /* This is the fast interface which I thought of first: */ |
||
21 | if (__svgalib_driverspecs->accel) { |
||
22 | int retval; |
||
23 | |||
24 | retval = (*(__svgalib_driverspecs->accel))(operation, params); |
||
25 | va_end(params); |
||
26 | return retval; |
||
27 | } |
||
28 | |||
29 | /* Do a quick availability check to avoid disasters. */ |
||
30 | if (__svgalib_driverspecs->accelspecs == 0) |
||
31 | return -1; |
||
32 | /* Check for operation availability flag. */ |
||
33 | if (!(__svgalib_driverspecs->accelspecs->operations & (1 << (operation - 1)))) |
||
34 | return -1; |
||
35 | |||
36 | vga_lockvc(); |
||
37 | |||
38 | /* |
||
39 | * gcc doesn't produce glorious code here, it's much better with |
||
40 | * only one va_arg traversal in a function. |
||
41 | */ |
||
42 | |||
43 | switch (operation) { |
||
44 | case ACCEL_FILLBOX: |
||
45 | { |
||
46 | int x, y, w, h; |
||
47 | x = va_arg(params, int); |
||
48 | y = va_arg(params, int); |
||
49 | w = va_arg(params, int); |
||
50 | h = va_arg(params, int); |
||
51 | (*__svgalib_driverspecs->accelspecs->FillBox) (x, y, w, h); |
||
52 | break; |
||
53 | } |
||
54 | case ACCEL_SCREENCOPY: |
||
55 | { |
||
56 | int x1, y1, x2, y2, w, h; |
||
57 | x1 = va_arg(params, int); |
||
58 | y1 = va_arg(params, int); |
||
59 | x2 = va_arg(params, int); |
||
60 | y2 = va_arg(params, int); |
||
61 | w = va_arg(params, int); |
||
62 | h = va_arg(params, int); |
||
63 | (*__svgalib_driverspecs->accelspecs->ScreenCopy) (x1, y1, x2, y2, w, h); |
||
64 | break; |
||
65 | } |
||
66 | case ACCEL_PUTIMAGE: |
||
67 | { |
||
68 | int x, y, w, h; |
||
69 | void *p; |
||
70 | x = va_arg(params, int); |
||
71 | y = va_arg(params, int); |
||
72 | w = va_arg(params, int); |
||
73 | h = va_arg(params, int); |
||
74 | p = va_arg(params, void *); |
||
75 | (*__svgalib_driverspecs->accelspecs->PutImage) (x, y, w, h, p); |
||
76 | break; |
||
77 | } |
||
78 | case ACCEL_DRAWLINE: |
||
79 | { |
||
80 | int x1, x2, y1, y2; |
||
81 | x1 = va_arg(params, int); |
||
82 | y1 = va_arg(params, int); |
||
83 | x2 = va_arg(params, int); |
||
84 | y2 = va_arg(params, int); |
||
85 | (*__svgalib_driverspecs->accelspecs->DrawLine) (x1, y1, x2, y2); |
||
86 | break; |
||
87 | } |
||
88 | case ACCEL_SETFGCOLOR: |
||
89 | { |
||
90 | int c; |
||
91 | c = va_arg(params, int); |
||
92 | (*__svgalib_driverspecs->accelspecs->SetFGColor) (c); |
||
93 | break; |
||
94 | } |
||
95 | case ACCEL_SETBGCOLOR: |
||
96 | { |
||
97 | int c; |
||
98 | c = va_arg(params, int); |
||
99 | (__svgalib_driverspecs->accelspecs->SetBGColor) (c); |
||
100 | break; |
||
101 | } |
||
102 | case ACCEL_SETTRANSPARENCY: |
||
103 | { |
||
104 | int m, c; |
||
105 | m = va_arg(params, int); |
||
106 | c = va_arg(params, int); |
||
107 | (*__svgalib_driverspecs->accelspecs->SetTransparency) (m, c); |
||
108 | break; |
||
109 | } |
||
110 | case ACCEL_SETRASTEROP: |
||
111 | { |
||
112 | int r; |
||
113 | r = va_arg(params, int); |
||
114 | (*__svgalib_driverspecs->accelspecs->SetRasterOp) (r); |
||
115 | break; |
||
116 | } |
||
117 | case ACCEL_PUTBITMAP: |
||
118 | { |
||
119 | int x, y, w, h; |
||
120 | void *p; |
||
121 | x = va_arg(params, int); |
||
122 | y = va_arg(params, int); |
||
123 | w = va_arg(params, int); |
||
124 | h = va_arg(params, int); |
||
125 | p = va_arg(params, void *); |
||
126 | (*__svgalib_driverspecs->accelspecs->PutBitmap) (x, y, w, h, p); |
||
127 | break; |
||
128 | } |
||
129 | case ACCEL_SCREENCOPYBITMAP: |
||
130 | { |
||
131 | int x1, y1, x2, y2, w, h; |
||
132 | x1 = va_arg(params, int); |
||
133 | y1 = va_arg(params, int); |
||
134 | x2 = va_arg(params, int); |
||
135 | y2 = va_arg(params, int); |
||
136 | w = va_arg(params, int); |
||
137 | h = va_arg(params, int); |
||
138 | (*__svgalib_driverspecs->accelspecs->ScreenCopyBitmap) (x1, y1, x2, y2, w, h); |
||
139 | break; |
||
140 | } |
||
141 | case ACCEL_DRAWHLINELIST: |
||
142 | { |
||
143 | int y, n, *x1, *x2; |
||
144 | y = va_arg(params, int); |
||
145 | n = va_arg(params, int); |
||
146 | x1 = va_arg(params, int *); |
||
147 | x2 = va_arg(params, int *); |
||
148 | (*__svgalib_driverspecs->accelspecs->DrawHLineList) (y, n, x1, x2); |
||
149 | break; |
||
150 | } |
||
151 | case ACCEL_SETMODE: |
||
152 | { |
||
153 | int m; |
||
154 | /* This isn't sent to the chipset-specific driver. */ |
||
155 | m = va_arg(params, int); |
||
156 | if ((__svgalib_accel_mode & BLITS_IN_BACKGROUND) |
||
157 | && !(m & BLITS_IN_BACKGROUND)) |
||
158 | /* Make sure background blits are finished. */ |
||
159 | (*__svgalib_driverspecs->accelspecs->Sync) (); |
||
160 | __svgalib_accel_mode = m; |
||
161 | break; |
||
162 | } |
||
163 | case ACCEL_SYNC: |
||
164 | (*__svgalib_driverspecs->accelspecs->Sync) (); |
||
165 | break; |
||
166 | } /* switch */ |
||
167 | |||
168 | va_end(params); |
||
169 | |||
170 | vga_unlockvc(); |
||
171 | |||
172 | return 0; |
||
173 | } |