Rev 6084 | Rev 6103 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6084 | Rev 6088 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | #include |
7 | #include |
8 | #include |
8 | #include |
9 | #include |
9 | #include |
10 | #include |
10 | #include |
Line -... | Line 11... | ||
- | 11 | ||
- | 12 | #include "getopt.h" |
|
11 | 13 | ||
- | 14 | #include "bitmap.h" |
|
Line 12... | Line 15... | ||
12 | #include "bitmap.h" |
15 | #include "i915_kos32.h" |
Line 13... | Line 16... | ||
13 | 16 | ||
14 | #define DRV_NAME "i915 v4.4" |
17 | #define DRV_NAME "i915 v4.4" |
15 | 18 | ||
Line 16... | Line -... | ||
16 | #define I915_DEV_CLOSE 0 |
- | |
17 | #define I915_DEV_INIT 1 |
- | |
18 | #define I915_DEV_READY 2 |
- | |
19 | - | ||
20 | - | ||
21 | struct pci_device { |
- | |
22 | uint16_t domain; |
- | |
23 | uint8_t bus; |
19 | #define I915_DEV_CLOSE 0 |
24 | uint8_t dev; |
- | |
25 | uint8_t func; |
- | |
26 | uint16_t vendor_id; |
- | |
27 | uint16_t device_id; |
- | |
28 | uint16_t subvendor_id; |
- | |
29 | uint16_t subdevice_id; |
- | |
30 | uint32_t device_class; |
- | |
31 | uint8_t revision; |
- | |
32 | }; |
- | |
33 | - | ||
34 | struct cmdtable |
- | |
35 | { |
- | |
36 | char *key; |
- | |
37 | int size; |
- | |
38 | int *val; |
20 | #define I915_DEV_INIT 1 |
39 | }; |
- | |
40 | - | ||
41 | #define CMDENTRY(key, val) {(key), (sizeof(key)-1), &val} |
- | |
42 | void parse_cmdline(char *cmdline, struct cmdtable *table, char *log, videomode_t *mode); |
- | |
43 | - | ||
44 | - | ||
45 | int oops_in_progress; |
- | |
46 | int i915_fbsize = 16; |
- | |
47 | struct drm_device *main_device; |
21 | #define I915_DEV_READY 2 |
48 | struct drm_file *drm_file_handlers[256]; |
22 | |
Line 49... | Line -... | ||
49 | videomode_t usermode; |
- | |
50 | - | ||
51 | void cpu_detect1(); |
- | |
52 | int kmap_init(); |
- | |
53 | - | ||
54 | int _stdcall display_handler(ioctl_t *io); |
- | |
55 | int init_agp(void); |
- | |
56 | - | ||
57 | void get_pci_info(struct pci_device *dev); |
- | |
58 | int i915_getparam(struct drm_device *dev, void *data, |
- | |
59 | struct drm_file *file_priv); |
- | |
60 | - | ||
61 | int i915_mask_update(struct drm_device *dev, void *data, |
- | |
62 | struct drm_file *file); |
- | |
63 | - | ||
64 | struct cmdtable cmdtable[]= { |
- | |
65 | CMDENTRY("-FB=", i915_fbsize), |
- | |
66 | /* CMDENTRY("-pm=", i915.powersave), */ |
- | |
67 | CMDENTRY("-rc6=", i915.enable_rc6), |
- | |
68 | CMDENTRY("-fbc=", i915.enable_fbc), |
- | |
69 | CMDENTRY("-ppgt=", i915.enable_ppgtt), |
- | |
70 | {NULL, 0} |
- | |
71 | }; |
23 | static int my_atoi(char **cmd); |
72 | - | ||
73 | - | ||
74 | static char log[256]; |
24 | static char* parse_mode(char *p, videomode_t *mode); |
75 | - | ||
76 | unsigned long volatile jiffies; |
25 | void cpu_detect1(); |
77 | 26 | int kmap_init(); |
|
78 | struct workqueue_struct *system_wq; |
- | |
79 | int driver_wq_state; |
- | |
80 | - | ||
81 | int x86_clflush_size; |
27 | |
82 | unsigned int tsc_khz; |
- | |
83 | - | ||
84 | int i915_modeset = 1; |
- | |
85 | - | ||
86 | typedef union __attribute__((packed)) |
28 | unsigned long volatile jiffies; |
87 | { |
- | |
88 | uint32_t val; |
29 | int oops_in_progress; |
89 | struct |
- | |
90 | { |
- | |
91 | uint8_t state; |
- | |
92 | uint8_t code; |
30 | int x86_clflush_size; |
93 | uint16_t ctrl_key; |
- | |
94 | }; |
31 | unsigned int tsc_khz; |
95 | }oskey_t; |
- | |
96 | 32 | struct workqueue_struct *system_wq; |
|
97 | static inline oskey_t get_key(void) |
- | |
98 | { |
- | |
99 | oskey_t val; |
- | |
Line 100... | Line 33... | ||
100 | asm volatile("int $0x40":"=a"(val):"a"(2)); |
33 | int driver_wq_state; |
101 | return val; |
34 | struct drm_device *main_device; |
102 | }; |
35 | struct drm_file *drm_file_handlers[256]; |
103 | 36 | videomode_t usermode; |
|
Line 184... | Line 117... | ||
184 | 117 | ||
185 | u32 __attribute__((externally_visible)) drvEntry(int action, char *cmdline) |
118 | u32 __attribute__((externally_visible)) drvEntry(int action, char *cmdline) |
186 | { |
119 | { |
187 | static pci_dev_t device; |
120 | static pci_dev_t device; |
188 | const struct pci_device_id *ent; |
- | |
- | 121 | const struct pci_device_id *ent; |
|
189 | 122 | char *safecmdline; |
|
Line 190... | Line 123... | ||
190 | int err = 0; |
123 | int err = 0; |
191 | 124 | ||
192 | if(action != 1) |
125 | if(action != 1) |
Line 197... | Line 130... | ||
197 | 130 | ||
198 | if( GetService("DISPLAY") != 0 ) |
131 | if( GetService("DISPLAY") != 0 ) |
Line 199... | Line 132... | ||
199 | return 0; |
132 | return 0; |
- | 133 | ||
200 | 134 | printf("\n%s build %s %s\nusage: i915 [options]\n" |
|
201 | printf("\n%s build %s %s\nusage: i915 [options]\n" |
- | |
202 | "-FB=<0-9> Set framebuffer size in megabytes (default: 16)\n", |
135 | "-f\n" |
Line 203... | Line 136... | ||
203 | "-pm=<0,1> Enable powersavings, fbc, downclocking, etc. (default: 1 - true)\n", |
136 | "--fbsize <0-9> Set framebuffer size in megabytes (default: 16)\n", |
204 | DRV_NAME, __DATE__, __TIME__); |
137 | DRV_NAME, __DATE__, __TIME__); |
205 | 138 | ||
- | 139 | printf("--rc6 <-1,0-7> Enable power-saving render C-state 6.\n" |
|
206 | printf("-rc6=<-1,0-7> Enable power-saving render C-state 6.\n" |
140 | " Different stages can be selected via bitmask values\n" |
- | 141 | " (0 = disable; 1 = enable rc6; 2 = enable deep rc6;\n" |
|
207 | " Different stages can be selected via bitmask values\n" |
142 | " 4 = enable deepest rc6).\n" |
208 | " (0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6).\n" |
143 | " For example, 3 would enable rc6 and deep rc6,\n" |
209 | " For example, 3 would enable rc6 and deep rc6, and 7 would enable everything.\n" |
144 | " and 7 would enable everything.\n" |
210 | " default: -1 (use per-chip default)\n"); |
145 | " default: -1 (use per-chip default)\n"); |
211 | printf("-fbc=<-1,0,1> Enable frame buffer compression for power savings\n" |
- | |
212 | " (default: -1 (use per-chip default))\n"); |
146 | printf("--fbc <-1,0,1> Enable frame buffer compression for power savings\n" |
- | 147 | " (default: -1 (use per-chip default))\n"); |
|
213 | printf("-ppgt=<0,1> Enable PPGTT (default: true)\n"); |
148 | printf("-l\n" |
- | 149 | "--log |
|
- | 150 | printf("-m\n" |
|
- | 151 | "--mode |
|
Line 214... | Line -... | ||
214 | - | ||
215 | printf("-l |
152 | printf("-v\n" |
- | 153 | "--video |
|
- | 154 | " set videomode for CONNECTOR\n"); |
|
- | 155 | ||
- | 156 | if( cmdline && *cmdline ) |
|
- | 157 | { |
|
- | 158 | int argc, i, c; |
|
- | 159 | char **argv; |
|
- | 160 | ||
- | 161 | safecmdline = __builtin_strdup(cmdline); |
|
216 | printf("-m |
162 | printf("cmdline %s\n", safecmdline); |
- | 163 | ||
- | 164 | argc = split_cmdline(safecmdline, NULL); |
|
- | 165 | argv = __builtin_malloc((argc+1)*sizeof(char*)); |
|
- | 166 | split_cmdline(safecmdline, argv); |
|
- | 167 | argv[argc] = NULL; |
|
- | 168 | ||
- | 169 | while(1) |
|
- | 170 | { |
|
- | 171 | static struct option long_options[] = |
|
- | 172 | { |
|
- | 173 | {"log", required_argument, 0, 'l'}, |
|
- | 174 | {"mode", required_argument, 0, 'm'}, |
|
- | 175 | {"fbsize",required_argument, 0, 'f'}, |
|
- | 176 | {"video", required_argument, 0, 'v'}, |
|
- | 177 | {"rc6", required_argument, 0, OPTION_RC6}, |
|
- | 178 | {"fbc", required_argument, 0, OPTION_FBC}, |
|
- | 179 | {0, 0, 0, 0} |
|
- | 180 | }; |
|
- | 181 | ||
Line -... | Line 182... | ||
- | 182 | int option_index = 0; |
|
217 | 183 | ||
- | 184 | c = getopt_long (argc, argv, "f:l:m:v:", |
|
- | 185 | long_options, &option_index); |
|
218 | printf("cmdline %s\n", cmdline); |
186 | |
- | 187 | if (c == -1) |
|
- | 188 | break; |
|
- | 189 | ||
- | 190 | switch(c) |
|
- | 191 | { |
|
- | 192 | case OPTION_RC6: |
|
- | 193 | i915.enable_rc6 = my_atoi(&optarg); |
|
- | 194 | printf("i915.rc6 = %d\n",i915.enable_rc6); |
|
- | 195 | break; |
|
- | 196 | ||
- | 197 | case OPTION_FBC: |
|
- | 198 | i915.enable_fbc = my_atoi(&optarg); |
|
- | 199 | printf("i915.fbc = %d\n",i915.enable_fbc); |
|
- | 200 | break; |
|
- | 201 | ||
- | 202 | case 'f': |
|
- | 203 | i915.fbsize = my_atoi(&optarg); |
|
- | 204 | printf("i915.fbsize =%d\n",i915.fbsize); |
|
- | 205 | break; |
|
- | 206 | ||
- | 207 | case 'l': |
|
- | 208 | i915.log_file = optarg; |
|
- | 209 | break; |
|
- | 210 | ||
- | 211 | case 'm': |
|
- | 212 | parse_mode(optarg, &usermode); |
|
- | 213 | break; |
|
- | 214 | ||
- | 215 | case 'v': |
|
- | 216 | i915.cmdline_mode = optarg; |
|
- | 217 | printf("i915.cmdline_mode =%s\n",i915.cmdline_mode); |
|
- | 218 | break; |
|
- | 219 | } |
|
219 | if( cmdline && *cmdline ) |
220 | } |
220 | parse_cmdline(cmdline, cmdtable, log, &usermode); |
221 | }; |
221 | 222 | ||
222 | if( *log && !dbg_open(log)) |
223 | if( i915.log_file && !dbg_open(i915.log_file)) |
223 | { |
224 | { |
224 | printf("Can't open %s\nExit\n", log); |
225 | printf("Can't open %s\nExit\n", i915.log_file); |
225 | return 0; |
226 | return 0; |
Line 226... | Line 227... | ||
226 | } |
227 | } |
227 | else |
- | |
Line 228... | Line 228... | ||
228 | { |
228 | else |
229 | dbgprintf("\nLOG: %s build %s %s\n",DRV_NAME,__DATE__, __TIME__); |
229 | { |
230 | } |
230 | dbgprintf("\nLOG: %s build %s %s\n",DRV_NAME,__DATE__, __TIME__); |
231 | 231 | } |
|
Line 270... | Line 270... | ||
270 | dbgprintf("Set DISPLAY handler\n"); |
270 | dbgprintf("Set DISPLAY handler\n"); |
Line 271... | Line 271... | ||
271 | 271 | ||
272 | return err; |
272 | return err; |
Line -... | Line 273... | ||
- | 273 | }; |
|
- | 274 | ||
- | 275 | int do_command_line(const char* usercmd) |
|
- | 276 | { |
|
- | 277 | char *cmdline; |
|
- | 278 | int argc, i, c; |
|
- | 279 | char **argv; |
|
- | 280 | ||
- | 281 | if( (usercmd == NULL) || (*usercmd == 0) ) |
|
- | 282 | return 1; |
|
- | 283 | ||
- | 284 | cmdline = __builtin_strdup(usercmd); |
|
- | 285 | printf("cmdline %s\n", cmdline); |
|
- | 286 | ||
- | 287 | argc = split_cmdline(cmdline, NULL); |
|
- | 288 | argv = __builtin_malloc((argc+1)*sizeof(char*)); |
|
- | 289 | split_cmdline(cmdline, argv); |
|
- | 290 | argv[argc] = NULL; |
|
- | 291 | ||
- | 292 | __getopt_initialized = 0; |
|
- | 293 | ||
- | 294 | while(1) |
|
- | 295 | { |
|
- | 296 | static struct option long_options[] = |
|
- | 297 | { |
|
- | 298 | {"video", required_argument, 0, 'v'}, |
|
- | 299 | {0, 0, 0, 0} |
|
- | 300 | }; |
|
- | 301 | ||
- | 302 | int option_index = 0; |
|
- | 303 | ||
- | 304 | c = getopt_long (argc, argv, "v:", |
|
- | 305 | long_options, &option_index); |
|
- | 306 | ||
- | 307 | if (c == -1) |
|
- | 308 | break; |
|
- | 309 | ||
- | 310 | switch(c) |
|
- | 311 | { |
|
- | 312 | case 'v': |
|
- | 313 | printf("cmdline_mode %s\n",optarg); |
|
- | 314 | set_cmdline_mode_ext(main_device, optarg); |
|
- | 315 | break; |
|
- | 316 | } |
|
- | 317 | } |
|
- | 318 | __builtin_free(argv); |
|
- | 319 | __builtin_free(cmdline); |
|
- | 320 | ||
Line 273... | Line 321... | ||
273 | }; |
321 | return 0; |
274 | 322 | }; |
|
Line 275... | Line 323... | ||
275 | 323 | ||
Line 282... | Line 330... | ||
282 | 330 | ||
283 | #define SRV_GETVERSION 0 |
331 | #define SRV_GETVERSION 0 |
284 | #define SRV_ENUM_MODES 1 |
332 | #define SRV_ENUM_MODES 1 |
285 | #define SRV_SET_MODE 2 |
333 | #define SRV_SET_MODE 2 |
286 | #define SRV_GET_CAPS 3 |
- | |
- | 334 | #define SRV_GET_CAPS 3 |
|
Line 287... | Line 335... | ||
287 | 335 | #define SRV_CMDLINE 4 |
|
288 | 336 | ||
289 | #define SRV_GET_PCI_INFO 20 |
337 | #define SRV_GET_PCI_INFO 20 |
290 | #define SRV_I915_GET_PARAM 21 |
338 | #define SRV_I915_GET_PARAM 21 |
Line 347... | Line 395... | ||
347 | case SRV_ENUM_MODES: |
395 | case SRV_ENUM_MODES: |
348 | // dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
396 | // dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
349 | // inp, io->inp_size, io->out_size ); |
397 | // inp, io->inp_size, io->out_size ); |
350 | check_output(4); |
398 | check_output(4); |
351 | // check_input(*outp * sizeof(videomode_t)); |
399 | // check_input(*outp * sizeof(videomode_t)); |
352 | if( i915_modeset) |
- | |
353 | retval = get_videomodes((videomode_t*)inp, outp); |
400 | retval = get_videomodes((videomode_t*)inp, outp); |
354 | break; |
401 | break; |
Line 355... | Line 402... | ||
355 | 402 | ||
356 | case SRV_SET_MODE: |
403 | case SRV_SET_MODE: |
357 | // dbgprintf("SRV_SET_MODE inp %x inp_size %x\n", |
404 | // dbgprintf("SRV_SET_MODE inp %x inp_size %x\n", |
358 | // inp, io->inp_size); |
405 | // inp, io->inp_size); |
359 | check_input(sizeof(videomode_t)); |
- | |
360 | if( i915_modeset ) |
406 | check_input(sizeof(videomode_t)); |
361 | retval = set_user_mode((videomode_t*)inp); |
407 | retval = set_user_mode((videomode_t*)inp); |
Line 362... | Line 408... | ||
362 | break; |
408 | break; |
363 | 409 | ||
364 | case SRV_GET_CAPS: |
410 | case SRV_GET_CAPS: |
Line -... | Line 411... | ||
- | 411 | retval = get_driver_caps((hwcaps_t*)inp); |
|
- | 412 | break; |
|
- | 413 | ||
- | 414 | case SRV_CMDLINE: |
|
365 | retval = get_driver_caps((hwcaps_t*)inp); |
415 | retval = do_command_line((char*)inp); |
366 | break; |
416 | break; |
367 | 417 | ||
368 | case SRV_GET_PCI_INFO: |
418 | case SRV_GET_PCI_INFO: |
Line 777... | Line 827... | ||
777 | return val*sign; |
827 | return val*sign; |
778 | } |
828 | } |
779 | } |
829 | } |
780 | } |
830 | } |
Line 781... | Line 831... | ||
781 | 831 | ||
782 | char* parse_mode(char *p, videomode_t *mode) |
832 | static char* parse_mode(char *p, videomode_t *mode) |
783 | { |
833 | { |
Line 784... | Line 834... | ||
784 | char c; |
834 | char c; |
Line 804... | Line 854... | ||
804 | } |
854 | } |
Line 805... | Line 855... | ||
805 | 855 | ||
806 | return p; |
856 | return p; |
Line 807... | Line -... | ||
807 | }; |
- | |
808 | - | ||
809 | - | ||
810 | static char* parse_path(char *p, char *log) |
- | |
811 | { |
- | |
812 | char c; |
- | |
813 | - | ||
814 | while( (c = *p++) == ' '); |
- | |
815 | p--; |
- | |
816 | while((c = *p++) && (c != ' ')) |
- | |
817 | *log++ = c; |
- | |
818 | - | ||
819 | *log = 0; |
- | |
820 | - | ||
821 | return p; |
- | |
822 | }; |
- | |
823 | - | ||
824 | void parse_cmdline(char *cmdline, struct cmdtable *table, char *log, videomode_t *mode) |
- | |
825 | { |
- | |
826 | char *p = cmdline; |
- | |
827 | char *p1; |
- | |
828 | int val; |
- | |
829 | char c = *p++; |
- | |
830 | - | ||
831 | if( table ) |
- | |
832 | { |
- | |
833 | while(table->key) |
- | |
834 | { |
- | |
835 | if(p1 = strstr(cmdline, table->key)) |
- | |
836 | { |
- | |
837 | p1+= table->size; |
- | |
838 | *table->val = my_atoi(&p1); |
- | |
839 | } |
- | |
840 | table++; |
- | |
841 | } |
- | |
842 | } |
- | |
843 | - | ||
844 | while( c ) |
- | |
845 | { |
- | |
846 | if( c == '-') |
- | |
847 | { |
- | |
848 | switch(*p++) |
- | |
849 | { |
- | |
850 | case 'l': |
- | |
851 | p = parse_path(p, log); |
- | |
852 | break; |
- | |
853 | - | ||
854 | case 'm': |
- | |
855 | p = parse_mode(p, mode); |
- | |
856 | break; |
- | |
857 | }; |
- | |
858 | }; |
- | |
859 | c = *p++; |
- | |
860 | }; |
- | |
861 | }; |
- | |
862 | - | ||
863 | char *strstr(const char *cs, const char *ct) |
- | |
864 | { |
- | |
865 | int d0, d1; |
- | |
866 | register char *__res; |
- | |
867 | __asm__ __volatile__( |
- | |
868 | "movl %6,%%edi\n\t" |
- | |
869 | "repne\n\t" |
- | |
870 | "scasb\n\t" |
- | |
871 | "notl %%ecx\n\t" |
- | |
872 | "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ |
- | |
873 | "movl %%ecx,%%edx\n" |
- | |
874 | "1:\tmovl %6,%%edi\n\t" |
- | |
875 | "movl %%esi,%%eax\n\t" |
- | |
876 | "movl %%edx,%%ecx\n\t" |
- | |
877 | "repe\n\t" |
- | |
878 | "cmpsb\n\t" |
- | |
879 | "je 2f\n\t" /* also works for empty string, see above */ |
- | |
880 | "xchgl %%eax,%%esi\n\t" |
- | |
881 | "incl %%esi\n\t" |
- | |
882 | "cmpb $0,-1(%%eax)\n\t" |
- | |
883 | "jne 1b\n\t" |
- | |
884 | "xorl %%eax,%%eax\n\t" |
- | |
885 | "2:" |
- | |
886 | : "=a" (__res), "=&c" (d0), "=&S" (d1) |
- | |
887 | : "0" (0), "1" (0xffffffff), "2" (cs), "g" (ct) |
- | |
888 | : "dx", "di"); |
- | |
889 | return __res; |
- | |
890 | } |
857 | }; |
Line 891... | Line 858... | ||
891 | 858 | ||
892 | #include |
859 | #include |
893 | 860 |