Skip to contentSkip to conversation

mgag200 fix and cleanup

PATCH In review Christopher Harvey 3 participants 6 messages Mar 18, 2013 – Mar 19, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover mgag200 fix and cleanup

Just a bit of cleanup from me (resubmitted). The important patch comes from Julia. Julia's patch conflicts with the following:
[email protected]

it fixes
https://bugzilla.kernel.org/show_bug.cgi?id=46591

Christopher Harvey (3):
drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth drm/mgag200: Pass driver specific mga_device in driver functions drm/mgag200: Remove extra variable assigns

Julia Lemire (1):
drm/mgag200: Bug fix: Modified pll algorithm for EH project

 drivers/gpu/drm/mgag200/mgag200_fb.c   |  3 ---
 drivers/gpu/drm/mgag200/mgag200_main.c |  2 --
 drivers/gpu/drm/mgag200/mgag200_mode.c | 17 ++++++++---------
 3 files changed, 8 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.12.4
#1 lore raw

PATCH 1/4 drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth

---
 drivers/gpu/drm/mgag200/mgag200_fb.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/mgag200/mgag200_fb.c +0 -3
index d2253f6..a5a1f34 100644
@@ -105,12 +105,9 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev,
 				   struct drm_gem_object **gobj_p)
 {
 	struct drm_device *dev = afbdev->helper.dev;
-	u32 bpp, depth;
 	u32 size;
 	struct drm_gem_object *gobj;
-
 	int ret = 0;
-	drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp);
 
 	size = mode_cmd->pitches[0] * mode_cmd->height;
 	ret = mgag200_gem_create(dev, size, true, &gobj);
Signature · 1 line
1.7.12.4
#2 lore raw

PATCH 2/4 drm/mgag200: Pass driver specific mga_device in driver functions

In reply to Christopher Harvey
---
 drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/mgag200/mgag200_mode.c +3 -4
index a274b99..6b5db83 100644
@@ -1261,9 +1261,8 @@ static const struct drm_crtc_helper_funcs mga_helper_funcs = {
 };
 
 /* CRTC setup */
-static void mga_crtc_init(struct drm_device *dev)
+static void mga_crtc_init(struct mga_device *mdev)
 {
-	struct mga_device *mdev = dev->dev_private;
 	struct mga_crtc *mga_crtc;
 	int i;
 
@@ -1274,7 +1273,7 @@ static void mga_crtc_init(struct drm_device *dev)
 	if (mga_crtc == NULL)
 		return;
 
-	drm_crtc_init(dev, &mga_crtc->base, &mga_crtc_funcs);
+	drm_crtc_init(mdev->dev, &mga_crtc->base, &mga_crtc_funcs);
 
 	drm_mode_crtc_set_gamma_size(&mga_crtc->base, MGAG200_LUT_SIZE);
 	mdev->mode_info.crtc = mga_crtc;
@@ -1529,7 +1528,7 @@ int mgag200_modeset_init(struct mga_device *mdev)
 
 	mdev->dev->mode_config.fb_base = mdev->mc.vram_base;
 
-	mga_crtc_init(mdev->dev);
+	mga_crtc_init(mdev);
 
 	encoder = mga_encoder_init(mdev->dev);
 	if (!encoder) {
Signature · 1 line
1.7.12.4
#3 lore raw

PATCH 3/4 drm/mgag200: Remove extra variable assigns

In reply to Christopher Harvey

These two variables are set again immediately in 'mgag200_modeset_init'

---
 drivers/gpu/drm/mgag200/mgag200_main.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/mgag200/mgag200_main.c +0 -2
index 64297c7..b762bfb 100644
@@ -234,8 +234,6 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
 
 	drm_mode_config_init(dev);
 	dev->mode_config.funcs = (void *)&mga_mode_funcs;
-	dev->mode_config.min_width = 0;
-	dev->mode_config.min_height = 0;
 	dev->mode_config.preferred_depth = 24;
 	dev->mode_config.prefer_shadow = 1;
 
Signature · 1 line
1.7.12.4
#4 lore raw

PATCH 4/4 drm/mgag200: Bug fix: Modified pll algorithm for EH project

In reply to Christopher Harvey

While testing the mgag200 kms driver on the HP ProLiant Gen8, a bug was seen. Once the bootloader would load the selected kernel, the screen would go black. At first it was assumed that the mgag200 kms driver was hanging. But after setting up the grub serial output, it was seen that the driver was being loaded properly. After trying serval monitors, one finaly displayed the message "Frequency Out of Range". By comparing the kms pll algorithm with the previous mgag200 xorg driver pll algorithm, discrepencies were found. Once the kms pll algorithm was modified, the expected pll values were produced. This fix was tested on several monitors of varying native resolutions.

---
 drivers/gpu/drm/mgag200/mgag200_mode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/mgag200/mgag200_mode.c +5 -5
index 6b5db83..7337013 100644
@@ -382,19 +382,19 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
 	m = n = p = 0;
 	vcomax = 800000;
 	vcomin = 400000;
-	pllreffreq = 3333;
+	pllreffreq = 33333;
 
 	delta = 0xffffffff;
 	permitteddelta = clock * 5 / 1000;
 
-	for (testp = 16; testp > 0; testp--) {
+	for (testp = 16; testp > 0; testp >>= 1) {
 		if (clock * testp > vcomax)
 			continue;
 		if (clock * testp < vcomin)
 			continue;
 
 		for (testm = 1; testm < 33; testm++) {
-			for (testn = 1; testn < 257; testn++) {
+			for (testn = 17; testn < 257; testn++) {
 				computed = (pllreffreq * testn) /
 					(testm * testp);
 				if (computed > clock)
@@ -404,11 +404,11 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
 				if (tmpdelta < delta) {
 					delta = tmpdelta;
 					n = testn - 1;
-					m = (testm - 1) | ((n >> 1) & 0x80);
+					m = (testm - 1);
 					p = testp - 1;
 				}
 				if ((clock * testp) >= 600000)
-					p |= 80;
+					p |= 0x80;
 			}
 		}
 	}
Signature · 1 line
1.7.12.4
maintainer
#5 lore raw
In reply to Christopher Harvey
Quoted 4 lines

Just a bit of cleanup from me (resubmitted). The important patch comes from Julia. Julia's patch conflicts with the following:
[email protected]

Yeah I was going to leave the cleanups until -next opens, I'll push the fix though and get it to stable.

Dave.