From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 53CBAC54E66 for ; Fri, 15 Mar 2024 08:22:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qWgOO0Syrd2KB+rqpCe3WT16FUfNDE7kdMOxo/N5ThU=; b=mSFShBTZkVMFcl rx7Y5kdssHmfHibNvFbd9K6uOgYIKVziqTQ8/HPIRrKNR61zNNQorZS4uMtX5WPGd0nsxl9sdQUng QhyOmJ9pzjx0b97X7Ouu5WG+F3dVfGr4Wi2sW1g1y68dy9E62/0gU9vn2EvIayjTXVyFqgUFZaRJr kObIAtz96D56+0yhiVLxUPwlBU2YXblqzIL1XNzOHphLWdQm4+jgvbfL9dPj3ZnXeByhaCu15//ts 9z28TZrovJfhgQkw9NxuTO6kervgGWVVminPSwpy8+gQ4bGqR/ufO0aXLlMbwkHAZ9j3j51kMYUYv ggXkI1OxkeqQ8HiiZF7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rl2pU-0000000H8u8-3TEn; Fri, 15 Mar 2024 08:22:16 +0000 Received: from mgamail.intel.com ([192.198.163.15]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rl2pR-0000000H8tC-30cp; Fri, 15 Mar 2024 08:22:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710490934; x=1742026934; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=nVn3aX7+3f9iTQBAed2ZqWdElNcvvfVXItbazWoBUAw=; b=j3qWw58pJJcdVH2ppabA8hzJCRtjBBxxjyYFa4k8gD3j2yUEqm2XvDT5 abqAjIuhPJYgU/Tn9NyfIFaAMxjuFSWGYtzdvgC9pAuMx1ZtgeHYdcXnz s5ZGtcs5BgwfWYNF7aBz9q+jxEmAEXE6aogeV/dTVItgIietpcPdRfM9k R3KG0k5vBGJ4joFhat0T6uPVUL9i+UmFyMQkN0CxK1XiWUNpyN+xW0/GD 0ebepdO2e4hpEVAiFmDEXuT1MMvBFJK4Fkt/bJ8JqHfXUgSu1ST5mDiDt PWS5ykM3WYPzCXuOUaRVmMAU1lYppwX8DbiVDp3N2+W/nX+ricUsUDGMd w==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="5534230" X-IronPort-AV: E=Sophos;i="6.07,127,1708416000"; d="scan'208";a="5534230" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 01:22:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="827780535" X-IronPort-AV: E=Sophos;i="6.07,127,1708416000"; d="scan'208";a="827780535" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orsmga001.jf.intel.com with SMTP; 15 Mar 2024 01:22:06 -0700 Received: by stinkbox (sSMTP sendmail emulation); Fri, 15 Mar 2024 10:22:05 +0200 Date: Fri, 15 Mar 2024 10:22:05 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Maxime Ripard Cc: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Jonathan Corbet , Sandy Huang , Heiko =?iso-8859-1?Q?St=FCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Hans Verkuil , Sebastian Wick , 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 v9 20/27] drm/connector: hdmi: Add Infoframes generation Message-ID: References: <20240311-kms-hdmi-connector-state-v9-0-d45890323344@kernel.org> <20240311-kms-hdmi-connector-state-v9-20-d45890323344@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240311-kms-hdmi-connector-state-v9-20-d45890323344@kernel.org> X-Patchwork-Hint: comment X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240315_012213_823557_84080514 X-CRM114-Status: GOOD ( 28.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 11, 2024 at 03:49:48PM +0100, Maxime Ripard wrote: > Infoframes in KMS is usually handled by a bunch of low-level helpers > that require quite some boilerplate for drivers. This leads to > discrepancies with how drivers generate them, and which are actually > sent. > = > Now that we have everything needed to generate them in the HDMI > connector state, we can generate them in our common logic so that > drivers can simply reuse what we precomputed. > = > Signed-off-by: Maxime Ripard > --- > drivers/gpu/drm/Kconfig | 1 + > drivers/gpu/drm/drm_atomic_state_helper.c | 323 +++++++++++++++= ++++++ > drivers/gpu/drm/drm_connector.c | 14 + > .../gpu/drm/tests/drm_atomic_state_helper_test.c | 1 + > drivers/gpu/drm/tests/drm_connector_test.c | 12 + > include/drm/drm_atomic_state_helper.h | 8 + > include/drm/drm_connector.h | 133 +++++++++ > 7 files changed, 492 insertions(+) > = > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig > index 872edb47bb53..ad9c467e20ce 100644 > --- a/drivers/gpu/drm/Kconfig > +++ b/drivers/gpu/drm/Kconfig > @@ -97,10 +97,11 @@ config DRM_KUNIT_TEST > If in doubt, say "N". > = > config DRM_KMS_HELPER > tristate > depends on DRM > + select DRM_DISPLAY_HDMI_HELPER > help > CRTC helpers for KMS drivers. > = > config DRM_DEBUG_DP_MST_TOPOLOGY_REFS > bool "Enable refcount backtrace history in the DP MST helpers" > diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/= drm_atomic_state_helper.c > index e66272c0d006..2bf53666fc9d 100644 > --- a/drivers/gpu/drm/drm_atomic_state_helper.c > +++ b/drivers/gpu/drm/drm_atomic_state_helper.c > @@ -36,10 +36,12 @@ > #include > #include > #include > #include > = > +#include > + > #include > #include > = > /** > * DOC: atomic state reset and initialization > @@ -912,10 +914,143 @@ hdmi_compute_config(const struct drm_connector *co= nnector, > } > = > return -EINVAL; > } > = > +static int hdmi_generate_avi_infoframe(const struct drm_connector *conne= ctor, > + struct drm_connector_state *state) > +{ > + const struct drm_display_mode *mode =3D > + connector_state_get_mode(state); > + struct drm_connector_hdmi_infoframe *infoframe =3D > + &state->hdmi.infoframes.avi; > + struct hdmi_avi_infoframe *frame =3D > + &infoframe->data.avi; > + bool is_full_range =3D state->hdmi.is_full_range; > + enum hdmi_quantization_range rgb_quant_range =3D > + is_full_range ? HDMI_QUANTIZATION_RANGE_FULL : HDMI_QUANTIZATION_RANGE= _LIMITED; > + int ret; > + > + ret =3D drm_hdmi_avi_infoframe_from_display_mode(frame, connector, mode= ); > + if (ret) > + return ret; > + > + frame->colorspace =3D state->hdmi.output_format; > + > + drm_hdmi_avi_infoframe_quant_range(frame, connector, mode, rgb_quant_ra= nge); drm_hdmi_avi_infoframe_quant_range() doesn't handle YCbCr currently. > + drm_hdmi_avi_infoframe_colorimetry(frame, state); > + drm_hdmi_avi_infoframe_bars(frame, state); > + > + infoframe->set =3D true; > + > + return 0; > +} > + > + > +#define UPDATE_INFOFRAME(c, os, ns, i) \ > + write_or_clear_infoframe(c, \ > + &(c)->hdmi.infoframes.i, \ > + &(os)->hdmi.infoframes.i, \ > + &(ns)->hdmi.infoframes.i) This macro feels like pointless obfuscation to me. > @@ -1984,20 +2063,73 @@ struct drm_connector { > = > /** > * @hdmi: HDMI-related variable and properties. > */ > struct { > +#define DRM_CONNECTOR_HDMI_VENDOR_LEN 8 > + /** > + * @vendor: HDMI Controller Vendor Name > + */ > + unsigned char vendor[DRM_CONNECTOR_HDMI_VENDOR_LEN] __nonstring; > + > +#define DRM_CONNECTOR_HDMI_PRODUCT_LEN 16 > + /** > + * @product: HDMI Controller Product Name > + */ > + unsigned char product[DRM_CONNECTOR_HDMI_PRODUCT_LEN] __nonstring; > + > /** > * @supported_formats: Bitmask of @hdmi_colorspace > * supported by the controller. > */ > unsigned long supported_formats; > = > /** > * @funcs: HDMI connector Control Functions > */ > const struct drm_connector_hdmi_funcs *funcs; > + > + /** > + * @infoframes: Current Infoframes output by the connector > + */ > + struct { > + /** > + * @lock: Mutex protecting against concurrent access to > + * the infoframes, most notably between KMS and ALSA. > + */ > + struct mutex lock; > + > + /** > + * @audio: Current Audio Infoframes structure. Protected > + * by @lock. > + */ > + struct drm_connector_hdmi_infoframe audio; > + > + /** > + * @avi: Current AVI Infoframes structure. Protected by > + * @lock. > + */ > + struct drm_connector_hdmi_infoframe avi; > + > + /** > + * @hdr_drm: Current DRM (Dynamic Range and Mastering) > + * Infoframes structure. Protected by @lock. > + */ > + struct drm_connector_hdmi_infoframe hdr_drm; > + > + /** > + * @spd: Current SPD Infoframes structure. Protected by > + * @lock. > + */ > + struct drm_connector_hdmi_infoframe spd; > + > + /** > + * @vendor: Current HDMI Vendor Infoframes structure. > + * Protected by @lock. > + */ > + struct drm_connector_hdmi_infoframe hdmi; > + } infoframes; > } hdmi; What's the deal with this bloat? These are already tracked in the connector's state so this looks entirely redundant. > }; > = > #define obj_to_connector(x) container_of(x, struct drm_connector, base) > = > @@ -2015,10 +2147,11 @@ int drmm_connector_init(struct drm_device *dev, > const struct drm_connector_funcs *funcs, > int connector_type, > struct i2c_adapter *ddc); > int drmm_connector_hdmi_init(struct drm_device *dev, > struct drm_connector *connector, > + const char *vendor, const char *product, > const struct drm_connector_funcs *funcs, > const struct drm_connector_hdmi_funcs *hdmi_funcs, > int connector_type, > struct i2c_adapter *ddc, > unsigned long supported_formats, > = > -- = > 2.43.2 -- = Ville Syrj=E4l=E4 Intel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel