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