From patchwork Thu Jan 30 16:33:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lemire X-Patchwork-Id: 3558171 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 05B8C9F382 for ; Thu, 30 Jan 2014 16:41:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2852201BC for ; Thu, 30 Jan 2014 16:41:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ABC0120181 for ; Thu, 30 Jan 2014 16:41:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7CE34101AED; Thu, 30 Jan 2014 08:40:56 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 411 seconds by postgrey-1.32 at gabe; Thu, 30 Jan 2014 08:40:37 PST 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=matrox.com; s=dkim; t=1391099626; bh=v7b4LB3gGRuk8zqnR9PtUcBluoWQJySkql2cW299wiU=; h=From:Subject:To:Cc:Date; b=EzZXFXbvwsgItVBcGaVdeUl93/ZXmIN/ruZgCsnq8NmJW1PHRWZcoW0mHtOv57T0w K8s3FDjK90ElOz5E25tDey5Ppj52YjILsawyNVRwzZAhQIVHOrlCZhfXAOO6zTJJri lxJ+imgBBn6dM3WvhN94rTddCRltxAcv46nptXmc= 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) X-Virus-MTX-Scanned: by Matrox Virus scanner at venus.matrox.com 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) Received: from matrox.com (dyn-152-69.matrox.com [192.168.152.69]) by venus-in.matrox.com (Postfix) with ESMTP id BD4D961BB8; Thu, 30 Jan 2014 11:33:45 -0500 (EST) Message-Id: <01879ff89a50359bfa7d0ca7e12153231cd8f62e.1391098496.git.jlemire@matrox.com> From: Julia Lemire Subject: [PATCH 1/1] drm/mgag200: Fix hardware cursor colour inversion and inaccurate register index. To: dri-devel@lists.freedesktop.org Date: Thu, 30 Jan 2014 11:33:45 -0500 (EST) Cc: Mathieu Larouche X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); }