Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5572918pxb; Mon, 14 Feb 2022 02:18:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzC7e46wWxP5kNs3aTCtcm0pobqz4sT2qbU9J/cTL+qCuM/Aeumpm4PU65ExcI4T/ob6UgC X-Received: by 2002:a63:ff43:: with SMTP id s3mr11293154pgk.623.1644833920932; Mon, 14 Feb 2022 02:18:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644833920; cv=none; d=google.com; s=arc-20160816; b=F/7RQm/SJ70Az/AX3PsG1MQCG/NaCdCdGLkg1qtMbb+a0xnhUmZjweOc2qpLj73Ayz ziuXSrXz5mvGay/bcvmLeITahS0piWBpFC/Ntwo1DWr/1+rgkZ8YmM/KYgXzhzHvTtLK gC1sbTF8u191ZTuJM8N/p9FNxj7oena34atLwO8cq3//D0o9YqrS5RoOxhr37ZZBW2zV AfIlXy7NVNBfEEBFNXHxKMuUf6UhMbf2TSF8FTwxtVTL+pU8Bo3xYrB+FClwBNzn/gTb FS2b0wVoYMmwY8MwKVNBFVzsXArBtLFNsozKRTYeERYxnXbXai7nVFBGum5n8If0/6AP OHUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=yez05jnuDoL6maFcCLN5heCRmVNcjew0CewJ1K209nc=; b=IEdHMeGptCEmJhi3XVT3V/HFJesptMYF1Ou4hYw3eqqoNQMs18rn+9Qd12A0RSZ3oY I+RyZcsGy5iOeky8TLiCxTbSs6tVmSbf8Mol3+1FV3cOp3yakPI2zW/nLIVsBJcWkP1e y/ZjHCFnq0Uy2FHLSNU/kFkQsPJgL0SM5WgbX2w6deAVNwDt3FEJpwR3aoXTRJpbigtf FMk3H95UraZS65TR1Z1THU8cQhMKdzaMIFUbuMa+1aaSEPMiJogmFUu1xAe03hvXl1sW lHKhfNrP8gRc+CizTtAPiiXCXET4PPRlLAP4h9AiZ2NrhpaoAoRm/vwc7pijOKD42I5o PL5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=mFIx8aID; 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=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e2si11516939plj.202.2022.02.14.02.18.27; Mon, 14 Feb 2022 02:18:40 -0800 (PST) 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=@collabora.com header.s=mail header.b=mFIx8aID; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242734AbiBNJPh (ORCPT + 99 others); Mon, 14 Feb 2022 04:15:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242730AbiBNJPg (ORCPT ); Mon, 14 Feb 2022 04:15:36 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B29E0606D5 for ; Mon, 14 Feb 2022 01:15:28 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 0CB661F43418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644830124; bh=QcBW7EbcVCJj4WVhYdUseyVwWonS1t6LoaXt/1doffQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=mFIx8aIDOuNZlJ27i12Qg5ovU1JWkvpMC/M1o0pKVoMQa3MY05a1XMv0AELQLDzXj EJb2TFW7JQ3c2vM+Y9RF86O8uK480YDzyuWew8qusIR8HQGN7cz7/A2j4LFmGjvmAb Oznh1THqcNKn/zBtxt55B4KaOKZIRIBOuUJXXNxyno2FiLgxyTTm/ZlnzaxUN7obDY B+PUP737ecZRBbOChMZOQBwm9Xf44Gzm+tR0F4mcE3ipovG/Ddm+elxqx/FryS5tZe LMK6S2pRy1gxTJ2FtNRS1k/02hjU+aP/AVTnrkzi5NSOwht3na3faBC56kiw2dV/z4 iSewDIdC3OvZw== Message-ID: Date: Mon, 14 Feb 2022 10:15:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v3] drm/mediatek: allow commands to be sent during video mode Content-Language: en-US To: Julien STEPHAN Cc: Mattijs Korpershoek , Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , "open list:DRM DRIVERS FOR MEDIATEK" , "moderated list:DRM DRIVERS FOR MEDIATEK" , "moderated list:ARM/Mediatek SoC support" , open list References: <20220214084736.3374211-1-jstephan@baylibre.com> From: AngeloGioacchino Del Regno In-Reply-To: <20220214084736.3374211-1-jstephan@baylibre.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 Il 14/02/22 09:47, Julien STEPHAN ha scritto: > 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 > --- > Changes in v3: > - increase readability of code and use correct return variable (see > comment https://lore.kernel.org/linux-mediatek/4907bdc1-b4a6-e9ad-5cfa-266fc20c0bec@collabora.com/) > > Changes in v2: > - update commit message to be more descriptive > > > 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 5d90d2eb0019..7f1b2b7ed3fd 100644 > --- a/drivers/gpu/drm/mediatek/mtk_dsi.c > +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c > @@ -891,24 +891,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++) > @@ -933,7 +942,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; Nitpick: you've missed a space ... ret : recv_cnt; With that fixed, Reviewed-by: AngeloGioacchino Del Regno > } > > static const struct mipi_dsi_host_ops mtk_dsi_ops = { > -- > 2.35.1 >