Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp598780rdb; Mon, 15 Jan 2024 07:26:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9bHVhqlkiKdRaDu666n/rspGHPdBLaRbao055k3dDzdCd30tkIXNafs60CRvfZldijxKZ X-Received: by 2002:a05:6358:c696:b0:170:2c2d:9d8f with SMTP id fe22-20020a056358c69600b001702c2d9d8fmr4387008rwb.1.1705332394540; Mon, 15 Jan 2024 07:26:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705332394; cv=none; d=google.com; s=arc-20160816; b=LWUMf9m+IlU7V+bm0chWTAhibJ8su4Bqio3vQaqTHVbzrn/X7OVxPfxRddKNBOEJAm kB/MJ+Jd+hZm9GxzZgvrKLMOOhHAURB4IILPZRKpwEFfxkN+/SdP7rYz005roMTGaXSI 6yYEpqkiw6xrIoBwS1/5G1vfxsmwLUCNybXKRrDOIdVmmyQNPc8cdW/LahetKwPBsc1j wsI9QiAVregLD+GPoq3PB0jWuaDrVv7NqIE6UCZKkiIb3UmtA0IdXr4T4FVr0UlhsP0A JfVT+vK0NpPiS8NKFYwuVJ23nl9L9t6gzPstcvZlP4Y9lgY8xRrw1Fr58wT8Z5jtZp1+ QJjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Gs+UzPDnI2weB70B2YlFKzQFUdUQrfeKnTQvo5OnFGo=; fh=naaJF2Zirasm4AMuBSzK8FCFf7cwkY/BTMJftRlJuUg=; b=K8brjZunW53SXnAI+VJntNwvcb0c+UIj/3RcCyTWQDT/0UsB3fFCSwQvrq3JWAi1XV TVBriGNrgNG966c4w8i/Skbt/1HSes61bWA8MIVmmofyUpmw+jglY+ISIfSfLLdrKoHr PRucKw4s5SWORrSZip8VUl1kwbpJ3L9NOXUoKcU6lAwQMRrWAVb4ZRZHqPayFL4f+2T3 R7iq9dQnHZRUFi2JVFZowo7m3Et+ZZgZKEENOI7eoPOFUuMomEwToSlEeXGeaifYfs7e 4skSODSaXzwQlqlLvv8WIdEy4wSMCbbU9d/IfM2hm3CeLyvhk5GFzDsPGwEKkBQTP0ok FadA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=euQlCMkL; spf=pass (google.com: domain of linux-kernel+bounces-26172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h191-20020a636cc8000000b005c68d9545b9si8778291pgc.619.2024.01.15.07.26.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 07:26:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=euQlCMkL; spf=pass (google.com: domain of linux-kernel+bounces-26172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2DFF2281878 for ; Mon, 15 Jan 2024 15:26:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED1E017994; Mon, 15 Jan 2024 15:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="euQlCMkL" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C13391773A; Mon, 15 Jan 2024 15:25:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEB19C433C7; Mon, 15 Jan 2024 15:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705332344; bh=F+KShPyxC2iWhYtXbRbIEplYrB9q6J1tUU6JHTlPDX8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=euQlCMkLJcL2D4vkC4R75T4/MgQt/FWOdjmTNjrXW4LWTF5fO3uKIJgoyQbjAjJw8 yOw0BRyBdyTB8uEyoeBz2SwjbRkeJkkXg0NVYq9Be0KYlNPjNIawRM0z0JgQ1/8OG4 dt9O64QiNHoyhyJbInor9qAWkq/0P+1Ifvd1qPNdA+K+fGD27Gm/yh5J7pBalsPt7e 5rYpN3eiJcY86z1aWyN+75ZKXeahea2OgZcr/YVbZbadEbA3aKzjteTvvAbXlD7rS4 j6HRMuiNpSOYk42xBoikwMHecf3dD9SVE+ChIiIChjfpD3XLERLKr19YPRz6djluow P/19UNpHxSYRA== Date: Mon, 15 Jan 2024 16:25:41 +0100 From: Maxime Ripard To: Sebastian Wick Cc: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Emma Anholt , Jonathan Corbet , Sandy Huang , Heiko =?utf-8?Q?St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Hans Verkuil , linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Subject: Re: Re: [PATCH v5 08/44] drm/connector: hdmi: Add Broadcast RGB property Message-ID: References: <20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org> <20231207-kms-hdmi-connector-state-v5-8-6538e19d634d@kernel.org> <20240115143308.GA159345@toolbox> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="yd3mop6hvuqz5nhz" Content-Disposition: inline In-Reply-To: <20240115143308.GA159345@toolbox> --yd3mop6hvuqz5nhz Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 15, 2024 at 03:33:08PM +0100, Sebastian Wick wrote: > On Thu, Dec 07, 2023 at 04:49:31PM +0100, Maxime Ripard wrote: > > The i915 driver has a property to force the RGB range of an HDMI output. > > The vc4 driver then implemented the same property with the same > > semantics. KWin has support for it, and a PR for mutter is also there to > > support it. > >=20 > > Both drivers implementing the same property with the same semantics, > > plus the userspace having support for it, is proof enough that it's > > pretty much a de-facto standard now and we can provide helpers for it. > >=20 > > Let's plumb it into the newly created HDMI connector. > >=20 > > Signed-off-by: Maxime Ripard > > --- > > Documentation/gpu/kms-properties.csv | 1 - > > drivers/gpu/drm/drm_atomic.c | 5 + > > drivers/gpu/drm/drm_atomic_state_helper.c | 17 + > > drivers/gpu/drm/drm_atomic_uapi.c | 4 + > > drivers/gpu/drm/drm_connector.c | 76 +++++ > > drivers/gpu/drm/tests/Makefile | 1 + > > .../gpu/drm/tests/drm_atomic_state_helper_test.c | 376 +++++++++++++= ++++++++ > > drivers/gpu/drm/tests/drm_connector_test.c | 117 ++++++- > > drivers/gpu/drm/tests/drm_kunit_edid.h | 106 ++++++ > > include/drm/drm_connector.h | 36 ++ > > 10 files changed, 737 insertions(+), 2 deletions(-) > >=20 > > diff --git a/Documentation/gpu/kms-properties.csv b/Documentation/gpu/k= ms-properties.csv > > index 0f9590834829..caef14c532d4 100644 > > --- a/Documentation/gpu/kms-properties.csv > > +++ b/Documentation/gpu/kms-properties.csv > > @@ -17,7 +17,6 @@ Owner Module/Drivers,Group,Property Name,Type,Propert= y Values,Object attached,De > > ,Virtual GPU,=E2=80=9Csuggested X=E2=80=9D,RANGE,"Min=3D0, Max=3D0xfff= fffff",Connector,property to suggest an X offset for a connector > > ,,=E2=80=9Csuggested Y=E2=80=9D,RANGE,"Min=3D0, Max=3D0xffffffff",Conn= ector,property to suggest an Y offset for a connector > > ,Optional,"""aspect ratio""",ENUM,"{ ""None"", ""4:3"", ""16:9"" }",Co= nnector,TDB > > -i915,Generic,"""Broadcast RGB""",ENUM,"{ ""Automatic"", ""Full"", ""Li= mited 16:235"" }",Connector,"When this property is set to Limited 16:235 an= d CTM is set, the hardware will be programmed with the result of the multip= lication of CTM by the limited range matrix to ensure the pixels normally i= n the range 0..1.0 are remapped to the range 16/255..235/255." > > ,,=E2=80=9Caudio=E2=80=9D,ENUM,"{ ""force-dvi"", ""off"", ""auto"", ""= on"" }",Connector,TBD > > ,SDVO-TV,=E2=80=9Cmode=E2=80=9D,ENUM,"{ ""NTSC_M"", ""NTSC_J"", ""NTSC= _443"", ""PAL_B"" } etc.",Connector,TBD > > ,,"""left_margin""",RANGE,"Min=3D0, Max=3D SDVO dependent",Connector,T= BD > > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c > > index c31fc0b48c31..1465a7f09a0b 100644 > > --- a/drivers/gpu/drm/drm_atomic.c > > +++ b/drivers/gpu/drm/drm_atomic.c > > @@ -1142,6 +1142,11 @@ static void drm_atomic_connector_print_state(str= uct drm_printer *p, > > drm_printf(p, "\tmax_requested_bpc=3D%d\n", state->max_requested_bpc); > > drm_printf(p, "\tcolorspace=3D%s\n", drm_get_colorspace_name(state->c= olorspace)); > > =20 > > + if (connector->connector_type =3D=3D DRM_MODE_CONNECTOR_HDMIA || > > + connector->connector_type =3D=3D DRM_MODE_CONNECTOR_HDMIB) > > + drm_printf(p, "\tbroadcast_rgb=3D%s\n", > > + drm_hdmi_connector_get_broadcast_rgb_name(state->hdmi.broadcast_= rgb)); > > + > > if (connector->connector_type =3D=3D DRM_MODE_CONNECTOR_WRITEBACK) > > if (state->writeback_job && state->writeback_job->fb) > > drm_printf(p, "\tfb=3D%d\n", state->writeback_job->fb->base.id); > > diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/dr= m/drm_atomic_state_helper.c > > index e69c0cc1c6da..10d98620a358 100644 > > --- a/drivers/gpu/drm/drm_atomic_state_helper.c > > +++ b/drivers/gpu/drm/drm_atomic_state_helper.c > > @@ -583,6 +583,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_tv_reset); > > void __drm_atomic_helper_connector_hdmi_reset(struct drm_connector *co= nnector, > > struct drm_connector_state *new_state) > > { > > + new_state->hdmi.broadcast_rgb =3D DRM_HDMI_BROADCAST_RGB_AUTO; > > } > > EXPORT_SYMBOL(__drm_atomic_helper_connector_hdmi_reset); > > =20 > > @@ -650,6 +651,22 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_tv_check= ); > > int drm_atomic_helper_connector_hdmi_check(struct drm_connector *conne= ctor, > > struct drm_atomic_state *state) > > { > > + struct drm_connector_state *old_state =3D > > + drm_atomic_get_old_connector_state(state, connector); > > + struct drm_connector_state *new_state =3D > > + drm_atomic_get_new_connector_state(state, connector); > > + > > + if (old_state->hdmi.broadcast_rgb !=3D new_state->hdmi.broadcast_rgb)= { > > + struct drm_crtc *crtc =3D new_state->crtc; > > + struct drm_crtc_state *crtc_state; > > + > > + crtc_state =3D drm_atomic_get_crtc_state(state, crtc); > > + if (IS_ERR(crtc_state)) > > + return PTR_ERR(crtc_state); > > + > > + crtc_state->mode_changed =3D true; > > + } > > + > > return 0; > > } > > EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check); > > diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_at= omic_uapi.c > > index aee4a65d4959..3eb4f4bc8b71 100644 > > --- a/drivers/gpu/drm/drm_atomic_uapi.c > > +++ b/drivers/gpu/drm/drm_atomic_uapi.c > > @@ -818,6 +818,8 @@ static int drm_atomic_connector_set_property(struct= drm_connector *connector, > > state->max_requested_bpc =3D val; > > } else if (property =3D=3D connector->privacy_screen_sw_state_propert= y) { > > state->privacy_screen_sw_state =3D val; > > + } else if (property =3D=3D connector->broadcast_rgb_property) { > > + state->hdmi.broadcast_rgb =3D val; > > } else if (connector->funcs->atomic_set_property) { > > return connector->funcs->atomic_set_property(connector, > > state, property, val); > > @@ -901,6 +903,8 @@ drm_atomic_connector_get_property(struct drm_connec= tor *connector, > > *val =3D state->max_requested_bpc; > > } else if (property =3D=3D connector->privacy_screen_sw_state_propert= y) { > > *val =3D state->privacy_screen_sw_state; > > + } else if (property =3D=3D connector->broadcast_rgb_property) { > > + *val =3D state->hdmi.broadcast_rgb; > > } else if (connector->funcs->atomic_get_property) { > > return connector->funcs->atomic_get_property(connector, > > state, property, val); > > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_conn= ector.c > > index d9961cce8245..929b0a911f62 100644 > > --- a/drivers/gpu/drm/drm_connector.c > > +++ b/drivers/gpu/drm/drm_connector.c > > @@ -1183,6 +1183,29 @@ static const u32 dp_colorspaces =3D > > BIT(DRM_MODE_COLORIMETRY_BT2020_CYCC) | > > BIT(DRM_MODE_COLORIMETRY_BT2020_YCC); > > =20 > > +static const struct drm_prop_enum_list broadcast_rgb_names[] =3D { > > + { DRM_HDMI_BROADCAST_RGB_AUTO, "Automatic" }, > > + { DRM_HDMI_BROADCAST_RGB_FULL, "Full" }, > > + { DRM_HDMI_BROADCAST_RGB_LIMITED, "Limited 16:235" }, > > +}; > > + > > +/* > > + * drm_hdmi_connector_get_broadcast_rgb_name - Return a string for HDM= I connector RGB broadcast selection > > + * @broadcast_rgb: Broadcast RGB selection to compute name of > > + * > > + * Returns: the name of the Broadcast RGB selection, or NULL if the ty= pe > > + * is not valid. > > + */ > > +const char * > > +drm_hdmi_connector_get_broadcast_rgb_name(enum drm_hdmi_broadcast_rgb = broadcast_rgb) > > +{ > > + if (broadcast_rgb > DRM_HDMI_BROADCAST_RGB_LIMITED) > > + return NULL; > > + > > + return broadcast_rgb_names[broadcast_rgb].name; > > +} > > +EXPORT_SYMBOL(drm_hdmi_connector_get_broadcast_rgb_name); > > + > > /** > > * DOC: standard connector properties > > * > > @@ -1655,6 +1678,26 @@ EXPORT_SYMBOL(drm_connector_attach_dp_subconnect= or_property); > > /** > > * DOC: HDMI connector properties > > * > > + * Broadcast RGB > > + * Indicates the RGB Quantization Range (Full vs Limited) used. > > + * Infoframes will be generated according to that value. > > + * > > + * The value of this property can be one of the following: > > + * > > + * Automatic: > > + * RGB Range is selected automatically based on the mode > > + * according to the HDMI specifications. > > + * > > + * Full: > > + * Full RGB Range is forced. > > + * > > + * Limited 16:235: > > + * Limited RGB Range is forced. Unlike the name suggests, > > + * this works for any number of bits-per-component. > > + * > > + * Drivers can set up this property by calling > > + * drm_connector_attach_broadcast_rgb_property(). > > + * >=20 > This is a good time to document this in more detail. I have the feeling that it already is documented in more detail. But anyway, last time we discussed it the answer was basically to not bother and just merge the thing. So I'm getting some mixed signals here. > There might be two different things being affected: >=20 > 1. The signalling (InfoFrame/SDP/...) > 2. The color pipeline processing >=20 > All values of Broadcast RGB always affect the color pipeline processing > such that a full-range input to the CRTC is converted to either full- or > limited-range, depending on what the monitor is supposed to accept. >=20 > When automatic is selected, does that mean that there is no signalling, > or that the signalling matches what the monitor is supposed to accept > according to the spec? The doc states that "Infoframes will be generated according to that value". Is it ambiguous? > Also, is this really HDMI specific? Probably not, but it can easily be expanded to other connector types when needs be. > When full or limited is selected and the monitor doesn't support the > signalling, what happens? I would expect colors to be off Maxime --yd3mop6hvuqz5nhz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZaVOdAAKCRDj7w1vZxhR xVZ6AQCBIsao3/wYmeGvcP81lWBqUDOqug3y4nijDxhLDsn2gQEAjbAujKqIXO3q T2U8XyzbANX2DfajXGwDY+9QrqnI/QY= =i+f4 -----END PGP SIGNATURE----- --yd3mop6hvuqz5nhz--