Skip to content

Commit 8b45a26

Browse files
Abhinav Kumarlumag
authored andcommitted
drm/msm/dpu: reserve cdm blocks for writeback in case of YUV output
Reserve CDM blocks for writeback if the format of the output fb is YUV. At the moment, the reservation is done only for writeback but can easily be extended by relaxing the checks once other interfaces are ready to output YUV. changes in v3: - squash CDM disable during encoder cleanup into this change changes in v2: - use needs_cdm from topology struct - drop fb related checks from atomic_mode_set() Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Patchwork: https://patchwork.freedesktop.org/patch/571838/ Link: https://lore.kernel.org/r/20231212205254.12422-14-quic_abhinavk@quicinc.com Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
1 parent f88c0c8 commit 8b45a26

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <drm/drm_crtc.h>
1717
#include <drm/drm_file.h>
1818
#include <drm/drm_probe_helper.h>
19+
#include <drm/drm_framebuffer.h>
1920

2021
#include "msm_drv.h"
2122
#include "dpu_kms.h"
@@ -26,6 +27,7 @@
2627
#include "dpu_hw_dspp.h"
2728
#include "dpu_hw_dsc.h"
2829
#include "dpu_hw_merge3d.h"
30+
#include "dpu_hw_cdm.h"
2931
#include "dpu_formats.h"
3032
#include "dpu_encoder_phys.h"
3133
#include "dpu_crtc.h"
@@ -584,6 +586,7 @@ static int dpu_encoder_virt_atomic_check(
584586
struct drm_display_mode *adj_mode;
585587
struct msm_display_topology topology;
586588
struct dpu_global_state *global_state;
589+
struct drm_framebuffer *fb;
587590
struct drm_dsc_config *dsc;
588591
int i = 0;
589592
int ret = 0;
@@ -624,6 +627,22 @@ static int dpu_encoder_virt_atomic_check(
624627

625628
topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, adj_mode, crtc_state, dsc);
626629

630+
/*
631+
* Use CDM only for writeback at the moment as other interfaces cannot handle it.
632+
* if writeback itself cannot handle cdm for some reason it will fail in its atomic_check()
633+
* earlier.
634+
*/
635+
if (dpu_enc->disp_info.intf_type == INTF_WB && conn_state->writeback_job) {
636+
fb = conn_state->writeback_job->fb;
637+
638+
if (fb && DPU_FORMAT_IS_YUV(to_dpu_format(msm_framebuffer_format(fb))))
639+
topology.needs_cdm = true;
640+
if (topology.needs_cdm && !dpu_enc->cur_master->hw_cdm)
641+
crtc_state->mode_changed = true;
642+
else if (!topology.needs_cdm && dpu_enc->cur_master->hw_cdm)
643+
crtc_state->mode_changed = true;
644+
}
645+
627646
/*
628647
* Release and Allocate resources on every modeset
629648
* Dont allocate when active is false.
@@ -1064,6 +1083,15 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,
10641083

10651084
dpu_enc->dsc_mask = dsc_mask;
10661085

1086+
if (dpu_enc->disp_info.intf_type == INTF_WB && conn_state->writeback_job) {
1087+
struct dpu_hw_blk *hw_cdm = NULL;
1088+
1089+
dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,
1090+
drm_enc->base.id, DPU_HW_BLK_CDM,
1091+
&hw_cdm, 1);
1092+
dpu_enc->cur_master->hw_cdm = hw_cdm ? to_dpu_hw_cdm(hw_cdm) : NULL;
1093+
}
1094+
10671095
cstate = to_dpu_crtc_state(crtc_state);
10681096

10691097
for (i = 0; i < num_lm; i++) {
@@ -2052,6 +2080,15 @@ void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc)
20522080
phys_enc->hw_pp->merge_3d->idx);
20532081
}
20542082

2083+
if (phys_enc->hw_cdm) {
2084+
if (phys_enc->hw_cdm->ops.bind_pingpong_blk && phys_enc->hw_pp)
2085+
phys_enc->hw_cdm->ops.bind_pingpong_blk(phys_enc->hw_cdm,
2086+
PINGPONG_NONE);
2087+
if (phys_enc->hw_ctl->ops.update_pending_flush_cdm)
2088+
phys_enc->hw_ctl->ops.update_pending_flush_cdm(phys_enc->hw_ctl,
2089+
phys_enc->hw_cdm->idx);
2090+
}
2091+
20552092
if (dpu_enc->dsc) {
20562093
dpu_encoder_unprep_dsc(dpu_enc);
20572094
dpu_enc->dsc = NULL;

0 commit comments

Comments
 (0)