From patchwork Thu Feb 10 12:46:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 12741900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17A91C433F5 for ; Thu, 10 Feb 2022 12:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=G0qOq6UcLwwWnBR2Ljmoftq6Ilo0y+VcCJuzO7qlCio=; b=zaQZl6w+wrlW6l q5pOUYVr5ar4syR0heIreoJy/bRhiYkrjrBR0j4f31fRCrJM7lTQq2zm8/Mp8Hr39oDOVnem8B1Lc BAd1Nr1eH5UxVUAVEHiABnBoxOy87ZuhWqfNkYaF/3NN25w+5FvCLqP1230j7E6roUlnw0yD/6fd8 8KrRJJzqN63rF7NPfgXueq20rClZTalsyCNHBvtxrR07D5VkESgCVYWqujUDvn2ySFEHvw04KsoDc oT9TrHRPJMaqoFYYRC7Iktl53KcyL7ECi+ATSDIAfyjg9c3rtNY41w/PAp+aKPvY1rkY8Cc2+YFNn pxHKWyeNebht7uXRnaoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nI8rh-003n4e-40; Thu, 10 Feb 2022 12:48:01 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nI8rY-003n29-Jg for linux-arm-kernel@lists.infradead.org; Thu, 10 Feb 2022 12:47:58 +0000 Received: by mail-wm1-x32c.google.com with SMTP id l67-20020a1c2546000000b00353951c3f62so3845137wml.5 for ; Thu, 10 Feb 2022 04:47:51 -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=mntgPn8Qh+Nga93zR2phIa+qhcyXEPyRC4rw0pc7QyU=; b=CBWimZf5de7rEjmsIbxW3CkZ60rLERED1BkV9KD7RlFFX1/jSQ0iQujTrsjEqdyatc TGucGngeS0HAEfQdmLnuUU9bJYzv7aeAxdxRp3pVk2sfsjvLg+iqX9DDb7KH3YkypUJr oJgdm4QB/zazezXnNWw/2NGivfLqUJ5hD+6MHG8JsjA+SxJ9CZZRttVTo/z9Mof1cyDX /tUdxtb5mjbVUUppHuRWzxdARUE+sWUAOKJFgjgi4D1pZaWfhTpLSQTEOGp27Oc3ss6c 8CHO5LzVKWymSWP06deo8tlSVJQO21bHmYgdFZIUwRtYgm0Rwc0ivlRgKF7Cwc1wjRKH lA6g== 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=mntgPn8Qh+Nga93zR2phIa+qhcyXEPyRC4rw0pc7QyU=; b=TWDYhQvDt86MrUQLBBFc/i39OVxjZo5vfRGNJmPrZHcheoP8XAHQxCr4sRn6g4ZwT1 iXcC62OlpvaQxMQNbhLWBBbiCZqQDOAq+VG+GECY7VY8L4SMOsGIdXkt8+0+4StWXuv9 j9kSK1tDqbDmpb2hG4TlCunddgkh8tEOxh0KOvlV/lbW+n824l557EKjyw0SOGXv7nHf KOcrc+tqZkX8TGEMe3kebR2+uetAGKZBXETT4EEwtTXEHRwvABvvuMBxpbxTepQ5qYgw Fbb8/5GodvbHUMsF7Rf8amF8hgn6t5jzV+ijzILYllQlpx7lvBq7KNOnwEpfExEqKlTr 8gJw== X-Gm-Message-State: AOAM532PI35hGBvnH3kQxjGam2dwIuAV5VgPU60Jwa63/eQA0DnxfETh KgAlLKuE/usP+Xi/jaYkASvHbQ== X-Google-Smtp-Source: ABdhPJx1QVGMDH3bSUlRi8xCAZYjMCX58cJhV8Nzi0bBPvuN8l8LEJFyXhAp8Uy4QXE2zk+rqIBFWQ== X-Received: by 2002:a1c:4e0c:: with SMTP id g12mr2050270wmh.67.1644497270112; Thu, 10 Feb 2022 04:47:50 -0800 (PST) Received: from localhost.localdomain (179.160.117.78.rev.sfr.net. [78.117.160.179]) by smtp.gmail.com with ESMTPSA id 24sm1331687wmf.48.2022.02.10.04.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 04:47:49 -0800 (PST) From: Julien STEPHAN To: ck.hu@mediatek.com 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 v2] drm/mediatek: allow commands to be sent during video mode Date: Thu, 10 Feb 2022 13:46:38 +0100 Message-Id: <20220210124638.2330904-1-jstephan@baylibre.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_044752_711978_35366C3B X-CRM114-Status: GOOD ( 16.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Mipi dsi panel drivers can use mipi_dsi_dcs_{set,get}_display_brightness() to request backlight changes. This can be done during panel initialization (dsi is in command mode) or afterwards (dsi is in Video Mode). 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 Reviewed-by: Chun-Kuang Hu --- Changes in v2: - update commit message to be more descriptive 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; }