From patchwork Thu Aug 10 16:02:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 134092 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp537489vqi; Thu, 10 Aug 2023 09:28:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkoJWt40O8BtDIC/RZ5r4Wj5PRu28p70E7bugNcWXVjk69qRNX3dS20CPf2v1kDfiaC3PP X-Received: by 2002:a05:6a00:1827:b0:687:9ba5:e3fe with SMTP id y39-20020a056a00182700b006879ba5e3femr3993116pfa.23.1691684934237; Thu, 10 Aug 2023 09:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691684934; cv=none; d=google.com; s=arc-20160816; b=M0DHIZN/XOP2WIv5AcD3sqNQSiaz1qqbbc6+5B9cLv7OjoPtoVhbE7VJi9Q5Pua42X rJfLN1bgIJpHKPbMsVXBdUlL/SlYIh1rGaVZrL9uojbLc5GcNkQApWTT1ZPGq1t0XoXu ut0eEayYlguzqc2RI5gZ46COjJea0YS5D3qSKsjm0ATu8Aibld3yGlj2iuBNbEJYYfnB s3JWq+XwuXMGiGqI3v1l9Pyi8VT6UVPwo4V9jmx2WxOByY0WPe2QSOUa9UHOoNh9yyT5 3xxu/Uire9YCOaTlpS9ChaRtaY1ZB1t4ktQSNw1dK1dijiZaiP3VCt9EyNektiaC0mJG PmUg== 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=XrhK8At5PUqoIR3n2oXhIsEpCYE7AZ5HTDYQD5Td9DQ=; fh=K4g2hpcHeis9i+u86e9V+yTBU0PZFkfdrKenkMdV+qw=; b=MXCIvwcTbiKnsEg7DUffuk+bVIrIeG45Dty6zrg/NwHiCUTfG4GwvVvi/M/izSs0Hd bO8qKyeEcH56OTM2edisvm2gcn8jwgF3f7+Hwu4XDmhMIBRZBJ7mSl7AuxYVZ5PGB8lJ XN+7QioV9TZ8TKUoy3sJzBpvftApEbhTdyHu86lr8ieraTcboiKd/CRQYZllWp+owRx2 lncDlvw6hdJB5r+rU2eNDiOjbsJOy9RVjPh+i5Rit2DPaLunTp9atRAuRZShF41XTiNz 1+tXu+93xCuzr2CNKaRfKdSbNhlPdDvh14SjmBPf0GYfIgNFsDOCLVQP9nq2d2tN73gr OzTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=rTnCx7B5; 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 e32-20020a630f20000000b00563deb65f93si1702919pgl.200.2023.08.10.09.28.41; Thu, 10 Aug 2023 09:28:54 -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=rTnCx7B5; 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 S236453AbjHJQE6 (ORCPT + 99 others); Thu, 10 Aug 2023 12:04:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236443AbjHJQEL (ORCPT ); Thu, 10 Aug 2023 12:04:11 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 739682D64 for ; Thu, 10 Aug 2023 09:04:10 -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=XrhK8At5PUqoIR3n2oXhIsEpCYE7AZ5HTDYQD5Td9DQ=; b=rTnCx7B5fQo05mU2KL/P5WuQMV FRTRiYWtionf1R5gM/7hYETlpIoZIBUgJefxGVnOrRVnj3PQjZfQfLeAX/B0Ww3taXVEoaabQsgpq RQ6SQeCzcOMAfHTukcbj8bkk3cxrtu2DL//NLRurm2/jMLwcHlxilJJ7PGJ2Gpjxy2AlaKvvfJAWx /Ma4CummAdkiVHJ0B8f+4UM4mHewDZO4YlADunxdvuFXB83ahO3D7Qp1KwXOFktDT0UEySz70FhDn 2ui91Rx/AOKHTNoc/DssynAeXH1HklOR+6NhbzDPdu5PvVasj4WV2ZFDQ43BoLqtqax/+0jp5mjZv SxvhGHig==; Received: from [38.44.68.151] (helo=killbill.home) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1qU88l-00GjYD-AR; Thu, 10 Aug 2023 18:03:59 +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 , Pekka Paalanen , Simon Ser , kernel-dev@igalia.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 19/34] drm/amd/display: decouple steps for mapping CRTC degamma to DC plane Date: Thu, 10 Aug 2023 15:02:59 -0100 Message-Id: <20230810160314.48225-20-mwen@igalia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230810160314.48225-1-mwen@igalia.com> References: <20230810160314.48225-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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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: INBOX X-GMAIL-THRID: 1773860221678269421 X-GMAIL-MSGID: 1773860221678269421 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. Reviewed-by: Harry Wentland Signed-off-by: Melissa Wen --- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 59 +++++++++++++------ 1 file changed, 41 insertions(+), 18 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 68e9f2c62f2e..74eb02655d96 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 @@ -764,20 +764,9 @@ 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; @@ -800,8 +789,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 @@ -837,7 +825,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. @@ -847,8 +835,43 @@ int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc, if (tf != TRANSFER_FUNCTION_SRGB && !mod_color_calculate_degamma_params(NULL, - dc_plane_state->in_transfer_func, NULL, false)) + 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;