dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 6/6] drm/cirrus: Retrieve default mode from the device-tree if any
Date: Wed, 25 Jul 2012 13:09:06 +1000	[thread overview]
Message-ID: <1343185746.3715.38.camel@pasglop> (raw)

On the pseries machine type, qemu puts a default mode in the
device-tree based on the user request (-g option) which the
firmware uses to setup the boot screen.

Currently cirrusdrmfb ignores this and always ends up using
1280x1024. This adds support for retrieving this information
and using it to set the default mode and depth.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |    3 +--
 drivers/gpu/drm/cirrus/cirrus_mode.c  |   37 +++++++++++++++++++++++++++++----
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 1345215..b0e4080 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -296,9 +296,8 @@ int cirrus_fbdev_init(struct cirrus_device *cdev)
 {
 	struct cirrus_fbdev *gfbdev;
 	int ret;
-	int bpp_sel = 24;
+	int bpp_sel = cdev->dev->mode_config.preferred_depth;
 
-	/*bpp_sel = 8;*/
 	gfbdev = kzalloc(sizeof(struct cirrus_fbdev), GFP_KERNEL);
 	if (!gfbdev)
 		return -ENOMEM;
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 1566853..1ba73b0 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -19,6 +19,8 @@
 #include "drm_crtc_helper.h"
 
 #include <video/cirrus.h>
+#include <linux/pci.h>
+#include <linux/of.h>
 
 #include "cirrus_drv.h"
 
@@ -498,15 +500,25 @@ int cirrus_vga_get_modes(struct drm_connector *connector)
 {
 	int count = 0;
 
+#ifdef CONFIG_OF
+	/*
+	 * Add qemu default mode as preferred on machines where it's
+	 * indicated in the device-tree
+	 */
+	if (of_chosen) {
+		u32 width, height;
+
+		if (of_property_read_u32(of_chosen, "qemu,graphic-width", &width) == 0 &&
+		    of_property_read_u32(of_chosen, "qemu,graphic-height", &height) == 0)
+			count += drm_add_modes_noedid(connector, width, height, true);
+	}
+#endif /* CONFIG_OF */
+
 	/* Just add a static list of modes */
 	count += drm_add_modes_noedid(connector, 640, 480, false);
 	count += drm_add_modes_noedid(connector, 800, 600, false);
 	count += drm_add_modes_noedid(connector, 1024, 768, false);
 	count += drm_add_modes_noedid(connector, 1280, 1024, false);
-	drm_add_modes_noedid(connector, 640, 480);
-	drm_add_modes_noedid(connector, 800, 600);
-	drm_add_modes_noedid(connector, 1024, 768);
-	drm_add_modes_noedid(connector, 1280, 1024);
 
 	return count;
 }
@@ -597,6 +609,23 @@ int cirrus_modeset_init(struct cirrus_device *cdev)
 
 	cdev->dev->mode_config.fb_base = cdev->mc.vram_base;
 	cdev->dev->mode_config.preferred_depth = 24;
+
+#ifdef CONFIG_OF
+	/*
+	 * Add qemu default depth as preferred on machines where it's
+	 * indicated in the device-tree
+	 */
+	if (of_chosen) {
+		u32 depth;
+
+		if (!of_property_read_u32(of_chosen, "qemu,graphic-depth", &depth)) {
+			if (depth == 8 || depth == 15 || depth == 16 ||
+			    depth == 24 || depth == 32)
+				cdev->dev->mode_config.preferred_depth = depth;
+		}
+	}
+#endif /* CONFIG_OF */
+
 	/* don't prefer a shadow on virt GPU */
 	cdev->dev->mode_config.prefer_shadow = 0;

                 reply	other threads:[~2012-07-25  3:22 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=1343185746.3715.38.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=dri-devel@lists.freedesktop.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