Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm/dsi: use DRM DSC helpers for DSC setup

Use new DRM DSC helpers to setup DSI DSC configuration. The
initial_scale_value needs to be adjusted according to the standard, but
this is a separate change.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
Signed-off-by: Jessica Zhang <quic_jesszhan@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/539276/
Link: https://lore.kernel.org/r/20230329-rfc-msm-dsc-helper-v14-4-bafc7be95691@quicinc.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

+8 -53
+8 -53
drivers/gpu/drm/msm/dsi/dsi_host.c
··· 1728 1728 return -EINVAL; 1729 1729 } 1730 1730 1731 - static u32 dsi_dsc_rc_buf_thresh[DSC_NUM_BUF_RANGES - 1] = { 1732 - 0x0e, 0x1c, 0x2a, 0x38, 0x46, 0x54, 0x62, 1733 - 0x69, 0x70, 0x77, 0x79, 0x7b, 0x7d, 0x7e 1734 - }; 1735 - 1736 - /* only 8bpc, 8bpp added */ 1737 - static char min_qp[DSC_NUM_BUF_RANGES] = { 1738 - 0, 0, 1, 1, 3, 3, 3, 3, 3, 3, 5, 5, 5, 7, 13 1739 - }; 1740 - 1741 - static char max_qp[DSC_NUM_BUF_RANGES] = { 1742 - 4, 4, 5, 6, 7, 7, 7, 8, 9, 10, 11, 12, 13, 13, 15 1743 - }; 1744 - 1745 - static char bpg_offset[DSC_NUM_BUF_RANGES] = { 1746 - 2, 0, 0, -2, -4, -6, -8, -8, -8, -10, -10, -12, -12, -12, -12 1747 - }; 1748 - 1749 1731 static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc) 1750 1732 { 1751 - int i; 1752 - u16 bpp = dsc->bits_per_pixel >> 4; 1733 + int ret; 1753 1734 1754 1735 if (dsc->bits_per_pixel & 0xf) { 1755 1736 DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support fractional bits_per_pixel\n"); ··· 1742 1761 return -EOPNOTSUPP; 1743 1762 } 1744 1763 1745 - dsc->rc_model_size = 8192; 1746 - dsc->first_line_bpg_offset = 12; 1747 - dsc->rc_edge_factor = 6; 1748 - dsc->rc_tgt_offset_high = 3; 1749 - dsc->rc_tgt_offset_low = 3; 1750 1764 dsc->simple_422 = 0; 1751 1765 dsc->convert_rgb = 1; 1752 1766 dsc->vbr_enable = 0; 1753 1767 1754 - /* handle only bpp = bpc = 8 */ 1755 - for (i = 0; i < DSC_NUM_BUF_RANGES - 1 ; i++) 1756 - dsc->rc_buf_thresh[i] = dsi_dsc_rc_buf_thresh[i]; 1768 + drm_dsc_set_const_params(dsc); 1769 + drm_dsc_set_rc_buf_thresh(dsc); 1757 1770 1758 - for (i = 0; i < DSC_NUM_BUF_RANGES; i++) { 1759 - dsc->rc_range_params[i].range_min_qp = min_qp[i]; 1760 - dsc->rc_range_params[i].range_max_qp = max_qp[i]; 1761 - /* 1762 - * Range BPG Offset contains two's-complement signed values that fill 1763 - * 8 bits, yet the registers and DCS PPS field are only 6 bits wide. 1764 - */ 1765 - dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i] & DSC_RANGE_BPG_OFFSET_MASK; 1771 + /* handle only bpp = bpc = 8, pre-SCR panels */ 1772 + ret = drm_dsc_setup_rc_params(dsc, DRM_DSC_1_1_PRE_SCR); 1773 + if (ret) { 1774 + DRM_DEV_ERROR(&msm_host->pdev->dev, "could not find DSC RC parameters\n"); 1775 + return ret; 1766 1776 } 1767 1777 1768 - dsc->initial_offset = 6144; /* Not bpp 12 */ 1769 - if (bpp != 8) 1770 - dsc->initial_offset = 2048; /* bpp = 12 */ 1771 - 1772 - if (dsc->bits_per_component <= 10) 1773 - dsc->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC; 1774 - else 1775 - dsc->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC; 1776 - 1777 - dsc->initial_xmit_delay = 512; 1778 1778 dsc->initial_scale_value = 32; 1779 - dsc->first_line_bpg_offset = 12; 1780 1779 dsc->line_buf_depth = dsc->bits_per_component + 1; 1781 - 1782 - /* bpc 8 */ 1783 - dsc->flatness_min_qp = 3; 1784 - dsc->flatness_max_qp = 12; 1785 - dsc->rc_quant_incr_limit0 = 11; 1786 - dsc->rc_quant_incr_limit1 = 11; 1787 1780 1788 1781 return drm_dsc_compute_rc_parameters(dsc); 1789 1782 }