[PATCH 07/17] drm: Add atomic/plane helpers
On Tue, Nov 4, 2014 at 11:30 PM, Sean Paul wrote: >> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl >> index 89829ae58e97..ea0ef43b19e1 100644 >> --- a/Documentation/DocBook/drm.tmpl >> +++ b/Documentation/DocBook/drm.tmpl >> @@ -996,6 +996,10 @@ int max_width, max_height; >> !Edrivers/gpu/drm/drm_modes.c >> >> >> + Atomic Mode Setting Function Reference >> +!Edrivers/gpu/drm/drm_atomic.c >> + >> + > > This change should probably be in the previous patch. Yeah, fixed locally. Thanks for the review so far. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
[PATCH 07/17] drm: Add atomic/plane helpers
On Sun, Nov 02, 2014 at 02:19:20PM +0100, Daniel Vetter wrote: > This is the first cut of atomic helper code. As-is it's only useful to > implement a pure atomic interface for plane updates. > > Later patches will integrate this with the crtc helpers so that full > atomic updates are possible. We also need a pile of helpers to aid > drivers in transitioning from the legacy world to the shiny new atomic > age. Finally we need helpers to implement legacy ioctls on top of the > atomic interface. > > The design of the overall helpers<->driver interaction is fairly > simple, but has an unfortunate large interface: > > - We have ->atomic_check callbacks for crtcs and planes. The idea is > that connectors don't need any checking, and if they do they can > adjust the relevant crtc driver-private state. So no connector hooks > should be needed. Also the crtc helpers integration will do the > ->best_encoder checks, so no need for that. > > - Framebuffer pinning needs to be done before we can commit to the hw > state. This is especially important for async updates where we must > pin all buffers before returning to userspace, so that really only > hw failures can happen in the asynchronous worker. > > Hence we add ->prepare_fb and ->cleanup_fb hooks for this resources > management. > > - The actual atomic plane commit can't fail (except hw woes), so has > void return type. It has three stages: > 1. Prepare all affected crtcs with crtc->atomic_begin. Drivers can > use this to unset the GO bit or similar latches to prevent plane > updates. > 2. Update plane state by looping over all changed planes and calling > plane->atomic_update. Presuming the hardware is sane and has GO > bits drivers can simply bash the state into the hardware in this > function. Other drivers might use this to precompute hw state for > the final step. > 3. Finally latch the update for the next vblank with > crtc->atomic_flush. Note that this function doesn't need to wait > for the vblank to happen even for the synchronous case. > > v2: Clear drm__state->state to NULL when swapping in state. > > v3: Add TODO that we don't short-circuit plane updates for now. Likely > no one will care. > > v4: Squash in a bit of polish that somehow landed in the wrong (later) > patche. > > v5: Integrate atomic functions into the drm docbook and fixup the > kerneldoc. > > v6: Fixup fixup patch squashing fumble. > > v7: Don't touch the legacy plane state plane->fb and plane->crtc. This > is only used by the legacy ioctl code in the drm core, and that code > already takes care of updating the pointers in all relevant cases. > This is in stark contrast to connector->encoder->crtc links on the > modeset side, which we still need to set since the core doesn't touch > them. > > Also some more kerneldoc polish. > > v8: Drop outdated comment. > > v9: Handle the state->state pointer correctly: Only clearing the > ->state pointer when assigning the state to the kms object isn't good > enough. We also need to re-link the swapped out state into the > drm_atomic_state structure. > > Signed-off-by: Daniel Vetter Minor nit re: docbook. Otherwise, Reviewed-by: Sean Paul > --- > Documentation/DocBook/drm.tmpl | 4 + > drivers/gpu/drm/Makefile| 2 +- > drivers/gpu/drm/drm_atomic_helper.c | 355 > > include/drm/drm_atomic_helper.h | 44 + > include/drm/drm_crtc.h | 6 + > include/drm/drm_crtc_helper.h | 6 + > include/drm/drm_plane_helper.h | 22 +++ > 7 files changed, 438 insertions(+), 1 deletion(-) > create mode 100644 drivers/gpu/drm/drm_atomic_helper.c > create mode 100644 include/drm/drm_atomic_helper.h > > diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl > index 89829ae58e97..ea0ef43b19e1 100644 > --- a/Documentation/DocBook/drm.tmpl > +++ b/Documentation/DocBook/drm.tmpl > @@ -996,6 +996,10 @@ int max_width, max_height; > !Edrivers/gpu/drm/drm_modes.c > > > + Atomic Mode Setting Function Reference > +!Edrivers/gpu/drm/drm_atomic.c > + > + This change should probably be in the previous patch. >Frame Buffer Creation >struct drm_framebuffer *(*fb_create)(struct drm_device *dev, > struct drm_file *file_priv, > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > index 2e89cd50c14f..96338e349a24 100644 > --- a/drivers/gpu/drm/Makefile > +++ b/drivers/gpu/drm/Makefile > @@ -24,7 +24,7 @@ drm-$(CONFIG_DRM_PANEL) += drm_panel.o > drm-$(CONFIG_OF) += drm_of.o > > drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \ > - drm_plane_helper.o drm_dp_mst_topology.o > + drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o > drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o > drm_kms_helper-$(CONFIG_DRM_KMS_FB_HELPER) += drm_fb_helper.o > drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER)
[PATCH 07/17] drm: Add atomic/plane helpers
This is the first cut of atomic helper code. As-is it's only useful to implement a pure atomic interface for plane updates. Later patches will integrate this with the crtc helpers so that full atomic updates are possible. We also need a pile of helpers to aid drivers in transitioning from the legacy world to the shiny new atomic age. Finally we need helpers to implement legacy ioctls on top of the atomic interface. The design of the overall helpers<->driver interaction is fairly simple, but has an unfortunate large interface: - We have ->atomic_check callbacks for crtcs and planes. The idea is that connectors don't need any checking, and if they do they can adjust the relevant crtc driver-private state. So no connector hooks should be needed. Also the crtc helpers integration will do the ->best_encoder checks, so no need for that. - Framebuffer pinning needs to be done before we can commit to the hw state. This is especially important for async updates where we must pin all buffers before returning to userspace, so that really only hw failures can happen in the asynchronous worker. Hence we add ->prepare_fb and ->cleanup_fb hooks for this resources management. - The actual atomic plane commit can't fail (except hw woes), so has void return type. It has three stages: 1. Prepare all affected crtcs with crtc->atomic_begin. Drivers can use this to unset the GO bit or similar latches to prevent plane updates. 2. Update plane state by looping over all changed planes and calling plane->atomic_update. Presuming the hardware is sane and has GO bits drivers can simply bash the state into the hardware in this function. Other drivers might use this to precompute hw state for the final step. 3. Finally latch the update for the next vblank with crtc->atomic_flush. Note that this function doesn't need to wait for the vblank to happen even for the synchronous case. v2: Clear drm__state->state to NULL when swapping in state. v3: Add TODO that we don't short-circuit plane updates for now. Likely no one will care. v4: Squash in a bit of polish that somehow landed in the wrong (later) patche. v5: Integrate atomic functions into the drm docbook and fixup the kerneldoc. v6: Fixup fixup patch squashing fumble. v7: Don't touch the legacy plane state plane->fb and plane->crtc. This is only used by the legacy ioctl code in the drm core, and that code already takes care of updating the pointers in all relevant cases. This is in stark contrast to connector->encoder->crtc links on the modeset side, which we still need to set since the core doesn't touch them. Also some more kerneldoc polish. v8: Drop outdated comment. v9: Handle the state->state pointer correctly: Only clearing the ->state pointer when assigning the state to the kms object isn't good enough. We also need to re-link the swapped out state into the drm_atomic_state structure. Signed-off-by: Daniel Vetter --- Documentation/DocBook/drm.tmpl | 4 + drivers/gpu/drm/Makefile| 2 +- drivers/gpu/drm/drm_atomic_helper.c | 355 include/drm/drm_atomic_helper.h | 44 + include/drm/drm_crtc.h | 6 + include/drm/drm_crtc_helper.h | 6 + include/drm/drm_plane_helper.h | 22 +++ 7 files changed, 438 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/drm_atomic_helper.c create mode 100644 include/drm/drm_atomic_helper.h diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 89829ae58e97..ea0ef43b19e1 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -996,6 +996,10 @@ int max_width, max_height; !Edrivers/gpu/drm/drm_modes.c + Atomic Mode Setting Function Reference +!Edrivers/gpu/drm/drm_atomic.c + + Frame Buffer Creation struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 2e89cd50c14f..96338e349a24 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -24,7 +24,7 @@ drm-$(CONFIG_DRM_PANEL) += drm_panel.o drm-$(CONFIG_OF) += drm_of.o drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \ - drm_plane_helper.o drm_dp_mst_topology.o + drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o drm_kms_helper-$(CONFIG_DRM_KMS_FB_HELPER) += drm_fb_helper.o drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c new file mode 100644 index ..55a8eb2678b0 --- /dev/null +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -0,0 +1,355 @@ +/* + * Copyright (C) 2014 Red Hat + * Copyright (C) 2014 Intel Corp. + * + * Permission