Commit 2750caff authored by Wenjing Liu's avatar Wenjing Liu Committed by Alex Deucher

drm/amd/display: move get_link_hwss to dc_resource

[why]
Isolate the way to obtain link_hwss from the actual implemenation of
link_hwss. So the caller can call link_hwss without knowing the
implementation detail of link_hwss.
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Reviewed-by: default avatarJun Lei <Jun.Lei@amd.com>
Acked-by: default avatarStylon Wang <stylon.wang@amd.com>
Signed-off-by: default avatarWenjing Liu <wenjing.liu@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent dfabe597
......@@ -29,12 +29,6 @@ static void virtual_setup_stream_encoder(struct pipe_ctx *pipe_ctx);
static void virtual_reset_stream_encoder(struct pipe_ctx *pipe_ctx);
/************************* below goes to dio_link_hwss ************************/
static bool can_use_dio_link_hwss(const struct dc_link *link,
const struct link_resource *link_res)
{
return link->link_enc != NULL;
}
static void set_dio_throttled_vcp_size(struct pipe_ctx *pipe_ctx,
struct fixed31_32 throttled_vcp_size)
{
......@@ -135,14 +129,19 @@ static const struct link_hwss dio_link_hwss = {
},
};
/*********************** below goes to hpo_dp_link_hwss ***********************/
static bool can_use_dp_hpo_link_hwss(const struct dc_link *link,
bool can_use_dio_link_hwss(const struct dc_link *link,
const struct link_resource *link_res)
{
return link_res->hpo_dp_link_enc != NULL;
return link->link_enc != NULL;
}
static void set_dp_hpo_throttled_vcp_size(struct pipe_ctx *pipe_ctx,
const struct link_hwss *get_dio_link_hwss(void)
{
return &dio_link_hwss;
}
/*********************** below goes to hpo_dp_link_hwss ***********************/
static void set_hpo_dp_throttled_vcp_size(struct pipe_ctx *pipe_ctx,
struct fixed31_32 throttled_vcp_size)
{
struct hpo_dp_stream_encoder *hpo_dp_stream_encoder =
......@@ -155,7 +154,7 @@ static void set_dp_hpo_throttled_vcp_size(struct pipe_ctx *pipe_ctx,
throttled_vcp_size);
}
static void set_dp_hpo_hblank_min_symbol_width(struct pipe_ctx *pipe_ctx,
static void set_hpo_dp_hblank_min_symbol_width(struct pipe_ctx *pipe_ctx,
const struct dc_link_settings *link_settings,
struct fixed31_32 throttled_vcp_size)
{
......@@ -328,22 +327,27 @@ static const struct link_hwss hpo_dp_link_hwss = {
.setup_stream_encoder = setup_hpo_dp_stream_encoder,
.reset_stream_encoder = reset_hpo_dp_stream_encoder,
.ext = {
.set_throttled_vcp_size = set_dp_hpo_throttled_vcp_size,
.set_hblank_min_symbol_width = set_dp_hpo_hblank_min_symbol_width,
.set_throttled_vcp_size = set_hpo_dp_throttled_vcp_size,
.set_hblank_min_symbol_width = set_hpo_dp_hblank_min_symbol_width,
.enable_dp_link_output = enable_hpo_dp_link_output,
.disable_dp_link_output = disable_hpo_dp_link_output,
.set_dp_link_test_pattern = set_hpo_dp_link_test_pattern,
.set_dp_lane_settings = set_hpo_dp_lane_settings,
},
};
/*********************** below goes to dpia_link_hwss *************************/
static bool can_use_dpia_link_hwss(const struct dc_link *link,
bool can_use_hpo_dp_link_hwss(const struct dc_link *link,
const struct link_resource *link_res)
{
return link->is_dig_mapping_flexible &&
link->dc->res_pool->funcs->link_encs_assign;
return link_res->hpo_dp_link_enc != NULL;
}
const struct link_hwss *get_hpo_dp_link_hwss(void)
{
return &hpo_dp_link_hwss;
}
/*********************** below goes to dpia_link_hwss *************************/
static const struct link_hwss dpia_link_hwss = {
.setup_stream_encoder = setup_dio_stream_encoder,
.reset_stream_encoder = reset_dio_stream_encoder,
......@@ -356,7 +360,18 @@ static const struct link_hwss dpia_link_hwss = {
},
};
/*********************** below goes to link_hwss ******************************/
bool can_use_dpia_link_hwss(const struct dc_link *link,
const struct link_resource *link_res)
{
return link->is_dig_mapping_flexible &&
link->dc->res_pool->funcs->link_encs_assign;
}
const struct link_hwss *get_dpia_link_hwss(void)
{
return &dpia_link_hwss;
}
/*********************** below goes to virtual_link_hwss ******************************/
static void virtual_setup_stream_encoder(struct pipe_ctx *pipe_ctx)
{
}
......
......@@ -3310,3 +3310,36 @@ uint8_t resource_transmitter_to_phy_idx(const struct dc *dc, enum transmitter tr
#endif
return phy_idx;
}
const struct link_hwss *get_link_hwss(const struct dc_link *link,
const struct link_resource *link_res)
{
/* Link_hwss is only accessible by getter function instead of accessing
* by pointers in dc with the intent to protect against breaking polymorphism.
*/
if (can_use_hpo_dp_link_hwss(link, link_res))
/* TODO: some assumes that if decided link settings is 128b/132b
* channel coding format hpo_dp_link_enc should be used.
* Others believe that if hpo_dp_link_enc is available in link
* resource then hpo_dp_link_enc must be used. This bound between
* hpo_dp_link_enc != NULL and decided link settings is loosely coupled
* with a premise that both hpo_dp_link_enc pointer and decided link
* settings are determined based on single policy function like
* "decide_link_settings" from upper layer. This "convention"
* cannot be maintained and enforced at current level.
* Therefore a refactor is due so we can enforce a strong bound
* between those two parameters at this level.
*
* To put it simple, we want to make enforcement at low level so that
* we will not return link hwss if caller plans to do 8b/10b
* with an hpo encoder. Or we can return a very dummy one that doesn't
* do work for all functions
*/
return get_hpo_dp_link_hwss();
else if (can_use_dpia_link_hwss(link, link_res))
return get_dpia_link_hwss();
else if (can_use_dio_link_hwss(link, link_res))
return get_dio_link_hwss();
else
return get_virtual_link_hwss();
}
......@@ -75,6 +75,21 @@ struct link_hwss {
void (*reset_stream_encoder)(struct pipe_ctx *pipe_ctx);
};
const struct link_hwss *get_link_hwss(const struct dc_link *link, const struct link_resource *link_res);
/*********************** below goes to virtual_link_hwss **********************/
const struct link_hwss *get_virtual_link_hwss(void);
/*********************** below goes to dpia_link_hwss *************************/
bool can_use_dpia_link_hwss(const struct dc_link *link,
const struct link_resource *link_res);
const struct link_hwss *get_dpia_link_hwss(void);
/*********************** below goes to hpo_dp_link_hwss ***********************/
bool can_use_hpo_dp_link_hwss(const struct dc_link *link,
const struct link_resource *link_res);
const struct link_hwss *get_hpo_dp_link_hwss(void);
/************************* below goes to dio_link_hwss ************************/
bool can_use_dio_link_hwss(const struct dc_link *link,
const struct link_resource *link_res);
const struct link_hwss *get_dio_link_hwss(void);
#endif /* __DC_LINK_HWSS_H__ */
......@@ -213,4 +213,7 @@ void check_syncd_pipes_for_disabled_master_pipe(struct dc *dc,
uint8_t disabled_master_pipe_idx);
uint8_t resource_transmitter_to_phy_idx(const struct dc *dc, enum transmitter transmitter);
const struct link_hwss *get_link_hwss(const struct dc_link *link,
const struct link_resource *link_res);
#endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */
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