[PATCH v2] drm/fsl-dcu: Implement gamma_lut atomic crtc properties
Meng Yi
meng.yi at nxp.com
Mon Aug 22 07:10:32 UTC 2016
Hi Stefan,
What do you think about this patch for gamma correction.
I see many people approach gamma correction this way. Do you have any comments?
Best Regards,
Meng
> +static void fsl_crtc_gamma_set(struct drm_crtc *crtc, struct drm_color_lut
> *lut,
> + uint32_t size)
> +{
> + struct fsl_dcu_drm_device *fsl_dev = crtc->dev->dev_private;
> + unsigned int i;
> +
> + for (i = 0; i < size; i++) {
> + regmap_write(fsl_dev->regmap, FSL_GAMMA_R + 4 * i,
> + lut[i].red << 24);
> + regmap_write(fsl_dev->regmap, FSL_GAMMA_G + 4 * i,
> + lut[i].green << 24);
> + regmap_write(fsl_dev->regmap, FSL_GAMMA_B + 4 * i,
> + lut[i].blue << 24);
> + }
> +}
> +
> static void fsl_dcu_drm_crtc_atomic_flush(struct drm_crtc *crtc,
> struct drm_crtc_state *old_crtc_state)
> { @@ -37,6 +53,11 @@ static void fsl_dcu_drm_crtc_atomic_flush(struct
> drm_crtc *crtc,
> drm_crtc_send_vblank_event(crtc, event);
> spin_unlock_irq(&crtc->dev->event_lock);
> }
> +
> + if (crtc->state->color_mgmt_changed && crtc->state->gamma_lut)
> + fsl_crtc_gamma_set(crtc, (struct drm_color_lut *)
> + crtc->state->gamma_lut->data,
> + 256);
> }
>
> static void fsl_dcu_drm_disable_crtc(struct drm_crtc *crtc) @@ -46,6 +67,11
> @@ static void fsl_dcu_drm_disable_crtc(struct drm_crtc *crtc)
>
> drm_crtc_vblank_off(crtc);
>
> + if (fsl_dev->enable_color_mgmt)
> + regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
> + DCU_MODE_EN_GAMMA_MASK,
> + DCU_MODE_GAMMA_DISABLE);
> +
> regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
> DCU_MODE_DCU_MODE_MASK,
> DCU_MODE_DCU_MODE(DCU_MODE_OFF)); @@ -
> 58,6 +84,11 @@ static void fsl_dcu_drm_crtc_enable(struct drm_crtc *crtc)
> struct drm_device *dev = crtc->dev;
> struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
>
> + if (fsl_dev->enable_color_mgmt)
> + regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
> + DCU_MODE_EN_GAMMA_MASK,
> + DCU_MODE_GAMMA_ENABLE);
> +
> regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
> DCU_MODE_DCU_MODE_MASK,
> DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
> @@ -135,6 +166,7 @@ static const struct drm_crtc_funcs
> fsl_dcu_drm_crtc_funcs = {
> .page_flip = drm_atomic_helper_page_flip,
> .reset = drm_atomic_helper_crtc_reset,
> .set_config = drm_atomic_helper_set_config,
> + .gamma_set = drm_atomic_helper_legacy_gamma_set,
> };
>
More information about the dri-devel
mailing list