Skip to content

Commit b40c837

Browse files
Paloma Arellanolumag
authored andcommitted
drm/msm/dpu: modify encoder programming for CDM over DP
Adjust the encoder format programming in the case of video mode for DP to accommodate CDM related changes. Changes in v4: - Remove hw_cdm check in dpu_encoder_needs_periph_flush() - Remove hw_cdm check when getting the fmt_fourcc in dpu_encoder_phys_vid_enable() Changes in v2: - Move timing engine programming to a separate patch from this one - Move update_pending_flush_periph() invocation completely to this patch - Change the logic of dpu_encoder_get_drm_fmt() so that it only calls drm_mode_is_420_only() instead of doing additional unnecessary checks - Create new functions msm_dp_needs_periph_flush() and it's supporting function dpu_encoder_needs_periph_flush() to check if the mode is YUV420 and VSC SDP is enabled before doing a peripheral flush Signed-off-by: Paloma Arellano <quic_parellan@quicinc.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Patchwork: https://patchwork.freedesktop.org/patch/579641/ Link: https://lore.kernel.org/r/20240222194025.25329-17-quic_parellan@quicinc.com Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
1 parent 21497a4 commit b40c837

File tree

5 files changed

+98
-1
lines changed

5 files changed

+98
-1
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,41 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
218218
15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
219219
};
220220

221+
u32 dpu_encoder_get_drm_fmt(struct dpu_encoder_phys *phys_enc)
222+
{
223+
struct drm_encoder *drm_enc;
224+
struct dpu_encoder_virt *dpu_enc;
225+
struct drm_display_info *info;
226+
struct drm_display_mode *mode;
227+
228+
drm_enc = phys_enc->parent;
229+
dpu_enc = to_dpu_encoder_virt(drm_enc);
230+
info = &dpu_enc->connector->display_info;
231+
mode = &phys_enc->cached_mode;
232+
233+
if (drm_mode_is_420_only(info, mode))
234+
return DRM_FORMAT_YUV420;
235+
236+
return DRM_FORMAT_RGB888;
237+
}
238+
239+
bool dpu_encoder_needs_periph_flush(struct dpu_encoder_phys *phys_enc)
240+
{
241+
struct drm_encoder *drm_enc;
242+
struct dpu_encoder_virt *dpu_enc;
243+
struct msm_display_info *disp_info;
244+
struct msm_drm_private *priv;
245+
struct drm_display_mode *mode;
246+
247+
drm_enc = phys_enc->parent;
248+
dpu_enc = to_dpu_encoder_virt(drm_enc);
249+
disp_info = &dpu_enc->disp_info;
250+
priv = drm_enc->dev->dev_private;
251+
mode = &phys_enc->cached_mode;
252+
253+
return phys_enc->hw_intf->cap->type == INTF_DP &&
254+
msm_dp_needs_periph_flush(priv->dp[disp_info->h_tile_instance[0]], mode);
255+
}
221256

222257
bool dpu_encoder_is_widebus_enabled(const struct drm_encoder *drm_enc)
223258
{

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,19 @@ static inline enum dpu_3d_blend_mode dpu_encoder_helper_get_3d_blend_mode(
334334
*/
335335
unsigned int dpu_encoder_helper_get_dsc(struct dpu_encoder_phys *phys_enc);
336336

337+
/**
338+
* dpu_encoder_get_drm_fmt - return DRM fourcc format
339+
* @phys_enc: Pointer to physical encoder structure
340+
*/
341+
u32 dpu_encoder_get_drm_fmt(struct dpu_encoder_phys *phys_enc);
342+
343+
/**
344+
* dpu_encoder_needs_periph_flush - return true if physical encoder requires
345+
* peripheral flush
346+
* @phys_enc: Pointer to physical encoder structure
347+
*/
348+
bool dpu_encoder_needs_periph_flush(struct dpu_encoder_phys *phys_enc);
349+
337350
/**
338351
* dpu_encoder_helper_split_config - split display configuration helper function
339352
* This helper function may be used by physical encoders to configure

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,12 @@ static int dpu_encoder_phys_vid_control_vblank_irq(
405405
static void dpu_encoder_phys_vid_enable(struct dpu_encoder_phys *phys_enc)
406406
{
407407
struct dpu_hw_ctl *ctl;
408+
const struct dpu_format *fmt;
409+
u32 fmt_fourcc;
408410

409411
ctl = phys_enc->hw_ctl;
412+
fmt_fourcc = dpu_encoder_get_drm_fmt(phys_enc);
413+
fmt = dpu_get_dpu_format(fmt_fourcc);
410414

411415
DPU_DEBUG_VIDENC(phys_enc, "\n");
412416

@@ -415,6 +419,8 @@ static void dpu_encoder_phys_vid_enable(struct dpu_encoder_phys *phys_enc)
415419

416420
dpu_encoder_helper_split_config(phys_enc, phys_enc->hw_intf->idx);
417421

422+
dpu_encoder_helper_phys_setup_cdm(phys_enc, fmt, CDM_CDWN_OUTPUT_HDMI);
423+
418424
dpu_encoder_phys_vid_setup_timing_engine(phys_enc);
419425

420426
/*
@@ -430,6 +436,16 @@ static void dpu_encoder_phys_vid_enable(struct dpu_encoder_phys *phys_enc)
430436
if (ctl->ops.update_pending_flush_merge_3d && phys_enc->hw_pp->merge_3d)
431437
ctl->ops.update_pending_flush_merge_3d(ctl, phys_enc->hw_pp->merge_3d->idx);
432438

439+
if (ctl->ops.update_pending_flush_cdm && phys_enc->hw_cdm)
440+
ctl->ops.update_pending_flush_cdm(ctl, phys_enc->hw_cdm->idx);
441+
442+
/*
443+
* Peripheral flush must be updated whenever flushing SDP packets is needed.
444+
* SDP packets are required for any YUV format (YUV420, YUV422, YUV444).
445+
*/
446+
if (ctl->ops.update_pending_flush_periph && dpu_encoder_needs_periph_flush(phys_enc))
447+
ctl->ops.update_pending_flush_periph(ctl, phys_enc->hw_intf->idx);
448+
433449
skip_flush:
434450
DPU_DEBUG_VIDENC(phys_enc,
435451
"update pending flush ctl %d intf %d\n",

drivers/gpu/drm/msm/dp/dp_display.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,24 @@ void __exit msm_dp_unregister(void)
13761376
platform_driver_unregister(&dp_display_driver);
13771377
}
13781378

1379+
bool msm_dp_is_yuv_420_enabled(const struct msm_dp *dp_display,
1380+
const struct drm_display_mode *mode)
1381+
{
1382+
struct dp_display_private *dp;
1383+
const struct drm_display_info *info;
1384+
1385+
dp = container_of(dp_display, struct dp_display_private, dp_display);
1386+
info = &dp_display->connector->display_info;
1387+
1388+
return dp->panel->vsc_sdp_supported && drm_mode_is_420_only(info, mode);
1389+
}
1390+
1391+
bool msm_dp_needs_periph_flush(const struct msm_dp *dp_display,
1392+
const struct drm_display_mode *mode)
1393+
{
1394+
return msm_dp_is_yuv_420_enabled(dp_display, mode);
1395+
}
1396+
13791397
bool msm_dp_wide_bus_available(const struct msm_dp *dp_display)
13801398
{
13811399
struct dp_display_private *dp;

drivers/gpu/drm/msm/msm_drv.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ void __exit msm_dp_unregister(void);
387387
int msm_dp_modeset_init(struct msm_dp *dp_display, struct drm_device *dev,
388388
struct drm_encoder *encoder);
389389
void msm_dp_snapshot(struct msm_disp_state *disp_state, struct msm_dp *dp_display);
390-
390+
bool msm_dp_is_yuv_420_enabled(const struct msm_dp *dp_display,
391+
const struct drm_display_mode *mode);
392+
bool msm_dp_needs_periph_flush(const struct msm_dp *dp_display,
393+
const struct drm_display_mode *mode);
391394
bool msm_dp_wide_bus_available(const struct msm_dp *dp_display);
392395

393396
#else
@@ -409,6 +412,18 @@ static inline void msm_dp_snapshot(struct msm_disp_state *disp_state, struct msm
409412
{
410413
}
411414

415+
static inline bool msm_dp_is_yuv_420_enabled(const struct msm_dp *dp_display,
416+
const struct drm_display_mode *mode)
417+
{
418+
return false;
419+
}
420+
421+
static inline bool msm_dp_needs_periph_flush(const struct msm_dp *dp_display,
422+
const struct drm_display_mode *mode)
423+
{
424+
return false;
425+
}
426+
412427
static inline bool msm_dp_wide_bus_available(const struct msm_dp *dp_display)
413428
{
414429
return false;

0 commit comments

Comments
 (0)