linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] fbdev: sh_mobile_hdmi: add command line option to use
@ 2011-01-06 18:23 Guennadi Liakhovetski
  2011-01-07  2:15 ` [PATCH 1/3] fbdev: sh_mobile_hdmi: add command line option to use the preferred EDID mode Paul Mundt
  0 siblings, 1 reply; 2+ messages in thread
From: Guennadi Liakhovetski @ 2011-01-06 18:23 UTC (permalink / raw)
  To: linux-fbdev

Currently, if no command-line option is specified, the sh_mobile_hdmi
will use the default 720p video mode. If a command line option of the
form "video=sh_mobile_lcdc:<width>x<height>@<refresh>" is provided,
the driver will look for that mode among those, available in the
monitor EDID. This patch adds the ability to request the driver to
use monitor's preferred mode by specifying 0 as width and hight in
the above string. If that mode is not supported by the system, the
driver will continue scanning through EDID modes, until it finds a
suitable one.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/video/sh_mobile_hdmi.c |   59 +++++++++++++++++++++++++++------------
 1 files changed, 41 insertions(+), 18 deletions(-)

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;
 		}
 
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/3] fbdev: sh_mobile_hdmi: add command line option to use the preferred EDID mode
  2011-01-06 18:23 [PATCH 1/3] fbdev: sh_mobile_hdmi: add command line option to use Guennadi Liakhovetski
@ 2011-01-07  2:15 ` Paul Mundt
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Mundt @ 2011-01-07  2:15 UTC (permalink / raw)
  To: linux-fbdev

On Thu, Jan 06, 2011 at 07:23:54PM +0100, Guennadi Liakhovetski wrote:
> Currently, if no command-line option is specified, the sh_mobile_hdmi
> will use the default 720p video mode. If a command line option of the
> form "video=sh_mobile_lcdc:<width>x<height>@<refresh>" is provided,
> the driver will look for that mode among those, available in the
> monitor EDID. This patch adds the ability to request the driver to
> use monitor's preferred mode by specifying 0 as width and hight in
> the above string. If that mode is not supported by the system, the
> driver will continue scanning through EDID modes, until it finds a
> suitable one.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

Ok, I tried applying this against all of the fbdev topic branches in the
sh tree, the fbdev tree, and Linus's tree (where the fbdev tree was just
merged), and it doesn't apply to any of them, so I have no idea what tree
you are working with, or if there are some dependencies or something that
you haven't specified.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-07  2:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-06 18:23 [PATCH 1/3] fbdev: sh_mobile_hdmi: add command line option to use Guennadi Liakhovetski
2011-01-07  2:15 ` [PATCH 1/3] fbdev: sh_mobile_hdmi: add command line option to use the preferred EDID mode Paul Mundt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).