[PATCH] drm/tinydrm/mi0283qt: Always set rotation value

2018-04-23 Thread Tom Callaway
The PiTFT (ili9340) has a hardware reset circuit that resets only
on power-on and not on each reboot through a gpio like the
rpi-display does. As a result, we need to always apply the
rotation value regardless of the display "on/off" state.
Moved the rotation setting code below out_enable:.

Signed-off-by: Tom Callaway <tcall...@redhat.com>
---
 drivers/gpu/drm/tinydrm/mi0283qt.c | 41 +-
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 4e6d2ee94e55..2bb9e3ce4823 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -84,24 +84,6 @@ static void mi0283qt_enable(struct drm_simple_display_pipe 
*pipe,
/* Memory Access Control */
mipi_dbi_command(mipi, MIPI_DCS_SET_PIXEL_FORMAT, 
MIPI_DCS_PIXEL_FMT_16BIT);
 
-   switch (mipi->rotation) {
-   default:
-   addr_mode = ILI9341_MADCTL_MV | ILI9341_MADCTL_MY |
-   ILI9341_MADCTL_MX;
-   break;
-   case 90:
-   addr_mode = ILI9341_MADCTL_MY;
-   break;
-   case 180:
-   addr_mode = ILI9341_MADCTL_MV;
-   break;
-   case 270:
-   addr_mode = ILI9341_MADCTL_MX;
-   break;
-   }
-   addr_mode |= ILI9341_MADCTL_BGR;
-   mipi_dbi_command(mipi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode);
-
/* Frame Rate */
mipi_dbi_command(mipi, ILI9341_FRMCTR1, 0x00, 0x1b);
 
@@ -127,6 +109,29 @@ static void mi0283qt_enable(struct drm_simple_display_pipe 
*pipe,
msleep(100);
 
 out_enable:
+   /* The PiTFT (ili9340) has a hardware reset circuit that
+* resets only on power-on and not on each reboot through
+* a gpio like the rpi-display does.
+* As a result, we need to always apply the rotation value
+* regardless of the display "on/off" state.
+*/
+   switch (mipi->rotation) {
+   default:
+   addr_mode = ILI9341_MADCTL_MV | ILI9341_MADCTL_MY |
+   ILI9341_MADCTL_MX;
+   break;
+   case 90:
+   addr_mode = ILI9341_MADCTL_MY;
+   break;
+   case 180:
+   addr_mode = ILI9341_MADCTL_MV;
+   break;
+   case 270:
+   addr_mode = ILI9341_MADCTL_MX;
+   break;
+   }
+   addr_mode |= ILI9341_MADCTL_BGR;
+   mipi_dbi_command(mipi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode);
mipi_dbi_enable_flush(mipi, crtc_state, plane_state);
 }
 
-- 
2.14.3

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: mi0283qt driver issues

2018-04-18 Thread Tom Callaway


On 04/18/2018 06:22 AM, Noralf Trønnes wrote:
> It turns out that the reason for this is that the pitft has a hw reset
> circuit that resets only on power-on and not on each reboot through a
> gpio like rpi-display does.
> 
> When the driver is enabling the display pipeline it checks if the
> controller is already initialized, and skips setup if it is. This means
> that the rotation value is only applied after power-on on the pitft and
> not on each reboot.
> 
> Turning off the "display" before rebooting should also work:
> 
> $ # change rotation value
> $ echo "28" | sudo tee /sys/kernel/debug/dri/0/command
> $ sudo reboot
> 
> Rotation/mirror/flip/bgr is controlled by commmand 0x36. The current
> value is returned by command 0x0b:
> 
> $ sudo cat /sys/kernel/debug/dri/0/command | grep "0b:"
> 0b: f8
> 
> So to fix this in the driver the rotation value has to always be applied
> regardless of display "on" state. This can be done by moving the rotation
> code in mi0283qt_enable() down after the out: label.

Confirmed, turning off the display before rebooting works, thanks.

To fix this correctly, it seems like there are two paths:

* If it is always safe to apply the rotation value regardless of display
state, move the rotation code down after out: in the mi0283qt driver.

* If this fix is only safe on the pitft (and not on the other panels
driven by the mi0283qt driver), either conditionalizing this behavior
somehow, or making a separate ili9340 driver with this change.

I'm willing to make patches if necessary here, but it is not clear which
path is the correct one.

~tom
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


mi0283qt driver issues

2018-04-16 Thread Tom Callaway
Noralf,

Thanks for the guidance on how to use the mi0283qt driver to run the
panel included in the Adafruit 2.8" capacitive PiTFT Plus (running on
top of a Raspberry Pi 3).

I am working with 4.16.0 (Fedora 28). I can get the driver to load, and
have console output appearing on it, but I have run into some issues
that I am unclear how to resolve.

Specifically:

1) If I change the rotation value to anything other than 90 (0x5a), the
screen output from the console is corrupt.
2) The resolution is set to 240x320, not the 320x240 that I expected.
3) pygame cannot run a display.set_mode call, always returning:

No video mode large enough for 240x320

When I run this python code:

   import os
   import pygame
   os.putenv('SDL_VIDEODRIVER', 'fbcon')
   os.putenv('SDL_FBDEV'  , '/dev/fb1')
   pygame.init()
   list = pygame.display.list_modes()
   print "List of modes: %s" % (list)

It shows an empty set ("List of modes: []").

Do you have any advice on how to resolve these issues?

Thanks in advance,

~tom

For debugging purposes:

I have the following device tree entry for the device (taken from dtc
-Ifs /proc/device-tree):

pitft@0 {
compatible = "multi-inno,mi0283qt";
buswidth = <0x8>;
rotation = <0x5a>;
bgr;
fps = <0x1e>;
reg = <0x0>;
pinctrl-0 = <0x10>;
debug = <0x0>;
dc-gpios = <0xf 0x19 0x0>;
spi-max-frequency = <0x3d09000>;
pinctrl-names = "default";
};

*** modetest output ***

[root@localhost ~]# modetest -M "mi0283qt" -c
Connectors:
id  encoder status  namesize (mm)   modes   encoders
28  31  connected   Virtual-1   43x58   1   31
  modes:
name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
  240x320 0 240 240 240 240 320 320 320 320 1 flags: ; type: preferred,
driver
  props:
2 DPMS:
flags: enum
enums: On=0 Standby=1 Suspend=2 Off=3
value: 0
5 link-status:
flags: enum
enums: Good=0 Bad=1
value: 0
6 non-desktop:
flags: immutable range
values: 0 1
value: 0
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel