Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: add helper functions to retrieve old and new crtc

Add new helper functions, drm_atomic_get_old_crtc_for_encoder
and drm_atomic_get_new_crtc_for_encoder to retrieve the
corresponding crtc for the encoder.

Signed-off-by: Sankeerth Billakanti <quic_sbillaka@quicinc.com>
Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Patchwork: https://patchwork.freedesktop.org/patch/524718/
Link: https://lore.kernel.org/r/1677774797-31063-2-git-send-email-quic_vpolimer@quicinc.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

authored by

Vinod Polimera and committed by
Dmitry Baryshkov
7b9a9e35 dbd7a2a9

+67
+60
drivers/gpu/drm/drm_atomic.c
··· 985 985 EXPORT_SYMBOL(drm_atomic_get_new_connector_for_encoder); 986 986 987 987 /** 988 + * drm_atomic_get_old_crtc_for_encoder - Get old crtc for an encoder 989 + * @state: Atomic state 990 + * @encoder: The encoder to fetch the crtc state for 991 + * 992 + * This function finds and returns the crtc that was connected to @encoder 993 + * as specified by the @state. 994 + * 995 + * Returns: The old crtc connected to @encoder, or NULL if the encoder is 996 + * not connected. 997 + */ 998 + struct drm_crtc * 999 + drm_atomic_get_old_crtc_for_encoder(struct drm_atomic_state *state, 1000 + struct drm_encoder *encoder) 1001 + { 1002 + struct drm_connector *connector; 1003 + struct drm_connector_state *conn_state; 1004 + 1005 + connector = drm_atomic_get_old_connector_for_encoder(state, encoder); 1006 + if (!connector) 1007 + return NULL; 1008 + 1009 + conn_state = drm_atomic_get_old_connector_state(state, connector); 1010 + if (!conn_state) 1011 + return NULL; 1012 + 1013 + return conn_state->crtc; 1014 + } 1015 + EXPORT_SYMBOL(drm_atomic_get_old_crtc_for_encoder); 1016 + 1017 + /** 1018 + * drm_atomic_get_new_crtc_for_encoder - Get new crtc for an encoder 1019 + * @state: Atomic state 1020 + * @encoder: The encoder to fetch the crtc state for 1021 + * 1022 + * This function finds and returns the crtc that will be connected to @encoder 1023 + * as specified by the @state. 1024 + * 1025 + * Returns: The new crtc connected to @encoder, or NULL if the encoder is 1026 + * not connected. 1027 + */ 1028 + struct drm_crtc * 1029 + drm_atomic_get_new_crtc_for_encoder(struct drm_atomic_state *state, 1030 + struct drm_encoder *encoder) 1031 + { 1032 + struct drm_connector *connector; 1033 + struct drm_connector_state *conn_state; 1034 + 1035 + connector = drm_atomic_get_new_connector_for_encoder(state, encoder); 1036 + if (!connector) 1037 + return NULL; 1038 + 1039 + conn_state = drm_atomic_get_new_connector_state(state, connector); 1040 + if (!conn_state) 1041 + return NULL; 1042 + 1043 + return conn_state->crtc; 1044 + } 1045 + EXPORT_SYMBOL(drm_atomic_get_new_crtc_for_encoder); 1046 + 1047 + /** 988 1048 * drm_atomic_get_connector_state - get connector state 989 1049 * @state: global atomic state object 990 1050 * @connector: connector to get state object for
+7
include/drm/drm_atomic.h
··· 528 528 drm_atomic_get_new_connector_for_encoder(const struct drm_atomic_state *state, 529 529 struct drm_encoder *encoder); 530 530 531 + struct drm_crtc * 532 + drm_atomic_get_old_crtc_for_encoder(struct drm_atomic_state *state, 533 + struct drm_encoder *encoder); 534 + struct drm_crtc * 535 + drm_atomic_get_new_crtc_for_encoder(struct drm_atomic_state *state, 536 + struct drm_encoder *encoder); 537 + 531 538 /** 532 539 * drm_atomic_get_existing_crtc_state - get CRTC state, if it exists 533 540 * @state: global atomic state object