2015-12-04 08:45:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2006 Keith Packard
|
|
|
|
* Copyright © 2007-2008 Dave Airlie
|
|
|
|
* Copyright © 2007-2008 Intel Corporation
|
|
|
|
* Jesse Barnes <jesse.barnes@intel.com>
|
|
|
|
* Copyright © 2011-2013 Intel Corporation
|
|
|
|
* Copyright © 2015 Intel Corporation
|
|
|
|
* Daniel Vetter <daniel.vetter@ffwll.ch>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DRM_MODESET_HELPER_VTABLES_H__
|
|
|
|
#define __DRM_MODESET_HELPER_VTABLES_H__
|
|
|
|
|
|
|
|
#include <drm/drm_crtc.h>
|
2016-11-28 18:51:09 +00:00
|
|
|
#include <drm/drm_encoder.h>
|
2015-12-04 08:45:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* DOC: overview
|
|
|
|
*
|
|
|
|
* The DRM mode setting helper functions are common code for drivers to use if
|
|
|
|
* they wish. Drivers are not forced to use this code in their
|
|
|
|
* implementations but it would be useful if the code they do use at least
|
|
|
|
* provides a consistent interface and operation to userspace. Therefore it is
|
|
|
|
* highly recommended to use the provided helpers as much as possible.
|
|
|
|
*
|
|
|
|
* Because there is only one pointer per modeset object to hold a vfunc table
|
|
|
|
* for helper libraries they are by necessity shared among the different
|
|
|
|
* helpers.
|
|
|
|
*
|
|
|
|
* To make this clear all the helper vtables are pulled together in this location here.
|
|
|
|
*/
|
|
|
|
|
drm: writeback: Add job prepare and cleanup operations
As writeback jobs contain a framebuffer, drivers may need to prepare and
cleanup them the same way they can prepare and cleanup framebuffers for
planes. Add two new optional connector helper operations,
.prepare_writeback_job() and .cleanup_writeback_job() to support this.
The job prepare operation is called from
drm_atomic_helper_prepare_planes() to avoid a new atomic commit helper
that would need to be called by all drivers not using
drm_atomic_helper_commit(). The job cleanup operation is called from the
existing drm_writeback_cleanup_job() function, invoked both when
destroying the job as part of a aborted commit, or when the job
completes.
The drm_writeback_job structure is extended with a priv field to let
drivers store per-job data, such as mappings related to the writeback
framebuffer.
For internal plumbing reasons the drm_writeback_job structure needs to
store a back-pointer to the drm_writeback_connector. To avoid pushing
too much writeback-specific knowledge to drm_atomic_uapi.c, create a
drm_writeback_set_fb() function, move the writeback job setup code
there, and set the connector backpointer. The prepare_signaling()
function doesn't need to allocate writeback jobs and can ignore
connectors without a job, as it is called after the writeback jobs are
allocated to store framebuffers, and a writeback fence with a
framebuffer is an invalid configuration that gets rejected by the commit
check.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
2019-02-21 01:01:38 +00:00
|
|
|
struct drm_writeback_connector;
|
|
|
|
struct drm_writeback_job;
|
2015-12-04 08:45:44 +00:00
|
|
|
|
2023-01-11 13:02:02 +00:00
|
|
|
enum mode_set_atomic {
|
|
|
|
LEAVE_ATOMIC_MODE_SET,
|
|
|
|
ENTER_ATOMIC_MODE_SET,
|
|
|
|
};
|
|
|
|
|
2015-12-04 08:45:44 +00:00
|
|
|
/**
|
|
|
|
* struct drm_crtc_helper_funcs - helper operations for CRTCs
|
|
|
|
*
|
2015-12-04 08:46:08 +00:00
|
|
|
* These hooks are used by the legacy CRTC helpers, the transitional plane
|
|
|
|
* helpers and the new atomic modesetting helpers.
|
2015-12-04 08:45:44 +00:00
|
|
|
*/
|
|
|
|
struct drm_crtc_helper_funcs {
|
2015-12-04 08:46:08 +00:00
|
|
|
/**
|
|
|
|
* @dpms:
|
|
|
|
*
|
|
|
|
* Callback to control power levels on the CRTC. If the mode passed in
|
|
|
|
* is unsupported, the provider must use the next lowest power level.
|
|
|
|
* This is used by the legacy CRTC helpers to implement DPMS
|
|
|
|
* functionality in drm_helper_connector_dpms().
|
|
|
|
*
|
|
|
|
* This callback is also used to disable a CRTC by calling it with
|
|
|
|
* DRM_MODE_DPMS_OFF if the @disable hook isn't used.
|
|
|
|
*
|
|
|
|
* This callback is used by the legacy CRTC helpers. Atomic helpers
|
|
|
|
* also support using this hook for enabling and disabling a CRTC to
|
|
|
|
* facilitate transitions to atomic, but it is deprecated. Instead
|
2017-06-30 09:36:44 +00:00
|
|
|
* @atomic_enable and @atomic_disable should be used.
|
2015-12-04 08:45:44 +00:00
|
|
|
*/
|
|
|
|
void (*dpms)(struct drm_crtc *crtc, int mode);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @prepare:
|
|
|
|
*
|
|
|
|
* This callback should prepare the CRTC for a subsequent modeset, which
|
|
|
|
* in practice means the driver should disable the CRTC if it is
|
|
|
|
* running. Most drivers ended up implementing this by calling their
|
|
|
|
* @dpms hook with DRM_MODE_DPMS_OFF.
|
|
|
|
*
|
|
|
|
* This callback is used by the legacy CRTC helpers. Atomic helpers
|
|
|
|
* also support using this hook for disabling a CRTC to facilitate
|
2017-06-30 09:36:44 +00:00
|
|
|
* transitions to atomic, but it is deprecated. Instead @atomic_disable
|
|
|
|
* should be used.
|
2015-12-04 08:46:08 +00:00
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*prepare)(struct drm_crtc *crtc);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @commit:
|
|
|
|
*
|
|
|
|
* This callback should commit the new mode on the CRTC after a modeset,
|
|
|
|
* which in practice means the driver should enable the CRTC. Most
|
|
|
|
* drivers ended up implementing this by calling their @dpms hook with
|
|
|
|
* DRM_MODE_DPMS_ON.
|
|
|
|
*
|
|
|
|
* This callback is used by the legacy CRTC helpers. Atomic helpers
|
|
|
|
* also support using this hook for enabling a CRTC to facilitate
|
2017-06-30 09:36:44 +00:00
|
|
|
* transitions to atomic, but it is deprecated. Instead @atomic_enable
|
|
|
|
* should be used.
|
2015-12-04 08:46:08 +00:00
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*commit)(struct drm_crtc *crtc);
|
|
|
|
|
2017-05-15 09:33:47 +00:00
|
|
|
/**
|
|
|
|
* @mode_valid:
|
|
|
|
*
|
|
|
|
* This callback is used to check if a specific mode is valid in this
|
|
|
|
* crtc. This should be implemented if the crtc has some sort of
|
|
|
|
* restriction in the modes it can display. For example, a given crtc
|
|
|
|
* may be responsible to set a clock value. If the clock can not
|
|
|
|
* produce all the values for the available modes then this callback
|
|
|
|
* can be used to restrict the number of modes to only the ones that
|
|
|
|
* can be displayed.
|
|
|
|
*
|
|
|
|
* This hook is used by the probe helpers to filter the mode list in
|
|
|
|
* drm_helper_probe_single_connector_modes(), and it is used by the
|
|
|
|
* atomic helpers to validate modes supplied by userspace in
|
|
|
|
* drm_atomic_helper_check_modeset().
|
|
|
|
*
|
|
|
|
* This function is optional.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* Since this function is both called from the check phase of an atomic
|
|
|
|
* commit, and the mode validation in the probe paths it is not allowed
|
|
|
|
* to look at anything else but the passed-in mode, and validate it
|
|
|
|
* against configuration-invariant hardward constraints. Any further
|
|
|
|
* limits which depend upon the configuration can only be checked in
|
|
|
|
* @mode_fixup or @atomic_check.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* drm_mode_status Enum
|
|
|
|
*/
|
|
|
|
enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
|
|
|
|
const struct drm_display_mode *mode);
|
|
|
|
|
2015-12-04 08:46:08 +00:00
|
|
|
/**
|
|
|
|
* @mode_fixup:
|
|
|
|
*
|
|
|
|
* This callback is used to validate a mode. The parameter mode is the
|
|
|
|
* display mode that userspace requested, adjusted_mode is the mode the
|
|
|
|
* encoders need to be fed with. Note that this is the inverse semantics
|
2017-01-25 06:26:43 +00:00
|
|
|
* of the meaning for the &drm_encoder and &drm_bridge_funcs.mode_fixup
|
|
|
|
* vfunc. If the CRTC cannot support the requested conversion from mode
|
2017-05-15 09:11:35 +00:00
|
|
|
* to adjusted_mode it should reject the modeset. See also
|
|
|
|
* &drm_crtc_state.adjusted_mode for more details.
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
|
|
|
* This function is used by both legacy CRTC helpers and atomic helpers.
|
|
|
|
* With atomic helpers it is optional.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* This function is called in the check phase of atomic modesets, which
|
|
|
|
* can be aborted for any reason (including on userspace's request to
|
|
|
|
* just check whether a configuration would be possible). Atomic drivers
|
|
|
|
* MUST NOT touch any persistent state (hardware or software) or data
|
|
|
|
* structures except the passed in adjusted_mode parameter.
|
|
|
|
*
|
|
|
|
* This is in contrast to the legacy CRTC helpers where this was
|
|
|
|
* allowed.
|
|
|
|
*
|
|
|
|
* Atomic drivers which need to inspect and adjust more state should
|
2017-05-15 09:11:36 +00:00
|
|
|
* instead use the @atomic_check callback, but note that they're not
|
|
|
|
* perfectly equivalent: @mode_valid is called from
|
|
|
|
* drm_atomic_helper_check_modeset(), but @atomic_check is called from
|
|
|
|
* drm_atomic_helper_check_planes(), because originally it was meant for
|
|
|
|
* plane update checks only.
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
2017-05-15 09:33:47 +00:00
|
|
|
* Also beware that userspace can request its own custom modes, neither
|
|
|
|
* core nor helpers filter modes to the list of probe modes reported by
|
|
|
|
* the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
|
|
|
|
* that modes are filtered consistently put any CRTC constraints and
|
|
|
|
* limits checks into @mode_valid.
|
2016-01-04 06:53:36 +00:00
|
|
|
*
|
2015-12-04 08:46:08 +00:00
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* True if an acceptable configuration is possible, false if the modeset
|
|
|
|
* operation should be rejected.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
bool (*mode_fixup)(struct drm_crtc *crtc,
|
|
|
|
const struct drm_display_mode *mode,
|
|
|
|
struct drm_display_mode *adjusted_mode);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @mode_set:
|
|
|
|
*
|
|
|
|
* This callback is used by the legacy CRTC helpers to set a new mode,
|
|
|
|
* position and framebuffer. Since it ties the primary plane to every
|
|
|
|
* mode change it is incompatible with universal plane support. And
|
|
|
|
* since it can't update other planes it's incompatible with atomic
|
|
|
|
* modeset support.
|
|
|
|
*
|
|
|
|
* This callback is only used by CRTC helpers and deprecated.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* 0 on success or a negative error code on failure.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
|
|
|
|
struct drm_display_mode *adjusted_mode, int x, int y,
|
|
|
|
struct drm_framebuffer *old_fb);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @mode_set_nofb:
|
|
|
|
*
|
|
|
|
* This callback is used to update the display mode of a CRTC without
|
|
|
|
* changing anything of the primary plane configuration. This fits the
|
|
|
|
* requirement of atomic and hence is used by the atomic helpers. It is
|
|
|
|
* also used by the transitional plane helpers to implement a
|
|
|
|
* @mode_set hook in drm_helper_crtc_mode_set().
|
|
|
|
*
|
|
|
|
* Note that the display pipe is completely off when this function is
|
|
|
|
* called. Atomic drivers which need hardware to be running before they
|
|
|
|
* program the new display mode (e.g. because they implement runtime PM)
|
|
|
|
* should not use this hook. This is because the helper library calls
|
|
|
|
* this hook only once per mode change and not every time the display
|
|
|
|
* pipeline is suspended using either DPMS or the new "ACTIVE" property.
|
|
|
|
* Which means register values set in this callback might get reset when
|
|
|
|
* the CRTC is suspended, but not restored. Such drivers should instead
|
2017-06-30 09:36:44 +00:00
|
|
|
* move all their CRTC setup into the @atomic_enable callback.
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
|
|
|
* This callback is optional.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*mode_set_nofb)(struct drm_crtc *crtc);
|
|
|
|
|
2015-12-04 08:46:08 +00:00
|
|
|
/**
|
|
|
|
* @mode_set_base:
|
|
|
|
*
|
|
|
|
* This callback is used by the legacy CRTC helpers to set a new
|
|
|
|
* framebuffer and scanout position. It is optional and used as an
|
|
|
|
* optimized fast-path instead of a full mode set operation with all the
|
2016-01-04 06:53:36 +00:00
|
|
|
* resulting flickering. If it is not present
|
|
|
|
* drm_crtc_helper_set_config() will fall back to a full modeset, using
|
2017-01-25 06:26:43 +00:00
|
|
|
* the @mode_set callback. Since it can't update other planes it's
|
2015-12-04 08:46:08 +00:00
|
|
|
* incompatible with atomic modeset support.
|
|
|
|
*
|
|
|
|
* This callback is only used by the CRTC helpers and deprecated.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* 0 on success or a negative error code on failure.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
|
|
|
|
struct drm_framebuffer *old_fb);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @mode_set_base_atomic:
|
|
|
|
*
|
|
|
|
* This callback is used by the fbdev helpers to set a new framebuffer
|
|
|
|
* and scanout without sleeping, i.e. from an atomic calling context. It
|
|
|
|
* is only used to implement kgdb support.
|
|
|
|
*
|
|
|
|
* This callback is optional and only needed for kgdb support in the fbdev
|
|
|
|
* helpers.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* 0 on success or a negative error code on failure.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
int (*mode_set_base_atomic)(struct drm_crtc *crtc,
|
|
|
|
struct drm_framebuffer *fb, int x, int y,
|
|
|
|
enum mode_set_atomic);
|
|
|
|
|
2015-12-04 08:46:08 +00:00
|
|
|
/**
|
|
|
|
* @disable:
|
|
|
|
*
|
|
|
|
* This callback should be used to disable the CRTC. With the atomic
|
|
|
|
* drivers it is called after all encoders connected to this CRTC have
|
2017-01-25 06:26:43 +00:00
|
|
|
* been shut off already using their own
|
|
|
|
* &drm_encoder_helper_funcs.disable hook. If that sequence is too
|
|
|
|
* simple drivers can just add their own hooks and call it from this
|
|
|
|
* CRTC callback here by looping over all encoders connected to it using
|
|
|
|
* for_each_encoder_on_crtc().
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
|
|
|
* This hook is used both by legacy CRTC helpers and atomic helpers.
|
|
|
|
* Atomic drivers don't need to implement it if there's no need to
|
|
|
|
* disable anything at the CRTC level. To ensure that runtime PM
|
|
|
|
* handling (using either DPMS or the new "ACTIVE" property) works
|
2017-06-30 09:36:44 +00:00
|
|
|
* @disable must be the inverse of @atomic_enable for atomic drivers.
|
2016-08-26 07:30:38 +00:00
|
|
|
* Atomic drivers should consider to use @atomic_disable instead of
|
|
|
|
* this one.
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* With legacy CRTC helpers there's a big semantic difference between
|
|
|
|
* @disable and other hooks (like @prepare or @dpms) used to shut down a
|
|
|
|
* CRTC: @disable is only called when also logically disabling the
|
|
|
|
* display pipeline and needs to release any resources acquired in
|
|
|
|
* @mode_set (like shared PLLs, or again release pinned framebuffers).
|
|
|
|
*
|
|
|
|
* Therefore @disable must be the inverse of @mode_set plus @commit for
|
|
|
|
* drivers still using legacy CRTC helpers, which is different from the
|
|
|
|
* rules under atomic.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*disable)(struct drm_crtc *crtc);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
2015-12-04 08:46:04 +00:00
|
|
|
/**
|
|
|
|
* @atomic_check:
|
|
|
|
*
|
|
|
|
* Drivers should check plane-update related CRTC constraints in this
|
|
|
|
* hook. They can also check mode related limitations but need to be
|
|
|
|
* aware of the calling order, since this hook is used by
|
|
|
|
* drm_atomic_helper_check_planes() whereas the preparations needed to
|
|
|
|
* check output routing and the display mode is done in
|
|
|
|
* drm_atomic_helper_check_modeset(). Therefore drivers that want to
|
|
|
|
* check output routing and display mode constraints in this callback
|
|
|
|
* must ensure that drm_atomic_helper_check_modeset() has been called
|
|
|
|
* beforehand. This is calling order used by the default helper
|
|
|
|
* implementation in drm_atomic_helper_check().
|
|
|
|
*
|
2017-01-25 06:26:43 +00:00
|
|
|
* When using drm_atomic_helper_check_planes() this hook is called
|
2017-09-01 14:40:41 +00:00
|
|
|
* after the &drm_plane_helper_funcs.atomic_check hook for planes, which
|
2017-01-25 06:26:43 +00:00
|
|
|
* allows drivers to assign shared resources requested by planes in this
|
|
|
|
* callback here. For more complicated dependencies the driver can call
|
|
|
|
* the provided check helpers multiple times until the computed state
|
|
|
|
* has a final configuration and everything has been checked.
|
2015-12-04 08:46:04 +00:00
|
|
|
*
|
|
|
|
* This function is also allowed to inspect any other object's state and
|
|
|
|
* can add more state objects to the atomic commit if needed. Care must
|
2017-01-25 06:26:43 +00:00
|
|
|
* be taken though to ensure that state check and compute functions for
|
2015-12-04 08:46:04 +00:00
|
|
|
* these added states are all called, and derived state in other objects
|
|
|
|
* all updated. Again the recommendation is to just call check helpers
|
|
|
|
* until a maximal configuration is reached.
|
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers and by the
|
|
|
|
* transitional plane helpers, but it is optional.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* This function is called in the check phase of an atomic update. The
|
|
|
|
* driver is not allowed to change anything outside of the free-standing
|
drm/atomic: Pass the full state to CRTC atomic_check
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's start convert all the remaining helpers to provide a consistent
interface, starting with the CRTC's atomic_check.
The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier ret, f;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- ret = FUNCS->atomic_check(crtc, crtc_state);
+ ret = FUNCS->atomic_check(crtc, state);
...>
}
@@
identifier crtc, new_state;
@@
struct drm_crtc_helper_funcs {
...
- int (*atomic_check)(struct drm_crtc *crtc, struct drm_crtc_state *new_state);
+ int (*atomic_check)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};
@ ignores_new_state @
identifier crtc_atomic_func.func;
identifier crtc, new_state;
@@
int func(struct drm_crtc *crtc,
struct drm_crtc_state *new_state)
{
... when != new_state
}
@ adds_new_state depends on crtc_atomic_func && !ignores_new_state @
identifier crtc_atomic_func.func;
identifier crtc, new_state;
@@
int func(struct drm_crtc *crtc, struct drm_crtc_state *new_state)
{
+ struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
int func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
int func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier new_state;
identifier crtc;
@@
int func(struct drm_crtc *crtc,
- struct drm_crtc_state *new_state
+ struct drm_atomic_state *state
)
{ ... }
@@
identifier new_state;
identifier crtc;
@@
int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *new_state
+ struct drm_atomic_state *state
)
{
+ struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
...
}
@@
identifier new_state;
identifier crtc;
@@
int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *new_state
+ struct drm_atomic_state *state
);
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-1-maxime@cerno.tech
2020-10-28 12:32:21 +00:00
|
|
|
* state object passed-in.
|
2015-12-04 08:46:04 +00:00
|
|
|
*
|
2017-05-15 09:33:47 +00:00
|
|
|
* Also beware that userspace can request its own custom modes, neither
|
|
|
|
* core nor helpers filter modes to the list of probe modes reported by
|
|
|
|
* the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
|
|
|
|
* that modes are filtered consistently put any CRTC constraints and
|
|
|
|
* limits checks into @mode_valid.
|
|
|
|
*
|
2015-12-04 08:46:04 +00:00
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* 0 on success, -EINVAL if the state or the transition can't be
|
|
|
|
* supported, -ENOMEM on memory allocation failure and -EDEADLK if an
|
|
|
|
* attempt to obtain another state object ran into a &drm_modeset_lock
|
|
|
|
* deadlock.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
int (*atomic_check)(struct drm_crtc *crtc,
|
drm/atomic: Pass the full state to CRTC atomic_check
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's start convert all the remaining helpers to provide a consistent
interface, starting with the CRTC's atomic_check.
The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier ret, f;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- ret = FUNCS->atomic_check(crtc, crtc_state);
+ ret = FUNCS->atomic_check(crtc, state);
...>
}
@@
identifier crtc, new_state;
@@
struct drm_crtc_helper_funcs {
...
- int (*atomic_check)(struct drm_crtc *crtc, struct drm_crtc_state *new_state);
+ int (*atomic_check)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};
@ ignores_new_state @
identifier crtc_atomic_func.func;
identifier crtc, new_state;
@@
int func(struct drm_crtc *crtc,
struct drm_crtc_state *new_state)
{
... when != new_state
}
@ adds_new_state depends on crtc_atomic_func && !ignores_new_state @
identifier crtc_atomic_func.func;
identifier crtc, new_state;
@@
int func(struct drm_crtc *crtc, struct drm_crtc_state *new_state)
{
+ struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
int func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
int func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier new_state;
identifier crtc;
@@
int func(struct drm_crtc *crtc,
- struct drm_crtc_state *new_state
+ struct drm_atomic_state *state
)
{ ... }
@@
identifier new_state;
identifier crtc;
@@
int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *new_state
+ struct drm_atomic_state *state
)
{
+ struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
...
}
@@
identifier new_state;
identifier crtc;
@@
int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *new_state
+ struct drm_atomic_state *state
);
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-1-maxime@cerno.tech
2020-10-28 12:32:21 +00:00
|
|
|
struct drm_atomic_state *state);
|
2015-12-04 08:46:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_begin:
|
|
|
|
*
|
|
|
|
* Drivers should prepare for an atomic update of multiple planes on
|
|
|
|
* a CRTC in this hook. Depending upon hardware this might be vblank
|
|
|
|
* evasion, blocking updates by setting bits or doing preparatory work
|
|
|
|
* for e.g. manual update display.
|
|
|
|
*
|
|
|
|
* This hook is called before any plane commit functions are called.
|
|
|
|
*
|
|
|
|
* Note that the power state of the display pipe when this function is
|
|
|
|
* called depends upon the exact helpers and calling sequence the driver
|
2016-10-31 17:36:46 +00:00
|
|
|
* has picked. See drm_atomic_helper_commit_planes() for a discussion of
|
|
|
|
* the tradeoffs and variants of plane commit helpers.
|
2015-12-04 08:46:04 +00:00
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers and by the
|
|
|
|
* transitional plane helpers, but it is optional.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*atomic_begin)(struct drm_crtc *crtc,
|
drm/atomic: Pass the full state to CRTC atomic begin and flush
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's start convert all the remaining helpers to provide a consistent
interface, starting with the CRTC's atomic_begin and atomic_flush.
The conversion was done using the coccinelle script below, built tested on
all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier old_crtc_state, old_state;
identifier crtc;
identifier f;
@@
f(struct drm_crtc_state *old_crtc_state)
{
...
struct drm_atomic_state *old_state = old_crtc_state->state;
<...
- FUNCS->atomic_begin(crtc, old_crtc_state);
+ FUNCS->atomic_begin(crtc, old_state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier old_crtc_state, old_state;
identifier crtc;
identifier f;
@@
f(struct drm_crtc_state *old_crtc_state)
{
...
struct drm_atomic_state *old_state = old_crtc_state->state;
<...
- FUNCS->atomic_flush(crtc, old_crtc_state);
+ FUNCS->atomic_flush(crtc, old_state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier f;
@@
f(struct drm_device *dev, struct drm_atomic_state *state, ...)
{
<...
- FUNCS->atomic_begin(crtc, crtc_state);
+ FUNCS->atomic_begin(crtc, state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier f;
@@
f(struct drm_device *dev, struct drm_atomic_state *state, ...)
{
<...
- FUNCS->atomic_flush(crtc, crtc_state);
+ FUNCS->atomic_flush(crtc, state);
...>
}
@@
identifier crtc, old_state;
@@
struct drm_crtc_helper_funcs {
...
- void (*atomic_begin)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_begin)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
- void (*atomic_flush)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_flush)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_begin = func,
...,
};
|
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_flush = func,
...,
};
)
@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
void func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
void func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@@
identifier old_state;
identifier crtc;
@@
void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@@
identifier old_state;
identifier crtc;
@@
void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
);
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{
...
}
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
);
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{
...
}
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
);
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@
void func(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-2-maxime@cerno.tech
2020-10-28 12:32:22 +00:00
|
|
|
struct drm_atomic_state *state);
|
2015-12-04 08:46:04 +00:00
|
|
|
/**
|
|
|
|
* @atomic_flush:
|
|
|
|
*
|
|
|
|
* Drivers should finalize an atomic update of multiple planes on
|
|
|
|
* a CRTC in this hook. Depending upon hardware this might include
|
|
|
|
* checking that vblank evasion was successful, unblocking updates by
|
|
|
|
* setting bits or setting the GO bit to flush out all updates.
|
|
|
|
*
|
|
|
|
* Simple hardware or hardware with special requirements can commit and
|
|
|
|
* flush out all updates for all planes from this hook and forgo all the
|
|
|
|
* other commit hooks for plane updates.
|
|
|
|
*
|
|
|
|
* This hook is called after any plane commit functions are called.
|
|
|
|
*
|
|
|
|
* Note that the power state of the display pipe when this function is
|
|
|
|
* called depends upon the exact helpers and calling sequence the driver
|
2016-10-31 17:36:46 +00:00
|
|
|
* has picked. See drm_atomic_helper_commit_planes() for a discussion of
|
|
|
|
* the tradeoffs and variants of plane commit helpers.
|
2015-12-04 08:46:04 +00:00
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers and by the
|
|
|
|
* transitional plane helpers, but it is optional.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*atomic_flush)(struct drm_crtc *crtc,
|
drm/atomic: Pass the full state to CRTC atomic begin and flush
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's start convert all the remaining helpers to provide a consistent
interface, starting with the CRTC's atomic_begin and atomic_flush.
The conversion was done using the coccinelle script below, built tested on
all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier old_crtc_state, old_state;
identifier crtc;
identifier f;
@@
f(struct drm_crtc_state *old_crtc_state)
{
...
struct drm_atomic_state *old_state = old_crtc_state->state;
<...
- FUNCS->atomic_begin(crtc, old_crtc_state);
+ FUNCS->atomic_begin(crtc, old_state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier old_crtc_state, old_state;
identifier crtc;
identifier f;
@@
f(struct drm_crtc_state *old_crtc_state)
{
...
struct drm_atomic_state *old_state = old_crtc_state->state;
<...
- FUNCS->atomic_flush(crtc, old_crtc_state);
+ FUNCS->atomic_flush(crtc, old_state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier f;
@@
f(struct drm_device *dev, struct drm_atomic_state *state, ...)
{
<...
- FUNCS->atomic_begin(crtc, crtc_state);
+ FUNCS->atomic_begin(crtc, state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier f;
@@
f(struct drm_device *dev, struct drm_atomic_state *state, ...)
{
<...
- FUNCS->atomic_flush(crtc, crtc_state);
+ FUNCS->atomic_flush(crtc, state);
...>
}
@@
identifier crtc, old_state;
@@
struct drm_crtc_helper_funcs {
...
- void (*atomic_begin)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_begin)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
- void (*atomic_flush)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_flush)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_begin = func,
...,
};
|
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_flush = func,
...,
};
)
@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
void func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
void func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@@
identifier old_state;
identifier crtc;
@@
void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@@
identifier old_state;
identifier crtc;
@@
void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
);
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{
...
}
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
);
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{
...
}
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
);
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@
void func(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-2-maxime@cerno.tech
2020-10-28 12:32:22 +00:00
|
|
|
struct drm_atomic_state *state);
|
2016-08-26 07:30:38 +00:00
|
|
|
|
2017-06-30 09:36:44 +00:00
|
|
|
/**
|
|
|
|
* @atomic_enable:
|
|
|
|
*
|
|
|
|
* This callback should be used to enable the CRTC. With the atomic
|
|
|
|
* drivers it is called before all encoders connected to this CRTC are
|
|
|
|
* enabled through the encoder's own &drm_encoder_helper_funcs.enable
|
|
|
|
* hook. If that sequence is too simple drivers can just add their own
|
|
|
|
* hooks and call it from this CRTC callback here by looping over all
|
|
|
|
* encoders connected to it using for_each_encoder_on_crtc().
|
|
|
|
*
|
|
|
|
* This hook is used only by atomic helpers, for symmetry with
|
|
|
|
* @atomic_disable. Atomic drivers don't need to implement it if there's
|
|
|
|
* no need to enable anything at the CRTC level. To ensure that runtime
|
|
|
|
* PM handling (using either DPMS or the new "ACTIVE" property) works
|
|
|
|
* @atomic_enable must be the inverse of @atomic_disable for atomic
|
|
|
|
* drivers.
|
|
|
|
*
|
2019-03-14 18:48:45 +00:00
|
|
|
* This function is optional.
|
2017-06-30 09:36:44 +00:00
|
|
|
*/
|
|
|
|
void (*atomic_enable)(struct drm_crtc *crtc,
|
drm/atomic: Pass the full state to CRTC atomic enable/disable
If the CRTC driver ever needs to access the full DRM state, it can't do so
at atomic_enable / atomic_disable time since drm_atomic_helper_swap_state
will have cleared the pointer from the struct drm_crtc_state to the struct
drm_atomic_state before calling those hooks.
In order to allow that, let's pass the full DRM state to atomic_enable and
atomic_disable. The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@
disable_outputs(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- FUNCS->atomic_disable(crtc, crtc_state);
+ FUNCS->atomic_disable(crtc, state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@
drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- FUNCS->atomic_enable(crtc, crtc_state);
+ FUNCS->atomic_enable(crtc, state);
...>
}
@@
identifier crtc, old_state;
@@
struct drm_crtc_helper_funcs {
...
- void (*atomic_enable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_enable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
- void (*atomic_disable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_disable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_enable = func,
...,
};
|
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
)
@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
void func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
void func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@
void func(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/845aa10ef171fc0ea060495efef142a0c13f7870.1602161031.git-series.maxime@cerno.tech
2020-10-08 12:44:08 +00:00
|
|
|
struct drm_atomic_state *state);
|
2017-06-30 09:36:44 +00:00
|
|
|
|
2016-08-26 07:30:38 +00:00
|
|
|
/**
|
|
|
|
* @atomic_disable:
|
|
|
|
*
|
|
|
|
* This callback should be used to disable the CRTC. With the atomic
|
|
|
|
* drivers it is called after all encoders connected to this CRTC have
|
2017-01-25 06:26:43 +00:00
|
|
|
* been shut off already using their own
|
|
|
|
* &drm_encoder_helper_funcs.disable hook. If that sequence is too
|
|
|
|
* simple drivers can just add their own hooks and call it from this
|
|
|
|
* CRTC callback here by looping over all encoders connected to it using
|
|
|
|
* for_each_encoder_on_crtc().
|
2016-08-26 07:30:38 +00:00
|
|
|
*
|
|
|
|
* This hook is used only by atomic helpers. Atomic drivers don't
|
|
|
|
* need to implement it if there's no need to disable anything at the
|
|
|
|
* CRTC level.
|
|
|
|
*
|
2019-03-14 18:48:45 +00:00
|
|
|
* This function is optional.
|
2016-08-26 07:30:38 +00:00
|
|
|
*/
|
|
|
|
void (*atomic_disable)(struct drm_crtc *crtc,
|
drm/atomic: Pass the full state to CRTC atomic enable/disable
If the CRTC driver ever needs to access the full DRM state, it can't do so
at atomic_enable / atomic_disable time since drm_atomic_helper_swap_state
will have cleared the pointer from the struct drm_crtc_state to the struct
drm_atomic_state before calling those hooks.
In order to allow that, let's pass the full DRM state to atomic_enable and
atomic_disable. The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@
disable_outputs(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- FUNCS->atomic_disable(crtc, crtc_state);
+ FUNCS->atomic_disable(crtc, state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@
drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- FUNCS->atomic_enable(crtc, crtc_state);
+ FUNCS->atomic_enable(crtc, state);
...>
}
@@
identifier crtc, old_state;
@@
struct drm_crtc_helper_funcs {
...
- void (*atomic_enable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_enable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
- void (*atomic_disable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_disable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_enable = func,
...,
};
|
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
)
@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
void func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
void func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@
void func(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/845aa10ef171fc0ea060495efef142a0c13f7870.1602161031.git-series.maxime@cerno.tech
2020-10-08 12:44:08 +00:00
|
|
|
struct drm_atomic_state *state);
|
2020-01-23 13:59:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @get_scanout_position:
|
|
|
|
*
|
|
|
|
* Called by vblank timestamping code.
|
|
|
|
*
|
|
|
|
* Returns the current display scanout position from a CRTC and an
|
|
|
|
* optional accurate ktime_get() timestamp of when the position was
|
|
|
|
* measured. Note that this is a helper callback which is only used
|
2020-01-23 13:59:24 +00:00
|
|
|
* if a driver uses drm_crtc_vblank_helper_get_vblank_timestamp()
|
|
|
|
* for the @drm_crtc_funcs.get_vblank_timestamp callback.
|
2020-01-23 13:59:23 +00:00
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
*
|
|
|
|
* crtc:
|
|
|
|
* The CRTC.
|
|
|
|
* in_vblank_irq:
|
|
|
|
* True when called from drm_crtc_handle_vblank(). Some drivers
|
|
|
|
* need to apply some workarounds for gpu-specific vblank irq
|
|
|
|
* quirks if the flag is set.
|
|
|
|
* vpos:
|
|
|
|
* Target location for current vertical scanout position.
|
|
|
|
* hpos:
|
|
|
|
* Target location for current horizontal scanout position.
|
|
|
|
* stime:
|
|
|
|
* Target location for timestamp taken immediately before
|
|
|
|
* scanout position query. Can be NULL to skip timestamp.
|
|
|
|
* etime:
|
|
|
|
* Target location for timestamp taken immediately after
|
|
|
|
* scanout position query. Can be NULL to skip timestamp.
|
|
|
|
* mode:
|
|
|
|
* Current display timings.
|
|
|
|
*
|
|
|
|
* Returns vpos as a positive number while in active scanout area.
|
|
|
|
* Returns vpos as a negative number inside vblank, counting the number
|
|
|
|
* of scanlines to go until end of vblank, e.g., -1 means "one scanline
|
|
|
|
* until start of active scanout / end of vblank."
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
*
|
|
|
|
* True on success, false if a reliable scanout position counter could
|
|
|
|
* not be read out.
|
|
|
|
*/
|
|
|
|
bool (*get_scanout_position)(struct drm_crtc *crtc,
|
|
|
|
bool in_vblank_irq, int *vpos, int *hpos,
|
|
|
|
ktime_t *stime, ktime_t *etime,
|
|
|
|
const struct drm_display_mode *mode);
|
2015-12-04 08:45:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_crtc_helper_add - sets the helper vtable for a crtc
|
|
|
|
* @crtc: DRM CRTC
|
|
|
|
* @funcs: helper vtable to set for @crtc
|
|
|
|
*/
|
|
|
|
static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
|
|
|
|
const struct drm_crtc_helper_funcs *funcs)
|
|
|
|
{
|
|
|
|
crtc->helper_private = funcs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct drm_encoder_helper_funcs - helper operations for encoders
|
|
|
|
*
|
2015-12-04 08:46:08 +00:00
|
|
|
* These hooks are used by the legacy CRTC helpers, the transitional plane
|
|
|
|
* helpers and the new atomic modesetting helpers.
|
2015-12-04 08:45:44 +00:00
|
|
|
*/
|
|
|
|
struct drm_encoder_helper_funcs {
|
2015-12-04 08:46:08 +00:00
|
|
|
/**
|
|
|
|
* @dpms:
|
|
|
|
*
|
|
|
|
* Callback to control power levels on the encoder. If the mode passed in
|
|
|
|
* is unsupported, the provider must use the next lowest power level.
|
|
|
|
* This is used by the legacy encoder helpers to implement DPMS
|
|
|
|
* functionality in drm_helper_connector_dpms().
|
|
|
|
*
|
|
|
|
* This callback is also used to disable an encoder by calling it with
|
|
|
|
* DRM_MODE_DPMS_OFF if the @disable hook isn't used.
|
|
|
|
*
|
|
|
|
* This callback is used by the legacy CRTC helpers. Atomic helpers
|
|
|
|
* also support using this hook for enabling and disabling an encoder to
|
|
|
|
* facilitate transitions to atomic, but it is deprecated. Instead
|
|
|
|
* @enable and @disable should be used.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*dpms)(struct drm_encoder *encoder, int mode);
|
|
|
|
|
2017-05-15 09:33:47 +00:00
|
|
|
/**
|
|
|
|
* @mode_valid:
|
|
|
|
*
|
|
|
|
* This callback is used to check if a specific mode is valid in this
|
|
|
|
* encoder. This should be implemented if the encoder has some sort
|
|
|
|
* of restriction in the modes it can display. For example, a given
|
|
|
|
* encoder may be responsible to set a clock value. If the clock can
|
|
|
|
* not produce all the values for the available modes then this callback
|
|
|
|
* can be used to restrict the number of modes to only the ones that
|
|
|
|
* can be displayed.
|
|
|
|
*
|
|
|
|
* This hook is used by the probe helpers to filter the mode list in
|
|
|
|
* drm_helper_probe_single_connector_modes(), and it is used by the
|
|
|
|
* atomic helpers to validate modes supplied by userspace in
|
|
|
|
* drm_atomic_helper_check_modeset().
|
|
|
|
*
|
|
|
|
* This function is optional.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* Since this function is both called from the check phase of an atomic
|
|
|
|
* commit, and the mode validation in the probe paths it is not allowed
|
|
|
|
* to look at anything else but the passed-in mode, and validate it
|
|
|
|
* against configuration-invariant hardward constraints. Any further
|
|
|
|
* limits which depend upon the configuration can only be checked in
|
|
|
|
* @mode_fixup or @atomic_check.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* drm_mode_status Enum
|
|
|
|
*/
|
|
|
|
enum drm_mode_status (*mode_valid)(struct drm_encoder *crtc,
|
|
|
|
const struct drm_display_mode *mode);
|
|
|
|
|
2015-12-04 08:46:08 +00:00
|
|
|
/**
|
|
|
|
* @mode_fixup:
|
|
|
|
*
|
|
|
|
* This callback is used to validate and adjust a mode. The parameter
|
|
|
|
* mode is the display mode that should be fed to the next element in
|
|
|
|
* the display chain, either the final &drm_connector or a &drm_bridge.
|
|
|
|
* The parameter adjusted_mode is the input mode the encoder requires. It
|
2017-05-15 09:11:35 +00:00
|
|
|
* can be modified by this callback and does not need to match mode. See
|
|
|
|
* also &drm_crtc_state.adjusted_mode for more details.
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
|
|
|
* This function is used by both legacy CRTC helpers and atomic helpers.
|
2016-02-10 12:15:22 +00:00
|
|
|
* This hook is optional.
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* This function is called in the check phase of atomic modesets, which
|
|
|
|
* can be aborted for any reason (including on userspace's request to
|
|
|
|
* just check whether a configuration would be possible). Atomic drivers
|
|
|
|
* MUST NOT touch any persistent state (hardware or software) or data
|
|
|
|
* structures except the passed in adjusted_mode parameter.
|
|
|
|
*
|
|
|
|
* This is in contrast to the legacy CRTC helpers where this was
|
|
|
|
* allowed.
|
|
|
|
*
|
|
|
|
* Atomic drivers which need to inspect and adjust more state should
|
2017-05-15 09:11:36 +00:00
|
|
|
* instead use the @atomic_check callback. If @atomic_check is used,
|
|
|
|
* this hook isn't called since @atomic_check allows a strict superset
|
|
|
|
* of the functionality of @mode_fixup.
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
2017-05-15 09:33:47 +00:00
|
|
|
* Also beware that userspace can request its own custom modes, neither
|
|
|
|
* core nor helpers filter modes to the list of probe modes reported by
|
|
|
|
* the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
|
|
|
|
* that modes are filtered consistently put any encoder constraints and
|
|
|
|
* limits checks into @mode_valid.
|
2016-01-04 06:53:36 +00:00
|
|
|
*
|
2015-12-04 08:46:08 +00:00
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* True if an acceptable configuration is possible, false if the modeset
|
|
|
|
* operation should be rejected.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
bool (*mode_fixup)(struct drm_encoder *encoder,
|
|
|
|
const struct drm_display_mode *mode,
|
|
|
|
struct drm_display_mode *adjusted_mode);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @prepare:
|
|
|
|
*
|
|
|
|
* This callback should prepare the encoder for a subsequent modeset,
|
|
|
|
* which in practice means the driver should disable the encoder if it
|
|
|
|
* is running. Most drivers ended up implementing this by calling their
|
|
|
|
* @dpms hook with DRM_MODE_DPMS_OFF.
|
|
|
|
*
|
|
|
|
* This callback is used by the legacy CRTC helpers. Atomic helpers
|
|
|
|
* also support using this hook for disabling an encoder to facilitate
|
|
|
|
* transitions to atomic, but it is deprecated. Instead @disable should
|
|
|
|
* be used.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*prepare)(struct drm_encoder *encoder);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @commit:
|
|
|
|
*
|
|
|
|
* This callback should commit the new mode on the encoder after a modeset,
|
|
|
|
* which in practice means the driver should enable the encoder. Most
|
|
|
|
* drivers ended up implementing this by calling their @dpms hook with
|
|
|
|
* DRM_MODE_DPMS_ON.
|
|
|
|
*
|
|
|
|
* This callback is used by the legacy CRTC helpers. Atomic helpers
|
|
|
|
* also support using this hook for enabling an encoder to facilitate
|
|
|
|
* transitions to atomic, but it is deprecated. Instead @enable should
|
|
|
|
* be used.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*commit)(struct drm_encoder *encoder);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @mode_set:
|
|
|
|
*
|
|
|
|
* This callback is used to update the display mode of an encoder.
|
|
|
|
*
|
|
|
|
* Note that the display pipe is completely off when this function is
|
|
|
|
* called. Drivers which need hardware to be running before they program
|
|
|
|
* the new display mode (because they implement runtime PM) should not
|
|
|
|
* use this hook, because the helper library calls it only once and not
|
|
|
|
* every time the display pipeline is suspend using either DPMS or the
|
|
|
|
* new "ACTIVE" property. Such drivers should instead move all their
|
2017-01-25 06:26:43 +00:00
|
|
|
* encoder setup into the @enable callback.
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
|
|
|
* This callback is used both by the legacy CRTC helpers and the atomic
|
|
|
|
* modeset helpers. It is optional in the atomic helpers.
|
2016-07-22 10:20:47 +00:00
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* If the driver uses the atomic modeset helpers and needs to inspect
|
|
|
|
* the connector state or connector display info during mode setting,
|
|
|
|
* @atomic_mode_set can be used instead.
|
2015-12-04 08:46:08 +00:00
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*mode_set)(struct drm_encoder *encoder,
|
|
|
|
struct drm_display_mode *mode,
|
|
|
|
struct drm_display_mode *adjusted_mode);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
2016-07-22 10:20:47 +00:00
|
|
|
/**
|
|
|
|
* @atomic_mode_set:
|
|
|
|
*
|
|
|
|
* This callback is used to update the display mode of an encoder.
|
|
|
|
*
|
|
|
|
* Note that the display pipe is completely off when this function is
|
|
|
|
* called. Drivers which need hardware to be running before they program
|
|
|
|
* the new display mode (because they implement runtime PM) should not
|
|
|
|
* use this hook, because the helper library calls it only once and not
|
|
|
|
* every time the display pipeline is suspended using either DPMS or the
|
|
|
|
* new "ACTIVE" property. Such drivers should instead move all their
|
2017-01-25 06:26:43 +00:00
|
|
|
* encoder setup into the @enable callback.
|
2016-07-22 10:20:47 +00:00
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers in place of the
|
|
|
|
* @mode_set callback, if set by the driver. It is optional and should
|
|
|
|
* be used instead of @mode_set if the driver needs to inspect the
|
|
|
|
* connector state or display info, since there is no direct way to
|
|
|
|
* go from the encoder to the current connector.
|
|
|
|
*/
|
|
|
|
void (*atomic_mode_set)(struct drm_encoder *encoder,
|
|
|
|
struct drm_crtc_state *crtc_state,
|
|
|
|
struct drm_connector_state *conn_state);
|
|
|
|
|
2015-12-04 08:46:08 +00:00
|
|
|
/**
|
|
|
|
* @detect:
|
|
|
|
*
|
|
|
|
* This callback can be used by drivers who want to do detection on the
|
|
|
|
* encoder object instead of in connector functions.
|
|
|
|
*
|
|
|
|
* It is not used by any helper and therefore has purely driver-specific
|
|
|
|
* semantics. New drivers shouldn't use this and instead just implement
|
|
|
|
* their own private callbacks.
|
|
|
|
*
|
|
|
|
* FIXME:
|
|
|
|
*
|
|
|
|
* This should just be converted into a pile of driver vfuncs.
|
|
|
|
* Currently radeon, amdgpu and nouveau are using it.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
enum drm_connector_status (*detect)(struct drm_encoder *encoder,
|
|
|
|
struct drm_connector *connector);
|
2015-12-04 08:46:08 +00:00
|
|
|
|
2019-06-11 20:49:53 +00:00
|
|
|
/**
|
|
|
|
* @atomic_disable:
|
|
|
|
*
|
|
|
|
* This callback should be used to disable the encoder. With the atomic
|
|
|
|
* drivers it is called before this encoder's CRTC has been shut off
|
|
|
|
* using their own &drm_crtc_helper_funcs.atomic_disable hook. If that
|
|
|
|
* sequence is too simple drivers can just add their own driver private
|
|
|
|
* encoder hooks and call them from CRTC's callback by looping over all
|
|
|
|
* encoders connected to it using for_each_encoder_on_crtc().
|
|
|
|
*
|
|
|
|
* This callback is a variant of @disable that provides the atomic state
|
|
|
|
* to the driver. If @atomic_disable is implemented, @disable is not
|
|
|
|
* called by the helpers.
|
|
|
|
*
|
|
|
|
* This hook is only used by atomic helpers. Atomic drivers don't need
|
|
|
|
* to implement it if there's no need to disable anything at the encoder
|
|
|
|
* level. To ensure that runtime PM handling (using either DPMS or the
|
|
|
|
* new "ACTIVE" property) works @atomic_disable must be the inverse of
|
|
|
|
* @atomic_enable.
|
|
|
|
*/
|
|
|
|
void (*atomic_disable)(struct drm_encoder *encoder,
|
|
|
|
struct drm_atomic_state *state);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_enable:
|
|
|
|
*
|
|
|
|
* This callback should be used to enable the encoder. It is called
|
|
|
|
* after this encoder's CRTC has been enabled using their own
|
|
|
|
* &drm_crtc_helper_funcs.atomic_enable hook. If that sequence is
|
|
|
|
* too simple drivers can just add their own driver private encoder
|
|
|
|
* hooks and call them from CRTC's callback by looping over all encoders
|
|
|
|
* connected to it using for_each_encoder_on_crtc().
|
|
|
|
*
|
|
|
|
* This callback is a variant of @enable that provides the atomic state
|
|
|
|
* to the driver. If @atomic_enable is implemented, @enable is not
|
|
|
|
* called by the helpers.
|
|
|
|
*
|
|
|
|
* This hook is only used by atomic helpers, it is the opposite of
|
|
|
|
* @atomic_disable. Atomic drivers don't need to implement it if there's
|
|
|
|
* no need to enable anything at the encoder level. To ensure that
|
|
|
|
* runtime PM handling works @atomic_enable must be the inverse of
|
|
|
|
* @atomic_disable.
|
|
|
|
*/
|
|
|
|
void (*atomic_enable)(struct drm_encoder *encoder,
|
|
|
|
struct drm_atomic_state *state);
|
|
|
|
|
2015-12-04 08:46:08 +00:00
|
|
|
/**
|
|
|
|
* @disable:
|
|
|
|
*
|
|
|
|
* This callback should be used to disable the encoder. With the atomic
|
|
|
|
* drivers it is called before this encoder's CRTC has been shut off
|
2017-01-25 06:26:43 +00:00
|
|
|
* using their own &drm_crtc_helper_funcs.disable hook. If that
|
|
|
|
* sequence is too simple drivers can just add their own driver private
|
|
|
|
* encoder hooks and call them from CRTC's callback by looping over all
|
|
|
|
* encoders connected to it using for_each_encoder_on_crtc().
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
|
|
|
* This hook is used both by legacy CRTC helpers and atomic helpers.
|
|
|
|
* Atomic drivers don't need to implement it if there's no need to
|
|
|
|
* disable anything at the encoder level. To ensure that runtime PM
|
|
|
|
* handling (using either DPMS or the new "ACTIVE" property) works
|
|
|
|
* @disable must be the inverse of @enable for atomic drivers.
|
|
|
|
*
|
2019-06-11 20:49:53 +00:00
|
|
|
* For atomic drivers also consider @atomic_disable and save yourself
|
|
|
|
* from having to read the NOTE below!
|
|
|
|
*
|
2015-12-04 08:46:08 +00:00
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* With legacy CRTC helpers there's a big semantic difference between
|
|
|
|
* @disable and other hooks (like @prepare or @dpms) used to shut down a
|
|
|
|
* encoder: @disable is only called when also logically disabling the
|
|
|
|
* display pipeline and needs to release any resources acquired in
|
|
|
|
* @mode_set (like shared PLLs, or again release pinned framebuffers).
|
|
|
|
*
|
|
|
|
* Therefore @disable must be the inverse of @mode_set plus @commit for
|
|
|
|
* drivers still using legacy CRTC helpers, which is different from the
|
|
|
|
* rules under atomic.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*disable)(struct drm_encoder *encoder);
|
|
|
|
|
2015-12-04 08:46:08 +00:00
|
|
|
/**
|
|
|
|
* @enable:
|
|
|
|
*
|
|
|
|
* This callback should be used to enable the encoder. With the atomic
|
|
|
|
* drivers it is called after this encoder's CRTC has been enabled using
|
2017-01-25 06:26:43 +00:00
|
|
|
* their own &drm_crtc_helper_funcs.enable hook. If that sequence is
|
|
|
|
* too simple drivers can just add their own driver private encoder
|
|
|
|
* hooks and call them from CRTC's callback by looping over all encoders
|
|
|
|
* connected to it using for_each_encoder_on_crtc().
|
2015-12-04 08:46:08 +00:00
|
|
|
*
|
2019-06-12 15:00:34 +00:00
|
|
|
* This hook is only used by atomic helpers, it is the opposite of
|
|
|
|
* @disable. Atomic drivers don't need to implement it if there's no
|
|
|
|
* need to enable anything at the encoder level. To ensure that
|
|
|
|
* runtime PM handling (using either DPMS or the new "ACTIVE" property)
|
|
|
|
* works @enable must be the inverse of @disable for atomic drivers.
|
2015-12-04 08:46:08 +00:00
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*enable)(struct drm_encoder *encoder);
|
|
|
|
|
2015-12-04 08:46:08 +00:00
|
|
|
/**
|
|
|
|
* @atomic_check:
|
|
|
|
*
|
|
|
|
* This callback is used to validate encoder state for atomic drivers.
|
|
|
|
* Since the encoder is the object connecting the CRTC and connector it
|
|
|
|
* gets passed both states, to be able to validate interactions and
|
|
|
|
* update the CRTC to match what the encoder needs for the requested
|
|
|
|
* connector.
|
|
|
|
*
|
2017-05-15 09:11:36 +00:00
|
|
|
* Since this provides a strict superset of the functionality of
|
|
|
|
* @mode_fixup (the requested and adjusted modes are both available
|
|
|
|
* through the passed in &struct drm_crtc_state) @mode_fixup is not
|
|
|
|
* called when @atomic_check is implemented.
|
|
|
|
*
|
2015-12-04 08:46:08 +00:00
|
|
|
* This function is used by the atomic helpers, but it is optional.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* This function is called in the check phase of an atomic update. The
|
|
|
|
* driver is not allowed to change anything outside of the free-standing
|
|
|
|
* state objects passed-in or assembled in the overall &drm_atomic_state
|
|
|
|
* update tracking structure.
|
|
|
|
*
|
2017-05-15 09:33:47 +00:00
|
|
|
* Also beware that userspace can request its own custom modes, neither
|
|
|
|
* core nor helpers filter modes to the list of probe modes reported by
|
|
|
|
* the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
|
|
|
|
* that modes are filtered consistently put any encoder constraints and
|
|
|
|
* limits checks into @mode_valid.
|
|
|
|
*
|
2015-12-04 08:46:08 +00:00
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* 0 on success, -EINVAL if the state or the transition can't be
|
|
|
|
* supported, -ENOMEM on memory allocation failure and -EDEADLK if an
|
|
|
|
* attempt to obtain another state object ran into a &drm_modeset_lock
|
|
|
|
* deadlock.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
int (*atomic_check)(struct drm_encoder *encoder,
|
|
|
|
struct drm_crtc_state *crtc_state,
|
|
|
|
struct drm_connector_state *conn_state);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2015-12-04 08:46:08 +00:00
|
|
|
* drm_encoder_helper_add - sets the helper vtable for an encoder
|
2015-12-04 08:45:44 +00:00
|
|
|
* @encoder: DRM encoder
|
|
|
|
* @funcs: helper vtable to set for @encoder
|
|
|
|
*/
|
|
|
|
static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
|
|
|
|
const struct drm_encoder_helper_funcs *funcs)
|
|
|
|
{
|
|
|
|
encoder->helper_private = funcs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct drm_connector_helper_funcs - helper operations for connectors
|
|
|
|
*
|
2015-12-04 08:46:05 +00:00
|
|
|
* These functions are used by the atomic and legacy modeset helpers and by the
|
|
|
|
* probe helpers.
|
2015-12-04 08:45:44 +00:00
|
|
|
*/
|
|
|
|
struct drm_connector_helper_funcs {
|
2015-12-04 08:46:05 +00:00
|
|
|
/**
|
|
|
|
* @get_modes:
|
|
|
|
*
|
|
|
|
* This function should fill in all modes currently valid for the sink
|
2017-01-25 06:26:43 +00:00
|
|
|
* into the &drm_connector.probed_modes list. It should also update the
|
2018-07-09 08:40:06 +00:00
|
|
|
* EDID property by calling drm_connector_update_edid_property().
|
2015-12-04 08:46:05 +00:00
|
|
|
*
|
|
|
|
* The usual way to implement this is to cache the EDID retrieved in the
|
|
|
|
* probe callback somewhere in the driver-private connector structure.
|
|
|
|
* In this function drivers then parse the modes in the EDID and add
|
2013-06-14 00:55:25 +00:00
|
|
|
* them by calling drm_add_edid_modes(). But connectors that drive a
|
2015-12-04 08:46:05 +00:00
|
|
|
* fixed panel can also manually add specific modes using
|
2016-01-04 06:53:36 +00:00
|
|
|
* drm_mode_probed_add(). Drivers which manually add modes should also
|
2017-01-25 06:26:43 +00:00
|
|
|
* make sure that the &drm_connector.display_info,
|
|
|
|
* &drm_connector.width_mm and &drm_connector.height_mm fields are
|
|
|
|
* filled in.
|
2016-01-04 06:53:36 +00:00
|
|
|
*
|
2013-06-14 00:55:25 +00:00
|
|
|
* Note that the caller function will automatically add standard VESA
|
|
|
|
* DMT modes up to 1024x768 if the .get_modes() helper operation returns
|
|
|
|
* no mode and if the connector status is connector_status_connected or
|
|
|
|
* connector_status_unknown. There is no need to call
|
|
|
|
* drm_add_modes_noedid() manually in that case.
|
2016-01-04 06:53:36 +00:00
|
|
|
*
|
|
|
|
* Virtual drivers that just want some standard VESA mode with a given
|
|
|
|
* resolution can call drm_add_modes_noedid(), and mark the preferred
|
|
|
|
* one using drm_set_preferred_mode().
|
|
|
|
*
|
2017-01-25 06:26:43 +00:00
|
|
|
* This function is only called after the @detect hook has indicated
|
2015-12-04 08:46:05 +00:00
|
|
|
* that a sink is connected and when the EDID isn't overridden through
|
|
|
|
* sysfs or the kernel commandline.
|
|
|
|
*
|
|
|
|
* This callback is used by the probe helpers in e.g.
|
|
|
|
* drm_helper_probe_single_connector_modes().
|
|
|
|
*
|
2017-04-06 18:55:20 +00:00
|
|
|
* To avoid races with concurrent connector state updates, the helper
|
|
|
|
* libraries always call this with the &drm_mode_config.connection_mutex
|
|
|
|
* held. Because of this it's safe to inspect &drm_connector->state.
|
|
|
|
*
|
2015-12-04 08:46:05 +00:00
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* The number of modes added by calling drm_mode_probed_add().
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
int (*get_modes)(struct drm_connector *connector);
|
2015-12-04 08:46:05 +00:00
|
|
|
|
2017-04-06 18:55:20 +00:00
|
|
|
/**
|
|
|
|
* @detect_ctx:
|
|
|
|
*
|
|
|
|
* Check to see if anything is attached to the connector. The parameter
|
|
|
|
* force is set to false whilst polling, true when checking the
|
|
|
|
* connector due to a user request. force can be used by the driver to
|
|
|
|
* avoid expensive, destructive operations during automated probing.
|
|
|
|
*
|
|
|
|
* This callback is optional, if not implemented the connector will be
|
|
|
|
* considered as always being attached.
|
|
|
|
*
|
|
|
|
* This is the atomic version of &drm_connector_funcs.detect.
|
|
|
|
*
|
|
|
|
* To avoid races against concurrent connector state updates, the
|
|
|
|
* helper libraries always call this with ctx set to a valid context,
|
|
|
|
* and &drm_mode_config.connection_mutex will always be locked with
|
|
|
|
* the ctx parameter set to this ctx. This allows taking additional
|
|
|
|
* locks as required.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* &drm_connector_status indicating the connector's status,
|
|
|
|
* or the error code returned by drm_modeset_lock(), -EDEADLK.
|
|
|
|
*/
|
|
|
|
int (*detect_ctx)(struct drm_connector *connector,
|
|
|
|
struct drm_modeset_acquire_ctx *ctx,
|
|
|
|
bool force);
|
|
|
|
|
2015-12-04 08:46:05 +00:00
|
|
|
/**
|
|
|
|
* @mode_valid:
|
|
|
|
*
|
|
|
|
* Callback to validate a mode for a connector, irrespective of the
|
|
|
|
* specific display configuration.
|
|
|
|
*
|
|
|
|
* This callback is used by the probe helpers to filter the mode list
|
|
|
|
* (which is usually derived from the EDID data block from the sink).
|
|
|
|
* See e.g. drm_helper_probe_single_connector_modes().
|
|
|
|
*
|
2017-05-15 09:33:47 +00:00
|
|
|
* This function is optional.
|
|
|
|
*
|
2015-12-04 08:46:05 +00:00
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* This only filters the mode list supplied to userspace in the
|
2017-05-15 09:33:47 +00:00
|
|
|
* GETCONNECTOR IOCTL. Compared to &drm_encoder_helper_funcs.mode_valid,
|
|
|
|
* &drm_crtc_helper_funcs.mode_valid and &drm_bridge_funcs.mode_valid,
|
|
|
|
* which are also called by the atomic helpers from
|
|
|
|
* drm_atomic_helper_check_modeset(). This allows userspace to force and
|
|
|
|
* ignore sink constraint (like the pixel clock limits in the screen's
|
|
|
|
* EDID), which is useful for e.g. testing, or working around a broken
|
|
|
|
* EDID. Any source hardware constraint (which always need to be
|
|
|
|
* enforced) therefore should be checked in one of the above callbacks,
|
|
|
|
* and not this one here.
|
2015-12-04 08:46:05 +00:00
|
|
|
*
|
2017-04-06 18:55:20 +00:00
|
|
|
* To avoid races with concurrent connector state updates, the helper
|
|
|
|
* libraries always call this with the &drm_mode_config.connection_mutex
|
|
|
|
* held. Because of this it's safe to inspect &drm_connector->state.
|
|
|
|
*
|
2015-12-04 08:46:05 +00:00
|
|
|
* RETURNS:
|
|
|
|
*
|
2017-01-25 06:26:43 +00:00
|
|
|
* Either &drm_mode_status.MODE_OK or one of the failure reasons in &enum
|
|
|
|
* drm_mode_status.
|
2015-12-04 08:46:05 +00:00
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
|
|
|
|
struct drm_display_mode *mode);
|
2020-07-13 17:07:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @mode_valid_ctx:
|
|
|
|
*
|
|
|
|
* Callback to validate a mode for a connector, irrespective of the
|
|
|
|
* specific display configuration.
|
|
|
|
*
|
|
|
|
* This callback is used by the probe helpers to filter the mode list
|
|
|
|
* (which is usually derived from the EDID data block from the sink).
|
|
|
|
* See e.g. drm_helper_probe_single_connector_modes().
|
|
|
|
*
|
|
|
|
* This function is optional, and is the atomic version of
|
|
|
|
* &drm_connector_helper_funcs.mode_valid.
|
|
|
|
*
|
|
|
|
* To allow for accessing the atomic state of modesetting objects, the
|
|
|
|
* helper libraries always call this with ctx set to a valid context,
|
|
|
|
* and &drm_mode_config.connection_mutex will always be locked with
|
|
|
|
* the ctx parameter set to @ctx. This allows for taking additional
|
|
|
|
* locks as required.
|
|
|
|
*
|
|
|
|
* Even though additional locks may be acquired, this callback is
|
|
|
|
* still expected not to take any constraints into account which would
|
|
|
|
* be influenced by the currently set display state - such constraints
|
|
|
|
* should be handled in the driver's atomic check. For example, if a
|
|
|
|
* connector shares display bandwidth with other connectors then it
|
|
|
|
* would be ok to validate the minimum bandwidth requirement of a mode
|
|
|
|
* against the maximum possible bandwidth of the connector. But it
|
|
|
|
* wouldn't be ok to take the current bandwidth usage of other
|
|
|
|
* connectors into account, as this would change depending on the
|
|
|
|
* display state.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 if &drm_connector_helper_funcs.mode_valid_ctx succeeded and wrote
|
|
|
|
* the &enum drm_mode_status value to @status, or a negative error
|
|
|
|
* code otherwise.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int (*mode_valid_ctx)(struct drm_connector *connector,
|
|
|
|
struct drm_display_mode *mode,
|
|
|
|
struct drm_modeset_acquire_ctx *ctx,
|
|
|
|
enum drm_mode_status *status);
|
|
|
|
|
2015-12-04 08:46:05 +00:00
|
|
|
/**
|
|
|
|
* @best_encoder:
|
|
|
|
*
|
|
|
|
* This function should select the best encoder for the given connector.
|
|
|
|
*
|
|
|
|
* This function is used by both the atomic helpers (in the
|
|
|
|
* drm_atomic_helper_check_modeset() function) and in the legacy CRTC
|
|
|
|
* helpers.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* In atomic drivers this function is called in the check phase of an
|
|
|
|
* atomic update. The driver is not allowed to change or inspect
|
|
|
|
* anything outside of arguments passed-in. Atomic drivers which need to
|
|
|
|
* inspect dynamic configuration state should instead use
|
|
|
|
* @atomic_best_encoder.
|
|
|
|
*
|
2016-06-07 11:47:56 +00:00
|
|
|
* You can leave this function to NULL if the connector is only
|
2019-09-13 23:28:56 +00:00
|
|
|
* attached to a single encoder. In this case, the core will call
|
|
|
|
* drm_connector_get_single_encoder() for you.
|
2016-06-07 11:47:56 +00:00
|
|
|
*
|
2015-12-04 08:46:05 +00:00
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* Encoder that should be used for the given connector and connector
|
|
|
|
* state, or NULL if no suitable encoder exists. Note that the helpers
|
|
|
|
* will ensure that encoders aren't used twice, drivers should not check
|
|
|
|
* for this.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
|
2015-12-04 08:46:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_best_encoder:
|
|
|
|
*
|
|
|
|
* This is the atomic version of @best_encoder for atomic drivers which
|
|
|
|
* need to select the best encoder depending upon the desired
|
|
|
|
* configuration and can't select it statically.
|
|
|
|
*
|
2016-06-07 11:47:56 +00:00
|
|
|
* This function is used by drm_atomic_helper_check_modeset().
|
|
|
|
* If it is not implemented, the core will fallback to @best_encoder
|
2019-09-13 23:28:56 +00:00
|
|
|
* (or drm_connector_get_single_encoder() if @best_encoder is NULL).
|
2015-12-04 08:46:05 +00:00
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* This function is called in the check phase of an atomic update. The
|
drm: Pass the full state to connectors atomic functions
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Now that the CRTCs have been converted, let's move forward with the
connectors to provide a consistent interface.
The conversion was done using the coccinelle script below, and built tested
on all the drivers.
@@
identifier connector, connector_state;
@@
struct drm_connector_helper_funcs {
...
struct drm_encoder* (*atomic_best_encoder)(struct drm_connector *connector,
- struct drm_connector_state *connector_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier connector, connector_state;
@@
struct drm_connector_helper_funcs {
...
void (*atomic_commit)(struct drm_connector *connector,
- struct drm_connector_state *connector_state);
+ struct drm_atomic_state *state);
...
}
@@
struct drm_connector_helper_funcs *FUNCS;
identifier state;
identifier connector, connector_state;
identifier f;
@@
f(..., struct drm_atomic_state *state, ...)
{
<+...
- FUNCS->atomic_commit(connector, connector_state);
+ FUNCS->atomic_commit(connector, state);
...+>
}
@@
struct drm_connector_helper_funcs *FUNCS;
identifier state;
identifier connector, connector_state;
identifier var, f;
@@
f(struct drm_atomic_state *state, ...)
{
<+...
- var = FUNCS->atomic_best_encoder(connector, connector_state);
+ var = FUNCS->atomic_best_encoder(connector, state);
...+>
}
@ connector_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_connector_helper_funcs helpers = {
...,
.atomic_best_encoder = func,
...,
};
|
static struct drm_connector_helper_funcs helpers = {
...,
.atomic_commit = func,
...,
};
)
@@
identifier connector_atomic_func.func;
identifier connector;
symbol state;
@@
func(struct drm_connector *connector,
- struct drm_connector_state *state
+ struct drm_connector_state *connector_state
)
{
...
- state
+ connector_state
...
}
@ ignores_state @
identifier connector_atomic_func.func;
identifier connector, connector_state;
@@
func(struct drm_connector *connector,
struct drm_connector_state *connector_state)
{
... when != connector_state
}
@ adds_state depends on connector_atomic_func && !ignores_state @
identifier connector_atomic_func.func;
identifier connector, connector_state;
@@
func(struct drm_connector *connector, struct drm_connector_state *connector_state)
{
+ struct drm_connector_state *connector_state = drm_atomic_get_new_connector_state(state, connector);
...
}
@ depends on connector_atomic_func @
identifier connector_atomic_func.func;
identifier connector_state;
identifier connector;
@@
func(struct drm_connector *connector,
- struct drm_connector_state *connector_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: Melissa Wen <melissa.srw@gmail.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201118094758.506730-1-maxime@cerno.tech
2020-11-18 09:47:58 +00:00
|
|
|
* driver is not allowed to change anything outside of the
|
|
|
|
* &drm_atomic_state update tracking structure passed in.
|
2015-12-04 08:46:05 +00:00
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* Encoder that should be used for the given connector and connector
|
|
|
|
* state, or NULL if no suitable encoder exists. Note that the helpers
|
|
|
|
* will ensure that encoders aren't used twice, drivers should not check
|
|
|
|
* for this.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,
|
drm: Pass the full state to connectors atomic functions
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Now that the CRTCs have been converted, let's move forward with the
connectors to provide a consistent interface.
The conversion was done using the coccinelle script below, and built tested
on all the drivers.
@@
identifier connector, connector_state;
@@
struct drm_connector_helper_funcs {
...
struct drm_encoder* (*atomic_best_encoder)(struct drm_connector *connector,
- struct drm_connector_state *connector_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier connector, connector_state;
@@
struct drm_connector_helper_funcs {
...
void (*atomic_commit)(struct drm_connector *connector,
- struct drm_connector_state *connector_state);
+ struct drm_atomic_state *state);
...
}
@@
struct drm_connector_helper_funcs *FUNCS;
identifier state;
identifier connector, connector_state;
identifier f;
@@
f(..., struct drm_atomic_state *state, ...)
{
<+...
- FUNCS->atomic_commit(connector, connector_state);
+ FUNCS->atomic_commit(connector, state);
...+>
}
@@
struct drm_connector_helper_funcs *FUNCS;
identifier state;
identifier connector, connector_state;
identifier var, f;
@@
f(struct drm_atomic_state *state, ...)
{
<+...
- var = FUNCS->atomic_best_encoder(connector, connector_state);
+ var = FUNCS->atomic_best_encoder(connector, state);
...+>
}
@ connector_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_connector_helper_funcs helpers = {
...,
.atomic_best_encoder = func,
...,
};
|
static struct drm_connector_helper_funcs helpers = {
...,
.atomic_commit = func,
...,
};
)
@@
identifier connector_atomic_func.func;
identifier connector;
symbol state;
@@
func(struct drm_connector *connector,
- struct drm_connector_state *state
+ struct drm_connector_state *connector_state
)
{
...
- state
+ connector_state
...
}
@ ignores_state @
identifier connector_atomic_func.func;
identifier connector, connector_state;
@@
func(struct drm_connector *connector,
struct drm_connector_state *connector_state)
{
... when != connector_state
}
@ adds_state depends on connector_atomic_func && !ignores_state @
identifier connector_atomic_func.func;
identifier connector, connector_state;
@@
func(struct drm_connector *connector, struct drm_connector_state *connector_state)
{
+ struct drm_connector_state *connector_state = drm_atomic_get_new_connector_state(state, connector);
...
}
@ depends on connector_atomic_func @
identifier connector_atomic_func.func;
identifier connector_state;
identifier connector;
@@
func(struct drm_connector *connector,
- struct drm_connector_state *connector_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: Melissa Wen <melissa.srw@gmail.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201118094758.506730-1-maxime@cerno.tech
2020-11-18 09:47:58 +00:00
|
|
|
struct drm_atomic_state *state);
|
2017-04-06 11:19:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_check:
|
|
|
|
*
|
|
|
|
* This hook is used to validate connector state. This function is
|
|
|
|
* called from &drm_atomic_helper_check_modeset, and is called when
|
|
|
|
* a connector property is set, or a modeset on the crtc is forced.
|
|
|
|
*
|
|
|
|
* Because &drm_atomic_helper_check_modeset may be called multiple times,
|
|
|
|
* this function should handle being called multiple times as well.
|
|
|
|
*
|
|
|
|
* This function is also allowed to inspect any other object's state and
|
|
|
|
* can add more state objects to the atomic commit if needed. Care must
|
|
|
|
* be taken though to ensure that state check and compute functions for
|
|
|
|
* these added states are all called, and derived state in other objects
|
|
|
|
* all updated. Again the recommendation is to just call check helpers
|
|
|
|
* until a maximal configuration is reached.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* This function is called in the check phase of an atomic update. The
|
|
|
|
* driver is not allowed to change anything outside of the free-standing
|
|
|
|
* state objects passed-in or assembled in the overall &drm_atomic_state
|
|
|
|
* update tracking structure.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* 0 on success, -EINVAL if the state or the transition can't be
|
|
|
|
* supported, -ENOMEM on memory allocation failure and -EDEADLK if an
|
|
|
|
* attempt to obtain another state object ran into a &drm_modeset_lock
|
|
|
|
* deadlock.
|
|
|
|
*/
|
|
|
|
int (*atomic_check)(struct drm_connector *connector,
|
2019-06-11 16:08:18 +00:00
|
|
|
struct drm_atomic_state *state);
|
2017-03-29 16:42:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_commit:
|
|
|
|
*
|
|
|
|
* This hook is to be used by drivers implementing writeback connectors
|
|
|
|
* that need a point when to commit the writeback job to the hardware.
|
drm: Pass the full state to connectors atomic functions
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Now that the CRTCs have been converted, let's move forward with the
connectors to provide a consistent interface.
The conversion was done using the coccinelle script below, and built tested
on all the drivers.
@@
identifier connector, connector_state;
@@
struct drm_connector_helper_funcs {
...
struct drm_encoder* (*atomic_best_encoder)(struct drm_connector *connector,
- struct drm_connector_state *connector_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier connector, connector_state;
@@
struct drm_connector_helper_funcs {
...
void (*atomic_commit)(struct drm_connector *connector,
- struct drm_connector_state *connector_state);
+ struct drm_atomic_state *state);
...
}
@@
struct drm_connector_helper_funcs *FUNCS;
identifier state;
identifier connector, connector_state;
identifier f;
@@
f(..., struct drm_atomic_state *state, ...)
{
<+...
- FUNCS->atomic_commit(connector, connector_state);
+ FUNCS->atomic_commit(connector, state);
...+>
}
@@
struct drm_connector_helper_funcs *FUNCS;
identifier state;
identifier connector, connector_state;
identifier var, f;
@@
f(struct drm_atomic_state *state, ...)
{
<+...
- var = FUNCS->atomic_best_encoder(connector, connector_state);
+ var = FUNCS->atomic_best_encoder(connector, state);
...+>
}
@ connector_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_connector_helper_funcs helpers = {
...,
.atomic_best_encoder = func,
...,
};
|
static struct drm_connector_helper_funcs helpers = {
...,
.atomic_commit = func,
...,
};
)
@@
identifier connector_atomic_func.func;
identifier connector;
symbol state;
@@
func(struct drm_connector *connector,
- struct drm_connector_state *state
+ struct drm_connector_state *connector_state
)
{
...
- state
+ connector_state
...
}
@ ignores_state @
identifier connector_atomic_func.func;
identifier connector, connector_state;
@@
func(struct drm_connector *connector,
struct drm_connector_state *connector_state)
{
... when != connector_state
}
@ adds_state depends on connector_atomic_func && !ignores_state @
identifier connector_atomic_func.func;
identifier connector, connector_state;
@@
func(struct drm_connector *connector, struct drm_connector_state *connector_state)
{
+ struct drm_connector_state *connector_state = drm_atomic_get_new_connector_state(state, connector);
...
}
@ depends on connector_atomic_func @
identifier connector_atomic_func.func;
identifier connector_state;
identifier connector;
@@
func(struct drm_connector *connector,
- struct drm_connector_state *connector_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: Melissa Wen <melissa.srw@gmail.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201118094758.506730-1-maxime@cerno.tech
2020-11-18 09:47:58 +00:00
|
|
|
* The writeback_job to commit is available in the new connector state,
|
|
|
|
* in &drm_connector_state.writeback_job.
|
2017-03-29 16:42:32 +00:00
|
|
|
*
|
2018-07-03 07:50:17 +00:00
|
|
|
* This hook is optional.
|
|
|
|
*
|
2017-03-29 16:42:32 +00:00
|
|
|
* This callback is used by the atomic modeset helpers.
|
|
|
|
*/
|
|
|
|
void (*atomic_commit)(struct drm_connector *connector,
|
drm: Pass the full state to connectors atomic functions
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Now that the CRTCs have been converted, let's move forward with the
connectors to provide a consistent interface.
The conversion was done using the coccinelle script below, and built tested
on all the drivers.
@@
identifier connector, connector_state;
@@
struct drm_connector_helper_funcs {
...
struct drm_encoder* (*atomic_best_encoder)(struct drm_connector *connector,
- struct drm_connector_state *connector_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier connector, connector_state;
@@
struct drm_connector_helper_funcs {
...
void (*atomic_commit)(struct drm_connector *connector,
- struct drm_connector_state *connector_state);
+ struct drm_atomic_state *state);
...
}
@@
struct drm_connector_helper_funcs *FUNCS;
identifier state;
identifier connector, connector_state;
identifier f;
@@
f(..., struct drm_atomic_state *state, ...)
{
<+...
- FUNCS->atomic_commit(connector, connector_state);
+ FUNCS->atomic_commit(connector, state);
...+>
}
@@
struct drm_connector_helper_funcs *FUNCS;
identifier state;
identifier connector, connector_state;
identifier var, f;
@@
f(struct drm_atomic_state *state, ...)
{
<+...
- var = FUNCS->atomic_best_encoder(connector, connector_state);
+ var = FUNCS->atomic_best_encoder(connector, state);
...+>
}
@ connector_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_connector_helper_funcs helpers = {
...,
.atomic_best_encoder = func,
...,
};
|
static struct drm_connector_helper_funcs helpers = {
...,
.atomic_commit = func,
...,
};
)
@@
identifier connector_atomic_func.func;
identifier connector;
symbol state;
@@
func(struct drm_connector *connector,
- struct drm_connector_state *state
+ struct drm_connector_state *connector_state
)
{
...
- state
+ connector_state
...
}
@ ignores_state @
identifier connector_atomic_func.func;
identifier connector, connector_state;
@@
func(struct drm_connector *connector,
struct drm_connector_state *connector_state)
{
... when != connector_state
}
@ adds_state depends on connector_atomic_func && !ignores_state @
identifier connector_atomic_func.func;
identifier connector, connector_state;
@@
func(struct drm_connector *connector, struct drm_connector_state *connector_state)
{
+ struct drm_connector_state *connector_state = drm_atomic_get_new_connector_state(state, connector);
...
}
@ depends on connector_atomic_func @
identifier connector_atomic_func.func;
identifier connector_state;
identifier connector;
@@
func(struct drm_connector *connector,
- struct drm_connector_state *connector_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: Melissa Wen <melissa.srw@gmail.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201118094758.506730-1-maxime@cerno.tech
2020-11-18 09:47:58 +00:00
|
|
|
struct drm_atomic_state *state);
|
drm: writeback: Add job prepare and cleanup operations
As writeback jobs contain a framebuffer, drivers may need to prepare and
cleanup them the same way they can prepare and cleanup framebuffers for
planes. Add two new optional connector helper operations,
.prepare_writeback_job() and .cleanup_writeback_job() to support this.
The job prepare operation is called from
drm_atomic_helper_prepare_planes() to avoid a new atomic commit helper
that would need to be called by all drivers not using
drm_atomic_helper_commit(). The job cleanup operation is called from the
existing drm_writeback_cleanup_job() function, invoked both when
destroying the job as part of a aborted commit, or when the job
completes.
The drm_writeback_job structure is extended with a priv field to let
drivers store per-job data, such as mappings related to the writeback
framebuffer.
For internal plumbing reasons the drm_writeback_job structure needs to
store a back-pointer to the drm_writeback_connector. To avoid pushing
too much writeback-specific knowledge to drm_atomic_uapi.c, create a
drm_writeback_set_fb() function, move the writeback job setup code
there, and set the connector backpointer. The prepare_signaling()
function doesn't need to allocate writeback jobs and can ignore
connectors without a job, as it is called after the writeback jobs are
allocated to store framebuffers, and a writeback fence with a
framebuffer is an invalid configuration that gets rejected by the commit
check.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
2019-02-21 01:01:38 +00:00
|
|
|
|
2020-04-06 19:47:45 +00:00
|
|
|
/**
|
|
|
|
* @prepare_writeback_job:
|
|
|
|
*
|
|
|
|
* As writeback jobs contain a framebuffer, drivers may need to
|
|
|
|
* prepare and clean them up the same way they can prepare and
|
|
|
|
* clean up framebuffers for planes. This optional connector operation
|
|
|
|
* is used to support the preparation of writeback jobs. The job
|
|
|
|
* prepare operation is called from drm_atomic_helper_prepare_planes()
|
|
|
|
* for struct &drm_writeback_connector connectors only.
|
|
|
|
*
|
|
|
|
* This operation is optional.
|
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers.
|
|
|
|
*/
|
drm: writeback: Add job prepare and cleanup operations
As writeback jobs contain a framebuffer, drivers may need to prepare and
cleanup them the same way they can prepare and cleanup framebuffers for
planes. Add two new optional connector helper operations,
.prepare_writeback_job() and .cleanup_writeback_job() to support this.
The job prepare operation is called from
drm_atomic_helper_prepare_planes() to avoid a new atomic commit helper
that would need to be called by all drivers not using
drm_atomic_helper_commit(). The job cleanup operation is called from the
existing drm_writeback_cleanup_job() function, invoked both when
destroying the job as part of a aborted commit, or when the job
completes.
The drm_writeback_job structure is extended with a priv field to let
drivers store per-job data, such as mappings related to the writeback
framebuffer.
For internal plumbing reasons the drm_writeback_job structure needs to
store a back-pointer to the drm_writeback_connector. To avoid pushing
too much writeback-specific knowledge to drm_atomic_uapi.c, create a
drm_writeback_set_fb() function, move the writeback job setup code
there, and set the connector backpointer. The prepare_signaling()
function doesn't need to allocate writeback jobs and can ignore
connectors without a job, as it is called after the writeback jobs are
allocated to store framebuffers, and a writeback fence with a
framebuffer is an invalid configuration that gets rejected by the commit
check.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
2019-02-21 01:01:38 +00:00
|
|
|
int (*prepare_writeback_job)(struct drm_writeback_connector *connector,
|
|
|
|
struct drm_writeback_job *job);
|
2020-04-06 19:47:45 +00:00
|
|
|
/**
|
|
|
|
* @cleanup_writeback_job:
|
|
|
|
*
|
|
|
|
* This optional connector operation is used to support the
|
|
|
|
* cleanup of writeback jobs. The job cleanup operation is called
|
|
|
|
* from the existing drm_writeback_cleanup_job() function, invoked
|
|
|
|
* both when destroying the job as part of an aborted commit, or when
|
|
|
|
* the job completes.
|
|
|
|
*
|
|
|
|
* This operation is optional.
|
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers.
|
|
|
|
*/
|
drm: writeback: Add job prepare and cleanup operations
As writeback jobs contain a framebuffer, drivers may need to prepare and
cleanup them the same way they can prepare and cleanup framebuffers for
planes. Add two new optional connector helper operations,
.prepare_writeback_job() and .cleanup_writeback_job() to support this.
The job prepare operation is called from
drm_atomic_helper_prepare_planes() to avoid a new atomic commit helper
that would need to be called by all drivers not using
drm_atomic_helper_commit(). The job cleanup operation is called from the
existing drm_writeback_cleanup_job() function, invoked both when
destroying the job as part of a aborted commit, or when the job
completes.
The drm_writeback_job structure is extended with a priv field to let
drivers store per-job data, such as mappings related to the writeback
framebuffer.
For internal plumbing reasons the drm_writeback_job structure needs to
store a back-pointer to the drm_writeback_connector. To avoid pushing
too much writeback-specific knowledge to drm_atomic_uapi.c, create a
drm_writeback_set_fb() function, move the writeback job setup code
there, and set the connector backpointer. The prepare_signaling()
function doesn't need to allocate writeback jobs and can ignore
connectors without a job, as it is called after the writeback jobs are
allocated to store framebuffers, and a writeback fence with a
framebuffer is an invalid configuration that gets rejected by the commit
check.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
2019-02-21 01:01:38 +00:00
|
|
|
void (*cleanup_writeback_job)(struct drm_writeback_connector *connector,
|
|
|
|
struct drm_writeback_job *job);
|
2022-11-02 18:07:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @enable_hpd:
|
|
|
|
*
|
|
|
|
* Enable hot-plug detection for the connector.
|
|
|
|
*
|
|
|
|
* This operation is optional.
|
|
|
|
*
|
|
|
|
* This callback is used by the drm_kms_helper_poll_enable() helpers.
|
|
|
|
*/
|
|
|
|
void (*enable_hpd)(struct drm_connector *connector);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @disable_hpd:
|
|
|
|
*
|
|
|
|
* Disable hot-plug detection for the connector.
|
|
|
|
*
|
|
|
|
* This operation is optional.
|
|
|
|
*
|
|
|
|
* This callback is used by the drm_kms_helper_poll_disable() helpers.
|
|
|
|
*/
|
|
|
|
void (*disable_hpd)(struct drm_connector *connector);
|
2015-12-04 08:45:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_connector_helper_add - sets the helper vtable for a connector
|
|
|
|
* @connector: DRM connector
|
|
|
|
* @funcs: helper vtable to set for @connector
|
|
|
|
*/
|
|
|
|
static inline void drm_connector_helper_add(struct drm_connector *connector,
|
|
|
|
const struct drm_connector_helper_funcs *funcs)
|
|
|
|
{
|
|
|
|
connector->helper_private = funcs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-12-04 08:46:04 +00:00
|
|
|
* struct drm_plane_helper_funcs - helper operations for planes
|
2015-12-04 08:45:44 +00:00
|
|
|
*
|
2015-12-04 08:46:04 +00:00
|
|
|
* These functions are used by the atomic helpers and by the transitional plane
|
|
|
|
* helpers.
|
2015-12-04 08:45:44 +00:00
|
|
|
*/
|
|
|
|
struct drm_plane_helper_funcs {
|
2015-12-04 08:46:04 +00:00
|
|
|
/**
|
|
|
|
* @prepare_fb:
|
|
|
|
*
|
|
|
|
* This hook is to prepare a framebuffer for scanout by e.g. pinning
|
2019-02-02 01:23:26 +00:00
|
|
|
* its backing storage or relocating it into a contiguous block of
|
2015-12-04 08:46:04 +00:00
|
|
|
* VRAM. Other possible preparatory work includes flushing caches.
|
|
|
|
*
|
|
|
|
* This function must not block for outstanding rendering, since it is
|
|
|
|
* called in the context of the atomic IOCTL even for async commits to
|
|
|
|
* be able to return any errors to userspace. Instead the recommended
|
2018-04-05 15:44:46 +00:00
|
|
|
* way is to fill out the &drm_plane_state.fence of the passed-in
|
2015-12-04 08:46:04 +00:00
|
|
|
* &drm_plane_state. If the driver doesn't support native fences then
|
|
|
|
* equivalent functionality should be implemented through private
|
|
|
|
* members in the plane structure.
|
|
|
|
*
|
2021-06-23 16:22:00 +00:00
|
|
|
* For GEM drivers who neither have a @prepare_fb nor @cleanup_fb hook
|
|
|
|
* set drm_gem_plane_helper_prepare_fb() is called automatically to
|
|
|
|
* implement this. Other drivers which need additional plane processing
|
|
|
|
* can call drm_gem_plane_helper_prepare_fb() from their @prepare_fb
|
|
|
|
* hook.
|
2018-04-05 15:44:46 +00:00
|
|
|
*
|
2022-10-25 10:17:36 +00:00
|
|
|
* The resources acquired in @prepare_fb persist after the end of
|
|
|
|
* the atomic commit. Resources that can be release at the commit's end
|
|
|
|
* should be acquired in @begin_fb_access and released in @end_fb_access.
|
|
|
|
* For example, a GEM buffer's pin operation belongs into @prepare_fb to
|
|
|
|
* keep the buffer pinned after the commit. But a vmap operation for
|
|
|
|
* shadow-plane helpers belongs into @begin_fb_access, so that atomic
|
|
|
|
* helpers remove the mapping at the end of the commit.
|
|
|
|
*
|
2015-12-04 08:46:04 +00:00
|
|
|
* The helpers will call @cleanup_fb with matching arguments for every
|
|
|
|
* successful call to this hook.
|
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers and by the
|
2022-10-25 10:17:36 +00:00
|
|
|
* transitional plane helpers, but it is optional. See @begin_fb_access
|
|
|
|
* for preparing per-commit resources.
|
2015-12-04 08:46:04 +00:00
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* 0 on success or one of the following negative error codes allowed by
|
2017-01-25 06:26:43 +00:00
|
|
|
* the &drm_mode_config_funcs.atomic_commit vfunc. When using helpers
|
2015-12-04 08:46:04 +00:00
|
|
|
* this callback is the only one which can fail an atomic commit,
|
|
|
|
* everything else must complete successfully.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
int (*prepare_fb)(struct drm_plane *plane,
|
2016-08-18 18:00:16 +00:00
|
|
|
struct drm_plane_state *new_state);
|
2015-12-04 08:46:04 +00:00
|
|
|
/**
|
|
|
|
* @cleanup_fb:
|
|
|
|
*
|
|
|
|
* This hook is called to clean up any resources allocated for the given
|
|
|
|
* framebuffer and plane configuration in @prepare_fb.
|
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers and by the
|
|
|
|
* transitional plane helpers, but it is optional.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*cleanup_fb)(struct drm_plane *plane,
|
2016-08-18 18:00:16 +00:00
|
|
|
struct drm_plane_state *old_state);
|
2015-12-04 08:45:44 +00:00
|
|
|
|
2022-10-25 10:17:36 +00:00
|
|
|
/**
|
|
|
|
* @begin_fb_access:
|
|
|
|
*
|
|
|
|
* This hook prepares the plane for access during an atomic commit.
|
|
|
|
* In contrast to @prepare_fb, resources acquired in @begin_fb_access,
|
|
|
|
* are released at the end of the atomic commit in @end_fb_access.
|
|
|
|
*
|
|
|
|
* For example, with shadow-plane helpers, the GEM buffer's vmap
|
|
|
|
* operation belongs into @begin_fb_access, so that the buffer's
|
|
|
|
* memory will be unmapped at the end of the commit in @end_fb_access.
|
|
|
|
* But a GEM buffer's pin operation belongs into @prepare_fb
|
|
|
|
* to keep the buffer pinned after the commit.
|
|
|
|
*
|
|
|
|
* The callback is used by the atomic modeset helpers, but it is optional.
|
|
|
|
* See @end_fb_cleanup for undoing the effects of @begin_fb_access and
|
|
|
|
* @prepare_fb for acquiring resources until the next pageflip.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 on success, or a negative errno code otherwise.
|
|
|
|
*/
|
|
|
|
int (*begin_fb_access)(struct drm_plane *plane, struct drm_plane_state *new_plane_state);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @end_fb_access:
|
|
|
|
*
|
|
|
|
* This hook cleans up resources allocated by @begin_fb_access. It it called
|
|
|
|
* at the end of a commit for the new plane state.
|
|
|
|
*/
|
|
|
|
void (*end_fb_access)(struct drm_plane *plane, struct drm_plane_state *new_plane_state);
|
|
|
|
|
2015-12-04 08:46:04 +00:00
|
|
|
/**
|
|
|
|
* @atomic_check:
|
|
|
|
*
|
|
|
|
* Drivers should check plane specific constraints in this hook.
|
|
|
|
*
|
2017-01-25 06:26:43 +00:00
|
|
|
* When using drm_atomic_helper_check_planes() plane's @atomic_check
|
2015-12-04 08:46:04 +00:00
|
|
|
* hooks are called before the ones for CRTCs, which allows drivers to
|
|
|
|
* request shared resources that the CRTC controls here. For more
|
|
|
|
* complicated dependencies the driver can call the provided check helpers
|
|
|
|
* multiple times until the computed state has a final configuration and
|
|
|
|
* everything has been checked.
|
|
|
|
*
|
|
|
|
* This function is also allowed to inspect any other object's state and
|
|
|
|
* can add more state objects to the atomic commit if needed. Care must
|
2017-01-25 06:26:43 +00:00
|
|
|
* be taken though to ensure that state check and compute functions for
|
2015-12-04 08:46:04 +00:00
|
|
|
* these added states are all called, and derived state in other objects
|
|
|
|
* all updated. Again the recommendation is to just call check helpers
|
|
|
|
* until a maximal configuration is reached.
|
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers and by the
|
|
|
|
* transitional plane helpers, but it is optional.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* This function is called in the check phase of an atomic update. The
|
drm/atomic: Pass the full state to planes atomic_check
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_check.
The conversion was done using the coccinelle script below plus some
manual changes for vmwgfx, built tested on all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
int (*atomic_check)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_check(plane, plane_state)
+ FUNCS->atomic_check(plane, state)
...+>
}
@ ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
... when != new_plane_state
}
@ adds_new_state depends on plane_atomic_func && !ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
+ struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *new_plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-4-maxime@cerno.tech
2021-02-19 12:00:24 +00:00
|
|
|
* driver is not allowed to change anything outside of the
|
|
|
|
* &drm_atomic_state update tracking structure.
|
2015-12-04 08:46:04 +00:00
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* 0 on success, -EINVAL if the state or the transition can't be
|
|
|
|
* supported, -ENOMEM on memory allocation failure and -EDEADLK if an
|
|
|
|
* attempt to obtain another state object ran into a &drm_modeset_lock
|
|
|
|
* deadlock.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
int (*atomic_check)(struct drm_plane *plane,
|
drm/atomic: Pass the full state to planes atomic_check
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_check.
The conversion was done using the coccinelle script below plus some
manual changes for vmwgfx, built tested on all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
int (*atomic_check)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_check(plane, plane_state)
+ FUNCS->atomic_check(plane, state)
...+>
}
@ ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
... when != new_plane_state
}
@ adds_new_state depends on plane_atomic_func && !ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
+ struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *new_plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-4-maxime@cerno.tech
2021-02-19 12:00:24 +00:00
|
|
|
struct drm_atomic_state *state);
|
2015-12-04 08:46:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_update:
|
|
|
|
*
|
|
|
|
* Drivers should use this function to update the plane state. This
|
2017-01-25 06:26:43 +00:00
|
|
|
* hook is called in-between the &drm_crtc_helper_funcs.atomic_begin and
|
|
|
|
* drm_crtc_helper_funcs.atomic_flush callbacks.
|
2015-12-04 08:46:04 +00:00
|
|
|
*
|
|
|
|
* Note that the power state of the display pipe when this function is
|
|
|
|
* called depends upon the exact helpers and calling sequence the driver
|
2016-10-31 17:36:46 +00:00
|
|
|
* has picked. See drm_atomic_helper_commit_planes() for a discussion of
|
|
|
|
* the tradeoffs and variants of plane commit helpers.
|
2015-12-04 08:46:04 +00:00
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers and by the
|
|
|
|
* transitional plane helpers, but it is optional.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*atomic_update)(struct drm_plane *plane,
|
drm/atomic: Pass the full state to planes atomic disable and update
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's convert the remaining helpers to provide a consistent interface,
this time with the planes atomic_update and atomic_disable.
The conversion was done using the coccinelle script below, built tested on
all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
void (*atomic_update)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
void (*atomic_disable)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_update = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
)
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier crtc_state;
identifier plane, plane_state, state;
expression e;
@@
f(struct drm_crtc_state *crtc_state)
{
...
struct drm_atomic_state *state = e;
<+...
(
- FUNCS->atomic_disable(plane, plane_state)
+ FUNCS->atomic_disable(plane, state)
|
- FUNCS->atomic_update(plane, plane_state)
+ FUNCS->atomic_update(plane, state)
)
...+>
}
@@
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *state)
+ struct drm_plane_state *old_plane_state)
{
<...
- state
+ old_plane_state
...>
}
@ ignores_old_state @
identifier plane_atomic_func.func;
identifier plane, old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on plane_atomic_func && !ignores_old_state @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *plane_state)
{
+ struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
...
struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
<+...
- plane_state->state
+ state
...+>
}
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-9-maxime@cerno.tech
2021-02-19 12:00:29 +00:00
|
|
|
struct drm_atomic_state *state);
|
2015-12-04 08:46:04 +00:00
|
|
|
/**
|
|
|
|
* @atomic_disable:
|
|
|
|
*
|
|
|
|
* Drivers should use this function to unconditionally disable a plane.
|
2017-01-25 06:26:43 +00:00
|
|
|
* This hook is called in-between the
|
|
|
|
* &drm_crtc_helper_funcs.atomic_begin and
|
|
|
|
* drm_crtc_helper_funcs.atomic_flush callbacks. It is an alternative to
|
2015-12-04 08:46:04 +00:00
|
|
|
* @atomic_update, which will be called for disabling planes, too, if
|
|
|
|
* the @atomic_disable hook isn't implemented.
|
|
|
|
*
|
|
|
|
* This hook is also useful to disable planes in preparation of a modeset,
|
|
|
|
* by calling drm_atomic_helper_disable_planes_on_crtc() from the
|
2017-01-25 06:26:43 +00:00
|
|
|
* &drm_crtc_helper_funcs.disable hook.
|
2015-12-04 08:46:04 +00:00
|
|
|
*
|
|
|
|
* Note that the power state of the display pipe when this function is
|
|
|
|
* called depends upon the exact helpers and calling sequence the driver
|
2016-10-31 17:36:46 +00:00
|
|
|
* has picked. See drm_atomic_helper_commit_planes() for a discussion of
|
|
|
|
* the tradeoffs and variants of plane commit helpers.
|
2015-12-04 08:46:04 +00:00
|
|
|
*
|
|
|
|
* This callback is used by the atomic modeset helpers and by the
|
|
|
|
* transitional plane helpers, but it is optional.
|
|
|
|
*/
|
2015-12-04 08:45:44 +00:00
|
|
|
void (*atomic_disable)(struct drm_plane *plane,
|
drm/atomic: Pass the full state to planes atomic disable and update
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's convert the remaining helpers to provide a consistent interface,
this time with the planes atomic_update and atomic_disable.
The conversion was done using the coccinelle script below, built tested on
all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
void (*atomic_update)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
void (*atomic_disable)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_update = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
)
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier crtc_state;
identifier plane, plane_state, state;
expression e;
@@
f(struct drm_crtc_state *crtc_state)
{
...
struct drm_atomic_state *state = e;
<+...
(
- FUNCS->atomic_disable(plane, plane_state)
+ FUNCS->atomic_disable(plane, state)
|
- FUNCS->atomic_update(plane, plane_state)
+ FUNCS->atomic_update(plane, state)
)
...+>
}
@@
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *state)
+ struct drm_plane_state *old_plane_state)
{
<...
- state
+ old_plane_state
...>
}
@ ignores_old_state @
identifier plane_atomic_func.func;
identifier plane, old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on plane_atomic_func && !ignores_old_state @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *plane_state)
{
+ struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
...
struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
<+...
- plane_state->state
+ state
...+>
}
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-9-maxime@cerno.tech
2021-02-19 12:00:29 +00:00
|
|
|
struct drm_atomic_state *state);
|
2017-06-30 18:03:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_async_check:
|
|
|
|
*
|
drm/atomic: Pass the full state to planes async atomic check and update
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's start convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_async_check and
atomic_async_update.
The conversion was done using the coccinelle script below, built tested on
all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
int (*atomic_async_check)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
void (*atomic_async_update)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_check = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_update = func,
...,
};
)
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_async_check(plane, plane_state)
+ FUNCS->atomic_async_check(plane, state)
...+>
}
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_async_update(plane, plane_state)
+ FUNCS->atomic_async_update(plane, state)
...+>
}
@@
identifier mtk_plane_atomic_async_update;
identifier plane;
symbol new_state, state;
expression e;
@@
void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
{
...
- struct mtk_plane_state *state = e;
+ struct mtk_plane_state *new_plane_state = e;
<+...
- state
+ new_plane_state
...+>
}
@@
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *state)
+ struct drm_plane_state *new_plane_state)
{
<...
- state
+ new_plane_state
...>
}
@ ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
... when != new_plane_state
}
@ adds_new_state depends on plane_atomic_func && !ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
+ struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
...
struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
<+...
- plane_state->state
+ state
...+>
}
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 12:00:21 +00:00
|
|
|
* Drivers should set this function pointer to check if the plane's
|
|
|
|
* atomic state can be updated in a async fashion. Here async means
|
|
|
|
* "not vblank synchronized".
|
2017-06-30 18:03:17 +00:00
|
|
|
*
|
|
|
|
* This hook is called by drm_atomic_async_check() to establish if a
|
|
|
|
* given update can be committed asynchronously, that is, if it can
|
|
|
|
* jump ahead of the state currently queued for update.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* Return 0 on success and any error returned indicates that the update
|
|
|
|
* can not be applied in asynchronous manner.
|
|
|
|
*/
|
|
|
|
int (*atomic_async_check)(struct drm_plane *plane,
|
drm/atomic: Pass the full state to planes async atomic check and update
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's start convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_async_check and
atomic_async_update.
The conversion was done using the coccinelle script below, built tested on
all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
int (*atomic_async_check)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
void (*atomic_async_update)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_check = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_update = func,
...,
};
)
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_async_check(plane, plane_state)
+ FUNCS->atomic_async_check(plane, state)
...+>
}
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_async_update(plane, plane_state)
+ FUNCS->atomic_async_update(plane, state)
...+>
}
@@
identifier mtk_plane_atomic_async_update;
identifier plane;
symbol new_state, state;
expression e;
@@
void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
{
...
- struct mtk_plane_state *state = e;
+ struct mtk_plane_state *new_plane_state = e;
<+...
- state
+ new_plane_state
...+>
}
@@
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *state)
+ struct drm_plane_state *new_plane_state)
{
<...
- state
+ new_plane_state
...>
}
@ ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
... when != new_plane_state
}
@ adds_new_state depends on plane_atomic_func && !ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
+ struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
...
struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
<+...
- plane_state->state
+ state
...+>
}
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 12:00:21 +00:00
|
|
|
struct drm_atomic_state *state);
|
2017-06-30 18:03:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_async_update:
|
|
|
|
*
|
|
|
|
* Drivers should set this function pointer to perform asynchronous
|
|
|
|
* updates of planes, that is, jump ahead of the currently queued
|
|
|
|
* state and update the plane. Here async means "not vblank
|
|
|
|
* synchronized".
|
|
|
|
*
|
|
|
|
* This hook is called by drm_atomic_helper_async_commit().
|
|
|
|
*
|
|
|
|
* An async update will happen on legacy cursor updates. An async
|
|
|
|
* update won't happen if there is an outstanding commit modifying
|
|
|
|
* the same plane.
|
|
|
|
*
|
drm/atomic: Pass the full state to planes async atomic check and update
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's start convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_async_check and
atomic_async_update.
The conversion was done using the coccinelle script below, built tested on
all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
int (*atomic_async_check)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
void (*atomic_async_update)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_check = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_update = func,
...,
};
)
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_async_check(plane, plane_state)
+ FUNCS->atomic_async_check(plane, state)
...+>
}
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_async_update(plane, plane_state)
+ FUNCS->atomic_async_update(plane, state)
...+>
}
@@
identifier mtk_plane_atomic_async_update;
identifier plane;
symbol new_state, state;
expression e;
@@
void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
{
...
- struct mtk_plane_state *state = e;
+ struct mtk_plane_state *new_plane_state = e;
<+...
- state
+ new_plane_state
...+>
}
@@
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *state)
+ struct drm_plane_state *new_plane_state)
{
<...
- state
+ new_plane_state
...>
}
@ ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
... when != new_plane_state
}
@ adds_new_state depends on plane_atomic_func && !ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
+ struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
...
struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
<+...
- plane_state->state
+ state
...+>
}
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 12:00:21 +00:00
|
|
|
* When doing async_update drivers shouldn't replace the
|
|
|
|
* &drm_plane_state but update the current one with the new plane
|
|
|
|
* configurations in the new plane_state.
|
2017-06-30 18:03:17 +00:00
|
|
|
*
|
drm: don't block fb changes for async plane updates
In the case of a normal sync update, the preparation of framebuffers (be
it calling drm_atomic_helper_prepare_planes() or doing setups with
drm_framebuffer_get()) are performed in the new_state and the respective
cleanups are performed in the old_state.
In the case of async updates, the preparation is also done in the
new_state but the cleanups are done in the new_state (because updates
are performed in place, i.e. in the current state).
The current code blocks async udpates when the fb is changed, turning
async updates into sync updates, slowing down cursor updates and
introducing regressions in igt tests with errors of type:
"CRITICAL: completed 97 cursor updated in a period of 30 flips, we
expect to complete approximately 15360 updates, with the threshold set
at 7680"
Fb changes in async updates were prevented to avoid the following scenario:
- Async update, oldfb = NULL, newfb = fb1, prepare fb1, cleanup fb1
- Async update, oldfb = fb1, newfb = fb2, prepare fb2, cleanup fb2
- Non-async commit, oldfb = fb2, newfb = fb1, prepare fb1, cleanup fb2 (wrong)
Where we have a single call to prepare fb2 but double cleanup call to fb2.
To solve the above problems, instead of blocking async fb changes, we
place the old framebuffer in the new_state object, so when the code
performs cleanups in the new_state it will cleanup the old_fb and we
will have the following scenario instead:
- Async update, oldfb = NULL, newfb = fb1, prepare fb1, no cleanup
- Async update, oldfb = fb1, newfb = fb2, prepare fb2, cleanup fb1
- Non-async commit, oldfb = fb2, newfb = fb1, prepare fb1, cleanup fb2
Where calls to prepare/cleanup are balanced.
Cc: <stable@vger.kernel.org> # v4.14+
Fixes: 25dc194b34dd ("drm: Block fb changes for async plane updates")
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Helen Koike <helen.koike@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190603165610.24614-6-helen.koike@collabora.com
2019-06-03 16:56:10 +00:00
|
|
|
* Drivers should also swap the framebuffers between current plane
|
|
|
|
* state (&drm_plane.state) and new_state.
|
|
|
|
* This is required since cleanup for async commits is performed on
|
|
|
|
* the new state, rather than old state like for traditional commits.
|
|
|
|
* Since we want to give up the reference on the current (old) fb
|
|
|
|
* instead of our brand new one, swap them in the driver during the
|
|
|
|
* async commit.
|
|
|
|
*
|
2017-06-30 18:03:17 +00:00
|
|
|
* FIXME:
|
|
|
|
* - It only works for single plane updates
|
|
|
|
* - Async Pageflips are not supported yet
|
|
|
|
* - Some hw might still scan out the old buffer until the next
|
2017-07-31 11:17:33 +00:00
|
|
|
* vblank, however we let go of the fb references as soon as
|
|
|
|
* we run this hook. For now drivers must implement their own workers
|
|
|
|
* for deferring if needed, until a common solution is created.
|
2017-06-30 18:03:17 +00:00
|
|
|
*/
|
|
|
|
void (*atomic_async_update)(struct drm_plane *plane,
|
drm/atomic: Pass the full state to planes async atomic check and update
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's start convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_async_check and
atomic_async_update.
The conversion was done using the coccinelle script below, built tested on
all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
int (*atomic_async_check)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
void (*atomic_async_update)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_check = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_update = func,
...,
};
)
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_async_check(plane, plane_state)
+ FUNCS->atomic_async_check(plane, state)
...+>
}
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_async_update(plane, plane_state)
+ FUNCS->atomic_async_update(plane, state)
...+>
}
@@
identifier mtk_plane_atomic_async_update;
identifier plane;
symbol new_state, state;
expression e;
@@
void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
{
...
- struct mtk_plane_state *state = e;
+ struct mtk_plane_state *new_plane_state = e;
<+...
- state
+ new_plane_state
...+>
}
@@
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *state)
+ struct drm_plane_state *new_plane_state)
{
<...
- state
+ new_plane_state
...>
}
@ ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
... when != new_plane_state
}
@ adds_new_state depends on plane_atomic_func && !ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
+ struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
...
struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
<+...
- plane_state->state
+ state
...+>
}
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 12:00:21 +00:00
|
|
|
struct drm_atomic_state *state);
|
2015-12-04 08:45:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_plane_helper_add - sets the helper vtable for a plane
|
|
|
|
* @plane: DRM plane
|
|
|
|
* @funcs: helper vtable to set for @plane
|
|
|
|
*/
|
|
|
|
static inline void drm_plane_helper_add(struct drm_plane *plane,
|
|
|
|
const struct drm_plane_helper_funcs *funcs)
|
|
|
|
{
|
|
|
|
plane->helper_private = funcs;
|
|
|
|
}
|
|
|
|
|
drm/atomic-helper: nonblocking commit support
Design ideas:
- split up the actual commit into different phases, and have
completions for each of them. This will be useful for the future
when we want to interleave phases much more aggressively, for e.g.
queue depth > 1. For not it's just a minimal optimization compared
to current common nonblocking implementation patterns from drivers,
which all stall for the entire commit to complete, including vblank
waits and cleanups.
- Extract a separate atomic_commit_hw hook since that's the part most
drivers will need to overwrite, hopefully allowing even more shared
code.
- Enforce EBUSY seamntics by attaching one of the completions to the
flip_done vblank event. Side benefit of forcing atomic drivers using
these helpers to implement event handlign at least semi-correct. I'm
evil that way ;-)
- Ridiculously modular, as usual.
- The main tracking unit for a commit stays struct drm_atomic_state,
and the ownership rules for that are unchanged. Ownership still
gets transferred to the driver (and subsequently to the worker) on
successful commits. What is added is a small, per-crtc, refcounted
structure to track pending commits called struct drm_crtc_commit.
No actual state is attached to that though, it's purely for ordering
and waiting.
- Dependencies are implicitly handled by assuming that any CRTC part
of &drm_atomic_state is a dependency, and that the current commit
must wait for any commits to complete on those CRTC. This way
drivers can easily add more depencies using
drm_atomic_get_crtc_state(), which is very natural since in most
case a dependency exists iff there's some bit of state that needs to
be cross checked.
Removing depencies is not possible, drivers simply need to be
careful to not include every CRTC in a commit if that's not
necessary. Which is a good idea anyway, since that also avoids
ww_mutex lock contention.
- Queue depth > 1 sees some prep work in this patch by adding a stall
paramater to drm_atomic_helper_swap_states(). To be able to push
commits entirely free-standing and in a deeper queue through the
back-end the driver must not access any obj->state pointers. This
means we need to track the old state in drm_atomic_state (much
easier with the consolidated arrays), and pass them all explicitly
to driver backends (this will be serious amounts of churn).
Once that's done stall can be set to false in swap_states.
v2: Dont ask for flip_done signalling when the CRTC is off and stays
off: Drivers don't handle events in that case. Instead complete right
away. This way future commits don't need to have special-case logic,
but can keep blocking for the flip_done completion.
v3: Tons of fixes:
- Stall for preceeding commit for real, not the current one by
accident.
- Add WARN_ON in case drivers don't fire the drm event.
- Don't double-free drm events.
v4: Make legacy cursor not stall.
v5: Extend the helper hook to cover the entire commit tail. Some
drivers need special code for cleanup and vblank waiting, this makes
it a bit more useful. Inspired by the rockchip driver.
v6: Add WARN_ON to catch drivers who forget to send out the
drm event.
v7: Fixup the stalls in swap_state for real!!
v8:
- Fixup trailing whitespace, spotted by Maarten.
- Actually wait for flip_done in cleanup_done, like the comment says
we should do. Thanks a lot for Tomeu for helping with debugging this
on.
v9: Now with awesome kerneldoc!
v10: Split out drm_crtc_commit tracking infrastructure.
v:
- Add missing static (Gustavo).
- Split out the sync functions, only do the actual nonblocking
logic in this patch (Maarten).
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Tested-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Tomeu Vizoso <tomeu.vizoso@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Tested-by: Liviu Dudau <Liviu.Dudau@arm.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Testcase: igt/kms_flip/*
Testcase: igt/kms_cursor*
Testcase: igt/kms*plane*
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1465388359-8070-10-git-send-email-daniel.vetter@ffwll.ch
2016-06-08 12:19:02 +00:00
|
|
|
/**
|
|
|
|
* struct drm_mode_config_helper_funcs - global modeset helper operations
|
|
|
|
*
|
|
|
|
* These helper functions are used by the atomic helpers.
|
|
|
|
*/
|
|
|
|
struct drm_mode_config_helper_funcs {
|
|
|
|
/**
|
|
|
|
* @atomic_commit_tail:
|
|
|
|
*
|
|
|
|
* This hook is used by the default atomic_commit() hook implemented in
|
|
|
|
* drm_atomic_helper_commit() together with the nonblocking commit
|
|
|
|
* helpers (see drm_atomic_helper_setup_commit() for a starting point)
|
|
|
|
* to implement blocking and nonblocking commits easily. It is not used
|
|
|
|
* by the atomic helpers
|
|
|
|
*
|
2016-11-21 17:18:02 +00:00
|
|
|
* This function is called when the new atomic state has already been
|
|
|
|
* swapped into the various state pointers. The passed in state
|
|
|
|
* therefore contains copies of the old/previous state. This hook should
|
|
|
|
* commit the new state into hardware. Note that the helpers have
|
|
|
|
* already waited for preceeding atomic commits and fences, but drivers
|
|
|
|
* can add more waiting calls at the start of their implementation, e.g.
|
|
|
|
* to wait for driver-internal request for implicit syncing, before
|
|
|
|
* starting to commit the update to the hardware.
|
drm/atomic-helper: nonblocking commit support
Design ideas:
- split up the actual commit into different phases, and have
completions for each of them. This will be useful for the future
when we want to interleave phases much more aggressively, for e.g.
queue depth > 1. For not it's just a minimal optimization compared
to current common nonblocking implementation patterns from drivers,
which all stall for the entire commit to complete, including vblank
waits and cleanups.
- Extract a separate atomic_commit_hw hook since that's the part most
drivers will need to overwrite, hopefully allowing even more shared
code.
- Enforce EBUSY seamntics by attaching one of the completions to the
flip_done vblank event. Side benefit of forcing atomic drivers using
these helpers to implement event handlign at least semi-correct. I'm
evil that way ;-)
- Ridiculously modular, as usual.
- The main tracking unit for a commit stays struct drm_atomic_state,
and the ownership rules for that are unchanged. Ownership still
gets transferred to the driver (and subsequently to the worker) on
successful commits. What is added is a small, per-crtc, refcounted
structure to track pending commits called struct drm_crtc_commit.
No actual state is attached to that though, it's purely for ordering
and waiting.
- Dependencies are implicitly handled by assuming that any CRTC part
of &drm_atomic_state is a dependency, and that the current commit
must wait for any commits to complete on those CRTC. This way
drivers can easily add more depencies using
drm_atomic_get_crtc_state(), which is very natural since in most
case a dependency exists iff there's some bit of state that needs to
be cross checked.
Removing depencies is not possible, drivers simply need to be
careful to not include every CRTC in a commit if that's not
necessary. Which is a good idea anyway, since that also avoids
ww_mutex lock contention.
- Queue depth > 1 sees some prep work in this patch by adding a stall
paramater to drm_atomic_helper_swap_states(). To be able to push
commits entirely free-standing and in a deeper queue through the
back-end the driver must not access any obj->state pointers. This
means we need to track the old state in drm_atomic_state (much
easier with the consolidated arrays), and pass them all explicitly
to driver backends (this will be serious amounts of churn).
Once that's done stall can be set to false in swap_states.
v2: Dont ask for flip_done signalling when the CRTC is off and stays
off: Drivers don't handle events in that case. Instead complete right
away. This way future commits don't need to have special-case logic,
but can keep blocking for the flip_done completion.
v3: Tons of fixes:
- Stall for preceeding commit for real, not the current one by
accident.
- Add WARN_ON in case drivers don't fire the drm event.
- Don't double-free drm events.
v4: Make legacy cursor not stall.
v5: Extend the helper hook to cover the entire commit tail. Some
drivers need special code for cleanup and vblank waiting, this makes
it a bit more useful. Inspired by the rockchip driver.
v6: Add WARN_ON to catch drivers who forget to send out the
drm event.
v7: Fixup the stalls in swap_state for real!!
v8:
- Fixup trailing whitespace, spotted by Maarten.
- Actually wait for flip_done in cleanup_done, like the comment says
we should do. Thanks a lot for Tomeu for helping with debugging this
on.
v9: Now with awesome kerneldoc!
v10: Split out drm_crtc_commit tracking infrastructure.
v:
- Add missing static (Gustavo).
- Split out the sync functions, only do the actual nonblocking
logic in this patch (Maarten).
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Tested-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Tomeu Vizoso <tomeu.vizoso@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Tested-by: Liviu Dudau <Liviu.Dudau@arm.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Testcase: igt/kms_flip/*
Testcase: igt/kms_cursor*
Testcase: igt/kms*plane*
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1465388359-8070-10-git-send-email-daniel.vetter@ffwll.ch
2016-06-08 12:19:02 +00:00
|
|
|
*
|
|
|
|
* After the atomic update is committed to the hardware this hook needs
|
2022-04-06 07:30:36 +00:00
|
|
|
* to call drm_atomic_helper_commit_hw_done(). Then wait for the update
|
drm/atomic-helper: nonblocking commit support
Design ideas:
- split up the actual commit into different phases, and have
completions for each of them. This will be useful for the future
when we want to interleave phases much more aggressively, for e.g.
queue depth > 1. For not it's just a minimal optimization compared
to current common nonblocking implementation patterns from drivers,
which all stall for the entire commit to complete, including vblank
waits and cleanups.
- Extract a separate atomic_commit_hw hook since that's the part most
drivers will need to overwrite, hopefully allowing even more shared
code.
- Enforce EBUSY seamntics by attaching one of the completions to the
flip_done vblank event. Side benefit of forcing atomic drivers using
these helpers to implement event handlign at least semi-correct. I'm
evil that way ;-)
- Ridiculously modular, as usual.
- The main tracking unit for a commit stays struct drm_atomic_state,
and the ownership rules for that are unchanged. Ownership still
gets transferred to the driver (and subsequently to the worker) on
successful commits. What is added is a small, per-crtc, refcounted
structure to track pending commits called struct drm_crtc_commit.
No actual state is attached to that though, it's purely for ordering
and waiting.
- Dependencies are implicitly handled by assuming that any CRTC part
of &drm_atomic_state is a dependency, and that the current commit
must wait for any commits to complete on those CRTC. This way
drivers can easily add more depencies using
drm_atomic_get_crtc_state(), which is very natural since in most
case a dependency exists iff there's some bit of state that needs to
be cross checked.
Removing depencies is not possible, drivers simply need to be
careful to not include every CRTC in a commit if that's not
necessary. Which is a good idea anyway, since that also avoids
ww_mutex lock contention.
- Queue depth > 1 sees some prep work in this patch by adding a stall
paramater to drm_atomic_helper_swap_states(). To be able to push
commits entirely free-standing and in a deeper queue through the
back-end the driver must not access any obj->state pointers. This
means we need to track the old state in drm_atomic_state (much
easier with the consolidated arrays), and pass them all explicitly
to driver backends (this will be serious amounts of churn).
Once that's done stall can be set to false in swap_states.
v2: Dont ask for flip_done signalling when the CRTC is off and stays
off: Drivers don't handle events in that case. Instead complete right
away. This way future commits don't need to have special-case logic,
but can keep blocking for the flip_done completion.
v3: Tons of fixes:
- Stall for preceeding commit for real, not the current one by
accident.
- Add WARN_ON in case drivers don't fire the drm event.
- Don't double-free drm events.
v4: Make legacy cursor not stall.
v5: Extend the helper hook to cover the entire commit tail. Some
drivers need special code for cleanup and vblank waiting, this makes
it a bit more useful. Inspired by the rockchip driver.
v6: Add WARN_ON to catch drivers who forget to send out the
drm event.
v7: Fixup the stalls in swap_state for real!!
v8:
- Fixup trailing whitespace, spotted by Maarten.
- Actually wait for flip_done in cleanup_done, like the comment says
we should do. Thanks a lot for Tomeu for helping with debugging this
on.
v9: Now with awesome kerneldoc!
v10: Split out drm_crtc_commit tracking infrastructure.
v:
- Add missing static (Gustavo).
- Split out the sync functions, only do the actual nonblocking
logic in this patch (Maarten).
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Tested-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Tomeu Vizoso <tomeu.vizoso@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Tested-by: Liviu Dudau <Liviu.Dudau@arm.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Testcase: igt/kms_flip/*
Testcase: igt/kms_cursor*
Testcase: igt/kms*plane*
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1465388359-8070-10-git-send-email-daniel.vetter@ffwll.ch
2016-06-08 12:19:02 +00:00
|
|
|
* to be executed by the hardware, for example using
|
2017-06-02 08:32:06 +00:00
|
|
|
* drm_atomic_helper_wait_for_vblanks() or
|
|
|
|
* drm_atomic_helper_wait_for_flip_done(), and then clean up the old
|
drm/atomic-helper: nonblocking commit support
Design ideas:
- split up the actual commit into different phases, and have
completions for each of them. This will be useful for the future
when we want to interleave phases much more aggressively, for e.g.
queue depth > 1. For not it's just a minimal optimization compared
to current common nonblocking implementation patterns from drivers,
which all stall for the entire commit to complete, including vblank
waits and cleanups.
- Extract a separate atomic_commit_hw hook since that's the part most
drivers will need to overwrite, hopefully allowing even more shared
code.
- Enforce EBUSY seamntics by attaching one of the completions to the
flip_done vblank event. Side benefit of forcing atomic drivers using
these helpers to implement event handlign at least semi-correct. I'm
evil that way ;-)
- Ridiculously modular, as usual.
- The main tracking unit for a commit stays struct drm_atomic_state,
and the ownership rules for that are unchanged. Ownership still
gets transferred to the driver (and subsequently to the worker) on
successful commits. What is added is a small, per-crtc, refcounted
structure to track pending commits called struct drm_crtc_commit.
No actual state is attached to that though, it's purely for ordering
and waiting.
- Dependencies are implicitly handled by assuming that any CRTC part
of &drm_atomic_state is a dependency, and that the current commit
must wait for any commits to complete on those CRTC. This way
drivers can easily add more depencies using
drm_atomic_get_crtc_state(), which is very natural since in most
case a dependency exists iff there's some bit of state that needs to
be cross checked.
Removing depencies is not possible, drivers simply need to be
careful to not include every CRTC in a commit if that's not
necessary. Which is a good idea anyway, since that also avoids
ww_mutex lock contention.
- Queue depth > 1 sees some prep work in this patch by adding a stall
paramater to drm_atomic_helper_swap_states(). To be able to push
commits entirely free-standing and in a deeper queue through the
back-end the driver must not access any obj->state pointers. This
means we need to track the old state in drm_atomic_state (much
easier with the consolidated arrays), and pass them all explicitly
to driver backends (this will be serious amounts of churn).
Once that's done stall can be set to false in swap_states.
v2: Dont ask for flip_done signalling when the CRTC is off and stays
off: Drivers don't handle events in that case. Instead complete right
away. This way future commits don't need to have special-case logic,
but can keep blocking for the flip_done completion.
v3: Tons of fixes:
- Stall for preceeding commit for real, not the current one by
accident.
- Add WARN_ON in case drivers don't fire the drm event.
- Don't double-free drm events.
v4: Make legacy cursor not stall.
v5: Extend the helper hook to cover the entire commit tail. Some
drivers need special code for cleanup and vblank waiting, this makes
it a bit more useful. Inspired by the rockchip driver.
v6: Add WARN_ON to catch drivers who forget to send out the
drm event.
v7: Fixup the stalls in swap_state for real!!
v8:
- Fixup trailing whitespace, spotted by Maarten.
- Actually wait for flip_done in cleanup_done, like the comment says
we should do. Thanks a lot for Tomeu for helping with debugging this
on.
v9: Now with awesome kerneldoc!
v10: Split out drm_crtc_commit tracking infrastructure.
v:
- Add missing static (Gustavo).
- Split out the sync functions, only do the actual nonblocking
logic in this patch (Maarten).
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Tested-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Tomeu Vizoso <tomeu.vizoso@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Tested-by: Liviu Dudau <Liviu.Dudau@arm.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Testcase: igt/kms_flip/*
Testcase: igt/kms_cursor*
Testcase: igt/kms*plane*
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1465388359-8070-10-git-send-email-daniel.vetter@ffwll.ch
2016-06-08 12:19:02 +00:00
|
|
|
* framebuffers using drm_atomic_helper_cleanup_planes().
|
|
|
|
*
|
|
|
|
* When disabling a CRTC this hook _must_ stall for the commit to
|
|
|
|
* complete. Vblank waits don't work on disabled CRTC, hence the core
|
|
|
|
* can't take care of this. And it also can't rely on the vblank event,
|
|
|
|
* since that can be signalled already when the screen shows black,
|
|
|
|
* which can happen much earlier than the last hardware access needed to
|
|
|
|
* shut off the display pipeline completely.
|
|
|
|
*
|
|
|
|
* This hook is optional, the default implementation is
|
|
|
|
* drm_atomic_helper_commit_tail().
|
|
|
|
*/
|
|
|
|
void (*atomic_commit_tail)(struct drm_atomic_state *state);
|
2020-12-04 15:11:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_commit_setup:
|
|
|
|
*
|
|
|
|
* This hook is used by the default atomic_commit() hook implemented in
|
|
|
|
* drm_atomic_helper_commit() together with the nonblocking helpers (see
|
|
|
|
* drm_atomic_helper_setup_commit()) to extend the DRM commit setup. It
|
|
|
|
* is not used by the atomic helpers.
|
|
|
|
*
|
|
|
|
* This function is called at the end of
|
|
|
|
* drm_atomic_helper_setup_commit(), so once the commit has been
|
|
|
|
* properly setup across the generic DRM object states. It allows
|
|
|
|
* drivers to do some additional commit tracking that isn't related to a
|
|
|
|
* CRTC, plane or connector, tracked in a &drm_private_obj structure.
|
|
|
|
*
|
|
|
|
* Note that the documentation of &drm_private_obj has more details on
|
|
|
|
* how one should implement this.
|
|
|
|
*
|
|
|
|
* This hook is optional.
|
|
|
|
*/
|
|
|
|
int (*atomic_commit_setup)(struct drm_atomic_state *state);
|
drm/atomic-helper: nonblocking commit support
Design ideas:
- split up the actual commit into different phases, and have
completions for each of them. This will be useful for the future
when we want to interleave phases much more aggressively, for e.g.
queue depth > 1. For not it's just a minimal optimization compared
to current common nonblocking implementation patterns from drivers,
which all stall for the entire commit to complete, including vblank
waits and cleanups.
- Extract a separate atomic_commit_hw hook since that's the part most
drivers will need to overwrite, hopefully allowing even more shared
code.
- Enforce EBUSY seamntics by attaching one of the completions to the
flip_done vblank event. Side benefit of forcing atomic drivers using
these helpers to implement event handlign at least semi-correct. I'm
evil that way ;-)
- Ridiculously modular, as usual.
- The main tracking unit for a commit stays struct drm_atomic_state,
and the ownership rules for that are unchanged. Ownership still
gets transferred to the driver (and subsequently to the worker) on
successful commits. What is added is a small, per-crtc, refcounted
structure to track pending commits called struct drm_crtc_commit.
No actual state is attached to that though, it's purely for ordering
and waiting.
- Dependencies are implicitly handled by assuming that any CRTC part
of &drm_atomic_state is a dependency, and that the current commit
must wait for any commits to complete on those CRTC. This way
drivers can easily add more depencies using
drm_atomic_get_crtc_state(), which is very natural since in most
case a dependency exists iff there's some bit of state that needs to
be cross checked.
Removing depencies is not possible, drivers simply need to be
careful to not include every CRTC in a commit if that's not
necessary. Which is a good idea anyway, since that also avoids
ww_mutex lock contention.
- Queue depth > 1 sees some prep work in this patch by adding a stall
paramater to drm_atomic_helper_swap_states(). To be able to push
commits entirely free-standing and in a deeper queue through the
back-end the driver must not access any obj->state pointers. This
means we need to track the old state in drm_atomic_state (much
easier with the consolidated arrays), and pass them all explicitly
to driver backends (this will be serious amounts of churn).
Once that's done stall can be set to false in swap_states.
v2: Dont ask for flip_done signalling when the CRTC is off and stays
off: Drivers don't handle events in that case. Instead complete right
away. This way future commits don't need to have special-case logic,
but can keep blocking for the flip_done completion.
v3: Tons of fixes:
- Stall for preceeding commit for real, not the current one by
accident.
- Add WARN_ON in case drivers don't fire the drm event.
- Don't double-free drm events.
v4: Make legacy cursor not stall.
v5: Extend the helper hook to cover the entire commit tail. Some
drivers need special code for cleanup and vblank waiting, this makes
it a bit more useful. Inspired by the rockchip driver.
v6: Add WARN_ON to catch drivers who forget to send out the
drm event.
v7: Fixup the stalls in swap_state for real!!
v8:
- Fixup trailing whitespace, spotted by Maarten.
- Actually wait for flip_done in cleanup_done, like the comment says
we should do. Thanks a lot for Tomeu for helping with debugging this
on.
v9: Now with awesome kerneldoc!
v10: Split out drm_crtc_commit tracking infrastructure.
v:
- Add missing static (Gustavo).
- Split out the sync functions, only do the actual nonblocking
logic in this patch (Maarten).
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Tested-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Tomeu Vizoso <tomeu.vizoso@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Tested-by: Liviu Dudau <Liviu.Dudau@arm.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Testcase: igt/kms_flip/*
Testcase: igt/kms_cursor*
Testcase: igt/kms*plane*
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1465388359-8070-10-git-send-email-daniel.vetter@ffwll.ch
2016-06-08 12:19:02 +00:00
|
|
|
};
|
|
|
|
|
2015-12-04 08:45:44 +00:00
|
|
|
#endif
|