Skip to contentSkip to conversation

drm/panel: otm8009a: backlight fixes & improvements

PATCH In review Philippe Cornu 2 participants 9 messages Apr 23, 2018 – May 14, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 90f1ae4af93c..0fd2e0144d2b 100644
@@ -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
Reviewed-by on v1 1/4
#2 lore raw

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.

---
  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
index 90f1ae4af93c..0fd2e0144d2b 100644
@@ -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

#3 lore raw

PATCH 2/4 drm/panel: otm8009a: fix glitches by moving backlight enable to otm8009a_enable()

In reply to Philippe Cornu

The 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
index 0fd2e0144d2b..de4a16d5275c 100644
@@ -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
Reviewed-by on v1 2/4
#4 lore raw

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 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 +3 -7
index 0fd2e0144d2b..de4a16d5275c 100644
@@ -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

#5 lore raw

PATCH 3/4 drm/panel: otm8009a: no message if probe success

In reply to 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.

---
 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
index de4a16d5275c..4c638b7b9943 100644
@@ -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
Reviewed-by on v1 3/4
#6 lore raw

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.

---
  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
index de4a16d5275c..4c638b7b9943 100644
@@ -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

#7 lore raw

PATCH 4/4 drm/panel: otm8009a: use new backlight api

In reply to Philippe Cornu

Use 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
index 4c638b7b9943..c2a71bd17e08 100644
@@ -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
Reviewed-by on v1 4/4
#8 lore raw

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.

---
  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
index 4c638b7b9943..c2a71bd17e08 100644
@@ -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