Commit 7df1ed6d authored by Jessica Zhang's avatar Jessica Zhang Committed by Dmitry Baryshkov
Browse files

drm/display/dsc: Add flatness and initial scale value calculations



Add helpers to calculate det_thresh_flatness and initial_scale_value as
these calculations are defined within the DSC spec.

Reviewed-by: default avatarMarijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: default avatarJessica Zhang <quic_jesszhan@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/539282/
Link: https://lore.kernel.org/r/20230329-rfc-msm-dsc-helper-v14-1-bafc7be95691@quicinc.com


Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
parent c7237517
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -1413,3 +1413,27 @@ int drm_dsc_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg)
	return 0;
}
EXPORT_SYMBOL(drm_dsc_compute_rc_parameters);

/**
 * drm_dsc_initial_scale_value() - Calculate the initial scale value for the given DSC config
 * @dsc: Pointer to DRM DSC config struct
 *
 * Return: Calculated initial scale value
 */
u8 drm_dsc_initial_scale_value(const struct drm_dsc_config *dsc)
{
	return 8 * dsc->rc_model_size / (dsc->rc_model_size - dsc->initial_offset);
}
EXPORT_SYMBOL(drm_dsc_initial_scale_value);

/**
 * drm_dsc_flatness_det_thresh() - Calculate the flatness_det_thresh for the given DSC config
 * @dsc: Pointer to DRM DSC config struct
 *
 * Return: Calculated flatness det thresh value
 */
u32 drm_dsc_flatness_det_thresh(const struct drm_dsc_config *dsc)
{
	return 2 << (dsc->bits_per_component - 8);
}
EXPORT_SYMBOL(drm_dsc_flatness_det_thresh);
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ void drm_dsc_pps_payload_pack(struct drm_dsc_picture_parameter_set *pps_sdp,
void drm_dsc_set_rc_buf_thresh(struct drm_dsc_config *vdsc_cfg);
int drm_dsc_setup_rc_params(struct drm_dsc_config *vdsc_cfg, enum drm_dsc_params_type type);
int drm_dsc_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg);
u8 drm_dsc_initial_scale_value(const struct drm_dsc_config *dsc);
u32 drm_dsc_flatness_det_thresh(const struct drm_dsc_config *dsc);

#endif /* _DRM_DSC_HELPER_H_ */