Mercurial > mplayer.hg
comparison libvo/vo_ggi.c @ 4841:5928e94c0d5f
older API fixes, support for async mode
author | alex |
---|---|
date | Sun, 24 Feb 2002 16:28:44 +0000 |
parents | 9153d1275b6d |
children | 6890819bc0dc |
comparison
equal
deleted
inserted
replaced
4840:7e56b1480a24 | 4841:5928e94c0d5f |
---|---|
3 | 3 |
4 (C) Alex Beregszaszi <alex@naxine.org> | 4 (C) Alex Beregszaszi <alex@naxine.org> |
5 | 5 |
6 Uses libGGI - http://www.ggi-project.org/ | 6 Uses libGGI - http://www.ggi-project.org/ |
7 | 7 |
8 TODO: | |
9 * implement non-directbuffer support | |
10 * improve directbuffer draw_frame (memcpy) | |
11 * check on many devices | |
12 * implement gamma handling | |
13 * implement direct rendering support | |
14 | |
8 Thanks to Andreas Beck for his patches. | 15 Thanks to Andreas Beck for his patches. |
9 Many thanks to Atmosfear, he hacked this driver to working with Planar | 16 Many thanks to Atmosfear, he hacked this driver to work with Planar |
10 formats, and he fixed the RGB handling. | 17 formats, and he fixed the RGB handling. |
11 */ | 18 */ |
12 | 19 |
13 #include <stdio.h> | 20 #include <stdio.h> |
14 #include <stdlib.h> | 21 #include <stdlib.h> |
22 #include "video_out_internal.h" | 29 #include "video_out_internal.h" |
23 | 30 |
24 #include "fastmemcpy.h" | 31 #include "fastmemcpy.h" |
25 | 32 |
26 #include <ggi/ggi.h> | 33 #include <ggi/ggi.h> |
27 | |
28 #undef GET_DB_INFO | |
29 | 34 |
30 /* maximum buffers */ | 35 /* maximum buffers */ |
31 #define GGI_FRAMES 4 | 36 #define GGI_FRAMES 4 |
32 | 37 |
33 #include "../postproc/rgb2rgb.h" | 38 #include "../postproc/rgb2rgb.h" |
59 int srcdepth; | 64 int srcdepth; |
60 | 65 |
61 /* destination */ | 66 /* destination */ |
62 int dstwidth; | 67 int dstwidth; |
63 int dstheight; | 68 int dstheight; |
69 | |
70 int async; | |
64 } ggi_conf; | 71 } ggi_conf; |
65 | 72 |
66 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, | 73 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, |
67 uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info) | 74 uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info) |
68 { | 75 { |
137 { | 144 { |
138 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get mode\n"); | 145 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get mode\n"); |
139 return(-1); | 146 return(-1); |
140 } | 147 } |
141 | 148 |
149 if ((mode.graphtype == GT_INVALID) || (mode.graphtype == GT_AUTO)) | |
150 { | |
151 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] not supported depth/bpp\n"); | |
152 return(-1); | |
153 } | |
154 | |
142 ggi_conf.gmode = mode; | 155 ggi_conf.gmode = mode; |
143 | 156 |
144 #if 1 | 157 #if 1 |
145 printf("[ggi] mode: "); | 158 printf("[ggi] mode: "); |
146 ggiPrintMode(&mode); | 159 ggiPrintMode(&mode); |
152 vo_screenheight = mode.visible.y; | 165 vo_screenheight = mode.visible.y; |
153 | 166 |
154 vo_dx = vo_dy = 0; | 167 vo_dx = vo_dy = 0; |
155 vo_dwidth = mode.virt.x; | 168 vo_dwidth = mode.virt.x; |
156 vo_dheight = mode.virt.y; | 169 vo_dheight = mode.virt.y; |
157 vo_dbpp = GT_ByPP(mode.graphtype); | 170 vo_dbpp = GT_SIZE(mode.graphtype); |
158 | 171 |
159 ggi_conf.srcwidth = width; | 172 ggi_conf.srcwidth = width; |
160 ggi_conf.srcheight = height; | 173 ggi_conf.srcheight = height; |
161 ggi_conf.srcformat = format; | 174 ggi_conf.srcformat = format; |
162 | 175 |
173 switch(ggi_conf.srcformat) | 186 switch(ggi_conf.srcformat) |
174 { | 187 { |
175 case IMGFMT_IYUV: | 188 case IMGFMT_IYUV: |
176 case IMGFMT_I420: | 189 case IMGFMT_I420: |
177 case IMGFMT_YV12: | 190 case IMGFMT_YV12: |
178 ggi_conf.srcdepth = vo_dbpp*8; | 191 ggi_conf.srcdepth = vo_dbpp; |
179 yuv2rgb_init(ggi_conf.srcdepth, MODE_RGB); | 192 yuv2rgb_init(ggi_conf.srcdepth, MODE_RGB); |
180 break; | 193 break; |
181 default: | 194 default: |
182 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n", | 195 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n", |
183 vo_format_name(ggi_conf.srcformat)); | 196 vo_format_name(ggi_conf.srcformat)); |
200 | 213 |
201 for (i = 0; i < ggi_conf.frames; i++) | 214 for (i = 0; i < ggi_conf.frames; i++) |
202 ggi_conf.buffer[i] = NULL; | 215 ggi_conf.buffer[i] = NULL; |
203 | 216 |
204 /* get available number of buffers */ | 217 /* get available number of buffers */ |
205 for (i = 0; DB = ggiDBGetBuffer(ggi_conf.vis, i), i < ggi_conf.frames; i++) | 218 for (i = 0; DB = (ggi_directbuffer *)ggiDBGetBuffer(ggi_conf.vis, i), |
219 i < ggi_conf.frames; i++) | |
206 { | 220 { |
207 if (!(DB->type & GGI_DB_SIMPLE_PLB) || | 221 if (!(DB->type & GGI_DB_SIMPLE_PLB) || |
208 (DB->page_size != 0) || | 222 (DB->page_size != 0) || |
209 (DB->write == NULL) || | 223 (DB->write == NULL) || |
210 (DB->noaccess != 0) || | 224 (DB->noaccess != 0) || |
233 ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.currframe); | 247 ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.currframe); |
234 ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe); | 248 ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe); |
235 | 249 |
236 mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %dx%dx%d, output: %dx%dx%d, frames: %d\n", | 250 mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %dx%dx%d, output: %dx%dx%d, frames: %d\n", |
237 ggi_conf.srcwidth, ggi_conf.srcheight, ggi_conf.srcdepth, | 251 ggi_conf.srcwidth, ggi_conf.srcheight, ggi_conf.srcdepth, |
238 vo_dwidth, vo_dheight, vo_dbpp*8, ggi_conf.frames); | 252 vo_dwidth, vo_dheight, vo_dbpp, ggi_conf.frames); |
253 | |
254 if (ggiGetFlags(ggi_conf.vis) & GGIFLAG_ASYNC) | |
255 { | |
256 mp_msg(MSGT_VO, MSGL_INFO, "[ggi] using asynchron mode\n"); | |
257 ggi_conf.async = 1; | |
258 } | |
239 | 259 |
240 return(0); | 260 return(0); |
241 } | 261 } |
242 | 262 |
243 static const vo_info_t *get_info(void) | 263 static const vo_info_t *get_info(void) |
284 } | 304 } |
285 | 305 |
286 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | 306 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, |
287 unsigned char *srca, int stride) | 307 unsigned char *srca, int stride) |
288 { | 308 { |
289 switch(vo_dbpp*8) | 309 switch(vo_dbpp) |
290 { | 310 { |
291 case 32: | 311 case 32: |
292 vo_draw_alpha_rgb32(w, h, src, srca, stride, | 312 vo_draw_alpha_rgb32(w, h, src, srca, stride, |
293 ggi_conf.buffer[ggi_conf.currframe]->write+4*(ggi_conf.dstwidth*y0+x0), 4*ggi_conf.dstwidth); | 313 ggi_conf.buffer[ggi_conf.currframe]->write+4*(ggi_conf.dstwidth*y0+x0), 4*ggi_conf.dstwidth); |
294 break; | 314 break; |
317 ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.currframe); | 337 ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.currframe); |
318 mp_dbg(MSGT_VO, MSGL_DBG2, "flip_page: current write frame: %d, display frame: %d\n", | 338 mp_dbg(MSGT_VO, MSGL_DBG2, "flip_page: current write frame: %d, display frame: %d\n", |
319 ggiGetWriteFrame(ggi_conf.vis), ggiGetDisplayFrame(ggi_conf.vis)); | 339 ggiGetWriteFrame(ggi_conf.vis), ggiGetDisplayFrame(ggi_conf.vis)); |
320 | 340 |
321 ggi_conf.currframe = (ggi_conf.currframe+1) % ggi_conf.frames; | 341 ggi_conf.currframe = (ggi_conf.currframe+1) % ggi_conf.frames; |
342 | |
343 if (ggi_conf.async) | |
344 ggiFlush(ggi_conf.vis); | |
322 } | 345 } |
323 | 346 |
324 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, | 347 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, |
325 int x, int y) | 348 int x, int y) |
326 { | 349 { |
368 { | 391 { |
369 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to initialize GGI\n"); | 392 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to initialize GGI\n"); |
370 return(-1); | 393 return(-1); |
371 } | 394 } |
372 | 395 |
373 if (arg) | 396 if ((char *)arg) |
374 ggi_conf.driver = arg; | 397 ggi_conf.driver = strdup(arg); |
375 else | 398 else |
376 ggi_conf.driver = NULL; | 399 ggi_conf.driver = NULL; |
377 | 400 |
378 if ((ggi_conf.vis = ggiOpen(ggi_conf.driver)) == NULL) | 401 if ((ggi_conf.vis = ggiOpen(ggi_conf.driver)) == NULL) |
379 { | 402 { |
389 return 0; | 412 return 0; |
390 } | 413 } |
391 | 414 |
392 static void uninit(void) | 415 static void uninit(void) |
393 { | 416 { |
417 if (ggi_conf.driver) | |
418 free(ggi_conf.driver); | |
394 ggiClose(ggi_conf.vis); | 419 ggiClose(ggi_conf.vis); |
395 ggiExit(); | 420 ggiExit(); |
396 } | 421 } |
397 | 422 |
423 #ifdef GGI_GAMMA | |
424 /* GAMMA handling */ | |
425 static int ggi_get_video_eq(vidix_video_eq_t *info) | |
426 { | |
427 memset(info, 0, sizeof(vidix_video_eq_t)); | |
428 } | |
429 | |
430 static void query_vaa(vo_vaa_t *vaa) | |
431 { | |
432 memset(vaa, 0, sizeof(vo_vaa_t)); | |
433 vaa->get_video_eq = ggi_get_video_eq; | |
434 vaa->set_video_eq = ggi_set_video_eq; | |
435 } | |
436 #endif | |
437 | |
398 static uint32_t control(uint32_t request, void *data, ...) | 438 static uint32_t control(uint32_t request, void *data, ...) |
399 { | 439 { |
400 switch (request) { | 440 switch (request) { |
441 #ifdef GGI_GAMMA | |
442 case VOCTRL_QUERY_VAA: | |
443 query_vaa((vo_vaa_t*)data); | |
444 return VO_TRUE; | |
445 #endif | |
401 case VOCTRL_QUERY_FORMAT: | 446 case VOCTRL_QUERY_FORMAT: |
402 return query_format(*((uint32_t*)data)); | 447 return query_format(*((uint32_t*)data)); |
403 } | 448 } |
404 return VO_NOTIMPL; | 449 return VO_NOTIMPL; |
405 } | 450 } |
406 | 451 |
452 /* EVENT handling */ | |
407 #include "../linux/keycodes.h" | 453 #include "../linux/keycodes.h" |
408 extern void mplayer_put_key(int code); | 454 extern void mplayer_put_key(int code); |
409 | 455 |
410 static void check_events(void) | 456 static void check_events(void) |
411 { | 457 { |