From patchwork Sun Jul 7 18:19:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11034271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2B01138B for ; Sun, 7 Jul 2019 18:37:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B102C2832D for ; Sun, 7 Jul 2019 18:37:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A59142835B; Sun, 7 Jul 2019 18:37:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 51A932832D for ; Sun, 7 Jul 2019 18:37:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 235C089BD4; Sun, 7 Jul 2019 18:37:31 +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 [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id C709789BD4 for ; Sun, 7 Jul 2019 18:37:29 +0000 (UTC) Received: from pendragon.nordic-sky.finnair.com (unknown [38.98.37.142]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C1146AF9; Sun, 7 Jul 2019 20:37:11 +0200 (CEST) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH 48/60] drm/omap: hdmi4: Simplify EDID read Date: Sun, 7 Jul 2019 21:19:25 +0300 Message-Id: <20190707181937.6250-45-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190707181937.6250-1-laurent.pinchart@ideasonboard.com> References: <20190707180852.5512-1-laurent.pinchart@ideasonboard.com> <20190707181937.6250-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562524648; bh=u6N41sFjfIsctsC7ZiADCjqlA1gdMpJOuhZfV8ZMubk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c1Nt14vpn6gjCtTFhTaVjhL8fttJVOI/1GtXHGPPSErkH6mm2HlEbScbFr8pwd8Oc YhgqhC72aiqPTwPKnE0RE+pOuCkmf8jIooP7loDvKPIiA2soxtDbk811zuIKTZMvoj 0JgeinIrtu7tOpgHTydT2tl4pLz2OUB3ibBgRTgs= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Sebastian Reichel , Tomi Valkeinen , Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that the omap_dss_device EDID read operation has been removed, simplify the bridge-based EDID access by merging multiple functions together. Signed-off-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 96 ++++++++++++----------------- 1 file changed, 40 insertions(+), 56 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c index 70d98f39b8c6..b8a552b25f43 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -319,55 +319,6 @@ void hdmi4_core_disable(struct hdmi_core_data *core) mutex_unlock(&hdmi->lock); } -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 edid *edid = NULL; - unsigned int cec_addr; - bool need_enable; - int r; - - need_enable = hdmi->core_enabled == false; - - if (need_enable) { - r = hdmi4_core_enable(&hdmi->core); - if (r) - return NULL; - } - - mutex_lock(&hdmi->lock); - r = hdmi_runtime_get(hdmi); - BUG_ON(r); - - r = hdmi4_core_ddc_init(&hdmi->core); - if (r) - goto done; - - edid = read(hdmi, connector); - -done: - hdmi_runtime_put(hdmi); - mutex_unlock(&hdmi->lock); - - if (edid && edid->extensions) { - unsigned int len = (edid->extensions + 1) * EDID_LENGTH; - - cec_addr = cec_get_edid_phys_addr((u8 *)edid, len, NULL); - } else { - cec_addr = CEC_PHYS_ADDR_INVALID; - } - - hdmi4_cec_set_phys_addr(&hdmi->core, cec_addr); - - if (need_enable) - hdmi4_core_disable(&hdmi->core); - - return edid; -} - /* ----------------------------------------------------------------------------- * DRM Bridge Operations */ @@ -491,18 +442,51 @@ static void hdmi4_bridge_lost_hotplug(struct drm_bridge *bridge) hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID); } -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); + struct edid *edid = NULL; + unsigned int cec_addr; + bool need_enable; + int r; - return hdmi_do_read_edid(hdmi, hdmi4_bridge_read_edid, connector); + need_enable = hdmi->core_enabled == false; + + if (need_enable) { + r = hdmi4_core_enable(&hdmi->core); + if (r) + return NULL; + } + + mutex_lock(&hdmi->lock); + r = hdmi_runtime_get(hdmi); + BUG_ON(r); + + r = hdmi4_core_ddc_init(&hdmi->core); + if (r) + goto done; + + edid = drm_do_get_edid(connector, hdmi4_core_ddc_read, &hdmi->core); + +done: + hdmi_runtime_put(hdmi); + mutex_unlock(&hdmi->lock); + + if (edid && edid->extensions) { + unsigned int len = (edid->extensions + 1) * EDID_LENGTH; + + cec_addr = cec_get_edid_phys_addr((u8 *)edid, len, NULL); + } else { + cec_addr = CEC_PHYS_ADDR_INVALID; + } + + hdmi4_cec_set_phys_addr(&hdmi->core, cec_addr); + + if (need_enable) + hdmi4_core_disable(&hdmi->core); + + return edid; } static const struct drm_bridge_funcs hdmi4_bridge_funcs = {