Example #1
0
File: mode.c Project: antrik/libggi
int GGI_lcd823_setmode(struct ggi_visual *vis, ggi_mode *mode)
{ 
	int err;

        if ((err = ggiCheckMode(vis, mode)) != 0) {
		return err;
	}

	if (LIBGGI_PAL(vis)->clut.data) {
		free(LIBGGI_PAL(vis)->clut.data);
		LIBGGI_PAL(vis)->clut.data = NULL;
	}

	if (LIBGGI_PAL(vis)->priv) {
		free(LIBGGI_PAL(vis)->priv);
		LIBGGI_PAL(vis)->priv = NULL;
	}

	_GGI_lcd823_free_dbs(vis);

	memcpy(LIBGGI_MODE(vis), mode, sizeof(ggi_mode));

	/* Now actually set the mode */
	err = do_setmode(vis);
	if (err != 0) {
		return err;
	}

	/* Reset panning and frames */
        vis->d_frame_num = vis->origin_x = vis->origin_y = 0;

	return 0;
}
Example #2
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;
}