mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Paul <seanpaul@chromium.org>
To: John Stultz <john.stultz@linaro.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Daniel Vetter <daniel.vetter@intel.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Sean Paul <seanpaul@chromium.org>,
	David Airlie <airlied@linux.ie>, Rob Clark <robdclark@gmail.com>,
	Xinliang Liu <xinliang.liu@linaro.org>,
	Xinliang Liu <z.liuxinliang@hisilicon.com>,
	Rongrong Zou <zourongrong@gmail.com>,
	Xinwei Kong <kong.kongxinwei@hisilicon.com>,
	Chen Feng <puck.chen@hisilicon.com>,
	Jose Abreu <Jose.Abreu@synopsys.com>,
	Archit Taneja <architt@codeaurora.org>,
	dri-devel@lists.freedesktop.org
Subject: Re: [RFC][PATCH] drm: kirin: Restrict modes to known good mode clocks
Date: Mon, 10 Jul 2017 17:18:33 -0400	[thread overview]
Message-ID: <20170710211833.bprcrq5tfpzxtpeg@art_vandelay> (raw)
In-Reply-To: <1499719682-31750-1-git-send-email-john.stultz@linaro.org>

On Mon, Jul 10, 2017 at 01:48:02PM -0700, John Stultz wrote:
> Currently the hikey dsi logic cannot generate accurate byte
> clocks values for all pixel clock values. Thus if a mode clock
> is selected that cannot match the calculated byte clock, the
> device will boot with a blank screen.
> 
> This patch uses the new mode_valid callback (many thanks to
> Jose Abreu for upstreaming it!) to enforces known good mode
> clocks for well known resolutions, which should allow the
> display to work from given EDID options, and ensures for a given
> resolution & refresh, the right mode clock is selected.
> 
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Xinliang Liu <xinliang.liu@linaro.org>
> Cc: Xinliang Liu <z.liuxinliang@hisilicon.com>
> Cc: Rongrong Zou <zourongrong@gmail.com>
> Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
> Cc: Chen Feng <puck.chen@hisilicon.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Cc: Archit Taneja <architt@codeaurora.org>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
>  drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 37 ++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
> index f77dcfa..a84f4bb 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
> @@ -603,6 +603,42 @@ static void dsi_encoder_enable(struct drm_encoder *encoder)
>  	dsi->enable = true;
>  }
>  
> +static enum drm_mode_status dsi_encoder_mode_valid(struct drm_encoder *crtc,
> +					const struct drm_display_mode *mode)
> +{
> +	/*
> +	 * kirin cannot generate all modes, so use the whitelist below
> +	 */
> +	DRM_DEBUG("%s: Checking mode %ix%i@%i clock: %i...", __func__,
> +		mode->hdisplay, mode->vdisplay, drm_mode_vrefresh(mode), mode->clock);
> +	if ((mode->hdisplay == 1920 && mode->vdisplay == 1080 && mode->clock == 148500) ||
> +	    (mode->hdisplay == 1920 && mode->vdisplay == 1080 && mode->clock == 80192)  ||
> +	    (mode->hdisplay == 1920 && mode->vdisplay == 1080 && mode->clock == 74250)  ||
> +	    (mode->hdisplay == 1920 && mode->vdisplay == 1080 && mode->clock == 61855)  ||
> +	    (mode->hdisplay == 1680 && mode->vdisplay == 1050 && mode->clock == 147116) ||
> +	    (mode->hdisplay == 1680 && mode->vdisplay == 1050 && mode->clock == 146250) ||
> +	    (mode->hdisplay == 1680 && mode->vdisplay == 1050 && mode->clock == 144589) ||
> +	    (mode->hdisplay == 1600 && mode->vdisplay == 1200 && mode->clock == 160961) ||
> +	    (mode->hdisplay == 1600 && mode->vdisplay == 900  && mode->clock == 118963) ||
> +	    (mode->hdisplay == 1440 && mode->vdisplay == 900  && mode->clock == 126991) ||
> +	    (mode->hdisplay == 1280 && mode->vdisplay == 1024 && mode->clock == 128946) ||
> +	    (mode->hdisplay == 1280 && mode->vdisplay == 1024 && mode->clock == 98619)  ||
> +	    (mode->hdisplay == 1280 && mode->vdisplay == 960  && mode->clock == 102081) ||
> +	    (mode->hdisplay == 1280 && mode->vdisplay == 800  && mode->clock == 83496)  ||
> +	    (mode->hdisplay == 1280 && mode->vdisplay == 720  && mode->clock == 74440)  ||
> +	    (mode->hdisplay == 1280 && mode->vdisplay == 720  && mode->clock == 74250)  ||
> +	    (mode->hdisplay == 1024 && mode->vdisplay == 768  && mode->clock == 78800)  ||
> +	    (mode->hdisplay == 1024 && mode->vdisplay == 768  && mode->clock == 75000)  ||
> +	    (mode->hdisplay == 1024 && mode->vdisplay == 768  && mode->clock == 81833)  ||
> +	    (mode->hdisplay == 800  && mode->vdisplay == 600  && mode->clock == 48907)  ||
> +	    (mode->hdisplay == 800  && mode->vdisplay == 600  && mode->clock == 40000)) {

Bikeshed incoming:

Can you break this out into a lookup table? It's kind of long-winded as-is. It'd
be even better if you could calculate whether the mode is valid, but I didn't
spend enough time to figure out if this is possible.

Sean


> +		DRM_DEBUG("OK\n");
> +		return MODE_OK;
> +	}
> +	DRM_DEBUG("BAD\n");
> +	return MODE_BAD;
> +}
> +
>  static void dsi_encoder_mode_set(struct drm_encoder *encoder,
>  				 struct drm_display_mode *mode,
>  				 struct drm_display_mode *adj_mode)
> @@ -622,6 +658,7 @@ static int dsi_encoder_atomic_check(struct drm_encoder *encoder,
>  
>  static const struct drm_encoder_helper_funcs dw_encoder_helper_funcs = {
>  	.atomic_check	= dsi_encoder_atomic_check,
> +	.mode_valid	= dsi_encoder_mode_valid,
>  	.mode_set	= dsi_encoder_mode_set,
>  	.enable		= dsi_encoder_enable,
>  	.disable	= dsi_encoder_disable
> -- 
> 2.7.4
> 

-- 
Sean Paul, Software Engineer, Google / Chromium OS

  reply	other threads:[~2017-07-10 21:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-10 20:48 John Stultz
2017-07-10 21:18 ` Sean Paul [this message]
2017-07-10 22:47   ` John Stultz
2017-07-11  7:56     ` Daniel Vetter
2017-07-11 15:05       ` John Stultz
2017-07-11 15:12         ` Daniel Vetter
2017-07-11 15:44           ` John Stultz
2017-07-11 16:27             ` Daniel Vetter
2017-07-17 23:20               ` John Stultz
2017-07-18  6:26                 ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170710211833.bprcrq5tfpzxtpeg@art_vandelay \
    --to=seanpaul@chromium.org \
    --cc=Jose.Abreu@synopsys.com \
    --cc=airlied@linux.ie \
    --cc=architt@codeaurora.org \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=john.stultz@linaro.org \
    --cc=kong.kongxinwei@hisilicon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=puck.chen@hisilicon.com \
    --cc=robdclark@gmail.com \
    --cc=xinliang.liu@linaro.org \
    --cc=z.liuxinliang@hisilicon.com \
    --cc=zourongrong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®