From patchwork Sun Feb 10 20:23:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Floris Bos X-Patchwork-Id: 2122961 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 64A63DF24C for ; Sun, 10 Feb 2013 20:49:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756315Ab3BJUtZ (ORCPT ); Sun, 10 Feb 2013 15:49:25 -0500 Received: from mx2.je-eigen-domein.nl ([85.10.196.86]:11914 "EHLO mx2.je-eigen-domein.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755681Ab3BJUtZ (ORCPT ); Sun, 10 Feb 2013 15:49:25 -0500 X-Greylist: delayed 1536 seconds by postgrey-1.27 at vger.kernel.org; Sun, 10 Feb 2013 15:49:25 EST Received: from lynx.to-the-max.net (localhost [127.0.0.1]) by mx2.je-eigen-domein.nl (Postfix) with ESMTP id BBE777880DD; Sun, 10 Feb 2013 21:23:48 +0100 (CET) From: Floris Bos To: linux-fbdev@vger.kernel.org, linux-sunxi@googlegroups.com Cc: Floris Bos Subject: [PATCH] video/modedb: fb_find_nearest_mode: take vmode into account Date: Sun, 10 Feb 2013 21:23:34 +0100 Message-Id: <1360527814-28883-1-git-send-email-bos@je-eigen-domein.nl> X-Mailer: git-send-email 1.7.10.4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Previously fb_find_nearest_mode() only searched the modelist for a video mode that best matches the desired resolution and refresh rate. With this patch it also takes the vmode into account if there is more then one mode with the same resolution and refresh rate. Typical use case is HDMI TVs that support both 1080p60 and 1080i60 Signed-off-by: Floris Bos --- drivers/video/modedb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c index a9a907c..e852371 100644 --- a/drivers/video/modedb.c +++ b/drivers/video/modedb.c @@ -913,6 +913,8 @@ const struct fb_videomode *fb_find_best_mode(const struct fb_var_screeninfo *var * Finds best matching videomode, smaller or greater in dimension. * If more than 1 videomode is found, will return the videomode with * the closest refresh rate. + * If multiple modes with the same resolution and refresh rate are found + * pick the one with the matching vmode (e.g. non-interlaced) */ const struct fb_videomode *fb_find_nearest_mode(const struct fb_videomode *mode, struct list_head *head) @@ -939,6 +941,8 @@ const struct fb_videomode *fb_find_nearest_mode(const struct fb_videomode *mode, if (diff_refresh > d) { diff_refresh = d; best = cmode; + } else if (diff_refresh == d && cmode->vmode == mode->vmode) { + best = cmode; } } }