示例#1
0
文件: visual.c 项目: antrik/libggi
static int do_cleanup(struct ggi_visual *vis)
{
        ggi_libkgi_priv *priv = LIBKGI_PRIV(vis);

        /* We may be called more than once due to the LibGG cleanup stuff */
        if (priv == NULL) return 0;

        DPRINT("display-libkgi: GGIdlcleanup start.\n");

        if (LIBGGI_FD(vis) >= 0) close(LIBGGI_FD(vis));

        if (vis->input != NULL) {
                giiClose(vis->input);
                vis->input = NULL;
        }

	free(priv);
        LIBKGI_PRIV(vis) = NULL;

        ggUnregisterCleanup((ggcleanup_func *)do_cleanup, vis);

        ggLock(_ggi_global_lock);
        refcount--;
        refcount--;
        if (refcount == 0) {
                ggLockDestroy(_ggi_libkgi_lock);
                _ggi_libkgi_lock = NULL;
        }
        ggUnlock(_ggi_global_lock);

        DPRINT("display-libkgi: GGIdlcleanup done.\n");

        return 0;
}
示例#2
0
static int do_cleanup(ggi_visual *vis)
{
	ggi_fbdev_priv *fbdevpriv = FBDEV_PRIV(vis);
	struct m2164w_priv *priv = NULL;
	int i;

	DPRINT_MISC("mga-2164w: Starting cleanup\n");

	if (fbdevpriv != NULL) {
		priv = M2164W_PRIV(vis);
	}

	/* We may be called more than once due to the LibGG cleanup stuff */
	if (priv == NULL) return 0;

	/* Restore OPMODE and terminate any pending DMA operations
	   Manual says we should write to byte 0 to terminate DMA sequence,
	   but it doesn't say whether a 8 bit access is required, or if any
	   access will do. We play it safe here... */
	mga_out8(fbdevpriv->mmioaddr, priv->origopmode & 0xff, OPMODE);
	mga_out16(fbdevpriv->mmioaddr, priv->origopmode, OPMODE);
	mga_waitidle(fbdevpriv->mmioaddr);

	munmap((void*)fbdevpriv->mmioaddr, fbdevpriv->orig_fix.mmio_len);
	DPRINT_MISC("mga-2164w: Unmapped MMIO\n");

	/* Free DB resource structures */
	for (i = LIBGGI_APPLIST(vis)->num-1; i >= 0; i--) {
		if (LIBGGI_APPBUFS(vis)[i]->resource) {
			free(LIBGGI_APPBUFS(vis)[i]->resource);
			LIBGGI_APPBUFS(vis)[i]->resource = NULL;
		}
	}

	free(priv);
	FBDEV_PRIV(vis)->accelpriv = NULL;

	ggUnregisterCleanup((ggcleanup_func *)do_cleanup, vis);

	return 0;
}
示例#3
0
static int do_cleanup(ggi_visual *vis)
{
	ggi_lcd823_priv *priv = LCD823_PRIV(vis);

	/* We may be called more than once due to the LibGG cleanup stuff */
	if (priv == NULL) return 0;

	DPRINT("display-lcd823: do_cleanup start.\n");

	_GGI_lcd823_free_dbs(vis);

	if (LIBGGI_FD(vis) >= 0) {
		if (priv->fb_ptr) {
			munmap(priv->fb_ptr, priv->fb_size);
		}
		ioctl(LIBGGI_FD(vis), 2); /* Disable LCD */
		close(LIBGGI_FD(vis));
		LIBGGI_FD(vis) = -1;
	}

	if (vis->input != NULL) {
		giiClose(vis->input);
		vis->input = NULL;
	}

	free(priv);
	LIBGGI_PRIVATE(vis) = NULL;

	if (LIBGGI_GC(vis)) {
		free(LIBGGI_GC(vis));
	}

	ggUnregisterCleanup((ggcleanup_func *)do_cleanup, vis);

	DPRINT("display-lcd823: do_cleanup done.\n");

	return 0;
}
示例#4
0
文件: input.c 项目: Nekrofage/DoomRPi
static int GII_lin_kbd_close(gii_input *inp)
{
	linkbd_priv *priv = LINKBD_PRIV(inp);

	DPRINT_MISC("Linux-kbd cleanup\n");

	if (priv == NULL) {
		/* Make sure we're only called once */
		return 0;
	}

	if (priv->old_kbled != 0x7f) {
		ioctl(priv->fd, KDSKBLED, priv->old_kbled);
	}

	if (ioctl(priv->fd, KDSKBMODE, priv->old_mode) < 0) {
		perror("Linux-kbd: couldn't restore mode");
	}

	if (tcsetattr(priv->fd, TCSANOW, &priv->old_termios) < 0) {
		perror("Linux-kbd: tcsetattr failed");
	}

	close(priv->fd);

	free(priv);
	inp->priv = NULL;

	ggUnregisterCleanup((ggcleanup_func *)GII_lin_kbd_close, inp);

	fputc('\n', stderr);
	fflush(stderr);

	DPRINT("Linux-kbd: exit OK.\n");

	return 0;
}