> -----Original Message----- > From: Intel-gfx <intel-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> On Behalf Of Ville > Syrjala > Sent: Saturday, July 18, 2020 2:44 AM > To: intel-gfx@xxxxxxxxxxxxxxxxxxxxx > Subject: [PATCH 14/20] drm/i915: Replace some gamma_mode ifs with > switches > > From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> > > Since gamma_mode can have more than two values on ilk+ let's use switch > statemnts when interpreting them. Nit: Typo in statements With this fixed, Reviewed-by: Uma Shankar <uma.shankar@xxxxxxxxx> > > Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> > --- > drivers/gpu/drm/i915/display/intel_color.c | 93 ++++++++++++++++------ > 1 file changed, 70 insertions(+), 23 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_color.c > b/drivers/gpu/drm/i915/display/intel_color.c > index 886f3f0d873a..d5ce58c3bc11 100644 > --- a/drivers/gpu/drm/i915/display/intel_color.c > +++ b/drivers/gpu/drm/i915/display/intel_color.c > @@ -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); > 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); > - else > + break; > + case GAMMA_MODE_MODE_10BIT: > 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) @@ -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); > 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 *blob = gamma_lut ?: degamma_lut; > > - if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT) { > - ilk_load_lut_8(crtc, gamma_lut); > - } else if (crtc_state->gamma_mode == GAMMA_MODE_MODE_SPLIT) { > + switch (crtc_state->gamma_mode) { > + case GAMMA_MODE_MODE_8BIT: > + ilk_load_lut_8(crtc, blob); > + break; > + case GAMMA_MODE_MODE_SPLIT: > ivb_load_lut_10(crtc, degamma_lut, PAL_PREC_SPLIT_MODE | > PAL_PREC_INDEX_VALUE(0)); > ivb_load_lut_ext_max(crtc_state); > ivb_load_lut_10(crtc, gamma_lut, PAL_PREC_SPLIT_MODE | > PAL_PREC_INDEX_VALUE(512)); > - } else { > - const struct drm_property_blob *blob = gamma_lut ?: > degamma_lut; > - > + break; > + case GAMMA_MODE_MODE_10BIT: > ivb_load_lut_10(crtc, blob, > PAL_PREC_INDEX_VALUE(0)); > ivb_load_lut_ext_max(crtc_state); > + break; > + default: > + MISSING_CASE(crtc_state->gamma_mode); > + break; > } > } > > @@ -768,21 +781,27 @@ static void bdw_load_luts(const struct intel_crtc_state > *crtc_state) > 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 *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) { > - ilk_load_lut_8(crtc, gamma_lut); > - } else if (crtc_state->gamma_mode == GAMMA_MODE_MODE_SPLIT) { > + switch (crtc_state->gamma_mode) { > + case GAMMA_MODE_MODE_8BIT: > + ilk_load_lut_8(crtc, blob); > + break; > + case GAMMA_MODE_MODE_SPLIT: > bdw_load_lut_10(crtc, degamma_lut, PAL_PREC_SPLIT_MODE | > PAL_PREC_INDEX_VALUE(0)); > ivb_load_lut_ext_max(crtc_state); > bdw_load_lut_10(crtc, gamma_lut, PAL_PREC_SPLIT_MODE | > PAL_PREC_INDEX_VALUE(512)); > - } else { > - const struct drm_property_blob *blob = gamma_lut ?: > degamma_lut; > - > + break; > + case GAMMA_MODE_MODE_10BIT: > bdw_load_lut_10(crtc, blob, > PAL_PREC_INDEX_VALUE(0)); > ivb_load_lut_ext_max(crtc_state); > + break; > + default: > + MISSING_CASE(crtc_state->gamma_mode); > + break; > } > } > > @@ -875,11 +894,17 @@ static void glk_load_luts(const struct intel_crtc_state > *crtc_state) > else > 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); > - } else { > + break; > + case GAMMA_MODE_MODE_10BIT: > bdw_load_lut_10(crtc, gamma_lut, PAL_PREC_INDEX_VALUE(0)); > ivb_load_lut_ext_max(crtc_state); > + break; > + default: > + MISSING_CASE(crtc_state->gamma_mode); > + break; > } > } > > @@ -1011,9 +1036,13 @@ static void icl_load_luts(const struct intel_crtc_state > *crtc_state) > icl_program_gamma_superfine_segment(crtc_state); > icl_program_gamma_multi_segment(crtc_state); > break; > - default: > + case GAMMA_MODE_MODE_10BIT: > bdw_load_lut_10(crtc, gamma_lut, PAL_PREC_INDEX_VALUE(0)); > ivb_load_lut_ext_max(crtc_state); > + break; > + default: > + MISSING_CASE(crtc_state->gamma_mode); > + break; > } > > intel_dsb_commit(crtc_state); > @@ -1744,7 +1773,7 @@ bool intel_color_lut_equal(struct drm_property_blob > *blob1, > break; > default: > MISSING_CASE(gamma_mode); > - return false; > + return false; > } > > return true; > @@ -1953,10 +1982,17 @@ static void ilk_read_luts(struct intel_crtc_state > *crtc_state) > if ((crtc_state->csc_mode & CSC_POSITION_BEFORE_GAMMA) == 0) > 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); > - else > + break; > + case GAMMA_MODE_MODE_10BIT: > crtc_state->hw.gamma_lut = ilk_read_lut_10(crtc); > + break; > + default: > + MISSING_CASE(crtc_state->gamma_mode); > + break; > + } > } > > /* > @@ -2149,10 +2185,17 @@ static void glk_read_luts(struct intel_crtc_state > *crtc_state) > if (!crtc_state->gamma_enable) > 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); > - else > + break; > + case GAMMA_MODE_MODE_10BIT: > 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 * > @@ -2207,11 +2250,15 @@ static void icl_read_luts(struct intel_crtc_state > *crtc_state) > case GAMMA_MODE_MODE_8BIT: > crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc); > 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: > crtc_state->hw.gamma_lut = icl_read_lut_multi_segment(crtc); > break; > default: > - crtc_state->hw.gamma_lut = bdw_read_lut_10(crtc, > PAL_PREC_INDEX_VALUE(0)); > + MISSING_CASE(crtc_state->gamma_mode); > + break; > } > } > > -- > 2.26.2 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/intel-gfx _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx