From: George Zhang <[email protected]> [why & how] Add functions to access the vblank_counter and scanoutpos of OTGs by instance number.
Cc: Sun peng Li <[email protected]> Signed-off-by: George Zhang <[email protected]> Signed-off-by: James Lin <[email protected]> --- .../gpu/drm/amd/display/dc/core/dc_stream.c | 38 +++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dc_stream.h | 6 +++ 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c index 56c7d97733a6..01b5ddd87289 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -862,6 +862,20 @@ uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream) return 0; } +uint32_t dc_otg_get_vblank_counter(struct dc *dc, int otg_inst) +{ + struct resource_context *res_ctx = &dc->current_state->res_ctx; + + dc_exit_ips_for_hw_access(dc); + + struct timing_generator *tg = res_ctx->pipe_ctx[otg_inst].stream_res.tg; + + if (!tg) + return 0; + + return tg->funcs->get_frame_count(tg); +} + bool dc_stream_send_dp_sdp(const struct dc_stream_state *stream, const uint8_t *custom_sdp_message, unsigned int sdp_message_size) @@ -937,6 +951,30 @@ bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream, return ret; } +bool dc_otg_get_scanoutpos(struct dc *dc, int otg_inst, + uint32_t *v_blank_start, + uint32_t *v_blank_end, + uint32_t *h_position, + uint32_t *v_position) +{ + struct resource_context *res_ctx = &dc->current_state->res_ctx; + + dc_exit_ips_for_hw_access(dc); + + struct timing_generator *tg = res_ctx->pipe_ctx[otg_inst].stream_res.tg; + + if (!tg) + return false; + + tg->funcs->get_scanoutpos(tg, + v_blank_start, + v_blank_end, + h_position, + v_position); + + return true; +} + bool dc_stream_dmdata_status_done(struct dc *dc, struct dc_stream_state *stream) { struct pipe_ctx *pipe = NULL; diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h index 94eccb87cbde..e507d334d598 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_stream.h +++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h @@ -452,6 +452,7 @@ struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i); * Return the current frame counter. */ uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream); +uint32_t dc_otg_get_vblank_counter(struct dc *dc, int otg_inst); /* * Send dp sdp message. @@ -469,6 +470,11 @@ bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream, uint32_t *v_blank_end, uint32_t *h_position, uint32_t *v_position); +bool dc_otg_get_scanoutpos(struct dc *dc, int otg_inst, + uint32_t *v_blank_start, + uint32_t *v_blank_end, + uint32_t *h_position, + uint32_t *v_position); bool dc_stream_add_writeback(struct dc *dc, struct dc_stream_state *stream, -- 2.43.0
