Skip to content

Commit cc84b66

Browse files
MarijnS95lumag
authored andcommitted
drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits
The bpg_offset array contains negative BPG offsets which fill the full 8 bits of a char thanks to two's complement: this however results in those bits bleeding into the next field when the value is packed into DSC PPS by the drm_dsc_helper function, which only expects range_bpg_offset to contain 6-bit wide values. As a consequence random slices appear corrupted on-screen (tested on a Sony Tama Akatsuki device with sdm845). Use AND operators to limit these two's complement values to 6 bits, similar to the AMD and i915 drivers. Fixes: b908032 ("drm/msm/dsi: add support for dsc data") Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org> Patchwork: https://patchwork.freedesktop.org/patch/508941/ Link: https://lore.kernel.org/r/20221026182824.876933-11-marijn.suijten@somainline.org Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
1 parent 0b55f6b commit cc84b66

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/gpu/drm/msm/dsi/dsi_host.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,11 @@ static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc
17821782
for (i = 0; i < DSC_NUM_BUF_RANGES; i++) {
17831783
dsc->rc_range_params[i].range_min_qp = min_qp[i];
17841784
dsc->rc_range_params[i].range_max_qp = max_qp[i];
1785-
dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i];
1785+
/*
1786+
* Range BPG Offset contains two's-complement signed values that fill
1787+
* 8 bits, yet the registers and DCS PPS field are only 6 bits wide.
1788+
*/
1789+
dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i] & DSC_RANGE_BPG_OFFSET_MASK;
17861790
}
17871791

17881792
dsc->initial_offset = 6144; /* Not bpp 12 */

0 commit comments

Comments
 (0)