Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4533573ybi; Sat, 6 Jul 2019 07:11:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqw10AnsrV7NaDg3vbseaE3FSrnE6WGOhgxQtR51C4bCfsFzBwn+lVpjo1cmg2ve9FGMH/QV X-Received: by 2002:a17:902:f095:: with SMTP id go21mr11957299plb.58.1562422260134; Sat, 06 Jul 2019 07:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562422260; cv=none; d=google.com; s=arc-20160816; b=aOYktfTnsA7p36n5fbqz7/N7gFYvcZP2t2oZDbwJ6Axjd5FKdwRAAxEir8yGnU7HC8 zntCA0qUaOgd/rQPRJFDDt4AS78F1t03kbdEzQCFn6N3qBO8zh5pylHXzQLKSqCdMZ1r vWDS+IBT5EoDdu8TvsHB+oWq6Oq6GVnoqV9TMJaXgl3RtqvA1ez5ubnF66c1ffJnekhl Ng7dpeHPrxCF4xDenF5s0Pyw/Uz7UK9Ai0Yp2hd/nYzDZTNvq8JEzqorX0VK0tGT7z6U OvqbitAqBfPaZ0TZ2NyI5+WxoijC2uWH4fprkJM243MxnaLvun5/Ws2/SvEGgORp9/md 4WIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ekTga1Z5AaF+rT/U3L/ythYRZrL+V1HI+M+7AHgQnDA=; b=t5fmBPJRaNLiYaVKvPAfYbeU6g+7cLuG2Vq0GiMuSxeIY5hhxOl48PVpqbRnn2lZaC ZREhrGuiVRvBSQf+oMlgrEzmyGGygtGZBkhSZYTnteG5NDIxvt2LIZQxhmNbMXzdNqRl ibfT532QVdLLeOQ+cOrtNzuSA4oer2zR4qw06R11cwkMpSxl/9X1X8FpIyyoKszIukbx eBmxWqOEGn9ZN4hiJHl9Wly1naBYRYl5D2BcGpUcRxRmVYyewIwSnMEwy9rmZbVEXRVn S2eubanuTT12x+/2fEhUMwMH6+9d13zWu6HtwIfD+smCa799dyBl7iFt9Z3fvh16seeB G3UA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si2080471pjn.42.2019.07.06.07.10.44; Sat, 06 Jul 2019 07:11:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727330AbfGFOHb (ORCPT + 99 others); Sat, 6 Jul 2019 10:07:31 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:42669 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727310AbfGFOH3 (ORCPT ); Sat, 6 Jul 2019 10:07:29 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.localdomain (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 0F6B5C0004; Sat, 6 Jul 2019 14:07:25 +0000 (UTC) From: Jacopo Mondi To: laurent.pinchart@ideasonboard.com, kieran.bingham+renesas@ideasonboard.com, airlied@linux.ie, daniel@ffwll.ch Cc: Jacopo Mondi , koji.matsuoka.xm@renesas.com, muroya@ksk.co.jp, VenkataRajesh.Kalakodima@in.bosch.com, Harsha.ManjulaMallikarjun@in.bosch.com, linux-renesas-soc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 19/19] drm: rcar-du: kms: Update CMM in atomic commit tail Date: Sat, 6 Jul 2019 16:07:46 +0200 Message-Id: <20190706140746.29132-20-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190706140746.29132-1-jacopo+renesas@jmondi.org> References: <20190706140746.29132-1-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update CMM settings at in the atomic commit tail helper method. The CMM is updated with new gamma values provided to the driver in the GAMMA_LUT blob property. Signed-off-by: Jacopo Mondi --- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index b79cda2f5531..f9aece78ca5f 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -21,6 +21,7 @@ #include #include +#include "rcar_cmm.h" #include "rcar_du_crtc.h" #include "rcar_du_drv.h" #include "rcar_du_encoder.h" @@ -287,6 +288,37 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, * Atomic Check and Update */ +static void rcar_du_atomic_commit_update_cmm(struct drm_crtc *crtc, + struct drm_crtc_state *old_state) +{ + struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); + struct rcar_cmm_config cmm_config = {}; + + if (!rcrtc->cmm || !crtc->state->color_mgmt_changed) + return; + + if (!crtc->state->gamma_lut) { + cmm_config.lut.enable = false; + rcar_cmm_setup(rcrtc->cmm, &cmm_config); + + return; + } + + cmm_config.lut.enable = true; + cmm_config.lut.table = (struct drm_color_lut *) + crtc->state->gamma_lut->data; + + /* Set LUT table size to 0 if entries should not be updated. */ + if (!old_state->gamma_lut || + old_state->gamma_lut->base.id != crtc->state->gamma_lut->base.id) + cmm_config.lut.size = crtc->state->gamma_lut->length + / sizeof(cmm_config.lut.table[0]); + else + cmm_config.lut.size = 0; + + rcar_cmm_setup(rcrtc->cmm, &cmm_config); +} + static int rcar_du_atomic_check(struct drm_device *dev, struct drm_atomic_state *state) { @@ -329,6 +361,9 @@ static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state) rcdu->dpad1_source = rcrtc->index; } + for_each_old_crtc_in_state(old_state, crtc, crtc_state, i) + rcar_du_atomic_commit_update_cmm(crtc, crtc_state); + /* Apply the atomic update. */ drm_atomic_helper_commit_modeset_disables(dev, old_state); drm_atomic_helper_commit_planes(dev, old_state, -- 2.21.0