dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: dri-devel@lists.freedesktop.org
Cc: Egbert Eich <eich@suse.de>, Dave Airlie <airlied@redhat.com>,
	Mathieu Larouche <mathieu.larouche@matrox.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 12/14] drm/mgag200: Add command line option to specify preferred depth
Date: Tue, 18 Jul 2017 16:43:18 +0200	[thread overview]
Message-ID: <20170718144320.8354-13-tiwai@suse.de> (raw)
In-Reply-To: <20170718144320.8354-1-tiwai@suse.de>

From: Egbert Eich <eich@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@suse.de>
Signed-off-by: Takashi Iwai <tiwai@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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-07-18 14:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 14:43 [PATCH 00/14] mgag200 fixes Takashi Iwai
2017-07-18 14:43 ` [PATCH 01/14] drm/mgag200: Add doublescan and interlace support Takashi Iwai
2017-07-18 14:43 ` [PATCH 02/14] drm/mgag200: Add additional limits for certain G200 variants Takashi Iwai
2017-07-18 14:43 ` [PATCH 03/14] drm/mgag200: Fix memleak in error path in mgag200_bo_create() Takashi Iwai
2017-07-18 14:43 ` [PATCH 04/14] drm/mgag200: Free container instead of member in mga_user_framebuffer_destroy() Takashi Iwai
2017-07-18 14:43 ` [PATCH 05/14] drm/mgag200: Initialize data needed to map fbdev memory Takashi Iwai
2017-07-18 14:43 ` [PATCH 06/14] drm/mgag200: Simplify function mgag200_ttm_placement() Takashi Iwai
2017-07-18 14:43 ` [PATCH 07/14] drm/mgag200: Add support for MATROX PCI device IDs 0x520 and 0x521 Takashi Iwai
2017-07-20  4:17   ` Dave Airlie
2017-07-20  9:47     ` Takashi Iwai
2017-07-20 15:05       ` Egbert Eich
2017-07-18 14:43 ` [PATCH 08/14] drm/mgag200: Cleanup cursor BOs properly Takashi Iwai
2017-07-18 14:43 ` [PATCH 09/14] drm/mgag200: Add missing drm_connector_unregister() Takashi Iwai
2017-07-19  8:44   ` Takashi Iwai
2017-07-20  8:15     ` Daniel Vetter
2017-07-18 14:43 ` [PATCH 10/14] drm/mgag200: Don't use crtc_* parameters for validation Takashi Iwai
2017-07-19  6:38   ` Daniel Vetter
2017-07-18 14:43 ` [PATCH 11/14] drm/mgag200: Consolidate depth/bpp handling Takashi Iwai
2017-07-20 11:58   ` Paul Menzel
2017-07-20 12:08     ` Takashi Iwai
2017-07-18 14:43 ` Takashi Iwai [this message]
2017-07-18 14:43 ` [PATCH 13/14] drm/mgag200: Add mode validation debugging code Takashi Iwai
2017-07-18 14:43 ` [PATCH 14/14] drm/mgag200: Implement basic PM support Takashi Iwai
2017-08-01 19:25 ` [PATCH 00/14] mgag200 fixes Mathieu Larouche
2017-08-01 21:18   ` Takashi Iwai

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=20170718144320.8354-13-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=airlied@redhat.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eich@suse.de \
    --cc=mathieu.larouche@matrox.com \
    /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;
as well as URLs for NNTP newsgroup(s).