* [PATCH v2 0/3] drm/panel: novatek-nt35560: Fix bug and clean up
@ 2025-07-29 5:44 Brigham Campbell
2025-07-29 5:44 ` [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value Brigham Campbell
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Brigham Campbell @ 2025-07-29 5:44 UTC (permalink / raw)
To: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
linus.walleij, neil.armstrong, jessica.zhang, sam
Cc: dianders, skhan, linux-kernel-mentees, dri-devel, linux-kernel,
Brigham Campbell
Fix bug in novatek-nt35560 driver's nt35560_set_brightness() which
causes the driver to incorrectly report that it "failed to disable
display backlight".
Add mipi_dsi_dcs_read_multi() to drm_mipi_dsi.c for improved error
handling in drivers which use mipi_dsi_dcs_read() multiple times in a
row. It seems like although this feature may be useful for the nt35560,
we don't expect many drivers to use it. Once again, I am happy to remove
this change if it's not worth maintaining.
Add mipi_dsi_dcs_write_var_seq_multi() and
mipi_dsi_generic_write_var_seq_multi() to drm_mipi_dsi.h to allow
drivers to more conveniently construct MIPI payloads at runtime.
Clean up novatek-nt35560 driver to use "multi" variants of MIPI
functions which promote cleaner code.
Brigham Campbell (3):
drm/panel: novatek-nt35560: Fix invalid return value
drm: Add MIPI support function and macros
drm/panel: novatek-nt35560: Clean up driver
drivers/gpu/drm/drm_mipi_dsi.c | 37 ++++
drivers/gpu/drm/panel/panel-novatek-nt35560.c | 198 ++++++------------
include/drm/drm_mipi_dsi.h | 35 ++++
3 files changed, 132 insertions(+), 138 deletions(-)
base-commit: 33f8f321e7aa7715ce19560801ee5223ba8b9a7d
--
2.50.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value
2025-07-29 5:44 [PATCH v2 0/3] drm/panel: novatek-nt35560: Fix bug and clean up Brigham Campbell
@ 2025-07-29 5:44 ` Brigham Campbell
2025-07-29 9:17 ` neil.armstrong
2025-07-29 21:33 ` Doug Anderson
2025-07-29 5:44 ` [PATCH v2 2/3] drm: Add MIPI support function and macros Brigham Campbell
` (2 subsequent siblings)
3 siblings, 2 replies; 11+ messages in thread
From: Brigham Campbell @ 2025-07-29 5:44 UTC (permalink / raw)
To: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
linus.walleij, neil.armstrong, jessica.zhang, sam
Cc: dianders, skhan, linux-kernel-mentees, dri-devel, linux-kernel,
Brigham Campbell
Fix bug in nt35560_set_brightness() which causes the function to
erroneously report an error. mipi_dsi_dcs_write() returns either a
negative value when an error occurred or a positive number of bytes
written when no error occurred. The buggy code reports an error under
either condition.
Fixes: 7835ed6a9e86 ("drm/panel-sony-acx424akp: Modernize backlight handling")
Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
---
drivers/gpu/drm/panel/panel-novatek-nt35560.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/panel/panel-novatek-nt35560.c b/drivers/gpu/drm/panel/panel-novatek-nt35560.c
index 98f0782c8411..17898a29efe8 100644
--- a/drivers/gpu/drm/panel/panel-novatek-nt35560.c
+++ b/drivers/gpu/drm/panel/panel-novatek-nt35560.c
@@ -161,7 +161,7 @@ static int nt35560_set_brightness(struct backlight_device *bl)
par = 0x00;
ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_WRITE_CONTROL_DISPLAY,
&par, 1);
- if (ret) {
+ if (ret < 0) {
dev_err(nt->dev, "failed to disable display backlight (%d)\n", ret);
return ret;
}
--
2.50.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] drm: Add MIPI support function and macros
2025-07-29 5:44 [PATCH v2 0/3] drm/panel: novatek-nt35560: Fix bug and clean up Brigham Campbell
2025-07-29 5:44 ` [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value Brigham Campbell
@ 2025-07-29 5:44 ` Brigham Campbell
2025-07-29 21:34 ` Doug Anderson
2025-07-29 5:44 ` [PATCH v2 3/3] drm/panel: novatek-nt35560: Clean up driver Brigham Campbell
2025-07-29 17:49 ` [PATCH v2 0/3] drm/panel: novatek-nt35560: Fix bug and clean up Brigham Campbell
3 siblings, 1 reply; 11+ messages in thread
From: Brigham Campbell @ 2025-07-29 5:44 UTC (permalink / raw)
To: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
linus.walleij, neil.armstrong, jessica.zhang, sam
Cc: dianders, skhan, linux-kernel-mentees, dri-devel, linux-kernel,
Brigham Campbell
Create mipi_dsi_dcs_read_multi(), which accepts a mipi_dsi_multi_context
struct for improved error handling and cleaner panel driver code.
Create mipi_dsi_dcs_write_var_seq_multi() and
mipi_dsi_generic_write_var_seq_multi() macros which allow MIPI panel
drivers to write non-static data to display controllers.
Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
---
I looked into using __builtin_constant_p() to extend
mipi_dsi_{generic,dcs}_write_seq_multi() to accept both static and
non-static sequences of bytes and store them accordingly, it looked
promising at first, but I found no such solution ultimately. At the very
least, if we find a solution at some point, my hope is that cocinelle
could be used to replace each of the new var_seq_multi() usages among
drivers with an improved seq_multi().
drivers/gpu/drm/drm_mipi_dsi.c | 37 ++++++++++++++++++++++++++++++++++
include/drm/drm_mipi_dsi.h | 35 ++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index a00d76443128..0f2c3be98212 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -1075,6 +1075,43 @@ ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
}
EXPORT_SYMBOL(mipi_dsi_dcs_read);
+/**
+ * mipi_dsi_dcs_read_multi() - mipi_dsi_dcs_read() w/ accum_err
+ * @ctx: Context for multiple DSI transactions
+ * @cmd: DCS command
+ * @data: buffer in which to receive data
+ * @len: size of receive buffer
+ *
+ * Like mipi_dsi_dcs_read() but deals with errors in a way that makes it
+ * convenient to make several calls in a row.
+ */
+void mipi_dsi_dcs_read_multi(struct mipi_dsi_multi_context *ctx, u8 cmd,
+ void *data, size_t len)
+{
+ struct mipi_dsi_device *dsi = ctx->dsi;
+ struct device *dev = &dsi->dev;
+ struct mipi_dsi_msg msg = {
+ .channel = dsi->channel,
+ .type = MIPI_DSI_DCS_READ,
+ .tx_buf = &cmd,
+ .tx_len = 1,
+ .rx_buf = data,
+ .rx_len = len
+ };
+ ssize_t ret;
+
+ if (ctx->accum_err)
+ return;
+
+ ret = mipi_dsi_device_transfer(dsi, &msg);
+ if (ret < 0) {
+ ctx->accum_err = ret;
+ dev_err(dev, "dcs read with command %#x failed: %d\n", cmd,
+ ctx->accum_err);
+ }
+}
+EXPORT_SYMBOL(mipi_dsi_dcs_read_multi);
+
/**
* mipi_dsi_dcs_nop() - send DCS nop packet
* @dsi: DSI peripheral device
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 369b0d8830c3..bfee4071e89e 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -333,6 +333,8 @@ ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd,
const void *data, size_t len);
ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
size_t len);
+void mipi_dsi_dcs_read_multi(struct mipi_dsi_multi_context *ctx, u8 cmd,
+ void *data, size_t len);
int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi);
int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi);
int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode);
@@ -415,6 +417,22 @@ void mipi_dsi_dcs_set_tear_off_multi(struct mipi_dsi_multi_context *ctx);
mipi_dsi_generic_write_multi(ctx, d, ARRAY_SIZE(d)); \
} while (0)
+/**
+ * mipi_dsi_generic_write_var_seq_multi - transmit non-static data using a
+ * generic write packet
+ *
+ * This macro will print errors for you and error handling is optimized for
+ * callers that call this multiple times in a row.
+ *
+ * @ctx: Context for multiple DSI transactions
+ * @seq: buffer containing the payload
+ */
+#define mipi_dsi_generic_write_var_seq_multi(ctx, seq...) \
+ do { \
+ const u8 d[] = { seq }; \
+ mipi_dsi_generic_write_multi(ctx, d, ARRAY_SIZE(d)); \
+ } while (0)
+
/**
* mipi_dsi_dcs_write_seq_multi - transmit a DCS command with payload
*
@@ -431,6 +449,23 @@ void mipi_dsi_dcs_set_tear_off_multi(struct mipi_dsi_multi_context *ctx);
mipi_dsi_dcs_write_buffer_multi(ctx, d, ARRAY_SIZE(d)); \
} while (0)
+/**
+ * mipi_dsi_dcs_write_var_seq_multi - transmit a DCS command with non-static
+ * payload
+ *
+ * This macro will print errors for you and error handling is optimized for
+ * callers that call this multiple times in a row.
+ *
+ * @ctx: Context for multiple DSI transactions
+ * @cmd: Command
+ * @seq: buffer containing data to be transmitted
+ */
+#define mipi_dsi_dcs_write_var_seq_multi(ctx, cmd, seq...) \
+ do { \
+ const u8 d[] = { cmd, seq }; \
+ mipi_dsi_dcs_write_buffer_multi(ctx, d, ARRAY_SIZE(d)); \
+ } while (0)
+
/**
* struct mipi_dsi_driver - DSI driver
* @driver: device driver model driver
--
2.50.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 3/3] drm/panel: novatek-nt35560: Clean up driver
2025-07-29 5:44 [PATCH v2 0/3] drm/panel: novatek-nt35560: Fix bug and clean up Brigham Campbell
2025-07-29 5:44 ` [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value Brigham Campbell
2025-07-29 5:44 ` [PATCH v2 2/3] drm: Add MIPI support function and macros Brigham Campbell
@ 2025-07-29 5:44 ` Brigham Campbell
2025-07-29 21:34 ` Doug Anderson
2025-07-29 17:49 ` [PATCH v2 0/3] drm/panel: novatek-nt35560: Fix bug and clean up Brigham Campbell
3 siblings, 1 reply; 11+ messages in thread
From: Brigham Campbell @ 2025-07-29 5:44 UTC (permalink / raw)
To: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
linus.walleij, neil.armstrong, jessica.zhang, sam
Cc: dianders, skhan, linux-kernel-mentees, dri-devel, linux-kernel,
Brigham Campbell
Update driver to use the "multi" variants of MIPI functions which
facilitate improved error handling and cleaner driver code.
Remove information from a comment which was made obsolete by commit
994ea402c767 ("drm/panel: Rename Sony ACX424 to Novatek NT35560"), which
determined that this driver supports the Novatek NT35560 panel
controller.
Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
---
drivers/gpu/drm/panel/panel-novatek-nt35560.c | 198 ++++++------------
1 file changed, 60 insertions(+), 138 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-novatek-nt35560.c b/drivers/gpu/drm/panel/panel-novatek-nt35560.c
index 17898a29efe8..561e6643dcbb 100644
--- a/drivers/gpu/drm/panel/panel-novatek-nt35560.c
+++ b/drivers/gpu/drm/panel/panel-novatek-nt35560.c
@@ -148,24 +148,20 @@ static inline struct nt35560 *panel_to_nt35560(struct drm_panel *panel)
static int nt35560_set_brightness(struct backlight_device *bl)
{
struct nt35560 *nt = bl_get_data(bl);
- struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
- int period_ns = 1023;
+ struct mipi_dsi_multi_context dsi_ctx = {
+ .dsi = to_mipi_dsi_device(nt->dev)
+ };
int duty_ns = bl->props.brightness;
+ int period_ns = 1023;
u8 pwm_ratio;
u8 pwm_div;
- u8 par;
- int ret;
if (backlight_is_blank(bl)) {
/* Disable backlight */
- par = 0x00;
- ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_WRITE_CONTROL_DISPLAY,
- &par, 1);
- if (ret < 0) {
- dev_err(nt->dev, "failed to disable display backlight (%d)\n", ret);
- return ret;
- }
- return 0;
+ mipi_dsi_dcs_write_seq_multi(&dsi_ctx,
+ MIPI_DCS_WRITE_CONTROL_DISPLAY,
+ 0x00);
+ return dsi_ctx.accum_err;
}
/* Calculate the PWM duty cycle in n/256's */
@@ -176,12 +172,6 @@ static int nt35560_set_brightness(struct backlight_device *bl)
/* Set up PWM dutycycle ONE byte (differs from the standard) */
dev_dbg(nt->dev, "calculated duty cycle %02x\n", pwm_ratio);
- ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
- &pwm_ratio, 1);
- if (ret < 0) {
- dev_err(nt->dev, "failed to set display PWM ratio (%d)\n", ret);
- return ret;
- }
/*
* Sequence to write PWMDIV:
@@ -192,46 +182,23 @@ static int nt35560_set_brightness(struct backlight_device *bl)
* 0x22 PWMDIV
* 0x7F 0xAA CMD2 page 1 lock
*/
- par = 0xaa;
- ret = mipi_dsi_dcs_write(dsi, 0xf3, &par, 1);
- if (ret < 0) {
- dev_err(nt->dev, "failed to unlock CMD 2 (%d)\n", ret);
- return ret;
- }
- par = 0x01;
- ret = mipi_dsi_dcs_write(dsi, 0x00, &par, 1);
- if (ret < 0) {
- dev_err(nt->dev, "failed to enter page 1 (%d)\n", ret);
- return ret;
- }
- par = 0x01;
- ret = mipi_dsi_dcs_write(dsi, 0x7d, &par, 1);
- if (ret < 0) {
- dev_err(nt->dev, "failed to disable MTP reload (%d)\n", ret);
- return ret;
- }
- ret = mipi_dsi_dcs_write(dsi, 0x22, &pwm_div, 1);
- if (ret < 0) {
- dev_err(nt->dev, "failed to set PWM divisor (%d)\n", ret);
- return ret;
- }
- par = 0xaa;
- ret = mipi_dsi_dcs_write(dsi, 0x7f, &par, 1);
- if (ret < 0) {
- dev_err(nt->dev, "failed to lock CMD 2 (%d)\n", ret);
- return ret;
- }
+ mipi_dsi_dcs_write_var_seq_multi(&dsi_ctx,
+ MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
+ pwm_ratio);
+
+ mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf3, 0xaa);
+ mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0x00, 0x01);
+ mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0x7d, 0x01);
+
+ mipi_dsi_dcs_write_var_seq_multi(&dsi_ctx, 0x22, pwm_div);
+
+ mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0x7f, 0xaa);
/* Enable backlight */
- par = 0x24;
- ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_WRITE_CONTROL_DISPLAY,
- &par, 1);
- if (ret < 0) {
- dev_err(nt->dev, "failed to enable display backlight (%d)\n", ret);
- return ret;
- }
+ mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_WRITE_CONTROL_DISPLAY,
+ 0x24);
- return 0;
+ return dsi_ctx.accum_err;
}
static const struct backlight_ops nt35560_bl_ops = {
@@ -244,32 +211,23 @@ static const struct backlight_properties nt35560_bl_props = {
.max_brightness = 1023,
};
-static int nt35560_read_id(struct nt35560 *nt)
+static void nt35560_read_id(struct mipi_dsi_multi_context *dsi_ctx)
{
- struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
+ struct device dev = dsi_ctx->dsi->dev;
u8 vendor, version, panel;
u16 val;
- int ret;
- ret = mipi_dsi_dcs_read(dsi, NT35560_DCS_READ_ID1, &vendor, 1);
- if (ret < 0) {
- dev_err(nt->dev, "could not vendor ID byte\n");
- return ret;
- }
- ret = mipi_dsi_dcs_read(dsi, NT35560_DCS_READ_ID2, &version, 1);
- if (ret < 0) {
- dev_err(nt->dev, "could not read device version byte\n");
- return ret;
- }
- ret = mipi_dsi_dcs_read(dsi, NT35560_DCS_READ_ID3, &panel, 1);
- if (ret < 0) {
- dev_err(nt->dev, "could not read panel ID byte\n");
- return ret;
- }
+ mipi_dsi_dcs_read_multi(dsi_ctx, NT35560_DCS_READ_ID1, &vendor, 1);
+ mipi_dsi_dcs_read_multi(dsi_ctx, NT35560_DCS_READ_ID2, &version, 1);
+ mipi_dsi_dcs_read_multi(dsi_ctx, NT35560_DCS_READ_ID3, &panel, 1);
+
+ if (dsi_ctx->accum_err < 0)
+ return;
if (vendor == 0x00) {
- dev_err(nt->dev, "device vendor ID is zero\n");
- return -ENODEV;
+ dev_err(&dev, "device vendor ID is zero\n");
+ dsi_ctx->accum_err = -ENODEV;
+ return;
}
val = (vendor << 8) | panel;
@@ -278,16 +236,16 @@ static int nt35560_read_id(struct nt35560 *nt)
case DISPLAY_SONY_ACX424AKP_ID2:
case DISPLAY_SONY_ACX424AKP_ID3:
case DISPLAY_SONY_ACX424AKP_ID4:
- dev_info(nt->dev, "MTP vendor: %02x, version: %02x, panel: %02x\n",
+ dev_info(&dev,
+ "MTP vendor: %02x, version: %02x, panel: %02x\n",
vendor, version, panel);
break;
default:
- dev_info(nt->dev, "unknown vendor: %02x, version: %02x, panel: %02x\n",
+ dev_info(&dev,
+ "unknown vendor: %02x, version: %02x, panel: %02x\n",
vendor, version, panel);
break;
}
-
- return 0;
}
static int nt35560_power_on(struct nt35560 *nt)
@@ -322,92 +280,56 @@ static void nt35560_power_off(struct nt35560 *nt)
static int nt35560_prepare(struct drm_panel *panel)
{
struct nt35560 *nt = panel_to_nt35560(panel);
- struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
- const u8 mddi = 3;
+ struct mipi_dsi_multi_context dsi_ctx = {
+ .dsi = to_mipi_dsi_device(nt->dev)
+ };
int ret;
ret = nt35560_power_on(nt);
if (ret)
return ret;
- ret = nt35560_read_id(nt);
- if (ret) {
- dev_err(nt->dev, "failed to read panel ID (%d)\n", ret);
- goto err_power_off;
- }
+ nt35560_read_id(&dsi_ctx);
- /* Enabe tearing mode: send TE (tearing effect) at VBLANK */
- ret = mipi_dsi_dcs_set_tear_on(dsi,
+ /* Enable tearing mode: send TE (tearing effect) at VBLANK */
+ mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx,
MIPI_DSI_DCS_TEAR_MODE_VBLANK);
- if (ret) {
- dev_err(nt->dev, "failed to enable vblank TE (%d)\n", ret);
- goto err_power_off;
- }
/*
* Set MDDI
*
* This presumably deactivates the Qualcomm MDDI interface and
* selects DSI, similar code is found in other drivers such as the
- * Sharp LS043T1LE01 which makes us suspect that this panel may be
- * using a Novatek NT35565 or similar display driver chip that shares
- * this command. Due to the lack of documentation we cannot know for
- * sure.
+ * Sharp LS043T1LE01.
*/
- ret = mipi_dsi_dcs_write(dsi, NT35560_DCS_SET_MDDI,
- &mddi, sizeof(mddi));
- if (ret < 0) {
- dev_err(nt->dev, "failed to set MDDI (%d)\n", ret);
- goto err_power_off;
- }
+ mipi_dsi_dcs_write_seq_multi(&dsi_ctx, NT35560_DCS_SET_MDDI, 3);
- /* Exit sleep mode */
- ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
- if (ret) {
- dev_err(nt->dev, "failed to exit sleep mode (%d)\n", ret);
- goto err_power_off;
- }
- msleep(140);
+ mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
+ mipi_dsi_msleep(&dsi_ctx, 140);
- ret = mipi_dsi_dcs_set_display_on(dsi);
- if (ret) {
- dev_err(nt->dev, "failed to turn display on (%d)\n", ret);
- goto err_power_off;
- }
+ mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
if (nt->video_mode) {
- /* In video mode turn peripheral on */
- ret = mipi_dsi_turn_on_peripheral(dsi);
- if (ret) {
- dev_err(nt->dev, "failed to turn on peripheral\n");
- goto err_power_off;
- }
+ mipi_dsi_turn_on_peripheral_multi(&dsi_ctx);
}
- return 0;
-
-err_power_off:
- nt35560_power_off(nt);
- return ret;
+ if (dsi_ctx.accum_err < 0)
+ nt35560_power_off(nt);
+ return dsi_ctx.accum_err;
}
static int nt35560_unprepare(struct drm_panel *panel)
{
struct nt35560 *nt = panel_to_nt35560(panel);
- struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
- int ret;
+ struct mipi_dsi_multi_context dsi_ctx = {
+ .dsi = to_mipi_dsi_device(nt->dev)
+ };
- ret = mipi_dsi_dcs_set_display_off(dsi);
- if (ret) {
- dev_err(nt->dev, "failed to turn display off (%d)\n", ret);
- return ret;
- }
+ mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
+ mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
+
+ if (dsi_ctx.accum_err < 0)
+ return dsi_ctx.accum_err;
- /* Enter sleep mode */
- ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
- if (ret) {
- dev_err(nt->dev, "failed to enter sleep mode (%d)\n", ret);
- return ret;
- }
msleep(85);
nt35560_power_off(nt);
--
2.50.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value
2025-07-29 5:44 ` [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value Brigham Campbell
@ 2025-07-29 9:17 ` neil.armstrong
2025-07-29 21:33 ` Doug Anderson
1 sibling, 0 replies; 11+ messages in thread
From: neil.armstrong @ 2025-07-29 9:17 UTC (permalink / raw)
To: Brigham Campbell, maarten.lankhorst, mripard, tzimmermann,
airlied, simona, linus.walleij, jessica.zhang, sam
Cc: dianders, skhan, linux-kernel-mentees, dri-devel, linux-kernel
On 29/07/2025 07:44, Brigham Campbell wrote:
> Fix bug in nt35560_set_brightness() which causes the function to
> erroneously report an error. mipi_dsi_dcs_write() returns either a
> negative value when an error occurred or a positive number of bytes
> written when no error occurred. The buggy code reports an error under
> either condition.
>
> Fixes: 7835ed6a9e86 ("drm/panel-sony-acx424akp: Modernize backlight handling")
> Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
> ---
> drivers/gpu/drm/panel/panel-novatek-nt35560.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/panel/panel-novatek-nt35560.c b/drivers/gpu/drm/panel/panel-novatek-nt35560.c
> index 98f0782c8411..17898a29efe8 100644
> --- a/drivers/gpu/drm/panel/panel-novatek-nt35560.c
> +++ b/drivers/gpu/drm/panel/panel-novatek-nt35560.c
> @@ -161,7 +161,7 @@ static int nt35560_set_brightness(struct backlight_device *bl)
> par = 0x00;
> ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_WRITE_CONTROL_DISPLAY,
> &par, 1);
> - if (ret) {
> + if (ret < 0) {
> dev_err(nt->dev, "failed to disable display backlight (%d)\n", ret);
> return ret;
> }
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/3] drm/panel: novatek-nt35560: Fix bug and clean up
2025-07-29 5:44 [PATCH v2 0/3] drm/panel: novatek-nt35560: Fix bug and clean up Brigham Campbell
` (2 preceding siblings ...)
2025-07-29 5:44 ` [PATCH v2 3/3] drm/panel: novatek-nt35560: Clean up driver Brigham Campbell
@ 2025-07-29 17:49 ` Brigham Campbell
3 siblings, 0 replies; 11+ messages in thread
From: Brigham Campbell @ 2025-07-29 17:49 UTC (permalink / raw)
To: Brigham Campbell, maarten.lankhorst, mripard, tzimmermann,
airlied, simona, linus.walleij, neil.armstrong, jessica.zhang,
sam
Cc: dianders, skhan, linux-kernel-mentees, dri-devel, linux-kernel
Oops! My apologies for forgetting to add the following changelog to the
cover letter.
Changes to v2:
- Separate bug fix into its own commit for backporting
- Add var_seq_multi() variants of MIPI write macros for sending
non-static MIPI messages.
- Minor formatting improvements.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value
2025-07-29 5:44 ` [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value Brigham Campbell
2025-07-29 9:17 ` neil.armstrong
@ 2025-07-29 21:33 ` Doug Anderson
2025-07-30 0:02 ` Brigham Campbell
1 sibling, 1 reply; 11+ messages in thread
From: Doug Anderson @ 2025-07-29 21:33 UTC (permalink / raw)
To: Brigham Campbell
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
linus.walleij, neil.armstrong, jessica.zhang, sam, skhan,
linux-kernel-mentees, dri-devel, linux-kernel
Hi,
On Mon, Jul 28, 2025 at 10:44 PM Brigham Campbell
<me@brighamcampbell.com> wrote:
>
> Fix bug in nt35560_set_brightness() which causes the function to
> erroneously report an error. mipi_dsi_dcs_write() returns either a
> negative value when an error occurred or a positive number of bytes
> written when no error occurred. The buggy code reports an error under
> either condition.
>
> Fixes: 7835ed6a9e86 ("drm/panel-sony-acx424akp: Modernize backlight handling")
I think your Fixes tag is wrong, actually. I think it needs to be:
Fixes: 8152c2bfd780 ("drm/panel: Add driver for Sony ACX424AKP panel")
Even though that commit that you pointed at moved the code around, I
believe the code has been wrong since the start of the driver.
Other than that:
Reviewed-by: Douglas Anderson <dianders@chromium.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/3] drm: Add MIPI support function and macros
2025-07-29 5:44 ` [PATCH v2 2/3] drm: Add MIPI support function and macros Brigham Campbell
@ 2025-07-29 21:34 ` Doug Anderson
2025-07-30 0:15 ` Brigham Campbell
0 siblings, 1 reply; 11+ messages in thread
From: Doug Anderson @ 2025-07-29 21:34 UTC (permalink / raw)
To: Brigham Campbell
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
linus.walleij, neil.armstrong, jessica.zhang, sam, skhan,
linux-kernel-mentees, dri-devel, linux-kernel
Hi,
On Mon, Jul 28, 2025 at 10:44 PM Brigham Campbell
<me@brighamcampbell.com> wrote:
>
> Create mipi_dsi_dcs_read_multi(), which accepts a mipi_dsi_multi_context
> struct for improved error handling and cleaner panel driver code.
>
> Create mipi_dsi_dcs_write_var_seq_multi() and
> mipi_dsi_generic_write_var_seq_multi() macros which allow MIPI panel
> drivers to write non-static data to display controllers.
>
> Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
> ---
>
> I looked into using __builtin_constant_p() to extend
> mipi_dsi_{generic,dcs}_write_seq_multi() to accept both static and
> non-static sequences of bytes and store them accordingly, it looked
> promising at first, but I found no such solution ultimately. At the very
> least, if we find a solution at some point, my hope is that cocinelle
> could be used to replace each of the new var_seq_multi() usages among
> drivers with an improved seq_multi().
>
>
> drivers/gpu/drm/drm_mipi_dsi.c | 37 ++++++++++++++++++++++++++++++++++
> include/drm/drm_mipi_dsi.h | 35 ++++++++++++++++++++++++++++++++
> 2 files changed, 72 insertions(+)
nit: maybe make the subject a bit more specific, like:
drm: Add MIPI _multi reader func and two new write variants
> @@ -415,6 +417,22 @@ void mipi_dsi_dcs_set_tear_off_multi(struct mipi_dsi_multi_context *ctx);
> mipi_dsi_generic_write_multi(ctx, d, ARRAY_SIZE(d)); \
> } while (0)
>
> +/**
> + * mipi_dsi_generic_write_var_seq_multi - transmit non-static data using a
> + * generic write packet
nit: "non-constant", not "non-static"
From the caller's point of view the difference is that the data is
compile-time constant in one case and not compile-time constant in the
other case. It happens that means you can _store_ it in a "static
const" in one case and not in the other case, but that doesn't make
the parameters "static".
Other than nits:
Reviewed-by: Douglas Anderson <dianders@chromium.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] drm/panel: novatek-nt35560: Clean up driver
2025-07-29 5:44 ` [PATCH v2 3/3] drm/panel: novatek-nt35560: Clean up driver Brigham Campbell
@ 2025-07-29 21:34 ` Doug Anderson
0 siblings, 0 replies; 11+ messages in thread
From: Doug Anderson @ 2025-07-29 21:34 UTC (permalink / raw)
To: Brigham Campbell
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
linus.walleij, neil.armstrong, jessica.zhang, sam, skhan,
linux-kernel-mentees, dri-devel, linux-kernel
Hi,
On Mon, Jul 28, 2025 at 10:44 PM Brigham Campbell
<me@brighamcampbell.com> wrote:
>
> Update driver to use the "multi" variants of MIPI functions which
> facilitate improved error handling and cleaner driver code.
>
> Remove information from a comment which was made obsolete by commit
> 994ea402c767 ("drm/panel: Rename Sony ACX424 to Novatek NT35560"), which
> determined that this driver supports the Novatek NT35560 panel
> controller.
>
> Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
> ---
> drivers/gpu/drm/panel/panel-novatek-nt35560.c | 198 ++++++------------
> 1 file changed, 60 insertions(+), 138 deletions(-)
Reviewed-by: Douglas Anderson <dianders@chromium.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value
2025-07-29 21:33 ` Doug Anderson
@ 2025-07-30 0:02 ` Brigham Campbell
0 siblings, 0 replies; 11+ messages in thread
From: Brigham Campbell @ 2025-07-30 0:02 UTC (permalink / raw)
To: Doug Anderson
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
linus.walleij, neil.armstrong, jessica.zhang, sam, skhan,
linux-kernel-mentees, dri-devel, linux-kernel
On Tue Jul 29, 2025 at 3:33 PM MDT, Doug Anderson wrote:
>>
>> Fixes: 7835ed6a9e86 ("drm/panel-sony-acx424akp: Modernize backlight handling")
>
> I think your Fixes tag is wrong, actually. I think it needs to be:
>
> Fixes: 8152c2bfd780 ("drm/panel: Add driver for Sony ACX424AKP panel")
Oh, good catch! I thought that 7835ed6a9e86 introduced that code instead
of just reorganizing it. I'll remember to take a closer look at the git
tree next time I add a Fixes tag to a commit and I'll address this in
v3.
Thanks,
Brigham
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/3] drm: Add MIPI support function and macros
2025-07-29 21:34 ` Doug Anderson
@ 2025-07-30 0:15 ` Brigham Campbell
0 siblings, 0 replies; 11+ messages in thread
From: Brigham Campbell @ 2025-07-30 0:15 UTC (permalink / raw)
To: Doug Anderson
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
linus.walleij, neil.armstrong, jessica.zhang, sam, skhan,
linux-kernel-mentees, dri-devel, linux-kernel
On Tue Jul 29, 2025 at 3:34 PM MDT, Doug Anderson wrote:
>> +/**
>> + * mipi_dsi_generic_write_var_seq_multi - transmit non-static data using a
>> + * generic write packet
>
> nit: "non-constant", not "non-static"
>
> From the caller's point of view the difference is that the data is
> compile-time constant in one case and not compile-time constant in the
> other case. It happens that means you can _store_ it in a "static
> const" in one case and not in the other case, but that doesn't make
> the parameters "static".
Good point. The storage class is an important implementation detail
within drm_mipi_dsi.h, but just that from the perspective of a panel
driver author: an implementation detail. I'll go ahead and address this
and other feedback in v3.
Thanks,
Brigham
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-07-30 0:15 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29 5:44 [PATCH v2 0/3] drm/panel: novatek-nt35560: Fix bug and clean up Brigham Campbell
2025-07-29 5:44 ` [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value Brigham Campbell
2025-07-29 9:17 ` neil.armstrong
2025-07-29 21:33 ` Doug Anderson
2025-07-30 0:02 ` Brigham Campbell
2025-07-29 5:44 ` [PATCH v2 2/3] drm: Add MIPI support function and macros Brigham Campbell
2025-07-29 21:34 ` Doug Anderson
2025-07-30 0:15 ` Brigham Campbell
2025-07-29 5:44 ` [PATCH v2 3/3] drm/panel: novatek-nt35560: Clean up driver Brigham Campbell
2025-07-29 21:34 ` Doug Anderson
2025-07-29 17:49 ` [PATCH v2 0/3] drm/panel: novatek-nt35560: Fix bug and clean up Brigham Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).