/* Select the smallest mode that allows the desired resolution to be displayed. If desired parameters can be rounded up.  */
static struct pxafb_mode_info* pxafb_getmode(struct pxafb_mach_info *mach, struct fb_var_screeninfo *var)
/* Select the smallest mode that allows the desired resolution to be displayed. If desired parameters can be rounded up.  */
static struct pxafb_mode_info* pxafb_getmode(struct pxafb_mach_info *mach, struct fb_var_screeninfo *var)
{
	struct pxafb_mode_info *mode = NULL;
	struct pxafb_mode_info *modelist = mach->modes;
	unsigned int best_x = 0xffffffff, best_y = 0xffffffff;
	unsigned int i;
	for (i = 0; i < mach->num_modes; i++) {
		if (modelist[i].xres >= var->xres &&
		    modelist[i].yres >= var->yres &&
		    modelist[i].xres < best_x &&
		    modelist[i].yres < best_y &&
		    modelist[i].bpp >= var->bits_per_pixel) {
			best_x = modelist[i].xres;
			best_y = modelist[i].yres;
			mode = &modelist[i];
		}
	}
	return mode;
}