Esempio n. 1
0
void
xeglInitInput (int  argc,
               char **argv)
{
    eglInitInput (&LinuxEvdevMouseFuncs, &LinuxEvdevKeyboardFuncs);
    RegisterBlockAndWakeupHandlers (xeglBlockHandler, KdWakeupHandler, NULL);
}
Esempio n. 2
0
void
XdmcpReset(void)
{
    state = XDM_INIT_STATE;
    if (state != XDM_OFF) {
        RegisterBlockAndWakeupHandlers(XdmcpBlockHandler, XdmcpWakeupHandler,
                                       (void *) 0);
        timeOutRtx = 0;
        send_packet();
    }
}
Esempio n. 3
0
/** Initialize the XSync() batching optimization, but only if
 * #dmxSyncActivate was last called with a non-negative value. */
void dmxSyncInit(void)
{
    if (dmxSyncInterval) {
        RegisterBlockAndWakeupHandlers(dmxSyncBlockHandler,
                                       dmxSyncWakeupHandler,
                                       NULL);
        dmxLog(dmxInfo, "XSync batching with %d ms interval\n",
               dmxSyncInterval);
    } else {
        dmxLog(dmxInfo, "XSync batching disabled\n");
    }
}
Esempio n. 4
0
int
ClientSleepUntil(ClientPtr client,
                 TimeStamp *revive,
                 void (*notifyFunc) (ClientPtr, void *), void *closure)
{
    SertafiedPtr pRequest, pReq, pPrev;

    if (SertafiedGeneration != serverGeneration) {
        SertafiedResType = CreateNewResourceType(SertafiedDelete,
                                                 "ClientSleep");
        if (!SertafiedResType)
            return FALSE;
        SertafiedGeneration = serverGeneration;
        BlockHandlerRegistered = FALSE;
    }
    pRequest = malloc(sizeof(SertafiedRec));
    if (!pRequest)
        return FALSE;
    pRequest->pClient = client;
    pRequest->revive = *revive;
    pRequest->id = FakeClientID(client->index);
    pRequest->closure = closure;
    if (!BlockHandlerRegistered) {
        if (!RegisterBlockAndWakeupHandlers(SertafiedBlockHandler,
                                            SertafiedWakeupHandler,
                                            (void *) 0)) {
            free(pRequest);
            return FALSE;
        }
        BlockHandlerRegistered = TRUE;
    }
    pRequest->notifyFunc = 0;
    if (!AddResource(pRequest->id, SertafiedResType, (void *) pRequest))
        return FALSE;
    if (!notifyFunc)
        notifyFunc = ClientAwaken;
    pRequest->notifyFunc = notifyFunc;
    /* Insert into time-ordered queue, with earliest activation time coming first. */
    pPrev = 0;
    for (pReq = pPending; pReq; pReq = pReq->next) {
        if (CompareTimeStamps(pReq->revive, *revive) == LATER)
            break;
        pPrev = pReq;
    }
    if (pPrev)
        pPrev->next = pRequest;
    else
        pPending = pRequest;
    pRequest->next = pReq;
    IgnoreClient(client);
    return TRUE;
}
Esempio n. 5
0
/**
 * Attempt to connect to the system bus, and set a filter to deal with
 * disconnection (see message_filter above).
 *
 * @return 1 on success, 0 on failure.
 */
static int
connect_to_bus(void)
{
    DBusError error;
    struct dbus_core_hook *hook;

    dbus_error_init(&error);
    bus_info.connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
    if (!bus_info.connection || dbus_error_is_set(&error)) {
        LogMessage(X_ERROR, "dbus-core: error connecting to system bus: %s (%s)\n",
               error.name, error.message);
        goto err_begin;
    }

    /* Thankyou.  Really, thankyou. */
    dbus_connection_set_exit_on_disconnect(bus_info.connection, FALSE);

    if (!dbus_connection_get_unix_fd(bus_info.connection, &bus_info.fd)) {
        ErrorF("[dbus-core] couldn't get fd for system bus\n");
        goto err_unref;
    }

    if (!dbus_connection_add_filter(bus_info.connection, message_filter,
                                    &bus_info, NULL)) {
        ErrorF("[dbus-core] couldn't add filter: %s (%s)\n", error.name,
               error.message);
        goto err_fd;
    }

    dbus_error_free(&error);
    AddGeneralSocket(bus_info.fd);

    RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, &bus_info);

    for (hook = bus_info.hooks; hook; hook = hook->next) {
        if (hook->connect)
            hook->connect(bus_info.connection, hook->data);
    }

    return 1;

 err_fd:
    bus_info.fd = -1;
 err_unref:
    dbus_connection_unref(bus_info.connection);
    bus_info.connection = NULL;
 err_begin:
    dbus_error_free(&error);

    return 0;
}
void
LinuxApmOpen(void)
{
    LinuxApmFd = open ("/dev/apm_bios", 2);
    if (LinuxApmFd < 0 && errno == ENOENT)
	LinuxApmFd = open ("/dev/misc/apm_bios", 2);
    if (LinuxApmFd >= 0)
    {
	LinuxApmRunning = TRUE;
	fcntl (LinuxApmFd, F_SETFL, fcntl (LinuxApmFd, F_GETFL) | NOBLOCK);
	RegisterBlockAndWakeupHandlers (LinuxApmBlock, LinuxApmWakeup, 0);
	AddEnabledDevice (LinuxApmFd);
    }
}
Esempio n. 7
0
File: Init.c Progetto: csulmone/X11
void
InitInput(int argc, char *argv[])
{
    int rc;

    rc = AllocDevicePair(serverClient, "Xnest",
                         &xnestPointerDevice,
                         &xnestKeyboardDevice,
                         xnestPointerProc, xnestKeyboardProc, FALSE);

    if (rc != Success)
        FatalError("Failed to init Xnest default devices.\n");

    mieqInit();

    AddEnabledDevice(XConnectionNumber(xnestDisplay));

    RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL);
}
Esempio n. 8
0
static void
LinuxEnable (void)
{
    if (enabled)
	return;
    if (kdSwitchPending)
    {
	kdSwitchPending = FALSE;
	ioctl (LinuxConsoleFd, VT_RELDISP, VT_ACKACQ);
    }
    /*
     * Open the APM driver
     */
    LinuxApmFd = open ("/dev/apm_bios", 2);
    if (LinuxApmFd < 0 && errno == ENOENT)
	LinuxApmFd = open ("/dev/misc/apm_bios", 2);
    if (LinuxApmFd >= 0)
    {
	LinuxApmRunning = TRUE;
	fcntl (LinuxApmFd, F_SETFL, fcntl (LinuxApmFd, F_GETFL) | NOBLOCK);
	RegisterBlockAndWakeupHandlers (LinuxApmBlock, LinuxApmWakeup, 0);
	AddEnabledDevice (LinuxApmFd);
    }

    /*
     * now get the VT
     */
    LinuxSetSwitchMode (VT_AUTO);
    if (ioctl(LinuxConsoleFd, VT_ACTIVATE, vtno) != 0)
    {
	FatalError("LinuxInit: VT_ACTIVATE failed\n");
    }
    if (ioctl(LinuxConsoleFd, VT_WAITACTIVE, vtno) != 0)
    {
	FatalError("LinuxInit: VT_WAITACTIVE failed\n");
    }
    LinuxSetSwitchMode (VT_PROCESS);
    if (ioctl(LinuxConsoleFd, KDSETMODE, KD_GRAPHICS) < 0)
    {
	FatalError("LinuxInit: KDSETMODE KD_GRAPHICS failed\n");
    }
    enabled = TRUE;
}
Esempio n. 9
0
_X_HIDDEN void
DtloginInit(void)
{
    int displayNumber = 0;
    struct dmdata *dmd;

    if (serverGeneration != 1) return;

    originalUser.uid = geteuid();
    originalUser.gid = getegid();
    getgroups(NGROUPS_UMAX, originalUser.groupids);
    originalUser.homedir = getcwd(NULL, 0);
    originalUser.projid = getprojid();

    if (getuid() != 0)  return;

    dmd = calloc(1, sizeof(struct dmdata));
    if (dmd == NULL) {
	DtloginError("Failed to allocate %d bytes for display manager pipe",
		     sizeof(struct dmdata));
	return;
    }

    dmd->user.uid = (uid_t) -1;
    dmd->user.gid = (gid_t) -1;
    dmd->user.projid = (projid_t) -1;

    displayNumber = atoi(display); /* Assigned in dix/main.c */

    dmd->pipeFD = dtlogin_create_pipe(displayNumber, dmd);

    if (dmd->pipeFD == -1) {
	free(dmd);
	return;
    }

    dmHandlerData = dmd;

    RegisterBlockAndWakeupHandlers (DtloginBlockHandler,
				    DtloginWakeupHandler,
				    (pointer) dmd);
}
Esempio n. 10
0
void
InitInput(int argc, char *argv[])
{
  xnestPointerDevice = AddInputDevice(xnestPointerProc, TRUE);
  xnestKeyboardDevice = AddInputDevice(xnestKeyboardProc, TRUE);

  if (!xnestEvents)
      xnestEvents = (xEvent *) xcalloc(sizeof(xEvent), GetMaximumEventsNum());
  if (!xnestEvents)
      FatalError("couldn't allocate room for events\n");

  RegisterPointerDevice(xnestPointerDevice);
  RegisterKeyboardDevice(xnestKeyboardDevice);

  mieqInit();

  AddEnabledDevice(XConnectionNumber(xnestDisplay));

  RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL);
}
Esempio n. 11
0
Bool
shadowAdd(ScreenPtr pScreen, PixmapPtr pPixmap, ShadowUpdateProc update,
	  ShadowWindowProc window, ShadowPreupdateProc preupdate,
          int randr, void *closure)
{
    shadowBuf(pScreen);

    if (!RegisterBlockAndWakeupHandlers(shadowBlockHandler, shadowWakeupHandler,
					(pointer)pScreen))
	return FALSE;

    /*
     * Map simple rotation values to bitmasks; fortunately,
     * these are all unique
     */
    switch (randr) {
    case 0:
	randr = SHADOW_ROTATE_0;
	break;
    case 90:
	randr = SHADOW_ROTATE_90;
	break;
    case 180:
	randr = SHADOW_ROTATE_180;
	break;
    case 270:
	randr = SHADOW_ROTATE_270;
	break;
    }
    pBuf->update = update;
    pBuf->window = window;
    if (preupdate)
        pBuf->ready_to_update = preupdate;
    else
        pBuf->ready_to_update = dummyPreupdate;
    pBuf->randr = randr;
    pBuf->closure = 0;
    pBuf->pPixmap = pPixmap;
    DamageRegister(&pPixmap->drawable, pBuf->pDamage);
    return TRUE;
}
Esempio n. 12
0
void
XdmcpInit(void)
{
    state = XDM_INIT_STATE;
#ifdef HASXDMAUTH
    if (xdmAuthCookie)
        XdmAuthenticationInit(xdmAuthCookie, strlen(xdmAuthCookie));
#endif
    if (state != XDM_OFF) {
        XdmcpRegisterAuthorizations();
        XdmcpRegisterDisplayClass(defaultDisplayClass,
                                  strlen(defaultDisplayClass));
        AccessUsingXdmcp();
        RegisterBlockAndWakeupHandlers(XdmcpBlockHandler, XdmcpWakeupHandler,
                                       (void *) 0);
        timeOutRtx = 0;
        DisplayNumber = (CARD16) atoi(display);
        get_xdmcp_sock();
        send_packet();
    }
}
Esempio n. 13
0
/*
 * RootlessInit
 * Rootless wraps lots of stuff and needs a bunch of devPrivates.
 */
Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcs *procs)
{
    RootlessScreenRec *s;

    if (! RootlessAllocatePrivates(pScreen)) return FALSE;
    s = (RootlessScreenRec*)
            pScreen->devPrivates[rootlessScreenPrivateIndex].ptr;

    s->pScreen = pScreen;
    s->frameProcs = *procs;

    RootlessWrap(pScreen);

    if (!RegisterBlockAndWakeupHandlers (RootlessBlockHandler,
                                         RootlessWakeupHandler,
                                         (pointer) pScreen))
    {
        return FALSE;
    }

    return TRUE;
}
Esempio n. 14
0
Bool
ephyrSetInternalDamage(ScreenPtr pScreen)
{
    KdScreenPriv(pScreen);
    KdScreenInfo *screen = pScreenPriv->screen;
    EphyrScrPriv *scrpriv = screen->driver;
    PixmapPtr pPixmap = NULL;

    scrpriv->pDamage = DamageCreate((DamageReportFunc) 0,
                                    (DamageDestroyFunc) 0,
                                    DamageReportNone, TRUE, pScreen, pScreen);

    if (!RegisterBlockAndWakeupHandlers(ephyrInternalDamageBlockHandler,
                                        ephyrInternalDamageWakeupHandler,
                                        (void *) pScreen))
        return FALSE;

    pPixmap = (*pScreen->GetScreenPixmap) (pScreen);

    DamageRegister(&pPixmap->drawable, scrpriv->pDamage);

    return TRUE;
}
Esempio n. 15
0
/*
 * RootlessInit
 *  Called by the rootless implementation to initialize the rootless layer.
 *  Rootless wraps lots of stuff and needs a bunch of devPrivates.
 */
Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs)
{
    RootlessScreenRec *s;

    if (!RootlessAllocatePrivates(pScreen))
        return FALSE;

    s = SCREENREC(pScreen);

    s->imp = procs;
    s->colormap = NULL;
    s->redisplay_expired = FALSE;

    RootlessWrap(pScreen);

    if (!RegisterBlockAndWakeupHandlers(RootlessBlockHandler,
                                        RootlessWakeupHandler,
                                        (pointer) pScreen))
    {
        return FALSE;
    }

    return TRUE;
}
Esempio n. 16
0
static void vgaswitch_claim_entity(void)
{
	RegisterBlockAndWakeupHandlers(vgaswitch_entity_init, NULL, NULL);
}
Esempio n. 17
0
Bool
GLAMODrawExaInit(ScreenPtr pScreen, ScrnInfoPtr pScrn)
{
	GlamoPtr pGlamo = GlamoPTR(pScrn);

	Bool success = FALSE;
	ExaDriverPtr exa;

	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
			"EXA hardware acceleration initialising\n");

	exa = pGlamo->exa = exaDriverAlloc();
    if(!exa) return FALSE;

	exa->memoryBase = pGlamo->fbstart;
	exa->memorySize = 1024 * 1024 * 4;
	/*exa->offScreenBase = pGlamo->fboff;*/
	exa->offScreenBase = pScrn->virtualX * pScrn->virtualY * 2;

	exa->exa_major = 2;
	exa->exa_minor = 0;

	exa->PrepareSolid = GLAMOExaPrepareSolid;
	exa->Solid = GLAMOExaSolid;
	exa->DoneSolid = GLAMOExaDoneSolid;

	exa->PrepareCopy = GLAMOExaPrepareCopy;
	exa->Copy = GLAMOExaCopy;
	exa->DoneCopy = GLAMOExaDoneCopy;

	exa->CheckComposite = GLAMOExaCheckComposite;
	exa->PrepareComposite = GLAMOExaPrepareComposite;
	exa->Composite = GLAMOExaComposite;
	exa->DoneComposite = GLAMOExaDoneComposite;


	exa->DownloadFromScreen = GLAMOExaDownloadFromScreen;
	exa->UploadToScreen = GLAMOExaUploadToScreen;

	/*glamos->exa.MarkSync = GLAMOExaMarkSync;*/
	exa->WaitMarker = GLAMOExaWaitMarker;

	exa->pixmapOffsetAlign = 2;
	exa->pixmapPitchAlign = 2;

	exa->maxX = 640;
	exa->maxY = 640;

	exa->flags = EXA_OFFSCREEN_PIXMAPS;

	RegisterBlockAndWakeupHandlers(GLAMOBlockHandler,
				       GLAMOWakeupHandler,
				       pScreen);

	success = exaDriverInit(pScreen, exa);
	if (success) {
		ErrorF("Initialized EXA acceleration\n");
	} else {
		ErrorF("Failed to initialize EXA acceleration\n");
	}

	return success;
}
Esempio n. 18
0
/** Set up glamor for an already-configured GL context. */
Bool
glamor_init(ScreenPtr screen, unsigned int flags)
{
    glamor_screen_private *glamor_priv;
    int gl_version;
    int max_viewport_size[2];

#ifdef RENDER
    PictureScreenPtr ps = GetPictureScreenIfSet(screen);
#endif
    if (flags & ~GLAMOR_VALID_FLAGS) {
        ErrorF("glamor_init: Invalid flags %x\n", flags);
        return FALSE;
    }
    glamor_priv = calloc(1, sizeof(*glamor_priv));
    if (glamor_priv == NULL)
        return FALSE;

    glamor_priv->flags = flags;

    if (!dixRegisterPrivateKey(&glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
        LogMessage(X_WARNING,
                   "glamor%d: Failed to allocate screen private\n",
                   screen->myNum);
        goto fail;
    }

    glamor_set_screen_private(screen, glamor_priv);

    if (!dixRegisterPrivateKey(&glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
        LogMessage(X_WARNING,
                   "glamor%d: Failed to allocate pixmap private\n",
                   screen->myNum);
        goto fail;
    }

    if (!dixRegisterPrivateKey(&glamor_gc_private_key, PRIVATE_GC,
                               sizeof (glamor_gc_private))) {
        LogMessage(X_WARNING,
                   "glamor%d: Failed to allocate gc private\n",
                   screen->myNum);
        goto fail;
    }

    if (epoxy_is_desktop_gl())
        glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP;
    else
        glamor_priv->gl_flavor = GLAMOR_GL_ES2;

    gl_version = epoxy_gl_version();

    /* Would be nice to have a cleaner test for GLSL 1.30 support,
     * but for now this should suffice
     */
    if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && gl_version >= 30)
        glamor_priv->glsl_version = 130;
    else
        glamor_priv->glsl_version = 120;


    /* We'd like to require GL_ARB_map_buffer_range or
     * GL_OES_map_buffer_range, since it offers more information to
     * the driver than plain old glMapBuffer() or glBufferSubData().
     * It's been supported on Mesa on the desktop since 2009 and on
     * GLES2 since October 2012.  It's supported on Apple's iOS
     * drivers for SGX535 and A7, but apparently not on most Android
     * devices (the OES extension spec wasn't released until June
     * 2012).
     *
     * 82% of 0 A.D. players (desktop GL) submitting hardware reports
     * have support for it, with most of the ones lacking it being on
     * Windows with Intel 4-series (G45) graphics or older.
     */
    if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
        if (gl_version < 21) {
            ErrorF("Require OpenGL version 2.1 or later.\n");
            goto fail;
        }
    } else {
        if (gl_version < 20) {
            ErrorF("Require Open GLES2.0 or later.\n");
            goto fail;
        }

        if (!epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888")) {
            ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
            goto fail;
        }
    }

    glamor_priv->has_rw_pbo = FALSE;
    if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
        glamor_priv->has_rw_pbo = TRUE;

    glamor_priv->has_khr_debug = epoxy_has_gl_extension("GL_KHR_debug");
    glamor_priv->has_pack_invert =
        epoxy_has_gl_extension("GL_MESA_pack_invert");
    glamor_priv->has_fbo_blit =
        epoxy_has_gl_extension("GL_EXT_framebuffer_blit");
    glamor_priv->has_map_buffer_range =
        epoxy_has_gl_extension("GL_ARB_map_buffer_range");
    glamor_priv->has_buffer_storage =
        epoxy_has_gl_extension("GL_ARB_buffer_storage");
    glamor_priv->has_nv_texture_barrier =
        epoxy_has_gl_extension("GL_NV_texture_barrier");

    glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size);
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glamor_priv->max_fbo_size);
    glGetIntegerv(GL_MAX_VIEWPORT_DIMS, max_viewport_size);
    glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size[0]);
    glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size[1]);
#ifdef MAX_FBO_SIZE
    glamor_priv->max_fbo_size = MAX_FBO_SIZE;
#endif

    glamor_set_debug_level(&glamor_debug_level);

    /* If we are using egl screen, call egl screen init to
     * register correct close screen function. */
    if (flags & GLAMOR_USE_EGL_SCREEN) {
        glamor_egl_screen_init(screen, &glamor_priv->ctx);
    } else {
        if (!glamor_glx_screen_init(&glamor_priv->ctx))
            goto fail;
    }

    glamor_priv->saved_procs.close_screen = screen->CloseScreen;
    screen->CloseScreen = glamor_close_screen;

    glamor_priv->saved_procs.create_screen_resources =
        screen->CreateScreenResources;
    screen->CreateScreenResources = glamor_create_screen_resources;

    if (!glamor_font_init(screen))
        goto fail;

    if (flags & GLAMOR_USE_SCREEN) {
        if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler,
                                            _glamor_wakeup_handler,
                                            glamor_priv)) {
            goto fail;
        }

        glamor_priv->saved_procs.create_gc = screen->CreateGC;
        screen->CreateGC = glamor_create_gc;

        glamor_priv->saved_procs.create_pixmap = screen->CreatePixmap;
        screen->CreatePixmap = glamor_create_pixmap;

        glamor_priv->saved_procs.destroy_pixmap = screen->DestroyPixmap;
        screen->DestroyPixmap = glamor_destroy_pixmap;

        glamor_priv->saved_procs.get_spans = screen->GetSpans;
        screen->GetSpans = glamor_get_spans;

        glamor_priv->saved_procs.get_image = screen->GetImage;
        screen->GetImage = glamor_get_image;

        glamor_priv->saved_procs.change_window_attributes =
            screen->ChangeWindowAttributes;
        screen->ChangeWindowAttributes = glamor_change_window_attributes;

        glamor_priv->saved_procs.copy_window = screen->CopyWindow;
        screen->CopyWindow = glamor_copy_window;

        glamor_priv->saved_procs.bitmap_to_region = screen->BitmapToRegion;
        screen->BitmapToRegion = glamor_bitmap_to_region;
    }
#ifdef RENDER
    if (flags & GLAMOR_USE_PICTURE_SCREEN) {
        glamor_priv->saved_procs.composite = ps->Composite;
        ps->Composite = glamor_composite;

        glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
        ps->Trapezoids = glamor_trapezoids;

        glamor_priv->saved_procs.triangles = ps->Triangles;
        ps->Triangles = glamor_triangles;

        glamor_priv->saved_procs.addtraps = ps->AddTraps;
        ps->AddTraps = glamor_add_traps;

    }

    glamor_priv->saved_procs.composite_rects = ps->CompositeRects;
    ps->CompositeRects = glamor_composite_rectangles;

    glamor_priv->saved_procs.glyphs = ps->Glyphs;
    ps->Glyphs = glamor_glyphs;

    glamor_priv->saved_procs.unrealize_glyph = ps->UnrealizeGlyph;
    ps->UnrealizeGlyph = glamor_glyph_unrealize;

    glamor_priv->saved_procs.create_picture = ps->CreatePicture;
    ps->CreatePicture = glamor_create_picture;

    glamor_priv->saved_procs.destroy_picture = ps->DestroyPicture;
    ps->DestroyPicture = glamor_destroy_picture;
    glamor_init_composite_shaders(screen);
#endif
    glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
    screen->SetWindowPixmap = glamor_set_window_pixmap;

    glamor_init_vbo(screen);
    glamor_init_pixmap_fbo(screen);
#ifdef GLAMOR_TRAPEZOID_SHADER
    glamor_init_trapezoid_shader(screen);
#endif
    glamor_init_finish_access_shaders(screen);
#ifdef GLAMOR_GRADIENT_SHADER
    glamor_init_gradient_shader(screen);
#endif
    glamor_pixmap_init(screen);
    glamor_glyphs_init(screen);
    glamor_sync_init(screen);

    glamor_priv->screen = screen;

    return TRUE;

 fail:
    free(glamor_priv);
    glamor_set_screen_private(screen, NULL);
    return FALSE;
}
Esempio n. 19
0
Bool
xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
{
    ScrnInfoPtr		pScrn = crtc->scrn;
    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    ScreenPtr		pScreen = pScrn->pScreen;
    
    if (rotation == RR_Rotate_0)
    {
	/* Free memory from rotation */
	if (crtc->rotatedPixmap || crtc->rotatedData)
	{
	    crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData);
	    crtc->rotatedPixmap = NULL;
	    crtc->rotatedData = NULL;
	}

	if (xf86_config->rotation_damage)
	{
	    /* Free damage structure */
	    DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
			      xf86_config->rotation_damage);
	    xf86_config->rotation_damage_registered = FALSE;
	    DamageDestroy (xf86_config->rotation_damage);
	    xf86_config->rotation_damage = NULL;
	    /* Free block/wakeup handler */
	    RemoveBlockAndWakeupHandlers (xf86RotateBlockHandler,
					  xf86RotateWakeupHandler,
					  (pointer) pScreen);
	}
    }
    else
    {
	/* 
	 * these are the size of the shadow pixmap, which
	 * matches the mode, not the pre-rotated copy in the
	 * frame buffer
	 */
	int	    width = mode->HDisplay;
	int	    height = mode->VDisplay;
	void	    *shadowData = crtc->rotatedData;
	PixmapPtr   shadow = crtc->rotatedPixmap;
	int	    old_width = shadow ? shadow->drawable.width : 0;
	int	    old_height = shadow ? shadow->drawable.height : 0;
	
	/* Allocate memory for rotation */
	if (old_width != width || old_height != height)
	{
	    if (shadow || shadowData)
	    {
		crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
		crtc->rotatedPixmap = NULL;
		crtc->rotatedData = NULL;
	    }
	    shadowData = crtc->funcs->shadow_allocate (crtc, width, height);
	    if (!shadowData)
		goto bail1;
	    crtc->rotatedData = shadowData;
	    /* shadow will be damaged in xf86RotatePrepare */
	}
	else
	{
	    /* mark shadowed area as damaged so it will be repainted */
	    xf86CrtcDamageShadow (crtc);
	}
	
	if (!xf86_config->rotation_damage)
	{
	    /* Create damage structure */
	    xf86_config->rotation_damage = DamageCreate (NULL, NULL,
						DamageReportNone,
						TRUE, pScreen, pScreen);
	    if (!xf86_config->rotation_damage)
		goto bail2;
	    
	    /* Assign block/wakeup handler */
	    if (!RegisterBlockAndWakeupHandlers (xf86RotateBlockHandler,
						 xf86RotateWakeupHandler,
						 (pointer) pScreen))
	    {
		goto bail3;
	    }
	}
	if (0)
	{
bail3:
	    DamageDestroy (xf86_config->rotation_damage);
	    xf86_config->rotation_damage = NULL;
	    
bail2:
	    if (shadow || shadowData)
	    {
		crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
		crtc->rotatedPixmap = NULL;
		crtc->rotatedData = NULL;
	    }
bail1:
	    if (old_width && old_height)
		crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc,
								  NULL,
								  old_width,
								  old_height);
	    return FALSE;
	}
    }
    
    /* All done */
    return TRUE;
}
Esempio n. 20
0
/*
 * InitOutput --
 *	Initialize screenInfo for all actually accessible framebuffers.
 *      That includes vt-manager setup, querying all possible devices and
 *      collecting the pixmap formats.
 */
void
InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
{
    int                    i, j, k, scr_index, was_blocked = 0;
    char                   **modulelist;
    pointer                *optionlist;
    Pix24Flags		 screenpix24, pix24;
    MessageType		 pix24From = X_DEFAULT;
    Bool			 pix24Fail = FALSE;
    Bool			 autoconfig = FALSE;
    GDevPtr		 configured_device;

    xf86Initialising = TRUE;

    if (serverGeneration == 1) {
        if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
            xf86ServerName++;
        else
            xf86ServerName = argv[0];

        xf86PrintBanner();
        xf86PrintMarkers();
        if (xf86LogFile)  {
            time_t t;
            const char *ct;
            t = time(NULL);
            ct = ctime(&t);
            xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
                        xf86LogFile, ct);
        }

        /* Read and parse the config file */
        if (!xf86DoConfigure && !xf86DoShowOptions) {
            switch (xf86HandleConfigFile(FALSE)) {
            case CONFIG_OK:
                break;
            case CONFIG_PARSE_ERROR:
                xf86Msg(X_ERROR, "Error parsing the config file\n");
                return;
            case CONFIG_NOFILE:
                autoconfig = TRUE;
                break;
            }
        }

        InstallSignalHandlers();

        /* Initialise the loader */
        LoaderInit();

        /* Tell the loader the default module search path */
        LoaderSetPath(xf86ModulePath);

        if (xf86Info.ignoreABI) {
            LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
        }

        if (xf86DoShowOptions)
            DoShowOptions();

        /* Do a general bus probe.  This will be a PCI probe for x86 platforms */
        xf86BusProbe();

        if (xf86DoConfigure)
            DoConfigure();

        if (autoconfig) {
            if (!xf86AutoConfig()) {
                xf86Msg(X_ERROR, "Auto configuration failed\n");
                return;
            }
        }

#ifdef XF86PM
        xf86OSPMClose = xf86OSPMOpen();
#endif

        /* Load all modules specified explicitly in the config file */
        if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
            xf86LoadModules(modulelist, optionlist);
            free(modulelist);
            free(optionlist);
        }

        /* Load all driver modules specified in the config file */
        /* If there aren't any specified in the config file, autoconfig them */
        /* FIXME: Does not handle multiple active screen sections, but I'm not
         * sure if we really want to handle that case*/
        configured_device = xf86ConfigLayout.screens->screen->device;
        if ((!configured_device) || (!configured_device->driver)) {
            if (!autoConfigDevice(configured_device)) {
                xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
                return ;
            }
        }
        if ((modulelist = xf86DriverlistFromConfig())) {
            xf86LoadModules(modulelist, NULL);
            free(modulelist);
        }

        /* Load all input driver modules specified in the config file. */
        if ((modulelist = xf86InputDriverlistFromConfig())) {
            xf86LoadModules(modulelist, NULL);
            free(modulelist);
        }

        /*
         * It is expected that xf86AddDriver()/xf86AddInputDriver will be
         * called for each driver as it is loaded.  Those functions save the
         * module pointers for drivers.
         * XXX Nothing keeps track of them for other modules.
         */
        /* XXX What do we do if not all of these could be loaded? */

        /*
         * At this point, xf86DriverList[] is all filled in with entries for
         * each of the drivers to try and xf86NumDrivers has the number of
         * drivers.  If there are none, return now.
         */

        if (xf86NumDrivers == 0) {
            xf86Msg(X_ERROR, "No drivers available.\n");
            return;
        }

        /*
         * Call each of the Identify functions and call the driverFunc to check
         * if HW access is required.  The Identify functions print out some
         * identifying information, and anything else that might be
         * needed at this early stage.
         */

        for (i = 0; i < xf86NumDrivers; i++) {
            if (xf86DriverList[i]->Identify != NULL)
                xf86DriverList[i]->Identify(0);

            if (!xorgHWAccess || !xorgHWOpenConsole) {
                xorgHWFlags flags;
                if(!xf86DriverList[i]->driverFunc
                        || !xf86DriverList[i]->driverFunc(NULL,
                                GET_REQUIRED_HW_INTERFACES,
                                &flags))
                    flags = HW_IO;

                if(NEED_IO_ENABLED(flags))
                    xorgHWAccess = TRUE;
                if(!(flags & HW_SKIP_CONSOLE))
                    xorgHWOpenConsole = TRUE;
            }
        }

        if (xorgHWOpenConsole)
            xf86OpenConsole();
        else
            xf86Info.dontVTSwitch = TRUE;

        if (xf86BusConfig() == FALSE)
            return;

        xf86PostProbe();

        /*
         * Sort the drivers to match the requested ording.  Using a slow
         * bubble sort.
         */
        for (j = 0; j < xf86NumScreens - 1; j++) {
            for (i = 0; i < xf86NumScreens - j - 1; i++) {
                if (xf86Screens[i + 1]->confScreen->screennum <
                        xf86Screens[i]->confScreen->screennum) {
                    ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
                    xf86Screens[i + 1] = xf86Screens[i];
                    xf86Screens[i] = tmpScrn;
                }
            }
        }
        /* Fix up the indexes */
        for (i = 0; i < xf86NumScreens; i++) {
            xf86Screens[i]->scrnIndex = i;
        }

        /*
         * Call the driver's PreInit()'s to complete initialisation for the first
         * generation.
         */

        for (i = 0; i < xf86NumScreens; i++) {
            xf86VGAarbiterScrnInit(xf86Screens[i]);
            xf86VGAarbiterLock(xf86Screens[i]);
            if (xf86Screens[i]->PreInit &&
                    xf86Screens[i]->PreInit(xf86Screens[i], 0))
                xf86Screens[i]->configured = TRUE;
            xf86VGAarbiterUnlock(xf86Screens[i]);
        }
        for (i = 0; i < xf86NumScreens; i++)
            if (!xf86Screens[i]->configured)
                xf86DeleteScreen(i--, 0);

        /*
         * If no screens left, return now.
         */

        if (xf86NumScreens == 0) {
            xf86Msg(X_ERROR,
                    "Screen(s) found, but none have a usable configuration.\n");
            return;
        }

        for (i = 0; i < xf86NumScreens; i++) {
            if (xf86Screens[i]->name == NULL) {
                XNFasprintf(&xf86Screens[i]->name, "screen%d", i);
                xf86MsgVerb(X_WARNING, 0,
                            "Screen driver %d has no name set, using `%s'.\n",
                            i, xf86Screens[i]->name);
            }
        }

        /* Remove (unload) drivers that are not required */
        for (i = 0; i < xf86NumDrivers; i++)
            if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
                xf86DeleteDriver(i);

        /*
         * At this stage we know how many screens there are.
         */

        for (i = 0; i < xf86NumScreens; i++)
            xf86InitViewport(xf86Screens[i]);

        /*
         * Collect all pixmap formats and check for conflicts at the display
         * level.  Should we die here?  Or just delete the offending screens?
         */
        screenpix24 = Pix24DontCare;
        for (i = 0; i < xf86NumScreens; i++) {
            if (xf86Screens[i]->imageByteOrder !=
                    xf86Screens[0]->imageByteOrder)
                FatalError("Inconsistent display bitmapBitOrder.  Exiting\n");
            if (xf86Screens[i]->bitmapScanlinePad !=
                    xf86Screens[0]->bitmapScanlinePad)
                FatalError("Inconsistent display bitmapScanlinePad.  Exiting\n");
            if (xf86Screens[i]->bitmapScanlineUnit !=
                    xf86Screens[0]->bitmapScanlineUnit)
                FatalError("Inconsistent display bitmapScanlineUnit.  Exiting\n");
            if (xf86Screens[i]->bitmapBitOrder !=
                    xf86Screens[0]->bitmapBitOrder)
                FatalError("Inconsistent display bitmapBitOrder.  Exiting\n");

            /* Determine the depth 24 pixmap format the screens would like */
            if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
                if (screenpix24 == Pix24DontCare)
                    screenpix24 = xf86Screens[i]->pixmap24;
                else if (screenpix24 != xf86Screens[i]->pixmap24)
                    FatalError("Inconsistent depth 24 pixmap format.  Exiting\n");
            }
        }
        /* check if screenpix24 is consistent with the config/cmdline */
        if (xf86Info.pixmap24 != Pix24DontCare) {
            pix24 = xf86Info.pixmap24;
            pix24From = xf86Info.pix24From;
            if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24)
                pix24Fail = TRUE;
        } else if (screenpix24 != Pix24DontCare) {
            pix24 = screenpix24;
            pix24From = X_PROBED;
        } else
            pix24 = Pix24Use32;

        if (pix24Fail)
            FatalError("Screen(s) can't use the required depth 24 pixmap format"
                       " (%d).  Exiting\n", PIX24TOBPP(pix24));

        /* Initialise the depth 24 format */
        for (j = 0; j < numFormats && formats[j].depth != 24; j++)
            ;
        formats[j].bitsPerPixel = PIX24TOBPP(pix24);

        /* Collect additional formats */
        for (i = 0; i < xf86NumScreens; i++) {
            for (j = 0; j < xf86Screens[i]->numFormats; j++) {
                for (k = 0; ; k++) {
                    if (k >= numFormats) {
                        if (k >= MAXFORMATS)
                            FatalError("Too many pixmap formats!  Exiting\n");
                        formats[k] = xf86Screens[i]->formats[j];
                        numFormats++;
                        break;
                    }
                    if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
                        if ((formats[k].bitsPerPixel ==
                                xf86Screens[i]->formats[j].bitsPerPixel) &&
                                (formats[k].scanlinePad ==
                                 xf86Screens[i]->formats[j].scanlinePad))
                            break;
                        FatalError("Inconsistent pixmap format for depth %d."
                                   "  Exiting\n", formats[k].depth);
                    }
                }
            }
        }
        formatsDone = TRUE;

        if (xf86Info.vtno >= 0 ) {
#define VT_ATOM_NAME         "XFree86_VT"
            Atom VTAtom=-1;
            CARD32  *VT = NULL;
            int  ret;

            /* This memory needs to stay available until the screen has been
            initialized, and we can create the property for real.
                */
            if ( (VT = malloc(sizeof(CARD32)))==NULL ) {
                FatalError("Unable to make VT property - out of memory. Exiting...\n");
            }
            *VT = xf86Info.vtno;

            VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);

            for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) {
                ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
                                                     VTAtom, XA_INTEGER, 32,
                                                     1, VT );
                if (ret != Success)
                    xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
                               "Failed to register VT property\n");
            }
        }

        if (SeatId) {
            Atom SeatAtom;

            SeatAtom = MakeAtom(SEAT_ATOM_NAME, sizeof(SEAT_ATOM_NAME) - 1, TRUE);

            for (i = 0; i < xf86NumScreens; i++) {
                int ret;

                ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
                                                     SeatAtom, XA_STRING, 8,
                                                     strlen(SeatId)+1, SeatId );
                if (ret != Success) {
                    xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
                               "Failed to register seat property\n");
                }
            }
        }

        /* If a screen uses depth 24, show what the pixmap format is */
        for (i = 0; i < xf86NumScreens; i++) {
            if (xf86Screens[i]->depth == 24) {
                xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
                        PIX24TOBPP(pix24));
                break;
            }
        }
    } else {
        /*
         * serverGeneration != 1; some OSs have to do things here, too.
         */
        if (xorgHWOpenConsole)
            xf86OpenConsole();

#ifdef XF86PM
        /*
          should we reopen it here? We need to deal with an already opened
          device. We could leave this to the OS layer. For now we simply
          close it here
        */
        if (xf86OSPMClose)
            xf86OSPMClose();
        if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
            xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
#endif

        /* Make sure full I/O access is enabled */
        if (xorgHWAccess)
            xf86EnableIO();
    }

    /*
     * Use the previously collected parts to setup pScreenInfo
     */

    pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
    pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
    pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
    pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
    pScreenInfo->numPixmapFormats = numFormats;
    for (i = 0; i < numFormats; i++)
        pScreenInfo->formats[i] = formats[i];

    /* Make sure the server's VT is active */

    if (serverGeneration != 1) {
        xf86Resetting = TRUE;
        /* All screens are in the same state, so just check the first */
        if (!xf86Screens[0]->vtSema) {
#ifdef HAS_USL_VTS
            ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
#endif
            xf86AccessEnter();
            was_blocked = xf86BlockSIGIO();
        }
    }

    for (i = 0; i < xf86NumScreens; i++)
        if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
            FatalError("Cannot register DDX private keys");

    if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
            !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0))
        FatalError("Cannot register DDX private keys");

    for (i = 0; i < xf86NumScreens; i++) {
        xf86VGAarbiterLock(xf86Screens[i]);
        /*
         * Almost everything uses these defaults, and many of those that
         * don't, will wrap them.
         */
        xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
#ifdef XFreeXDGA
        xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
#endif
        xf86Screens[i]->DPMSSet = NULL;
        xf86Screens[i]->LoadPalette = NULL;
        xf86Screens[i]->SetOverscan = NULL;
        xf86Screens[i]->DriverFunc = NULL;
        xf86Screens[i]->pScreen = NULL;
        scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
        xf86VGAarbiterUnlock(xf86Screens[i]);
        if (scr_index == i) {
            /*
             * Hook in our ScrnInfoRec, and initialise some other pScreen
             * fields.
             */
            dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
                          xf86ScreenKey, xf86Screens[i]);
            xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
            /* The driver should set this, but make sure it is set anyway */
            xf86Screens[i]->vtSema = TRUE;
        } else {
            /* This shouldn't normally happen */
            FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
        }

        DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
               i, xf86Screens[i]->pScreen );
        DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
               i, xf86Screens[i]->pScreen->CreateWindow );

        dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
                      xf86CreateRootWindowKey,
                      xf86Screens[i]->pScreen->CreateWindow);
        xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;

        if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
        {
            xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC);
            PictureSetSubpixelOrder (xf86Screens[i]->pScreen,
                                     DDC ?
                                     (DDC->features.input_type ?
                                      SubPixelHorizontalRGB : SubPixelNone) :
                                     SubPixelUnknown);
        }
#ifdef RANDR
        if (!xf86Info.disableRandR)
            xf86RandRInit (screenInfo.screens[scr_index]);
        xf86Msg(xf86Info.randRFrom, "RandR %s\n",
                xf86Info.disableRandR ? "disabled" : "enabled");
#endif
    }

    xf86VGAarbiterWrapFunctions();
    xf86UnblockSIGIO(was_blocked);

    xf86InitOrigins();

    xf86Resetting = FALSE;
    xf86Initialising = FALSE;

    RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
                                   NULL);
}