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 "libvtsSUNWast.h" /* VTS library definitions for ast device */ |
26 #include <errno.h> |
25 |
27 #include <signal.h> /* signal() */ |
26 /* |
28 #include <stdio.h> |
27 * ast_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 ast_test_chip( |
35 #include "gfx_vts.h" /* VTS Graphics Test common routines */ |
34 register int const fd) |
36 #include "ast.h" |
35 { |
37 |
36 static return_packet rp; |
38 void |
37 |
39 box(struct ast_info *pAST, 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 |
43 TraceMessage(VTS_DEBUG, "ast_test_chip", |
45 if (x2 < x1) { |
44 "ast_test_chip running\n"); |
46 tmp = x2; |
45 |
47 x2 = x1; |
46 ast_block_signals(); |
48 x1 = tmp; |
47 |
49 } |
48 ast_lock_display(); |
50 if (y2 < y1) { |
49 |
51 tmp = y2; |
50 chip_test(&rp, fd); |
52 y2 = y1; |
51 |
53 y1 = tmp; |
52 ast_unlock_display(); |
54 } |
53 |
55 |
54 ast_restore_signals(); |
56 width = x2 - x1; |
55 |
57 height = y2 - y1; |
56 TraceMessage(VTS_DEBUG, "ast_test_chip", |
58 |
57 "ast_test_chip completed\n"); |
59 ASTSetupForSolidFill(pAST, color, 0xf0); |
58 |
60 ASTSolidFillRect(pAST, x1, y1, width, height); |
59 return (&rp); |
61 |
60 |
62 } /* box() */ |
61 } /* ast_test_chip() */ |
63 |
62 |
64 void |
63 |
65 line(struct ast_info *pAST, |
64 int |
66 int x1, |
65 chip_test( |
67 int y1, |
66 register return_packet *const rp, |
68 int x2, |
67 register int const fd) |
69 int y2, |
68 { |
70 unsigned int color |
69 register uint_t black; |
71 ) |
70 register uint_t white; |
72 { |
71 |
73 ASTSetupForSolidLine(pAST, color, 0xf0); |
72 memset(&ast_info, 0, sizeof (ast_info)); |
74 ASTSolidLine(pAST, x1, y1, x2, y2); |
73 ast_info.ast_fd = fd; |
75 |
74 |
76 } /* line() */ |
75 if (ast_map_mem(rp, GRAPHICS_ERR_CHIP) != 0) |
77 |
76 return (-1); |
78 |
77 |
79 void |
78 if (ast_init_info(rp, GRAPHICS_ERR_CHIP) != 0) { |
80 draw_cascaded_box(struct ast_info *pAST, int width, int height) |
79 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
81 { |
80 return (-1); |
82 unsigned int x1; |
81 } |
83 unsigned int y1; |
82 |
84 unsigned int x2; |
83 if (ast_init_graphics() < 0) { |
85 unsigned int y2; |
84 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
86 unsigned int w; |
85 return (0); |
87 unsigned int h; |
86 } |
88 int i; |
87 |
89 unsigned int k = 0; |
88 if (ast_save_palet() < 0) { |
90 |
89 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
91 for (i = 0; i < 256; i++) { |
90 return (0); |
92 |
91 } |
93 x1 = (unsigned int)((width * i) / 512); |
92 |
94 x2 = width - x1; |
93 if (ast_set_palet() < 0) { |
95 w = x2 - x1; |
94 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
96 |
95 return (0); |
97 y1 = (unsigned int)((height * i) / 512); |
96 } |
98 y2 = height - y1; |
97 |
99 |
98 /* Clear screen black */ |
100 k = (i<<24 | i<<16 | i<<8 | i); |
99 |
101 |
100 black = ast_color(0x00, 0x00, 0x00); |
102 box(pAST, x1, y1, x2, y2, k); |
101 if (!ast_fill_solid_rect(0, 0, |
103 } |
102 ast_info.ast_width, ast_info.ast_height, black)) { |
104 |
103 ast_restore_palet(); |
105 } /* draw_cascaded_box() */ |
104 ast_finish_graphics(); |
106 |
105 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
107 |
106 return (-1); |
108 void |
107 } |
109 draw_lines(struct ast_info *pAST, int width, int height) |
108 |
110 { |
109 if (!ast_wait_idle()) { |
111 unsigned int x1; |
110 ast_restore_palet(); |
112 unsigned int y1; |
111 ast_finish_graphics(); |
113 unsigned int x2; |
112 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
114 unsigned int y2; |
113 return (-1); |
115 int k; |
114 } |
116 int i; |
115 |
117 int nlines = 128; |
116 /* line test */ |
118 |
117 |
119 k = 0; |
118 if (!draw_lines(ast_info.ast_width, ast_info.ast_height)) { |
120 for (i = 0; i < nlines; i++) { |
119 ast_restore_palet(); |
121 k = 0x00af0000 | (i << 8) | i; |
120 ast_finish_graphics(); |
122 |
121 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
123 x1 = (unsigned int)((width * i) / nlines); |
122 return (-1); |
124 x2 = x1; |
123 } |
125 y1 = 0; |
124 |
126 y2 = height; |
125 if (!ast_wait_idle()) { |
127 |
126 ast_restore_palet(); |
128 line(pAST, x1, y1, x2, y2, k); |
127 ast_finish_graphics(); |
129 } |
128 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
130 |
129 return (-1); |
131 for (i = 0; i < nlines; i++) { |
130 } |
132 k = 0x00af0000 | (i << 8) | i; |
131 |
133 |
132 if (ast_sleep(2)) { |
134 x1 = 0; |
133 ast_restore_palet(); |
135 x2 = width; |
134 ast_finish_graphics(); |
136 y1 = (unsigned int)((height * i) / nlines); |
135 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
137 y2 = y1; |
136 return (-1); |
138 |
137 } |
139 line(pAST, x1, y1, x2, y2, k); |
138 |
140 } |
139 /* fill rectangle test */ |
|
140 |
|
141 if (!draw_cascaded_box(ast_info.ast_width, ast_info.ast_height)) { |
|
142 ast_restore_palet(); |
|
143 ast_finish_graphics(); |
|
144 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
|
145 return (-1); |
|
146 } |
|
147 |
|
148 if (!ast_wait_idle()) { |
|
149 ast_restore_palet(); |
|
150 ast_finish_graphics(); |
|
151 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
|
152 return (-1); |
|
153 } |
|
154 |
|
155 if (ast_sleep(2)) { |
|
156 ast_restore_palet(); |
|
157 ast_finish_graphics(); |
|
158 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
|
159 return (-1); |
|
160 } |
|
161 |
|
162 /* Clear screen white */ |
|
163 |
|
164 white = ast_color(0xff, 0xff, 0xff); |
|
165 if (!ast_fill_solid_rect(0, 0, |
|
166 ast_info.ast_width, ast_info.ast_height, white)) { |
|
167 ast_restore_palet(); |
|
168 ast_finish_graphics(); |
|
169 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
|
170 return (-1); |
|
171 } |
|
172 |
|
173 if (!ast_wait_idle()) { |
|
174 ast_restore_palet(); |
|
175 ast_finish_graphics(); |
|
176 ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP); |
|
177 return (-1); |
|
178 } |
|
179 |
|
180 ast_sleep(2); |
|
181 |
|
182 ast_restore_palet(); |
|
183 ast_finish_graphics(); |
|
184 |
|
185 /* |
|
186 * Unmap the registers & frame buffers memory |
|
187 */ |
|
188 |
|
189 if (ast_unmap_mem(rp, GRAPHICS_ERR_CHIP) != 0) |
|
190 return (-1); |
|
191 |
|
192 return (0); |
141 } |
193 } |
142 |
194 int |
143 void |
195 draw_lines( |
144 chip_test(return_packet *rp, int fd) |
196 register uint_t const width, |
145 { |
197 register uint_t const height) |
146 struct ast_info ast_info; |
198 { |
147 struct ast_info *pAST; |
199 register uint_t x1; |
148 unsigned int red; |
200 register uint_t y1; |
149 unsigned char *fbaddr; |
201 register uint_t x2; |
150 int i; |
202 register uint_t y2; |
151 int bytepp; |
203 register uint_t color; |
152 int fb_offset, fb_pitch, fb_height, fb_width; |
204 register uint_t lineon; |
153 |
205 register uint_t const numlines = 128; |
154 pAST = &ast_info; |
206 |
155 pAST->fd = fd; |
207 for (lineon = 0; lineon < numlines; lineon++) { |
156 |
208 color = ast_color(0xaf, lineon, lineon); |
157 /* |
209 |
158 * map the registers & frame buffers memory |
210 x1 = (uint_t)((width * lineon) / numlines); |
159 */ |
211 x2 = x1; |
160 if (ast_map_mem(pAST, rp, GRAPHICS_ERR_CHIP) == -1) { |
212 y1 = 0; |
161 return; |
213 y2 = height; |
162 } |
214 |
163 |
215 if (!ast_draw_solid_line(x1, y1, x2, y2, color)) |
164 /* |
216 return (0); |
165 * initialize ast info |
217 } |
166 */ |
218 |
167 if (ast_init_info(pAST) == -1) { |
219 for (lineon = 0; lineon < numlines; lineon++) { |
168 return; |
220 color = ast_color(0xaf, lineon, lineon); |
169 } |
221 |
170 |
222 x1 = 0; |
171 /* |
223 x2 = width; |
172 * only support 32 bits depth for now |
224 y1 = (uint_t)((height * lineon) / numlines); |
173 */ |
225 y2 = y1; |
174 if (pAST->bytesPerPixel == 1) { |
226 |
175 goto done; |
227 if (!ast_draw_solid_line(x1, y1, x2, y2, color)) |
176 } |
228 return (0); |
177 |
229 } |
178 /* |
230 return (1); |
179 * enable 2D, initialize command queue |
231 } |
180 */ |
232 |
181 ASTEnable2D(pAST); |
233 int |
182 |
234 draw_cascaded_box( |
183 if (ASTInitCMDQ(pAST) == -1) { |
235 register uint_t const width, |
184 pAST->MMIO2D = 1; |
236 register uint_t const height) |
185 } else {; |
237 { |
186 ASTEnableCMDQ(pAST); |
238 register uint_t x1; |
187 } |
239 register uint_t y1; |
188 |
240 register uint_t x2; |
189 ASTSaveState(pAST); |
241 register uint_t y2; |
190 |
242 register uint_t color; |
191 /* |
243 register uint_t recton; |
192 * set clipping rectangle |
244 register uint_t const numrects = 256; |
193 */ |
245 |
194 ASTSetClippingRectangle(pAST, 0, 0, pAST->screenWidth, pAST->screenHeight); |
246 for (recton = 0; recton < numrects; recton++) { |
195 |
247 |
196 /* |
248 x1 = (uint_t)((width * recton) / 512); |
197 * Clear screen |
249 x2 = width - x1; |
198 */ |
250 |
199 box(pAST, 0, 0, pAST->screenWidth, pAST->screenHeight, 0); |
251 y1 = (uint_t)((height * recton) / 512); |
200 ASTWaitEngIdle(pAST); |
252 y2 = height - y1; |
201 |
253 |
202 /* |
254 color = ast_color(recton, recton, recton); |
203 * line test |
255 |
204 */ |
256 if (!ast_fill_solid_rect(x1, y1, x2, y2, color)) |
205 draw_lines(pAST, pAST->screenWidth, pAST->screenHeight); |
257 return (0); |
206 ASTWaitEngIdle(pAST); |
258 } |
207 sleep(2); |
259 |
208 |
260 return (1); |
209 /* |
261 } |
210 * fill test |
|
211 */ |
|
212 draw_cascaded_box(pAST, pAST->screenWidth, pAST->screenHeight); |
|
213 ASTWaitEngIdle(pAST); |
|
214 sleep(2); |
|
215 |
|
216 /* |
|
217 * Clear screen |
|
218 */ |
|
219 box(pAST, 0, 0, pAST->screenWidth, pAST->screenHeight, 0xff); |
|
220 ASTWaitEngIdle(pAST); |
|
221 sleep(2); |
|
222 |
|
223 ASTResetState(pAST); |
|
224 |
|
225 done: |
|
226 /* |
|
227 * Unmap the registers & frame buffers memory |
|
228 */ |
|
229 if (ast_unmap_mem(pAST, rp, GRAPHICS_ERR_CHIP) == -1) { |
|
230 return; |
|
231 } |
|
232 |
|
233 |
|
234 if (close(fd) == -1) { |
|
235 gfx_vts_set_message(rp, 1, GRAPHICS_ERR_CHIP, "error closing device\n"); |
|
236 return; |
|
237 } |
|
238 |
|
239 } /* chip_test() */ |
|
240 |
|
241 |
|
242 /* End of chip.c */ |
|