clinuxframebufferdirectfb

DirectFB tutorial invalid argument


I don't seem to be able to launch DirectFB so that it would start without problems. I get "invalid argument" when ever I try to access functions after DFBCHECK (DirectFBCreate (&dfb)); I try to run simple example from tutorials. Code is bellow:

 #include <stdio.h>
#include <unistd.h>
#include <directfb.h>

static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static int screen_width  = 0;
static int screen_height = 0;

#define DFBCHECK(x...)                                         \
  {                                                            \
    DFBResult err = x;                                         \
                                                               \
    if (err != DFB_OK)                                         \
      {                                                        \
        fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
        DirectFBErrorFatal( #x, err );                         \
      }                                                        \
  }

int main (int argc, char **argv)
{
   int argx = 2;
   char *argData[] = {"self","--dfb:system=fbdev,disable-module=keyboard,disable-module=joystick,no-hardware",0};
   char **argPointer = argData;

   DFBSurfaceDescription dsc;
   DFBCHECK (DirectFBInit (&argx,&argPointer));
   DFBCHECK (DirectFBCreate (&dfb));
   DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
   dsc.flags = DSDESC_CAPS;
   dsc.caps  = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
   DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
   DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
   DFBCHECK (primary->FillRectangle (primary, 0, 0, screen_width, screen_height));
   DFBCHECK (primary->SetColor (primary, 0x80, 0x80, 0xff, 0xff));
   DFBCHECK (primary->DrawLine (primary,
                                  0, screen_height / 2,
                   screen_width - 1, screen_height / 2));

   DFBCHECK (primary->Flip (primary, NULL, 0));
   sleep (5);
   primary->Release( primary );
   dfb->Release( dfb );
   return 23;
}

As you can see I provide arguments in hard coded char*. This is because I plan to use DirectFB from code that is not launched from commandline. Code is compiled with command " gcc -I/usr/local/include/directfb dfbtest.c -o dfbtest -ldirectfb"

This generates an error:

   ~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.2.10 |~~~~~~~~~~~~~~~~~~~~~~~~~~
    (c) 2001-2008  The world wide DirectFB Open Source Community
    (c) 2000-2004  Convergence (integrated media) GmbH
  ----------------------------------------------------------------

(*) DirectFB/Core: Single Application Core. (2012-05-21 06:43)

(*) Direct/Thread: Started 'VT Switcher' (3285) [CRITICAL OTHER/OTHER 0/0] <8388608>...

(*) Direct/Modules: suppress module 'joystick'

(*) Direct/Modules: suppress module 'keyboard'

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: Lid Switch (1) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: Power Button (2) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: Sleep Button (3) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: Power Button (4) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: Apple Computer Apple Internal K (5) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: Apple Computer Apple Internal K (6) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: Logitech USB-PS/2 Optical Mouse (7) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: appletouch (8) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: applesmc (9) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: HDA Intel SPDIF In (10) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: HDA Intel Line (11) 0.1 (directfb.org)

(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: HDA Intel Headphone (12) 0.1 (directfb.org)

(*) Direct/Thread: Started 'PS/2 Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: IMPS/2 Mouse (1) 1.0 (directfb.org)

(*) Direct/Thread: Started 'PS/2 Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/Input: IMPS/2 Mouse (2) 1.0 (directfb.org)

(*) DirectFB/Genefx: MMX detected and enabled

(*) DirectFB/Graphics: MMX Software Rasterizer 0.6 (directfb.org)

(*) DirectFB/Core/WM: Default 0.3 (directfb.org)

(*) FBDev/Surface: Allocated 640x480 32 bit LUT8 buffer (index 0) at offset 0 and pitch 5888.

(*) FBDev/Mode: Setting 640x480 LUT8

(*) FBDev/Mode: Switched to 640x480 (virtual 640x480) at 8 bit (LUT8), pitch 5888 dfbtest.c <30>:

(#) DirectFBError [dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)]: Invalid argument!

(!!!) * WARNING [Application exited without deinitialization of DirectFB!] * [../../../src/core/core.c:859 in dfb_core_deinit_check()]

Any ideas how to debug further would be appreciated. I am running this on Ubuntu 12. something with old MacBook Pro that has Radeon chip. The result is the same if I run this on console or under X11. Screen flickers so that framebuffer starts but it crashes on this setcooperativelevel call.


Solution

  • So this was version compatibility issue. Headers were included from later version of DirectFB than the library that was linked. Linking against correct version of the DirectFB library removed the problem.