From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC6C33ACEFB for ; Sun, 2 Aug 2026 14:35:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785681333; cv=none; b=KucWQJ8QYoJs3DsFLFQba+hcsIDqMyuf2hEG61JPTTPTvnoEGDSQ9ArCv3aa7q1avvOyjBXoMLj5UV3E3rgIZJYEIAjIe3K1QwpgDEnti5y4sJIXl1qtZda3gJOzJyoOr0LriZhvh3ck0ybhwE8Rap4hpTyWJeVqVgjRffA0dzg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785681333; c=relaxed/simple; bh=0lbI9NAFSNMHlqoKLV++JDtAGFqZHgKoxS7qabCEK5I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cL8p8oSs8H9ltY+DexikAPkyjbrOIMvD0ahYpFeAKykiWrfWLQNFvj7l0Kflwp0quxWulIc5orZQ3+OZiU1MMVueKMmTRHc4F1VL+CfgfO/VrYFRkIJO+cHieUm+x9SxYzoCNqaZCFqN/tJDKekgBHTORVoQ54x2Xrys3YSqqGM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lC5vhAi5; arc=none smtp.client-ip=209.85.167.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lC5vhAi5" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-4a46a53abc9so1242177b6e.3 for ; Sun, 02 Aug 2026 07:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785681330; x=1786286130; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=OBwqQBQZ7gr9qfD8QTCGZXfSKgrXALeSbfMpkftaqF8=; b=lC5vhAi5IMAvAg8p5LWVrv5WZidAseROhvBgGmy+KzDnaOr05EkztD1lHVPNAex6Lk m8lmwuz4HdsSQUk8xtIJ07+FKaM7y/JYdEl6dzHoic3Ajvrqc5EsxcEFVStcQS3VpDx9 Ac2ZLrPEQS8XZ07sC7589lifXeSOMyKiT7LvHlNPIBWt1kUSkDXg4bRR0186gaZWVtAC DJiLcH/KEIAj6ILfMDKLEkMlH35Ipncb4Q8brK3BaA8wHpdVqr/Ro8e/uCJ5ULlFurNA /+TO9AIBFNPrrhv2YEL0+VsS1XtQnK2zyIc1ZzWb3uhx31ogqGSXXgbFB346B55PBP29 Bqnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785681330; x=1786286130; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OBwqQBQZ7gr9qfD8QTCGZXfSKgrXALeSbfMpkftaqF8=; b=fKT5TZM1lzeU/Dsf1fB8oLTDjn6JRW1R+WNFz6Z4A6kNSiOCcBP2jVIfkTFQyH3/+w FTFLnpM9jMnWBawJGiCrjIn9A7p/ERPXPqrYNwxqYhpMwBIFnFJpE072YeAk4QVUQMjF V+wEX579OtixbrcymIotPgzLBSuUrR5dM66Io4i5Ajsi53aTOhHVVcq6C5kkfSASMxYc WjwkGP7rZpvC4wAef1OMxzIQS3gvx+yPXZkSY6S6QnFEXroThmxdn1YaMvU6zQLTLSKI b6PcO8l9WyQ4dTK26zx1Ihl2UluABu3MgMhyedSCWqdsZelW+vCiILAtuyBoNSQcTyVg T7yg== X-Forwarded-Encrypted: i=1; AHgh+Rq04rS29NIEimDh+mcKm91+UfKJbeCA7Ca/hMEcxDBiX65L4ASfzKQ7SA9gtAP3A0zH1bzyGBaRPdphEgo=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3i47/1KViEeXL5IwGXTCurHA2faJgJkd71DVRbWZa0ZRq/rXT xlqLM2zE41h2zj8DOcSQvvcM+mEm8roeMZeXpSHwjPHnwPoO0oroHO0P X-Gm-Gg: AR+sD10cEI3Ounb6IYXO2QlSgBVDJbrFdzrBpJAq7w3LS8nN88TxbRpaLQ8cMcegaOC GsoO+VDZZXpJsz/6gwTwWK3FjHz7ckq0kWdzSG6eE7+g2HIX2mE5fXAcDe1JLX/v6j2j54fcYoc 6ZZokVPclmbxPNZ2bQsiCArLQIx8ui1VCl7QR4XWyFRcMYyPnqtDvuBNay08ZhcIXvIcbHV6jPo Mbt+zN8r+5CWsOLifgVPz2Jjq1w+atp9F5jT6wmywg2yLif2FMNYTLGK3+XnFZrzLLyvFJ5moNM mlw6ByvyzUXgMtbgiiXuzm8npgkYcVdc3SbpSb9OI84TxFfj1J1Mr+F8dBdfEzelkcHcCSsv68h Z56IvfXNFe062O0wT69Kq5urUiif9xwNuicI5ywY9tQdumDNHgQYlYs7XoaG8L2xsXvheiixvEP usuGS/88NoNMamDaVvmAQXsDNsqKu1ICic0LdRLIKk1X39Pj9Nrf6cBi9rYpVCIv4940yMF7keC 0zgF57m1VHE+lZr16I6h9mDikLTtN2H3EZD7yzBM6jl X-Received: by 2002:a05:6808:14c1:b0:4a3:58a6:8a57 with SMTP id 5614622812f47-4af5e3a5f51mr11753697b6e.20.1785681330605; Sun, 02 Aug 2026 07:35:30 -0700 (PDT) Received: from natebox2.jabitha.com (46-110-104-162.wmnscoaa.metronetinc.net. [46.110.104.162]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4af58e9551dsm4778877b6e.11.2026.08.02.07.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2026 07:35:30 -0700 (PDT) From: Nathan Lucas To: amd-gfx@lists.freedesktop.org Cc: harry.wentland@amd.com, sunpeng.li@amd.com, siqueira@igalia.com, alexander.deucher@amd.com, joshua@froggi.es, mwen@igalia.com, leorize+oss@disroot.org, alex.hung@amd.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/2] drm/amd/display: fix BT.2020 YCbCr output CSC matrices Date: Sun, 2 Aug 2026 08:35:22 -0600 Message-ID: X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This patch series fixes COLOR_SPACE_YCBCR2020_TYPE in dc_hw_sequencer.c which is used for COLOR_SPACE_2020_YCBCR_LIMITED output but does not have correct luma and chroma scaling for that output range, and fixes its copies in dce_transform.c and dce110_opp_csc_v.c. It looks like this matrix was originally added in commit 40df2f809e8f ("drm/amd/display: color space ycbcr709 support") as a raw BT.2020-NCL RGB to YCbCr conversion matrix that had not yet been prepared for unsigned limited or full-range quantization. Commit 973a9c810c78 ("drm/amd/display: Fix COLOR_SPACE_YCBCR2020_TYPE matrix") applied offsets for unsigned limited-range quantization but did not fix the luma and chroma scales which are still full range. Because of this, output on a calibrated display is too bright with incorrect color, although it still looks roughly correct at low luminance in my testing. Later, in commit 51e6668ab4ba ("drm/amd/display: add missing CSC entries for BT.2020 for DCE IPs"), the incorrect COLOR_SPACE_YCBCR2020_TYPE matrix coefficients were duplicated to DCE COLOR_SPACE_2020_YCBCR_LIMITED and COLOR_SPACE_2020_YCBCR_FULL, so those matrices are also currently incorrect. The first patch adds separate matrices for full and limited-range. The derivation is in the commit message. The second patch replaces the copied matrix coefficients in dce_transform.c and dce110_opp_csc_v.c with the new ones. For testing I have only been able to check the limited-range DCN path on a 9070 XT with a patched kernel. amdgpu_dm_get_output_color_space does not currently have a path to select COLOR_SPACE_2020_YCBCR_FULL although the enum value exists. Also, I cannot test the DCE paths as I do not have the hardware to do so. I ran into this issue measuring PQ test patterns through mpv with the following command line: mpv \ --no-config \ --vo=gpu-next \ --gpu-context=displayvk \ --gpu-api=vulkan \ --vulkan-display-plane=3 \ --vulkan-display-mode=22 \ --target-trc=pq \ --target-prim=bt.2020 \ --target-colorspace-hint-mode=source \ --target-colorspace-hint=yes \ --tone-mapping=clip \ --hdr-compute-peak=no \ [pattern file] Free test patterns: https://diversifiedvideosolutions.com/hdr-10.html Below is a table of values I measured on a Samsung S95H (US model) with a Calibrite Display Pro HL meter. Three sets of meter readings below: Unpatched - Unpatched Fedora 44 kernel 7.1.4-200.fc44.x86_64 Patched - The patches in these e-mails applied to Fedora 44 kernel 7.1.4-200.fc44.x86_64 NVS/Kodi - NVIDIA Shield Pro with Kodi 5% HDR10/PQ Test Pattern Meter Readings (nits) ============== ============================== PQ% Nits Unpatched Patched NVS/Kodi 15 1.01 1.63 1.01 1.02 25 5.24 9.68 5.46 5.12 35 18.78 40 20.5 21.2 45 56.55 128 62.0 62.1 55 148.03 369 155 155 65 384.71 1106 403 401 75 973.13 2681* 1030 1025 * This is at the peak capability for this TV. PQ brightness overtracks a bit in Patched and NVS/Kodi, but that is likely due to the TV's default calibration or my meter since the readings are so similar. Unpatched stands out as being way too bright. Nathan Lucas (2): drm/amd/display: fix BT.2020 YCbCr limited output CSC matrix drm/amd/display: fix BT.2020 YCbCr output CSC matrices for DCE .../drm/amd/display/dc/core/dc_hw_sequencer.c | 31 ++++++++++++------- .../drm/amd/display/dc/dce/dce_transform.c | 7 +++-- .../amd/display/dc/dce110/dce110_opp_csc_v.c | 7 +++-- 3 files changed, 28 insertions(+), 17 deletions(-) -- 2.55.0