dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	dri-devel@lists.freedesktop.org, Sekhar Nori <nsekhar@ti.com>,
	Jyri Sarha <jsarha@ti.com>, Nikhil Devshatwar <nikhil.nd@ti.com>
Subject: Re: [PATCH v2 3/5] drm/omap: Implement CTM property for CRTC using OVL managers CPR matrix
Date: Mon, 30 Nov 2020 12:41:41 +0200	[thread overview]
Message-ID: <20201130104141.GS4141@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20201103080310.164453-4-tomi.valkeinen@ti.com>

Hi Tomi and Jyri,

Thank you for the patch.

On Tue, Nov 03, 2020 at 10:03:08AM +0200, Tomi Valkeinen wrote:
> From: Jyri Sarha <jsarha@ti.com>
> 
> Implement CTM color management property for OMAP CRTC using DSS
> overlay manager's Color Phase Rotation matrix. The CPR matrix does not
> exactly match the CTM property documentation. On DSS the CPR matrix is
> applied after gamma table look up. However, it seems stupid to add a
> custom property just for that.

Should this be updated now that the driver has switched to using degamma
?

> Signed-off-by: Jyri Sarha <jsarha@ti.com>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/omap_crtc.c | 39 +++++++++++++++++++++++++++--
>  1 file changed, 37 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
> index d40220b2f312..b2c251a8b404 100644
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
> @@ -391,6 +391,33 @@ static void omap_crtc_manual_display_update(struct work_struct *data)
>  	}
>  }
>  
> +static s16 omap_crtc_s31_32_to_s2_8(s64 coef)
> +{
> +	u64 sign_bit = 1ULL << 63;
> +	u64 cbits = (u64)coef;
> +
> +	s16 ret = clamp_val(((cbits & ~sign_bit) >> 24), 0, 0x1ff);
> +
> +	if (cbits & sign_bit)
> +		ret = -ret;
> +
> +	return ret;
> +}
> +
> +static void omap_crtc_cpr_coefs_from_ctm(const struct drm_color_ctm *ctm,
> +					 struct omap_dss_cpr_coefs *cpr)
> +{
> +	cpr->rr = omap_crtc_s31_32_to_s2_8(ctm->matrix[0]);
> +	cpr->rg = omap_crtc_s31_32_to_s2_8(ctm->matrix[1]);
> +	cpr->rb = omap_crtc_s31_32_to_s2_8(ctm->matrix[2]);
> +	cpr->gr = omap_crtc_s31_32_to_s2_8(ctm->matrix[3]);
> +	cpr->gg = omap_crtc_s31_32_to_s2_8(ctm->matrix[4]);
> +	cpr->gb = omap_crtc_s31_32_to_s2_8(ctm->matrix[5]);
> +	cpr->br = omap_crtc_s31_32_to_s2_8(ctm->matrix[6]);
> +	cpr->bg = omap_crtc_s31_32_to_s2_8(ctm->matrix[7]);
> +	cpr->bb = omap_crtc_s31_32_to_s2_8(ctm->matrix[8]);
> +}
> +
>  static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)
>  {
>  	struct omap_drm_private *priv = crtc->dev->dev_private;
> @@ -402,7 +429,15 @@ static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)
>  	info.default_color = 0x000000;
>  	info.trans_enabled = false;
>  	info.partial_alpha_enabled = false;
> -	info.cpr_enable = false;
> +
> +	if (crtc->state->ctm) {
> +		struct drm_color_ctm *ctm = crtc->state->ctm->data;
> +
> +		info.cpr_enable = true;
> +		omap_crtc_cpr_coefs_from_ctm(ctm, &info.cpr_coefs);
> +	} else {
> +		info.cpr_enable = false;
> +	}
>  
>  	priv->dispc_ops->mgr_setup(priv->dispc, omap_crtc->channel, &info);
>  }
> @@ -842,7 +877,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
>  	if (priv->dispc_ops->mgr_gamma_size(priv->dispc, channel)) {
>  		unsigned int gamma_lut_size = 256;
>  
> -		drm_crtc_enable_color_mgmt(crtc, gamma_lut_size, false, 0);
> +		drm_crtc_enable_color_mgmt(crtc, gamma_lut_size, true, 0);
>  		drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size);
>  	}
>  

-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-11-30 10:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03  8:03 [PATCH v2 0/5] drm/omap: add color mgmt support Tomi Valkeinen
2020-11-03  8:03 ` [PATCH v2 1/5] drm: add legacy support for using degamma for gamma Tomi Valkeinen
2020-11-30 10:38   ` Laurent Pinchart
2020-11-30 12:12     ` Tomi Valkeinen
2020-11-30 14:10       ` Daniel Vetter
2020-12-02 11:52         ` Tomi Valkeinen
2020-12-02 12:38           ` Daniel Vetter
2020-12-03 12:31             ` Ville Syrjälä
2020-12-03 12:35               ` Tomi Valkeinen
2020-11-03  8:03 ` [PATCH v2 2/5] drm/omap: use degamma property for gamma table Tomi Valkeinen
2020-11-30 10:39   ` Laurent Pinchart
2020-11-03  8:03 ` [PATCH v2 3/5] drm/omap: Implement CTM property for CRTC using OVL managers CPR matrix Tomi Valkeinen
2020-11-30 10:41   ` Laurent Pinchart [this message]
2020-11-30 11:39     ` Tomi Valkeinen
2020-11-03  8:03 ` [PATCH v2 4/5] drm/omap: rearrange includes in omapdss.h Tomi Valkeinen
2020-11-30 10:42   ` Laurent Pinchart
2020-11-03  8:03 ` [PATCH v2 5/5] drm/omap: Enable COLOR_ENCODING and COLOR_RANGE properties for planes Tomi Valkeinen
2020-11-30 10:50   ` Laurent Pinchart
2020-11-30 11:53     ` Tomi Valkeinen
2020-11-30 14:19       ` Laurent Pinchart
2020-11-30 14:36         ` Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201130104141.GS4141@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=nikhil.nd@ti.com \
    --cc=nsekhar@ti.com \
    --cc=pekka.paalanen@collabora.com \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox