From: Julia Lemire Subject: [PATCH v2 2/2] drm/mgag200: Fix hardware cursor colour inversion and inaccurate register index. Date: Mon, 24 Feb 2014 16:14:40 -0500 (EST) Message-ID: <537afbc755ccf454483a259657367a533344d761.1393253082.git.jlemire@matrox.com> References: <48f006a143feb34fdbaeb489a9c9eaf163d017d6.1393253082.git.jlemire@matrox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mtxmxout3.matrox.com (mtxmxout3.matrox.com [138.11.2.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 97335FAC26 for ; Mon, 24 Feb 2014 13:14:41 -0800 (PST) Received: from venus.matrox.com (unknown [192.168.1.36]) by mtxmxout3.matrox.com (Postfix) with ESMTP id 01D1070B65 for ; Mon, 24 Feb 2014 16:14:41 -0500 (EST) Received: (from ssmsp@localhost) by venus.matrox.com (8.14.6/8.13.2) id s1OLEe3R013715 for dri-devel@lists.freedesktop.org; Mon, 24 Feb 2014 16:14:40 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by venus.matrox.com (Postfix) with ESMTP id E04895F753 for ; Mon, 24 Feb 2014 16:14:40 -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 JfMqFRsLfYuD for ; Mon, 24 Feb 2014 16:14:40 -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 CDAFC5F75D for ; Mon, 24 Feb 2014 16:14:40 -0500 (EST) In-Reply-To: <48f006a143feb34fdbaeb489a9c9eaf163d017d6.1393253082.git.jlemire@matrox.com> 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 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 --- 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