Remove d3d driver
[mesa.git] / src / mesa / drivers / dos / null.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 4.1
4 *
5 * Copyright (C) 1999 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /*
26 * DOS/DJGPP device driver for Mesa
27 *
28 * Author: Daniel Borca
29 * Email : dborca@users.sourceforge.net
30 * Web : http://www.geocities.com/dborca
31 */
32
33
34 #include <stdlib.h>
35 #include <sys/segments.h>
36
37 #include "video.h"
38 #include "null.h"
39
40
41 static vl_mode *modes;
42
43 #define null_color_precision 8
44
45
46 static void
47 null_blit_nop (void)
48 {
49 }
50
51
52 /* Desc: Attempts to detect NUL, check video modes and create selectors.
53 *
54 * In : -
55 * Out : mode array
56 *
57 * Note: -
58 */
59 static vl_mode *
60 null_init (void)
61 {
62 static int m[][2] = {
63 { 320, 200 },
64 { 320, 240 },
65 { 400, 300 },
66 { 512, 384 },
67 { 640, 400 },
68 { 640, 480 },
69 { 800, 600 },
70 { 1024, 768 },
71 { 1280, 1024 },
72 { 1600, 1200 }
73 };
74 static int b[] = {
75 8,
76 15,
77 16,
78 24,
79 32
80 };
81 const unsigned int m_count = sizeof(m) / sizeof(m[0]);
82 const unsigned int b_count = sizeof(b) / sizeof(b[0]);
83
84 unsigned int i, j, k;
85
86 if (modes == NULL) {
87 modes = malloc(sizeof(vl_mode) * (1 + m_count * b_count));
88
89 if (modes != NULL) {
90 for (k = 0, i = 0; i < m_count; i++) {
91 for (j = 0; j < b_count; j++, k++) {
92 modes[k].xres = m[i][0];
93 modes[k].yres = m[i][1];
94 modes[k].bpp = b[j];
95 modes[k].mode = 0x4000;
96 modes[k].scanlen = m[i][0] * ((b[j] + 7) / 8);
97 modes[k].sel = -1;
98 modes[k].gran = -1;
99 }
100 }
101 modes[k].xres = -1;
102 modes[k].yres = -1;
103 modes[k].bpp = -1;
104 modes[k].mode = 0xffff;
105 modes[k].scanlen = -1;
106 modes[k].sel = -1;
107 modes[k].gran = -1;
108 }
109 }
110
111 return modes;
112 }
113
114
115 /* Desc: Frees all resources allocated by NUL init code.
116 *
117 * In : -
118 * Out : -
119 *
120 * Note: -
121 */
122 static void
123 null_fini (void)
124 {
125 if (modes != NULL) {
126 free(modes);
127 modes = NULL;
128 }
129 }
130
131
132 /* Desc: Attempts to enter specified video mode.
133 *
134 * In : ptr to mode structure, refresh rate
135 * Out : 0 if success
136 *
137 * Note: -
138 */
139 static int
140 null_entermode (vl_mode *p, int refresh, int fbbits)
141 {
142 NUL.blit = null_blit_nop;
143
144 return 0;
145
146 (void)(p && refresh && fbbits); /* silence compiler warning */
147 }
148
149
150 /* Desc: Restores to the mode prior to first call to null_entermode.
151 *
152 * In : -
153 * Out : -
154 *
155 * Note: -
156 */
157 static void
158 null_restore (void)
159 {
160 }
161
162
163 /* Desc: set one palette entry
164 *
165 * In : color index, R, G, B
166 * Out : -
167 *
168 * Note: uses integer values
169 */
170 static void
171 null_setCI_i (int index, int red, int green, int blue)
172 {
173 (void)(index && red && green && blue); /* silence compiler warning */
174 }
175
176
177 /* Desc: set one palette entry
178 *
179 * In : color index, R, G, B
180 * Out : -
181 *
182 * Note: uses normalized values
183 */
184 static void
185 null_setCI_f (int index, float red, float green, float blue)
186 {
187 float max = (1 << null_color_precision) - 1;
188
189 null_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
190 }
191
192
193 /* Desc: state retrieval
194 *
195 * In : parameter name, ptr to storage
196 * Out : 0 if request successfully processed
197 *
198 * Note: -
199 */
200 static int
201 null_get (int pname, int *params)
202 {
203 switch (pname) {
204 default:
205 params[0] = params[0]; /* silence compiler warning */
206 return -1;
207 }
208 return 0;
209 }
210
211
212 /*
213 * the driver
214 */
215 vl_driver NUL = {
216 null_init,
217 null_entermode,
218 NULL,
219 null_setCI_f,
220 null_setCI_i,
221 null_get,
222 null_restore,
223 null_fini
224 };