drm: Add drm_atomic_get_(old|new)_connector_for_encoder() helpers
Add functions to the atomic core to retrieve the old and new connectors associated with an encoder in a drm_atomic_state. This is useful for encoders and bridges that need to access the connector, for instance for the drm_display_info. The CRTC associated with the encoder can also be retrieved through the connector state, and from it, the old and new CRTC states. Changed in v4: - Added to the set Changed in v5: - Fix up docbook (Daniel & Laurent) Changed in v6: - Updated commit subject (Sam) Link to v4: https://patchwork.freedesktop.org/patch/msgid/20190508160920.144739-3-sean@poorly.run Link to v5: https://patchwork.freedesktop.org/patch/msgid/20190611160844.257498-3-sean@poorly.run Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Sam Ravnborg <sam@ravnborg.org> Tested-by: Heiko Stuebner <heiko@sntech.de> Reviewed-by: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [seanpaul removed WARNs from helpers and added docs to explain why returning NULL might be valid] Signed-off-by: Sean Paul <seanpaul@chromium.org> Link: https://patchwork.freedesktop.org/patch/msgid/20190611205147.181298-1-sean@poorly.run
This commit is contained in:
parent
43c76d72ea
commit
1b27fbdde1
|
@ -846,6 +846,75 @@ drm_atomic_get_new_private_obj_state(struct drm_atomic_state *state,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_atomic_get_new_private_obj_state);
|
EXPORT_SYMBOL(drm_atomic_get_new_private_obj_state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* drm_atomic_get_old_connector_for_encoder - Get old connector for an encoder
|
||||||
|
* @state: Atomic state
|
||||||
|
* @encoder: The encoder to fetch the connector state for
|
||||||
|
*
|
||||||
|
* This function finds and returns the connector that was connected to @encoder
|
||||||
|
* as specified by the @state.
|
||||||
|
*
|
||||||
|
* If there is no connector in @state which previously had @encoder connected to
|
||||||
|
* it, this function will return NULL. While this may seem like an invalid use
|
||||||
|
* case, it is sometimes useful to differentiate commits which had no prior
|
||||||
|
* connectors attached to @encoder vs ones that did (and to inspect their
|
||||||
|
* state). This is especially true in enable hooks because the pipeline has
|
||||||
|
* changed.
|
||||||
|
*
|
||||||
|
* Returns: The old connector connected to @encoder, or NULL if the encoder is
|
||||||
|
* not connected.
|
||||||
|
*/
|
||||||
|
struct drm_connector *
|
||||||
|
drm_atomic_get_old_connector_for_encoder(struct drm_atomic_state *state,
|
||||||
|
struct drm_encoder *encoder)
|
||||||
|
{
|
||||||
|
struct drm_connector_state *conn_state;
|
||||||
|
struct drm_connector *connector;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for_each_old_connector_in_state(state, connector, conn_state, i) {
|
||||||
|
if (conn_state->best_encoder == encoder)
|
||||||
|
return connector;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(drm_atomic_get_old_connector_for_encoder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* drm_atomic_get_new_connector_for_encoder - Get new connector for an encoder
|
||||||
|
* @state: Atomic state
|
||||||
|
* @encoder: The encoder to fetch the connector state for
|
||||||
|
*
|
||||||
|
* This function finds and returns the connector that will be connected to
|
||||||
|
* @encoder as specified by the @state.
|
||||||
|
*
|
||||||
|
* If there is no connector in @state which will have @encoder connected to it,
|
||||||
|
* this function will return NULL. While this may seem like an invalid use case,
|
||||||
|
* it is sometimes useful to differentiate commits which have no connectors
|
||||||
|
* attached to @encoder vs ones that do (and to inspect their state). This is
|
||||||
|
* especially true in disable hooks because the pipeline will change.
|
||||||
|
*
|
||||||
|
* Returns: The new connector connected to @encoder, or NULL if the encoder is
|
||||||
|
* not connected.
|
||||||
|
*/
|
||||||
|
struct drm_connector *
|
||||||
|
drm_atomic_get_new_connector_for_encoder(struct drm_atomic_state *state,
|
||||||
|
struct drm_encoder *encoder)
|
||||||
|
{
|
||||||
|
struct drm_connector_state *conn_state;
|
||||||
|
struct drm_connector *connector;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for_each_new_connector_in_state(state, connector, conn_state, i) {
|
||||||
|
if (conn_state->best_encoder == encoder)
|
||||||
|
return connector;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(drm_atomic_get_new_connector_for_encoder);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* drm_atomic_get_connector_state - get connector state
|
* drm_atomic_get_connector_state - get connector state
|
||||||
* @state: global atomic state object
|
* @state: global atomic state object
|
||||||
|
|
|
@ -459,6 +459,13 @@ struct drm_private_state *
|
||||||
drm_atomic_get_new_private_obj_state(struct drm_atomic_state *state,
|
drm_atomic_get_new_private_obj_state(struct drm_atomic_state *state,
|
||||||
struct drm_private_obj *obj);
|
struct drm_private_obj *obj);
|
||||||
|
|
||||||
|
struct drm_connector *
|
||||||
|
drm_atomic_get_old_connector_for_encoder(struct drm_atomic_state *state,
|
||||||
|
struct drm_encoder *encoder);
|
||||||
|
struct drm_connector *
|
||||||
|
drm_atomic_get_new_connector_for_encoder(struct drm_atomic_state *state,
|
||||||
|
struct drm_encoder *encoder);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* drm_atomic_get_existing_crtc_state - get crtc state, if it exists
|
* drm_atomic_get_existing_crtc_state - get crtc state, if it exists
|
||||||
* @state: global atomic state object
|
* @state: global atomic state object
|
||||||
|
|
|
@ -518,6 +518,11 @@ struct drm_connector_state {
|
||||||
* &drm_connector_helper_funcs.atomic_best_encoder or
|
* &drm_connector_helper_funcs.atomic_best_encoder or
|
||||||
* &drm_connector_helper_funcs.best_encoder callbacks.
|
* &drm_connector_helper_funcs.best_encoder callbacks.
|
||||||
*
|
*
|
||||||
|
* This is also used in the atomic helpers to map encoders to their
|
||||||
|
* current and previous connectors, see
|
||||||
|
* &drm_atomic_get_old_connector_for_encoder() and
|
||||||
|
* &drm_atomic_get_new_connector_for_encoder().
|
||||||
|
*
|
||||||
* NOTE: Atomic drivers must fill this out (either themselves or through
|
* NOTE: Atomic drivers must fill this out (either themselves or through
|
||||||
* helpers), for otherwise the GETCONNECTOR and GETENCODER IOCTLs will
|
* helpers), for otherwise the GETCONNECTOR and GETENCODER IOCTLs will
|
||||||
* not return correct data to userspace.
|
* not return correct data to userspace.
|
||||||
|
|
Loading…
Reference in New Issue