mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jan Luebbe <jlu@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] drivers/video: support three ways to select default video mode
Date: Mon, 25 Jun 2012 15:54:28 +0200	[thread overview]
Message-ID: <1340632468-9972-1-git-send-email-jlu@pengutronix.de> (raw)

Currently the first entry in the board's mode list is the default.
In cases where the connected panel is not fixed, it is better to
configure it at runtime via the fb0.mode_name variable.

This patch allows choosing between:
 - First mode in the board's list (old behavior)
 - No default mode
 - Default mode selection by mode name (from string config variable)

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 drivers/video/Kconfig |   23 +++++++++++++++++++++++
 drivers/video/fb.c    |   17 ++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 519cdbf..baadb54 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -51,4 +51,27 @@ config DRIVER_VIDEO_PXA
 	  Add support for the frame buffer device found on the PXA270
 	  CPU.
 
+choice
+	prompt "Default mode selection"
+	default VIDEO_DEFAULT_FIRST
+
+	config VIDEO_DEFAULT_FIRST
+		bool "First mode from the board's list"
+
+	config VIDEO_DEFAULT_NONE
+		bool "Do not activate a mode by default"
+
+	config VIDEO_DEFAULT_NAME
+		bool "Select the default mode by name"
+
+endchoice
+
+if VIDEO_DEFAULT_NAME
+
+config VIDEO_DEFAULT_MODE
+	string
+	prompt "Default mode name (as defined by the board)"
+
+endif
+
 endif
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index 0be465f..4b39eac 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -40,6 +40,11 @@ static int fb_enable_set(struct device_d *dev, struct param_d *param,
 
 	enable = simple_strtoul(val, NULL, 0);
 
+	if (enable && info->mode == NULL) {
+		dev_err(dev, "cannot enable unconfigured framebuffer\n");
+		return -EPERM;
+	}
+
 	if (enable) {
 		if (!info->enabled)
 			info->fbops->fb_enable(info);
@@ -66,8 +71,10 @@ static int fb_setup_mode(struct device_d *dev, struct param_d *param,
 	if (info->enabled != 0)
 		return -EPERM;
 
-	if (!val)
+	if (!val) {
+		info->mode = NULL;
 		return dev_param_set_generic(dev, param, NULL);
+	}
 
 	for (mode = 0; mode < info->num_modes; mode++) {
 		if (!strcmp(info->mode_list[mode].name, val))
@@ -132,7 +139,15 @@ int register_framebuffer(struct fb_info *info)
 	if (info->num_modes && (info->mode_list != NULL) &&
 			(info->fbops->fb_activate_var != NULL)) {
 		dev_add_param(dev, "mode_name", fb_setup_mode, NULL, 0);
+#ifdef CONFIG_VIDEO_DEFAULT_FIRST
 		dev_set_param(dev, "mode_name", info->mode_list[0].name);
+#endif
+#ifdef CONFIG_VIDEO_DEFAULT_NONE
+		dev_set_param(dev, "mode_name", NULL);
+#endif
+#ifdef CONFIG_VIDEO_DEFAULT_NAME
+		dev_set_param(dev, "mode_name", CONFIG_VIDEO_DEFAULT_MODE);
+#endif
 	}
 
 	devfs_create(&info->cdev);
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2012-06-25 13:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340632468-9972-1-git-send-email-jlu@pengutronix.de \
    --to=jlu@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox