From patchwork Thu Aug 10 16:03:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 134102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp543493vqi; Thu, 10 Aug 2023 09:38:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4+xIUjilXJC7GS0pIxnJhw9utf7TAff9hkP9YyNhtV4uF0HW3lAieoLaauovC3nxalb55 X-Received: by 2002:a05:6808:1506:b0:3a7:8f7:62ee with SMTP id u6-20020a056808150600b003a708f762eemr4034563oiw.12.1691685516258; Thu, 10 Aug 2023 09:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691685516; cv=none; d=google.com; s=arc-20160816; b=lBC49bQ15Gck8p8MMjYlMXz6UgzTJwQdY12v0uP4xxdIxOv2JABvwM9C9spcDQQ4al vCPUmvAiSr6taJRktClEgyGSqWVVVik0ezwS06fwhr1FV9iX33Pst5AEqISTq1D08nNz 1Ldkxao984egKBh8DzspyDAvAX6jSSAA47hvfK8wGQB/ce9G+rz1A8yhQ9hr8rn3iHdi QZgCpewMbCFIGlrV7dwEWtIQkTwcbjUJygh9VGYGUbPXyxl1OrVeF6LBbNEiw+/W3ZVx +HDKpcrW7UVDtzXd/JrmK817PnI0M8xAt+ST92qPXpAM1BDy+58/NVuN7enoegDhOtZb v2/Q== 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=ogyLSwgzcKyk7tiMK7CaQ8c7v+cHVa1H8W0lteF4a4M=; fh=K4g2hpcHeis9i+u86e9V+yTBU0PZFkfdrKenkMdV+qw=; b=gY3dkT0IbB8C1Ko/L1t0+XVwHerPDMHFhMSxhToPJDK9DRLrIQr2ST+c8xmxljecOP k9WjArW7FRlceLjIgLg0Ku/YtyG3hA/6Brks6Pw7KTEl106jqGuMUAQcGJETk40uPNDQ kePOUQzxJp6s0fTcCyrDtEiPMJfwl1h+kHqnA1A90oAPsbDfSplJpQJqEmq5ld2fQEDC HUL+z3NJQI7a1FaooRV9Lm4ai50qijfpZHYTCc0XlN9pz4rsumLTpzww5XOpRqDSRiOi C6q2bsR5UgsJxNNTwLVeTNjX95Lfx3vTQUT8sUboaWXyda6M16iboG4y9OfPxPcaMxQ6 kAKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=H4b5cAKd; 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 67-20020a630046000000b005533647f7c5si1863997pga.420.2023.08.10.09.38.13; Thu, 10 Aug 2023 09:38:36 -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=H4b5cAKd; 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 S236669AbjHJQGW (ORCPT + 99 others); Thu, 10 Aug 2023 12:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236577AbjHJQFZ (ORCPT ); Thu, 10 Aug 2023 12:05:25 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1D0C2737 for ; Thu, 10 Aug 2023 09:04:28 -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=ogyLSwgzcKyk7tiMK7CaQ8c7v+cHVa1H8W0lteF4a4M=; b=H4b5cAKdOaHkIHS5GMC3qypXuG 4jYiK723bTC7fr+DioYtNMCu8pqK0TxDXo2JKC/mNK6Xy/kK/kG7Kop3EoeeQngaq+OZZBDjkrV7m NmGBbMp+FpS9EYZNT6K7G/8FQR2a0DyzwqkcFgPc+BNj6gRfxRP9YaDh6yQB7nkzV/aiOMwiWmja6 3BxOEyidgJT62EGgFxrooRVx4uBbaGWi8gP1Kz030NWfdmu3/7xsEYb0eI73pBZO0HzBHzTdjP2qy k33cZZFmtMhNcjRpWcj7PTaCaWfj5DI7+RRuM7KlM5JYW3pK9iKzf4H+Ka5+JI2fwHMp4RQoSeLjr PNyWDHMA==; 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 1qU894-00GjYD-O0; Thu, 10 Aug 2023 18:04:18 +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 28/34] drm/amd/display: add plane blend LUT and TF support Date: Thu, 10 Aug 2023 15:03:08 -0100 Message-Id: <20230810160314.48225-29-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: 1773860831564069772 X-GMAIL-MSGID: 1773860831564069772 From: Joshua Ashton Map plane blend properties to DPP blend gamma. Plane blend is a post-3D LUT curve that linearizes color space for blending. It may be defined by a user-blob LUT and/or predefined transfer function. As hardcoded curve (ROM) is not supported on blend gamma, we use AMD color module to fill parameters when setting non-linear TF with empty LUT. v2: - rename DRM TFs to AMDGPU TFs Reviewed-by: Harry Wentland Signed-off-by: Joshua Ashton Signed-off-by: Melissa Wen --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 + .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 55 +++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 025a7eb5c8aa..d37269a2179e 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -8063,6 +8063,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, bundle->surface_updates[planes_count].hdr_mult = dc_plane->hdr_mult; bundle->surface_updates[planes_count].func_shaper = dc_plane->in_shaper_func; bundle->surface_updates[planes_count].lut3d_func = dc_plane->lut3d_func; + bundle->surface_updates[planes_count].blend_tf = dc_plane->blend_tf; } amdgpu_dm_plane_fill_dc_scaling_info(dm->adev, new_plane_state, 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 2c96501d2fc0..f638e5b3a70b 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 @@ -706,6 +706,34 @@ static int amdgpu_dm_atomic_shaper_lut(const struct drm_color_lut *shaper_lut, return ret; } +static int amdgpu_dm_atomic_blend_lut(const struct drm_color_lut *blend_lut, + bool has_rom, + enum dc_transfer_func_predefined tf, + uint32_t blend_size, + struct dc_transfer_func *func_blend) +{ + int ret = 0; + + if (blend_size || tf != TRANSFER_FUNCTION_LINEAR) { + /* DRM plane gamma LUT or TF means we are linearizing color + * space before blending (similar to degamma programming). As + * we don't have hardcoded curve support, or we use AMD color + * module to fill the parameters that will be translated to HW + * points. + */ + func_blend->type = TF_TYPE_DISTRIBUTED_POINTS; + func_blend->tf = tf; + func_blend->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE; + + ret = __set_input_tf(func_blend, blend_lut, blend_size); + } else { + func_blend->type = TF_TYPE_BYPASS; + func_blend->tf = TRANSFER_FUNCTION_LINEAR; + } + + return ret; +} + /* amdgpu_dm_lut3d_size - get expected size according to hw color caps * @adev: amdgpu device * @lut_size: default size @@ -1053,8 +1081,9 @@ amdgpu_dm_plane_set_color_properties(struct drm_plane_state *plane_state, { struct dm_plane_state *dm_plane_state = to_dm_plane_state(plane_state); enum amdgpu_transfer_function shaper_tf = AMDGPU_TRANSFER_FUNCTION_DEFAULT; - const struct drm_color_lut *shaper_lut, *lut3d; - uint32_t shaper_size, lut3d_size; + enum amdgpu_transfer_function blend_tf = AMDGPU_TRANSFER_FUNCTION_DEFAULT; + const struct drm_color_lut *shaper_lut, *lut3d, *blend_lut; + uint32_t shaper_size, lut3d_size, blend_size; int ret; /* We have nothing to do here, return */ @@ -1074,12 +1103,30 @@ amdgpu_dm_plane_set_color_properties(struct drm_plane_state *plane_state, amdgpu_tf_to_dc_tf(shaper_tf), shaper_size, dc_plane_state->in_shaper_func); - if (ret) + if (ret) { drm_dbg_kms(plane_state->plane->dev, "setting plane %d shaper LUT failed.\n", plane_state->plane->index); - return ret; + return ret; + } + + blend_tf = dm_plane_state->blend_tf; + blend_lut = __extract_blob_lut(dm_plane_state->blend_lut, &blend_size); + blend_size = blend_lut != NULL ? blend_size : 0; + + ret = amdgpu_dm_atomic_blend_lut(blend_lut, false, + amdgpu_tf_to_dc_tf(blend_tf), + blend_size, dc_plane_state->blend_tf); + if (ret) { + drm_dbg_kms(plane_state->plane->dev, + "setting plane %d gamma lut failed.\n", + plane_state->plane->index); + + return ret; + } + + return 0; } /**