aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/console/fbcon.c3
-rw-r--r--drivers/video/modedb.c24
2 files changed, 15 insertions, 12 deletions
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 5ff51cd0a2a9..3cf1b61ff1f8 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -2715,7 +2715,8 @@ static void fbcon_new_modelist(struct fb_info *info)
2715 continue; 2715 continue;
2716 vc = vc_cons[i].d; 2716 vc = vc_cons[i].d;
2717 display_to_var(&var, &fb_display[i]); 2717 display_to_var(&var, &fb_display[i]);
2718 mode = fb_find_nearest_mode(&var, &info->modelist); 2718 mode = fb_find_nearest_mode(fb_display[i].mode,
2719 &info->modelist);
2719 fb_videomode_to_var(&var, mode); 2720 fb_videomode_to_var(&var, mode);
2720 2721
2721 if (vc) 2722 if (vc)
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c
index 47516c44a390..aadef046ce7b 100644
--- a/drivers/video/modedb.c
+++ b/drivers/video/modedb.c
@@ -676,6 +676,8 @@ void fb_var_to_videomode(struct fb_videomode *mode,
676 mode->sync = var->sync; 676 mode->sync = var->sync;
677 mode->vmode = var->vmode & FB_VMODE_MASK; 677 mode->vmode = var->vmode & FB_VMODE_MASK;
678 mode->flag = FB_MODE_IS_FROM_VAR; 678 mode->flag = FB_MODE_IS_FROM_VAR;
679 mode->refresh = 0;
680
679 if (!var->pixclock) 681 if (!var->pixclock)
680 return; 682 return;
681 683
@@ -785,39 +787,39 @@ struct fb_videomode *fb_find_best_mode(struct fb_var_screeninfo *var,
785} 787}
786 788
787/** 789/**
788 * fb_find_nearest_mode - find mode closest video mode 790 * fb_find_nearest_mode - find closest videomode
789 * 791 *
790 * @var: pointer to struct fb_var_screeninfo 792 * @mode: pointer to struct fb_videomode
791 * @head: pointer to modelist 793 * @head: pointer to modelist
792 * 794 *
793 * Finds best matching videomode, smaller or greater in dimension. 795 * Finds best matching videomode, smaller or greater in dimension.
794 * If more than 1 videomode is found, will return the videomode with 796 * If more than 1 videomode is found, will return the videomode with
795 * the closest refresh rate 797 * the closest refresh rate.
796 */ 798 */
797struct fb_videomode *fb_find_nearest_mode(struct fb_var_screeninfo *var, 799struct fb_videomode *fb_find_nearest_mode(struct fb_videomode *mode,
798 struct list_head *head) 800 struct list_head *head)
799{ 801{
800 struct list_head *pos; 802 struct list_head *pos;
801 struct fb_modelist *modelist; 803 struct fb_modelist *modelist;
802 struct fb_videomode *mode, *best = NULL; 804 struct fb_videomode *cmode, *best = NULL;
803 u32 diff = -1, diff_refresh = -1; 805 u32 diff = -1, diff_refresh = -1;
804 806
805 list_for_each(pos, head) { 807 list_for_each(pos, head) {
806 u32 d; 808 u32 d;
807 809
808 modelist = list_entry(pos, struct fb_modelist, list); 810 modelist = list_entry(pos, struct fb_modelist, list);
809 mode = &modelist->mode; 811 cmode = &modelist->mode;
810 812
811 d = abs(mode->xres - var->xres) + 813 d = abs(cmode->xres - mode->xres) +
812 abs(mode->yres - var->yres); 814 abs(cmode->yres - mode->yres);
813 if (diff > d) { 815 if (diff > d) {
814 diff = d; 816 diff = d;
815 best = mode; 817 best = cmode;
816 } else if (diff == d) { 818 } else if (diff == d) {
817 d = abs(mode->refresh - best->refresh); 819 d = abs(cmode->refresh - mode->refresh);
818 if (diff_refresh > d) { 820 if (diff_refresh > d) {
819 diff_refresh = d; 821 diff_refresh = d;
820 best = mode; 822 best = cmode;
821 } 823 }
822 } 824 }
823 } 825 }