From: Julia Lemire Subject: [PATCH 1/1] drm/mgag200: Fix hardware cursor colour inversion and inaccurate register index. Date: Thu, 30 Jan 2014 11:33:45 -0500 (EST) Message-ID: <01879ff89a50359bfa7d0ca7e12153231cd8f62e.1391098496.git.jlemire@matrox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mtxmxout2.matrox.com (mtxmxout2.matrox.com [138.11.2.92]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D974101ADC for ; Thu, 30 Jan 2014 08:40:37 -0800 (PST) Received: from venus.matrox.com (unknown [192.168.1.36]) by mtxmxout2.matrox.com (Postfix) with ESMTP id EAAA5989A6 for ; Thu, 30 Jan 2014 11:33:45 -0500 (EST) Received: (from ssmsp@localhost) by venus.matrox.com (8.14.6/8.13.2) id s0UGXjo7021721 for dri-devel@lists.freedesktop.org; Thu, 30 Jan 2014 11:33:45 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by venus.matrox.com (Postfix) with ESMTP id D19425F757 for ; Thu, 30 Jan 2014 11:33:45 -0500 (EST) Received: from venus.matrox.com ([127.0.0.1]) by localhost (venus.matrox.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id kCv9Qoa96sx6 for ; Thu, 30 Jan 2014 11:33:45 -0500 (EST) Received: from venus-in.matrox.com (localhost.localdomain [127.0.0.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by venus.matrox.com (Postfix) with ESMTPS id BF59D5F709 for ; Thu, 30 Jan 2014 11:33:45 -0500 (EST) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org To: dri-devel@lists.freedesktop.org Cc: Mathieu Larouche List-Id: dri-devel@lists.freedesktop.org The hardware cursor colours 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 buffer. Assuming the transparency is the MSB (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 --- drivers/gpu/drm/mgag200/mgag200_cursor.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_cursor.c b/drivers/gpu/drm/mgag200/mgag200_cursor.c index 801731a..24463b8 100644 --- a/drivers/gpu/drm/mgag200/mgag200_cursor.c +++ b/drivers/gpu/drm/mgag200/mgag200_cursor.c @@ -32,7 +32,7 @@ int mga_crtc_cursor_set(struct drm_crtc *crtc, uint32_t width, uint32_t height) { - struct drm_device *dev = (struct drm_device *)file_priv->minor->dev; + struct drm_device *dev = crtc->dev; struct mga_device *mdev = (struct mga_device *)dev->dev_private; struct mgag200_bo *pixels_1 = mdev->cursor.pixels_1; struct mgag200_bo *pixels_2 = mdev->cursor.pixels_2; @@ -45,12 +45,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); @@ -171,14 +171,20 @@ int mga_crtc_cursor_set(struct drm_crtc *crtc, } /* Program colours from cursor icon into palette */ + /* Colour is received as RGB, where 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