* [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask
@ 2022-03-08 16:07 Chen-Yu Tsai
2022-03-08 16:07 ` [PATCH 2/2] drm: ssd130x: Always apply segment remap setting Chen-Yu Tsai
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Chen-Yu Tsai @ 2022-03-08 16:07 UTC (permalink / raw)
To: Javier Martinez Canillas, David Airlie, Daniel Vetter
Cc: Chen-Yu Tsai, dri-devel, linux-kernel
From: Chen-Yu Tsai <wens@csie.org>
The SSD130x's command to toggle COM scan direction uses bit 3 and only
bit 3 to set the direction of the scanout. The driver has an incorrect
GENMASK(3, 2), causing the setting to be set on bit 2, rendering it
ineffective.
Fix the mask to only bit 3, so that the requested setting is applied
correctly.
Fixes: a61732e80867 ("drm: Add driver for Solomon SSD130x OLED displays")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
drivers/gpu/drm/solomon/ssd130x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index ce4dc20412e0..ccd378135589 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -61,7 +61,7 @@
#define SSD130X_SET_COM_PINS_CONFIG 0xda
#define SSD130X_SET_VCOMH 0xdb
-#define SSD130X_SET_COM_SCAN_DIR_MASK GENMASK(3, 2)
+#define SSD130X_SET_COM_SCAN_DIR_MASK GENMASK(3, 3)
#define SSD130X_SET_COM_SCAN_DIR_SET(val) FIELD_PREP(SSD130X_SET_COM_SCAN_DIR_MASK, (val))
#define SSD130X_SET_CLOCK_DIV_MASK GENMASK(3, 0)
#define SSD130X_SET_CLOCK_DIV_SET(val) FIELD_PREP(SSD130X_SET_CLOCK_DIV_MASK, (val))
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] drm: ssd130x: Always apply segment remap setting
2022-03-08 16:07 [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask Chen-Yu Tsai
@ 2022-03-08 16:07 ` Chen-Yu Tsai
2022-03-08 20:38 ` Javier Martinez Canillas
2022-03-08 20:26 ` [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask Javier Martinez Canillas
2022-03-09 12:56 ` Geert Uytterhoeven
2 siblings, 1 reply; 6+ messages in thread
From: Chen-Yu Tsai @ 2022-03-08 16:07 UTC (permalink / raw)
To: Javier Martinez Canillas, David Airlie, Daniel Vetter
Cc: Chen-Yu Tsai, dri-devel, linux-kernel
From: Chen-Yu Tsai <wens@csie.org>
Currently the ssd130x driver only sets the segment remap setting when
the device tree requests it; it however does not clear the setting if
it is not requested. This leads to the setting incorrectly persisting
if the hardware is always on and has no reset GPIO wired. This might
happen when a developer is trying to find the correct settings for an
unknown module, and cause the developer to get confused because the
settings from the device tree are not consistently applied.
Make the driver apply the segment remap setting consistently, setting
the value correctly based on the device tree setting. This also makes
this setting's behavior consistent with the other settings, which are
always applied.
Fixes: a61732e80867 ("drm: Add driver for Solomon SSD130x OLED displays")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
drivers/gpu/drm/solomon/ssd130x.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index ccd378135589..d08d86ef07bc 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -48,7 +48,7 @@
#define SSD130X_CONTRAST 0x81
#define SSD130X_SET_LOOKUP_TABLE 0x91
#define SSD130X_CHARGE_PUMP 0x8d
-#define SSD130X_SEG_REMAP_ON 0xa1
+#define SSD130X_SET_SEG_REMAP 0xa0
#define SSD130X_DISPLAY_OFF 0xae
#define SSD130X_SET_MULTIPLEX_RATIO 0xa8
#define SSD130X_DISPLAY_ON 0xaf
@@ -61,6 +61,8 @@
#define SSD130X_SET_COM_PINS_CONFIG 0xda
#define SSD130X_SET_VCOMH 0xdb
+#define SSD130X_SET_SEG_REMAP_MASK GENMASK(0, 0)
+#define SSD130X_SET_SEG_REMAP_SET(val) FIELD_PREP(SSD130X_SET_SEG_REMAP_MASK, (val))
#define SSD130X_SET_COM_SCAN_DIR_MASK GENMASK(3, 3)
#define SSD130X_SET_COM_SCAN_DIR_SET(val) FIELD_PREP(SSD130X_SET_COM_SCAN_DIR_MASK, (val))
#define SSD130X_SET_CLOCK_DIV_MASK GENMASK(3, 0)
@@ -235,7 +237,7 @@ static void ssd130x_power_off(struct ssd130x_device *ssd130x)
static int ssd130x_init(struct ssd130x_device *ssd130x)
{
- u32 precharge, dclk, com_invdir, compins, chargepump;
+ u32 precharge, dclk, com_invdir, compins, chargepump, seg_remap;
int ret;
/* Set initial contrast */
@@ -244,11 +246,11 @@ static int ssd130x_init(struct ssd130x_device *ssd130x)
return ret;
/* Set segment re-map */
- if (ssd130x->seg_remap) {
- ret = ssd130x_write_cmd(ssd130x, 1, SSD130X_SEG_REMAP_ON);
- if (ret < 0)
- return ret;
- }
+ seg_remap = (SSD130X_SET_SEG_REMAP |
+ SSD130X_SET_SEG_REMAP_SET(ssd130x->seg_remap));
+ ret = ssd130x_write_cmd(ssd130x, 1, seg_remap);
+ if (ret < 0)
+ return ret;
/* Set COM direction */
com_invdir = (SSD130X_SET_COM_SCAN_DIR |
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask
2022-03-08 16:07 [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask Chen-Yu Tsai
2022-03-08 16:07 ` [PATCH 2/2] drm: ssd130x: Always apply segment remap setting Chen-Yu Tsai
@ 2022-03-08 20:26 ` Javier Martinez Canillas
2022-03-09 12:56 ` Geert Uytterhoeven
2 siblings, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2022-03-08 20:26 UTC (permalink / raw)
To: Chen-Yu Tsai, David Airlie, Daniel Vetter
Cc: Chen-Yu Tsai, linux-kernel, dri-devel
Hello Chen-Yu,
Thanks a lot for your patch.
On 3/8/22 17:07, Chen-Yu Tsai wrote:
> From: Chen-Yu Tsai <wens@csie.org>
>
> The SSD130x's command to toggle COM scan direction uses bit 3 and only
> bit 3 to set the direction of the scanout. The driver has an incorrect
> GENMASK(3, 2), causing the setting to be set on bit 2, rendering it
> ineffective.
>
> Fix the mask to only bit 3, so that the requested setting is applied
> correctly.
>
Sigh, you are correct. I thought that triple checked the datasheet
when writing this but I got it wrong anyways...
> Fixes: a61732e80867 ("drm: Add driver for Solomon SSD130x OLED displays")
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
--
Best regards,
Javier Martinez Canillas
Linux Engineering
Red Hat
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] drm: ssd130x: Always apply segment remap setting
2022-03-08 16:07 ` [PATCH 2/2] drm: ssd130x: Always apply segment remap setting Chen-Yu Tsai
@ 2022-03-08 20:38 ` Javier Martinez Canillas
0 siblings, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2022-03-08 20:38 UTC (permalink / raw)
To: Chen-Yu Tsai, David Airlie, Daniel Vetter
Cc: Chen-Yu Tsai, linux-kernel, dri-devel
On 3/8/22 17:07, Chen-Yu Tsai wrote:
> From: Chen-Yu Tsai <wens@csie.org>
>
> Currently the ssd130x driver only sets the segment remap setting when
> the device tree requests it; it however does not clear the setting if
> it is not requested. This leads to the setting incorrectly persisting
> if the hardware is always on and has no reset GPIO wired. This might
> happen when a developer is trying to find the correct settings for an
> unknown module, and cause the developer to get confused because the
> settings from the device tree are not consistently applied.
>
> Make the driver apply the segment remap setting consistently, setting
> the value correctly based on the device tree setting. This also makes
> this setting's behavior consistent with the other settings, which are
> always applied.
>
Nice catch. This is certainly much better. Thanks!
> Fixes: a61732e80867 ("drm: Add driver for Solomon SSD130x OLED displays")
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
--
Best regards,
Javier Martinez Canillas
Linux Engineering
Red Hat
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask
2022-03-08 16:07 [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask Chen-Yu Tsai
2022-03-08 16:07 ` [PATCH 2/2] drm: ssd130x: Always apply segment remap setting Chen-Yu Tsai
2022-03-08 20:26 ` [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask Javier Martinez Canillas
@ 2022-03-09 12:56 ` Geert Uytterhoeven
2022-03-09 13:59 ` Javier Martinez Canillas
2 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2022-03-09 12:56 UTC (permalink / raw)
To: Chen-Yu Tsai
Cc: Javier Martinez Canillas, David Airlie, Daniel Vetter,
Chen-Yu Tsai, DRI Development, Linux Kernel Mailing List
On Wed, Mar 9, 2022 at 2:57 AM Chen-Yu Tsai <wens@kernel.org> wrote:
> From: Chen-Yu Tsai <wens@csie.org>
>
> The SSD130x's command to toggle COM scan direction uses bit 3 and only
> bit 3 to set the direction of the scanout. The driver has an incorrect
> GENMASK(3, 2), causing the setting to be set on bit 2, rendering it
> ineffective.
>
> Fix the mask to only bit 3, so that the requested setting is applied
> correctly.
>
> Fixes: a61732e80867 ("drm: Add driver for Solomon SSD130x OLED displays")
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Thanks, this fixes the vertically-mirrored display on my Adafruit
FeatherWing 128x32 OLED.
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask
2022-03-09 12:56 ` Geert Uytterhoeven
@ 2022-03-09 13:59 ` Javier Martinez Canillas
0 siblings, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2022-03-09 13:59 UTC (permalink / raw)
To: Geert Uytterhoeven, Chen-Yu Tsai
Cc: David Airlie, Daniel Vetter, Chen-Yu Tsai, DRI Development,
Linux Kernel Mailing List
On 3/9/22 13:56, Geert Uytterhoeven wrote:
> On Wed, Mar 9, 2022 at 2:57 AM Chen-Yu Tsai <wens@kernel.org> wrote:
>> From: Chen-Yu Tsai <wens@csie.org>
>>
>> The SSD130x's command to toggle COM scan direction uses bit 3 and only
>> bit 3 to set the direction of the scanout. The driver has an incorrect
>> GENMASK(3, 2), causing the setting to be set on bit 2, rendering it
>> ineffective.
>>
>> Fix the mask to only bit 3, so that the requested setting is applied
>> correctly.
>>
>> Fixes: a61732e80867 ("drm: Add driver for Solomon SSD130x OLED displays")
>> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>
> Thanks, this fixes the vertically-mirrored display on my Adafruit
> FeatherWing 128x32 OLED.
> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
>
Thanks for the testing and review. I've pushed both patches to drm-misc-next.
--
Best regards,
Javier Martinez Canillas
Linux Engineering
Red Hat
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-03-09 13:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-08 16:07 [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask Chen-Yu Tsai
2022-03-08 16:07 ` [PATCH 2/2] drm: ssd130x: Always apply segment remap setting Chen-Yu Tsai
2022-03-08 20:38 ` Javier Martinez Canillas
2022-03-08 20:26 ` [PATCH 1/2] drm: ssd130x: Fix COM scan direction register mask Javier Martinez Canillas
2022-03-09 12:56 ` Geert Uytterhoeven
2022-03-09 13:59 ` 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