From patchwork Mon Aug 16 19:25:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 12439113 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.4 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,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 389FDC4338F for ; Mon, 16 Aug 2021 19:27:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 EC9D060F41 for ; Mon, 16 Aug 2021 19:27:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EC9D060F41 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=nC+OO1B+G5x4GV1hXwneEsKiYBX0qvzM8h+sx0UG48Y=; b=o+VR1bqhbXTcYy N3Cs6LpVxqvr/ZeeAtkFKYSLBnVFNWuPGhHDqe+RAkHjdcUHfDFKbd2OcNw9OUE9bpdFNZ5dYT8B4 UbMS0iZ/xWncIHsq+7WJYdKUrSuPxvDg+OuCLz3X/Qr8UzdjP+lfaWJCLmXtR6KFGD5BYbF1Gco80 1hFtXro3ESSvs1QUyCGHLAyt3oFkl6JoCowv+9F0AHJTRb/PCBy78F0a/ppvSbV7voX2F5VSQx0gL lq9z7Nc/UvUBsbp1V6fxK+aj1wQTb5nRI9833vxUEtLCJnaix5U7jvCpwRstqLAF52wwWOkK5HXQB 11qvtu0FDGGL4FesK8Lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFiGQ-0008hf-57; Mon, 16 Aug 2021 19:27:14 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFiF3-0008Gr-S5 for linux-mediatek@lists.infradead.org; Mon, 16 Aug 2021 19:25:54 +0000 Received: by mail-wr1-x42e.google.com with SMTP id q10so25143230wro.2 for ; Mon, 16 Aug 2021 12:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cuwv4CvAhC05XO/EvjJwqQIYC9i7gmGCUO5hp62Mr0c=; b=CPlb/rsrvzBG23rv3SzKewzwWwNQQQzgWeP1HSmiCOTkXST7xpnMXkde39Vdx2WHW3 P7GKNsJ6Q6WqB8edC93S0hQISFDowL1PW2EoLturEvfBtbsONxNH/R04V3qPNmmMv4UX h2u5MKhV2Tj0EpfRQQW5zmvRX38eG8d5kyFZu8FIKl8z2z3Mt008e0WVf577nGhAnA0X HJ+lTJ0zJC9NbjB2N2LFYJM1g2HBX3OYIhYeHxwzGl52Rs5oluRmFFq3Kc736geWmgtE MnfDcm4Hkk73cWKgJ6BoTtRndgetz8Toe+t+aU29J3TsJdgdLUQHdYXsM+f4XbUSE3ZF lqlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cuwv4CvAhC05XO/EvjJwqQIYC9i7gmGCUO5hp62Mr0c=; b=fU4AbpDf21/Mn0jy52wu+K1Zl9SU/vecmEUkeQU96oNXLKt0kv/lHEiBuhSdSGoZvP 8XS/BhStiYzrzOIW1YOcAUZa2LZcoXaJaaIivEsKEv4Ia4XlwZdeSULBa5lH3PxCEyfv tV2X9JOYtNb2LRGw9Z4QysgHstG/DK+N6MSG7IABJrwncAS6ZHGCOL9qrBDYkYFUbGTb 4+UAQvvI9WGkGFMa9A18zDoVw7hQiCzdJFR7aNvMO+u6Eg6LR+TBM0sBPWEisN1MaoRS yNNqRPaiVKDK43quuDFGXgbUqIBbEezmCXVo0b1e3p/2nBZT9bFMo/iLW/aRTWJjlk8w ivAw== X-Gm-Message-State: AOAM532xqlIxA1ihiV4gkaN0/X/zAaElwyglblu2P5k5VYKoLoGZ/290 ZcSK7L7VJD6HCew7tuhREwwSKQ== X-Google-Smtp-Source: ABdhPJyMWlB5Xjlg2TVVeZf98LQxRuHOrhJGqrDGXl3FSZ5HPt+73twdtLFI+5rzbw89BirDZTSthQ== X-Received: by 2002:a5d:51cb:: with SMTP id n11mr38039wrv.221.1629141947284; Mon, 16 Aug 2021 12:25:47 -0700 (PDT) Received: from blmsp.lan ([2a02:2454:3e6:c900::97e]) by smtp.gmail.com with ESMTPSA id k17sm333954wmj.0.2021.08.16.12.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 12:25:47 -0700 (PDT) From: Markus Schneider-Pargmann To: Chun-Kuang Hu , Philipp Zabel Cc: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Markus Schneider-Pargmann Subject: [RFC PATCH 1/5] dt-bindings: mediatek,dpi: Add mt8195 dpintf Date: Mon, 16 Aug 2021 21:25:19 +0200 Message-Id: <20210816192523.1739365-2-msp@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816192523.1739365-1-msp@baylibre.com> References: <20210816192523.1739365-1-msp@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210816_122549_930402_4AEC7DB0 X-CRM114-Status: GOOD ( 11.30 ) 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 DP_INTF is similar to the actual dpi. They differ in some points regarding registers and what needs to be set but the function blocks itself are similar in design. Signed-off-by: Markus Schneider-Pargmann --- .../display/mediatek/mediatek,dpi.yaml | 48 ++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml b/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml index dd2896a40ff0..de4bdacd83ac 100644 --- a/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml @@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/display/mediatek/mediatek,dpi.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: mediatek DPI Controller Device Tree Bindings +title: mediatek DPI/DP_INTF Controller Device Tree Bindings maintainers: - CK Hu @@ -13,7 +13,8 @@ maintainers: description: | The Mediatek DPI function block is a sink of the display subsystem and provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a parallel - output bus. + output bus. The Mediatek DP_INTF is a similar function block that is + connected to the (embedded) display port function block. properties: compatible: @@ -23,6 +24,7 @@ properties: - mediatek,mt8173-dpi - mediatek,mt8183-dpi - mediatek,mt8192-dpi + - mediatek,mt8195-dpintf reg: maxItems: 1 @@ -37,10 +39,11 @@ properties: - description: DPI PLL clock-names: - items: - - const: pixel - - const: engine - - const: pll + description: + For dpi clocks pixel, engine and pll are required. For dpintf pixel, pll, + pll_d2, pll_d4, pll_d8, pll_d16, hf_fmm, hf_fdp are required. + minItems: 3 + maxItems: 8 pinctrl-0: true pinctrl-1: true @@ -64,6 +67,39 @@ required: - clock-names - port +allOf: + - if: + properties: + compatible: + contains: + enum: + - mediatek,mt8195-dpintf + then: + properties: + clocks: + minItems: 8 + maxItems: 8 + clock-names: + items: + - const: pixel + - const: pll + - const: pll_d2 + - const: pll_d4 + - const: pll_d8 + - const: pll_d16 + - const: hf_fmm + - const: hf_fdp + else: + properties: + clocks: + minItems: 3 + maxItems: 3 + clock-names: + items: + - const: pixel + - const: engine + - const: pll + additionalProperties: false examples: From patchwork Mon Aug 16 19:25:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 12439117 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.4 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,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 F0E6CC4338F for ; Mon, 16 Aug 2021 19:28:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A5A2F60F41 for ; Mon, 16 Aug 2021 19:28:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A5A2F60F41 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=8cwp2RSxfosu7xuPXchzuHLXoxm5z7EyJGUpqpZvmSY=; b=znCxjCve0zPlMH 73u/xVRvbjPp0VREMeziIZ/WaT0kK267FJVV2W7UtwPumnF5w9ncFL+P3QPtCy1fRys8VW3QzLBo3 umU+1RlXKuhXFnu8O5evRfsLaiKe9/8bmd/42l61/lucmlQq8p7V3srA25WDp5UHypni0d5FbaMY5 5rN+QqZfUoe9y0EdyCXjlJM4KQ82rFVu+KdzhcNWTLaepvkZv+fk2oP137Ld1Qb8NMYLnZL8eKHCX GMUaLzdsbtvLKrneZU+6N1g3q46O/sHAOsz9mIu43fClR2c9OcKYhqnZr1enedNXR8Ex0oPDtQ0bU ObyWn3RpTvf2GfD4VMMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFiHB-00090b-Ax; Mon, 16 Aug 2021 19:28:01 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFiF4-0008H1-Je for linux-mediatek@lists.infradead.org; Mon, 16 Aug 2021 19:25:56 +0000 Received: by mail-wm1-x32c.google.com with SMTP id g138so12208174wmg.4 for ; Mon, 16 Aug 2021 12:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TUblRPdvdgQ5kCSSZOYtbSz6srqmTxBHF+lOa2X1xjk=; b=IYDZRY5f9976oA4GDzm/5T8HjJfCVRHNwtmxXH+19qe1ka5gIyVufNWIvNkfapzpUl VClRY4SZwiHwoqZ9UY2wcIi6vsGJFrmhM1ifUbIFYe2efJeoda0zX8vOvD5SqTdzaQkl tQ+0wVGehcd839mqNCjdvEcqHCmybfYPa8yLpf8iGBJ1odW48P3dQ0O1cjp5iEg14wUE vRWcgWiEVZgql6OgiqZUHjvYxtKKl1FSmvTRSK/UCPYPqBzg9V7GCP7IaeG+LwP8oD0q WlHwRiMrRDELnwO0HemMLZRZy+Z2EY93lcrk4D1lE/RQHvawNe1HpZhr3qAQYLFkpS2b 4tOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TUblRPdvdgQ5kCSSZOYtbSz6srqmTxBHF+lOa2X1xjk=; b=q+ggJzqnBWkNI6vKDn86fyCJ+GIMREC1Ttv7orcKUpzqFW3kgnOeNVGivDjBsPBXK0 GerAEKfWjMhoC49zaQuPEekiOYhYMrtSD9psXyFoJBZIfR47NzEi0yc+0/LlL5XZmJCN 9B/S66FmALjoVYP8rAFfmdIgezWyQVwKlM5twvWUz+JkHMWfG1Zx6k8AI8I1M2gcH3uo 4nfW5e3HMjpJO1/5Mx2+TVmJhKof70XYH8150Q9vVCpJCTmvd28fQf3lSaIsN/eEzjA1 iL2uPhE1IHf2z6LthgA5+mQ/xy7R3HQ8KbsyWO3Mv2g9r9Gea6Q/R74Y3Mvkdbpoy33F ptDA== X-Gm-Message-State: AOAM5314ZYsRAuL5zf63oQmYWqLH1+CHUUOxZPGo8T7EB6sKaKhsVDtL Rz5EtzyOQWxRLb53wLOnCAFASg== X-Google-Smtp-Source: ABdhPJwgPFdPhcEAKj8F/XGjLPqfccpko0kf/pXxDpSont9AoxU2WADKI9PQH2Jkj/S5GItTwXQh4w== X-Received: by 2002:a05:600c:3793:: with SMTP id o19mr593926wmr.53.1629141947963; Mon, 16 Aug 2021 12:25:47 -0700 (PDT) Received: from blmsp.lan ([2a02:2454:3e6:c900::97e]) by smtp.gmail.com with ESMTPSA id k17sm333954wmj.0.2021.08.16.12.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 12:25:47 -0700 (PDT) From: Markus Schneider-Pargmann To: Chun-Kuang Hu , Philipp Zabel Cc: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Markus Schneider-Pargmann Subject: [RFC PATCH 2/5] drm/mediatek: dpi: Add dpintf support Date: Mon, 16 Aug 2021 21:25:20 +0200 Message-Id: <20210816192523.1739365-3-msp@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816192523.1739365-1-msp@baylibre.com> References: <20210816192523.1739365-1-msp@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210816_122550_791492_270117E0 X-CRM114-Status: GOOD ( 22.91 ) 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 dpintf is the displayport interface hardware unit. This unit is similar to dpi and can reuse most of the code. This patch adds support for mt8195-dpintf to this dpi driver. Main differences are: - Some features/functional components are not available for dpintf which are now excluded from code execution once is_dpintf is set - dpintf can and needs to choose between different clockdividers based on the clockspeed. This is done by choosing a different clock parent. - There are two additional clocks that need to be managed. These are only set for dpintf and will be set to NULL if not supplied. The clk_* calls handle these as normal clocks then. - Some register contents differ slightly between the two components. To work around this I added register bits/masks with a DPINTF_ prefix and use them where different. Based on a separate driver for dpintf created by Jason-JH.Lin . Signed-off-by: Markus Schneider-Pargmann --- drivers/gpu/drm/mediatek/mtk_dpi.c | 282 ++++++++++++++++++++---- drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 12 + 2 files changed, 247 insertions(+), 47 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index bced555648b0..4ad6d1fc6bde 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -63,6 +63,14 @@ enum mtk_dpi_out_color_format { MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL }; +enum mtk_dpi_tvdpll_clk { + MTK_DPI_TVDPLL_D2 = 0, + MTK_DPI_TVDPLL_D4 = 1, + MTK_DPI_TVDPLL_D8 = 2, + MTK_DPI_TVDPLL_D16 = 3, + MTK_DPI_TVDPLL_NUM_CLKS = 4 +}; + struct mtk_dpi { struct drm_encoder encoder; struct drm_bridge bridge; @@ -71,8 +79,11 @@ struct mtk_dpi { void __iomem *regs; struct device *dev; struct clk *engine_clk; + struct clk *hf_fmm_clk; + struct clk *hf_fdp_clk; struct clk *pixel_clk; struct clk *tvd_clk; + struct clk_bulk_data tvd_clks[MTK_DPI_TVDPLL_NUM_CLKS]; int irq; struct drm_display_mode mode; const struct mtk_dpi_conf *conf; @@ -125,6 +136,7 @@ struct mtk_dpi_conf { bool edge_sel_en; const u32 *output_fmts; u32 num_output_fmts; + bool is_dpintf; }; static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask) @@ -153,30 +165,52 @@ static void mtk_dpi_disable(struct mtk_dpi *dpi) static void mtk_dpi_config_hsync(struct mtk_dpi *dpi, struct mtk_dpi_sync_param *sync) { - mtk_dpi_mask(dpi, DPI_TGEN_HWIDTH, - sync->sync_width << HPW, HPW_MASK); - mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, - sync->back_porch << HBP, HBP_MASK); - mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, sync->front_porch << HFP, - HFP_MASK); + if (dpi->conf->is_dpintf) { + mtk_dpi_mask(dpi, DPI_TGEN_HWIDTH, + sync->sync_width << HPW, DPINTF_HPW_MASK); + mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, + sync->back_porch << HBP, DPINTF_HBP_MASK); + mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, sync->front_porch << HFP, + DPINTF_HFP_MASK); + } else { + mtk_dpi_mask(dpi, DPI_TGEN_HWIDTH, + sync->sync_width << HPW, HPW_MASK); + mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, + sync->back_porch << HBP, HBP_MASK); + mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, sync->front_porch << HFP, + HFP_MASK); + } } static void mtk_dpi_config_vsync(struct mtk_dpi *dpi, struct mtk_dpi_sync_param *sync, u32 width_addr, u32 porch_addr) { - mtk_dpi_mask(dpi, width_addr, - sync->sync_width << VSYNC_WIDTH_SHIFT, - VSYNC_WIDTH_MASK); mtk_dpi_mask(dpi, width_addr, sync->shift_half_line << VSYNC_HALF_LINE_SHIFT, VSYNC_HALF_LINE_MASK); - mtk_dpi_mask(dpi, porch_addr, - sync->back_porch << VSYNC_BACK_PORCH_SHIFT, - VSYNC_BACK_PORCH_MASK); - mtk_dpi_mask(dpi, porch_addr, - sync->front_porch << VSYNC_FRONT_PORCH_SHIFT, - VSYNC_FRONT_PORCH_MASK); + + if (dpi->conf->is_dpintf) { + mtk_dpi_mask(dpi, width_addr, + sync->sync_width << VSYNC_WIDTH_SHIFT, + DPINTF_VSYNC_WIDTH_MASK); + mtk_dpi_mask(dpi, porch_addr, + sync->back_porch << VSYNC_BACK_PORCH_SHIFT, + DPINTF_VSYNC_BACK_PORCH_MASK); + mtk_dpi_mask(dpi, porch_addr, + sync->front_porch << VSYNC_FRONT_PORCH_SHIFT, + DPINTF_VSYNC_FRONT_PORCH_MASK); + } else { + mtk_dpi_mask(dpi, width_addr, + sync->sync_width << VSYNC_WIDTH_SHIFT, + VSYNC_WIDTH_MASK); + mtk_dpi_mask(dpi, porch_addr, + sync->back_porch << VSYNC_BACK_PORCH_SHIFT, + VSYNC_BACK_PORCH_MASK); + mtk_dpi_mask(dpi, porch_addr, + sync->front_porch << VSYNC_FRONT_PORCH_SHIFT, + VSYNC_FRONT_PORCH_MASK); + } } static void mtk_dpi_config_vsync_lodd(struct mtk_dpi *dpi, @@ -210,13 +244,20 @@ static void mtk_dpi_config_pol(struct mtk_dpi *dpi, struct mtk_dpi_polarities *dpi_pol) { unsigned int pol; + unsigned int mask; - pol = (dpi_pol->ck_pol == MTK_DPI_POLARITY_RISING ? 0 : CK_POL) | - (dpi_pol->de_pol == MTK_DPI_POLARITY_RISING ? 0 : DE_POL) | - (dpi_pol->hsync_pol == MTK_DPI_POLARITY_RISING ? 0 : HSYNC_POL) | + mask = HSYNC_POL | VSYNC_POL; + pol = (dpi_pol->hsync_pol == MTK_DPI_POLARITY_RISING ? 0 : HSYNC_POL) | (dpi_pol->vsync_pol == MTK_DPI_POLARITY_RISING ? 0 : VSYNC_POL); - mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, pol, - CK_POL | DE_POL | HSYNC_POL | VSYNC_POL); + if (!dpi->conf->is_dpintf) { + mask |= CK_POL | DE_POL; + pol |= (dpi_pol->ck_pol == MTK_DPI_POLARITY_RISING ? + 0 : CK_POL) | + (dpi_pol->de_pol == MTK_DPI_POLARITY_RISING ? + 0 : DE_POL); + } + + mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, pol, mask); } static void mtk_dpi_config_3d(struct mtk_dpi *dpi, bool en_3d) @@ -270,8 +311,12 @@ static void mtk_dpi_config_bit_num(struct mtk_dpi *dpi, val = OUT_BIT_8; break; } - mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << OUT_BIT, - OUT_BIT_MASK); + if (dpi->conf->is_dpintf) + mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << DPINTF_OUT_BIT, + DPINTF_OUT_BIT_MASK); + else + mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << OUT_BIT, + OUT_BIT_MASK); } static void mtk_dpi_config_yc_map(struct mtk_dpi *dpi, @@ -332,12 +377,21 @@ static void mtk_dpi_config_channel_swap(struct mtk_dpi *dpi, break; } - mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << CH_SWAP, CH_SWAP_MASK); + if (dpi->conf->is_dpintf) + mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << DPINTF_CH_SWAP, + DPINTF_CH_SWAP_MASK); + else + mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << CH_SWAP, + CH_SWAP_MASK); } static void mtk_dpi_config_yuv422_enable(struct mtk_dpi *dpi, bool enable) { - mtk_dpi_mask(dpi, DPI_CON, enable ? YUV422_EN : 0, YUV422_EN); + if (dpi->conf->is_dpintf) + mtk_dpi_mask(dpi, DPI_CON, enable ? DPINTF_YUV422_EN : 0, + DPINTF_YUV422_EN); + else + mtk_dpi_mask(dpi, DPI_CON, enable ? YUV422_EN : 0, YUV422_EN); } static void mtk_dpi_config_csc_enable(struct mtk_dpi *dpi, bool enable) @@ -367,19 +421,25 @@ static void mtk_dpi_config_color_format(struct mtk_dpi *dpi, if ((format == MTK_DPI_COLOR_FORMAT_YCBCR_444) || (format == MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL)) { mtk_dpi_config_yuv422_enable(dpi, false); - mtk_dpi_config_csc_enable(dpi, true); - mtk_dpi_config_swap_input(dpi, false); + if (!dpi->conf->is_dpintf) { + mtk_dpi_config_csc_enable(dpi, true); + mtk_dpi_config_swap_input(dpi, false); + } mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_BGR); } else if ((format == MTK_DPI_COLOR_FORMAT_YCBCR_422) || (format == MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL)) { mtk_dpi_config_yuv422_enable(dpi, true); - mtk_dpi_config_csc_enable(dpi, true); - mtk_dpi_config_swap_input(dpi, true); + if (!dpi->conf->is_dpintf) { + mtk_dpi_config_csc_enable(dpi, true); + mtk_dpi_config_swap_input(dpi, true); + } mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_RGB); } else { mtk_dpi_config_yuv422_enable(dpi, false); - mtk_dpi_config_csc_enable(dpi, false); - mtk_dpi_config_swap_input(dpi, false); + if (!dpi->conf->is_dpintf) { + mtk_dpi_config_csc_enable(dpi, false); + mtk_dpi_config_swap_input(dpi, false); + } mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_RGB); } } @@ -410,8 +470,10 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi) pinctrl_select_state(dpi->pinctrl, dpi->pins_gpio); mtk_dpi_disable(dpi); - clk_disable_unprepare(dpi->pixel_clk); clk_disable_unprepare(dpi->engine_clk); + clk_disable_unprepare(dpi->hf_fdp_clk); + clk_disable_unprepare(dpi->hf_fmm_clk); + clk_disable_unprepare(dpi->pixel_clk); } static int mtk_dpi_power_on(struct mtk_dpi *dpi) @@ -433,12 +495,28 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) goto err_pixel; } + ret = clk_prepare_enable(dpi->hf_fmm_clk); + if (ret) { + dev_err(dpi->dev, "Failed to enable hf_fmm clock: %d\n", ret); + goto err_hf_fmm; + } + + ret = clk_prepare_enable(dpi->hf_fdp_clk); + if (ret) { + dev_err(dpi->dev, "Failed to enable hf_fdp clock: %d\n", ret); + goto err_hf_fdp; + } + if (dpi->pinctrl && dpi->pins_dpi) pinctrl_select_state(dpi->pinctrl, dpi->pins_dpi); mtk_dpi_enable(dpi); return 0; +err_hf_fdp: + clk_disable_unprepare(dpi->hf_fmm_clk); +err_hf_fmm: + clk_disable_unprepare(dpi->pixel_clk); err_pixel: clk_disable_unprepare(dpi->engine_clk); err_refcount: @@ -446,6 +524,31 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) return ret; } +static void mtk_dpi_set_pixel_clk_parent(struct mtk_dpi *dpi, + unsigned int factor) +{ + struct clk *new_parent; + + switch (factor) { + case 16: + new_parent = dpi->tvd_clks[MTK_DPI_TVDPLL_D16].clk; + break; + case 8: + new_parent = dpi->tvd_clks[MTK_DPI_TVDPLL_D8].clk; + break; + case 4: + new_parent = dpi->tvd_clks[MTK_DPI_TVDPLL_D4].clk; + break; + case 2: + new_parent = dpi->tvd_clks[MTK_DPI_TVDPLL_D2].clk; + break; + default: + new_parent = NULL; + } + if (new_parent) + clk_set_parent(dpi->pixel_clk, new_parent); +} + static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, struct drm_display_mode *mode) { @@ -465,6 +568,8 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, drm_display_mode_to_videomode(mode, &vm); pll_rate = vm.pixelclock * factor; + mtk_dpi_set_pixel_clk_parent(dpi, factor); + dev_dbg(dpi->dev, "Want PLL %lu Hz, pixel clock %lu Hz\n", pll_rate, vm.pixelclock); @@ -484,10 +589,17 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, dev_dbg(dpi->dev, "Got PLL %lu Hz, pixel clock %lu Hz\n", pll_rate, vm.pixelclock); - limit.c_bottom = 0x0010; - limit.c_top = 0x0FE0; - limit.y_bottom = 0x0010; - limit.y_top = 0x0FE0; + if (dpi->conf->is_dpintf) { + limit.c_bottom = 0x0000; + limit.c_top = 0xFFF; + limit.y_bottom = 0x0000; + limit.y_top = 0xFFF; + } else { + limit.c_bottom = 0x0010; + limit.c_top = 0x0FE0; + limit.y_bottom = 0x0010; + limit.y_top = 0x0FE0; + } dpi_pol.ck_pol = MTK_DPI_POLARITY_FALLING; dpi_pol.de_pol = MTK_DPI_POLARITY_RISING; @@ -495,6 +607,7 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, MTK_DPI_POLARITY_FALLING : MTK_DPI_POLARITY_RISING; dpi_pol.vsync_pol = vm.flags & DISPLAY_FLAGS_VSYNC_HIGH ? MTK_DPI_POLARITY_FALLING : MTK_DPI_POLARITY_RISING; + // TODO(scosu): dpintf divides these 3 values by 4 hsync.sync_width = vm.hsync_len; hsync.back_porch = vm.hback_porch; hsync.front_porch = vm.hfront_porch; @@ -539,12 +652,17 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, mtk_dpi_config_channel_limit(dpi, &limit); mtk_dpi_config_bit_num(dpi, dpi->bit_num); mtk_dpi_config_channel_swap(dpi, dpi->channel_swap); - 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); + if (dpi->conf->is_dpintf) { + mtk_dpi_mask(dpi, DPI_CON, DPINTF_INPUT_2P_EN, + DPINTF_INPUT_2P_EN); + } else { + mtk_dpi_config_yc_map(dpi, dpi->yc_map); + mtk_dpi_config_2n_h_fre(dpi); + mtk_dpi_dual_edge(dpi); + mtk_dpi_config_disable_edge(dpi); + mtk_dpi_sw_reset(dpi, false); + } return 0; } @@ -683,6 +801,14 @@ static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = { .atomic_reset = drm_atomic_helper_bridge_reset, }; +static const struct drm_bridge_funcs mtk_dpintf_bridge_funcs = { + .attach = mtk_dpi_bridge_attach, + .mode_set = mtk_dpi_bridge_mode_set, + .disable = mtk_dpi_bridge_disable, + .enable = mtk_dpi_bridge_enable, + .atomic_check = mtk_dpi_bridge_atomic_check, +}; + void mtk_dpi_start(struct device *dev) { struct mtk_dpi *dpi = dev_get_drvdata(dev); @@ -779,6 +905,16 @@ static unsigned int mt8183_calculate_factor(int clock) return 2; } +static unsigned int mt8195_dpintf_calculate_factor(int clock) +{ + if (clock < 70000) + return 16; + else if (clock < 200000) + return 8; + else + return 4; +} + static const u32 mt8173_output_fmts[] = { MEDIA_BUS_FMT_RGB888_1X24, }; @@ -794,6 +930,7 @@ static const struct mtk_dpi_conf mt8173_conf = { .max_clock_khz = 300000, .output_fmts = mt8173_output_fmts, .num_output_fmts = ARRAY_SIZE(mt8173_output_fmts), + .is_dpintf = false, }; static const struct mtk_dpi_conf mt2701_conf = { @@ -803,6 +940,7 @@ static const struct mtk_dpi_conf mt2701_conf = { .max_clock_khz = 150000, .output_fmts = mt8173_output_fmts, .num_output_fmts = ARRAY_SIZE(mt8173_output_fmts), + .is_dpintf = false, }; static const struct mtk_dpi_conf mt8183_conf = { @@ -811,6 +949,7 @@ static const struct mtk_dpi_conf mt8183_conf = { .max_clock_khz = 100000, .output_fmts = mt8183_output_fmts, .num_output_fmts = ARRAY_SIZE(mt8183_output_fmts), + .is_dpintf = false, }; static const struct mtk_dpi_conf mt8192_conf = { @@ -819,6 +958,12 @@ static const struct mtk_dpi_conf mt8192_conf = { .max_clock_khz = 150000, .output_fmts = mt8173_output_fmts, .num_output_fmts = ARRAY_SIZE(mt8173_output_fmts), + .is_dpintf = false, +}; + +static const struct mtk_dpi_conf mt8195_dpintf_conf = { + .cal_factor = mt8195_dpintf_calculate_factor, + .is_dpintf = true, }; static int mtk_dpi_probe(struct platform_device *pdev) @@ -864,13 +1009,16 @@ static int mtk_dpi_probe(struct platform_device *pdev) return ret; } - dpi->engine_clk = devm_clk_get(dev, "engine"); - if (IS_ERR(dpi->engine_clk)) { - ret = PTR_ERR(dpi->engine_clk); - if (ret != -EPROBE_DEFER) - dev_err(dev, "Failed to get engine clock: %d\n", ret); + if (!dpi->conf->is_dpintf) { + dpi->engine_clk = devm_clk_get(dev, "engine"); + if (IS_ERR(dpi->engine_clk)) { + ret = PTR_ERR(dpi->engine_clk); + if (ret != -EPROBE_DEFER) + dev_err(dev, "Failed to get engine clock: %d\n", + ret); - return ret; + return ret; + } } dpi->pixel_clk = devm_clk_get(dev, "pixel"); @@ -891,6 +1039,40 @@ static int mtk_dpi_probe(struct platform_device *pdev) return ret; } + dpi->hf_fmm_clk = devm_clk_get_optional(dev, "hf_fmm"); + if (IS_ERR(dpi->hf_fmm_clk)) { + ret = PTR_ERR(dpi->hf_fmm_clk); + if (ret != -EPROBE_DEFER) + dev_err(dev, "Failed to get hf_fmm clock: %d\n", ret); + + return ret; + } + + dpi->hf_fdp_clk = devm_clk_get_optional(dev, "hf_fdp"); + if (IS_ERR(dpi->hf_fdp_clk)) { + ret = PTR_ERR(dpi->hf_fdp_clk); + if (ret != -EPROBE_DEFER) + dev_err(dev, "Failed to get hf_fdp clock: %d\n", ret); + + return ret; + } + + if (dpi->conf->is_dpintf) { + dpi->tvd_clks[MTK_DPI_TVDPLL_D2].id = "pll_d2"; + dpi->tvd_clks[MTK_DPI_TVDPLL_D4].id = "pll_d4"; + dpi->tvd_clks[MTK_DPI_TVDPLL_D8].id = "pll_d8"; + dpi->tvd_clks[MTK_DPI_TVDPLL_D16].id = "pll_d16"; + ret = devm_clk_bulk_get_optional(dev, MTK_DPI_TVDPLL_NUM_CLKS, + dpi->tvd_clks); + if (ret) { + if (ret != -EPROBE_DEFER) + dev_err(dev, + "Failed to get optional tvdpll divider clock: %d\n", + ret); + return ret; + } + } + dpi->irq = platform_get_irq(pdev, 0); if (dpi->irq <= 0) return -EINVAL; @@ -904,7 +1086,10 @@ static int mtk_dpi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dpi); - dpi->bridge.funcs = &mtk_dpi_bridge_funcs; + if (dpi->conf->is_dpintf) + dpi->bridge.funcs = &mtk_dpintf_bridge_funcs; + else + dpi->bridge.funcs = &mtk_dpi_bridge_funcs; dpi->bridge.of_node = dev->of_node; dpi->bridge.type = DRM_MODE_CONNECTOR_DPI; @@ -943,6 +1128,9 @@ static const struct of_device_id mtk_dpi_of_ids[] = { { .compatible = "mediatek,mt8192-dpi", .data = &mt8192_conf, }, + { .compatible = "mediatek,mt8195-dpintf", + .data = &mt8195_dpintf_conf, + }, { }, }; MODULE_DEVICE_TABLE(of, mtk_dpi_of_ids); diff --git a/drivers/gpu/drm/mediatek/mtk_dpi_regs.h b/drivers/gpu/drm/mediatek/mtk_dpi_regs.h index 3a02fabe1662..c7489be5c713 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi_regs.h +++ b/drivers/gpu/drm/mediatek/mtk_dpi_regs.h @@ -40,10 +40,14 @@ #define FAKE_DE_LEVEN BIT(21) #define FAKE_DE_RODD BIT(22) #define FAKE_DE_REVEN BIT(23) +#define DPINTF_YUV422_EN BIT(24) +#define DPINTF_INPUT_2P_EN BIT(29) #define DPI_OUTPUT_SETTING 0x14 #define CH_SWAP 0 +#define DPINTF_CH_SWAP BIT(1) #define CH_SWAP_MASK (0x7 << 0) +#define DPINTF_CH_SWAP_MASK (0x7 << 1) #define SWAP_RGB 0x00 #define SWAP_GBR 0x01 #define SWAP_BRG 0x02 @@ -64,7 +68,9 @@ #define OEN_OFF BIT(16) #define EDGE_SEL BIT(17) #define OUT_BIT 18 +#define DPINTF_OUT_BIT 16 #define OUT_BIT_MASK (0x3 << 18) +#define DPINTF_OUT_BIT_MASK (0x3 << 16) #define OUT_BIT_8 0x00 #define OUT_BIT_10 0x01 #define OUT_BIT_12 0x02 @@ -93,24 +99,30 @@ #define DPI_TGEN_HWIDTH 0x20 #define HPW 0 #define HPW_MASK (0xFFF << 0) +#define DPINTF_HPW_MASK (0xFFFF << 0) #define DPI_TGEN_HPORCH 0x24 #define HBP 0 #define HBP_MASK (0xFFF << 0) +#define DPINTF_HBP_MASK (0xFFFF << 0) #define HFP 16 #define HFP_MASK (0xFFF << 16) +#define DPINTF_HFP_MASK (0xFFFF << 16) #define DPI_TGEN_VWIDTH 0x28 #define DPI_TGEN_VPORCH 0x2C #define VSYNC_WIDTH_SHIFT 0 #define VSYNC_WIDTH_MASK (0xFFF << 0) +#define DPINTF_VSYNC_WIDTH_MASK (0xFFFF << 0) #define VSYNC_HALF_LINE_SHIFT 16 #define VSYNC_HALF_LINE_MASK BIT(16) #define VSYNC_BACK_PORCH_SHIFT 0 #define VSYNC_BACK_PORCH_MASK (0xFFF << 0) +#define DPINTF_VSYNC_BACK_PORCH_MASK (0xFFFF << 0) #define VSYNC_FRONT_PORCH_SHIFT 16 #define VSYNC_FRONT_PORCH_MASK (0xFFF << 16) +#define DPINTF_VSYNC_FRONT_PORCH_MASK (0xFFFF << 16) #define DPI_BG_HCNTL 0x30 #define BG_RIGHT (0x1FFF << 0) From patchwork Mon Aug 16 19:25:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 12439111 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.4 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,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 50620C432BE for ; Mon, 16 Aug 2021 19:26:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 0F87060E76 for ; Mon, 16 Aug 2021 19:26:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0F87060E76 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=Gm6s8Sjn9tBu1DcMHtoyzO1Q+zgAIcr1ADSSr+n+ZkY=; b=R0DQid6VMke24C YNaGNGXWLnrqppWT3JEmD4VeozTWhOI0dNapGpQktaXcHY2Na1u/rLOBYf6A4uJyd8Mmtj7sIj1SZ A961ghrcM03dm7Ggb7PI39DY8XDVW8dIH7ULOczOEvZShy5KO7cg4bCuRS8rfeL826P+wYcar7UAh Y4gQVjVOKvHgr8AKAb5zozhgh78htNTKudG057xvJHR1UolcrPPlePexrs+jX+yDzfxEsh/Zm0/e1 FXjo4+479YaGdr4dbVabdgVrPtZ4jfCB2TzNOjQ5VJ22wECGEmWmzfhnEfVMk/3Kb+qBFd1Mo7GM2 9AfGzzJM+cFPwAlKJ/tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFiFm-0008Ui-5O; Mon, 16 Aug 2021 19:26:34 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFiF3-0008HI-Oa for linux-mediatek@lists.infradead.org; Mon, 16 Aug 2021 19:25:53 +0000 Received: by mail-wr1-x42b.google.com with SMTP id x12so25079195wrr.11 for ; Mon, 16 Aug 2021 12:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5GQZcK6R0BkYHGP9eubs/dRk+ABz3Z6fvnc3XZsSEy8=; b=qswMkmAu9bvSVVAU5bWeCnVdJT1Xtnk8Vj9Ey3kptbC3XhmPW77Dfm1zVC9qm7vHsb cFWqnPtkV3X9dss5MkTxth9Jnb/vLDe3gFa0vGkJV3EkXh4JcTzyvD7Qv8J1nnWU0lcL julwMf+kHajNnxxAXdqK3J3dilfUlCqiJk9aOjOOlF9Pc4N6NwTNhsPBjeEJjK7pHniJ QLWRQMSWHGMKRLRs7M+ObckE0hKA7BVvdLeHiR/tf/D9BRdMYHD9qSTg0ZUwxzNe5PPd cBPPx1BwQ3rSLM6Rcka0MVtjYjKFgN2DLq0zaykYxaAvCYGtClsXkrwQdjOZ7wZd0av/ uDPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5GQZcK6R0BkYHGP9eubs/dRk+ABz3Z6fvnc3XZsSEy8=; b=A45omIgKK0ATJSl2zlWvu7Uo01i2sC/ljBGvV/hFWAn5h5OPCdCWtKX7ua9Kmd6AON SH7OZjCHL+B5hnCozmKO+fRbIMrnks+iylCsDoLHP2XWp3j1LUQgu0ir1NpmEVbW7iWK GwiypT18mDb8coSoQidWucbqxuiPeEke3xYoIF1yZE9W/hyvF5Ucfa/C5uIrvFjn+FD+ vWZmEdihkD4N7iKdz7TuOyOMH2qruj34luy4nz9cnnzH5Vl/GxUACd0Jj6TlKYtXwxTR NXnlrT9mRLi69FyFa9Zke/NxwvbialHCNQYL67q2O2oe6X7FV+aq/xkMp57trYBFKs3U xZjA== X-Gm-Message-State: AOAM532s96Zoy5sKr3TBxeut06+SbeZJ1x/29Y6tmuP4R/wGWzYEZ70t sUak7eN8NF4r870LweI0oznXUA== X-Google-Smtp-Source: ABdhPJwITFVfElVNGgxJw2RutXnkGSR5NyNK8EdadYD0hJjotYhAoS2uhBbK/P2u4IKKms4iL/Ne9w== X-Received: by 2002:a5d:49c5:: with SMTP id t5mr45265wrs.161.1629141948597; Mon, 16 Aug 2021 12:25:48 -0700 (PDT) Received: from blmsp.lan ([2a02:2454:3e6:c900::97e]) by smtp.gmail.com with ESMTPSA id k17sm333954wmj.0.2021.08.16.12.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 12:25:48 -0700 (PDT) From: Markus Schneider-Pargmann To: Chun-Kuang Hu , Philipp Zabel Cc: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Markus Schneider-Pargmann Subject: [RFC PATCH 3/5] drm/edid: Add cea_sad helpers for freq/length Date: Mon, 16 Aug 2021 21:25:21 +0200 Message-Id: <20210816192523.1739365-4-msp@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816192523.1739365-1-msp@baylibre.com> References: <20210816192523.1739365-1-msp@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210816_122549_850636_DD8EF306 X-CRM114-Status: GOOD ( 13.23 ) 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 This patch adds two helper functions that extract the frequency and word length from a struct cea_sad. For these helper functions new defines are added that help translate the 'freq' and 'byte2' fields into real numbers. Signed-off-by: Markus Schneider-Pargmann --- drivers/gpu/drm/drm_edid.c | 57 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 18 ++++++++++-- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 81d5f2524246..2389d34ce10e 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -4666,6 +4666,63 @@ int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb) } EXPORT_SYMBOL(drm_edid_to_speaker_allocation); +/** + * drm_cea_sad_get_sample_rate - Extract the sample rate from cea_sad + * @sad: Pointer to the cea_sad struct + * + * Extracts the cea_sad frequency field and returns the sample rate in Hz. + * + * Return: Sample rate in Hz or a negative errno if parsing failed. + */ +int drm_cea_sad_get_sample_rate(struct cea_sad *sad) +{ + switch (sad->freq) { + case CEA_SAD_FREQ_32KHZ: + return 32000; + case CEA_SAD_FREQ_44KHZ: + return 44100; + case CEA_SAD_FREQ_48KHZ: + return 48000; + case CEA_SAD_FREQ_88KHZ: + return 88200; + case CEA_SAD_FREQ_96KHZ: + return 96000; + case CEA_SAD_FREQ_176KHZ: + return 176400; + case CEA_SAD_FREQ_192KHZ: + return 192000; + default: + return -EINVAL; + } +} +EXPORT_SYMBOL(drm_cea_sad_get_sample_rate); + +/** + * drm_cea_sad_get_uncompressed_word_length - Extract word length + * @sad: Pointer to the cea_sad struct + * + * Extracts the cea_sad byte2 field and returns the word length for an + * uncompressed stream. + * + * Note: This function may only be called for uncompressed audio. + * + * Return: Word length in bits or a negative errno if parsing failed. + */ +int drm_cea_sad_get_uncompressed_word_length(struct cea_sad *sad) +{ + switch (sad->byte2) { + case CEA_SAD_UNCOMPRESSED_WORD_16BIT: + return 16; + case CEA_SAD_UNCOMPRESSED_WORD_20BIT: + return 20; + case CEA_SAD_UNCOMPRESSED_WORD_24BIT: + return 24; + default: + return -EINVAL; + } +} +EXPORT_SYMBOL(drm_cea_sad_get_uncompressed_word_length); + /** * drm_av_sync_delay - compute the HDMI/DP sink audio-video sync delay * @connector: connector associated with the HDMI/DP sink diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 759328a5eeb2..bed091a749ef 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -361,12 +361,24 @@ struct edid { /* Short Audio Descriptor */ struct cea_sad { - u8 format; + u8 format; /* See HDMI_AUDIO_CODING_TYPE_* */ u8 channels; /* max number of channels - 1 */ - u8 freq; + u8 freq; /* See CEA_SAD_FREQ_* */ u8 byte2; /* meaning depends on format */ }; +#define CEA_SAD_FREQ_32KHZ BIT(0) +#define CEA_SAD_FREQ_44KHZ BIT(1) +#define CEA_SAD_FREQ_48KHZ BIT(2) +#define CEA_SAD_FREQ_88KHZ BIT(3) +#define CEA_SAD_FREQ_96KHZ BIT(4) +#define CEA_SAD_FREQ_176KHZ BIT(5) +#define CEA_SAD_FREQ_192KHZ BIT(6) + +#define CEA_SAD_UNCOMPRESSED_WORD_16BIT BIT(0) +#define CEA_SAD_UNCOMPRESSED_WORD_20BIT BIT(1) +#define CEA_SAD_UNCOMPRESSED_WORD_24BIT BIT(2) + struct drm_encoder; struct drm_connector; struct drm_connector_state; @@ -374,6 +386,8 @@ struct drm_display_mode; int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads); int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb); +int drm_cea_sad_get_sample_rate(struct cea_sad *sad); +int drm_cea_sad_get_uncompressed_word_length(struct cea_sad *sad); int drm_av_sync_delay(struct drm_connector *connector, const struct drm_display_mode *mode); From patchwork Mon Aug 16 19:25:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 12439115 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.4 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,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 22377C432BE for ; Mon, 16 Aug 2021 19:27:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 DD09D60E76 for ; Mon, 16 Aug 2021 19:27:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DD09D60E76 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=qzS79HQTgxeDADkRZ0rA7K0/J+OhMWblzuLYGTcjGvo=; b=Dv2pODrDVSDG5G IXsd5F6SjJmYP3MyRvgJbVuCCN2jCrUFUuPP8LR4U+8qrjzAoyin+xsjxtnOqJOSjWqz46TlGFflA U/vmdEHqNB67HHfLv05rEWQfis8luu1GDhAlLKfbCYGPTLQ7dkW9t1eIzxRpy5l0WFJOW/4jybnbs Sn1r11X0ifFGFOk3zOvAqur2zkI66FMo+YrQwrvBLziwK7G2cAzoY/evG6j+Ahy1TUa5c5Gfw7i5P tlCEbq9f3hzWzPhxpNpjjAwS9rkQnc3U2KxtHgSUuJIQ8+4cRv8d6/Y56svbAo7o7fzVaIOWv2xuG 7JJJXOUllvQ96p1m52dw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFiGS-0008iZ-I4; Mon, 16 Aug 2021 19:27:16 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFiF5-0008I2-Rx for linux-mediatek@lists.infradead.org; Mon, 16 Aug 2021 19:25:55 +0000 Received: by mail-wr1-x435.google.com with SMTP id q10so25143341wro.2 for ; Mon, 16 Aug 2021 12:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y5VYmJK3EyqmfhH+BfVMGjh2lMBLY0y87vkPhxmR1fE=; b=Q6VilRTJlXhBTxPwoxK0Dv6DqfrBAtJL/FQWBA78STpBnt892iVD2I/4oC5EvbL7iO /EBI9dILWaFxitg2X4FoRtlhvWiH35duYafUVCmLNOQPfu9GKSIyg7pQ4HgE1s5hyfLa xVWhhE5UmwzcQbd7WnsDSYZORLXPAELB6UoxxR/XHGRNeMf24mvRwBu7hX6zJTetqKWS IE574Y9osIfJpTu4IwEsskjji0q9yhVcb0XuJ23r12L6GMcL+tXsWTa8UXTNBzh3l/42 Pef5Jx3jW/I2eHHo072AFPHJOhCO70UZBUfiIhnmas4IA9UUYAQyeq26gv7RSoRLW3rp fN0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y5VYmJK3EyqmfhH+BfVMGjh2lMBLY0y87vkPhxmR1fE=; b=t9oCSFds46RlSQ9u4CjDnE6mquiIANuVENK6WZxTehXdegS5ZIqV2ovmFl3YPo9x3a JcfqeOkQQVtzjQaehKoi2dJf39y6rd3iKWRndcdgCZOeuKCQaELKqqgFHQQlHAiu4Cm/ lGDwsVyBMIEx7fu/3HgJJPsBM8pcdMsNYqg/HXvaDcZ8pmJ/mhDZj0x3vUb9s/c1pnRH wOSCxC27PmJNDzDqWaX9mgQ8nQRBSuPsZjACN6p6nK9C6IHWymv0+QBLUnEJgqbGqO6I ZnqNlcocPgAJwTwq8Auxn8RxoBLixqn70iqiEHBPTqssppRrO7Esq0MERFzl+QLFwCui m5aQ== X-Gm-Message-State: AOAM531N8R5Qxhnc92I8GBqI/b9hSke2jSfm1yhrPJOYUpt+9L34AAwR 6NkAKGIRtw9sXvzLbHpb0IXnBw== X-Google-Smtp-Source: ABdhPJz2kJKg6ucKnNqvzzNTIcKiPTrBAqNLCYGOzzpwmHkdMqYF9+ht7vmA5ZoTxLxeU2TuNJINGQ== X-Received: by 2002:adf:ffcb:: with SMTP id x11mr82146wrs.158.1629141949201; Mon, 16 Aug 2021 12:25:49 -0700 (PDT) Received: from blmsp.lan ([2a02:2454:3e6:c900::97e]) by smtp.gmail.com with ESMTPSA id k17sm333954wmj.0.2021.08.16.12.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 12:25:48 -0700 (PDT) From: Markus Schneider-Pargmann To: Chun-Kuang Hu , Philipp Zabel Cc: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Markus Schneider-Pargmann Subject: [RFC PATCH 4/5] video/hdmi: Add audio_infoframe packing for DP Date: Mon, 16 Aug 2021 21:25:22 +0200 Message-Id: <20210816192523.1739365-5-msp@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816192523.1739365-1-msp@baylibre.com> References: <20210816192523.1739365-1-msp@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210816_122551_979640_0BA90345 X-CRM114-Status: GOOD ( 16.38 ) 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 Similar to HDMI, DP uses audio infoframes as well which are structured very similar to the HDMI ones. This patch adds a helper function to pack the HDMI audio infoframe for DP, called hdmi_audio_infoframe_pack_for_dp(). hdmi_audio_infoframe_pack_only() is split into two parts. One of them packs the payload only and can be used for HDMI and DP. Signed-off-by: Markus Schneider-Pargmann --- drivers/video/hdmi.c | 87 +++++++++++++++++++++++++++++++++++--------- include/linux/hdmi.h | 4 ++ 2 files changed, 73 insertions(+), 18 deletions(-) diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c index 947be761dfa4..59c4341549e4 100644 --- a/drivers/video/hdmi.c +++ b/drivers/video/hdmi.c @@ -387,6 +387,28 @@ int hdmi_audio_infoframe_check(struct hdmi_audio_infoframe *frame) } EXPORT_SYMBOL(hdmi_audio_infoframe_check); +static void +hdmi_audio_infoframe_pack_payload(const struct hdmi_audio_infoframe *frame, + u8 *buffer) +{ + u8 channels; + + if (frame->channels >= 2) + channels = frame->channels - 1; + else + channels = 0; + + buffer[0] = ((frame->coding_type & 0xf) << 4) | (channels & 0x7); + buffer[1] = ((frame->sample_frequency & 0x7) << 2) | + (frame->sample_size & 0x3); + buffer[2] = frame->coding_type_ext & 0x1f; + buffer[3] = frame->channel_allocation; + buffer[4] = (frame->level_shift_value & 0xf) << 3; + + if (frame->downmix_inhibit) + buffer[4] |= BIT(7); +} + /** * hdmi_audio_infoframe_pack_only() - write HDMI audio infoframe to binary buffer * @frame: HDMI audio infoframe @@ -404,7 +426,6 @@ EXPORT_SYMBOL(hdmi_audio_infoframe_check); ssize_t hdmi_audio_infoframe_pack_only(const struct hdmi_audio_infoframe *frame, void *buffer, size_t size) { - unsigned char channels; u8 *ptr = buffer; size_t length; int ret; @@ -420,28 +441,13 @@ ssize_t hdmi_audio_infoframe_pack_only(const struct hdmi_audio_infoframe *frame, memset(buffer, 0, size); - if (frame->channels >= 2) - channels = frame->channels - 1; - else - channels = 0; - ptr[0] = frame->type; ptr[1] = frame->version; ptr[2] = frame->length; ptr[3] = 0; /* checksum */ - /* start infoframe payload */ - ptr += HDMI_INFOFRAME_HEADER_SIZE; - - ptr[0] = ((frame->coding_type & 0xf) << 4) | (channels & 0x7); - ptr[1] = ((frame->sample_frequency & 0x7) << 2) | - (frame->sample_size & 0x3); - ptr[2] = frame->coding_type_ext & 0x1f; - ptr[3] = frame->channel_allocation; - ptr[4] = (frame->level_shift_value & 0xf) << 3; - - if (frame->downmix_inhibit) - ptr[4] |= BIT(7); + hdmi_audio_infoframe_pack_payload(frame, + ptr + HDMI_INFOFRAME_HEADER_SIZE); hdmi_infoframe_set_checksum(buffer, length); @@ -479,6 +485,51 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, } EXPORT_SYMBOL(hdmi_audio_infoframe_pack); +/** + * hdmi_audio_infoframe_pack_for_dp - Pack a HDMI Audio infoframe for + * displayport + * + * @frame HDMI Audio infoframe + * @header Header buffer to be used + * @header_size Size of header buffer + * @data Data buffer to be used + * @data_size Size of data buffer + * @dp_version Display Port version to be encoded in the header + * + * Packs a HDMI Audio Infoframe to be sent over Display Port. This function + * fills both header and data buffer with the required data. + * + * Return: Number of total written bytes or a negative errno on failure. + */ +ssize_t hdmi_audio_infoframe_pack_for_dp(struct hdmi_audio_infoframe *frame, + void *header, size_t header_size, + void *data, size_t data_size, + u8 dp_version) +{ + int ret; + u8 *hdr_ptr = header; + + ret = hdmi_audio_infoframe_check(frame); + if (ret) + return ret; + + if (header_size < 4 || data_size < frame->length) + return -ENOSPC; + + memset(header, 0, header_size); + memset(data, 0, data_size); + + // Secondary-data packet header + hdr_ptr[1] = frame->type; + hdr_ptr[2] = 0x1B; // As documented by DP spec for Secondary-data Packets + hdr_ptr[3] = (dp_version & 0x3f) << 2; + + hdmi_audio_infoframe_pack_payload(frame, data); + + return frame->length + 4; +} +EXPORT_SYMBOL(hdmi_audio_infoframe_pack_for_dp); + /** * hdmi_vendor_infoframe_init() - initialize an HDMI vendor infoframe * @frame: HDMI vendor infoframe diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h index c8ec982ff498..f576a0b08c85 100644 --- a/include/linux/hdmi.h +++ b/include/linux/hdmi.h @@ -334,6 +334,10 @@ struct hdmi_audio_infoframe { int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame); ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, void *buffer, size_t size); +ssize_t hdmi_audio_infoframe_pack_for_dp(struct hdmi_audio_infoframe *frame, + void *header, size_t header_size, + void *data, size_t data_size, + u8 dp_version); ssize_t hdmi_audio_infoframe_pack_only(const struct hdmi_audio_infoframe *frame, void *buffer, size_t size); int hdmi_audio_infoframe_check(struct hdmi_audio_infoframe *frame); From patchwork Mon Aug 16 19:25:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 12439119 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.4 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,UPPERCASE_50_75, 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 211C2C4338F for ; Mon, 16 Aug 2021 19:29:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 AB92D60E76 for ; Mon, 16 Aug 2021 19:29:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AB92D60E76 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=gZzn1YcztgDKC4e0elOOEJTuHoyevVddhi/KLVgI1bo=; b=Q8KFH4YU+zHm+O KutIYIRuasp7yocwRDVvQPNvt8PgNJWHZXKQPZjCtD7+edFTHCuzy9YmN1/3vdOg6It4FiejWfy53 fhwNaJ/c9qlc1ne2+EHWsbjKUo7ZY9T7J0OssZEGp/1ZXs9rqjJsZQw9P6cZpLHBz4FheRWNKxH33 TkXcWb6/Mban+mVu6Ot+VILCNdeBieswKWzwrg2071wpgWIoKQWsFKpGmy7W3Fbg070VukhZTGk1D snz+KRsVkPA7Uy3kDv/baIXpmt/4XxhNeAmCuSzt35d4gK0No7h5if20Zu77/JNRZwbpP0NvXqxze qUrZ09SO1jAa2+Yp0h1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFiIk-0009bd-DW; Mon, 16 Aug 2021 19:29:38 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFiF7-0008JF-1P for linux-mediatek@lists.infradead.org; Mon, 16 Aug 2021 19:26:03 +0000 Received: by mail-wr1-x42c.google.com with SMTP id q10so25143429wro.2 for ; Mon, 16 Aug 2021 12:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/XfYFIYwy/HkujSVpOAeCSjRnFWuHt2xEmDcZy3F/4Y=; b=S85xAQN6w1FtqeHt1YXtSmFEOjPaNOnNwspAVDXg199BhDU7XBNwSl/5i5wcYpTGaH Myu5QsY/UdjKor2I4MpIpq0BZDsPPFv3bsK7Z35xgl533WZA7ssfLfU1xBMqnvbGUF3o R8RCkdG7HE3SHT2JY3aIAa/buJXj6oriK7AEW0ZXALHn8z1BVMcnAFIgvDB1R52OMr4+ 9RXSocIV0RbApSGTthHcplt5jzMYJ1ZR6LnmCYtswPADscZ40XRzLnTbgpDwsxQTdHLM pjEIFG7xCVDFiwtZ97kuDaJrr6rk337TOOIxkZcCc0F88eMVNI2A9yQNV8AHztKwfnS4 c9Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/XfYFIYwy/HkujSVpOAeCSjRnFWuHt2xEmDcZy3F/4Y=; b=AK7mpBuBCqRtmk1RMX7QNS64xcRFzuXe+H8dP/R8wD335uORKDXE+m9nOYd2Bj0qjV HpHL9FK87UaXmX/c4FqpMuGAWQEAEirM2LptOVH1PVDizmm3d8xqRu7thXf0BBKbXB03 d3OLCDJclygO0ZEYYqXYZRtJWLMNC2l2XXaaGdJzZRHRxcXXMfyDlBY2d3CZDXNZ9yxM NpAdsWouAf6+sycdUrpPEvsi+Hdk0bwz31nJRh/+ViVz+kpIj5NvqOn2td72Daqqwb5c tzrQimYJLBY4kKnwixDCHYkc12RyFFuDYT2gQ+QsXRUarfmKNm2xEVIucFq/9hqt4qM9 NwIA== X-Gm-Message-State: AOAM530TuBEbdNr1vHk+OcJwzfSZ1/PIV+J/KlWtx6coKzvqGMExfR9a n5XytLhfBCeM0tAtAGJQjXyT/JHkirU9yw== X-Google-Smtp-Source: ABdhPJw3jfeZIRgdw9Um2xmvFRnS0MnRpKmcR7W1UGKYD0Q3/yCaet5CgdvMqwZIu/cCEkTbqLHu8w== X-Received: by 2002:a5d:4c4e:: with SMTP id n14mr69719wrt.226.1629141950515; Mon, 16 Aug 2021 12:25:50 -0700 (PDT) Received: from blmsp.lan ([2a02:2454:3e6:c900::97e]) by smtp.gmail.com with ESMTPSA id k17sm333954wmj.0.2021.08.16.12.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 12:25:50 -0700 (PDT) From: Markus Schneider-Pargmann To: Chun-Kuang Hu , Philipp Zabel Cc: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Markus Schneider-Pargmann Subject: [RFC PATCH 5/5] drm/mediatek: Add mt8195 DisplayPort driver Date: Mon, 16 Aug 2021 21:25:23 +0200 Message-Id: <20210816192523.1739365-6-msp@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816192523.1739365-1-msp@baylibre.com> References: <20210816192523.1739365-1-msp@baylibre.com> MIME-Version: 1.0 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 This patch adds a DisplayPort driver for the Mediatek mt8195 SoC. It supports both functional units on the mt8195, the embedded DisplayPort as well as the external DisplayPort units. It offers hot-plug-detection, audio up to 8 channels, and DisplayPort 1.4 with up to 4 lanes. This driver is based on an initial version by Jason-JH.Lin . Signed-off-by: Markus Schneider-Pargmann --- drivers/gpu/drm/mediatek/Kconfig | 7 + drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_dp.c | 3025 ++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 3095 +++++++++++++++++++++++++ 4 files changed, 6129 insertions(+) create mode 100644 drivers/gpu/drm/mediatek/mtk_dp.c create mode 100644 drivers/gpu/drm/mediatek/mtk_dp_reg.h diff --git a/drivers/gpu/drm/mediatek/Kconfig b/drivers/gpu/drm/mediatek/Kconfig index 2976d21e9a34..d81eb3521c1c 100644 --- a/drivers/gpu/drm/mediatek/Kconfig +++ b/drivers/gpu/drm/mediatek/Kconfig @@ -28,3 +28,10 @@ config DRM_MEDIATEK_HDMI select PHY_MTK_HDMI help DRM/KMS HDMI driver for Mediatek SoCs + +config MTK_DPTX_SUPPORT + tristate "DRM DPTX Support for Mediatek SoCs" + depends on DRM_MEDIATEK + select GENERIC_PHY + help + DRM/KMS Display Port driver for Mediatek SoCs. diff --git a/drivers/gpu/drm/mediatek/Makefile b/drivers/gpu/drm/mediatek/Makefile index dc54a7a69005..6b9d148ab7fe 100644 --- a/drivers/gpu/drm/mediatek/Makefile +++ b/drivers/gpu/drm/mediatek/Makefile @@ -20,3 +20,5 @@ mediatek-drm-hdmi-objs := mtk_cec.o \ mtk_hdmi_ddc.o obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o + +obj-$(CONFIG_MTK_DPTX_SUPPORT) += mtk_dp.o diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c new file mode 100644 index 000000000000..055ab816937f --- /dev/null +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -0,0 +1,3025 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 MediaTek Inc. + * Copyright (c) 2021 BayLibre + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include