Commit 320d41b3 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Extract ilk_lut_10()

Extract a helper to calculate the ILK+ 10bit gamma LUT entry.
It's already duplicated twice, and soon we'll have more.

v2: s/it/bit/ (Matt)
Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190401200231.2333-2-ville.syrjala@linux.intel.comReviewed-by: default avatarUma Shankar <uma.shankar@intel.com>
parent 59f9e9ca
...@@ -359,6 +359,13 @@ static void cherryview_load_csc_matrix(const struct intel_crtc_state *crtc_state ...@@ -359,6 +359,13 @@ static void cherryview_load_csc_matrix(const struct intel_crtc_state *crtc_state
I915_WRITE(CGM_PIPE_MODE(pipe), crtc_state->cgm_mode); I915_WRITE(CGM_PIPE_MODE(pipe), crtc_state->cgm_mode);
} }
static u32 ilk_lut_10(const struct drm_color_lut *color)
{
return drm_color_lut_extract(color->red, 10) << 20 |
drm_color_lut_extract(color->green, 10) << 10 |
drm_color_lut_extract(color->blue, 10);
}
/* Loads the legacy palette/gamma unit for the CRTC. */ /* Loads the legacy palette/gamma unit for the CRTC. */
static void i9xx_load_luts_internal(const struct intel_crtc_state *crtc_state, static void i9xx_load_luts_internal(const struct intel_crtc_state *crtc_state,
const struct drm_property_blob *blob) const struct drm_property_blob *blob)
...@@ -473,14 +480,8 @@ static void bdw_load_degamma_lut(const struct intel_crtc_state *crtc_state) ...@@ -473,14 +480,8 @@ static void bdw_load_degamma_lut(const struct intel_crtc_state *crtc_state)
if (degamma_lut) { if (degamma_lut) {
const struct drm_color_lut *lut = degamma_lut->data; const struct drm_color_lut *lut = degamma_lut->data;
for (i = 0; i < lut_size; i++) { for (i = 0; i < lut_size; i++)
u32 word = I915_WRITE(PREC_PAL_DATA(pipe), ilk_lut_10(&lut[i]));
drm_color_lut_extract(lut[i].red, 10) << 20 |
drm_color_lut_extract(lut[i].green, 10) << 10 |
drm_color_lut_extract(lut[i].blue, 10);
I915_WRITE(PREC_PAL_DATA(pipe), word);
}
} else { } else {
for (i = 0; i < lut_size; i++) { for (i = 0; i < lut_size; i++) {
u32 v = (i * ((1 << 10) - 1)) / (lut_size - 1); u32 v = (i * ((1 << 10) - 1)) / (lut_size - 1);
...@@ -509,14 +510,8 @@ static void bdw_load_gamma_lut(const struct intel_crtc_state *crtc_state, u32 of ...@@ -509,14 +510,8 @@ static void bdw_load_gamma_lut(const struct intel_crtc_state *crtc_state, u32 of
if (gamma_lut) { if (gamma_lut) {
const struct drm_color_lut *lut = gamma_lut->data; const struct drm_color_lut *lut = gamma_lut->data;
for (i = 0; i < lut_size; i++) { for (i = 0; i < lut_size; i++)
u32 word = I915_WRITE(PREC_PAL_DATA(pipe), ilk_lut_10(&lut[i]));
(drm_color_lut_extract(lut[i].red, 10) << 20) |
(drm_color_lut_extract(lut[i].green, 10) << 10) |
drm_color_lut_extract(lut[i].blue, 10);
I915_WRITE(PREC_PAL_DATA(pipe), word);
}
/* /*
* Program the max register to clamp values > 1.0. * Program the max register to clamp values > 1.0.
......
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