From patchwork Fri Jul 3 19:24:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Ravnborg X-Patchwork-Id: 11642775 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 1738560D for ; Fri, 3 Jul 2020 19:25:02 +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 EA06C20884 for ; Fri, 3 Jul 2020 19:25:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FGm5BDJk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA06C20884 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org 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 2AAFA6EBC3; Fri, 3 Jul 2020 19:24:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 493A46EBC1 for ; Fri, 3 Jul 2020 19:24:46 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id n23so38240225ljh.7 for ; Fri, 03 Jul 2020 12:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E2awxpQwNdgliNiuyXwBUPI0+3Y9fl9Ao6gbJ2At26g=; b=FGm5BDJk5LnvGPrNimY/fzvo7CfLlZhTmykLykjHMKLdKYfM50ukl4toWyrIL2bbgG nceNIXKi9cpjYu03KPwcoN0iv8k+AoBgEZrYDN/Iz3+/pwDqWndv83B80bQvabwF1MHn oE0V4SC5H3yZOyRUY4OFR3lep17273NaNn2VsDfR5klNEd8/mtQ8Wf5WxYCi4K8Xwyln KMxjLnMzOvtJfrZ154cGmmgg6UJs0YSi7lLErWYCZHjGyOaAPwYRrFXxO9zAptJ61egX PlqkuNdkh2Iqe6OdhNEMRH2aspCR7dgtDq53ThasM0v7pL9+j17qFGsNUOdQNxU+8Tr+ ivnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=E2awxpQwNdgliNiuyXwBUPI0+3Y9fl9Ao6gbJ2At26g=; b=kMMR07D0Qh8ojT2vtrgnwuH4bGs1H8wO1vofX3Mj0qlAuh/hP+9PhYrDQ3UTICpaFo o3F23kD3eQIleRDiVK2qe8QhfsepFE3M6rZe5nuPUMuYsEERqCiiiGSHUmbeZz91GBW2 kJRL+znKV2dtlCMWxREE4WH3NhU8nKsBu9qnCVSKh5IkQrT8IOrvzD1fE7Jg+qscrJo5 bEegbHyrmhFYH/LCUg2YU5X9WUM/z3qk0cLUblN5W5+HH8HCnCL6Co0g/OLZ9qBAxoJv SeoxnIUA2S273oO4fAdyUg7/Wiv360aATu1uJE9eWJ6c0qXhG8vfBIKtoZ/rluqiCRem cIBA== X-Gm-Message-State: AOAM532bHHjt1EPIvz/w/u356RpUUEO+ORh+1Q+lZjaym5lEWaIrqhOX EfUoMlPMNwdOxujCElmpC8pOfRxM7BA= X-Google-Smtp-Source: ABdhPJxzddOVjCQQAkP9oHNDpS30Xaw3EZpOvWuHRbBUSK/ADv8qS4sOvhDKD28zfXE147aA4AZLWw== X-Received: by 2002:a2e:7e08:: with SMTP id z8mr15942295ljc.66.1593804284566; Fri, 03 Jul 2020 12:24:44 -0700 (PDT) Received: from saturn.lan ([2a00:fd00:805f:db00:4025:a614:1d5c:b7bc]) by smtp.gmail.com with ESMTPSA id y26sm4411791ljm.46.2020.07.03.12.24.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2020 12:24:44 -0700 (PDT) From: Sam Ravnborg To: dri-devel@lists.freedesktop.org, Laurent Pinchart , Neil Armstrong Subject: [PATCH v3 19/21] drm/bridge: nxp-ptn3460: add get_modes bridge operation Date: Fri, 3 Jul 2020 21:24:15 +0200 Message-Id: <20200703192417.372164-20-sam@ravnborg.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200703192417.372164-1-sam@ravnborg.org> References: <20200703192417.372164-1-sam@ravnborg.org> 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: Jernej Skrabec , Martyn Welch , Jonas Karlman , Peter Senna Tschudin , Andrzej Hajda , Thierry Reding , Sam Ravnborg , kbuild test robot Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add the get_modes() bridge operation to prepare for use as a chained bridge. Add helper function that is also used by the connector. Signed-off-by: Sam Ravnborg Cc: Andrzej Hajda Cc: Neil Armstrong Cc: Laurent Pinchart Cc: Jonas Karlman Cc: Jernej Skrabec --- drivers/gpu/drm/bridge/nxp-ptn3460.c | 52 ++++++++++++++++++---------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/bridge/nxp-ptn3460.c b/drivers/gpu/drm/bridge/nxp-ptn3460.c index 0bd9f0e451b3..e253c185f94c 100644 --- a/drivers/gpu/drm/bridge/nxp-ptn3460.c +++ b/drivers/gpu/drm/bridge/nxp-ptn3460.c @@ -154,17 +154,13 @@ static void ptn3460_disable(struct drm_bridge *bridge) gpiod_set_value(ptn_bridge->gpio_pd_n, 0); } -static int ptn3460_get_modes(struct drm_connector *connector) +static struct edid *ptn3460_get_edid(struct drm_bridge *bridge, + struct drm_connector *connector) { - struct ptn3460_bridge *ptn_bridge; - u8 *edid; - int ret, num_modes = 0; + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); bool power_off; - - ptn_bridge = connector_to_ptn3460(connector); - - if (ptn_bridge->edid) - return drm_add_edid_modes(connector, ptn_bridge->edid); + u8 *edid; + int ret; power_off = !ptn_bridge->enabled; ptn3460_pre_enable(&ptn_bridge->bridge); @@ -172,30 +168,46 @@ static int ptn3460_get_modes(struct drm_connector *connector) edid = kmalloc(EDID_LENGTH, GFP_KERNEL); if (!edid) { DRM_ERROR("Failed to allocate EDID\n"); - return 0; + return NULL; } ret = ptn3460_read_bytes(ptn_bridge, PTN3460_EDID_ADDR, edid, - EDID_LENGTH); + EDID_LENGTH); if (ret) { kfree(edid); - goto out; + return NULL; } + if (power_off) + ptn3460_disable(&ptn_bridge->bridge); + + kfree(ptn_bridge->edid); ptn_bridge->edid = (struct edid *)edid; - drm_connector_update_edid_property(connector, ptn_bridge->edid); - num_modes = drm_add_edid_modes(connector, ptn_bridge->edid); + return ptn_bridge->edid; +} -out: - if (power_off) - ptn3460_disable(&ptn_bridge->bridge); +static int ptn3460_connector_get_modes(struct drm_connector *connector) +{ + struct ptn3460_bridge *ptn_bridge; + struct edid *edid; + + ptn_bridge = connector_to_ptn3460(connector); + + if (ptn_bridge->edid) + return drm_add_edid_modes(connector, ptn_bridge->edid); + + edid = ptn3460_get_edid(&ptn_bridge->bridge, connector); + if (!edid) + return 0; + + drm_connector_update_edid_property(connector, edid); - return num_modes; + return drm_add_edid_modes(connector, edid); } static const struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = { - .get_modes = ptn3460_get_modes, + .get_modes = ptn3460_connector_get_modes, }; static const struct drm_connector_funcs ptn3460_connector_funcs = { @@ -249,6 +261,7 @@ static const struct drm_bridge_funcs ptn3460_bridge_funcs = { .pre_enable = ptn3460_pre_enable, .disable = ptn3460_disable, .attach = ptn3460_bridge_attach, + .get_edid = ptn3460_get_edid, }; static int ptn3460_probe(struct i2c_client *client, @@ -304,6 +317,7 @@ static int ptn3460_probe(struct i2c_client *client, } ptn_bridge->bridge.funcs = &ptn3460_bridge_funcs; + ptn_bridge->bridge.ops = DRM_BRIDGE_OP_EDID; ptn_bridge->bridge.of_node = dev->of_node; drm_bridge_add(&ptn_bridge->bridge);