[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8c611775-7994-427b-b15e-68ada7e340e4@linaro.org>
Date: Wed, 23 Oct 2024 09:41:03 +0200
From: Neil Armstrong <neil.armstrong@...aro.org>
To: Jakob Hauser <jahau@...ketmail.com>,
Jessica Zhang <quic_jesszhan@...cinc.com>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>
Cc: Thierry Reding <thierry.reding@...il.com>,
Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
Andrzej Hajda <andrzej.hajda@...el.com>, dri-devel@...ts.freedesktop.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
~postmarketos/upstreaming@...ts.sr.ht
Subject: Re: [PATCH v2 3/5] drm/panel: samsung-s6e88a0-ams427ap24: Add initial
driver
Hi,
On 22/10/2024 23:33, Jakob Hauser wrote:
> This initial part of the panel driver was mostly generated by the
> "linux-mdss-dsi-panel-driver-generator" tool [1], reading downstream
> Android kernel file "dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi" [2].
>
> On top of the generic output of the tool, there were a couple of changes
> applied:
> - Added mipi_dsi_dcs_set_display_on() to function s6e88a0_ams427ap24_on(),
> otherwise the display does not show up.
> - In functions s6e88a0_ams427ap24_on() and s6e88a0_ams427ap24_off()
> changed DSI commands to multi context and used "accum_err" returns.
> - In functions s6e88a0_ams427ap24_on() and s6e88a0_ams427ap24_off() replaced
> msleep() by mipi_dsi_msleep().
> - The function s6e88a0_ams427ap24_get_modes() was changed to make use of
> drm_connector_helper_get_modes_fixed(). This also required to include
> drm/drm_probe_helper.h.
> - In function s6e88a0_ams427ap24_probe() registring the regulators was changed
> to devm_regulator_bulk_get_const(). This required to change supplies in struct
> s6e88a0_ams427ap24 to a pointer.
> - Removed bool "prepared" from struct s6e88a0_ams427ap24 and instead used
> framework-provided "panel->prepared" in functions s6e88a0_ams427ap24_prepare()
> and s6e88a0_ams427ap24_unprepare().
>
> [1] https://github.com/msm8916-mainline/linux-mdss-dsi-panel-driver-generator
> [2] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi
>
> Signed-off-by: Jakob Hauser <jahau@...ketmail.com>
> ---
> Coulnd't read out RAW EDID, /sys/class/drm/card0-DSI-1/edid is empty.
DSI panels doesn't have EDID, you can drop this comment
>
> Changes in v2:
> - Removed bool "prepared" from struct s6e88a0_ams427ap24 and instead used
> framework-provided "panel->prepared" in functions s6e88a0_ams427ap24_prepare()
> and s6e88a0_ams427ap24_unprepare(). Mentioned this in the commit message.
> ---
> drivers/gpu/drm/panel/Kconfig | 9 +
> drivers/gpu/drm/panel/Makefile | 1 +
> .../panel/panel-samsung-s6e88a0-ams427ap24.c | 260 ++++++++++++++++++
> 3 files changed, 270 insertions(+)
> create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams427ap24.c
>
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index bce4cb64184a..f8adc38447fb 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -632,6 +632,15 @@ config DRM_PANEL_SAMSUNG_AMS639RQ08
> Say Y or M here if you want to enable support for the
> Samsung AMS639RQ08 FHD Plus (2340x1080@...z) CMD mode panel.
>
> +config DRM_PANEL_SAMSUNG_S6E88A0_AMS427AP24
> + tristate "Samsung AMS427AP24 panel with S6E88A0 controller"
> + depends on GPIOLIB && OF && REGULATOR
> + depends on DRM_MIPI_DSI
> + help
> + Say Y here if you want to enable support for Samsung AMS427AP24 panel
> + with S6E88A0 controller (found in Samsung Galaxy S4 Mini Value Edition
> + GT-I9195I). To compile this driver as a module, choose M here.
> +
> config DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01
> tristate "Samsung AMS452EF01 panel with S6E88A0 DSI video mode controller"
> depends on OF
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index 4db02c2411ae..7dcf72646cac 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -77,6 +77,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03) += panel-samsung-s6e63j0x03.o
> obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.o
> obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_SPI) += panel-samsung-s6e63m0-spi.o
> obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_DSI) += panel-samsung-s6e63m0-dsi.o
> +obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E88A0_AMS427AP24) += panel-samsung-s6e88a0-ams427ap24.o
> obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01) += panel-samsung-s6e88a0-ams452ef01.o
> obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
> obj-$(CONFIG_DRM_PANEL_SAMSUNG_SOFEF00) += panel-samsung-sofef00.o
> diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams427ap24.c b/drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams427ap24.c
> new file mode 100644
> index 000000000000..0ab2768e0e2b
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams427ap24.c
> @@ -0,0 +1,260 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Samsung AMS427AP24 panel with S6E88A0 controller
> + * Copyright (c) 2024 Jakob Hauser <jahau@...ketmail.com>
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/regulator/consumer.h>
> +
> +#include <video/mipi_display.h>
> +
> +#include <drm/drm_mipi_dsi.h>
> +#include <drm/drm_modes.h>
> +#include <drm/drm_panel.h>
> +#include <drm/drm_probe_helper.h>
> +
> +struct s6e88a0_ams427ap24 {
> + struct drm_panel panel;
> + struct mipi_dsi_device *dsi;
> + struct regulator_bulk_data *supplies;
> + struct gpio_desc *reset_gpio;
> +};
> +
> +const struct regulator_bulk_data s6e88a0_ams427ap24_supplies[] = {
Please add static
> + { .supply = "vdd3" },
> + { .supply = "vci" },
> +};
> +
> +static inline
> +struct s6e88a0_ams427ap24 *to_s6e88a0_ams427ap24(struct drm_panel *panel)
> +{
> + return container_of(panel, struct s6e88a0_ams427ap24, panel);
> +}
> +
> +static void s6e88a0_ams427ap24_reset(struct s6e88a0_ams427ap24 *ctx)
> +{
> + gpiod_set_value_cansleep(ctx->reset_gpio, 0);
> + usleep_range(5000, 6000);
> + gpiod_set_value_cansleep(ctx->reset_gpio, 1);
> + usleep_range(1000, 2000);
> + gpiod_set_value_cansleep(ctx->reset_gpio, 0);
> + usleep_range(18000, 19000);
> +}
> +
> +static int s6e88a0_ams427ap24_on(struct s6e88a0_ams427ap24 *ctx)
> +{
> + struct mipi_dsi_device *dsi = ctx->dsi;
> + struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
> +
> + dsi->mode_flags |= MIPI_DSI_MODE_LPM;
> +
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf0, 0x5a, 0x5a);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xfc, 0x5a, 0x5a);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x11);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xfd, 0x11);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x13);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xfd, 0x18);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x02);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb8, 0x30);
> +
> + mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
> + mipi_dsi_msleep(&dsi_ctx, 20);
> +
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf1, 0x5a, 0x5a);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xcc, 0x4c);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf2, 0x03, 0x0d);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf1, 0xa5, 0xa5);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xca,
> + 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x80,
> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> + 0x80, 0x80, 0x00, 0x00, 0x00);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb2,
> + 0x40, 0x08, 0x20, 0x00, 0x08);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb6, 0x28, 0x0b);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf7, 0x03);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0x55, 0x00);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf0, 0xa5, 0xa5);
> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xfc, 0xa5, 0xa5);
> +
> + mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
> +
> + return dsi_ctx.accum_err;
> +}
> +
> +static int s6e88a0_ams427ap24_off(struct s6e88a0_ams427ap24 *ctx)
> +{
> + struct mipi_dsi_device *dsi = ctx->dsi;
> + struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
> +
> + dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
> +
> + mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
> + mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
> + mipi_dsi_msleep(&dsi_ctx, 120);
> +
> + return dsi_ctx.accum_err;
> +}
> +
> +static int s6e88a0_ams427ap24_prepare(struct drm_panel *panel)
> +{
> + struct s6e88a0_ams427ap24 *ctx = to_s6e88a0_ams427ap24(panel);
> + struct device *dev = &ctx->dsi->dev;
> + int ret;
> +
> + if (panel->prepared)
> + return 0;
You can drop these, _prepare won't be called twice, the framework controls that.
> +
> + ret = regulator_bulk_enable(ARRAY_SIZE(s6e88a0_ams427ap24_supplies),
> + ctx->supplies);
> + if (ret < 0) {
> + dev_err(dev, "Failed to enable regulators: %d\n", ret);
> + return ret;
> + }
> +
> + s6e88a0_ams427ap24_reset(ctx);
> +
> + ret = s6e88a0_ams427ap24_on(ctx);
> + if (ret < 0) {
> + dev_err(dev, "Failed to initialize panel: %d\n", ret);
> + gpiod_set_value_cansleep(ctx->reset_gpio, 1);
> + regulator_bulk_disable(ARRAY_SIZE(s6e88a0_ams427ap24_supplies),
> + ctx->supplies);
> + return ret;
> + }
> +
> + panel->prepared = true;
Ditto
> + return 0;
> +}
> +
> +static int s6e88a0_ams427ap24_unprepare(struct drm_panel *panel)
> +{
> + struct s6e88a0_ams427ap24 *ctx = to_s6e88a0_ams427ap24(panel);
> + struct device *dev = &ctx->dsi->dev;
> + int ret;
> +
> + if (!panel->prepared)
> + return 0;
Ditto
> +
> + ret = s6e88a0_ams427ap24_off(ctx);
> + if (ret < 0)
> + dev_err(dev, "Failed to un-initialize panel: %d\n", ret);
> +
> + gpiod_set_value_cansleep(ctx->reset_gpio, 1);
> + regulator_bulk_disable(ARRAY_SIZE(s6e88a0_ams427ap24_supplies),
> + ctx->supplies);
> +
> + panel->prepared = false;
Ditto
> + return 0;
> +}
> +
> +static const struct drm_display_mode s6e88a0_ams427ap24_mode = {
> + .clock = (540 + 94 + 4 + 18) * (960 + 12 + 1 + 3) * 60 / 1000,
> + .hdisplay = 540,
> + .hsync_start = 540 + 94,
> + .hsync_end = 540 + 94 + 4,
> + .htotal = 540 + 94 + 4 + 18,
> + .vdisplay = 960,
> + .vsync_start = 960 + 12,
> + .vsync_end = 960 + 12 + 1,
> + .vtotal = 960 + 12 + 1 + 3,
> + .width_mm = 55,
> + .height_mm = 95,
> + .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
> +};
> +
> +static int s6e88a0_ams427ap24_get_modes(struct drm_panel *panel,
> + struct drm_connector *connector)
> +{
> + return drm_connector_helper_get_modes_fixed(connector,
> + &s6e88a0_ams427ap24_mode);
> +}
> +
> +static const struct drm_panel_funcs s6e88a0_ams427ap24_panel_funcs = {
> + .prepare = s6e88a0_ams427ap24_prepare,
> + .unprepare = s6e88a0_ams427ap24_unprepare,
> + .get_modes = s6e88a0_ams427ap24_get_modes,
> +};
> +
> +static int s6e88a0_ams427ap24_probe(struct mipi_dsi_device *dsi)
> +{
> + struct device *dev = &dsi->dev;
> + struct s6e88a0_ams427ap24 *ctx;
> + int ret;
> +
> + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> + if (!ctx)
> + return -ENOMEM;
> +
> + ret = devm_regulator_bulk_get_const(dev,
> + ARRAY_SIZE(s6e88a0_ams427ap24_supplies),
> + s6e88a0_ams427ap24_supplies,
> + &ctx->supplies);
> + if (ret < 0)
> + return ret;
> +
> + ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
> + if (IS_ERR(ctx->reset_gpio))
> + return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio),
> + "Failed to get reset-gpios\n");
> +
> + ctx->dsi = dsi;
> + mipi_dsi_set_drvdata(dsi, ctx);
> +
> + dsi->lanes = 2;
> + dsi->format = MIPI_DSI_FMT_RGB888;
> + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
> + MIPI_DSI_MODE_NO_EOT_PACKET;
> +
> + drm_panel_init(&ctx->panel, dev, &s6e88a0_ams427ap24_panel_funcs,
> + DRM_MODE_CONNECTOR_DSI);
> + ctx->panel.prepare_prev_first = true;
> +
> + drm_panel_add(&ctx->panel);
> +
> + ret = mipi_dsi_attach(dsi);
> + if (ret < 0) {
> + dev_err(dev, "Failed to attach to DSI host: %d\n", ret);
> + drm_panel_remove(&ctx->panel);
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static void s6e88a0_ams427ap24_remove(struct mipi_dsi_device *dsi)
> +{
> + struct s6e88a0_ams427ap24 *ctx = mipi_dsi_get_drvdata(dsi);
> + int ret;
> +
> + ret = mipi_dsi_detach(dsi);
> + if (ret < 0)
> + dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret);
> +
> + drm_panel_remove(&ctx->panel);
> +}
> +
> +static const struct of_device_id s6e88a0_ams427ap24_of_match[] = {
> + { .compatible = "samsung,s6e88a0-ams427ap24" },
> + { /* sentinel */ },
> +};
> +MODULE_DEVICE_TABLE(of, s6e88a0_ams427ap24_of_match);
> +
> +static struct mipi_dsi_driver s6e88a0_ams427ap24_driver = {
> + .probe = s6e88a0_ams427ap24_probe,
> + .remove = s6e88a0_ams427ap24_remove,
> + .driver = {
> + .name = "panel-s6e88a0-ams427ap24",
> + .of_match_table = s6e88a0_ams427ap24_of_match,
> + },
> +};
> +module_mipi_dsi_driver(s6e88a0_ams427ap24_driver);
> +
> +MODULE_AUTHOR("Jakob Hauser <jahau@...ketmail.com>");
> +MODULE_DESCRIPTION("Samsung AMS427AP24 panel with S6E88A0 controller");
> +MODULE_LICENSE("GPL v2");
Thanks,
Neil
Powered by blists - more mailing lists