]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
drm/amd/display: audio dynamic resource acquired related
authorCharlene Liu <charlene.liu@amd.com>
Thu, 28 Sep 2017 03:23:16 +0000 (23:23 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Sat, 21 Oct 2017 20:46:16 +0000 (16:46 -0400)
Signed-off-by: Charlene Liu <charlene.liu@amd.com>
Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_link.c
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/dc.h
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/inc/core_types.h
drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h
drivers/gpu/drm/amd/display/dc/inc/resource.h

index e414e4770789f97bedc01dcc9069861b83110075..2d59f77fa9a27f64d5b6176b010c77492997b72f 100644 (file)
@@ -2323,14 +2323,14 @@ void core_link_enable_stream(
                allocate_mst_payload(pipe_ctx);
 }
 
-void core_link_disable_stream(struct pipe_ctx *pipe_ctx)
+void core_link_disable_stream(struct pipe_ctx *pipe_ctx, int option)
 {
        struct dc  *core_dc = pipe_ctx->stream->ctx->dc;
 
        if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
                deallocate_mst_payload(pipe_ctx);
 
-       core_dc->hwss.disable_stream(pipe_ctx);
+       core_dc->hwss.disable_stream(pipe_ctx, option);
 
        disable_link(pipe_ctx->stream->sink->link, pipe_ctx->stream->signal);
 }
index 34b6d1cb151eefd474fc593a1fc6e6b8fb718af9..9a33b471270a1c47fccc5f361af65ae58d95719e 100644 (file)
@@ -282,7 +282,7 @@ void dp_retrain_link_dp_test(struct dc_link *link,
 
                        dp_receiver_power_ctrl(link, false);
 
-                       link->dc->hwss.disable_stream(&pipes[i]);
+                       link->dc->hwss.disable_stream(&pipes[i], KEEP_ACQUIRED_RESOURCE);
 
                        link->link_enc->funcs->disable_output(
                                        link->link_enc,
index bbfec7cb2ad1952dcf27a3ccc157e139bc4af2f6..68c613229a1095fd59b627d0c62eaeee97d46b93 100644 (file)
@@ -242,7 +242,10 @@ bool resource_construct(
                        pool->stream_enc_count++;
                }
        }
-
+       dc->caps.dynamic_audio = false;
+       if (pool->audio_count < pool->stream_enc_count) {
+               dc->caps.dynamic_audio = true;
+       }
        for (i = 0; i < num_virtual_links; i++) {
                pool->stream_enc[pool->stream_enc_count] =
                        virtual_stream_encoder_create(
@@ -1330,7 +1333,7 @@ static void update_stream_engine_usage(
 }
 
 /* TODO: release audio object */
-static void update_audio_usage(
+void update_audio_usage(
                struct resource_context *res_ctx,
                const struct resource_pool *pool,
                struct audio *audio,
@@ -1414,12 +1417,21 @@ static struct audio *find_first_free_audio(
                const struct resource_pool *pool)
 {
        int i;
-       for (i = 0; i < pool->audio_count; i++) {
-               if (res_ctx->is_audio_acquired[i] == false) {
-                       return pool->audios[i];
+       if (pool->audio_count >=  pool->stream_enc_count) {
+               for (i = 0; i < pool->audio_count; i++) {
+                       if ((res_ctx->is_audio_acquired[i] == false) && (res_ctx->is_stream_enc_acquired[i] == true)) {
+                               /*we have enough audio endpoint, no need to do dynamic distribution*/
+                               return pool->audios[i];
+                       }
                }
-       }
+       } else { /*first come first serve*/
+               for (i = 0; i < pool->audio_count; i++) {
+                       if (res_ctx->is_audio_acquired[i] == false) {
 
+                               return pool->audios[i];
+                       }
+               }
+       }
        return 0;
 }
 
index adadfad2bd51dccaf314c849dd7e3362e7879638..2517fb821fffe4a754a885bccb363d0997f4828e 100644 (file)
@@ -58,6 +58,7 @@ struct dc_caps {
        uint32_t i2c_speed_in_khz;
        unsigned int max_cursor_size;
        bool dcc_const_color;
+       bool dynamic_audio;
 };
 
 struct dc_dcc_surface_param {
index 247e81806c4a4c7bb86fd0b03ce890906421a7ab..453d2ffd5c4a07803a589bf4f0758e10b3f4f5ba 100644 (file)
@@ -985,10 +985,11 @@ void hwss_edp_backlight_control(
        link_transmitter_control(link->dc->ctx->dc_bios, &cntl);
 }
 
-void dce110_disable_stream(struct pipe_ctx *pipe_ctx)
+void dce110_disable_stream(struct pipe_ctx *pipe_ctx, int option)
 {
        struct dc_stream_state *stream = pipe_ctx->stream;
        struct dc_link *link = stream->sink->link;
+       struct dc *dc = pipe_ctx->stream->ctx->dc;
 
        if (pipe_ctx->stream_res.audio) {
                pipe_ctx->stream_res.audio->funcs->az_disable(pipe_ctx->stream_res.audio);
@@ -999,6 +1000,13 @@ void dce110_disable_stream(struct pipe_ctx *pipe_ctx)
                else
                        pipe_ctx->stream_res.stream_enc->funcs->hdmi_audio_disable(
                                        pipe_ctx->stream_res.stream_enc);
+               /*don't free audio if it is from retrain or internal disable stream*/
+               if (option == FREE_ACQUIRED_RESOURCE && dc->caps.dynamic_audio == true) {
+                       /*we have to dynamic arbitrate the audio endpoints*/
+                       pipe_ctx->stream_res.audio = NULL;
+                       /*we free the resource, need reset is_audio_acquired*/
+                       update_audio_usage(&dc->current_state->res_ctx, dc->res_pool, pipe_ctx->stream_res.audio, false);
+               }
 
                /* TODO: notify audio driver for if audio modes list changed
                 * add audio mode list change flag */
@@ -1871,7 +1879,7 @@ static void dce110_reset_hw_ctx_wrap(
                                pipe_need_reprogram(pipe_ctx_old, pipe_ctx)) {
                        struct clock_source *old_clk = pipe_ctx_old->clock_source;
 
-                       core_link_disable_stream(pipe_ctx_old);
+                       core_link_disable_stream(pipe_ctx_old, FREE_ACQUIRED_RESOURCE);
                        pipe_ctx_old->stream_res.tg->funcs->set_blank(pipe_ctx_old->stream_res.tg, true);
                        if (!hwss_wait_for_blank_complete(pipe_ctx_old->stream_res.tg)) {
                                dm_error("DC: failed to blank crtc!\n");
index a1e964af60ac135d6849de9718d485f8600ee4c3..4d72bb99be9346baefab6ed2ab6da96f5210cc03 100644 (file)
@@ -47,7 +47,7 @@ void dce110_set_displaymarks(
 
 void dce110_enable_stream(struct pipe_ctx *pipe_ctx);
 
-void dce110_disable_stream(struct pipe_ctx *pipe_ctx);
+void dce110_disable_stream(struct pipe_ctx *pipe_ctx, int option);
 
 void dce110_unblank_stream(struct pipe_ctx *pipe_ctx,
                struct dc_link_settings *link_settings);
index 84d9d202d3b5bdb1ba830e8d015aae0b5c6ae191..072c48188b793e5cfe032a07e9a65cc7e00d45f1 100644 (file)
@@ -1025,7 +1025,7 @@ static void reset_back_end_for_pipe(
         * which is used by otg. Move disable_link after disable_crtc
         */
        if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment))
-               core_link_disable_stream(pipe_ctx);
+               core_link_disable_stream(pipe_ctx, FREE_ACQUIRED_RESOURCE);
 
        /* by upper caller loop, parent pipe: pipe0, will be reset last.
         * back end share by all pipes and will be disable only when disable
index ff23f268fe02e595bcbfd1590d4320a935e43502..5230dddc86171c79ebe5872acabbaa21639e8c2c 100644 (file)
@@ -58,6 +58,11 @@ struct link_init_data {
                                TODO: remove it when DC is complete. */
 };
 
+enum {
+       FREE_ACQUIRED_RESOURCE = 0,
+       KEEP_ACQUIRED_RESOURCE = 1,
+};
+
 struct dc_link *link_create(const struct link_init_data *init_params);
 void link_destroy(struct dc_link **link);
 
@@ -72,7 +77,7 @@ void core_link_enable_stream(
                struct dc_state *state,
                struct pipe_ctx *pipe_ctx);
 
-void core_link_disable_stream(struct pipe_ctx *pipe_ctx);
+void core_link_disable_stream(struct pipe_ctx *pipe_ctx, int option);
 
 void core_link_set_avmute(struct pipe_ctx *pipe_ctx, bool enable);
 /********** DAL Core*********************/
index bf3ab5d7398e34c57c82d41fb3e5424d43cd46a3..8734689a9245bfb46a031943e4c99cab3d65bef0 100644 (file)
@@ -134,7 +134,8 @@ struct hw_sequencer_funcs {
 
        void (*enable_stream)(struct pipe_ctx *pipe_ctx);
 
-       void (*disable_stream)(struct pipe_ctx *pipe_ctx);
+       void (*disable_stream)(struct pipe_ctx *pipe_ctx,
+                       int option);
 
        void (*unblank_stream)(struct pipe_ctx *pipe_ctx,
                        struct dc_link_settings *link_settings);
index 614bb691ab59d46db275f80c970b2d924df1140f..5467332faf7b00532925fa52069e93b29aa4ee34 100644 (file)
@@ -164,4 +164,9 @@ bool pipe_need_reprogram(
 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
                struct bit_depth_reduction_params *fmt_bit_depth);
 
+void update_audio_usage(
+               struct resource_context *res_ctx,
+               const struct resource_pool *pool,
+               struct audio *audio,
+               bool acquired);
 #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */