Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp47027imm; Mon, 4 Jun 2018 12:45:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIuHsdVru05EDqkGzBqGSuDge7zCU/t2d7IxiUeLUNBD+wydAl/EECup/KjUs7m0/WPaXpK X-Received: by 2002:a17:902:8341:: with SMTP id z1-v6mr7200450pln.40.1528141540819; Mon, 04 Jun 2018 12:45:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528141540; cv=none; d=google.com; s=arc-20160816; b=Ll3qH497fm6jEsLM+PfYjYo2c4a9TLo9u+83/JxyYT3JQzPcPN28PSc4X10MD07vmm UpnEjuJXDlE1Pqtry/E/GDLKl5IWpSZanr38CQiiYh8ZOITyyY85/sj19mkScDTv2ic7 Az/hFUG/YElzAMNW2jo8BcTBo6qvoJDzco+dYe9e8cqeW5njGHHIdslEANviLAzWqnoZ tniJa/dFQuburVxEC+9JOStfadVnJhGmVsfgxU1kbZMYgf8CYJGIp1hFPhRwZK0RlAkv rFCsGYH6V7HaPvFChaaooy2EoQp3Ef/dtWpV7ZEUX+9EXIvxQ40oBkXVckK6uizbEbEd kI8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=e5OvmQiuv/nAjfjua9m+a++QAX4sVfmZLM/BvJvw0F4=; b=do1SeKk8GBUVoZ85t5AjeJpLNBA7rW/Xc+gbYfe4iU3T2HC9ytF65E+atT1qYa2h0v G5jeZjdbM8y72dFeh8O2IvR/jdN+MQIT/SU5QzfWR7UJOYojZbVAfzdSl1MCmTFbMx4i sKOd50hNeZYSe4jReCxCITbgQxBaC0yekAAjxXgfYRvhoMqYCAahoogMRTSg0XrvOXzw K8oMIBn84NdH3IQtlOSfLbDwPGA0MmFE+euh+UHSKzeUt/nnczb7DU2OfkgjEOV+8PW8 UrAqb0U7A+YiaAW/paW6zHhSBGaueeKXRfWHEMuomqf0txu++YMSe5E6K0Gmxb6pDzF1 f4Ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v69-v6si22449431pgb.609.2018.06.04.12.45.25; Mon, 04 Jun 2018 12:45:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751091AbeFDTom (ORCPT + 99 others); Mon, 4 Jun 2018 15:44:42 -0400 Received: from anholt.net ([50.246.234.109]:59046 "EHLO anholt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750779AbeFDTok (ORCPT ); Mon, 4 Jun 2018 15:44:40 -0400 Received: from localhost (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id E949C10A1642; Mon, 4 Jun 2018 12:44:39 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at anholt.net Received: from anholt.net ([127.0.0.1]) by localhost (kingsolver.anholt.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 6z5GTDVQcU1R; Mon, 4 Jun 2018 12:44:38 -0700 (PDT) Received: from eliezer.anholt.net (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 4CBE410A0413; Mon, 4 Jun 2018 12:44:38 -0700 (PDT) Received: by eliezer.anholt.net (Postfix, from userid 1000) id AEA2C2FE2D7C; Mon, 4 Jun 2018 12:44:37 -0700 (PDT) From: Eric Anholt To: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, Eric Anholt , Kevin Quigley , James Hughes , Boris Brezillon Subject: [PATCH] drm/vc4: Enable the DSI module and link before other enables. Date: Mon, 4 Jun 2018 12:44:37 -0700 Message-Id: <20180604194437.13790-1-eric@anholt.net> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We want the DSI PHY to be enabled and the DSI module clocked before a panel or bridge's prepare() function, since most DSI panel drivers with a prepare() hook are doing DCS transactions inside of them. Signed-off-by: Eric Anholt Cc: Kevin Quigley Cc: James Hughes Cc: Boris Brezillon --- I'm not sure it makes sense to enable CRTCs before encoders on vc4 at all. Why start scanning pixels before the encoder is ready to hear about VSTART? However, this patch will hopefully unblock people trying to attach other panels to rpi drivers/gpu/drm/vc4/vc4_drv.h | 1 + drivers/gpu/drm/vc4/vc4_dsi.c | 3 +-- drivers/gpu/drm/vc4/vc4_kms.c | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index 554a4e810d5b..e7d7bfc75acd 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -711,6 +711,7 @@ int vc4_dpi_debugfs_regs(struct seq_file *m, void *unused); /* vc4_dsi.c */ extern struct platform_driver vc4_dsi_driver; int vc4_dsi_debugfs_regs(struct seq_file *m, void *unused); +void vc4_dsi_prepare(struct drm_encoder *encoder); /* vc4_fence.c */ extern const struct dma_fence_ops vc4_fence_ops; diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index 8aa897835118..88471731e066 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -875,7 +875,7 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, return true; } -static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) +void vc4_dsi_prepare(struct drm_encoder *encoder) { struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; struct vc4_dsi_encoder *vc4_encoder = to_vc4_dsi_encoder(encoder); @@ -1345,7 +1345,6 @@ static const struct mipi_dsi_host_ops vc4_dsi_host_ops = { static const struct drm_encoder_helper_funcs vc4_dsi_encoder_helper_funcs = { .disable = vc4_dsi_encoder_disable, - .enable = vc4_dsi_encoder_enable, .mode_fixup = vc4_dsi_encoder_mode_fixup, }; diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c index 8a411e5f8776..7e9b52ba3448 100644 --- a/drivers/gpu/drm/vc4/vc4_kms.c +++ b/drivers/gpu/drm/vc4/vc4_kms.c @@ -140,6 +140,9 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state) { struct drm_device *dev = state->dev; struct vc4_dev *vc4 = to_vc4_dev(dev); + struct drm_connector *connector; + struct drm_connector_state *new_conn_state; + int i; drm_atomic_helper_wait_for_fences(dev, state, false); @@ -151,6 +154,28 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state) drm_atomic_helper_commit_planes(dev, state, 0); + /* Enable DSI link. */ + for_each_new_connector_in_state(state, connector, new_conn_state, i) { + struct drm_encoder *encoder; + struct vc4_encoder *vc4_encoder; + + if (!new_conn_state->best_encoder) + continue; + + if (!new_conn_state->crtc->state->active || + !drm_atomic_crtc_needs_modeset(new_conn_state->crtc->state)) + continue; + + (void)connector; + encoder = new_conn_state->best_encoder; + vc4_encoder = to_vc4_encoder(encoder); + + if (vc4_encoder->type == VC4_ENCODER_TYPE_DSI0 || + vc4_encoder->type == VC4_ENCODER_TYPE_DSI1) { + vc4_dsi_prepare(encoder); + } + } + drm_atomic_helper_commit_modeset_enables(dev, state); /* Make sure that drm_atomic_helper_wait_for_vblanks() -- 2.17.0