Commit 7852ddd5 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Replace some gamma_mode ifs with switches

Since gamma_mode can have more than two values on ilk+
let's use switch statements when interpreting them.

v2: Fix typo (Uma)
Reviewed-by: default avatarUma Shankar <uma.shankar@intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200925131656.10022-10-ville.syrjala@linux.intel.com
parent d0a9acaa
...@@ -638,10 +638,17 @@ static void ilk_load_luts(const struct intel_crtc_state *crtc_state) ...@@ -638,10 +638,17 @@ static void ilk_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; const struct drm_property_blob *gamma_lut = crtc_state->hw.gamma_lut;
if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT) switch (crtc_state->gamma_mode) {
case GAMMA_MODE_MODE_8BIT:
ilk_load_lut_8(crtc, gamma_lut); ilk_load_lut_8(crtc, gamma_lut);
else break;
case GAMMA_MODE_MODE_10BIT:
ilk_load_lut_10(crtc, gamma_lut); ilk_load_lut_10(crtc, gamma_lut);
break;
default:
MISSING_CASE(crtc_state->gamma_mode);
break;
}
} }
static int ivb_lut_10_size(u32 prec_index) static int ivb_lut_10_size(u32 prec_index)
...@@ -745,21 +752,27 @@ static void ivb_load_luts(const struct intel_crtc_state *crtc_state) ...@@ -745,21 +752,27 @@ static void ivb_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; const struct drm_property_blob *gamma_lut = crtc_state->hw.gamma_lut;
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 *blob = gamma_lut ?: degamma_lut;
if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT) { switch (crtc_state->gamma_mode) {
ilk_load_lut_8(crtc, gamma_lut); case GAMMA_MODE_MODE_8BIT:
} else if (crtc_state->gamma_mode == GAMMA_MODE_MODE_SPLIT) { ilk_load_lut_8(crtc, blob);
break;
case GAMMA_MODE_MODE_SPLIT:
ivb_load_lut_10(crtc, degamma_lut, PAL_PREC_SPLIT_MODE | ivb_load_lut_10(crtc, degamma_lut, PAL_PREC_SPLIT_MODE |
PAL_PREC_INDEX_VALUE(0)); PAL_PREC_INDEX_VALUE(0));
ivb_load_lut_ext_max(crtc_state); ivb_load_lut_ext_max(crtc_state);
ivb_load_lut_10(crtc, gamma_lut, PAL_PREC_SPLIT_MODE | ivb_load_lut_10(crtc, gamma_lut, PAL_PREC_SPLIT_MODE |
PAL_PREC_INDEX_VALUE(512)); PAL_PREC_INDEX_VALUE(512));
} else { break;
const struct drm_property_blob *blob = gamma_lut ?: degamma_lut; case GAMMA_MODE_MODE_10BIT:
ivb_load_lut_10(crtc, blob, ivb_load_lut_10(crtc, blob,
PAL_PREC_INDEX_VALUE(0)); PAL_PREC_INDEX_VALUE(0));
ivb_load_lut_ext_max(crtc_state); ivb_load_lut_ext_max(crtc_state);
break;
default:
MISSING_CASE(crtc_state->gamma_mode);
break;
} }
} }
...@@ -768,21 +781,28 @@ static void bdw_load_luts(const struct intel_crtc_state *crtc_state) ...@@ -768,21 +781,28 @@ static void bdw_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; const struct drm_property_blob *gamma_lut = crtc_state->hw.gamma_lut;
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 *blob = gamma_lut ?: degamma_lut;
if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT) { switch (crtc_state->gamma_mode) {
ilk_load_lut_8(crtc, gamma_lut); case GAMMA_MODE_MODE_8BIT:
} else if (crtc_state->gamma_mode == GAMMA_MODE_MODE_SPLIT) { ilk_load_lut_8(crtc, blob);
break;
case GAMMA_MODE_MODE_SPLIT:
bdw_load_lut_10(crtc, degamma_lut, PAL_PREC_SPLIT_MODE | bdw_load_lut_10(crtc, degamma_lut, PAL_PREC_SPLIT_MODE |
PAL_PREC_INDEX_VALUE(0)); PAL_PREC_INDEX_VALUE(0));
ivb_load_lut_ext_max(crtc_state); ivb_load_lut_ext_max(crtc_state);
bdw_load_lut_10(crtc, gamma_lut, PAL_PREC_SPLIT_MODE | bdw_load_lut_10(crtc, gamma_lut, PAL_PREC_SPLIT_MODE |
PAL_PREC_INDEX_VALUE(512)); PAL_PREC_INDEX_VALUE(512));
} else { break;
const struct drm_property_blob *blob = gamma_lut ?: degamma_lut; case GAMMA_MODE_MODE_10BIT:
bdw_load_lut_10(crtc, blob, bdw_load_lut_10(crtc, blob,
PAL_PREC_INDEX_VALUE(0)); PAL_PREC_INDEX_VALUE(0));
ivb_load_lut_ext_max(crtc_state); ivb_load_lut_ext_max(crtc_state);
break;
default:
MISSING_CASE(crtc_state->gamma_mode);
break;
} }
} }
...@@ -875,11 +895,17 @@ static void glk_load_luts(const struct intel_crtc_state *crtc_state) ...@@ -875,11 +895,17 @@ static void glk_load_luts(const struct intel_crtc_state *crtc_state)
else else
glk_load_degamma_lut_linear(crtc_state); glk_load_degamma_lut_linear(crtc_state);
if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT) { switch (crtc_state->gamma_mode) {
case GAMMA_MODE_MODE_8BIT:
ilk_load_lut_8(crtc, gamma_lut); ilk_load_lut_8(crtc, gamma_lut);
} else { break;
case GAMMA_MODE_MODE_10BIT:
bdw_load_lut_10(crtc, gamma_lut, PAL_PREC_INDEX_VALUE(0)); bdw_load_lut_10(crtc, gamma_lut, PAL_PREC_INDEX_VALUE(0));
ivb_load_lut_ext_max(crtc_state); ivb_load_lut_ext_max(crtc_state);
break;
default:
MISSING_CASE(crtc_state->gamma_mode);
break;
} }
} }
...@@ -1011,9 +1037,13 @@ static void icl_load_luts(const struct intel_crtc_state *crtc_state) ...@@ -1011,9 +1037,13 @@ static void icl_load_luts(const struct intel_crtc_state *crtc_state)
icl_program_gamma_superfine_segment(crtc_state); icl_program_gamma_superfine_segment(crtc_state);
icl_program_gamma_multi_segment(crtc_state); icl_program_gamma_multi_segment(crtc_state);
break; break;
default: case GAMMA_MODE_MODE_10BIT:
bdw_load_lut_10(crtc, gamma_lut, PAL_PREC_INDEX_VALUE(0)); bdw_load_lut_10(crtc, gamma_lut, PAL_PREC_INDEX_VALUE(0));
ivb_load_lut_ext_max(crtc_state); ivb_load_lut_ext_max(crtc_state);
break;
default:
MISSING_CASE(crtc_state->gamma_mode);
break;
} }
intel_dsb_commit(crtc_state); intel_dsb_commit(crtc_state);
...@@ -1917,10 +1947,17 @@ static void ilk_read_luts(struct intel_crtc_state *crtc_state) ...@@ -1917,10 +1947,17 @@ static void ilk_read_luts(struct intel_crtc_state *crtc_state)
if ((crtc_state->csc_mode & CSC_POSITION_BEFORE_GAMMA) == 0) if ((crtc_state->csc_mode & CSC_POSITION_BEFORE_GAMMA) == 0)
return; return;
if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT) switch (crtc_state->gamma_mode) {
case GAMMA_MODE_MODE_8BIT:
crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc); crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc);
else break;
case GAMMA_MODE_MODE_10BIT:
crtc_state->hw.gamma_lut = ilk_read_lut_10(crtc); crtc_state->hw.gamma_lut = ilk_read_lut_10(crtc);
break;
default:
MISSING_CASE(crtc_state->gamma_mode);
break;
}
} }
/* On BDW+ the index auto increment mode actually works */ /* On BDW+ the index auto increment mode actually works */
...@@ -1965,10 +2002,17 @@ static void glk_read_luts(struct intel_crtc_state *crtc_state) ...@@ -1965,10 +2002,17 @@ static void glk_read_luts(struct intel_crtc_state *crtc_state)
if (!crtc_state->gamma_enable) if (!crtc_state->gamma_enable)
return; return;
if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT) switch (crtc_state->gamma_mode) {
case GAMMA_MODE_MODE_8BIT:
crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc); crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc);
else break;
case GAMMA_MODE_MODE_10BIT:
crtc_state->hw.gamma_lut = bdw_read_lut_10(crtc, PAL_PREC_INDEX_VALUE(0)); crtc_state->hw.gamma_lut = bdw_read_lut_10(crtc, PAL_PREC_INDEX_VALUE(0));
break;
default:
MISSING_CASE(crtc_state->gamma_mode);
break;
}
} }
static struct drm_property_blob * static struct drm_property_blob *
...@@ -2020,11 +2064,15 @@ static void icl_read_luts(struct intel_crtc_state *crtc_state) ...@@ -2020,11 +2064,15 @@ static void icl_read_luts(struct intel_crtc_state *crtc_state)
case GAMMA_MODE_MODE_8BIT: case GAMMA_MODE_MODE_8BIT:
crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc); crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc);
break; break;
case GAMMA_MODE_MODE_10BIT:
crtc_state->hw.gamma_lut = bdw_read_lut_10(crtc, PAL_PREC_INDEX_VALUE(0));
break;
case GAMMA_MODE_MODE_12BIT_MULTI_SEGMENTED: case GAMMA_MODE_MODE_12BIT_MULTI_SEGMENTED:
crtc_state->hw.gamma_lut = icl_read_lut_multi_segment(crtc); crtc_state->hw.gamma_lut = icl_read_lut_multi_segment(crtc);
break; break;
default: default:
crtc_state->hw.gamma_lut = bdw_read_lut_10(crtc, PAL_PREC_INDEX_VALUE(0)); MISSING_CASE(crtc_state->gamma_mode);
break;
} }
} }
......
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