/* directfb includes */ #include /* other things */ #include #include #include #include #include #include #include #include #include #include #include static IDirectFB *dfb; static IDirectFBDisplayLayer *crtc2; static IDirectFBSurface *c2frame; static DFBSurfacePixelFormat frame_format; static IDirectFBInputDevice *keyboard; static IDirectFBEventBuffer *buffer = NULL; static int screen_width = 0; static int screen_height = 0; static void *screen_framebuffer = 0; static int screen_pitch = 0; void dfb_lockframebuffer( void ) { c2frame->Lock( c2frame, DSLF_WRITE, &screen_framebuffer, &screen_pitch ); } void dfb_unlockframebuffer( void ) { c2frame->Unlock( c2frame ); } unsigned char *dfb_getframebuffer( void ) { return (unsigned char *) screen_framebuffer; } int dfb_getcurrentoutputfield( void ) { int fieldid; crtc2->GetCurrentOutputField( crtc2, &fieldid ); return fieldid; } int dfb_get_width( void ) { return screen_width; } int dfb_get_height( void ) { return screen_height; } int dfb_get_pitch( void ) { return screen_pitch; } void dfb_uninit( void ) { if( buffer ) { buffer->Release( buffer ); } if( keyboard ) { keyboard->Release( keyboard ); } if( c2frame ) { c2frame->Release( c2frame ); } if( crtc2 ) { crtc2->Release( crtc2 ); } if( dfb ) { dfb->Release( dfb ); } } int dfb_pollevents( void ) { DFBInputEvent event; if (buffer->GetEvent( buffer, DFB_EVENT( &event )) == DFB_OK) { if (event.type == DIET_KEYPRESS) { switch (event.key_symbol) { case DIKS_ESCAPE: return 1; break; default: } } } /* * empty buffer, because of repeating * keyboard repeat is faster than key handling and this causes problems during seek * temporary workabout. should be solved in the future */ buffer->Reset( buffer ); return 0; } int dfb_init( const char *fb_dev_name, int pal_mode ) { DFBDisplayLayerConfig dlc; DFBDisplayLayerConfigFlags failed; DirectFBInit( 0, 0 ); DirectFBSetOption( "fbdev", fb_dev_name ); DirectFBSetOption( "no-cursor", "" ); DirectFBSetOption( "bg-color", "00000000" ); DirectFBSetOption( "matrox-crtc2", "" ); DirectFBSetOption( "matrox-tv-standard", pal_mode ? "pal" : "ntsc" ); DirectFBCreate( &dfb ); dfb->GetDisplayLayer( dfb, 2, &crtc2 ); if( !crtc2 ) { fprintf( stderr, "failure, exiting\n" ); dfb_uninit(); return 0; } crtc2->SetCooperativeLevel( crtc2, DLSCL_EXCLUSIVE ); dfb->GetInputDevice( dfb, DIDID_KEYBOARD, &keyboard ); keyboard->CreateEventBuffer( keyboard, &buffer ); buffer->Reset( buffer ); dlc.flags = DLCONF_PIXELFORMAT; // | DLCONF_BUFFERMODE; dlc.buffermode = 0; // DLBM_BACKVIDEO; //dlc.pixelformat = DSPF_ARGB; dlc.pixelformat = DSPF_YUY2; //dlc.pixelformat = DSPF_RGB32; if( crtc2->TestConfiguration( crtc2, &dlc, &failed ) != DFB_OK ) { fprintf( stderr, "config tested and failed.\n" ); return 0; } crtc2->SetConfiguration( crtc2, &dlc ); crtc2->GetSurface( crtc2, &c2frame ); c2frame->GetSize( c2frame, &screen_width, &screen_height ); fprintf( stderr, "DirectFB: Screen is %d x %d\n", screen_width, screen_height ); c2frame->GetPixelFormat( c2frame, &frame_format ); fprintf( stderr, "DirectFB: Frame format = " ); switch (frame_format) { case DSPF_ARGB: fprintf( stderr, "ARGB\n" ); break; case DSPF_RGB32: fprintf( stderr, "RGB32\n" ); break; case DSPF_RGB24: fprintf( stderr, "RGB24\n" ); break; case DSPF_RGB16: fprintf( stderr, "RGB16\n" ); break; case DSPF_RGB15: fprintf( stderr, "RGB15\n" ); break; case DSPF_YUY2: fprintf( stderr, "YUY2\n" ); break; case DSPF_UYVY: fprintf( stderr, "UYVY\n" ); break; case DSPF_YV12: fprintf( stderr, "YV12\n" ); break; case DSPF_I420: fprintf( stderr, "I420\n" ); break; default: fprintf( stderr, "unknown\n" ); } crtc2->SetOpacity( crtc2, 0xff ); return 1; } void dfb_waitforsync( void ) { dfb->WaitForSync( dfb ); }