bscheffold wrote: ↑
Tue Oct 24, 2017 9:13 pm
@bzt: thank you for your code examples... to me they look very "clean" and very powerful ... maybe to me - as a beginner - too difficult to access. but i will keep them in mind... until i will see the things clearer.
Here's a little explanation:
What we have here, is a bunch of defines (lines 216-235), mailbox write function (lines 238-242) and mailbox read function (lines 243-251). Same with all the other examples. I've added another function, mbox_call (lines 253-257), which writes to the mailbox, reads the response back and checks if response valid (also can be found in all the other examples, just not in a separate function but always inlined).
The frame buffer code is really simple, fills up mbox array with values (lines 748-790), then uses the aforementioned mbox_call (line 792) to get the response in the same mbox array.
- The first element in the array is the array's size in bytes, the second is a magic value for request. After that come some command packets (each separated by an empty line in the source), finally a zero terminator element (line 790). I've used commands equivalent to FrameBufferInfo plus pixel order. That's all.
- Probably unnecessary, but I've added extra checks for the response (line 792), the depth must be 32 bit (mbox) and the frame buffer allocation must have returned a valid 8 bytes response (mbox) with a non-empty address (mbox). If so, it's safe to use the values (width, height, pitch, pointer etc., lines 793-799) just as you would from a FrameBufferInfo. There's a one-by-one relation to FrameBufferInfo fields and certain mbox elements, I've added comments for them.
I haven't used defines for tags and mbox index because I use them only once so comments are good for me. Detailed description of the tags and their arguments can be found here
If you have problems with converting C into Assembly, take a look at Peter Lemon's example. Equivalent of mbox_call is here
, and mbox array is here
. And as I see, LdB also using this property channel mailbox instead of FrameBufferInfo, but his mailbox routines are far better and more bullet-proof than Peter's.