static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { if (var->xres > 1600 || var->yres > 1200) return -EINVAL; if ((var->xres > 1280 || var->yres > 1024) && var->bits_per_pixel > 16) return -EINVAL; if (var->bits_per_pixel == 32) { var->red.offset = 16; var->red.length = 8; var->green.offset = 8; var->green.length = 8; var->blue.offset = 0; var->blue.length = 8; } else if (var->bits_per_pixel == 16) { var->red.offset = 11; var->red.length = 5; var->green.offset = 5; var->green.length = 6; var->blue.offset = 0; var->blue.length = 5; } else if (var->bits_per_pixel == 8) { var->red.offset = 0; var->red.length = 8; var->green.offset = 0; var->green.length = 8; var->blue.offset = 0; var->blue.length = 8; } else return -EINVAL; var->transp.offset = 0; var->transp.length = 0; /* Enough video memory? */ if (gx_line_delta(var->xres, var->bits_per_pixel) * var->yres > info->fix.smem_len) return -EINVAL; /* FIXME: Check timing parameters here? */ return 0; }
static int gxfb_set_par(struct fb_info *info) { if (info->var.bits_per_pixel > 8) info->fix.visual = FB_VISUAL_TRUECOLOR; else info->fix.visual = FB_VISUAL_PSEUDOCOLOR; info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel); gx_set_mode(info); return 0; }
static int gxfb_set_par(struct fb_info *info) { if (info->var.bits_per_pixel > 8) { info->fix.visual = FB_VISUAL_TRUECOLOR; fb_dealloc_cmap(&info->cmap); } else { info->fix.visual = FB_VISUAL_PSEUDOCOLOR; fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0); } info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel); gx_set_mode(info); return 0; }