20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 * DEALINGS IN THE SOFTWARE. |
21 * DEALINGS IN THE SOFTWARE. |
23 */ |
22 */ |
24 |
23 |
25 #include <sys/types.h> |
24 #include "libvtsSUNWefb.h" |
26 #include <errno.h> |
25 |
27 #include <signal.h> /* signal() */ |
26 /* |
28 #include <stdio.h> |
27 * efb_test_chip() |
29 #include <stropts.h> /* ioctl() */ |
28 * |
30 #include <unistd.h> /* ioctl(), sleep() */ |
29 * Test Chip, functional tests. |
31 #include <sys/mman.h> |
30 */ |
32 |
31 |
33 #include "gfx_common.h" /* VTS Graphics Test common routines */ |
32 return_packet * |
34 #include "graphicstest.h" |
33 efb_test_chip( |
35 #include "gfx_vts.h" /* VTS Graphics Test common routines */ |
34 register int const fd) |
36 #include "efb.h" |
35 { |
37 |
36 static return_packet rp; |
38 void |
37 |
39 box(struct efb_info *pEFB, int x1, int y1, int x2, int y2, unsigned int color) |
38 memset(&rp, 0, sizeof (return_packet)); |
40 { |
39 |
41 int tmp; |
40 if (gfx_vts_debug_mask & GRAPHICS_VTS_CHIP_OFF) |
42 int width; |
41 return (&rp); |
43 int height; |
42 |
44 unsigned int v; |
43 TraceMessage(VTS_DEBUG, "efb_test_chip", "efb_test_chip running\n"); |
45 |
44 |
46 width = x2 - x1; |
45 efb_block_signals(); |
47 height = y2 - y1; |
46 |
48 |
47 efb_lock_display(); |
49 if ((width <= 0) || (height <= 0)) { |
48 |
50 #ifdef DEBUG |
49 chip_test(&rp, fd); |
51 printf("x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2); |
50 |
52 #endif |
51 efb_unlock_display(); |
53 return; |
52 |
54 } |
53 efb_restore_signals(); |
55 |
54 |
56 efb_wait_for_fifo(pEFB, 5); |
55 TraceMessage(VTS_DEBUG, "efb_test_chip", "efb_test_chip completed\n"); |
57 |
56 |
58 REGW(RADEON_DP_WRITE_MASK, 0xffffffff); |
57 return (&rp); |
59 REGW(RADEON_DP_CNTL, |
58 |
60 (RADEON_DST_X_LEFT_TO_RIGHT | RADEON_DST_Y_TOP_TO_BOTTOM)); |
59 } /* efb_test_chip() */ |
61 |
60 |
62 REGW(RADEON_DP_BRUSH_FRGD_CLR, color); |
61 |
63 REGW(DST_Y_X, x1 << DST_Y_X__DST_X__SHIFT | |
62 int |
64 y1 << DST_Y_X__DST_Y__SHIFT) ; |
63 chip_test( |
65 REGW(DST_WIDTH_HEIGHT, |
64 register return_packet *const rp, |
66 height << DST_WIDTH_HEIGHT__DST_HEIGHT__SHIFT | |
65 register int const fd) |
67 width << DST_WIDTH_HEIGHT__DST_WIDTH__SHIFT ) ; |
66 { |
68 |
67 register uint_t black; |
69 } /* box() */ |
68 register uint_t white; |
70 |
69 |
71 void |
70 memset(&efb_info, 0, sizeof (efb_info)); |
72 line(struct efb_info *pEFB, |
71 efb_info.efb_fd = fd; |
73 int x1, |
72 |
74 int y1, |
73 /* |
75 int x2, |
74 * map the registers & frame buffers memory |
76 int y2, |
75 */ |
77 unsigned int color |
76 if (efb_map_mem(rp, GRAPHICS_ERR_CHIP) != 0) |
78 ) |
77 return (-1); |
79 { |
78 |
80 efb_wait_for_fifo(pEFB, 5); |
79 if (efb_init_info(rp, GRAPHICS_ERR_CHIP) != 0) { |
81 |
80 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
82 REGW(RADEON_DP_WRITE_MASK, 0xffffffff); |
81 return (-1); |
83 REGW(RADEON_DP_CNTL, |
82 } |
84 (RADEON_DST_X_LEFT_TO_RIGHT | RADEON_DST_Y_TOP_TO_BOTTOM)); |
83 |
85 |
84 if (!efb_init_graphics()) { |
86 REGW(RADEON_DP_BRUSH_FRGD_CLR, color); |
85 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
87 REGW(DST_LINE_START, |
86 return (-1); |
88 (x1 << DST_LINE_START__DST_START_X__SHIFT | y1 << DST_LINE_START__DST_START_Y__SHIFT)); |
87 } |
89 REGW(DST_LINE_END, |
88 |
90 (x2 << DST_LINE_END__DST_END_X__SHIFT | y2 << DST_LINE_END__DST_END_Y__SHIFT)); |
89 efb_save_palet(); |
91 |
90 efb_set_palet(); |
92 } /* line() */ |
91 |
93 |
92 /* |
94 #define NBOX 100 |
93 * Clear screen black |
95 |
94 */ |
96 void |
95 black = efb_color(0x00, 0x00, 0x00); |
97 draw_cascaded_box(struct efb_info *pEFB, int width, int height) |
96 if (!efb_fill_solid_rect(0, 0, |
98 { |
97 efb_info.efb_width, efb_info.efb_height, black)) { |
99 unsigned int x1; |
98 efb_restore_palet(); |
100 unsigned int y1; |
99 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
101 unsigned int x2; |
100 return (-1); |
102 unsigned int y2; |
101 } |
103 unsigned int w; |
102 |
104 unsigned int h; |
103 if (!efb_wait_idle()) { |
105 unsigned int i, j; |
104 efb_restore_palet(); |
106 unsigned int k = 0; |
105 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
107 unsigned int cinc = 0; |
106 return (-1); |
108 unsigned int xinc, yinc; |
107 } |
109 |
108 |
110 cinc = 256 / NBOX; |
109 efb_flush_pixel_cache(); |
111 xinc = width / (NBOX * 2); |
110 |
112 yinc = height / (NBOX * 2); |
111 /* |
113 x1 = y1 = 0; |
112 * line test |
114 |
113 */ |
115 for (i = 0; i < NBOX; i++) { |
114 if (!draw_lines(efb_info.efb_width, efb_info.efb_height)) { |
116 |
115 efb_restore_palet(); |
117 x2 = width - x1; |
116 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
118 y2 = height - y1; |
117 return (-1); |
119 |
118 } |
120 j = i * cinc; |
119 |
121 |
120 if (!efb_wait_idle()) { |
122 k = (j<<24 | j<<16 | j<<8 | j); |
121 efb_restore_palet(); |
123 |
122 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
124 box(pEFB, x1, y1, x2, y2, k); |
123 return (-1); |
125 |
124 } |
126 x1 += xinc; |
125 |
127 y1 += yinc; |
126 efb_flush_pixel_cache(); |
128 } |
127 |
129 |
128 if (efb_sleep(2)) { |
130 } /* draw_cascaded_box() */ |
129 efb_restore_palet(); |
131 |
130 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
132 |
131 return (-1); |
133 #define NLINE 128 |
132 } |
134 |
133 |
135 void |
134 /* |
136 draw_lines(struct efb_info *pEFB, int width, int height) |
135 * fill rectangle test |
137 { |
136 */ |
138 unsigned int x1; |
137 if (!draw_cascaded_box(efb_info.efb_width, efb_info.efb_height)) { |
139 unsigned int y1; |
138 efb_restore_palet(); |
140 unsigned int x2; |
139 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
141 unsigned int y2; |
140 return (-1); |
142 int k; |
141 } |
143 int i; |
142 |
144 unsigned int xinc, yinc; |
143 if (!efb_wait_idle()) { |
145 |
144 efb_restore_palet(); |
146 xinc = width / NLINE; |
145 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
147 yinc = height / NLINE; |
146 return (-1); |
148 x1 = y1 = 0; |
147 } |
149 |
148 |
150 |
149 efb_flush_pixel_cache(); |
151 k = 0; |
150 |
152 x1 = 0; |
151 if (efb_sleep(2)) { |
153 y1 = 0; |
152 efb_restore_palet(); |
154 y2 = height; |
153 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
155 for (i = 0; i < NLINE; i++) { |
154 return (-1); |
156 k = 0x00af0000 | (i << 8) | i; |
155 } |
157 |
156 |
158 x2 = x1; |
157 /* Clear screen white */ |
159 |
158 |
160 line(pEFB, x1, y1, x2, y2, k); |
159 white = efb_color(0xff, 0xff, 0xff); |
161 |
160 |
162 x1 += xinc; |
161 /* |
163 } |
162 * Clear screen |
164 |
163 */ |
165 x1 = 0; |
164 if (!efb_fill_solid_rect(0, 0, |
166 x2 = width; |
165 efb_info.efb_width, efb_info.efb_height, white)) { |
167 y1 = 0; |
166 efb_restore_palet(); |
168 |
167 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
169 for (i = 0; i < NLINE; i++) { |
168 return (-1); |
170 k = 0x00af0000 | (i << 8) | i; |
169 } |
171 |
170 |
172 y2 = y1; |
171 if (!efb_wait_idle()) { |
173 |
172 efb_restore_palet(); |
174 line(pEFB, x1, y1, x2, y2, k); |
173 efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
175 |
174 return (-1); |
176 y1 += yinc; |
175 } |
177 } |
176 |
|
177 efb_flush_pixel_cache(); |
|
178 |
|
179 efb_sleep(2); |
|
180 |
|
181 efb_restore_palet(); |
|
182 |
|
183 if (efb_unmap_mem(rp, GRAPHICS_ERR_CHIP) != 0) |
|
184 return (-1); |
|
185 |
|
186 return (0); |
|
187 } /* chip_test() */ |
|
188 |
|
189 |
|
190 int |
|
191 draw_lines( |
|
192 register uint_t const width, |
|
193 register uint_t const height) |
|
194 { |
|
195 register uint_t x1; |
|
196 register uint_t y1; |
|
197 register uint_t x2; |
|
198 register uint_t y2; |
|
199 register uint_t color; |
|
200 register uint_t lineon; |
|
201 register uint_t const numlines = 128; |
|
202 |
|
203 for (lineon = 0; lineon < numlines; lineon++) { |
|
204 color = efb_color(0xaf, lineon, lineon); |
|
205 |
|
206 x1 = (uint_t)((width * lineon) / numlines); |
|
207 x2 = x1; |
|
208 y1 = 0; |
|
209 y2 = height; |
|
210 |
|
211 if (!efb_draw_solid_line(x1, y1, x2, y2, color)) |
|
212 return (0); |
|
213 } |
|
214 |
|
215 for (lineon = 0; lineon < numlines; lineon++) { |
|
216 color = efb_color(0xaf, lineon, lineon); |
|
217 |
|
218 x1 = 0; |
|
219 x2 = width; |
|
220 y1 = (uint_t)((height * lineon) / numlines); |
|
221 y2 = y1; |
|
222 |
|
223 if (!efb_draw_solid_line(x1, y1, x2, y2, color)) |
|
224 return (0); |
|
225 } |
|
226 return (1); |
178 } |
227 } |
179 |
228 |
180 int |
229 int |
181 efb_init_2D(struct efb_info *pEFB) |
230 draw_cascaded_box( |
182 { |
231 register uint_t const width, |
183 unsigned int pitch_offset; |
232 register uint_t const height) |
184 unsigned int pitch; |
233 { |
185 unsigned int offset; |
234 register uint_t x1; |
186 unsigned int bytepp; |
235 register uint_t y1; |
187 unsigned int gmc_bpp; |
236 register uint_t x2; |
188 unsigned int dp_datatype; |
237 register uint_t y2; |
189 unsigned int v; |
238 register uint_t color; |
190 int i; |
239 register uint_t recton; |
191 |
240 register uint_t const numrects = 256; |
192 switch (pEFB->bitsPerPixel) { |
241 |
193 case 8: |
242 for (recton = 0; recton < numrects; recton++) { |
194 gmc_bpp = GMC_DST_8BPP; |
243 |
195 dp_datatype = DST_8BPP | BRUSH_SOLIDCOLOR | SRC_DSTCOLOR; |
244 x1 = (uint_t)((width * recton) / 512); |
196 bytepp = 1; |
245 x2 = width - x1; |
197 break; |
246 |
198 case 32: |
247 y1 = (uint_t)((height * recton) / 512); |
199 gmc_bpp = GMC_DST_32BPP; |
248 y2 = height - y1; |
200 dp_datatype = DST_32BPP | BRUSH_SOLIDCOLOR | SRC_DSTCOLOR; |
249 |
201 bytepp = 4; |
250 color = efb_color(recton, recton, recton); |
202 break; |
251 |
203 } |
252 if (!efb_fill_solid_rect(x1, y1, x2, y2, color)) |
204 |
253 return (0); |
205 offset = REGR(CRTC_OFFSET) & 0x7ffffff; |
254 } |
206 pitch = REGR(CRTC_PITCH) & 0x7ff; |
255 |
207 |
256 return (1); |
208 pitch = pitch * 8; // was in groups of 8 pixels |
|
209 |
|
210 pitch_offset = |
|
211 ((pitch * bytepp / 64) << 22) | |
|
212 (offset / 1024); |
|
213 |
|
214 /* |
|
215 * Initialize GUI engine |
|
216 */ |
|
217 efb_wait_for_idle(pEFB); |
|
218 |
|
219 efb_wait_for_fifo(pEFB, 5); |
|
220 |
|
221 |
|
222 REGW(DEFAULT_PITCH_OFFSET, pitch_offset); |
|
223 REGW(RADEON_DST_PITCH_OFFSET, pitch_offset); |
|
224 REGW(RADEON_SRC_PITCH_OFFSET, pitch_offset); |
|
225 |
|
226 REGW(DEFAULT_SC_BOTTOM_RIGHT, |
|
227 (pEFB->screenHeight << 16) | |
|
228 (pEFB->screenWidth)); |
|
229 |
|
230 v = ( |
|
231 GMC_SRC_PITCH_OFFSET_DEFAULT | |
|
232 GMC_DST_PITCH_OFFSET_LEAVE | |
|
233 GMC_SRC_CLIP_DEFAULT | |
|
234 GMC_DST_CLIP_DEFAULT | |
|
235 GMC_BRUSH_SOLIDCOLOR | |
|
236 gmc_bpp | |
|
237 GMC_SRC_DSTCOLOR | |
|
238 RADEON_ROP3_P | |
|
239 GMC_WRITE_MASK_LEAVE); |
|
240 |
|
241 REGW(RADEON_DP_GUI_MASTER_CNTL, v); |
|
242 |
|
243 #ifdef DEBUG |
|
244 printf("v=0x%x\n", v); |
|
245 #endif |
|
246 } |
257 } |
247 |
258 |
248 |
|
249 |
|
250 |
|
251 void |
|
252 chip_test(return_packet *rp, int fd) |
|
253 { |
|
254 struct efb_info efb_info; |
|
255 struct efb_info *pEFB; |
|
256 unsigned int red; |
|
257 unsigned char *fbaddr; |
|
258 int i; |
|
259 int bytepp; |
|
260 int fb_offset, fb_pitch, fb_height, fb_width; |
|
261 |
|
262 pEFB = &efb_info; |
|
263 pEFB->fd = fd; |
|
264 |
|
265 /* |
|
266 * map the registers & frame buffers memory |
|
267 */ |
|
268 if (efb_map_mem(pEFB, rp, GRAPHICS_ERR_CHIP) == -1) { |
|
269 return; |
|
270 } |
|
271 |
|
272 /* |
|
273 * initialize efb info |
|
274 */ |
|
275 if (efb_init_info(pEFB) == -1) { |
|
276 return; |
|
277 } |
|
278 |
|
279 if (efb_init_2D(pEFB) == -1) { |
|
280 return; |
|
281 } |
|
282 |
|
283 |
|
284 /* |
|
285 * Clear screen |
|
286 */ |
|
287 box(pEFB, 0, 0, pEFB->screenWidth, pEFB->screenHeight, 0); |
|
288 efb_wait_for_idle(pEFB); |
|
289 efb_flush_pixel_cache(pEFB); |
|
290 sleep(2); |
|
291 |
|
292 /* |
|
293 * line test |
|
294 */ |
|
295 draw_lines(pEFB, pEFB->screenWidth, pEFB->screenHeight); |
|
296 efb_wait_for_idle(pEFB); |
|
297 efb_flush_pixel_cache(pEFB); |
|
298 sleep(1); |
|
299 |
|
300 /* |
|
301 * fill test |
|
302 */ |
|
303 draw_cascaded_box(pEFB, pEFB->screenWidth, pEFB->screenHeight); |
|
304 efb_wait_for_idle(pEFB); |
|
305 efb_flush_pixel_cache(pEFB); |
|
306 sleep(1); |
|
307 efb_wait_for_idle(pEFB); |
|
308 efb_flush_pixel_cache(pEFB); |
|
309 |
|
310 /* |
|
311 * Clear screen |
|
312 */ |
|
313 box(pEFB, 0, 0, pEFB->screenWidth, pEFB->screenHeight, 0xff); |
|
314 efb_wait_for_idle(pEFB); |
|
315 efb_flush_pixel_cache(pEFB); |
|
316 sleep(2); |
|
317 |
|
318 |
|
319 done: |
|
320 /* |
|
321 * Unmap the registers & frame buffers memory |
|
322 */ |
|
323 if (efb_unmap_mem(pEFB, rp, GRAPHICS_ERR_CHIP) == -1) { |
|
324 return; |
|
325 } |
|
326 |
|
327 |
|
328 if (close(fd) == -1) { |
|
329 gfx_vts_set_message(rp, 1, GRAPHICS_ERR_CHIP, "error closing device\n"); |
|
330 return; |
|
331 } |
|
332 |
|
333 } /* chip_test() */ |
|
334 |
|
335 |
|
336 /* End of chip.c */ |
259 /* End of chip.c */ |