-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify the use of SPI displays now that fbtft_device is gone #4659
Comments
Can we make a driver more akin to panel-simple or panel-ilitek-ili9881 where each compatible string looks up a configuration that can then be used with the display? OK it means that each new panel means a code (and dtbinding!) change rather than overlay, but in theory it should be acceptable to mainline. You have the basis of it already with your existing tiny/mipi_dbi_drv driver, but need the configuration structs to be added rather than putting them in an overlay. |
Indeed that's possible having the driver support many displays, drivers/gpu/drm/tiny/st7735r.c supports 2 displays. Zephyr has properties for some of the commands which seems like a good idea. This avoids panel specifics in the driver. Unfortunately getting stuff into mainline is more work than I can spend, so that's not something I can take on. |
I'm not against supporting another downstream driver if it will be widely used (as I think an fbtft replacement might be). I also like the sound of option 2, but I don't see how that could work without a driver that gets settings from DT - is there such a thing? And welcome back. |
Understood. I fully recognise the pain - I also have a load of patches I really ought to submit to mainline. I'm not sure that Zephyr's bindings would be acceptable. They differ significantly to mainline, and seems to be specifying configuration instead of describing the hardware, and that's normally the big no-no. |
Your comment jogged my memory and I remembered seeing something similar in mainline: bindings/display/solomon%2Cssd1307fb.yaml |
All fbtft drivers support the same set of properties (except bgr), I was thinking something like this: https://gist.github.com/notro/0c1cead85dfb406d5d9b2d8cef07f542 Using that overlay, these two configs will create identical SPI devices (ignoring touchcontroller):
The one thing I didn't find out how to do, was to create a 32-bit array from a parameter:
Example overlay using the init property: mz61581-overlay.dts
Thanks Phil |
I discovered that fbtft gpio backlight is broken: staging/fbtft: Fix backlight |
There are a couple of ways in which you could build up an integer array from a parameter - patching in each integer at a time (properties can be extended with offsets beyond the existing length), or as a byte array - but they are neither elegant nor efficient. My advice would be to put each variant of the For example:
Fragments 2 and 3 are intra-overlay fragments because they target another part of the overlay. The firmware is careful to apply intra- fragments before those the others targetting the base DTB (inter-, I suppose), but that is the limit of its intelligence. For example, if fragment 1 targets the base DTB, 2 targets 1 and 3 targets 2, 2 will correctly be applied to 1 before it is merged, but 3 will be applied too and late and will be lost. In general it's safest to write the fragments in the order in which they should be applied, but having a base fragment at the start of the file that is then populated by the others is also fine. |
What am I doing wrong here, I have this in the overlay:
config.txt:
log:
|
Try without the brackets and spaces - I can check the exact rules later. |
Ah - whitespace and colons are legal separators between pairs of hex digits, but separators are optional. |
Luckily for my use case the property values are stored as big-endian, so it's not so bad to use a byte string. But it looks like there's something wrong with the parser?
Hm, it looks like the string is capped at len=13. |
Oh, it's the total length of the statement that is too long:
|
This it what I would like to do, would it be possible to increase the max length to 1024?
If this would be possible a DT overlay can perform all that fbtft_device could do (except handle a panel with an offset on the address). |
There's a 78-character line length limit (the buffer holds 80 characters, including newline and NUL), which has been raised to 98 with the very latest firmwares. Increasing the maximum length would also affect all the other readers of config.txt, including bootcode.bin which is memory-limited because it runs before SDRAM has been enabled, so I'm reluctant to do that. The byte string feature was added with MAC addresses in mind, and it fell out nicely that single byte/integer parameters had an offset after the separator, and the other types (booleans, strings, byte strings) didn't. That prevents us from having multiple init properties that start at different offsets - One option which would allow long byte strings like this is to say that assigning to the same byte string property repeatedly (or consecutively) causes the new content to be appended. You would then (with the increased line length limit) be able to split the assignment into groups of 8 words:
|
I would like to go back and explore my earlier comment:
Given that you are already proposing to build knowledge of each of the displays into the overlay (e.g. |
I've pinged Maxime as maintainer of solomon-ssd1307fb.yaml to get his view on config in DT vs code. |
Ok, so it's not trivial to change. Even without the init property an fbtft overlay will be a big improvement on the current situation. And it doesn't take much effort to do.
I can do that for the displays that are supported in fbtft_device. An init property would have made it easy to support any display if the inititialization sequence is known, without needing to understand Device Tree files. I have just installed Home Assistant and are faced with cryptic yaml files, so I can relate to how it feels for someone that just wants to use a display they bought (without doing research to see if it's supported). Not having an init property excludes option 3 as well (generic DRM driver), but it's not a big loss. It's best avoided to carry around things that can't go into mainline. It could be possible to change the format of the init property to be bytes instead of u32's which would shorten the line considerly, but making mainline drivers more generic is preferrable. Let's see what Maxime has to say about using properties in that way. |
I am prepared to add byte string concatenation as an option of last resort (as long as it is unlikely to happen accidentally), but as you say Maxime may have other ideas. |
Comment from Maxime:
I'll let @mripard expand on that if required. |
I think I'll make a PR adding the fbtft overlay and add a step-by-step guide on the fbtft wiki on how to create an overlay with an init property. That will cover most of the fbtft_device use cases. Long term the first step would be to make a patch and add controller properties to Thanks for helping me explore the options. |
I have commit rights in DRM so I can apply patches, but I can only apply my own patches after someone else has reviewed them. And since I haven't partnered up with someone else cross reviewing patches, I can't be certain that someone will review them or how long it will take for me to get them in.
@6by9 would you be interested in reviewing the driver patches if I take a stab at this and the DT maintainer accepts the binding? |
I claim no expertise with these SPI displays, but can give things a review, and test where I have hardware (I've got about 6 of these displays kicking around). @mripard does have a contract with Raspberry Pi for vc4 DRM work, and I have no issues with him reviewing your patches under that contract if he's willing to do so. |
Thanks, I'll give it try then. I'll do the st7735r since doing the ili9341 would require me to convert the binding to yaml as well. |
I have known for some time that many find it difficult to use SPI displays that don't have an existing DT overlay.
Before Linux 5.4 it was possible to use fbtft_device to support nearly every SPI DBI display, but this is now gone.
When the issue came to my attention again recently I decided to see if I can do something about it.
I see 3 ways to solve this:
Resurrect fbtft_device and make it work again.
Pros: All those existing blog posts will be relevant again.
Cons: It can't go into mainline so have to stay downstream. And it's not my favorite.
Make a DT overlay that behaves like fbtft_device. I see that the overlays have come a long way since I looked at it in detail a few years back so I don't know its capabilities. Some properties like reset-gpios, led-gpios and init need to be optional and can only be enabled when the argument is used, the other properties can have a default value. The compatible property/argument picks the wanted driver and thus its default initialization sequence. The init property can override this.
Pros: No need to add any code, just an overlay.
The downside of these 2 is that fbdev is deprecated so it's not an optimal solution going forward.
drivers/gpu/drm/tiny/mipi_dbi_drv.c (wiki)
Pros: It's a very small and simple DRM driver which makes it easy to maintain. All the difficult stuffs happens in DRM libraries. Fully configurable from DT.
Cons: One more deviation from mainline that needs to be carried "forever" since this driver can't go into mainline (not allowed to set arbitrary registers from Device Tree).
Thoughts?
Cc: @6by9
The text was updated successfully, but these errors were encountered: