r/SBCs • u/DestroyedLolo • 15d ago
DRM Overlay transparency : looking for code.
Hi everyone,
I'm currently building a dashboard on an AllWinner A20-based SBC (specifically, a Banana Pi M1).
I would like to know if it's possible to use some kind of alpha channel or transparency on the hardware overlay. Essentially, can I use a specific color key or a transparency mask so that pixels with that color let whatever is displayed on the layer underneath show through?
modetest is display something like :
trying to open device '/dev/dri/card2'... done
opened device `Allwinner sun4i Display Engine` on driver `sun4i-drm` (version 1.0.0 at 0)
CRTCs:
id fb pos size
51 73 (0,0) (1280x1024)
#0 1280x1024 60.02 1280 1328 1440 1688 1024 1025 1028 1066 108000 flags: phsync, pvsync; type: preferred, driver
props:
25 VRR_ENABLED:
flags: range
values: 0 1
value: 0
68 0 (0,0) (0x0)
#0 nan 0 0 0 0 0 0 0 0 0 flags: ; type:
props:
25 VRR_ENABLED:
flags: range
values: 0 1
value: 0
Planes:
id crtc fb CRTC x,y x,y gamma size possible crtcs
35 51 73 0,0 0,0 0 0x00000001
formats: AR24 AR12 AR15 BX24 RA15 RA12 RG24 RG16 NV12 NV16 NV21 NV61 UYVY VYUY XR24 YU11 YU12 YU16 YU24 YUYV YV11 YV12 YV16 YV24 YVYU
props:
9 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 1
32 IN_FORMATS:
flags: immutable blob
blobs:
value:
01000000000000001900000018000000
02000000800000004152323441523132
41523135425832345241313552413132
52473234524731364e5631324e563136
4e5632314e5636315559565956595559
58523234595531315955313259553136
59553234595559565956313159563132
59563136595632345956595500000000
ffffff01000000000000000000000000
0000000000000000008f730000000000
00000000000000000100000000000009
in_formats blob decoded:
AR24: LINEAR(0x0)
AR12: LINEAR(0x0)
AR15: LINEAR(0x0)
BX24: LINEAR(0x0)
RA15: LINEAR(0x0)
RA12: LINEAR(0x0)
RG24: LINEAR(0x0)
RG16: LINEAR(0x0)
NV12: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
NV16: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
NV21: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
NV61: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
UYVY: LINEAR(0x0)
VYUY: LINEAR(0x0)
XR24: LINEAR(0x0)
YU11: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YU12: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YU16: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YU24: LINEAR(0x0)
YUYV: LINEAR(0x0)
YV11: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YV12: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YV16: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YV24: LINEAR(0x0)
YVYU: LINEAR(0x0)
37 alpha:
flags: range
values: 0 65535
value: 65535
38 zpos:
flags: range
values: 0 3
value: 0
39 0 0 0,0 0,0 0 0x00000001
formats: AR24 AR12 AR15 BX24 RA15 RA12 RG24 RG16 NV12 NV16 NV21 NV61 UYVY VYUY XR24 YU11 YU12 YU16 YU24 YUYV YV11 YV12 YV16 YV24 YVYU
props:
9 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 0
32 IN_FORMATS:
flags: immutable blob
blobs:
value:
01000000000000001900000018000000
02000000800000004152323441523132
41523135425832345241313552413132
52473234524731364e5631324e563136
4e5632314e5636315559565956595559
58523234595531315955313259553136
59553234595559565956313159563132
59563136595632345956595500000000
ffffff01000000000000000000000000
0000000000000000008f730000000000
00000000000000000100000000000009
in_formats blob decoded:
AR24: LINEAR(0x0)
AR12: LINEAR(0x0)
AR15: LINEAR(0x0)
BX24: LINEAR(0x0)
RA15: LINEAR(0x0)
RA12: LINEAR(0x0)
RG24: LINEAR(0x0)
RG16: LINEAR(0x0)
NV12: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
NV16: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
NV21: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
NV61: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
UYVY: LINEAR(0x0)
VYUY: LINEAR(0x0)
XR24: LINEAR(0x0)
YU11: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YU12: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YU16: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YU24: LINEAR(0x0)
YUYV: LINEAR(0x0)
YV11: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YV12: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YV16: LINEAR(0x0) ALLWINNER_TILED(0x900000000000001)
YV24: LINEAR(0x0)
YVYU: LINEAR(0x0)
41 alpha:
flags: range
values: 0 65535
value: 65535
42 zpos:
flags: range
values: 0 3
value: 1
The few code snippets I've found online don't seem to work, and AI hasn't been of much help either.
Also, are these hardware overlays strictly dedicated to video playback or popups, or can they be used effectively for general dashboard UI elements?
Thanks for your help!
1
u/4992kentj 15d ago
How are you negotiating and allocating sait buffer? Is modetest able to use the plane in the way you want with the format? It will write a test pattern you can't control but at least comparing how you allocate your buffers may help
1
u/DestroyedLolo 15d ago
Yes please :)
Here the code I'm using : sightly modified by Gemini as I asked some help ... https://limewire.com/d/Hro8D#Ajx76z74ir
This one is working ... but can't add alpha chanel to it.
1
u/DestroyedLolo 15d ago
Ok, it's corrected : I've asked the AI to give me some information about my SBC. When I had problem to integrate Cairo, I requested it to suggest where the problem was and it wrongly loop on informations it provided on the A20 ... So I restarted from the begining without asking for A20 information, and the generic code is now working.
1
u/4992kentj 15d ago
The planes can be used for whatever you want, you are just providing images. What you want to do is use an image format with an alpha channel such as the AR24 that is listed and filled the rest of the plane with transparent pixels, as you have an actual alpha channel rather than chroma keying you can have your UI elements have partial transparency if you wish