Rev 1029 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1029 | serge | 1 | |
2 | { |
||
3 | local_pixmap_t *pixmap; |
||
4 | |||
5 | |||
6 | size_t size; |
||
7 | |||
8 | |||
9 | addr_t mem_dma = 0; |
||
10 | void *mapped; |
||
11 | |||
12 | |||
13 | (io->height == 0)|| (io->height > 2048)) |
||
14 | { |
||
15 | dbgprintf("Invalid pixmap size w:%d h:%d\n", io->width,io->height); |
||
16 | return ERR_PARAM; |
||
17 | }; |
||
18 | |||
19 | |||
20 | |||
21 | |||
22 | return ERR_PARAM; |
||
23 | |||
24 | |||
25 | size = pitch*io->height; |
||
26 | |||
27 | |||
28 | |||
29 | |||
30 | mem_local = rhd_mem_alloc(&rhd,RHD_MEM_FB,size); |
||
31 | mem_dma = mem_local + rhd.fbLocation; |
||
32 | } |
||
33 | else |
||
34 | mem_local = mem_dma = AllocPages( size >> 12 ); |
||
35 | |||
36 | |||
37 | dbgprintf("Not enough memory for pixmap\n"); |
||
38 | free(pixmap); |
||
39 | return ERR_PARAM; |
||
40 | }; |
||
41 | |||
42 | |||
43 | pixmap->local = mem_dma; |
||
44 | |||
45 | |||
46 | |||
47 | |||
48 | { |
||
49 | CommitPages(mapped, mem_dma|7|(1<<9), size); |
||
50 | |||
51 | |||
52 | io->pitch = pitch; |
||
53 | io->handle = (u32_t)pixmap; |
||
54 | |||
55 | |||
56 | pixmap->height = io->height; |
||
57 | pixmap->format = PICT_a8r8g8b8; |
||
58 | pixmap->flags = io->flags; |
||
59 | pixmap->pitch = pitch; |
||
60 | pixmap->mapped = mapped; |
||
61 | |||
62 | |||
63 | dbgprintf("width: %d height: %d\n",pixmap->width,pixmap->height ); |
||
64 | dbgprintf("map at %x\n", pixmap->mapped); |
||
65 | |||
66 | |||
67 | }; |
||
68 | rhd_mem_free(&rhd, RHD_MEM_FB, mem_local); |
||
69 | free(pixmap); |
||
70 | |||
71 | |||
72 | }; |
||
73 | |||
74 | |||
75 | |||
76 | { |
||
77 | local_pixmap_t *pixmap; |
||
78 | size_t size; |
||
79 | |||
80 | |||
81 | |||
82 | |||
83 | return ERR_PARAM; |
||
84 | else |
||
85 | pixmap = (local_pixmap_t*)io->handle; |
||
86 | |||
87 | |||
88 | |||
89 | |||
90 | UserFree(pixmap->mapped); |
||
91 | |||
92 | |||
93 | { |
||
94 | rhd_mem_free(&rhd,RHD_MEM_FB,pixmap->local-rhd.fbLocation); |
||
95 | } |
||
96 | else |
||
97 | { |
||
98 | count_t pages = size >> 12; |
||
99 | addr_t base = pixmap->local; |
||
100 | |||
101 | |||
102 | { |
||
103 | addr_t tmp; |
||
104 | // __asm__ __volatile__( |
||
105 | // "call *__imp__PageFree" |
||
106 | // :"=eax" (tmp):"a" (base) ); |
||
107 | // base+= 4096; |
||
108 | }; |
||
109 | } |
||
110 | |||
111 | |||
112 | |||
113 | |||
114 | io->pitch = 0; |
||
115 | io->mapped = NULL; |
||
116 | io->handle = 0; |
||
117 | |||
118 | |||
119 | }; |
||
120 | |||
121 | |||
122 | |||
123 | # define ATI_PCIGART_PAGE_MASK (~(ATI_PCIGART_PAGE_SIZE-1)) |
||
124 | |||
125 | |||
126 | #define ATI_PCIE_READ 0x8 |
||
127 | |||
128 | |||
129 | |||
130 | |||
131 | |||
132 | { |
||
133 | addr_t page_base; |
||
134 | |||
135 | |||
136 | { |
||
137 | page_base = base & ATI_PCIGART_PAGE_MASK; |
||
138 | |||
139 | |||
140 | page_base |= (upper_32_bits(base) & 0xff) << 24; |
||
141 | page_base |= ATI_PCIE_READ | ATI_PCIE_WRITE; |
||
142 | |||
143 | |||
144 | base+= 4096; |
||
145 | gart++; |
||
146 | } |
||
147 | __asm__ __volatile("sfence":::"memory"); |
||
148 | |||
149 | |||
150 | RADEON_PCIE_TX_GART_EN |
||
151 | | RADEON_PCIE_TX_GART_INVALIDATE_TLB); |
||
152 | } |
||
153 | |||
154 | |||
155 | { |
||
156 | u32_t tmp; |
||
157 | |||
158 | |||
159 | OUTREG(RADEON_AIC_CNTL, tmp & ~RADEON_PCIGART_TRANSLATE_EN); |
||
160 | |||
161 | |||
162 | { |
||
163 | *gart = base & ATI_PCIGART_PAGE_MASK; |
||
164 | base+= 4096; |
||
165 | gart++; |
||
166 | } |
||
167 | __asm__ __volatile("sfence":::"memory"); |
||
168 | |||
169 | |||
170 | OUTREG(RADEON_AIC_PT_BASE, rhd.gart_table_dma); |
||
171 | } |
||
172 | |||
173 | |||
174 | { |
||
175 | u32_t *gart = rhd.gart_table; |
||
176 | count_t pages = ((pixmap->height * pixmap->pitch+4095)&~4095)>>12; |
||
177 | addr_t base = pixmap->local; |
||
178 | |||
179 | |||
180 | bind_pcie(gart, base, pages); |
||
181 | else |
||
182 | bind_pci(gart, base, pages); |
||
183 | |||
184 | |||
185 | } |
||
186 | |||
187 | |||
188 | |||
189 | |||
190 | { |
||
191 | pixmap_t *pixmap; |
||
192 | size_t size; |
||
193 | void *usermap; |
||
194 | |||
195 | |||
196 | |||
197 | |||
198 | return ERR_PARAM; |
||
199 | else |
||
200 | pixmap = io->pixmap; |
||
201 | |||
202 | |||
203 | return ERR_PARAM; |
||
204 | |||
205 | |||
206 | if (usermap = UserAlloc(size)) |
||
207 | { |
||
208 | CommitPages(usermap, ((u32_t)pixmap->raw+rhd.PhisBase)|7|(1<<9), size); |
||
209 | pixmap->flags |= PX_LOCK; |
||
210 | pixmap->usermap = usermap; |
||
211 | io->usermap = usermap; |
||
212 | io->pitch = pixmap->pitch; |
||
213 | dbgprintf("map at %x\n", io->usermap); |
||
214 | |||
215 | |||
216 | } |
||
217 | else |
||
218 | return ERR_PARAM; |
||
219 | }; |
||
220 | |||
221 | |||
222 | { |
||
223 | pixmap_t *pixmap; |
||
224 | size_t size; |
||
225 | |||
226 | |||
227 | |||
228 | |||
229 | return ERR_PARAM; |
||
230 | else |
||
231 | pixmap = io->pixmap; |
||
232 | |||
233 | |||
234 | return ERR_PARAM; |
||
235 | |||
236 | |||
237 | |||
238 | |||
239 | ((u32_t)pixmap->usermap >= 0x80000000) || |
||
240 | ((u32_t)pixmap->usermap & 4095) |
||
241 | ) |
||
242 | return ERR_PARAM; |
||
243 | |||
244 | |||
245 | |||
246 | |||
247 | UserFree(pixmap->usermap); |
||
248 | pixmap->usermap = NULL; |
||
249 | pixmap->flags &= ~PX_LOCK; |
||
250 | io->usermap = NULL; |
||
251 | io->pitch = 0; |
||
252 | |||
253 | |||
254 | }; |
||
255 | |||
256 | |||
257 |