Lines Matching +full:m +full:- +full:mode

2  *  linux/drivers/video/modedb.c -- Standard video mode database management
6 * 2001 - Documented with DocBook
7 * - Brad Douglas <brad@neruo.com>
33 * Standard video mode definitions (taken from XFree86)
293 /* 0 640x350-85 VESA */
296 /* 1 640x400-85 VESA */
299 /* 2 720x400-85 VESA */
302 /* 3 640x480-60 VESA */
305 /* 4 640x480-72 VESA */
308 /* 5 640x480-75 VESA */
311 /* 6 640x480-85 VESA */
314 /* 7 800x600-56 VESA */
318 /* 8 800x600-60 VESA */
322 /* 9 800x600-72 VESA */
326 /* 10 800x600-75 VESA */
330 /* 11 800x600-85 VESA */
334 /* 12 1024x768i-43 VESA */
338 /* 13 1024x768-60 VESA */
341 /* 14 1024x768-70 VESA */
344 /* 15 1024x768-75 VESA */
348 /* 16 1024x768-85 VESA */
352 /* 17 1152x864-75 VESA */
356 /* 18 1280x960-60 VESA */
360 /* 19 1280x960-85 VESA */
364 /* 20 1280x1024-60 VESA */
368 /* 21 1280x1024-75 VESA */
372 /* 22 1280x1024-85 VESA */
376 /* 23 1600x1200-60 VESA */
380 /* 24 1600x1200-65 VESA */
384 /* 25 1600x1200-70 VESA */
388 /* 26 1600x1200-75 VESA */
392 /* 27 1600x1200-85 VESA */
396 /* 28 1792x1344-60 VESA */
399 /* 29 1792x1344-75 VESA */
402 /* 30 1856x1392-60 VESA */
405 /* 31 1856x1392-75 VESA */
408 /* 32 1920x1440-60 VESA */
411 /* 33 1920x1440-75 VESA */
414 /* 34 1920x1200-60 RB VESA */
417 /* 35 1920x1200-60 VESA */
420 /* 36 1920x1200-75 VESA */
423 /* 37 1920x1200-85 VESA */
426 /* 38 2560x1600-60 RB VESA */
429 /* 39 2560x1600-60 VESA */
432 /* 40 2560x1600-75 VESA */
435 /* 41 2560x1600-85 VESA */
438 /* 42 2560x1600-120 RB VESA */
530 * fb_try_mode - test a video mode
533 * @mode: frame buffer video mode structure
536 * Tries a video mode to test it's validity for device @info.
543 const struct fb_videomode *mode, unsigned int bpp) in fb_try_mode() argument
547 DPRINTK("Trying mode %s %dx%d-%d@%d\n", in fb_try_mode()
548 mode->name ? mode->name : "noname", in fb_try_mode()
549 mode->xres, mode->yres, bpp, mode->refresh); in fb_try_mode()
550 var->xres = mode->xres; in fb_try_mode()
551 var->yres = mode->yres; in fb_try_mode()
552 var->xres_virtual = mode->xres; in fb_try_mode()
553 var->yres_virtual = mode->yres; in fb_try_mode()
554 var->xoffset = 0; in fb_try_mode()
555 var->yoffset = 0; in fb_try_mode()
556 var->bits_per_pixel = bpp; in fb_try_mode()
557 var->activate |= FB_ACTIVATE_TEST; in fb_try_mode()
558 var->pixclock = mode->pixclock; in fb_try_mode()
559 var->left_margin = mode->left_margin; in fb_try_mode()
560 var->right_margin = mode->right_margin; in fb_try_mode()
561 var->upper_margin = mode->upper_margin; in fb_try_mode()
562 var->lower_margin = mode->lower_margin; in fb_try_mode()
563 var->hsync_len = mode->hsync_len; in fb_try_mode()
564 var->vsync_len = mode->vsync_len; in fb_try_mode()
565 var->sync = mode->sync; in fb_try_mode()
566 var->vmode = mode->vmode; in fb_try_mode()
567 if (info->fbops->fb_check_var) in fb_try_mode()
568 err = info->fbops->fb_check_var(var, info); in fb_try_mode()
569 var->activate &= ~FB_ACTIVATE_TEST; in fb_try_mode()
574 * fb_find_mode - finds a valid video mode
577 * @mode_option: string video mode to find
578 * @db: video mode database
580 * @default_mode: default video mode to fall back to
583 * Finds a suitable video mode, starting with the specified mode
585 * @default_mode fails, all modes in the video mode database will
588 * Valid mode specifiers for @mode_option::
590 * <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][p][m]
594 * <name>[-<bpp>][@<refresh>]
599 * If 'M' is present after yres (and before refresh/bpp if present),
601 * Video Timings (CVT). If 'R' is present after 'M', will compute with
603 * interlaced or progressive mode. If 'm' is present, add margins equal
605 * 'i', 'p' and 'm' must be after 'M' and 'R'. Example::
607 * 1024x768MR-8@60m - Reduced blank with margins at 60Hz.
614 * 3 if default mode is used, 4 if fall back to any valid mode.
637 /* Did the user specify a video mode? */ in fb_find_mode()
650 for (i = namelen-1; i >= 0; i--) { in fb_find_mode()
664 case '-': in fb_find_mode()
685 case 'M': in fb_find_mode()
693 case 'm': in fb_find_mode()
722 DPRINTK("CVT mode %dx%d@%dHz%s%s%s\n", xres, yres, in fb_find_mode()
741 DPRINTK("modedb CVT: CVT mode ok\n"); in fb_find_mode()
745 DPRINTK("CVT mode invalid, getting mode from database\n"); in fb_find_mode()
748 DPRINTK("Trying specified video mode%s %ix%i\n", in fb_find_mode()
754 * If the caller has provided a custom mode database and in fb_find_mode()
755 * a valid monspecs structure, we look for the mode with in fb_find_mode()
757 * it and try to find a mode with a refresh rate closest in fb_find_mode()
761 info->monspecs.vfmin && info->monspecs.vfmax && in fb_find_mode()
762 info->monspecs.hfmin && info->monspecs.hfmax && in fb_find_mode()
763 info->monspecs.dclkmax) { in fb_find_mode()
770 diff = -1; in fb_find_mode()
771 best = -1; in fb_find_mode()
778 int score = abs(db[i].refresh - refresh); in fb_find_mode()
781 score += abs(db_interlace - interlace); in fb_find_mode()
795 if (best != -1) { in fb_find_mode()
801 best = -1; in fb_find_mode()
802 DPRINTK("Trying best-fit modes\n"); in fb_find_mode()
806 tdiff = abs(db[i].xres - xres) + in fb_find_mode()
807 abs(db[i].yres - yres); in fb_find_mode()
822 if (best != -1) { in fb_find_mode()
828 DPRINTK("Trying default video mode\n"); in fb_find_mode()
837 DPRINTK("No valid mode found\n"); in fb_find_mode()
842 * fb_var_to_videomode - convert fb_var_screeninfo to fb_videomode
843 * @mode: pointer to struct fb_videomode
846 void fb_var_to_videomode(struct fb_videomode *mode, in fb_var_to_videomode() argument
851 mode->name = NULL; in fb_var_to_videomode()
852 mode->xres = var->xres; in fb_var_to_videomode()
853 mode->yres = var->yres; in fb_var_to_videomode()
854 mode->pixclock = var->pixclock; in fb_var_to_videomode()
855 mode->hsync_len = var->hsync_len; in fb_var_to_videomode()
856 mode->vsync_len = var->vsync_len; in fb_var_to_videomode()
857 mode->left_margin = var->left_margin; in fb_var_to_videomode()
858 mode->right_margin = var->right_margin; in fb_var_to_videomode()
859 mode->upper_margin = var->upper_margin; in fb_var_to_videomode()
860 mode->lower_margin = var->lower_margin; in fb_var_to_videomode()
861 mode->sync = var->sync; in fb_var_to_videomode()
862 mode->vmode = var->vmode & FB_VMODE_MASK; in fb_var_to_videomode()
863 mode->flag = FB_MODE_IS_FROM_VAR; in fb_var_to_videomode()
864 mode->refresh = 0; in fb_var_to_videomode()
866 if (!var->pixclock) in fb_var_to_videomode()
869 pixclock = PICOS2KHZ(var->pixclock) * 1000; in fb_var_to_videomode()
871 htotal = var->xres + var->right_margin + var->hsync_len + in fb_var_to_videomode()
872 var->left_margin; in fb_var_to_videomode()
873 vtotal = var->yres + var->lower_margin + var->vsync_len + in fb_var_to_videomode()
874 var->upper_margin; in fb_var_to_videomode()
876 if (var->vmode & FB_VMODE_INTERLACED) in fb_var_to_videomode()
878 if (var->vmode & FB_VMODE_DOUBLE) in fb_var_to_videomode()
885 mode->refresh = hfreq/vtotal; in fb_var_to_videomode()
889 * fb_videomode_to_var - convert fb_videomode to fb_var_screeninfo
891 * @mode: pointer to struct fb_videomode
894 const struct fb_videomode *mode) in fb_videomode_to_var() argument
896 var->xres = mode->xres; in fb_videomode_to_var()
897 var->yres = mode->yres; in fb_videomode_to_var()
898 var->xres_virtual = mode->xres; in fb_videomode_to_var()
899 var->yres_virtual = mode->yres; in fb_videomode_to_var()
900 var->xoffset = 0; in fb_videomode_to_var()
901 var->yoffset = 0; in fb_videomode_to_var()
902 var->pixclock = mode->pixclock; in fb_videomode_to_var()
903 var->left_margin = mode->left_margin; in fb_videomode_to_var()
904 var->right_margin = mode->right_margin; in fb_videomode_to_var()
905 var->upper_margin = mode->upper_margin; in fb_videomode_to_var()
906 var->lower_margin = mode->lower_margin; in fb_videomode_to_var()
907 var->hsync_len = mode->hsync_len; in fb_videomode_to_var()
908 var->vsync_len = mode->vsync_len; in fb_videomode_to_var()
909 var->sync = mode->sync; in fb_videomode_to_var()
910 var->vmode = mode->vmode & FB_VMODE_MASK; in fb_videomode_to_var()
914 * fb_mode_is_equal - compare 2 videomodes
924 return (mode1->xres == mode2->xres && in fb_mode_is_equal()
925 mode1->yres == mode2->yres && in fb_mode_is_equal()
926 mode1->pixclock == mode2->pixclock && in fb_mode_is_equal()
927 mode1->hsync_len == mode2->hsync_len && in fb_mode_is_equal()
928 mode1->vsync_len == mode2->vsync_len && in fb_mode_is_equal()
929 mode1->left_margin == mode2->left_margin && in fb_mode_is_equal()
930 mode1->right_margin == mode2->right_margin && in fb_mode_is_equal()
931 mode1->upper_margin == mode2->upper_margin && in fb_mode_is_equal()
932 mode1->lower_margin == mode2->lower_margin && in fb_mode_is_equal()
933 mode1->sync == mode2->sync && in fb_mode_is_equal()
934 mode1->vmode == mode2->vmode); in fb_mode_is_equal()
938 * fb_find_best_mode - find best matching videomode
947 * info->modelist are valid.
951 * var->xres and var->yres. If more than 1 videomode is found, will return
959 struct fb_videomode *mode, *best = NULL; in fb_find_best_mode() local
960 u32 diff = -1; in fb_find_best_mode()
966 mode = &modelist->mode; in fb_find_best_mode()
968 if (mode->xres >= var->xres && mode->yres >= var->yres) { in fb_find_best_mode()
969 d = (mode->xres - var->xres) + in fb_find_best_mode()
970 (mode->yres - var->yres); in fb_find_best_mode()
973 best = mode; in fb_find_best_mode()
975 mode->refresh > best->refresh) in fb_find_best_mode()
976 best = mode; in fb_find_best_mode()
983 * fb_find_nearest_mode - find closest videomode
985 * @mode: pointer to struct fb_videomode
992 const struct fb_videomode *fb_find_nearest_mode(const struct fb_videomode *mode, in fb_find_nearest_mode() argument
998 u32 diff = -1, diff_refresh = -1; in fb_find_nearest_mode()
1004 cmode = &modelist->mode; in fb_find_nearest_mode()
1006 d = abs(cmode->xres - mode->xres) + in fb_find_nearest_mode()
1007 abs(cmode->yres - mode->yres); in fb_find_nearest_mode()
1010 diff_refresh = abs(cmode->refresh - mode->refresh); in fb_find_nearest_mode()
1013 d = abs(cmode->refresh - mode->refresh); in fb_find_nearest_mode()
1025 * fb_match_mode - find a videomode which exactly matches the timings in var
1037 struct fb_videomode *m, mode; in fb_match_mode() local
1039 fb_var_to_videomode(&mode, var); in fb_match_mode()
1042 m = &modelist->mode; in fb_match_mode()
1043 if (fb_mode_is_equal(m, &mode)) in fb_match_mode()
1044 return m; in fb_match_mode()
1050 * fb_add_videomode - adds videomode entry to modelist
1051 * @mode: videomode to add
1055 * Will only add unmatched mode entries
1057 int fb_add_videomode(const struct fb_videomode *mode, struct list_head *head) in fb_add_videomode() argument
1061 struct fb_videomode *m; in fb_add_videomode() local
1066 m = &modelist->mode; in fb_add_videomode()
1067 if (fb_mode_is_equal(m, mode)) { in fb_add_videomode()
1077 return -ENOMEM; in fb_add_videomode()
1078 modelist->mode = *mode; in fb_add_videomode()
1079 list_add(&modelist->list, head); in fb_add_videomode()
1085 * fb_delete_videomode - removed videomode entry from modelist
1086 * @mode: videomode to remove
1090 * Will remove all matching mode entries
1092 void fb_delete_videomode(const struct fb_videomode *mode, in fb_delete_videomode() argument
1097 struct fb_videomode *m; in fb_delete_videomode() local
1101 m = &modelist->mode; in fb_delete_videomode()
1102 if (fb_mode_is_equal(m, mode)) { in fb_delete_videomode()
1110 * fb_destroy_modelist - destroy modelist
1125 * fb_videomode_to_modelist - convert mode array to mode list
1148 const struct fb_videomode *m, *m1 = NULL, *md = NULL, *best = NULL; in fb_find_best_display() local
1151 if (!head->prev || !head->next || list_empty(head)) in fb_find_best_display()
1154 /* get the first detailed mode and the very first mode */ in fb_find_best_display()
1157 m = &modelist->mode; in fb_find_best_display()
1160 m1 = m; in fb_find_best_display()
1164 if (m->flag & FB_MODE_IS_FIRST) { in fb_find_best_display()
1165 md = m; in fb_find_best_display()
1171 if (specs->misc & FB_MISC_1ST_DETAIL) { in fb_find_best_display()
1176 /* find best mode based on display width and height */ in fb_find_best_display()
1177 if (specs->max_x && specs->max_y) { in fb_find_best_display()
1181 var.xres = (specs->max_x * 7200)/254; in fb_find_best_display()
1182 var.yres = (specs->max_y * 7200)/254; in fb_find_best_display()
1183 m = fb_find_best_mode(&var, head); in fb_find_best_display()
1184 if (m) { in fb_find_best_display()
1185 best = m; in fb_find_best_display()
1190 /* use first detailed mode */ in fb_find_best_display()
1196 /* last resort, use the very first mode */ in fb_find_best_display()