Main Page   File List   Globals  

FButil.c

Go to the documentation of this file.
00001 
00010 /* This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; version 2 of the License. */
00013  
00014 #include "FBlib.h"
00015 #include "FBpriv.h"
00016 
00017 FB_pixel FB_makecol(u_char r, u_char g, u_char b, u_char t)
00018 {
00019         FB_pixel color = 0;
00020         
00021         color |= ( (r >> (8 - work_var_info.red.length)) << (work_var_info.red.offset) );
00022         color |= ( (g >> (8 - work_var_info.green.length)) << (work_var_info.green.offset) );
00023         color |= ( (b >> (8 - work_var_info.blue.length)) << (work_var_info.blue.offset) );
00024         if(work_var_info.bits_per_pixel == 32)
00025                 color |= ( (t >> (8 - work_var_info.transp.length)) << (work_var_info.transp.offset) );
00026         return color;
00027 }
00028 
00029 long int get_screensize()
00030 {
00031         return fb_fix_info.smem_len;
00032 }
00033 
00034 int FB_getVisual()
00035 {
00036         return fb_fix_info.visual;
00037 }
00038 
00039 void FB_getres(int *x, int *y)
00040 {
00041         if(x!=NULL && y!=NULL)
00042         {
00043                 if(fb_rotation==FB_ROTATE_NONE || fb_rotation==FB_ROTATE_180)
00044                 {
00045                         *x = work_var_info.xres;
00046                         *y = work_var_info.yres;
00047                 }
00048                 else
00049                 {
00050                         *y = work_var_info.xres;
00051                         *x = work_var_info.yres;
00052                 }
00053         }
00054         return;
00055 }
00056 
00057 int FB_getxres()
00058 {
00059         if(fb_rotation==FB_ROTATE_NONE || fb_rotation==FB_ROTATE_180)
00060                 return work_var_info.xres;
00061         else
00062                 return work_var_info.yres;
00063 }
00064 
00065 int FB_getyres()
00066 {
00067         if(fb_rotation==FB_ROTATE_NONE || fb_rotation==FB_ROTATE_180)
00068                 return work_var_info.yres;
00069         else
00070                 return work_var_info.xres;
00071 }
00072 
00073 int FB_getXVres()
00074 {
00075         if(fb_rotation==FB_ROTATE_NONE || fb_rotation==FB_ROTATE_180)
00076                 return work_var_info.xres_virtual;
00077         else
00078                 return work_var_info.yres_virtual;
00079 }
00080 
00081 int FB_getYVres()
00082 {
00083         if(fb_rotation==FB_ROTATE_NONE || fb_rotation==FB_ROTATE_180)
00084                 return work_var_info.yres_virtual;
00085         else
00086                 return work_var_info.xres_virtual;
00087 }
00088 
00089 int FB_getbpp()
00090 {
00091         return work_var_info.bits_per_pixel;
00092 }
00093 
00094 int FB_setbpp(int bpp)
00095 {
00096         int ioctl_err, oldbpp;  
00097 
00098         /* Check if depth is supported */
00099         if(bpp != 16 || bpp != 32)
00100                 return -1;
00101         oldbpp = work_var_info.bits_per_pixel;
00102         work_var_info.bits_per_pixel = bpp;
00103         /* Try to set bpp */
00104         ioctl_err=ioctl(fbufd,FBIOPUT_VSCREENINFO,&work_var_info);
00105         if(ioctl_err < 0)
00106         {
00107                 fprintf(stderr,"FBlib:unable to change bpp to %d, %s \n",bpp,strerror(errno));
00108                 work_var_info.bits_per_pixel = oldbpp;
00109                 return IOCTL_ERR;
00110         }
00111         /* If everything went well change inc_x */
00112         inc_x = work_var_info.bits_per_pixel / 8;
00113 
00114         return 0;
00115 }
00116 
00117 int FB_setrotation(int rotation)
00118 {
00119         switch(rotation)
00120         {
00121                 case FB_ROTATE_NONE:
00122                 case FB_ROTATE_90:
00123                 case FB_ROTATE_180:
00124                 case FB_ROTATE_270:
00125                         fb_rotation = rotation;
00126                         break;
00127                 default:
00128                         return PARAM_ERR;
00129         }
00130         return OK;
00131 }
00132 
00133 int FB_getrotation()
00134 {
00135         return fb_rotation;
00136 }

Generated on Sat Jul 5 09:04:51 2003 for LibFB by doxygen1.2.18