From patchwork Tue Feb 14 19:25:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 9572575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5C7C860573 for ; Tue, 14 Feb 2017 19:25:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B1D627D8D for ; Tue, 14 Feb 2017 19:25:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4000C27F81; Tue, 14 Feb 2017 19:25:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D39C627D8D for ; Tue, 14 Feb 2017 19:25:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 667556E7E1; Tue, 14 Feb 2017 19:25:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot0-x232.google.com (mail-ot0-x232.google.com [IPv6:2607:f8b0:4003:c0f::232]) by gabe.freedesktop.org (Postfix) with ESMTPS id CF92C6E7DB for ; Tue, 14 Feb 2017 19:25:11 +0000 (UTC) Received: by mail-ot0-x232.google.com with SMTP id 32so102094540oth.3 for ; Tue, 14 Feb 2017 11:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rGpJlTut9rmXqY2tl0yQZxgDFGfcFmqWpVo1S5sMNLg=; b=eL3oBAEiBMksQtVPvYL8auVWwqC+kkgCDrbTuGWZjtc6BBT+Z0fNrhjJGU2YX02F3X RaPccQOo+P9UQ9zv7KQTPuBOc88iLYlxlmXk2TUkP3rhn0yZpJIxCJsClNX++Yju+VI/ OtwBACypRfyGsX2nHZqE1MokluSY6AyrUWJxo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rGpJlTut9rmXqY2tl0yQZxgDFGfcFmqWpVo1S5sMNLg=; b=p1UN/wkzabpFpQziy0N7b45b5v3eN8CAqyscm5rB5o3LYWquvRTh9T/+gT3oG9gTBZ TS/rMqnNqxvqqm8q9gM5iLQFaSJ7I/NYzKg4rSw6iOjhhItaZXdDh5xDlo8VSGEpXTYz md10r2z0kRRdPx4/H2w6tuNTQNjo/XQuAGx/yTdw6/JjPudnt2jbywvyRXdd9bPdZSpp 5xgPRnvr2TdgR+4WDjYfOOqMoKpxdY9bhHrKNTCgjYKdHmxN/g5QeYflV9gvE5LZnsyG lel23lnR3a+JvbmSLbCcxsGM7VN5bUuolvoaM9jf/zORASQhuOnA+fsoUn67dMpM4o0x 6tyQ== X-Gm-Message-State: AMke39mbk0Ui+lb8d/A95LdW1YDuIhJJLWO/rs9P7IKaACtCRUkyaDEgoG5dDgAn6ks8Y4o5 X-Received: by 10.98.71.7 with SMTP id u7mr33583001pfa.76.1487100311059; Tue, 14 Feb 2017 11:25:11 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id t6sm2825378pgt.8.2017.02.14.11.25.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Feb 2017 11:25:09 -0800 (PST) From: John Stultz To: lkml Subject: [RFC][PATCH 2/2] drm: kirin: Restrict modes to known good mode clocks Date: Tue, 14 Feb 2017 11:25:02 -0800 Message-Id: <1487100302-9445-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487100302-9445-1-git-send-email-john.stultz@linaro.org> References: <1487100302-9445-1-git-send-email-john.stultz@linaro.org> Cc: Chen Feng , Xinwei Kong , Xinliang Liu , dri-devel@lists.freedesktop.org, Rongrong Zou , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 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 Cc: Jani Nikula Cc: Sean Paul Cc: David Airlie Cc: Rob Clark Cc: Xinliang Liu Cc: Xinliang Liu Cc: Rongrong Zou Cc: Xinwei Kong Cc: Chen Feng Cc: Archit Taneja Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index afc2b5d..9161633 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -504,6 +504,43 @@ static void ade_crtc_disable(struct drm_crtc *crtc) acrtc->enable = false; } +static enum drm_mode_status ade_crtc_mode_valid(struct drm_crtc *crtc, + struct drm_display_mode *mode) +{ + /* + * kirin_ade cannot generate all modes, so use the whitelist below + */ + DRM_DEBUG("Checking mode %ix%i@%i clock: %i...", + 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)) { + mode->type |= DRM_MODE_TYPE_PREFERRED; + DRM_DEBUG("OK\n"); + return MODE_OK; + } + DRM_DEBUG("BAD\n"); + return MODE_BAD; +} + static void ade_crtc_mode_set_nofb(struct drm_crtc *crtc) { struct ade_crtc *acrtc = to_ade_crtc(crtc); @@ -557,6 +594,7 @@ static void ade_crtc_atomic_flush(struct drm_crtc *crtc, static const struct drm_crtc_helper_funcs ade_crtc_helper_funcs = { .enable = ade_crtc_enable, .disable = ade_crtc_disable, + .mode_valid = ade_crtc_mode_valid, .mode_set_nofb = ade_crtc_mode_set_nofb, .atomic_begin = ade_crtc_atomic_begin, .atomic_flush = ade_crtc_atomic_flush,