From patchwork Wed Feb 26 11:24:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11406223 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80C601395 for ; Wed, 26 Feb 2020 11:27:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F8E720637 for ; Wed, 26 Feb 2020 11:27:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qJ5rmCfR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F8E720637 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA0636E8AC; Wed, 26 Feb 2020 11:26:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3CB296E524 for ; Wed, 26 Feb 2020 11:26:05 +0000 (UTC) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BA5F5D53; Wed, 26 Feb 2020 12:25:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1582716358; bh=fJUXwAIIaqXxfYodyZmpFkNElTv9oo7UYaFJdlHcUe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qJ5rmCfRihi1+w58hfNiu9Rc9iKy1HFZAWm4GJQrNkX2E5I5DmgSDeYdC19LVwLNN qrtUR+SbM9TfZL3xaLc3UEwGosyS+uHlDf1U4B7g82vnVDnwb8ArpBwof+tdF55+9L pwh5hF8JjQHNtopbPeAocW1IUxkYYKW+tAVO/q+s= From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v8 31/54] drm/omap: hdmi4: Register a drm_bridge for EDID read Date: Wed, 26 Feb 2020 13:24:51 +0200 Message-Id: <20200226112514.12455-32-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200226112514.12455-1-laurent.pinchart@ideasonboard.com> References: <20200226112514.12455-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In order to integrate with a chain of drm_bridge, the internal HDMI4 encoder has to expose the EDID read operation through the drm_bridge API. Register a bridge at initialisation time to do so. For the time being make the next bridge in the chain optional as the HDMI output is still based on omap_dss_device. The create_connector argument to the bridge attach function is also ignored for the same reason. This will be changed later when removing the related omapdrm-specific display drivers. Signed-off-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Tested-by: Sebastian Reichel Reviewed-by: Sebastian Reichel --- drivers/gpu/drm/omapdrm/dss/hdmi.h | 3 ++ drivers/gpu/drm/omapdrm/dss/hdmi4.c | 78 ++++++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h index c867552c925c..bd43f6abf27b 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "omapdss.h" #include "dss.h" @@ -364,6 +365,7 @@ struct omap_hdmi { bool core_enabled; struct omap_dss_device output; + struct drm_bridge bridge; struct platform_device *audio_pdev; void (*audio_abort_cb)(struct device *dev); @@ -379,5 +381,6 @@ struct omap_hdmi { }; #define dssdev_to_hdmi(dssdev) container_of(dssdev, struct omap_hdmi, output) +#define drm_bridge_to_hdmi(b) container_of(b, struct omap_hdmi, bridge) #endif diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c index 37536b9f3114..67994287447b 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -390,7 +390,8 @@ static void hdmi_disconnect(struct omap_dss_device *src, #define MAX_EDID 512 -static struct edid *hdmi_read_edid_data(struct omap_hdmi *hdmi) +static struct edid *hdmi_read_edid_data(struct omap_hdmi *hdmi, + struct drm_connector *connector) { u8 *edid; int r; @@ -428,9 +429,12 @@ static struct edid *hdmi_read_edid_data(struct omap_hdmi *hdmi) return NULL; } -static struct edid *hdmi_read_edid(struct omap_dss_device *dssdev) +static struct edid * +hdmi_do_read_edid(struct omap_hdmi *hdmi, + struct edid *(*read)(struct omap_hdmi *hdmi, + struct drm_connector *connector), + struct drm_connector *connector) { - struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); struct edid *edid = NULL; unsigned int cec_addr; bool need_enable; @@ -452,7 +456,7 @@ static struct edid *hdmi_read_edid(struct omap_dss_device *dssdev) if (r) goto done; - edid = hdmi_read_edid_data(hdmi); + edid = read(hdmi, connector); done: hdmi_runtime_put(hdmi); @@ -474,6 +478,12 @@ static struct edid *hdmi_read_edid(struct omap_dss_device *dssdev) return edid; } +static struct edid *hdmi_read_edid(struct omap_dss_device *dssdev) +{ + return hdmi_do_read_edid(dssdev_to_hdmi(dssdev), hdmi_read_edid_data, + NULL); +} + static void hdmi_lost_hotplug(struct omap_dss_device *dssdev) { struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); @@ -517,6 +527,56 @@ static const struct omap_dss_device_ops hdmi_ops = { }, }; +/* ----------------------------------------------------------------------------- + * DRM Bridge Operations + */ + +static int hdmi4_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge); + + if (!hdmi->output.next_bridge) + return 0; + + return drm_bridge_attach(bridge->encoder, hdmi->output.next_bridge, + bridge, flags); +} + +static struct edid *hdmi4_bridge_read_edid(struct omap_hdmi *hdmi, + struct drm_connector *connector) +{ + return drm_do_get_edid(connector, hdmi4_core_ddc_read, &hdmi->core); +} + +static struct edid *hdmi4_bridge_get_edid(struct drm_bridge *bridge, + struct drm_connector *connector) +{ + struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge); + + return hdmi_do_read_edid(hdmi, hdmi4_bridge_read_edid, connector); +} + +static const struct drm_bridge_funcs hdmi4_bridge_funcs = { + .attach = hdmi4_bridge_attach, + .get_edid = hdmi4_bridge_get_edid, +}; + +static void hdmi4_bridge_init(struct omap_hdmi *hdmi) +{ + hdmi->bridge.funcs = &hdmi4_bridge_funcs; + hdmi->bridge.of_node = hdmi->pdev->dev.of_node; + hdmi->bridge.ops = DRM_BRIDGE_OP_EDID; + hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA; + + drm_bridge_add(&hdmi->bridge); +} + +static void hdmi4_bridge_cleanup(struct omap_hdmi *hdmi) +{ + drm_bridge_remove(&hdmi->bridge); +} + /* ----------------------------------------------------------------------------- * Audio Callbacks */ @@ -708,6 +768,8 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi) struct omap_dss_device *out = &hdmi->output; int r; + hdmi4_bridge_init(hdmi); + out->dev = &hdmi->pdev->dev; out->id = OMAP_DSS_OUTPUT_HDMI; out->type = OMAP_DISPLAY_TYPE_HDMI; @@ -718,9 +780,11 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi) out->of_port = 0; out->ops_flags = OMAP_DSS_DEVICE_OP_EDID; - r = omapdss_device_init_output(out, NULL); - if (r < 0) + r = omapdss_device_init_output(out, &hdmi->bridge); + if (r < 0) { + hdmi4_bridge_cleanup(hdmi); return r; + } omapdss_device_register(out); @@ -733,6 +797,8 @@ static void hdmi4_uninit_output(struct omap_hdmi *hdmi) omapdss_device_unregister(out); omapdss_device_cleanup_output(out); + + hdmi4_bridge_cleanup(hdmi); } static int hdmi4_probe_of(struct omap_hdmi *hdmi)