DisplayDispatcher::DisplayDispatcher()
    {
        int 				err;
        hw_module_t* 		module;
        status_t 			result;
	    
	    err = hw_get_module(DISPLAY_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
	    if (err == 0) 
	    {
            //LOGD("DisplayDispatcher createing1 err = %d!\n",err);
            
		    err = display_open(module, &mDevice);
		    if (err == 0) 
		    {
		    	LOGE("Open Display Device Failed!\n");
		    } 
	    } 
        else
        {
            LOGD("hw_get display module Failed!\n");
        }
	    
	    //LOGD("DisplayDispatcher createing err2 = %d!\n",err);

        mThread = new DisplayDispatcherThread(mDevice);
        result = mThread->run("DisplayDispatcheR", PRIORITY_HIGHEST);
	    if (result) 
	    {
	        LOGE("Could not start DisplayDispatcheR thread due to error %d.", result);
	
	        mThread->requestExit();
	    }
    }
Пример #2
0
int main(int argc, char *argv[])
{
	const unsigned int width = 640;
	const unsigned int height = 480;
	struct display *display;
	struct window *window;

	display = display_open();
	if (!display) {
		fprintf(stderr, "failed to open display\n");
		return 1;
	}

	window = window_create(display, argv[0], 0, 0, width, height);
	if (!window) {
		fprintf(stderr, "failed to create window\n");
		return 1;
	}

	window_show(window);

	event_loop(window);

	window_close(window);
	display_close(display);
	return 0;
}
Пример #3
0
static gboolean
gst_sh_video_sink_start (GstBaseSink *bsink)
{
	GstSHVideoSink *sink = GST_SH_VIDEO_SINK (bsink);

	GST_DEBUG_OBJECT(sink,"START, opening devices.");

	sink->display = display_open();
	if (!sink->display) {
		GST_ELEMENT_ERROR((GstElement *) sink, CORE, FAILED,
				  ("Error opening fb device"), (NULL));
	}

	return TRUE;
}
Пример #4
0
void file_is_loaded()
{
    List *GOPs;
    List *pictures;
    gchar buf[128];
    char *pathname;
    int picture_count = 0;

    // toggle our file options
    gtk_widget_set_sensitive(menu_load_mpeg2, FALSE);
    gtk_widget_set_sensitive(menu_load_clip_list, FALSE);
    gtk_widget_set_sensitive(menu_save_clip_list, TRUE);
    gtk_widget_set_sensitive(menu_export_mpeg2, TRUE);
    gtk_widget_set_sensitive(menu_close, TRUE);

    gtk_widget_set_sensitive(menu_delete, TRUE);
    gtk_widget_set_sensitive(menu_clear, TRUE);

    gtk_widget_set_sensitive(menu_video_window, TRUE);

    gtk_widget_set_sensitive(button_run, TRUE);
    gtk_widget_set_sensitive(button_prev, TRUE);
    gtk_widget_set_sensitive(button_next, TRUE);
    gtk_widget_set_sensitive(button_refresh, TRUE);
    gtk_widget_set_sensitive(button_start_mark, TRUE);
    gtk_widget_set_sensitive(button_end_mark, FALSE);

    // adjust the slider scales
    gtk_range_set_range(GTK_RANGE(GOP_selector), 0.0, (gdouble) (mpeg2parser->numGOPs()));
    gtk_spin_button_set_range(GTK_SPIN_BUTTON(GOP_selector_spinbutton), 0.0, (gdouble) (mpeg2parser->numGOPs()-1));

    // start decode window
    display_close(engine);
    engine = display_open(desired_output,opt_pipe,opt_videoout,opt_show_states);
    set_GOP_selected(0);
    flush();
    slider_updated_actions(0);

    pathname = mpeg2parser->getFilename();
    if (!pathname)
        pathname = "unknown";
    gtk_label_set_text(GTK_LABEL(GOP_label_filename), pathname);
}
Пример #5
0
    DisplayDispatcher::DisplayDispatcher(const sp<SurfaceFlinger>& flinger)
    {
        int                 err;
        hw_module_t*         module;
        status_t             result;
        char property[PROPERTY_VALUE_MAX];
        err = hw_get_module(DISPLAY_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
        if (err == 0)
        {
            err = display_open(module, &mDevice);
        }
        else
        {
            ALOGW("hw_get display module Failed!\n");
        }

        mWifiDisplayBufHandle = 0;
        mStartConvert = false;

        mFlinger   = flinger;

       if (property_get("ro.display.switch", property, NULL) > 0)
       {
            if (atoi(property) == 1)
            {
                mThread = new DisplayDispatcherThread(mDevice,mFlinger);
                result = mThread->run("DisplayDispatcheR", PRIORITY_HIGHEST);
                if (result)
                {
                    ALOGE("Could not start DisplayDispatcher thread due to error %d.", result);

                    mThread->requestExit();
                }

                ALOGD("display dispatcher enabled");
            }
        }
        else
        {
                ALOGW("display dispatcher disable");
        }

        if (property_get("ro.wifidisplay.switch", property, NULL) > 0) //
        {
            if (atoi(property) == 1) //
            {
                ALOGW("wifidisplay dispatcher enabled");
                if(mDevice)
                {
                    mWifiDisplayBufWidth      = mDevice->getdisplayparameter(mDevice,0,DISPLAY_FBWIDTH);
                    mWifiDisplayBufHeight     = mDevice->getdisplayparameter(mDevice,0,DISPLAY_FBHEIGHT);
                    mWifiDisplayBufFormat     = DISPLAY_FORMAT_PYUV420UVC;
                    ALOGD("mSendWidth = %d,mSendHeight = %d,mSendFormat = %d\n",mWifiDisplayBufWidth,mWifiDisplayBufHeight,mWifiDisplayBufFormat);
                    mWifiDisplayBufHandle  = mDevice->requestdispbuf(mDevice,mWifiDisplayBufWidth,mWifiDisplayBufHeight,mWifiDisplayBufFormat,DISPLAYDISPATCH_MAXBUFNO);
                    if(mWifiDisplayBufHandle == 0)
                    {
                        ALOGV("display device request buffer failed! width = %d,height = %d,format = %d\n",mWifiDisplayBufWidth,mWifiDisplayBufHeight,mWifiDisplayBufFormat);
                    }

                    mThread->setConvertBufParam(mWifiDisplayBufHandle,mWifiDisplayBufWidth,mWifiDisplayBufHeight,mWifiDisplayBufFormat);
                }
            }
            else
            {
                ALOGW("wifidisplay dispatcher disable");
            }
        }
        else
        {
            ALOGW("wifidisplay dispatcher disable");
        }
            //LOGD("DisplayDispatcher createing err2 = %d!\n",err);
    }
Пример #6
0
int
main(int argc, char **argv)
{
    AVFormatContext *afc;
    AVStream *st;
    AVPacket pk;
    struct frame_format frame_fmt = { 0 };
    const struct pixconv *pixconv = NULL;
    const struct memman *memman = NULL;
    const struct codec *codec = NULL;
    struct frame_format dp;
    int bufsize = BUFFER_SIZE;
    pthread_t dispt;
    unsigned flags = OFBP_DOUBLE_BUF;
    char *test_param = NULL;
    char *dispdrv = NULL;
    char *timer_drv = NULL;
    char *memman_drv = NULL;
    char *pixconv_drv = NULL;
    char *codec_drv = NULL;
    int opt;
    int ret = 0;

#define error(n) do { ret = n; goto out; } while (0)

    while ((opt = getopt(argc, argv, "b:d:fFM:P:st:T:v:")) != -1) {
        switch (opt) {
        case 'b':
            bufsize = strtol(optarg, NULL, 0) * 1048576;
            break;
        case 'd':
            dispdrv = optarg;
            break;
        case 'F':
            noaspect = 1;
        case 'f':
            flags |= OFBP_FULLSCREEN;
            break;
        case 'M':
            memman_drv = optarg;
            break;
        case 'P':
            pixconv_drv = optarg;
            break;
        case 's':
            flags &= ~OFBP_DOUBLE_BUF;
            break;
        case 't':
            test_param = optarg;
            break;
        case 'T':
            timer_drv = optarg;
            break;
        case 'v':
            codec_drv = optarg;
            break;
        }
    }

    argc -= optind;
    argv += optind;

    if (test_param)
        return speed_test(dispdrv, memman_drv, pixconv_drv, test_param, flags);

    if (argc < 1)
        return 1;

    av_register_all();
    avcodec_register_all();

    afc = open_file(argv[0]);

    st = find_stream(afc);
    if (!st) {
        fprintf(stderr, "No video streams found.\n");
        exit(1);
    }

    codec = find_driver(codec_drv, NULL, ofbp_codec_start);
    if (!codec) {
        fprintf(stderr, "Decoder '%s' not found\n", codec_drv);
        error(1);
    }

    if (codec->open(NULL, st->codec, &frame_fmt)) {
        fprintf(stderr, "Error opening decoder\n");
        error(1);
    }

    if (!frame_fmt.width) {
        fprintf(stderr, "Decoder error: frame size not specified\n");
        error(1);
    }

    dp.pixfmt = frame_fmt.pixfmt;
    display = display_open(dispdrv, &dp, &frame_fmt);
    if (!display)
        error(1);

    set_scale(&dp, &frame_fmt, flags);

    if (display->memman) {
        if (dp.pixfmt == frame_fmt.pixfmt) {
            memman = display->memman;
        } else if (display->flags & OFBP_PRIV_MEM) {
            fprintf(stderr, "Decoder/display pixel format mismatch\n");
            error(1);
        }
    }

    if (!memman)
        memman = find_driver(memman_drv, NULL, ofbp_memman_start);
    if (!memman)
        error(1);

    if ((codec->flags & OFBP_PHYS_MEM) && !(memman->flags & OFBP_PHYS_MEM)) {
        fprintf(stderr, "Incompatible decoder/memman\n");
        error(1);
    }

    if (memman->alloc_frames(&frame_fmt, bufsize, &frames, &num_frames))
        error(1);

    if (memman != display->memman) {
        pixconv = pixconv_open(pixconv_drv, &frame_fmt, &dp);
        if (!pixconv)
            error(1);
        if ((pixconv->flags & OFBP_PHYS_MEM) &&
            !(memman->flags & display->flags & OFBP_PHYS_MEM)) {
            fprintf(stderr, "Incompatible display/memman/pixconv\n");
            error(1);
        }
    }

    timer = timer_open(timer_drv);
    if (!timer)
        error(1);

    init_frames(&frame_fmt);

    if (display->enable(&frame_fmt, flags, pixconv, &dp))
        error(1);

    pthread_mutex_init(&disp_lock, NULL);
    sem_init(&disp_sem, 0, 0);

    signal(SIGINT, sigint);

    pthread_create(&dispt, NULL, disp_thread, st);

    while (!stop && !av_read_frame(afc, &pk)) {
        if (pk.stream_index == st->index)
            if (codec->decode(&pk))
                stop = 1;
        av_free_packet(&pk);
    }

    if (!stop) {
        sem_post(&disp_sem);
        while (disp_tail != -1)
            usleep(100000);
    }

    stop = 1;
    sem_post(&disp_sem);
    pthread_join(dispt, NULL);

out:
    if (afc) av_close_input_file(afc);

    if (codec)   codec->close();
    if (timer)   timer->close();
    if (memman)  memman->free_frames(frames, num_frames);
    if (display) display->close();
    if (pixconv) pixconv->close();

    return ret;
}
Пример #7
0
static int
speed_test(const char *drv, const char *mem, const char *conv,
           char *size, unsigned disp_flags)
{
    const struct pixconv *pixconv = NULL;
    const struct memman *memman = NULL;
    struct frame_format dp = { 0 };
    struct frame_format ff = { 0 };
    struct timespec t1, t2;
    unsigned w, h = 0;
    unsigned n = 1000;
    unsigned bufsize;
    char *ss = size;
    int i, j;

    w = strtoul(size, &size, 0);
    if (*size++)
        h = strtoul(size, &size, 0);
    if (*size++)
        n = strtoul(size, NULL, 0);

    if (!w || !h || !n) {
        fprintf(stderr, "Invalid size/count '%s'\n", ss);
        return 1;
    }

    ff.width  = ALIGN(w, 32);
    ff.height = ALIGN(h, 32);
    ff.disp_x = 0;
    ff.disp_y = 0;
    ff.disp_w = w;
    ff.disp_h = h;

    dp.pixfmt = ff.pixfmt = PIX_FMT_YUV420P;
    display = display_open(drv, &dp, &ff);
    if (!display)
        return 1;

    set_scale(&dp, &ff, disp_flags);

    if (display->memman) {
        memman = display->memman;
        ff.pixfmt = dp.pixfmt;
    }

    if (!memman)
        memman = find_driver(mem, NULL, ofbp_memman_start);

    if (memman->alloc_frames(&ff, 0, &frames, &num_frames))
        return 1;

    if (memman != display->memman) {
        pixconv = pixconv_open(conv, &ff, &dp);
        if (!pixconv)
            return 1;
        if ((pixconv->flags & OFBP_PHYS_MEM) &&
            !(memman->flags & display->flags & OFBP_PHYS_MEM)) {
            fprintf(stderr, "Incompatible display/memman/pixconv\n");
            return 1;
        }
    }

    init_frames(&ff);

    if (display->enable(&ff, disp_flags, pixconv, &dp))
        return 1;

    bufsize = ff.disp_w * ff.disp_h * 3 / 2;

    test_pattern(frames, num_frames, &ff);

    signal(SIGINT, sigint);

    clock_gettime(CLOCK_REALTIME, &t1);

    for (i = 0; i < n && !stop; i++) {
        struct frame *f = ofbp_get_frame();
        display->prepare(f);
        display->show(f);
    }

    clock_gettime(CLOCK_REALTIME, &t2);
    j = ts_diff_ms(&t2, &t1);
    fprintf(stderr, "%d ms, %d fps, read %lld B/s, write %lld B/s\n",
            j, i*1000 / j, 1000LL*i*bufsize / j, 2000LL*i*w*h / j);

    memman->free_frames(frames, num_frames);
    display->close();
    if (pixconv) pixconv->close();

    return 0;
}
Пример #8
0
Файл: mtr.c Проект: RichiH/mtr
int main(int argc, char **argv)
{
  struct hostent *  host                = NULL;
  int               net_preopen_result;
#ifdef ENABLE_IPV6
  struct addrinfo       hints, *res;
  int                   error;
  struct hostent        trhost;
  char *                alptr[2];
  struct sockaddr_in *  sa4;
  struct sockaddr_in6 * sa6;
#endif

  /*  Get the raw sockets first thing, so we can drop to user euid immediately  */

  if ( ( net_preopen_result = net_preopen () ) ) {
    fprintf( stderr, "mtr: unable to get raw sockets.\n" );
    exit( EXIT_FAILURE );
  }

  /*  Now drop to user permissions  */
  if (setgid(getgid()) || setuid(getuid())) {
    fprintf (stderr, "mtr: Unable to drop permissions.\n");
    exit(1);
  }

  /*  Double check, just in case  */
  if ((geteuid() != getuid()) || (getegid() != getgid())) {
    fprintf (stderr, "mtr: Unable to drop permissions.\n");
    exit(1);
  }

  /* reset the random seed */
  srand (getpid());

  display_detect(&argc, &argv);

  /* The field options are now in a static array all together,
     but that requires a run-time initialization. */
  init_fld_options ();

  parse_mtr_options (getenv ("MTR_OPTIONS"));

  parse_arg (argc, argv);

  while (optind < argc) {
    char* name = argv[optind++];
    append_to_names(argv[0], name);
  }

  /* Now that we know mtrtype we can select which socket to use */
  if (net_selectsocket() != 0) {
    fprintf( stderr, "mtr: Couldn't determine raw socket type.\n" );
    exit( EXIT_FAILURE );
  }

  if (PrintVersion) {
    printf ("mtr " MTR_VERSION "\n");
    exit(0);
  }

  if (PrintHelp) {
    printf("usage: %s [-hvrwctglspniuT46] [--help] [--version] [--report]\n"
	   "\t\t[--report-wide] [--report-cycles=COUNT] [--curses] [--gtk]\n"
           "\t\t[--csv|-C] [--raw] [--split] [--mpls] [--no-dns] [--show-ips]\n"
           "\t\t[--address interface] [--filename=FILE|-F]\n" /* BL */
#ifdef IPINFO
           "\t\t[--ipinfo=item_no|-y item_no]\n"
           "\t\t[--aslookup|-z]\n"
#endif
           "\t\t[--psize=bytes/-s bytes]\n"            /* ok */
           "\t\t[--report-wide|-w] [-u|-T] [--port=PORT] [--timeout=SECONDS]\n"            /* rew */
	   "\t\t[--interval=SECONDS] HOSTNAME\n", argv[0]);
    exit(0);
  }

  time_t now = time(NULL);

  if (!names) append_to_names (argv[0], "localhost"); // default: localhost. 

  names_t* head = names;
  while (names != NULL) {

    Hostname = names->name;
    //  if (Hostname == NULL) Hostname = "localhost"; // no longer necessary.
    if (gethostname(LocalHostname, sizeof(LocalHostname))) {
      strcpy(LocalHostname, "UNKNOWNHOST");
    }

    if (net_preopen_result != 0) {
      fprintf(stderr, "mtr: Unable to get raw socket.  (Executable not suid?)\n");
      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
      else {
        names = names->next;
        continue;
      }
    }

#ifdef ENABLE_IPV6
    /* gethostbyname2() is deprecated so we'll use getaddrinfo() instead. */
    bzero( &hints, sizeof hints );
    hints.ai_family = af;
    hints.ai_socktype = SOCK_DGRAM;
    error = getaddrinfo( Hostname, NULL, &hints, &res );
    if ( error ) {
      if (error == EAI_SYSTEM)
         perror ("Failed to resolve host");
      else
         fprintf (stderr, "Failed to resolve host: %s\n", gai_strerror(error));

      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
      else {
        names = names->next;
        continue;
      }
    }
    /* Convert the first addrinfo into a hostent. */
    host = &trhost;
    bzero( host, sizeof trhost );
    host->h_name = res->ai_canonname;
    host->h_aliases = NULL;
    host->h_addrtype = res->ai_family;
    af = res->ai_family;
    host->h_length = res->ai_addrlen;
    host->h_addr_list = alptr;
    switch ( af ) {
    case AF_INET:
      sa4 = (struct sockaddr_in *) res->ai_addr;
      alptr[0] = (void *) &(sa4->sin_addr);
      break;
    case AF_INET6:
      sa6 = (struct sockaddr_in6 *) res->ai_addr;
      alptr[0] = (void *) &(sa6->sin6_addr);
      break;
    default:
      fprintf( stderr, "mtr unknown address type\n" );
      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
      else {
        names = names->next;
        continue;
      }
    }
    alptr[1] = NULL;
#else
      host = gethostbyname(Hostname);
    if (host == NULL) {
      herror("mtr gethostbyname");
      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
      else {
        names = names->next;
        continue;
      }
    }
    af = host->h_addrtype;
#endif

    if (net_open(host) != 0) {
      fprintf(stderr, "mtr: Unable to start net module.\n");
      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
      else {
        names = names->next;
        continue;
      }
    }

    if (net_set_interfaceaddress (InterfaceAddress) != 0) {
      fprintf( stderr, "mtr: Couldn't set interface address.\n" );
      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
      else {
        names = names->next;
        continue;
      }
    }

    lock(argv[0], stdout);
      display_open();
      dns_open();

      display_mode = 0;
      display_loop();

      net_end_transit();
      display_close(now);
    unlock(argv[0], stdout);

    if ( DisplayMode != DisplayCSV ) break;
    else names = names->next;

  }

  net_close();

  while (head != NULL) {
    names_t* item = head;
    free(item->name); item->name = NULL;
    head = head->next;
    free(item); item = NULL;
  }
  head=NULL;

  return 0;
}
Пример #9
0
extern "C" int main(int argc , char** argv)
{
	int preview_width = 640;
	int preview_height = 480;

	V4l2 * camera = new V4l2(NULL, preview_width, preview_height);
	camera->v4l2_config(preview_width, preview_height, V4l2_YUV422P);

	display_cfg * disconf = NULL;

	int ret = display_open(&disconf);
	if(ret != 0)
	{
		printf("display_open is error %d\n", ret);
	}
	
	disconf->bpp = 16;
	disconf->format = FORMAT_PLANAR_422;
	disconf->screen_width = 320;
	disconf->screen_height = 480;
	disconf->screen_pos_x = 0;
	disconf->screen_pos_y = 0;
	disconf->step = 640;
	disconf->height = 480;

    ret = display_config(disconf);
	if( ret != 0 )
	{
		display_close(&disconf);
		printf("overlay2 config error... close");
	}

	unsigned char * src[3] = {0};
	while(1)
	{
		if(!camera->getNextFrameAsYuv422(src))
		{
			printf("getNextFrameAsYuv422 is error\n");

			goto  camera_stop;
			break;
		}

		ret = copy_to_overlay(disconf, src);
		if(ret != 0)
		{
			printf("copy_to_overlay is error %d\n", ret);
			
			goto camera_stop;
			break;
		}
	
	};

camera_stop:
	
		delete camera;
		display_close(&disconf);

		return 0;
};
void *
evas_software_wince_gapi_init(HWND window,
                              int  width,
                              int  height)
{
   WCHAR                        oemstr[100];
   _GAPI_Display_Properties     prop;
   HMODULE                      gapi_lib;
   Evas_Engine_WinCE_GAPI_Priv *priv;

   gapi_display_open            display_open = NULL;
   gapi_display_close           display_close = NULL;
   gapi_display_properties_get  display_properties_get = NULL;
   gapi_draw_begin              draw_begin = NULL;
   gapi_draw_end                draw_end = NULL;

   priv = (Evas_Engine_WinCE_GAPI_Priv *)malloc(sizeof(Evas_Engine_WinCE_GAPI_Priv));
   if (!priv)
     return NULL;

   gapi_lib = LoadLibrary(L"\\Windows\\gx.dll");
   if (!gapi_lib)
     {
        gapi_lib = LoadLibrary(L"gx.dll");
        if (!gapi_lib)
          {
             ERR("[Engine] [WinCE GAPI] Can not load gx.dll");
             goto free_priv;
          }
     }

   LINK(display_open, display_open, L"?GXOpenDisplay@@YAHPAUHWND__@@K@Z");
   LINK(display_close, display_close, L"?GXCloseDisplay@@YAHXZ");
   LINK(display_properties_get, display_properties_get, L"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ");
   LINK(draw_begin, draw_begin, L"?GXBeginDraw@@YAPAXXZ");
   LINK(draw_end, draw_end, L"?GXEndDraw@@YAHXZ");
   LINK(suspend, suspend, L"?GXSuspend@@YAHXZ" );
   LINK(resume, resume, L"?GXResume@@YAHXZ" );

   if (!display_open ||
       !display_close ||
       !display_properties_get ||
       !draw_begin ||
       !draw_end ||
       !suspend ||
       !resume)
     {
	ERR("[Engine] [WinCE GAPI] Can not find valid symbols");
        goto free_lib;
     }

   if (!display_open(window, GX_FULLSCREEN))
     {
	ERR("[Engine] [WinCE GAPI] Can not open display");
        goto free_lib;
     }

   prop = display_properties_get();

   // verify pixel format
   if(!(prop.ffFormat & kfDirect565) || (prop.cBPP != 16))
     {
        ERR("[Engine] [WinCE GAPI] display format mismatch\n");
        goto close_display;
     }

   // verify we have a vga device
   if ((GetSystemMetrics(SM_CXSCREEN) != (int)prop.cxWidth) ||
       (GetSystemMetrics(SM_CYSCREEN) != (int)prop.cyHeight))
     {
        ERR("[Engine] [WinCE GAPI] display size mismatch\n");
        goto close_display;
     }

   priv->lib = gapi_lib;
   priv->close_display = display_close;
   priv->draw_begin = draw_begin;
   priv->draw_end = draw_end;

   /* GAPI on Ipaq H38** and H39** is completely buggy */
   /* They are detected as portrait device (width = 240 and height = 320) */
   /* but the framebuffer is managed like a landscape device : */
   /*
     240
 +---------+
 |         |
 |         |
 |         |
 |         |
 |         | 320
 | ^^^     |
 | |||     |
 | |||     |
 | |||     |
 +---------+
  ---->

   */
   /* So these devices are considered as landscape devices */
   /* and width and height are switched. */
   /* Other devices are managed normally : */
   /*
     240
  +---------+
| |--->     |
| |--->     |
| |--->     |
v |         |
  |         | 320
  |         |
  |         |
  |         |
  |         |
  +---------+

    */

   SystemParametersInfo (SPI_GETOEMINFO, sizeof (oemstr), oemstr, 0);

   if (((oemstr[12] == 'H') &&
        (oemstr[13] == '3') &&
        (oemstr[14] == '8')) ||
       ((oemstr[12] == 'H') &&
        (oemstr[13] == '3') &&
        (oemstr[14] == '9')))
     {
        _GXDeviceInfo gxInfo = { 0 };
        HDC           dc;
        int           result;

        priv->width = prop.cyHeight;
        priv->height = prop.cxWidth;
        priv->stride = prop.cbxPitch;

        dc = GetDC (window);
        if (!dc)
          {
             ERR("[Engine] [WinCE GAPI] Can not get device\n");
             goto close_display;
          }

        gxInfo.Version = 100;
        result = ExtEscape(dc, GETGXINFO, 0, NULL, sizeof(gxInfo),
                           (char *) &gxInfo);
        if (result <= 0)
          {
             ERR("[Engine] [WinCE GAPI] ExtEscape failed\n");
             ReleaseDC(window, dc);
             goto close_display;
          }

        priv->buffer = gxInfo.pvFrameBuffer;
        ReleaseDC(window, dc);
     }
   else
     {
        priv->width = prop.cxWidth;
        priv->height = prop.cyHeight;
        priv->stride = prop.cbyPitch;
        priv->buffer = NULL;
     }

   if ((priv->width != width) ||
       (priv->height != height))
     {
        ERR("[Engine] [WinCE GAPI] Size mismatch\n");
        ERR("[Engine] [WinCE GAPI] asked: %dx%d\n", width, height);
        ERR("[Engine] [WinCE GAPI] got  : %dx%d\n", priv->width, priv->height);
        goto close_display;
     }

   return priv;

 close_display:
   display_close();
 free_lib:
   FreeLibrary(gapi_lib);
 free_priv:
   free(priv);
   return NULL;
}