Feasibility of using DE2 rotate core to rotate display output?

43 views
Skip to first unread message

Roman Beránek

unread,
Jan 28, 2020, 9:37:26 PM1/28/20
to linux-sunxi
A good portion of LCD panels available on the market has a portrait orientation.
Although the screen rotation can be performed in userspace, a system-wide
solution would be much welcome.

Seeing the DE2 rotate core be involved in the recently submitted media driver
for rotating CSI camera input, a question comes to mind: is it feasible to write
an alternative driver incorporating the core inside the DRM subsystem in order
to facilitate screen rotation?

Best Regards
Roman

Jernej Škrabec

unread,
Jan 29, 2020, 1:43:43 AM1/29/20
to linux-sunxi, roman....@prusa3d.cz
Hi!

Dne sreda, 29. januar 2020 ob 03:37:26 CET je Roman Beránek napisal(a):
Possible? Yes. Feasable? No.

It wouldn't be accepted upstream:
- 1 peripheral 1 driver rule
- natural fit to V4L2 M2M framework
- you can share buffers between V4L2 and DRM subsystem, this is also used in
that camera app you saw
- you would need to write very complex DRM logic, it is better done in
userspace

For last one, consider this: rotation engine can rotate only one buffer at the
same time, but DRM driver supports 2 or 4 planes. Most of the time, only one
is used, but sometimes, like in that camera app or video player app, 2 or more
can be used. Would you cache buffers, rotate one by one and when all are
finished, submitted them all at once to DRM driver? But then you would
introduce very bad latency, which userspace would be unaware of. You would
have audio/video sync issues, for example. There is writeback functionality in
HW, which is not exposed in mainline yet. This would solve multiple buffers
issue, but it's unusuable because at the time you get composed image back, it
is already displayed. It's meant only for taking screenshots or mirroring on
another display. Another issue - what do you do if two displays are active at
the same time (A-series SoCs which have rotation engine have two independent
display pipelines) - would you take care only for one display?

Anyway, AW doesn't really use this core much in Android. The only place I saw
it is used is for video rotation in CedarX library. I guess display is rotated
with GPU.

As I said earlier, buffer sharing between V4L2 and DRM is possible and simple.
You just need to export buffer in V4L2 to get dma-buf handle and import it in
DRM driver to get drmprime handle. You can also allocate all buffers in display
driver (dumb buffers), export them to get dma-buf handles and import them in
V4L2 driver. AFAIK you need to do that just once.

Best regards,
Jernej


Reply all
Reply to author
Forward
0 new messages