From patchwork Tue Dec 8 04:44:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 339701 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3501805jai; Tue, 8 Dec 2020 00:33:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLJqlSZKJZnjbx9wqEIZmDwwqEpZjHBWfCtiYY5IScQaSWQD+X2fO3FoDSDE7zX5+4+Nhf X-Received: by 2002:a63:455e:: with SMTP id u30mr21728586pgk.113.1607416401868; Tue, 08 Dec 2020 00:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607416401; cv=none; d=google.com; s=arc-20160816; b=o0qiDPb+lHaIRRPyl3Cy4gMtaFzsDmMrSF4ASjRri7v2wyQGlCz9UtFlzt2/ZWuG5p nwDHsB3mHF2h8TwlKqeIeS+LxriQV61YAJPKArlVcFoIdX4w76tRVXRwdkAXe9usKAJ9 wLJS4ixqmVkbo83nmt6c0slz2NgvsTvOe9jm/iIEUOJpsnZrsayhftrKnvT74SlVS0JL /nCeyApltmmVM4H/razOk2YEvDUN3i6lvzfq6qrdVbB4pAFRpuYIdHZxygi5ZE+ESm74 OkH6J/OiFoKTKI8zF+BouPq4uDtC3TNyugtlvs32mNMSdn0V85yFzJtKzVePwBb/UCYG OjLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :dkim-signature:delivered-to; bh=4C90LYmas5/DOTpv7+7Ylhl7YS2zCbqf9dEHjdQ6MRU=; b=PLdXZQOxwdvOOBzScqjsXI0gtM7dz27OC/6NxakhBk2+ImUM4q55304ALcaA+/bIsK RUjGLAwCBGf7tetAhMI6hy/kN2IzIV2ER5vixWLjpxVPhYRWA2cVq2nNfvQE9SQr+qU2 Z7Jta2BsiY99vbonBXzsJ5tqDaNM5pSn6qRQPxfOeCMwRwCNtDqcWa23tlQV+Oki/P2/ o912ZQ0xzc25GJE8J3YRaVeIiBNYlzeEXbplrXWA08v01GVpQ7lFPWB7n74PRENvHLxm 8E9HoL54Ly2glJHaW7s0FPMBUKDeJopFv1EGdIOsHGX+PpmqWB74NqGD3O4fWJo+8X54 Q+DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cPp45lFN; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id g11si2175317pjk.75.2020.12.08.00.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 00:33:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cPp45lFN; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F7A56E9BD; Tue, 8 Dec 2020 08:32:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0219C8972C for ; Tue, 8 Dec 2020 04:44:48 +0000 (UTC) Received: by mail-ot1-x344.google.com with SMTP id f16so14759263otl.11 for ; Mon, 07 Dec 2020 20:44:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=S839lFMHy0MANqMX7LWPsNoTjUegKOQvqUVMPavlC6U=; b=cPp45lFN7EuWl0/lks1tVaMwk5uWFdxivYWhaGF4067O3UY2TYPjybuRmrsoFtp181 jyFkty98xB+dpDH/Zp5SKoBL3wi8wGd0kGbMVsZhtxnf0137Ty1SPv9l09C1H5VPQwp9 HRiG7CAvk+PSumHqbQbwSCBlSFG8ubvb4arPsbJvxl2JESREVz14KEqYdpolVA64eHFH 1FPJZ1ZiDhom6U4BDoehZBcOfU9UYbmqB/93NBcpYMGXD4TCxISBD9h6SOjDxKV8+RYP +wB9YGUsEaQ0lwqvvJTniFX0s2sEo176ugxVzL9gG51AsKz1nxAHyJm3LJzR1W1eWBmH 8Kfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=S839lFMHy0MANqMX7LWPsNoTjUegKOQvqUVMPavlC6U=; b=tqKNUV2ZedctaxFyYRSpwkdbrnYve5b4aNcTKrDQA+ApJbJRi6JeflDeZNBMKSDdTu kqoOUFwe3p6ZBr5hKfXa2FYRsHoN2DrQRFJvWHLBW67nDfG3RZ9JU4bJcjHxamCyWD61 ff4Zo+mUkDk015MVNusw/in5vfYnvDQJBFZqBkqLdVo2JYmRQRtDB1rzQ9PaX8X1KbCr BpdiPY2HiyP/rba/WoVNRUxef04h7tlM5yHdH8UZKRfu3gaGKLdkGhPCtl3LxceoeG0D lkfkT5fkJiQRX9zdEOnM2dLjx9/BHIDfvyili+I43lxytHorZGZ258lyen+BRjZhCE5c A85A== X-Gm-Message-State: AOAM532Cow3eDC3xSBlMRIFV8Fe5jWg/W+U9MJU8Q1aUocNOvQszdgFM VfZWllo893VUvhvCdYB66T+86Q== X-Received: by 2002:a05:6830:11cc:: with SMTP id v12mr16250268otq.363.1607402688364; Mon, 07 Dec 2020 20:44:48 -0800 (PST) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id c19sm3171921otn.59.2020.12.07.20.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 20:44:47 -0800 (PST) From: Bjorn Andersson To: Thierry Reding , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [RFC PATCH] drm/panel: Make backlight attachment lazy Date: Mon, 7 Dec 2020 22:44:46 -0600 Message-Id: <20201208044446.973238-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 08 Dec 2020 08:32:06 +0000 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Some bridge chips, such as the TI SN65DSI86 DSI/eDP bridge, provides means of generating a PWM signal for backlight control of the attached panel. The provided PWM chip is typically controlled by the pwm-backlight driver, which if tied to the panel will provide DPMS. But with the current implementation the panel will refuse to probe because the bridge driver has yet to probe and register the PWM chip, and the bridge driver will refuse to probe because it's unable to find the panel. Mitigate this catch-22 situation by allowing the panel driver to probe and retry the attachment of the backlight as the panel is turned on or off. Signed-off-by: Bjorn Andersson --- drivers/gpu/drm/drm_panel.c | 47 +++++++++++++++++++++++++++---------- include/drm/drm_panel.h | 8 +++++++ 2 files changed, 43 insertions(+), 12 deletions(-) -- 2.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index f634371c717a..7487329bd22d 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -43,6 +43,34 @@ static LIST_HEAD(panel_list); * take look at drm_panel_bridge_add() and devm_drm_panel_bridge_add(). */ +#if IS_REACHABLE(CONFIG_BACKLIGHT_CLASS_DEVICE) +static int drm_panel_of_backlight_lazy(struct drm_panel *panel) +{ + struct backlight_device *backlight; + + if (!panel || !panel->dev) + return -EINVAL; + + backlight = devm_of_find_backlight(panel->dev); + + if (IS_ERR(backlight)) { + if (PTR_ERR(backlight) == -EPROBE_DEFER) { + panel->backlight_init_pending = true; + return 0; + } + + return PTR_ERR(backlight); + } + + panel->backlight = backlight; + panel->backlight_init_pending = false; + + return 0; +} +#else +static int drm_panel_of_backlight_lazy(struct drm_panel *panel) { return 0; } +#endif + /** * drm_panel_init - initialize a panel * @panel: DRM panel @@ -161,6 +189,9 @@ int drm_panel_enable(struct drm_panel *panel) return ret; } + if (panel->backlight_init_pending) + drm_panel_of_backlight_lazy(panel); + ret = backlight_enable(panel->backlight); if (ret < 0) DRM_DEV_INFO(panel->dev, "failed to enable backlight: %d\n", @@ -187,6 +218,9 @@ int drm_panel_disable(struct drm_panel *panel) if (!panel) return -EINVAL; + if (panel->backlight_init_pending) + drm_panel_of_backlight_lazy(panel); + ret = backlight_disable(panel->backlight); if (ret < 0) DRM_DEV_INFO(panel->dev, "failed to disable backlight: %d\n", @@ -328,18 +362,7 @@ EXPORT_SYMBOL(of_drm_get_panel_orientation); */ int drm_panel_of_backlight(struct drm_panel *panel) { - struct backlight_device *backlight; - - if (!panel || !panel->dev) - return -EINVAL; - - backlight = devm_of_find_backlight(panel->dev); - - if (IS_ERR(backlight)) - return PTR_ERR(backlight); - - panel->backlight = backlight; - return 0; + return drm_panel_of_backlight_lazy(panel); } EXPORT_SYMBOL(drm_panel_of_backlight); #endif diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 33605c3f0eba..b126abebb2f3 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -149,6 +149,14 @@ struct drm_panel { */ struct backlight_device *backlight; + /** + * @backlight_init_pending + * + * Backlight driver is not yet available so further attempts to + * initialize @backlight is necessary. + */ + bool backlight_init_pending; + /** * @funcs: *