From patchwork Thu Apr 29 04:16:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmV4LUJDIENoZW4gKOmZs+afj+i+sCk=?= X-Patchwork-Id: 12230429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 526F8C433B4 for ; Thu, 29 Apr 2021 04:17:35 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BED2661450 for ; Thu, 29 Apr 2021 04:17:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BED2661450 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yMzyzomkt94s9EKmBujBEeC4HoGvZPNxYslTCIFD8rA=; b=k+wKNVL8zhHFbC+i4NSs7Pt6E XVVOaX+LeoUNWd7X4lZQzfPTaYwA0NTTam1nE7QmOKopzLIPW/uhaQUAnhTW0s/Ft0MFQc0DrXoPO VOXOuuVyWjDTyhzjk32QFU6mjfT0qCZ1lrC5sMRkk29sbEsFEN+RM3qyXMItYGr/tezJnt9ErjQp0 AFidJocbg5jmdZgt/Uq8ri+xt0HbeB0+jUDZwF+Uf0IRPiI1qSxW75mI/JjEkCy29DbtROxOi67LE WqMrcUdgOf/KJTX+QUjb8gk6PEPwQbSZwgzklXPW3BMiIIi1xDk1Z58bOqm1SYf6ttOp6Hb7VP+b2 LDpl7v6fw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lby70-004qYs-AE; Thu, 29 Apr 2021 04:17:14 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lby6h-004qXF-Sf; Thu, 29 Apr 2021 04:16:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=Bkvd93yKu2uEmla9e30/yYGvZ0MOYFr0iUFIHbgWIfs=; b=g+RPzXC9N2VqCNOWMh0+dsPc3c lfvcs213DZwQb06Bxg+rOBCrJ1LiQLgK0RDpXy5v/F8Vze8iUE4pxuFlIQ0UHJyNGg//HoRMYRfLk /SJ79xL7GEAbzSQUk8dtkcBw0NmMF4RsA4ELPoh/2wVUjRLWu1rEGJ+VXWTlpQuWRCLfU7s6gtqwE r95eqL/I9BoYl/jvvCP4+NJ4wR/teSTeAwLqunJWZgnd/b70U/IQq+sV69l3573CT7psN6qRDGZoj eCixK//5F8CCesA8UCtSOwnzS5OOUYunvskR6vEau2BfZR+E/dGr0GciFeX+YOFEvYS0iQwSUHrgC g0SV8PqQ==; Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lby6f-000MDJ-5t; Thu, 29 Apr 2021 04:16:54 +0000 X-UUID: a3b829220ea24e7bab214ebcd03f1806-20210428 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Bkvd93yKu2uEmla9e30/yYGvZ0MOYFr0iUFIHbgWIfs=; b=ZM+Cw8xH0cF6LKlKhkzSJsIig9C+ze/htQpcUzvObwJQkyXj6IzyhlzoqEYcG6f61JIQNRkO66GWSNNye/3mfTC8FhDfAjNo6srrI3uG/lnYZCOylAu3JVDNOxIp95Evyvq53n6Q5Jcw/cNaolHWTVThknnmdN2FvF74+ENBqFQ=; X-UUID: a3b829220ea24e7bab214ebcd03f1806-20210428 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 371903399; Wed, 28 Apr 2021 21:16:50 -0700 Received: from mtkmbs05n1.mediatek.inc (172.21.101.15) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 28 Apr 2021 21:16:48 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 29 Apr 2021 12:16:47 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 29 Apr 2021 12:16:47 +0800 From: Rex-BC Chen To: , CC: , , , , , Rex-BC Chen , Jitao Shi Subject: [v3 RESEND, PATCH 1/3] drm/mediatek: dpi dual edge sample mode support Date: Thu, 29 Apr 2021 12:16:39 +0800 Message-ID: <20210429041641.11077-2-rex-bc.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210429041641.11077-1-rex-bc.chen@mediatek.com> References: <20210429041641.11077-1-rex-bc.chen@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210428_211653_233020_F62068B3 X-CRM114-Status: GOOD ( 11.26 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DPI can sample on falling, rising or both edge. When DPI sample the data both rising and falling edge. It can reduce half data io pins. Signed-off-by: Jitao Shi Signed-off-by: Rex-BC Chen --- drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index b05f900d9322..79f3e83f40ef 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -83,6 +83,7 @@ struct mtk_dpi { struct pinctrl *pinctrl; struct pinctrl_state *pins_gpio; struct pinctrl_state *pins_dpi; + bool ddr_edge_sel; int refcount; }; @@ -121,6 +122,7 @@ struct mtk_dpi_conf { unsigned int (*cal_factor)(int clock); u32 reg_h_fre_con; bool edge_sel_en; + bool dual_edge; }; static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask) @@ -380,6 +382,15 @@ static void mtk_dpi_config_color_format(struct mtk_dpi *dpi, } } +static void mtk_dpi_dual_edge(struct mtk_dpi *dpi) +{ + if (dpi->conf->dual_edge) { + mtk_dpi_mask(dpi, DPI_DDR_SETTING, DDR_EN | DDR_4PHASE, + DDR_EN | DDR_4PHASE); + mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, dpi->ddr_edge_sel ? EDGE_SEL : 0, EDGE_SEL); + } +} + static void mtk_dpi_power_off(struct mtk_dpi *dpi) { if (WARN_ON(dpi->refcount == 0)) @@ -454,7 +465,7 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, pll_rate = clk_get_rate(dpi->tvd_clk); vm.pixelclock = pll_rate / factor; - clk_set_rate(dpi->pixel_clk, vm.pixelclock); + clk_set_rate(dpi->pixel_clk, vm.pixelclock * (dpi->conf->dual_edge ? 2 : 1)); vm.pixelclock = clk_get_rate(dpi->pixel_clk); dev_dbg(dpi->dev, "Got PLL %lu Hz, pixel clock %lu Hz\n", @@ -518,6 +529,7 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, mtk_dpi_config_yc_map(dpi, dpi->yc_map); mtk_dpi_config_color_format(dpi, dpi->color_format); mtk_dpi_config_2n_h_fre(dpi); + mtk_dpi_dual_edge(dpi); mtk_dpi_config_disable_edge(dpi); mtk_dpi_sw_reset(dpi, false); From patchwork Thu Apr 29 04:16:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmV4LUJDIENoZW4gKOmZs+afj+i+sCk=?= X-Patchwork-Id: 12230425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78088C433ED for ; Thu, 29 Apr 2021 04:17:22 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 340E461453 for ; Thu, 29 Apr 2021 04:17:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 340E461453 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=iVripO5RaeX6zioRg7qk/EW8ZWlFj53/xeP67tfaRhw=; b=pugo17WyWSNDR0/Phoj+3ae65 SAZ8AL+9UY5Jo163zhK7PFxdbM7QllFRz99NR9HXzlrYtDteS7cJRkQmSxtHhhQrYXwGJ/fuLAQw+ e/ShlPckZwljhH1iRCXvZvgETjBjZqRoFcO+PWNqYNBX6FAAtS+t6kTtVnAuvLSXkvzICyTirlelH S7J5/lOH9cQJcN+6XB7jKumKjbQnN5agma3DVJXcfrJaqtMe741Oy0UdG7/KAGzMnJz+HkOnxOesr l1fU5uDD2rMAIoq9skMYZ97puv7nUNxkXEV8esxTHHS+mOB6TosxGp1RberYdqHcNMEfLGjnz3Y8j kwsh+5DZg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lby6q-004qY0-A3; Thu, 29 Apr 2021 04:17:04 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lby6i-004qXI-U0; Thu, 29 Apr 2021 04:16:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=gdbIqgi/2OFG3TkM7HUsvCi6RxrQlCjbtiuCLzRxmKs=; b=tQQiLm/AT7d2w40a71mqfcsB+O B/i1uhjGOGfFcFYVRPuh5DIms+DI1jrY2f1AQBDshYTeS6wMsJr+ZLRFNUZhHZaBQl/SQUces3ROL EAcZ0Sp1Wkakb/DhtlbuEW0NEkF6dkNw0htFwYkfrEk8Vo61UaV/vZrJ3qQrj4LW62zEf00usy1SO T0fGpQ9gl0p5e7FoV/kpri8gWKx+bknwXG4Cg5kUMXSsT6cMO6msHshqmuSthsRpD36HYo1fDZ+uu DGHLwLgdbNXIRPKno+H3ABrfmxJwXxWbOwDs9tVWgmAgEMvlYcV+9LI6Dyd7S3XyyVhmOPn/beMI1 m7R0bfgg==; Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lby6g-000MDJ-Ig; Thu, 29 Apr 2021 04:16:55 +0000 X-UUID: 37a4a30ffaa142f3b0ddc4089ceea756-20210428 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=gdbIqgi/2OFG3TkM7HUsvCi6RxrQlCjbtiuCLzRxmKs=; b=kxuPqp9SCzdTxoGtwuaux3tAog/B/Gw9lL6ETvWIS+orFkR5SuwJ0oCnwq1/9wmuAOwVGfaja6bC7EutszCPT51cGkmv+Xrsrsl9QUZ3sl2iIPa0t9+cbEOMUbDBxq7jC72cpW2iQSjJ5pQw7px+OEvNFcJvtD7itCInJct9uZk=; X-UUID: 37a4a30ffaa142f3b0ddc4089ceea756-20210428 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 118769784; Wed, 28 Apr 2021 21:16:50 -0700 Received: from mtkmbs05n2.mediatek.inc (172.21.101.140) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 28 Apr 2021 21:16:49 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 29 Apr 2021 12:16:47 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 29 Apr 2021 12:16:47 +0800 From: Rex-BC Chen To: , CC: , , , , , Rex-BC Chen , Jitao Shi Subject: [v3 RESEND, PATCH 2/3] drm/mediatek: config mt8183 driver data to support dual edge sample Date: Thu, 29 Apr 2021 12:16:40 +0800 Message-ID: <20210429041641.11077-3-rex-bc.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210429041641.11077-1-rex-bc.chen@mediatek.com> References: <20210429041641.11077-1-rex-bc.chen@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210428_211654_629000_153494A4 X-CRM114-Status: UNSURE ( 9.76 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org add dual_edge value for mt8183_conf Signed-off-by: Jitao Shi Signed-off-by: Rex-BC Chen --- drivers/gpu/drm/mediatek/mtk_dpi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 79f3e83f40ef..c548780dd3a5 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -691,6 +691,7 @@ static const struct mtk_dpi_conf mt2701_conf = { static const struct mtk_dpi_conf mt8183_conf = { .cal_factor = mt8183_calculate_factor, .reg_h_fre_con = 0xe0, + .dual_edge = true, }; static int mtk_dpi_probe(struct platform_device *pdev) From patchwork Thu Apr 29 04:16:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmV4LUJDIENoZW4gKOmZs+afj+i+sCk=?= X-Patchwork-Id: 12230427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF90FC433B4 for ; Thu, 29 Apr 2021 04:17:22 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2A4A561405 for ; Thu, 29 Apr 2021 04:17:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A4A561405 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7VCllykqoUbX3pJA6khIf5s58uHqhCpGJTuL6sS5ciI=; b=J/nPa5E1Js91SZ3ZT83mGHf6v MfojCq6ek++IN0W+yvHRqHzAwsm0JYMw4Ghgz7egbwmTugAvsby3nsT1P152JtZh//OVYDBvmVtw1 USPge/STp6bwK6dwdR9ABZOxMsuV/B5IJkUkSUTgEUt+xcolrtBCEOrgLI1KKKPyNAlhJIiizi/rr tvg/nkvkK5ZJq/NFNcyV741ycTFx5hiHH2P4G+f8FbBucGMVaLKWjidSK9odmLBiLe3fiWEib8LIN QD1szVIe1H9hkRoGJYe1NTX0v6+YP67SoS9UEjFonsBQ0CK6ZYiU9zMrNYqv9nMeRcCtmnUo47n3K BEepD0mfQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lby6w-004qYO-OD; Thu, 29 Apr 2021 04:17:11 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lby6i-004qXH-AL; Thu, 29 Apr 2021 04:16:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=/yp831CsZwTCGgWpU/xzJhqvMCXhzY++XDvDUCw18hM=; b=1FTAtT9fzpsRJsa9I+5Uh1R5Y2 n+jvNtXTWcMZaUUPAUVrzfCVTjRqc5QSYmRnm5jbGmF63r7ye8bRDIigGxRtzzFY3TIq0NrIdhjeo 9J8jHzJzyxK+uOvBpHR/92ZDoZK5jdwd19kpS6LZtOhQNegg7+yIMZ/25beLJTs+ETtvQ6BGwfNKT a8v56o+1+S3cdS2hB3owxnYEpjv1jaPiGZicxZ6vpPYSwjzd3QXXqLava5adw9BrYC0J1owBbaGqp oARPCugkzPZJx3LLT/h8Z5iF3gpgBgExml6dIQbx+h+9jrrCgy1XY8wgqeXfQo1afPJjxeJQ1/1hK 2S3K4JXQ==; Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lby6f-000MD3-N7; Thu, 29 Apr 2021 04:16:55 +0000 X-UUID: 95517bdf53434a6c908946d5c89517a2-20210428 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=/yp831CsZwTCGgWpU/xzJhqvMCXhzY++XDvDUCw18hM=; b=h96LU4txJzYT1e1bTpMdKNMoyFeb0nQTYTtlitQAFtfcQW4AC4EUBJwLWLiARghXvpQ+iDsj4T+E9XaR2jLrvDJrnS3L+yWU0zXrHWgcQfADI9VH4sER41Tg1lGeBFaq++zcSa3Fn8q6YkgAuQyPBcHygkyGiWZhqaVjUUGyyKQ=; X-UUID: 95517bdf53434a6c908946d5c89517a2-20210428 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 891157705; Wed, 28 Apr 2021 21:16:50 -0700 Received: from mtkmbs05n1.mediatek.inc (172.21.101.15) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 28 Apr 2021 21:16:49 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 29 Apr 2021 12:16:47 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 29 Apr 2021 12:16:47 +0800 From: Rex-BC Chen To: , CC: , , , , , Rex-BC Chen , Jitao Shi Subject: [v3 RESEND,PATCH 3/3] drm/mediatek: dpi: add bus format negotiation Date: Thu, 29 Apr 2021 12:16:41 +0800 Message-ID: <20210429041641.11077-4-rex-bc.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210429041641.11077-1-rex-bc.chen@mediatek.com> References: <20210429041641.11077-1-rex-bc.chen@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210428_211653_784940_0660FB96 X-CRM114-Status: GOOD ( 14.82 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Add the atomic_get_output_bus_fmts, atomic_get_input_bus_fmts to negotiate the possible output and input formats for the current mode and monitor, and use the negotiated formats in a basic atomic_check callback. Signed-off-by: Jitao Shi Signed-off-by: Rex-BC Chen --- drivers/gpu/drm/mediatek/mtk_dpi.c | 92 ++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index c548780dd3a5..8822d9448ae8 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -536,6 +536,87 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, return 0; } +#define MAX_OUTPUT_SEL_FORMATS 2 + +static u32 *mtk_dpi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + unsigned int *num_output_fmts) +{ + u32 *output_fmts; + struct mtk_dpi *dpi = bridge_to_dpi(bridge); + + *num_output_fmts = 0; + + output_fmts = kcalloc(MAX_OUTPUT_SEL_FORMATS, sizeof(*output_fmts), + GFP_KERNEL); + if (!output_fmts) + return NULL; + + /* Default 8bit RGB fallback */ + if (dpi->conf->dual_edge) { + output_fmts[0] = MEDIA_BUS_FMT_RGB888_2X12_LE; + output_fmts[1] = MEDIA_BUS_FMT_RGB888_2X12_BE; + *num_output_fmts = 2; + } else { + output_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24; + *num_output_fmts = 1; + } + + return output_fmts; +} + +#define MAX_INPUT_SEL_FORMATS 1 + +static u32 *mtk_dpi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + u32 output_fmt, + unsigned int *num_input_fmts) +{ + u32 *input_fmts; + + *num_input_fmts = 0; + + input_fmts = kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts), + GFP_KERNEL); + if (!input_fmts) + return NULL; + + *num_input_fmts = 1; + input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24; + + return input_fmts; +} + +static int mtk_dpi_bridge_atomic_check(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + struct mtk_dpi *dpi = bridge->driver_private; + unsigned int out_bus_format; + + out_bus_format = bridge_state->output_bus_cfg.format; + + dev_dbg(dpi->dev, "input format 0x%04x, output format 0x%04x\n", + bridge_state->input_bus_cfg.format, + bridge_state->output_bus_cfg.format); + + dpi->ddr_edge_sel = (out_bus_format == MEDIA_BUS_FMT_RGB888_2X12_LE) ? + true : false; + + dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS; + dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB; + dpi->yc_map = MTK_DPI_OUT_YC_MAP_RGB; + dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB; + + return 0; +} + static int mtk_dpi_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -574,6 +655,12 @@ static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = { .mode_set = mtk_dpi_bridge_mode_set, .disable = mtk_dpi_bridge_disable, .enable = mtk_dpi_bridge_enable, + .atomic_check = mtk_dpi_bridge_atomic_check, + .atomic_get_output_bus_fmts = mtk_dpi_bridge_atomic_get_output_bus_fmts, + .atomic_get_input_bus_fmts = mtk_dpi_bridge_atomic_get_input_bus_fmts, + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, }; void mtk_dpi_start(struct device *dev) @@ -620,11 +707,6 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) } drm_connector_attach_encoder(dpi->connector, &dpi->encoder); - dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS; - dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB; - dpi->yc_map = MTK_DPI_OUT_YC_MAP_RGB; - dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB; - return 0; err_cleanup: