diff --git a/drivers/amlogic/drm/meson_crtc.c b/drivers/amlogic/drm/meson_crtc.c index 1021e1a273ce..011f87172b1b 100644 --- a/drivers/amlogic/drm/meson_crtc.c +++ b/drivers/amlogic/drm/meson_crtc.c @@ -194,7 +194,7 @@ static void am_meson_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_color_lut *lut; struct am_meson_crtc *amcrtc = to_am_meson_crtc(crtc); struct drm_atomic_state *old_atomic_state = old_state->state; - + struct meson_drm *priv = amcrtc->priv; struct meson_vpu_pipeline *pipeline = amcrtc->pipeline; #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT int gamma_lut_size = 0; @@ -209,15 +209,32 @@ static void am_meson_crtc_atomic_flush(struct drm_crtc *crtc, #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT am_meson_ctm_set(0, ctm); #endif + } else { + DRM_DEBUG("%s Disable CTM!\n", __func__); + #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT + am_meson_ctm_disable(); + #endif } + } + if (crtc->state->gamma_lut != priv->gamma_lut_blob) { + DRM_DEBUG("%s GAMMA LUT blob changed!\n", __func__); + drm_property_unreference_blob(priv->gamma_lut_blob); + priv->gamma_lut_blob = NULL; if (crtc->state->gamma_lut) { - DRM_INFO("%s color_mgmt_changed 2!\n", __func__); + DRM_INFO("%s Set GAMMA\n", __func__); + priv->gamma_lut_blob = drm_property_reference_blob( + crtc->state->gamma_lut); lut = (struct drm_color_lut *) crtc->state->gamma_lut->data; #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT gamma_lut_size = amvecm_drm_get_gamma_size(0); amvecm_drm_gamma_set(0, lut, gamma_lut_size); #endif + } else { + DRM_DEBUG("%s Disable GAMMA!\n", __func__); + #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT + amvecm_drm_gamma_disable(0); + #endif } } @@ -258,7 +275,6 @@ int am_meson_crtc_create(struct am_meson_crtc *amcrtc) #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT amvecm_drm_init(0); - amvecm_drm_gamma_enable(0); gamma_lut_size = amvecm_drm_get_gamma_size(0); drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size); drm_crtc_enable_color_mgmt(crtc, 0, true, gamma_lut_size); diff --git a/drivers/amlogic/drm/meson_drv.h b/drivers/amlogic/drm/meson_drv.h index 331e06fe324d..4260a3ca00fa 100644 --- a/drivers/amlogic/drm/meson_drv.h +++ b/drivers/amlogic/drm/meson_drv.h @@ -51,6 +51,7 @@ struct meson_drm { struct drm_gem_object *fbdev_bo; struct drm_plane *primary_plane; struct drm_plane *cursor_plane; + struct drm_property_blob *gamma_lut_blob; #ifdef CONFIG_DRM_MESON_USE_ION struct ion_client *gem_client; diff --git a/drivers/amlogic/media/enhancement/amvecm/amvecm.c b/drivers/amlogic/media/enhancement/amvecm/amvecm.c index cfa82dfff7c0..cb0c87dddf22 100644 --- a/drivers/amlogic/media/enhancement/amvecm/amvecm.c +++ b/drivers/amlogic/media/enhancement/amvecm/amvecm.c @@ -4489,6 +4489,47 @@ static int cm2_luma_array[color_mode_idx][2]; static int cm2_sat_array[color_mode_idx][2]; static int cm2_hue_by_hs_array[color_mode_idx][2]; +#define MAX_CLIP_VAL ((1<<30)-1) +static ssize_t amvecm_clamp_color_top_show(struct class *cla, + struct class_attribute *attr, char *buf) +{ + return sprintf(buf, "0x%08x\n", READ_VPP_REG(VPP_CLIP_MISC0)); +} +static ssize_t amvecm_clamp_color_top_store(struct class *cla, + struct class_attribute *attr, + const char *buf, size_t count) +{ + size_t r; + uint32_t val; + + r = sscanf(buf, "%x\n", &val); + if ((r != 1) || (val > MAX_CLIP_VAL)) + return -EINVAL; + + WRITE_VPP_REG(VPP_CLIP_MISC0, val); + return count; +} + +static ssize_t amvecm_clamp_color_bottom_show(struct class *cla, + struct class_attribute *attr, char *buf) +{ + return sprintf(buf, "0x%08x\n", READ_VPP_REG(VPP_CLIP_MISC1)); +} +static ssize_t amvecm_clamp_color_bottom_store(struct class *cla, + struct class_attribute *attr, + const char *buf, size_t count) +{ + size_t r; + uint32_t val; + + r = sscanf(buf, "%x\n", &val); + if ((r != 1) || (val > MAX_CLIP_VAL)) + return -EINVAL; + + WRITE_VPP_REG(VPP_CLIP_MISC1, val); + return count; +} + static ssize_t amvecm_cm2_hue_show(struct class *cla, struct class_attribute *attr, char *buf) { @@ -5752,6 +5793,11 @@ static struct class_attribute amvecm_class_attrs[] = { __ATTR(lc, 0644, amvecm_lc_show, amvecm_lc_store), + __ATTR(color_top, 0644, + amvecm_clamp_color_top_show, amvecm_clamp_color_top_store), + __ATTR(color_bottom, 0644, + amvecm_clamp_color_bottom_show, + amvecm_clamp_color_bottom_store), __ATTR_NULL };