BoCoKeith
Posts: 10
Joined: Sun Jul 15, 2018 6:34 am

Dual-Window RPi: HDMI + TFT

Wed Apr 21, 2021 1:14 am

(I have posted this same question on https://raspberrypi.stackexchange.com; if I get a good answer there I'll post it here, and vice-versa.)

Like others, I'd like to set up my RPi (3/B+) with two independent screens: an HDMI and a 3.5" TFT hat (mine happens to be from Adafruit). I can get to the point where the HDMI monitor works fully as the "primary" monitor and the TFT shows the selected wallpaper (and maybe some desktop icons), but nothing, including xrandr, seems to see the TFT monitor and I can't find any useful way to interact with it. I've read several articles on this topic the answers all boil down to "Ah. That's because that doesn't work."

My question is "Why not?".

To be more specific, I can successfully load the TFT driver. '/dev/fb1' does indeed exist and I can 'cat /dev/urandom > /dev/fb1' to get a TFT screen full of junk.

I've built an 'xorg.conf' dual screen configuration (see below) that, on boot, paints the (Temple.png) wallpaper and selected desktop icons on both the HDMI and the TFT monitors, which means to me that XWindows at least sort of sees the TFT. However, I can't interact with the TFT from the RPi desktop.

Further 'xrandr' doesn't seem to see the TFT. That is, 'xrandr --listmonitors' shows only the HDMI monitor.

Being a C# hack, I ran a simple WinForms app to show the number of screens available, and it, too, only reports one screen.

I can enable Xinerama to make a single wide screen including both the HDMI and the TFT, but that's not an ideal solution. (Also, Xinerama seems to lose its way after a while and the wallpaper starts tiling, or getting cropped, or worse).

So I'm puzzled. There is a second monitor. XWindows at least sort of knows it's there. Why can't I use it or interact with it? Does the same problem arise if I were to add a second HDMI monitor (through, say, a splitter)?

Here's some config info:

/boot/config.txt additions:

Code: Select all

hdmi_force_hotplug=1 #allows me to run headless
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on
dtoverlay=pitft35-resistive,rotate=90,speed=20000000,fps=20
#framebuffer_depth=16   #uncomment this for Xinerama
/etc/X11/xorg.conf

Code: Select all

Section "Device"
    Identifier "DeviceHDMI"
    Driver "fbturbo"
    Option "fbdev" "/dev/fb0"
    Option "SwapbuffersWait" "true"
EndSection

Section "Device"
    Identifier "DeviceTFT"
    Driver "fbturbo"
    Option "fbdev" "/dev/fb1"
    Option "SwapbuffersWait" "true"
EndSection

Section "Monitor"
    Identifier "MonitorHDMI"
EndSection

Section "Monitor"
    Identifier "MonitorTFT"
EndSection

Section "Screen"
    Identifier "ScreenHDMI"
    Monitor "MonitorHDMI"
    Device "DeviceHDMI"
EndSection

Section "Screen"
    Identifier "ScreenTFT"
    Monitor "MonitorTFT"
    Device "DeviceTFT"
EndSection

MiscBits
Posts: 249
Joined: Wed Jan 27, 2021 12:48 pm

Re: Dual-Window RPi: HDMI + TFT

Wed Apr 21, 2021 2:05 am

Is a computer language with goto's totally Wirth-less?

aBUGSworstnightmare
Posts: 2938
Joined: Tue Jun 30, 2015 1:35 pm

Re: Dual-Window RPi: HDMI + TFT

Wed Apr 21, 2021 5:35 am

Is your TFT working when connected only?
Is there a real need for using legacy driver?
Which display do you use?
Maybe this is of interrest viewtopic.php?f=63&t=306624&p=1834648&h ... 1#p1834648

Note: this is under KMS, so answer the question why you will need legacy driver.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11250
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Dual-Window RPi: HDMI + TFT

Wed Apr 21, 2021 10:22 am

If you want to use xrandr to configure your displays instead of Xinerama then you need to be using the DRM/KMS drivers. That means dtoverlay=vc4-kms-v3d or dtoverlay=vc4-fkms-v3d in config.txt.

To mix in an SPI TFT you need to be using the DRM/KMS version of the TFT driver (if one exists). aBUGSworstnightmare has already linked to the thread where I did the same thing for the ili9341 driver (although I haven't pushed the overlay PR as yet).
It looks like a suitable driver exists as https://github.com/raspberrypi/linux/bl ... /hx8357d.c, under CONFIG_TINYDRM_HX8357D
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

sdess
Posts: 1
Joined: Thu Apr 22, 2021 5:58 am

Re: Dual-Window RPi: HDMI + TFT

Thu Apr 22, 2021 7:58 am

Hi,

I'd like to do the same. Without success neither for now.
The final App will be use on the tft, but for the dev part, it's more suitable to use an external hdmi monitor. So, it would be great to have both working in the same time. I can switch from one to other, but like BoCoKeith , I can't make them work together.
If you find a solution, I will be pleased to read it.
If I find one, I'll post it here too.

Regards
Steeve

BoCoKeith
Posts: 10
Joined: Sun Jul 15, 2018 6:34 am

Re: Dual-Window RPi: HDMI + TFT

Thu Apr 22, 2021 3:12 pm

@MiscBits - Thanks for the link. That's pretty much what I did, except that I hadn't started on the input part yet. I did notice that the test command 'DISPLAY="0.1 chromium-browser <url>' does work for me (which is cool), so maybe I set it up properly after all. The keyboard follows the app to the new window but, sadly, the mouse doesn't. Also, many programs don't recognize the DISPLAY setup.

BoCoKeith
Posts: 10
Joined: Sun Jul 15, 2018 6:34 am

Re: Dual-Window RPi: HDMI + TFT

Thu Apr 22, 2021 3:15 pm

@6By9 - Sounds very promising, but I am far too inexperienced to be trying to build and install a device driver without some pretty explicit instructions. Can you point me at a pre-built driver, or point me at some instructions for doing a build myself? Much appreciated.

BoCoKeith
Posts: 10
Joined: Sun Jul 15, 2018 6:34 am

Re: Dual-Window RPi: HDMI + TFT

Thu Apr 22, 2021 3:22 pm

@aBUGSworstnightmare - I was using 'legacy' mostly because I don't know better. :-/ I have enabled Fake KMS.

The link you provided sounds very promising (it includes work by @6By9 who has also posted in this thread), but it's largely going over the top of my head. Can you give me some pointer on how I might use/implement a DRM version of the driver I need (again, for an Adafruit 3.5" TFT)?
Last edited by BoCoKeith on Thu Apr 22, 2021 5:03 pm, edited 1 time in total.

aBUGSworstnightmare
Posts: 2938
Joined: Tue Jun 30, 2015 1:35 pm

Re: Dual-Window RPi: HDMI + TFT

Thu Apr 22, 2021 4:19 pm

Sorry, never used a TFT on SPI interface from the Pi, so can't help here.

Have a look here for an xorg.conf which is was known working (as you can see from the pictures)
viewtopic.php?f=63&t=246384&p=1834304&h ... 3#p1504551

Return to “General discussion”