[PATCH 11/14] drm/mgag200: Consolidate depth/bpp handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Egbert Eich <eich@xxxxxxx>

The depth/bpp handling for chips with limited memory in commit
918be888d613 ("drm/mgag200: on cards with < 2MB VRAM default to
16-bit") was incomplete: the bpp limits were applied to mode
validation.

This consolidates dpeth/bpp handling, adds it to mode validation
and moves the code which reads the command line specified depth
into the correct location.

Fixes: 918be888d613 ("drm/mgag200: on cards with < 2MB VRAM default to 16-bit")
Signed-off-by: Egbert Eich <eich@xxxxxxx>
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
 drivers/gpu/drm/mgag200/mgag200_drv.h  |  2 ++
 drivers/gpu/drm/mgag200/mgag200_fb.c   |  7 +------
 drivers/gpu/drm/mgag200/mgag200_main.c |  9 ++++++---
 drivers/gpu/drm/mgag200/mgag200_mode.c | 14 +++++++-------
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h
index 1ba559c93b8f..9d7ae61ce915 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -209,6 +209,8 @@ struct mga_device {
 	int				has_sdram;
 	struct drm_display_mode		mode;
 
+	int preferred_bpp;
+
 	int bpp_shifts[4];
 
 	int fb_mtrr;
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
index bb9a4c409dc0..173aed918183 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -267,11 +267,6 @@ int mgag200_fbdev_init(struct mga_device *mdev)
 {
 	struct mga_fbdev *mfbdev;
 	int ret;
-	int bpp_sel = 32;
-
-	/* prefer 16bpp on low end gpus with limited VRAM */
-	if (IS_G200_SE(mdev) && mdev->mc.vram_size < (2048*1024))
-		bpp_sel = 16;
 
 	mfbdev = devm_kzalloc(mdev->dev->dev, sizeof(struct mga_fbdev), GFP_KERNEL);
 	if (!mfbdev)
@@ -294,7 +289,7 @@ int mgag200_fbdev_init(struct mga_device *mdev)
 	/* disable all the possible outputs/crtcs before entering KMS mode */
 	drm_helper_disable_unused_functions(mdev->dev);
 
-	ret = drm_fb_helper_initial_config(&mfbdev->helper, bpp_sel);
+	ret = drm_fb_helper_initial_config(&mfbdev->helper, mdev->preferred_bpp);
 	if (ret)
 		goto err_fb_setup;
 
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index 73614154a5ef..2ec76d6615a8 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -339,10 +339,13 @@ 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))
-		dev->mode_config.preferred_depth = 16;
-	else
+	if (IS_G200_SE(mdev) && mdev->mc.vram_size < (2048*1024)) {
+		/* prefer 16bpp on low end gpus with limited VRAM */
+		mdev->preferred_bpp = dev->mode_config.preferred_depth = 16;
+	} else {
+		mdev->preferred_bpp = 32;
 		dev->mode_config.preferred_depth = 24;
+	}
 	dev->mode_config.prefer_shadow = 1;
 
 	r = mgag200_modeset_init(mdev);
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index a07f67ed6e4a..77b8efcd3c65 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -1705,9 +1705,15 @@ static int mga_vga_mode_valid(struct drm_connector *connector,
 {
 	struct drm_device *dev = connector->dev;
 	struct mga_device *mdev = (struct mga_device*)dev->dev_private;
-	int bpp = 32;
+	int bpp;
 	int lace;
 
+	bpp = mdev->preferred_bpp;
+	/* Validate the mode input by the user */
+	if (connector->cmdline_mode.specified &&
+	    connector->cmdline_mode.bpp_specified)
+		bpp = connector->cmdline_mode.bpp;
+
 	lace = (mode->flags & DRM_MODE_FLAG_INTERLACE) ? 2 : 1;
 	if (IS_G200_SE(mdev)) {
 		if (mdev->unique_rev_id == 0x01) {
@@ -1767,12 +1773,6 @@ static int mga_vga_mode_valid(struct drm_connector *connector,
 		return MODE_BAD;
 	}
 
-	/* Validate the mode input by the user */
-	if (connector->cmdline_mode.specified) {
-		if (connector->cmdline_mode.bpp_specified)
-			bpp = connector->cmdline_mode.bpp;
-	}
-
 	if ((mode->hdisplay * mode->vdisplay * (bpp/8)) > mdev->mc.vram_size) {
 		if (connector->cmdline_mode.specified)
 			connector->cmdline_mode.specified = false;
-- 
2.13.2

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




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux