Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp170209lqo; Thu, 16 May 2024 02:45:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUq+bXfTfcR2mhTUuS7WF39lp47HIS0+m/9voXEeQiC8A/uRx+odqSz1zYkXxAXZoRkucDu69SPSys+04r+3Dp4OG+4mQndWNRHZGtySw== X-Google-Smtp-Source: AGHT+IEUURxblUpEQEooSmZtVTwC6nzr7dhX7LzV19acpLvQsSR1RxkyCTQlp7Hh7Oxy4vaf35py X-Received: by 2002:a17:907:9625:b0:a59:db0f:6bdd with SMTP id a640c23a62f3a-a5a2d5d56b7mr1471319466b.44.1715852750411; Thu, 16 May 2024 02:45:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715852750; cv=pass; d=google.com; s=arc-20160816; b=hXO9/Qg1Hd447jwRl6IrA+3cdvrobBM4ERxt37//3TN0gb9Dlh/SEXS3Z1PoC3nNlE u7yOBhEs291H6UUU0X7bNVVxZldU73QMrmNDeHgSoHgXB61bM5nm4fKmIaPfOXAWdxJu h7y8P/mD7ojHyIiug4qdx9dHlBhiwwmA4+Pwrfvh8O1J2Xdkb/In2BgGUYhYYvRerGgv 1RrrIVUx1Dz+0QY+sp4QkDXCFSDqP6VgZvQ0GYkZPSGRaetpW7xnQJLLjJIL4Zk9aJ7M SovtGZlt48buN8KxpwmpI8w87Fz5viOm5fO/0LDhOLlYtEwXKhLQyibMM9GrewHuKIR0 OiPA== ARC-Message-Signature: i=2; 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=E5Ll2PbLgCFsx2OLwp+4NcyXhd5ltxmaiAU4M8Yb3FI=; fh=6xBozFkbHpBRTNoI1LLd6tlMaTk1U3noKiYxVVg2xyE=; b=K1YoDLdFagYVnbduaYs7fkQI8q4YyAQ4V2goigI7lR1WgtzVZhUdV+u6LhtQhHXSAm uLvKYZR7R6QLYjw3S9vS0tWak8/eQq7reOIflI8CVy9B0WtFVtOtGmBquO+8Klkts7g4 Q+sXDFYHV86+srPvifM1pOUGfRTyQxQDJx7H7ehfHAm17Ccury2jFkdMHaAyLQcN9sfh 8B7Yxn6O6H2EgAOYrsHjZgPX5liOGosDiidIqOMRObjHCQtQEHUcH/7enPtVd4VTyQdX bW5XvcTEkZsiiwHkMtC1/OBPdk5wPwqjjLc2uWofzotiClpI0esn8uL+QDMupiceHt9M h2ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ba5TCAMY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-180861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17bb137esi873081766b.690.2024.05.16.02.45.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 02:45:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ba5TCAMY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-180861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180861-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 020531F245DB for ; Thu, 16 May 2024 09:45:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63ED9143873; Thu, 16 May 2024 09:45:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ba5TCAMY" 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 42CF33FBA7; Thu, 16 May 2024 09:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715852737; cv=none; b=A4oMDK8ABdeJD4y/2ZwPLdYM3mYYOsLe+9yAJcyrA2sHQncxpweIrN+cTTBFGP8Q6WisUauqv3s5bHIVGbqZL/VB0aE3Gw+I+Ya86DJZ1R8I48mRJczbKLdd/9S9BHItAM62hDHGaavgETy7YAkQmRWJkG2KZGpZSR0JECdewCo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715852737; c=relaxed/simple; bh=yXCqhL29SVvT8WjrDeHNlvHXxEyfDjFKwsltPgc1BOk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YvzVnWf96pHhfL6hRECYLNjNmx1eSlaGQvZOE+vOU3sMCi3RxgSV0oAv2THrH/jrxdpKeG1l1ABnlAjn3t724UrMAx0OJpvJweXkAw7wcjJElin5mjbMMeVvMnP8gwq/Z2Q7LQhGoidHr6vKwUeJUtPNXEhHA5aWAL5rtiGxA5M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ba5TCAMY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58290C113CC; Thu, 16 May 2024 09:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715852736; bh=yXCqhL29SVvT8WjrDeHNlvHXxEyfDjFKwsltPgc1BOk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ba5TCAMYUEVuM1HddFl0N3gS+f6oX3izyFyLul6eetaKJMafh+e+7Viqp5sb7HNqG JTLMIiFC0eRSKkd+Y8l65cNK5FwB1B4WvIaoKTNusgD29wj/dSoQkb2CVPaobbkzV+ oT2CLHsEwaLSyJ4sT9NxQJod5gJXsXs7/LKWj6SYgaOnaNLoYwZ8ci9sMh4omr0l/O sR3UslWLSnq1Bo8ZTc15qw1rNXRP2VriSlqYjdzr1JpYgm6wmWPo7nx1ScKhPWQcUt Pdkbr/wPIX5cnWl48RtbVW9zjxhVqPHVZLEpvAo3u7Hs8wXe0+g3ewoztFpHXqP3Ru MjyLNkPCTlpJQ== Date: Thu, 16 May 2024 11:45:33 +0200 From: Maxime Ripard To: Andy Yan Cc: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Jonathan Corbet , Sandy Huang , Heiko =?utf-8?Q?St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Andy Yan , Hans Verkuil , Sebastian Wick , Ville =?utf-8?B?U3lyasOkbMOk?= , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v13 15/28] drm/connector: hdmi: Compute bpc and format automatically Message-ID: <20240516-lean-smooth-bonobo-d7e198@penduick> References: <20240507-kms-hdmi-connector-state-v13-0-8fafc5efe8be@kernel.org> <20240507-kms-hdmi-connector-state-v13-15-8fafc5efe8be@kernel.org> <73944574.1631.18f6be1e78f.Coremail.andyshrk@163.com> 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-sha384; protocol="application/pgp-signature"; boundary="zvciie23y5uhhbzh" Content-Disposition: inline In-Reply-To: <73944574.1631.18f6be1e78f.Coremail.andyshrk@163.com> --zvciie23y5uhhbzh Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi again, On Sun, May 12, 2024 at 04:18:38PM +0800, Andy Yan wrote: > =E5=9C=A8 2024-05-07 21:17:33=EF=BC=8C"Maxime Ripard" =E5=86=99=E9=81=93=EF=BC=9A > >Now that we have all the infrastructure needed, we can add some code > >that will, for a given connector state and mode, compute the best output > >format and bpc. > > > >The algorithm is equivalent to the one already found in i915 and vc4. > > > >Cc: Ville Syrj=C3=A4l=C3=A4 > >Signed-off-by: Maxime Ripard > >--- > > drivers/gpu/drm/display/drm_hdmi_state_helper.c | 199 ++++++++++++++= ++++++- > > drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c | 25 ++- > > 2 files changed, 212 insertions(+), 12 deletions(-) > > > >diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/g= pu/drm/display/drm_hdmi_state_helper.c > >index 063421835dba..f20dcfecb6b8 100644 > >--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c > >+++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c > >@@ -1,9 +1,11 @@ > > // SPDX-License-Identifier: MIT > >=20 > > #include > > #include > >+#include > >+#include > >=20 > > #include > > #include > >=20 > > /** > >@@ -46,10 +48,112 @@ connector_state_get_mode(const struct drm_connector= _state *conn_state) > > return NULL; > >=20 > > return &crtc_state->mode; > > } > >=20 > >+static bool > >+sink_supports_format_bpc(const struct drm_connector *connector, > >+ const struct drm_display_info *info, > >+ const struct drm_display_mode *mode, > >+ unsigned int format, unsigned int bpc) > >+{ > >+ struct drm_device *dev =3D connector->dev; > >+ u8 vic =3D drm_match_cea_mode(mode); > >+ > >+ /* > >+ * CTA-861-F, section 5.4 - Color Coding & Quantization states > >+ * that the bpc must be 8, 10, 12 or 16 except for the default > >+ * 640x480 VIC1 where the value must be 8. > >+ * > >+ * The definition of default here is ambiguous but the spec > >+ * refers to VIC1 being the default timing in several occasions > >+ * so our understanding is that for the default timing (ie, > >+ * VIC1), the bpc must be 8. > >+ */ > >+ if (vic =3D=3D 1 && bpc !=3D 8) { > >+ drm_dbg_kms(dev, "VIC1 requires a bpc of 8, got %u\n", bpc); > >+ return false; > >+ } > >+ > >+ if (!info->is_hdmi && > >+ (format !=3D HDMI_COLORSPACE_RGB || bpc !=3D 8)) { > >+ drm_dbg_kms(dev, "DVI Monitors require an RGB output at 8 bpc\n"); > >+ return false; > >+ } > >+ > >+ if (!(connector->hdmi.supported_formats & BIT(format))) { > >+ drm_dbg_kms(dev, "%s format unsupported by the connector.\n", > >+ drm_hdmi_connector_get_output_format_name(format)); > >+ return false; > >+ } > >+ > >+ switch (format) { > >+ case HDMI_COLORSPACE_RGB: > >+ drm_dbg_kms(dev, "RGB Format, checking the constraints.\n"); > >+ > >+ if (!(info->color_formats & DRM_COLOR_FORMAT_RGB444)) { > >+ drm_dbg_kms(dev, "Sink doesn't support RGB.\n"); > >+ return false; > >+ } > >+ > As I reported in V12, the HDMI output on my rk3036-kylin was lost after = apply this series. > This is because there is something wrong with the DDC on my board, the ed= id read always failed > on first bootup. That means inno_hdmi_connector_get_modes will return 0. >=20 > and in function drm_helper_probe_single_connector_modes: >=20 > count =3D drm_helper_probe_get_modes(connector); >=20 > if (count =3D=3D 0 && (connector->status =3D=3D connector_status= _connected || > connector->status =3D=3D connector_status_unk= nown)) { > count =3D drm_add_modes_noedid(connector, 1024, 768); >=20 > /* > * Section 4.2.2.6 (EDID Corruption Detection) of the DP= 1.4a > * Link CTS specifies that 640x480 (the official "failsa= fe" > * mode) needs to be the default if there's no EDID. > */ > if (connector->connector_type =3D=3D DRM_MODE_CONNECTOR_= DisplayPort) > drm_set_preferred_mode(connector, 640, 480); > } > drm_add_modes_noedid will not initialize display_info. So the check about= display info will always failed here: >=20 > [ 4.205368] rockchip-drm display-subsystem: [drm:drm_atomic_check_only= ] checking (ptrval) > [ 4.205410] rockchip-drm display-subsystem: [drm:drm_atomic_helper_che= ck_modeset] [CRTC:35:crtc-0] mode changed > [ 4.205439] rockchip-drm display-subsystem: [drm:drm_atomic_helper_che= ck_modeset] [CRTC:35:crtc-0] enable changed > [ 4.205464] rockchip-drm display-subsystem: [drm:drm_atomic_helper_che= ck_modeset] [CRTC:35:crtc-0] active changed > [ 4.205490] rockchip-drm display-subsystem: [drm:drm_atomic_helper_che= ck_modeset] Updating routing for [CONNECTOR:37:HDMI-A-1] > [ 4.205517] rockchip-drm display-subsystem: [drm:drm_atomic_helper_che= ck_modeset] [CONNECTOR:37:HDMI-A-1] using [ENCODER:36:TMDS-36] on [CRTC:35:= crtc-0] > [ 4.205545] rockchip-drm display-subsystem: [drm:drm_atomic_helper_con= nector_hdmi_check] Trying with a 8 bpc output > [ 4.205575] rockchip-drm display-subsystem: [drm:drm_atomic_helper_con= nector_hdmi_check] Trying RGB output format > [ 4.205670] rockchip-drm display-subsystem: [drm:drm_atomic_helper_con= nector_hdmi_check] RGB Format, checking the constraints. > [ 4.205696] rockchip-drm display-subsystem: [drm:drm_atomic_helper_con= nector_hdmi_check] Sink doesn't support RGB. > [ 4.205720] rockchip-drm display-subsystem: [drm:drm_atomic_helper_con= nector_hdmi_check] RGB output format not supported with 8 bpc > [ 4.205747] rockchip-drm display-subsystem: [drm:drm_atomic_helper_con= nector_hdmi_check] Failed. No Format Supported for that bpc count. > [ 4.205772] rockchip-drm display-subsystem: [drm:drm_atomic_helper_che= ck_modeset] [CONNECTOR:37:HDMI-A-1] driver check failed > [ 4.205796] rockchip-drm display-subsystem: [drm:drm_atomic_check_only= ] atomic driver check for (ptrval) failed: -22 >=20 > My reply for your email in V12[0] was bounced, so I think you didn't read= it. >=20 > [0]https://patchwork.kernel.org/project/linux-rockchip/patch/20240423-kms= -hdmi-connector-state-v12-27-3338e4c0b189@kernel.org/ Indeed, I never received it, sorry. Thanks for looking into it, it's very valuable. I can see several things that interact and could go wrong: * The DDC readout should not fail like that. From a quick look at the driver, I'm wondering if it's not due to the fact that the DDC controller isn't powered until the first modeset happens. Since the first get_modes call is done with the controller disabled, it's probably not initialized enough yet. The first modeset then comes and will initialize the controller enough for the subsequent get_modes to work. Is it something you could look into? * drm_display_info not being filled to some sane default when there's no EDID is indeed an issue. I can't be made generic, but the HDMI spec provides us with some minimum requirements we can probably set in this case (RGB supported, 8bpc supported, etc.) I'll work on that. Thanks again, Maxime --zvciie23y5uhhbzh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iJUEABMJAB0WIQTkHFbLp4ejekA/qfgnX84Zoj2+dgUCZkXVvQAKCRAnX84Zoj2+ dhk4AYDogM4jEJWYBgXDz/9UjL6hM3e7hDiwpTPzxkObPEWZiK3oKr2a2v7jLuE5 xTCqq9MBegJT2DFubE/fsL0xtq9L6tXFall+M0VLBe504G/qtrbBpVtz4xc3xqIJ KoTH3BOGyQ== =996h -----END PGP SIGNATURE----- --zvciie23y5uhhbzh--