Rev 2338 | Rev 2342 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2338 | Serge | 1 | #include "drmP.h" |
2 | #include "drm.h" |
||
3 | #include "i915_drm.h" |
||
4 | #include "i915_drv.h" |
||
5 | #include "intel_drv.h" |
||
6 | |||
7 | |||
2325 | Serge | 8 | #include |
9 | #include |
||
10 | #include |
||
11 | #include |
||
12 | #include |
||
13 | #include |
||
14 | |||
2340 | Serge | 15 | typedef struct bitmap bitmap_t; |
16 | |||
17 | void parse_cmdline(char *cmdline, char *log); |
||
2338 | Serge | 18 | int _stdcall display_handler(ioctl_t *io); |
2325 | Serge | 19 | int init_agp(void); |
20 | |||
2340 | Serge | 21 | int create_video(int width, int height, u32_t *outp); |
22 | int create_bitmap(bitmap_t **pbitmap, int width, int height); |
||
23 | int video_blit(uint64_t src_offset, int x, int y, |
||
24 | int w, int h, int pitch); |
||
25 | |||
2325 | Serge | 26 | static char log[256]; |
27 | |||
2338 | Serge | 28 | int i915_modeset = 1; |
29 | |||
2325 | Serge | 30 | u32_t drvEntry(int action, char *cmdline) |
31 | { |
||
32 | struct pci_device_id *ent; |
||
33 | |||
34 | int err = 0; |
||
35 | |||
36 | if(action != 1) |
||
37 | return 0; |
||
38 | |||
39 | if( GetService("DISPLAY") != 0 ) |
||
40 | return 0; |
||
41 | |||
2340 | Serge | 42 | if( cmdline && *cmdline ) |
43 | parse_cmdline(cmdline, log); |
||
2325 | Serge | 44 | |
45 | if(!dbg_open(log)) |
||
46 | { |
||
2340 | Serge | 47 | strcpy(log, "/RD/1/DRIVERS/i915.log"); |
2325 | Serge | 48 | |
49 | if(!dbg_open(log)) |
||
50 | { |
||
51 | printf("Can't open %s\nExit\n", log); |
||
52 | return 0; |
||
53 | }; |
||
54 | } |
||
2340 | Serge | 55 | dbgprintf("i915_early_preview second edition\n cmdline: %s\n", cmdline); |
2325 | Serge | 56 | |
57 | enum_pci_devices(); |
||
58 | |||
59 | err = i915_init(); |
||
60 | |||
2338 | Serge | 61 | if(err) |
62 | { |
||
63 | dbgprintf("Epic Fail :(/n"); |
||
2325 | Serge | 64 | |
2338 | Serge | 65 | }; |
2325 | Serge | 66 | |
2338 | Serge | 67 | err = RegService("DISPLAY", display_handler); |
2325 | Serge | 68 | |
2338 | Serge | 69 | if( err != 0) |
70 | dbgprintf("Set DISPLAY handler\n"); |
||
71 | |||
2325 | Serge | 72 | return err; |
73 | }; |
||
74 | |||
2338 | Serge | 75 | #define API_VERSION 0x01000100 |
76 | |||
77 | #define SRV_GETVERSION 0 |
||
78 | #define SRV_ENUM_MODES 1 |
||
79 | #define SRV_SET_MODE 2 |
||
80 | |||
81 | #define SRV_CREATE_VIDEO 9 |
||
82 | #define SRV_BLIT_VIDEO 10 |
||
83 | #define SRV_CREATE_BITMAP 11 |
||
84 | |||
85 | #define check_input(size) \ |
||
86 | if( unlikely((inp==NULL)||(io->inp_size != (size))) ) \ |
||
87 | break; |
||
88 | |||
89 | #define check_output(size) \ |
||
90 | if( unlikely((outp==NULL)||(io->out_size != (size))) ) \ |
||
91 | break; |
||
92 | |||
93 | int _stdcall display_handler(ioctl_t *io) |
||
94 | { |
||
95 | int retval = -1; |
||
96 | u32_t *inp; |
||
97 | u32_t *outp; |
||
98 | |||
99 | inp = io->input; |
||
100 | outp = io->output; |
||
101 | |||
102 | switch(io->io_code) |
||
103 | { |
||
104 | case SRV_GETVERSION: |
||
105 | check_output(4); |
||
106 | *outp = API_VERSION; |
||
107 | retval = 0; |
||
108 | break; |
||
109 | |||
110 | case SRV_ENUM_MODES: |
||
111 | dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
||
112 | inp, io->inp_size, io->out_size ); |
||
2340 | Serge | 113 | check_output(4); |
2338 | Serge | 114 | // check_input(*outp * sizeof(videomode_t)); |
115 | if( i915_modeset) |
||
116 | retval = get_videomodes((videomode_t*)inp, outp); |
||
117 | break; |
||
118 | |||
119 | case SRV_SET_MODE: |
||
120 | dbgprintf("SRV_SET_MODE inp %x inp_size %x\n", |
||
121 | inp, io->inp_size); |
||
122 | check_input(sizeof(videomode_t)); |
||
123 | if( i915_modeset ) |
||
124 | retval = set_user_mode((videomode_t*)inp); |
||
125 | break; |
||
126 | |||
127 | case SRV_CREATE_VIDEO: |
||
2340 | Serge | 128 | check_input(2); |
129 | check_output(4); |
||
130 | retval = create_video(inp[0], inp[1], outp); |
||
2338 | Serge | 131 | break; |
132 | |||
133 | case SRV_BLIT_VIDEO: |
||
2340 | Serge | 134 | video_blit( ((uint64_t*)inp)[0], inp[2], inp[3], |
2338 | Serge | 135 | inp[4], inp[5], inp[6]); |
136 | |||
137 | retval = 0; |
||
138 | break; |
||
139 | |||
140 | case SRV_CREATE_BITMAP: |
||
141 | check_input(8); |
||
142 | check_output(4); |
||
2340 | Serge | 143 | retval = create_bitmap((bitmap_t**)outp, inp[0], inp[1]); |
2338 | Serge | 144 | break; |
2340 | Serge | 145 | |
2338 | Serge | 146 | }; |
147 | |||
148 | return retval; |
||
149 | } |
||
150 | |||
151 | |||
2325 | Serge | 152 | #define PCI_CLASS_REVISION 0x08 |
153 | #define PCI_CLASS_DISPLAY_VGA 0x0300 |
||
154 | #define PCI_CLASS_BRIDGE_HOST 0x0600 |
||
2326 | Serge | 155 | #define PCI_CLASS_BRIDGE_ISA 0x0601 |
2325 | Serge | 156 | |
157 | int pci_scan_filter(u32_t id, u32_t busnr, u32_t devfn) |
||
158 | { |
||
159 | u16_t vendor, device; |
||
160 | u32_t class; |
||
161 | int ret = 0; |
||
162 | |||
163 | vendor = id & 0xffff; |
||
164 | device = (id >> 16) & 0xffff; |
||
165 | |||
166 | if(vendor == 0x8086) |
||
167 | { |
||
168 | class = PciRead32(busnr, devfn, PCI_CLASS_REVISION); |
||
169 | class >>= 16; |
||
170 | |||
171 | if( (class == PCI_CLASS_DISPLAY_VGA) || |
||
2326 | Serge | 172 | (class == PCI_CLASS_BRIDGE_HOST) || |
173 | (class == PCI_CLASS_BRIDGE_ISA)) |
||
2325 | Serge | 174 | ret = 1; |
175 | } |
||
176 | return ret; |
||
177 | }; |
||
2340 | Serge | 178 | |
179 | |||
180 | static char* parse_path(char *p, char *log) |
||
181 | { |
||
182 | char c; |
||
183 | |||
184 | while( (c = *p++) == ' '); |
||
185 | p--; |
||
186 | while( (c = *log++ = *p++) && (c != ' ')); |
||
187 | *log = 0; |
||
188 | |||
189 | return p; |
||
190 | }; |
||
191 | |||
192 | void parse_cmdline(char *cmdline, char *log) |
||
193 | { |
||
194 | char *p = cmdline; |
||
195 | |||
196 | char c = *p++; |
||
197 | |||
198 | while( c ) |
||
199 | { |
||
200 | if( c == '-') |
||
201 | { |
||
202 | switch(*p++) |
||
203 | { |
||
204 | case 'l': |
||
205 | p = parse_path(p, log); |
||
206 | break; |
||
207 | }; |
||
208 | }; |
||
209 | c = *p++; |
||
210 | }; |
||
211 | }; |
||
212 |