From: Sam Ravnborg <sam@ravnborg.org>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: daniel.vetter@ffwll.ch, emil.l.velikov@gmail.com,
josef@lusticky.cz, dri-devel@lists.freedesktop.org,
thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com
Subject: Re: [PATCH 4/4] drm/panel/ili9341: Support DPI panels
Date: Sun, 11 Aug 2019 19:02:02 +0200 [thread overview]
Message-ID: <20190811170201.GF14660@ravnborg.org> (raw)
In-Reply-To: <20190801135249.28803-5-noralf@tronnes.org>
Hi Noralf.
On Thu, Aug 01, 2019 at 03:52:49PM +0200, Noralf Trønnes wrote:
> Add support for panels that use the DPI interface.
> ILI9341 has onboard RAM so the assumption made here is that all such
> panels support pixel upload over DBI.
>
> The presence/absense of the Device Tree 'port' node decides which
> interface is used for pixel transfer.
>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> ---
> drivers/gpu/drm/panel/panel-ilitek-ili9341.c | 56 ++++++++++++++++----
> 1 file changed, 45 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
> index f6082fa2a389..7cbfd739c7fd 100644
> --- a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
> +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
> @@ -11,6 +11,7 @@
> #include <linux/gpio/consumer.h>
> #include <linux/module.h>
> #include <linux/of_device.h>
> +#include <linux/of_graph.h>
> #include <linux/pm.h>
> #include <linux/property.h>
> #include <linux/regulator/consumer.h>
> @@ -53,11 +54,13 @@
> struct ili9341_config {
> const struct drm_panel_funcs *funcs;
> const struct drm_display_mode *mode;
> + bool no_dpi;
> };
>
> struct ili9341 {
> struct mipi_dbi_dev dbidev; /* This must be the first entry */
> struct drm_panel panel;
> + bool use_dpi;
> struct regulator *regulator;
> struct backlight_device *backlight;
> const struct ili9341_config *conf;
> @@ -174,6 +177,7 @@ static const struct drm_display_mode yx240qv29_mode = {
> static const struct ili9341_config yx240qv29_data = {
> .funcs = &yx240qv29_funcs,
> .mode = &yx240qv29_mode,
> + .no_dpi = true,
> };
>
> static int mi0283qt_prepare(struct drm_panel *panel)
> @@ -291,6 +295,7 @@ static const struct drm_display_mode mi0283qt_mode = {
> static const struct ili9341_config mi0283qt_data = {
> .funcs = &mi0283qt_drm_funcs,
> .mode = &mi0283qt_mode,
> + .no_dpi = true,
> };
>
> /* Legacy, DRM driver name is ABI */
> @@ -303,6 +308,7 @@ static int ili9341_probe(struct spi_device *spi)
> const struct spi_device_id *spi_id;
> struct device *dev = &spi->dev;
> struct drm_driver *driver;
> + struct device_node *port;
> struct mipi_dbi *dbi;
> struct gpio_desc *dc;
> struct ili9341 *ili;
> @@ -357,21 +363,44 @@ static int ili9341_probe(struct spi_device *spi)
> ili->panel.dev = dev;
> ili->panel.funcs = ili->conf->funcs;
>
> - if (ili->conf == &mi0283qt_data)
> - driver = &mi0283qt_drm_driver;
> - else
> - driver = &ili9341_drm_driver;
>
> - return drm_mipi_dbi_panel_register(&ili->panel, &ili->dbidev, driver,
> - ili->conf->mode, rotation);
> + port = of_get_child_by_name(dev->of_node, "port");
> + if (port) {
> + of_node_put(port);
> + ili->use_dpi = true;
> + }
> +
> + if (ili->conf->no_dpi)
> + ili->use_dpi = false;
> +
> + if (ili->use_dpi) {
> + ret = drm_panel_add(&ili->panel);
> + } else {
> + if (ili->conf == &mi0283qt_data)
> + driver = &mi0283qt_drm_driver;
> + else
> + driver = &ili9341_drm_driver;
> +
> + ret = drm_mipi_dbi_panel_register(&ili->panel, &ili->dbidev, driver,
> + ili->conf->mode, rotation);
> + }
> +
> + return ret;
> }
>
> static int ili9341_remove(struct spi_device *spi)
> {
> struct ili9341 *ili = spi_get_drvdata(spi);
>
> - drm_dev_unplug(&ili->dbidev.drm);
> - drm_atomic_helper_shutdown(&ili->dbidev.drm);
> + if (ili->use_dpi) {
> + drm_panel_remove(&ili->panel);
> + drm_panel_disable(&ili->panel);
> + drm_panel_unprepare(&ili->panel);
> + kfree(ili);
At first I thought - order is wrong.
But drm_panel_remove() prevents display drivers from using the driver.
And this will not invalidate the other calls.
Maybe add a short comment?
Sam
> + } else {
> + drm_dev_unplug(&ili->dbidev.drm);
> + drm_atomic_helper_shutdown(&ili->dbidev.drm);
> + }
>
> return 0;
> }
> @@ -380,21 +409,26 @@ static void ili9341_shutdown(struct spi_device *spi)
> {
> struct ili9341 *ili = spi_get_drvdata(spi);
>
> - drm_atomic_helper_shutdown(&ili->dbidev.drm);
> + if (!ili->use_dpi)
> + drm_atomic_helper_shutdown(&ili->dbidev.drm);
> }
>
> static int __maybe_unused ili9341_pm_suspend(struct device *dev)
> {
> struct ili9341 *ili = dev_get_drvdata(dev);
>
> - return drm_mode_config_helper_suspend(&ili->dbidev.drm);
> + if (!ili->use_dpi)
> + return drm_mode_config_helper_suspend(&ili->dbidev.drm);
> +
> + return 0;
> }
>
> static int __maybe_unused ili9341_pm_resume(struct device *dev)
> {
> struct ili9341 *ili = dev_get_drvdata(dev);
>
> - drm_mode_config_helper_resume(&ili->dbidev.drm);
> + if (!ili->use_dpi)
> + drm_mode_config_helper_resume(&ili->dbidev.drm);
>
> return 0;
> }
> --
> 2.20.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-08-11 17:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 13:52 [PATCH 0/4] drm/mipi-dbi: Support panel drivers Noralf Trønnes
2019-08-01 13:52 ` [PATCH 1/4] drm/mipi-dbi: Support command mode " Noralf Trønnes
2019-08-11 14:16 ` Sam Ravnborg
2019-08-12 12:05 ` Noralf Trønnes
2019-08-12 18:49 ` Sam Ravnborg
2019-08-13 16:24 ` Noralf Trønnes
2019-08-01 13:52 ` [PATCH 2/4] drm/tiny/ili9341: Move driver to drm/panel Noralf Trønnes
2019-08-01 19:43 ` David Lechner
2019-08-02 14:19 ` Noralf Trønnes
2019-08-11 15:24 ` Sam Ravnborg
2019-08-12 12:11 ` Noralf Trønnes
2019-08-01 13:52 ` [PATCH 3/4] drm/tiny/mi0283qt: Move driver to panel-ilitek-ili9341 Noralf Trønnes
2019-08-01 19:13 ` David Lechner
2019-08-01 13:52 ` [PATCH 4/4] drm/panel/ili9341: Support DPI panels Noralf Trønnes
2019-08-01 19:10 ` [4/4] " David Lechner
2019-08-02 14:14 ` Noralf Trønnes
2019-08-11 16:41 ` [PATCH 4/4] " Sam Ravnborg
2019-08-12 12:13 ` Noralf Trønnes
2019-08-12 15:35 ` Laurent Pinchart
2019-08-12 18:20 ` Sam Ravnborg
2019-08-11 17:02 ` Sam Ravnborg [this message]
2019-08-12 12:18 ` Noralf Trønnes
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=20190811170201.GF14660@ravnborg.org \
--to=sam@ravnborg.org \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=josef@lusticky.cz \
--cc=laurent.pinchart@ideasonboard.com \
--cc=noralf@tronnes.org \
--cc=thierry.reding@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.