int start() { EGLBoolean result; EGLConfig config; EGLint num_config; g->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); assert(g->display != EGL_NO_DISPLAY); result = eglInitialize(g->display, NULL, NULL); assert(result != EGL_FALSE); static const EGLint config_kw[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_NONE }; result = eglChooseConfig(g->display, config_kw, &config, 1, &num_config); assert(result != EGL_FALSE); g->context = eglCreateContext(g->display, config, EGL_NO_CONTEXT, NULL); assert(g->context != EGL_NO_CONTEXT); assert(get_fb_resolution(&g->width, &g->height) == 0); g->surface = create_fb_surface(g->display, config, g->width, g->height); assert(g->surface != EGL_NO_SURFACE); result = eglMakeCurrent(g->display, g->surface, g->surface, g->context); assert(result != EGL_FALSE); // init viewport float nearp = 1.0f; float farp = 500.0f; float hht; float hwd; glViewport(0, 0, g->width, g->height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); hht = nearp * (float)tan(45.0 / 2.0 / 180.0 * M_PI); hwd = hht * (float)g->width / (float)g->height; glFrustumf(-hwd, hwd, -hht, hht, nearp, farp); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.f, 0.f, -50.f); glEnableClientState( GL_VERTEX_ARRAY ); glVertexPointer( 3, GL_BYTE, 0, quad ); EGLint client[5]; FILE* fd = fopen("global_image_handle.tmp", "r"); fread(client, sizeof(EGLint), 5, fd); fclose(fd); glEnable(GL_TEXTURE_2D); g->clientbuf = create_texture_from_shared_pixmap(g->display, client); glTexCoordPointer(2, GL_FLOAT, 0, texCoords); glEnableClientState(GL_TEXTURE_COORD_ARRAY); }
int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg) { struct omapfb_info *ofbi = FB2OFB(fbi); struct omapfb2_device *fbdev = ofbi->fbdev; struct omap_dss_device *display = fb2display(fbi); union { struct omapfb_update_window_old uwnd_o; struct omapfb_update_window uwnd; struct omapfb_plane_info plane_info; struct omapfb_caps caps; struct omapfb_mem_info mem_info; struct omapfb_color_key color_key; struct omapfb_ovl_colormode ovl_colormode; enum omapfb_update_mode update_mode; int test_num; struct omapfb_memory_read memory_read; struct omapfb_vram_info vram_info; struct omapfb_tearsync_info tearsync_info; struct omapfb_display_info display_info; u32 crt; } p; int r = 0; switch (cmd) { case OMAPFB_SYNC_GFX: DBG("ioctl SYNC_GFX\n"); if (!display || !display->driver->sync) { /* DSS1 never returns an error here, so we neither */ /*r = -EINVAL;*/ break; } r = display->driver->sync(display); break; case OMAPFB_UPDATE_WINDOW_OLD: DBG("ioctl UPDATE_WINDOW_OLD\n"); if (!display || !display->driver->update) { r = -EINVAL; break; } if (copy_from_user(&p.uwnd_o, (void __user *)arg, sizeof(p.uwnd_o))) { r = -EFAULT; break; } r = omapfb_update_window_nolock(fbi, p.uwnd_o.x, p.uwnd_o.y, p.uwnd_o.width, p.uwnd_o.height); break; case OMAPFB_UPDATE_WINDOW: DBG("ioctl UPDATE_WINDOW\n"); if (!display || !display->driver->update) { r = -EINVAL; break; } if (copy_from_user(&p.uwnd, (void __user *)arg, sizeof(p.uwnd))) { r = -EFAULT; break; } r = omapfb_update_window_nolock(fbi, p.uwnd.x, p.uwnd.y, p.uwnd.width, p.uwnd.height); break; case OMAPFB_SETUP_PLANE: DBG("ioctl SETUP_PLANE\n"); if (copy_from_user(&p.plane_info, (void __user *)arg, sizeof(p.plane_info))) r = -EFAULT; else r = omapfb_setup_plane(fbi, &p.plane_info); break; case OMAPFB_QUERY_PLANE: DBG("ioctl QUERY_PLANE\n"); r = omapfb_query_plane(fbi, &p.plane_info); if (r < 0) break; if (copy_to_user((void __user *)arg, &p.plane_info, sizeof(p.plane_info))) r = -EFAULT; break; case OMAPFB_SETUP_MEM: DBG("ioctl SETUP_MEM\n"); if (copy_from_user(&p.mem_info, (void __user *)arg, sizeof(p.mem_info))) r = -EFAULT; else r = omapfb_setup_mem(fbi, &p.mem_info); break; case OMAPFB_QUERY_MEM: DBG("ioctl QUERY_MEM\n"); r = omapfb_query_mem(fbi, &p.mem_info); if (r < 0) break; if (copy_to_user((void __user *)arg, &p.mem_info, sizeof(p.mem_info))) r = -EFAULT; break; case OMAPFB_GET_CAPS: DBG("ioctl GET_CAPS\n"); if (!display) { r = -EINVAL; break; } memset(&p.caps, 0, sizeof(p.caps)); if (display->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) p.caps.ctrl |= OMAPFB_CAPS_MANUAL_UPDATE; if (display->caps & OMAP_DSS_DISPLAY_CAP_TEAR_ELIM) p.caps.ctrl |= OMAPFB_CAPS_TEARSYNC; if (copy_to_user((void __user *)arg, &p.caps, sizeof(p.caps))) r = -EFAULT; break; case OMAPFB_GET_OVERLAY_COLORMODE: DBG("ioctl GET_OVERLAY_COLORMODE\n"); if (copy_from_user(&p.ovl_colormode, (void __user *)arg, sizeof(p.ovl_colormode))) { r = -EFAULT; break; } r = omapfb_get_ovl_colormode(fbdev, &p.ovl_colormode); if (r < 0) break; if (copy_to_user((void __user *)arg, &p.ovl_colormode, sizeof(p.ovl_colormode))) r = -EFAULT; break; case OMAPFB_SET_UPDATE_MODE: DBG("ioctl SET_UPDATE_MODE\n"); if (get_user(p.update_mode, (int __user *)arg)) r = -EFAULT; else r = omapfb_set_update_mode(fbi, p.update_mode); break; case OMAPFB_GET_UPDATE_MODE: DBG("ioctl GET_UPDATE_MODE\n"); r = omapfb_get_update_mode(fbi, &p.update_mode); if (r) break; if (put_user(p.update_mode, (enum omapfb_update_mode __user *)arg)) r = -EFAULT; break; case OMAPFB_SET_COLOR_KEY: DBG("ioctl SET_COLOR_KEY\n"); if (copy_from_user(&p.color_key, (void __user *)arg, sizeof(p.color_key))) r = -EFAULT; else r = omapfb_set_color_key(fbi, &p.color_key); break; case OMAPFB_GET_COLOR_KEY: DBG("ioctl GET_COLOR_KEY\n"); r = omapfb_get_color_key(fbi, &p.color_key); if (r) break; if (copy_to_user((void __user *)arg, &p.color_key, sizeof(p.color_key))) r = -EFAULT; break; case FBIO_WAITFORVSYNC: if (get_user(p.crt, (__u32 __user *)arg)) { r = -EFAULT; break; } if (p.crt != 0) { r = -ENODEV; break; } /* FALLTHROUGH */ case OMAPFB_WAITFORVSYNC: DBG("ioctl WAITFORVSYNC\n"); if (!display) { r = -EINVAL; break; } r = display->manager->wait_for_vsync(display->manager); break; case OMAPFB_WAITFORGO: DBG("ioctl WAITFORGO\n"); if (!display) { r = -EINVAL; break; } r = omapfb_wait_for_go(fbi); break; /* LCD and CTRL tests do the same thing for backward * compatibility */ case OMAPFB_LCD_TEST: DBG("ioctl LCD_TEST\n"); if (get_user(p.test_num, (int __user *)arg)) { r = -EFAULT; break; } if (!display || !display->driver->run_test) { r = -EINVAL; break; } r = display->driver->run_test(display, p.test_num); break; case OMAPFB_CTRL_TEST: DBG("ioctl CTRL_TEST\n"); if (get_user(p.test_num, (int __user *)arg)) { r = -EFAULT; break; } if (!display || !display->driver->run_test) { r = -EINVAL; break; } r = display->driver->run_test(display, p.test_num); break; case OMAPFB_MEMORY_READ: DBG("ioctl MEMORY_READ\n"); if (copy_from_user(&p.memory_read, (void __user *)arg, sizeof(p.memory_read))) { r = -EFAULT; break; } r = omapfb_memory_read(fbi, &p.memory_read); break; case OMAPFB_GET_VRAM_INFO: { unsigned long vram, free, largest; DBG("ioctl GET_VRAM_INFO\n"); omap_vram_get_info(&vram, &free, &largest); p.vram_info.total = vram; p.vram_info.free = free; p.vram_info.largest_free_block = largest; if (copy_to_user((void __user *)arg, &p.vram_info, sizeof(p.vram_info))) r = -EFAULT; break; } case OMAPFB_SET_TEARSYNC: { DBG("ioctl SET_TEARSYNC\n"); if (copy_from_user(&p.tearsync_info, (void __user *)arg, sizeof(p.tearsync_info))) { r = -EFAULT; break; } if (!display || !display->driver->enable_te) { r = -ENODEV; break; } r = display->driver->enable_te(display, !!p.tearsync_info.enabled); break; } case OMAPFB_GET_DISPLAY_INFO: { u16 xres, yres; u32 w, h; DBG("ioctl GET_DISPLAY_INFO\n"); if (display == NULL) { r = -ENODEV; break; } get_fb_resolution(display, &xres, &yres); p.display_info.xres = xres; p.display_info.yres = yres; omapdss_display_get_dimensions(display, &w, &h); p.display_info.width = w; p.display_info.height = h; if (copy_to_user((void __user *)arg, &p.display_info, sizeof(p.display_info))) r = -EFAULT; break; } case OMAPFB_ENABLEVSYNC: if (get_user(p.crt, (__u32 __user *)arg)) { r = -EFAULT; break; } omapfb_lock(fbdev); fbdev->vsync_active = !!p.crt; if (display->state == OMAP_DSS_DISPLAY_ACTIVE) { if (p.crt) omapfb_enable_vsync(fbdev, display->channel, true); else omapfb_enable_vsync(fbdev, display->channel, false); } omapfb_unlock(fbdev); break; default: dev_err(fbdev->dev, "Unknown ioctl 0x%x\n", cmd); r = -EINVAL; } if (r < 0) DBG("ioctl failed: %d\n", r); return r; }