Convert the BOCHS and CIRRUS drivers to atomic mode-setting
Zhao Junwang
Organization: X.Org Foundation
Abstract: Atomic mode-setting has been discussed and designed for literally years, now it's finally there, it is not only necessary but allows a bunch of nice and long overdue cleanup and unification. There are a lot ongoing atomic mode-setting conversions and some already committed to drm-next ones, while there still are some subsystems haven't started the work, as far as I know, radeon, udl, bochs and cirrus are some optional drivers. I will take DRM_BOCHS and DRM_CIRRUS_QEMU as my converting goals.
- mode sets fail too late, if the mode-setting fails, there's no way to rollback
- KMS does not guarantee that a configuration is applied in totality for the next frame
- no VBLANK-synchronized page-flips for planes
- not perfect frames
- allows an output configuration to be validated before it is applied:
- no hardware is touched before the driver acknowleges that the configuration is valid and can be applied
- no need for rollback
- allows atomic updates of an output configuration:
- multiple planes updated at the same time
- we got perfect frames show at the same time
- allows for unification and simplification of drivers
- legacy code can be removed from drivers
- much of the handling moves into helpers (core DRM)
Project Goals
- convert DRM_BOCHS driver into Atomic Mode-Setting driver
- convert DRM_CIRRUS_QEMU driver into Atomic Mode-Setting driver
- Make it a more complete ecosystem for the atomic mode-setting
- Use unified helpers will make it more concise for the subsystem, less code
- CRTCs
- ->atomic_check() - validate state
- ->atomic_begin() - prepare for updates
- ->atomic_flush() - apply updates atomically
- ->atomic_set_nofb - apply CRTC timings, this callback must be implement
- planes
- ->prepare_fb() - setup the framebuffers, e.g. pin backing storage into memory and setup any needed hardware resources
- ->cleanup_fb() - e.g. unpi backing storage
- ->atomic_check() - validate state
- ->atomic_update() - per-plane update, like setting up the new viewport or the new base address of the framebuffer for each plane
- ->atomic_disable() - disable plane
The provided helpers functions drm_helper_crtc_mode_set and drm_helper_crtc_mode_set_base then implement the callbacks required by the CRTC helpers in terms of new ->mode_set_nofb callback and the the above newly implmented plane helper callbacks.
- wire up state callbacks for planes, CRTCs and connectors:
- ->reset()
- drm_atomic_helper_*_reset()
- ->atomic_duplicate_state()
- drm_atomic_helper_*_duplicate_state()
- ->atomic_destroy_state()
- drm_atomic_helper_*_destroy_state()
- patching up the state objects in legacy code paths
- make sure that we can partially transition to atomic updates.
- drm_atomic_set_fb_for_plane
- usually the only place this is need to be manually added is the ->page_flip callback.
- all ->mode_fixup callbacks need to be audited
- not depend upon any state which is only set in the various CRTC helpers.
- not tracked by the atomic state objects.
- switch to atomic helpers internally (after this Drivers uses only atomic interfaces internally):
- Planes:
- drm_atomic_helper_update_plane()
- drm_atomic_helper_disable_plane()
- Drivers
- drm_atomic_helper_check()
- drm_atomic_helper_commit()
- Planes:
- switch to atomic helpers for userspace IOCTLs (after this Drivers is fully atomic):
- drm_atomic_helper_set_config(): DRM_MODE_IOCTL_SET_CRTC
- provide a customer ->atomic_commit() implementation to support asynchronous commits, required for page-flipping
- drm_atomic_helper_page_flip(): DRM_MODE_IOCTL_PAGE_FLIP
- ->mode_set() and ->mode_set_base() are no longer used, ->mode_set_nofb() does what is necessary to set a mode.
- atomic DPMS, DPMS standby and suspend are no more, ->disable() and ->enable() callbacks are used now, atomic DPMS is a full off or on cycle
References
_______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel