Skip to contentSkip to conversation

drm/nouveau: HDMI Deep Color link depth (30/36/48 bpp)

PATCH New Daniel Campos Ramos 1 participant 4 messages Sep 22 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

v2 cover drm/nouveau: HDMI Deep Color link depth (30/36/48 bpp)

This series wires up HDMI Deep Color on nouveau. The connector gains the "max bpc" property, the atomic check selects a link depth that both the sink EDID (HDMI VSDB DC_30/36/48) and the TMDS character-rate budget admit, the head is programmed for 30/36/48 bpp RGB, and the TMDS General Control Packet carries the matching CD/PP fields.

Patch 3 is what makes the link physically work on GSP boards. The GV100-class GCP writers emitted a depth-less packet, and on GSP systems the HDMI audio enable runs after the display commit and emits it again, erasing the deep-color declaration (sor->disp->func->gsp.hdmi_gcp). The proprietary NVIDIA stack performs the same audio operation and then rebuilds the GCP from the committed head depth. Threading CD/PP through the OUTP HDMI ctrl method (patch 2), caching them on the ior, and writing them with a 0x00ffffff mask gives nouveau the same ordering; the mask also keeps generation-specific bits sharing the register intact (GB20x SB1_CTRL).

Tested on a GA106 (RTX 3060) driving a Sony KDL-46HX855 (HDMI 1.4 sink, EDID DC_30/DC_36, 225 MHz TMDS ceiling): 1920x1080p60 RGB at 36 bpp, i.e. a 222.75 MHz character rate. Without the series the sink rejects the modeset with an incompatible-signal OSD; with it the set accepts the signal, reports a 12-bit input, and renders correctly. The v2 30-bpp additions follow the same wire construction (CD/PP encodings per HDMI 1.4b section 6.5.3, with CD=5 verified against the Synopsys dw-hdmi packetizer). The new 30-bpp arm is bench-exercised too: with "max bpc" clamped to 10 the same sink links at 30 bpp and renders correctly, a regression run at the default depth confirms the 36-bpp 12-bit result is unchanged, and 1080p24 frame packing at 12 bpc (a 222.75 MHz link) and side-by-side/top-and-bottom 3D at 12 bpc all display correctly with the sink in 3D. All runs are logged in the bench repository.

Changes in v2 (credit to the automated review mails on v1 for the first two):

- patch 2: encode GCP CD/PP for 30 bpp as well (CD=5, PP from the four-pixel packing group, wire 0 = phase 4 per NVIDIA's phase constant numbering). v1's description already promised 30/36/48 bpp, but the enable path only encoded the 36 and 48-bpp arms; 10 bpc was reachable there and would have declared the default 24 bpp on a 30-bpp wire.
- patch 2: gate SCDC scrambling and the 1:40 TMDS bit clock ratio on the TMDS character rate (pixel clock scaled by depth), not the raw pixel clock, per the HDMI 2.0 340 MHz character-rate rule. The OUTP HDMI ctrl khz argument stays the pixel clock on purpose: measured on the bench, the 36-bpp link trained at the correct 222.75 MHz character rate, so the sequencer derives the scaling itself.
- patches 1 and 2: rate frame-packed 3D modes at the link clock, twice the mode clock, in the depth selection and the SCDC gate, as nouveau_connector_mode_valid() already does. v1 used the per-eye clock, which could pick a depth the link cannot carry; found reading the bench logs, harmless on the test sink.
- patch 1 (no code change): the "max bpc" property stays attached to HDMI-A connectors only, matching i915. Extending it to DVI connectors that feed HDMI sinks through passive adapters belongs with the follow-on series below, which does it; DP++ adapters stay open.

Scope and non-goals, so nobody has to guess:

- Only RGB is selected. YCbCr output additionally needs a connector color-format selection path that nouveau does not have today, plus AVI InfoFrame colorspace/range handling and format-aware bandwidth and packing. That is a follow-on series built on this one, using the DRM "color format" and "Broadcast RGB" properties (limited/full RGB, YCbCr 4:4:4, 4:2:2 and 4:2:0), sent separately.
- 48 bpp (16 bpc) is implemented from DC_48, BPP_48_444 and GCP CD=7 but is untested: the bench has no DC_48 sink. It might enable professional 16-bit displays; the mechanism is the same, but we do not own the hardware to test or claim it.
- HDR might benefit: HDR10's baseline transport is 10-bpc YCbCr 4:2:2 carried in a 12-bpc container, and link-depth failures feature in HDR reports. The transport mechanism is the same, but we do not have hardware to test or claim native HDR here (static metadata and colorspace are separate pieces nouveau does not yet emit for HDMI).

For context: on this same bench the installed proprietary NVIDIA driver (615.71.09, hdmi_deepcolor=Y, max_output_color_depth=10) caps this sink at 10 bpc by default policy, while Windows on the same card reports 12 bpc; with the parameter lifted to 12 the stock Linux driver drives this sink at 12 bpc too. A companion one-line default-cap change for the open NVIDIA kernel modules is in that repository as the closed-source counterpart of this series.

Related items from the same diagnosis, for maintainers who want the full EDID-surface picture on the proprietary stack: NVIDIA's repository tracks three measured symptoms of the same narrowing at
https://github.com/NVIDIA/open-gpu-kernel-modules/issues/1384 (plus the HDMI 1.4 3D VSDB sibling at .../issues/1382), with the one-line default-cap companion PR at .../pull/1386. Nothing there blocks this series; it is the same disease seen from the other driver.

Normative chain this series is built and measured against: HDMI 1.4b section 6.5.3 (General Control Packet CD/PP encodings), HDMI 2.0a (340 MHz character-rate scrambling and clock-ratio rule), CTA-861-G (EDID VSDB Deep Color capability bits), NVIDIA's public nvtiming.h and display-class headers, and the in-tree Synopsys dw-hdmi packetizer, which implements the same CD table with the same section citation. The reproducible bench harness, EDID dumps and test logs live at
https://github.com/danielcamposramos/sony-bravia-linux (tools/stereo-modeset); the curated public evidence indexes are
https://github.com/danielcamposramos/awesome-stereoscopy and
https://github.com/danielcamposramos/awesome-linux-hdr.

AI partners were leveraged in the production of this work.

Daniel Campos Ramos (3):
drm/nouveau: select HDMI deep-color link depth drm/nouveau: pass HDMI GCP deep-color state through NVIF drm/nouveau: program HDMI deep-color GCP fields

 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 110 ++++++++++++++++--
 drivers/gpu/drm/nouveau/dispnv50/headc37d.c   |   6 +
 drivers/gpu/drm/nouveau/dispnv50/headc57d.c   |   6 +
 drivers/gpu/drm/nouveau/dispnv50/headca7d.c   |   6 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h |   3 +
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |   2 +-
 drivers/gpu/drm/nouveau/nouveau_connector.c   |   9 +-
 drivers/gpu/drm/nouveau/nouveau_connector.h   |   1 +
 drivers/gpu/drm/nouveau/nvif/outp.c           |   7 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gb202.c  |  12 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gv100.c  |   4 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/ior.h    |   2 +
 .../gpu/drm/nouveau/nvkm/engine/disp/tu102.c  |   4 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  |   6 +
 14 files changed, 157 insertions(+), 21 deletions(-)
Signature · 1 line
2.53.0
#2 lore raw

PATCH v2 1/3 drm/nouveau: select HDMI deep-color link depth

Nouveau currently initializes the output depth from the EDID basic display parameters and does not expose a max bpc property on HDMI connectors. As a result, HDMI deep-color modes advertised by the VSDB are never selected.

Attach an 8..16 max bpc property. Select 10, 12 or 16 bpc only when the sink advertises the corresponding RGB 4:4:4 deep-color mode and the resulting TMDS character rate fits the existing link limit. Program the matching head output-resource depth on NVDisplay.

Share the existing TMDS bandwidth helper with the atomic check so the depth selection observes both sink and GPU limits.

---
 drivers/gpu/drm/nouveau/dispnv50/disp.c     | 70 ++++++++++++++++++++-
 drivers/gpu/drm/nouveau/dispnv50/headc37d.c |  6 ++
 drivers/gpu/drm/nouveau/dispnv50/headc57d.c |  6 ++
 drivers/gpu/drm/nouveau/dispnv50/headca7d.c |  6 ++
 drivers/gpu/drm/nouveau/nouveau_connector.c |  9 ++-
 drivers/gpu/drm/nouveau/nouveau_connector.h |  1 +
 6 files changed, 93 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +68 -2
index add19d479ebe..028512f8767b 100644
@@ -374,11 +374,26 @@ nv50_outp_atomic_check_view(struct drm_encoder *encoder,
 	return 0;
 }
 
+/* Pixel clock on the link.  Frame packing sends both eyes, doubling the mode
+ * clock; drm_mode_set_crtcinfo() applies the same doubling to crtc_clock, but
+ * only once the head's atomic check has run.
+ */
+static unsigned int
+nv50_outp_link_clock(const struct drm_display_mode *mode)
+{
+	if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING)
+		return mode->clock * 2;
+
+	return mode->clock;
+}
+
 static void
-nv50_outp_atomic_fix_depth(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state)
+nv50_outp_atomic_fix_depth(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state,
+			   struct drm_connector_state *conn_state)
 {
 	struct nv50_head_atom *asyh = nv50_head_atom(crtc_state);
 	struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
+	struct drm_connector *connector = conn_state->connector;
 	struct drm_display_mode *mode = &asyh->state.adjusted_mode;
 	unsigned int max_rate, mode_rate;
 
@@ -398,6 +413,36 @@ nv50_outp_atomic_fix_depth(struct drm_encoder *encoder, struct drm_crtc_state *c
 			asyh->or.bpc -= 2;
 		}
 		break;
+	case DCB_OUTPUT_TMDS:
+		if (!connector->display_info.is_hdmi)
+			break;
+
+		max_rate = nouveau_connector_get_tmds_link_bandwidth(connector);
+		asyh->or.bpc = 8;
+
+		if (conn_state->max_requested_bpc >= 16 &&
+		    connector->display_info.edid_hdmi_rgb444_dc_modes & DRM_EDID_HDMI_DC_48) {
+			mode_rate = DIV_ROUND_UP(nv50_outp_link_clock(mode) * 16, 8);
+			if (mode_rate <= max_rate)
+				asyh->or.bpc = 16;
+		}
+
+		if (asyh->or.bpc == 8 && conn_state->max_requested_bpc >= 12 &&
+		    connector->display_info.edid_hdmi_rgb444_dc_modes & DRM_EDID_HDMI_DC_36) {
+			mode_rate = DIV_ROUND_UP(nv50_outp_link_clock(mode) * 12, 8);
+			if (mode_rate <= max_rate)
+				asyh->or.bpc = 12;
+		}
+
+		if (asyh->or.bpc == 8 && conn_state->max_requested_bpc >= 10 &&
+		    connector->display_info.edid_hdmi_rgb444_dc_modes & DRM_EDID_HDMI_DC_30) {
+			mode_rate = DIV_ROUND_UP(nv50_outp_link_clock(mode) * 10, 8);
+			if (mode_rate <= max_rate)
+				asyh->or.bpc = 10;
+		}
+
+		conn_state->max_bpc = asyh->or.bpc;
+		break;
 	default:
 		break;
 	}
@@ -422,7 +467,7 @@ nv50_outp_atomic_check(struct drm_encoder *encoder,
 		asyh->or.bpc = connector->display_info.bpc;
 
 	/* We might have to reduce the bpc */
-	nv50_outp_atomic_fix_depth(encoder, crtc_state);
+	nv50_outp_atomic_fix_depth(encoder, crtc_state, conn_state);
 
 	return 0;
 }
@@ -1776,6 +1821,27 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_commit *st
 
 	switch (nv_encoder->dcb->type) {
 	case DCB_OUTPUT_TMDS:
+		switch (asyh->or.bpc) {
+		case 16:
+			depth = NV837D_SOR_SET_CONTROL_PIXEL_DEPTH_BPP_48_444;
+			break;
+		case 12:
+			depth = NV837D_SOR_SET_CONTROL_PIXEL_DEPTH_BPP_36_444;
+			break;
+		case 10:
+			depth = NV837D_SOR_SET_CONTROL_PIXEL_DEPTH_BPP_30_444;
+			break;
+		case 8:
+			depth = NV837D_SOR_SET_CONTROL_PIXEL_DEPTH_BPP_24_444;
+			break;
+		case 6:
+			depth = NV837D_SOR_SET_CONTROL_PIXEL_DEPTH_BPP_18_444;
+			break;
+		default:
+			depth = NV837D_SOR_SET_CONTROL_PIXEL_DEPTH_DEFAULT;
+			break;
+		}
+
 		if (disp->disp->object.oclass != NV50_DISP &&
 		    nv_connector->base.display_info.is_hdmi)
 			nv50_hdmi_enable(encoder, nv_crtc, nv_connector, state, mode, hda);
drivers/gpu/drm/nouveau/dispnv50/headc37d.c +6 -0
index 2bcb3790fc10..f42d6642d6e0 100644
@@ -39,6 +39,12 @@ headc37d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
 	 *     improved later for deep colour etc.
 	 */
 	switch (asyh->or.depth) {
+	case 9:
+		depth = 8;
+		break;
+	case 8:
+		depth = 7;
+		break;
 	case 6: depth = 5; break;
 	case 5: depth = 4; break;
 	case 2: depth = 1; break;
drivers/gpu/drm/nouveau/dispnv50/headc57d.c +6 -0
index 3f8ba495de8f..f1e9f02d177c 100644
@@ -52,6 +52,12 @@ headc57d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
 	 *     improved later for deep colour etc.
 	 */
 	switch (asyh->or.depth) {
+	case 9:
+		depth = 8;
+		break;
+	case 8:
+		depth = 7;
+		break;
 	case 6: depth = 5; break;
 	case 5: depth = 4; break;
 	case 2: depth = 1; break;
drivers/gpu/drm/nouveau/dispnv50/headca7d.c +6 -0
index 678cbc78ca9f..437633ff7807 100644
@@ -35,6 +35,12 @@ headca7d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
 	int ret;
 
 	switch (asyh->or.depth) {
+	case 9:
+		depth = NVCA7D_HEAD_SET_CONTROL_OUTPUT_RESOURCE_PIXEL_DEPTH_BPP_48_444;
+		break;
+	case 8:
+		depth = NVCA7D_HEAD_SET_CONTROL_OUTPUT_RESOURCE_PIXEL_DEPTH_BPP_36_444;
+		break;
 	case 6:
 		depth = NVCA7D_HEAD_SET_CONTROL_OUTPUT_RESOURCE_PIXEL_DEPTH_BPP_30_444;
 		break;
drivers/gpu/drm/nouveau/nouveau_connector.c +6 -3
index cc3caf8de64b..b452e73f03f1 100644
@@ -298,6 +298,9 @@ nouveau_conn_attach_properties(struct drm_connector *connector)
 		drm_object_attach_property(&connector->base, dev->mode_config.
 					   dvi_i_subconnector_property, 0);
 
+	if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA)
+		drm_connector_attach_max_bpc_property(connector, 8, 16);
+
 	/* Add overscan compensation options to digital outputs. */
 	if (disp->underscan_property &&
 	    (connector->connector_type == DRM_MODE_CONNECTOR_DVID ||
@@ -1101,8 +1104,8 @@ nouveau_connector_get_modes(struct drm_connector *connector)
 	return ret;
 }
 
-static unsigned
-get_tmds_link_bandwidth(struct drm_connector *connector)
+unsigned int
+nouveau_connector_get_tmds_link_bandwidth(struct drm_connector *connector)
 {
 	struct nouveau_connector *nv_connector = nouveau_connector(connector);
 	struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
@@ -1168,7 +1171,7 @@ nouveau_connector_mode_valid(struct drm_connector *connector,
 		max_clock = 400000;
 		break;
 	case DCB_OUTPUT_TMDS:
-		max_clock = get_tmds_link_bandwidth(connector);
+		max_clock = nouveau_connector_get_tmds_link_bandwidth(connector);
 		break;
 	case DCB_OUTPUT_ANALOG:
 		max_clock = nv_encoder->dcb->crtconf.maxfreq;
drivers/gpu/drm/nouveau/nouveau_connector.h +1 -0
index eb292d2ba4bc..6623b5e17796 100644
@@ -216,6 +216,7 @@ extern int nouveau_duallink;
 extern int nouveau_hdmimhz;
 
 void nouveau_conn_attach_properties(struct drm_connector *);
+unsigned int nouveau_connector_get_tmds_link_bandwidth(struct drm_connector *connector);
 void nouveau_conn_reset(struct drm_connector *);
 struct drm_connector_state *
 nouveau_conn_atomic_duplicate_state(struct drm_connector *);
Signature · 1 line
2.53.0
#3 lore raw

PATCH v2 2/3 drm/nouveau: pass HDMI GCP deep-color state through NVIF

In reply to Daniel Campos Ramos

The HDMI GCP carries color depth and pixel packing phase. These fields are required for 30-, 36- and 48-bpp RGB links. Nouveau has no way to pass them from the atomic state to the display engine.

Build CD and PP using NVIDIA NVKMS's 36-bpp rule and the HDMI 48-bpp encoding.
Extend the internal HDMI NVIF method and cache the values in the armed TMDS state. The following change uses that state in the generation-specific GCP writers.

---
 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 40 ++++++++++++++++---
 drivers/gpu/drm/nouveau/include/nvif/if0012.h |  3 ++
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |  2 +-
 drivers/gpu/drm/nouveau/nvif/outp.c           |  7 +++-
 .../gpu/drm/nouveau/nvkm/engine/disp/ior.h    |  2 +
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  |  6 +++
 6 files changed, 52 insertions(+), 8 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +35 -5
index 028512f8767b..b183e1865bf5 100644
@@ -822,13 +822,14 @@ nv50_audio_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,
 static void
 nv50_hdmi_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,
 		 struct nouveau_connector *nv_connector, struct drm_atomic_commit *state,
-		 struct drm_display_mode *mode, bool hda)
+		 struct drm_display_mode *mode, bool hda, u8 bpc)
 {
 	struct nouveau_drm *drm = nouveau_drm(encoder->dev);
 	struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
 	struct drm_hdmi_info *hdmi = &nv_connector->base.display_info.hdmi;
 	union hdmi_infoframe infoframe = { 0 };
 	const u8 rekey = 56; /* binary driver, and tegra, constant */
+	u8 gcp_cd = 0, gcp_pp = 0;
 	u32 max_ac_packet;
 	DEFINE_RAW_FLEX(struct nvif_outp_infoframe_v0, args, data, 17);
 	const u8 data_len = __member_size(args->data);
@@ -839,8 +840,36 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,
 	max_ac_packet -= 18; /* constant from tegra */
 	max_ac_packet /= 32;
 
+	/* HDMI 1.4b section 6.5.3 GCP encodings, extended from NVIDIA's
+	 * 36-bpp construction: CD is 5/6/7 for 30/36/48-bpp and PP is the
+	 * packing phase of the last pixel in the packing group (wire 0 is
+	 * phase 4, per NVIDIA's nvtiming.h phase constant numbering).
+	 * 48-bpp groups contain one pixel, so PP is always 4 (zero);
+	 * 36-bpp groups contain two pixels and 30-bpp groups four, so PP
+	 * follows the pixel count of the final group.
+	 */
+	if (bpc == 16) {
+		gcp_cd = 7;
+	} else if (bpc == 12 || bpc == 10) {
+		const u32 pixels = mode->crtc_hdisplay +
+				   (mode->crtc_hblank_end - mode->crtc_hsync_end);
+
+		if (bpc == 12) {
+			gcp_cd = 6;
+			gcp_pp = (pixels & 1) ? 1 : 2;
+		} else {
+			gcp_cd = 5;
+			gcp_pp = pixels & 3;
+		}
+	}
+
 	if (nv_encoder->i2c && hdmi->scdc.scrambling.supported) {
-		const bool high_tmds_clock_ratio = mode->clock > 340000;
+		/* Deep Colour raises the TMDS character rate above the pixel
+		 * clock; the HDMI 2.0 340 MHz scrambling and clock-ratio
+		 * thresholds apply to the character rate.
+		 */
+		const u32 tmds_char_clock = nv50_outp_link_clock(mode) * bpc / 8;
+		const bool high_tmds_clock_ratio = tmds_char_clock > 340000;
 		u8 scdc;
 
 		ret = drm_scdc_readb(nv_encoder->i2c, SCDC_TMDS_CONFIG, &scdc);
@@ -863,7 +892,7 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,
 
 	ret = nvif_outp_hdmi(&nv_encoder->outp, nv_crtc->index, true, max_ac_packet, rekey,
 			     mode->clock, hdmi->scdc.supported, hdmi->scdc.scrambling.supported,
-			     hdmi->scdc.scrambling.low_rates);
+			     hdmi->scdc.scrambling.low_rates, gcp_cd, gcp_pp);
 	if (ret)
 		return;
 
@@ -1628,7 +1657,7 @@ nv50_sor_atomic_disable(struct drm_encoder *encoder, struct drm_atomic_commit *s
 
 	if (nv_encoder->dcb->type == DCB_OUTPUT_TMDS && nv_encoder->hdmi.enabled) {
 		nvif_outp_hdmi(&nv_encoder->outp, head->base.index,
-			       false, 0, 0, 0, false, false, false);
+			       false, 0, 0, 0, false, false, false, 0, 0);
 		nv_encoder->hdmi.enabled = false;
 	}
 
@@ -1844,7 +1873,8 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_commit *st
 
 		if (disp->disp->object.oclass != NV50_DISP &&
 		    nv_connector->base.display_info.is_hdmi)
-			nv50_hdmi_enable(encoder, nv_crtc, nv_connector, state, mode, hda);
+			nv50_hdmi_enable(encoder, nv_crtc, nv_connector, state, mode, hda,
+					 asyh->or.bpc);
 
 		if (nv_encoder->outp.or.link & 1) {
 			proto = NV507D_SOR_SET_CONTROL_PROTOCOL_SINGLE_TMDS_A;
drivers/gpu/drm/nouveau/include/nvif/if0012.h +3 -0
index bde9bfae8d11..ebfa60f98252 100644
@@ -176,6 +176,9 @@ union nvif_outp_hdmi_args {
 		__u8 scdc_scrambling;
 		__u8 scdc_low_rates;
 		__u32 khz;
+		__u8 gcp_cd;
+		__u8 gcp_pp;
+		__u8 pad14[2];
 	} v0;
 };
 
drivers/gpu/drm/nouveau/include/nvif/outp.h +1 -1
index bc122a5ba7df..3d5ed53fd13c 100644
@@ -90,7 +90,7 @@ int nvif_outp_bl_set(struct nvif_outp *, int level);
 int nvif_outp_lvds(struct nvif_outp *, bool dual, bool bpc8);
 
 int nvif_outp_hdmi(struct nvif_outp *, int head, bool enable, u8 max_ac_packet, u8 rekey, u32 khz,
-		   bool scdc, bool scdc_scrambling, bool scdc_low_rates);
+		   bool scdc, bool scdc_scrambling, bool scdc_low_rates, u8 gcp_cd, u8 gcp_pp);
 
 int nvif_outp_infoframe(struct nvif_outp *, u8 type, struct nvif_outp_infoframe_v0 *, u32 size);
 int nvif_outp_hda_eld(struct nvif_outp *, int head, void *data, u32 size);
drivers/gpu/drm/nouveau/nvif/outp.c +5 -2
index 8cf4775a0a1e..4456264512eb 100644
@@ -224,9 +224,10 @@ nvif_outp_infoframe(struct nvif_outp *outp, u8 type, struct nvif_outp_infoframe_
 
 int
 nvif_outp_hdmi(struct nvif_outp *outp, int head, bool enable, u8 max_ac_packet, u8 rekey,
-	       u32 khz, bool scdc, bool scdc_scrambling, bool scdc_low_rates)
+	       u32 khz, bool scdc, bool scdc_scrambling, bool scdc_low_rates,
+	       u8 gcp_cd, u8 gcp_pp)
 {
-	struct nvif_outp_hdmi_v0 args;
+	struct nvif_outp_hdmi_v0 args = {};
 	int ret;
 
 	args.version = 0;
@@ -238,6 +239,8 @@ nvif_outp_hdmi(struct nvif_outp *outp, int head, bool enable, u8 max_ac_packet,
 	args.scdc = scdc;
 	args.scdc_scrambling = scdc_scrambling;
 	args.scdc_low_rates = scdc_low_rates;
+	args.gcp_cd = gcp_cd;
+	args.gcp_pp = gcp_pp;
 
 	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_HDMI, &args, sizeof(args));
 	NVIF_ERRON(ret, &outp->object,
drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h +2 -0
index 5d682a774f2d..fcf624cff976 100644
@@ -46,6 +46,8 @@ struct nvkm_ior {
 	/* Armed TMDS state. */
 	struct {
 		bool high_speed;
+		u8 gcp_cd;
+		u8 gcp_pp;
 	} tmds;
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +6 -0
index 377d0e0cef84..dff75d7257ac 100644
@@ -254,16 +254,22 @@ nvkm_uoutp_mthd_hdmi(struct nvkm_outp *outp, void *argv, u32 argc)
 	if (!ior->func->hdmi ||
 	    args->v0.max_ac_packet > 0x1f ||
 	    args->v0.rekey > 0x7f ||
+	    args->v0.gcp_cd > 0x0f ||
+	    args->v0.gcp_pp > 0x0f ||
 	    (args->v0.scdc && !ior->func->hdmi->scdc))
 		return -EINVAL;
 
 	if (!args->v0.enable) {
+		ior->tmds.gcp_cd = 0;
+		ior->tmds.gcp_pp = 0;
 		ior->func->hdmi->infoframe_avi(ior, args->v0.head, NULL, 0);
 		ior->func->hdmi->infoframe_vsi(ior, args->v0.head, NULL, 0);
 		ior->func->hdmi->ctrl(ior, args->v0.head, false, 0, 0);
 		return 0;
 	}
 
+	ior->tmds.gcp_cd = args->v0.gcp_cd;
+	ior->tmds.gcp_pp = args->v0.gcp_pp;
 	ior->func->hdmi->ctrl(ior, args->v0.head, args->v0.enable,
 			      args->v0.max_ac_packet, args->v0.rekey);
 	if (ior->func->hdmi->scdc)
Signature · 1 line
2.53.0
#4 lore raw

PATCH v2 3/3 drm/nouveau: program HDMI deep-color GCP fields

In reply to Daniel Campos Ramos

The GV100-class GCP writers always program a depth-less packet. On GSP systems the HDMI audio setup runs after the display commit and writes that packet again, replacing any earlier deep-color declaration.

Program cached CD and PP in the direct and GSP GCP paths. Update only SB0..SB2 so generation-specific bits sharing the register remain intact, including GB20x SB1_CTRL.

On a GA106 driving a Sony KDL-46HX855, the depth-less packet produced an incompatible-signal OSD at 1920x1080p60. Restoring CD=6 and PP=2 after audio setup made the same sink accept the image and report 12-bit input.

---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/gb202.c | 12 ++++++------
 drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c |  4 +++-
 drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c |  4 +++-
 3 files changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/nouveau/nvkm/engine/disp/gb202.c +6 -6
index d0360610f9fa..517a51caed2a 100644
@@ -66,20 +66,20 @@ gb202_sor_hdmi_infoframe_vsi(struct nvkm_ior *ior, int head, void *data, u32 siz
 }
 
 /* General Control Packet AVMute bracket. The GCP unit moved to slot 1 on
- * NVD5.0. Only SB0 (the AVMute bit) is ours to write so we must not do a
- * full write here: SB1 carries the deep-color CD/PP fields, and SB1_CTRL
- * (bit 24, new with clc871.h) controls where their generation happens (HW
- * or driver) on these chips, with the default being HW.
+ * NVD5.0. SB0 carries AVMute, SB1 carries the deep-color CD/PP fields, and
+ * SB1_CTRL (bit 24, new with clc871.h) controls where their generation
+ * happens (HW or driver). Preserve SB1_CTRL while updating SB0..SB2.
  */
 static void
 gb202_sor_hdmi_gcp(struct nvkm_ior *sor, int head, bool enable)
 {
 	struct nvkm_device *device = sor->disp->engine.subdev.device;
 	const u32 hdmi = head * 0x400;
+	const u32 gcp = (!enable ? 0x00000001 : 0x00000010) |
+			 sor->tmds.gcp_cd << 8 | sor->tmds.gcp_pp << 12;
 
 	nvkm_mask(device, 0x6f0040 + hdmi, 0x00000001, 0x00000000);
-	nvkm_mask(device, 0x6f004c + hdmi, 0x000000ff, !enable ? 0x00000001 :
-								 0x00000010);
+	nvkm_mask(device, 0x6f004c + hdmi, 0x00ffffff, gcp);
 	nvkm_mask(device, 0x6f0040 + hdmi, 0x00000001, 0x00000001);
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c +3 -1
index 0608266188d3..d1e4b38b90a5 100644
@@ -149,6 +149,8 @@ gv100_sor_hdmi_ctrl(struct nvkm_ior *ior, int head, bool enable, u8 max_ac_packe
 	const u32 ctrl = 0x40000000 * enable |
 			 max_ac_packet << 16 |
 			 rekey;
+	const u32 gcp = 0x00000010 | ior->tmds.gcp_cd << 8 |
+					   ior->tmds.gcp_pp << 12;
 	const u32 hoff = head * 0x800;
 	const u32 hdmi = head * 0x400;
 
@@ -162,7 +164,7 @@ gv100_sor_hdmi_ctrl(struct nvkm_ior *ior, int head, bool enable, u8 max_ac_packe
 
 	/* General Control (GCP). */
 	nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000000);
-	nvkm_wr32(device, 0x6f00cc + hdmi, 0x00000010);
+	nvkm_mask(device, 0x6f00cc + hdmi, 0x00ffffff, gcp);
 	nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000001);
 
 	/* Audio Clock Regeneration (ACR). */
drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c +3 -1
index f6c163072ff6..49c84927583e 100644
@@ -39,9 +39,11 @@ tu102_sor_hdmi_gcp(struct nvkm_ior *sor, int head, bool enable)
 {
 	struct nvkm_device *device = sor->disp->engine.subdev.device;
 	const u32 hdmi = head * 0x400;
+	const u32 gcp = (!enable ? 0x00000001 : 0x00000010) |
+			 sor->tmds.gcp_cd << 8 | sor->tmds.gcp_pp << 12;
 
 	nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000000);
-	nvkm_wr32(device, 0x6f00cc + hdmi, !enable ? 0x00000001 : 0x00000010);
+	nvkm_mask(device, 0x6f00cc + hdmi, 0x00ffffff, gcp);
 	nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000001);
 }
 
Signature · 1 line
2.53.0