- size = (info->var.bits_per_pixel == 8) ? 256 : 16;
- fb_alloc_cmap(&info->cmap, size, 0);
+ /* maximize virtual vertical length */
+ lpitch = info->var.xres_virtual * ((info->var.bits_per_pixel + 7) >> 3);
+ info->var.yres_virtual = info->fix.smem_len/lpitch;
+ if (info->var.yres_virtual < info->var.yres)
+ goto out_err;
+
+#ifdef CONFIG_FB_3DFX_ACCEL
+ /*
+ * FIXME: Limit var->yres_virtual to 4096 because of screen artifacts
+ * during scrolling. This is only present if 2D acceleration is
+ * enabled.
+ */
+ if (info->var.yres_virtual > 4096)
+ info->var.yres_virtual = 4096;
+#endif /* CONFIG_FB_3DFX_ACCEL */
+
+ if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
+ printk(KERN_WARNING "tdfxfb: Can't allocate color map\n");
+ goto out_err;
+ }