Re: [PATCH] drm/komeda: Adds more check in mode_valid

From: Mihail Atanassov
Date: Thu Oct 03 2019 - 13:06:06 EST


On Friday, 26 July 2019 09:06:16 BST Lowry Li (Arm Technology China) wrote:
> This patch adds the checks for vrefresh, crtc_hdisplay and crtc_vdisplay.
>
> Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@xxxxxxx>
> ---
> drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 28 +++++++++++++++++++++++-
> 1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> index 2fed1f6..017f6b6 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -403,11 +403,37 @@ unsigned long komeda_crtc_get_aclk(struct komeda_crtc_state *kcrtc_st)
> struct komeda_dev *mdev = crtc->dev->dev_private;
> struct komeda_crtc *kcrtc = to_kcrtc(crtc);
> struct komeda_pipeline *master = kcrtc->master;
> - unsigned long min_pxlclk, min_aclk;
> + struct komeda_compiz *compiz = master->compiz;
> + unsigned long min_pxlclk, min_aclk, delta, full_frame;
> + int hdisplay = m->hdisplay;
>
> if (m->flags & DRM_MODE_FLAG_INTERLACE)
> return MODE_NO_INTERLACE;
>
> + full_frame = m->htotal * m->vtotal;
> + delta = abs(m->clock * 1000 - m->vrefresh * full_frame);
> + if (m->vrefresh && (delta > full_frame)) {
> + DRM_DEBUG_ATOMIC("mode clock check error!\n");
> + return MODE_CLOCK_RANGE;
> + }
> +
> + if (kcrtc->side_by_side)
> + hdisplay /= 2;
> +
> + if (!in_range(&compiz->hsize, hdisplay)) {
> + DRM_DEBUG_ATOMIC("hdisplay[%u] is out of range[%u, %u]!\n",
> + hdisplay, compiz->hsize.start,
> + compiz->hsize.end);
> + return MODE_BAD_HVALUE;
> + }
> +
> + if (!in_range(&compiz->vsize, m->vdisplay)) {
> + DRM_DEBUG_ATOMIC("vdisplay[%u] is out of range[%u, %u]!\n",
> + m->vdisplay, compiz->vsize.start,
> + compiz->vsize.end);
> + return MODE_BAD_VVALUE;
> + }
> +
> min_pxlclk = m->clock * 1000;
> if (master->dual_link)
> min_pxlclk /= 2;
>
LGTM,

Reviewed-by: Mihail Atanassov <mihail.atanassov@xxxxxxx>

--
Mihail