Mercurial > mplayer.hg
annotate drivers/mga_vid_test.c @ 27176:dc788f427b1c
dvd:// streams accept the device path in the url; patch by Mathieu SCHROETER mathieu.schroeter gamesover ch
author | nicodvb |
---|---|
date | Sat, 05 Jul 2008 12:45:55 +0000 |
parents | 03f571138664 |
children | 0f1b5b68af32 |
rev | line source |
---|---|
1 | 1 /* |
26003
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
2 * Copyright (C) 1999 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> |
1 | 3 * |
27027 | 4 * This file is part of mga_vid. |
1 | 5 * |
27027 | 6 * mga_vid is free software; you can redistribute it and/or modify |
26003
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
9 * (at your option) any later version. |
1 | 10 * |
27027 | 11 * mga_vid is distributed in the hope that it will be useful, |
26003
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
14 * GNU General Public License for more details. |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
15 * |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along |
27027 | 17 * with mga_vid; if not, write to the Free Software Foundation, Inc., |
26003
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
1 | 19 */ |
20 | |
21 //#include <stddef.h> | |
22 #include <stdio.h> | |
23 #include <stdlib.h> | |
24 #include <sys/ioctl.h> | |
25 #include <unistd.h> | |
26 #include <fcntl.h> | |
27 #include <sys/mman.h> | |
854
76ca00724e12
gcc warnings fixed - patch by Aelius aelius@wish.net
arpi_esp
parents:
76
diff
changeset
|
28 #include <inttypes.h> |
6245
aee789fa2d07
When compiling mga_vid_test.c, memcpy() is subject to an implicit
jaf
parents:
854
diff
changeset
|
29 #include <string.h> |
1 | 30 #include "mga_vid.h" |
31 | |
32 mga_vid_config_t config; | |
33 uint8_t *mga_vid_base; | |
34 uint32_t is_g400; | |
35 | |
36 #define SRC_IMAGE_WIDTH 256 | |
37 #define SRC_IMAGE_HEIGHT 256 | |
38 | |
39 uint8_t y_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
40 uint8_t cr_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
41 uint8_t cb_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
42 | |
43 | |
44 void | |
45 write_frame_g200(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
46 { | |
47 uint8_t *dest; | |
48 uint32_t bespitch,h,w; | |
49 | |
50 dest = mga_vid_base; | |
51 bespitch = (config.src_width + 31) & ~31; | |
52 | |
53 for(h=0; h < config.src_height; h++) | |
54 { | |
55 memcpy(dest, y, config.src_width); | |
56 y += config.src_width; | |
57 dest += bespitch; | |
58 } | |
59 | |
60 for(h=0; h < config.src_height/2; h++) | |
61 { | |
62 for(w=0; w < config.src_width/2; w++) | |
63 { | |
64 *dest++ = *cb++; | |
65 *dest++ = *cr++; | |
66 } | |
67 dest += bespitch - config.src_width; | |
68 } | |
69 } | |
70 | |
71 void | |
72 write_frame_g400(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
73 { | |
74 uint8_t *dest; | |
75 uint32_t bespitch,h; | |
76 | |
77 dest = mga_vid_base; | |
78 bespitch = (config.src_width + 31) & ~31; | |
79 | |
80 for(h=0; h < config.src_height; h++) | |
81 { | |
82 memcpy(dest, y, config.src_width); | |
83 y += config.src_width; | |
84 dest += bespitch; | |
85 } | |
86 | |
87 for(h=0; h < config.src_height/2; h++) | |
88 { | |
89 memcpy(dest, cb, config.src_width/2); | |
90 cb += config.src_width/2; | |
91 dest += bespitch/2; | |
92 } | |
93 | |
94 for(h=0; h < config.src_height/2; h++) | |
95 { | |
96 memcpy(dest, cr, config.src_width/2); | |
97 cr += config.src_width/2; | |
98 dest += bespitch/2; | |
99 } | |
100 } | |
101 | |
102 void write_frame(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
103 { | |
104 if(is_g400) | |
105 write_frame_g400(y,cr,cb); | |
106 else | |
107 write_frame_g200(y,cr,cb); | |
108 } | |
109 | |
110 void | |
111 draw_cool_pattern(void) | |
112 { | |
113 int i,x,y; | |
114 | |
115 i = 0; | |
116 for (y=0; y<config.src_height; y++) { | |
117 for (x=0; x<config.src_width; x++) { | |
118 y_image[i++] = x*x/2 + y*y/2 - 128; | |
119 } | |
120 } | |
121 | |
122 i = 0; | |
123 for (y=0; y<config.src_height/2; y++) | |
124 for (x=0; x<config.src_width/2; x++) | |
125 { | |
126 cr_image[i++] = x - 128; | |
127 } | |
128 | |
129 i = 0; | |
130 for (y=0; y<config.src_height/2; y++) | |
131 for (x=0; x<config.src_width/2; x++) | |
132 { | |
133 cb_image[i++] = y - 128; | |
134 } | |
135 } | |
136 | |
137 void | |
138 draw_color_blend(void) | |
139 { | |
140 int i,x,y; | |
141 | |
142 i = 0; | |
143 for (y=0; y<config.src_height; y++) { | |
144 for (x=0; x<config.src_width; x++) { | |
145 y_image[i++] = 0; | |
146 } | |
147 } | |
148 | |
149 i = 0; | |
150 for (y=0; y<config.src_height/2; y++) | |
151 for (x=0; x<config.src_width/2; x++) | |
152 { | |
153 cr_image[i++] = x - 128; | |
154 } | |
155 | |
156 i = 0; | |
157 for (y=0; y<config.src_height/2; y++) | |
158 for (x=0; x<config.src_width/2; x++) | |
159 { | |
160 cb_image[i++] = y - 128; | |
161 } | |
162 } | |
163 | |
164 | |
165 int | |
24287 | 166 main(void) |
1 | 167 { |
168 int f; | |
169 | |
170 f = open("/dev/mga_vid",O_RDWR); | |
171 | |
172 if(f == -1) | |
173 { | |
174 fprintf(stderr,"Couldn't open driver\n"); | |
175 exit(1); | |
176 } | |
177 | |
76 | 178 config.version = MGA_VID_VERSION; |
1 | 179 config.src_width = SRC_IMAGE_WIDTH; |
180 config.src_height= SRC_IMAGE_HEIGHT; | |
181 config.dest_width = SRC_IMAGE_WIDTH; | |
182 config.dest_height = SRC_IMAGE_HEIGHT; | |
183 config.x_org= 10; | |
184 config.y_org= 10; | |
185 config.colkey_on = 0; | |
186 config.format = MGA_VID_FORMAT_YV12; | |
76 | 187 config.frame_size=SRC_IMAGE_WIDTH*SRC_IMAGE_HEIGHT*2; |
188 config.num_frames=1; | |
1 | 189 |
190 if (ioctl(f,MGA_VID_CONFIG,&config)) | |
191 { | |
192 perror("Error in config ioctl"); | |
193 } | |
194 | |
195 if (config.card_type == MGA_G200) | |
196 { | |
197 printf("Testing MGA G200 Backend Scaler with %d MB of RAM\n", config.ram_size); | |
198 is_g400 = 0; | |
199 } | |
200 else | |
201 { | |
202 printf("Testing MGA G400 Backend Scaler with %d MB of RAM\n", config.ram_size); | |
203 is_g400 = 1; | |
204 } | |
205 | |
206 ioctl(f,MGA_VID_ON,0); | |
207 mga_vid_base = (uint8_t*)mmap(0,256 * 4096,PROT_WRITE,MAP_SHARED,f,0); | |
208 printf("mga_vid_base = %8p\n",mga_vid_base); | |
209 | |
210 | |
211 //memset(y_image,80,256 * 128); | |
212 //memset(cr_image,80,256/2 * 20); | |
213 //memset(cb_image,80,256/2 * 20); | |
214 write_frame(y_image,cr_image,cb_image); | |
215 printf("(1) There should be a green square, offset by 10 pixels from\n" | |
216 " the upper left corner displayed\n"); | |
217 sleep(3); | |
218 | |
219 | |
220 draw_cool_pattern(); | |
221 write_frame(y_image,cr_image,cb_image); | |
222 printf("(2) There should be a cool mosaic like pattern now.\n"); | |
223 sleep(3); | |
224 | |
225 draw_color_blend(); | |
226 write_frame(y_image,cr_image,cb_image); | |
227 printf("(3) There should be a color blend with black, red, purple, blue\n" | |
228 " corners (starting top left going CW)\n"); | |
229 sleep(3); | |
230 | |
231 ioctl(f,MGA_VID_OFF,0); | |
232 | |
233 close(f); | |
234 return 0; | |
235 } |