Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2877948rwb; Mon, 15 Aug 2022 13:08:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6GVKlVUiEanRVZbGAhAwde7bzB66xn4lTRBoJ+bKQ9AbkHxUBYoifTZpIJlaqsPwuMn76Z X-Received: by 2002:a17:902:ce82:b0:16f:9697:1d94 with SMTP id f2-20020a170902ce8200b0016f96971d94mr19081370plg.12.1660594135967; Mon, 15 Aug 2022 13:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594135; cv=none; d=google.com; s=arc-20160816; b=jjMxd4IXXkM2HdbjoSoCD2+SXYuA32A9Zxy7ub7FGq6Wo6f+rnhxWJWSHE0BwkVqOd 7zICMfmVUqM+2wHU/EIy9Bf8TJ67IFmdN0si2LQx0yr4RcJGIh21Hh9N6302F8oWXJ8j Vlecr/ySudjajlR8YOOASg9cL6gCL67TyBraX560BiX4Dl4ai9WvhGiVnmsG87eWPd/Q acdYImXLkvcCifKtF1zMzRjg+phml7leZsMCDgpUTy8/KRxRIIO7DL4pfB1/xITZsr2d jy1E4XqK7CW4O5DDWjYh51FKc8DhVQuelXW0P6v64dY8fpED7mJ2bMhjRwZBF6mDKENr SNUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SlsTdpp0QtY+UnsESIvoHnH3RWL4e40CIkaYW74s1b4=; b=rM11aDAIRjXugwZC5H+PMf5fAZKYqU25uuO5u4M1E301k+w9DMwNNxan+FwqCHn4NC KhSE6E4CoppLlB/59DBHaXu4iTcWonieS9r9L9bj1WhAKDJp2kSq5xlxp3dlwmegVYCE j5Z2UfQlNACQWJHHqW/3R3Z9GN2mPwjIsCnlbrxLvaUQGQgvT5OEKo7LdlQaNRKP/pwW E71041lzt6DXAbAGPD5+KHapQPr8sDIpWOBqq07L2bbJ4KpD93hlsGiEfQbx4jSf3Iyl qi35xRDQ/Co8LvlBvKcpCqAXBw4geyU7Zu2uJyOsx0Qh3RquJAceY211H8nQPKD/2I2D xAPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yQtDxpla; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y124-20020a62ce82000000b0052c5e4d5b4fsi8746954pfg.246.2022.08.15.13.08.44; Mon, 15 Aug 2022 13:08:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yQtDxpla; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345108AbiHOTsc (ORCPT + 99 others); Mon, 15 Aug 2022 15:48:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345405AbiHOTqq (ORCPT ); Mon, 15 Aug 2022 15:46:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB15C6EF1B; Mon, 15 Aug 2022 11:49:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DA95A60FB8; Mon, 15 Aug 2022 18:49:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C87B8C433D6; Mon, 15 Aug 2022 18:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589352; bh=Uwev548IYElSeCQTYrImO0QWItBgX9fBfs9V/XNmhns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yQtDxplajPUQomnqCtSGYniy3leZv+AocpZdatntfHjuR+IMgDR8DyZfs52tLrX44 t4i6h2PkUFzacdPx2d6KmNA3i0lvJ9WQJQKIe4Ke8INHMBN/0xHJcQ3PSoqEtsmJeV 25Qznnvi+Hk+mPNJmk6+XWi+s6/9efA9PTfmw9M4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julien STEPHAN , Mattijs Korpershoek , AngeloGioacchino Del Regno , Chun-Kuang Hu , Sasha Levin Subject: [PATCH 5.15 690/779] drm/mediatek: Allow commands to be sent during video mode Date: Mon, 15 Aug 2022 20:05:34 +0200 Message-Id: <20220815180406.830645325@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julien STEPHAN [ Upstream commit 81cc7e51c4f1686b71e30046437056ece6b2cb4d ] 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: AngeloGioacchino Del Regno Signed-off-by: Chun-Kuang Hu Signed-off-by: Sasha Levin --- drivers/gpu/drm/mediatek/mtk_dsi.c | 33 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index b0cb0ba53589..ab51656d5dae 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -910,24 +910,33 @@ 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; + u32 dsi_mode; + int ret; - if (readl(dsi->regs + DSI_MODE_CTRL) & MODE) { - DRM_ERROR("dsi engine is not command mode\n"); - return -EINVAL; + dsi_mode = readl(dsi->regs + DSI_MODE_CTRL); + if (dsi_mode & MODE) { + mtk_dsi_stop(dsi); + ret = mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500); + if (ret) + 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; + ret = mtk_dsi_host_send_cmd(dsi, msg, irq_flag); + if (ret) + 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; + ret = -EINVAL; + goto restore_dsi_mode; } for (i = 0; i < 16; i++) @@ -952,7 +961,13 @@ 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))); - return recv_cnt; +restore_dsi_mode: + if (dsi_mode & MODE) { + mtk_dsi_set_mode(dsi); + mtk_dsi_start(dsi); + } + + return ret < 0 ? ret : recv_cnt; } static const struct mipi_dsi_host_ops mtk_dsi_ops = { -- 2.35.1