summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_color.c
diff options
context:
space:
mode:
authorUma Shankar <uma.shankar@intel.com>2019-02-11 19:20:24 +0530
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2019-02-13 11:25:44 +0100
commita91de580541c37dcd6a82091fdd2d36cca7cda77 (patch)
tree953b489b07ac9992cc4945d6de76e12694148c46 /drivers/gpu/drm/i915/intel_color.c
parent255fcfbc3c1893cd9b8fbca56674be400275fb72 (diff)
downloadlinux-stable-a91de580541c37dcd6a82091fdd2d36cca7cda77.tar.gz
linux-stable-a91de580541c37dcd6a82091fdd2d36cca7cda77.tar.bz2
linux-stable-a91de580541c37dcd6a82091fdd2d36cca7cda77.zip
drm/i915/icl: Enable pipe output csc
GEN11+ onwards an output csc hardware block has been added. This is after the pipe gamma block and is in addition to the legacy pipe CSC block. Primary use case for this block is to convert RGB to YUV in case sink supports YUV. This patch adds supports for the same. v2: This is added after splitting the existing ICL pipe CSC handling. As per Matt's suggestion, made this to co-exist with existing pipe CSC, wherein both can be enabled if a certain usecase arises. v3: Fixed an issue with co-existence of output csc and normal pipe csc, spotted by Matt. Put the csc mode flag enabling to color_check to align with atomic. v4: Fixed macro alignment and checkpatch complaints wrt line over 100 characters limit. Signed-off-by: Uma Shankar <uma.shankar@intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/1549893025-21837-5-git-send-email-uma.shankar@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/intel_color.c')
-rw-r--r--drivers/gpu/drm/i915/intel_color.c77
1 files changed, 58 insertions, 19 deletions
diff --git a/drivers/gpu/drm/i915/intel_color.c b/drivers/gpu/drm/i915/intel_color.c
index 395b475c57ce..da7a07d5ccea 100644
--- a/drivers/gpu/drm/i915/intel_color.c
+++ b/drivers/gpu/drm/i915/intel_color.c
@@ -118,23 +118,47 @@ static void ilk_load_ycbcr_conversion_matrix(struct intel_crtc *crtc)
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
enum pipe pipe = crtc->pipe;
- I915_WRITE(PIPE_CSC_PREOFF_HI(pipe), 0);
- I915_WRITE(PIPE_CSC_PREOFF_ME(pipe), 0);
- I915_WRITE(PIPE_CSC_PREOFF_LO(pipe), 0);
+ if (INTEL_GEN(dev_priv) < 11) {
+ I915_WRITE(PIPE_CSC_PREOFF_HI(pipe), 0);
+ I915_WRITE(PIPE_CSC_PREOFF_ME(pipe), 0);
+ I915_WRITE(PIPE_CSC_PREOFF_LO(pipe), 0);
- I915_WRITE(PIPE_CSC_COEFF_RU_GU(pipe), CSC_RGB_TO_YUV_RU_GU);
- I915_WRITE(PIPE_CSC_COEFF_BU(pipe), CSC_RGB_TO_YUV_BU);
+ I915_WRITE(PIPE_CSC_COEFF_RU_GU(pipe), CSC_RGB_TO_YUV_RU_GU);
+ I915_WRITE(PIPE_CSC_COEFF_BU(pipe), CSC_RGB_TO_YUV_BU);
- I915_WRITE(PIPE_CSC_COEFF_RY_GY(pipe), CSC_RGB_TO_YUV_RY_GY);
- I915_WRITE(PIPE_CSC_COEFF_BY(pipe), CSC_RGB_TO_YUV_BY);
+ I915_WRITE(PIPE_CSC_COEFF_RY_GY(pipe), CSC_RGB_TO_YUV_RY_GY);
+ I915_WRITE(PIPE_CSC_COEFF_BY(pipe), CSC_RGB_TO_YUV_BY);
- I915_WRITE(PIPE_CSC_COEFF_RV_GV(pipe), CSC_RGB_TO_YUV_RV_GV);
- I915_WRITE(PIPE_CSC_COEFF_BV(pipe), CSC_RGB_TO_YUV_BV);
+ I915_WRITE(PIPE_CSC_COEFF_RV_GV(pipe), CSC_RGB_TO_YUV_RV_GV);
+ I915_WRITE(PIPE_CSC_COEFF_BV(pipe), CSC_RGB_TO_YUV_BV);
- I915_WRITE(PIPE_CSC_POSTOFF_HI(pipe), POSTOFF_RGB_TO_YUV_HI);
- I915_WRITE(PIPE_CSC_POSTOFF_ME(pipe), POSTOFF_RGB_TO_YUV_ME);
- I915_WRITE(PIPE_CSC_POSTOFF_LO(pipe), POSTOFF_RGB_TO_YUV_LO);
- I915_WRITE(PIPE_CSC_MODE(pipe), 0);
+ I915_WRITE(PIPE_CSC_POSTOFF_HI(pipe), POSTOFF_RGB_TO_YUV_HI);
+ I915_WRITE(PIPE_CSC_POSTOFF_ME(pipe), POSTOFF_RGB_TO_YUV_ME);
+ I915_WRITE(PIPE_CSC_POSTOFF_LO(pipe), POSTOFF_RGB_TO_YUV_LO);
+ } else {
+ I915_WRITE(PIPE_CSC_OUTPUT_PREOFF_HI(pipe), 0);
+ I915_WRITE(PIPE_CSC_OUTPUT_PREOFF_ME(pipe), 0);
+ I915_WRITE(PIPE_CSC_OUTPUT_PREOFF_LO(pipe), 0);
+
+ I915_WRITE(PIPE_CSC_OUTPUT_COEFF_RU_GU(pipe),
+ CSC_RGB_TO_YUV_RU_GU);
+ I915_WRITE(PIPE_CSC_OUTPUT_COEFF_BU(pipe), CSC_RGB_TO_YUV_BU);
+
+ I915_WRITE(PIPE_CSC_OUTPUT_COEFF_RY_GY(pipe),
+ CSC_RGB_TO_YUV_RY_GY);
+ I915_WRITE(PIPE_CSC_OUTPUT_COEFF_BY(pipe), CSC_RGB_TO_YUV_BY);
+
+ I915_WRITE(PIPE_CSC_OUTPUT_COEFF_RV_GV(pipe),
+ CSC_RGB_TO_YUV_RV_GV);
+ I915_WRITE(PIPE_CSC_OUTPUT_COEFF_BV(pipe), CSC_RGB_TO_YUV_BV);
+
+ I915_WRITE(PIPE_CSC_OUTPUT_POSTOFF_HI(pipe),
+ POSTOFF_RGB_TO_YUV_HI);
+ I915_WRITE(PIPE_CSC_OUTPUT_POSTOFF_ME(pipe),
+ POSTOFF_RGB_TO_YUV_ME);
+ I915_WRITE(PIPE_CSC_OUTPUT_POSTOFF_LO(pipe),
+ POSTOFF_RGB_TO_YUV_LO);
+ }
}
static void ilk_load_csc_matrix(const struct intel_crtc_state *crtc_state)
@@ -156,8 +180,16 @@ static void ilk_load_csc_matrix(const struct intel_crtc_state *crtc_state)
if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420 ||
crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444) {
ilk_load_ycbcr_conversion_matrix(crtc);
- return;
- } else if (crtc_state->base.ctm) {
+ I915_WRITE(PIPE_CSC_MODE(pipe), crtc_state->csc_mode);
+ /*
+ * On pre GEN11 output CSC is not there, so with 1 pipe CSC
+ * RGB to YUV conversion can be done. No need to go further
+ */
+ if (INTEL_GEN(dev_priv) < 11)
+ return;
+ }
+
+ if (crtc_state->base.ctm) {
struct drm_color_ctm *ctm = crtc_state->base.ctm->data;
const u64 *input;
u64 temp[9];
@@ -243,10 +275,7 @@ static void ilk_load_csc_matrix(const struct intel_crtc_state *crtc_state)
I915_WRITE(PIPE_CSC_POSTOFF_ME(pipe), postoff);
I915_WRITE(PIPE_CSC_POSTOFF_LO(pipe), postoff);
- if (INTEL_GEN(dev_priv) >= 11)
- I915_WRITE(PIPE_CSC_MODE(pipe), ICL_CSC_ENABLE);
- else
- I915_WRITE(PIPE_CSC_MODE(pipe), 0);
+ I915_WRITE(PIPE_CSC_MODE(pipe), crtc_state->csc_mode);
} else {
u32 mode = CSC_MODE_YUV_TO_RGB;
@@ -785,6 +814,16 @@ int intel_color_check(struct intel_crtc_state *crtc_state)
else
crtc_state->gamma_mode = GAMMA_MODE_MODE_8BIT;
+ crtc_state->csc_mode = 0;
+
+ if (INTEL_GEN(dev_priv) >= 11) {
+ if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420 ||
+ crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444)
+ crtc_state->csc_mode |= ICL_OUTPUT_CSC_ENABLE;
+
+ crtc_state->csc_mode |= ICL_CSC_ENABLE;
+ }
+
return 0;
}