Skip to content

Commit

Permalink
drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits
Browse files Browse the repository at this point in the history
[ Upstream commit d2c277c ]

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 <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/508938/
Link: https://lore.kernel.org/r/20221026182824.876933-8-marijn.suijten@somainline.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
MarijnS95 authored and gregkh committed Dec 31, 2022
1 parent 8a80ad3 commit 0a323c2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions drivers/gpu/drm/msm/dsi/dsi_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#define DSI_RESET_TOGGLE_DELAY_MS 20

static int dsi_populate_dsc_params(struct drm_dsc_config *dsc);
static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc);

static int dsi_get_version(const void __iomem *base, u32 *major, u32 *minor)
{
Expand Down Expand Up @@ -909,6 +909,7 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi)
u32 va_end = va_start + mode->vdisplay;
u32 hdisplay = mode->hdisplay;
u32 wc;
int ret;

DBG("");

Expand Down Expand Up @@ -944,7 +945,9 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi)
/* we do the calculations for dsc parameters here so that
* panel can use these parameters
*/
dsi_populate_dsc_params(dsc);
ret = dsi_populate_dsc_params(msm_host, dsc);
if (ret)
return;

/* Divide the display by 3 but keep back/font porch and
* pulse width same
Expand Down Expand Up @@ -1748,9 +1751,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 drm_dsc_config *dsc)
static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc)
{
int i;
u16 bpp = dsc->bits_per_pixel >> 4;

if (dsc->bits_per_pixel & 0xf) {
DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support fractional bits_per_pixel\n");
return -EINVAL;
}

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

dsc->initial_offset = 6144; /* Not bpp 12 */
if (dsc->bits_per_pixel != 8)
dsc->initial_offset = 6144; /* Not bpp 12 */
if (bpp != 8)
dsc->initial_offset = 2048; /* bpp = 12 */

if (dsc->bits_per_component <= 10)
Expand Down

0 comments on commit 0a323c2

Please sign in to comment.