dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: airlied@gmail.com, dri-devel@lists.freedesktop.org
Subject: [PATCH 20/25] drm/radeon/kms: add support for DCE5 display LUTs
Date: Thu,  6 Jan 2011 21:19:30 -0500	[thread overview]
Message-ID: <1294366775-1605-21-git-send-email-alexdeucher@gmail.com> (raw)
In-Reply-To: <1294366775-1605-1-git-send-email-alexdeucher@gmail.com>

The hardware supports advanced user defined color management
but at the moment, there is no infrastructure in place to take
advantage of it so for now we just support the legacy LUTs.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
---
 drivers/gpu/drm/radeon/radeon_display.c |   68 +++++++++++++++++++++++++++++-
 1 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 30d867c..d26dabf 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -68,7 +68,7 @@ static void avivo_crtc_load_lut(struct drm_crtc *crtc)
 	WREG32(AVIVO_D1GRPH_LUT_SEL + radeon_crtc->crtc_offset, radeon_crtc->crtc_id);
 }
 
-static void evergreen_crtc_load_lut(struct drm_crtc *crtc)
+static void dce4_crtc_load_lut(struct drm_crtc *crtc)
 {
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
@@ -98,6 +98,66 @@ static void evergreen_crtc_load_lut(struct drm_crtc *crtc)
 	}
 }
 
+static void dce5_crtc_load_lut(struct drm_crtc *crtc)
+{
+	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+	struct drm_device *dev = crtc->dev;
+	struct radeon_device *rdev = dev->dev_private;
+	int i;
+
+	DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
+
+	WREG32(NI_INPUT_CSC_CONTROL + radeon_crtc->crtc_offset,
+	       (NI_INPUT_CSC_GRPH_MODE(NI_INPUT_CSC_BYPASS) |
+		NI_INPUT_CSC_OVL_MODE(NI_INPUT_CSC_BYPASS)));
+	WREG32(NI_PRESCALE_GRPH_CONTROL + radeon_crtc->crtc_offset,
+	       NI_GRPH_PRESCALE_BYPASS);
+	WREG32(NI_PRESCALE_OVL_CONTROL + radeon_crtc->crtc_offset,
+	       NI_OVL_PRESCALE_BYPASS);
+	WREG32(NI_INPUT_GAMMA_CONTROL + radeon_crtc->crtc_offset,
+	       (NI_GRPH_INPUT_GAMMA_MODE(NI_INPUT_GAMMA_USE_LUT) |
+		NI_OVL_INPUT_GAMMA_MODE(NI_INPUT_GAMMA_USE_LUT)));
+
+	WREG32(EVERGREEN_DC_LUT_CONTROL + radeon_crtc->crtc_offset, 0);
+
+	WREG32(EVERGREEN_DC_LUT_BLACK_OFFSET_BLUE + radeon_crtc->crtc_offset, 0);
+	WREG32(EVERGREEN_DC_LUT_BLACK_OFFSET_GREEN + radeon_crtc->crtc_offset, 0);
+	WREG32(EVERGREEN_DC_LUT_BLACK_OFFSET_RED + radeon_crtc->crtc_offset, 0);
+
+	WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_BLUE + radeon_crtc->crtc_offset, 0xffff);
+	WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_GREEN + radeon_crtc->crtc_offset, 0xffff);
+	WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_RED + radeon_crtc->crtc_offset, 0xffff);
+
+	WREG32(EVERGREEN_DC_LUT_RW_MODE + radeon_crtc->crtc_offset, 0);
+	WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK + radeon_crtc->crtc_offset, 0x00000007);
+
+	WREG32(EVERGREEN_DC_LUT_RW_INDEX + radeon_crtc->crtc_offset, 0);
+	for (i = 0; i < 256; i++) {
+		WREG32(EVERGREEN_DC_LUT_30_COLOR + radeon_crtc->crtc_offset,
+		       (radeon_crtc->lut_r[i] << 20) |
+		       (radeon_crtc->lut_g[i] << 10) |
+		       (radeon_crtc->lut_b[i] << 0));
+	}
+
+	WREG32(NI_DEGAMMA_CONTROL + radeon_crtc->crtc_offset,
+	       (NI_GRPH_DEGAMMA_MODE(NI_DEGAMMA_BYPASS) |
+		NI_OVL_DEGAMMA_MODE(NI_DEGAMMA_BYPASS) |
+		NI_ICON_DEGAMMA_MODE(NI_DEGAMMA_BYPASS) |
+		NI_CURSOR_DEGAMMA_MODE(NI_DEGAMMA_BYPASS)));
+	WREG32(NI_GAMUT_REMAP_CONTROL + radeon_crtc->crtc_offset,
+	       (NI_GRPH_GAMUT_REMAP_MODE(NI_GAMUT_REMAP_BYPASS) |
+		NI_OVL_GAMUT_REMAP_MODE(NI_GAMUT_REMAP_BYPASS)));
+	WREG32(NI_REGAMMA_CONTROL + radeon_crtc->crtc_offset,
+	       (NI_GRPH_REGAMMA_MODE(NI_REGAMMA_BYPASS) |
+		NI_OVL_REGAMMA_MODE(NI_REGAMMA_BYPASS)));
+	WREG32(NI_OUTPUT_CSC_CONTROL + radeon_crtc->crtc_offset,
+	       (NI_OUTPUT_CSC_GRPH_MODE(NI_OUTPUT_CSC_BYPASS) |
+		NI_OUTPUT_CSC_OVL_MODE(NI_OUTPUT_CSC_BYPASS)));
+	/* XXX match this to the depth of the crtc fmt block, move to modeset? */
+	WREG32(0x6940 + radeon_crtc->crtc_offset, 0);
+
+}
+
 static void legacy_crtc_load_lut(struct drm_crtc *crtc)
 {
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
@@ -130,8 +190,10 @@ void radeon_crtc_load_lut(struct drm_crtc *crtc)
 	if (!crtc->enabled)
 		return;
 
-	if (ASIC_IS_DCE4(rdev))
-		evergreen_crtc_load_lut(crtc);
+	if (ASIC_IS_DCE5(rdev))
+		dce5_crtc_load_lut(crtc);
+	else if (ASIC_IS_DCE4(rdev))
+		dce4_crtc_load_lut(crtc);
 	else if (ASIC_IS_AVIVO(rdev))
 		avivo_crtc_load_lut(crtc);
 	else
-- 
1.7.1.1

  parent reply	other threads:[~2011-01-07  2:20 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-07  2:19 [PATCH 0/25] drm/radeon/kms: Add support for NI (Northern Islands) Alex Deucher
2011-01-07  2:19 ` [PATCH 01/25] drm/radeon/kms: clean up ASIC_IS_DCE41() macro Alex Deucher
2011-01-07  2:19 ` [PATCH 02/25] drm/radeon/kms: add NI chip families Alex Deucher
2011-01-07  2:19 ` [PATCH 03/25] drm/radeon/kms: update display watermark calculations for DCE5 Alex Deucher
2011-01-07  2:19 ` [PATCH 04/25] drm/radeon/kms: DCE5 supports 16k display surfaces Alex Deucher
2011-01-07  2:19 ` [PATCH 05/25] drm/radeon/kms: DCE5 atom SetPixelClock updates Alex Deucher
2011-01-07  2:19 ` [PATCH 06/25] drm/radeon/kms: DCE5 atom spread spectrum updates Alex Deucher
2011-01-07  2:19 ` [PATCH 07/25] drm/radeon/kms: DCE5 atom transmitter control updates Alex Deucher
2011-01-07  2:19 ` [PATCH 08/25] drm/radeon/kms: DCE5 atom dig encoder updates Alex Deucher
2011-01-07  2:19 ` [PATCH 09/25] drm/radeon/kms: dac dpms updates for DCE5 Alex Deucher
2011-01-07  2:19 ` [PATCH 10/25] drm/radeon/kms: dvo " Alex Deucher
2011-01-07  2:19 ` [PATCH 11/25] drm/radeon/kms: parse DCE5 encoder caps when setting up encoders Alex Deucher
2011-01-07  2:19 ` [PATCH 12/25] drm/radeon/kms: handle NI thermal controller Alex Deucher
2011-01-07  2:19 ` [PATCH 13/25] drm/radeon/kms: add disabled vbios accessor for NI asics Alex Deucher
2011-01-07  2:19 ` [PATCH 14/25] drm/radeon/kms: fill gpu init " Alex Deucher
2011-01-07  2:19 ` [PATCH 15/25] drm/radeon/kms: add backend map workaround for barts Alex Deucher
2011-01-07  2:19 ` [PATCH 16/25] drm/radeon/kms: adjust default clock/vddc tracking for pm on DCE5 Alex Deucher
2011-01-07  2:19 ` [PATCH 17/25] drm/radeon/kms: always use writeback/events for fences on NI Alex Deucher
2011-01-07  2:19 ` [PATCH 18/25] drm/radeon/kms: add bo blit support for NI Alex Deucher
2011-01-07  2:19 ` [PATCH 19/25] drm/radeon/kms: add ni_reg.h Alex Deucher
2011-01-07  2:19 ` Alex Deucher [this message]
2011-01-07  2:19 ` [PATCH 21/25] drm/radeon/kms: add ucode loader for NI Alex Deucher
2011-01-07  2:19 ` [PATCH 22/25] drm/radeon/kms/ni: load default sclk/mclk/vddc at pm init Alex Deucher
2011-01-07  2:19 ` [PATCH 23/25] drm/radeon/kms: add radeon_asic struct for NI asics Alex Deucher
2011-01-07  2:19 ` [PATCH 24/25] drm/radeon/kms: don't enable pcie gen2 on NI yet Alex Deucher
2011-01-07  2:19 ` [PATCH 25/25] drm/radeon/kms: add NI pci ids Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1294366775-1605-21-git-send-email-alexdeucher@gmail.com \
    --to=alexdeucher@gmail.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).