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: 107325 Delivered-To: patches@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3926346qge; Mon, 10 Jul 2017 13:48:07 -0700 (PDT) X-Received: by 10.99.143.94 with SMTP id r30mr16341760pgn.102.1499719687732; Mon, 10 Jul 2017 13:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499719687; cv=none; d=google.com; s=arc-20160816; b=GxHJ/8JgqSZ1PtPk72mG38vBN2GUf4UGZSpOPcUEXqsJ9zE1WLQAAqPuh0ikOP7tWZ K0G2ENJWdj5AwNT+SHl979lVwq7+uu5COTuGloj6KIVm9/Jh2oOQZgoG/r/4Dll7h3a6 YOkbDogG3ORo1F4r2bkdrTsxljISDB9i1E8OQqTbPEIX/vn7kkq8Tb2FyuKQ3LIEqiXC yFHbIIfbkRZxVoTwjT9i2DBm8AA1spGSKMZyNUG+oolHj7asSrS+UxiJE2Mjz1rBG2op RTPqZbiqUxEvj9gjTzG393b14QUCtK+JNdghvRfOiI0GaPH9oZ8JmQrNr7PWCxA4aECU Sf+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=AMAW2oiSzshdV6hf/1oiNCBGA9FynVwweexyYfrH9wI=; b=vECPtlNtEB231WYFBwkxJJ15P7/zcC8rYC/KEQv4Qr68KD3dmIqGAxoyfEeIeczwCl DportrFP3DAhKFENl4MIR8AtrQXtl8EN4gOhsbhU7DBYk4X0o93rbVMN6R/aENKaQi+m 5xzS7aSBQebtVOKcDB5ZdeJApuYAtfK3W67c2L/zXjdmjdRD+tQQ9YpG5h//9beee6FK FtKq8sH0YceU2oG/RrCVinNXSzT2ZTDKkc17rZ2Y5lyX+yt3welEojO+fozbiio5Gz7v LTKpaXQaSAe+ehb5swIHfW/ntrQkjPBcMwsKPsmNgZOh4mPy2uQIkXGNoFf9iPmbPA1z nptg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=SyWhB3Hj; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::232 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-pf0-x232.google.com (mail-pf0-x232.google.com. [2607:f8b0:400e:c00::232]) by mx.google.com with ESMTPS id b6si9324757pll.83.2017.07.10.13.48.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jul 2017 13:48:07 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::232 as permitted sender) client-ip=2607:f8b0:400e:c00::232; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=SyWhB3Hj; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::232 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pf0-x232.google.com with SMTP id q86so55563320pfl.3 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=f/gtLddqc+s/wViV5Stzn3ixRCwg45OQF6cgzEC/0lSJ5DoBof6N7ULpBtHh1n8P1O tKRE4LIabn63HNDDrIUI1keQJF2hETF678Qn4uMdn+sK4pfdZjY5k2m8nWvpkvaqJgxN XUCXR8JF+okax4MFAWYXWD0JPDpoooWUvRYQ1ZtxO5gcOIZFzVIinwjA2S7p5H0Dkxoy sTUzzAE1USlMlWBz/W2ZxR1J8VPMWJtnIY5s/b01IRRg5lCmNXCLxXwisP65raDSeWTB /JVBC3TB93BcCVmNDbLEuf1cqGPi95UqwBVeiBhlnixDNTbcxZ0JutWUoSe38A1OwJ3g /j2g== X-Gm-Message-State: AIVw110kKjaNGVyXkoncUOVkmkpq8U2WjLIka0rEplQ7OGidNmXVqCuW vHzEApBcul5l3RUQb4o= X-Received: by 10.99.172.17 with SMTP id v17mr16436818pge.196.1499719687419; Mon, 10 Jul 2017 13:48:07 -0700 (PDT) Return-Path: 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 Cc: John Stultz , Daniel Vetter , Jani Nikula , Sean Paul , David Airlie , Rob Clark , Xinliang Liu , Xinliang Liu , Rongrong Zou , Xinwei Kong , Chen Feng , Jose Abreu , Archit Taneja , dri-devel@lists.freedesktop.org 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 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(+) -- 2.7.4 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