From: Chintan Patel <chintanlike@gmail.com>
To: sumit.semwal@linaro.org, neil.armstrong@linaro.org
Cc: dianders@chromium.org, jesszhan0024@gmail.com,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Chintan Patel <chintanlike@gmail.com>
Subject: [PATCH] drm/panel: novatek-nt36672a: Convert to mipi_dsi_*_multi() helpers
Date: Sun, 22 Feb 2026 20:34:41 -0800 [thread overview]
Message-ID: <20260223043441.5295-1-chintanlike@gmail.com> (raw)
Convert the driver to use the non-deprecated mipi_dsi_*_multi()
helpers and mipi_dsi_msleep().
This removes open-coded error handling and relies on
mipi_dsi_multi_context for error accumulation.
In unprepare(), reset the accumulated error between
set_display_off and enter_sleep_mode to preserve the
existing power-down sequencing semantics.
Signed-off-by: Chintan Patel <chintanlike@gmail.com>
---
.../gpu/drm/panel/panel-novatek-nt36672a.c | 83 ++++++-------------
1 file changed, 26 insertions(+), 57 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
index 29e1f6aea480..2c8d67a69c7e 100644
--- a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
+++ b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
@@ -79,23 +79,17 @@ static inline struct nt36672a_panel *to_nt36672a_panel(struct drm_panel *panel)
return container_of(panel, struct nt36672a_panel, base);
}
-static int nt36672a_send_cmds(struct drm_panel *panel, const struct nt36672a_panel_cmd *cmds,
- int num)
+static void nt36672a_send_cmds(struct mipi_dsi_multi_context *dsi_ctx,
+ const struct nt36672a_panel_cmd *cmds, int num)
{
- struct nt36672a_panel *pinfo = to_nt36672a_panel(panel);
unsigned int i;
- int err;
for (i = 0; i < num; i++) {
const struct nt36672a_panel_cmd *cmd = &cmds[i];
- err = mipi_dsi_dcs_write(pinfo->link, cmd->data[0], cmd->data + 1, 1);
-
- if (err < 0)
- return err;
+ /* cmd->data[0] is the DCS command, cmd->data[1] is the parameter */
+ mipi_dsi_dcs_write_buffer_multi(dsi_ctx, cmd->data, sizeof(cmd->data));
}
-
- return 0;
}
static int nt36672a_panel_power_off(struct drm_panel *panel)
@@ -115,34 +109,26 @@ static int nt36672a_panel_power_off(struct drm_panel *panel)
static int nt36672a_panel_unprepare(struct drm_panel *panel)
{
struct nt36672a_panel *pinfo = to_nt36672a_panel(panel);
- int ret;
+ struct mipi_dsi_multi_context dsi_ctx = { .dsi = pinfo->link };
/* send off cmds */
- ret = nt36672a_send_cmds(panel, pinfo->desc->off_cmds,
- pinfo->desc->num_off_cmds);
+ nt36672a_send_cmds(&dsi_ctx, pinfo->desc->off_cmds,
+ pinfo->desc->num_off_cmds);
- if (ret < 0)
- dev_err(panel->dev, "failed to send DCS off cmds: %d\n", ret);
-
- ret = mipi_dsi_dcs_set_display_off(pinfo->link);
- if (ret < 0)
- dev_err(panel->dev, "set_display_off cmd failed ret = %d\n", ret);
+ mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
+ /* Reset error to continue power-down even if display off failed */
+ dsi_ctx.accum_err = 0;
+ mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
/* 120ms delay required here as per DCS spec */
msleep(120);
- ret = mipi_dsi_dcs_enter_sleep_mode(pinfo->link);
- if (ret < 0)
- dev_err(panel->dev, "enter_sleep cmd failed ret = %d\n", ret);
-
/* 0x3C = 60ms delay */
msleep(60);
- ret = nt36672a_panel_power_off(panel);
- if (ret < 0)
- dev_err(panel->dev, "power_off failed ret = %d\n", ret);
+ nt36672a_panel_power_off(panel);
- return ret;
+ return 0;
}
static int nt36672a_panel_power_on(struct nt36672a_panel *pinfo)
@@ -170,51 +156,34 @@ static int nt36672a_panel_power_on(struct nt36672a_panel *pinfo)
static int nt36672a_panel_prepare(struct drm_panel *panel)
{
struct nt36672a_panel *pinfo = to_nt36672a_panel(panel);
+ struct mipi_dsi_multi_context dsi_ctx = { .dsi = pinfo->link };
int err;
err = nt36672a_panel_power_on(pinfo);
if (err < 0)
- goto poweroff;
+ return err;
/* send first part of init cmds */
- err = nt36672a_send_cmds(panel, pinfo->desc->on_cmds_1,
- pinfo->desc->num_on_cmds_1);
+ nt36672a_send_cmds(&dsi_ctx, pinfo->desc->on_cmds_1,
+ pinfo->desc->num_on_cmds_1);
- if (err < 0) {
- dev_err(panel->dev, "failed to send DCS Init 1st Code: %d\n", err);
- goto poweroff;
- }
-
- err = mipi_dsi_dcs_exit_sleep_mode(pinfo->link);
- if (err < 0) {
- dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
- goto poweroff;
- }
+ mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
/* 0x46 = 70 ms delay */
- msleep(70);
+ mipi_dsi_msleep(&dsi_ctx, 70);
- err = mipi_dsi_dcs_set_display_on(pinfo->link);
- if (err < 0) {
- dev_err(panel->dev, "failed to Set Display ON: %d\n", err);
- goto poweroff;
- }
+ mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
/* Send rest of the init cmds */
- err = nt36672a_send_cmds(panel, pinfo->desc->on_cmds_2,
- pinfo->desc->num_on_cmds_2);
+ nt36672a_send_cmds(&dsi_ctx, pinfo->desc->on_cmds_2,
+ pinfo->desc->num_on_cmds_2);
- if (err < 0) {
- dev_err(panel->dev, "failed to send DCS Init 2nd Code: %d\n", err);
- goto poweroff;
- }
-
- msleep(120);
+ mipi_dsi_msleep(&dsi_ctx, 120);
- return 0;
+ err = dsi_ctx.accum_err;
+ if (err < 0)
+ gpiod_set_value(pinfo->reset_gpio, 0);
-poweroff:
- gpiod_set_value(pinfo->reset_gpio, 0);
return err;
}
--
2.43.0
next reply other threads:[~2026-02-23 4:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 4:34 Chintan Patel [this message]
2026-02-23 21:33 ` [PATCH] drm/panel: novatek-nt36672a: Convert to mipi_dsi_*_multi() helpers Doug Anderson
2026-02-24 0:48 ` Claude review: " Claude Code Review Bot
2026-02-24 0:48 ` Claude Code Review Bot
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=20260223043441.5295-1-chintanlike@gmail.com \
--to=chintanlike@gmail.com \
--cc=airlied@gmail.com \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jesszhan0024@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=simona@ffwll.ch \
--cc=sumit.semwal@linaro.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