extend "multi" functions and use them in jdi-fhd-r63452
Subsystems (3)
v3 cover extend "multi" functions and use them in jdi-fhd-r63452
This patch adds mipi_dsi_dcs_set_tear_scanline_multi to the list of multi functions and uses it with other multi functions in the jdi-fhd-r63452 panel.
This patch uses functions introduced in [1] and must be applied after it.
[1] https://lore.kernel.org/all/[email protected]/
---
Changes in v3:
- use mipi_dsi_usleep_range
Changes in v2:
- Fixed return values
- Removed extra error messages
v1: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
---
Tejas Vipin (2):
drm/mipi-dsi: Add mipi_dsi_dcs_set_tear_scanline_multi drm/panel: jdi-fhd-r63452: transition to mipi_dsi wrapped functions
drivers/gpu/drm/drm_mipi_dsi.c | 31 ++++ drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c | 149 ++++++------------- include/drm/drm_mipi_dsi.h | 2 + 3 files changed, 81 insertions(+), 101 deletions(-)
Signature · 1 line
2.46.0
PATCH v3 1/2 drm/mipi-dsi: Add mipi_dsi_dcs_set_tear_scanline_multi
mipi_dsi_dcs_set_tear_scanline_multi can heavily benefit from being converted to a multi style function as it is often called in the context of similar functions.
--- drivers/gpu/drm/drm_mipi_dsi.c | 31 +++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 2 ++ 2 files changed, 33 insertions(+)
drivers/gpu/drm/drm_mipi_dsi.c +31 -0
@@ -1339,6 +1339,9 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);* @dsi: DSI peripheral device * @scanline: scanline to use as trigger * +* This function is deprecated. Use mipi_dsi_dcs_set_tear_scanline_multi() +* instead. +* * Return: 0 on success or a negative error code on failure */ int mipi_dsi_dcs_set_tear_scanline (struct mipi_dsi_device *dsi,u16 scanline)
@@ -1833,6 +1836,34 @@ void mipi_dsi_dcs_set_page_address_multi(struct mipi_dsi_multi_context *ctx, }EXPORT_SYMBOL (mipi_dsi_dcs_set_page_address_multi); +/** +* mipi_dsi_dcs_set_tear_scanline_multi() - set the scanline to use as trigger for +* the Tearing Effect output signal of the display module +* @ctx: Context for multiple DSI transactions +* @scanline: scanline to use as trigger +* +* Like mipi_dsi_dcs_set_tear_scanline() but deals with errors in a way that +* makes it convenient to make several calls in a row. +*/ +void mipi_dsi_dcs_set_tear_scanline_multi (struct mipi_dsi_multi_context *ctx, +u16 scanline) +{ +struct mipi_dsi_device *dsi = ctx->dsi; +struct device *dev = &dsi->dev; +int ret; + +if (ctx->accum_err) +return ; + + ret =mipi_dsi_dcs_set_tear_scanline (dsi, scanline); +if (ret <0 ) { + ctx->accum_err = ret; +dev_err (dev,"Failed to set tear scanline: %d\n" , + ctx->accum_err); + } +} +EXPORT_SYMBOL (mipi_dsi_dcs_set_tear_scanline_multi); +static int mipi_dsi_drv_probe (struct device *dev) {struct mipi_dsi_driver *drv =to_mipi_dsi_driver (dev->driver);
include/drm/drm_mipi_dsi.h +2 -0
@@ -375,6 +375,8 @@ void mipi_dsi_dcs_set_column_address_multi(struct mipi_dsi_multi_context *ctx, u16 start, u16 end);void mipi_dsi_dcs_set_page_address_multi (struct mipi_dsi_multi_context *ctx,u16 start,u16 end); +void mipi_dsi_dcs_set_tear_scanline_multi (struct mipi_dsi_multi_context *ctx, +u16 scanline);/** * mipi_dsi_generic_write_seq - transmit data using a generic write packet
Signature · 1 line
2.46.0
Re: [PATCH v3 1/2] drm/mipi-dsi: Add mipi_dsi_dcs_set_tear_scanline_multi
Hi,
Quoted 11 lines · Tejas Vipin
mipi_dsi_dcs_set_tear_scanline_multican heavily benefit from being converted to a multi style function as it is often called in the context of similar functions.Reviewed-by Douglas Anderson <[email protected]>Signed-off-by Tejas Vipin <[email protected]>--- drivers/gpu/drm/drm_mipi_dsi.c | 31 +++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 2 ++ 2 files changed, 33 insertions(+)
Since I adjusted the whitespace on the previous patch when applying I had to adjust this one to fix the merge conflict. Then I also fixed the whitespace on this patch since the DRM tools run checkpatch in a more strict mode. :P
In any case, pushed to drm-misc-next.
[1/2] drm/mipi-dsi: Add mipi_dsi_dcs_set_tear_scanline_multi
commit: 051c86afc342aed1f84d66ff5d09dc9e1c1685a1
PATCH v3 2/2 drm/panel: jdi-fhd-r63452: transition to mipi_dsi wrapped functions
In reply to Tejas VipinChanges the jdi-fhd-r63452 panel to use multi style functions for improved error handling.
--- drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c | 149 ++++++------------- 1 file changed, 48 insertions(+), 101 deletions(-)
drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c +48 -101
@@ -41,142 +41,89 @@ static void jdi_fhd_r63452_reset(struct jdi_fhd_r63452 *ctx)static int jdi_fhd_r63452_on (struct jdi_fhd_r63452 *ctx) {struct mipi_dsi_device *dsi = ctx->dsi; -struct device *dev = &dsi->dev; -int ret; +struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; dsi->mode_flags |=MIPI_DSI_MODE_LPM ; -mipi_dsi_generic_write_seq (dsi,0xb0 ,0x00 ); -mipi_dsi_generic_write_seq (dsi,0xd6 ,0x01 ); -mipi_dsi_generic_write_seq (dsi,0xec , -0x64 ,0xdc ,0xec ,0x3b ,0x52 ,0x00 ,0x0b ,0x0b , -0x13 ,0x15 ,0x68 ,0x0b ,0xb5 ); -mipi_dsi_generic_write_seq (dsi,0xb0 ,0x03 ); - - ret =mipi_dsi_dcs_set_tear_on (dsi,MIPI_DSI_DCS_TEAR_MODE_VBLANK ); -if (ret <0 ) { -dev_err (dev,"Failed to set tear on: %d\n" , ret); -return ret; - } - -mipi_dsi_dcs_write_seq (dsi,MIPI_DCS_SET_ADDRESS_MODE ,0x00 ); +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xb0 ,0x00 ); +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xd6 ,0x01 ); +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xec , +0x64 ,0xdc ,0xec ,0x3b ,0x52 ,0x00 ,0x0b ,0x0b , +0x13 ,0x15 ,0x68 ,0x0b ,0xb5 ); +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xb0 ,0x03 ); - ret =mipi_dsi_dcs_set_pixel_format (dsi,0x77 ); -if (ret <0 ) { -dev_err (dev,"Failed to set pixel format: %d\n" , ret); -return ret; - } - - ret =mipi_dsi_dcs_set_column_address (dsi,0x0000 ,0x0437 ); -if (ret <0 ) { -dev_err (dev,"Failed to set column address: %d\n" , ret); -return ret; - } +mipi_dsi_dcs_set_tear_on_multi (&dsi_ctx,MIPI_DSI_DCS_TEAR_MODE_VBLANK ); - ret =mipi_dsi_dcs_set_page_address (dsi,0x0000 ,0x077f ); -if (ret <0 ) { -dev_err (dev,"Failed to set page address: %d\n" , ret); -return ret; - } +mipi_dsi_dcs_write_seq_multi (&dsi_ctx,MIPI_DCS_SET_ADDRESS_MODE ,0x00 ); - ret =mipi_dsi_dcs_set_tear_scanline (dsi,0x0000 ); -if (ret <0 ) { -dev_err (dev,"Failed to set tear scanline: %d\n" , ret); -return ret; - } +mipi_dsi_dcs_set_pixel_format_multi (&dsi_ctx,0x77 ); +mipi_dsi_dcs_set_column_address_multi (&dsi_ctx,0x0000 ,0x0437 ); +mipi_dsi_dcs_set_page_address_multi (&dsi_ctx,0x0000 ,0x077f ); +mipi_dsi_dcs_set_tear_scanline_multi (&dsi_ctx,0x0000 ); +mipi_dsi_dcs_set_display_brightness_multi (&dsi_ctx,0x00ff ); - ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ); -if (ret <0 ) { -dev_err (dev,"Failed to set display brightness: %d\n" , ret); -return ret; - } +mipi_dsi_dcs_write_seq_multi (&dsi_ctx,MIPI_DCS_WRITE_CONTROL_DISPLAY ,0x24 ); +mipi_dsi_dcs_write_seq_multi (&dsi_ctx,MIPI_DCS_WRITE_POWER_SAVE ,0x00 ); +mipi_dsi_dcs_write_seq_multi (&dsi_ctx,MIPI_DCS_SET_CABC_MIN_BRIGHTNESS ,0x00 ); +mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0x84 ,0x00 ); -mipi_dsi_dcs_write_seq (dsi,MIPI_DCS_WRITE_CONTROL_DISPLAY ,0x24 ); -mipi_dsi_dcs_write_seq (dsi,MIPI_DCS_WRITE_POWER_SAVE ,0x00 ); -mipi_dsi_dcs_write_seq (dsi,MIPI_DCS_SET_CABC_MIN_BRIGHTNESS ,0x00 ); -mipi_dsi_dcs_write_seq (dsi,0x84 ,0x00 ); +mipi_dsi_dcs_set_display_on_multi (&dsi_ctx); +mipi_dsi_msleep (&dsi_ctx,20 ); +mipi_dsi_dcs_exit_sleep_mode_multi (&dsi_ctx); +mipi_dsi_msleep (&dsi_ctx,80 ); - ret =mipi_dsi_dcs_set_display_on (dsi); -if (ret <0 ) { -dev_err (dev,"Failed to set display on: %d\n" , ret); -return ret; - } -msleep (20 ); +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xb0 ,0x04 ); +mipi_dsi_dcs_write_seq_multi (&dsi_ctx,0x84 ,0x00 ); +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xc8 ,0x11 ); +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xb0 ,0x03 ); - ret =mipi_dsi_dcs_exit_sleep_mode (dsi); -if (ret <0 ) { -dev_err (dev,"Failed to exit sleep mode: %d\n" , ret); -return ret; - } -msleep (80 ); - -mipi_dsi_generic_write_seq (dsi,0xb0 ,0x04 ); -mipi_dsi_dcs_write_seq (dsi,0x84 ,0x00 ); -mipi_dsi_generic_write_seq (dsi,0xc8 ,0x11 ); -mipi_dsi_generic_write_seq (dsi,0xb0 ,0x03 ); - -return 0 ; +return dsi_ctx.accum_err; } -static int jdi_fhd_r63452_off (struct jdi_fhd_r63452 *ctx) +static void jdi_fhd_r63452_off (struct jdi_fhd_r63452 *ctx) {struct mipi_dsi_device *dsi = ctx->dsi; -struct device *dev = &dsi->dev; -int ret; +struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; dsi->mode_flags &= ~MIPI_DSI_MODE_LPM ; -mipi_dsi_generic_write_seq (dsi,0xb0 ,0x00 ); -mipi_dsi_generic_write_seq (dsi,0xd6 ,0x01 ); -mipi_dsi_generic_write_seq (dsi,0xec , -0x64 ,0xdc ,0xec ,0x3b ,0x52 ,0x00 ,0x0b ,0x0b , -0x13 ,0x15 ,0x68 ,0x0b ,0x95 ); -mipi_dsi_generic_write_seq (dsi,0xb0 ,0x03 ); - - ret =mipi_dsi_dcs_set_display_off (dsi); -if (ret <0 ) { -dev_err (dev,"Failed to set display off: %d\n" , ret); -return ret; - } -usleep_range (2000 ,3000 ); - - ret =mipi_dsi_dcs_enter_sleep_mode (dsi); -if (ret <0 ) { -dev_err (dev,"Failed to enter sleep mode: %d\n" , ret); -return ret; - } -msleep (120 ); - -return 0 ; +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xb0 ,0x00 ); +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xd6 ,0x01 ); +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xec , +0x64 ,0xdc ,0xec ,0x3b ,0x52 ,0x00 ,0x0b ,0x0b , +0x13 ,0x15 ,0x68 ,0x0b ,0x95 ); +mipi_dsi_generic_write_seq_multi (&dsi_ctx,0xb0 ,0x03 ); + +mipi_dsi_dcs_set_display_off_multi (&dsi_ctx); +mipi_dsi_usleep_range (&dsi_ctx,2000 ,3000 ); +mipi_dsi_dcs_enter_sleep_mode_multi (&dsi_ctx); +mipi_dsi_msleep (&dsi_ctx,120 ); }static int jdi_fhd_r63452_prepare (struct drm_panel *panel) {struct jdi_fhd_r63452 *ctx =to_jdi_fhd_r63452 (panel); -struct device *dev = &ctx->dsi->dev;int ret;jdi_fhd_r63452_reset (ctx); ret =jdi_fhd_r63452_on (ctx); -if (ret <0 ) { -dev_err (dev,"Failed to initialize panel: %d\n" , ret); +if (ret <0 )gpiod_set_value_cansleep (ctx->reset_gpio,1 ); -return ret; - } -return 0 ; +return ret; }static int jdi_fhd_r63452_unprepare (struct drm_panel *panel) {struct jdi_fhd_r63452 *ctx =to_jdi_fhd_r63452 (panel); -struct device *dev = &ctx->dsi->dev; -int ret; - ret =jdi_fhd_r63452_off (ctx); -if (ret <0 ) -dev_err (dev,"Failed to un-initialize panel: %d\n" , ret); +/* +* NOTE: We don't return an error here as while the panel won't have +* been cleanly turned off at least we've asserted the reset signal +* so it should be safe to power it back on again later +*/ +jdi_fhd_r63452_off (ctx);gpiod_set_value_cansleep (ctx->reset_gpio,1 );
Signature · 1 line
2.46.0
Doug Anderson
AppliedRe: [PATCH v3 2/2] drm/panel: jdi-fhd-r63452: transition to mipi_dsi wrapped functions
Hi,
Quoted 9 lines · Tejas Vipin
Changes the jdi-fhd-r63452 panel to use multi style functions for improved error handling.
Reviewed-by Douglas Anderson <[email protected]>Signed-off-by Tejas Vipin <[email protected]>--- drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c | 149 ++++++------------- 1 file changed, 48 insertions(+), 101 deletions(-)
Pushed to drm-misc-next.
[2/2] drm/panel: jdi-fhd-r63452: transition to mipi_dsi wrapped functions
commit: 04b5b362bc2a36f1dfe5cad52c83b1ea9d25b87c
Hi,
Quoted 5 lines · Tejas Vipin
This patch adds
mipi_dsi_dcs_set_tear_scanline_multito the list of multi functions and uses it with other multi functions in the jdi-fhd-r63452 panel.
Quoted 7 lines
This patch uses functions introduced in [1] and must be applied after it.
[1] https://lore.kernel.org/all/[email protected]/
---
Changes in v3:
- usemipi_dsi_usleep_range
Oh! Thanks for updating this. I had been debating whether we should add mipi_dsi_usleep_range() but hadn't noticed that someone already had. Nice! :-) I think this series is pretty much ready to apply, but I'll give it one more day (or Neil can apply them if he's good w/ them).
-Doug