evas/fb: expose and call fb_freemode() and fb_cleanup()

properly clean memory and restore framebuffer on error conditions.

@fix
This commit is contained in:
Gustavo Sverzut Barbieri 2014-03-06 02:16:03 -03:00
parent b0aa7325ae
commit 587a171061
3 changed files with 16 additions and 4 deletions

View File

@ -41,6 +41,8 @@ struct _fb_mode
/* init a framebuffer (and switch to) vt number vt. If vt == 0 use current */
/* vt */
void fb_init(int vt, int device);
/* finishes whatever was done at fb_init() */
void fb_cleanup(void);
/* call this afetr setting or getting the fb mode (whichever) to complete */
/* the dsetup */
int fb_postinit(FB_Mode *mode);
@ -64,6 +66,8 @@ FB_Mode *fb_list_modes(unsigned int *num_return);
FB_Mode *fb_setmode(unsigned int width, unsigned int height, unsigned int depth, unsigned int refresh);
/* returns the current fb mode being used in FB_Mode */
FB_Mode *fb_getmode(void);
/* free the FB_Mode struct returned by fb_getmode() */
void fb_freemode(FB_Mode *mode);
/* changes the bit depth of the current fb mode to depth and returns a new */
/* handle to a new fb mode with updated parameters. frees cur_mode for you. */
FB_Mode *fb_changedepth(FB_Mode *cur_mode, unsigned int depth);

View File

@ -36,7 +36,6 @@ static struct fb_cmap cmap = { 0, 256, red, green, blue, NULL };
/* -------------------------------------------------------------------- */
/* internal function prototypes */
static void fb_cleanup(void);
//static void fb_cleanup_fork(void);
//static void fb_setvt(int vtno);
static void fb_init_palette_332(FB_Mode *mode);
@ -388,6 +387,12 @@ fb_getmode(void)
return mode;
}
void
fb_freemode(FB_Mode *mode)
{
free(mode);
}
/* XXX: unused
static void
fb_setvt(int vtno)
@ -583,7 +588,7 @@ fb_postinit(FB_Mode *mode)
return fb;
}
static void
void
fb_cleanup(void)
{
if (fb < 0) return;

View File

@ -11,10 +11,10 @@ evas_fb_outbuf_fb_init(void)
void
evas_fb_outbuf_fb_free(Outbuf *buf)
{
/* FIXME: implement */
WRN("destroying fb info.. not implemented!!!! WARNING. LEAK!");
if (buf->priv.back_buf)
evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
fb_freemode(buf->priv.fb.fb);
fb_cleanup();
free(buf);
}
@ -53,6 +53,7 @@ evas_fb_outbuf_fb_setup_fb(int w, int h, int rot, Outbuf_Depth depth, int vt_no,
fb_fd = fb_postinit(buf->priv.fb.fb);
if (fb_fd < 1)
{
fb_freemode(buf->priv.fb.fb);
free(buf);
return NULL;
}
@ -104,6 +105,8 @@ evas_fb_outbuf_fb_setup_fb(int w, int h, int rot, Outbuf_Depth depth, int vt_no,
buf->rot);
if (!conv_func)
{
fb_freemode(buf->priv.fb.fb);
fb_cleanup();
free(buf);
return NULL;
}