diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/video/modedb.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c index aadef046ce7b..1789a52d776a 100644 --- a/drivers/video/modedb.c +++ b/drivers/video/modedb.c | |||
@@ -944,6 +944,66 @@ void fb_videomode_to_modelist(struct fb_videomode *modedb, int num, | |||
944 | } | 944 | } |
945 | } | 945 | } |
946 | 946 | ||
947 | struct fb_videomode *fb_find_best_display(struct fb_monspecs *specs, | ||
948 | struct list_head *head) | ||
949 | { | ||
950 | struct list_head *pos; | ||
951 | struct fb_modelist *modelist; | ||
952 | struct fb_videomode *m, *m1 = NULL, *md = NULL, *best = NULL; | ||
953 | int first = 0; | ||
954 | |||
955 | if (!head->prev || !head->next || list_empty(head)) | ||
956 | goto finished; | ||
957 | |||
958 | /* get the first detailed mode and the very first mode */ | ||
959 | list_for_each(pos, head) { | ||
960 | modelist = list_entry(pos, struct fb_modelist, list); | ||
961 | m = &modelist->mode; | ||
962 | |||
963 | if (!first) { | ||
964 | m1 = m; | ||
965 | first = 1; | ||
966 | } | ||
967 | |||
968 | if (m->flag & FB_MODE_IS_FIRST) { | ||
969 | md = m; | ||
970 | break; | ||
971 | } | ||
972 | } | ||
973 | |||
974 | /* first detailed timing is preferred */ | ||
975 | if (specs->misc & FB_MISC_1ST_DETAIL) { | ||
976 | best = md; | ||
977 | goto finished; | ||
978 | } | ||
979 | |||
980 | /* find best mode based on display width and height */ | ||
981 | if (specs->max_x && specs->max_y) { | ||
982 | struct fb_var_screeninfo var; | ||
983 | |||
984 | memset(&var, 0, sizeof(struct fb_var_screeninfo)); | ||
985 | var.xres = (specs->max_x * 7200)/254; | ||
986 | var.yres = (specs->max_y * 7200)/254; | ||
987 | m = fb_find_best_mode(&var, head); | ||
988 | if (m) { | ||
989 | best = m; | ||
990 | goto finished; | ||
991 | } | ||
992 | } | ||
993 | |||
994 | /* use first detailed mode */ | ||
995 | if (md) { | ||
996 | best = md; | ||
997 | goto finished; | ||
998 | } | ||
999 | |||
1000 | /* last resort, use the very first mode */ | ||
1001 | best = m1; | ||
1002 | finished: | ||
1003 | return best; | ||
1004 | } | ||
1005 | EXPORT_SYMBOL(fb_find_best_display); | ||
1006 | |||
947 | EXPORT_SYMBOL(fb_videomode_to_var); | 1007 | EXPORT_SYMBOL(fb_videomode_to_var); |
948 | EXPORT_SYMBOL(fb_var_to_videomode); | 1008 | EXPORT_SYMBOL(fb_var_to_videomode); |
949 | EXPORT_SYMBOL(fb_mode_is_equal); | 1009 | EXPORT_SYMBOL(fb_mode_is_equal); |