// SPDX-License-Identifier: MIT /* * Copyright © 2023 Intel Corporation */ #include "i915_drv.h" #include <drm/display/drm_dp_tunnel.h> #include "intel_atomic.h" #include "intel_display_limits.h" #include "intel_display_types.h" #include "intel_dp.h" #include "intel_dp_link_training.h" #include "intel_dp_mst.h" #include "intel_dp_tunnel.h" #include "intel_link_bw.h" struct intel_dp_tunnel_inherited_state { … }; /** * intel_dp_tunnel_disconnect - Disconnect a DP tunnel from a port * @intel_dp: DP port object the tunnel is connected to * * Disconnect a DP tunnel from @intel_dp, destroying any related state. This * should be called after detecting a sink-disconnect event from the port. */ void intel_dp_tunnel_disconnect(struct intel_dp *intel_dp) { … } /** * intel_dp_tunnel_destroy - Destroy a DP tunnel * @intel_dp: DP port object the tunnel is connected to * * Destroy a DP tunnel connected to @intel_dp, after disabling the BW * allocation mode on the tunnel. This should be called while destroying the * port. */ void intel_dp_tunnel_destroy(struct intel_dp *intel_dp) { … } static int kbytes_to_mbits(int kbytes) { … } static int get_current_link_bw(struct intel_dp *intel_dp, bool *below_dprx_bw) { … } static int update_tunnel_state(struct intel_dp *intel_dp) { … } /* * Allocate the BW for a tunnel on a DP connector/port if the connector/port * was already active when detecting the tunnel. The allocated BW must be * freed by the next atomic modeset, storing the BW in the * intel_atomic_state::inherited_dp_tunnels, and calling * intel_dp_tunnel_atomic_free_bw(). */ static int allocate_initial_tunnel_bw_for_pipes(struct intel_dp *intel_dp, u8 pipe_mask) { … } static int allocate_initial_tunnel_bw(struct intel_dp *intel_dp, struct drm_modeset_acquire_ctx *ctx) { … } static int detect_new_tunnel(struct intel_dp *intel_dp, struct drm_modeset_acquire_ctx *ctx) { … } /** * intel_dp_tunnel_detect - Detect a DP tunnel on a port * @intel_dp: DP port object * @ctx: lock context acquired by the connector detection handler * * Detect a DP tunnel on the @intel_dp port, enabling the BW allocation mode * on it if supported and allocating the BW required on an already active port. * The BW allocated this way must be freed by the next atomic modeset calling * intel_dp_tunnel_atomic_free_bw(). * * If @intel_dp has already a tunnel detected on it, update the tunnel's state * wrt. its support for BW allocation mode and the available BW via the * tunnel. If the tunnel's state change requires this - for instance the * tunnel's group ID has changed - the tunnel will be dropped and recreated. * * Return 0 in case of success - after any tunnel detected and added to * @intel_dp - 1 in case the BW on an already existing tunnel has changed in a * way that requires notifying user space. */ int intel_dp_tunnel_detect(struct intel_dp *intel_dp, struct drm_modeset_acquire_ctx *ctx) { … } /** * intel_dp_tunnel_bw_alloc_is_enabled - Query the BW allocation support on a tunnel * @intel_dp: DP port object * * Query whether a DP tunnel is connected on @intel_dp and the tunnel supports * the BW allocation mode. * * Returns %true if the BW allocation mode is supported on @intel_dp. */ bool intel_dp_tunnel_bw_alloc_is_enabled(struct intel_dp *intel_dp) { … } /** * intel_dp_tunnel_suspend - Suspend a DP tunnel connected on a port * @intel_dp: DP port object * * Suspend a DP tunnel on @intel_dp with BW allocation mode enabled on it. */ void intel_dp_tunnel_suspend(struct intel_dp *intel_dp) { … } /** * intel_dp_tunnel_resume - Resume a DP tunnel connected on a port * @intel_dp: DP port object * @crtc_state: CRTC state * @dpcd_updated: the DPCD DPRX capabilities got updated during resume * * Resume a DP tunnel on @intel_dp with BW allocation mode enabled on it. */ void intel_dp_tunnel_resume(struct intel_dp *intel_dp, const struct intel_crtc_state *crtc_state, bool dpcd_updated) { … } static struct drm_dp_tunnel * get_inherited_tunnel(struct intel_atomic_state *state, struct intel_crtc *crtc) { … } static int add_inherited_tunnel(struct intel_atomic_state *state, struct drm_dp_tunnel *tunnel, struct intel_crtc *crtc) { … } static int check_inherited_tunnel_state(struct intel_atomic_state *state, struct intel_dp *intel_dp, const struct intel_digital_connector_state *old_conn_state) { … } /** * intel_dp_tunnel_atomic_cleanup_inherited_state - Free any inherited DP tunnel state * @state: Atomic state * * Free the inherited DP tunnel state in @state. */ void intel_dp_tunnel_atomic_cleanup_inherited_state(struct intel_atomic_state *state) { … } static int intel_dp_tunnel_atomic_add_group_state(struct intel_atomic_state *state, struct drm_dp_tunnel *tunnel) { … } /** * intel_dp_tunnel_atomic_add_state_for_crtc - Add CRTC specific DP tunnel state * @state: Atomic state * @crtc: CRTC to add the tunnel state for * * Add the DP tunnel state for @crtc if the CRTC (aka DP tunnel stream) is enabled * via a DP tunnel. * * Return 0 in case of success, a negative error code otherwise. */ int intel_dp_tunnel_atomic_add_state_for_crtc(struct intel_atomic_state *state, struct intel_crtc *crtc) { … } static int check_group_state(struct intel_atomic_state *state, struct intel_dp *intel_dp, struct intel_connector *connector, struct intel_crtc *crtc) { … } /** * intel_dp_tunnel_atomic_check_state - Check a connector's DP tunnel specific state * @state: Atomic state * @intel_dp: DP port object * @connector: connector using @intel_dp * * Check and add the DP tunnel atomic state for @intel_dp/@connector to * @state, if there is a DP tunnel detected on @intel_dp with BW allocation * mode enabled on it, or if @intel_dp/@connector was previously enabled via a * DP tunnel. * * Returns 0 in case of success, or a negative error code otherwise. */ int intel_dp_tunnel_atomic_check_state(struct intel_atomic_state *state, struct intel_dp *intel_dp, struct intel_connector *connector) { … } /** * intel_dp_tunnel_atomic_compute_stream_bw - Compute the BW required by a DP tunnel stream * @state: Atomic state * @intel_dp: DP object * @connector: connector using @intel_dp * @crtc_state: state of CRTC of the given DP tunnel stream * * Compute the required BW of CRTC (aka DP tunnel stream), storing this BW to * the DP tunnel state containing the stream in @state. Before re-calculating a * BW requirement in the crtc_state state the old BW requirement computed by this * function must be cleared by calling intel_dp_tunnel_atomic_clear_stream_bw(). * * Returns 0 in case of success, a negative error code otherwise. */ int intel_dp_tunnel_atomic_compute_stream_bw(struct intel_atomic_state *state, struct intel_dp *intel_dp, const struct intel_connector *connector, struct intel_crtc_state *crtc_state) { … } /** * intel_dp_tunnel_atomic_clear_stream_bw - Clear any DP tunnel stream BW requirement * @state: Atomic state * @crtc_state: state of CRTC of the given DP tunnel stream * * Clear any DP tunnel stream BW requirement set by * intel_dp_tunnel_atomic_compute_stream_bw(). */ void intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state, struct intel_crtc_state *crtc_state) { … } /** * intel_dp_tunnel_atomic_check_link - Check the DP tunnel atomic state * @state: intel atomic state * @limits: link BW limits * * Check the link configuration for all DP tunnels in @state. If the * configuration is invalid @limits will be updated if possible to * reduce the total BW, after which the configuration for all CRTCs in * @state must be recomputed with the updated @limits. * * Returns: * - 0 if the confugration is valid * - %-EAGAIN, if the configuration is invalid and @limits got updated * with fallback values with which the configuration of all CRTCs in * @state must be recomputed * - Other negative error, if the configuration is invalid without a * fallback possibility, or the check failed for another reason */ int intel_dp_tunnel_atomic_check_link(struct intel_atomic_state *state, struct intel_link_bw_limits *limits) { … } static void atomic_decrease_bw(struct intel_atomic_state *state) { … } static void queue_retry_work(struct intel_atomic_state *state, struct drm_dp_tunnel *tunnel, const struct intel_crtc_state *crtc_state) { … } static void atomic_increase_bw(struct intel_atomic_state *state) { … } /** * intel_dp_tunnel_atomic_alloc_bw - Allocate the BW for all modeset tunnels * @state: Atomic state * * Allocate the required BW for all tunnels in @state. */ void intel_dp_tunnel_atomic_alloc_bw(struct intel_atomic_state *state) { … } /** * intel_dp_tunnel_mgr_init - Initialize the DP tunnel manager * @display: display device * * Initialize the DP tunnel manager. The tunnel manager will support the * detection/management of DP tunnels on all DP connectors, so the function * must be called after all these connectors have been registered already. * * Return 0 in case of success, a negative error code otherwise. */ int intel_dp_tunnel_mgr_init(struct intel_display *display) { … } /** * intel_dp_tunnel_mgr_cleanup - Clean up the DP tunnel manager state * @display: display device * * Clean up the DP tunnel manager state. */ void intel_dp_tunnel_mgr_cleanup(struct intel_display *display) { … }