Mercurial > mplayer.hg
annotate drivers/mga_vid_test.c @ 22727:82c405252244
Make sure bogus parameter will not be ignored by user.
author | voroshil |
---|---|
date | Mon, 19 Mar 2007 12:28:53 +0000 |
parents | aee789fa2d07 |
children | 6635801bbf1b |
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> |
6245
aee789fa2d07
When compiling mga_vid_test.c, memcpy() is subject to an implicit
jaf
parents:
854
diff
changeset
|
20 #include <string.h> |
1 | 21 #include "mga_vid.h" |
22 | |
23 mga_vid_config_t config; | |
24 uint8_t *mga_vid_base; | |
25 uint32_t is_g400; | |
26 | |
27 #define SRC_IMAGE_WIDTH 256 | |
28 #define SRC_IMAGE_HEIGHT 256 | |
29 | |
30 uint8_t y_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
31 uint8_t cr_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
32 uint8_t cb_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
33 | |
34 | |
35 void | |
36 write_frame_g200(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
37 { | |
38 uint8_t *dest; | |
39 uint32_t bespitch,h,w; | |
40 | |
41 dest = mga_vid_base; | |
42 bespitch = (config.src_width + 31) & ~31; | |
43 | |
44 for(h=0; h < config.src_height; h++) | |
45 { | |
46 memcpy(dest, y, config.src_width); | |
47 y += config.src_width; | |
48 dest += bespitch; | |
49 } | |
50 | |
51 for(h=0; h < config.src_height/2; h++) | |
52 { | |
53 for(w=0; w < config.src_width/2; w++) | |
54 { | |
55 *dest++ = *cb++; | |
56 *dest++ = *cr++; | |
57 } | |
58 dest += bespitch - config.src_width; | |
59 } | |
60 } | |
61 | |
62 void | |
63 write_frame_g400(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
64 { | |
65 uint8_t *dest; | |
66 uint32_t bespitch,h; | |
67 | |
68 dest = mga_vid_base; | |
69 bespitch = (config.src_width + 31) & ~31; | |
70 | |
71 for(h=0; h < config.src_height; h++) | |
72 { | |
73 memcpy(dest, y, config.src_width); | |
74 y += config.src_width; | |
75 dest += bespitch; | |
76 } | |
77 | |
78 for(h=0; h < config.src_height/2; h++) | |
79 { | |
80 memcpy(dest, cb, config.src_width/2); | |
81 cb += config.src_width/2; | |
82 dest += bespitch/2; | |
83 } | |
84 | |
85 for(h=0; h < config.src_height/2; h++) | |
86 { | |
87 memcpy(dest, cr, config.src_width/2); | |
88 cr += config.src_width/2; | |
89 dest += bespitch/2; | |
90 } | |
91 } | |
92 | |
93 void write_frame(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
94 { | |
95 if(is_g400) | |
96 write_frame_g400(y,cr,cb); | |
97 else | |
98 write_frame_g200(y,cr,cb); | |
99 } | |
100 | |
101 void | |
102 draw_cool_pattern(void) | |
103 { | |
104 int i,x,y; | |
105 | |
106 i = 0; | |
107 for (y=0; y<config.src_height; y++) { | |
108 for (x=0; x<config.src_width; x++) { | |
109 y_image[i++] = x*x/2 + y*y/2 - 128; | |
110 } | |
111 } | |
112 | |
113 i = 0; | |
114 for (y=0; y<config.src_height/2; y++) | |
115 for (x=0; x<config.src_width/2; x++) | |
116 { | |
117 cr_image[i++] = x - 128; | |
118 } | |
119 | |
120 i = 0; | |
121 for (y=0; y<config.src_height/2; y++) | |
122 for (x=0; x<config.src_width/2; x++) | |
123 { | |
124 cb_image[i++] = y - 128; | |
125 } | |
126 } | |
127 | |
128 void | |
129 draw_color_blend(void) | |
130 { | |
131 int i,x,y; | |
132 | |
133 i = 0; | |
134 for (y=0; y<config.src_height; y++) { | |
135 for (x=0; x<config.src_width; x++) { | |
136 y_image[i++] = 0; | |
137 } | |
138 } | |
139 | |
140 i = 0; | |
141 for (y=0; y<config.src_height/2; y++) | |
142 for (x=0; x<config.src_width/2; x++) | |
143 { | |
144 cr_image[i++] = x - 128; | |
145 } | |
146 | |
147 i = 0; | |
148 for (y=0; y<config.src_height/2; y++) | |
149 for (x=0; x<config.src_width/2; x++) | |
150 { | |
151 cb_image[i++] = y - 128; | |
152 } | |
153 } | |
154 | |
155 | |
156 int | |
157 main(int argc, char *argv[]) | |
158 { | |
159 int f; | |
160 | |
161 f = open("/dev/mga_vid",O_RDWR); | |
162 | |
163 if(f == -1) | |
164 { | |
165 fprintf(stderr,"Couldn't open driver\n"); | |
166 exit(1); | |
167 } | |
168 | |
76 | 169 config.version = MGA_VID_VERSION; |
1 | 170 config.src_width = SRC_IMAGE_WIDTH; |
171 config.src_height= SRC_IMAGE_HEIGHT; | |
172 config.dest_width = SRC_IMAGE_WIDTH; | |
173 config.dest_height = SRC_IMAGE_HEIGHT; | |
174 config.x_org= 10; | |
175 config.y_org= 10; | |
176 config.colkey_on = 0; | |
177 config.format = MGA_VID_FORMAT_YV12; | |
76 | 178 config.frame_size=SRC_IMAGE_WIDTH*SRC_IMAGE_HEIGHT*2; |
179 config.num_frames=1; | |
1 | 180 |
181 if (ioctl(f,MGA_VID_CONFIG,&config)) | |
182 { | |
183 perror("Error in config ioctl"); | |
184 } | |
185 | |
186 if (config.card_type == MGA_G200) | |
187 { | |
188 printf("Testing MGA G200 Backend Scaler with %d MB of RAM\n", config.ram_size); | |
189 is_g400 = 0; | |
190 } | |
191 else | |
192 { | |
193 printf("Testing MGA G400 Backend Scaler with %d MB of RAM\n", config.ram_size); | |
194 is_g400 = 1; | |
195 } | |
196 | |
197 ioctl(f,MGA_VID_ON,0); | |
198 mga_vid_base = (uint8_t*)mmap(0,256 * 4096,PROT_WRITE,MAP_SHARED,f,0); | |
199 printf("mga_vid_base = %8p\n",mga_vid_base); | |
200 | |
201 | |
202 //memset(y_image,80,256 * 128); | |
203 //memset(cr_image,80,256/2 * 20); | |
204 //memset(cb_image,80,256/2 * 20); | |
205 write_frame(y_image,cr_image,cb_image); | |
206 printf("(1) There should be a green square, offset by 10 pixels from\n" | |
207 " the upper left corner displayed\n"); | |
208 sleep(3); | |
209 | |
210 | |
211 draw_cool_pattern(); | |
212 write_frame(y_image,cr_image,cb_image); | |
213 printf("(2) There should be a cool mosaic like pattern now.\n"); | |
214 sleep(3); | |
215 | |
216 draw_color_blend(); | |
217 write_frame(y_image,cr_image,cb_image); | |
218 printf("(3) There should be a color blend with black, red, purple, blue\n" | |
219 " corners (starting top left going CW)\n"); | |
220 sleep(3); | |
221 | |
222 ioctl(f,MGA_VID_OFF,0); | |
223 | |
224 close(f); | |
225 return 0; | |
226 } |