XPUIPC
Posts: 10
Joined: Sun Jul 28, 2019 4:47 pm

CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 8:32 am

Hi,

i hooked up an TFT display with an st7701s interface chip from here:
https://www.buydisplay.com/4-inch-tft-l ... ot-devices
https://www.buydisplay.com/download/ic/ST7701.pdf
to a CM4 on the DISP1 DSI port. It has two DSI lines and i configured it for pure DSI commands only, no SPI communication according to datasheet of display and the st7701 chip.

IM3~IM0 1 1 0 1 => MIPI

This is what i have done so far:
0. Read all the relevant threads concerning connecting a custom tft to a raspberry pi under linux (thanks a lot for the huge work you have done)
viewtopic.php?f=98&t=282974
viewtopic.php?f=108&t=293877
viewtopic.php?f=45&t=283890
viewtopic.php?f=44&t=269792
https://github.com/anholt/linux/wiki/Ra ... lay-panels
viewforum.php?f=107
viewforum.php?f=44
etc...
1. Connected the display to DISP1 DSI of the CM4 dev. board with an adapter that maps the correct 22 pin of the DISP1 to my 60 pin tft interface (DSI clock, two DSI data lines, power, etc.)
2. I found out that there is already a st7701 driver (panel-sitronix-st7701.c) for a ts8550b techstar panel compiled into the linux kernel 5.10 that will fit my needs, except the timings (but this is ok) and perhaps the GPIO pins for reset and PWM for backlight
3. I have the above kernel version on my CM4
Linux raspberrypi 5.10.17-v7l+ #1421 SMP Thu May 27 14:00:13 BST 2021 armv7l
4. I read that i will also need an overlay (.dts) and compile it, but not really understanding the references between the driver and the content of the overlay (GPIO pins, compatibility string used in the driver)

What is happening:
1. I can not see that the DSI DISP1 is "activated/probed/polled" in the logs (it seems it is only looking on the HDMI), nor activity to my display on the data lines/clock

Questions:
0. General workflow to "activate/create" a driver e.g. ?
a. create/modify the driver
b. compile it etc.
c. create/modify the overlay
=> which references are needed (GPIO, compatibilty string, ...)?
d. compile and activate overlay
e. configure/edit config.txt
1. How could a .dts file look like together with the panel-sitronix-st7701.c panel driver, which references are important?
I assume that this string is important

Code: Select all

static const struct of_device_id st7701_of_match[] = {
	{ .compatible = "techstar,ts8550b", .data = &ts8550b_desc },
	{ }
};
and perhaps this:

Code: Select all

static struct mipi_dsi_driver st7701_dsi_driver = {
	.probe		= st7701_dsi_probe,
	.remove		= st7701_dsi_remove,
	.driver = {
		.name		= "st7701",
		.of_match_table	= st7701_of_match,
	},
};
2. What has to be done in the config.txt file to "activate" the DSI DISP1 together with the above driver/dts combo ?

Really will be happy if there is someone who can help me(us?) here to get it to work... i am a bit stuck at the moment...

Thank you very much

Torsten

User avatar
Gavinmc42
Posts: 6044
Joined: Wed Aug 28, 2013 3:31 am

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 8:39 am

Sure would be nice if RPF had some direct connect DSI displays.
Seems a shame to waste those two on the CM4 I/O board and the single one on the PI4 boards.
.
Has anyone got DSI displays working without using a converter chip?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

XPUIPC
Posts: 10
Joined: Sun Jul 28, 2019 4:47 pm

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 9:06 am

Has anyone got DSI displays working without using a converter chip?
I think and as far as i read in this forum/github/google it is possible but not an "easy piece of cake" and information how it can be done is there (see the referenced threads) but a bit scattered all over the place. Perhaps this thread can collect and sum up a bit the things we need to get it done...I understand that there is no "generic" approach for this "problem"...perhaps here is someone who can structure/answer it a bit according my questions...
Often it is more easy to understand (for me) to do it with an "Hello world" code example => here for my needs with the existing st7701s driver....

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 29307
Joined: Sat Jul 30, 2011 7:41 pm

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 9:55 am

DSI displays are very difficult to get going. The DSI spec describes an electrical connection, but the register settings is pretty much a free for all, so every display is different, and every display usually needs some arcane set of registers set to values that make no sense to anyone except the display manufacturer.

For example, I had a DSI to HDMI chip plumbed in to the Pi I was testing for the original Pi400 (never used as we moved to the 2711 with two HDMI). I got it working fairly well on 2 channel DSI, 3 channel also worked. I NEVER figured out why 4 channel didn't work. Seems to be no rhyme nor reason to it.

We have been working on getting various displays working under KMS, but we've had to buy a VERY expensive DSI analyser to help with it. It only arrived yesterday, but hopefully will enable us to get more and more displays working a bit more quickly.

Once we get a bit more experienced in using KMS/DSI we will produce some documentation that will hopefully help others to do the same.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Applications Team.

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

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 11:45 am

jamesh wrote:
Mon Jul 26, 2021 9:55 am
DSI displays are very difficult to get going. The DSI spec describes an electrical connection, but the register settings is pretty much a free for all, so every display is different, and every display usually needs some arcane set of registers set to values that make no sense to anyone except the display manufacturer.

For example, I had a DSI to HDMI chip plumbed in to the Pi I was testing for the original Pi400 (never used as we moved to the 2711 with two HDMI). I got it working fairly well on 2 channel DSI, 3 channel also worked. I NEVER figured out why 4 channel didn't work. Seems to be no rhyme nor reason to it.

We have been working on getting various displays working under KMS, but we've had to buy a VERY expensive DSI analyser to help with it. It only arrived yesterday, but hopefully will enable us to get more and more displays working a bit more quickly.

Once we get a bit more experienced in using KMS/DSI we will produce some documentation that will hopefully help others to do the same.
4-lane DSI also never worked so far for the SN65DSI8x MIPI-to-LVDS bridge. 6by9 is aware of it and hopefully the DSI analyses will bring some light into this.

Don't expect a DSI display will 'just work' when you connect it to any SOC - not only a Rpi3/4. You need to have lot's of details (i.e. initialization sequence, power-up sequence, full spec to get to know which other signals needs to get served, etc.

If you want o have an easy solution, which also seems to work with 4-lane DSI have a look at this https://github.com/harlab/CM4_LCD_LT070ME05000. He used the panel from Google Nexus 7 Gen2 tablet and all required files (driver and overlay) to get it working under KMS are in the kernel tree (at least 5.10.xx).
Always work with the latest kernel sources when dealing with DSI/KMS!

@jamesh: looking forward to this 'guide' 8-)
Last edited by aBUGSworstnightmare on Mon Jul 26, 2021 3:42 pm, edited 2 times in total.

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

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 11:46 am

Gavinmc42 wrote:
Mon Jul 26, 2021 8:39 am
Sure would be nice if RPF had some direct connect DSI displays.
Seems a shame to waste those two on the CM4 I/O board and the single one on the PI4 boards.
.
Has anyone got DSI displays working without using a converter chip?
https://github.com/harlab/CM4_LCD_LT070ME05000

XPUIPC
Posts: 10
Joined: Sun Jul 28, 2019 4:47 pm

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 11:50 am

@jamesh: Wow this is really good news, very much appreciated!

And yes, MIPI DSI seems to be really tricky and lots of displaycontrollers around...
...so but for my special "problem" it seems that i am very close to my solution: I have a kernel driver already for the st7701s (panel-sitronix-st7701.c) including st7701 init sequence and the items which seem to be needed:

Code: Select all

static void st7701_init_sequence(struct st7701 *st7701)
{
	const struct drm_display_mode *mode = st7701->desc->mode;

	ST7701_DSI(st7701, MIPI_DCS_SOFT_RESET, 0x00);

	/* We need to wait 5ms before sending new commands */
	msleep(5);

	ST7701_DSI(st7701, MIPI_DCS_EXIT_SLEEP_MODE, 0x00);

	msleep(st7701->sleep_delay);

	/* Command2, BK0 */
	ST7701_DSI(st7701, DSI_CMD2BKX_SEL,
		   0x77, 0x01, 0x00, 0x00, DSI_CMD2BK0_SEL);
	......
}
static int st7701_prepare(struct drm_panel *panel)
...
static int st7701_enable(struct drm_panel *panel)
...
static int st7701_disable(struct drm_panel *panel)
...
static int st7701_unprepare(struct drm_panel *panel)
...
etc.
It is compiled in the kernel but not really sure how to get it to work/active (via overlay ?)

So, what is in my case missing to get the DISP1 to work with the above driver ?
config.txt ?
*.dts ?

I am under a bit pressure to get it work, so i want to progress as much as possible...

Thank you

Torsten

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

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 12:02 pm

XPUIPC wrote:
Mon Jul 26, 2021 8:32 am
Hi,

i hooked up an TFT display with an st7701s interface chip from here:
https://www.buydisplay.com/4-inch-tft-l ... ot-devices
https://www.buydisplay.com/download/ic/ST7701.pdf
to a CM4 on the DISP1 DSI port. It has two DSI lines and i configured it for pure DSI commands only, no SPI communication according to datasheet of display and the st7701 chip.

IM3~IM0 1 1 0 1 => MIPI

This is what i have done so far:
0. Read all the relevant threads concerning connecting a custom tft to a raspberry pi under linux (thanks a lot for the huge work you have done)
viewtopic.php?f=98&t=282974
viewtopic.php?f=108&t=293877
viewtopic.php?f=45&t=283890
viewtopic.php?f=44&t=269792
https://github.com/anholt/linux/wiki/Ra ... lay-panels
viewforum.php?f=107
viewforum.php?f=44
etc...
1. Connected the display to DISP1 DSI of the CM4 dev. board with an adapter that maps the correct 22 pin of the DISP1 to my 60 pin tft interface (DSI clock, two DSI data lines, power, etc.)
2. I found out that there is already a st7701 driver (panel-sitronix-st7701.c) for a ts8550b techstar panel compiled into the linux kernel 5.10 that will fit my needs, except the timings (but this is ok) and perhaps the GPIO pins for reset and PWM for backlight
3. I have the above kernel version on my CM4
Linux raspberrypi 5.10.17-v7l+ #1421 SMP Thu May 27 14:00:13 BST 2021 armv7l
4. I read that i will also need an overlay (.dts) and compile it, but not really understanding the references between the driver and the content of the overlay (GPIO pins, compatibility string used in the driver)

What is happening:
1. I can not see that the DSI DISP1 is "activated/probed/polled" in the logs (it seems it is only looking on the HDMI), nor activity to my display on the data lines/clock

Questions:
0. General workflow to "activate/create" a driver e.g. ?
a. create/modify the driver
b. compile it etc.
c. create/modify the overlay
=> which references are needed (GPIO, compatibilty string, ...)?
d. compile and activate overlay
e. configure/edit config.txt
1. How could a .dts file look like together with the panel-sitronix-st7701.c panel driver, which references are important?
I assume that this string is important

Code: Select all

static const struct of_device_id st7701_of_match[] = {
	{ .compatible = "techstar,ts8550b", .data = &ts8550b_desc },
	{ }
};
and perhaps this:

Code: Select all

static struct mipi_dsi_driver st7701_dsi_driver = {
	.probe		= st7701_dsi_probe,
	.remove		= st7701_dsi_remove,
	.driver = {
		.name		= "st7701",
		.of_match_table	= st7701_of_match,
	},
};
2. What has to be done in the config.txt file to "activate" the DSI DISP1 together with the above driver/dts combo ?

Really will be happy if there is someone who can help me(us?) here to get it to work... i am a bit stuck at the moment...

Thank you very much

Torsten
Your 'reference list' isn't complete as you're missing the most active threads, like i.e.
viewtopic.php?f=44&t=305690 - deals with a TI SN65DSI8x MIPI-to-LVDS bridge but is an excellent example of what has to be done to get a DSI device (display/bridge, etc) working. You will also learn from it that high-end tools might be needed at some point even if you're a professional.

viewtopic.php?f=98&t=253912&hilit=LT070ME05000 - deals with the JDI panel used in Nexus Gen2

viewtopic.php?f=98&t=314940 - work in progress for a small high-ppi display

And, btw ... did you have a closer look at data sheet for this 4in display? They are listing 4-wire SPI+MIPI although the display controller supports MIPI only. MIPI+SPI not only requires a running DSI interface, it also needs a SPI driver to send the required commands to the displays TCON. Do you know them ... as I can't find anything in the spec

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

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 12:04 pm

XPUIPC wrote:
Mon Jul 26, 2021 11:50 am
@jamesh: Wow this is really good news, very much appreciated!

And yes, MIPI DSI seems to be really tricky and lots of displaycontrollers around...
...so but for my special "problem" it seems that i am very close to my solution: I have a kernel driver already for the st7701s (panel-sitronix-st7701.c) including st7701 init sequence and the items which seem to be needed:

Code: Select all

static void st7701_init_sequence(struct st7701 *st7701)
{
	const struct drm_display_mode *mode = st7701->desc->mode;

	ST7701_DSI(st7701, MIPI_DCS_SOFT_RESET, 0x00);

	/* We need to wait 5ms before sending new commands */
	msleep(5);

	ST7701_DSI(st7701, MIPI_DCS_EXIT_SLEEP_MODE, 0x00);

	msleep(st7701->sleep_delay);

	/* Command2, BK0 */
	ST7701_DSI(st7701, DSI_CMD2BKX_SEL,
		   0x77, 0x01, 0x00, 0x00, DSI_CMD2BK0_SEL);
	......
}
static int st7701_prepare(struct drm_panel *panel)
...
static int st7701_enable(struct drm_panel *panel)
...
static int st7701_disable(struct drm_panel *panel)
...
static int st7701_unprepare(struct drm_panel *panel)
...
etc.
It is compiled in the kernel but not really sure how to get it to work/active (via overlay ?)

So, what is in my case missing to get the DISP1 to work with the above driver ?
config.txt ?
*.dts ?

I am under a bit pressure to get it work, so i want to progress as much as possible...

Thank you

Torsten
https://www.raspberrypi.org/documentati ... uilding.md , get latest sources from git 5.10 https://github.com/raspberrypi/linux

Even knowing the TCON means nothing! You need to know the init sequence for your display (!) not a random one!. If you don't have it -> full fail!
And even if you know all the dirty details there is still a big chance to fail (as some other quirks might have to be solved first)

XPUIPC
Posts: 10
Joined: Sun Jul 28, 2019 4:47 pm

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 7:29 pm

@aBUGSworstnightmare: It sounds between the lines that you are a bit frustrated about the topic displays/panels together with raspi DSI...;-) but thank you for your links and help...and i can understand that it is hard to comment these things again/again to the guys who start to try to hook up a DSI panel...
You need to know the init sequence for your display (!) not a random one!
You need to have lot's of details (i.e. initialization sequence, power-up sequence, full spec to get to know which other signals needs to get served, etc
I have an init sequence for this display...and an example in the already existing kernel driver panel-sitronix-st7701.c which is compiled in the 5.10 and i have this display/chip running together with a BT817 chip with RGB interface and SPI (9bit) and init it with the init sequence and wake it up and so on...but now i changed to raspberryPi because of several reasons...=> So this is then only my second problem to solve...

My first problem is that i do not really understand how the DSI interface is "activated" and the panel-sitronix-st7701.c driver will/is do/ing something (probing etc.), i can not see something related to DSI in the logs...
So current status so far:
0. Display wired to DISP1
1. I have this in my config.txt

Code: Select all

ignore_lcd=1
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-kms-v3d
max_framebuffers=2
2. A driver (panel-sitronix-st7701.c) is already there and is compiled into the kernel since 5.10 => which i have installed on my CM4=> so kernel building should not be necessary at this point, only when i have to modify the driver, right?
3. I assume that for "the driver is doing something" thing i need an overlay (*.dts) compile it and register it, right?
4. If yes, perhaps there is an overlay already for the driver and i missed it and i have just to add something into the config.txt? (like dtoverlay=blabla7701..)?

So long story short: How can i use/activate the "panel-sitronix-st7701.c" driver ? :?

Thank you...

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

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 8:11 pm

XPUIPC wrote:
Mon Jul 26, 2021 7:29 pm
My first problem is that i do not really understand how the DSI interface is "activated" and the panel-sitronix-st7701.c driver will/is do/ing something (probing etc.), i can not see something related to DSI in the logs...
So current status so far:
0. Display wired to DISP1
1. I have this in my config.txt

Code: Select all

ignore_lcd=1
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-kms-v3d
max_framebuffers=2
2. A driver (panel-sitronix-st7701.c) is already there and is compiled into the kernel since 5.10 => which i have installed on my CM4=> so kernel building should not be necessary at this point, only when i have to modify the driver, right?
It's not in the default kernel config, so you'll have had to build a custom kernel for it. Please ensure you're using the latest kernel (currently 5.10.52) as the vc4 display drivers are under significant development at present.
XPUIPC wrote:3. I assume that for "the driver is doing something" thing i need an overlay (*.dts) compile it and register it, right?
4. If yes, perhaps there is an overlay already for the driver and i missed it and i have just to add something into the config.txt? (like dtoverlay=blabla7701..)?

So long story short: How can i use/activate the "panel-sitronix-st7701.c" driver ? :?
Yes you need an overlay. No there isn't an existing one for st7701.
You could take vc4-kms-dsi-lt070me05000-overlay.dts as a basis. You'll need to look at the binding docs for st7701 to get the syntax and other resource requirements for that panel.
You'll need to add a second "dtoverlay=" line to config.txt to load your new overlay.
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.

XPUIPC
Posts: 10
Joined: Sun Jul 28, 2019 4:47 pm

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 8:15 pm

Oi...

@6by9: you made my day....for today ;-)

Thank you...

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

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 8:26 pm

My working life seems to be swearing at DSI panels at present.
I'm working my way through various DSI quirks at present with the help of the new analyser, but it's not helping that DSI support in the Linux kernel is patchy and undefined in places :-(
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.

XPUIPC
Posts: 10
Joined: Sun Jul 28, 2019 4:47 pm

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Mon Jul 26, 2021 8:38 pm

My working life seems to be swearing at DSI panels at present.
...yes lots of panels out there...and...CM4 is nice...so demand for this interface/panels will grow (e.g. i need this small 4inch panel because my project is for aerospace use and the default raspi 7inch panel is far too big and wron formfactor) so i have to customize...
I'm working my way through various DSI quirks at present with the help of the new analyser, but it's not helping that DSI support in the Linux kernel is patchy and undefined in places
...but...we will tackle it...and get it done.... hopefully ;)

Really thank you for your effords/help...and thumbs up!

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

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Tue Jul 27, 2021 5:32 am

XPUIPC wrote:
Mon Jul 26, 2021 7:29 pm
@aBUGSworstnightmare: It sounds between the lines that you are a bit frustrated about the topic displays/panels together with raspi DSI...;-) but thank you for your links and help...and i can understand that it is hard to comment these things again/again to the guys who start to try to hook up a DSI panel...
...
2. A driver (panel-sitronix-st7701.c) is already there and is compiled into the kernel since 5.10 => which i have installed on my CM4=> so kernel building should not be necessary at this point, only when i have to modify the driver, right?
3. I assume that for "the driver is doing something" thing i need an overlay (*.dts) compile it and register it, right?
4. If yes, perhaps there is an overlay already for the driver and i missed it and i have just to add something into the config.txt? (like dtoverlay=blabla7701..)?

So long story short: How can i use/activate the "panel-sitronix-st7701.c" driver ? :?

Thank you...
Well, one can only be frustaded about people that don't want to listen, not about some quirks with DSI on RPI.

You've asked how to activate a driver which sources are in the tree and that is perfectly described in the link which I've posted here viewtopic.php?f=98&t=316479#p1893401 . All required build instruction steps are written there, so why should one type them here again?

In addition to that you will need an overlay (as said). The example for the JDI panel can be used as a template. https://github.com/raspberrypi/linux/bl ... t7701.yaml has details on the bindings required by the st7701 driver.
It will also hint you to the panel it was used with: compatible = "techstar,ts8550b", "sitronix,st7701".
As you can see there are two compatibles, with 'panel-techstar-ts8550b.c' not in the standard tree.

That said brings you back to st7701 driver which has the timings and the init sequence for a 480x854pixel resolution display (Techstar TS8550b), means you will have to update 'st7701_init_sequence' and 'drm_display_mode ts8550b_mode' at least before you try to light up your display. DSI displays have a bad habit: they stay pitch black most of the time if something is initialized wrong, means if you try to use the init sequence for RGB with DSI you will see one solid color most likely, guess which.

You have the init sequence and the timings, as none of it is available from the display data sheet... So, how should any forum user know how to change the above driver portions for writing a customized driver with that info beeing hidden?

And yes! You WILL have to compile your kernel! You will have to do it because:
1.) the required/desired driver is not in the dafault kernel config
2.) 'Default' driver is unsuited because the init sequence and timings do not match with your display

So, looking forward to see the display running on CM4! As it is affordable and might be easy to source it can be used as one example for interfacing DSI displays to RPi.


XPUIPC
Posts: 10
Joined: Sun Jul 28, 2019 4:47 pm

Re: CM4, custom MIPI TFT display connected to DISP1 DSI interface

Tue Aug 24, 2021 8:24 pm

aBUGSworstnightmare wrote:
Tue Aug 03, 2021 6:55 am
@OP: made any progress here?
....not the desired progress here, not only due to technical issues...but...i will get it to work...:)

Return to “Compute Module”