From patchwork Thu Jan 6 18:23:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 460091 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p06INrai015393 for ; Thu, 6 Jan 2011 18:23:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752483Ab1AFSX5 (ORCPT ); Thu, 6 Jan 2011 13:23:57 -0500 Received: from moutng.kundenserver.de ([212.227.17.10]:62441 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751686Ab1AFSX4 (ORCPT ); Thu, 6 Jan 2011 13:23:56 -0500 Received: from axis700.grange (pD9EB8D9E.dip0.t-ipconnect.de [217.235.141.158]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0LaYSx-1Q2ItA0kzn-00lumS; Thu, 06 Jan 2011 19:23:55 +0100 Received: by axis700.grange (Postfix, from userid 1000) id DE8ED189B93; Thu, 6 Jan 2011 19:23:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id DBF2C189B8D; Thu, 6 Jan 2011 19:23:54 +0100 (CET) Date: Thu, 6 Jan 2011 19:23:54 +0100 (CET) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: linux-sh@vger.kernel.org cc: linux-fbdev@vger.kernel.org Subject: [PATCH 1/3] fbdev: sh_mobile_hdmi: add command line option to use the preferred EDID mode In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Provags-ID: V02:K0:X5ecChQG6WvNBSexGRVvZtnmzE9b/el1ERGFJeJpHwu qkxOrIj2BUxM7oLk90+j2GKyAzBxY6gDYgFhJqELwl4CEgX2xD zYxa/8000Bl29d/oArvejijo1WNi6FG19oB2TksHBBAp7Tq138 4WcLo82YMtokY0PUWT3bNQfd2A4usEWF10YQxF64zkRTbnOGus YvG+Ryk3Z7Wayx62YNdxX/kTj2zReMOIAxO6GdS8Lg= Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 06 Jan 2011 18:23:57 +0000 (UTC) diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c index fcda0e9..f18a619 100644 --- a/drivers/video/sh_mobile_hdmi.c +++ b/drivers/video/sh_mobile_hdmi.c @@ -713,7 +713,7 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi) struct fb_modelist *modelist = NULL; unsigned int f_width = 0, f_height = 0, f_refresh = 0; unsigned long found_rate_error = ULONG_MAX; /* silly compiler... */ - bool exact_match = false; + bool scanning = false, preferred_bad = false; u8 edid[128]; char *forced; int i; @@ -745,6 +745,9 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi) if (i < 2) { f_width = 0; f_height = 0; + } else { + /* The user wants us to use the EDID data */ + scanning = true; } dev_dbg(hdmi->dev, "Forced mode %ux%u@%uHz\n", f_width, f_height, f_refresh); @@ -752,34 +755,54 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi) /* Walk monitor modes to find the best or the exact match */ for (i = 0, mode = hdmi->monspec.modedb; - f_width && f_height && i < hdmi->monspec.modedb_len && !exact_match; + i < hdmi->monspec.modedb_len && scanning; i++, mode++) { - unsigned long rate_error = sh_hdmi_rate_error(hdmi, mode); + unsigned long rate_error; - /* No interest in unmatching modes */ - if (f_width != mode->xres || f_height != mode->yres) - continue; - if (f_refresh == mode->refresh || (!f_refresh && !rate_error)) - /* - * Exact match if either the refresh rate matches or it - * hasn't been specified and we've found a mode, for - * which we can configure the clock precisely - */ - exact_match = true; - else if (found && found_rate_error <= rate_error) + if (!f_width && !f_height) { /* - * We otherwise search for the closest matching clock - * rate - either if no refresh rate has been specified - * or we cannot find an exactly matching one + * A parameter string "video=sh_mobile_lcdc:0x0" means + * use the preferred EDID mode. If it is rejected by + * .fb_check_var(), keep looking, until an acceptable + * one is found. */ + if ((mode->flag & FB_MODE_IS_FIRST) || preferred_bad) + scanning = false; + else + continue; + } else if (f_width != mode->xres || f_height != mode->yres) { + /* No interest in unmatching modes */ continue; + } + + rate_error = sh_hdmi_rate_error(hdmi, mode); + + if (scanning) { + if (f_refresh == mode->refresh || (!f_refresh && !rate_error)) + /* + * Exact match if either the refresh rate + * matches or it hasn't been specified and we've + * found a mode, for which we can configure the + * clock precisely + */ + scanning = false; + else if (found && found_rate_error <= rate_error) + /* + * We otherwise search for the closest matching + * clock rate - either if no refresh rate has + * been specified or we cannot find an exactly + * matching one + */ + continue; + } /* Check if supported: sufficient fb memory, supported clock-rate */ fb_videomode_to_var(var, mode); if (info && info->fbops->fb_check_var && info->fbops->fb_check_var(var, info)) { - exact_match = false; + scanning = true; + preferred_bad = true; continue; }