Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3527555pxb; Mon, 24 Jan 2022 11:27:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIRYB6mjzFAcwfBnM8uC2Q0blh2tz7t8lAiENF96AjX6pfiV8X6wgnceJ8WryFf9cBsKHP X-Received: by 2002:a17:903:110c:b0:149:8018:e9d4 with SMTP id n12-20020a170903110c00b001498018e9d4mr15287939plh.117.1643052425052; Mon, 24 Jan 2022 11:27:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643052425; cv=none; d=google.com; s=arc-20160816; b=cwuAQq/XK6kZ8rNt9dIUfIQK3Tv8Errp2sXhSfeySXP6eNES6vMopdK3cZoypnqqsC AocEiSJPpgnwx14W/DcBWuLnnSi7jDrWF1egz0OKgoRo4nCrqr6IIN11zc6du3yaU4sd Nocz90fkf8Xay8wOKtDamfTntWt5O4m1yd3EqZHtxX4ebspmA2PvtRQ/VhPoPVd5N2C3 Rlg6LV72cYY5hLqaG5e4hz1G3Dkx7RHfaNF9zet4ryHDFM7cFkn9a5UXIapbsC5QN7Ec c98UcfIgzCMSew17jxRgzxpCtU01NSPTlXC7aNLHw/uYPO0c3YvhUTzct2cMH0+p/rD7 kCEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=HoCKTXe73b6LRfZ2yfJRg1I4/082DZV6wf8n+3iyv3U=; b=XMQrI2TxuCP+Oe4/Dg3PUOajR2VHtXMs70iKRgdB8EZEnnohyTb6js9EwrCgPR5jTl eDmo74a2UIcKh6vu7fNiVCMF3kij4gJorKEnBfnvcZlkCo6aJiSrizTNrtffgKz63kQp G6aX8X7DOGySxU1aS5Zrs20E1pZImTNfL88baL9hJnkpb1k7bbgEbsRE8OuTGWlMmd6c SW2zFQN5/NYsncvD8G6O6ntlq6vOdJoxBLFo0mpaC+OnpFu8r5oLfHHMTe18v8ahXbP/ 5ZBNTjuen7AhEgUItyXSUa+ucusIe3jGDgP2fXrClA+NNSf8aNP13vpvEfinS7KxdQus 6Auw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=DXFMPQqZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r84si6173809pgr.542.2022.01.24.11.26.51; Mon, 24 Jan 2022 11:27:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=DXFMPQqZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240619AbiAXPXy (ORCPT + 99 others); Mon, 24 Jan 2022 10:23:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235210AbiAXPXu (ORCPT ); Mon, 24 Jan 2022 10:23:50 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 363FFC06173B for ; Mon, 24 Jan 2022 07:23:50 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id e8so12468390wrc.0 for ; Mon, 24 Jan 2022 07:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HoCKTXe73b6LRfZ2yfJRg1I4/082DZV6wf8n+3iyv3U=; b=DXFMPQqZJ0tKT0e1GyjQjptwLQE+7cHPUKFQBr+FQZeLkkE77ifDs5YB3GOF2h2Seh bgVGO7FGtiVNy3Mg062PsxfHEv95vu/7FuDahESCUCJFO1xZnM5iGo1upx+/pmKrvaB6 CSUStL3QD1cOCq8v/QVMbsKXpJs2to+BaJ6sFHSy/sLvqdOxY9TIlA8KUI4Jrj4Zarux H3yY4uEjrAm5+t5Un+56XZMFQGrGxPIHVNdV9OMQtXbVEBu7Yd1EyCdR9Putf8JzYEQ7 7zdN+Tdh+rSzq6KW5FsWt+yw5LYnZnrdPn/KOiBaoshGM3xl5+rV4Szbq/KKk17PP89m 4qiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HoCKTXe73b6LRfZ2yfJRg1I4/082DZV6wf8n+3iyv3U=; b=g0cfoMTJzmPhKG89OjtlSl/ekMmY1ECkXvv+oALQxKySqlCyGC/C2WKiY+fLvEyk1G FekPqxQobjBo1W8VFZmA7M1XocGcfxPVFIvp+t0vAnRybO7L5PElBU+A6BiSCidGE6+Q RPAU58D0A7V9JYSxqLIovATy7lJ7VoSawpS2BTJTioLbgt9CwOq4o1o1EBpkHDlGFvc4 aUv7vLxwaPurWmBUfH59Vw0EzDjxLYja9G86+oJYGfgAc8vCNiU0hE0upg+K9rh7WUMu fym3m1yD7TiyrN/+2KhgJqSVS3WwjFt886yiRp7ZNWKBWOAHYaGi9lFuOuHs77XRvT96 mLxA== X-Gm-Message-State: AOAM533qJfCL82nI9lzgEFkW7SwAf5YgmqrRn/vKC8MsS1B+bB08FtYF WlS59kqDWmVzlBsssI6BDGN4haKuTjTmaw== X-Received: by 2002:a5d:544c:: with SMTP id w12mr1825656wrv.47.1643037828828; Mon, 24 Jan 2022 07:23:48 -0800 (PST) Received: from localhost.localdomain (179.160.117.78.rev.sfr.net. [78.117.160.179]) by smtp.gmail.com with ESMTPSA id p14sm3806868wmq.40.2022.01.24.07.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 07:23:48 -0800 (PST) From: Julien STEPHAN Cc: Julien STEPHAN , Mattijs Korpershoek , Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR MEDIATEK), linux-mediatek@lists.infradead.org (moderated list:DRM DRIVERS FOR MEDIATEK), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/mediatek: allow commands to be sent during video mode Date: Mon, 24 Jan 2022 16:22:50 +0100 Message-Id: <20220124152250.441809-1-jstephan@baylibre.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the DSI is in video mode, all commands are rejected. Detect current DSI mode in mtk_dsi_host_transfer() and switch modes temporarily to allow commands to be sent. Signed-off-by: Julien STEPHAN Signed-off-by: Mattijs Korpershoek --- drivers/gpu/drm/mediatek/mtk_dsi.c | 34 ++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index 5d90d2eb0019..7d66fdc7f81d 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -891,24 +891,34 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host, u8 read_data[16]; void *src_addr; u8 irq_flag = CMD_DONE_INT_FLAG; - - if (readl(dsi->regs + DSI_MODE_CTRL) & MODE) { - DRM_ERROR("dsi engine is not command mode\n"); - return -EINVAL; + u32 dsi_mode; + + dsi_mode = readl(dsi->regs + DSI_MODE_CTRL); + if (dsi_mode & MODE) { + mtk_dsi_stop(dsi); + if (mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500)) { + recv_cnt = -EINVAL; + goto restore_dsi_mode; + } } if (MTK_DSI_HOST_IS_READ(msg->type)) irq_flag |= LPRX_RD_RDY_INT_FLAG; - if (mtk_dsi_host_send_cmd(dsi, msg, irq_flag) < 0) - return -ETIME; + if (mtk_dsi_host_send_cmd(dsi, msg, irq_flag) < 0) { + recv_cnt = -ETIME; + goto restore_dsi_mode; + } - if (!MTK_DSI_HOST_IS_READ(msg->type)) - return 0; + if (!MTK_DSI_HOST_IS_READ(msg->type)) { + recv_cnt = 0; + goto restore_dsi_mode; + } if (!msg->rx_buf) { DRM_ERROR("dsi receive buffer size may be NULL\n"); - return -EINVAL; + recv_cnt = -EINVAL; + goto restore_dsi_mode; } for (i = 0; i < 16; i++) @@ -933,6 +943,12 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host, DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n", recv_cnt, *((u8 *)(msg->tx_buf))); +restore_dsi_mode: + if (dsi_mode & MODE) { + mtk_dsi_set_mode(dsi); + mtk_dsi_start(dsi); + } + return recv_cnt; } -- 2.34.1