From patchwork Mon Sep 2 12:53:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 172753 Delivered-To: patch@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp4168468ocp; Mon, 2 Sep 2019 05:54:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6wmrPb8UDy6umdvgboBjG6pjgNwRN1FDvxzBiUbfgRqlmzbbEi+n/1TFgf2GrsbPUZ8MD X-Received: by 2002:a62:55c1:: with SMTP id j184mr14216016pfb.104.1567428892739; Mon, 02 Sep 2019 05:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567428892; cv=none; d=google.com; s=arc-20160816; b=roYMyb0kmcmIpdyOL5Zu8bL3icYZowUNKkjITLAORsstxdBBDdQjJxTSontZ/VaPRx B4ggSxupH0H9aTZXyjm0rzkQDYgR5jZFgTomDJQh55GNvGD8KP0OC6f0hX3uWR09qSy3 P+itWlS/ClHv+9ZTRF9DmzbnQdUD+B8piQ8RQy/K9Ga+Rs2oqN2FHdUVPknvlQTVYulW D5tfbj8ZLXg77MGjP6D3mJjvu+6TCo/QkvU7NPFKTNNwS7tLkU89WImC7NgFpnvIZ9Ib sjsRfsdu+VQBUGwxOdEp1YwD80H5Xmm4XRQ2/qLgrJ64Ujg2b9UXu2AJA7jfqCl4/eOT BEVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=/DKhuMiHKjM1G8wUdaEjNMI3tlFtQ/6Mgl5z1sOBVY8=; b=OCXSxYjzbx/cKS8c+Nt1NzzWBPEbjIr23V88fyjAWUeIAiY7tKTN1HH+NMjyzVCxZy x8ip0dGjwqDgd3mGBFe/jDMSXTZROLs5m8dR6c0MMLEkOd4ZPXuanxxD3yjVt33PYVzd 1tWcxSJxrQEf6I9TQmXaqNhNC/p3Oxk2+8YVBVMBp09AlNm4ueCIeTgQzPpP1wJc2rUD MN7kRC2EUZ7Jaz2S6eJPIngBuDjdnMVFTx9+szZtuGfKe7GS1bXwJb/VVRZph7huoMIa quys/llTBLw3OHfjsTfNrA5wUoeMsxi0/dKIQVMy4F2uVKxfNfmF/+FaMGs6q08k0LEK p61Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id y13si11645271pgp.339.2019.09.02.05.54.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Sep 2019 05:54:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2ED26890B9; Mon, 2 Sep 2019 12:54:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3FC128908C for ; Mon, 2 Sep 2019 12:54:46 +0000 (UTC) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x82CshE0021126; Mon, 2 Sep 2019 07:54:43 -0500 Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x82CshJY000784 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 2 Sep 2019 07:54:43 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 2 Sep 2019 07:54:43 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Mon, 2 Sep 2019 07:54:43 -0500 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x82CsYYM126767; Mon, 2 Sep 2019 07:54:42 -0500 From: Tomi Valkeinen To: , Laurent Pinchart Subject: [PATCH 4/7] drm/omap: Implement CTM property for CRTC using OVL managers CPR matrix Date: Mon, 2 Sep 2019 15:53:56 +0300 Message-ID: <20190902125359.18001-5-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190902125359.18001-1-tomi.valkeinen@ti.com> References: <20190902125359.18001-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1567428884; bh=djV77i26A0+F5MOTKnyz3vMQTUtN0MSuCkdbk8DNuD8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=PgBMD7r2/93vKT9sTGewEHmTl8Oh+88NOciswp/YU5cSiyfz/jVYxcXtxMoRQpLfR cHx1PeDaK2nCBMf3xTpo+4FC2eVhmKsqjXY6xcoaHM+V7CTgx6Ww3Uh42Ibl/hxfr2 M1ZdOlNzwoK0V4S2GTGdgyaI52aXWzprniTe/MT0= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen , Jyri Sarha Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Jyri Sarha 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. Signed-off-by: Jyri Sarha Signed-off-by: Tomi Valkeinen --- 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 3c5ddbf30e97..d63213dd7d83 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -391,6 +391,32 @@ static void omap_crtc_manual_display_update(struct work_struct *data) } } +static s16 omap_crtc_S31_32_to_s2_8(s64 coef) +{ + uint64_t sign_bit = 1ULL << 63; + uint64_t cbits = (uint64_t) 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 +428,16 @@ 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 = + (struct drm_color_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); } @@ -836,7 +871,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, 0, false, gamma_lut_size); + drm_crtc_enable_color_mgmt(crtc, 0, true, gamma_lut_size); drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size); }