linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/ssd130x: Init display before the SSD130X_DISPLAY_ON command
@ 2023-01-25 18:42 Javier Martinez Canillas
  2023-01-25 19:56 ` Thomas Zimmermann
  0 siblings, 1 reply; 3+ messages in thread
From: Javier Martinez Canillas @ 2023-01-25 18:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: Maxime Ripard, Thomas Zimmermann, Javier Martinez Canillas,
	Daniel Vetter, David Airlie, dri-devel

Commit 622113b9f11f ("drm/ssd130x: Replace simple display helpers with the
atomic helpers") changed the driver to just use the atomic helpers instead
of the simple KMS abstraction layer.

But the commit also made a subtle change on the display power sequence and
initialization order, by moving the ssd130x_power_on() call to the encoder
.atomic_enable handler and the ssd130x_init() call to CRTC .reset handler.

Before this change, both ssd130x_power_on() and ssd130x_init() were called
in the simple display pipeline .enable handler, so the display was already
initialized by the time the SSD130X_DISPLAY_ON command was sent.

For some reasons, it only made the ssd130x SPI driver to fail but the I2C
was still working. That is the reason why the bug was not noticed before.

To revert to the old driver behavior, move the ssd130x_init() call to the
encoder .atomic_enable as well. Besides fixing the panel not being turned
on when using SPI, it also gets rid of the custom CRTC .reset callback.

Fixes: 622113b9f11f ("drm/ssd130x: Replace simple display helpers with the atomic helpers")
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

 drivers/gpu/drm/solomon/ssd130x.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index b16330a8b624..8cbf5aa66e19 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -663,18 +663,8 @@ static const struct drm_crtc_helper_funcs ssd130x_crtc_helper_funcs = {
 	.atomic_check = drm_crtc_helper_atomic_check,
 };
 
-static void ssd130x_crtc_reset(struct drm_crtc *crtc)
-{
-	struct drm_device *drm = crtc->dev;
-	struct ssd130x_device *ssd130x = drm_to_ssd130x(drm);
-
-	ssd130x_init(ssd130x);
-
-	drm_atomic_helper_crtc_reset(crtc);
-}
-
 static const struct drm_crtc_funcs ssd130x_crtc_funcs = {
-	.reset = ssd130x_crtc_reset,
+	.reset = drm_atomic_helper_crtc_reset,
 	.destroy = drm_crtc_cleanup,
 	.set_config = drm_atomic_helper_set_config,
 	.page_flip = drm_atomic_helper_page_flip,
@@ -693,6 +683,12 @@ static void ssd130x_encoder_helper_atomic_enable(struct drm_encoder *encoder,
 	if (ret)
 		return;
 
+	ret = ssd130x_init(ssd130x);
+	if (ret) {
+		ssd130x_power_off(ssd130x);
+		return;
+	}
+
 	ssd130x_write_cmd(ssd130x, 1, SSD130X_DISPLAY_ON);
 
 	backlight_enable(ssd130x->bl_dev);
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/ssd130x: Init display before the SSD130X_DISPLAY_ON command
  2023-01-25 18:42 [PATCH] drm/ssd130x: Init display before the SSD130X_DISPLAY_ON command Javier Martinez Canillas
@ 2023-01-25 19:56 ` Thomas Zimmermann
  2023-01-26 19:18   ` Javier Martinez Canillas
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Zimmermann @ 2023-01-25 19:56 UTC (permalink / raw)
  To: Javier Martinez Canillas, linux-kernel
  Cc: Maxime Ripard, Daniel Vetter, David Airlie, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 2912 bytes --]



Am 25.01.23 um 19:42 schrieb Javier Martinez Canillas:
> Commit 622113b9f11f ("drm/ssd130x: Replace simple display helpers with the
> atomic helpers") changed the driver to just use the atomic helpers instead
> of the simple KMS abstraction layer.
> 
> But the commit also made a subtle change on the display power sequence and
> initialization order, by moving the ssd130x_power_on() call to the encoder
> .atomic_enable handler and the ssd130x_init() call to CRTC .reset handler.
> 
> Before this change, both ssd130x_power_on() and ssd130x_init() were called
> in the simple display pipeline .enable handler, so the display was already
> initialized by the time the SSD130X_DISPLAY_ON command was sent.
> 
> For some reasons, it only made the ssd130x SPI driver to fail but the I2C
> was still working. That is the reason why the bug was not noticed before.
> 
> To revert to the old driver behavior, move the ssd130x_init() call to the
> encoder .atomic_enable as well. Besides fixing the panel not being turned
> on when using SPI, it also gets rid of the custom CRTC .reset callback.
> 
> Fixes: 622113b9f11f ("drm/ssd130x: Replace simple display helpers with the atomic helpers")
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
> 
>   drivers/gpu/drm/solomon/ssd130x.c | 18 +++++++-----------
>   1 file changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
> index b16330a8b624..8cbf5aa66e19 100644
> --- a/drivers/gpu/drm/solomon/ssd130x.c
> +++ b/drivers/gpu/drm/solomon/ssd130x.c
> @@ -663,18 +663,8 @@ static const struct drm_crtc_helper_funcs ssd130x_crtc_helper_funcs = {
>   	.atomic_check = drm_crtc_helper_atomic_check,
>   };
>   
> -static void ssd130x_crtc_reset(struct drm_crtc *crtc)
> -{
> -	struct drm_device *drm = crtc->dev;
> -	struct ssd130x_device *ssd130x = drm_to_ssd130x(drm);
> -
> -	ssd130x_init(ssd130x);
> -
> -	drm_atomic_helper_crtc_reset(crtc);
> -}
> -
>   static const struct drm_crtc_funcs ssd130x_crtc_funcs = {
> -	.reset = ssd130x_crtc_reset,
> +	.reset = drm_atomic_helper_crtc_reset,
>   	.destroy = drm_crtc_cleanup,
>   	.set_config = drm_atomic_helper_set_config,
>   	.page_flip = drm_atomic_helper_page_flip,
> @@ -693,6 +683,12 @@ static void ssd130x_encoder_helper_atomic_enable(struct drm_encoder *encoder,
>   	if (ret)
>   		return;
>   
> +	ret = ssd130x_init(ssd130x);
> +	if (ret) {
> +		ssd130x_power_off(ssd130x);
> +		return;
> +	}
> +
>   	ssd130x_write_cmd(ssd130x, 1, SSD130X_DISPLAY_ON);
>   
>   	backlight_enable(ssd130x->bl_dev);

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/ssd130x: Init display before the SSD130X_DISPLAY_ON command
  2023-01-25 19:56 ` Thomas Zimmermann
@ 2023-01-26 19:18   ` Javier Martinez Canillas
  0 siblings, 0 replies; 3+ messages in thread
From: Javier Martinez Canillas @ 2023-01-26 19:18 UTC (permalink / raw)
  To: Thomas Zimmermann, linux-kernel
  Cc: Maxime Ripard, Daniel Vetter, David Airlie, dri-devel

On 1/25/23 20:56, Thomas Zimmermann wrote:
> 
> 
> Am 25.01.23 um 19:42 schrieb Javier Martinez Canillas:
>> Commit 622113b9f11f ("drm/ssd130x: Replace simple display helpers with the
>> atomic helpers") changed the driver to just use the atomic helpers instead
>> of the simple KMS abstraction layer.
>>
>> But the commit also made a subtle change on the display power sequence and
>> initialization order, by moving the ssd130x_power_on() call to the encoder
>> .atomic_enable handler and the ssd130x_init() call to CRTC .reset handler.
>>
>> Before this change, both ssd130x_power_on() and ssd130x_init() were called
>> in the simple display pipeline .enable handler, so the display was already
>> initialized by the time the SSD130X_DISPLAY_ON command was sent.
>>
>> For some reasons, it only made the ssd130x SPI driver to fail but the I2C
>> was still working. That is the reason why the bug was not noticed before.
>>
>> To revert to the old driver behavior, move the ssd130x_init() call to the
>> encoder .atomic_enable as well. Besides fixing the panel not being turned
>> on when using SPI, it also gets rid of the custom CRTC .reset callback.
>>
>> Fixes: 622113b9f11f ("drm/ssd130x: Replace simple display helpers with the atomic helpers")
>> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
> 
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> 

Applied this to drm-misc (drm-misc-next). Thanks!

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-26 19:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25 18:42 [PATCH] drm/ssd130x: Init display before the SSD130X_DISPLAY_ON command Javier Martinez Canillas
2023-01-25 19:56 ` Thomas Zimmermann
2023-01-26 19:18   ` Javier Martinez Canillas

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).