From patchwork Tue Jul 12 11:12:23 2022 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: 12914789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 21F89C43334 for ; Tue, 12 Jul 2022 11:15:36 +0000 (UTC) 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=O+WW9RaD/U3GTxOJ8yVtzyX+icRUxezlh+f9BZ17zp0=; b=i7OHcTQFBrMk+H uhjVnkdV/O6qn5LiH/MqXiudw0ovTWTL2lfBPZ+OVZz//FMkx8puURkJcONTZDy+cywkquige2Sjv 2T7MY8TGzM0wYGdPt5YbSfFV+MXP36L0e9lmwH59V8x9H01ktg8j9sNSvPW9exNIor84FgAV4UTCn J/duMPBjpSy5FRak4DFv4AOyLdMsxBqSdSUQP+/u/L14ZgaSQPgESVRk7k13dePsk0/GXQOEMLT5d 2Tkzu/eBCiKfWT8zh+O3fz6UjNSP3rc2vR9cQxrwJKCC+B4NGNMahc9BHhc5hjYM2XJ4ebvQPbuM2 40Net/Vb8gEip9NMDpUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBDqZ-00AKmR-5n; Tue, 12 Jul 2022 11:14:31 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBDph-00AK3Z-T4; Tue, 12 Jul 2022 11:13:41 +0000 X-UUID: ec221f83b27a4ae8bef40d0194082de1-20220712 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8,REQID:ec39e35c-36b1-43da-86f0-bbd75079c5e6,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:-5 X-CID-META: VersionHash:0f94e32,CLOUDID:3c7f1364-0b3f-4b2c-b3a6-ed5c044366a0,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: ec221f83b27a4ae8bef40d0194082de1-20220712 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2100073968; Tue, 12 Jul 2022 04:13:31 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Tue, 12 Jul 2022 19:12:26 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.3 via Frontend Transport; Tue, 12 Jul 2022 19:12:26 +0800 From: Bo-Chen Chen To: , , , , , , , , , CC: , , , , , , , , , , , , , , Bo-Chen Chen Subject: [PATCH v14 10/10] drm/mediatek: Use cached audio config when changing resolution Date: Tue, 12 Jul 2022 19:12:23 +0800 Message-ID: <20220712111223.13080-11-rex-bc.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220712111223.13080-1-rex-bc.chen@mediatek.com> References: <20220712111223.13080-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-20220712_041337_991713_5F4C334F X-CRM114-Status: GOOD ( 17.26 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When the audio is playing, we need to use the original configuration to set the audio instead of using new configuration. Therefore, use the cached audio configuration during a resolution switch to avoid loss of sound. Signed-off-by: Jitao Shi Signed-off-by: Bo-Chen Chen Reviewed-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 54 ++++++++++--------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index fa7bb102a105..32fb7be374ed 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -104,7 +104,7 @@ struct mtk_dp_audio_cfg { struct mtk_dp_info { u32 depth; enum dp_pixelformat format; - struct mtk_dp_audio_cfg audio_caps; + struct mtk_dp_audio_cfg audio_cur_cfg; struct mtk_dp_timings timings; }; @@ -1858,9 +1858,7 @@ static bool mtk_dp_edid_parse_audio_capabilities(struct mtk_dp *mtk_dp, struct mtk_dp_audio_cfg *cfg) { struct cea_sad *sads; - int sad_count; - int i; - bool ret = false; + int ret; if (mtk_dp_is_edp(mtk_dp)) return false; @@ -1871,36 +1869,16 @@ static bool mtk_dp_edid_parse_audio_capabilities(struct mtk_dp *mtk_dp, dev_err(mtk_dp->dev, "EDID not found!\n"); return false; } - sad_count = drm_edid_to_sad(mtk_dp->edid, &sads); - mutex_unlock(&mtk_dp->edid_lock); - if (sad_count <= 0) { + ret = drm_edid_to_sad(mtk_dp->edid, &sads); + mutex_unlock(&mtk_dp->edid_lock); + if (ret <= 0) { drm_info(mtk_dp->drm_dev, "The SADs is NULL\n"); return false; } - - for (i = 0; i < sad_count; i++) { - int sample_rate, word_length; - - /* Only PCM supported at the moment */ - if (sads[i].format != HDMI_AUDIO_CODING_TYPE_PCM) - continue; - - sample_rate = drm_cea_sad_get_sample_rate(&sads[i]); - word_length = - drm_cea_sad_get_uncompressed_word_length(&sads[i]); - if (sample_rate <= 0 || word_length <= 0) - continue; - - cfg->channels = sads[i].channels; - cfg->word_length_bits = word_length; - cfg->sample_rate = sample_rate; - ret = true; - break; - } kfree(sads); - return ret; + return true; } static void mtk_dp_train_change_mode(struct mtk_dp *mtk_dp) @@ -2081,13 +2059,13 @@ static int mtk_dp_training(struct mtk_dp *mtk_dp) mtk_dp->audio_enable = mtk_dp_edid_parse_audio_capabilities(mtk_dp, - &mtk_dp->info.audio_caps); + &mtk_dp->info.audio_cur_cfg); if (mtk_dp->audio_enable) { - mtk_dp_audio_setup(mtk_dp, &mtk_dp->info.audio_caps); + mtk_dp_audio_setup(mtk_dp, &mtk_dp->info.audio_cur_cfg); mtk_dp_audio_mute(mtk_dp, false); } else { - memset(&mtk_dp->info.audio_caps, 0, - sizeof(mtk_dp->info.audio_caps)); + memset(&mtk_dp->info.audio_cur_cfg, 0, + sizeof(mtk_dp->info.audio_cur_cfg)); } return 0; @@ -2491,6 +2469,9 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge, if (mtk_dp_plug_state(mtk_dp)) { drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3); usleep_range(2000, 3000); + } else { + memset(&mtk_dp->info.audio_cur_cfg, 0, + sizeof(mtk_dp->info.audio_cur_cfg)); } mtk_dp_video_mute(mtk_dp, true); @@ -2701,18 +2682,17 @@ static int mtk_dp_audio_hw_params(struct device *dev, void *data, struct hdmi_codec_params *params) { struct mtk_dp *mtk_dp = dev_get_drvdata(dev); - struct mtk_dp_audio_cfg cfg; if (!mtk_dp->enabled) { pr_err("%s, DP is not ready!\n", __func__); return -ENODEV; } - cfg.channels = params->cea.channels; - cfg.sample_rate = params->sample_rate; - cfg.word_length_bits = 24; + mtk_dp->info.audio_cur_cfg.channels = params->cea.channels; + mtk_dp->info.audio_cur_cfg.sample_rate = params->sample_rate; + mtk_dp->info.audio_cur_cfg.word_length_bits = 24; - mtk_dp_audio_setup(mtk_dp, &cfg); + mtk_dp_audio_setup(mtk_dp, &mtk_dp->info.audio_cur_cfg); return 0; }