From: Neil Armstrong <neil.armstrong@linaro.org>
To: Svyatoslav Ryhel <clamor95@gmail.com>,
Jessica Zhang <jesszhan0024@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Thierry Reding <thierry.reding@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>,
Mikko Perttunen <mperttunen@nvidia.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v4 3/7] drm/panel: Add LG LH400WV3-SD04 MIPI DBI Type B panel driver
Date: Mon, 2 Nov 2026 14:19:49 +0100 [thread overview]
Message-ID: <d0aa0ffb-e598-485c-a793-442d548fab90@linaro.org> (raw)
In-Reply-To: <20261022132259.240717-4-clamor95@gmail.com>
On 10/22/26 15:22, Svyatoslav Ryhel wrote:
> Add a driver for panel used in LG Optimus 2X P990. Panel is 4" WVGA MIPI
> DBI Type B linked to DRM encoder via RGB to DBI bridge.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> drivers/gpu/drm/panel/Kconfig | 13 ++
> drivers/gpu/drm/panel/Makefile | 1 +
> drivers/gpu/drm/panel/panel-lg-lh400wv3.c | 236 ++++++++++++++++++++++
> 3 files changed, 250 insertions(+)
> create mode 100644 drivers/gpu/drm/panel/panel-lg-lh400wv3.c
>
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index 5f68b78526c3e..f29b63ad8ba0f 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -554,6 +554,19 @@ config DRM_PANEL_LG_LG4573
> Say Y here if you want to enable support for LG4573 RGB panel.
> To compile this driver as a module, choose M here.
>
> +config DRM_PANEL_LG_LH400WV3
> + tristate "LG LH400WV3 MIPI DBI Type B panel"
> + depends on OF
> + depends on BACKLIGHT_CLASS_DEVICE
> + select DRM_MIPI_DBI
> + select VIDEOMODE_HELPERS
> + help
> + Say Y here if you want to enable support for the LG LH400WV3 MIPI
> + DBI Type B panel found in the LG Optimus 2X P990 smartphone.
> +
> + To compile this driver as a module, choose M here: the module will
> + be called panel-lg-lh400wv3.
> +
> config DRM_PANEL_LG_SW43408
> tristate "LG SW43408 panel"
> depends on GPIOLIB
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index 414267a49d922..842a2a973777f 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -54,6 +54,7 @@ obj-$(CONFIG_DRM_PANEL_LINCOLNTECH_LCD197) += panel-lincolntech-lcd197.o
> obj-$(CONFIG_DRM_PANEL_LG_LB035Q02) += panel-lg-lb035q02.o
> obj-$(CONFIG_DRM_PANEL_LG_LD070WX3) += panel-lg-ld070wx3.o
> obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
> +obj-$(CONFIG_DRM_PANEL_LG_LH400WV3) += panel-lg-lh400wv3.o
> obj-$(CONFIG_DRM_PANEL_LG_SW43408) += panel-lg-sw43408.o
> obj-$(CONFIG_DRM_PANEL_LXD_M9189A) += panel-lxd-m9189a.o
> obj-$(CONFIG_DRM_PANEL_MAGNACHIP_D53E6EA8966) += panel-magnachip-d53e6ea8966.o
> diff --git a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
> new file mode 100644
> index 0000000000000..557bcb6f2ca70
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
> @@ -0,0 +1,236 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <linux/array_size.h>
> +#include <linux/delay.h>
> +#include <linux/err.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/media-bus-format.h>
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
> +#include <linux/platform_device.h>
> +#include <linux/property.h>
> +#include <linux/regulator/consumer.h>
> +
> +#include <video/mipi_display.h>
> +
> +#include <drm/drm_mipi_dbi.h>
> +#include <drm/drm_modes.h>
> +#include <drm/drm_of.h>
> +#include <drm/drm_panel.h>
> +#include <drm/drm_probe_helper.h>
> +
> +static const struct regulator_bulk_data lg_lh400wv3_supplies[] = {
> + { .supply = "avci" }, { .supply = "iovcc" },
> +};
> +
> +struct lg_lh400wv3 {
> + struct drm_panel panel;
> + struct mipi_dbi *dbi;
> +
> + struct regulator_bulk_data *supplies;
> + struct gpio_desc *reset_gpio;
> +};
> +
> +static inline struct lg_lh400wv3 *to_lg_lh400wv3(struct drm_panel *panel)
> +{
> + return container_of(panel, struct lg_lh400wv3, panel);
> +}
> +
> +#define panel_dbi_command(priv, cmd, seq...) \
> +({ \
> + const u8 d[] = { seq }; \
> + struct drm_panel *panel = &(priv)->panel; \
> + struct device *dev = panel->dev; \
> + int ret; \
> + ret = mipi_dbi_command_stackbuf((priv)->dbi, cmd, d, ARRAY_SIZE(d)); \
> + if (ret) \
> + dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
> + ret; \
> +})
> +
> +static int lg_lh400wv3_prepare(struct drm_panel *panel)
> +{
> + struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel);
> + struct device *dev = panel->dev;
> + int ret;
> +
> + priv->dbi = dev_get_drvdata(dev->parent);
> + if (!priv->dbi)
> + return -ENODEV;
> +
> + gpiod_set_value_cansleep(priv->reset_gpio, 1);
> +
> + ret = regulator_bulk_enable(ARRAY_SIZE(lg_lh400wv3_supplies), priv->supplies);
> + if (ret) {
> + dev_err(dev, "failed to enable power supplies: %d\n", ret);
> + return ret;
> + }
> +
> + usleep_range(1000, 2000);
> +
> + gpiod_set_value_cansleep(priv->reset_gpio, 0);
> +
> + usleep_range(10000, 11000);
> +
> + return 0;
> +};
> +
> +static int lg_lh400wv3_enable(struct drm_panel *panel)
> +{
> + struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel);
> +
> + panel_dbi_command(priv, MIPI_DCS_EXIT_INVERT_MODE);
> + panel_dbi_command(priv, MIPI_DCS_SET_TEAR_ON);
> +
> + panel_dbi_command(priv, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT |
> + MIPI_DCS_PIXEL_FMT_24BIT << 4);
> +
> + panel_dbi_command(priv, 0xb2, 0x00, 0xc8);
> + panel_dbi_command(priv, 0xb3, 0x00);
> + panel_dbi_command(priv, 0xb4, 0x04);
> + panel_dbi_command(priv, 0xb5, 0x42, 0x10, 0x10, 0x00, 0x20);
> + panel_dbi_command(priv, 0xb6, 0x0b, 0x0f, 0x3c, 0x13, 0x13, 0xe8);
> + panel_dbi_command(priv, 0xb7, 0x4c, 0x06, 0x0c, 0x00, 0x00);
> +
> + panel_dbi_command(priv, 0xc0, 0x01, 0x11);
> + panel_dbi_command(priv, 0xc3, 0x07, 0x03, 0x04, 0x04, 0x04);
> + panel_dbi_command(priv, 0xc4, 0x12, 0x24, 0x18, 0x18, 0x02, 0x49);
> + panel_dbi_command(priv, 0xc5, 0x65);
> + panel_dbi_command(priv, 0xc6, 0x41, 0x63);
> +
> + panel_dbi_command(priv, 0xd0, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04);
> + panel_dbi_command(priv, 0xd1, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04);
> + panel_dbi_command(priv, 0xd2, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04);
> + panel_dbi_command(priv, 0xd3, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04);
> + panel_dbi_command(priv, 0xd4, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04);
> + panel_dbi_command(priv, 0xd5, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04);
> +
> + panel_dbi_command(priv, MIPI_DCS_SET_COLUMN_ADDRESS, 0x00, 0x00, 0x01, 0xdf);
> + panel_dbi_command(priv, MIPI_DCS_SET_PAGE_ADDRESS, 0x00, 0x00, 0x03, 0x1f);
> +
> + panel_dbi_command(priv, MIPI_DCS_EXIT_SLEEP_MODE);
> + msleep(120);
> +
> + panel_dbi_command(priv, MIPI_DCS_WRITE_MEMORY_START);
> + panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_ON);
> +
> + return 0;
> +}
> +
> +static int lg_lh400wv3_disable(struct drm_panel *panel)
> +{
> + struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel);
> +
> + panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_OFF);
> + panel_dbi_command(priv, MIPI_DCS_ENTER_SLEEP_MODE);
> + msleep(150);
> +
> + panel_dbi_command(priv, 0xc1, 0x01);
> + usleep_range(10000, 11000);
> +
> + return 0;
> +};
> +
> +static int lg_lh400wv3_unprepare(struct drm_panel *panel)
> +{
> + struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel);
> +
> + gpiod_set_value_cansleep(priv->reset_gpio, 1);
> + regulator_bulk_disable(ARRAY_SIZE(lg_lh400wv3_supplies), priv->supplies);
> +
> + msleep(50);
> +
> + return 0;
> +}
> +
> +static const struct drm_display_mode lg_lh400wv3_mode = {
> + .clock = (480 + 10 + 10 + 10) * (800 + 4 + 4 + 4) * 60 / 1000,
> + .hdisplay = 480,
> + .hsync_start = 480 + 10,
> + .hsync_end = 480 + 10 + 10,
> + .htotal = 480 + 10 + 10 + 10,
> + .vdisplay = 800,
> + .vsync_start = 800 + 4,
> + .vsync_end = 800 + 4 + 4,
> + .vtotal = 800 + 4 + 4 + 4,
> + .width_mm = 52,
> + .height_mm = 86,
> + .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
> +};
> +
> +static int lg_lh400wv3_get_modes(struct drm_panel *panel,
> + struct drm_connector *connector)
> +{
> + u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
> +
> + drm_display_info_set_bus_formats(&connector->display_info,
> + &bus_format, 1);
> +
> + connector->display_info.bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE |
> + DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE |
> + DRM_BUS_FLAG_DE_HIGH |
> + DRM_BUS_FLAG_DATA_LSB_TO_MSB;
> +
> + return drm_connector_helper_get_modes_fixed(connector, &lg_lh400wv3_mode);
> +}
> +
> +static const struct drm_panel_funcs lg_lh400wv3_panel_funcs = {
> + .prepare = lg_lh400wv3_prepare,
> + .enable = lg_lh400wv3_enable,
> + .disable = lg_lh400wv3_disable,
> + .unprepare = lg_lh400wv3_unprepare,
> + .get_modes = lg_lh400wv3_get_modes,
> +};
> +
> +static int lg_lh400wv3_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct lg_lh400wv3 *priv;
> + int ret;
> +
> + priv = devm_drm_panel_alloc(dev, struct lg_lh400wv3, panel,
> + &lg_lh400wv3_panel_funcs, DRM_MODE_CONNECTOR_DPI);
> + if (IS_ERR(priv))
> + return PTR_ERR(priv);
> +
> + ret = devm_regulator_bulk_get_const(dev, ARRAY_SIZE(lg_lh400wv3_supplies),
> + lg_lh400wv3_supplies, &priv->supplies);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to get supplies\n");
> +
> + priv->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> + if (IS_ERR(priv->reset_gpio))
> + return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
> + "Failed to get reset gpio\n");
> +
> + ret = drm_panel_of_backlight(&priv->panel);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to get backlight\n");
> +
> + ret = devm_drm_panel_add(dev, &priv->panel);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to add panel\n");
> +
> + platform_set_drvdata(pdev, priv);
> +
> + return 0;
> +}
> +
> +static const struct of_device_id lg_lh400wv3_of_match[] = {
> + { .compatible = "lg,lh400wv3-sd04" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, lg_lh400wv3_of_match);
> +
> +static struct platform_driver lg_lh400wv3_driver = {
> + .driver = {
> + .name = "panel-lg-lh400wv3",
> + .of_match_table = lg_lh400wv3_of_match,
> + },
> + .probe = lg_lh400wv3_probe,
> +};
> +module_platform_driver(lg_lh400wv3_driver);
> +
> +MODULE_AUTHOR("Svyatoslav Ryhel <clamor95@gmail.com>");
> +MODULE_DESCRIPTION("LG LH400WV3-SD04 MIPI DBI Type B panel driver");
> +MODULE_LICENSE("GPL");
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Thanks,
Neil
next prev parent reply other threads:[~2026-11-02 13:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 13:22 [PATCH v4 0/7] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
2026-10-22 13:22 ` [PATCH v4 1/7] dt-bindings: display: panel: Document Hitachi TX10D07VM0BAA and LG LH400WV3 panels Svyatoslav Ryhel
2026-10-22 13:22 ` [PATCH v4 2/7] drm/panel: Add Hitachi TX10D07VM0BAA MIPI DBI Type B panel driver Svyatoslav Ryhel
2026-11-02 13:19 ` Neil Armstrong
2026-10-22 13:22 ` [PATCH v4 3/7] drm/panel: Add LG LH400WV3-SD04 " Svyatoslav Ryhel
2026-11-02 13:19 ` Neil Armstrong [this message]
2026-10-22 13:22 ` [PATCH v4 4/7] drm/tegra: dc: Expand available registers layouts Svyatoslav Ryhel
2026-10-23 7:14 ` Mikko Perttunen
2026-10-23 8:06 ` Svyatoslav Ryhel
2026-10-22 13:22 ` [PATCH v4 5/7] drm/tegra: rgb: Parameterize configuration based on bus flags Svyatoslav Ryhel
2026-10-22 13:22 ` [PATCH v4 6/7] dt-bindings: display: tegra: Document 8-bit CPU parallel interface Svyatoslav Ryhel
2026-10-22 13:22 ` [PATCH v4 7/7] drm/tegra: Add support for 8-bit CPU interface Svyatoslav Ryhel
2026-10-23 7:53 ` Mikko Perttunen
2026-10-23 8:26 ` Svyatoslav Ryhel
2026-10-23 14:14 ` Svyatoslav Ryhel
2026-10-25 1:42 ` Mikko Perttunen
2026-10-25 8:51 ` Svyatoslav Ryhel
2026-10-28 1:35 ` Mikko Perttunen
2026-10-28 12:46 ` Svyatoslav Ryhel
2026-11-02 13:40 ` (subset) [PATCH v4 0/7] drm/tegra: Add support for Tegra20/Tegra30 " Neil Armstrong
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=d0aa0ffb-e598-485c-a793-442d548fab90@linaro.org \
--to=neil.armstrong@linaro.org \
--cc=airlied@gmail.com \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jesszhan0024@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mperttunen@nvidia.com \
--cc=mripard@kernel.org \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=thierry.reding@kernel.org \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®