Commit d191832d authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Polish CHV CGM CSC loading

Only load the CGM CSC based on the cgm_mode bit like we
do with the gamma/degamma LUTs. And make the function
naming and arguments consistent as well.

TODO: the code to convert the coefficients look totally
bogus. IIRC CHV uses two's complement format but the code
certainly doesn't generate that, so probably negative
coefficients are totally busted.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200303173313.28117-2-ville.syrjala@linux.intel.comReviewed-by: default avatarSwati Sharma <swati2.sharma@intel.com>
parent ff345271
...@@ -348,32 +348,29 @@ static void icl_load_csc_matrix(const struct intel_crtc_state *crtc_state) ...@@ -348,32 +348,29 @@ static void icl_load_csc_matrix(const struct intel_crtc_state *crtc_state)
crtc_state->csc_mode); crtc_state->csc_mode);
} }
/* static void chv_load_cgm_csc(struct intel_crtc *crtc,
* Set up the pipe CSC unit on CherryView. const struct drm_property_blob *blob)
*/
static void cherryview_load_csc_matrix(const struct intel_crtc_state *crtc_state)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
const struct drm_color_ctm *ctm = blob->data;
enum pipe pipe = crtc->pipe; enum pipe pipe = crtc->pipe;
u16 coeffs[9];
if (crtc_state->hw.ctm) {
const struct drm_color_ctm *ctm = crtc_state->hw.ctm->data;
u16 coeffs[9] = {};
int i; int i;
for (i = 0; i < ARRAY_SIZE(coeffs); i++) { for (i = 0; i < ARRAY_SIZE(coeffs); i++) {
u64 abs_coeff = u64 abs_coeff = ((1ULL << 63) - 1) & ctm->matrix[i];
((1ULL << 63) - 1) & ctm->matrix[i];
/* Round coefficient. */ /* Round coefficient. */
abs_coeff += 1 << (32 - 13); abs_coeff += 1 << (32 - 13);
/* Clamp to hardware limits. */ /* Clamp to hardware limits. */
abs_coeff = clamp_val(abs_coeff, 0, CTM_COEFF_8_0 - 1); abs_coeff = clamp_val(abs_coeff, 0, CTM_COEFF_8_0 - 1);
coeffs[i] = 0;
/* Write coefficients in S3.12 format. */ /* Write coefficients in S3.12 format. */
if (ctm->matrix[i] & (1ULL << 63)) if (ctm->matrix[i] & (1ULL << 63))
coeffs[i] = 1 << 15; coeffs[i] |= 1 << 15;
coeffs[i] |= ((abs_coeff >> 32) & 7) << 12; coeffs[i] |= ((abs_coeff >> 32) & 7) << 12;
coeffs[i] |= (abs_coeff >> 20) & 0xfff; coeffs[i] |= (abs_coeff >> 20) & 0xfff;
} }
...@@ -386,10 +383,8 @@ static void cherryview_load_csc_matrix(const struct intel_crtc_state *crtc_state ...@@ -386,10 +383,8 @@ static void cherryview_load_csc_matrix(const struct intel_crtc_state *crtc_state
coeffs[5] << 16 | coeffs[4]); coeffs[5] << 16 | coeffs[4]);
intel_de_write(dev_priv, CGM_PIPE_CSC_COEFF67(pipe), intel_de_write(dev_priv, CGM_PIPE_CSC_COEFF67(pipe),
coeffs[7] << 16 | coeffs[6]); coeffs[7] << 16 | coeffs[6]);
intel_de_write(dev_priv, CGM_PIPE_CSC_COEFF8(pipe), coeffs[8]); intel_de_write(dev_priv, CGM_PIPE_CSC_COEFF8(pipe),
} coeffs[8]);
intel_de_write(dev_priv, CGM_PIPE_MODE(pipe), crtc_state->cgm_mode);
} }
static u32 i9xx_lut_8(const struct drm_color_lut *color) static u32 i9xx_lut_8(const struct drm_color_lut *color)
...@@ -1020,10 +1015,13 @@ static void chv_load_cgm_gamma(struct intel_crtc *crtc, ...@@ -1020,10 +1015,13 @@ static void chv_load_cgm_gamma(struct intel_crtc *crtc,
static void chv_load_luts(const struct intel_crtc_state *crtc_state) static void chv_load_luts(const struct intel_crtc_state *crtc_state)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
const struct drm_property_blob *gamma_lut = crtc_state->hw.gamma_lut; struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
const struct drm_property_blob *degamma_lut = crtc_state->hw.degamma_lut; const struct drm_property_blob *degamma_lut = crtc_state->hw.degamma_lut;
const struct drm_property_blob *gamma_lut = crtc_state->hw.gamma_lut;
const struct drm_property_blob *ctm = crtc_state->hw.ctm;
cherryview_load_csc_matrix(crtc_state); if (crtc_state->cgm_mode & CGM_PIPE_MODE_CSC)
chv_load_cgm_csc(crtc, ctm);
if (crtc_state->cgm_mode & CGM_PIPE_MODE_DEGAMMA) if (crtc_state->cgm_mode & CGM_PIPE_MODE_DEGAMMA)
chv_load_cgm_degamma(crtc, degamma_lut); chv_load_cgm_degamma(crtc, degamma_lut);
...@@ -1032,6 +1030,9 @@ static void chv_load_luts(const struct intel_crtc_state *crtc_state) ...@@ -1032,6 +1030,9 @@ static void chv_load_luts(const struct intel_crtc_state *crtc_state)
chv_load_cgm_gamma(crtc, gamma_lut); chv_load_cgm_gamma(crtc, gamma_lut);
else else
i965_load_luts(crtc_state); i965_load_luts(crtc_state);
intel_de_write(dev_priv, CGM_PIPE_MODE(crtc->pipe),
crtc_state->cgm_mode);
} }
void intel_color_load_luts(const struct intel_crtc_state *crtc_state) void intel_color_load_luts(const struct intel_crtc_state *crtc_state)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment