Skip to content

Commit d2c277c

Browse files
MarijnS95lumag
authored andcommitted
drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits
drm_dsc_config's bits_per_pixel field holds a fractional value with 4 bits, which all panel drivers should adhere to for drm_dsc_pps_payload_pack() to generate a valid payload. All code in the DSI driver here seems to assume that this field doesn't contain any fractional bits, hence resulting in the wrong values being computed. Since none of the calculations leave any room for fractional bits or seem to indicate any possible area of support, disallow such values altogether. calculate_rc_params() in intel_vdsc.c performs an identical bitshift to get at this integer value. Fixes: b908032 ("drm/msm/dsi: add support for dsc data") Reviewed-by: Abhinav Kumar <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Marijn Suijten <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/508938/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent c3a1aab commit d2c277c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#define DSI_RESET_TOGGLE_DELAY_MS 20
3636

37-
static int dsi_populate_dsc_params(struct drm_dsc_config *dsc);
37+
static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc);
3838

3939
static int dsi_get_version(const void __iomem *base, u32 *major, u32 *minor)
4040
{
@@ -909,6 +909,7 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi)
909909
u32 va_end = va_start + mode->vdisplay;
910910
u32 hdisplay = mode->hdisplay;
911911
u32 wc;
912+
int ret;
912913

913914
DBG("");
914915

@@ -944,7 +945,9 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi)
944945
/* we do the calculations for dsc parameters here so that
945946
* panel can use these parameters
946947
*/
947-
dsi_populate_dsc_params(dsc);
948+
ret = dsi_populate_dsc_params(msm_host, dsc);
949+
if (ret)
950+
return;
948951

949952
/* Divide the display by 3 but keep back/font porch and
950953
* pulse width same
@@ -1748,9 +1751,15 @@ static char bpg_offset[DSC_NUM_BUF_RANGES] = {
17481751
2, 0, 0, -2, -4, -6, -8, -8, -8, -10, -10, -12, -12, -12, -12
17491752
};
17501753

1751-
static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
1754+
static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc)
17521755
{
17531756
int i;
1757+
u16 bpp = dsc->bits_per_pixel >> 4;
1758+
1759+
if (dsc->bits_per_pixel & 0xf) {
1760+
DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support fractional bits_per_pixel\n");
1761+
return -EINVAL;
1762+
}
17541763

17551764
dsc->rc_model_size = 8192;
17561765
dsc->first_line_bpg_offset = 12;
@@ -1771,8 +1780,8 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
17711780
dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i];
17721781
}
17731782

1774-
dsc->initial_offset = 6144; /* Not bpp 12 */
1775-
if (dsc->bits_per_pixel != 8)
1783+
dsc->initial_offset = 6144; /* Not bpp 12 */
1784+
if (bpp != 8)
17761785
dsc->initial_offset = 2048; /* bpp = 12 */
17771786

17781787
if (dsc->bits_per_component <= 10)

0 commit comments

Comments
 (0)