~sergiusens/libhybris/autotests

« back to all changes in this revision

Viewing changes to hybris/egl/platforms/fbdev/eglplatform_fbdev.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2013-06-04 07:33:11 UTC
  • Revision ID: package-import@ubuntu.com-20130604073311-20ldi2hm1axkvjl1
Tags: upstream-0.1.0+git20130601+dfb2e26
ImportĀ upstreamĀ versionĀ 0.1.0+git20130601+dfb2e26

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <ws.h>
 
2
#include "fbdev_window.h"
 
3
#include <malloc.h>
 
4
#include <assert.h>
 
5
#include <fcntl.h>
 
6
#include <stdio.h>
 
7
#include <sys/stat.h>
 
8
#include <unistd.h>
 
9
#include <assert.h>
 
10
extern "C" {
 
11
#include <eglplatformcommon.h>
 
12
};
 
13
 
 
14
static int inited = 0;
 
15
static gralloc_module_t *gralloc = 0;
 
16
static framebuffer_device_t *framebuffer = 0;
 
17
static alloc_device_t *alloc = 0;
 
18
 
 
19
extern "C" int fbdevws_IsValidDisplay(EGLNativeDisplayType display)
 
20
{
 
21
        if (__sync_fetch_and_add(&inited,1)==0)
 
22
        {
 
23
                int err;
 
24
                err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **) &gralloc);
 
25
                if (gralloc==NULL) {
 
26
                        fprintf(stderr, "failed to get gralloc module: (%s)\n",strerror(-err));
 
27
                        assert(0);
 
28
                }
 
29
 
 
30
                err = framebuffer_open((hw_module_t *) gralloc, &framebuffer);
 
31
                if (err) {
 
32
                        fprintf(stderr, "ERROR: failed to open framebuffer: (%s)\n",strerror(-err));
 
33
                        assert(0);
 
34
                }
 
35
                printf("** framebuffer_open: status=(%s) format=x%x", strerror(-err), framebuffer->format);
 
36
 
 
37
                err = gralloc_open((const hw_module_t *) gralloc, &alloc);
 
38
                if (err) {
 
39
                        fprintf(stderr, "ERROR: failed to open gralloc: (%s)\n",strerror(-err));
 
40
                        assert(0);
 
41
                }
 
42
                printf("** gralloc_open %p status=%s\n", gralloc, strerror(-err));
 
43
                eglplatformcommon_init(gralloc);
 
44
        }
 
45
 
 
46
        return display == EGL_DEFAULT_DISPLAY;
 
47
}
 
48
 
 
49
extern "C" EGLNativeWindowType fbdevws_CreateWindow(EGLNativeWindowType win, EGLNativeDisplayType display)
 
50
{
 
51
        assert (inited == 1);
 
52
        return (EGLNativeWindowType) *(new FbDevNativeWindow(gralloc, alloc, framebuffer));
 
53
}
 
54
 
 
55
extern "C" __eglMustCastToProperFunctionPointerType fbdevws_eglGetProcAddress(const char *procname) 
 
56
{
 
57
        return eglplatformcommon_eglGetProcAddress(procname);
 
58
}
 
59
 
 
60
extern "C" void fbdevws_passthroughImageKHR(EGLenum *target, EGLClientBuffer *buffer)
 
61
{
 
62
        eglplatformcommon_passthroughImageKHR(target, buffer);
 
63
}
 
64
 
 
65
struct ws_module ws_module_info = {
 
66
        fbdevws_IsValidDisplay,
 
67
        fbdevws_CreateWindow,
 
68
        fbdevws_eglGetProcAddress,
 
69
        fbdevws_passthroughImageKHR,
 
70
        eglplatformcommon_eglQueryString
 
71
};
 
72
 
 
73
// vim:ts=4:sw=4:noexpandtab