Skip to content

Commit ae4d721

Browse files
Abhinav Kumarlumag
authored andcommitted
drm/msm/dpu: add an API to reset the encoder related hw blocks
Add an API to reset the encoder related hw blocks to ensure a proper teardown of the pipeline. At the moment this is being used only for the writeback encoder but eventually we can start using this for all interfaces. changes in v4: - none Signed-off-by: Abhinav Kumar <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/483512/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 6d08480 commit ae4d721

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

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

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (c) 2014-2018, 2020-2021 The Linux Foundation. All rights reserved.
43
* Copyright (C) 2013 Red Hat
4+
* Copyright (c) 2014-2018, 2020-2021 The Linux Foundation. All rights reserved.
5+
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
6+
*
57
* Author: Rob Clark <[email protected]>
68
*/
79

@@ -22,6 +24,7 @@
2224
#include "dpu_hw_ctl.h"
2325
#include "dpu_hw_dspp.h"
2426
#include "dpu_hw_dsc.h"
27+
#include "dpu_hw_merge3d.h"
2528
#include "dpu_formats.h"
2629
#include "dpu_encoder_phys.h"
2730
#include "dpu_crtc.h"
@@ -1838,6 +1841,86 @@ void dpu_encoder_kickoff(struct drm_encoder *drm_enc)
18381841
DPU_ATRACE_END("encoder_kickoff");
18391842
}
18401843

1844+
static void dpu_encoder_helper_reset_mixers(struct dpu_encoder_phys *phys_enc)
1845+
{
1846+
struct dpu_hw_mixer_cfg mixer;
1847+
int i, num_lm;
1848+
u32 flush_mask = 0;
1849+
struct dpu_global_state *global_state;
1850+
struct dpu_hw_blk *hw_lm[2];
1851+
struct dpu_hw_mixer *hw_mixer[2];
1852+
struct dpu_hw_ctl *ctl = phys_enc->hw_ctl;
1853+
1854+
memset(&mixer, 0, sizeof(mixer));
1855+
1856+
/* reset all mixers for this encoder */
1857+
if (phys_enc->hw_ctl->ops.clear_all_blendstages)
1858+
phys_enc->hw_ctl->ops.clear_all_blendstages(phys_enc->hw_ctl);
1859+
1860+
global_state = dpu_kms_get_existing_global_state(phys_enc->dpu_kms);
1861+
1862+
num_lm = dpu_rm_get_assigned_resources(&phys_enc->dpu_kms->rm, global_state,
1863+
phys_enc->parent->base.id, DPU_HW_BLK_LM, hw_lm, ARRAY_SIZE(hw_lm));
1864+
1865+
for (i = 0; i < num_lm; i++) {
1866+
hw_mixer[i] = to_dpu_hw_mixer(hw_lm[i]);
1867+
flush_mask = phys_enc->hw_ctl->ops.get_bitmask_mixer(ctl, hw_mixer[i]->idx);
1868+
if (phys_enc->hw_ctl->ops.update_pending_flush)
1869+
phys_enc->hw_ctl->ops.update_pending_flush(ctl, flush_mask);
1870+
1871+
/* clear all blendstages */
1872+
if (phys_enc->hw_ctl->ops.setup_blendstage)
1873+
phys_enc->hw_ctl->ops.setup_blendstage(ctl, hw_mixer[i]->idx, NULL);
1874+
}
1875+
}
1876+
1877+
void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc)
1878+
{
1879+
struct dpu_hw_ctl *ctl = phys_enc->hw_ctl;
1880+
struct dpu_hw_intf_cfg intf_cfg = { 0 };
1881+
int i;
1882+
struct dpu_encoder_virt *dpu_enc;
1883+
1884+
dpu_enc = to_dpu_encoder_virt(phys_enc->parent);
1885+
1886+
phys_enc->hw_ctl->ops.reset(ctl);
1887+
1888+
dpu_encoder_helper_reset_mixers(phys_enc);
1889+
1890+
for (i = 0; i < dpu_enc->num_phys_encs; i++) {
1891+
if (dpu_enc->phys_encs[i] && phys_enc->hw_intf->ops.bind_pingpong_blk)
1892+
phys_enc->hw_intf->ops.bind_pingpong_blk(
1893+
dpu_enc->phys_encs[i]->hw_intf, false,
1894+
dpu_enc->phys_encs[i]->hw_pp->idx);
1895+
1896+
/* mark INTF flush as pending */
1897+
if (phys_enc->hw_ctl->ops.update_pending_flush_intf)
1898+
phys_enc->hw_ctl->ops.update_pending_flush_intf(phys_enc->hw_ctl,
1899+
dpu_enc->phys_encs[i]->hw_intf->idx);
1900+
}
1901+
1902+
/* reset the merge 3D HW block */
1903+
if (phys_enc->hw_pp->merge_3d) {
1904+
phys_enc->hw_pp->merge_3d->ops.setup_3d_mode(phys_enc->hw_pp->merge_3d,
1905+
BLEND_3D_NONE);
1906+
if (phys_enc->hw_ctl->ops.update_pending_flush_merge_3d)
1907+
phys_enc->hw_ctl->ops.update_pending_flush_merge_3d(ctl,
1908+
phys_enc->hw_pp->merge_3d->idx);
1909+
}
1910+
1911+
intf_cfg.stream_sel = 0; /* Don't care value for video mode */
1912+
intf_cfg.mode_3d = dpu_encoder_helper_get_3d_blend_mode(phys_enc);
1913+
if (phys_enc->hw_pp->merge_3d)
1914+
intf_cfg.merge_3d = phys_enc->hw_pp->merge_3d->idx;
1915+
1916+
if (ctl->ops.reset_intf_cfg)
1917+
ctl->ops.reset_intf_cfg(ctl, &intf_cfg);
1918+
1919+
ctl->ops.trigger_flush(ctl);
1920+
ctl->ops.trigger_start(ctl);
1921+
ctl->ops.clear_pending_flush(ctl);
1922+
}
1923+
18411924
void dpu_encoder_prepare_commit(struct drm_encoder *drm_enc)
18421925
{
18431926
struct dpu_encoder_virt *dpu_enc;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
/*
3+
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
34
* Copyright (c) 2015-2018 The Linux Foundation. All rights reserved.
45
*/
56

@@ -350,4 +351,10 @@ int dpu_encoder_helper_wait_for_irq(struct dpu_encoder_phys *phys_enc,
350351
void (*func)(void *arg, int irq_idx),
351352
struct dpu_encoder_wait_info *wait_info);
352353

354+
/**
355+
* dpu_encoder_helper_phys_cleanup - helper to cleanup dpu pipeline
356+
* @phys_enc: Pointer to physical encoder structure
357+
*/
358+
void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc);
359+
353360
#endif /* __dpu_encoder_phys_H__ */

0 commit comments

Comments
 (0)