From patchwork Wed Apr 3 13:14:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalakodima Venkata Rajesh (RBEI/ECF3)" X-Patchwork-Id: 10885079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40345139A for ; Thu, 4 Apr 2019 07:17:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2171528901 for ; Thu, 4 Apr 2019 07:17:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13F2528992; Thu, 4 Apr 2019 07:17:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4615228901 for ; Thu, 4 Apr 2019 07:17:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8624E6E562; Thu, 4 Apr 2019 07:17:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from de-deferred2.bosch-org.com (de-deferred2.bosch-org.com [139.15.180.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id EEF0F6E8F2 for ; Wed, 3 Apr 2019 13:25:40 +0000 (UTC) Received: from de-out1.bosch-org.com (unknown [139.15.180.215]) by fe0vms0193.rbdmz01.com (Postfix) with ESMTPS id 44Z65q2SlFz2bR for ; Wed, 3 Apr 2019 15:15:59 +0200 (CEST) Received: from si0vm1947.rbesz01.com (unknown [139.15.230.188]) by fe0vms0187.rbdmz01.com (Postfix) with ESMTPS id 44Z65n3R47z1XLDQt; Wed, 3 Apr 2019 15:15:57 +0200 (CEST) Received: from fe0vm7918.rbesz01.com (unknown [10.58.172.176]) by si0vm1947.rbesz01.com (Postfix) with ESMTPS id 44Z65n2q3fz6CjQSN; Wed, 3 Apr 2019 15:15:57 +0200 (CEST) X-AuditID: 0a3aad10-03fff70000007f88-86-5ca4b20d2a59 Received: from fe0vm1652.rbesz01.com ( [10.58.173.29]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by fe0vm7918.rbesz01.com (SMG Outbound) with SMTP id C1.BF.32648.D02B4AC5; Wed, 3 Apr 2019 15:15:57 +0200 (CEST) Received: from SI-HUB2000.de.bosch.com (si-hub2000.de.bosch.com [10.4.103.108]) by fe0vm1652.rbesz01.com (Postfix) with ESMTPS id 44Z65n0R74zVv1; Wed, 3 Apr 2019 15:15:57 +0200 (CEST) Received: from localhost.localdomain (10.47.103.88) by SI-HUB2000.de.bosch.com (10.4.103.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5; Wed, 3 Apr 2019 15:15:55 +0200 From: To: , , , , Subject: [PATCH 6/8] drm: rcar-du: Implement atomic_check to check for gamma and ctm properties Date: Wed, 3 Apr 2019 18:44:42 +0530 Message-ID: <1554297284-14009-7-git-send-email-VenkataRajesh.Kalakodima@in.bosch.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554297284-14009-1-git-send-email-VenkataRajesh.Kalakodima@in.bosch.com> References: <1554297284-14009-1-git-send-email-VenkataRajesh.Kalakodima@in.bosch.com> MIME-Version: 1.0 X-Originating-IP: [10.47.103.88] X-Brightmail-Tracker: H4sIAAAAAAAAA22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rdr9kx1csY/WgcK718am9vtm/7MPKz3uE/s/XsyZUdJtDb6NlX354DG2546 Gck+dO/9Ld0fcQU/HP3t2qmbM+4db7k6jx/41tp0azCSvpFVihY+/wWFQ+T/A3Fq90ZCBAAA X-Mailman-Approved-At: Thu, 04 Apr 2019 07:17:55 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=in.bosch.com; s=2015-01-21; t=1554297357; bh=5JmXTCA8402bhLcSZ4Bm03a+Df0e1eFcN7hmyjl8vSI=; l=10; h=From:From:Reply-To:Sender; b=KsSr5mfZkWC84xy343neKHvYjnHU2ZDc0SrPG3doa1ZabNcvuZ6zwN+afLtGaTfO0 HUCBcfrjmBLT+dMMaxG/+5u37sztMO4g5rJL0x0gT2H/UHLVwTol6W3apedsquw822 ZH05RnQPtngcH3/QeSgbm/Z/LsbpT3kjj2FElSwk= 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: Harsha M M , kalakodima venkata rajesh Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: kalakodima venkata rajesh Implement atomic helper check and allocate memory necessary for lut and clu tables Signed-off-by: Harsha M M - Resolved checkpatch errors - Resolved merge conflicts according to latest version Signed-off-by: kalakodima venkata rajesh --- drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 58 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/rcar-du/rcar_du_crtc.h | 3 +- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 864fb94..a00b7a7 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -622,6 +622,63 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc) * CRTC Functions */ +static bool rcar_du_crtc_is_ctm_updated(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + return (state->color_mgmt_changed && state->ctm && + crtc->state->ctm && + (crtc->state->ctm->base.id != state->ctm->base.id)); +} + +static bool rcar_du_crtc_is_gamma_updated(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + return (state->color_mgmt_changed && state->gamma_lut && + crtc->state->gamma_lut && + (crtc->state->gamma_lut->base.id != state->gamma_lut->base.id)); +} + +static int rcar_du_crtc_cmm_atomic_check(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + int ret = 0; + struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); + + /*Check gamma update and allocate memory*/ + if (rcar_du_crtc_is_gamma_updated(crtc, state) && + !rcrtc->lut_handle) { + ret = rcar_du_cmm_lut_valid((crtc->state->gamma_lut->length / + sizeof(struct drm_color_lut))); + if (ret >= 0) { + rcrtc->lut_handle = + rcar_du_cmm_alloc_lut(rcrtc->cmm_handle); + if (!rcrtc->lut_handle) + ret = -ENOMEM; + } + } + + /*Check update of ctm and allocate memory*/ + if (ret >= 0 && rcar_du_crtc_is_ctm_updated(crtc, state) && + !rcrtc->clu_handle) { + rcrtc->clu_handle = rcar_du_cmm_alloc_clu(rcrtc->cmm_handle); + if (!rcrtc->clu_handle) { + if (!rcrtc->lut_handle) { + rcar_du_cmm_free_lut(rcrtc->lut_handle); + rcrtc->lut_handle = NULL; + } + ret = -ENOMEM; + } + } + + return ret; +} + +static int rcar_du_crtc_atomic_check(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + return rcar_du_crtc_cmm_atomic_check(crtc, state); +} + static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { @@ -708,6 +765,7 @@ static const struct drm_crtc_helper_funcs crtc_helper_funcs = { .atomic_flush = rcar_du_crtc_atomic_flush, .atomic_enable = rcar_du_crtc_atomic_enable, .atomic_disable = rcar_du_crtc_atomic_disable, + .atomic_check = rcar_du_crtc_atomic_check, }; static struct drm_crtc_state * diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h index 5b85de4..b79080e 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h @@ -70,7 +70,8 @@ struct rcar_du_crtc { int lvds_ch; void *cmm_handle; - + void *lut_handle; + void *clu_handle; }; #define to_rcar_crtc(c) container_of(c, struct rcar_du_crtc, crtc)