Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2021 Advanced Micro Devices, Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: AMD
0023  *
0024  */
0025 
0026 #ifndef DC_INC_LINK_ENC_CFG_H_
0027 #define DC_INC_LINK_ENC_CFG_H_
0028 
0029 /* This module implements functionality for dynamically assigning DIG link
0030  * encoder resources to display endpoints (links).
0031  */
0032 
0033 #include "core_types.h"
0034 
0035 /*
0036  * Initialise link encoder resource tracking.
0037  */
0038 void link_enc_cfg_init(
0039         const struct dc *dc,
0040         struct dc_state *state);
0041 
0042 /*
0043  * Copies a link encoder assignment from another state.
0044  */
0045 void link_enc_cfg_copy(const struct dc_state *src_ctx, struct dc_state *dst_ctx);
0046 
0047 /*
0048  * Algorithm for assigning available DIG link encoders to streams.
0049  *
0050  * Update link_enc_assignments table and link_enc_avail list accordingly in
0051  * struct resource_context.
0052  *
0053  * Loop over all streams twice:
0054  * a) First assign encoders to unmappable endpoints.
0055  * b) Then assign encoders to mappable endpoints.
0056  */
0057 void link_enc_cfg_link_encs_assign(
0058         struct dc *dc,
0059         struct dc_state *state,
0060         struct dc_stream_state *streams[],
0061         uint8_t stream_count);
0062 
0063 /*
0064  * Unassign a link encoder from a stream.
0065  *
0066  * Update link_enc_assignments table and link_enc_avail list accordingly in
0067  * struct resource_context.
0068  */
0069 void link_enc_cfg_link_enc_unassign(
0070         struct dc_state *state,
0071         struct dc_stream_state *stream);
0072 
0073 /*
0074  * Check whether the transmitter driven by a link encoder is a mappable
0075  * endpoint.
0076  */
0077 bool link_enc_cfg_is_transmitter_mappable(
0078         struct dc *dc,
0079         struct link_encoder *link_enc);
0080 
0081 /* Return stream using DIG link encoder resource. NULL if unused. */
0082 struct dc_stream_state *link_enc_cfg_get_stream_using_link_enc(
0083         struct dc *dc,
0084         enum engine_id eng_id);
0085 
0086 /* Return link using DIG link encoder resource. NULL if unused. */
0087 struct dc_link *link_enc_cfg_get_link_using_link_enc(
0088         struct dc *dc,
0089         enum engine_id eng_id);
0090 
0091 /* Return DIG link encoder used by link. NULL if unused. */
0092 struct link_encoder *link_enc_cfg_get_link_enc_used_by_link(
0093         struct dc *dc,
0094         const struct dc_link *link);
0095 
0096 /* Return next available DIG link encoder. NULL if none available. */
0097 struct link_encoder *link_enc_cfg_get_next_avail_link_enc(struct dc *dc);
0098 
0099 /* Return DIG link encoder used by stream. NULL if unused. */
0100 struct link_encoder *link_enc_cfg_get_link_enc_used_by_stream(
0101         struct dc *dc,
0102         const struct dc_stream_state *stream);
0103 
0104 /* Return DIG link encoder. NULL if unused. */
0105 struct link_encoder *link_enc_cfg_get_link_enc(const struct dc_link *link);
0106 
0107 /* Return DIG link encoder used by stream in current/previous state. NULL if unused. */
0108 struct link_encoder *link_enc_cfg_get_link_enc_used_by_stream_current(
0109         struct dc *dc,
0110         const struct dc_stream_state *stream);
0111 
0112 /* Return true if encoder available to use. */
0113 bool link_enc_cfg_is_link_enc_avail(struct dc *dc, enum engine_id eng_id, struct dc_link *link);
0114 
0115 /* Returns true if encoder assignments in supplied state pass validity checks. */
0116 bool link_enc_cfg_validate(struct dc *dc, struct dc_state *state);
0117 
0118 /* Set the link encoder assignment mode for the current_state to LINK_ENC_CFG_TRANSIENT mode.
0119  * This indicates that a new_state is in the process of being applied to hardware.
0120  * During this transition, old and new encoder assignments should be accessible from the old_state.
0121  * Only allow transition into transient mode if new encoder assignments are valid.
0122  */
0123 void link_enc_cfg_set_transient_mode(struct dc *dc, struct dc_state *current_state, struct dc_state *new_state);
0124 
0125 #endif /* DC_INC_LINK_ENC_CFG_H_ */