📄 macmodes.c
字号:
return err; var.activate = FB_ACTIVATE_TEST; err = console_fb_info->fbops->fb_set_var(&var, fg_console, console_fb_info); if (err || !doit) return err; else { int unit; var.activate = FB_ACTIVATE_NOW; for (unit = 0; unit < MAX_NR_CONSOLES; unit++) if (fb_display[unit].conp && (GET_FB_IDX(console_fb_info->node) == con2fb_map[unit])) console_fb_info->fbops->fb_set_var(&var, unit, console_fb_info); } return 0;}/** * console_setcmap - sets palette color map for console * @n_entries: number of entries in the palette (max 16) * @red: value for red component of palette * @green: value for green component of palette * @blue: value for blue component of palette * * Sets global palette_cmap structure and activates the palette * on the current console. * * Note, this function is only for XPMAC compatibility. * * Returns negative errno on error, or zero for success. * */int console_setcmap(int n_entries, unsigned char *red, unsigned char *green, unsigned char *blue){ int i, j, n = 0, err; if (!console_fb_info) return -EOPNOTSUPP; for (i = 0; i < n_entries; i += n) { n = n_entries - i; if (n > 16) n = 16; palette_cmap.start = i; palette_cmap.len = n; for (j = 0; j < n; j++) { palette_cmap.red[j] = (red[i+j] << 8) | red[i+j]; palette_cmap.green[j] = (green[i+j] << 8) | green[i+j]; palette_cmap.blue[j] = (blue[i+j] << 8) | blue[i+j]; } err = console_fb_info->fbops->fb_set_cmap(&palette_cmap, 1, fg_console, console_fb_info); if (err) return err; } return 0;}/** * console_powermode - sets monitor power mode * @mode: power state to set * * Sets power state as dictated by @mode. * * Note that this function is only for XPMAC compatibility and * doesn't do much. * * Returns 0 for %VC_POWERMODE_INQUIRY, -EINVAL for VESA power * settings, or -ENIXIO on failure. * */int console_powermode(int mode){ if (mode == VC_POWERMODE_INQUIRY) return 0; if (mode < VESA_NO_BLANKING || mode > VESA_POWERDOWN) return -EINVAL; /* Not Supported */ return -ENXIO;}#endif /* CONFIG_FB_COMPAT_XPMAC *//** * mac_vmode_to_var - converts vmode/cmode pair to var structure * @vmode: MacOS video mode * @cmode: MacOS color mode * @var: frame buffer video mode structure * * Converts a MacOS vmode/cmode pair to a frame buffer video * mode structure. * * Returns negative errno on error, or zero for success. * */int mac_vmode_to_var(int vmode, int cmode, struct fb_var_screeninfo *var){ const struct fb_videomode *mode = NULL; const struct mode_map *map; for (map = mac_modes; map->vmode != -1; map++) if (map->vmode == vmode) { mode = map->mode; break; } if (!mode) return -EINVAL; memset(var, 0, sizeof(struct fb_var_screeninfo)); switch (cmode) { case CMODE_8: 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; break; case CMODE_16: var->bits_per_pixel = 16; var->red.offset = 10; var->red.length = 5; var->green.offset = 5; var->green.length = 5; var->blue.offset = 0; var->blue.length = 5; break; case CMODE_32: 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; var->transp.offset = 24; var->transp.length = 8; break; default: return -EINVAL; } var->xres = mode->xres; var->yres = mode->yres; var->xres_virtual = mode->xres; var->yres_virtual = mode->yres; var->height = -1; var->width = -1; var->pixclock = mode->pixclock; var->left_margin = mode->left_margin; var->right_margin = mode->right_margin; var->upper_margin = mode->upper_margin; var->lower_margin = mode->lower_margin; var->hsync_len = mode->hsync_len; var->vsync_len = mode->vsync_len; var->sync = mode->sync; var->vmode = mode->vmode; return 0;}/** * 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. * */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_map_monitor_sense - Convert monitor sense to vmode * @sense: Macintosh monitor sense number * * Converts a Macintosh monitor sense number to a MacOS * vmode number. * * Returns MacOS vmode video mode number. * */int mac_map_monitor_sense(int sense){ const struct monitor_map *map; for (map = mac_monitors; map->sense != -1; map++) if (map->sense == sense) break; return map->vmode;}/** * mac_find_mode - find a video mode * @var: frame buffer user defined part of display * @info: frame buffer info structure * @mode_option: video mode name (see mac_modedb[]) * @default_bpp: default color depth in bits per pixel * * Finds a suitable video mode. Tries to set mode specified * by @mode_option. If the name of the wanted mode begins with * 'mac', the Mac video mode database will be used, otherwise it * will fall back to the standard video mode database. * * Note: Function marked as __init and can only be used during * system boot. * * Returns error code from fb_find_mode (see fb_find_mode * function). * */int __init mac_find_mode(struct fb_var_screeninfo *var, struct fb_info *info, const char *mode_option, unsigned int default_bpp){ const struct fb_videomode *db = NULL; unsigned int dbsize = 0; if (mode_option && !strncmp(mode_option, "mac", 3)) { db = mac_modedb; dbsize = sizeof(mac_modedb)/sizeof(*mac_modedb); } return fb_find_mode(var, info, mode_option, db, dbsize, &mac_modedb[DEFAULT_MODEDB_INDEX], default_bpp);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -