From patchwork Wed Dec 7 16:07:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13067306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1E61C352A1 for ; Wed, 7 Dec 2022 16:09:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8911D10E3D9; Wed, 7 Dec 2022 16:09:11 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 03B1910E3E2 for ; Wed, 7 Dec 2022 16:09:09 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 906485C018B; Wed, 7 Dec 2022 11:09:08 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 07 Dec 2022 11:09:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670429348; x= 1670515748; bh=Mq5aA9U7Au9SdBfuWfKmxSGYdNinh4Uk6f7mzeVUm/Q=; b=P 3HnIVad3ldAmGacbFk19Z05sKhm666Pnd92ETbHaCLQ+grTy+tupXG8MDAoH2jD9 kkS0fNenD+w+c7uuqd4WZiZaVHpkVr4Bf91VZbG1XOBz6hLarrxJJkN/iSTzmQvj r5OBEJq6SD92WaxYIb1CSrOcTUT+uhJ8vd09hesBegJFEWwDDlRjwmY2CQ5s2N7q t3s5YQyS4GzsmuMhgn1fVCNbI0QBmRt63iIPJAbBe9P4F+FWxq8UwdteV+uNwH85 lRCRs5BQe+XP4aDjmuSmIi2b6UVSij2vsha6GFZolnqsrh58Q8ypdOT2vdZfbj9T zHAtGkcpWGJY0P9341vAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670429348; x= 1670515748; bh=Mq5aA9U7Au9SdBfuWfKmxSGYdNinh4Uk6f7mzeVUm/Q=; b=U E7DqAG5wNvreHLmbQKJLUDqmHNM4ne9xtUZJMLO0IlyZErU6W/rXBR8hUvPNAWp8 QwLPeV2QN5xQJjgBCqqZY61GTo/vwNXh+h7e50l0vlTFqKafLpstu+s6QZbDNVLH CeEDYecA6Fhl5gAuSGPhMTVeX6/8y0oVaiJ8fRxdS+vHGyKfPFtFubPNiH23JBTJ QJleyaGavSAlq70R+VJ1VegoIFDGFGIv2vabaBt7mWPfEmlYA8ttZ97nzSlM6QQn O8tgJVA10TV1flGw7BfOcFgcOXdiW1WLwVlRfaHHW/DUpoabPdLawRa27PPxeWGA XnIyc3wxCfCIMytAgiv9Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpefgffegieetveehffdugfektedvvdfhudeiffdtleehgeduvefgveefleff keffudenucffohhmrghinhepmhgrrhhgihhnshdrthhophenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgv tghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 11:09:07 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 17:07:45 +0100 Subject: [PATCH 1/9] drm/vc4: hdmi: Update all the planes if the TV margins are changed MIME-Version: 1.0 Message-Id: <20221207-rpi-hdmi-improvements-v1-1-6b15f774c13a@cerno.tech> References: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> In-Reply-To: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=1645; i=maxime@cerno.tech; h=from:subject:message-id; bh=XInLZaSZElEYW1YjY5hSU2D+3FpWCp2LOTFzMps4gHo=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTdgVNS1OXe2KQbFTBoy7yX/DpP3vP570eJlPWrfSwXvJE ncu7o5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABNRWMDIcDDd4XkFe9qa2U+ffniu9W HX11DNj7OspUznvJ3rrnpP/QHDP/UNc/aZmO54vk1Wu5l/of0+zi+flzDM3PTrxb8jPiKd59kB X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On VC4, the TV margins on the HDMI connector are implemented by scaling the planes. However, if only the TV margins or the connector are changed by a new state, the planes ending up on that connector won't be. Thus, they won't be updated properly and we'll effectively ignore that change until the next commit affecting these planes. Let's make sure to add all the planes attached to the connector so that we can update them properly. Signed-off-by: Maxime Ripard Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/vc4/vc4_hdmi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 12a00d644b61..0eafaf0b76e5 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -522,6 +522,22 @@ static int vc4_hdmi_connector_atomic_check(struct drm_connector *connector, if (!crtc) return 0; + if (old_state->tv.margins.left != new_state->tv.margins.left || + old_state->tv.margins.right != new_state->tv.margins.right || + old_state->tv.margins.top != new_state->tv.margins.top || + old_state->tv.margins.bottom != new_state->tv.margins.bottom) { + struct drm_crtc_state *crtc_state; + int ret; + + crtc_state = drm_atomic_get_crtc_state(state, crtc); + if (IS_ERR(crtc_state)) + return PTR_ERR(crtc_state); + + ret = drm_atomic_add_affected_planes(state, crtc); + if (ret) + return ret; + } + if (old_state->colorspace != new_state->colorspace || !drm_connector_atomic_hdr_metadata_equal(old_state, new_state)) { struct drm_crtc_state *crtc_state; From patchwork Wed Dec 7 16:07:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13067308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85133C4708E for ; Wed, 7 Dec 2022 16:09:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF0F210E3E6; Wed, 7 Dec 2022 16:09:18 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id F40B310E3D9 for ; Wed, 7 Dec 2022 16:09:10 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 57F075C00A6; Wed, 7 Dec 2022 11:09:10 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 07 Dec 2022 11:09:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670429350; x= 1670515750; bh=px2+MbhbeI+jrnsZ/vqUEifAPSMXpR4NGEBEX3i+hsw=; b=Y CaxLUsx7sbkNkpYxwbVV5dtH3TbJG0pr0L1judfcJdwMCQJzJCnZiIavSMV0g7Ks YyF0gdwyjwrG8q2N12xJsmPVQokQJsajMUdflALXTZKRVAnyeFpcGV2SCDnoFvEq V79ab1iMFu0eCrT6zMrjypZoNueZBiBvenCg7nmpEClMlFr/BmbujZxd8E3VnC3x u3Dn0QB5/qszbtHKgTdimHbu2gbvoNKcibQV9UMz6OigNVMxIrswoqqXyLBRqJ2h vaKQWFvb7Z3XIXoYVYeGTTnzM6rFfhw1XTCEd3NM1j0wEGxOh0+sKJGwuZxHKuAV NIa+wcCDnwzADN9rZQ0LA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670429350; x= 1670515750; bh=px2+MbhbeI+jrnsZ/vqUEifAPSMXpR4NGEBEX3i+hsw=; b=l anFwiR4bWUyMdKHuFjfIMQCTitktsAklfKzRoMPcyJXuMmRlc7VZKWoKmTiPGQB+ dLSNYHA38TqvPt7u1jFmf7hWoASTn0ndYdI5GdGSwLA8F8wNiuzWEI5Q56Rh/f8O 8xvGrVJZYncHbJJFZcCso28KaXesRnt24L1lzCs4579Znz1RG/2XzghORO0cJee9 FMJIuJrclpggKINshV+qLTfYNKYOedP/miEgzm9G+ocvnxii9cUgqUBs130ifRuN gCVoVq3BxWRXZWpK6dNOBRgyXAAXdgMyCsRhvbbCiXXRiOOZD1I6pxHXvGxYr8d+ fhsjsSZXDHWVlBpoP1qBA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdekgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 11:09:09 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 17:07:46 +0100 Subject: [PATCH 2/9] drm/vc4: hdmi: Constify container_of wrappers MIME-Version: 1.0 Message-Id: <20221207-rpi-hdmi-improvements-v1-2-6b15f774c13a@cerno.tech> References: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> In-Reply-To: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=1406; i=maxime@cerno.tech; h=from:subject:message-id; bh=dCH6llKR5UwxqNbbxar32+yc+y4RRk/F+4gf1CbtXyE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTdgV1SruruN33CH23+ET6vpLqMvtVofxOG6dtXczKW7FN Uq+to5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABMRVWVkeCSoY/rAvPPKJk29p7d+3h VrrQ38mDPROPXpxY9ma43PTGD47zP35PuuwqorzNf7lJSuTX4YvHnBq8u/rnI3RcTFq1+dzgEA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" None of our wrappers around container_of to access our objects from the DRM object pointer actually modify the latter. Let's make them const. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index dc3ccd8002a0..023ea64ef006 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -224,13 +224,13 @@ struct vc4_hdmi { }; static inline struct vc4_hdmi * -connector_to_vc4_hdmi(struct drm_connector *connector) +connector_to_vc4_hdmi(const struct drm_connector *connector) { return container_of(connector, struct vc4_hdmi, connector); } static inline struct vc4_hdmi * -encoder_to_vc4_hdmi(struct drm_encoder *encoder) +encoder_to_vc4_hdmi(const struct drm_encoder *encoder) { struct vc4_encoder *_encoder = to_vc4_encoder(encoder); return container_of(_encoder, struct vc4_hdmi, encoder); @@ -244,7 +244,7 @@ struct vc4_hdmi_connector_state { }; static inline struct vc4_hdmi_connector_state * -conn_state_to_vc4_hdmi_conn_state(struct drm_connector_state *conn_state) +conn_state_to_vc4_hdmi_conn_state(const struct drm_connector_state *conn_state) { return container_of(conn_state, struct vc4_hdmi_connector_state, base); } From patchwork Wed Dec 7 16:07:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13067311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6AC4EC352A1 for ; Wed, 7 Dec 2022 16:09:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D9CF10E3E7; Wed, 7 Dec 2022 16:09:25 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFF0410E3E3 for ; Wed, 7 Dec 2022 16:09:12 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 4CBFB5C0178; Wed, 7 Dec 2022 11:09:12 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 07 Dec 2022 11:09:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670429352; x= 1670515752; bh=7vOQ4kY2xlVuqIbP2mOJ++PsRwhZhQVpILcjOtlTWic=; b=G B6R5APPyYEZtroiQFtMXJ9CGldbB0NrOFU2UqqgSjFS0raQrfkhp0M4MiBMRUON7 haBUee1UstM6mR7fbftJBvBiPTBf6CRqf/fQk2jwQwmEKt3+b5FPDvlYlKHfjxWa h7O79Q76x8QAhS7uBl6eainxP0y+CUqMoyWD8PlxZh7k25cnIzaBXscBdGdiYbF3 /KC8kP1Q0gxMsNfCbKuUDef3Gwd90apF89/wzRVrTXF8ZZmWyNrMGBwPj6JV4wgJ uN8IQHdxDUtRbipbd+fJVEnQszOCemsbWrp/F675AuGM6jOryOrkocFemKdfpFii bd7IUPbXyBrYeNg0WLy1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670429352; x= 1670515752; bh=7vOQ4kY2xlVuqIbP2mOJ++PsRwhZhQVpILcjOtlTWic=; b=o 9KHYHuhI/pvdvFmhYGzsGgRSW5vvR+EL8OXIU3p+7eLkEKdNpuUZMCm28hp7oTXd ZCWlWqQqA/mGRbbF3JS7b58xVIptTAzI6nU+T0DtT2ywtQ1v9AbS+jgWeF1KD9mB euwVP2uPM6SHacjPbr+nnqZPDHARdMjLwbOa9m5jWNaWY0gArJe6z62fKVmxSAQi z4h9Yq9t4YyJ9P+lu82zawXECwwFgfX/XVev602NI5Qpsotsb2bpozxq6qKjdWDO JLEoxHynTXfRXN2HYc0xklFfhneTziX56qYEvH36eWARhI+WY7LPheKcm5qEoyIW 2MbdsG+ph6eekcx2GM+Mg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 11:09:11 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 17:07:47 +0100 Subject: [PATCH 3/9] drm/vc4: hdmi: Add Broadcast RGB property to allow override of RGB range MIME-Version: 1.0 Message-Id: <20221207-rpi-hdmi-improvements-v1-3-6b15f774c13a@cerno.tech> References: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> In-Reply-To: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=7949; i=maxime@cerno.tech; h=from:subject:message-id; bh=+kPKqlCCsqLPoCGeW5qfUUrf7WllrgcP3sp7IFnD31o=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTdgX9VDy9zs014Nmuvrmxfxc/KywqebiN4cfBZ64zL/st 7L/b3lHKwiDGxSArpsgSI2y+JO7UrNedbHzzYOawMoEMYeDiFICJXORn+B+yyW/JNKcFKpY1U93Om7 z+Ufb8xQR/w5Vvph5ItLRc87KX4b+XwLMvExo57xbalHN7JWidWzGFuaWw9Uh/Q8bBrGBZTkYA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson Copy Intel's "Broadcast RGB" property semantics to add manual override of the HDMI pixel range for monitors that don't abide by the content of the AVI Infoframe. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 87 ++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_hdmi.h | 15 ++++++++ 2 files changed, 102 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 0eafaf0b76e5..488a4012d422 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -154,6 +154,11 @@ static bool vc4_hdmi_is_full_range_rgb(struct vc4_hdmi *vc4_hdmi, { struct drm_display_info *display = &vc4_hdmi->connector.display_info; + if (vc4_hdmi->broadcast_rgb == VC4_HDMI_BROADCAST_RGB_LIMITED) + return false; + else if (vc4_hdmi->broadcast_rgb == VC4_HDMI_BROADCAST_RGB_FULL) + return true; + return !display->is_hdmi || drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_FULL; } @@ -515,8 +520,12 @@ static int vc4_hdmi_connector_atomic_check(struct drm_connector *connector, { struct drm_connector_state *old_state = drm_atomic_get_old_connector_state(state, connector); + struct vc4_hdmi_connector_state *old_vc4_state = + conn_state_to_vc4_hdmi_conn_state(old_state); struct drm_connector_state *new_state = drm_atomic_get_new_connector_state(state, connector); + struct vc4_hdmi_connector_state *new_vc4_state = + conn_state_to_vc4_hdmi_conn_state(new_state); struct drm_crtc *crtc = new_state->crtc; if (!crtc) @@ -539,6 +548,7 @@ static int vc4_hdmi_connector_atomic_check(struct drm_connector *connector, } if (old_state->colorspace != new_state->colorspace || + old_vc4_state->broadcast_rgb != new_vc4_state->broadcast_rgb || !drm_connector_atomic_hdr_metadata_equal(old_state, new_state)) { struct drm_crtc_state *crtc_state; @@ -552,6 +562,49 @@ static int vc4_hdmi_connector_atomic_check(struct drm_connector *connector, return 0; } +static int vc4_hdmi_connector_get_property(struct drm_connector *connector, + const struct drm_connector_state *state, + struct drm_property *property, + uint64_t *val) +{ + struct drm_device *drm = connector->dev; + struct vc4_hdmi *vc4_hdmi = + connector_to_vc4_hdmi(connector); + struct vc4_hdmi_connector_state *vc4_conn_state = + conn_state_to_vc4_hdmi_conn_state(state); + + if (property == vc4_hdmi->broadcast_rgb_property) { + *val = vc4_conn_state->broadcast_rgb; + } else { + drm_dbg(drm, "Unknown property [PROP:%d:%s]\n", + property->base.id, property->name); + return -EINVAL; + } + + return 0; +} + +static int vc4_hdmi_connector_set_property(struct drm_connector *connector, + struct drm_connector_state *state, + struct drm_property *property, + uint64_t val) +{ + struct drm_device *drm = connector->dev; + struct vc4_hdmi *vc4_hdmi = + connector_to_vc4_hdmi(connector); + struct vc4_hdmi_connector_state *vc4_conn_state = + conn_state_to_vc4_hdmi_conn_state(state); + + if (property == vc4_hdmi->broadcast_rgb_property) { + vc4_conn_state->broadcast_rgb = val; + return 0; + } + + drm_dbg(drm, "Unknown property [PROP:%d:%s]\n", + property->base.id, property->name); + return -EINVAL; +} + static void vc4_hdmi_connector_reset(struct drm_connector *connector) { struct vc4_hdmi_connector_state *old_state = @@ -571,6 +624,7 @@ static void vc4_hdmi_connector_reset(struct drm_connector *connector) new_state->base.max_bpc = 8; new_state->base.max_requested_bpc = 8; new_state->output_format = VC4_HDMI_OUTPUT_RGB; + new_state->broadcast_rgb = VC4_HDMI_BROADCAST_RGB_AUTO; drm_atomic_helper_connector_tv_margins_reset(connector); } @@ -588,6 +642,7 @@ vc4_hdmi_connector_duplicate_state(struct drm_connector *connector) new_state->tmds_char_rate = vc4_state->tmds_char_rate; new_state->output_bpc = vc4_state->output_bpc; new_state->output_format = vc4_state->output_format; + new_state->broadcast_rgb = vc4_state->broadcast_rgb; __drm_atomic_helper_connector_duplicate_state(connector, &new_state->base); return &new_state->base; @@ -598,6 +653,8 @@ static const struct drm_connector_funcs vc4_hdmi_connector_funcs = { .reset = vc4_hdmi_connector_reset, .atomic_duplicate_state = vc4_hdmi_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, + .atomic_get_property = vc4_hdmi_connector_get_property, + .atomic_set_property = vc4_hdmi_connector_set_property, }; static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs = { @@ -606,6 +663,33 @@ static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs = .atomic_check = vc4_hdmi_connector_atomic_check, }; +static const struct drm_prop_enum_list broadcast_rgb_names[] = { + { VC4_HDMI_BROADCAST_RGB_AUTO, "Automatic" }, + { VC4_HDMI_BROADCAST_RGB_FULL, "Full" }, + { VC4_HDMI_BROADCAST_RGB_LIMITED, "Limited 16:235" }, +}; + +static void +vc4_hdmi_attach_broadcast_rgb_property(struct drm_device *dev, + struct vc4_hdmi *vc4_hdmi) +{ + struct drm_property *prop = vc4_hdmi->broadcast_rgb_property; + + if (!prop) { + prop = drm_property_create_enum(dev, DRM_MODE_PROP_ENUM, + "Broadcast RGB", + broadcast_rgb_names, + ARRAY_SIZE(broadcast_rgb_names)); + if (!prop) + return; + + vc4_hdmi->broadcast_rgb_property = prop; + } + + drm_object_attach_property(&vc4_hdmi->connector.base, prop, + VC4_HDMI_BROADCAST_RGB_AUTO); +} + static int vc4_hdmi_connector_init(struct drm_device *dev, struct vc4_hdmi *vc4_hdmi) { @@ -652,6 +736,8 @@ static int vc4_hdmi_connector_init(struct drm_device *dev, if (vc4_hdmi->variant->supports_hdr) drm_connector_attach_hdr_output_metadata_property(connector); + vc4_hdmi_attach_broadcast_rgb_property(dev, vc4_hdmi); + drm_connector_attach_encoder(connector, encoder); return 0; @@ -1690,6 +1776,7 @@ static void vc4_hdmi_encoder_atomic_mode_set(struct drm_encoder *encoder, mutex_lock(&vc4_hdmi->mutex); drm_mode_copy(&vc4_hdmi->saved_adjusted_mode, &crtc_state->adjusted_mode); + vc4_hdmi->broadcast_rgb = vc4_state->broadcast_rgb; vc4_hdmi->output_bpc = vc4_state->output_bpc; vc4_hdmi->output_format = vc4_state->output_format; mutex_unlock(&vc4_hdmi->mutex); diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index 023ea64ef006..d423f175339f 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -117,6 +117,12 @@ enum vc4_hdmi_output_format { VC4_HDMI_OUTPUT_YUV420, }; +enum vc4_hdmi_broadcast_rgb { + VC4_HDMI_BROADCAST_RGB_AUTO, + VC4_HDMI_BROADCAST_RGB_FULL, + VC4_HDMI_BROADCAST_RGB_LIMITED, +}; + /* General HDMI hardware state. */ struct vc4_hdmi { struct vc4_hdmi_audio audio; @@ -129,6 +135,8 @@ struct vc4_hdmi { struct delayed_work scrambling_work; + struct drm_property *broadcast_rgb_property; + struct i2c_adapter *ddc; void __iomem *hdmicore_regs; void __iomem *hd_regs; @@ -221,6 +229,12 @@ struct vc4_hdmi { * for use outside of KMS hooks. Protected by @mutex. */ enum vc4_hdmi_output_format output_format; + + /** + * @broadcast_rgb: Copy of @vc4_connector_state.broadcast_rgb + * for use outside of KMS hooks. Protected by @mutex. + */ + enum vc4_hdmi_broadcast_rgb broadcast_rgb; }; static inline struct vc4_hdmi * @@ -241,6 +255,7 @@ struct vc4_hdmi_connector_state { unsigned long long tmds_char_rate; unsigned int output_bpc; enum vc4_hdmi_output_format output_format; + int broadcast_rgb; }; static inline struct vc4_hdmi_connector_state * From patchwork Wed Dec 7 16:07:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13067312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D91EBC4708E for ; Wed, 7 Dec 2022 16:09:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E9B7410E3E5; Wed, 7 Dec 2022 16:09:26 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0533210E3E2 for ; Wed, 7 Dec 2022 16:09:15 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 60D8C5C00C5; Wed, 7 Dec 2022 11:09:14 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 07 Dec 2022 11:09:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670429354; x= 1670515754; bh=wOH8b02xWJ0mRQcHqZZQHEuSYyhICsE6ixqlZb6HdKs=; b=n ZjRCRXSXFDQcGdh9cZ7f93KRo2hSU5HpiluUE1BpSQAazB/QdOS4nrisMgMYpEDO UcmCKOekw2iPJW9jBQugsSNUFnJPgTAnnb3kE1aVY6eeA5GQlQUEP00oyYroZWTs O+Ewh7wM/8uFnXpK+7G4LDe4ryY6Gob3BX6Ae+HGrZnsYTR4f5EDaB/jGDLIRBSe Qh+daFX9nyMigC2rTuLoqFCNHYag7ygZE6qBRD7oyO21Y5o302sWQ9sLlUEhHhky 9LZA37GQiDAFHNy89PUkRAQqg6nhXzU1xQT+Exqu8CfbSh7L8UzAf/5//3eptHY5 hvn+5F0sBfSKaL6d26rJw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670429354; x= 1670515754; bh=wOH8b02xWJ0mRQcHqZZQHEuSYyhICsE6ixqlZb6HdKs=; b=X VTpAOgL3rJmqLfBe801kzt+97X4nUTYMGH/80eXEwO4+PFouyxotZu5y6rdZFLsv SDof97mDYVmRyWGfuemlTsXMovgMNPCvZLjnavsvbgCaGcyAY4EqwgmxUTmBNu6W HGlrtlPaVFz9GVE8ZLrMb/Xla1MeZ+BwnMu6c8i6THPUCQeXSyhAKYMJDDbItTfO Psq15og/cLLGugi9ogyJN7tN6MmeoMsrQZGMXzyb/6uPLsl2VfFnWcD3VHANN+H9 BlbbRg3xCtj2ZoT5Q4yJ35iNslczB1vWdBSF6fFEWzQFZxs3BJiHU2wW1dNpbAIH cKZ2rmxuc8EPMQDtSHsQg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdekgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 11:09:13 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 17:07:48 +0100 Subject: [PATCH 4/9] drm/vc4: hdmi: Rename full range helper MIME-Version: 1.0 Message-Id: <20221207-rpi-hdmi-improvements-v1-4-6b15f774c13a@cerno.tech> References: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> In-Reply-To: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=2384; i=maxime@cerno.tech; h=from:subject:message-id; bh=vvagXCydGCs7AAmT7tK7VEtuwCOyOXRnqiXl7KI3dvs=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTdgXdrNgfPKvm5vyJG9b+UJjzcNnR30z7zy07W6jz8laN 7ml93Y5SFgYxLgZZMUWWGGHzJXGnZr3uZOObBzOHlQlkCAMXpwBMZBoPI8ParTlfz1wsMHy3xnvnW5 fWg/unfV6V4yK74eClnOnBarnzGRkuOCe8+r9rE+PhhoBFyYIv1p7L/rp7V7T+ibfv5rprWTHzAAA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson The VC4 HDMI driver has a helper function to figure out whether full range or limited range RGB is being used called vc4_hdmi_is_full_range_rgb(). We'll need it to support other colorspaces, so let's rename it to vc4_hdmi_is_full_range(). Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/vc4/vc4_hdmi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 488a4012d422..51469939a8b4 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -149,8 +149,8 @@ static bool vc4_hdmi_mode_needs_scrambling(const struct drm_display_mode *mode, return clock > HDMI_14_MAX_TMDS_CLK; } -static bool vc4_hdmi_is_full_range_rgb(struct vc4_hdmi *vc4_hdmi, - const struct drm_display_mode *mode) +static bool vc4_hdmi_is_full_range(struct vc4_hdmi *vc4_hdmi, + const struct drm_display_mode *mode) { struct drm_display_info *display = &vc4_hdmi->connector.display_info; @@ -892,7 +892,7 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder) drm_hdmi_avi_infoframe_quant_range(&frame.avi, connector, mode, - vc4_hdmi_is_full_range_rgb(vc4_hdmi, mode) ? + vc4_hdmi_is_full_range(vc4_hdmi, mode) ? HDMI_QUANTIZATION_RANGE_FULL : HDMI_QUANTIZATION_RANGE_LIMITED); drm_hdmi_avi_infoframe_colorimetry(&frame.avi, cstate); @@ -1145,7 +1145,7 @@ static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, csc_ctl = VC4_SET_FIELD(VC4_HD_CSC_CTL_ORDER_BGR, VC4_HD_CSC_CTL_ORDER); - if (!vc4_hdmi_is_full_range_rgb(vc4_hdmi, mode)) { + if (!vc4_hdmi_is_full_range(vc4_hdmi, mode)) { /* CEA VICs other than #1 requre limited range RGB * output unless overridden by an AVI infoframe. * Apply a colorspace conversion to squash 0-255 down @@ -1298,7 +1298,7 @@ static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, case VC4_HDMI_OUTPUT_RGB: if_xbar = 0x354021; - if (!vc4_hdmi_is_full_range_rgb(vc4_hdmi, mode)) + if (!vc4_hdmi_is_full_range(vc4_hdmi, mode)) vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_to_limited_rgb); else vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_unity); From patchwork Wed Dec 7 16:07:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13067310 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0221FC4708E for ; Wed, 7 Dec 2022 16:09:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E0C410E3E4; Wed, 7 Dec 2022 16:09:24 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id E77A410E3E4 for ; Wed, 7 Dec 2022 16:09:16 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 502FB5C018F; Wed, 7 Dec 2022 11:09:16 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 07 Dec 2022 11:09:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670429356; x= 1670515756; bh=nzYXVlpHr4DJEniOQFydXkuv2oHucdJP3nm3LsVi7Wg=; b=c aji4xJiESE4sWG1qqfVNzHZJmcLRaGZPSu1L/m5MRBqef9QOjSJO4UBgGLtpt7sZ RjscuSTIkVho93yh6AapcbfwdTimKok0+03k460+mmIHqvrM8kFXFNAg2sqEM087 um2/QDrsIygN5cj/D4HwwfKDf0yOCwm2zclL5uhXJXK1MY6FA6BUQVyhzA3kipAQ fq6MfOgWM5h0jWlb/QyhtGVlRroNMxkBVc2GoQ0Y5O71I3i242+3GQyI/HieVodt 9xro4GndnsD76M8C2DELUmCEGAFkOW7nSVAh5ascCutrkMMWg0CBgey5VZTMCS3m F4WPU7zftAg8ZfsKxPKoA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670429356; x= 1670515756; bh=nzYXVlpHr4DJEniOQFydXkuv2oHucdJP3nm3LsVi7Wg=; b=w WYx8Bpss8nIwjHu69NP2rtZ0AyYXQpmpUiXnPQ08LDc7aRt5IT0E9xYnKeMboS/A RV5Y5r5O1cgnGdVlLoCNKIgsz5APfD95h3f5yjS3w8/mU3HMjQ7ugwuj2mlGU7Gf 3VFm0UEhOjLAL0zbOzgXM1iXtsVAW7ZGo/BdbL0X20weyphj8jHtr3sfvpw1HAWl Is5p766dEfN0JCdX2gAxVve7e4GqXHbi55M1nOnfptZzG6wp7S5DF8fQsvYlbCsb G1T7+YhbKLWOyUVEDpUbpogTtwDHIwunFxTkiqhSe9bUiGx6uoAjlwkAMs5z8/pA sZ/kGlMdKS18OpBqi6/zA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 11:09:15 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 17:07:49 +0100 Subject: [PATCH 5/9] drm/vc4: hdmi: Rework the CSC matrices organization MIME-Version: 1.0 Message-Id: <20221207-rpi-hdmi-improvements-v1-5-6b15f774c13a@cerno.tech> References: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> In-Reply-To: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=6415; i=maxime@cerno.tech; h=from:subject:message-id; bh=G1kYxw4a/X7kQqYgZh8cknQwFpSgW5utRkEkpGJILs4=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTdgV9y4zdJ/v/y/2z7qL7bp77qCV9LN801c15on/KSfsK piMnO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRzbcZGWZk2L0z5FKcbuTQYLPRce PNz45rt52e3BZcf7mu6dbCRe8Y/iltiX9zs/How6jTk8y/8D8Mennf0nX/qUruE1sUTj8TKeUBAA== X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson The CSC matrices were stored as separate matrix for each colorspace, and if we wanted a limited or full RGB output. This created some gaps in our support and we would not always pick the relevant matrix. Let's rework our data structure to store one per colorspace, and then a matrix for limited range and one for full range. This makes us add a new matrix to support full range BT709 YUV output, and drops the redundant (but somehow different) BT709 YUV444 vs YUV422 matrix. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 124 +++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 61 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 51469939a8b4..299a8fe7a2ae 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1178,68 +1178,72 @@ static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, } /* - * If we need to output Full Range RGB, then use the unity matrix + * Matrices for (internal) RGB to RGB output. * - * [ 1 0 0 0] - * [ 0 1 0 0] - * [ 0 0 1 0] - * - * Matrix is signed 2p13 fixed point, with signed 9p6 offsets - */ -static const u16 vc5_hdmi_csc_full_rgb_unity[3][4] = { - { 0x2000, 0x0000, 0x0000, 0x0000 }, - { 0x0000, 0x2000, 0x0000, 0x0000 }, - { 0x0000, 0x0000, 0x2000, 0x0000 }, -}; - -/* - * CEA VICs other than #1 require limited range RGB output unless - * overridden by an AVI infoframe. Apply a colorspace conversion to - * squash 0-255 down to 16-235. The matrix here is: - * - * [ 0.8594 0 0 16] - * [ 0 0.8594 0 16] - * [ 0 0 0.8594 16] - * - * Matrix is signed 2p13 fixed point, with signed 9p6 offsets + * Matrices are signed 2p13 fixed point, with signed 9p6 offsets */ -static const u16 vc5_hdmi_csc_full_rgb_to_limited_rgb[3][4] = { - { 0x1b80, 0x0000, 0x0000, 0x0400 }, - { 0x0000, 0x1b80, 0x0000, 0x0400 }, - { 0x0000, 0x0000, 0x1b80, 0x0400 }, +static const u16 vc5_hdmi_csc_full_rgb_to_rgb[2][3][4] = { + { + /* + * Full range - unity + * + * [ 1 0 0 0] + * [ 0 1 0 0] + * [ 0 0 1 0] + */ + { 0x2000, 0x0000, 0x0000, 0x0000 }, + { 0x0000, 0x2000, 0x0000, 0x0000 }, + { 0x0000, 0x0000, 0x2000, 0x0000 }, + }, + { + /* + * Limited range + * + * CEA VICs other than #1 require limited range RGB + * output unless overridden by an AVI infoframe. Apply a + * colorspace conversion to squash 0-255 down to 16-235. + * The matrix here is: + * + * [ 0.8594 0 0 16] + * [ 0 0.8594 0 16] + * [ 0 0 0.8594 16] + */ + { 0x1b80, 0x0000, 0x0000, 0x0400 }, + { 0x0000, 0x1b80, 0x0000, 0x0400 }, + { 0x0000, 0x0000, 0x1b80, 0x0400 }, + }, }; /* - * Conversion between Full Range RGB and Full Range YUV422 using the - * BT.709 Colorspace - * - * - * [ 0.181906 0.611804 0.061758 16 ] - * [ -0.100268 -0.337232 0.437500 128 ] - * [ 0.437500 -0.397386 -0.040114 128 ] - * - * Matrix is signed 2p13 fixed point, with signed 9p6 offsets - */ -static const u16 vc5_hdmi_csc_full_rgb_to_limited_yuv422_bt709[3][4] = { - { 0x05d2, 0x1394, 0x01fa, 0x0400 }, - { 0xfccc, 0xf536, 0x0e00, 0x2000 }, - { 0x0e00, 0xf34a, 0xfeb8, 0x2000 }, -}; - -/* - * Conversion between Full Range RGB and Full Range YUV444 using the - * BT.709 Colorspace - * - * [ -0.100268 -0.337232 0.437500 128 ] - * [ 0.437500 -0.397386 -0.040114 128 ] - * [ 0.181906 0.611804 0.061758 16 ] + * Conversion between Full Range RGB and YUV using the BT.709 Colorspace * - * Matrix is signed 2p13 fixed point, with signed 9p6 offsets + * Matrices are signed 2p13 fixed point, with signed 9p6 offsets */ -static const u16 vc5_hdmi_csc_full_rgb_to_limited_yuv444_bt709[3][4] = { - { 0xfccc, 0xf536, 0x0e00, 0x2000 }, - { 0x0e00, 0xf34a, 0xfeb8, 0x2000 }, - { 0x05d2, 0x1394, 0x01fa, 0x0400 }, +static const u16 vc5_hdmi_csc_full_rgb_to_yuv_bt709[2][3][4] = { + { + /* + * Full Range + * + * [ 0.212600 0.715200 0.072200 0 ] + * [ -0.114572 -0.385428 0.500000 128 ] + * [ 0.500000 -0.454153 -0.045847 128 ] + */ + { 0x06ce, 0x16e3, 0x024f, 0x0000 }, + { 0xfc56, 0xf3ac, 0x1000, 0x2000 }, + { 0x1000, 0xf179, 0xfe89, 0x2000 }, + }, + { + /* + * Limited Range + * + * [ 0.181906 0.611804 0.061758 16 ] + * [ -0.100268 -0.337232 0.437500 128 ] + * [ 0.437500 -0.397386 -0.040114 128 ] + */ + { 0x05d2, 0x1394, 0x01fa, 0x0400 }, + { 0xfccc, 0xf536, 0x0e00, 0x2000 }, + { 0x0e00, 0xf34a, 0xfeb8, 0x2000 }, + }, }; static void vc5_hdmi_set_csc_coeffs(struct vc4_hdmi *vc4_hdmi, @@ -1262,6 +1266,7 @@ static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, struct drm_device *drm = vc4_hdmi->connector.dev; struct vc4_hdmi_connector_state *vc4_state = conn_state_to_vc4_hdmi_conn_state(state); + unsigned int lim_range = vc4_hdmi_is_full_range(vc4_hdmi, mode) ? 0 : 1; unsigned long flags; u32 if_cfg = 0; u32 if_xbar = 0x543210; @@ -1277,7 +1282,7 @@ static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, switch (vc4_state->output_format) { case VC4_HDMI_OUTPUT_YUV444: - vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_to_limited_yuv444_bt709); + vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_to_yuv_bt709[lim_range]); break; case VC4_HDMI_OUTPUT_YUV422: @@ -1292,16 +1297,13 @@ static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, if_cfg |= VC4_SET_FIELD(VC5_DVP_HT_VEC_INTERFACE_CFG_SEL_422_FORMAT_422_LEGACY, VC5_DVP_HT_VEC_INTERFACE_CFG_SEL_422); - vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_to_limited_yuv422_bt709); + vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_to_yuv_bt709[lim_range]); break; case VC4_HDMI_OUTPUT_RGB: if_xbar = 0x354021; - if (!vc4_hdmi_is_full_range(vc4_hdmi, mode)) - vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_to_limited_rgb); - else - vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_unity); + vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_to_rgb[lim_range]); break; default: From patchwork Wed Dec 7 16:07:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13067309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C7CFC63703 for ; Wed, 7 Dec 2022 16:09:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A2CE910E3E3; Wed, 7 Dec 2022 16:09:23 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD10F10E3E3 for ; Wed, 7 Dec 2022 16:09:18 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 326A15C0154; Wed, 7 Dec 2022 11:09:18 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 07 Dec 2022 11:09:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670429358; x= 1670515758; bh=aU3+SAGNsaXTIACYBbikYt5EqyP0a5oCez925jVkFE4=; b=J 2ChyCnA2225kuUEj6xBgak1VxM4FF3b3EAwTiuRS9A6ffLxm2Jg8o//EDv+/dExx 579xkMQVm5XtCZgZqCXAteYeKtFJ7Q2WQQOhg+QISpWo9KNNEk4+7Ksq/1oCfgOq 5BHQi7L1iF2s9Bd0GM7cAEBSVGAp9jyzWKGNq2vMWRD8P/bukehW7z/6AGLP12dw bMAQ3y58vJ85ier0RMKuewR+IgpJvlsg3fN3ZpQMpMc3pHtFdOD/t+kT7Hq3vO0y qfU71BSNDerBcAHMHUrL05wDemPAReHG6wUE6jOH/pkUmNoDI9qH0Vee/xmTGfPV AmfXBAdr7U+sr8Su22UGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670429358; x= 1670515758; bh=aU3+SAGNsaXTIACYBbikYt5EqyP0a5oCez925jVkFE4=; b=d VCvYLmSr9I+7Mk70730rJXmpEHXudXrNEFo35GtIxKnxJVob4qO3uoO3JZUmSAc3 hPGfwvBXEJDlLyZ5x+Xvr/QfUnQGnM6xxcRPT1WE2bHn4/itfbNNENAr1YwV7WxK MhIoLBhWES1j3cOOjZzCTzrczBF4ou88B6plZNA0b42o2s5N7c/bXpPY3DLkxaGv VMtcNkS23a9mkLdvlIMSWn30FUCPrUCm11DTGtqLbjWzqDRQB+BTyolRAmIXEoh5 o9XKm9sKYCdQKGTqhPbT+45Vf3x9i3CJd4XqKloC2t8fpYhBdGBoconDChWLUynE 3Cmiefqccfn47qou4zD5w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdekgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 11:09:17 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 17:07:50 +0100 Subject: [PATCH 6/9] drm/vc4: hdmi: Swap CSC matrix channels for YUV444 MIME-Version: 1.0 Message-Id: <20221207-rpi-hdmi-improvements-v1-6-6b15f774c13a@cerno.tech> References: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> In-Reply-To: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=1941; i=maxime@cerno.tech; h=from:subject:message-id; bh=PjOw181ve0z7NoRfNls2DdNyUoLxdXweXksOmPbbBG8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTdgWp3Z8faOn3KUxnnUda5jPha3pPXx+9HHJ8Q8y0+Wtl exfv6yhlYRDjYpAVU2SJETZfEndq1utONr55MHNYmUCGMHBxCsBEZvUz/C8rkLhZxr6mOu+K9gXF5x Gh7rf/zBfe4H7IqfDwh3k+dtsY/teWXvksp3W3O/eVrrJ6wvvWGpbDLPNcnywq/iTGUmC/ghkA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson YUV444 requires the matrix coefficients to be programmed in a different way than the other formats. Let's add a function to program it properly. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/vc4/vc4_hdmi.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 299a8fe7a2ae..cb92d07680f0 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1259,6 +1259,20 @@ static void vc5_hdmi_set_csc_coeffs(struct vc4_hdmi *vc4_hdmi, HDMI_WRITE(HDMI_CSC_34_33, (coeffs[2][3] << 16) | coeffs[2][2]); } +static void vc5_hdmi_set_csc_coeffs_swap(struct vc4_hdmi *vc4_hdmi, + const u16 coeffs[3][4]) +{ + lockdep_assert_held(&vc4_hdmi->hw_lock); + + /* YUV444 needs the CSC matrices using the channels in a different order */ + HDMI_WRITE(HDMI_CSC_12_11, (coeffs[2][1] << 16) | coeffs[2][0]); + HDMI_WRITE(HDMI_CSC_14_13, (coeffs[2][3] << 16) | coeffs[2][2]); + HDMI_WRITE(HDMI_CSC_22_21, (coeffs[0][1] << 16) | coeffs[0][0]); + HDMI_WRITE(HDMI_CSC_24_23, (coeffs[0][3] << 16) | coeffs[0][2]); + HDMI_WRITE(HDMI_CSC_32_31, (coeffs[1][1] << 16) | coeffs[1][0]); + HDMI_WRITE(HDMI_CSC_34_33, (coeffs[1][3] << 16) | coeffs[1][2]); +} + static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, struct drm_connector_state *state, const struct drm_display_mode *mode) @@ -1282,7 +1296,8 @@ static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, switch (vc4_state->output_format) { case VC4_HDMI_OUTPUT_YUV444: - vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_to_yuv_bt709[lim_range]); + vc5_hdmi_set_csc_coeffs_swap(vc4_hdmi, + vc5_hdmi_csc_full_rgb_to_yuv_bt709[lim_range]); break; case VC4_HDMI_OUTPUT_YUV422: From patchwork Wed Dec 7 16:07:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13067313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 318BAC4708E for ; Wed, 7 Dec 2022 16:09:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D74110E3E8; Wed, 7 Dec 2022 16:09:44 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id A53A210E3E3 for ; Wed, 7 Dec 2022 16:09:20 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 0AB795C00D4; Wed, 7 Dec 2022 11:09:20 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 07 Dec 2022 11:09:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670429360; x= 1670515760; bh=VANsvsLz3xnVIYxpgJjZLKq+5JcSs2mZ7cYzZ7vM/6c=; b=b H2bT59MZI6UEavku6zf6hrDgDiCyinlPOlRsZe4isagAWVAYOqMuVoA5trznEEfk Yv5YMmC7BxJq/PJ/8PHQ7CbNyktc3SXgcUmad+B+WO0ZFt9KwWy4eIA2ijObjQO3 RN5wcwymOjc2pa9h96mktqAA+a5l8rVR9knwpCzE9lgyOV6QrodzzSbEgxXRHFqD POv3XE6c9K2dVZCo+GsPBEFLhHuWp1JEW1VgpYzS5O9zGPuRyXE2cFlZG1iq8p7W 8tJD4VsJhr1vp/ZmBz/MI/yvw3JzzDSCFnG5jlxAMkuWKb9KA875BCju+lU+yqA1 uSmYZKFm+ogNniC4c3nEw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670429360; x= 1670515760; bh=VANsvsLz3xnVIYxpgJjZLKq+5JcSs2mZ7cYzZ7vM/6c=; b=O 2ESWZHo5gccbRd1u91NFcyZrreNEK44zT4xL7c/vgtI3noUsGVh4FFrOqOK4iw4r 7sMcHiLx19IFbUGGb12AQzzM1isX/jrJdf/zTs5By9dClA2WG6ulcR/lDO8BYhBX i2HMdsWPpulBs9M79XIZaVY2cC/XYwi7/SBEXUSHRcecxBKr0yC9jxRWL2RE8iaq WT7ux3SvSvzewG60o0ROFbATt2af1Tw3JmytnNXbrhvH/XKM2QyyPM7BdaFo0J1K C88+UfxNaySbBqR9J+LQL++5GH/pUWiI2IeBekQyP4wEnDJ56+30oRvfUubNyoco 377qr94WVuTUdUQ0zb/tg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdekgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 11:09:19 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 17:07:51 +0100 Subject: [PATCH 7/9] drm/vc4: hdmi: Add a function to retrieve the CSC matrix MIME-Version: 1.0 Message-Id: <20221207-rpi-hdmi-improvements-v1-7-6b15f774c13a@cerno.tech> References: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> In-Reply-To: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=2861; i=maxime@cerno.tech; h=from:subject:message-id; bh=xAmnB0avYsRh5WF1+mP80EaoZr0FJhVVGPCw1ocrG8c=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTdgWvVm95c+vmnI//4vpjc8xXb3r8+8PdA6d/q36Kd7+w a7qNfkcpC4MYF4OsmCJLjLD5krhTs153svHNg5nDygQyhIGLUwAmIhbA8N/9Udiz5eYmvtO2ybVPuv KJg9nr09F1EpPWL/DN//hrRf5jRoZ52x/cMt1+WniHlCxfb7rHnj/dT+7O+6q0dfHrwmPqX1lZAA== X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson The CSC matrix to use depends on the output format, its range and the colorspace. Since we're going to add more colorspaces, let's move the CSC matrix retrieval to a function. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/vc4/vc4_hdmi.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index cb92d07680f0..cd6775429b5e 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1273,6 +1273,20 @@ static void vc5_hdmi_set_csc_coeffs_swap(struct vc4_hdmi *vc4_hdmi, HDMI_WRITE(HDMI_CSC_34_33, (coeffs[1][3] << 16) | coeffs[1][2]); } +static const u16 +(*vc5_hdmi_get_yuv_csc_coeffs(struct vc4_hdmi *vc4_hdmi, u32 colorspace, bool limited))[4] +{ + switch (colorspace) { + default: + case DRM_MODE_COLORIMETRY_NO_DATA: + case DRM_MODE_COLORIMETRY_BT709_YCC: + case DRM_MODE_COLORIMETRY_XVYCC_709: + case DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED: + case DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT: + return vc5_hdmi_csc_full_rgb_to_yuv_bt709[limited]; + } +} + static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, struct drm_connector_state *state, const struct drm_display_mode *mode) @@ -1282,6 +1296,7 @@ static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, conn_state_to_vc4_hdmi_conn_state(state); unsigned int lim_range = vc4_hdmi_is_full_range(vc4_hdmi, mode) ? 0 : 1; unsigned long flags; + const u16 (*csc)[4]; u32 if_cfg = 0; u32 if_xbar = 0x543210; u32 csc_chan_ctl = 0; @@ -1296,11 +1311,16 @@ static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, switch (vc4_state->output_format) { case VC4_HDMI_OUTPUT_YUV444: - vc5_hdmi_set_csc_coeffs_swap(vc4_hdmi, - vc5_hdmi_csc_full_rgb_to_yuv_bt709[lim_range]); + csc = vc5_hdmi_get_yuv_csc_coeffs(vc4_hdmi, state->colorspace, + vc4_hdmi_is_full_range(vc4_hdmi, mode)); + + vc5_hdmi_set_csc_coeffs_swap(vc4_hdmi, csc); break; case VC4_HDMI_OUTPUT_YUV422: + csc = vc5_hdmi_get_yuv_csc_coeffs(vc4_hdmi, state->colorspace, + vc4_hdmi_is_full_range(vc4_hdmi, mode)); + csc_ctl |= VC4_SET_FIELD(VC5_MT_CP_CSC_CTL_FILTER_MODE_444_TO_422_STANDARD, VC5_MT_CP_CSC_CTL_FILTER_MODE_444_TO_422) | VC5_MT_CP_CSC_CTL_USE_444_TO_422 | @@ -1312,7 +1332,7 @@ static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, if_cfg |= VC4_SET_FIELD(VC5_DVP_HT_VEC_INTERFACE_CFG_SEL_422_FORMAT_422_LEGACY, VC5_DVP_HT_VEC_INTERFACE_CFG_SEL_422); - vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_to_yuv_bt709[lim_range]); + vc5_hdmi_set_csc_coeffs(vc4_hdmi, csc); break; case VC4_HDMI_OUTPUT_RGB: From patchwork Wed Dec 7 16:07:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13067315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C183CC4708E for ; Wed, 7 Dec 2022 16:09:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CA4DE10E3EB; Wed, 7 Dec 2022 16:09:49 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7754710E3E3 for ; Wed, 7 Dec 2022 16:09:22 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id CE3655C018B; Wed, 7 Dec 2022 11:09:21 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 07 Dec 2022 11:09:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670429361; x= 1670515761; bh=YHRLmuQhYpWVXrMM0zJgMc8WtAAfUasmH7iyil8sVlg=; b=Q BIQ1OfmHXibD+vIWxQJj8IeuQ0eJRI1lyD2CIfN86rxVJfv+WA1UcDUDXq9Tal6b L0NuDfzknTYOgIcqqMgvaZ4cycHCG/tGbBgfiqrchxHVHHm3iYxTl2tLYYzQMtKv LfuZsVyszV3Gl4+LGm51ODuSIXzJGl+C2MCNf1N824tRYH9y5lpD3uhRIlPxcJ2+ wGU3cbQeZ7C5yA1vXiUBd7anQ5iATJ0GumbJcJSiOpbPHiq8qMn0I0hxA0VpOVAS cbs8SOIw51Xx0W+ZTglhJAdS/WGFjzWhXiLTTlvXKB33csLJCQWYNIGeGhk+4Yyv DKuYnl77ImdRDhvV5txvA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670429361; x= 1670515761; bh=YHRLmuQhYpWVXrMM0zJgMc8WtAAfUasmH7iyil8sVlg=; b=s gG5OWanettho9cIYEbb0lTxRJ8HdaTrAgZ8JkVdTtA/ZAuAoNBtq0eAkJuxBTIzD QZtzfn4OVutL8eG1hJw7pfgSAJ1NBOmCausFWBvT4HCSbRARWAD/LLcwHIicBrup GXZfY8z6MuevjYMHxGcI9P80AtDZMpt9ffNXv+Ju7QeTKp7gwyv2WLPyn6ihHtyB wOMFmSY0xHFsPn4pi6f2z3YkgAH2WNU6BzCQRmzv4ieg2Kh7LzHYIgrH50ifRIP5 3geR5hL2WEXMcY4RVK3ST8QNpO1yw35kZrgcBSSbgH1CcZU+fZIzGcbegnui8YWK S0m+EuzujkLzikjwqXmvg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 11:09:21 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 17:07:52 +0100 Subject: [PATCH 8/9] drm/vc4: hdmi: Add BT.601 Support MIME-Version: 1.0 Message-Id: <20221207-rpi-hdmi-improvements-v1-8-6b15f774c13a@cerno.tech> References: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> In-Reply-To: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=2131; i=maxime@cerno.tech; h=from:subject:message-id; bh=iIbI5HLac1bVrGiMm7IXYnTLI/x/+D9iamG0JUy4yek=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTdgUbLdBY/JRru++U1SzMb1593THxwZXbb+Zv4EvyZuR+ yvPBsaOUhUGMi0FWTJElRth8SdypWa872fjmwcxhZQIZwsDFKQATma7H8D80ybLxv2Ziy+M8tkozG1 e/0DM3Cs5/n56mkN90Z01FmS/DP9PstU3zJm43lJypuzCNc5NQQ+zk9WLtc5rqVeve61+5zgoA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson Even though we report that we support the BT601 Colorspace, we were always using the BT.709 conversion matrices. Let's add the BT601 ones. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/vc4/vc4_hdmi.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index cd6775429b5e..e3428fb2c22d 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1214,6 +1214,37 @@ static const u16 vc5_hdmi_csc_full_rgb_to_rgb[2][3][4] = { }, }; +/* + * Conversion between Full Range RGB and YUV using the BT.601 Colorspace + * + * Matrices are signed 2p13 fixed point, with signed 9p6 offsets + */ +static const u16 vc5_hdmi_csc_full_rgb_to_yuv_bt601[2][3][4] = { + { + /* + * Full Range + * + * [ 0.299000 0.587000 0.114000 0 ] + * [ -0.168736 -0.331264 0.500000 128 ] + * [ 0.500000 -0.418688 -0.081312 128 ] + */ + { 0x0991, 0x12c9, 0x03a6, 0x0000 }, + { 0xfa9b, 0xf567, 0x1000, 0x2000 }, + { 0x1000, 0xf29b, 0xfd67, 0x2000 }, + }, + { + /* Limited Range + * + * [ 0.255785 0.502160 0.097523 16 ] + * [ -0.147644 -0.289856 0.437500 128 ] + * [ 0.437500 -0.366352 -0.071148 128 ] + */ + { 0x082f, 0x1012, 0x031f, 0x0400 }, + { 0xfb48, 0xf6ba, 0x0e00, 0x2000 }, + { 0x0e00, 0xf448, 0xfdba, 0x2000 }, + }, +}; + /* * Conversion between Full Range RGB and YUV using the BT.709 Colorspace * @@ -1277,6 +1308,13 @@ static const u16 (*vc5_hdmi_get_yuv_csc_coeffs(struct vc4_hdmi *vc4_hdmi, u32 colorspace, bool limited))[4] { switch (colorspace) { + case DRM_MODE_COLORIMETRY_SMPTE_170M_YCC: + case DRM_MODE_COLORIMETRY_XVYCC_601: + case DRM_MODE_COLORIMETRY_SYCC_601: + case DRM_MODE_COLORIMETRY_OPYCC_601: + case DRM_MODE_COLORIMETRY_BT601_YCC: + return vc5_hdmi_csc_full_rgb_to_yuv_bt601[limited]; + default: case DRM_MODE_COLORIMETRY_NO_DATA: case DRM_MODE_COLORIMETRY_BT709_YCC: From patchwork Wed Dec 7 16:07:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13067314 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EAD19C63703 for ; Wed, 7 Dec 2022 16:09:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D353210E3E9; Wed, 7 Dec 2022 16:09:44 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4092E10E3E5 for ; Wed, 7 Dec 2022 16:09:24 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 97F9A5C00C5; Wed, 7 Dec 2022 11:09:23 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 07 Dec 2022 11:09:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670429363; x= 1670515763; bh=o3govFPZ9TDXWjhwGjG9dUBjhZnBpew2lQenIBrTic0=; b=L pky/gaTHoHPSiTmxucEilxu9Aucfqj03cabHlZqFv9joCzF4kuw82zwjaSLKSBp7 fW0qrqK+lXUdCq5L82tY5XnSHwivbuew+sAJyv+T7V0O4EAYiUE9L23eefAWROVs Xt3y0c2SUrT05qm57CEPzWq/M/u9lEm+mkO7RN4/sHradi+Ymqd7EglVsxMt/OqO dc6LGQK4zUFdoOO+q05lGNnmXPmHHS3lwz5NPlVh3Ddj0662tMCMUgSmo++wzjJ1 +18nS1a1K11JeN/lSzFpdfBEVu6tx48uffpaPksLbP9VTMw2kphH2QIFxg42OJtT Rmkolgvvto+jX2ZeXY8AA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670429363; x= 1670515763; bh=o3govFPZ9TDXWjhwGjG9dUBjhZnBpew2lQenIBrTic0=; b=C m0a8s3Ykv+j1YiMnCxiI7GH9WWjqFmAji3VOlRJEIfDG+CPxpbEzPTfBmZb8SLGl imi4a7LG58Aou3x9JgeJKWyttHvETaaXUuvE0ImBQ9UcxddvC1Smz7JY7TmjcPlb MfUaZXtDFxNl2+xIsxVbty/mMOJs531vtCWsNgpMl+Hxx7ZlOwy0Kb3YY8508+lA 2wJ+0d6uq6mlRCTtelLvxGWFpSChGRRUo2sa6For8CmbSmG8uwqjkGmhZndN2FYJ HslNFvdeygnQhI0TjvgnREXTYpZJmKJNgvqG6nLh8dV7GcqxbZ0ShQF+NlZNpgex HMULWfeQQrTmubK79ZM1g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 11:09:22 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 17:07:53 +0100 Subject: [PATCH 9/9] drm/vc4: hdmi: Add BT.2020 Support MIME-Version: 1.0 Message-Id: <20221207-rpi-hdmi-improvements-v1-9-6b15f774c13a@cerno.tech> References: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> In-Reply-To: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=2122; i=maxime@cerno.tech; h=from:subject:message-id; bh=7EgvINvx0LZ5GQlV8rxr2sFz+Jzwj1VfMAT/EoLsgRo=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTdgU7T0hc8v+wYqTmitC7ZuIb++csueHh2P9OS45p+Qvp 7dEnO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRQ0wM/6zu6ueol0qsszoQkv1S8C WzfOVF66U3L9ZGxRqsryvmLmP47+27j2Pv756ItwohC7duTG+wSEk3e7y9UkZMUlKkeVUuDwA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson Even though we report that we support the BT.2020 Colorspace, we were always using the BT.709 conversion matrices. Let's add the BT.2020 ones. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/vc4/vc4_hdmi.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index e3428fb2c22d..2734cab34660 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1277,6 +1277,37 @@ static const u16 vc5_hdmi_csc_full_rgb_to_yuv_bt709[2][3][4] = { }, }; +/* + * Conversion between Full Range RGB and YUV using the BT.2020 Colorspace + * + * Matrices are signed 2p13 fixed point, with signed 9p6 offsets + */ +static const u16 vc5_hdmi_csc_full_rgb_to_yuv_bt2020[2][3][4] = { + { + /* + * Full Range + * + * [ 0.262700 0.678000 0.059300 0 ] + * [ -0.139630 -0.360370 0.500000 128 ] + * [ 0.500000 -0.459786 -0.040214 128 ] + */ + { 0x0868, 0x15b2, 0x01e6, 0x0000 }, + { 0xfb89, 0xf479, 0x1000, 0x2000 }, + { 0x1000, 0xf14a, 0xfeb8, 0x2000 }, + }, + { + /* Limited Range + * + * [ 0.224732 0.580008 0.050729 16 ] + * [ -0.122176 -0.315324 0.437500 128 ] + * [ 0.437500 -0.402312 -0.035188 128 ] + */ + { 0x082f, 0x1012, 0x031f, 0x0400 }, + { 0xfb48, 0xf6ba, 0x0e00, 0x2000 }, + { 0x0e00, 0xf448, 0xfdba, 0x2000 }, + }, +}; + static void vc5_hdmi_set_csc_coeffs(struct vc4_hdmi *vc4_hdmi, const u16 coeffs[3][4]) { @@ -1322,6 +1353,13 @@ static const u16 case DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED: case DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT: return vc5_hdmi_csc_full_rgb_to_yuv_bt709[limited]; + + case DRM_MODE_COLORIMETRY_BT2020_CYCC: + case DRM_MODE_COLORIMETRY_BT2020_YCC: + case DRM_MODE_COLORIMETRY_BT2020_RGB: + case DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65: + case DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER: + return vc5_hdmi_csc_full_rgb_to_yuv_bt2020[limited]; } }