From patchwork Sun Apr 23 14:10:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 86764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2241864vqo; Sun, 23 Apr 2023 08:10:21 -0700 (PDT) X-Google-Smtp-Source: AKy350YaOYAtq921ui/KzCT9EtxXkFmcQQlduSdKyQ6ct5gaPbc+gITDoVZedwc0IDo18wr/U91k X-Received: by 2002:a05:6a20:a696:b0:f1:b3c1:82f2 with SMTP id ba22-20020a056a20a69600b000f1b3c182f2mr12160420pzb.38.1682262621113; Sun, 23 Apr 2023 08:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682262621; cv=none; d=google.com; s=arc-20160816; b=IP9mECwIHvEDPC3Vu0aEdTXH8arXkoqRRuMfVmx32JFS4O1Su8LPhBqaHV3JQXEq1z EbliZLBs5UrGvi1OMfYqL2Z61b3RafmokkhdzmCgl5dtD7yAHFDUzD2vw9r4c+qKpP3L MI8fVbZhhqV1dknl9hB1eOxI/w+wuQadzHBZmPals+h3OZILjHLJA3IWQ5c321tvIb5M NGlhF5iz5OFmX59iJ6ZnxkK7rwuwUMr8zGM1kuFZmYmdrfZ/ih1PaLIYTyjq5cYUs12K HbFTsc8Spq2wudrCuveSRC0DJQoCZKhFMNqj7cMOS7ovAPBCCS9fhT5EIFIL3fZfdCHU DvkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QwuSO2LNJ+LJ1+yrvEcZOrqAYwcz+YFmvLiCu9u3lbQ=; b=NWEfYYjN1KYeGA5Vsma+m0VYPrxY8Fgopy0Izb9dA2A7E037XhUOHJ8wCpl/tQsbLw yFaAFheAtSNgSveEwEMiylVffLLljem86QPiJIyhlwM3+1To2pmOtqoSH9ET7NTCz87Y TFqDhfcFTv2fd2BAxOwpb7aq2+qIfAgMm0BTSOE1u/SqIrzXeMT4qpeQKzJs/0Jo6nWa CWBQjTbBnfiry+tXO3FE2K/2nm9jGe3KFTVkmVJx9jQUELvDHIaIpHmALTgwpIREadGS IQo7kRab5qurULLROJFVfwrIuWIGPy5s6dS3qRe+E3dgiQfreNTxLgA2GA215HA9FPGr PkDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=mORa53lO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v69-20020a638948000000b0050bfc85d989si9675498pgd.154.2023.04.23.08.10.06; Sun, 23 Apr 2023 08:10:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=mORa53lO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230402AbjDWOtK (ORCPT + 99 others); Sun, 23 Apr 2023 10:49:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbjDWOtF (ORCPT ); Sun, 23 Apr 2023 10:49:05 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E541B1FD8 for ; Sun, 23 Apr 2023 07:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=QwuSO2LNJ+LJ1+yrvEcZOrqAYwcz+YFmvLiCu9u3lbQ=; b=mORa53lOjf6BQPulDyK5c+ctGp 7OS8D5hV+ZI9NRVY0Ypu6IY6WqiF0u0PogOM0YVPNCTSHAZv21TK2yltFeu/NOinJ5+GZDwCB8sIE XA2LN+prpg73D38iJoWmtLIxa5fZEQvsITh/jOLw7H43mP2xHOClrJnhXK8nwhrSnZlA7jJiRxwMo AcSCwp8ShKkdKEEZeFf0qUdetr2sbbhPccegDIUB1NCLhEWKf/hNebglaABOnRm6OA+ylqMCgVas3 VvKi5XzfLqcTNLiddrsRsJYHNLCQl/x982gL31yJZNkebLSzsCoJKFm5A1IFgEq6EuGdTydUlVViZ WfDpbpnQ==; Received: from nat-wifi.fi.muni.cz ([147.251.43.9] helo=killbill.fi.muni.cz) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pqaTD-00ANVs-Ax; Sun, 23 Apr 2023 16:13:39 +0200 From: Melissa Wen To: amd-gfx@lists.freedesktop.org, Harry Wentland , Rodrigo Siqueira , sunpeng.li@amd.com, Alex Deucher , dri-devel@lists.freedesktop.org, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch Cc: Joshua Ashton , Sebastian Wick , Xaver Hugl , Shashank Sharma , Nicholas Kazlauskas , sungjoon.kim@amd.com, Alex Hung , Melissa Wen , linux-kernel@vger.kernel.org Subject: [RFC PATCH 31/40] drm/amd/display: decouple steps for mapping CRTC degamma to DC plane Date: Sun, 23 Apr 2023 13:10:43 -0100 Message-Id: <20230423141051.702990-32-mwen@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230423141051.702990-1-mwen@igalia.com> References: <20230423141051.702990-1-mwen@igalia.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763980210179598887?= X-GMAIL-MSGID: =?utf-8?q?1763980210179598887?= The next patch adds pre-blending degamma to AMD color mgmt pipeline, but pre-blending degamma caps (DPP) is currently in use to provide DRM CRTC atomic degamma or implict degamma on legacy gamma. Detach degamma usage regarging CRTC color properties to manage plane and CRTC color correction combinations. Signed-off-by: Melissa Wen --- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 55 +++++++++++++------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c index 6a233380f284..518082222fff 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c @@ -791,20 +791,8 @@ int amdgpu_dm_update_crtc_color_mgmt(struct dm_crtc_state *crtc, return 0; } -/** - * amdgpu_dm_update_plane_color_mgmt: Maps DRM color management to DC plane. - * @crtc: amdgpu_dm crtc state - * @dc_plane_state: target DC surface - * - * Update the underlying dc_stream_state's input transfer function (ITF) in - * preparation for hardware commit. The transfer function used depends on - * the preparation done on the stream for color management. - * - * Returns: - * 0 on success. -ENOMEM if mem allocation fails. - */ -int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc, - struct dc_plane_state *dc_plane_state) +static int map_crtc_degamma_to_dc_plane(struct dm_crtc_state *crtc, + struct dc_plane_state *dc_plane_state) { const struct drm_color_lut *degamma_lut; enum dc_transfer_func_predefined tf = TRANSFER_FUNCTION_SRGB; @@ -827,8 +815,7 @@ int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc, °amma_size); ASSERT(degamma_size == MAX_COLOR_LUT_ENTRIES); - dc_plane_state->in_transfer_func->type = - TF_TYPE_DISTRIBUTED_POINTS; + dc_plane_state->in_transfer_func->type = TF_TYPE_DISTRIBUTED_POINTS; /* * This case isn't fully correct, but also fairly @@ -864,7 +851,7 @@ int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc, degamma_lut, degamma_size); if (r) return r; - } else if (crtc->cm_is_degamma_srgb) { + } else { /* * For legacy gamma support we need the regamma input * in linear space. Assume that the input is sRGB. @@ -876,6 +863,40 @@ int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc, !mod_color_calculate_degamma_params(NULL, dc_plane_state->in_transfer_func, NULL, false)) return -ENOMEM; + } + + return 0; +} + +/** + * amdgpu_dm_update_plane_color_mgmt: Maps DRM color management to DC plane. + * @crtc: amdgpu_dm crtc state + * @dc_plane_state: target DC surface + * + * Update the underlying dc_stream_state's input transfer function (ITF) in + * preparation for hardware commit. The transfer function used depends on + * the preparation done on the stream for color management. + * + * Returns: + * 0 on success. -ENOMEM if mem allocation fails. + */ +int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc, + struct dc_plane_state *dc_plane_state) +{ + bool has_crtc_cm_degamma; + int ret; + + has_crtc_cm_degamma = (crtc->cm_has_degamma || crtc->cm_is_degamma_srgb); + if (has_crtc_cm_degamma){ + /* AMD HW doesn't have post-blending degamma caps. When DRM + * CRTC atomic degamma is set, we maps it to DPP degamma block + * (pre-blending) or, on legacy gamma, we use DPP degamma to + * linearize (implicit degamma) from sRGB/BT709 according to + * the input space. + */ + ret = map_crtc_degamma_to_dc_plane(crtc, dc_plane_state); + if (ret) + return ret; } else { /* ...Otherwise we can just bypass the DGM block. */ dc_plane_state->in_transfer_func->type = TF_TYPE_BYPASS;