From patchwork Mon Jul 10 20:48: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: 9833765 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 77F6260350 for ; Mon, 10 Jul 2017 20:48:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 699D928562 for ; Mon, 10 Jul 2017 20:48:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E3A32856A; Mon, 10 Jul 2017 20:48:11 +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 8C50F28562 for ; Mon, 10 Jul 2017 20:48:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5ADE89C53; Mon, 10 Jul 2017 20:48:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x22c.google.com (mail-pf0-x22c.google.com [IPv6:2607:f8b0:400e:c00::22c]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE12489BB3 for ; Mon, 10 Jul 2017 20:48:07 +0000 (UTC) Received: by mail-pf0-x22c.google.com with SMTP id q85so55546839pfq.1 for ; Mon, 10 Jul 2017 13:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=AMAW2oiSzshdV6hf/1oiNCBGA9FynVwweexyYfrH9wI=; b=SyWhB3Hj4jQp0PgOLOuakRlWCfRMS1jV4qOqUDccOFEqXlLyyUeZCyUvov1q34DdHx s+hkw8POlG0MnBg7Xnc8NDlHRCS2UaO7hhffZ3ag66PywSRFvzkYLJpIvoQNeaJjAV0t uc8t4PgbheGQmsH9y6Wv49fxHq9Wq4GBkHsT0= 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; bh=AMAW2oiSzshdV6hf/1oiNCBGA9FynVwweexyYfrH9wI=; b=AqKejQZ9q4nNAR7IdubV3Cd1nr6U3naUw4ixQtRMIYvnSRmL396hyhbx6XGxUft+2P 7jbCB7PcHKXgnyjib6Gt6MQ00P3m3nbiyV1uCwJjXrrWwkyCydg0kDOTnPZbBDfHqd8a 31X7ltj8YOa2OWZTCx6aVpk+42JaGGnNr9Y8n+Ng1Xhue6lKvoEsSdvb45SXiPki8OYP S/IHv4ko2vuyMpRs2Uwk/EbqCx+Ow58DOqYy9UN1oABiN6MOlP63nrRzrkU21wpbS7ee sXGu3Eapa16gWilpK5mS13ohzRLCX9TDGWrszIQgE+OC+MWmTJDeM6qcRjFgNU3xeb0k tQUA== X-Gm-Message-State: AIVw111/qpSR8caMuLEZL7boKR+BS01xZ+3xgmgV9j+NvBvt/CycjNOR VpFgFPJDQBDVD172 X-Received: by 10.99.172.17 with SMTP id v17mr16436818pge.196.1499719687419; Mon, 10 Jul 2017 13:48:07 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id l78sm7295641pfb.59.2017.07.10.13.48.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Jul 2017 13:48:06 -0700 (PDT) From: John Stultz To: lkml Subject: [RFC][PATCH] drm: kirin: Restrict modes to known good mode clocks Date: Mon, 10 Jul 2017 13:48:02 -0700 Message-Id: <1499719682-31750-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: Jose Abreu , 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 (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 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: Jose Abreu Cc: Archit Taneja Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz --- 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)) { + 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