Skip to contentSkip to conversation

drm/mgag200: Added the hwcursor parameter to turn hardware cursor on/off.

PATCH New Julia Lemire 1 participant 2 messages Feb 24, 2014

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

PATCH 1/2 drm/mgag200: Added the hwcursor parameter to turn hardware cursor on/off.

The hwcursor parameter is a boolean variable. When set to true, the hardware cursor is enabled. When set to false, it is disabled.

---
 drivers/gpu/drm/mgag200/mgag200_cursor.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/gpu/drm/mgag200/mgag200_cursor.c +18 -0
index 9f9780b..c9a94a6 100644
@@ -10,9 +10,17 @@
 
 #include <drm/drmP.h>
 #include "mgag200_drv.h"
+#include <linux/moduleparam.h>
+
+static bool hwcursor = true;
 
 static bool warn_transparent = true;
 static bool warn_palette = true;
+static bool warn_user_input = true;
+
+module_param(hwcursor, bool, 0644);
+MODULE_PARM_DESC(hwcursor, "When true, the hardware cursor is enabled.  When false, it is disabled.");
+
 
 /*
   Hide the cursor off screen. We can't disable the cursor hardware because it
@@ -90,6 +98,16 @@ int mga_crtc_cursor_set(struct drm_crtc *crtc,
 		goto out1;
 	}
 
+	if (!hwcursor) {
+		if (warn_user_input) {
+			dev_info(&dev->pdev->dev, "User disabled hardware cursor.\n");
+			warn_user_input = false;
+		}
+		mga_hide_cursor(mdev);
+		ret = -EINVAL;
+		goto out1;
+	}
+
 	/* Move cursor buffers into VRAM if they aren't already */
 	if (!pixels_1->pin_count) {
 		ret = mgag200_bo_pin(pixels_1, TTM_PL_FLAG_VRAM,
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 2/2 drm/mgag200: Fix hardware cursor colour inversion and inaccurate register index.

The hardware cursor colous are stored in the DAC indexed registers. The algorithm for setting these colours via their corresponding index was off by a value of 0x03.

It was also noted that the R and B bytes were being misread from the cursor bugger. Assuming the transparency is the MSB or bits 31-24, then R should be bits 23-16, G should be bits 15-8 and B should be the LSB or bits 7-0.

---
 drivers/gpu/drm/mgag200/mgag200_cursor.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/gpu/drm/mgag200/mgag200_cursor.c +11 -5
index c9a94a6..0fd4ba0 100644
@@ -55,12 +55,12 @@ int mga_crtc_cursor_set(struct drm_crtc *crtc,
 	uint32_t colour_set[16];
 	uint32_t *next_space = &colour_set[0];
 	uint32_t *palette_iter;
-	uint32_t this_colour;
+	uint32_t this_colour; /* 32-bit colour encoded pixel */
 	bool found = false;
 	int colour_count = 0;
 	u64 gpu_addr;
 	u8 reg_index;
-	u8 this_row[48];
+	u8 this_row[48]; /* cursor bitmap row array */
 
 	if (!pixels_1 || !pixels_2) {
 		WREG8(MGA_CURPOSXL, 0);
@@ -191,14 +191,20 @@ int mga_crtc_cursor_set(struct drm_crtc *crtc,
 	}
 
 	/* Program colours from cursor icon into palette */
+	/* Colour is receieved as RGB, where is R are the MSB and B are the LSB. */
+	/* The first three colours are located between indexes 0x08-0x12. */
+	/* The remaining colours are located between indexes 0x60-0x86. */
 	for (i = 0; i < colour_count; i++) {
 		if (i <= 2)
 			reg_index = 0x8 + i*0x4;
 		else
-			reg_index = 0x60 + i*0x3;
-		WREG_DAC(reg_index, colour_set[i] & 0xff);
+			reg_index = 0x60 + (i-3)*0x3;
+		/* Write the Red bits. */
+		WREG_DAC(reg_index, colour_set[i]>>16 & 0xff);
+		/* Write the Green bits. */
 		WREG_DAC(reg_index+1, colour_set[i]>>8 & 0xff);
-		WREG_DAC(reg_index+2, colour_set[i]>>16 & 0xff);
+		/* Write the Blue bits. */
+		WREG_DAC(reg_index+2, colour_set[i] & 0xff);
 		BUG_ON((colour_set[i]>>24 & 0xff) != 0xff);
 	}
 
Signature · 1 line
1.7.10.4