Mercurial > mplayer.hg
annotate drivers/mga_vid_test.c @ 2407:2e4c17f4a744
More verbosing
author | nick |
---|---|
date | Tue, 23 Oct 2001 07:05:05 +0000 |
parents | 76ca00724e12 |
children | aee789fa2d07 |
rev | line source |
---|---|
1 | 1 /* |
2 * | |
3 * mga_vid_test.c | |
4 * | |
5 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca> | |
6 * Sept 1999 | |
7 * | |
8 * This software has been released under the terms of the GNU Public | |
9 * license. See http://www.gnu.org/copyleft/gpl.html for details. | |
10 */ | |
11 | |
12 //#include <stddef.h> | |
13 #include <stdio.h> | |
14 #include <stdlib.h> | |
15 #include <sys/ioctl.h> | |
16 #include <unistd.h> | |
17 #include <fcntl.h> | |
18 #include <sys/mman.h> | |
854
76ca00724e12
gcc warnings fixed - patch by Aelius aelius@wish.net
arpi_esp
parents:
76
diff
changeset
|
19 #include <inttypes.h> |
1 | 20 #include "mga_vid.h" |
21 | |
22 mga_vid_config_t config; | |
23 uint8_t *mga_vid_base; | |
24 uint32_t is_g400; | |
25 | |
26 #define SRC_IMAGE_WIDTH 256 | |
27 #define SRC_IMAGE_HEIGHT 256 | |
28 | |
29 uint8_t y_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
30 uint8_t cr_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
31 uint8_t cb_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
32 | |
33 | |
34 void | |
35 write_frame_g200(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
36 { | |
37 uint8_t *dest; | |
38 uint32_t bespitch,h,w; | |
39 | |
40 dest = mga_vid_base; | |
41 bespitch = (config.src_width + 31) & ~31; | |
42 | |
43 for(h=0; h < config.src_height; h++) | |
44 { | |
45 memcpy(dest, y, config.src_width); | |
46 y += config.src_width; | |
47 dest += bespitch; | |
48 } | |
49 | |
50 for(h=0; h < config.src_height/2; h++) | |
51 { | |
52 for(w=0; w < config.src_width/2; w++) | |
53 { | |
54 *dest++ = *cb++; | |
55 *dest++ = *cr++; | |
56 } | |
57 dest += bespitch - config.src_width; | |
58 } | |
59 } | |
60 | |
61 void | |
62 write_frame_g400(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
63 { | |
64 uint8_t *dest; | |
65 uint32_t bespitch,h; | |
66 | |
67 dest = mga_vid_base; | |
68 bespitch = (config.src_width + 31) & ~31; | |
69 | |
70 for(h=0; h < config.src_height; h++) | |
71 { | |
72 memcpy(dest, y, config.src_width); | |
73 y += config.src_width; | |
74 dest += bespitch; | |
75 } | |
76 | |
77 for(h=0; h < config.src_height/2; h++) | |
78 { | |
79 memcpy(dest, cb, config.src_width/2); | |
80 cb += config.src_width/2; | |
81 dest += bespitch/2; | |
82 } | |
83 | |
84 for(h=0; h < config.src_height/2; h++) | |
85 { | |
86 memcpy(dest, cr, config.src_width/2); | |
87 cr += config.src_width/2; | |
88 dest += bespitch/2; | |
89 } | |
90 } | |
91 | |
92 void write_frame(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
93 { | |
94 if(is_g400) | |
95 write_frame_g400(y,cr,cb); | |
96 else | |
97 write_frame_g200(y,cr,cb); | |
98 } | |
99 | |
100 void | |
101 draw_cool_pattern(void) | |
102 { | |
103 int i,x,y; | |
104 | |
105 i = 0; | |
106 for (y=0; y<config.src_height; y++) { | |
107 for (x=0; x<config.src_width; x++) { | |
108 y_image[i++] = x*x/2 + y*y/2 - 128; | |
109 } | |
110 } | |
111 | |
112 i = 0; | |
113 for (y=0; y<config.src_height/2; y++) | |
114 for (x=0; x<config.src_width/2; x++) | |
115 { | |
116 cr_image[i++] = x - 128; | |
117 } | |
118 | |
119 i = 0; | |
120 for (y=0; y<config.src_height/2; y++) | |
121 for (x=0; x<config.src_width/2; x++) | |
122 { | |
123 cb_image[i++] = y - 128; | |
124 } | |
125 } | |
126 | |
127 void | |
128 draw_color_blend(void) | |
129 { | |
130 int i,x,y; | |
131 | |
132 i = 0; | |
133 for (y=0; y<config.src_height; y++) { | |
134 for (x=0; x<config.src_width; x++) { | |
135 y_image[i++] = 0; | |
136 } | |
137 } | |
138 | |
139 i = 0; | |
140 for (y=0; y<config.src_height/2; y++) | |
141 for (x=0; x<config.src_width/2; x++) | |
142 { | |
143 cr_image[i++] = x - 128; | |
144 } | |
145 | |
146 i = 0; | |
147 for (y=0; y<config.src_height/2; y++) | |
148 for (x=0; x<config.src_width/2; x++) | |
149 { | |
150 cb_image[i++] = y - 128; | |
151 } | |
152 } | |
153 | |
154 | |
155 int | |
156 main(int argc, char *argv[]) | |
157 { | |
158 int f; | |
159 | |
160 f = open("/dev/mga_vid",O_RDWR); | |
161 | |
162 if(f == -1) | |
163 { | |
164 fprintf(stderr,"Couldn't open driver\n"); | |
165 exit(1); | |
166 } | |
167 | |
76 | 168 config.version = MGA_VID_VERSION; |
1 | 169 config.src_width = SRC_IMAGE_WIDTH; |
170 config.src_height= SRC_IMAGE_HEIGHT; | |
171 config.dest_width = SRC_IMAGE_WIDTH; | |
172 config.dest_height = SRC_IMAGE_HEIGHT; | |
173 config.x_org= 10; | |
174 config.y_org= 10; | |
175 config.colkey_on = 0; | |
176 config.format = MGA_VID_FORMAT_YV12; | |
76 | 177 config.frame_size=SRC_IMAGE_WIDTH*SRC_IMAGE_HEIGHT*2; |
178 config.num_frames=1; | |
1 | 179 |
180 if (ioctl(f,MGA_VID_CONFIG,&config)) | |
181 { | |
182 perror("Error in config ioctl"); | |
183 } | |
184 | |
185 if (config.card_type == MGA_G200) | |
186 { | |
187 printf("Testing MGA G200 Backend Scaler with %d MB of RAM\n", config.ram_size); | |
188 is_g400 = 0; | |
189 } | |
190 else | |
191 { | |
192 printf("Testing MGA G400 Backend Scaler with %d MB of RAM\n", config.ram_size); | |
193 is_g400 = 1; | |
194 } | |
195 | |
196 ioctl(f,MGA_VID_ON,0); | |
197 mga_vid_base = (uint8_t*)mmap(0,256 * 4096,PROT_WRITE,MAP_SHARED,f,0); | |
198 printf("mga_vid_base = %8p\n",mga_vid_base); | |
199 | |
200 | |
201 //memset(y_image,80,256 * 128); | |
202 //memset(cr_image,80,256/2 * 20); | |
203 //memset(cb_image,80,256/2 * 20); | |
204 write_frame(y_image,cr_image,cb_image); | |
205 printf("(1) There should be a green square, offset by 10 pixels from\n" | |
206 " the upper left corner displayed\n"); | |
207 sleep(3); | |
208 | |
209 | |
210 draw_cool_pattern(); | |
211 write_frame(y_image,cr_image,cb_image); | |
212 printf("(2) There should be a cool mosaic like pattern now.\n"); | |
213 sleep(3); | |
214 | |
215 draw_color_blend(); | |
216 write_frame(y_image,cr_image,cb_image); | |
217 printf("(3) There should be a color blend with black, red, purple, blue\n" | |
218 " corners (starting top left going CW)\n"); | |
219 sleep(3); | |
220 | |
221 ioctl(f,MGA_VID_OFF,0); | |
222 | |
223 close(f); | |
224 return 0; | |
225 } |