From patchwork Sun Aug 4 20:16:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Ravnborg X-Patchwork-Id: 11074931 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 4FF081395 for ; Sun, 4 Aug 2019 20:17:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 404B7287A0 for ; Sun, 4 Aug 2019 20:17:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3350A28803; Sun, 4 Aug 2019 20:17:51 +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 A7E3B287A0 for ; Sun, 4 Aug 2019 20:17:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D452A89F03; Sun, 4 Aug 2019 20:17:49 +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 1272A89F03 for ; Sun, 4 Aug 2019 20:17:48 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id r9so77431909ljg.5 for ; Sun, 04 Aug 2019 13:17:47 -0700 (PDT) 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=58L2c6AoPRdtw97mukFPxD0pdo2vv2X7JQRJbq8/vUE=; b=tOYycddbqOaQs+3mXgzx9Dmlbofz8ShLTn+2Gj6fpNAJg7qeNKdKYqysEfbYppPWWR Sm1znIohJmsPyL7X4AmFHRTTLeyWLQLPeTtq9N3BEDkl5fTpPYCD+AaG0Puvbal6wY60 Gv8joUsx+8q4sb69aC2a0kx9vJSZbx2c8q67dVMWhdZdsKc3LHHWDHAEt+QkW56JXDc8 2tDbllzAi8IJfy9IMmp/+niUM5yiAVoBJEj7KCwJOKWAA6qk2M25u0rxXaAjxFZLkaaY FO7iMNf+QKKCoQqMrjgcyJ7DvI4iWajHXxNIFxYuBTqnI9JmW+Xo2B1vJbQd5mRdAJ8c 4fuA== X-Gm-Message-State: APjAAAXEEAwVB9XGYGjvXS03WKzXqiKeDeK6MeS1v5pW9EJmcTf0zLhQ m7T841NteqaJq/sApAto6tnsaVCOvU0BoA== X-Google-Smtp-Source: APXvYqwd3qng5VMg9Mb2Vmyn/6Orka9Dj+RSr/HOVzJm2eC00ZYEFloJNhEpBCBt7pNnr0htBnzZ8A== X-Received: by 2002:a2e:834e:: with SMTP id l14mr30558098ljh.158.1564949866148; Sun, 04 Aug 2019 13:17:46 -0700 (PDT) Received: from saturn.lan (18.158-248-194.customer.lyse.net. [158.248.194.18]) by smtp.gmail.com with ESMTPSA id p87sm16540794ljp.50.2019.08.04.13.17.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 04 Aug 2019 13:17:45 -0700 (PDT) From: Sam Ravnborg To: dri-devel@lists.freedesktop.org, Thierry Reding Subject: [PATCH v1 16/16] drm/panel: simple: use drm_panel infrastructure Date: Sun, 4 Aug 2019 22:16:37 +0200 Message-Id: <20190804201637.1240-17-sam@ravnborg.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org> References: <20190804201637.1240-1-sam@ravnborg.org> MIME-Version: 1.0 X-Mailman-Original-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=58L2c6AoPRdtw97mukFPxD0pdo2vv2X7JQRJbq8/vUE=; b=iWaSTn6msFtanMS3ltawVoyI/akm3SIk334RyboYedy/nyCR1hjYvRVV5qxkjjz0/H HqXXvHotINKZ0MV5HIpyWLnyZtxGL/1hGgmFIEEI7UdhvUfg75bpnhgOJWt5N8zKgrdm iOXfl/+wIB5SpvjXO1jqzazjXb4JocnXkPI+PCSJkpOFvrS+MIjtXrKGdq9eXuHzZGgb +cj5IV6oh60Itbyl7Tn5K5BhmHxd4/gcjJnW0V2KehXKtOWe4oIYhKGzrUlEdTmqAkt/ 88lPYDyYgqhmfZxkZeRgCPjyUrPVFHA+tyGQMdVbBGoApF+gML1pHYItNM5NHOyvti76 MsBw== 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: Neil Armstrong , David Airlie , Laurent Pinchart , Marek Vasut , Laurent Pinchart , Sam Ravnborg , Krzysztof Kozlowski , Jonathan Hunter , Maxime Ripard , Kukjin Kim , Allison Randal , NXP Linux Team , Pengutronix Kernel Team , Jonas Karlman , Alison Wang , Gwan-gyeong Mun , Alexios Zavras , linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, Thomas Gleixner , Sean Paul , linux-arm-kernel@lists.infradead.org, Jernej Skrabec , Shawn Guo , Seung-Woo Kim , Vincent Abriou , Kyungmin Park , Enrico Weigelt Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use drm_panel infrastrucute: - drm_panel has guards for calling disable/enable twice - drm_panel has backlight support To use the drm_panel infrastructure use the drm_panel_* variants for prepare/enable/disable/unprepare. Signed-off-by: Sam Ravnborg Cc: Thierry Reding Cc: Sam Ravnborg Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/panel/panel-simple.c | 73 +++++----------------------- 1 file changed, 11 insertions(+), 62 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index bff7578f84dd..c7eed34f2c9c 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -21,7 +21,6 @@ * DEALINGS IN THE SOFTWARE. */ -#include #include #include #include @@ -98,13 +97,10 @@ struct panel_desc { struct panel_simple { struct drm_panel base; - bool prepared; - bool enabled; bool no_hpd; const struct panel_desc *desc; - struct backlight_device *backlight; struct regulator *supply; struct i2c_adapter *ddc; @@ -232,20 +228,9 @@ static int panel_simple_disable(struct drm_panel *panel) { struct panel_simple *p = to_panel_simple(panel); - if (!p->enabled) - return 0; - - if (p->backlight) { - p->backlight->props.power = FB_BLANK_POWERDOWN; - p->backlight->props.state |= BL_CORE_FBBLANK; - backlight_update_status(p->backlight); - } - if (p->desc->delay.disable) msleep(p->desc->delay.disable); - p->enabled = false; - return 0; } @@ -253,9 +238,6 @@ static int panel_simple_unprepare(struct drm_panel *panel) { struct panel_simple *p = to_panel_simple(panel); - if (!p->prepared) - return 0; - gpiod_set_value_cansleep(p->enable_gpio, 0); regulator_disable(p->supply); @@ -263,8 +245,6 @@ static int panel_simple_unprepare(struct drm_panel *panel) if (p->desc->delay.unprepare) msleep(p->desc->delay.unprepare); - p->prepared = false; - return 0; } @@ -274,9 +254,6 @@ static int panel_simple_prepare(struct drm_panel *panel) unsigned int delay; int err; - if (p->prepared) - return 0; - err = regulator_enable(p->supply); if (err < 0) { dev_err(panel->dev, "failed to enable supply: %d\n", err); @@ -291,8 +268,6 @@ static int panel_simple_prepare(struct drm_panel *panel) if (delay) msleep(delay); - p->prepared = true; - return 0; } @@ -300,20 +275,9 @@ static int panel_simple_enable(struct drm_panel *panel) { struct panel_simple *p = to_panel_simple(panel); - if (p->enabled) - return 0; - if (p->desc->delay.enable) msleep(p->desc->delay.enable); - if (p->backlight) { - p->backlight->props.state &= ~BL_CORE_FBBLANK; - p->backlight->props.power = FB_BLANK_UNBLANK; - backlight_update_status(p->backlight); - } - - p->enabled = true; - return 0; } @@ -413,7 +377,7 @@ static void panel_simple_parse_panel_timing_node(struct device *dev, static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) { - struct device_node *backlight, *ddc; + struct device_node *ddc; struct panel_simple *panel; struct display_timing dt; int err; @@ -422,8 +386,6 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) if (!panel) return -ENOMEM; - panel->enabled = false; - panel->prepared = false; panel->desc = desc; panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd"); @@ -441,24 +403,13 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) return err; } - backlight = of_parse_phandle(dev->of_node, "backlight", 0); - if (backlight) { - panel->backlight = of_find_backlight_by_node(backlight); - of_node_put(backlight); - - if (!panel->backlight) - return -EPROBE_DEFER; - } - ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0); if (ddc) { panel->ddc = of_find_i2c_adapter_by_node(ddc); of_node_put(ddc); - if (!panel->ddc) { - err = -EPROBE_DEFER; - goto free_backlight; - } + if (!panel->ddc) + return -EPROBE_DEFER; } if (!of_get_display_timing(dev->of_node, "panel-timing", &dt)) @@ -468,6 +419,10 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) panel->base.dev = dev; panel->base.funcs = &panel_simple_funcs; + err = drm_panel_of_backlight(&panel->base); + if (err) + goto free_ddc; + err = drm_panel_add(&panel->base); if (err < 0) goto free_ddc; @@ -479,9 +434,6 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) free_ddc: if (panel->ddc) put_device(&panel->ddc->dev); -free_backlight: - if (panel->backlight) - put_device(&panel->backlight->dev); return err; } @@ -492,15 +444,12 @@ static int panel_simple_remove(struct device *dev) drm_panel_remove(&panel->base); - panel_simple_disable(&panel->base); - panel_simple_unprepare(&panel->base); + drm_panel_disable(&panel->base); + drm_panel_unprepare(&panel->base); if (panel->ddc) put_device(&panel->ddc->dev); - if (panel->backlight) - put_device(&panel->backlight->dev); - return 0; } @@ -508,8 +457,8 @@ static void panel_simple_shutdown(struct device *dev) { struct panel_simple *panel = dev_get_drvdata(dev); - panel_simple_disable(&panel->base); - panel_simple_unprepare(&panel->base); + drm_panel_disable(&panel->base); + drm_panel_unprepare(&panel->base); } static const struct drm_display_mode ampire_am_480272h3tmqw_t01h_mode = {