Silveryard
Posts: 5
Joined: Thu Jun 23, 2016 10:45 am

Controlling DispmanX Layers

Tue Jun 20, 2017 12:09 pm

Hey everybody

Not sure if this is the appropriate subforum. Please move if I´m wrong.

So I am currently programming a software that displays graphics via SDL (without X). This software allows other GUI programs as well and lets you switch between them.
Currently the main process gets requests from the other "apps" to do specific rendering things and executes it for them. The main disadvantage is that developers are limited to my own graphics library. What I try to accomplish is that everyone can use the library he wants (that supports rendering without X) and the main process has control over the ordering of dispmanx layers.

Example dispmanx layout:

1: App1
0: Black Background Layer
-1: App2
-2: App3

And after a switch:

1: App2
0: Black Background Layer
-1: App1
-2: App3

Is it possible to rearrange dispmanx layers from processes you do not own? (The main process is running as root) Are there any other ways I could accomplish this without porting every graphics library to support my own system?

Thanks in advance,
Silveryard

User avatar
Paeryn
Posts: 2986
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Controlling DispmanX Layers

Tue Jun 20, 2017 1:50 pm

As far as I'm aware the only way would be if the other programs all told you what their element handles are. I've just tested it and it happily lets you alter another program's element, just be careful as the other program won't be aware that anything has changed.

You would also need to cope with programs that have more than one element (and keep the ordering that the program requires) and agree with those programs that they won't go around changing the element layers themselves, but then if they have more than one element they might well want to rearrange them at some point.
She who travels light — forgot something.

Silveryard
Posts: 5
Joined: Thu Jun 23, 2016 10:45 am

Re: Controlling DispmanX Layers

Tue Jun 20, 2017 5:46 pm

Thank you for this fast response!

You are right, multiple elements would cause some trouble and I need to make sure the programs itself do not change their own layer.

So as conclusion I would not need to port a graphics library to my platform but provide the tools to fetch the element handles from each of them? Could be quite difficult in case of javafx oder some other higher level libraries.

As you already told (and the vc_dispmanx header does show this too) dispmanx does not provide the functionality to get a handle from another process such as windows does. I'd rather not modify the kernel but would it be possible to get more functionality from there? (or wherever dispmanx lives and does its thing)

I assume there are no lower level constructs that would give me the power to do what I want?

User avatar
Paeryn
Posts: 2986
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Controlling DispmanX Layers

Tue Jun 20, 2017 8:47 pm

Silveryard wrote:As you already told (and the vc_dispmanx header does show this too) dispmanx does not provide the functionality to get a handle from another process such as windows does. I'd rather not modify the kernel but would it be possible to get more functionality from there? (or wherever dispmanx lives and does its thing)

I assume there are no lower level constructs that would give me the power to do what I want?
The dispmanx calls all (mainly) just send messages on to the VC4, linux isn't involved with it after that. All the work is done in the black box that is the VC4 firmware and that is closed source.
She who travels light — forgot something.

Silveryard
Posts: 5
Joined: Thu Jun 23, 2016 10:45 am

Re: Controlling DispmanX Layers

Wed Jun 21, 2017 6:42 am

Is the dispmanx source also closed source? Or would it be possible to modify dispmanx to send my main process the element handles when they are created?

Edit: Nevermind. Found it here https://github.com/raspberrypi/userland ... dispmanx.c

Silveryard
Posts: 5
Joined: Thu Jun 23, 2016 10:45 am

Re: Controlling DispmanX Layers

Sun Jun 25, 2017 2:27 pm

So I tinkered a bit with dispmanx sourcecode and thought I found a solution by caching the result of vc_dispmanx_element_add and vc_dispmanx_update_start and provide two new functions vc_dispmanx_get_update_handle and vc_dispmanx_get_element_handle.

Problem is that dispmanx code builds to libvchostif.a which is a static library.. So there would be no way to get the cached results when calling the getters from another self compiled library... I could of course write this data to some intermediate storage of send the handles to some kind of manager but this would require me to recompile any gui library that uses libvchostif.a

Are there any other possible approaches to get these handles? I could not find much info about getting them directly from vc4

Edit: For the record. libchostif.a gets compiled into libbcm_host.so Am now able to receive the update handle and the element handle just as I wanted it

Return to “Graphics programming”