drm/msm: Add Display Stream Compression Support
Subsystems (5)
v7 cover drm/msm: Add Display Stream Compression Support
Display Stream Compression (DSC) compresses the display stream in host which is later decoded by panel. This series enables this for Qualcomm msm driver. This was tested on Google Pixel3 phone which use LGE SW43408 panel.
The changes include DSC data and hardware block enabling for DPU1 then support in encoder. We also add support in DSI and introduce required topology changes.
In order for panel to set the DSC parameters we add dsc in drm_panel and pass the dsc configuration from the panel driver
Complete changes which enable this for Pixel3 along with panel driver (not part of this series) and DT changes can be found at:
git.linaro.org/people/vinod.koul/kernel.git pixel/dsc_v7
Comments welcome!
Changes since v6:
- Fix warning reported by kbuild bot
- Add r-b by Dmitry
Changes since v5:
- rebase on msm-next
- use generated header patch from mesa for dsc registers
- use generated header macros for dsc register calculation
- remove msm dsc struct (Dmitry)
Changes since v4:
- Use new apprach based on Abhinav suggestion for dsc with 3d-merge
- Make common function for dsc timing caln and call that from video and cmd mode
- update description for patch "Pass DSC params to drm_panel"
- update couple of typos as pointed by Marijn
- drop dpu_encoder_dsc_pclk_param_calc() as that was duplicating the caln done in dsi timing
- Update copyright to 2022 to new files
- Update Abhinav's email to new quic one
Changes since v3:
- Merge changes from Dmitry to have dsc per encoder instance
- add warning for dsc and mode3d enabled together
- set dsc in dpu_encoder_phys_vid as well
- remove dsc hardcoded mask
- use devm_kzalloc for memory allocation for dsc
Changes since v2:
- Fix comments by Dimitry except the dsc being global.
- Move RM patch later for dependency on topology now
- Add patch for mode valid callback for dsi_mgr
- Add missing structure documentation patch
- Fix errors in mode_3d changes
- Rebase on v5.16-rc1 and test
Changes since v1:
- Fix various issues spotted by kbuildbot
- Rebase to v5.15-rc3
- Remove unused fields and duplicate defines
- Enable DSC blocks only when DSC is enabled
- remove sdm845 feature mask, use 0
- Check for DSC in hw_ctl
Changes since RFC:
- Drop the DT binding patch as we derive the configuration from panel
- Drop the drm api patch as we no longer need it (use pps drm api)
- Fix comments raised by Dimitry
- Add dsc parameters calculation from downstream
Dmitry Baryshkov (1):
drm/msm/dpu: don't use merge_3d if DSC merge topology is used
Vinod Koul (13):
drm/msm/dsi: add support for dsc data drm/msm/dsi: Pass DSC params to drm_panel drm/msm/disp/dpu1: Add support for DSC drm/msm/disp/dpu1: Add support for DSC in pingpong block drm/msm/disp/dpu1: Add DSC for SDM845 to hw_catalog drm/msm/disp/dpu1: Add DSC support in hw_ctl drm/msm/disp/dpu1: Add support for DSC in encoder drm/msm: Add missing num_dspp field documentation drm/msm/disp/dpu1: Add support for DSC in topology drm/msm/disp/dpu1: Add DSC support in RM drm/msm/dsi: add mode valid callback for dsi_mgr drm/msm: Update generated headers
drm/msm/dsi: Add support for DSC configuration
drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 157 +++++++++- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 8 + .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 12 +- .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c | 20 ++ .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h | 13 + drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 11 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c | 215 ++++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.h | 80 +++++ drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 13 + .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c | 32 ++ .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.h | 14 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 + drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 56 ++++ drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 1 + drivers/gpu/drm/msm/dsi/dsi.c | 5 + drivers/gpu/drm/msm/dsi/dsi.h | 3 + drivers/gpu/drm/msm/dsi/dsi.xml.h | 80 +++++ drivers/gpu/drm/msm/dsi/dsi_host.c | 276 +++++++++++++++++- drivers/gpu/drm/msm/dsi/dsi_manager.c | 12 + drivers/gpu/drm/msm/msm_drv.h | 15 + include/drm/drm_panel.h | 7 + 24 files changed, 1032 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c create mode 100644 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.h
Signature · 1 line
2.34.1
PATCH v7 1/14 drm/msm/dsi: add support for dsc data
Display Stream Compression (DSC) parameters need to be calculated. Add helpers and struct msm_display_dsc_config in msm_drv for this msm_display_dsc_config uses drm_dsc_config for DSC parameters.
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 130 +++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_drv.h | 6 ++ 2 files changed, 136 insertions(+)
drivers/gpu/drm/msm/dsi/dsi_host.c +130 -0
@@ -31,6 +31,8 @@#define DSI_RESET_TOGGLE_DELAY_MS 20 +static int dsi_populate_dsc_params (struct msm_display_dsc_config *dsc); +static int dsi_get_version (const void __iomem *base,u32 *major,u32 *minor) {u32 ver;
@@ -157,6 +159,7 @@ struct msm_dsi_host {struct regmap *sfpb;struct drm_display_mode *mode; +struct msm_display_dsc_config *dsc;/* connected device info */ struct device_node *device_node;
@@ -1722,6 +1725,133 @@ static int dsi_host_parse_lane_data(struct msm_dsi_host *msm_host,return -EINVAL ; } +static u32 dsi_dsc_rc_buf_thresh[DSC_NUM_BUF_RANGES -1 ] = { +0x0e ,0x1c ,0x2a ,0x38 ,0x46 ,0x54 ,0x62 , +0x69 ,0x70 ,0x77 ,0x79 ,0x7b ,0x7d ,0x7e +}; + +/* only 8bpc, 8bpp added */ +static char min_qp[DSC_NUM_BUF_RANGES ] = { +0 ,0 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,5 ,5 ,5 ,7 ,13 +}; + +static char max_qp[DSC_NUM_BUF_RANGES ] = { +4 ,4 ,5 ,6 ,7 ,7 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,13 ,15 +}; + +static char bpg_offset[DSC_NUM_BUF_RANGES ] = { +2 ,0 ,0 ,-2 ,-4 ,-6 ,-8 ,-8 ,-8 ,-10 ,-10 ,-12 ,-12 ,-12 ,-12 +}; + +static int dsi_populate_dsc_params (struct msm_display_dsc_config *dsc) +{ +int mux_words_size; +int groups_per_line, groups_total; +int min_rate_buffer_size; +int hrd_delay; +int pre_num_extra_mux_bits, num_extra_mux_bits; +int slice_bits; +int target_bpp_x16; +int data; +int final_value, final_scale; +int i; + + dsc->drm->rc_model_size =8192 ; + dsc->drm->first_line_bpg_offset =12 ; + dsc->drm->rc_edge_factor =6 ; + dsc->drm->rc_tgt_offset_high =3 ; + dsc->drm->rc_tgt_offset_low =3 ; + dsc->drm->simple_422 =0 ; + dsc->drm->convert_rgb =1 ; + dsc->drm->vbr_enable =0 ; + +/* handle only bpp = bpc = 8 */ +for (i =0 ; i <DSC_NUM_BUF_RANGES -1 ; i++) + dsc->drm->rc_buf_thresh[i] = dsi_dsc_rc_buf_thresh[i]; + +for (i =0 ; i <DSC_NUM_BUF_RANGES ; i++) { + dsc->drm->rc_range_params[i].range_min_qp = min_qp[i]; + dsc->drm->rc_range_params[i].range_max_qp = max_qp[i]; + dsc->drm->rc_range_params[i].range_bpg_offset = bpg_offset[i]; + } + + dsc->drm->initial_offset =6144 ;/* Not bpp 12 */ +if (dsc->drm->bits_per_pixel !=8 ) + dsc->drm->initial_offset =2048 ;/* bpp = 12 */ + + mux_words_size =48 ;/* bpc == 8/10 */ +if (dsc->drm->bits_per_component ==12 ) + mux_words_size =64 ; + + dsc->drm->initial_xmit_delay =512 ; + dsc->drm->initial_scale_value =32 ; + dsc->drm->first_line_bpg_offset =12 ; + dsc->drm->line_buf_depth = dsc->drm->bits_per_component +1 ; + +/* bpc 8 */ + dsc->drm->flatness_min_qp =3 ; + dsc->drm->flatness_max_qp =12 ; + dsc->drm->rc_quant_incr_limit0 =11 ; + dsc->drm->rc_quant_incr_limit1 =11 ; + dsc->drm->mux_word_size =DSC_MUX_WORD_SIZE_8_10_BPC ; + +/* FIXME: need to call drm_dsc_compute_rc_parameters() so that rest of +* params are calculated +*/ + groups_per_line =DIV_ROUND_UP (dsc->drm->slice_width,3 ); + dsc->drm->slice_chunk_size = dsc->drm->slice_width * dsc->drm->bits_per_pixel /8 ; +if ((dsc->drm->slice_width * dsc->drm->bits_per_pixel) %8 ) + dsc->drm->slice_chunk_size++; + +/* rbs-min */ + min_rate_buffer_size = dsc->drm->rc_model_size - dsc->drm->initial_offset + + dsc->drm->initial_xmit_delay * dsc->drm->bits_per_pixel + + groups_per_line * dsc->drm->first_line_bpg_offset; + + hrd_delay =DIV_ROUND_UP (min_rate_buffer_size, dsc->drm->bits_per_pixel); + + dsc->drm->initial_dec_delay = hrd_delay - dsc->drm->initial_xmit_delay; + + dsc->drm->initial_scale_value =8 * dsc->drm->rc_model_size / + (dsc->drm->rc_model_size - dsc->drm->initial_offset); + + slice_bits =8 * dsc->drm->slice_chunk_size * dsc->drm->slice_height; + + groups_total = groups_per_line * dsc->drm->slice_height; + + data = dsc->drm->first_line_bpg_offset *2048 ; + + dsc->drm->nfl_bpg_offset =DIV_ROUND_UP (data, (dsc->drm->slice_height -1 )); + + pre_num_extra_mux_bits =3 * (mux_words_size + (4 * dsc->drm->bits_per_component +4 ) -2 ); + + num_extra_mux_bits = pre_num_extra_mux_bits - (mux_words_size - + ((slice_bits - pre_num_extra_mux_bits) % mux_words_size)); + + data =2048 * (dsc->drm->rc_model_size - dsc->drm->initial_offset + num_extra_mux_bits); + dsc->drm->slice_bpg_offset =DIV_ROUND_UP (data, groups_total); + +/* bpp * 16 + 0.5 */ + data = dsc->drm->bits_per_pixel *16 ; + data *=2 ; + data++; + data /=2 ; + target_bpp_x16 = data; + + data = (dsc->drm->initial_xmit_delay * target_bpp_x16) /16 ; + final_value = dsc->drm->rc_model_size - data + num_extra_mux_bits; + dsc->drm->final_offset = final_value; + + final_scale =8 * dsc->drm->rc_model_size / (dsc->drm->rc_model_size - final_value); + + data = (final_scale -9 ) * (dsc->drm->nfl_bpg_offset + dsc->drm->slice_bpg_offset); + dsc->drm->scale_increment_interval = (2048 * dsc->drm->final_offset) / data; + + dsc->drm->scale_decrement_interval = groups_per_line / (dsc->drm->initial_scale_value -8 ); + +return 0 ; +} +static int dsi_host_parse_dt (struct msm_dsi_host *msm_host) {struct device *dev = &msm_host->pdev->dev;
drivers/gpu/drm/msm/msm_drv.h +6 -0
@@ -30,6 +30,7 @@#include <drm/drm_plane_helper.h> #include <drm/drm_probe_helper.h> #include <drm/drm_fb_helper.h> +#include <drm/drm_dsc.h> #include <drm/msm_drm.h> #include <drm/drm_gem.h>
@@ -116,6 +117,11 @@ struct msm_drm_thread {struct kthread_worker *worker; }; +/* DSC config */ +struct msm_display_dsc_config { +struct drm_dsc_config *drm; +}; +struct msm_drm_private {struct drm_device *dev;
Signature · 1 line
2.34.1
PATCH v7 2/14 drm/msm/dsi: Pass DSC params to drm_panel
In reply to Vinod KoulWhen DSC is enabled, we need to get the DSC parameters from the panel driver, so add a dsc parameter in panel to fetch and pass DSC configuration for DSI panels to DPU encoder, which will enable and then configure DSC hardware blocks accordingly.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 2 ++ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 2 ++ drivers/gpu/drm/msm/dsi/dsi.c | 5 +++++ drivers/gpu/drm/msm/dsi/dsi.h | 1 + drivers/gpu/drm/msm/dsi/dsi_host.c | 22 +++++++++++++++++++++ drivers/gpu/drm/msm/msm_drv.h | 6 ++++++ include/drm/drm_panel.h | 7 +++++++ 7 files changed, 45 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +2 -0
@@ -27,6 +27,7 @@* based on num_of_h_tiles * @is_te_using_watchdog_timer: Boolean to indicate watchdog TE is * used instead of panel TE in cmd mode panels +* @dsc: DSC configuration data for DSC-enabled displays */ struct msm_display_info {int intf_type;
@@ -34,6 +35,7 @@ struct msm_display_info {uint32_t num_of_h_tiles;uint32_t h_tile_instance[MAX_H_TILES_PER_DISPLAY ];bool is_te_using_watchdog_timer; +struct msm_display_dsc_config *dsc; };/**
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +2 -0
@@ -582,6 +582,8 @@ static int _dpu_kms_initialize_dsi(struct drm_device *dev, MSM_DISPLAY_CAP_CMD_MODE :MSM_DISPLAY_CAP_VID_MODE ; + info.dsc =msm_dsi_get_dsc_config (priv->dsi[i]); +if (msm_dsi_is_bonded_dsi (priv->dsi[i]) && priv->dsi[other]) { rc =msm_dsi_modeset_init (priv->dsi[other], dev, encoder);if (rc) {
drivers/gpu/drm/msm/dsi/dsi.c +5 -0
@@ -21,6 +21,11 @@ bool msm_dsi_is_cmd_mode(struct msm_dsi *msm_dsi)return !(host_flags &MIPI_DSI_MODE_VIDEO ); } +struct msm_display_dsc_config *msm_dsi_get_dsc_config (struct msm_dsi *msm_dsi) +{ +return msm_dsi_host_get_dsc_config (msm_dsi->host); +} +static int dsi_get_phy (struct msm_dsi *msm_dsi) {struct platform_device *pdev = msm_dsi->pdev;
drivers/gpu/drm/msm/dsi/dsi.h +1 -0
@@ -152,6 +152,7 @@ int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi);int dsi_calc_clk_rate_6g (struct msm_dsi_host *msm_host,bool is_bonded_dsi);void msm_dsi_host_snapshot (struct msm_disp_state *disp_state,struct mipi_dsi_host *host);void msm_dsi_host_test_pattern_en (struct mipi_dsi_host *host); +struct msm_display_dsc_config *msm_dsi_host_get_dsc_config (struct mipi_dsi_host *host);/* dsi phy */ struct msm_dsi_phy ;
drivers/gpu/drm/msm/dsi/dsi_host.c +22 -0
@@ -2061,9 +2061,24 @@ int msm_dsi_host_modeset_init(struct mipi_dsi_host *host, {struct msm_dsi_host *msm_host =to_msm_dsi_host (host);const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; +struct drm_panel *panel;int ret; msm_host->dev = dev; + panel =msm_dsi_host_get_panel (&msm_host->base); + +if (panel && panel->dsc) { +struct msm_display_dsc_config *dsc = msm_host->dsc; + +if (!dsc) { + dsc =devm_kzalloc (&msm_host->pdev->dev,sizeof (*dsc),GFP_KERNEL ); +if (!dsc) +return -ENOMEM ; + dsc->drm = panel->dsc; + msm_host->dsc = dsc; + } + } + ret = cfg_hnd->ops->tx_buf_alloc (msm_host,SZ_4K );if (ret) {pr_err ("%s: alloc tx gem obj failed, %d\n" , __func__, ret);
@@ -2628,3 +2643,10 @@ void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host)dsi_write (msm_host,REG_DSI_TEST_PATTERN_GEN_CMD_STREAM0_TRIGGER ,DSI_TEST_PATTERN_GEN_CMD_STREAM0_TRIGGER_SW_TRIGGER ); } + +struct msm_display_dsc_config *msm_dsi_host_get_dsc_config (struct mipi_dsi_host *host) +{ +struct msm_dsi_host *msm_host =to_msm_dsi_host (host); + +return msm_host->dsc; +}
drivers/gpu/drm/msm/msm_drv.h +6 -0
@@ -336,6 +336,7 @@ void msm_dsi_snapshot(struct msm_disp_state *disp_state, struct msm_dsi *msm_dsibool msm_dsi_is_cmd_mode (struct msm_dsi *msm_dsi);bool msm_dsi_is_bonded_dsi (struct msm_dsi *msm_dsi);bool msm_dsi_is_master_dsi (struct msm_dsi *msm_dsi); +struct msm_display_dsc_config *msm_dsi_get_dsc_config (struct msm_dsi *msm_dsi);#else static inline void __init msm_dsi_register (void ) {
@@ -364,6 +365,11 @@ static inline bool msm_dsi_is_master_dsi(struct msm_dsi *msm_dsi) {return false; } + +static inline struct msm_display_dsc_config *msm_dsi_get_dsc_config (struct msm_dsi *msm_dsi) +{ +return NULL ; +}#endif #ifdef CONFIG_DRM_MSM_DP
include/drm/drm_panel.h +7 -0
@@ -171,6 +171,13 @@ struct drm_panel {* Panel entry in registry. */ struct list_head list; + +/** +* @dsc: +* +* Panel DSC pps payload to be sent +*/ +struct drm_dsc_config *dsc; }; void drm_panel_init(struct drm_panel *panel, struct device *dev,
Signature · 1 line
2.34.1
PATCH v7 3/14 drm/msm/disp/dpu1: Add support for DSC
In reply to Vinod KoulDisplay Stream Compression (DSC) is one of the hw blocks in dpu, so add support by adding hw blocks for DSC
--- drivers/gpu/drm/msm/Makefile | 1 + .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h | 13 ++ drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c | 215 ++++++++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.h | 80 +++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 13 ++ 5 files changed, 322 insertions(+) create mode 100644 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c create mode 100644 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.h
drivers/gpu/drm/msm/Makefile +1 -0
@@ -56,6 +56,7 @@ msm-y := \ disp/dpu1/dpu_formats.o \ disp/dpu1/dpu_hw_catalog.o \ disp/dpu1/dpu_hw_ctl.o \ + disp/dpu1/dpu_hw_dsc.o \ disp/dpu1/dpu_hw_interrupts.o \ disp/dpu1/dpu_hw_intf.o \ disp/dpu1/dpu_hw_lm.o \
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h +13 -0
@@ -561,6 +561,16 @@ struct dpu_merge_3d_cfg {const struct dpu_merge_3d_sub_blks *sblk; }; +/** +* struct dpu_dsc_cfg - information of DSC blocks +* @id enum identifying this block +* @base register offset of this block +* @features bit mask identifying sub-blocks/features +*/ +struct dpu_dsc_cfg { +DPU_HW_BLK_INFO ; +}; +/** * struct dpu_intf_cfg - information of timing engine blocks * @id enum identifying this block
@@ -757,6 +767,9 @@ struct dpu_mdss_cfg {u32 merge_3d_count;const struct dpu_merge_3d_cfg *merge_3d; +u32 dsc_count; +struct dpu_dsc_cfg *dsc; +u32 intf_count;const struct dpu_intf_cfg *intf;
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c new file +215 -0
215 lines not on this page · raw message
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.h new file +80 -0
80 lines not on this page · raw message
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h +13 -0
@@ -97,6 +97,7 @@ enum dpu_hw_blk_type {DPU_HW_BLK_WB ,DPU_HW_BLK_DSPP ,DPU_HW_BLK_MERGE_3D , +DPU_HW_BLK_DSC , DPU_HW_BLK_MAX, };
@@ -176,6 +177,17 @@ enum dpu_ctl {CTL_MAX }; +enum dpu_dsc { +DSC_NONE =0 , +DSC_0 , +DSC_1 , +DSC_2 , +DSC_3 , +DSC_4 , +DSC_5 , +DSC_MAX +}; +enum dpu_pingpong {PINGPONG_0 =1 ,PINGPONG_1 ,
@@ -437,5 +449,6 @@ struct dpu_mdss_color {#define DPU_DBG_MASK_VBIF (1 << 8)#define DPU_DBG_MASK_ROT (1 << 9)#define DPU_DBG_MASK_DSPP (1 << 10) +#define DPU_DBG_MASK_DSC (1 << 11)#endif /* _DPU_HW_MDSS_H */
Signature · 1 line
2.34.1
PATCH v7 4/14 drm/msm/disp/dpu1: Add support for DSC in pingpong block
In reply to Vinod KoulIn SDM845, DSC can be enabled by writing to pingpong block registers, so add support for DSC in hw_pp
--- .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c | 32 +++++++++++++++++++ .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.h | 14 ++++++++ 2 files changed, 46 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +32 -0
@@ -28,6 +28,9 @@#define PP_FBC_MODE 0x034#define PP_FBC_BUDGET_CTL 0x038#define PP_FBC_LOSSY_MODE 0x03C +#define PP_DSC_MODE 0x0a0 +#define PP_DCE_DATA_IN_SWAP 0x0ac +#define PP_DCE_DATA_OUT_SWAP 0x0c8#define PP_DITHER_EN 0x000#define PP_DITHER_BITDEPTH 0x004
@@ -245,6 +248,32 @@ static u32 dpu_hw_pp_get_line_count(struct dpu_hw_pingpong *pp)return line; } +static int dpu_hw_pp_dsc_enable (struct dpu_hw_pingpong *pp) +{ +struct dpu_hw_blk_reg_map *c = &pp->hw; + +DPU_REG_WRITE (c,PP_DSC_MODE ,1 ); +return 0 ; +} + +static void dpu_hw_pp_dsc_disable (struct dpu_hw_pingpong *pp) +{ +struct dpu_hw_blk_reg_map *c = &pp->hw; + +DPU_REG_WRITE (c,PP_DSC_MODE ,0 ); +} + +static int dpu_hw_pp_setup_dsc (struct dpu_hw_pingpong *pp) +{ +struct dpu_hw_blk_reg_map *pp_c = &pp->hw; +int data; + + data =DPU_REG_READ (pp_c,PP_DCE_DATA_OUT_SWAP ); + data |=BIT (18 );/* endian flip */ +DPU_REG_WRITE (pp_c,PP_DCE_DATA_OUT_SWAP , data); +return 0 ; +} +static void _setup_pingpong_ops (struct dpu_hw_pingpong *c,unsigned long features) {
@@ -256,6 +285,9 @@ static void _setup_pingpong_ops(struct dpu_hw_pingpong *c, c->ops.get_autorefresh = dpu_hw_pp_get_autorefresh_config; c->ops.poll_timeout_wr_ptr = dpu_hw_pp_poll_timeout_wr_ptr; c->ops.get_line_count = dpu_hw_pp_get_line_count; + c->ops.setup_dsc = dpu_hw_pp_setup_dsc; + c->ops.enable_dsc = dpu_hw_pp_dsc_enable; + c->ops.disable_dsc = dpu_hw_pp_dsc_disable;if (test_bit (DPU_PINGPONG_DITHER , &features)) c->ops.setup_dither = dpu_hw_pp_setup_dither;
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.h +14 -0
@@ -124,6 +124,20 @@ struct dpu_hw_pingpong_ops {*/ void (*setup_dither)(struct dpu_hw_pingpong *pp,struct dpu_hw_dither_cfg *cfg); +/** +* Enable DSC +*/ +int (*enable_dsc)(struct dpu_hw_pingpong *pp); + +/** +* Disable DSC +*/ +void (*disable_dsc)(struct dpu_hw_pingpong *pp); + +/** +* Setup DSC +*/ +int (*setup_dsc)(struct dpu_hw_pingpong *pp); };struct dpu_hw_merge_3d ;
Signature · 1 line
2.34.1
PATCH v7 5/14 drm/msm/disp/dpu1: Add DSC for SDM845 to hw_catalog
In reply to Vinod KoulThis adds SDM845 DSC blocks into hw_catalog
--- .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c +20 -0
@@ -1117,6 +1117,24 @@ static const struct dpu_pingpong_cfg sc7280_pp[] = {PP_BLK ("pingpong_2" ,PINGPONG_2 ,0x6b000 ,0 , sc7280_pp_sblk,-1 ,-1 ), PP_BLK("pingpong_3", PINGPONG_3, 0x6c000, 0, sc7280_pp_sblk, -1, -1), }; + +/************************************************************* +* DSC sub blocks config +*************************************************************/ +#define DSC_BLK (_name, _id, _base) \ + {\ + .name = _name, .id = _id, \ + .base = _base, .len = 0x140, \ + .features = 0, \ + } + +static struct dpu_dsc_cfg sdm845_dsc[] = { +DSC_BLK ("dsc_0" ,DSC_0 ,0x80000 ), +DSC_BLK ("dsc_1" ,DSC_1 ,0x80400 ), +DSC_BLK ("dsc_2" ,DSC_2 ,0x80800 ), +DSC_BLK ("dsc_3" ,DSC_3 ,0x80c00 ), +}; +/************************************************************* * INTF sub blocks config *************************************************************/
@@ -1643,6 +1661,8 @@ static void sdm845_cfg_init(struct dpu_mdss_cfg *dpu_cfg) .mixer = sdm845_lm, .pingpong_count = ARRAY_SIZE(sdm845_pp), .pingpong = sdm845_pp, + .dsc_count = ARRAY_SIZE(sdm845_dsc), + .dsc = sdm845_dsc, .intf_count = ARRAY_SIZE(sdm845_intf), .intf = sdm845_intf, .vbif_count = ARRAY_SIZE(sdm845_vbif),
Signature · 1 line
2.34.1
PATCH v7 6/14 drm/msm/disp/dpu1: Add DSC support in hw_ctl
In reply to Vinod KoulLater gens of hardware have DSC bits moved to hw_ctl, so configure these bits so that DSC would work there as well
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 11 ++++++++++- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +10 -1
@@ -25,6 +25,8 @@#define CTL_MERGE_3D_ACTIVE 0x0E4#define CTL_INTF_ACTIVE 0x0F4#define CTL_MERGE_3D_FLUSH 0x100 +#define CTL_DSC_ACTIVE 0x0E8 +#define CTL_DSC_FLUSH 0x104#define CTL_INTF_FLUSH 0x110#define CTL_INTF_MASTER 0x134#define CTL_FETCH_PIPE_ACTIVE 0x0FC
@@ -34,6 +36,7 @@#define DPU_REG_RESET_TIMEOUT_US 2000#define MERGE_3D_IDX 23 +#define DSC_IDX 22#define INTF_IDX 31#define CTL_INVALID_BIT 0xffff#define CTL_DEFAULT_GROUP_ID 0xf
@@ -126,7 +129,6 @@ static u32 dpu_hw_ctl_get_pending_flush(struct dpu_hw_ctl *ctx)static inline void dpu_hw_ctl_trigger_flush_v1 (struct dpu_hw_ctl *ctx) { -if (ctx->pending_flush_mask &BIT (MERGE_3D_IDX ))DPU_REG_WRITE (&ctx->hw,CTL_MERGE_3D_FLUSH , ctx->pending_merge_3d_flush_mask);
@@ -511,6 +513,9 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx,if ((test_bit (DPU_CTL_VM_CFG , &ctx->caps->features))) mode_sel =CTL_DEFAULT_GROUP_ID <<28 ; +if (cfg->dsc) +DPU_REG_WRITE (&ctx->hw,CTL_DSC_FLUSH , cfg->dsc); +if (cfg->intf_mode_sel ==DPU_CTL_MODE_SEL_CMD ) mode_sel |=BIT (17 );
@@ -522,6 +527,10 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx,if (cfg->merge_3d)DPU_REG_WRITE (c,CTL_MERGE_3D_ACTIVE ,BIT (cfg->merge_3d -MERGE_3D_0 )); +if (cfg->dsc) { +DPU_REG_WRITE (&ctx->hw,CTL_FLUSH ,DSC_IDX ); +DPU_REG_WRITE (c,CTL_DSC_ACTIVE , cfg->dsc); + } } static void dpu_hw_ctl_intf_cfg(struct dpu_hw_ctl *ctx,
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h +2 -0
@@ -40,6 +40,7 @@ struct dpu_hw_stage_cfg {* @merge_3d: 3d merge block used * @intf_mode_sel: Interface mode, cmd / vid * @stream_sel: Stream selection for multi-stream interfaces +* @dsc: DSC BIT masks used */ struct dpu_hw_intf_cfg {enum dpu_intf intf;
@@ -47,6 +48,7 @@ struct dpu_hw_intf_cfg {enum dpu_merge_3d merge_3d;enum dpu_ctl_mode_sel intf_mode_sel;int stream_sel; +unsigned int dsc; };/**
Signature · 1 line
2.34.1
PATCH v7 7/14 drm/msm/disp/dpu1: Add support for DSC in encoder
In reply to Vinod KoulWe need to configure the encoder for DSC configuration and calculate DSC parameters for the given timing so this patch adds that support by adding dpu_encoder_prep_dsc() which is invoked when DSC is enabled.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 128 +++++++++++++++++- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 8 ++ 2 files changed, 135 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +127 -1
@@ -21,6 +21,7 @@#include "dpu_hw_intf.h" #include "dpu_hw_ctl.h" #include "dpu_hw_dspp.h" +#include "dpu_hw_dsc.h" #include "dpu_formats.h" #include "dpu_encoder_phys.h" #include "dpu_crtc.h"
@@ -135,6 +136,8 @@ enum dpu_enc_rc_states {* @cur_slave: As above but for the slave encoder. * @hw_pp: Handle to the pingpong blocks used for the display. No. * pingpong blocks can be different than num_phys_encs. +* @hw_dsc: Handle to the DSC blocks used for the display. +* @dsc_mask: Bitmask of used DSC blocks. * @intfs_swapped: Whether or not the phys_enc interfaces have been swapped * for partial update right-only cases, such as pingpong * split where virtual pingpong does not generate IRQs
@@ -168,6 +171,7 @@ enum dpu_enc_rc_states {* @vsync_event_work: worker to handle vsync event for autorefresh * @topology: topology of the display * @idle_timeout: idle timeout duration in milliseconds +* @dsc: msm_display_dsc_config pointer, for DSC-enabled encoders */ struct dpu_encoder_virt {struct drm_encoder base;
@@ -180,6 +184,9 @@ struct dpu_encoder_virt {struct dpu_encoder_phys *cur_master;struct dpu_encoder_phys *cur_slave;struct dpu_hw_pingpong *hw_pp[MAX_CHANNELS_PER_ENC ]; +struct dpu_hw_dsc *hw_dsc[MAX_CHANNELS_PER_ENC ]; + +unsigned int dsc_mask;bool intfs_swapped;
@@ -206,6 +213,9 @@ struct dpu_encoder_virt {struct msm_display_topology topology;u32 idle_timeout; + +/* DSC configuration */ +struct msm_display_dsc_config *dsc; };#define to_dpu_encoder_virt (x) container_of(x, struct dpu_encoder_virt, base)
@@ -942,7 +952,9 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,struct dpu_hw_blk *hw_ctl[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_lm[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_dspp[MAX_CHANNELS_PER_ENC ] = {NULL }; -int num_lm, num_ctl, num_pp; +struct dpu_hw_blk *hw_dsc[MAX_CHANNELS_PER_ENC ]; +int num_lm, num_ctl, num_pp, num_dsc; +unsigned int dsc_mask =0 ;int i;if (!drm_enc) {
@@ -980,6 +992,18 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc, dpu_enc->hw_pp[i] = i < num_pp ?to_dpu_hw_pingpong (hw_pp[i]) :NULL ; +if (dpu_enc->dsc) { + num_dsc =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->base.id,DPU_HW_BLK_DSC , + hw_dsc,ARRAY_SIZE (hw_dsc)); +for (i =0 ; i < num_dsc; i++) { + dpu_enc->hw_dsc[i] =to_dpu_hw_dsc (hw_dsc[i]); + dsc_mask |=BIT (dpu_enc->hw_dsc[i]->idx -DSC_0 ); + } + } + + dpu_enc->dsc_mask = dsc_mask; + cstate =to_dpu_crtc_state (crtc_state);for (i =0 ; i < num_lm; i++) {
@@ -1677,6 +1701,95 @@ static void dpu_encoder_vsync_event_work_handler(struct kthread_work *work) nsecs_to_jiffies(ktime_to_ns(wakeup_time))); } +static u32 +dpu_encoder_dsc_initial_line_calc (struct msm_display_dsc_config *dsc, +u32 enc_ip_width) +{ +int ssm_delay, total_pixels, soft_slice_per_enc; + + soft_slice_per_enc = enc_ip_width / dsc->drm->slice_width; + +/* +* minimum number of initial line pixels is a sum of: +* 1. sub-stream multiplexer delay (83 groups for 8bpc, +* 91 for 10 bpc) * 3 +* 2. for two soft slice cases, add extra sub-stream multiplexer * 3 +* 3. the initial xmit delay +* 4. total pipeline delay through the "lock step" of encoder (47) +* 5. 6 additional pixels as the output of the rate buffer is +* 48 bits wide +*/ + ssm_delay = ((dsc->drm->bits_per_component <10 ) ?84 :92 ); + total_pixels = ssm_delay *3 + dsc->drm->initial_xmit_delay +47 ; +if (soft_slice_per_enc >1 ) + total_pixels += (ssm_delay *3 ); +return DIV_ROUND_UP (total_pixels, dsc->drm->slice_width); +} + +static void dpu_encoder_dsc_pipe_cfg (struct dpu_hw_dsc *hw_dsc, +struct dpu_hw_pingpong *hw_pp, +struct msm_display_dsc_config *dsc, +u32 common_mode, +u32 initial_lines) +{ +if (hw_dsc->ops.dsc_config) + hw_dsc->ops.dsc_config (hw_dsc, dsc, common_mode, initial_lines); + +if (hw_dsc->ops.dsc_config_thresh) + hw_dsc->ops.dsc_config_thresh (hw_dsc, dsc); + +if (hw_pp->ops.setup_dsc) + hw_pp->ops.setup_dsc (hw_pp); + +if (hw_pp->ops.enable_dsc) + hw_pp->ops.enable_dsc (hw_pp); +} + +static void dpu_encoder_prep_dsc (struct dpu_encoder_virt *dpu_enc, +struct msm_display_dsc_config *dsc) +{ +/* coding only for 2LM, 2enc, 1 dsc config */ +struct dpu_encoder_phys *enc_master = dpu_enc->cur_master; +struct dpu_hw_dsc *hw_dsc[MAX_CHANNELS_PER_ENC ]; +struct dpu_hw_pingpong *hw_pp[MAX_CHANNELS_PER_ENC ]; +int this_frame_slices; +int intf_ip_w, enc_ip_w; +int dsc_common_mode; +int pic_width; +u32 initial_lines; +int i; + +for (i =0 ; i <MAX_CHANNELS_PER_ENC ; i++) { + hw_pp[i] = dpu_enc->hw_pp[i]; + hw_dsc[i] = dpu_enc->hw_dsc[i]; + +if (!hw_pp[i] || !hw_dsc[i]) { +DPU_ERROR_ENC (dpu_enc,"invalid params for DSC\n" ); +return ; + } + } + + dsc_common_mode =0 ; + pic_width = dsc->drm->pic_width; + + dsc_common_mode =DSC_MODE_MULTIPLEX |DSC_MODE_SPLIT_PANEL ; +if (enc_master->intf_mode ==INTF_MODE_VIDEO ) + dsc_common_mode |=DSC_MODE_VIDEO ; + + this_frame_slices = pic_width / dsc->drm->slice_width; + intf_ip_w = this_frame_slices * dsc->drm->slice_width; + +/* +* dsc merge case: when using 2 encoders for the same stream, +* no. of slices need to be same on both the encoders. +*/ + enc_ip_w = intf_ip_w /2 ; + initial_lines =dpu_encoder_dsc_initial_line_calc (dsc, enc_ip_w); + +for (i =0 ; i <MAX_CHANNELS_PER_ENC ; i++) +dpu_encoder_dsc_pipe_cfg (hw_dsc[i], hw_pp[i], dsc, dsc_common_mode, initial_lines); +} +void dpu_encoder_prepare_for_kickoff (struct drm_encoder *drm_enc) {struct dpu_encoder_virt *dpu_enc;
@@ -1708,6 +1821,9 @@ void dpu_encoder_prepare_for_kickoff(struct drm_encoder *drm_enc)dpu_encoder_helper_hw_reset (dpu_enc->phys_encs[i]); } } + +if (dpu_enc->dsc) +dpu_encoder_prep_dsc (dpu_enc, dpu_enc->dsc); }void dpu_encoder_kickoff (struct drm_encoder *drm_enc)
@@ -1953,6 +2069,8 @@ static int dpu_encoder_setup_display(struct dpu_encoder_virt *dpu_enc, dpu_enc->idle_pc_supported = dpu_kms->catalog->caps->has_idle_pc; + dpu_enc->dsc = disp_info->dsc; +mutex_lock (&dpu_enc->enc_lock);for (i =0 ; i < disp_info->num_of_h_tiles && !ret; i++) {/*
@@ -2180,3 +2298,11 @@ enum dpu_intf_mode dpu_encoder_get_intf_mode(struct drm_encoder *encoder)return INTF_MODE_NONE ; } + +unsigned int dpu_encoder_helper_get_dsc (struct dpu_encoder_phys *phys_enc) +{ +struct drm_encoder *encoder = phys_enc->parent; +struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (encoder); + +return dpu_enc->dsc_mask; +}
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h +8 -0
@@ -321,6 +321,14 @@ static inline enum dpu_3d_blend_mode dpu_encoder_helper_get_3d_blend_mode(return BLEND_3D_NONE ; } +/** +* dpu_encoder_helper_get_dsc - get DSC blocks mask for the DPU encoder +* This helper function is used by physical encoder to get DSC blocks mask +* used for this encoder. +* @phys_enc: Pointer to physical encoder structure +*/ +unsigned int dpu_encoder_helper_get_dsc (struct dpu_encoder_phys *phys_enc); +/** * dpu_encoder_helper_split_config - split display configuration helper function * This helper function may be used by physical encoders to configure
Signature · 1 line
2.34.1
PATCH v7 8/14 drm/msm/dpu: don't use merge_3d if DSC merge topology is used
In reply to Vinod KoulFrom: Dmitry Baryshkov <[email protected]>
DPU supports different topologies for the case when multiple INTFs are being driven by the single phys_enc. The driver defaults to using 3DMux in such cases. Don't use it if DSC merge is used instead.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 6 ++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 4 +++- 3 files changed, 25 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +16 -0
@@ -511,6 +511,22 @@ void dpu_encoder_helper_split_config( } } +bool dpu_encoder_use_dsc_merge (struct drm_encoder *drm_enc) +{ +struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (drm_enc); +int i, intf_count =0 , num_dsc =0 ; + +for (i =0 ; i <MAX_PHYS_ENCODERS_PER_VIRTUAL ; i++) +if (dpu_enc->phys_encs[i]) + intf_count++; + +/* See dpu_encoder_get_topology, we only support 2:2:1 topology */ +if (dpu_enc->dsc) + num_dsc =2 ; + +return (num_dsc >0 ) && (num_dsc > intf_count); +} + static struct msm_display_topology dpu_encoder_get_topology( struct dpu_encoder_virt *dpu_enc, struct dpu_kms *dpu_kms,
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +6 -0
@@ -172,4 +172,10 @@ int dpu_encoder_get_linecount(struct drm_encoder *drm_enc);*/ int dpu_encoder_get_vsync_count (struct drm_encoder *drm_enc); +/** +* dpu_encoder_use_dsc_merge - returns true if the encoder uses DSC merge topology. +* @drm_enc: Pointer to previously created drm encoder structure +*/ +bool dpu_encoder_use_dsc_merge (struct drm_encoder *drm_enc); +#endif /* __DPU_ENCODER_H__ */
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h +3 -1
@@ -314,8 +314,10 @@ static inline enum dpu_3d_blend_mode dpu_encoder_helper_get_3d_blend_mode( dpu_cstate =to_dpu_crtc_state (phys_enc->parent->crtc->state); +/* Use merge_3d unless DSC MERGE topology is used */ if (phys_enc->split_role ==ENC_ROLE_SOLO && - dpu_cstate->num_mixers ==CRTC_DUAL_MIXERS ) + dpu_cstate->num_mixers ==CRTC_DUAL_MIXERS && + !dpu_encoder_use_dsc_merge (phys_enc->parent))return BLEND_3D_H_ROW_INT ;return BLEND_3D_NONE ;
Signature · 1 line
2.34.1
Re: [PATCH v7 08/14] drm/msm/dpu: don't use merge_3d if DSC merge topology is used
Quoted 9 lines · Vinod Koul
From: Dmitry Baryshkov <[email protected]>
DPU supports different topologies for the case when multiple INTFs are being driven by the single
phys_enc. The driver defaults to using 3DMux in such cases. Don't use it if DSC merge is used instead.Suggested-by Abhinav Kumar <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>Signed-off-by Vinod Koul <[email protected]>
Thank you for making the change generic as suggested.
Quoted 64 lines
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 6 ++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 4 +++- 3 files changed, 25 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +16
-0@@ -511,6 +511,22 @@ void dpu_encoder_helper_split_config( } } +bool dpu_encoder_use_dsc_merge (struct drm_encoder *drm_enc) +{ +struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (drm_enc); +int i, intf_count =0 , num_dsc =0 ; + +for (i =0 ; i <MAX_PHYS_ENCODERS_PER_VIRTUAL ; i++) +if (dpu_enc->phys_encs[i]) + intf_count++; + +/* See dpu_encoder_get_topology, we only support 2:2:1 topology */ +if (dpu_enc->dsc) + num_dsc =2 ; + +return (num_dsc >0 ) && (num_dsc > intf_count); +} + static struct msm_display_topology dpu_encoder_get_topology( struct dpu_encoder_virt *dpu_enc, struct dpu_kms *dpu_kms,drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +6
-0@@ -172,4 +172,10 @@ int dpu_encoder_get_linecount(struct drm_encoder *drm_enc);*/ int dpu_encoder_get_vsync_count (struct drm_encoder *drm_enc); +/** +* dpu_encoder_use_dsc_merge - returns true if the encoder uses DSC merge topology. +* @drm_enc: Pointer to previously created drm encoder structure +*/ +bool dpu_encoder_use_dsc_merge (struct drm_encoder *drm_enc); +#endif /* __DPU_ENCODER_H__ */ drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h +3
-1@@ -314,8 +314,10 @@ static inline enum dpu_3d_blend_mode dpu_encoder_helper_get_3d_blend_mode( dpu_cstate =to_dpu_crtc_state (phys_enc->parent->crtc->state); +/* Use merge_3d unless DSC MERGE topology is used */ if (phys_enc->split_role ==ENC_ROLE_SOLO && - dpu_cstate->num_mixers ==CRTC_DUAL_MIXERS ) + dpu_cstate->num_mixers ==CRTC_DUAL_MIXERS && + !dpu_encoder_use_dsc_merge (phys_enc->parent))return BLEND_3D_H_ROW_INT ;return BLEND_3D_NONE ;
PATCH v7 9/14 drm/msm: Add missing num_dspp field documentation
In reply to Vinod KoulSomehow documentation for num_dspp was missed, so add that
--- drivers/gpu/drm/msm/msm_drv.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/msm/msm_drv.h +1 -0
@@ -102,6 +102,7 @@ enum msm_event_wait {* @num_lm: number of layer mixers used * @num_enc: number of compression encoder blocks used * @num_intf: number of interfaces the panel is mounted on +* @num_dspp: number of dspp blocks used */ struct msm_display_topology {u32 num_lm;
Signature · 1 line
2.34.1
PATCH v7 10/14 drm/msm/disp/dpu1: Add support for DSC in topology
In reply to Vinod KoulFor DSC to work we typically need a 2,2,1 configuration. This should suffice for resolutions up to 4k. For more resolutions like 8k this won't work.
Also, it is better to use 2 LMs and DSC instances as half width results in lesser power consumption as compared to single LM, DSC at full width.
The panel has been tested only with 2,2,1 configuration, so for now we blindly create 2,2,1 topology when DSC is enabled
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 13 +++++++++++++ drivers/gpu/drm/msm/msm_drv.h | 2 ++ 2 files changed, 15 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +13 -0
@@ -567,8 +567,21 @@ static struct msm_display_topology dpu_encoder_get_topology( topology.num_enc =0 ; topology.num_intf = intf_count; +if (dpu_enc->dsc) { +/* In case of Display Stream Compression (DSC), we would use +* 2 encoders, 2 layer mixers and 1 interface +* this is power optimal and can drive up to (including) 4k +* screens +*/ + topology.num_enc =2 ; + topology.num_dsc =2 ; + topology.num_intf =1 ; + topology.num_lm =2 ; + } +return topology; } + static int dpu_encoder_virt_atomic_check( struct drm_encoder *drm_enc, struct drm_crtc_state *crtc_state,
drivers/gpu/drm/msm/msm_drv.h +2 -0
@@ -103,12 +103,14 @@ enum msm_event_wait {* @num_enc: number of compression encoder blocks used * @num_intf: number of interfaces the panel is mounted on * @num_dspp: number of dspp blocks used +* @num_dsc: number of Display Stream Compression (DSC) blocks used */ struct msm_display_topology {u32 num_lm;u32 num_enc;u32 num_intf;u32 num_dspp; +u32 num_dsc; };/* Commit/Event thread specific structure */
Signature · 1 line
2.34.1
PATCH v7 11/14 drm/msm/disp/dpu1: Add DSC support in RM
In reply to Vinod KoulThis add the bits in RM to enable the DSC blocks
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 + drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 56 +++++++++++++++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 1 + 3 files changed, 58 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +1 -0
@@ -145,6 +145,7 @@ struct dpu_global_state {uint32_t mixer_to_enc_id[LM_MAX -LM_0 ];uint32_t ctl_to_enc_id[CTL_MAX -CTL_0 ];uint32_t dspp_to_enc_id[DSPP_MAX -DSPP_0 ]; +uint32_t dsc_to_enc_id[DSC_MAX -DSC_0 ]; };struct dpu_global_state
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +56 -0
98 lines not on this page · raw message
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +1 -0
@@ -28,6 +28,7 @@ struct dpu_rm {struct dpu_hw_intf *hw_intf[INTF_MAX -INTF_0 ];struct dpu_hw_blk *dspp_blks[DSPP_MAX -DSPP_0 ];struct dpu_hw_blk *merge_3d_blks[MERGE_3D_MAX -MERGE_3D_0 ]; +struct dpu_hw_blk *dsc_blks[DSC_MAX -DSC_0 ]; };/**
Signature · 1 line
2.34.1
PATCH v7 12/14 drm/msm/dsi: add mode valid callback for dsi_mgr
In reply to Vinod KoulAdd a mode valid callback for dsi_mgr for checking mode being valid in case of DSC. For DSC the height and width needs to be multiple of slice, so we check that here
--- drivers/gpu/drm/msm/dsi/dsi.h | 2 ++ drivers/gpu/drm/msm/dsi/dsi_host.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/msm/dsi/dsi_manager.c | 12 ++++++++++++ 3 files changed, 40 insertions(+)
drivers/gpu/drm/msm/dsi/dsi.h +2 -0
@@ -114,6 +114,8 @@ int msm_dsi_host_power_on(struct mipi_dsi_host *host,int msm_dsi_host_power_off (struct mipi_dsi_host *host);int msm_dsi_host_set_display_mode (struct mipi_dsi_host *host,const struct drm_display_mode *mode); +enum drm_mode_status msm_dsi_host_check_dsc (struct mipi_dsi_host *host, +const struct drm_display_mode *mode);struct drm_panel *msm_dsi_host_get_panel (struct mipi_dsi_host *host);unsigned long msm_dsi_host_get_mode_flags (struct mipi_dsi_host *host);struct drm_bridge *msm_dsi_host_get_bridge (struct mipi_dsi_host *host);
drivers/gpu/drm/msm/dsi/dsi_host.c +26 -0
@@ -2554,6 +2554,32 @@ int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,return 0 ; } +enum drm_mode_status msm_dsi_host_check_dsc (struct mipi_dsi_host *host, +const struct drm_display_mode *mode) +{ +struct msm_dsi_host *msm_host =to_msm_dsi_host (host); +struct msm_display_dsc_config *dsc = msm_host->dsc; +int pic_width = mode->hdisplay; +int pic_height = mode->vdisplay; + +if (!msm_host->dsc) +return MODE_OK ; + +if (pic_width % dsc->drm->slice_width) { +pr_err ("DSI: pic_width %d has to be multiple of slice %d\n" , + pic_width, dsc->drm->slice_width); +return MODE_H_ILLEGAL ; + } + +if (pic_height % dsc->drm->slice_height) { +pr_err ("DSI: pic_height %d has to be multiple of slice %d\n" , + pic_height, dsc->drm->slice_height); +return MODE_V_ILLEGAL ; + } + +return MODE_OK ; +} +struct drm_panel *msm_dsi_host_get_panel (struct mipi_dsi_host *host) {return of_drm_find_panel (to_msm_dsi_host (host)->device_node);
drivers/gpu/drm/msm/dsi/dsi_manager.c +12 -0
@@ -573,6 +573,17 @@ static void dsi_mgr_bridge_mode_set(struct drm_bridge *bridge,dsi_mgr_bridge_power_on (bridge); } +static enum drm_mode_status dsi_mgr_bridge_mode_valid (struct drm_bridge *bridge, +const struct drm_display_info *info, +const struct drm_display_mode *mode) +{ +int id =dsi_mgr_bridge_get_id (bridge); +struct msm_dsi *msm_dsi =dsi_mgr_get_dsi (id); +struct mipi_dsi_host *host = msm_dsi->host; + +return msm_dsi_host_check_dsc (host, mode); +} +static const struct drm_connector_funcs dsi_mgr_connector_funcs = { .detect = dsi_mgr_connector_detect, .fill_modes = drm_helper_probe_single_connector_modes,
@@ -593,6 +604,7 @@ static const struct drm_bridge_funcs dsi_mgr_bridge_funcs = { .disable = dsi_mgr_bridge_disable, .post_disable = dsi_mgr_bridge_post_disable, .mode_set = dsi_mgr_bridge_mode_set, + .mode_valid = dsi_mgr_bridge_mode_valid, };/* initialize connector when we're connected to a drm_panel */
Signature · 1 line
2.34.1
PATCH v7 13/14 drm/msm: Update generated headers
In reply to Vinod KoulUpdate headers from mesa commit:
commit 28ae397be111c37c6ced397e12d453a7695701bd
Author: Vinod Koul <[email protected]>
Date: Fri Apr 1 16:53:04 2022 +0530
freedreno/registers: update dsi registers to support dsc
Display Stream compression (DSC) compresses the display stream in host which is later decoded by panel. This requires addition of 3 new DSI registers to support DSC over DSI.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14967>
--- drivers/gpu/drm/msm/dsi/dsi.xml.h | 80 +++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
drivers/gpu/drm/msm/dsi/dsi.xml.h +80 -0
@@ -704,5 +704,85 @@ static inline uint32_t DSI_VERSION_MAJOR(uint32_t val)#define REG_DSI_CPHY_MODE_CTRL 0x000002d4 +#define REG_DSI_VIDEO_COMPRESSION_MODE_CTRL 0x0000029c +#define DSI_VIDEO_COMPRESSION_MODE_CTRL_WC__MASK 0xffff0000 +#define DSI_VIDEO_COMPRESSION_MODE_CTRL_WC__SHIFT 16 +static inline uint32_t DSI_VIDEO_COMPRESSION_MODE_CTRL_WC (uint32_t val) +{ +return ((val) <<DSI_VIDEO_COMPRESSION_MODE_CTRL_WC__SHIFT ) &DSI_VIDEO_COMPRESSION_MODE_CTRL_WC__MASK ; +} +#define DSI_VIDEO_COMPRESSION_MODE_CTRL_DATATYPE__MASK 0x00003f00 +#define DSI_VIDEO_COMPRESSION_MODE_CTRL_DATATYPE__SHIFT 8 +static inline uint32_t DSI_VIDEO_COMPRESSION_MODE_CTRL_DATATYPE (uint32_t val) +{ +return ((val) <<DSI_VIDEO_COMPRESSION_MODE_CTRL_DATATYPE__SHIFT ) &DSI_VIDEO_COMPRESSION_MODE_CTRL_DATATYPE__MASK ; +} +#define DSI_VIDEO_COMPRESSION_MODE_CTRL_PKT_PER_LINE__MASK 0x000000c0 +#define DSI_VIDEO_COMPRESSION_MODE_CTRL_PKT_PER_LINE__SHIFT 6 +static inline uint32_t DSI_VIDEO_COMPRESSION_MODE_CTRL_PKT_PER_LINE (uint32_t val) +{ +return ((val) <<DSI_VIDEO_COMPRESSION_MODE_CTRL_PKT_PER_LINE__SHIFT ) &DSI_VIDEO_COMPRESSION_MODE_CTRL_PKT_PER_LINE__MASK ; +} +#define DSI_VIDEO_COMPRESSION_MODE_CTRL_EOL_BYTE_NUM__MASK 0x00000030 +#define DSI_VIDEO_COMPRESSION_MODE_CTRL_EOL_BYTE_NUM__SHIFT 4 +static inline uint32_t DSI_VIDEO_COMPRESSION_MODE_CTRL_EOL_BYTE_NUM (uint32_t val) +{ +return ((val) <<DSI_VIDEO_COMPRESSION_MODE_CTRL_EOL_BYTE_NUM__SHIFT ) &DSI_VIDEO_COMPRESSION_MODE_CTRL_EOL_BYTE_NUM__MASK ; +} +#define DSI_VIDEO_COMPRESSION_MODE_CTRL_EN 0x00000001 + +#define REG_DSI_COMMAND_COMPRESSION_MODE_CTRL 0x000002a4 +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_DATATYPE__MASK 0x3f000000 +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_DATATYPE__SHIFT 24 +static inline uint32_t DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_DATATYPE (uint32_t val) +{ +return ((val) <<DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_DATATYPE__SHIFT ) &DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_DATATYPE__MASK ; +} +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_PKT_PER_LINE__MASK 0x00c00000 +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_PKT_PER_LINE__SHIFT 22 +static inline uint32_t DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_PKT_PER_LINE (uint32_t val) +{ +return ((val) <<DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_PKT_PER_LINE__SHIFT ) &DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_PKT_PER_LINE__MASK ; +} +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_EOL_BYTE_NUM__MASK 0x00300000 +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_EOL_BYTE_NUM__SHIFT 20 +static inline uint32_t DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_EOL_BYTE_NUM (uint32_t val) +{ +return ((val) <<DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_EOL_BYTE_NUM__SHIFT ) &DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_EOL_BYTE_NUM__MASK ; +} +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM1_EN 0x00010000 +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE__MASK 0x00003f00 +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE__SHIFT 8 +static inline uint32_t DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE (uint32_t val) +{ +return ((val) <<DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE__SHIFT ) &DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE__MASK ; +} +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_PKT_PER_LINE__MASK 0x000000c0 +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_PKT_PER_LINE__SHIFT 6 +static inline uint32_t DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_PKT_PER_LINE (uint32_t val) +{ +return ((val) <<DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_PKT_PER_LINE__SHIFT ) &DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_PKT_PER_LINE__MASK ; +} +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_EOL_BYTE_NUM__MASK 0x00000030 +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_EOL_BYTE_NUM__SHIFT 4 +static inline uint32_t DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_EOL_BYTE_NUM (uint32_t val) +{ +return ((val) <<DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_EOL_BYTE_NUM__SHIFT ) &DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_EOL_BYTE_NUM__MASK ; +} +#define DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_EN 0x00000001 + +#define REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2 0x000002a8 +#define DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM1_SLICE_WIDTH__MASK 0xffff0000 +#define DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM1_SLICE_WIDTH__SHIFT 16 +static inline uint32_t DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM1_SLICE_WIDTH (uint32_t val) +{ +return ((val) <<DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM1_SLICE_WIDTH__SHIFT ) &DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM1_SLICE_WIDTH__MASK ; +} +#define DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM0_SLICE_WIDTH__MASK 0x0000ffff +#define DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM0_SLICE_WIDTH__SHIFT 0 +static inline uint32_t DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM0_SLICE_WIDTH (uint32_t val) +{ +return ((val) <<DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM0_SLICE_WIDTH__SHIFT ) &DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM0_SLICE_WIDTH__MASK ; +}#endif /* DSI_XML */
Signature · 1 line
2.34.1
PATCH v7 14/14 drm/msm/dsi: Add support for DSC configuration
In reply to Vinod KoulWhen DSC is enabled, we need to configure DSI registers accordingly and configure the respective stream compression registers.
Add support to calculate the register setting based on DSC params and timing information and configure these registers.
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 98 +++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +97 -1
@@ -912,6 +912,65 @@ static void dsi_ctrl_config(struct msm_dsi_host *msm_host, bool enable,dsi_write (msm_host,REG_DSI_CPHY_MODE_CTRL ,BIT (0 )); } +static void dsi_update_dsc_timing (struct msm_dsi_host *msm_host,bool is_cmd_mode,u32 hdisplay) +{ +struct msm_display_dsc_config *dsc = msm_host->dsc; +u32 reg, intf_width, reg_ctrl, reg_ctrl2; +u32 slice_per_intf, total_bytes_per_intf; +u32 pkt_per_line; +u32 bytes_in_slice; +u32 eol_byte_num; + +/* first calculate dsc parameters and then program +* compress mode registers +*/ + intf_width = hdisplay; + slice_per_intf =DIV_ROUND_UP (intf_width, dsc->drm->slice_width); + +/* If slice_per_pkt is greater than slice_per_intf +* then default to 1. This can happen during partial +* update. +*/ +if (slice_per_intf > dsc->drm->slice_count) + dsc->drm->slice_count =1 ; + + slice_per_intf =DIV_ROUND_UP (hdisplay, dsc->drm->slice_width); + bytes_in_slice =DIV_ROUND_UP (dsc->drm->slice_width * dsc->drm->bits_per_pixel,8 ); + + dsc->drm->slice_chunk_size = bytes_in_slice; + + total_bytes_per_intf = bytes_in_slice * slice_per_intf; + + eol_byte_num = total_bytes_per_intf %3 ; + pkt_per_line = slice_per_intf / dsc->drm->slice_count; + +if (is_cmd_mode)/* packet data type */ + reg =DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE (MIPI_DSI_DCS_LONG_WRITE ); +else + reg =DSI_VIDEO_COMPRESSION_MODE_CTRL_DATATYPE (MIPI_DSI_COMPRESSED_PIXEL_STREAM ); + +/* DSI_VIDEO_COMPRESSION_MODE & DSI_COMMAND_COMPRESSION_MODE +* registers have similar offsets, so for below common code use +* DSI_VIDEO_COMPRESSION_MODE_XXXX for setting bits +*/ + reg |=DSI_VIDEO_COMPRESSION_MODE_CTRL_PKT_PER_LINE (pkt_per_line >>1 ); + reg |=DSI_VIDEO_COMPRESSION_MODE_CTRL_EOL_BYTE_NUM (eol_byte_num); + reg |=DSI_VIDEO_COMPRESSION_MODE_CTRL_EN ; + +if (is_cmd_mode) { + reg_ctrl =dsi_read (msm_host,REG_DSI_COMMAND_COMPRESSION_MODE_CTRL ); + reg_ctrl2 =dsi_read (msm_host,REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2 ); + + reg_ctrl |= reg; + reg_ctrl2 |=DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM0_SLICE_WIDTH (bytes_in_slice); + +dsi_write (msm_host,REG_DSI_COMMAND_COMPRESSION_MODE_CTRL , reg); +dsi_write (msm_host,REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2 , reg_ctrl2); + }else { +dsi_write (msm_host,REG_DSI_VIDEO_COMPRESSION_MODE_CTRL , reg); + } +} +static void dsi_timing_setup (struct msm_dsi_host *msm_host,bool is_bonded_dsi) {struct drm_display_mode *mode = msm_host->mode;
@@ -944,7 +1003,38 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi) hdisplay /=2 ; } +if (msm_host->dsc) { +struct msm_display_dsc_config *dsc = msm_host->dsc; + +/* update dsc params with timing params */ +if (!dsc || !mode->hdisplay || !mode->vdisplay) { +pr_err ("DSI: invalid input: pic_width: %d pic_height: %d\n" , + mode->hdisplay, mode->vdisplay); +return ; + } + + dsc->drm->pic_width = mode->hdisplay; + dsc->drm->pic_height = mode->vdisplay; +DBG ("Mode %dx%d\n" , dsc->drm->pic_width, dsc->drm->pic_height); + +/* we do the calculations for dsc parameters here so that +* panel can use these parameters +*/ +dsi_populate_dsc_params (dsc); + +/* Divide the display by 3 but keep back/font porch and +* pulse width same +*/ + h_total -= hdisplay; + hdisplay /=3 ; + h_total += hdisplay; + ha_end = ha_start + hdisplay; + } +if (msm_host->mode_flags &MIPI_DSI_MODE_VIDEO ) { +if (msm_host->dsc) +dsi_update_dsc_timing (msm_host, false, mode->hdisplay); +dsi_write (msm_host,REG_DSI_ACTIVE_H ,DSI_ACTIVE_H_START (ha_start) |DSI_ACTIVE_H_END (ha_end));
@@ -963,8 +1053,14 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi)DSI_ACTIVE_VSYNC_VPOS_START (vs_start) | DSI_ACTIVE_VSYNC_VPOS_END(vs_end)); }else {/* command mode */ +if (msm_host->dsc) +dsi_update_dsc_timing (msm_host, true, mode->hdisplay); +/* image data and 1 byte write_memory_start cmd */ - wc = hdisplay *dsi_get_bpp (msm_host->format) /8 +1 ; +if (!msm_host->dsc) + wc = hdisplay *dsi_get_bpp (msm_host->format) /8 +1 ; +else + wc = mode->hdisplay /2 +1 ; dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM0_CTRL, DSI_CMD_MDP_STREAM0_CTRL_WORD_COUNT(wc) |
Signature · 1 line
2.34.1