move around - flatter.
[profile/ivi/evas.git] / src / modules / engines / fb / evas_fb.h
1 #ifndef _EVAS_FB_H
2 #define _EVAS_FB_H 1
3
4 /* -------------------------------------------------------------------- */
5 /* LINUX FBCON FRAMEBUFFER UTILITY CODE                                 */
6 /* makes setting up the framebuffer easy. Also makes it eays to port to */
7 /* some other system if needed.                                         */
8 /* Copyright (c) 1999 - Carsten Haitzler (The Rasterman)                */
9 /* -------------------------------------------------------------------- */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <unistd.h>
15 #include <fcntl.h>
16 #include <termios.h>
17 #include <signal.h>
18 #include <errno.h>
19 #include <signal.h>
20 #include <sys/ioctl.h>
21 #include <sys/mman.h>
22 #include <sys/wait.h>
23 #include <sys/stat.h>
24 #include <linux/kd.h>
25 #include <linux/vt.h>
26 #include <linux/fb.h>
27
28 typedef struct _fb_mode FB_Mode;
29
30 struct _fb_mode
31 {
32   int             width;
33   int             height;
34   int             refresh;
35   int             depth;
36   int             bpp;
37   int             fb_fd;
38   void           *mem;
39   int             mem_offset;
40   struct fb_var_screeninfo fb_var;
41 };
42
43 /* init a framebuffer (and switch to) vt number vt. If vt == 0 use current   */
44 /* vt                                                                        */
45 void fb_init(int vt, int device);
46 /* call this afetr setting or getting the fb mode (whichever) to complete    */
47 /* the dsetup                                                                */
48 int  fb_postinit(FB_Mode *mode);
49 /* console switching - if a switch was requested this with block if block    */
50 /* is 1, otherwise it will return 1 if current console is active or 0 if     */
51 /* the user has switched away in the meantime                                */
52 int  fb_await_switch(int block);
53 /* list all current possible video modes listed in /etc/fb.modes             */
54 /* returns pointer to an aray of FB_Mode, and sets num_return to the number  */
55 /* of elements int he returned array                                         */
56 FB_Mode *fb_list_modes(int *num_return);
57 /* sets the fb mode to the resolution width x height and the depth to depth. */
58 /* and if refresh > 0 attempts to use a mode with a refresh rate (in Hz) of  */
59 /* that. If this fails it will return NULL - if it succeeds it will return   */
60 /* a pointer to the FB_Mode thatwas set. only modes in /etc/fb.modes will    */
61 /* be used. If refresh is 0 it uses the DEFAULT mode (the one with no        */
62 /* refresh rate at the end of its name (WIDTHxHEIGHT-REFRESH)                */
63 /* NB: in 8bpp you get a 332 palette. This is fixed so all modes are         */
64 /* "truecolor" - the onyl difference is how many bits bep red, green and     */
65 /* blue channel. This is for speed reasons                                   */
66 FB_Mode *fb_setmode(int width, int height, int depth, int refresh);
67 /* returns the current fb mode being used in FB_Mode                         */
68 FB_Mode *fb_getmode(void);
69 /* changes the bit depth of the current fb mode to depth and returns a new   */
70 /* handle to a new fb mode with updated parameters. frees cur_mode for you.  */
71 FB_Mode *fb_changedepth(FB_Mode *cur_mode, int depth);
72 /* changes resolution - retaining current depth of the current mode,         */
73 /* returning a handle to the new mode once done. frees cur_mode for you.     */
74 FB_Mode *fb_changeres(FB_Mode *cur_mode, int width, int height, int refresh);
75 /* chnages both resolution and depth and returns a handle to the new mode    */
76 /* when done. frees cur_mode for you                                         */
77 FB_Mode *fb_changemode(FB_Mode *cur_mode, int width, int height, int depth, int refresh);
78
79 /* ------------------------------------------------------------------------- */
80 /* How to init:                                                              */
81 /* (Example)                                                                 */
82
83 /* FB_Mode *mode;                                                            */
84 /* int fb_fd = -1;                                                           */
85 /* fb_init(0);                                                               */
86 /* mode = fb_setmode(640, 480, 8, 0);                                        */
87 /* if (mode)                                                                 */
88 /*   fb_fd = fb_postinit(mode);                                              */
89 /* if (fb_fd == -1)                                                          */
90 /*   {                                                                       */
91 /*     fprintf(stderr, "Frambuffer init failed\n");                          */
92 /*     exit(1);                                                              */
93 /*   }                                                                       */
94 /* .... code to play with the FB                                             */
95 #endif