dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Sean Paul <seanpaul@chromium.org>
To: dri-devel@lists.freedesktop.org
Subject: [RFC PATCH 3/3] drm/panel: panel-sharp-ls043t1le01: Use panel-common helpers
Date: Thu, 16 Mar 2017 18:08:33 -0400	[thread overview]
Message-ID: <20170316220837.17347-4-seanpaul@chromium.org> (raw)
In-Reply-To: <20170316220837.17347-1-seanpaul@chromium.org>

Instead of duplicating common code from panel-simple, use the panel-common helpers.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/panel/Kconfig                   |  1 +
 drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c | 70 +++++++------------------
 2 files changed, 20 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 98db78d22a13..22f374f414cd 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -88,6 +88,7 @@ config DRM_PANEL_SHARP_LS043T1LE01
 	depends on OF
 	depends on DRM_MIPI_DSI
 	depends on BACKLIGHT_CLASS_DEVICE
+	select DRM_PANEL_COMMON
 	help
 	  Say Y here if you want to enable support for Sharp LS043T1LE01 qHD
 	  (540x960) DSI panel as found on the Qualcomm APQ8074 Dragonboard
diff --git a/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c b/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c
index 3aeb0bda4947..d89e45aa4912 100644
--- a/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c
+++ b/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c
@@ -18,11 +18,9 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <linux/backlight.h>
 #include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/regulator/consumer.h>
 
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
@@ -31,16 +29,16 @@
 
 #include <video/mipi_display.h>
 
+#include "panel-common.h"
+
 struct sharp_nt_panel {
 	struct drm_panel base;
+	struct panel_common common;
 	struct mipi_dsi_device *dsi;
 
-	struct backlight_device *backlight;
-	struct regulator *supply;
 	struct gpio_desc *reset_gpio;
 
 	bool prepared;
-	bool enabled;
 
 	const struct drm_display_mode *mode;
 };
@@ -114,17 +112,7 @@ static int sharp_nt_panel_disable(struct drm_panel *panel)
 {
 	struct sharp_nt_panel *sharp_nt = to_sharp_nt_panel(panel);
 
-	if (!sharp_nt->enabled)
-		return 0;
-
-	if (sharp_nt->backlight) {
-		sharp_nt->backlight->props.power = FB_BLANK_POWERDOWN;
-		backlight_update_status(sharp_nt->backlight);
-	}
-
-	sharp_nt->enabled = false;
-
-	return 0;
+	return panel_common_disable(&sharp_nt->common, 0);
 }
 
 static int sharp_nt_panel_unprepare(struct drm_panel *panel)
@@ -141,7 +129,10 @@ static int sharp_nt_panel_unprepare(struct drm_panel *panel)
 		return ret;
 	}
 
-	regulator_disable(sharp_nt->supply);
+	ret = panel_common_unprepare(&sharp_nt->common, 0);
+	if (ret < 0)
+		dev_err(panel->dev, "failed common unprepare: %d\n", ret);
+
 	if (sharp_nt->reset_gpio)
 		gpiod_set_value(sharp_nt->reset_gpio, 0);
 
@@ -158,12 +149,10 @@ static int sharp_nt_panel_prepare(struct drm_panel *panel)
 	if (sharp_nt->prepared)
 		return 0;
 
-	ret = regulator_enable(sharp_nt->supply);
+	ret = panel_common_prepare(&sharp_nt->common, 20);
 	if (ret < 0)
 		return ret;
 
-	msleep(20);
-
 	if (sharp_nt->reset_gpio) {
 		gpiod_set_value(sharp_nt->reset_gpio, 1);
 		msleep(1);
@@ -190,7 +179,7 @@ static int sharp_nt_panel_prepare(struct drm_panel *panel)
 	return 0;
 
 poweroff:
-	regulator_disable(sharp_nt->supply);
+	panel_common_unprepare(&sharp_nt->common, 0);
 	if (sharp_nt->reset_gpio)
 		gpiod_set_value(sharp_nt->reset_gpio, 0);
 	return ret;
@@ -200,17 +189,7 @@ static int sharp_nt_panel_enable(struct drm_panel *panel)
 {
 	struct sharp_nt_panel *sharp_nt = to_sharp_nt_panel(panel);
 
-	if (sharp_nt->enabled)
-		return 0;
-
-	if (sharp_nt->backlight) {
-		sharp_nt->backlight->props.power = FB_BLANK_UNBLANK;
-		backlight_update_status(sharp_nt->backlight);
-	}
-
-	sharp_nt->enabled = true;
-
-	return 0;
+	return panel_common_enable(&sharp_nt->common, 0);
 }
 
 static const struct drm_display_mode default_mode = {
@@ -259,14 +238,14 @@ static const struct drm_panel_funcs sharp_nt_panel_funcs = {
 static int sharp_nt_panel_add(struct sharp_nt_panel *sharp_nt)
 {
 	struct device *dev = &sharp_nt->dsi->dev;
-	struct device_node *np;
 	int ret;
 
 	sharp_nt->mode = &default_mode;
 
-	sharp_nt->supply = devm_regulator_get(dev, "avdd");
-	if (IS_ERR(sharp_nt->supply))
-		return PTR_ERR(sharp_nt->supply);
+	ret = panel_common_init(dev, &sharp_nt->common, "avdd", "",
+				"backlight");
+	if (ret < 0)
+		return ret;
 
 	sharp_nt->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(sharp_nt->reset_gpio)) {
@@ -277,28 +256,18 @@ static int sharp_nt_panel_add(struct sharp_nt_panel *sharp_nt)
 		gpiod_set_value(sharp_nt->reset_gpio, 0);
 	}
 
-	np = of_parse_phandle(dev->of_node, "backlight", 0);
-	if (np) {
-		sharp_nt->backlight = of_find_backlight_by_node(np);
-		of_node_put(np);
-
-		if (!sharp_nt->backlight)
-			return -EPROBE_DEFER;
-	}
-
 	drm_panel_init(&sharp_nt->base);
 	sharp_nt->base.funcs = &sharp_nt_panel_funcs;
 	sharp_nt->base.dev = &sharp_nt->dsi->dev;
 
 	ret = drm_panel_add(&sharp_nt->base);
 	if (ret < 0)
-		goto put_backlight;
+		goto err_common;
 
 	return 0;
 
-put_backlight:
-	if (sharp_nt->backlight)
-		put_device(&sharp_nt->backlight->dev);
+err_common:
+	panel_common_fini(&sharp_nt->common);
 
 	return ret;
 }
@@ -308,8 +277,7 @@ static void sharp_nt_panel_del(struct sharp_nt_panel *sharp_nt)
 	if (sharp_nt->base.dev)
 		drm_panel_remove(&sharp_nt->base);
 
-	if (sharp_nt->backlight)
-		put_device(&sharp_nt->backlight->dev);
+	panel_common_fini(&sharp_nt->common);
 }
 
 static int sharp_nt_panel_probe(struct mipi_dsi_device *dsi)
-- 
2.12.0.367.g23dc2f6d3c-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-03-16 22:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 22:08 [RFC PATCH 0/3] drm/panel: Pull some code out into common helpers Sean Paul
2017-03-16 22:08 ` [RFC PATCH 1/3] drm/panel: Pull common panel code out into helpers Sean Paul
2017-03-25 14:23   ` Emil Velikov
2017-03-16 22:08 ` [RFC PATCH 2/3] drm/panel: sharp-lq101r1sx01: Use panel-common helpers Sean Paul
2017-03-21 21:06   ` Eric Anholt
2017-03-22 14:16     ` Sean Paul
2017-03-16 22:08 ` Sean Paul [this message]
2017-03-25 14:39   ` [RFC PATCH 3/3] drm/panel: panel-sharp-ls043t1le01: " Emil Velikov
2017-03-17 14:17 ` [RFC PATCH 0/3] drm/panel: Pull some code out into common helpers Sean Paul
2017-03-25 12:05   ` Noralf Trønnes
2017-03-21 21:08 ` Eric Anholt
2017-03-22 14:36 ` Emil Velikov
2017-03-22 15:06   ` Sean Paul
2017-03-25 14:19     ` Emil Velikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170316220837.17347-4-seanpaul@chromium.org \
    --to=seanpaul@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).