Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30287009rwd; Thu, 6 Jul 2023 03:51:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGuiS6XujPoifFIXMBLAgh6E+Gj2nn2hyq/omiozqkLPaM24xfN+rAv3I+4ZjjIazm8MfB9 X-Received: by 2002:a05:6870:c34e:b0:1b0:1b2b:7e0b with SMTP id e14-20020a056870c34e00b001b01b2b7e0bmr1701514oak.30.1688640669496; Thu, 06 Jul 2023 03:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688640669; cv=none; d=google.com; s=arc-20160816; b=uqjCulXBxECcC3HTDcAY1JsDGtLwaDfoknh94y7U1n2QwfAPQu4vzT2yWfec4yAIlF XGO7czQK5x4EzUBTjp05QFrnIX+JG7lPj/6pjMD1m60DUJz1yp6sosdAPw1F1GaFoyNU X7v0HAgWo/eXPnnfRtjGGTk7M8K4k2Q3LW//W0xeMZTmpGch7+SmCATrIAQOsOcm1h8M fxmAjeYEt/YW8Qs0ixfUhQIWCQgKryYGXlEayPpRMJaGwlIDq/p83Vh0/XJl98K7K5MV Xl1coo9blirZxRvNJ/za7rQZRCuxrw5qTR1idB6dWwWD68NShTmqiFwkNxFSmiqIYP0R 1xlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=rOaQqbvt1fRwPon1beIEWw+Wy/5jMRNwCuVcFPbo5gU=; fh=waD6wemqaW3KCglGFvo1DWzMZD3u6vCUny6jPGU7WGM=; b=jHu/DO3+8ci47l19nddOwlDDNBupAiu5ahe9Olp3FWvTqnFn8E0Tluk/E5rEyW0iPT C8YTh4D9r2mJAOdQ6y6donzrXm4wuRkDNIN14+NeElj2OYWETaD3Vju462lVL40K61vm LxCELuY2W/vEUC7/81GxVFf6fMdvVuJo/j/L5MfBMajA907lsAG2Goi4QOohVUg44Cik qlhnuzFy+pyGuPm0YR3u2RevtqcXV5FdoC23ctMK5uETBC6In5IvO8AU7CC3OMiwINCk +dT/jT9G9RVlQgDxY3nMx5y45khvoNPxwMSWrYCiCAr/dYrXzkBu91PDor0fjVddyZUk T0bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=m5giy2mC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i185-20020a6387c2000000b0053f01212571si1233670pge.257.2023.07.06.03.50.55; Thu, 06 Jul 2023 03:51:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=m5giy2mC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231636AbjGFK1A (ORCPT + 99 others); Thu, 6 Jul 2023 06:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231745AbjGFK06 (ORCPT ); Thu, 6 Jul 2023 06:26:58 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8D731BC2; Thu, 6 Jul 2023 03:26:56 -0700 (PDT) Received: from [192.168.1.100] (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 98A23660585C; Thu, 6 Jul 2023 11:26:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688639215; bh=6CgHdMHanq24fvS8FaBS8qQ0RlrA+kGzfVHRX7V3k+U=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=m5giy2mCP/OsIEhQ87ulCwEghPPvsIuwbA3Q+mBAn7Jb9MxcTPtx5AtNq1BITdAZr nA/Fb0ZmF6helJOemGYvB+JWK00bYzDbOu5JO1rBNhp638s3pQe6tvofWEaJ4SCMDi 4YoQJhQtuRhtemc6+DBW8lM0QEndAgAhYRvwEjMmZIYN6gdqiGJwzkMqonjkd5aOKn 6OzwQVzoYzgkeKE3lYMxwmdwcC1p+UyA0vels2urvwoOGV7bZrenay6YqK8wWBWB4B EvQ7qp5SriPvb1RbAIcGOeSQRsyzDntlgKQvuJ8hV/CmqKHaDAKhqL1A3qwO7r603d Ek6uHcPF9qOog== Message-ID: <7b8d221f-107f-3352-d851-a0cb40008c1a@collabora.com> Date: Thu, 6 Jul 2023 12:26:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v2,2/2] drm/mediatek: dp: Add the audio control to mtk_dp_data struct Content-Language: en-US To: Shuijing Li , chunkuang.hu@kernel.org, p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, matthias.bgg@gmail.com, jitao.shi@mediatek.com Cc: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Project_Global_Chrome_Upstream_Group@mediatek.com References: <20230706021425.31735-1-shuijing.li@mediatek.com> <20230706021425.31735-3-shuijing.li@mediatek.com> From: AngeloGioacchino Del Regno In-Reply-To: <20230706021425.31735-3-shuijing.li@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 06/07/23 04:14, Shuijing Li ha scritto: > Mainly add the following two flag: > > 1.The audio packet arrangement function is to only arrange audio > packets into the Hblanking area. In order to align with the HW > default setting of g1200, this function needs to be turned off. > > 2.Due to the difference of HW, different dividers need to be set. > > Signed-off-by: Shuijing Li > Signed-off-by: Jitao Shi > --- > Changes in v2: > - change the variables' name to be more descriptive > - add a comment that describes the function of mtk_dp_audio_sample_arrange > - reduce indentation by doing the inverse check > - add a definition of some bits > - add support for mediatek, mt8188-edp-tx > per suggestion from the previous thread: > https://lore.kernel.org/lkml/ac0fcec9-a2fe-06cc-c727-189ef7babe9c@collabora.com/ > --- > drivers/gpu/drm/mediatek/mtk_dp.c | 47 ++++++++++++++++++++++++++- > drivers/gpu/drm/mediatek/mtk_dp_reg.h | 6 ++++ > 2 files changed, 52 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c > index 64eee77452c0..8e1a13ab2ba2 100644 > --- a/drivers/gpu/drm/mediatek/mtk_dp.c > +++ b/drivers/gpu/drm/mediatek/mtk_dp.c > @@ -139,6 +139,8 @@ struct mtk_dp_data { > unsigned int smc_cmd; > const struct mtk_dp_efuse_fmt *efuse_fmt; > bool audio_supported; > + bool audio_pkt_in_hblank_area; > + u16 audio_m_div2_bit; > }; > > static const struct mtk_dp_efuse_fmt mt8195_edp_efuse_fmt[MTK_DP_CAL_MAX] = { > @@ -647,7 +649,7 @@ static void mtk_dp_audio_sdp_asp_set_channels(struct mtk_dp *mtk_dp, > static void mtk_dp_audio_set_divider(struct mtk_dp *mtk_dp) > { > mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_30BC, > - AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_2, > + mtk_dp->data->audio_m_div2_bit, > AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_MASK); > } > > @@ -1362,6 +1364,18 @@ static void mtk_dp_sdp_set_down_cnt_init_in_hblank(struct mtk_dp *mtk_dp) > SDP_DOWN_CNT_INIT_IN_HBLANK_DP_ENC1_P0_MASK); > } > > +static void mtk_dp_audio_sample_arrange(struct mtk_dp *mtk_dp) > +{ > + /* arrange audio packets into the Hblanking and Vblanking area */ > + if (!mtk_dp->data->audio_pkt_in_hblank_area) > + return; There's only one remaining question: why is this done for MT8188 but *not* for MT8195? Thanks, Angelo > + > + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC1_P0_3374, 0, > + SDP_ASP_INSERT_IN_HBLANK_DP_ENC1_P0_MASK); > + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC1_P0_3374, 0, > + SDP_DOWN_ASP_CNT_INIT_DP_ENC1_P0_MASK); > +} > + > static void mtk_dp_setup_tu(struct mtk_dp *mtk_dp) > { > u32 sram_read_start = min_t(u32, MTK_DP_TBC_BUF_READ_START_ADDR, > @@ -1371,6 +1385,7 @@ static void mtk_dp_setup_tu(struct mtk_dp *mtk_dp) > MTK_DP_PIX_PER_ADDR); > mtk_dp_set_sram_read_start(mtk_dp, sram_read_start); > mtk_dp_setup_encoder(mtk_dp); > + mtk_dp_audio_sample_arrange(mtk_dp); > mtk_dp_sdp_set_down_cnt_init_in_hblank(mtk_dp); > mtk_dp_sdp_set_down_cnt_init(mtk_dp, sram_read_start); > } > @@ -2616,11 +2631,31 @@ static int mtk_dp_resume(struct device *dev) > > static SIMPLE_DEV_PM_OPS(mtk_dp_pm_ops, mtk_dp_suspend, mtk_dp_resume); > > +static const struct mtk_dp_data mt8188_edp_data = { > + .bridge_type = DRM_MODE_CONNECTOR_eDP, > + .smc_cmd = MTK_DP_SIP_ATF_EDP_VIDEO_UNMUTE, > + .efuse_fmt = mt8195_edp_efuse_fmt, > + .audio_supported = false, > + .audio_pkt_in_hblank_area = false, > + .audio_m_div2_bit = MT8188_AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_2, > +}; > + > +static const struct mtk_dp_data mt8188_dp_data = { > + .bridge_type = DRM_MODE_CONNECTOR_DisplayPort, > + .smc_cmd = MTK_DP_SIP_ATF_VIDEO_UNMUTE, > + .efuse_fmt = mt8195_dp_efuse_fmt, > + .audio_supported = true, > + .audio_pkt_in_hblank_area = true, > + .audio_m_div2_bit = MT8188_AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_2, > +}; > + > static const struct mtk_dp_data mt8195_edp_data = { > .bridge_type = DRM_MODE_CONNECTOR_eDP, > .smc_cmd = MTK_DP_SIP_ATF_EDP_VIDEO_UNMUTE, > .efuse_fmt = mt8195_edp_efuse_fmt, > .audio_supported = false, > + .audio_pkt_in_hblank_area = false, > + .audio_m_div2_bit = AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_2, > }; > > static const struct mtk_dp_data mt8195_dp_data = { > @@ -2628,9 +2663,19 @@ static const struct mtk_dp_data mt8195_dp_data = { > .smc_cmd = MTK_DP_SIP_ATF_VIDEO_UNMUTE, > .efuse_fmt = mt8195_dp_efuse_fmt, > .audio_supported = true, > + .audio_pkt_in_hblank_area = false, > + .audio_m_div2_bit = AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_2, > }; > > static const struct of_device_id mtk_dp_of_match[] = { > + { > + .compatible = "mediatek,mt8188-edp-tx", > + .data = &mt8188_edp_data, > + }, > + { > + .compatible = "mediatek,mt8188-dp-tx", > + .data = &mt8188_dp_data, > + }, > { > .compatible = "mediatek,mt8195-edp-tx", > .data = &mt8195_edp_data, > diff --git a/drivers/gpu/drm/mediatek/mtk_dp_reg.h b/drivers/gpu/drm/mediatek/mtk_dp_reg.h > index 84e38cef03c2..6d7f0405867e 100644 > --- a/drivers/gpu/drm/mediatek/mtk_dp_reg.h > +++ b/drivers/gpu/drm/mediatek/mtk_dp_reg.h > @@ -162,6 +162,7 @@ > #define AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_MUL_2 (1 << 8) > #define AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_MUL_4 (2 << 8) > #define AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_MUL_8 (3 << 8) > +#define MT8188_AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_2 (4 << 8) > #define AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_2 (5 << 8) > #define AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_4 (6 << 8) > #define AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_8 (7 << 8) > @@ -228,6 +229,11 @@ > VIDEO_STABLE_CNT_THRD_DP_ENC1_P0 | \ > SDP_DP13_EN_DP_ENC1_P0 | \ > BS2BS_MODE_DP_ENC1_P0) > + > +#define MTK_DP_ENC1_P0_3374 0x3374 > +#define SDP_ASP_INSERT_IN_HBLANK_DP_ENC1_P0_MASK BIT(12) > +#define SDP_DOWN_ASP_CNT_INIT_DP_ENC1_P0_MASK GENMASK(11, 0) > + > #define MTK_DP_ENC1_P0_33F4 0x33f4 > #define DP_ENC_DUMMY_RW_1_AUDIO_RST_EN BIT(0) > #define DP_ENC_DUMMY_RW_1 BIT(9)