]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: move get_link_hwss to dc_resource
authorWenjing Liu <wenjing.liu@amd.com>
Fri, 28 Jan 2022 14:04:06 +0000 (22:04 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 2 Feb 2022 23:26:32 +0000 (18:26 -0500)
[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: Daniel Wheeler <daniel.wheeler@amd.com>
Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Stylon Wang <stylon.wang@amd.com>
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
drivers/gpu/drm/amd/display/dc/inc/link_hwss.h
drivers/gpu/drm/amd/display/dc/inc/resource.h

index 96414f99c671fdbcf757782e9a62f5605f345f98..dab532cf52b97caa528221c340ba3ec64f7bc4a5 100644 (file)
@@ -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)
 {
 }
index 9af8794c5b2461ac457e9b3bf258ec6f877ba1dc..19e06331169d77fa51ce231808389244f2562299 100644 (file)
@@ -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();
+}
index 43c6c0e0ddd951aedcf5ff5f8e46b843504c1d5f..fd4bfa22eda8290540b09dadf845c7fcc8f58d33 100644 (file)
@@ -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__ */
+
index a02887f644b0ba09651efd3205b6c42299f67cd4..63ed28cbf8736beeee1ce49cd99159756386b0d7 100644 (file)
@@ -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_ */