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