From patchwork Mon Sep 18 08:41:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 142722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4600914vqi; Wed, 20 Sep 2023 21:26:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEv9d33ZUfV3oj+dNcfHIYL1k2OL8lzb3ZxcNCFMHupjJMRBAt7BlkThiwrnsRUkraszzGG X-Received: by 2002:a05:6a00:2d16:b0:68c:44ed:fb6 with SMTP id fa22-20020a056a002d1600b0068c44ed0fb6mr6366717pfb.16.1695270369218; Wed, 20 Sep 2023 21:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695270369; cv=none; d=google.com; s=arc-20160816; b=JffFSPZfaeGIN/5/sgkNleszuIw2MvrdR7Fh20Kjnmea7zzv4+Hjr+pWoufMryJX3l PK2vjkoeFrm4LH5BfFZoQr75WVEX+c7bldgC2FrK7pLs8qDtWwtSkULiISD+b3+ULa7A OcpfVpVmJVoglcf7swdYsZPB3iJ4HO1gvdv3gSZO1RL6YBWzFlRWsGOsxed+lVLSLrDb FST+Ann6qQUWrpPubPlltDxPTX2l6FhlCAWDhs1fNHCnyYW3MH3zpVl5NgvJML3VmEh1 uCWd9jJ4SXO9mOiaPFhoj29iQsALORrcClowvAe+Fe4xErwFOHvTdVPKnlJnTU3lUYAT 0LMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=b6V401Lm9p1LvWa9KGI7mbDqGFURLmVgi0aMd5A67Kg=; fh=zj/1xCYHHy/mPJj+kFbga0zHrcDizctVV21xrPlQjYA=; b=AjRSJOndy66TEfQDkNzXRKpBNcqIFYn4I7PiHfSSUSon1N5OPGQuhrfUxWN2d+84S+ jyVkIo5LfBvHKwpm47bi4FNrJkctOlECBSHor0h9N9tS2Lf0u+ZS0QlR4XFQYMFPI2Xc oeVFO9qVQMsPjmBebmdoF5+te6ptNX93JsvUl8hgVEFUZupe51UYmMtNdODPf+zqHLbv kiHtxCTHuyNj/rjHo2sO4wdG0XkjPVm3mPj1yNWw0gCgMRCtpJ5xMot0ecAUwk5sRvlx n+fIIx8UKYds0coOVzsREaNXI8wVq+oXoY9wDqcRDtBh3JzSyuoxKgzbfHzNoWMAWAed mw/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=qSKzHUnx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b00563deb65f93si541713pgb.200.2023.09.20.21.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 21:26:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=qSKzHUnx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 43FB980AC457; Mon, 18 Sep 2023 01:43:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240833AbjIRInF (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240724AbjIRImb (ORCPT ); Mon, 18 Sep 2023 04:42:31 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1DE2AA for ; Mon, 18 Sep 2023 01:42:18 -0700 (PDT) X-UUID: 42af657c55ff11ee8051498923ad61e6-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=b6V401Lm9p1LvWa9KGI7mbDqGFURLmVgi0aMd5A67Kg=; b=qSKzHUnxnMjxwVNtfC8m33IEE6OcbBpg+UvBn8zy9Z9hCmaDy1uDI99wDiD/ErPejrHuTjJGhEOm8Qt5ppM7p5e0eZc/+WZnz9oG5cTW6ckwqrzIV2Kvf60s9reEktdqY0BZWzBCgTw17Aas5L1yJ9rxjFl2rqLHXPzipzxVH3U=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:df5be2ac-7655-47bb-a07f-7d8b6fa57591,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:0ad78a4,CLOUDID:97efd2ef-9a6e-4c39-b73e-f2bc08ca3dc5,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 42af657c55ff11ee8051498923ad61e6-20230918 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1063294411; Mon, 18 Sep 2023 16:42:11 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:10 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:10 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , Philipp Zabel , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 01/11] soc: mediatek: Add register definitions for GCE Date: Mon, 18 Sep 2023 16:41:57 +0800 Message-ID: <20230918084207.23604-2-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777398075279659697 X-GMAIL-MSGID: 1777619822609364086 Add register definitions for GCE so users can use them as a buffer to store data. Signed-off-by: Hsiao Chien Sung --- include/linux/soc/mediatek/mtk-cmdq.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h index 649955d2cf5c..a253c001c861 100644 --- a/include/linux/soc/mediatek/mtk-cmdq.h +++ b/include/linux/soc/mediatek/mtk-cmdq.h @@ -14,6 +14,16 @@ #define CMDQ_ADDR_HIGH(addr) ((u32)(((addr) >> 16) & GENMASK(31, 0))) #define CMDQ_ADDR_LOW(addr) ((u16)(addr) | BIT(1)) +/* + * Every cmdq thread has its own SPRs (Specific Purpose Registers), + * so there are 4 * 24 (threads) = 96 SPRs in GCE that shares the + * same indexes below + */ +#define CMDQ_THR_SPR_IDX0 (0) +#define CMDQ_THR_SPR_IDX1 (1) +#define CMDQ_THR_SPR_IDX2 (2) +#define CMDQ_THR_SPR_IDX3 (3) + struct cmdq_pkt; struct cmdq_client_reg { From patchwork Mon Sep 18 08:41:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 141309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2513193vqi; Mon, 18 Sep 2023 01:49:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyYnXadnWzXPUZO0zI7W8+e8tvGqZWlOWGfvOzjySEqI/GiaRoBSaB5wHH0QBwBFlAiDLj X-Received: by 2002:a17:90b:3015:b0:274:116b:8f84 with SMTP id hg21-20020a17090b301500b00274116b8f84mr7427692pjb.34.1695026959048; Mon, 18 Sep 2023 01:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695026959; cv=none; d=google.com; s=arc-20160816; b=yH5TIYAJobHvWYp3ofwmY9ZQf2P+pPS/N8DEcprw07mZAG7IkvDIR7VSR9dgjsSSwt TGaHlDZ/enOYLZ91dVr07jUMbFQHDdJZoPSHQR1CLx7ptxTxWeVAp7nOFolIDQnQ5JnK VyY/yq0wmuzDZbbZlqN02F/WEMWq6uFqax1jfpQG1G1RJPIKAcSxOgUl3+xRjgfXXIww T8F77+KOkit3HVFj15k4Q5c4FJ3f9xZJsjlCa592AxIuxDloi5BLfQrG6PeRFaaIoDKp j0GIkpdHOJrHbfjTGNC4PgonUFjNG05DRGjjqFLVfY53UFPBtTW1UNKqe4Gy5Hx4cmLC 2o4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hMROI+KyTxkRwOY6Y2Mkyb4j/NIBOwy1O3mAhVSp7Zc=; fh=KJWo/jBTlm0DyYU3URocXiKjA7/okmVQZjxpzD6zcfQ=; b=bujxhCVT8OxCEzbCbpgBHOtGIb5HtZBPSrI4DzHLFt6bQRHaMN2qmaJH0CGcteRfpg nIp3Ls65vrmdOp6MuNRuBSt3iiIWSN3sAe6/TxjntIeRv57UNhpAWFvv57XyeIhiNO6+ +YEhkeDHIc+mKXyso7hEZb+D9jcF3uRq022Y3uhyzfRY10t1FcKgfonMdaeVhPWV+WTw nGurhnDGg/H/N4oXGQckZHWI5K9rEdtarzkoOdTsr+MspHnKWhZehql/8rdV6GspN5Yy ySD1ilTnu+KU4vLNT6lANTSLnOgXe4CL89SOdwm60rUC5i+wuT602z5v6gtA3NKZY9Cq C06g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=FwyynsLV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d19-20020a17090ae29300b0025979e8c246si7611683pjz.70.2023.09.18.01.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 01:49:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=FwyynsLV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id F2D7B80FCCB5; Mon, 18 Sep 2023 01:43:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240857AbjIRInI (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240670AbjIRIma (ORCPT ); Mon, 18 Sep 2023 04:42:30 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E5AF99 for ; Mon, 18 Sep 2023 01:42:18 -0700 (PDT) X-UUID: 432df7f255ff11eea33bb35ae8d461a2-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=hMROI+KyTxkRwOY6Y2Mkyb4j/NIBOwy1O3mAhVSp7Zc=; b=FwyynsLVp4BC86n4vzIrnTq2E8QhjLo8X4+w/4n0teEKg+0IPrGza5AqQa3e9zmien6nn4qoM1JmiXVnWrdPBvbssAsqaXaSw6fr08x7WYHdx5H3VfBbK7JGISZRT12wDnO3JwyluHYK1lrkaxB3e1XU75yTL/oFUZn2iUmX/qU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:7ce2deef-ef74-4a7d-bd76-7f9ec9da3e27,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:0ad78a4,CLOUDID:9aefd2ef-9a6e-4c39-b73e-f2bc08ca3dc5,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 432df7f255ff11eea33bb35ae8d461a2-20230918 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 822502823; Mon, 18 Sep 2023 16:42:12 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:10 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:10 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , "Philipp Zabel" , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 02/11] soc: mediatek: Support GCE jump to absolute Date: Mon, 18 Sep 2023 16:41:58 +0800 Message-ID: <20230918084207.23604-3-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--1.545900-8.000000 X-TMASE-MatchedRID: wDTc/wNgEcMLazoQyrpm0huZoNKc6pl+X4GSJGyYc35GL0g1nVmkYXB4 4IkzjfYywLMNNIlHL0L9Id3tL+hFwoS2KcusOPFAoMfp2vHck9XzWEMQjooUzaVznMmzBIHPsKF vJaID/xQ8ivFkadaiTfvQCPiy8IEcHxPMjOKY7A8LbigRnpKlKZx+7GyJjhAUMTh4vIBXfjEjwV wu7UGckDtnB9jUmlXAF8gvGd3ATIXcs08IJF1Ww1GPJeBexK4PXDRlFVZzjO/EDk7r56pdm/luA qyqxuxoSZrfNhP3sgUBh9AgBSEFrJm+YJspVvj2xkvrHlT8euI+kK598Yf3Mg== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.545900-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 0FA05998AD91C59151682AED4596AD464A18BD4B332223096FD5D3E87DD8428E2000:8 X-MTK: N X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777364588411924401 X-GMAIL-MSGID: 1777364588411924401 Add a new API to jump to the head of cmdq packet by appending a jump command at the end of it. Signed-off-by: Hsiao Chien Sung --- drivers/soc/mediatek/mtk-cmdq-helper.c | 16 ++++++++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c index b0cd071c4719..e029ce231df1 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -441,4 +441,20 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt) } EXPORT_SYMBOL(cmdq_pkt_flush_async); +int cmdq_pkt_jump_absolute(struct cmdq_pkt *pkt) +{ + struct cmdq_instruction inst = { 0 }; + u8 shift_pa; + + shift_pa = cmdq_get_shift_pa(((struct cmdq_client *)pkt->cl)->chan); + + /* jump to head of the packet */ + inst.op = CMDQ_CODE_JUMP; + inst.offset = CMDQ_JUMP_RELATIVE; + inst.value = pkt->pa_base >> shift_pa; + + return cmdq_pkt_append_command(pkt, inst); +} +EXPORT_SYMBOL(cmdq_pkt_jump_absolute); + MODULE_LICENSE("GPL v2"); diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h index a253c001c861..106988cc5f01 100644 --- a/include/linux/soc/mediatek/mtk-cmdq.h +++ b/include/linux/soc/mediatek/mtk-cmdq.h @@ -276,6 +276,8 @@ int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr); */ int cmdq_pkt_finalize(struct cmdq_pkt *pkt); +int cmdq_pkt_jump_absolute(struct cmdq_pkt *pkt); + /** * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ * packet and call back at the end of done packet From patchwork Mon Sep 18 08:41:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 141326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2533925vqi; Mon, 18 Sep 2023 02:42:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfQeWhmU+PzxsPI87YTooaLk2GI+/P5fDS4cIzRhCWXWf/i50dR0PcQQtgOIZF+ftcjvum X-Received: by 2002:a17:90a:d252:b0:26d:1f3d:6e85 with SMTP id o18-20020a17090ad25200b0026d1f3d6e85mr5829848pjw.37.1695030137337; Mon, 18 Sep 2023 02:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695030137; cv=none; d=google.com; s=arc-20160816; b=jyCjnnosvqIZo3XQEFnV4owHy+oWfcaUWIziW+AZFh7s8CKG0pPr5MJ5UkPPYTN1+2 IZ90wfo3C3tR7xPu95MLhBg9JBvk3BunZy2WiXDTItrCz+BR1oGlspQzg2oSK7/ZoVXj KR+bakTnXkgz9R8XUV/z3iNoo4/KrX0NVSZH7vQNEh+yv6u7DbDMGpo1VBSTj4syOCLP Fd6L0h3IswEjXcLmHG4esCZgWYFs2MqY7mWwHv27oRWuIRF3N0LnqDKyh9brGJvTGq/I q2iXv2EBj+N5gvreYtRZbb2Y9JhNbpL4p1QKsr5YGHfeSHqZYZYAxo5hv+uNpsb6cwkW DLsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JzNyns0UVad0oAtB463nUueppzHDt6e6thwwaV9IvXI=; fh=KJWo/jBTlm0DyYU3URocXiKjA7/okmVQZjxpzD6zcfQ=; b=HBUgCrfoQ8iaJzuvYYd3ECdBWD5FHBG0bnkDhWvmGDa+fftLGTB7JiFiX82N7/1M7z hSTNVJiysLNh+YotXXPLq07nJ4/r3E6J09roaJTaOJ7S2HPQLMYq/ZWY48l3SgK943EK Ht3Gv0wlbBCaCLRCZzkrGPEToKz8AZPECZmQUfBs4hp8hMebcxIzcj075ZDoVKzEX6VJ H5tcoD0t1Wi4ZWALVjVXeRqNQ3Yev1kjNFbETBjDnZO4eES3qZTzUPO8UABymA1hVLgu tI0EeZnuzPC/8CeorKdJ6BoDzay5L0LmP3TGf7+Nlou5O9qG9KKYyqJkefzwrVwOmO9s VjhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=N2bUpN9M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id z11-20020a170903018b00b001bc17ab8d6esi8072727plg.530.2023.09.18.02.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 02:42:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=N2bUpN9M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5683A8108353; Mon, 18 Sep 2023 01:43:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240877AbjIRInK (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240689AbjIRIma (ORCPT ); Mon, 18 Sep 2023 04:42:30 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68E2A91 for ; Mon, 18 Sep 2023 01:42:17 -0700 (PDT) X-UUID: 432802de55ff11eea33bb35ae8d461a2-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=JzNyns0UVad0oAtB463nUueppzHDt6e6thwwaV9IvXI=; b=N2bUpN9MVPWmPzwMRpkV0yH+fM16VvcupbNrpBBQeVLgop4Wg2J74XMNy1P9rFI88iPvUoHyeS0EP+rt8VDSVu2NcUdGbmJqxRTQp+m0RNaaoF4aMMDBsyArcowITTlO73WSL6gtbi47ZM2h4j/yMFcIYrRsur4xJacDtqGs9Dk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:9101aba3-de35-4db7-9b04-6478337d104b,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:0ad78a4,CLOUDID:2e93f6be-14cc-44ca-b657-2d2783296e72,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 432802de55ff11eea33bb35ae8d461a2-20230918 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 442846352; Mon, 18 Sep 2023 16:42:12 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:11 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , "Philipp Zabel" , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 03/11] soc: mediatek: Disable 9-bit alpha in ETHDR Date: Mon, 18 Sep 2023 16:41:59 +0800 Message-ID: <20230918084207.23604-4-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--5.052100-8.000000 X-TMASE-MatchedRID: alJg/GEaUw2+Yp4vsvc0tLMsPmSZxbpksvllF/5zpT2LEf4RB+xkYVaP 6AhhdqyDrUhQzMxACbpkTkpOguG6lcYsXQyX9kH4e5NWR5iixe0ol9KlwBS/XZsoi2XrUn/Js98 n9dYnJNNQSFbL1bvQASAHAopEd76vYRbNu1tC79JEtnyHlOOG0IX+n0vRN9Ql2LhP3SSUgZTaKw jkgd6X8w== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--5.052100-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 8FA9CB363904B36906B867D4D261DE7DA6C7027E87BBDE1085A96C5D835E8B5F2000:8 X-MTK: N X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777367921265902390 X-GMAIL-MSGID: 1777367921265902390 ETHDR 9-bit alpha should be disabled by default, otherwise alpha blending will not work. Signed-off-by: Hsiao Chien Sung Reviewed-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-mmsys.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c index ffb75711a1da..8b6c39b5d1b4 100644 --- a/drivers/soc/mediatek/mtk-mmsys.c +++ b/drivers/soc/mediatek/mtk-mmsys.c @@ -209,6 +209,7 @@ void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool alpha_sel, u16 mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_ALPHA + (idx - 1) * 4, ~0, alpha << 16 | alpha, cmdq_pkt); + mtk_mmsys_update_bits(mmsys, MT8195_VDO1_HDR_TOP_CFG, BIT(15 + idx), 0, cmdq_pkt); mtk_mmsys_update_bits(mmsys, MT8195_VDO1_HDR_TOP_CFG, BIT(19 + idx), alpha_sel << (19 + idx), cmdq_pkt); mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_PAD + (idx - 1) * 4, From patchwork Mon Sep 18 08:42:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 141362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2578956vqi; Mon, 18 Sep 2023 04:24:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWP3kORQ/sy/YQE99Zd8zMiNHelzq7A5LL1b6xXOoqP0RsQIz5F8YB8CEw0e8KqLHeeWpw X-Received: by 2002:a17:902:d2cd:b0:1b2:676d:1143 with SMTP id n13-20020a170902d2cd00b001b2676d1143mr11843781plc.15.1695036253106; Mon, 18 Sep 2023 04:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695036253; cv=none; d=google.com; s=arc-20160816; b=ftq1prP8rFGjggOXGr7lxLJUxK9yonJ1fIt1aWc0bvEgmN+fMR/gIoGpU/gDJAJFYq TOr96RwP1BRD1EGdfC5G4rw4a3L+xyrnNmEwisPGl0KbrVueOm+IO2Q8/puOw+1DSOd3 sEup9imdtjKupRyq356MlQkgJkFbGODrTjKvGPhXWKPwoMAZngl0Gop0gOyaTH4r7ERn r9wzNTpDWYblPAOM/pA4YxDBg2NNCPiLU69f+KSHZYgg8KXUsy9m8FBxOqSPhi/PiDaD 8050xfsFqJ8h6aI+/riJEoIv1spnTtIHKryiSyTYq+wXsmXSZ0g+4I8A0funvO22mkXf Ou1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hiYgAJXuS1H/ON0IHRoYcIaq91Vuto1QXFXSITw8YEA=; fh=zj/1xCYHHy/mPJj+kFbga0zHrcDizctVV21xrPlQjYA=; b=cOUglF+VfTTQS1cSAYpxb3xfxF0+X2zcQCzola6zIF+P5dcnrX+nwRgGdtRXKvfinq JnFp1Z34Z7TSGcByewfE7tftMi/7h0V1CG6Trh8M3tHpeOF3x0NvPtB6kal5VJW3A1Qi Va3mHed2zuJme+OeCmLOcWrL/KWRYVSt8k38fzZ3NcVIaLWG2GtQJbDtpTdeyOasHGDK hRRCiM6CVZojfEtjbWYRr+7W1jT98Cx4UWgNdQFIuFuqt4bzpG73eD0Gu7APORf3wadN iaiex9kev75kroeCaZOGm6D+z59pfA4tPWn9ciDS+gKsDrqDBebUlZa+UrfdgZBXyujq ohUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=f+BkPPnv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id lg16-20020a170902fb9000b001c3d864d6b5si7748239plb.292.2023.09.18.04.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 04:24:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=f+BkPPnv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 84B8983F5302; Mon, 18 Sep 2023 01:43:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241054AbjIRInU (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240756AbjIRImb (ORCPT ); Mon, 18 Sep 2023 04:42:31 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F2EECD for ; Mon, 18 Sep 2023 01:42:20 -0700 (PDT) X-UUID: 42f79d7e55ff11eea33bb35ae8d461a2-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=hiYgAJXuS1H/ON0IHRoYcIaq91Vuto1QXFXSITw8YEA=; b=f+BkPPnvZczEAd2Ve7m59yp8t1UBL6NbfxJlXEht5YXqJECSftSHRFiH3G04pZMUyzINr5e3dGJMaT/Xdh8/55TBY1d8XnbmqFBe8zS78PeMAZqL3a2RxPIyMAFBtFxWewsLE8RfG9O0XMbbIswSnTKRboCxat6g0AmZKd990Bs=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:bdf8a3c2-3252-4acb-bd05-ed888eb38602,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:0ad78a4,CLOUDID:c95327c3-1e57-4345-9d31-31ad9818b39f,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 42f79d7e55ff11eea33bb35ae8d461a2-20230918 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 497019405; Mon, 18 Sep 2023 16:42:12 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:11 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , Philipp Zabel , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 04/11] drm/mediatek: Add OVL compatible name for MT8195 Date: Mon, 18 Sep 2023 16:42:00 +0800 Message-ID: <20230918084207.23604-5-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777374334195703923 X-GMAIL-MSGID: 1777374334195703923 Add OVL compatible name for MT8195. Signed-off-by: Hsiao Chien Sung Reviewed-by: CK Hu --- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 93552d76b6e7..7759a06e5c0e 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -715,6 +715,8 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = { .data = (void *)MTK_DISP_OVL }, { .compatible = "mediatek,mt8192-disp-ovl", .data = (void *)MTK_DISP_OVL }, + { .compatible = "mediatek,mt8195-disp-ovl", + .data = (void *)MTK_DISP_OVL }, { .compatible = "mediatek,mt8183-disp-ovl-2l", .data = (void *)MTK_DISP_OVL_2L }, { .compatible = "mediatek,mt8192-disp-ovl-2l", From patchwork Mon Sep 18 08:42:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 141315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2519917vqi; Mon, 18 Sep 2023 02:06:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEv/+uWKWDzgKSwpcjrOasj9ENzee8mSWPiN+aBx11lsCLBwkjKPDFgEpB/jg5aFPxMVCmS X-Received: by 2002:a05:6a00:1acd:b0:68b:e29c:b61 with SMTP id f13-20020a056a001acd00b0068be29c0b61mr8282714pfv.19.1695027990238; Mon, 18 Sep 2023 02:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695027990; cv=none; d=google.com; s=arc-20160816; b=nx/WhnRHZ0/jHIdHlJwfX6GtIWRPM8o4LNuXZlGiE2hvvfiFRM1vsnTgk5+vPu40cQ +IhmZ+6duuW4vc5XwKCJijr+1FV7Z7WFlxZJdXWX63UWBAHSUyBKIDydr/Y6EuFrlrTF gaboURYgfoeg8t4hAv0EeYVaw95zbqHk033BjpN/XvtHxBdQce8VImxeBiOmiZ/g9DvK ES6rS67unL+hs9k7B5QbmXuoKd517jt7qV6LiKzSGGJqfpJ0aDJW3d0o5MNwyEL0XhUv UTlYdr2VdWgTZHzOhXPm1lwI5T6OBua7nTCS378OsouKcp/41XtNRZc/4IHDd89BuRia c56A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=72eVayWVp8rYcnVKWBje8fRu/Ay09M8ccvdljh1dMk4=; fh=zj/1xCYHHy/mPJj+kFbga0zHrcDizctVV21xrPlQjYA=; b=KOVmRh0OQcVFE6KReHGTLoQFK0rjyteeMzlnpaPvThi/pFQ+QGvFUqkhClG6I4ZCfb x5UDA8m23fZABZH2RHZAp6wStkjCwegyxErv7ukrSy2TcmbmGmdl1Og5zObwmW3Dq2f7 rXa983pSZZ/IZufgjwLnP1Pf7tYb5eVBUBHpPyaxWK4VpVBbRzQdTQVIurDQ9LGP4QLl 0tcCERFO35VBsh2d5aRGWOXiIheE8je6Ptpely9sxmZ1p278v9ulkxmQgnM3AQlfXKpJ UzYQGs0GbIyUHWCe+nJDQ3waiJ3j/4WUH8DooaoxInP74jb6nWmjNcCAlk7OfQ7IVgU5 QxyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=PqMdtJYm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id a14-20020a63e84e000000b00577461b010fsi7865592pgk.685.2023.09.18.02.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 02:06:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=PqMdtJYm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 56C288108355; Mon, 18 Sep 2023 01:43:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240812AbjIRInA (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240716AbjIRImb (ORCPT ); Mon, 18 Sep 2023 04:42:31 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 687349D for ; Mon, 18 Sep 2023 01:42:18 -0700 (PDT) X-UUID: 42b1b1b055ff11ee8051498923ad61e6-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=72eVayWVp8rYcnVKWBje8fRu/Ay09M8ccvdljh1dMk4=; b=PqMdtJYmOh+fNAqeSrd+qfoLPzpkAGLCG7KwFBPibIdOrkUQ5zFzhwRfmkVnS88PCH6di6ZbIS/cbyKt2IQrsvQqAfhFP88KPg29yLRTVyBDiPHCeVUP4YhL6e70SfIsw8gMooQ7A4gnnKIwfJr2dvSCoh6esufmXJk0zXo0jwI=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:d9f6cd49-985a-4f04-b2e3-f942c3bafced,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:0ad78a4,CLOUDID:99efd2ef-9a6e-4c39-b73e-f2bc08ca3dc5,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 42b1b1b055ff11ee8051498923ad61e6-20230918 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 115661417; Mon, 18 Sep 2023 16:42:11 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:11 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , Philipp Zabel , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 05/11] drm/mediatek: Adjust DRM mode configs for IGT Date: Mon, 18 Sep 2023 16:42:01 +0800 Message-ID: <20230918084207.23604-6-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777365670163494613 X-GMAIL-MSGID: 1777365670163494613 IGT (Intel GPU Tool) could commit the following planes during the test: kms_plane: The sub-tests pixel-format-* will create planes with size of 1 or 4512 pixels, these size will be rejected by the original mode configs. Adjust minimum and maximum value of both plane width and height. kms_cursor_crc: If cursor_width and cursor_height is not defined, IGT uses min_width and min_height as the limitation when creating cursor plane so sub-tests like cursor-rapid-movement will be skipped. Set cursor_width and cursor_height to 512 pixel can solve the problem. Signed-off-by: Hsiao Chien Sung --- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 7759a06e5c0e..62581b2a470b 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -429,16 +429,18 @@ static int mtk_drm_kms_init(struct drm_device *drm) if (ret) goto put_mutex_dev; - drm->mode_config.min_width = 64; - drm->mode_config.min_height = 64; + drm->mode_config.min_width = 1; + drm->mode_config.min_height = 1; /* * set max width and height as default value(4096x4096). * this value would be used to check framebuffer size limitation * at drm_mode_addfb(). */ - drm->mode_config.max_width = 4096; - drm->mode_config.max_height = 4096; + drm->mode_config.max_width = 8191; + drm->mode_config.max_height = 8191; + drm->mode_config.cursor_width = 512; + drm->mode_config.cursor_height = 512; drm->mode_config.funcs = &mtk_drm_mode_config_funcs; drm->mode_config.helper_private = &mtk_drm_mode_config_helpers; From patchwork Mon Sep 18 08:42:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 141471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2788244vqi; Mon, 18 Sep 2023 09:29:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQqPe5CHmG75o97qLnFDZdMGN4O5kqJseNv9NIu6sSd1iJZXvyIw1u8La9aH5RG3geKn8Z X-Received: by 2002:a17:903:1249:b0:1c0:e472:5412 with SMTP id u9-20020a170903124900b001c0e4725412mr9137922plh.18.1695054583718; Mon, 18 Sep 2023 09:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695054583; cv=none; d=google.com; s=arc-20160816; b=QRdmzI7npcNzbTK9cc54pAHTdnprN/UetT75wffGTFAHAueMzSKuDHd7EWmgip8PjE bKNXok+Kw1ArUnSB3pjRbmNY97CjXxsQaUEejr7X8TPZNB/7FIN56v5Dn6HcZMl2YDb6 gnTJbaBpnZCEQ4khkhHphBBVnSSdej/B4BUNqMXAUrKfhvfagmnaCbMOX1xUBmDmXEnC jxbseOUqPRNYKbZxzG9XQndAKqkXEDi60xXx31BZD1mgVQ1tBIFC+1VfbBe+PcLbyiSM wER7VHuCUN92qjcFUZGVYeumjyWrnzgADU76JtmamYIi+yb179Z3cl6o26gxgJLtmR0k Vo8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2FmL+tmhWGFQcrwwwy2xFlnk4sPriKRNmcjNvLKxuIk=; fh=KJWo/jBTlm0DyYU3URocXiKjA7/okmVQZjxpzD6zcfQ=; b=rJ7UhyhXjRrl5MSlzrTZNH6Syc6f3nkTEdEX5EAFF4l/OgAHkPFewkUQcmTkxtHSCW SRcNtfYHGz+ywworD9V40zbXEDFpi5920sJvqOoQ7E3y174Iq51vCwm+oCBQqGgBtEBP HsCCSOaWAb2NdbRTvHOBrPhvvuuOAX0beyXpUUwe1ssMWxtEKiqZI9L48P7t9WVs/Zb4 IZDu51HlCy9PW6AiA9SuTTw4Wu4G+Qb7D+QVDNcBXZz80/qU/5qeP4w47fsbQYwjXWym RknVtweNS23KEaRdZzCKNG6K/Gh2+U4Nk9DgVcXOxBVSIEf3U4v1MAz9Z6jqNyvsWUFr 1hDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=XtYHvi6L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b11-20020a170902d50b00b001c4743e4a60si3170801plg.197.2023.09.18.09.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:29:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=XtYHvi6L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F1A7B804747D; Mon, 18 Sep 2023 01:43:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241035AbjIRInR (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240755AbjIRImb (ORCPT ); Mon, 18 Sep 2023 04:42:31 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40BD8D1 for ; Mon, 18 Sep 2023 01:42:21 -0700 (PDT) X-UUID: 432f38f655ff11eea33bb35ae8d461a2-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=2FmL+tmhWGFQcrwwwy2xFlnk4sPriKRNmcjNvLKxuIk=; b=XtYHvi6LM/Qr2+ikCHEEYsK6og1hX+Hqv4AFlPQaYAoR1s/jWiWUSAYwR1HCMSxSPs4CBm5LREBexF8lkT/TvQnJX+QgYTVZUvQ+qxKsW3pekKrOwnreTOILIGzl/y/DiAn5FBPZhSN5Zoiicr1P+JV0g+kAfn0EexjYiHeAwfQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:8c65be78-9937-49aa-be6a-10a41575df23,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:0ad78a4,CLOUDID:c9c91014-4929-4845-9571-38c601e9c3c9,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 432f38f655ff11eea33bb35ae8d461a2-20230918 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1268704023; Mon, 18 Sep 2023 16:42:12 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:11 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , "Philipp Zabel" , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 06/11] drm/mediatek: Support alpha blending in display driver Date: Mon, 18 Sep 2023 16:42:02 +0800 Message-ID: <20230918084207.23604-7-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--9.435800-8.000000 X-TMASE-MatchedRID: 61l6kdP/ldn2fv0LTPfvM6MVgdN9w+TCWjWsWQUWzVr/evmlVf9xZkN+ V6ZFLcNd6rlI+AD5R5wSqo3ZUfrHh25/NyTKlG69DB+ErBr0bAOuiRuR9mCautchlMhSt6FeQHf bKe/4YJLlpBcKhHrskTLaKLaWub4PHxPMjOKY7A8LbigRnpKlKSPzRlrdFGDwU+2vIzDCyqmf+Q y/rKrINsCo2Oi+tjk+FpltkTCMnT3Dhj6t95pUrg== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--9.435800-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 428F88119AF2C6E762C3F1B230F9FA71349FB6689841C1FBE17B295B794B9CE12000:8 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777383615473549273 X-GMAIL-MSGID: 1777393555141069066 Support alpha blending by adding correct blend mode and alpha property in plane initialization. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Hsiao Chien Sung --- drivers/gpu/drm/mediatek/mtk_drm_plane.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c index db2f70ae060d..f87cf56fb846 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c @@ -301,6 +301,9 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, size_t num_formats) { int err; + u32 blend_mode = BIT(DRM_MODE_BLEND_PIXEL_NONE) | + BIT(DRM_MODE_BLEND_PREMULTI) | + BIT(DRM_MODE_BLEND_COVERAGE); if (!formats || !num_formats) { DRM_ERROR("no formats for plane\n"); @@ -323,6 +326,14 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, DRM_INFO("Create rotation property failed\n"); } + err = drm_plane_create_alpha_property(plane); + if (err) + DRM_ERROR("failed to create property: alpha\n"); + + err = drm_plane_create_blend_mode_property(plane, blend_mode); + if (err) + DRM_ERROR("failed to create property: blend_mode\n"); + drm_plane_helper_add(plane, &mtk_plane_helper_funcs); return 0; From patchwork Mon Sep 18 08:42:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 141363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2583958vqi; Mon, 18 Sep 2023 04:33:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnba49tupCHEpHija4EWcyb3ZN3fWYMvzRawEq+lhA5ZxPRnHc/h++CQlFdlvfp5fCE36U X-Received: by 2002:a05:6e02:1027:b0:34c:f2cb:b2c with SMTP id o7-20020a056e02102700b0034cf2cb0b2cmr11062554ilj.19.1695036831884; Mon, 18 Sep 2023 04:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695036831; cv=none; d=google.com; s=arc-20160816; b=tfFRXo3pUG4pzVH2bY1Izk9iXHOwDgFO9aUVLt6wtc5ieUQkE/D3PfWYCKzYRg0H7I kYyZdZ7K5DyKdzDUwfid7UGVFXdZPjDuVRWeXhKTtKWk3fCeuXydFDz3Gm6IvrJmJNx6 /Uv5dKSL54MAkRpGZgl2yYo4klUsMY2IsQJ66vF4lk+03Du7f20VePZznUX6Z6qgjc8C FYBdtU8fDNk22JD5naH2/uf2lgnQvkcukOFQXpvuwSB3Z5m3+edpBQQkFFhIgTCIlowL xmlemkCwLuW3c20jBBUEMWRT50tZNYzPciOYlMq6Z8GvG5rldAbtpR3w5RhEVrf+mqhq p9iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jEarBmJax9GgjlJYeMZIJu2uxv9egCgOzSwzTZYwoY4=; fh=KJWo/jBTlm0DyYU3URocXiKjA7/okmVQZjxpzD6zcfQ=; b=stoq1U3oCkZEf31fwvSVithO/8XR6t6M/r6rK/pdnGFhh9uIPmMXAB24B2rCpTrbfa WPivN84HmBlj8J6NEJYxc0Bd9zYHo7p9k9HFYn25k8s2Qwr+vkNVnU80YO60aAlOyZeT xqK5GMVr4HpmosBl4ueNohFIpCWLCFdF08kWWSthcfmFzjoAY4Ixg2Roqd9vPcO3Gt+n qVaXzid4Z+vqWCe0YN0820QwDiRp1YTWpi4ITIOA3512U6Yjs4i8hDUyWRxrAxF21TxP 9oNIFS4wCnmScxVjZCP+CkOr4nV3dKpiVYHygbttfb7qglrP5ulU+klW+zH9P1O943wt l5nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=j1GYkzTD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id o6-20020a6548c6000000b005780a1effa4si6596612pgs.375.2023.09.18.04.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 04:33:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=j1GYkzTD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 88CF183F427B; Mon, 18 Sep 2023 01:43:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240928AbjIRInO (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240814AbjIRImc (ORCPT ); Mon, 18 Sep 2023 04:42:32 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E75CD9 for ; Mon, 18 Sep 2023 01:42:22 -0700 (PDT) X-UUID: 43297f1055ff11eea33bb35ae8d461a2-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=jEarBmJax9GgjlJYeMZIJu2uxv9egCgOzSwzTZYwoY4=; b=j1GYkzTDQsi2BALG5hL0svk2pB8tQ+n8zyzy0N1AO2/Z+KJLibeBUfOoFVtT8ceyJoX+Zey2BJ8oCOgLAQwASkjBrm3ypJd3CRQ0zUAAjkKsmhadG5AlvGBivxdbOhddf7oPD5wnjdvC6qGsytB8s2e4qMQFDKKfTsv42X8QXMc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:444d45e3-f5d9-4be3-9992-6b80f60bec9f,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:0ad78a4,CLOUDID:cc5327c3-1e57-4345-9d31-31ad9818b39f,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 43297f1055ff11eea33bb35ae8d461a2-20230918 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2087041403; Mon, 18 Sep 2023 16:42:12 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:11 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , "Philipp Zabel" , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 07/11] drm/mediatek: Support alpha blending in VDOSYS0 Date: Mon, 18 Sep 2023 16:42:03 +0800 Message-ID: <20230918084207.23604-8-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--11.236600-8.000000 X-TMASE-MatchedRID: GlUfE5FNQQz2fv0LTPfvM5JAa1C/+FcuEbxKVXd70tWU8ftiyKjZrRsY DextMHGuGJd2qe6nWQsaTIVsbS1pG+F/B1jEjV+6y7TSWcbz49b/lBG+uXYJkNchlMhSt6FexEs GD8geUL38aLTyW2a3YkhxRggzEU3FMH15eekLeUiHZXNSWjgdU4ED+PNzPecBRQ0dAChl/lz8/L 2o6LnOlxWt9a3ryuo3lHJpPX3ZHleyRDt3x3st943NgkEqAN0RpwnFZnn+VHwHBp+1KU23QYFaK sEtPT2WFm9c8s2OWMvrSFeO0C8F5I9oUcx9VMLgFEUknJ/kEl7dB/CxWTRRu25FeHtsUoHuPmT0 js3FXVC5lpKwiuLw5JGumwfIFp5jAUfAWyyQaUW+68HqACCvKA== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--11.236600-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 1E132E282DFC25ECB4481593C22B7D42C381A2DE4C4CA4532EE3B8CB85B606702000:8 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777374941145101846 X-GMAIL-MSGID: 1777374941145101846 Support premultiply and coverage alpha blending modes. Signed-off-by: Hsiao Chien Sung --- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 202 +++++++++++++++++++++--- 1 file changed, 178 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c index 2bffe4245466..8c58b204992e 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c @@ -30,6 +30,7 @@ #define OVL_LAYER_SMI_ID_EN BIT(0) #define OVL_BGCLR_SEL_IN BIT(2) #define OVL_LAYER_AFBC_EN(n) BIT(4+n) +#define OVL_OUTPUT_CLAMP BIT(26) #define DISP_REG_OVL_ROI_BGCLR 0x0028 #define DISP_REG_OVL_SRC_CON 0x002c #define DISP_REG_OVL_CON(n) (0x0030 + 0x20 * (n)) @@ -38,10 +39,28 @@ #define DISP_REG_OVL_PITCH_MSB(n) (0x0040 + 0x20 * (n)) #define OVL_PITCH_MSB_2ND_SUBBUF BIT(16) #define DISP_REG_OVL_PITCH(n) (0x0044 + 0x20 * (n)) +#define OVL_CONST_BLEND BIT(28) #define DISP_REG_OVL_RDMA_CTRL(n) (0x00c0 + 0x20 * (n)) #define DISP_REG_OVL_RDMA_GMC(n) (0x00c8 + 0x20 * (n)) #define DISP_REG_OVL_ADDR_MT2701 0x0040 #define DISP_REG_OVL_CLRFMT_EXT 0x02D0 +#define DISP_REG_OVL_CLRFMT_EXT1 0x02D8 +#define OVL_CLRFMT_EXT1_CSC_EN(n) (1 << (((n) * 4) + 1)) +#define DISP_REG_OVL_Y2R_PARA_R0(n) (0x0134 + 0x28 * (n)) +#define OVL_Y2R_PARA_C_CF_RMY (GENMASK(14, 0)) +#define DISP_REG_OVL_Y2R_PARA_G0(n) (0x013c + 0x28 * (n)) +#define OVL_Y2R_PARA_C_CF_GMU (GENMASK(30, 16)) +#define DISP_REG_OVL_Y2R_PARA_B1(n) (0x0148 + 0x28 * (n)) +#define OVL_Y2R_PARA_C_CF_BMV (GENMASK(14, 0)) +#define DISP_REG_OVL_Y2R_PARA_YUV_A_0(n) (0x014c + 0x28 * (n)) +#define OVL_Y2R_PARA_C_CF_YA (GENMASK(10, 0)) +#define OVL_Y2R_PARA_C_CF_UA (GENMASK(26, 16)) +#define DISP_REG_OVL_Y2R_PARA_YUV_A_1(n) (0x0150 + 0x28 * (n)) +#define OVL_Y2R_PARA_C_CF_VA (GENMASK(10, 0)) +#define DISP_REG_OVL_Y2R_PRE_ADD2(n) (0x0154 + 0x28 * (n)) +#define DISP_REG_OVL_R2R_R0(n) (0x0500 + 0x40 * (n)) +#define DISP_REG_OVL_R2R_G1(n) (0x0510 + 0x40 * (n)) +#define DISP_REG_OVL_R2R_B2(n) (0x0520 + 0x40 * (n)) #define DISP_REG_OVL_ADDR_MT8173 0x0f40 #define DISP_REG_OVL_ADDR(ovl, n) ((ovl)->data->addr + 0x20 * (n)) #define DISP_REG_OVL_HDR_ADDR(ovl, n) ((ovl)->data->addr + 0x20 * (n) + 0x04) @@ -51,13 +70,19 @@ #define GMC_THRESHOLD_HIGH ((1 << GMC_THRESHOLD_BITS) / 4) #define GMC_THRESHOLD_LOW ((1 << GMC_THRESHOLD_BITS) / 8) -#define OVL_CON_BYTE_SWAP BIT(24) -#define OVL_CON_MTX_YUV_TO_RGB (6 << 16) -#define OVL_CON_CLRFMT_RGB (1 << 12) -#define OVL_CON_CLRFMT_RGBA8888 (2 << 12) -#define OVL_CON_CLRFMT_ARGB8888 (3 << 12) -#define OVL_CON_CLRFMT_UYVY (4 << 12) -#define OVL_CON_CLRFMT_YUYV (5 << 12) +#define OVL_CON_CLRFMT_MAN BIT(23) +#define OVL_CON_BYTE_SWAP BIT(24) +#define OVL_CON_RGB_SWAP BIT(25) +#define OVL_CON_MTX_AUTO_DIS BIT(26) +#define OVL_CON_MTX_EN BIT(27) +#define OVL_CON_CLRFMT_RGB (1 << 12) +#define OVL_CON_CLRFMT_RGBA8888 (2 << 12) +#define OVL_CON_CLRFMT_ARGB8888 (3 << 12) +#define OVL_CON_CLRFMT_PARGB8888 (OVL_CON_CLRFMT_ARGB8888 | OVL_CON_CLRFMT_MAN) +#define OVL_CON_CLRFMT_UYVY (4 << 12) +#define OVL_CON_CLRFMT_YUYV (5 << 12) +#define OVL_CON_MTX_YUV_TO_RGB (6 << 16) +#define OVL_CON_MTX_PROGRAMMABLE (8 << 16) #define OVL_CON_CLRFMT_RGB565(ovl) ((ovl)->data->fmt_rgb565_is_0 ? \ 0 : OVL_CON_CLRFMT_RGB) #define OVL_CON_CLRFMT_RGB888(ovl) ((ovl)->data->fmt_rgb565_is_0 ? \ @@ -71,6 +96,22 @@ #define OVL_CON_VIRT_FLIP BIT(9) #define OVL_CON_HORZ_FLIP BIT(10) +static inline bool is_10bit_rgb(u32 fmt) +{ + switch (fmt) { + case DRM_FORMAT_XRGB2101010: + case DRM_FORMAT_ARGB2101010: + case DRM_FORMAT_RGBX1010102: + case DRM_FORMAT_RGBA1010102: + case DRM_FORMAT_XBGR2101010: + case DRM_FORMAT_ABGR2101010: + case DRM_FORMAT_BGRX1010102: + case DRM_FORMAT_BGRA1010102: + return true; + } + return false; +} + static const u32 mt8173_formats[] = { DRM_FORMAT_XRGB8888, DRM_FORMAT_ARGB8888, @@ -88,12 +129,20 @@ static const u32 mt8173_formats[] = { static const u32 mt8195_formats[] = { DRM_FORMAT_XRGB8888, DRM_FORMAT_ARGB8888, + DRM_FORMAT_XRGB2101010, DRM_FORMAT_ARGB2101010, DRM_FORMAT_BGRX8888, DRM_FORMAT_BGRA8888, + DRM_FORMAT_BGRX1010102, DRM_FORMAT_BGRA1010102, DRM_FORMAT_ABGR8888, DRM_FORMAT_XBGR8888, + DRM_FORMAT_XBGR2101010, + DRM_FORMAT_ABGR2101010, + DRM_FORMAT_RGBX8888, + DRM_FORMAT_RGBA8888, + DRM_FORMAT_RGBX1010102, + DRM_FORMAT_RGBA1010102, DRM_FORMAT_RGB888, DRM_FORMAT_BGR888, DRM_FORMAT_RGB565, @@ -207,14 +256,19 @@ void mtk_ovl_clk_disable(struct device *dev) void mtk_ovl_start(struct device *dev) { struct mtk_disp_ovl *ovl = dev_get_drvdata(dev); + unsigned int reg = readl(ovl->regs + DISP_REG_OVL_DATAPATH_CON); - if (ovl->data->smi_id_en) { - unsigned int reg; + if (ovl->data->smi_id_en) + reg |= OVL_LAYER_SMI_ID_EN; - reg = readl(ovl->regs + DISP_REG_OVL_DATAPATH_CON); - reg = reg | OVL_LAYER_SMI_ID_EN; - writel_relaxed(reg, ovl->regs + DISP_REG_OVL_DATAPATH_CON); - } + /* + * clamp output to 10 bits per channel + * overflow and underflow usually happens when doing Y2R conversion + * this bit should be always enable to avoid this kind of situation + */ + reg |= OVL_OUTPUT_CLAMP; + + writel_relaxed(reg, ovl->regs + DISP_REG_OVL_DATAPATH_CON); writel_relaxed(0x1, ovl->regs + DISP_REG_OVL_EN); } @@ -253,9 +307,7 @@ static void mtk_ovl_set_bit_depth(struct device *dev, int idx, u32 format, reg = readl(ovl->regs + DISP_REG_OVL_CLRFMT_EXT); reg &= ~OVL_CON_CLRFMT_BIT_DEPTH_MASK(idx); - if (format == DRM_FORMAT_RGBA1010102 || - format == DRM_FORMAT_BGRA1010102 || - format == DRM_FORMAT_ARGB2101010) + if (is_10bit_rgb(format)) bit_depth = OVL_CON_CLRFMT_10_BIT; reg |= OVL_CON_CLRFMT_BIT_DEPTH(bit_depth, idx); @@ -273,7 +325,8 @@ void mtk_ovl_config(struct device *dev, unsigned int w, if (w != 0 && h != 0) mtk_ddp_write_relaxed(cmdq_pkt, h << 16 | w, &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_ROI_SIZE); - mtk_ddp_write_relaxed(cmdq_pkt, 0x0, &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_ROI_BGCLR); + mtk_ddp_write_relaxed(cmdq_pkt, 0xff000000, &ovl->cmdq_reg, ovl->regs, + DISP_REG_OVL_ROI_BGCLR); mtk_ddp_write(cmdq_pkt, 0x1, &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_RST); mtk_ddp_write(cmdq_pkt, 0x0, &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_RST); @@ -356,7 +409,8 @@ void mtk_ovl_layer_off(struct device *dev, unsigned int idx, DISP_REG_OVL_RDMA_CTRL(idx)); } -static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt) +static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt, + unsigned int blend_mode) { /* The return value in switch "MEM_MODE_INPUT_FORMAT_XXX" * is defined in mediatek HW data sheet. @@ -375,17 +429,37 @@ static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt) return OVL_CON_CLRFMT_RGB888(ovl) | OVL_CON_BYTE_SWAP; case DRM_FORMAT_RGBX8888: case DRM_FORMAT_RGBA8888: + return blend_mode == DRM_MODE_BLEND_COVERAGE ? + OVL_CON_CLRFMT_ARGB8888 : + OVL_CON_CLRFMT_PARGB8888; + case DRM_FORMAT_RGBX1010102: + case DRM_FORMAT_RGBA1010102: return OVL_CON_CLRFMT_ARGB8888; case DRM_FORMAT_BGRX8888: case DRM_FORMAT_BGRA8888: + return OVL_CON_BYTE_SWAP | + (blend_mode == DRM_MODE_BLEND_COVERAGE ? + OVL_CON_CLRFMT_ARGB8888 : + OVL_CON_CLRFMT_PARGB8888); + case DRM_FORMAT_BGRX1010102: case DRM_FORMAT_BGRA1010102: return OVL_CON_CLRFMT_ARGB8888 | OVL_CON_BYTE_SWAP; case DRM_FORMAT_XRGB8888: case DRM_FORMAT_ARGB8888: + return blend_mode == DRM_MODE_BLEND_COVERAGE ? + OVL_CON_CLRFMT_RGBA8888 : + OVL_CON_CLRFMT_PARGB8888; + case DRM_FORMAT_XRGB2101010: case DRM_FORMAT_ARGB2101010: return OVL_CON_CLRFMT_RGBA8888; case DRM_FORMAT_XBGR8888: case DRM_FORMAT_ABGR8888: + return OVL_CON_RGB_SWAP | + (blend_mode == DRM_MODE_BLEND_COVERAGE ? + OVL_CON_CLRFMT_RGBA8888 : + OVL_CON_CLRFMT_PARGB8888); + case DRM_FORMAT_XBGR2101010: + case DRM_FORMAT_ABGR2101010: return OVL_CON_CLRFMT_RGBA8888 | OVL_CON_BYTE_SWAP; case DRM_FORMAT_UYVY: return OVL_CON_CLRFMT_UYVY | OVL_CON_MTX_YUV_TO_RGB; @@ -407,6 +481,8 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx, unsigned int fmt = pending->format; unsigned int offset = (pending->y << 16) | pending->x; unsigned int src_size = (pending->height << 16) | pending->width; + unsigned int blend_mode = state->base.pixel_blend_mode; + unsigned int ignore_pixel_alpha = 0; unsigned int con; bool is_afbc = pending->modifier != DRM_FORMAT_MOD_LINEAR; union overlay_pitch { @@ -419,14 +495,92 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx, overlay_pitch.pitch = pitch; - if (!pending->enable) { + if (!pending->enable || !pending->width || !pending->height) { mtk_ovl_layer_off(dev, idx, cmdq_pkt); return; } - con = ovl_fmt_convert(ovl, fmt); - if (state->base.fb && state->base.fb->format->has_alpha) - con |= OVL_CON_AEN | OVL_CON_ALPHA; + con = ovl_fmt_convert(ovl, fmt, blend_mode); + if (state->base.fb) { + con |= OVL_CON_AEN; + con |= state->base.alpha & 0xff; + } + + if (blend_mode == DRM_MODE_BLEND_PIXEL_NONE || + (state->base.fb && !state->base.fb->format->has_alpha)) + ignore_pixel_alpha = OVL_CONST_BLEND; + + /* need to do Y2R and R2R to reduce 10bit data to 8bit for CRC calculation */ + if (ovl->data->supports_clrfmt_ext) { + u32 y2r_coef = 0, y2r_offset = 0, r2r_coef = 0, csc_en = 0; + + if (is_10bit_rgb(fmt)) { + con |= OVL_CON_MTX_AUTO_DIS | OVL_CON_MTX_EN | OVL_CON_MTX_PROGRAMMABLE; + + /* + * Y2R coef setting + * bit 13 is 2^1, bit 12 is 2^0, bit 11 is 2^-1, + * bit 10 is 2^-2 = 0.25 + */ + y2r_coef = BIT(10); + + /* -1 in 10bit */ + y2r_offset = GENMASK(10, 0) - 1; + + /* + * R2R coef setting + * bit 19 is 2^1, bit 18 is 2^0, bit 17 is 2^-1, + * bit 20 is 2^2 = 4 + */ + r2r_coef = BIT(20); + + /* CSC_EN is for R2R */ + csc_en = OVL_CLRFMT_EXT1_CSC_EN(idx); + + /* + * 1. YUV input data - 1 and shift right for 2 bits to remove it + * [R'] [0.25 0 0] [Y in - 1] + * [G'] = [ 0 0.25 0] * [U in - 1] + * [B'] [ 0 0 0.25] [V in - 1] + * + * 2. shift left for 2 bit letting the last 2 bits become 0 + * [R out] [ 4 0 0] [R'] + * [G out] = [ 0 4 0] * [G'] + * [B out] [ 0 0 4] [B'] + */ + } + + mtk_ddp_write_mask(cmdq_pkt, y2r_coef, + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_R0(idx), + OVL_Y2R_PARA_C_CF_RMY); + mtk_ddp_write_mask(cmdq_pkt, (y2r_coef << 16), + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_G0(idx), + OVL_Y2R_PARA_C_CF_GMU); + mtk_ddp_write_mask(cmdq_pkt, y2r_coef, + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_B1(idx), + OVL_Y2R_PARA_C_CF_BMV); + + mtk_ddp_write_mask(cmdq_pkt, y2r_offset, + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_YUV_A_0(idx), + OVL_Y2R_PARA_C_CF_YA); + mtk_ddp_write_mask(cmdq_pkt, (y2r_offset << 16), + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_YUV_A_0(idx), + OVL_Y2R_PARA_C_CF_UA); + mtk_ddp_write_mask(cmdq_pkt, y2r_offset, + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_YUV_A_1(idx), + OVL_Y2R_PARA_C_CF_VA); + + mtk_ddp_write_relaxed(cmdq_pkt, r2r_coef, + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_R2R_R0(idx)); + mtk_ddp_write_relaxed(cmdq_pkt, r2r_coef, + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_R2R_G1(idx)); + mtk_ddp_write_relaxed(cmdq_pkt, r2r_coef, + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_R2R_B2(idx)); + + mtk_ddp_write_mask(cmdq_pkt, csc_en, + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_CLRFMT_EXT1, + OVL_CLRFMT_EXT1_CSC_EN(idx)); + } if (pending->rotation & DRM_MODE_REFLECT_Y) { con |= OVL_CON_VIRT_FLIP; @@ -443,8 +597,8 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx, mtk_ddp_write_relaxed(cmdq_pkt, con, &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_CON(idx)); - mtk_ddp_write_relaxed(cmdq_pkt, overlay_pitch.split_pitch.lsb, &ovl->cmdq_reg, ovl->regs, - DISP_REG_OVL_PITCH(idx)); + mtk_ddp_write_relaxed(cmdq_pkt, overlay_pitch.split_pitch.lsb | ignore_pixel_alpha, + &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_PITCH(idx)); mtk_ddp_write_relaxed(cmdq_pkt, src_size, &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_SRC_SIZE(idx)); mtk_ddp_write_relaxed(cmdq_pkt, offset, &ovl->cmdq_reg, ovl->regs, From patchwork Mon Sep 18 08:42:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 141443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2732487vqi; Mon, 18 Sep 2023 08:11:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6aWa9JptvnfTKz8EGkh8MGsif1tT2kA2oQwVTsroNoQM7M/vpahufVEc1Pv6pkZBMlDhh X-Received: by 2002:a17:902:e54c:b0:1bf:2e5c:7367 with SMTP id n12-20020a170902e54c00b001bf2e5c7367mr11486574plf.42.1695049871206; Mon, 18 Sep 2023 08:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695049871; cv=none; d=google.com; s=arc-20160816; b=y6KRTs3jpYfTTV7z15WEgmRAK7ZivGDlfGhtwXXwmalhptcaSynrAjIjjBR8goC1jL PiQk/Dl4BzU2lsigJVvjKgc7E1kmO5hndoxkITOs+t1jIiLV9wUs5A3h4PVgjIPyBpfz 7wILiXJx7QK9LaEYxERor+wCWVvfNyY9T3wda7RSZBqwZgrRb7xgoSpiuUhvjZfJ7GBk NQq2P4pOUp9AFoXR705XBKRC6oxaPmQUPs9GJcwQpa67XvKC/Xsa34A6ij+cevAXrlSy HJBhFJqhYjAD7PWcJz+dQQZvn8FD1UQ86vhC8JnKh7snnNXJju3lOXZh5+RC+h5vC8ET Cniw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fXr6Cut6jTnXdSAIgAVzIjJPsM8eECFQF8sZwclKBZM=; fh=zj/1xCYHHy/mPJj+kFbga0zHrcDizctVV21xrPlQjYA=; b=xLV11e44STugBSvkNMLsNXV9mw/bLK/zyioPr+zE9Kltwi6k9bpZQD+ISLqUYlLWoD 6rhP9V+//zI03sc6lUsyQsW4rfiQBYuCTCsOxmBsT+dDVKAbeoT2hNZEGaspVINiXSuy OFP/a9gXI0FJiThzZGtuDWR4vC57Hpo+FRGsfCGMPQC1DJ8enhEPb1QG898jq9/uFCnD ZFxLecJSvaCbl6M3mhx3oPrznmr5u1dCZ+xrXJuIHo2XYn7UMq4Kus1VDo5z1IjplSQ8 Z27RPTMOkCSvRK7K5qf1HjDESJFMT3shj9WX/3BBkmZ637nyO7RXbtmAPgiwJa2znLKN Q9Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iN7ybDjM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id q20-20020a170902e31400b001c33d339754si7973109plc.136.2023.09.18.08.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 08:11:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iN7ybDjM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id BC47A80AC461; Mon, 18 Sep 2023 01:43:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240888AbjIRInM (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240744AbjIRImb (ORCPT ); Mon, 18 Sep 2023 04:42:31 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D193C5 for ; Mon, 18 Sep 2023 01:42:20 -0700 (PDT) X-UUID: 434d157e55ff11ee8051498923ad61e6-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=fXr6Cut6jTnXdSAIgAVzIjJPsM8eECFQF8sZwclKBZM=; b=iN7ybDjMOX5ttJM9FcSOyYID6Tb9Iq5Je6hff/uFQn9J9AtvS/8BBkHrCDqUgMWFiMmh99VR4fzfF5aA7FnuqjbK+dDChJcyiEmxLN9tfiPwjM+AdlwXUJT9/Fpf5V8K19ZjXuRZ1h9ZbQTwLhOXqr8QskCiAOl7PLvpuWJAQ6I=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:7c141f63-48b2-46f7-94dc-963e5aa7ad58,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:0ad78a4,CLOUDID:c65327c3-1e57-4345-9d31-31ad9818b39f,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 434d157e55ff11ee8051498923ad61e6-20230918 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1196658862; Mon, 18 Sep 2023 16:42:12 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:11 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , Philipp Zabel , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 08/11] drm/mediatek: Support alpha blending in VDOSYS1 Date: Mon, 18 Sep 2023 16:42:04 +0800 Message-ID: <20230918084207.23604-9-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777388613545593683 X-GMAIL-MSGID: 1777388613545593683 Support premultiply and coverage alpha blending modes. Signed-off-by: Hsiao Chien Sung --- drivers/gpu/drm/mediatek/mtk_ethdr.c | 48 ++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_ethdr.c b/drivers/gpu/drm/mediatek/mtk_ethdr.c index db7ac666ec5e..a41b3950e081 100644 --- a/drivers/gpu/drm/mediatek/mtk_ethdr.c +++ b/drivers/gpu/drm/mediatek/mtk_ethdr.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,7 @@ #define MIX_SRC_L0_EN BIT(0) #define MIX_L_SRC_CON(n) (0x28 + 0x18 * (n)) #define NON_PREMULTI_SOURCE (2 << 12) +#define PREMULTI_SOURCE (3 << 12) #define MIX_L_SRC_SIZE(n) (0x30 + 0x18 * (n)) #define MIX_L_SRC_OFFSET(n) (0x34 + 0x18 * (n)) #define MIX_FUNC_DCM0 0x120 @@ -153,33 +155,59 @@ void mtk_ethdr_layer_config(struct device *dev, unsigned int idx, struct mtk_plane_pending_state *pending = &state->pending; unsigned int offset = (pending->x & 1) << 31 | pending->y << 16 | pending->x; unsigned int align_width = ALIGN_DOWN(pending->width, 2); - unsigned int alpha_con = 0; + unsigned int mix_con = NON_PREMULTI_SOURCE; + bool replace_src_a = false; + + union format { + u32 raw; + u8 str[5]; + } format; dev_dbg(dev, "%s+ idx:%d", __func__, idx); if (idx >= 4) return; - if (!pending->enable) { + if (!pending->enable || !pending->width || !pending->height) { + /* + * instead of disabling layer with MIX_SRC_CON directly + * set the size to 0 to avoid screen shift due to mode switch + */ mtk_ddp_write(cmdq_pkt, 0, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_SIZE(idx)); return; } - if (state->base.fb && state->base.fb->format->has_alpha) - alpha_con = MIXER_ALPHA_AEN | MIXER_ALPHA; + mix_con |= MIXER_ALPHA_AEN | (state->base.alpha & MIXER_ALPHA); + + if (state->base.pixel_blend_mode != DRM_MODE_BLEND_COVERAGE) + mix_con |= PREMULTI_SOURCE; + + if (state->base.pixel_blend_mode == DRM_MODE_BLEND_PIXEL_NONE || + (state->base.fb && !state->base.fb->format->has_alpha)) { + /* + * Mixer doesn't support CONST_BLD mode, + * use a trick to make the output equivalent + */ + replace_src_a = true; + } + + format.raw = pending->format; + + dev_dbg(dev, "L%d: %ux%u(%u,%u)%s: SCA=0x%x(%u), MIX=0x%x\n", idx, + pending->width, pending->height, pending->x, pending->y, + format.str, (state->base.alpha & MIXER_ALPHA), + state->base.pixel_blend_mode, mix_con); - mtk_mmsys_mixer_in_config(priv->mmsys_dev, idx + 1, alpha_con ? false : true, - DEFAULT_9BIT_ALPHA, + mtk_mmsys_mixer_in_config(priv->mmsys_dev, idx + 1, replace_src_a, MIXER_ALPHA, pending->x & 1 ? MIXER_INX_MODE_EVEN_EXTEND : MIXER_INX_MODE_BYPASS, align_width / 2 - 1, cmdq_pkt); mtk_ddp_write(cmdq_pkt, pending->height << 16 | align_width, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_SIZE(idx)); mtk_ddp_write(cmdq_pkt, offset, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_OFFSET(idx)); - mtk_ddp_write_mask(cmdq_pkt, alpha_con, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_CON(idx), - 0x1ff); - mtk_ddp_write_mask(cmdq_pkt, BIT(idx), &mixer->cmdq_base, mixer->regs, MIX_SRC_CON, - BIT(idx)); + mtk_ddp_write(cmdq_pkt, mix_con, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_CON(idx)); + mtk_ddp_write_mask(cmdq_pkt, BIT(idx), &mixer->cmdq_base, mixer->regs, + MIX_SRC_CON, BIT(idx)); } void mtk_ethdr_config(struct device *dev, unsigned int w, From patchwork Mon Sep 18 08:42:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 141426 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2694125vqi; Mon, 18 Sep 2023 07:18:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFt1F7h7Dz7214+7iJcriVr5nVowaxnOtQIqaL6sHAdUs9cTZo0J/TrQtZku6U/qbX6gK9o X-Received: by 2002:a05:6a00:1344:b0:68f:cb69:8e6c with SMTP id k4-20020a056a00134400b0068fcb698e6cmr9085370pfu.33.1695046714368; Mon, 18 Sep 2023 07:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695046714; cv=none; d=google.com; s=arc-20160816; b=Qdoc/SwEj2txVANdZS1QMsg57OUPqkBH0AVD+AsszRglgHS+RMjXwYFkIYXacpDYQE 0nwS6ioHGYWoEwvosutWVQL7ZaEec/xxo7+cdrJAA+uJqNKCtAEVjE8ya62KVPEvnrn8 /ts/JuD5QrjKP27nGPjC8RunPxu0VEw3nRVKHuXeyrLU/SEFlX3Zn9fiVv4i0EW5OZF9 /C/B3k9JseOGj1BMVW0XHpMkQnRhscODrT624KZEO1hbhG/89HtPFplJhZ8EFfbzbN21 Z2GA1lJ8gvbtSaOgH+nep3qFO4lIpP/SOS3H7jyj0tmNYdGeXdktBLsv5QNwIosbByDY x32g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dWXM2MxkcfzW6RN49ZK59mOAlLhCtd/7QmLoWaia1fw=; fh=zj/1xCYHHy/mPJj+kFbga0zHrcDizctVV21xrPlQjYA=; b=T9dMdhir5UxUW1QqTa5P26bKHonFXuzYqdymyB6+HbHYOKCCgxz5VplYSqTRXK7dkb 8XRiEGi0zoc9fAOJyYToBE3qrSHD5dcg5E6uDTHQGL8F3xJfVPiJK8IlJmIkXMmXOKcm UI3iARa0m/4syWTr9KZXr+K4zAw23NA6cCYpjKoAqVMHK6vEx36K5O5XbD6dOkg7dAA4 G+YJJh5dvhk8pCa9K4bEQ0XBHsFRgzDnxAWiIkewCEY8tDYK5XZzsqqW3pnA7Mg9EsNr aFIeepPMb9Mh30xZpXCjENZbyXtuM1fl54A2h/l+5oDAWauvIpqPdV7HTkX54hG5kWup 0oNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iCZ6FzAC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id h1-20020a056a00230100b006906f7d783fsi3013268pfh.87.2023.09.18.07.18.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 07:18:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iCZ6FzAC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5885583F533B; Mon, 18 Sep 2023 01:43:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241111AbjIRIn3 (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240818AbjIRImd (ORCPT ); Mon, 18 Sep 2023 04:42:33 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DDA0E3 for ; Mon, 18 Sep 2023 01:42:23 -0700 (PDT) X-UUID: 436947da55ff11eea33bb35ae8d461a2-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=dWXM2MxkcfzW6RN49ZK59mOAlLhCtd/7QmLoWaia1fw=; b=iCZ6FzACNb+7ApKNGVlCgqjmL1PlC5tPl6dZFSYQPbIjShC+Pu/JLAVtvBdDWYpQcO9eoiWP8PPXcXkQlCsgrHTwH18bGxpIVnIpDCcRnAvvowCU/rvC39JoKYNbMDcfUsgwhcFCoA8phaY9qa57EG9CiGu0b56moTQqOSIo4Qo=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:2f120c75-3166-4539-abe2-0e7bd6a1f33f,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:0ad78a4,CLOUDID:3093f6be-14cc-44ca-b657-2d2783296e72,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR: NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 436947da55ff11eea33bb35ae8d461a2-20230918 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 408464815; Mon, 18 Sep 2023 16:42:13 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:11 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , Philipp Zabel , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 09/11] drm/mediatek: Support CRC in display driver Date: Mon, 18 Sep 2023 16:42:05 +0800 Message-ID: <20230918084207.23604-10-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777385303316737678 X-GMAIL-MSGID: 1777385303316737678 Register CRC related function pointers to support CRC retrieval. Signed-off-by: Hsiao Chien Sung --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 258 +++++++++++++++++++- drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 39 +++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 35 +++ 3 files changed, 330 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index b6fa4ad2f94d..59501d3eec8a 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -29,14 +29,30 @@ * struct mtk_drm_crtc - MediaTek specific crtc structure. * @base: crtc object. * @enabled: records whether crtc_enable succeeded + * @pending_needs_vblank: determine if we need to handle vblank event + * @event: the vblank event to handle * @planes: array of 4 drm_plane structures, one for each overlay plane + * @layer_nr: layer numbers that the crtc supports * @pending_planes: whether any plane has pending changes to be applied + * @pending_async_planes: if there is any pending async update + * @cmdq_client: a handler to control cmdq (mbox channel, thread ...etc.) + * @cmdq_handle: cmdq packet to store the commands + * @cmdq_event: cmdq event that the thread is waiting for + * @cmdq_vblank_cnt: vblank count that is dedicated for the cmdq thread + * @cb_blocking_queue: wait queue to determine if cmdq is blocked * @mmsys_dev: pointer to the mmsys device for configuration registers + * @dma_dev: pointer to the dma device (usually rdma) * @mutex: handle to one of the ten disp_mutex streams + * @ddp_comp_nr_ori: + * @max_ddp_comp_nr: * @ddp_comp_nr: number of components in ddp_comp * @ddp_comp: array of pointers the mtk_ddp_comp structures used by this crtc - * - * TODO: Needs update: this header is missing a bunch of member descriptions. + * @conn_route_nr: + * @conn_routes: + * @hw_lock: mutex lock to avoid race condition when layer config + * @config_updating: determine if the layer configuration is done + * @crc_provider: get crc provider of the crtc + * @frames: count the frames that are added to crc entry */ struct mtk_drm_crtc { struct drm_crtc base; @@ -67,6 +83,9 @@ struct mtk_drm_crtc { /* lock for display hardware access */ struct mutex hw_lock; bool config_updating; + + struct mtk_ddp_comp *crc_provider; + unsigned int frames; }; struct mtk_crtc_state { @@ -615,6 +634,14 @@ static void mtk_crtc_ddp_irq(void *data) struct drm_crtc *crtc = data; struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); struct mtk_drm_private *priv = crtc->dev->dev_private; + struct mtk_ddp_comp *comp = mtk_crtc->crc_provider; + + /* + * crc providers should make sure the crc is always correct + * by resetting it in .crc_read() + */ + if (crtc->crc.opened) + comp->funcs->crc_read(comp->dev); #if IS_REACHABLE(CONFIG_MTK_CMDQ) if (!priv->data->shadow_register && !mtk_crtc->cmdq_client.chan) @@ -626,6 +653,24 @@ static void mtk_crtc_ddp_irq(void *data) if (!priv->data->shadow_register) mtk_crtc_ddp_config(crtc, NULL); #endif + + /* + * drm_crtc_add_crc_entry() could take more than 50ms to finish + * put it at the end of the isr + */ + if (crtc->crc.opened) { + /* + * skip the first crc because the first frame is configured by + * mtk_crtc_ddp_hw_init() when atomic enable + */ + if (++mtk_crtc->frames > 1) { + drm_crtc_add_crc_entry(crtc, true, + drm_crtc_vblank_count(crtc), + comp->funcs->crc_entry(comp->dev)); + } + } else { + mtk_crtc->frames = 0; + } mtk_drm_finish_page_flip(mtk_crtc); } @@ -647,6 +692,40 @@ static void mtk_drm_crtc_disable_vblank(struct drm_crtc *crtc) mtk_ddp_comp_disable_vblank(comp); } +static int mtk_drm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src) +{ + if (src && strcmp(src, "auto") != 0) { + DRM_ERROR("%s(crtc-%d): unknown source '%s'\n", + __func__, drm_crtc_index(crtc), src); + return -EINVAL; + } + return 0; +} + +static int mtk_drm_crtc_verify_crc_source(struct drm_crtc *crtc, + const char *src, + size_t *cnt) +{ + struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); + struct mtk_ddp_comp *comp = mtk_crtc->crc_provider; + + if (!comp) { + DRM_ERROR("%s(crtc-%d): no crc provider\n", + __func__, drm_crtc_index(crtc)); + return -ENOENT; + } + + if (src && strcmp(src, "auto") != 0) { + DRM_ERROR("%s(crtc-%d): unknown source '%s'\n", + __func__, drm_crtc_index(crtc), src); + return -EINVAL; + } + + *cnt = comp->funcs->crc_cnt(comp->dev); + + return 0; +} + int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane, struct mtk_plane_state *state) { @@ -779,6 +858,8 @@ static const struct drm_crtc_funcs mtk_crtc_funcs = { .atomic_destroy_state = mtk_drm_crtc_destroy_state, .enable_vblank = mtk_drm_crtc_enable_vblank, .disable_vblank = mtk_drm_crtc_disable_vblank, + .set_crc_source = mtk_drm_crtc_set_crc_source, + .verify_crc_source = mtk_drm_crtc_verify_crc_source, }; static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = { @@ -961,6 +1042,11 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, if (comp->funcs->ctm_set) has_ctm = true; + + if (comp->funcs->crc_cnt && + comp->funcs->crc_entry && + comp->funcs->crc_read) + mtk_crtc->crc_provider = comp; } mtk_ddp_comp_register_vblank_cb(comp, mtk_crtc_ddp_irq, @@ -1040,3 +1126,171 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, #endif return 0; } + +void mtk_drm_crc_init(struct mtk_drm_crc *crc, + const u32 *crc_offset_table, size_t crc_count, + u32 reset_offset, u32 reset_mask) +{ + crc->ofs = crc_offset_table; + crc->cnt = crc_count; + crc->rst_ofs = reset_offset; + crc->rst_msk = reset_mask; + crc->va = kcalloc(crc->cnt, sizeof(*crc->va), GFP_KERNEL); + if (!crc->va) { + DRM_ERROR("failed to allocate memory for crc\n"); + crc->cnt = 0; + } +} + +void mtk_drm_crc_read(struct mtk_drm_crc *crc, void __iomem *reg) +{ + if (!crc->cnt || !crc->ofs || !crc->va) + return; + +#if IS_REACHABLE(CONFIG_MTK_CMDQ) + /* sync to see the most up-to-date copy of the DMA buffer */ + dma_sync_single_for_cpu(crc->cmdq_client.chan->mbox->dev, + crc->pa, crc->cnt * sizeof(*crc->va), + DMA_FROM_DEVICE); +#else + /* read crc with cpu for the platforms without cmdq */ + { + u32 n; + + for (n = 0; n < crc->cnt; n++) + crc->va[n] = readl(reg + crc->ofs[n]); + + n = readl(reg + crc->rst_ofs); + + /* pull reset bit */ + n |= crc->rst_msk; + writel(n, reg + crc->rst_ofs); + + /* release reset bit */ + n &= ~crc->rst_msk; + writel(n, reg + crc->rst_ofs); + } +#endif +} + +void mtk_drm_crc_destroy(struct mtk_drm_crc *crc) +{ + if (!crc->cnt) + return; + +#if IS_REACHABLE(CONFIG_MTK_CMDQ) + if (crc->pa) { + dma_unmap_single(crc->cmdq_client.chan->mbox->dev, + crc->pa, crc->cnt * sizeof(*crc->va), + DMA_TO_DEVICE); + crc->pa = 0; + } + if (crc->cmdq_client.chan) { + mtk_drm_cmdq_pkt_destroy(&crc->cmdq_handle); + mbox_free_channel(crc->cmdq_client.chan); + crc->cmdq_client.chan = NULL; + } +#endif + kfree(crc->va); + crc->va = NULL; + crc->cnt = 0; +} + +#if IS_REACHABLE(CONFIG_MTK_CMDQ) +void mtk_drm_crc_cmdq_create(struct device *dev, struct mtk_drm_crc *crc) +{ + int i; + + if (!crc->cnt) { + dev_warn(dev, "%s: not support\n", __func__); + goto cleanup; + } + + if (!crc->ofs) { + dev_warn(dev, "%s: not defined\n", __func__); + goto cleanup; + } + + crc->cmdq_client.client.dev = dev; + crc->cmdq_client.client.tx_block = false; + crc->cmdq_client.client.knows_txdone = true; + crc->cmdq_client.client.rx_callback = NULL; + crc->cmdq_client.chan = mbox_request_channel(&crc->cmdq_client.client, 0); + if (IS_ERR(crc->cmdq_client.chan)) { + dev_warn(dev, "%s: failed to create mailbox client\n", __func__); + crc->cmdq_client.chan = NULL; + goto cleanup; + } + + if (mtk_drm_cmdq_pkt_create(&crc->cmdq_client, &crc->cmdq_handle, PAGE_SIZE)) { + dev_warn(dev, "%s: failed to create cmdq packet\n", __func__); + goto cleanup; + } + + if (!crc->va) { + dev_warn(dev, "%s: no memory\n", __func__); + goto cleanup; + } + + /* map the entry to get a dma address for cmdq to store the crc */ + crc->pa = dma_map_single(crc->cmdq_client.chan->mbox->dev, + crc->va, crc->cnt * sizeof(*crc->va), + DMA_FROM_DEVICE); + + if (dma_mapping_error(crc->cmdq_client.chan->mbox->dev, crc->pa)) { + dev_err(dev, "%s: failed to map dma\n", __func__); + goto cleanup; + } + + if (crc->cmdq_event) + cmdq_pkt_wfe(&crc->cmdq_handle, crc->cmdq_event, true); + + for (i = 0; i < crc->cnt; i++) { + /* put crc to spr1 register */ + cmdq_pkt_read_s(&crc->cmdq_handle, crc->cmdq_reg->subsys, + crc->cmdq_reg->offset + crc->ofs[i], + CMDQ_THR_SPR_IDX1); + + /* copy spr1 register to physical address of the crc */ + cmdq_pkt_assign(&crc->cmdq_handle, CMDQ_THR_SPR_IDX0, + CMDQ_ADDR_HIGH(crc->pa + i * sizeof(*crc->va))); + cmdq_pkt_write_s(&crc->cmdq_handle, CMDQ_THR_SPR_IDX0, + CMDQ_ADDR_LOW(crc->pa + i * sizeof(*crc->va)), + CMDQ_THR_SPR_IDX1); + } + /* reset crc */ + mtk_ddp_write_mask(&crc->cmdq_handle, ~0, crc->cmdq_reg, 0, + crc->rst_ofs, crc->rst_msk); + + /* clear reset bit */ + mtk_ddp_write_mask(&crc->cmdq_handle, 0, crc->cmdq_reg, 0, + crc->rst_ofs, crc->rst_msk); + + cmdq_pkt_jump_absolute(&crc->cmdq_handle); + + return; +cleanup: + mtk_drm_crc_destroy(crc); +} + +void mtk_drm_crc_cmdq_start(struct mtk_drm_crc *crc) +{ + if (!crc->cmdq_client.chan) + return; + + dma_sync_single_for_device(crc->cmdq_client.chan->mbox->dev, + crc->cmdq_handle.pa_base, + crc->cmdq_handle.cmd_buf_size, + DMA_TO_DEVICE); + mbox_send_message(crc->cmdq_client.chan, &crc->cmdq_handle); + mbox_client_txdone(crc->cmdq_client.chan, 0); +} + +void mtk_drm_crc_cmdq_stop(struct mtk_drm_crc *crc) +{ + if (!crc->cmdq_client.chan) + return; + + mbox_flush(crc->cmdq_client.chan, 2000); +} +#endif diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h index 3e9046993d09..3e0e20a3c404 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h @@ -14,6 +14,45 @@ #define MTK_MAX_BPC 10 #define MTK_MIN_BPC 3 +/** + * struct mtk_drm_crc - crc related information + * @ofs: register offset of crc + * @rst_ofs: register offset of crc reset + * @rst_msk: register mask of crc reset + * @cnt: count of crc + * @va: pointer to the start of crc array + * @pa: physical address of the crc for gce to access + * @cmdq_event: the event to trigger the cmdq + * @cmdq_reg: address of the register that cmdq is going to access + * @cmdq_client: handler to control cmdq (mbox channel, thread ...etc.) + * @cmdq_handle: cmdq packet to store the commands + */ +struct mtk_drm_crc { + const u32 *ofs; + u32 rst_ofs; + u32 rst_msk; + size_t cnt; + u32 *va; +#if IS_REACHABLE(CONFIG_MTK_CMDQ) + dma_addr_t pa; + u32 cmdq_event; + struct cmdq_client_reg *cmdq_reg; + struct cmdq_client cmdq_client; + struct cmdq_pkt cmdq_handle; +#endif +}; + +void mtk_drm_crc_init(struct mtk_drm_crc *crc, + const u32 *crc_offset_table, size_t crc_count, + u32 reset_offset, u32 reset_mask); +void mtk_drm_crc_read(struct mtk_drm_crc *crc, void __iomem *reg); +void mtk_drm_crc_destroy(struct mtk_drm_crc *crc); +#if IS_REACHABLE(CONFIG_MTK_CMDQ) +void mtk_drm_crc_cmdq_create(struct device *dev, struct mtk_drm_crc *crc); +void mtk_drm_crc_cmdq_start(struct mtk_drm_crc *crc); +void mtk_drm_crc_cmdq_stop(struct mtk_drm_crc *crc); +#endif + void mtk_drm_crtc_commit(struct drm_crtc *crtc); int mtk_drm_crtc_create(struct drm_device *drm_dev, const unsigned int *path, diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index febcaeef16a1..07c26d881187 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -45,6 +45,38 @@ enum mtk_ddp_comp_type { struct mtk_ddp_comp; struct cmdq_pkt; + +/* struct mtk_ddp_comp_funcs - function pointers of the ddp components + * @clk_enable: enable the clocks of the component + * @clk_disable: disable the clocks of the component + * @config: configure the component + * @start: start (enable) the component + * @stop: stop (disable) the component + * @register_vblank_cb: to register a callback function when vblank irq occurs + * @unregister_vblank_cb: to unregister the callback function from the vblank irq + * @enable_vblank: enable vblank irq + * @disable_vblank: disable vblank irq + * @supported_rotations: return rotation capability of the component + * @layer_nr: how many layers the component supports + * @layer_check: to check if the state of the layer is valid for the component + * @layer_config: to configure the component according to the state of the layer + * @gamma_set: to set gamma for the component + * @bgclr_in_on: turn on background color + * @bgclr_in_off: turn off background color + * @ctm_set: set color transformation matrix + * @dma_dev_get: return the device that uses direct memory access + * @get_formats: get the format that is currently in use by the component + * @get_num_formats: get number of the formats that the component supports + * @connect: connect the sub modules of the component + * @disconnect: disconnect the sub modules of the component + * @add: add the device to the component (mount them in the mutex) + * @remove: remove the device from the component (unmount them from the mutex) + * @encoder_index: get the encoder index of the component + * @crc: return the start of crc array + * @crc_cnt: how many CRCs the component supports + * @crc_entry: get the pointer to the crc entry + * @crc_read: call this function to read crc from the hardware component + */ struct mtk_ddp_comp_funcs { int (*clk_enable)(struct device *dev); void (*clk_disable)(struct device *dev); @@ -80,6 +112,9 @@ struct mtk_ddp_comp_funcs { void (*disconnect)(struct device *dev, struct device *mmsys_dev, unsigned int next); void (*add)(struct device *dev, struct mtk_mutex *mutex); void (*remove)(struct device *dev, struct mtk_mutex *mutex); + size_t (*crc_cnt)(struct device *dev); + u32 *(*crc_entry)(struct device *dev); + void (*crc_read)(struct device *dev); }; struct mtk_ddp_comp { From patchwork Mon Sep 18 08:42:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 141360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2575188vqi; Mon, 18 Sep 2023 04:16:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE16dzweLMOjXmgDFEdS9qdwRK+4UncA8NhaUbO/AtFvPwqseA6/kRx+XwfhqvVf6alNwVI X-Received: by 2002:a05:6a00:14d5:b0:690:4362:7025 with SMTP id w21-20020a056a0014d500b0069043627025mr8297758pfu.29.1695035795728; Mon, 18 Sep 2023 04:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695035795; cv=none; d=google.com; s=arc-20160816; b=AzItNJuqUo2YxrDxCFqnv7TavSiCOnqrKPMglbroHf4BRrt+8YFauj7l+t/R9K+Mo9 ej/16vsUOS/Yc5z0G/Ml9Pf7gho1j0/QehCv75CntvVtWgN/kJU5A6BmdGfLYxhrXPVW m5jUu0blar9q9LD47Lx7SKx/XHiLJ8LQD1DUv7NZc9Db8iNgQVR2iRI2dufDjxmlz06R tTUthqJ44eeBnqbe4j29UaFiNDKI28HVPS+37YrTzDvCD+Yx26HIWTRp3PdhhVUnW7Ex LT6iePcq+qF11tyz7e6DmvKioXbcNAo1ivZoApURr8nDtnNW4dJ70ch1K9Z3r+cpKJVt cyPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=RHQ/l6ttjF5r52bgRrkwg8RRvNnrtkz1inmQmR6eWGI=; fh=zj/1xCYHHy/mPJj+kFbga0zHrcDizctVV21xrPlQjYA=; b=GDxRbZlp6IT8RDXC7P1B2xN40WR3VrUhIXRrsC4uE9h15EHKQWxeVBwzg81Q7AFPbe C7d+skXXsPeGuLc6pfu2XMKliU/LL+P7TSjOgUTTWValh2/nRQoc4zyKUMO2AL/XXqhN 8+IuyW1w/FUP8BlBB4wQHnYnTlJWVk47w4d4MLqA7Rlr4Icy4t2rJHrKrkZsMX+dNlou SiFA8ZhMr1D+BNpd67pOrxTeXKAmnimkwxhJnAAZjBqR8BIor5PkFDyjDogmHA/5sV0H Awf5TdYEXu8ugw8g2WTpVVF9qWr1Jwc5P9aE9Cdty9h3HDwpAtb5ZMowJn0QoOIqd3TD +97A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=p7XKUfYF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id t18-20020a056a0021d200b0068fea05ecdasi8090388pfj.182.2023.09.18.04.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 04:16:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=p7XKUfYF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1E25F840B7DE; Mon, 18 Sep 2023 01:43:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241076AbjIRInY (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240778AbjIRImb (ORCPT ); Mon, 18 Sep 2023 04:42:31 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AD18D2 for ; Mon, 18 Sep 2023 01:42:21 -0700 (PDT) X-UUID: 434f567c55ff11ee8051498923ad61e6-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=RHQ/l6ttjF5r52bgRrkwg8RRvNnrtkz1inmQmR6eWGI=; b=p7XKUfYFdIrdvv8TI9aGApuJ5t5mUHsumKmv17OF1terLUr3mnCbj1MgaEBTy9TuagnpY02Eak0UXv0KJ5pMP1w7nkWHFZb0Mc4b3kQ05li57pZtqCJtBaKYJHJwUBFnN2sRBu8OaEQBPdnTT0XoVUcvHb/UAls07srCF+XpTm4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:eef55eab-c89c-4756-840c-c706e2fa3a05,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:0ad78a4,CLOUDID:c5c91014-4929-4845-9571-38c601e9c3c9,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR: NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 434f567c55ff11ee8051498923ad61e6-20230918 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2011985252; Mon, 18 Sep 2023 16:42:12 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:12 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:11 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , Philipp Zabel , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 10/11] drm/mediatek: Support CRC in VDOSYS0 Date: Mon, 18 Sep 2023 16:42:06 +0800 Message-ID: <20230918084207.23604-11-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,RDNS_NONE, SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777373854492985510 X-GMAIL-MSGID: 1777373854492985510 We choose OVL as CRC generator from other hardware components that are also capable of calculating CRCs, since its frame done event triggers vblanks, it can be used as a signal to know when is safe to retrieve CRC of the frame. Please note that position of the hardware component that is chosen as CRC generator in the display path is significant. For example, while OVL is the first module in VDOSYS0, its CRC won't be affected by the modules after it, which means effects applied by PQ, Gamma, Dither or any other components after OVL won't be calculated in CRC generation. Signed-off-by: Hsiao Chien Sung --- drivers/gpu/drm/mediatek/mtk_disp_drv.h | 3 + drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 111 ++++++++++++++++++-- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 3 + 3 files changed, 109 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/mediatek/mtk_disp_drv.h index 2254038519e1..3e2f8084913c 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h @@ -100,6 +100,9 @@ void mtk_ovl_enable_vblank(struct device *dev); void mtk_ovl_disable_vblank(struct device *dev); const u32 *mtk_ovl_get_formats(struct device *dev); size_t mtk_ovl_get_num_formats(struct device *dev); +size_t mtk_ovl_crc_cnt(struct device *dev); +u32 *mtk_ovl_crc_entry(struct device *dev); +void mtk_ovl_crc_read(struct device *dev); void mtk_ovl_adaptor_add_comp(struct device *dev, struct mtk_mutex *mutex); void mtk_ovl_adaptor_remove_comp(struct device *dev, struct mtk_mutex *mutex); diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c index 8c58b204992e..8c7339f12410 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c @@ -24,6 +24,13 @@ #define OVL_FME_CPL_INT BIT(1) #define DISP_REG_OVL_INTSTA 0x0008 #define DISP_REG_OVL_EN 0x000c +#define OVL_EN BIT(0) +#define OVL_OP_8BIT_MODE BIT(4) +#define OVL_HG_FOVL_CK_ON BIT(8) +#define OVL_HF_FOVL_CK_ON BIT(10) +#define DISP_REG_OVL_TRIG 0x0010 +#define OVL_CRC_EN BIT(8) +#define OVL_CRC_CLR BIT(9) #define DISP_REG_OVL_RST 0x0014 #define DISP_REG_OVL_ROI_SIZE 0x0020 #define DISP_REG_OVL_DATAPATH_CON 0x0024 @@ -43,6 +50,8 @@ #define DISP_REG_OVL_RDMA_CTRL(n) (0x00c0 + 0x20 * (n)) #define DISP_REG_OVL_RDMA_GMC(n) (0x00c8 + 0x20 * (n)) #define DISP_REG_OVL_ADDR_MT2701 0x0040 +#define DISP_REG_OVL_CRC 0x0270 +#define OVL_CRC_OUT_MASK GENMASK(30, 0) #define DISP_REG_OVL_CLRFMT_EXT 0x02D0 #define DISP_REG_OVL_CLRFMT_EXT1 0x02D8 #define OVL_CLRFMT_EXT1_CSC_EN(n) (1 << (((n) * 4) + 1)) @@ -150,6 +159,24 @@ static const u32 mt8195_formats[] = { DRM_FORMAT_YUYV, }; +static const u32 mt8195_ovl_crc_ofs[] = { + DISP_REG_OVL_CRC, +}; + +/** + * struct mtk_disp_ovl_data - ovl driver data + * @addr: offset of the first layer (layer-0) + * @gmc_bits: gmc (gating memory clock) bit masks for adjusting positivity for ovl + * @layer_nr: layer numbers that ovl supports + * @fmt_rgb565_is_0: whether or not rgb565 is represented as 0 + * @smi_id_en: determine if smi needs to be enabled + * @supports_afbc: determine if ovl supports afbc + * @formats: format table that ovl supports + * @num_formats: number of formats that ovl supports + * @supports_clrfmt_ext: whether the ovl supports clear format (for alpha blend) + * @crc_ofs: crc offset table + * @crc_cnt: count of crc registers (could be more than one bank) + */ struct mtk_disp_ovl_data { unsigned int addr; unsigned int gmc_bits; @@ -160,12 +187,20 @@ struct mtk_disp_ovl_data { const u32 *formats; size_t num_formats; bool supports_clrfmt_ext; + const u32 *crc_ofs; + size_t crc_cnt; }; -/* +/** * struct mtk_disp_ovl - DISP_OVL driver structure * @crtc: associated crtc to report vblank events to + * @clk: clock of the ovl + * @regs: base address of the ovl register that can be accessed by cpu + * @cmdq_reg: register related info for cmdq (subsys, offset ...etc.) * @data: platform data + * @vblank_cb: callback function when vblank irq happened + * @vblank_cb_data: data to the callback function + * @crc: crc related information */ struct mtk_disp_ovl { struct drm_crtc *crtc; @@ -175,8 +210,30 @@ struct mtk_disp_ovl { const struct mtk_disp_ovl_data *data; void (*vblank_cb)(void *data); void *vblank_cb_data; + struct mtk_drm_crc crc; }; +size_t mtk_ovl_crc_cnt(struct device *dev) +{ + struct mtk_disp_ovl *ovl = dev_get_drvdata(dev); + + return ovl->crc.cnt; +} + +u32 *mtk_ovl_crc_entry(struct device *dev) +{ + struct mtk_disp_ovl *ovl = dev_get_drvdata(dev); + + return ovl->crc.va; +} + +void mtk_ovl_crc_read(struct device *dev) +{ + struct mtk_disp_ovl *ovl = dev_get_drvdata(dev); + + mtk_drm_crc_read(&ovl->crc, ovl->regs); +} + static irqreturn_t mtk_disp_ovl_irq_handler(int irq, void *dev_id) { struct mtk_disp_ovl *priv = dev_id; @@ -215,7 +272,7 @@ void mtk_ovl_enable_vblank(struct device *dev) struct mtk_disp_ovl *ovl = dev_get_drvdata(dev); writel(0x0, ovl->regs + DISP_REG_OVL_INTSTA); - writel_relaxed(OVL_FME_CPL_INT, ovl->regs + DISP_REG_OVL_INTEN); + writel(OVL_FME_CPL_INT, ovl->regs + DISP_REG_OVL_INTEN); } void mtk_ovl_disable_vblank(struct device *dev) @@ -268,14 +325,30 @@ void mtk_ovl_start(struct device *dev) */ reg |= OVL_OUTPUT_CLAMP; - writel_relaxed(reg, ovl->regs + DISP_REG_OVL_DATAPATH_CON); - writel_relaxed(0x1, ovl->regs + DISP_REG_OVL_EN); + writel(reg, ovl->regs + DISP_REG_OVL_DATAPATH_CON); + + reg = OVL_EN; + + if (ovl->data->crc_cnt) { + /* enable crc */ + writel(OVL_CRC_EN, ovl->regs + DISP_REG_OVL_TRIG); + /* enable crc related clocks */ + reg |= OVL_OP_8BIT_MODE | OVL_HG_FOVL_CK_ON | OVL_HF_FOVL_CK_ON; + } + writel(reg, ovl->regs + DISP_REG_OVL_EN); + +#if IS_REACHABLE(CONFIG_MTK_CMDQ) + mtk_drm_crc_cmdq_start(&ovl->crc); +#endif } void mtk_ovl_stop(struct device *dev) { struct mtk_disp_ovl *ovl = dev_get_drvdata(dev); +#if IS_REACHABLE(CONFIG_MTK_CMDQ) + mtk_drm_crc_cmdq_stop(&ovl->crc); +#endif writel_relaxed(0x0, ovl->regs + DISP_REG_OVL_EN); if (ovl->data->smi_id_en) { unsigned int reg; @@ -688,15 +761,31 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev) dev_err(dev, "failed to ioremap ovl\n"); return PTR_ERR(priv->regs); } + + priv->data = of_device_get_match_data(dev); + platform_set_drvdata(pdev, priv); + + if (priv->data->crc_cnt) { + mtk_drm_crc_init(&priv->crc, + priv->data->crc_ofs, priv->data->crc_cnt, + DISP_REG_OVL_TRIG, OVL_CRC_CLR); + } + #if IS_REACHABLE(CONFIG_MTK_CMDQ) ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0); if (ret) dev_dbg(dev, "get mediatek,gce-client-reg fail!\n"); -#endif - - priv->data = of_device_get_match_data(dev); - platform_set_drvdata(pdev, priv); + if (priv->data->crc_cnt) { + if (of_property_read_u32_index(dev->of_node, + "mediatek,gce-events", 0, + &priv->crc.cmdq_event)) { + dev_warn(dev, "failed to get gce-events for crc\n"); + } + priv->crc.cmdq_reg = &priv->cmdq_reg; + mtk_drm_crc_cmdq_create(dev, &priv->crc); + } +#endif ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler, IRQF_TRIGGER_NONE, dev_name(dev), priv); if (ret < 0) { @@ -717,6 +806,10 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev) static void mtk_disp_ovl_remove(struct platform_device *pdev) { + struct device *dev = &pdev->dev; + struct mtk_disp_ovl *ovl = dev_get_drvdata(dev); + + mtk_drm_crc_destroy(&ovl->crc); component_del(&pdev->dev, &mtk_disp_ovl_component_ops); pm_runtime_disable(&pdev->dev); } @@ -787,6 +880,8 @@ static const struct mtk_disp_ovl_data mt8195_ovl_driver_data = { .formats = mt8195_formats, .num_formats = ARRAY_SIZE(mt8195_formats), .supports_clrfmt_ext = true, + .crc_ofs = mt8195_ovl_crc_ofs, + .crc_cnt = ARRAY_SIZE(mt8195_ovl_crc_ofs), }; static const struct of_device_id mtk_disp_ovl_driver_dt_match[] = { diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index 771f4e173353..b8b3884dfa63 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -347,6 +347,9 @@ static const struct mtk_ddp_comp_funcs ddp_ovl = { .clk_enable = mtk_ovl_clk_enable, .clk_disable = mtk_ovl_clk_disable, .config = mtk_ovl_config, + .crc_cnt = mtk_ovl_crc_cnt, + .crc_entry = mtk_ovl_crc_entry, + .crc_read = mtk_ovl_crc_read, .start = mtk_ovl_start, .stop = mtk_ovl_stop, .register_vblank_cb = mtk_ovl_register_vblank_cb, From patchwork Mon Sep 18 08:42:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 141422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2679844vqi; Mon, 18 Sep 2023 07:01:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7+GQsLeZVauTs4sFiz9lH/DE6L/o0Xxq1QEVY40jQmASMfFTh5VpZA91+2BvG+rXG+ktu X-Received: by 2002:a17:902:b901:b0:1b8:6987:de84 with SMTP id bf1-20020a170902b90100b001b86987de84mr9877961plb.48.1695045718996; Mon, 18 Sep 2023 07:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695045718; cv=none; d=google.com; s=arc-20160816; b=rUG8C2UkxXfWjFupDbXFP2Oal4cfSp1UcgY635nU/6RcL8F+rVLQuibC2/wuqXxnMf jmagpyJLkGetsqKFx9oBibzESJEf8w0hHW2/1593LvyTXeE8LnYLQkpgzFDblfC1fYxK L2m9NAlBYP5KMgaQd03Vbq7dhORsuPxs+hMfcLryElC/bdpg7foeUIg4xyKr+4sBLt8Z OKTofyBu3J2q/52ya/Vjd23jkblY41YlGbtotS9SKbYCzk9xXle11ypnbVr0WCp2RxDH CcOJkN8sVSV8UsUY2IqnXyoyAEdtCSHZv9Yx2Hg795nUW2SxSQBj1h5B66l7tJGYVZ0/ 1+KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1zOwWFeG5NGBnZYWyrLagHyH+cMh1aLIgKpN5K4YYzs=; fh=KJWo/jBTlm0DyYU3URocXiKjA7/okmVQZjxpzD6zcfQ=; b=kAm1ypNgv8U0nnzHahvfyaN2Af3VY7EgsXZ5Wi0ouPcxQ+nkzBfybzKQ4c89yfM3s8 W8e0TUXXJEErFIFlwzvkz5OPbpWYCpAuHP/sfeYt9dLXd0nkro5zQckU97WaGwcXZM2u U1QObL4ZKA+PM2jjKz+NHtUaKPD4T2sLu+/umBpFc4cANNhF0+foYlysFijnjOnBuOLb 2fNrEWhuBsjChhE9xnM+ZjcDZQqK91bzohPLgpX9Pw+o4+t2c3/z/DqNhuPQbOvNtFYe fSglsd1wMVqkDJgdikCtiK1Y/H4v3nRf0fr08M4ejSIoLVMA1paHAYRWxvRXtX31INWt FnKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=EquVFZf3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a14-20020a170902ecce00b001c413905d87si7629555plh.49.2023.09.18.07.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 07:01:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=EquVFZf3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A4B3C80B5A02; Mon, 18 Sep 2023 01:43:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241096AbjIRIn1 (ORCPT + 27 others); Mon, 18 Sep 2023 04:43:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240780AbjIRImc (ORCPT ); Mon, 18 Sep 2023 04:42:32 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED9DAD8 for ; Mon, 18 Sep 2023 01:42:21 -0700 (PDT) X-UUID: 44c0b5d255ff11ee8051498923ad61e6-20230918 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=1zOwWFeG5NGBnZYWyrLagHyH+cMh1aLIgKpN5K4YYzs=; b=EquVFZf3kBVP4fs0wTKFSKqaT1+Ru5TQk3OZN0A2Wq/HjSPn4Kt/8i61fVURmzk7vZ8imGrAi+fIeehj733+dvMcFgLix87n+hCbdloKm/RJBDng2ZMytiLft38EPeq9RpThrVLN/+ceIBdXHxfK/QOS/VIgpI7HGe+axVAUAgg=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:dfc5adf8-8dc5-4acd-9f4b-dea5ec466ccc,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:0ad78a4,CLOUDID:4d93f6be-14cc-44ca-b657-2d2783296e72,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR: NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_ULN,TF_CID_SPAM_SNR X-UUID: 44c0b5d255ff11ee8051498923ad61e6-20230918 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1982334087; Mon, 18 Sep 2023 16:42:15 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 18 Sep 2023 16:42:12 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 18 Sep 2023 16:42:12 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Matthias Brugger CC: Daniel Vetter , David Airlie , "Philipp Zabel" , Chen-Yu Tsai , CK Hu , , , , , Hsiao Chien Sung Subject: [PATCH v2 11/11] drm/mediatek: Support CRC in VDOSYS1 Date: Mon, 18 Sep 2023 16:42:07 +0800 Message-ID: <20230918084207.23604-12-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230918084207.23604-1-shawn.sung@mediatek.com> References: <20230918084207.23604-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--7.538200-8.000000 X-TMASE-MatchedRID: bHUmO6Ydv7rXldNKzKPlvawxbZnudyr73FYvKmZiVnOCsBeCv8CM/a9q iUd5V6DYAak79SdgQsDW9RHvDZKnVSUtdpGicV4RA9lly13c/gEraL2mh8ZVK35h6y4KCSJcjse 1+4fQ7uvLqCJZs0VuwGSLax1QSEcDqH7dGVt6/4kOSj4RiINDEZKLNrbpy/A0DZjzHLL3eRahBi oZvW2mjSxzuGmAt8MyuPAycf9X/Euns5Q49D70/XV7tdtvoibaGEfoClqBl86bKItl61J/yZ+in TK0bC9eKrauXd3MZDVjsiBcbMhSNLkWSzA8xpNrThYReVz0uCphQolsfFVqEvfiLzqKam7O X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.538200-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: BDB18C1E7868CACE935102C79273B68ACFF6A43E4A6E96C97603EF594E8EE2522000:8 X-MTK: N X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,RDNS_NONE, SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:43:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777384259381882067 X-GMAIL-MSGID: 1777384259381882067 We choose Mixer as CRC generator in VDOSYS1 since its frame done event will trigger vblanks, we can know when is safe to retrieve CRC of the frame. In VDOSYS1, there's no image procession after Mixer, unlike OVL in VDOSYS0, Mixer's CRC will include all the effects that are applied to the frame. Signed-off-by: Hsiao Chien Sung --- drivers/gpu/drm/mediatek/mtk_disp_drv.h | 3 + .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 21 ++++++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 3 + drivers/gpu/drm/mediatek/mtk_ethdr.c | 73 +++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_ethdr.h | 5 ++ 5 files changed, 105 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/mediatek/mtk_disp_drv.h index 3e2f8084913c..ac8468917a2e 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h @@ -129,6 +129,9 @@ unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev); struct device *mtk_ovl_adaptor_dma_dev_get(struct device *dev); const u32 *mtk_ovl_adaptor_get_formats(struct device *dev); size_t mtk_ovl_adaptor_get_num_formats(struct device *dev); +size_t mtk_ovl_adaptor_crc_cnt(struct device *dev); +u32 *mtk_ovl_adaptor_crc_entry(struct device *dev); +void mtk_ovl_adaptor_crc_read(struct device *dev); void mtk_rdma_bypass_shadow(struct device *dev); int mtk_rdma_clk_enable(struct device *dev); diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c index 6bf6367853fb..8fe706ccee72 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c @@ -160,6 +160,27 @@ void mtk_ovl_adaptor_layer_config(struct device *dev, unsigned int idx, mtk_ethdr_layer_config(ethdr, idx, state, cmdq_pkt); } +size_t mtk_ovl_adaptor_crc_cnt(struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev); + + return mtk_ethdr_crc_cnt(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]); +} + +u32 *mtk_ovl_adaptor_crc_entry(struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev); + + return mtk_ethdr_crc_entry(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]); +} + +void mtk_ovl_adaptor_crc_read(struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev); + + mtk_ethdr_crc_read(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]); +} + void mtk_ovl_adaptor_config(struct device *dev, unsigned int w, unsigned int h, unsigned int vrefresh, unsigned int bpc, struct cmdq_pkt *cmdq_pkt) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index b8b3884dfa63..7dfb37ae2c80 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -400,6 +400,9 @@ static const struct mtk_ddp_comp_funcs ddp_ovl_adaptor = { .clk_enable = mtk_ovl_adaptor_clk_enable, .clk_disable = mtk_ovl_adaptor_clk_disable, .config = mtk_ovl_adaptor_config, + .crc_cnt = mtk_ovl_adaptor_crc_cnt, + .crc_entry = mtk_ovl_adaptor_crc_entry, + .crc_read = mtk_ovl_adaptor_crc_read, .start = mtk_ovl_adaptor_start, .stop = mtk_ovl_adaptor_stop, .layer_nr = mtk_ovl_adaptor_layer_nr, diff --git a/drivers/gpu/drm/mediatek/mtk_ethdr.c b/drivers/gpu/drm/mediatek/mtk_ethdr.c index a41b3950e081..693b9a438a3d 100644 --- a/drivers/gpu/drm/mediatek/mtk_ethdr.c +++ b/drivers/gpu/drm/mediatek/mtk_ethdr.c @@ -24,6 +24,9 @@ #define MIX_FME_CPL_INTEN BIT(1) #define MIX_INTSTA 0x8 #define MIX_EN 0xc +#define MIX_TRIG 0x10 +#define MIX_TRIG_CRC_EN BIT(8) +#define MIX_TRIG_CRC_RST BIT(9) #define MIX_RST 0x14 #define MIX_ROI_SIZE 0x18 #define MIX_DATAPATH_CON 0x1c @@ -39,6 +42,11 @@ #define PREMULTI_SOURCE (3 << 12) #define MIX_L_SRC_SIZE(n) (0x30 + 0x18 * (n)) #define MIX_L_SRC_OFFSET(n) (0x34 + 0x18 * (n)) + +/* CRC register offsets for odd and even lines */ +#define MIX_CRC_ODD 0x110 +#define MIX_CRC_EVEN 0x114 + #define MIX_FUNC_DCM0 0x120 #define MIX_FUNC_DCM1 0x124 #define MIX_FUNC_DCM_ENABLE 0xffffffff @@ -74,6 +82,17 @@ struct mtk_ethdr_comp { struct cmdq_client_reg cmdq_base; }; +/** + * struct mtk_ethdr - ethdr driver data + * @ethdr_comp: components of ethdr(mixer) + * @ethdr_clk: clocks of ethdr components + * @mmsys_dev: mmsys device that ethdr binds to + * @vblank_cb: callback function when vblank irq occurs + * @vblank_cb_data: data fo vblank callback + * @irq: irq that triggers irq handler + * @reset_ctl: reset control of ethdr + * @crc: crc information + */ struct mtk_ethdr { struct mtk_ethdr_comp ethdr_comp[ETHDR_ID_MAX]; struct clk_bulk_data ethdr_clk[ETHDR_CLK_NUM]; @@ -82,6 +101,7 @@ struct mtk_ethdr { void *vblank_cb_data; int irq; struct reset_control *reset_ctl; + struct mtk_drm_crc crc; }; static const char * const ethdr_clk_str[] = { @@ -100,6 +120,32 @@ static const char * const ethdr_clk_str[] = { "vdo_be_async", }; +static const u32 ethdr_crc_ofs[] = { + MIX_CRC_ODD, + MIX_CRC_EVEN, +}; + +size_t mtk_ethdr_crc_cnt(struct device *dev) +{ + struct mtk_ethdr *priv = dev_get_drvdata(dev); + + return priv->crc.cnt; +} + +u32 *mtk_ethdr_crc_entry(struct device *dev) +{ + struct mtk_ethdr *priv = dev_get_drvdata(dev); + + return priv->crc.va; +} + +void mtk_ethdr_crc_read(struct device *dev) +{ + struct mtk_ethdr *priv = dev_get_drvdata(dev); + + mtk_drm_crc_read(&priv->crc, priv->ethdr_comp[ETHDR_MIXER].regs); +} + void mtk_ethdr_register_vblank_cb(struct device *dev, void (*vblank_cb)(void *), void *vblank_cb_data) @@ -267,6 +313,13 @@ void mtk_ethdr_start(struct device *dev) struct mtk_ethdr_comp *mixer = &priv->ethdr_comp[ETHDR_MIXER]; writel(1, mixer->regs + MIX_EN); + + if (priv->crc.cnt) { + writel(MIX_TRIG_CRC_EN, mixer->regs + MIX_TRIG); +#if IS_REACHABLE(CONFIG_MTK_CMDQ) + mtk_drm_crc_cmdq_start(&priv->crc); +#endif + } } void mtk_ethdr_stop(struct device *dev) @@ -274,6 +327,9 @@ void mtk_ethdr_stop(struct device *dev) struct mtk_ethdr *priv = dev_get_drvdata(dev); struct mtk_ethdr_comp *mixer = &priv->ethdr_comp[ETHDR_MIXER]; +#if IS_REACHABLE(CONFIG_MTK_CMDQ) + mtk_drm_crc_cmdq_stop(&priv->crc); +#endif writel(0, mixer->regs + MIX_EN); writel(1, mixer->regs + MIX_RST); reset_control_reset(priv->reset_ctl); @@ -328,6 +384,10 @@ static int mtk_ethdr_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; + mtk_drm_crc_init(&priv->crc, + ethdr_crc_ofs, ARRAY_SIZE(ethdr_crc_ofs), + MIX_TRIG, MIX_TRIG_CRC_RST); + for (i = 0; i < ETHDR_ID_MAX; i++) { priv->ethdr_comp[i].dev = dev; priv->ethdr_comp[i].regs = of_iomap(dev->of_node, i); @@ -336,6 +396,16 @@ static int mtk_ethdr_probe(struct platform_device *pdev) &priv->ethdr_comp[i].cmdq_base, i); if (ret) dev_dbg(dev, "get mediatek,gce-client-reg fail!\n"); + + if (i == ETHDR_MIXER) { + if (of_property_read_u32_index(dev->of_node, + "mediatek,gce-events", i, + &priv->crc.cmdq_event)) { + dev_warn(dev, "failed to get gce-events for crc\n"); + } + priv->crc.cmdq_reg = &priv->ethdr_comp[i].cmdq_base; + mtk_drm_crc_cmdq_create(dev, &priv->crc); + } #endif dev_dbg(dev, "[DRM]regs:0x%p, node:%d\n", priv->ethdr_comp[i].regs, i); } @@ -376,6 +446,9 @@ static int mtk_ethdr_probe(struct platform_device *pdev) static int mtk_ethdr_remove(struct platform_device *pdev) { + struct mtk_ethdr *priv = dev_get_drvdata(&pdev->dev); + + mtk_drm_crc_destroy(&priv->crc); component_del(&pdev->dev, &mtk_ethdr_component_ops); return 0; } diff --git a/drivers/gpu/drm/mediatek/mtk_ethdr.h b/drivers/gpu/drm/mediatek/mtk_ethdr.h index 81af9edea3f7..d17d7256bd12 100644 --- a/drivers/gpu/drm/mediatek/mtk_ethdr.h +++ b/drivers/gpu/drm/mediatek/mtk_ethdr.h @@ -22,4 +22,9 @@ void mtk_ethdr_register_vblank_cb(struct device *dev, void mtk_ethdr_unregister_vblank_cb(struct device *dev); void mtk_ethdr_enable_vblank(struct device *dev); void mtk_ethdr_disable_vblank(struct device *dev); + +size_t mtk_ethdr_crc_cnt(struct device *dev); +u32 *mtk_ethdr_crc_entry(struct device *dev); +void mtk_ethdr_crc_read(struct device *dev); + #endif