Rev 3120 | Rev 3255 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3031 | serge | 1 | #include |
2 | #include |
||
3 | #include |
||
2338 | Serge | 4 | #include "i915_drv.h" |
3031 | serge | 5 | //#include "intel_drv.h" |
2338 | Serge | 6 | |
2325 | Serge | 7 | #include |
8 | #include |
||
9 | #include |
||
10 | #include |
||
11 | #include |
||
12 | #include |
||
13 | |||
2342 | Serge | 14 | #include "bitmap.h" |
2340 | Serge | 15 | |
3033 | serge | 16 | extern struct drm_device *main_device; |
17 | |||
2344 | Serge | 18 | void cpu_detect(); |
19 | |||
2340 | Serge | 20 | void parse_cmdline(char *cmdline, char *log); |
2338 | Serge | 21 | int _stdcall display_handler(ioctl_t *io); |
2325 | Serge | 22 | int init_agp(void); |
23 | |||
3120 | serge | 24 | int srv_blit_bitmap(u32 hbitmap, int dst_x, int dst_y, |
2351 | Serge | 25 | int src_x, int src_y, u32 w, u32 h); |
2340 | Serge | 26 | |
2351 | Serge | 27 | int blit_textured(u32 hbitmap, int dst_x, int dst_y, |
28 | int src_x, int src_y, u32 w, u32 h); |
||
29 | |||
2361 | Serge | 30 | int blit_tex(u32 hbitmap, int dst_x, int dst_y, |
31 | int src_x, int src_y, u32 w, u32 h); |
||
32 | |||
2325 | Serge | 33 | static char log[256]; |
34 | |||
2344 | Serge | 35 | int x86_clflush_size; |
36 | |||
2338 | Serge | 37 | int i915_modeset = 1; |
38 | |||
2325 | Serge | 39 | u32_t drvEntry(int action, char *cmdline) |
40 | { |
||
41 | struct pci_device_id *ent; |
||
42 | |||
43 | int err = 0; |
||
44 | |||
45 | if(action != 1) |
||
46 | return 0; |
||
47 | |||
48 | if( GetService("DISPLAY") != 0 ) |
||
49 | return 0; |
||
50 | |||
2340 | Serge | 51 | if( cmdline && *cmdline ) |
52 | parse_cmdline(cmdline, log); |
||
2325 | Serge | 53 | |
54 | if(!dbg_open(log)) |
||
55 | { |
||
3243 | Serge | 56 | // strcpy(log, "/tmp1/1/i915.log"); |
3031 | serge | 57 | strcpy(log, "/RD/1/DRIVERS/i915.log"); |
2325 | Serge | 58 | |
59 | if(!dbg_open(log)) |
||
60 | { |
||
61 | printf("Can't open %s\nExit\n", log); |
||
62 | return 0; |
||
63 | }; |
||
64 | } |
||
3243 | Serge | 65 | dbgprintf("i915 RC 10\n cmdline: %s\n", cmdline); |
2325 | Serge | 66 | |
2351 | Serge | 67 | cpu_detect(); |
68 | dbgprintf("\ncache line size %d\n", x86_clflush_size); |
||
69 | |||
2325 | Serge | 70 | enum_pci_devices(); |
71 | |||
72 | err = i915_init(); |
||
73 | |||
2338 | Serge | 74 | if(err) |
75 | { |
||
76 | dbgprintf("Epic Fail :(/n"); |
||
77 | }; |
||
2325 | Serge | 78 | |
2338 | Serge | 79 | err = RegService("DISPLAY", display_handler); |
2325 | Serge | 80 | |
2338 | Serge | 81 | if( err != 0) |
82 | dbgprintf("Set DISPLAY handler\n"); |
||
83 | |||
2325 | Serge | 84 | return err; |
85 | }; |
||
86 | |||
2344 | Serge | 87 | #define CURRENT_API 0x0200 /* 2.00 */ |
88 | #define COMPATIBLE_API 0x0100 /* 1.00 */ |
||
2338 | Serge | 89 | |
2344 | Serge | 90 | #define API_VERSION (COMPATIBLE_API << 16) | CURRENT_API |
2351 | Serge | 91 | #define DISPLAY_VERSION API_VERSION |
2338 | Serge | 92 | |
93 | |||
2352 | Serge | 94 | #define SRV_GETVERSION 0 |
95 | #define SRV_ENUM_MODES 1 |
||
96 | #define SRV_SET_MODE 2 |
||
97 | #define SRV_GET_CAPS 3 |
||
2342 | Serge | 98 | |
2352 | Serge | 99 | #define SRV_CREATE_SURFACE 10 |
100 | #define SRV_DESTROY_SURFACE 11 |
||
101 | #define SRV_LOCK_SURFACE 12 |
||
102 | #define SRV_UNLOCK_SURFACE 13 |
||
3039 | serge | 103 | #define SRV_RESIZE_SURFACE 14 |
3120 | serge | 104 | #define SRV_BLIT_BITMAP 15 |
105 | #define SRV_BLIT_TEXTURE 16 |
||
106 | #define SRV_BLIT_VIDEO 17 |
||
2344 | Serge | 107 | |
2338 | Serge | 108 | #define check_input(size) \ |
109 | if( unlikely((inp==NULL)||(io->inp_size != (size))) ) \ |
||
110 | break; |
||
111 | |||
112 | #define check_output(size) \ |
||
113 | if( unlikely((outp==NULL)||(io->out_size != (size))) ) \ |
||
114 | break; |
||
115 | |||
116 | int _stdcall display_handler(ioctl_t *io) |
||
117 | { |
||
118 | int retval = -1; |
||
119 | u32_t *inp; |
||
120 | u32_t *outp; |
||
121 | |||
122 | inp = io->input; |
||
123 | outp = io->output; |
||
124 | |||
125 | switch(io->io_code) |
||
126 | { |
||
127 | case SRV_GETVERSION: |
||
128 | check_output(4); |
||
2344 | Serge | 129 | *outp = DISPLAY_VERSION; |
2338 | Serge | 130 | retval = 0; |
131 | break; |
||
132 | |||
133 | case SRV_ENUM_MODES: |
||
3031 | serge | 134 | // dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
135 | // inp, io->inp_size, io->out_size ); |
||
2340 | Serge | 136 | check_output(4); |
2338 | Serge | 137 | // check_input(*outp * sizeof(videomode_t)); |
138 | if( i915_modeset) |
||
139 | retval = get_videomodes((videomode_t*)inp, outp); |
||
140 | break; |
||
141 | |||
142 | case SRV_SET_MODE: |
||
3031 | serge | 143 | // dbgprintf("SRV_SET_MODE inp %x inp_size %x\n", |
144 | // inp, io->inp_size); |
||
2338 | Serge | 145 | check_input(sizeof(videomode_t)); |
146 | if( i915_modeset ) |
||
147 | retval = set_user_mode((videomode_t*)inp); |
||
148 | break; |
||
3033 | serge | 149 | |
2351 | Serge | 150 | case SRV_GET_CAPS: |
151 | retval = get_driver_caps((hwcaps_t*)inp); |
||
152 | break; |
||
153 | |||
2344 | Serge | 154 | case SRV_CREATE_SURFACE: |
155 | // check_input(8); |
||
3243 | Serge | 156 | // retval = create_surface(main_device, (struct io_call_10*)inp); |
2338 | Serge | 157 | break; |
158 | |||
2352 | Serge | 159 | case SRV_LOCK_SURFACE: |
3243 | Serge | 160 | // retval = lock_surface((struct io_call_12*)inp); |
2352 | Serge | 161 | break; |
2342 | Serge | 162 | |
3039 | serge | 163 | case SRV_RESIZE_SURFACE: |
3243 | Serge | 164 | // retval = resize_surface((struct io_call_14*)inp); |
3039 | serge | 165 | break; |
166 | |||
3243 | Serge | 167 | // case SRV_BLIT_BITMAP: |
168 | // srv_blit_bitmap( inp[0], inp[1], inp[2], |
||
169 | // inp[3], inp[4], inp[5], inp[6]); |
||
3033 | serge | 170 | |
171 | // blit_tex( inp[0], inp[1], inp[2], |
||
2351 | Serge | 172 | // inp[3], inp[4], inp[5], inp[6]); |
173 | |||
2338 | Serge | 174 | |
175 | retval = 0; |
||
176 | break; |
||
3031 | serge | 177 | |
2338 | Serge | 178 | }; |
179 | |||
180 | return retval; |
||
181 | } |
||
182 | |||
183 | |||
2325 | Serge | 184 | #define PCI_CLASS_REVISION 0x08 |
185 | #define PCI_CLASS_DISPLAY_VGA 0x0300 |
||
186 | #define PCI_CLASS_BRIDGE_HOST 0x0600 |
||
2326 | Serge | 187 | #define PCI_CLASS_BRIDGE_ISA 0x0601 |
2325 | Serge | 188 | |
189 | int pci_scan_filter(u32_t id, u32_t busnr, u32_t devfn) |
||
190 | { |
||
191 | u16_t vendor, device; |
||
192 | u32_t class; |
||
193 | int ret = 0; |
||
194 | |||
195 | vendor = id & 0xffff; |
||
196 | device = (id >> 16) & 0xffff; |
||
197 | |||
198 | if(vendor == 0x8086) |
||
199 | { |
||
200 | class = PciRead32(busnr, devfn, PCI_CLASS_REVISION); |
||
201 | class >>= 16; |
||
202 | |||
203 | if( (class == PCI_CLASS_DISPLAY_VGA) || |
||
2326 | Serge | 204 | (class == PCI_CLASS_BRIDGE_HOST) || |
205 | (class == PCI_CLASS_BRIDGE_ISA)) |
||
2325 | Serge | 206 | ret = 1; |
207 | } |
||
208 | return ret; |
||
209 | }; |
||
2340 | Serge | 210 | |
211 | |||
212 | static char* parse_path(char *p, char *log) |
||
213 | { |
||
214 | char c; |
||
215 | |||
216 | while( (c = *p++) == ' '); |
||
217 | p--; |
||
218 | while( (c = *log++ = *p++) && (c != ' ')); |
||
219 | *log = 0; |
||
220 | |||
221 | return p; |
||
222 | }; |
||
223 | |||
224 | void parse_cmdline(char *cmdline, char *log) |
||
225 | { |
||
226 | char *p = cmdline; |
||
227 | |||
228 | char c = *p++; |
||
229 | |||
230 | while( c ) |
||
231 | { |
||
232 | if( c == '-') |
||
233 | { |
||
234 | switch(*p++) |
||
235 | { |
||
236 | case 'l': |
||
237 | p = parse_path(p, log); |
||
238 | break; |
||
239 | }; |
||
240 | }; |
||
241 | c = *p++; |
||
242 | }; |
||
243 | }; |
||
244 | |||
2351 | Serge | 245 | |
2344 | Serge | 246 | static inline void __cpuid(unsigned int *eax, unsigned int *ebx, |
2351 | Serge | 247 | unsigned int *ecx, unsigned int *edx) |
2344 | Serge | 248 | { |
249 | /* ecx is often an input as well as an output. */ |
||
2351 | Serge | 250 | asm volatile("cpuid" |
2344 | Serge | 251 | : "=a" (*eax), |
252 | "=b" (*ebx), |
||
253 | "=c" (*ecx), |
||
254 | "=d" (*edx) |
||
2351 | Serge | 255 | : "0" (*eax), "2" (*ecx) |
256 | : "memory"); |
||
2344 | Serge | 257 | } |
258 | |||
2351 | Serge | 259 | |
260 | |||
2344 | Serge | 261 | static inline void cpuid(unsigned int op, |
262 | unsigned int *eax, unsigned int *ebx, |
||
263 | unsigned int *ecx, unsigned int *edx) |
||
264 | { |
||
265 | *eax = op; |
||
266 | *ecx = 0; |
||
267 | __cpuid(eax, ebx, ecx, edx); |
||
268 | } |
||
269 | |||
270 | void cpu_detect() |
||
271 | { |
||
272 | u32 junk, tfms, cap0, misc; |
||
273 | |||
274 | cpuid(0x00000001, &tfms, &misc, &junk, &cap0); |
||
275 | |||
276 | if (cap0 & (1<<19)) |
||
277 | { |
||
278 | x86_clflush_size = ((misc >> 8) & 0xff) * 8; |
||
279 | } |
||
280 | } |
||
281 | |||
3243 | Serge | 282 | |
283 | int get_driver_caps(hwcaps_t *caps) |
||
284 | { |
||
285 | int ret = 0; |
||
286 | |||
287 | switch(caps->idx) |
||
288 | { |
||
289 | case 0: |
||
290 | caps->opt[0] = 0; |
||
291 | caps->opt[1] = 0; |
||
292 | break; |
||
293 | |||
294 | case 1: |
||
295 | caps->cap1.max_tex_width = 4096; |
||
296 | caps->cap1.max_tex_height = 4096; |
||
297 | break; |
||
298 | default: |
||
299 | ret = 1; |
||
300 | }; |
||
301 | caps->idx = 1; |
||
302 | return ret; |
||
303 | }19)) |
||
304 |