drm/panel: samsung: Share test key command helpers
Subsystems (7)
cover drm/panel: samsung: Share test key command helpers
Several Samsung display controller drivers use identical three-byte commands to enable and disable test key levels. The commands are currently repeated as driver-specific macros or raw DCS writes.
Add a private Samsung DSI header with typed helpers for all three test key levels. Use it in the drivers that already identify these commands by level, including the S6E88A0 AMS452EF01 driver whose comments identify the raw F0 pair as level 2 commands.
Drivers with conflicting level numbering or without an established test-key name are deliberately left unchanged.
---
Linus Walleij (2):
drm/panel: samsung: Add shared test key helpers drm/panel: samsung-s6e88a0-ams452ef01: Use test key helpers
drivers/gpu/drm/panel/panel-samsung-dsi.h | 38 ++++++++++++ drivers/gpu/drm/panel/panel-samsung-s6e3fc2x01.c | 71 +++++++++------------- drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c | 70 +++++++++------------ .../drm/panel/panel-samsung-s6e88a0-ams452ef01.c | 6 +- .../gpu/drm/panel/panel-samsung-s6e8fc0-m1906f9.c | 23 +++---- drivers/gpu/drm/panel/panel-samsung-sofef00.c | 15 ++--- 6 files changed, 116 insertions(+), 107 deletions(-)
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260903-drm-panels-sofef0-73886714ac49
Best regards,
Signature · 1 line
Linus Walleij <[email protected]>
PATCH 1/2 drm/panel: samsung: Add shared test key helpers
Several Samsung display controllers use identical commands to enable and disable their three levels of test keys. The drivers currently duplicate these commands in local macros.
Move the commands to typed helpers in a private Samsung DSI header and use them from the drivers which already identify the commands by their test key level.
--- drivers/gpu/drm/panel/panel-samsung-dsi.h | 38 ++++++++++++ drivers/gpu/drm/panel/panel-samsung-s6e3fc2x01.c | 71 +++++++++------------- drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c | 70 +++++++++------------ .../gpu/drm/panel/panel-samsung-s6e8fc0-m1906f9.c | 23 +++---- drivers/gpu/drm/panel/panel-samsung-sofef00.c | 15 ++--- 5 files changed, 112 insertions(+), 105 deletions(-)
drivers/gpu/drm/panel/panel-samsung-dsi.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _PANEL_SAMSUNG_DSI_H +#define _PANEL_SAMSUNG_DSI_H + +#include <drm/drm_mipi_dsi.h> + +static inline void samsung_dsi_test_key_on_lvl1 (struct mipi_dsi_multi_context *ctx) +{ +mipi_dsi_dcs_write_seq_multi (ctx,0x9f ,0xa5 ,0xa5 ); +} + +static inline void samsung_dsi_test_key_off_lvl1 (struct mipi_dsi_multi_context *ctx) +{ +mipi_dsi_dcs_write_seq_multi (ctx,0x9f ,0x5a ,0x5a ); +} + +static inline void samsung_dsi_test_key_on_lvl2 (struct mipi_dsi_multi_context *ctx) +{ +mipi_dsi_dcs_write_seq_multi (ctx,0xf0 ,0x5a ,0x5a ); +} + +static inline void samsung_dsi_test_key_off_lvl2 (struct mipi_dsi_multi_context *ctx) +{ +mipi_dsi_dcs_write_seq_multi (ctx,0xf0 ,0xa5 ,0xa5 ); +} + +static inline void samsung_dsi_test_key_on_lvl3 (struct mipi_dsi_multi_context *ctx) +{ +mipi_dsi_dcs_write_seq_multi (ctx,0xfc ,0x5a ,0x5a ); +} + +static inline void samsung_dsi_test_key_off_lvl3 (struct mipi_dsi_multi_context *ctx) +{ +mipi_dsi_dcs_write_seq_multi (ctx,0xfc ,0xa5 ,0xa5 ); +} + +#endif /* _PANEL_SAMSUNG_DSI_H */
drivers/gpu/drm/panel/panel-samsung-s6e3fc2x01.c +30 -41
176 lines not on this page · raw message
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c +30 -40
152 lines not on this page · raw message
drivers/gpu/drm/panel/panel-samsung-s6e8fc0-m1906f9.c +8 -15
@@ -17,6 +17,8 @@#include <drm/drm_panel.h> #include <drm/drm_probe_helper.h> +#include "panel-samsung-dsi.h" +struct s6e8fc0_ctx {struct drm_panel panel;struct mipi_dsi_device *dsi;
@@ -45,20 +47,11 @@ static void s6e8fc0_m1906f9_reset(struct s6e8fc0_ctx *ctx)usleep_range (10000 ,11000 ); } -#define s6e8fc0_test_key_on_lvl2 (ctx) \ - mipi_dsi_dcs_write_seq_multi(ctx, 0xf0, 0x5a, 0x5a) -#define s6e8fc0_test_key_off_lvl2 (ctx) \ - mipi_dsi_dcs_write_seq_multi(ctx, 0xf0, 0xa5, 0xa5) -#define s6e8fc0_test_key_on_lvl3 (ctx) \ - mipi_dsi_dcs_write_seq_multi(ctx, 0xfc, 0x5a, 0x5a) -#define s6e8fc0_test_key_off_lvl3 (ctx) \ - mipi_dsi_dcs_write_seq_multi(ctx, 0xfc, 0xa5, 0xa5) -static int s6e8fc0_m1906f9_on (struct s6e8fc0_ctx *ctx) {struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi }; -s6e8fc0_test_key_on_lvl3 (&dsi_ctx); +samsung_dsi_test_key_on_lvl3 (&dsi_ctx);mipi_dsi_dcs_set_display_brightness_multi (&dsi_ctx,0x0000 ); mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_WRITE_CONTROL_DISPLAY,
@@ -71,15 +64,15 @@ static int s6e8fc0_m1906f9_on(struct s6e8fc0_ctx *ctx)mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xed ,0xe4 ,0x08 ,0x96 ,0xa4 ,0x2a ,0x72 ,0xe2 ,0xca ,0x00 ); -s6e8fc0_test_key_off_lvl3 (&dsi_ctx); -s6e8fc0_test_key_on_lvl2 (&dsi_ctx); -s6e8fc0_test_key_on_lvl3 (&dsi_ctx); +samsung_dsi_test_key_off_lvl3 (&dsi_ctx); +samsung_dsi_test_key_on_lvl2 (&dsi_ctx); +samsung_dsi_test_key_on_lvl3 (&dsi_ctx);mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xe1 ,0x93 );mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xb0 ,0x05 ,0xf4 );mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xf4 ,0x03 );mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xed ,0x01 ,0x81 ,0x04 ); -s6e8fc0_test_key_off_lvl2 (&dsi_ctx); -s6e8fc0_test_key_off_lvl3 (&dsi_ctx); +samsung_dsi_test_key_off_lvl2 (&dsi_ctx); +samsung_dsi_test_key_off_lvl3 (&dsi_ctx);return dsi_ctx.accum_err; }
drivers/gpu/drm/panel/panel-samsung-sofef00.c +6 -9
@@ -18,6 +18,8 @@#include <drm/drm_panel.h> #include <drm/drm_probe_helper.h> +#include "panel-samsung-dsi.h" +struct sofef00_panel {struct drm_panel panel;struct mipi_dsi_device *dsi;
@@ -37,11 +39,6 @@ struct sofef00_panel *to_sofef00_panel(struct drm_panel *panel) return container_of(panel, struct sofef00_panel, panel); } -#define sofef00_test_key_on_lvl2 (ctx) \ - mipi_dsi_dcs_write_seq_multi(ctx, 0xf0, 0x5a, 0x5a) -#define sofef00_test_key_off_lvl2 (ctx) \ - mipi_dsi_dcs_write_seq_multi(ctx, 0xf0, 0xa5, 0xa5) -static void sofef00_panel_reset (struct sofef00_panel *ctx) {gpiod_set_value_cansleep (ctx->reset_gpio,0 );
@@ -62,14 +59,14 @@ static int sofef00_panel_on(struct sofef00_panel *ctx)mipi_dsi_dcs_exit_sleep_mode_multi (&dsi_ctx);mipi_dsi_usleep_range (&dsi_ctx,10000 ,11000 ); -sofef00_test_key_on_lvl2 (&dsi_ctx); +samsung_dsi_test_key_on_lvl2 (&dsi_ctx);mipi_dsi_dcs_set_tear_on_multi (&dsi_ctx,MIPI_DSI_DCS_TEAR_MODE_VBLANK ); -sofef00_test_key_off_lvl2 (&dsi_ctx); +samsung_dsi_test_key_off_lvl2 (&dsi_ctx); -sofef00_test_key_on_lvl2 (&dsi_ctx); +samsung_dsi_test_key_on_lvl2 (&dsi_ctx);mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xb0 ,0x07 );mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xb6 ,0x12 ); -sofef00_test_key_off_lvl2 (&dsi_ctx); +samsung_dsi_test_key_off_lvl2 (&dsi_ctx);mipi_dsi_dcs_write_seq_multi (&dsi_ctx,MIPI_DCS_WRITE_CONTROL_DISPLAY ,0x20 );mipi_dsi_dcs_write_seq_multi (&dsi_ctx,MIPI_DCS_WRITE_POWER_SAVE ,0x00 );
Signature · 1 line
2.55.0
PATCH 2/2 drm/panel: samsung-s6e88a0-ams452ef01: Use test key helpers
In reply to Linus WalleijThe F0 command pair in this driver is already documented as enabling and disabling level 2 commands. Replace the raw writes with the shared level 2 test key helpers.
--- drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams452ef01.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams452ef01.c +4 -2
@@ -13,6 +13,8 @@#include <drm/drm_modes.h> #include <drm/drm_panel.h> +#include "panel-samsung-dsi.h" +struct s6e88a0_ams452ef01 {struct drm_panel panel;struct mipi_dsi_device *dsi;
@@ -43,7 +45,7 @@ static int s6e88a0_ams452ef01_on(struct s6e88a0_ams452ef01 *ctx) dsi->mode_flags |=MIPI_DSI_MODE_LPM ; -mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xf0 ,0x5a ,0x5a );// enable LEVEL2 commands +samsung_dsi_test_key_on_lvl2 (&dsi_ctx);mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xcc ,0x4c );// set Pixel Clock Divider polarity mipi_dsi_dcs_exit_sleep_mode_multi (&dsi_ctx);
@@ -66,7 +68,7 @@ static int s6e88a0_ams452ef01_on(struct s6e88a0_ams452ef01 *ctx)mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xb6 ,0x2c ,0x0b );// set default elvss voltage mipi_dsi_dcs_write_seq_multi (&dsi_ctx,MIPI_DCS_WRITE_POWER_SAVE ,0x00 );mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xf7 ,0x03 );// gamma/aor update -mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0xf0 ,0xa5 ,0xa5 );// disable LEVEL2 commands +samsung_dsi_test_key_off_lvl2 (&dsi_ctx);mipi_dsi_dcs_set_display_on_multi (&dsi_ctx);
Signature · 1 line
2.55.0
Quoted 9 lines · Linus Walleij
Several Samsung display controller drivers use identical three-byte commands to enable and disable test key levels. The commands are currently repeated as driver-specific macros or raw DCS writes.
Add a private Samsung DSI header with typed helpers for all three test key levels. Use it in the drivers that already identify these commands by level, including the S6E88A0 AMS452EF01 driver whose comments identify the raw F0 pair as level 2 commands.
Quoted 6 lines
Drivers with conflicting level numbering or without an established test-key name are deliberately left unchanged.
Assisted-by LLMSigned-off-by Linus Walleij <[email protected]>---
In general,
I just hope the naming is correct, I would assume it's a bit of copy-pasta.
David
Quoted 26 lines · Linus Walleij
Several Samsung display controller drivers use identical three-byte commands to enable and disable test key levels. The commands are currently repeated as driver-specific macros or raw DCS writes.
Add a private Samsung DSI header with typed helpers for all three test key levels. Use it in the drivers that already identify these commands by level, including the S6E88A0 AMS452EF01 driver whose comments identify the raw F0 pair as level 2 commands.
Drivers with conflicting level numbering or without an established test-key name are deliberately left unchanged.
Assisted-by LLMSigned-off-by Linus Walleij <[email protected]>---
Linus Walleij (2):
drm/panel: samsung: Add shared test key helpers drm/panel: samsung-s6e88a0-ams452ef01: Use test key helpersdrivers/gpu/drm/panel/panel-samsung-dsi.h | 38 ++++++++++++ drivers/gpu/drm/panel/panel-samsung-s6e3fc2x01.c | 71 +++++++++------------- drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c | 70 +++++++++------------ .../drm/panel/panel-samsung-s6e88a0-ams452ef01.c | 6 +- .../gpu/drm/panel/panel-samsung-s6e8fc0-m1906f9.c | 23 +++---- drivers/gpu/drm/panel/panel-samsung-sofef00.c | 15 ++--- 6 files changed, 116 insertions(+), 107 deletions(-)
Quoted 8 lines
---
base-commit:cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260903-drm-panels-sofef0-73886714ac49Best regards,
--
Linus Walleij <[email protected]>
Thanks,
Neil
Quoted 3 lines · Linus Walleij
Several Samsung display controller drivers use identical three-byte commands to enable and disable test key levels. The commands are currently repeated as driver-specific macros or raw DCS writes.
Patches applied.
Yours,
Linus Walleij