From: Sean Paul <seanpaul@chromium.org>
To: Eric Anholt <eric@anholt.net>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [RFC PATCH 2/3] drm/panel: sharp-lq101r1sx01: Use panel-common helpers
Date: Wed, 22 Mar 2017 10:16:18 -0400 [thread overview]
Message-ID: <20170322141618.GO19389@art_vandelay> (raw)
In-Reply-To: <87poha1grx.fsf@eliezer.anholt.net>
On Tue, Mar 21, 2017 at 02:06:26PM -0700, Eric Anholt wrote:
> Sean Paul <seanpaul@chromium.org> writes:
>
> > 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-lq101r1sx01.c | 79 +++++++------------------
> > 2 files changed, 24 insertions(+), 56 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> > index be8590724042..98db78d22a13 100644
> > --- a/drivers/gpu/drm/panel/Kconfig
> > +++ b/drivers/gpu/drm/panel/Kconfig
> > @@ -73,6 +73,7 @@ config DRM_PANEL_SHARP_LQ101R1SX01
> > 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 LQ101R1SX01
> > TFT-LCD modules. The panel has a 2560x1600 resolution and uses
> > diff --git a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
> > index 3cce3ca19601..fb2bf67449ab 100644
> > --- a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
> > +++ b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
> > @@ -6,11 +6,8 @@
> > * published by the Free Software Foundation.
> > */
> >
> > -#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>
> > @@ -19,17 +16,17 @@
> >
> > #include <video/mipi_display.h>
> >
> > +#include "panel-common.h"
> > +
> > struct sharp_panel {
> > struct drm_panel base;
> > + struct panel_common common;
> > +
> > /* the datasheet refers to them as DSI-LINK1 and DSI-LINK2 */
> > struct mipi_dsi_device *link1;
> > struct mipi_dsi_device *link2;
> >
> > - struct backlight_device *backlight;
> > - struct regulator *supply;
> > -
> > bool prepared;
> > - bool enabled;
> >
> > const struct drm_display_mode *mode;
> > };
> > @@ -93,17 +90,7 @@ static int sharp_panel_disable(struct drm_panel *panel)
> > {
> > struct sharp_panel *sharp = to_sharp_panel(panel);
> >
> > - if (!sharp->enabled)
> > - return 0;
> > -
> > - if (sharp->backlight) {
> > - sharp->backlight->props.power = FB_BLANK_POWERDOWN;
> > - backlight_update_status(sharp->backlight);
> > - }
> > -
> > - sharp->enabled = false;
> > -
> > - return 0;
> > + return panel_common_disable(&sharp->common, 0);
> > }
> >
> > static int sharp_panel_unprepare(struct drm_panel *panel)
> > @@ -126,11 +113,13 @@ static int sharp_panel_unprepare(struct drm_panel *panel)
> >
> > msleep(120);
> >
> > - regulator_disable(sharp->supply);
> > + err = panel_common_unprepare(&sharp->common, 0);
> > + if (err < 0)
> > + dev_err(panel->dev, "failed common unprepare: %d\n", err);
> >
> > sharp->prepared = false;
> >
> > - return 0;
> > + return err;
> > }
> >
> > static int sharp_setup_symmetrical_split(struct mipi_dsi_device *left,
> > @@ -176,17 +165,15 @@ static int sharp_panel_prepare(struct drm_panel *panel)
> > if (sharp->prepared)
> > return 0;
> >
> > - err = regulator_enable(sharp->supply);
> > - if (err < 0)
> > - return err;
> > -
> > /*
> > * According to the datasheet, the panel needs around 10 ms to fully
> > * power up. At least another 120 ms is required before exiting sleep
> > * mode to make sure the panel is ready. Throw in another 20 ms for
> > * good measure.
> > */
> > - msleep(150);
> > + err = panel_common_prepare(&sharp->common, 150);
> > + if (err < 0)
> > + return err;
>
> Aside: I like how 120 + 20 = 150, because always round up your delays :)
You missed the initial 10ms to "fully power up", so it's 10 + 120 + 20 = 150
That said, you can never have enough fudge in your delays :-)
>
> >
> > err = mipi_dsi_dcs_exit_sleep_mode(sharp->link1);
> > if (err < 0) {
> > @@ -252,7 +239,7 @@ static int sharp_panel_prepare(struct drm_panel *panel)
> > return 0;
> >
> > poweroff:
> > - regulator_disable(sharp->supply);
> > + panel_common_unprepare(&sharp->common, 0);
> > return err;
> > }
> >
> > @@ -260,17 +247,7 @@ static int sharp_panel_enable(struct drm_panel *panel)
> > {
> > struct sharp_panel *sharp = to_sharp_panel(panel);
> >
> > - if (sharp->enabled)
> > - return 0;
> > -
> > - if (sharp->backlight) {
> > - sharp->backlight->props.power = FB_BLANK_UNBLANK;
> > - backlight_update_status(sharp->backlight);
> > - }
> > -
> > - sharp->enabled = true;
> > -
> > - return 0;
> > + return panel_common_enable(&sharp->common, 0);
> > }
> >
> > static const struct drm_display_mode default_mode = {
> > @@ -324,23 +301,15 @@ MODULE_DEVICE_TABLE(of, sharp_of_match);
> >
> > static int sharp_panel_add(struct sharp_panel *sharp)
> > {
> > - struct device_node *np;
> > int err;
> >
> > sharp->mode = &default_mode;
> > + sharp->prepared = false;
> >
> > - sharp->supply = devm_regulator_get(&sharp->link1->dev, "power");
> > - if (IS_ERR(sharp->supply))
> > - return PTR_ERR(sharp->supply);
> > -
> > - np = of_parse_phandle(sharp->link1->dev.of_node, "backlight", 0);
> > - if (np) {
> > - sharp->backlight = of_find_backlight_by_node(np);
> > - of_node_put(np);
> > -
> > - if (!sharp->backlight)
> > - return -EPROBE_DEFER;
> > - }
> > + err = panel_common_init(&sharp->link1->dev, &sharp->common, "supply",
> > + "gpio", "backlight");
> > + if (err < 0)
> > + return err;
>
> Looks like you've incidentally changed the regulator name from "power"
> to "supply". Seems like it should be a called out in the commit
> message, if intentional.
Oh my, yes I did, thanks for catching that. I'll fix this up locally and wait
for Thierry to weigh in before posting a v2.
Sean
--
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-03-22 14:16 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 [this message]
2017-03-16 22:08 ` [RFC PATCH 3/3] drm/panel: panel-sharp-ls043t1le01: " Sean Paul
2017-03-25 14:39 ` 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=20170322141618.GO19389@art_vandelay \
--to=seanpaul@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=eric@anholt.net \
/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