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