moonlight-stream / moonlight-embedded

Gamestream client for embedded systems
https://github.com/moonlight-stream/moonlight-embedded/wiki
GNU General Public License v3.0
1.48k stars 322 forks source link

Support cursor plane on Rockchip platforms #882

Closed amazingfate closed 5 months ago

amazingfate commented 6 months ago

Rockchip's vop2 driver from vendor kernel will set plane type to DRM_PLANE_TYPE_CURSOR when device tree has defined property cursor-win-id. This property is widely used in rk3588 boards, such as rock-5b: https://github.com/armbian/linux-rockchip/blob/rk-5.10-rkr6/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts#L761

This commit will allow moonlight using the cursor plane.

cgutman commented 5 months ago

So these devices have no overlay or primary planes that support NV12, but they do have cursor planes with NV12 support?

amazingfate commented 5 months ago

So these devices have no overlay or primary planes that support NV12, but they do have cursor planes with NV12 support?

They do have planes that support NV12. Vendor kernel from rockchip just don't have an overlay plane, instead they have one primary plane and one cursor plane. If device tree doesn't define cursor-win-id, then the device will have one overlay plane that supports NV12.

cgutman commented 5 months ago

They do have planes that support NV12. Vendor kernel from rockchip just don't have an overlay plane, instead they have one primary plane and one cursor plane.

Hmm, okay. I assume we're not picking the primary plane because it's already in use (!ovr->crtc_id check is false). What other applications are running that might have claimed the primary plane on your system?

I'd prefer not to abuse the cursor plane for displaying video, since many drivers really do have restrictions on the cursor plane size (64x64, 256x256, or similar). I know it's RK specific code here, but it's easily possible that a future version of the RK SoC has a proper cursor plane with similar restrictions.

Would it be better to simply claim a plane that is already associated with a CRTC? That's what we do with Moonlight Qt now and I haven't heard of issues reported because of it.

amazingfate commented 5 months ago

moonlight-qt also has similar issue Failed to find suitable overlay plane. Log: https://paste.armbian.com/ejikevoviw.makefile But it can start the stream.

cgutman commented 5 months ago

Can you compile and run https://gitlab.freedesktop.org/emersion/drm_info on your Rockchip device?

Ideally also upload the info to drmdb (drm_info -j | curl -d @- https://drmdb.emersion.fr/submit) and send me a link to it.

amazingfate commented 5 months ago

Here is the drm info: https://drmdb.emersion.fr/snapshots/c98f8e2d90d4

cgutman commented 5 months ago

Thank you. I guess this change is fine.

The YUV format checks should prevent us from ever picking a "normal" ARGB8888-only cursor plane, and the cursor planes seem to all be enumerated last anyway.