release/src-rt/linux/linux-2.6/drivers/video/macmodes.c
/**
 *	mac_var_to_vmode - convert var structure to MacOS vmode/cmode pair
 *	@var: frame buffer video mode structure
 *	@vmode: MacOS video mode
 *	@cmode: MacOS color mode
 *
 *	Converts a frame buffer video mode structure to a MacOS
 *	vmode/cmode pair.
 *
 *	Returns negative errno on error, or zero for success.
 *
 */
convert var structure to MacOS vmode/cmode pair
@var: frame buffer video mode structure
@vmode: MacOS video mode
@cmode: MacOS color mode

Converts a frame buffer video mode structure to a MacOS
vmode/cmode pair.

Returns negative errno on error, or zero for success.
convert var structure to MacOS vmode / cmode pair @var : frame buffer video mode structure @vmode : MacOS video mode @cmode : MacOS color mode Converts a frame buffer video mode structure to a MacOS vmode / cmode pair . Returns negative errno on error or zero for success .
int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode,
		     int *cmode)
{
    const struct fb_videomode *mode = NULL;
    const struct mode_map *map;
    if (var->bits_per_pixel <= 8)
	*cmode = CMODE_8;
    else if (var->bits_per_pixel <= 16)
	*cmode = CMODE_16;
    else if (var->bits_per_pixel <= 32)
	*cmode = CMODE_32;
    else
	return -EINVAL;
    for (map = mac_modes; map->vmode != -1; map++) {
	mode = map->mode;
	if (var->xres > mode->xres || var->yres > mode->yres)
	    continue;
	if (var->xres_virtual > mode->xres || var->yres_virtual > mode->yres)
	    continue;
	if (var->pixclock > mode->pixclock)
	    continue;
	if ((var->vmode & FB_VMODE_MASK) != mode->vmode)
	    continue;
	*vmode = map->vmode;
	return 0;
    }
    return -EINVAL;
}
int mac_var_to_vmode ( const struct fb_var_screeninfo * var , int * vmode , int * cmode ) { const struct fb_videomode * mode = NULL ; const struct mode_map * map ; if ( var -> bits_per_pixel <= 8 ) * cmode = CMODE_8 ; else if ( var -> bits_per_pixel <= 16 ) * cmode = CMODE_16 ; else if ( var -> bits_per_pixel <= 32 ) * cmode = CMODE_32 ; else return - EINVAL ; for ( map = mac_modes ; map -> vmode != -1 ; map ++ ) { mode = map -> mode ; if ( var -> xres > mode -> xres || var -> yres > mode -> yres ) continue ; if ( var -> xres_virtual > mode -> xres || var -> yres_virtual > mode -> yres ) continue ; if ( var -> pixclock > mode -> pixclock ) continue ; if ( ( var -> vmode & FB_VMODE_MASK ) != mode -> vmode ) continue ; * vmode = map -> vmode ; return 0 ; } return - EINVAL ; }
mac_var_to_vmode - convert var structure to MacOS vmode/cmode pair
      @var: frame buffer video mode structure
      @vmode: MacOS video mode
      @cmode: MacOS color mode
mac_var_to_vmode - convert var structure to MacOS vmode / cmode pair @var : frame buffer video mode structure @vmode : MacOS video mode @cmode : MacOS color mode