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. Signed-off-by: Julia Lemire <jlemire@xxxxxxxxxx> --- drivers/gpu/drm/mgag200/mgag200_cursor.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_cursor.c b/drivers/gpu/drm/mgag200/mgag200_cursor.c index c9a94a6..0fd4ba0 100644 --- a/drivers/gpu/drm/mgag200/mgag200_cursor.c +++ b/drivers/gpu/drm/mgag200/mgag200_cursor.c @@ -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); } -- 1.7.10.4 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel