Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4608547pxb; Thu, 14 Oct 2021 08:29:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXKFz1v5hjds22LIj8Seeg0LK9FmcVwDxpIn6I3Ue8Ak71kfiJy9QkK6VE8pDaGKxvbdV8 X-Received: by 2002:a62:17d3:0:b0:44c:6022:9428 with SMTP id 202-20020a6217d3000000b0044c60229428mr5987541pfx.65.1634225396863; Thu, 14 Oct 2021 08:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634225396; cv=none; d=google.com; s=arc-20160816; b=wMkoBst8kRt7tU4gbOYvxDGExO+QjHBwWew7Q5pKGb7UeS8XknRsnbVurNnp1yyfGP fo7R/SCj2+LQt8GBSd4fCgPFxmVWvNSR7/9mj8IELR58lYEzvDQXSPxm5kpSlfwfjCHn 5dGyeSyt2Qu12MAaPusLNIbnvjqlZn0QvL5PNz+MXYAnZQFlbDXkZcAHBTj6bqbn4/FQ RUDXmuZfcNVmbNGrxGPf2ZQy1FqFZy6aI3LZdEsfkJYcGbIOEgXo2ccy6dQVKMGCC93C L+YnGao1NQ2Fr0lq3oMebWoL/8fzrF28dgJ4JidP7x32jamjObNwgdez22LbaXTYEueo khnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9uFRAg/cSZ1Ge1wEiYH5jWmFxwS6RH3twCyxI3UBC5c=; b=lMKuUC+45I/wUKwjZHMWcT7JtEZ3kl0YwjWbf5F1zh+zoXOoXvrdJ8F+qoA/aHT3ab tMnJDRoOGE1ILCYcjKjMGP1Dlf/1rdmZZhA2dg8dZB8mzYNuH8391xIPj61buIKLr+OB 9zA+hm6QoGbU2s5hGWHXZHfi2ANQQnwcPdf1/x2LZRn9H7MTibGlUEkepJhDlPckpsoj EE+FHu1hko/WzH8JVeAReOYqWcaUoB55GzJ8CNNc3hJTXYnUhmATMJcC02hM5owfMLoB h16dpIQFi+ATU+Z+eKbFEoP1AeWYgMC4KvVvdnZ+91rxyjC0TUae3VM7bne3wO3KC84E rl8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=CegzzxFt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w3si3718646pjf.43.2021.10.14.08.29.43; Thu, 14 Oct 2021 08:29:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=CegzzxFt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233316AbhJNP2m (ORCPT + 99 others); Thu, 14 Oct 2021 11:28:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233465AbhJNP2g (ORCPT ); Thu, 14 Oct 2021 11:28:36 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 525E7C061766 for ; Thu, 14 Oct 2021 08:26:30 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id x27so28341076lfa.9 for ; Thu, 14 Oct 2021 08:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9uFRAg/cSZ1Ge1wEiYH5jWmFxwS6RH3twCyxI3UBC5c=; b=CegzzxFtb/uayp1+8cDO1U6QxOoeWj31k1k1Z7XOfoo/i5+bHkASQvbn9FvaS6p/uu zyF2bI8Dlz48Ki38g+v8EKeY3wBd7rRxKgwiYxQ4Kdz07k7zJikiY/sVfzPpM96SUP3V 3QBBqZsIfzDufuPB42h2s4XgIMYIla38OL/zrNs4WISrmGbRbXACPpVK24cDsuUAgZTI HyyjlP5dXGMF6a6JmkpWf7Dp6oXf+ckaBDrMhcOglx+Xmv8i3XeahsyJ11Y1teohpSlg oH+mVbvQ+KxcbOFy/khczxq+/xllWkTBcS1Vin7m9JDit2i4TuXJ9m3RQNBHXLkNBCcD geMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9uFRAg/cSZ1Ge1wEiYH5jWmFxwS6RH3twCyxI3UBC5c=; b=zrsSkseRRldcurtVXyb0Y4tg4FPSD+OI8MCaLo8XdVy7y84Vuh4g/sQjhLF5vHtF8j GovRH85G/DHUQ7nmRwlJZ1+MClvf+HfQC1pAaHxls/j1NaFgMBT1wPFRi3/cc3AqpW9b CNrMi3N37gb1PyHcGno7QysB8e7YbhIZ4ywnnRWaH44R4EZ04a7tYoejFRxVTXO5a1gb gDYUkLPX8FeIyYGgL2qN87WRxx8OW3EHeHQV59z5itDXsFPRYy4KZsRbda9Jt6ydZ6BF V6NO3Ln/1UMQqBhA9D4mZLJhutDogvPUqYaUvwnRVxcj7BtlI0hPJzFHnjEWSyl3zWLb EZXQ== X-Gm-Message-State: AOAM5329MeOVbWcqcUM4QCqB3+DCPSJjPhrSSN5J3RTOAIruAtdYuPnT cSooHoOrOcHB83scblzxsGe5IJBwdhqhOg== X-Received: by 2002:adf:9b97:: with SMTP id d23mr7342393wrc.135.1634225177180; Thu, 14 Oct 2021 08:26:17 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:209b:8400:2b80:b4ae]) by smtp.gmail.com with ESMTPSA id k22sm2626790wrd.59.2021.10.14.08.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 08:26:16 -0700 (PDT) From: Neil Armstrong To: daniel@ffwll.ch, Laurent.pinchart@ideasonboard.com Cc: martin.blumenstingl@googlemail.com, dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Neil Armstrong Subject: [PATCH 5/7] drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR Date: Thu, 14 Oct 2021 17:26:04 +0200 Message-Id: <20211014152606.2289528-6-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211014152606.2289528-1-narmstrong@baylibre.com> References: <20211014152606.2289528-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7744; h=from:subject; bh=6i6KMw5kTyiPYblQgBG12n2DEPIZia2mYTPpIOLuziA=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhaEuA/2fFsyQw1JOef8WiTXD7UMaSzOoThtR9lJXC d6jt0DCJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYWhLgAAKCRB33NvayMhJ0Z6OD/ 9RP0uaVWA6EnqwnTt5JQMCDaCIBbX6KmvlbMTRxFt5vBaFuFaqSOQGLyxcWBu12Fgn0khi3fl6pfn6 EzZ3iID8xbgAnoSyNj/QMiwOcVVelzuK0xDxlQwH2crdVVgKCulq1lnBi8C2OQ4x7NN3i+e3LevgIk bOBIXUH14xVi0BEhIAy7PbvuQc6/KNN8nNjss+uEQcHH6UbPHtDIxpepVPRdD6rncFOxZ/aqKcEf9F hVYJL3YmBxoQM4rf1mKd0Qqvm+k6j/C/UlIIIlm5KetkfgDYRX7ZfP3VZnGWnQV3ZU2k/hZbKhiQKH DwrSlvYG1yG874xnwPbOZYfD9IJWNHnVNg6YeTeQjleKLBX+Mxg3OUUDM3oOEYuKWe9fK/I+UK/NZQ +TO43vYsrIHrRAi+aaiSvEDPKimW+iHOWowQAYAd+T16PVnzyOsC7Qy8bwYHfzmgc+2UuTEHm9YQ9E CJI0cVudV7KcNl2b7ji82l38K7fBbM9KB/2UGpKXFSeYvHX5jl3k+cBaiRsQwRZJzcbDxtpNYK5qoF sOuQkYZ95JORAPj7xmjqIIudXSF+m934EcvFi0B3AmU2gZQDU4QHwir+xiGc8h9oVeVMRfWKgYEA+S UYc0ZmTALl0aMM9B4JPpKNUT7Bjl6WzJOKAo4m9AdmeJAruU5V6B9laHY5bA== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This implements the necessary change to no more use the embedded connector in dw-hdmi and use the dedicated bridge connector driver by passing DRM_BRIDGE_ATTACH_NO_CONNECTOR to the bridge attach call. The necessary connector properties are added to handle the same functionalities as the embedded dw-hdmi connector, i.e. the HDR metadata, the CEC notifier & other flags. The dw-hdmi output_port is set to 1 in order to look for a connector next bridge in order to get DRM_BRIDGE_ATTACH_NO_CONNECTOR working. Signed-off-by: Neil Armstrong --- drivers/gpu/drm/meson/Kconfig | 2 + drivers/gpu/drm/meson/meson_dw_hdmi.c | 1 + drivers/gpu/drm/meson/meson_encoder_hdmi.c | 81 +++++++++++++++++++++- 3 files changed, 82 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/meson/Kconfig b/drivers/gpu/drm/meson/Kconfig index 9f9281dd49f8..a4e1ed96e5e8 100644 --- a/drivers/gpu/drm/meson/Kconfig +++ b/drivers/gpu/drm/meson/Kconfig @@ -6,9 +6,11 @@ config DRM_MESON select DRM_KMS_HELPER select DRM_KMS_CMA_HELPER select DRM_GEM_CMA_HELPER + select DRM_DISPLAY_CONNECTOR select VIDEOMODE_HELPERS select REGMAP_MMIO select MESON_CANVAS + select CEC_CORE if CEC_NOTIFIER config DRM_MESON_DW_HDMI tristate "HDMI Synopsys Controller support for Amlogic Meson Display" diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index c2480b3335ac..933ff63b1ecf 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -805,6 +805,7 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master, dw_plat_data->input_bus_encoding = V4L2_YCBCR_ENC_709; dw_plat_data->ycbcr_420_allowed = true; dw_plat_data->disable_cec = true; + dw_plat_data->output_port = 1; if (dw_hdmi_is_compatible(meson_dw_hdmi, "amlogic,meson-gxl-dw-hdmi") || dw_hdmi_is_compatible(meson_dw_hdmi, "amlogic,meson-gxm-dw-hdmi") || diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c index c775a1ab5b1e..a4264587d89a 100644 --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c @@ -14,9 +14,12 @@ #include #include +#include + #include #include #include +#include #include #include #include @@ -34,8 +37,10 @@ struct meson_encoder_hdmi { struct drm_encoder encoder; struct drm_bridge bridge; struct drm_bridge *next_bridge; + struct drm_connector *connector; struct meson_drm *priv; unsigned long output_bus_fmt; + struct cec_notifier *cec_notifier; }; #define bridge_to_meson_encoder_hdmi(x) \ @@ -50,6 +55,14 @@ static int meson_encoder_hdmi_attach(struct drm_bridge *bridge, &encoder_hdmi->bridge, flags); } +static void meson_encoder_hdmi_detach(struct drm_bridge *bridge) +{ + struct meson_encoder_hdmi *encoder_hdmi = bridge_to_meson_encoder_hdmi(bridge); + + cec_notifier_conn_unregister(encoder_hdmi->cec_notifier); + encoder_hdmi->cec_notifier = NULL; +} + static void meson_encoder_hdmi_enable(struct drm_bridge *bridge) { struct meson_encoder_hdmi *encoder_hdmi = bridge_to_meson_encoder_hdmi(bridge); @@ -284,12 +297,33 @@ static int meson_encoder_hdmi_atomic_check(struct drm_bridge *bridge, return 0; } +static void meson_encoder_hdmi_hpd_notify(struct drm_bridge *bridge, + enum drm_connector_status status) +{ + struct meson_encoder_hdmi *encoder_hdmi = bridge_to_meson_encoder_hdmi(bridge); + struct edid *edid; + + if (!encoder_hdmi->cec_notifier) + return; + + if (status == connector_status_connected) { + edid = drm_bridge_get_edid(encoder_hdmi->next_bridge, encoder_hdmi->connector); + if (!edid) + return; + + cec_notifier_set_phys_addr_from_edid(encoder_hdmi->cec_notifier, edid); + } else + cec_notifier_phys_addr_invalidate(encoder_hdmi->cec_notifier); +} + static const struct drm_bridge_funcs meson_encoder_hdmi_bridge_funcs = { .attach = meson_encoder_hdmi_attach, + .detach = meson_encoder_hdmi_detach, .enable = meson_encoder_hdmi_enable, .disable = meson_encoder_hdmi_disable, .mode_valid = meson_encoder_hdmi_mode_valid, .mode_set = meson_encoder_hdmi_mode_set, + .hpd_notify = meson_encoder_hdmi_hpd_notify, .atomic_get_input_bus_fmts = meson_encoder_hdmi_get_inp_bus_fmts, .atomic_check = meson_encoder_hdmi_atomic_check, .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, @@ -300,6 +334,7 @@ static const struct drm_bridge_funcs meson_encoder_hdmi_bridge_funcs = { int meson_encoder_hdmi_init(struct meson_drm *priv) { struct meson_encoder_hdmi *meson_encoder_hdmi; + struct platform_device *pdev; struct device_node *remote; int ret; @@ -326,6 +361,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) meson_encoder_hdmi->bridge.funcs = &meson_encoder_hdmi_bridge_funcs; meson_encoder_hdmi->bridge.of_node = priv->dev->of_node; meson_encoder_hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA; + meson_encoder_hdmi->bridge.interlace_allowed = true; drm_bridge_add(&meson_encoder_hdmi->bridge); @@ -342,17 +378,58 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) meson_encoder_hdmi->encoder.possible_crtcs = BIT(0); /* Attach HDMI Encoder Bridge to Encoder */ - ret = drm_bridge_attach(&meson_encoder_hdmi->encoder, &meson_encoder_hdmi->bridge, NULL, 0); + ret = drm_bridge_attach(&meson_encoder_hdmi->encoder, &meson_encoder_hdmi->bridge, NULL, + DRM_BRIDGE_ATTACH_NO_CONNECTOR); if (ret) { dev_err(priv->dev, "Failed to attach bridge: %d\n", ret); return ret; } + /* Initialize & attach Bridge Connector */ + meson_encoder_hdmi->connector = drm_bridge_connector_init(priv->drm, + &meson_encoder_hdmi->encoder); + if (IS_ERR(meson_encoder_hdmi->connector)) { + dev_err(priv->dev, "Unable to create HDMI bridge connector\n"); + return PTR_ERR(meson_encoder_hdmi->connector); + } + drm_connector_attach_encoder(meson_encoder_hdmi->connector, + &meson_encoder_hdmi->encoder); + /* * We should have now in place: - * encoder->[hdmi encoder bridge]->[dw-hdmi bridge]->[dw-hdmi connector] + * encoder->[hdmi encoder bridge]->[dw-hdmi bridge]->[display connector bridge]->[display connector] */ + /* + * drm_connector_attach_max_bpc_property() requires the + * connector to have a state. + */ + drm_atomic_helper_connector_reset(meson_encoder_hdmi->connector); + + if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXL) || + meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM) || + meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) + drm_connector_attach_hdr_output_metadata_property(meson_encoder_hdmi->connector); + + drm_connector_attach_max_bpc_property(meson_encoder_hdmi->connector, 8, 8); + + /* Handle this here until handled by drm_bridge_connector_init() */ + meson_encoder_hdmi->connector->ycbcr_420_allowed = true; + + pdev = of_find_device_by_node(remote); + if (pdev) { + struct cec_connector_info conn_info; + struct cec_notifier *notifier; + + cec_fill_conn_info_from_drm(&conn_info, meson_encoder_hdmi->connector); + + notifier = cec_notifier_conn_register(&pdev->dev, NULL, &conn_info); + if (!notifier) + return -ENOMEM; + + meson_encoder_hdmi->cec_notifier = notifier; + } + DRM_DEBUG_DRIVER("HDMI encoder initialized\n"); return 0; -- 2.25.1