From patchwork Sun Apr 23 14:10:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 86726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2218708vqo; Sun, 23 Apr 2023 07:17:14 -0700 (PDT) X-Google-Smtp-Source: AKy350YydSlmg6CabZafT0Wcnon7p7TwvVknyiC4tNEaWP6RRXqrb9tWM3w2B84Gq/ViffGuGZDy X-Received: by 2002:a17:90a:4902:b0:240:883:8ff8 with SMTP id c2-20020a17090a490200b0024008838ff8mr11431857pjh.3.1682259434634; Sun, 23 Apr 2023 07:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682259434; cv=none; d=google.com; s=arc-20160816; b=zqGjiHO1I8e93dix2KxMHgpuL+qZHRO5kMZnwznIePWA22fdwesIT0v2IFFuzu/z3o Bv60flQrxemwthRkYVCO1uJZxZw2VPmfBR+0nidWJvIbClcYk2+9bXk8B6sE78fqw5f5 skhkGb1oDR/nZtbCB6xwgowM9rqChCMg4Nsk8hasczVCXuwtVO+AK4/Isg6SqVcADshk Dx7wGWfX2ptAnyIA6ibq9lzDZSB1ylX26M8yeL6iWrnFgUefmM+6EnumaPzpQ/EKHOzA OTLWzKhazR0SMY0IvbK033Cf1XE5l4X4OIkMaCzGLoU0MmU3tku3Mz4jz5oK32mNbtVs K0Qw== 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=iBiuc4P8VmKXEvqKrXrkHjYNh/Y8fk7rr++PQPaLmzc=; b=Uc9W1o52Z75OthmcavhKiM85Ws8i2LHc+e4+ahCwlkuGwweAib70cxKfFnvhv4xE25 8G42ewli/XgZbrW+rJOuxewihqAdfSoIoW6D+R9Q/VqhzO3ihofgmx9fk5iZ+CCpCn31 U5RQOIXUI5yjii9uwU5s/5RMB7voLtBe3pf4tgTdHTmG4x2eDGF1wgVB85tUC4A49WYw lhPz+aRjUKeKrw0mUIFcn+JCmTzw2xsRlBLhOCuky0PMuM2ZUIV5pORxFIsWuUzf91ok 2XAUtgxjR5rJP6B5Homg6MAcDLtt8ngGHnpAFsjGO0DpOiVOrALs1/Ps5gtQfT6HHEHi i0ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=GIDKrGFW; 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 b7-20020a656687000000b005211941267asi2418319pgw.153.2023.04.23.07.16.58; Sun, 23 Apr 2023 07:17:14 -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=GIDKrGFW; 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 S229749AbjDWONc (ORCPT + 99 others); Sun, 23 Apr 2023 10:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbjDWON3 (ORCPT ); Sun, 23 Apr 2023 10:13:29 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 255E43590 for ; Sun, 23 Apr 2023 07:12:58 -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=iBiuc4P8VmKXEvqKrXrkHjYNh/Y8fk7rr++PQPaLmzc=; b=GIDKrGFWjV2LVJfKwgRPiiS6x3 gbHBG2Bm7wGkCLVsMtXx6H7ibDyL641Bk1ZcsxALGNewCyVQaxRZ6hQNqL0Gh8YXD+H/WFlwJB90M XRD2Urv0bhq6OoijHYQ+OsuOl3++mf9n6tFkjJY2anUTL7BzKWdz5jS+Zj1sQwV4UhJZJxvuRtnOF Hy56sb0sKVy1yyELsMyxudELZXIXDYYTEuBXTTeqfFNTuc4kUYZ7ElYd95Mst5lNJoUDgjIxCP2Ay kQkpat7fm7VidyfjwWBLCyLCvNz7qtfLD89aiI7C6BN7wUbaPq5ZGe8npr6QwPWyk1DORMdX5ZFqG 6BY6dGCQ==; 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 1pqaS7-00ANVs-22; Sun, 23 Apr 2023 16:12:31 +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 , linux-kernel@vger.kernel.org Subject: [RFC PATCH 11/40] drm/amd/display: add plane degamma TF driver-private property Date: Sun, 23 Apr 2023 13:10:23 -0100 Message-Id: <20230423141051.702990-12-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?1763976868995112407?= X-GMAIL-MSGID: =?utf-8?q?1763976868995112407?= From: Joshua Ashton Allow userspace to tell the kernel driver the input space and, therefore, uses correct predefined transfer function (TF) to delinearize content with or without LUT (using hardcoded curve caps). Signed-off-by: Joshua Ashton --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 9 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 5 ++++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 7 +++++ .../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 28 +++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 996c9c3fd471..24595906dab1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -1317,6 +1317,15 @@ amdgpu_display_create_color_properties(struct amdgpu_device *adev) return -ENOMEM; adev->mode_info.plane_degamma_lut_size_property = prop; + prop = drm_property_create_enum(adev_to_drm(adev), + DRM_MODE_PROP_ENUM, + "AMD_PLANE_DEGAMMA_TF", + drm_transfer_function_enum_list, + ARRAY_SIZE(drm_transfer_function_enum_list)); + if (!prop) + return -ENOMEM; + adev->mode_info.plane_degamma_tf_property = prop; + return 0; } #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h index d4e609a8b67e..ab9ce6f26c90 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h @@ -382,6 +382,11 @@ struct amdgpu_mode_info { * size of degamma LUT as supported by the driver (read-only). */ struct drm_property *plane_degamma_lut_size_property; + /** + * @plane_degamma_tf_property: Predefined transfer function to + * linearize content with or without LUT. + */ + struct drm_property *plane_degamma_tf_property; #endif }; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index b1d0c65d821d..005632c1c9ec 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h @@ -729,6 +729,13 @@ struct dm_plane_state { * The blob (if not NULL) is an array of &struct drm_color_lut. */ struct drm_property_blob *degamma_lut; + /** + * @degamma_tf: + * + * Predefined transfer function to tell DC driver the input space to + * linearize. + */ + enum drm_transfer_function degamma_tf; #endif }; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c index 7b9d62c70b30..5b458cc0781c 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c @@ -1319,6 +1319,11 @@ static void dm_drm_plane_reset(struct drm_plane *plane) if (amdgpu_state) __drm_atomic_helper_plane_reset(plane, &amdgpu_state->base); + +#ifdef CONFIG_STEAM_DECK + if (amdgpu_state) + amdgpu_state->degamma_tf = DRM_TRANSFER_FUNCTION_DEFAULT; +#endif } static struct drm_plane_state * @@ -1450,6 +1455,19 @@ amdgpu_dm_replace_property_blob_from_id(struct drm_device *dev, return 0; } +static const struct drm_prop_enum_list drm_transfer_function_enum_list[] = { + { DRM_TRANSFER_FUNCTION_DEFAULT, "Default" }, + { DRM_TRANSFER_FUNCTION_SRGB, "sRGB" }, + { DRM_TRANSFER_FUNCTION_BT709, "BT.709" }, + { DRM_TRANSFER_FUNCTION_PQ, "PQ (Perceptual Quantizer)" }, + { DRM_TRANSFER_FUNCTION_LINEAR, "Linear" }, + { DRM_TRANSFER_FUNCTION_UNITY, "Unity" }, + { DRM_TRANSFER_FUNCTION_HLG, "HLG (Hybrid Log Gamma)" }, + { DRM_TRANSFER_FUNCTION_GAMMA22, "Gamma 2.2" }, + { DRM_TRANSFER_FUNCTION_GAMMA24, "Gamma 2.4" }, + { DRM_TRANSFER_FUNCTION_GAMMA26, "Gamma 2.6" }, +}; + static void dm_plane_attach_color_mgmt_properties(struct amdgpu_display_manager *dm, struct drm_plane *plane) @@ -1460,6 +1478,9 @@ dm_plane_attach_color_mgmt_properties(struct amdgpu_display_manager *dm, drm_object_attach_property(&plane->base, dm->adev->mode_info.plane_degamma_lut_size_property, MAX_COLOR_LUT_ENTRIES); + drm_object_attach_property(&plane->base, + dm->adev->mode_info.plane_degamma_tf_property, + DRM_TRANSFER_FUNCTION_DEFAULT); } } @@ -1481,6 +1502,11 @@ dm_atomic_plane_set_property(struct drm_plane *plane, &replaced); dm_plane_state->base.color_mgmt_changed |= replaced; return ret; + } else if (property == adev->mode_info.plane_degamma_tf_property) { + if (dm_plane_state->degamma_tf != val) { + dm_plane_state->degamma_tf = val; + dm_plane_state->base.color_mgmt_changed = 1; + } } else { drm_dbg_atomic(plane->dev, "[PLANE:%d:%s] unknown property [PROP:%d:%s]]\n", @@ -1505,6 +1531,8 @@ dm_atomic_plane_get_property(struct drm_plane *plane, if (property == adev->mode_info.plane_degamma_lut_property) { *val = (dm_plane_state->degamma_lut) ? dm_plane_state->degamma_lut->base.id : 0; + } else if (property == adev->mode_info.plane_degamma_tf_property) { + *val = dm_plane_state->degamma_tf; } else { return -EINVAL; }