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