[PATCH 12/14] drm/mgag200: Add command line option to specify preferred depth

Takashi Iwai tiwai at suse.de
Tue Jul 18 14:43:18 UTC 2017


From: Egbert Eich <eich at suse.de>

G200 is old hardware. When KMS was designed around 2007 none of the
chipsets current at this time had any restrictions to video modes
depending on the depth. Thus video modes are validated independent
of the depth which is purely a property of the scanout buffer.

The mgag200 driver however has some bandwidth limitations and the
bandwidth required depends on the bpp. Since the video mode is validated
before the depth/bpp is actually known we are missing an important piece of
information at validation time.
So far we assumed the highest possible bpp value (except for systems with
video memory <= 2MB). Unfortunately this will kill some badly needed higher
res modes at lower depths.

This patch adds a cludge which allows to set the desired depth for the
mgag200 driver with the boot option mgag200.preferreddepth=16|24.
This is a KLUDGE(!) to get around the shortcomings of the mode setting
model for older hardware.

Signed-off-by: Egbert Eich <eich at suse.de>
Signed-off-by: Takashi Iwai <tiwai at suse.de>
---
 drivers/gpu/drm/mgag200/mgag200_drv.c  | 11 +++++++++++
 drivers/gpu/drm/mgag200/mgag200_drv.h  |  2 ++
 drivers/gpu/drm/mgag200/mgag200_main.c | 17 +++++++++++++----
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 03258e9fc6c0..7a71ac729a81 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -22,9 +22,12 @@
  * functions
  */
 int mgag200_modeset = -1;
+int mgag200_preferred_depth __read_mostly;
 
 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
 module_param_named(modeset, mgag200_modeset, int, 0400);
+MODULE_PARM_DESC(preferreddepth, "Set preferred bpp");
+module_param_named(preferreddepth, mgag200_preferred_depth, int, 0400);
 
 static struct drm_driver driver;
 
@@ -122,6 +125,14 @@ static int __init mgag200_init(void)
 
 	if (mgag200_modeset == 0)
 		return -EINVAL;
+	switch (mgag200_preferred_depth) {
+	case 0: /* driver default */
+	case 16:
+	case 24:
+		break;
+	default:
+		return -EINVAL;
+	}
 	return drm_pci_init(&driver, &mgag200_pci_driver);
 }
 
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h
index 9d7ae61ce915..949bbcbf9d19 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -318,4 +318,6 @@ int mga_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
 						uint32_t handle, uint32_t width, uint32_t height);
 int mga_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
 
+extern int mgag200_preferred_depth __read_mostly;
+
 #endif				/* __MGAG200_DRV_H__ */
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index 2ec76d6615a8..56970eced8d7 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -339,12 +339,21 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
 
 	drm_mode_config_init(dev);
 	dev->mode_config.funcs = (void *)&mga_mode_funcs;
-	if (IS_G200_SE(mdev) && mdev->mc.vram_size < (2048*1024)) {
+	if (mgag200_preferred_depth == 0) {
 		/* prefer 16bpp on low end gpus with limited VRAM */
-		mdev->preferred_bpp = dev->mode_config.preferred_depth = 16;
+		if (IS_G200_SE(mdev) && mdev->mc.vram_size <= 2048 * 1024) {
+			mdev->preferred_bpp =
+				dev->mode_config.preferred_depth = 16;
+		} else {
+			mdev->preferred_bpp = 32;
+			dev->mode_config.preferred_depth = 24;
+		}
 	} else {
-		mdev->preferred_bpp = 32;
-		dev->mode_config.preferred_depth = 24;
+		if (mgag200_preferred_depth == 16)
+			mdev->preferred_bpp = 16;
+		else /* mgag200_preferred_depth == 24 */
+			mdev->preferred_bpp = 32;
+		dev->mode_config.preferred_depth = mgag200_preferred_depth;
 	}
 	dev->mode_config.prefer_shadow = 1;
 
-- 
2.13.2



More information about the dri-devel mailing list