Subject: Re: [PATCH v11 03/22] drm: Add new general DRM property "color format"

From: Pekka Paalanen <[email-masked]>
Date: Tue, 31 Mar 2026 16:52:24 +0300

On Sat, 28 Mar 2026 02:22:01 +0200
Ville Syrjälä <[email-masked]> wrote:

> On Thu, Mar 26, 2026 at 07:58:25PM +0200, Ville Syrjälä wrote:
> > On Thu, Mar 26, 2026 at 06:02:47PM +0100, Maxime Ripard wrote:  
> > > On Wed, Mar 25, 2026 at 08:43:15PM +0200, Ville Syrjälä wrote:  
> > > > On Wed, Mar 25, 2026 at 03:56:58PM +0100, Maxime Ripard wrote:  
> > > > > On Wed, Mar 25, 2026 at 01:03:07PM +0200, Ville Syrjälä wrote:  
> > > > > > On Wed, Mar 25, 2026 at 09:24:27AM +0100, Maxime Ripard wrote:  
> > > > > > > On Tue, Mar 24, 2026 at 09:53:35PM +0200, Ville Syrjälä wrote:  
> > > > > > > > On Tue, Mar 24, 2026 at 08:10:11PM +0100, Nicolas Frattaroli wrote:  
> > > > > > > > > On Tuesday, 24 March 2026 18:00:45 Central European Standard Time Ville Syrjälä wrote:  
> > > > > > > > > > On Tue, Mar 24, 2026 at 05:01:07PM +0100, Nicolas Frattaroli wrote:  
> > > > > > > > > > > +enum drm_connector_color_format {
> > > > > > > > > > > +	/**
> > > > > > > > > > > +	 * @DRM_CONNECTOR_COLOR_FORMAT_AUTO: The driver or display protocol
> > > > > > > > > > > +	 * helpers should pick a suitable color format. All implementations of a
> > > > > > > > > > > +	 * specific display protocol must behave the same way with "AUTO", but
> > > > > > > > > > > +	 * different display protocols do not necessarily have the same "AUTO"
> > > > > > > > > > > +	 * semantics.
> > > > > > > > > > > +	 *
> > > > > > > > > > > +	 * For HDMI, "AUTO" picks RGB, but falls back to YCbCr 4:2:0 if the
> > > > > > > > > > > +	 * bandwidth required for full-scale RGB is not available, or the mode
> > > > > > > > > > > +	 * is YCbCr 4:2:0-only, as long as the mode and output both support
> > > > > > > > > > > +	 * YCbCr 4:2:0.
> > > > > > > > > > > +	 *
> > > > > > > > > > > +	 * For display protocols other than HDMI, the recursive bridge chain
> > > > > > > > > > > +	 * format selection picks the first chain of bridge formats that works,
> > > > > > > > > > > +	 * as has already been the case before the introduction of the "color
> > > > > > > > > > > +	 * format" property. Non-HDMI bridges should therefore either sort their
> > > > > > > > > > > +	 * bus output formats by preference, or agree on a unified auto format
> > > > > > > > > > > +	 * selection logic that's implemented in a common state helper (like
> > > > > > > > > > > +	 * how HDMI does it).
> > > > > > > > > > > +	 */
> > > > > > > > > > > +	DRM_CONNECTOR_COLOR_FORMAT_AUTO = 0,
> > > > > > > > > > > +
> > > > > > > > > > > +	/**
> > > > > > > > > > > +	 * @DRM_CONNECTOR_COLOR_FORMAT_RGB444: RGB output format
> > > > > > > > > > > +	 */
> > > > > > > > > > > +	DRM_CONNECTOR_COLOR_FORMAT_RGB444,
> > > > > > > > > > > +
> > > > > > > > > > > +	/**
> > > > > > > > > > > +	 * @DRM_CONNECTOR_COLOR_FORMAT_YCBCR444: YCbCr 4:4:4 output format (ie.
> > > > > > > > > > > +	 * not subsampled)
> > > > > > > > > > > +	 */
> > > > > > > > > > > +	DRM_CONNECTOR_COLOR_FORMAT_YCBCR444,
> > > > > > > > > > > +
> > > > > > > > > > > +	/**
> > > > > > > > > > > +	 * @DRM_CONNECTOR_COLOR_FORMAT_YCBCR422: YCbCr 4:2:2 output format (ie.
> > > > > > > > > > > +	 * with horizontal subsampling)
> > > > > > > > > > > +	 */
> > > > > > > > > > > +	DRM_CONNECTOR_COLOR_FORMAT_YCBCR422,
> > > > > > > > > > > +
> > > > > > > > > > > +	/**
> > > > > > > > > > > +	 * @DRM_CONNECTOR_COLOR_FORMAT_YCBCR420: YCbCr 4:2:0 output format (ie.
> > > > > > > > > > > +	 * with horizontal and vertical subsampling)
> > > > > > > > > > > +	 */
> > > > > > > > > > > +	DRM_CONNECTOR_COLOR_FORMAT_YCBCR420,  
> > > > > > > > > > 
> > > > > > > > > > Seems like this should document what the quantization range
> > > > > > > > > > should be for each format.
> > > > > > > > > >   
> > > > > > > > > 
> > > > > > > > > I don't think so? If you want per-component bit depth values,
> > > > > > > > > DRM_FORMAT_* defines would be the appropriate values to use. This
> > > > > > > > > enum is more abstract than that, and is there to communicate
> > > > > > > > > YUV vs. RGB and chroma subsampling, with bit depth being handled
> > > > > > > > > by other properties.
> > > > > > > > > 
> > > > > > > > > If you mean the factor used for subsampling, then that'd only be
> > > > > > > > > relevant if YCBCR410 was supported where one chroma plane isn't
> > > > > > > > > halved but quartered in resolution. I suspect 4:1:0 will never
> > > > > > > > > be added; no digital display protocol standard supports it to my
> > > > > > > > > knowledge, and hopefully none ever will.  
> > > > > > > > 
> > > > > > > > No, I mean the quantization range (16-235 vs. 0-255 etc).
> > > > > > > > 
> > > > > > > > The i915 behaviour is that YCbCr is always limited range,
> > > > > > > > RGB can either be full or limited range depending on the 
> > > > > > > > "Broadcast RGB" property and other related factors.  
> > > > > > > 
> > > > > > > So far the HDMI state has both the format and quantization range as
> > > > > > > different fields. I'm not sure we need to document the range in the
> > > > > > > format field, maybe only mention it's not part of the format but has a
> > > > > > > field of its own?  
> > > > > > 
> > > > > > I think we only have it for RGB (on some drivers only?). For YCbCr
> > > > > > I think the assumption is limited range everywhere.
> > > > > > 
> > > > > > But I'm not really concerned about documenting struct members.
> > > > > > What I'm talking about is the *uapi* docs. Surely userspace
> > > > > > will want to know what the new property actually does so the
> > > > > > uapi needs to be documented properly. And down the line some
> > > > > > new driver might also implement the wrong behaviour if there
> > > > > > is no clear specification.  
> > > > > 
> > > > > Ack
> > > > >   
> > > > > > So I'm thinking (or perhaps hoping) the rule might be something like:
> > > > > > - YCbCr limited range 
> > > > > > - RGB full range if "Broadcast RGB" property is not present  
> > > > > 
> > > > > Isn't it much more complicated than that for HDMI though? My
> > > > > recollection was that any VIC but VIC1 would be limited range, and
> > > > > anything else full range?  
> > > > 
> > > > Do we have some driver that implements the CTA-861 CE vs. IT mode
> > > > logic but doesn't expose the "Broadcast RGB" property? I was hoping
> > > > those would always go hand in hand now.  
> > > 
> > > I'm not sure. i915 and the HDMI state helpers handle it properly (I
> > > think?) but it looks like only vc4 registers the Broadcast RGB property
> > > and uses the HDMI state helpers.
> > > 
> > > And it looks like amdgpu registers Broadcast RGB but doesn't use
> > > drm_default_rgb_quant_range() which seems suspicious?  
> > 
> > If they want just manual full vs. limited then they should
> > limit the property to not expose the "auto" option at all.
> > 
> > amdgpu also ties this in with the "colorspace" property, which
> > originally in i915 only controlled the infoframes/etc. But on
> > amdgpu it now controls various aspects of output color
> > transformation. The end result is that the property is a complete
> > mess with most of the values making no sense. And for whatever
> > reason everyone involved refused to remove/deprecate the
> > nonsensical values :/
> > 
> > Looks like this series should make sure the documentation for
> > the "colorspace" property is in sync with the new property
> > as well. Currently now it's giving conflicting information.  
> 
> After pondering about this a bit more I guess we could actually
> use this to make all the values of the colorspace property make
> some sense.
> 
> Since we won't have to worry about that RGB->YCbCr 4:2:0
> fallback when using and explicit color format, all we'd have
> to do is explicitly reject the nonsensical combinations:
> 
> color_format_and_colorspace_ok()
> {
> 	switch (color_format) {
> 	case DRM_CONNECTOR_COLOR_FORMAT_YCBCR444:
> 	case DRM_CONNECTOR_COLOR_FORMAT_YCBCR422:
> 	case DRM_CONNECTOR_COLOR_FORMAT_YCBCR420:
> 		switch (colorspace) {
> 		case DRM_MODE_COLORIMETRY_NO_DATA:
> 		case DRM_MODE_COLORIMETRY_SMPTE_170M_YCC:
> 		case DRM_MODE_COLORIMETRY_BT601_YCC:
> 		case DRM_MODE_COLORIMETRY_BT709_YCC:
> 		case DRM_MODE_COLORIMETRY_XVYCC_601:
> 		case DRM_MODE_COLORIMETRY_XVYCC_709:
> 		case DRM_MODE_COLORIMETRY_SYCC_601:
> 		case DRM_MODE_COLORIMETRY_OPYCC_601:
> 		case DRM_MODE_COLORIMETRY_BT2020_CYCC:
> 		case DRM_MODE_COLORIMETRY_BT2020_YCC:
> 		case DRM_MODE_COLORIMETRY_BT709_YCC:
> 			return true;
> 		default:
> 			return false;
> 		}
> 		break;
> 	case DRM_CONNECTOR_COLOR_FORMAT_RGB444:
> 		switch (colorspace) {
> 		case DRM_MODE_COLORIMETRY_NO_DATA:
> 		case DRM_MODE_COLORIMETRY_OPRGB:
> 		case DRM_MODE_COLORIMETRY_BT2020_RGB:
> 		case DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65:
> 		case DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER:
> 		case DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED:
> 		case DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT:
> 		case DRM_MODE_COLORIMETRY_OPRGB:
> 		case DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65:
> 		case DRM_MODE_COLORIMETRY_BT2020_RGB:
> 			return true;
> 		default
> 			return false;
> 		}
> 		break;
> 	case DRM_CONNECTOR_COLOR_FORMAT_AUTO:
> 		switch (colorspace) {
> 		case DRM_MODE_COLORIMETRY_NO_DATA:
> 		case DRM_MODE_COLORIMETRY_BT2020_RGB:
> 		case DRM_MODE_COLORIMETRY_BT2020_YCC:
> 			return true;
> 		default:
> 			return false;
> 		}
> 	default:
> 		bad;
> 	}
> }
> 
> And then presumably the colorspace property is the thing that should
> dictate which conversion matrix to use. So something like this:
> 
> csc_matrix()
> {
> 	switch (colorspace) {
> 	case DRM_MODE_COLORIMETRY_SMPTE_170M_YCC:
> 	case DRM_MODE_COLORIMETRY_BT601_YCC:
> 	case DRM_MODE_COLORIMETRY_XVYCC_601:
> 	case DRM_MODE_COLORIMETRY_SYCC_601:
> 	case DRM_MODE_COLORIMETRY_OPYCC_601:
> 		return 601;
> 	case DRM_MODE_COLORIMETRY_BT709_YCC:
> 	case DRM_MODE_COLORIMETRY_XVYCC_709:
> 		return 709;
> 	case DRM_MODE_COLORIMETRY_BT2020_YCC:
> 	case DRM_MODE_COLORIMETRY_BT2020_RGB:
> 		return 2020;
> 	case DRM_MODE_COLORIMETRY_BT2020_CYCC:
> 		return 2020_const;
> 	case DRM_MODE_COLORIMETRY_NO_DATA:
> 		return vdisplay >= 720 ? 709 : 601;
> 	default:
> 		bad;
> 	}
> }
> 

Hi Ville,

I believe the RGB-to-YCbCr matrix choice belongs in a colorop in the
CRTC color pipeline. It would be really nice to let go of the
requirement that the KMS color pipeline can be only in full-range RGB.

I imagine being able to scan out a YCbCr limited range buffer as-is
would be really useful for professional broadcasting industry and
particularly PLUGE testing which relies on being able to send the
sub-black and super-white YCbCr values for monitor calibration.

However, if there is an "auto" value in the colorop (implies the
input to the colorop must be full-range RGB) or the colorop is missing,
then your proposal could be used there.

Thanks,
pq