Commit ab2dd990 authored by Ville Syrjälä's avatar Ville Syrjälä

drm: Add __drm_atomic_helper_crtc_state_reset() & co.

Annoyingly __drm_atomic_helper_crtc_reset() does two
totally separate things:
a) reset the state to defaults values
b) assign the crtc->state pointer

I just want a) without the b) so let's split out part
a) into __drm_atomic_helper_crtc_state_reset(). And
of course we'll do the same thing for planes and connectors.

v2: Fix conn__state vs. conn_state typo (Lucas)
    Make code and kerneldoc match for
    __drm_atomic_helper_plane_state_reset()
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191107142417.11107-1-ville.syrjala@linux.intel.comReviewed-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 81ff52b7
...@@ -57,6 +57,22 @@ ...@@ -57,6 +57,22 @@
* for these functions. * for these functions.
*/ */
/**
* __drm_atomic_helper_crtc_state_reset - reset the CRTC state
* @crtc_state: atomic CRTC state, must not be NULL
* @crtc: CRTC object, must not be NULL
*
* Initializes the newly allocated @crtc_state with default
* values. This is useful for drivers that subclass the CRTC state.
*/
void
__drm_atomic_helper_crtc_state_reset(struct drm_crtc_state *crtc_state,
struct drm_crtc *crtc)
{
crtc_state->crtc = crtc;
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_state_reset);
/** /**
* __drm_atomic_helper_crtc_reset - reset state on CRTC * __drm_atomic_helper_crtc_reset - reset state on CRTC
* @crtc: drm CRTC * @crtc: drm CRTC
...@@ -74,7 +90,7 @@ __drm_atomic_helper_crtc_reset(struct drm_crtc *crtc, ...@@ -74,7 +90,7 @@ __drm_atomic_helper_crtc_reset(struct drm_crtc *crtc,
struct drm_crtc_state *crtc_state) struct drm_crtc_state *crtc_state)
{ {
if (crtc_state) if (crtc_state)
crtc_state->crtc = crtc; __drm_atomic_helper_crtc_state_reset(crtc_state, crtc);
crtc->state = crtc_state; crtc->state = crtc_state;
} }
...@@ -212,23 +228,43 @@ void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc, ...@@ -212,23 +228,43 @@ void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc,
EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state); EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state);
/** /**
* __drm_atomic_helper_plane_reset - resets planes state to default values * __drm_atomic_helper_plane_state_reset - resets plane state to default values
* @plane_state: atomic plane state, must not be NULL
* @plane: plane object, must not be NULL * @plane: plane object, must not be NULL
* @state: atomic plane state, must not be NULL
* *
* Initializes plane state to default. This is useful for drivers that subclass * Initializes the newly allocated @plane_state with default
* the plane state. * values. This is useful for drivers that subclass the CRTC state.
*/ */
void __drm_atomic_helper_plane_reset(struct drm_plane *plane, void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state,
struct drm_plane_state *state) struct drm_plane *plane)
{ {
state->plane = plane; plane_state->plane = plane;
state->rotation = DRM_MODE_ROTATE_0; plane_state->rotation = DRM_MODE_ROTATE_0;
state->alpha = DRM_BLEND_ALPHA_OPAQUE; plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;
state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
}
EXPORT_SYMBOL(__drm_atomic_helper_plane_state_reset);
/**
* __drm_atomic_helper_plane_reset - reset state on plane
* @plane: drm plane
* @plane_state: plane state to assign
*
* Initializes the newly allocated @plane_state and assigns it to
* the &drm_crtc->state pointer of @plane, usually required when
* initializing the drivers or when called from the &drm_plane_funcs.reset
* hook.
*
* This is useful for drivers that subclass the plane state.
*/
void __drm_atomic_helper_plane_reset(struct drm_plane *plane,
struct drm_plane_state *plane_state)
{
if (plane_state)
__drm_atomic_helper_plane_state_reset(plane_state, plane);
plane->state = state; plane->state = plane_state;
} }
EXPORT_SYMBOL(__drm_atomic_helper_plane_reset); EXPORT_SYMBOL(__drm_atomic_helper_plane_reset);
...@@ -335,6 +371,22 @@ void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane, ...@@ -335,6 +371,22 @@ void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane,
} }
EXPORT_SYMBOL(drm_atomic_helper_plane_destroy_state); EXPORT_SYMBOL(drm_atomic_helper_plane_destroy_state);
/**
* __drm_atomic_helper_connector_state_reset - reset the connector state
* @conn_state: atomic connector state, must not be NULL
* @connector: connectotr object, must not be NULL
*
* Initializes the newly allocated @conn_state with default
* values. This is useful for drivers that subclass the connector state.
*/
void
__drm_atomic_helper_connector_state_reset(struct drm_connector_state *conn_state,
struct drm_connector *connector)
{
conn_state->connector = connector;
}
EXPORT_SYMBOL(__drm_atomic_helper_connector_state_reset);
/** /**
* __drm_atomic_helper_connector_reset - reset state on connector * __drm_atomic_helper_connector_reset - reset state on connector
* @connector: drm connector * @connector: drm connector
...@@ -352,7 +404,7 @@ __drm_atomic_helper_connector_reset(struct drm_connector *connector, ...@@ -352,7 +404,7 @@ __drm_atomic_helper_connector_reset(struct drm_connector *connector,
struct drm_connector_state *conn_state) struct drm_connector_state *conn_state)
{ {
if (conn_state) if (conn_state)
conn_state->connector = connector; __drm_atomic_helper_connector_state_reset(conn_state, connector);
connector->state = conn_state; connector->state = conn_state;
} }
......
...@@ -37,6 +37,8 @@ struct drm_private_state; ...@@ -37,6 +37,8 @@ struct drm_private_state;
struct drm_modeset_acquire_ctx; struct drm_modeset_acquire_ctx;
struct drm_device; struct drm_device;
void __drm_atomic_helper_crtc_state_reset(struct drm_crtc_state *state,
struct drm_crtc *crtc);
void __drm_atomic_helper_crtc_reset(struct drm_crtc *crtc, void __drm_atomic_helper_crtc_reset(struct drm_crtc *crtc,
struct drm_crtc_state *state); struct drm_crtc_state *state);
void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc); void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc);
...@@ -48,6 +50,8 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state); ...@@ -48,6 +50,8 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state);
void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc, void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc,
struct drm_crtc_state *state); struct drm_crtc_state *state);
void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *state,
struct drm_plane *plane);
void __drm_atomic_helper_plane_reset(struct drm_plane *plane, void __drm_atomic_helper_plane_reset(struct drm_plane *plane,
struct drm_plane_state *state); struct drm_plane_state *state);
void drm_atomic_helper_plane_reset(struct drm_plane *plane); void drm_atomic_helper_plane_reset(struct drm_plane *plane);
...@@ -59,6 +63,8 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state); ...@@ -59,6 +63,8 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state);
void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane, void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane,
struct drm_plane_state *state); struct drm_plane_state *state);
void __drm_atomic_helper_connector_state_reset(struct drm_connector_state *conn_state,
struct drm_connector *connector);
void __drm_atomic_helper_connector_reset(struct drm_connector *connector, void __drm_atomic_helper_connector_reset(struct drm_connector *connector,
struct drm_connector_state *conn_state); struct drm_connector_state *conn_state);
void drm_atomic_helper_connector_reset(struct drm_connector *connector); void drm_atomic_helper_connector_reset(struct drm_connector *connector);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment