Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1862438rwb; Fri, 19 Aug 2022 10:37:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR5GzQq7llJwlHz7C2med4xBhfBlV5Ih5MhDOr6WaBPWdAqMJrbCuJ8pkHoMJ/VPWF4e4zbR X-Received: by 2002:a17:903:1c8:b0:171:2ed3:6780 with SMTP id e8-20020a17090301c800b001712ed36780mr8555376plh.30.1660930638724; Fri, 19 Aug 2022 10:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930638; cv=none; d=google.com; s=arc-20160816; b=q2LMJcXmade8pSuBTnec7w1BuIIKIT+kGTCUVzjMwoJRbN4cmh+2LF6kuBXNmIjMxL YkTuubNXR/1g+Q1OVUtJG+h3NFkhT5EFQc6YCiO9eHJRclfB9eqVjEuJL0hOKU9R6alY s5u1l3pz/+jCqBD0JQTPLYRv+qpuOUMZLiqszUYckon8EzYvMkeY7NEB4oxRdKNrVn1F Xn2DPP1SwepCsDb5CnpZ6SXcP9FKa7hJQE5zzD5G1dsniC0OGA+AH3O5pJUry0a/0cFj frAhS7EpeWvjpqIUucAk+kJFlACdobNJ2H5hvGOfB0VCtgRujJgrbDO7QTrGAKdU2S6c XJRQ== 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=1ySqVdjHhIV1GL00GzKiBcbSRhWMqK1/rMcUkPkQFpI=; b=WghzCg2E406JFffR+ZgSCmnvmLzMlyfVIdHZNmuFqtmlCNqDAbgln2irN0Amg0fSu3 7HJT0mf9yIqAmlepvMQ1zVSgYb+Fv6YrRICtgX+z0uP1xz3WH4l5+f4ne+tDXxlugmME s4qDusAnZg8l5ud/qGl30grDGtc+4F4/EKbEQmE3UZOFomqm6n4OwJfbmvaeS013Aqx7 E1eeo3xSMXU0I96hjz9Vuww5Aas3cS6wFYjnuvYL8CFUcMkkUU87u9Xb16eyAsMRPEYz 2ITcq6s8M7oi4/C08YrcKcLxRzz/QGn46N3zPQUe2LnHFdiyTwY9joFy0p7n9PTCanEB aS+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e+7S0pEo; 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 v21-20020a170902ca9500b0016ccf06c2aesi3949716pld.512.2022.08.19.10.37.08; Fri, 19 Aug 2022 10:37:18 -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=e+7S0pEo; 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 S1353831AbiHSQod (ORCPT + 99 others); Fri, 19 Aug 2022 12:44:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353778AbiHSQkw (ORCPT ); Fri, 19 Aug 2022 12:40:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC558124F1C; Fri, 19 Aug 2022 09:09:17 -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 ams.source.kernel.org (Postfix) with ESMTPS id BB00CB8281F; Fri, 19 Aug 2022 16:08:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14A40C433D7; Fri, 19 Aug 2022 16:08:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925316; bh=2/L29mzLUGWxBty/CKSXc4bgzSJhfSHaQ+Q+8OtgU8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e+7S0pEoHbH3hDG5tNr79SOFPqRC1BUi+/4Q6Uk4A3RmmUMgdUF3ityAJIujttrOt 2CLa4ZmY2e9jFcBWW/OU/E/9++DEHhggvlaXEgi5sjElQalypI9TpORF3E4RIb0ciD JlmC6drGyCev3U1dhg3dKdfzPiwNb0mS14L1URYc= 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.10 453/545] drm/mediatek: Allow commands to be sent during video mode Date: Fri, 19 Aug 2022 17:43:43 +0200 Message-Id: <20220819153849.669537539@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 f39785934999..9d54bb6aec30 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