FreeBSD/sys/dev/fb/vga.c
/* map a generic video mode to a known mode number */
map a generic video mode to a known mode number
map a generic video mode to a known mode number
static int
map_gen_mode_num(int type, int color, int mode)
{
    static struct {
	int from;
	int to_color;
	int to_mono;
    } mode_map[] = {
	{ M_TEXT_80x30,	M_VGA_C80x30, M_VGA_M80x30, },
	{ M_TEXT_80x43,	M_ENH_C80x43, M_ENH_B80x43, },
	{ M_TEXT_80x50,	M_VGA_C80x50, M_VGA_M80x50, },
	{ M_TEXT_80x60,	M_VGA_C80x60, M_VGA_M80x60, },
    };
    int i;
    if (mode == M_TEXT_80x25) {
	switch (type) {
	case KD_VGA:
	    if (color)
		return M_VGA_C80x25;
	    else
		return M_VGA_M80x25;
	    break;
	case KD_EGA:
	    if (color)
		return M_ENH_C80x25;
	    else
		return M_EGAMONO80x25;
	    break;
	case KD_CGA:
	    return M_C80x25;
	case KD_MONO:
	case KD_HERCULES:
	    return M_EGAMONO80x25;	
 	default:
	    return -1;
	}
    }
    for (i = 0; i < nitems(mode_map); ++i) {
        if (mode_map[i].from == mode)
            return ((color) ? mode_map[i].to_color : mode_map[i].to_mono);
    }
    return mode;
}
static int map_gen_mode_num ( int type , int color , int mode ) { static struct { int from ; int to_color ; int to_mono ; } mode_map [ ] = { { M_TEXT_80x30 , M_VGA_C80x30 , M_VGA_M80x30 , } , { M_TEXT_80x43 , M_ENH_C80x43 , M_ENH_B80x43 , } , { M_TEXT_80x50 , M_VGA_C80x50 , M_VGA_M80x50 , } , { M_TEXT_80x60 , M_VGA_C80x60 , M_VGA_M80x60 , } , } ; int i ; if ( mode == M_TEXT_80x25 ) { switch ( type ) { case KD_VGA : if ( color ) return M_VGA_C80x25 ; else return M_VGA_M80x25 ; break ; case KD_EGA : if ( color ) return M_ENH_C80x25 ; else return M_EGAMONO80x25 ; break ; case KD_CGA : return M_C80x25 ; case KD_MONO : case KD_HERCULES : return M_EGAMONO80x25 ; default : return -1 ; } } for ( i = 0 ; i < nitems ( mode_map ) ; ++ i ) { if ( mode_map [ i ] . from == mode ) return ( ( color ) ? mode_map [ i ] . to_color : mode_map [ i ] . to_mono ) ; } return mode ; }
map a generic video mode to a known mode number
map a generic video mode to a known mode number
/* XXX: this name is confusing */