413
|
1
|
|
2 //#include "fastmemcpy.h"
|
1
|
3
|
|
4 // mga_vid drawing functions
|
|
5
|
56
|
6 static int mga_next_frame=0;
|
|
7
|
|
8 static mga_vid_config_t mga_vid_config;
|
|
9 static uint8_t *vid_data, *frames[4];
|
|
10 static int f;
|
|
11
|
202
|
12 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
|
|
13 int x,y;
|
|
14 uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31;
|
326
|
15 if (mga_vid_config.format==MGA_VID_FORMAT_YV12)
|
|
16 vo_draw_alpha_yv12(w,h,src,srca,stride,vid_data+bespitch*y0+x0,bespitch);
|
|
17 else
|
|
18 vo_draw_alpha_yuy2(w,h,src,srca,stride,vid_data+2*(bespitch*y0+x0),2*bespitch);
|
1
|
19 }
|
|
20
|
|
21
|
|
22 //static void
|
|
23 //write_slice_g200(uint8_t *y,uint8_t *cr, uint8_t *cb,uint32_t slice_num)
|
|
24
|
|
25 static void
|
|
26 draw_slice_g200(uint8_t *image[], int stride[], int width,int height,int x,int y)
|
|
27 {
|
|
28 uint8_t *src;
|
|
29 uint8_t *src2;
|
|
30 uint8_t *dest;
|
|
31 uint32_t bespitch,h,w;
|
|
32
|
284
|
33 bespitch = (mga_vid_config.src_width + 31) & ~31;
|
1
|
34
|
284
|
35 dest = vid_data + bespitch*y + x;
|
1
|
36 src = image[0];
|
284
|
37 for(h=0; h < height; h++)
|
|
38 {
|
|
39 memcpy(dest, src, width);
|
|
40 src += stride[0];
|
|
41 dest += bespitch;
|
|
42 }
|
1
|
43
|
|
44 width/=2;height/=2;x/=2;y/=2;
|
|
45
|
284
|
46 dest = vid_data + bespitch*mga_vid_config.src_height + bespitch*y + 2*x;
|
1
|
47 src = image[1];
|
|
48 src2 = image[2];
|
|
49 for(h=0; h < height; h++)
|
|
50 {
|
|
51 for(w=0; w < width; w++)
|
|
52 {
|
|
53 dest[2*w+0] = src[w];
|
|
54 dest[2*w+1] = src2[w];
|
|
55 }
|
|
56 dest += bespitch;
|
284
|
57 src += stride[1];
|
|
58 src2+= stride[2];
|
1
|
59 }
|
|
60 }
|
|
61
|
|
62 static void
|
|
63 draw_slice_g400(uint8_t *image[], int stride[], int w,int h,int x,int y)
|
|
64 {
|
|
65 uint8_t *src;
|
|
66 uint8_t *dest;
|
|
67 uint32_t bespitch,bespitch2;
|
|
68 int i;
|
|
69
|
|
70 bespitch = (mga_vid_config.src_width + 31) & ~31;
|
|
71 bespitch2 = bespitch/2;
|
|
72
|
|
73 dest = vid_data + bespitch * y + x;
|
|
74 src = image[0];
|
|
75 for(i=0;i<h;i++){
|
|
76 memcpy(dest,src,w);
|
|
77 src+=stride[0];
|
|
78 dest += bespitch;
|
|
79 }
|
|
80
|
|
81 w/=2;h/=2;x/=2;y/=2;
|
|
82
|
|
83 dest = vid_data + bespitch*mga_vid_config.src_height + bespitch2 * y + x;
|
|
84 src = image[1];
|
|
85 for(i=0;i<h;i++){
|
|
86 memcpy(dest,src,w);
|
|
87 src+=stride[1];
|
|
88 dest += bespitch2;
|
|
89 }
|
|
90
|
|
91 dest = vid_data + bespitch*mga_vid_config.src_height
|
|
92 + bespitch*mga_vid_config.src_height / 4
|
|
93 + bespitch2 * y + x;
|
|
94 src = image[2];
|
|
95 for(i=0;i<h;i++){
|
|
96 memcpy(dest,src,w);
|
|
97 src+=stride[2];
|
|
98 dest += bespitch2;
|
|
99 }
|
|
100
|
|
101 }
|
|
102
|
|
103 static uint32_t
|
|
104 draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
|
|
105 {
|
|
106 if (mga_vid_config.card_type == MGA_G200)
|
|
107 draw_slice_g200(src,stride,w,h,x,y);
|
|
108 else
|
|
109 draw_slice_g400(src,stride,w,h,x,y);
|
|
110 return 0;
|
|
111 }
|
|
112
|
|
113 static void
|
31
|
114 vo_mga_flip_page(void)
|
1
|
115 {
|
47
|
116
|
|
117 // printf("-- flip to %d --\n",mga_next_frame);
|
1
|
118
|
47
|
119 #if 1
|
|
120 ioctl(f,MGA_VID_FSEL,&mga_next_frame);
|
56
|
121 mga_next_frame=(mga_next_frame+1)%mga_vid_config.num_frames;
|
47
|
122 vid_data=frames[mga_next_frame];
|
|
123 #endif
|
1
|
124
|
|
125 }
|
|
126
|
|
127
|
|
128 static void
|
|
129 write_frame_yuy2(uint8_t *y)
|
|
130 {
|
|
131 uint8_t *dest;
|
|
132 uint32_t bespitch,h;
|
|
133 int len=2*mga_vid_config.src_width;
|
|
134
|
|
135 dest = vid_data;
|
|
136 bespitch = (mga_vid_config.src_width + 31) & ~31;
|
|
137
|
|
138 // y+=2*mga_vid_config.src_width*mga_vid_config.src_height;
|
|
139
|
|
140 for(h=0; h < mga_vid_config.src_height; h++)
|
|
141 {
|
|
142 // y -= 2*mga_vid_config.src_width;
|
|
143 memcpy(dest, y, len);
|
|
144 y += len;
|
|
145 dest += 2*bespitch;
|
|
146 }
|
|
147 }
|
|
148
|
|
149
|
|
150 static uint32_t
|
|
151 draw_frame(uint8_t *src[])
|
|
152 {
|
|
153 if (mga_vid_config.format==MGA_VID_FORMAT_YUY2)
|
|
154 write_frame_yuy2(src[0]);
|
|
155 return 0;
|
|
156 }
|
|
157
|
|
158 static uint32_t
|
|
159 query_format(uint32_t format)
|
|
160 {
|
|
161 switch(format){
|
|
162 case IMGFMT_YV12:
|
|
163 case IMGFMT_YUY2:
|
|
164 // case IMGFMT_RGB|24:
|
|
165 // case IMGFMT_BGR|24:
|
|
166 return 1;
|
|
167 }
|
|
168 return 0;
|
|
169 }
|
|
170
|
56
|
171 static int mga_init(){
|
|
172 char *frame_mem;
|
|
173
|
|
174 mga_vid_config.num_frames=4;
|
|
175 mga_vid_config.version=MGA_VID_VERSION;
|
|
176 if (ioctl(f,MGA_VID_CONFIG,&mga_vid_config))
|
|
177 {
|
275
|
178 perror("Error in mga_vid_config ioctl()");
|
|
179 printf("Your mga_vid driver version is incompatible with this MPlayer version!\n");
|
56
|
180 return -1;
|
|
181 }
|
|
182 ioctl(f,MGA_VID_ON,0);
|
|
183
|
|
184 frames[0] = (char*)mmap(0,mga_vid_config.frame_size*mga_vid_config.num_frames,PROT_WRITE,MAP_SHARED,f,0);
|
|
185 frames[1] = frames[0] + 1*mga_vid_config.frame_size;
|
|
186 frames[2] = frames[0] + 2*mga_vid_config.frame_size;
|
|
187 frames[3] = frames[0] + 3*mga_vid_config.frame_size;
|
|
188 mga_next_frame = 0;
|
|
189 vid_data = frames[mga_next_frame];
|
|
190
|
|
191 //clear the buffer
|
|
192 memset(frames[0],0x80,mga_vid_config.frame_size*mga_vid_config.num_frames);
|
|
193
|
|
194 return 0;
|
|
195
|
|
196 }
|
|
197
|