Mercurial > mplayer.hg
annotate libvo/vo_directfb2.c @ 9851:6a348d3ed626
A new control called upon stream reset.
author | albeu |
---|---|
date | Sun, 06 Apr 2003 16:34:26 +0000 |
parents | 7b1907aa1422 |
children | 8098165634f7 |
rev | line source |
---|---|
6952 | 1 /* |
2 MPlayer video driver for DirectFramebuffer device | |
3 | |
4 (C) 2002 | |
5 | |
6 Written by Jiri Svoboda <Jiri.Svoboda@seznam.cz> | |
7 | |
8 This library is free software; you can redistribute it and/or | |
9 modify it under the terms of the GNU Lesser General Public | |
10 License as published by the Free Software Foundation; either | |
11 version 2 of the License, or (at your option) any later version. | |
12 | |
13 This library is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 Lesser General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU Lesser General Public | |
19 License along with this library; if not, write to the | |
20 Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. | |
22 */ | |
23 | |
24 // directfb includes | |
25 | |
26 #include <directfb.h> | |
27 | |
28 // other things | |
29 | |
30 #include <stdio.h> | |
31 #include <stdlib.h> | |
32 #include <string.h> | |
33 #include <fcntl.h> | |
34 #include <unistd.h> | |
35 #include <errno.h> | |
36 #include <ctype.h> | |
37 #include <assert.h> | |
38 | |
39 #include <sys/mman.h> | |
40 #include <sys/ioctl.h> | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
41 #ifdef __linux__ |
6952 | 42 #include <sys/kd.h> |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
43 #else |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
44 #include <linux/kd.h> |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
45 #endif |
6952 | 46 |
47 #include "config.h" | |
48 #include "video_out.h" | |
49 #include "video_out_internal.h" | |
50 #include "fastmemcpy.h" | |
51 #include "sub.h" | |
52 | |
53 #include "aspect.h" | |
54 | |
55 #ifndef min | |
56 #define min(x,y) (((x)<(y))?(x):(y)) | |
57 #endif | |
58 | |
59 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8137
diff
changeset
|
60 static vo_info_t info = { |
6952 | 61 "Direct Framebuffer Device", |
62 "directfb", | |
63 "Jiri Svoboda Jiri.Svoboda@seznam.cz", | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
64 "v 2.0 (for DirectFB version >=0.9.13)" |
6952 | 65 }; |
66 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8137
diff
changeset
|
67 LIBVO_EXTERN(directfb) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8137
diff
changeset
|
68 |
6952 | 69 extern int verbose; |
70 | |
71 /****************************** | |
72 * vo_directfb globals * | |
73 ******************************/ | |
74 | |
75 #define DFBCHECK(x...) \ | |
76 { \ | |
77 DFBResult err = x; \ | |
78 \ | |
79 if (err != DFB_OK) \ | |
80 { \ | |
81 fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ | |
82 DirectFBErrorFatal( #x, err ); \ | |
83 } \ | |
84 } | |
85 | |
86 /* | |
87 * filled by preinit | |
88 */ | |
89 | |
90 // main DirectFB handle | |
91 static IDirectFB *dfb = NULL; | |
92 // keyboard handle | |
93 static IDirectFBInputDevice *keyboard = NULL; | |
94 // A buffer for input events. | |
95 static IDirectFBEventBuffer *buffer = NULL; | |
96 | |
97 /* | |
98 * filled during config | |
99 */ | |
100 | |
101 // handle of used layer | |
102 static IDirectFBDisplayLayer *layer = NULL; | |
103 // surface of used layer | |
104 static IDirectFBSurface *primary = NULL; | |
105 static int primarylocked = 0; | |
106 // handle of temporary surface (if used) | |
107 static IDirectFBSurface *frame = NULL; | |
108 static int framelocked = 0; | |
109 // flipping mode flag (layer/surface) | |
110 static int flipping = 0; | |
111 // scaling flag | |
112 static int stretch = 0; | |
113 // pictrure position | |
114 static int xoffset=0,yoffset=0; | |
115 // picture size | |
116 static int out_width=0,out_height=0; | |
117 // frame/primary size | |
118 static int width=0,height=0; | |
119 // frame primary format | |
120 DFBSurfacePixelFormat pixel_format; | |
121 /* | |
122 static void (*draw_alpha_p)(int w, int h, unsigned char *src, | |
123 unsigned char *srca, int stride, unsigned char *dst, | |
124 int dstride); | |
125 */ | |
126 | |
127 /****************************** | |
128 * cmd line parameteres * | |
129 ******************************/ | |
130 | |
131 /* command line/config file options */ | |
132 #ifdef HAVE_FBDEV | |
133 extern char *fb_dev_name; | |
134 #else | |
135 char *fb_dev_name; | |
136 #endif | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
137 char *dfb_params; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
138 int layer_id = -1; |
6952 | 139 |
140 /****************************** | |
141 * implementation * | |
142 ******************************/ | |
143 | |
144 void unlock() { | |
145 if (frame && framelocked) frame->Unlock(frame); | |
146 if (primary && primarylocked) primary->Unlock(primary); | |
147 } | |
148 | |
149 | |
150 static uint32_t preinit(const char *arg) | |
151 { | |
152 | |
153 DFBResult ret; | |
154 | |
155 if (verbose) printf("DirectFB: Preinit entered\n"); | |
156 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
157 if (arg) { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
158 int tmp=-1; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
159 if (sscanf(arg,"%i",&tmp)) { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
160 layer_id=tmp; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
161 if (verbose) printf("DirectFB: Layer id forced to %i\n",layer_id); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
162 }; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
163 } |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
164 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
165 if (dfb_params) |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
166 { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
167 int argc = 2; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
168 char arg0[10] = "mplayer"; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
169 char arg1[256] = "--dfb:"; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
170 char* argv[3]; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
171 char ** a; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
172 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
173 a = &argv[0]; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
174 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
175 strncat(arg1,dfb_params,249); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
176 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
177 argv[0]=arg0; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
178 argv[1]=arg1; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
179 argv[2]=NULL; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
180 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
181 DFBCHECK (DirectFBInit (&argc,&a)); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
182 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
183 } else { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
184 |
6952 | 185 DFBCHECK (DirectFBInit (NULL,NULL)); |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
186 } |
6952 | 187 |
188 if (((directfb_major_version <= 0) && | |
189 (directfb_minor_version <= 9) && | |
190 (directfb_micro_version < 13))) | |
191 { | |
192 printf("DirectFB: Unsupported DirectFB version\n"); | |
193 return 1; | |
194 } | |
195 | |
196 /* | |
197 * (set options) | |
198 */ | |
199 | |
200 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER"))) fb_dev_name = "/dev/fb0"; | |
201 DFBCHECK (DirectFBSetOption ("fbdev",fb_dev_name)); | |
202 | |
203 // uncomment this if you do not wish to create a new vt for DirectFB | |
204 // DFBCHECK (DirectFBSetOption ("no-vt-switch","")); | |
205 | |
206 // uncomment this if you want to allow vt switching | |
207 // DFBCHECK (DirectFBSetOption ("vt-switching","")); | |
208 | |
209 // uncomment this if you want to hide gfx cursor (req dfb >=0.9.9) | |
210 DFBCHECK (DirectFBSetOption ("no-cursor","")); | |
211 | |
212 // bg color fix | |
213 DFBCHECK (DirectFBSetOption ("bg-color","00000000")); | |
214 | |
215 /* | |
216 * (Initialize) | |
217 */ | |
218 | |
219 DFBCHECK (DirectFBCreate (&dfb)); | |
220 | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
221 #if DIRECTFBVERSION != 917 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
222 if (DFB_OK != dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
223 printf("DirectFB: Warning - cannot swith to fullscreen mode"); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
224 }; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
225 #endif |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
226 |
6952 | 227 /* |
228 * (Get keyboard) | |
229 */ | |
230 | |
231 ret = dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard); | |
232 | |
233 if (ret==DFB_OK) { | |
234 if (verbose) { | |
235 printf("DirectFB: Keyboard init OK\n"); | |
236 } | |
237 } else { | |
238 keyboard = NULL; | |
239 printf("DirectFB: Keyboard init FAILED\n"); | |
240 } | |
241 | |
242 /* | |
243 * Create an input buffer for the keyboard. | |
244 */ | |
245 if (keyboard) DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer)); | |
246 | |
247 // just to start with clean ... | |
248 if (buffer) buffer->Reset(buffer); | |
249 | |
250 if (verbose) { | |
251 printf("DirectFB: Preinit OK\n"); | |
252 } | |
253 | |
254 return 0; | |
255 | |
256 } | |
257 | |
258 DFBSurfacePixelFormat convformat(uint32_t format) | |
259 { | |
260 // add more formats !!! | |
261 switch (format) { | |
262 case IMGFMT_RGB32: return DSPF_RGB32; break; | |
263 case IMGFMT_BGR32: return DSPF_RGB32; break; | |
264 case IMGFMT_RGB24: return DSPF_RGB24; break; | |
265 case IMGFMT_BGR24: return DSPF_RGB24; break; | |
266 case IMGFMT_RGB16: return DSPF_RGB16; break; | |
267 case IMGFMT_BGR16: return DSPF_RGB16; break; | |
8640 | 268 #if DIRECTFBVERSION > 915 |
269 case IMGFMT_RGB15: return DSPF_ARGB1555; break; | |
270 case IMGFMT_BGR15: return DSPF_ARGB1555; break; | |
271 #else | |
6952 | 272 case IMGFMT_RGB15: return DSPF_RGB15; break; |
273 case IMGFMT_BGR15: return DSPF_RGB15; break; | |
8640 | 274 #endif |
6952 | 275 case IMGFMT_YUY2: return DSPF_YUY2; break; |
276 case IMGFMT_UYVY: return DSPF_UYVY; break; | |
277 case IMGFMT_YV12: return DSPF_YV12; break; | |
278 case IMGFMT_I420: return DSPF_I420; break; | |
279 // case IMGFMT_IYUV: return DSPF_IYUV; break; | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
280 case IMGFMT_RGB8: return DSPF_RGB332; break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
281 case IMGFMT_BGR8: return DSPF_RGB332; break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
282 |
6952 | 283 default: return 0; |
284 } | |
285 return 0; | |
286 } | |
287 | |
288 typedef struct enum1_s { | |
289 uint32_t format; | |
290 int scale; | |
291 int result; | |
292 unsigned int id; | |
293 unsigned int width; | |
294 unsigned int height; | |
295 int setsize; | |
296 } enum1_t; | |
297 | |
298 DFBEnumerationResult test_format_callback( unsigned int id, | |
299 DFBDisplayLayerDescription desc, | |
300 void *data) | |
301 { | |
302 enum1_t *params =(enum1_t *)data; | |
303 IDirectFBDisplayLayer *layer; | |
304 DFBResult ret; | |
305 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
306 if ((layer_id == -1 )||(layer_id == id)) { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
307 |
6952 | 308 ret = dfb->GetDisplayLayer( dfb, id, &layer); |
309 if (ret) { | |
310 DirectFBError( "dfb->GetDisplayLayer failed", ret ); | |
311 return DFENUM_OK; | |
312 } else { | |
313 DFBDisplayLayerConfig dlc; | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
314 |
6952 | 315 if (params->setsize) { |
316 dlc.flags = DLCONF_WIDTH |DLCONF_HEIGHT; | |
317 dlc.width = params->width; | |
318 dlc.height = params->height; | |
319 layer->SetConfiguration(layer,&dlc); | |
320 } | |
321 | |
322 | |
323 dlc.flags = DLCONF_PIXELFORMAT; | |
324 dlc.pixelformat = convformat(params->format); | |
9515 | 325 |
326 layer->SetOpacity(layer,0); | |
6952 | 327 |
328 ret = layer->TestConfiguration(layer,&dlc,NULL); | |
329 | |
330 layer->Release(layer); | |
331 | |
332 if (verbose) printf("DirectFB: Test format - layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); | |
333 | |
9515 | 334 if (ret==DFB_OK) { |
6952 | 335 // printf("Test OK\n"); |
336 if (params->result) { | |
337 if ((!params->scale) && (desc.caps & DLCAPS_SCREEN_LOCATION)) { | |
338 params->scale=1; | |
339 params->id=id; | |
340 if (verbose) printf("DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); | |
341 } | |
342 } else { | |
343 params->result=1; | |
344 params->id=id; | |
345 if (desc.caps & DLCAPS_SCREEN_LOCATION) params->scale=1; | |
346 if (verbose) printf("DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); | |
347 }; | |
348 }; | |
349 }; | |
350 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
351 }; |
9515 | 352 |
6952 | 353 return DFENUM_OK; |
354 } | |
355 | |
356 static uint32_t query_format(uint32_t format) | |
357 { | |
358 int ret = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD; // osd should be removed in future -> will be handled outside... | |
359 enum1_t params; | |
360 | |
361 | |
362 if (!convformat(format)) return 0; | |
363 // temporary disable YV12 | |
364 // if (format == IMGFMT_YV12) return 0; | |
365 // if (format == IMGFMT_I420) return 0; | |
366 if (format == IMGFMT_IYUV) return 0; | |
367 | |
368 if (verbose) printf("DirectFB: Format query: %s\n",vo_format_name(format)); | |
369 | |
370 params.format=format; | |
371 params.scale=0; | |
372 params.result=0; | |
373 params.setsize=0; | |
374 | |
375 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,¶ms)); | |
376 | |
377 if (params.result) { | |
378 if (params.scale) ret |=VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN; | |
379 return ret; | |
380 } | |
381 | |
382 return 0; | |
383 } | |
384 | |
385 typedef struct videomode_s { | |
386 int width; | |
387 int height; | |
388 int out_width; | |
389 int out_height; | |
390 int overx; | |
391 int overy; | |
392 int bpp; | |
393 } videomode_t; | |
394 | |
395 | |
396 DFBEnumerationResult video_modes_callback( unsigned int width,unsigned int height,unsigned int bpp, void *data) | |
397 { | |
398 videomode_t *params =(videomode_t *)data; | |
399 | |
400 int overx=0,overy=0,closer=0,over=0; | |
401 int we_are_under=0; | |
402 | |
403 if (verbose) printf("DirectFB: Validator entered %i %i %i\n",width,height,bpp); | |
404 | |
405 overx=width-params->out_width; | |
406 overy=height-params->out_height; | |
407 | |
408 if (!params->width) { | |
409 params->width=width; | |
410 params->height=height; | |
411 params->overx=overx; | |
412 params->overy=overy; | |
413 if (verbose) printf("DirectFB: Mode added %i %i %i\n",width,height,bpp); | |
414 } | |
415 | |
416 if ((params->overy<0)||(params->overx<0)) we_are_under=1; // stored mode is smaller than req mode | |
417 if (abs(overx*overy)<abs(params->overx * params->overy)) closer=1; // current mode is closer to desired res | |
418 if ((overx>=0)&&(overy>=0)) over=1; // current mode is bigger or equaul to desired res | |
419 if ((closer && (over || we_are_under)) || (we_are_under && over)) { | |
420 params->width=width; | |
421 params->height=height; | |
422 params->overx=overx; | |
423 params->overy=overy; | |
424 if (verbose) printf("DirectFB: Better mode added %i %i %i\n",width,height,bpp); | |
425 }; | |
426 | |
427 return DFENUM_OK; | |
428 } | |
429 | |
430 #define CONFIG_ERROR -1 | |
431 | |
432 static uint32_t config(uint32_t s_width, uint32_t s_height, uint32_t d_width, | |
433 uint32_t d_height, uint32_t fullscreen, char *title, | |
7272 | 434 uint32_t format) |
6952 | 435 { |
436 /* | |
437 * (Locals) | |
438 */ | |
439 | |
440 // decode flags | |
441 | |
442 int fs = fullscreen & 0x01; | |
443 int vm = fullscreen & 0x02; | |
444 int zoom = fullscreen & 0x04; | |
445 int flip = fullscreen & 0x08; | |
446 | |
447 DFBSurfaceDescription dsc; | |
448 DFBResult ret; | |
449 DFBDisplayLayerConfig dlc; | |
450 DFBSurfaceCapabilities caps; | |
451 | |
452 enum1_t params; | |
453 | |
454 if (verbose) { | |
455 printf("DirectFB: Config entered [%ix%i]\n",s_width,s_height); | |
456 printf("DirectFB: With requested format: %s\n",vo_format_name(format)); | |
457 } | |
458 // initial clean-up | |
459 if (frame) { | |
460 frame->Release(frame); | |
461 frame=NULL; | |
462 } | |
463 | |
464 if (primary) { | |
465 primary->Release(primary); | |
466 primary=NULL; | |
467 } | |
468 | |
469 if (layer) { | |
470 layer->Release(layer); | |
471 layer=NULL; | |
472 } | |
473 | |
474 | |
475 // vm things | |
476 | |
477 if (vm) { | |
478 videomode_t params; | |
479 params.out_width=d_width; | |
480 params.out_height=d_height; | |
481 params.width=0; | |
482 params.height=0; | |
483 switch (format) { | |
9515 | 484 case IMGFMT_RGB32: |
485 case IMGFMT_BGR32: | |
6952 | 486 params.bpp=32; |
487 break; | |
9515 | 488 case IMGFMT_RGB24: |
489 case IMGFMT_BGR24: | |
6952 | 490 params.bpp=24; |
491 break; | |
492 case IMGFMT_RGB16: | |
493 case IMGFMT_BGR16: | |
494 case IMGFMT_RGB15: | |
495 case IMGFMT_BGR15: | |
496 params.bpp=16; | |
497 break; | |
9515 | 498 default: params.bpp=0; |
499 | |
500 } | |
6952 | 501 if (verbose) printf("DirectFB: Config - videomode change\n"); |
502 DFBCHECK (dfb->EnumVideoModes(dfb,video_modes_callback,¶ms)); | |
503 ret=dfb->SetVideoMode(dfb,params.width,params.height,params.bpp); | |
504 if (ret) { | |
505 ret=dfb->SetVideoMode(dfb,params.width,params.height,24); | |
506 if (ret) { | |
507 ret=dfb->SetVideoMode(dfb,params.width,params.height,32); | |
508 if (ret) { | |
509 ret=dfb->SetVideoMode(dfb,params.width,params.height,16); | |
510 if (ret) { | |
511 ret=dfb->SetVideoMode(dfb,params.width,params.height,8); | |
512 } | |
513 } | |
514 } | |
515 } | |
516 } // vm end | |
517 | |
518 // find best layer | |
519 | |
520 if (verbose) printf("DirectFB: Config - find suitable layer\n"); | |
521 params.format=format; | |
522 params.scale=0; | |
523 params.result=0; | |
524 params.width=s_width; | |
525 params.height=s_height; | |
526 params.setsize=1; | |
527 | |
528 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,¶ms)); | |
529 | |
530 if (!params.result) { | |
531 printf("DirectFB: ConfigError - no suitable layer found\n"); | |
532 params.id = DLID_PRIMARY; | |
9515 | 533 } |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
534 |
6952 | 535 if (verbose) printf("DirectFB: Config - layer %i\n",params.id); |
536 | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
537 // setup layer |
6952 | 538 |
539 DFBCHECK (dfb->GetDisplayLayer( dfb, params.id, &layer)); | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
540 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
541 #if DIRECTFBVERSION > 916 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
542 ret = layer->SetCooperativeLevel (layer, DLSCL_EXCLUSIVE); |
6952 | 543 |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
544 if (DFB_OK != ret) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
545 DirectFBError("MPlayer - Switch layer to exlusive mode.",ret); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
546 printf("DirectFB: Warning - cannot swith layer to exclusive mode. This could cause\nproblems. You may need to select correct pixel format manually!\n"); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
547 }; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
548 #endif |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
549 |
6952 | 550 if (params.scale) { |
551 if (verbose) printf("DirectFB: Config - set layer config (size)\n"); | |
552 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT; | |
553 dlc.width = s_width; | |
554 dlc.height = s_height; | |
9515 | 555 |
6952 | 556 ret = layer->SetConfiguration(layer,&dlc); |
9515 | 557 |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
558 if (ret) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
559 printf("DirectFB: ConfigError in layer configuration (size)\n"); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
560 DirectFBError("MPlayer - Layer size change.",ret); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
561 }; |
6952 | 562 } |
563 | |
9515 | 564 // look if we need to change pixel fromat of layer |
565 // and just for sure fetch also all layer propreties | |
566 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_OPTIONS | DLCONF_BUFFERMODE; | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
567 |
9515 | 568 ret = layer->GetConfiguration(layer,&dlc); |
569 | |
570 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT; | |
571 | |
572 if (ret) { | |
573 printf("DirectFB: Warning - could not get layer properties!\n"); | |
574 } else if (verbose) { | |
575 printf("DirectFB: Layer reports format:%x\n",dlc.pixelformat); | |
576 } | |
6952 | 577 |
9515 | 578 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) { |
579 | |
580 dlc.flags = DLCONF_PIXELFORMAT; | |
581 dlc.pixelformat = convformat(params.format); | |
582 | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
583 printf("DirectFB: Desired pixelformat: %x\n",dlc.pixelformat); |
9515 | 584 |
585 if (verbose) printf("DirectFB: Config - set layer config (format)\n"); | |
586 ret = layer->SetConfiguration(layer,&dlc); | |
587 | |
588 if (ret) { | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
589 unsigned int bpp; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
590 printf("DirectFB: ConfigError in layer configuration (format, flags=%x)\n",dlc.flags); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
591 DirectFBError("MPlayer - layer pixelformat change",ret); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
592 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
593 // ugly fbdev workabout - try to switch pixelformat via videomode change |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
594 switch (dlc.pixelformat) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
595 case DSPF_ARGB: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
596 case DSPF_RGB32: bpp=32;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
597 case DSPF_RGB24: bpp=24;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
598 case DSPF_RGB16: bpp=16;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
599 #if DIRECTFBVERSION > 915 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
600 case DSPF_ARGB1555: bpp=15;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
601 #else |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
602 case DSPF_RGB15: bpp=15;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
603 #endif |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
604 case DSPF_RGB332 : bpp=8;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
605 } |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
606 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
607 switch (dlc.pixelformat) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
608 case DSPF_ARGB: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
609 case DSPF_RGB32: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
610 case DSPF_RGB24: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
611 case DSPF_RGB16: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
612 #if DIRECTFBVERSION > 915 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
613 case DSPF_ARGB1555: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
614 #else |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
615 case DSPF_RGB15: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
616 #endif |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
617 case DSPF_RGB332: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
618 printf("DirectFB: Trying to recover via videomode change (VM).\n"); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
619 // get size |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
620 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
621 if (DFB_OK==layer->GetConfiguration(layer,&dlc)) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
622 // try to set videomode |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
623 printf("DirectFB: Videomode %ix%i BPP %i\n",dlc.width,dlc.height,bpp); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
624 ret = dfb->SetVideoMode(dfb,dlc.width,dlc.height,bpp); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
625 if (ret) DirectFBError("MPlayer - VM - pixelformat change",ret); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
626 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
627 }; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
628 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
629 //get current pixel format |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
630 dlc.flags = DLCONF_PIXELFORMAT; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
631 ret = layer->GetConfiguration(layer,&dlc); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
632 if (ret) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
633 DirectFBError("MPlayer - VM - Layer->GetConfiguration",ret); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
634 } else { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
635 printf("DirectFB: Layer has now pixelformat [%x]\n",dlc.pixelformat); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
636 }; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
637 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
638 // check if we were succesfull |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
639 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
640 printf("DirectFB: Recovery failed!.\n"); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
641 return CONFIG_ERROR; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
642 } |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
643 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
644 break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
645 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
646 default: return CONFIG_ERROR; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
647 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
648 }; |
9515 | 649 }; |
6952 | 650 }; |
651 | |
652 // flipping of layer | |
653 | |
654 dlc.flags = DLCONF_BUFFERMODE; | |
655 dlc.buffermode = DLBM_BACKVIDEO; | |
656 ret = layer->SetConfiguration( layer, &dlc ); | |
657 if (ret!=DFB_OK) { | |
658 dlc.buffermode = DLBM_BACKSYSTEM; | |
659 ret = layer->SetConfiguration( layer, &dlc ); | |
660 } | |
661 | |
662 // get layer surface | |
663 | |
664 ret = layer->GetSurface(layer,&primary); | |
665 | |
666 if (ret) { | |
667 printf("DirectFB: ConfigError in obtaining surface\n"); | |
668 return CONFIG_ERROR; // what shall we report on fail? | |
669 } | |
670 | |
671 // test surface for flipping | |
672 DFBCHECK(primary->GetCapabilities(primary,&caps)); | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
673 #if DIRECTFBVERSION > 913 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
674 primary->Clear(primary,0,0,0,0); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
675 #endif |
6952 | 676 flipping = 0; |
677 if (caps & DSCAPS_FLIPPING) { | |
678 ret = primary->Flip(primary,NULL,0); | |
679 if (ret==DFB_OK) { | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
680 #if DIRECTFBVERSION > 913 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
681 primary->Clear(primary,0,0,0,0); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
682 #endif |
6952 | 683 flipping = 1; |
684 } | |
685 }; | |
686 | |
687 if (verbose) printf("DirectFB: Config - flipping = %i\n",flipping); | |
688 | |
689 // is scale needed ? Aspect ratio and layer pos/size | |
690 | |
691 | |
692 // get surface size | |
693 DFBCHECK(primary->GetSize(primary,&width,&height)); | |
694 | |
695 if (verbose) printf("DirectFB: Config - surface size = %ix%i\n",width,height); | |
696 | |
697 aspect_save_orig(s_width,s_height); | |
698 aspect_save_prescale(d_width,d_height); | |
699 if (params.scale) { | |
700 aspect_save_screenres(10000,10000); | |
701 aspect(&out_width,&out_height,A_ZOOM); | |
702 | |
703 ret = layer->SetScreenLocation(layer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000)); | |
704 | |
705 if (ret) printf("DirectFB: ConfigError in layer configuration (position)\n"); | |
706 | |
707 xoffset = 0; | |
708 yoffset = 0; | |
709 | |
710 } else { | |
711 | |
712 aspect_save_screenres(width,height); | |
713 | |
714 if(fs) /* -fs */ | |
715 aspect(&out_width,&out_height,A_ZOOM); | |
716 else | |
717 aspect(&out_width,&out_height,A_NOZOOM); | |
718 | |
719 | |
720 xoffset = (width - out_width) / 2; | |
721 yoffset = (height - out_height) / 2; | |
722 } | |
723 | |
724 if (((s_width==out_width)&&(s_height==out_height)) || (params.scale)) { | |
725 stretch = 0; | |
726 } else { | |
727 stretch = 1; | |
728 } | |
729 | |
730 | |
731 // temporary buffer in case of not flipping or scaling | |
732 if ((!flipping) || stretch) { | |
733 | |
734 DFBCHECK (primary->GetPixelFormat (primary, &dsc.pixelformat)); | |
735 | |
736 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH; | |
737 | |
738 dsc.width = s_width; | |
739 dsc.height = s_height; | |
740 | |
741 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame)); | |
742 DFBCHECK(frame->GetSize(frame,&width,&height)); | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
743 if (verbose) printf("DirectFB: Frame is active.\n"); |
6952 | 744 } |
745 | |
746 // get format for draw_alpha - should be removed soon - osd will be rendered outside vo driver | |
747 if (frame) { | |
748 DFBCHECK (frame->GetPixelFormat(frame,&pixel_format)); | |
749 } else { | |
750 DFBCHECK (primary->GetPixelFormat(primary,&pixel_format)); | |
751 }; | |
752 | |
753 // finally turn on layer | |
754 layer->SetOpacity(layer,255); | |
755 | |
756 if (verbose) printf("DirectFB: Config finished [%ix%i] - [%ix%i]\n",out_width,out_height,width,height); | |
757 | |
758 return 0; | |
759 } | |
760 | |
761 extern void mplayer_put_key(int code); | |
762 | |
9380 | 763 #include "../osdep/keycodes.h" |
6952 | 764 |
765 static void check_events(void) | |
766 { | |
767 | |
768 if (buffer) { | |
769 | |
770 DFBInputEvent event; | |
771 | |
772 //if (verbose) printf ("DirectFB: Check events entered\n"); | |
773 if (buffer->GetEvent(buffer, DFB_EVENT (&event)) == DFB_OK) { | |
774 | |
775 if (event.type == DIET_KEYPRESS) { | |
776 switch (event.key_symbol) { | |
777 case DIKS_ESCAPE: | |
778 mplayer_put_key('q'); | |
779 break; | |
780 case DIKS_PAGE_UP: mplayer_put_key(KEY_PAGE_UP);break; | |
781 case DIKS_PAGE_DOWN: mplayer_put_key(KEY_PAGE_DOWN);break; | |
782 case DIKS_CURSOR_UP: mplayer_put_key(KEY_UP);break; | |
783 case DIKS_CURSOR_DOWN: mplayer_put_key(KEY_DOWN);break; | |
784 case DIKS_CURSOR_LEFT: mplayer_put_key(KEY_LEFT);break; | |
785 case DIKS_CURSOR_RIGHT: mplayer_put_key(KEY_RIGHT);break; | |
786 case DIKS_INSERT: mplayer_put_key(KEY_INSERT);break; | |
787 case DIKS_DELETE: mplayer_put_key(KEY_DELETE);break; | |
788 case DIKS_HOME: mplayer_put_key(KEY_HOME);break; | |
789 case DIKS_END: mplayer_put_key(KEY_END);break; | |
790 | |
791 default:mplayer_put_key(event.key_symbol); | |
792 }; | |
793 }; | |
794 }; | |
795 // empty buffer, because of repeating (keyboard repeat is faster than key handling | |
796 // and this causes problems during seek) | |
797 // temporary workabout should be solved in the future | |
798 buffer->Reset(buffer); | |
799 | |
800 } | |
801 //if (verbose) printf ("DirectFB: Check events finished\n"); | |
802 } | |
803 | |
804 static void flip_page(void) | |
805 { | |
806 DFBSurfaceBlittingFlags flags=DSBLIT_NOFX; | |
807 | |
808 unlock(); // unlock frame & primary | |
809 | |
810 // if (verbose) printf("DirectFB: Flip page entered"); | |
811 | |
812 DFBCHECK (primary->SetBlittingFlags(primary,flags)); | |
813 | |
814 if (frame) { | |
815 if (stretch) { | |
816 DFBRectangle rect; | |
817 rect.x=xoffset; | |
818 rect.y=yoffset; | |
819 rect.w=out_width; | |
820 rect.h=out_height; | |
821 | |
822 DFBCHECK (primary->StretchBlit(primary,frame,NULL,&rect)); | |
823 | |
824 } else { | |
825 | |
826 DFBCHECK (primary->Blit(primary,frame,NULL,xoffset,yoffset)); | |
827 | |
828 }; | |
829 }; | |
830 | |
831 | |
832 if (flipping) { | |
833 DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC)); | |
834 } | |
835 | |
836 } | |
837 | |
838 | |
839 | |
840 static void uninit(void) | |
841 { | |
842 | |
843 if (verbose ) printf("DirectFB: Uninit entered\n"); | |
844 | |
845 unlock(); | |
846 | |
847 /* | |
848 * (Release) | |
849 */ | |
850 if (verbose ) printf("DirectFB: Release buffer\n"); | |
851 if (buffer) buffer->Release (buffer); | |
852 if (verbose ) printf("DirectFB: Release keyboard\n"); | |
853 if (keyboard) keyboard->Release (keyboard); | |
854 if (frame) { | |
855 if (verbose ) printf("DirectFB: Release frame\n"); | |
856 frame->Release (frame); | |
857 }; | |
858 | |
859 if (verbose ) printf("DirectFB: Release primary\n"); | |
860 if (primary) primary->Release (primary); | |
861 | |
862 // switch off BES | |
863 // if (layer) layer->SetOpacity(layer,0); | |
864 | |
865 if (layer) layer->Release(layer); | |
866 | |
867 if (verbose ) printf("DirectFB: Release DirectFB library\n"); | |
868 | |
869 dfb->Release (dfb); | |
870 | |
871 if (verbose ) printf("DirectFB: Uninit done.\n"); | |
872 } | |
873 | |
874 | |
875 static uint32_t directfb_set_video_eq(char *data, int value) //data==name | |
876 { | |
877 | |
878 DFBColorAdjustment ca; | |
879 float factor = (float)0xffff / 200.0; | |
880 | |
881 DFBDisplayLayerDescription desc; | |
882 | |
883 unlock(); | |
884 | |
885 if (layer) { | |
886 | |
887 layer->GetDescription(layer,&desc); | |
888 | |
889 ca.flags=DCAF_NONE; | |
890 | |
891 if (! strcmp( data,"brightness" )) { | |
892 if (desc.caps & DLCAPS_BRIGHTNESS) { | |
893 ca.brightness = value * factor +0x8000; | |
894 ca.flags |= DCAF_BRIGHTNESS; | |
895 if (verbose) printf("DirectFB: SetVEq Brightness 0x%X %i\n",ca.brightness,value); | |
896 } else return VO_FALSE; | |
897 } | |
898 | |
899 if (! strcmp( data,"contrast" )) { | |
900 if ((desc.caps & DLCAPS_CONTRAST)) { | |
901 ca.contrast = value * factor + 0x8000; | |
902 ca.flags |= DCAF_CONTRAST; | |
903 if (verbose) printf("DirectFB: SetVEq Contrast 0x%X %i\n",ca.contrast,value); | |
904 } else return VO_FALSE; | |
905 } | |
906 | |
907 if (! strcmp( data,"hue" )) { | |
908 if ((desc.caps & DLCAPS_HUE)) { | |
909 ca.hue = value * factor + 0x8000; | |
910 ca.flags |= DCAF_HUE; | |
911 if (verbose) printf("DirectFB: SetVEq Hue 0x%X %i\n",ca.hue,value); | |
912 } else return VO_FALSE; | |
913 } | |
914 | |
915 if (! strcmp( data,"saturation" )) { | |
916 if ((desc.caps & DLCAPS_SATURATION)) { | |
917 ca.saturation = value * factor + 0x8000; | |
918 ca.flags |= DCAF_SATURATION; | |
919 if (verbose) printf("DirectFB: SetVEq Saturation 0x%X %i\n",ca.saturation,value); | |
920 } else return VO_FALSE; | |
921 } | |
922 | |
923 if (ca.flags != DCAF_NONE) { | |
924 layer->SetColorAdjustment(layer,&ca); | |
925 return VO_TRUE; | |
926 } | |
927 } | |
928 | |
929 return VO_FALSE; | |
930 | |
931 } | |
932 | |
933 static uint32_t directfb_get_video_eq(char *data, int *value) // data==name | |
934 { | |
935 | |
936 DFBColorAdjustment ca; | |
937 float factor = 200.0 / (float)0xffff; | |
938 | |
939 DFBDisplayLayerDescription desc; | |
940 | |
941 if (layer) { | |
942 | |
943 unlock(); | |
944 | |
945 layer->GetDescription(layer,&desc); | |
946 | |
947 layer->GetColorAdjustment(layer,&ca); | |
948 | |
949 if (! strcmp( data,"brightness" )) { | |
950 if (desc.caps & DLCAPS_BRIGHTNESS) { | |
951 *value = (int) ((ca.brightness-0x8000) * factor); | |
952 if (verbose) printf("DirectFB: GetVEq Brightness 0x%X %i\n",ca.brightness,*value); | |
953 return VO_TRUE; | |
954 } else return VO_FALSE; | |
955 } | |
956 | |
957 if (! strcmp( data,"contrast" )) { | |
958 if ((desc.caps & DLCAPS_CONTRAST)) { | |
959 *value = (int) ((ca.contrast-0x8000) * factor); | |
960 if (verbose) printf("DirectFB: GetVEq Contrast 0x%X %i\n",ca.contrast,*value); | |
961 return VO_TRUE; | |
962 } else return VO_FALSE; | |
963 } | |
964 | |
965 if (! strcmp( data,"hue" )) { | |
966 if ((desc.caps & DLCAPS_HUE)) { | |
967 *value = (int) ((ca.hue-0x8000) * factor); | |
968 if (verbose) printf("DirectFB: GetVEq Hue 0x%X %i\n",ca.hue,*value); | |
969 return VO_TRUE; | |
970 } else return VO_FALSE; | |
971 } | |
972 | |
973 if (! strcmp( data,"saturation" )) { | |
974 if ((desc.caps & DLCAPS_SATURATION)) { | |
975 *value = (int) ((ca.saturation-0x8000) * factor); | |
976 if (verbose) printf("DirectFB: GetVEq Saturation 0x%X %i\n",ca.saturation,*value); | |
977 return VO_TRUE; | |
978 } else return VO_FALSE; | |
979 } | |
980 } | |
981 return VO_FALSE; | |
982 } | |
983 | |
984 static uint32_t get_image(mp_image_t *mpi) | |
985 { | |
986 | |
987 int err; | |
988 void *dst; | |
989 int pitch; | |
990 | |
991 // if (verbose) printf("DirectFB: get_image() called\n"); | |
992 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram | |
993 if(mpi->type==MP_IMGTYPE_STATIC) return VO_FALSE; // it is not static | |
994 | |
995 // printf("width=%d vs. pitch=%d, flags=0x%X \n",mpi->width,pitch,mpi->flags); | |
996 | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
997 if((mpi->width==pitch) || |
6952 | 998 (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))){ |
999 // we're lucky or codec accepts stride => ok, let's go! | |
1000 | |
1001 if (frame) { | |
1002 err = frame->Lock(frame,DSLF_WRITE,&dst,&pitch); | |
1003 framelocked=1; | |
1004 } else { | |
1005 err = primary->Lock(primary,DSLF_WRITE,&dst,&pitch); | |
1006 primarylocked=1; | |
1007 } | |
1008 | |
1009 if (err) { | |
1010 if (verbose) printf("DirectFB: DR lock failed!"); | |
1011 return VO_FALSE; | |
1012 }; | |
1013 | |
1014 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
1015 //YV12 format | |
1016 mpi->planes[0]=dst; | |
1017 if(mpi->flags&MP_IMGFLAG_SWAPPED){ | |
1018 mpi->planes[1]=dst + pitch*height; | |
1019 mpi->planes[2]=mpi->planes[1] + pitch*height/4; | |
1020 } else { | |
1021 mpi->planes[2]=dst + pitch*height; | |
1022 mpi->planes[1]=mpi->planes[2] + pitch*height/4; | |
1023 } | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
1024 mpi->width=width; |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
1025 mpi->stride[0]=pitch; |
6952 | 1026 mpi->stride[1]=mpi->stride[2]=pitch/2; |
1027 } else { | |
1028 //YUY2 and RGB formats | |
1029 mpi->planes[0]=dst; | |
1030 mpi->width=width; | |
1031 mpi->stride[0]=pitch; | |
1032 } | |
1033 mpi->flags|=MP_IMGFLAG_DIRECT; | |
1034 // if (verbose) printf("DirectFB: get_image() SUCCESS -> Direct Rendering ENABLED\n"); | |
1035 return VO_TRUE; | |
1036 | |
1037 } | |
1038 return VO_FALSE; | |
1039 } | |
1040 | |
1041 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) | |
1042 { | |
1043 int i; | |
1044 unsigned int pitch; | |
1045 void *dst; | |
1046 void *dst2; | |
1047 void *srcp; | |
1048 unsigned int p; | |
1049 | |
1050 unlock(); | |
1051 | |
1052 if (frame) { | |
1053 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); | |
1054 framelocked = 1; | |
1055 } else { | |
1056 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
1057 primarylocked = 1; | |
1058 }; | |
1059 | |
1060 p=min(w,pitch); | |
1061 | |
1062 dst += y*pitch + x; | |
1063 dst2 = dst + pitch*height - y*pitch + y*pitch/4 - x/2; | |
1064 srcp = src[0]; | |
1065 | |
1066 for (i=0;i<h;i++) { | |
1067 memcpy(dst,srcp,p); | |
1068 dst += pitch; | |
1069 srcp += stride[0]; | |
1070 } | |
1071 | |
1072 if (pixel_format == DSPF_YV12) { | |
1073 | |
1074 dst = dst2; | |
1075 srcp = src[2]; | |
1076 p = p/2; | |
1077 | |
1078 for (i=0;i<h/2;i++) { | |
1079 memcpy(dst,srcp,p); | |
1080 dst += pitch/2; | |
1081 srcp += stride[2]; | |
1082 } | |
1083 | |
1084 dst = dst2 + pitch*height/4; | |
1085 srcp = src[1]; | |
1086 | |
1087 for (i=0;i<h/2;i++) { | |
1088 memcpy(dst,srcp,p); | |
1089 dst += pitch/2; | |
1090 srcp += stride[1]; | |
1091 } | |
1092 | |
1093 } else { | |
1094 | |
1095 dst = dst2; | |
1096 srcp = src[1]; | |
1097 p = p/2; | |
1098 | |
1099 for (i=0;i<h/2;i++) { | |
1100 memcpy(dst,srcp,p); | |
1101 dst += pitch/2; | |
1102 srcp += stride[1]; | |
1103 } | |
1104 | |
1105 dst = dst2 + pitch*height/4; | |
1106 srcp = src[2]; | |
1107 | |
1108 for (i=0;i<h/2;i++) { | |
1109 memcpy(dst,srcp,p); | |
1110 dst += pitch/2; | |
1111 srcp += stride[2]; | |
1112 } | |
1113 | |
1114 } | |
1115 | |
1116 unlock(); | |
1117 | |
1118 return 0; | |
1119 } | |
1120 | |
1121 | |
1122 static uint32_t put_image(mp_image_t *mpi){ | |
1123 | |
1124 | |
1125 static IDirectFBSurface *tmp = NULL; | |
1126 DFBSurfaceDescription dsc; | |
1127 DFBRectangle rect; | |
1128 | |
1129 // if (verbose) printf("DirectFB: Put_image entered %i %i %i %i %i %i\n",mpi->x,mpi->y,mpi->w,mpi->h,mpi->width,mpi->height); | |
1130 | |
1131 unlock(); | |
1132 | |
1133 // already out? | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
1134 if((mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) { |
6952 | 1135 // if (verbose) printf("DirectFB: Put_image - nothing todo\n"); |
1136 return VO_TRUE; | |
1137 } | |
1138 | |
1139 if (mpi->flags&MP_IMGFLAG_PLANAR) { | |
1140 // memcpy all planes - sad but necessary | |
1141 int i; | |
1142 unsigned int pitch; | |
1143 void *dst; | |
1144 void *src; | |
1145 unsigned int p; | |
1146 | |
1147 // if (verbose) printf("DirectFB: Put_image - planar branch\n"); | |
1148 if (frame) { | |
1149 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); | |
1150 framelocked = 1; | |
1151 } else { | |
1152 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
1153 primarylocked = 1; | |
1154 }; | |
1155 | |
1156 p=min(mpi->w,pitch); | |
1157 | |
1158 src = mpi->planes[0]+mpi->y*mpi->stride[0]+mpi->x; | |
1159 | |
1160 for (i=0;i<mpi->h;i++) { | |
1161 memcpy(dst+i*pitch,src+i*mpi->stride[0],p); | |
1162 } | |
1163 | |
1164 if (pixel_format == DSPF_YV12) { | |
1165 | |
1166 dst += pitch*height; | |
1167 p = p/2; | |
1168 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2; | |
1169 | |
1170 for (i=0;i<mpi->h/2;i++) { | |
1171 memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p); | |
1172 } | |
1173 | |
1174 dst += pitch*height/4; | |
1175 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2; | |
1176 | |
1177 for (i=0;i<mpi->h/2;i++) { | |
1178 memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p); | |
1179 } | |
1180 | |
1181 } else { | |
1182 | |
1183 dst += pitch*height; | |
1184 p = p/2; | |
1185 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2; | |
1186 | |
1187 for (i=0;i<mpi->h/2;i++) { | |
1188 memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p); | |
1189 } | |
1190 | |
1191 dst += pitch*height/4; | |
1192 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2; | |
1193 | |
1194 for (i=0;i<mpi->h/2;i++) { | |
1195 memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p); | |
1196 } | |
1197 | |
1198 } | |
1199 unlock(); | |
1200 | |
1201 } else { | |
1202 | |
1203 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_PREALLOCATED; | |
1204 dsc.preallocated[0].data = mpi->planes[0]; | |
1205 dsc.preallocated[0].pitch = mpi->stride[0]; | |
1206 dsc.width = mpi->width; | |
1207 dsc.height = mpi->height; | |
1208 dsc.pixelformat = convformat(mpi->imgfmt); | |
1209 | |
1210 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &tmp)); | |
1211 | |
1212 rect.x=mpi->x; | |
1213 rect.y=mpi->y; | |
1214 rect.w=mpi->w; | |
1215 rect.h=mpi->h; | |
1216 | |
1217 if (frame) { | |
1218 DFBCHECK (tmp->Blit(tmp,frame,&rect,0,0)); | |
1219 } else { | |
1220 DFBCHECK (tmp->Blit(tmp,primary,&rect,xoffset,yoffset)); | |
1221 }; | |
1222 tmp->Release(tmp); | |
1223 } | |
1224 return VO_TRUE; | |
1225 } | |
1226 | |
1227 | |
1228 | |
1229 static uint32_t control(uint32_t request, void *data, ...) | |
1230 { | |
1231 switch (request) { | |
1232 case VOCTRL_QUERY_FORMAT: | |
1233 return query_format(*((uint32_t*)data)); | |
1234 case VOCTRL_GET_IMAGE: | |
1235 return get_image(data); | |
1236 case VOCTRL_DRAW_IMAGE: | |
1237 return put_image(data); | |
1238 case VOCTRL_SET_EQUALIZER: | |
1239 { | |
1240 va_list ap; | |
1241 int value; | |
1242 | |
1243 va_start(ap, data); | |
1244 value = va_arg(ap, int); | |
1245 va_end(ap); | |
1246 | |
1247 return(directfb_set_video_eq(data, value)); | |
1248 } | |
1249 case VOCTRL_GET_EQUALIZER: | |
1250 { | |
1251 va_list ap; | |
1252 int *value; | |
1253 | |
1254 va_start(ap, data); | |
1255 value = va_arg(ap, int*); | |
1256 va_end(ap); | |
1257 | |
1258 return(directfb_get_video_eq(data, value)); | |
1259 } | |
1260 }; | |
1261 return VO_NOTIMPL; | |
1262 } | |
1263 | |
1264 // unused function | |
1265 | |
1266 static uint32_t draw_frame(uint8_t *src[]) | |
1267 { | |
1268 return -1; | |
1269 } | |
1270 | |
1271 // hopefully will be removed soon | |
1272 | |
1273 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | |
1274 unsigned char *srca, int stride) | |
1275 { | |
1276 void *dst; | |
1277 int pitch; | |
1278 | |
1279 unlock(); // isnt it silly I have to unlock surface and than lock again :-) | |
1280 | |
1281 if (frame) { | |
1282 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); | |
1283 framelocked = 1; | |
1284 } else { | |
1285 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
1286 primarylocked = 1; | |
1287 }; | |
1288 | |
1289 switch(pixel_format) { | |
1290 case DSPF_RGB32: | |
1291 case DSPF_ARGB: | |
1292 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 4*x0,pitch); | |
1293 break; | |
1294 | |
1295 case DSPF_RGB24: | |
1296 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 3*x0,pitch); | |
1297 break; | |
1298 | |
1299 case DSPF_RGB16: | |
1300 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch); | |
1301 break; | |
8640 | 1302 #if DIRECTFBVERSION > 915 |
1303 case DSPF_ARGB1555: | |
1304 #else | |
6952 | 1305 case DSPF_RGB15: |
8640 | 1306 #endif |
6952 | 1307 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch); |
1308 break; | |
1309 | |
1310 case DSPF_YUY2: | |
1311 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0,pitch); | |
1312 break; | |
1313 | |
1314 case DSPF_UYVY: | |
1315 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0 + 1,pitch); | |
1316 break; | |
1317 | |
1318 case DSPF_I420: | |
1319 case DSPF_YV12: | |
1320 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 1*x0,pitch); | |
1321 break; | |
1322 } | |
1323 | |
1324 unlock(); | |
1325 } | |
1326 | |
1327 static void draw_osd(void) | |
1328 { | |
1329 vo_draw_text(width,height,draw_alpha); | |
1330 } |