Rev 2338 | Rev 2342 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2338 | Rev 2340 | ||
---|---|---|---|
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 | ||
- | 15 | typedef struct bitmap bitmap_t; |
|
- | 16 | ||
14 | 17 | void parse_cmdline(char *cmdline, char *log); |
|
15 | int _stdcall display_handler(ioctl_t *io); |
18 | int _stdcall display_handler(ioctl_t *io); |
16 | int init_agp(void); |
19 | int init_agp(void); |
- | 20 | ||
- | 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); |
|
17 | 25 | ||
18 | static char log[256]; |
26 | static char log[256]; |
19 | 27 | ||
20 | int i915_modeset = 1; |
28 | int i915_modeset = 1; |
21 | 29 | ||
22 | u32_t drvEntry(int action, char *cmdline) |
30 | u32_t drvEntry(int action, char *cmdline) |
23 | { |
31 | { |
24 | struct pci_device_id *ent; |
32 | struct pci_device_id *ent; |
25 | 33 | ||
26 | int err = 0; |
34 | int err = 0; |
27 | 35 | ||
28 | if(action != 1) |
36 | if(action != 1) |
29 | return 0; |
37 | return 0; |
30 | 38 | ||
31 | if( GetService("DISPLAY") != 0 ) |
39 | if( GetService("DISPLAY") != 0 ) |
32 | return 0; |
40 | return 0; |
33 | 41 | ||
34 | // if( cmdline && *cmdline ) |
42 | if( cmdline && *cmdline ) |
35 | // parse_cmdline(cmdline, &usermode, log, &radeon_modeset); |
43 | parse_cmdline(cmdline, log); |
36 | 44 | ||
37 | if(!dbg_open(log)) |
45 | if(!dbg_open(log)) |
38 | { |
46 | { |
39 | strcpy(log, "/HD1/2/i915.log"); |
47 | strcpy(log, "/RD/1/DRIVERS/i915.log"); |
40 | 48 | ||
41 | if(!dbg_open(log)) |
49 | if(!dbg_open(log)) |
42 | { |
50 | { |
43 | printf("Can't open %s\nExit\n", log); |
51 | printf("Can't open %s\nExit\n", log); |
44 | return 0; |
52 | return 0; |
45 | }; |
53 | }; |
46 | } |
54 | } |
47 | dbgprintf("i915 RC01 cmdline %s\n", cmdline); |
55 | dbgprintf("i915_early_preview second edition\n cmdline: %s\n", cmdline); |
48 | 56 | ||
49 | enum_pci_devices(); |
57 | enum_pci_devices(); |
50 | 58 | ||
51 | err = i915_init(); |
59 | err = i915_init(); |
52 | 60 | ||
53 | if(err) |
61 | if(err) |
54 | { |
62 | { |
55 | dbgprintf("Epic Fail :(/n"); |
63 | dbgprintf("Epic Fail :(/n"); |
56 | 64 | ||
57 | }; |
65 | }; |
58 | 66 | ||
59 | err = RegService("DISPLAY", display_handler); |
67 | err = RegService("DISPLAY", display_handler); |
60 | 68 | ||
61 | if( err != 0) |
69 | if( err != 0) |
62 | dbgprintf("Set DISPLAY handler\n"); |
70 | dbgprintf("Set DISPLAY handler\n"); |
63 | 71 | ||
64 | return err; |
72 | return err; |
65 | }; |
73 | }; |
66 | 74 | ||
67 | #define API_VERSION 0x01000100 |
75 | #define API_VERSION 0x01000100 |
68 | 76 | ||
69 | #define SRV_GETVERSION 0 |
77 | #define SRV_GETVERSION 0 |
70 | #define SRV_ENUM_MODES 1 |
78 | #define SRV_ENUM_MODES 1 |
71 | #define SRV_SET_MODE 2 |
79 | #define SRV_SET_MODE 2 |
72 | 80 | ||
73 | #define SRV_CREATE_VIDEO 9 |
81 | #define SRV_CREATE_VIDEO 9 |
74 | #define SRV_BLIT_VIDEO 10 |
82 | #define SRV_BLIT_VIDEO 10 |
75 | #define SRV_CREATE_BITMAP 11 |
83 | #define SRV_CREATE_BITMAP 11 |
76 | 84 | ||
77 | #define check_input(size) \ |
85 | #define check_input(size) \ |
78 | if( unlikely((inp==NULL)||(io->inp_size != (size))) ) \ |
86 | if( unlikely((inp==NULL)||(io->inp_size != (size))) ) \ |
79 | break; |
87 | break; |
80 | 88 | ||
81 | #define check_output(size) \ |
89 | #define check_output(size) \ |
82 | if( unlikely((outp==NULL)||(io->out_size != (size))) ) \ |
90 | if( unlikely((outp==NULL)||(io->out_size != (size))) ) \ |
83 | break; |
91 | break; |
84 | 92 | ||
85 | int _stdcall display_handler(ioctl_t *io) |
93 | int _stdcall display_handler(ioctl_t *io) |
86 | { |
94 | { |
87 | int retval = -1; |
95 | int retval = -1; |
88 | u32_t *inp; |
96 | u32_t *inp; |
89 | u32_t *outp; |
97 | u32_t *outp; |
90 | 98 | ||
91 | inp = io->input; |
99 | inp = io->input; |
92 | outp = io->output; |
100 | outp = io->output; |
93 | 101 | ||
94 | switch(io->io_code) |
102 | switch(io->io_code) |
95 | { |
103 | { |
96 | case SRV_GETVERSION: |
104 | case SRV_GETVERSION: |
97 | check_output(4); |
105 | check_output(4); |
98 | *outp = API_VERSION; |
106 | *outp = API_VERSION; |
99 | retval = 0; |
107 | retval = 0; |
100 | break; |
108 | break; |
101 | 109 | ||
102 | case SRV_ENUM_MODES: |
110 | case SRV_ENUM_MODES: |
103 | dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
111 | dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
104 | inp, io->inp_size, io->out_size ); |
112 | inp, io->inp_size, io->out_size ); |
105 | // check_output(4); |
113 | check_output(4); |
106 | // check_input(*outp * sizeof(videomode_t)); |
114 | // check_input(*outp * sizeof(videomode_t)); |
107 | if( i915_modeset) |
115 | if( i915_modeset) |
108 | retval = get_videomodes((videomode_t*)inp, outp); |
116 | retval = get_videomodes((videomode_t*)inp, outp); |
109 | break; |
117 | break; |
110 | 118 | ||
111 | case SRV_SET_MODE: |
119 | case SRV_SET_MODE: |
112 | dbgprintf("SRV_SET_MODE inp %x inp_size %x\n", |
120 | dbgprintf("SRV_SET_MODE inp %x inp_size %x\n", |
113 | inp, io->inp_size); |
121 | inp, io->inp_size); |
114 | check_input(sizeof(videomode_t)); |
122 | check_input(sizeof(videomode_t)); |
115 | if( i915_modeset ) |
123 | if( i915_modeset ) |
116 | retval = set_user_mode((videomode_t*)inp); |
124 | retval = set_user_mode((videomode_t*)inp); |
117 | break; |
125 | break; |
118 | - | ||
119 | /* |
126 | |
- | 127 | case SRV_CREATE_VIDEO: |
|
- | 128 | check_input(2); |
|
120 | case SRV_CREATE_VIDEO: |
129 | check_output(4); |
121 | retval = r600_create_video(inp[0], inp[1], outp); |
130 | retval = create_video(inp[0], inp[1], outp); |
122 | break; |
131 | break; |
123 | 132 | ||
124 | case SRV_BLIT_VIDEO: |
133 | case SRV_BLIT_VIDEO: |
125 | r600_video_blit( ((uint64_t*)inp)[0], inp[2], inp[3], |
134 | video_blit( ((uint64_t*)inp)[0], inp[2], inp[3], |
126 | inp[4], inp[5], inp[6]); |
135 | inp[4], inp[5], inp[6]); |
127 | 136 | ||
128 | retval = 0; |
137 | retval = 0; |
129 | break; |
138 | break; |
130 | 139 | ||
131 | case SRV_CREATE_BITMAP: |
140 | case SRV_CREATE_BITMAP: |
132 | check_input(8); |
141 | check_input(8); |
133 | check_output(4); |
142 | check_output(4); |
134 | retval = create_bitmap(outp, inp[0], inp[1]); |
143 | retval = create_bitmap((bitmap_t**)outp, inp[0], inp[1]); |
135 | break; |
144 | break; |
136 | */ |
145 | |
137 | }; |
146 | }; |
138 | 147 | ||
139 | return retval; |
148 | return retval; |
140 | } |
149 | } |
141 | 150 | ||
142 | 151 | ||
143 | #define PCI_CLASS_REVISION 0x08 |
152 | #define PCI_CLASS_REVISION 0x08 |
144 | #define PCI_CLASS_DISPLAY_VGA 0x0300 |
153 | #define PCI_CLASS_DISPLAY_VGA 0x0300 |
145 | #define PCI_CLASS_BRIDGE_HOST 0x0600 |
154 | #define PCI_CLASS_BRIDGE_HOST 0x0600 |
146 | #define PCI_CLASS_BRIDGE_ISA 0x0601 |
155 | #define PCI_CLASS_BRIDGE_ISA 0x0601 |
147 | 156 | ||
148 | int pci_scan_filter(u32_t id, u32_t busnr, u32_t devfn) |
157 | int pci_scan_filter(u32_t id, u32_t busnr, u32_t devfn) |
149 | { |
158 | { |
150 | u16_t vendor, device; |
159 | u16_t vendor, device; |
151 | u32_t class; |
160 | u32_t class; |
152 | int ret = 0; |
161 | int ret = 0; |
153 | 162 | ||
154 | vendor = id & 0xffff; |
163 | vendor = id & 0xffff; |
155 | device = (id >> 16) & 0xffff; |
164 | device = (id >> 16) & 0xffff; |
156 | 165 | ||
157 | if(vendor == 0x8086) |
166 | if(vendor == 0x8086) |
158 | { |
167 | { |
159 | class = PciRead32(busnr, devfn, PCI_CLASS_REVISION); |
168 | class = PciRead32(busnr, devfn, PCI_CLASS_REVISION); |
160 | class >>= 16; |
169 | class >>= 16; |
161 | 170 | ||
162 | if( (class == PCI_CLASS_DISPLAY_VGA) || |
171 | if( (class == PCI_CLASS_DISPLAY_VGA) || |
163 | (class == PCI_CLASS_BRIDGE_HOST) || |
172 | (class == PCI_CLASS_BRIDGE_HOST) || |
164 | (class == PCI_CLASS_BRIDGE_ISA)) |
173 | (class == PCI_CLASS_BRIDGE_ISA)) |
165 | ret = 1; |
174 | ret = 1; |
166 | } |
175 | } |
167 | return ret; |
176 | return ret; |
168 | }; |
177 | }; |
- | 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 |