drm/panel: otm8009a: backlight fixes & improvements
Subsystems (3)
cover drm/panel: otm8009a: backlight fixes & improvements
This patch serie fixes 2 backlight issues and adds the new backlight api support.
Philippe Cornu (4):
drm/panel: otm8009a: fix backlight updates
drm/panel: otm8009a: fix glitches by moving backlight enable to
otm8009a_enable()
drm/panel: otm8009a: no message if probe success drm/panel: otm8009a: use new backlight api
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c | 58 ++++++++++++------------ 1 file changed, 30 insertions(+), 28 deletions(-)
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/4 drm/panel: otm8009a: fix backlight updates
Backlight updates was not working anymore since the good implementation of the dsi lpm mode in the dsi host driver. After a longer analysis, the backlight updates in dsi video mode require the dsi hs mode.
Note: it is important to keep the dsi lpm mode for the rest of the driver as init sequence, sleep in/out... dsi commands work in lp mode.
--- drivers/gpu/drm/panel/panel-orisetech-otm8009a.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +16 -2
@@ -98,6 +98,20 @@ static void otm8009a_dcs_write_buf(struct otm8009a *ctx, const void *data,DRM_WARN ("mipi dsi dcs write buffer failed\n" ); } +static void otm8009a_dcs_write_buf_hs (struct otm8009a *ctx,const void *data, +size_t len) +{ +struct mipi_dsi_device *dsi =to_mipi_dsi_device (ctx->dev); + +/* data will be sent in dsi hs mode (ie. no lpm) */ + dsi->mode_flags &= ~MIPI_DSI_MODE_LPM ; + +otm8009a_dcs_write_buf (ctx, data, len); + +/* restore back the dsi lpm mode */ + dsi->mode_flags |=MIPI_DSI_MODE_LPM ; +} + #define dcs_write_seq(ctx, seq...) \ ({ \ static const u8 d[] = { seq }; \
@@ -387,7 +401,7 @@ static int otm8009a_backlight_update_status(struct backlight_device *bd)*/ data[0 ] =MIPI_DCS_SET_DISPLAY_BRIGHTNESS ; data[1 ] = bd->props.brightness; -otm8009a_dcs_write_buf (ctx, data,ARRAY_SIZE (data)); +otm8009a_dcs_write_buf_hs (ctx, data,ARRAY_SIZE (data));/* set Brightness Control & Backlight on */ data[1 ] =0x24 ;
@@ -399,7 +413,7 @@ static int otm8009a_backlight_update_status(struct backlight_device *bd)/* Update Brightness Control & Backlight */ data[0 ] =MIPI_DCS_WRITE_CONTROL_DISPLAY ; -otm8009a_dcs_write_buf (ctx, data,ARRAY_SIZE (data)); +otm8009a_dcs_write_buf_hs (ctx, data,ARRAY_SIZE (data));return 0 ; }
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/4] drm/panel: otm8009a: fix backlight updates
Hi Philippe,
BR
Vincent
Quoted 49 lines · Philippe Cornu
Backlight updates was not working anymore since the good implementation of the dsi lpm mode in the dsi host driver. After a longer analysis, the backlight updates in dsi video mode require the dsi hs mode.
Note: it is important to keep the dsi lpm mode for the rest of the driver as init sequence, sleep in/out... dsi commands work in lp mode.Signed-off-by Philippe Cornu <[email protected]>--- drivers/gpu/drm/panel/panel-orisetech-otm8009a.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +15
-1@@ -98,6 +98,20 @@ static void otm8009a_dcs_write_buf(struct otm8009a *ctx, const void *data,DRM_WARN ("mipi dsi dcs write buffer failed\n" ); } +static void otm8009a_dcs_write_buf_hs (struct otm8009a *ctx,const void *data, +size_t len) +{ +struct mipi_dsi_device *dsi =to_mipi_dsi_device (ctx->dev); + +/* data will be sent in dsi hs mode (ie. no lpm) */ + dsi->mode_flags &= ~MIPI_DSI_MODE_LPM ; + +otm8009a_dcs_write_buf (ctx, data, len); + +/* restore back the dsi lpm mode */ + dsi->mode_flags |=MIPI_DSI_MODE_LPM ; +} + #define dcs_write_seq(ctx, seq...) \ ({ \ static const u8 d[] = { seq }; \@@ -387,7 +401,7 @@ static int otm8009a_backlight_update_status(struct backlight_device *bd)*/ data[0 ] =MIPI_DCS_SET_DISPLAY_BRIGHTNESS ; data[1 ] = bd->props.brightness; -otm8009a_dcs_write_buf (ctx, data,ARRAY_SIZE (data)); +otm8009a_dcs_write_buf_hs (ctx, data,ARRAY_SIZE (data));/* set Brightness Control & Backlight on */ data[1 ] =0x24 ;
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c static int otm8009a_backlight_update_status(struct backlight_device *bd) · line 419
Quoted 8 lines
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +1
-1@@ -399,7 +413,7 @@ static int otm8009a_backlight_update_status(struct backlight_device *bd)/* Update Brightness Control & Backlight */ data[0 ] =MIPI_DCS_WRITE_CONTROL_DISPLAY ; -otm8009a_dcs_write_buf (ctx, data,ARRAY_SIZE (data)); +otm8009a_dcs_write_buf_hs (ctx, data,ARRAY_SIZE (data));return 0 ; }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/4 drm/panel: otm8009a: fix glitches by moving backlight enable to otm8009a_enable()
In reply to Philippe CornuThe backlight 1st update was in the otm8009a_prepare() function for a bad reason: backlight was not working in video mode and the otm8009a_prepare() is in command mode for the init sequence. As the backlight is now fixed (no lpm), it is good to put it back in the otm8009a_enable() function, avoiding also image glitches visible on some "slow" devices.
--- drivers/gpu/drm/panel/panel-orisetech-otm8009a.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +10 -7
@@ -330,13 +330,6 @@ static int otm8009a_prepare(struct drm_panel *panel) ctx->prepared = true; -/* -* Power on the backlight. Note: end-user still controls brightness -* Note: ctx->prepared must be true before updating the backlight. -*/ - ctx->bl_dev->props.power =FB_BLANK_UNBLANK ; -backlight_update_status (ctx->bl_dev); -return 0 ; }
@@ -344,6 +337,16 @@ static int otm8009a_enable(struct drm_panel *panel) {struct otm8009a *ctx =panel_to_otm8009a (panel); +if (ctx->enabled) +return 0 ; + +/* +* Power on the backlight. Note: end-user still controls brightness +* Note: ctx->prepared must be true before updating the backlight. +*/ + ctx->bl_dev->props.power =FB_BLANK_UNBLANK ; +backlight_update_status (ctx->bl_dev); + ctx->enabled = true;return 0 ;
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/4] drm/panel: otm8009a: fix glitches by moving backlight enable to otm8009a_enable()
Hi Philippe,
BR
Vincent
Quoted 38 lines · Philippe Cornu
The backlight 1st update was in the
otm8009a_prepare()function for a bad reason: backlight was not working in video mode and theotm8009a_prepare()is in command mode for the init sequence. As the backlight is now fixed (no lpm), it is good to put it back in theotm8009a_enable()function, avoiding also image glitches visible on some "slow" devices.Signed-off-by Philippe Cornu <[email protected]>--- drivers/gpu/drm/panel/panel-orisetech-otm8009a.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +3
-7@@ -330,13 +330,6 @@ static int otm8009a_prepare(struct drm_panel *panel) ctx->prepared = true; -/* -* Power on the backlight. Note: end-user still controls brightness -* Note: ctx->prepared must be true before updating the backlight. -*/ - ctx->bl_dev->props.power =FB_BLANK_UNBLANK ; -backlight_update_status (ctx->bl_dev); -return 0 ; }@@ -344,6 +337,16 @@ static int otm8009a_enable(struct drm_panel *panel) {struct otm8009a *ctx =panel_to_otm8009a (panel); +if (ctx->enabled) +return 0 ; +
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c static int otm8009a_enable(struct drm_panel *panel) · line 352
Quoted 10 lines
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +7
-0+/* +* Power on the backlight. Note: end-user still controls brightness +* Note: ctx->prepared must be true before updating the backlight. +*/ + ctx->bl_dev->props.power =FB_BLANK_UNBLANK ; +backlight_update_status (ctx->bl_dev); + ctx->enabled = true;return 0 ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/4 drm/panel: otm8009a: no message if probe success
In reply to Philippe CornuRemove the message in case of probe success. This comes from a suggestion followed in the recent integration of the raydium rm68200 panel.
--- drivers/gpu/drm/panel/panel-orisetech-otm8009a.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +2 -9
@@ -14,8 +14,6 @@#include <linux/regulator/consumer.h> #include <video/mipi_display.h> -#define DRV_NAME "orisetech_otm8009a" -#define OTM8009A_BACKLIGHT_DEFAULT 240#define OTM8009A_BACKLIGHT_MAX 255
@@ -461,7 +459,7 @@ static int otm8009a_probe(struct mipi_dsi_device *dsi) ctx->panel.dev = dev; ctx->panel.funcs = &otm8009a_drm_funcs; - ctx->bl_dev =backlight_device_register (DRV_NAME "_backlight" , dev, ctx, + ctx->bl_dev =backlight_device_register (dev_name (dev), dev, ctx, &otm8009a_backlight_ops,NULL );if (IS_ERR (ctx->bl_dev)) {dev_err (dev,"failed to register backlight device\n" );
@@ -483,11 +481,6 @@ static int otm8009a_probe(struct mipi_dsi_device *dsi)return ret; } -DRM_INFO (DRV_NAME "_panel %ux%u@%u %ubpp dsi %udl - ready\n" , - default_mode.hdisplay, default_mode.vdisplay, - default_mode.vrefresh, -mipi_dsi_pixel_format_to_bpp (dsi->format), dsi->lanes); -return 0 ; }
@@ -513,7 +506,7 @@ static struct mipi_dsi_driver orisetech_otm8009a_driver = { .probe = otm8009a_probe, .remove = otm8009a_remove, .driver = { - .name = DRV_NAME "_panel", + .name = "panel-orisetech-otm8009a", .of_match_table = orisetech_otm8009a_of_match, }, };
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/4] drm/panel: otm8009a: no message if probe success
Hi Philippe,
BR
Vincent
Quoted 45 lines · Philippe Cornu
Remove the message in case of probe success. This comes from a suggestion followed in the recent integration of the raydium rm68200 panel.
Signed-off-by Philippe Cornu <[email protected]>--- drivers/gpu/drm/panel/panel-orisetech-otm8009a.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +1
-8@@ -14,8 +14,6 @@#include <linux/regulator/consumer.h> #include <video/mipi_display.h> -#define DRV_NAME "orisetech_otm8009a" -#define OTM8009A_BACKLIGHT_DEFAULT 240#define OTM8009A_BACKLIGHT_MAX 255@@ -461,7 +459,7 @@ static int otm8009a_probe(struct mipi_dsi_device *dsi) ctx->panel.dev = dev; ctx->panel.funcs = &otm8009a_drm_funcs; - ctx->bl_dev =backlight_device_register (DRV_NAME "_backlight" , dev, ctx, + ctx->bl_dev =backlight_device_register (dev_name (dev), dev, ctx, &otm8009a_backlight_ops,NULL );if (IS_ERR (ctx->bl_dev)) {dev_err (dev,"failed to register backlight device\n" );@@ -483,11 +481,6 @@ static int otm8009a_probe(struct mipi_dsi_device *dsi)return ret; } -DRM_INFO (DRV_NAME "_panel %ux%u@%u %ubpp dsi %udl - ready\n" , - default_mode.hdisplay, default_mode.vdisplay, - default_mode.vrefresh, -mipi_dsi_pixel_format_to_bpp (dsi->format), dsi->lanes); -return 0 ; }
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c static struct mipi_dsi_driver orisetech_otm8009a_driver = { · line 512
Quoted 8 lines
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +1
-1@@ -513,7 +506,7 @@ static struct mipi_dsi_driver orisetech_otm8009a_driver = { .probe = otm8009a_probe, .remove = otm8009a_remove, .driver = { - .name = DRV_NAME "_panel", + .name = "panel-orisetech-otm8009a", .of_match_table = orisetech_otm8009a_of_match, }, };
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/4 drm/panel: otm8009a: use new backlight api
In reply to Philippe CornuUse the new backlight api.
--- drivers/gpu/drm/panel/panel-orisetech-otm8009a.c | 26 ++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-)
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +9 -17
@@ -260,11 +260,7 @@ static int otm8009a_disable(struct drm_panel *panel)if (!ctx->enabled)return 0 ;/* This is not an issue so we return 0 here */ -/* Power off the backlight. Note: end-user still controls brightness */ - ctx->bl_dev->props.power =FB_BLANK_POWERDOWN ; - ret =backlight_update_status (ctx->bl_dev); -if (ret) -return ret; +backlight_disable (ctx->bl_dev); ret =mipi_dsi_dcs_set_display_off (dsi);if (ret)
@@ -338,12 +334,7 @@ static int otm8009a_enable(struct drm_panel *panel)if (ctx->enabled)return 0 ; -/* -* Power on the backlight. Note: end-user still controls brightness -* Note: ctx->prepared must be true before updating the backlight. -*/ - ctx->bl_dev->props.power =FB_BLANK_UNBLANK ; -backlight_update_status (ctx->bl_dev); +backlight_enable (ctx->bl_dev); ctx->enabled = true;
@@ -459,11 +450,14 @@ static int otm8009a_probe(struct mipi_dsi_device *dsi) ctx->panel.dev = dev; ctx->panel.funcs = &otm8009a_drm_funcs; - ctx->bl_dev =backlight_device_register (dev_name (dev), dev, ctx, - &otm8009a_backlight_ops,NULL ); + ctx->bl_dev =devm_backlight_device_register (dev,dev_name (dev), + dsi->host->dev, ctx, + &otm8009a_backlight_ops, +NULL );if (IS_ERR (ctx->bl_dev)) { -dev_err (dev,"failed to register backlight device\n" ); -return PTR_ERR (ctx->bl_dev); + ret =PTR_ERR (ctx->bl_dev); +dev_err (dev,"failed to register backlight %d\n" , ret); +return ret; } ctx->bl_dev->props.max_brightness =OTM8009A_BACKLIGHT_MAX ;
@@ -491,8 +485,6 @@ static int otm8009a_remove(struct mipi_dsi_device *dsi)mipi_dsi_detach (dsi);drm_panel_remove (&ctx->panel); -backlight_device_unregister (ctx->bl_dev); -return 0 ; }
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/4] drm/panel: otm8009a: use new backlight api
Hi Philippe,
BR
Vincent
Quoted 59 lines · Philippe Cornu
Use the new backlight api.
Signed-off-by Philippe Cornu <[email protected]>--- drivers/gpu/drm/panel/panel-orisetech-otm8009a.c | 26 ++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-)drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +9
-15@@ -260,11 +260,7 @@ static int otm8009a_disable(struct drm_panel *panel)if (!ctx->enabled)return 0 ;/* This is not an issue so we return 0 here */ -/* Power off the backlight. Note: end-user still controls brightness */ - ctx->bl_dev->props.power =FB_BLANK_POWERDOWN ; - ret =backlight_update_status (ctx->bl_dev); -if (ret) -return ret; +backlight_disable (ctx->bl_dev); ret =mipi_dsi_dcs_set_display_off (dsi);if (ret)@@ -338,12 +334,7 @@ static int otm8009a_enable(struct drm_panel *panel)if (ctx->enabled)return 0 ; -/* -* Power on the backlight. Note: end-user still controls brightness -* Note: ctx->prepared must be true before updating the backlight. -*/ - ctx->bl_dev->props.power =FB_BLANK_UNBLANK ; -backlight_update_status (ctx->bl_dev); +backlight_enable (ctx->bl_dev); ctx->enabled = true;@@ -459,11 +450,14 @@ static int otm8009a_probe(struct mipi_dsi_device *dsi) ctx->panel.dev = dev; ctx->panel.funcs = &otm8009a_drm_funcs; - ctx->bl_dev =backlight_device_register (dev_name (dev), dev, ctx, - &otm8009a_backlight_ops,NULL ); + ctx->bl_dev =devm_backlight_device_register (dev,dev_name (dev), + dsi->host->dev, ctx, + &otm8009a_backlight_ops, +NULL );if (IS_ERR (ctx->bl_dev)) { -dev_err (dev,"failed to register backlight device\n" ); -return PTR_ERR (ctx->bl_dev); + ret =PTR_ERR (ctx->bl_dev); +dev_err (dev,"failed to register backlight %d\n" , ret); +return ret; } ctx->bl_dev->props.max_brightness =OTM8009A_BACKLIGHT_MAX ;
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c static int otm8009a_remove(struct mipi_dsi_device *dsi) · line 490
Quoted 8 lines
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c +0
-2@@ -491,8 +485,6 @@ static int otm8009a_remove(struct mipi_dsi_device *dsi)mipi_dsi_detach (dsi);drm_panel_remove (&ctx->panel); -backlight_device_unregister (ctx->bl_dev); -return 0 ; }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel