From patchwork Sun Jul 30 18:08:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxin Yu X-Patchwork-Id: 13333491 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 D2723C00528 for ; Sun, 30 Jul 2023 18:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=7AGOYJf6IgitJjoa7VTj5ABs/QIt0Vp5FPUCdFNSDG0=; b=sTGAOVPzS3Nv+tOWVX7jmNm2i/ LkPsQdVIxQLlBOSwhPoU5UFeshQ7ERzciSsyW5w+v7Io7pp7Zv7Y8zQJpvRULY2qMKspFPIjixqxd PAVDloylnUvCBS3T2fXmyyRBSv7UzuXC8qVHlwaN+yXHbaWo8A1MRnmZ0zS7jqepigLF8BBKudvpq 5g0Km6SvukcdJsGgsv+WJYwa3ZlpxqELvfqSZnFj00t2vUPajXIMB8MCRUjzPIjehZIzGrUOHRZzM AgkJZgmFoKysHjIRJxC+/PH53eCUE4whIUiLFGa2Y5aRMdU+iXUyY1I3sesCvSFq3fwGgjAUoCxSj Zllsl66A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQAqR-00CMYG-2w; Sun, 30 Jul 2023 18:08:43 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQAq4-00CMNx-2E; Sun, 30 Jul 2023 18:08:22 +0000 X-UUID: 0a9199522f0411ee83ed1395ce914268-20230730 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=7AGOYJf6IgitJjoa7VTj5ABs/QIt0Vp5FPUCdFNSDG0=; b=c/AbBvDmT1rZ4r8WplLNxxdFrimMcbieanc99EULugTYc1uOGz23ALQ4fMaKzhKMyPS7lPw1Dc2ZcXHV2RUlhx2mYvHq6o5JpenxrUu97ghUDK2cl0q7RAsF5T4ATHbremhBnabv/TVvDWfT/wcZZnI2ixLkve7DyM+e9pDoqdM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.30,REQID:6e6bdf39-1c44-4a72-a976-e8dcdeb2f254,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:100 X-CID-INFO: VERSION:1.1.30,REQID:6e6bdf39-1c44-4a72-a976-e8dcdeb2f254,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:100 X-CID-META: VersionHash:1fcc6f8,CLOUDID:4de79c42-d291-4e62-b539-43d7d78362ba,B ulkID:230731020810SF827MI0,BulkQuantity:0,Recheck:0,SF:29|28|17|19|48|38,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_SDM,TF_CID_SPAM_ASC,TF_CID_SPAM_FAS, TF_CID_SPAM_FSD X-UUID: 0a9199522f0411ee83ed1395ce914268-20230730 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1672161951; Sun, 30 Jul 2023 11:08:09 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 31 Jul 2023 02:08:07 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 31 Jul 2023 02:08:06 +0800 From: Jiaxin Yu To: , , , , , , , CC: , , , , , , , , , Jiaxin Yu Subject: [v3 1/3] ASoC: hdmi-codec: Add event handler for hdmi TX Date: Mon, 31 Jul 2023 02:08:01 +0800 Message-ID: <20230730180803.22570-2-jiaxin.yu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230730180803.22570-1-jiaxin.yu@mediatek.com> References: <20230730180803.22570-1-jiaxin.yu@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-20230730_110820_729990_F9803F77 X-CRM114-Status: GOOD ( 19.59 ) 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 If the speaker and hdmi are connect to the same port of I2S, when try to switch to speaker playback, we will find that hdmi is always turned on automatically. The connection as follows: ==> hdmi-codec ==> it6505(HDMI output) DL1(FE) ==> I2S3(BE) ==> rt1015p(SPEAKER output) So in order to separately control their power on/off, we have added a dapm widget to notify each output. Also the machine driver need add a _PIN_SWITCH() on the output of the device that will cause DAPM to keep the device powered down when not in use. The purpose of adding .trigger callback here is to enable hdmi-codec to notify the dp output driver to power on or off device. Signed-off-by: Jiaxin Yu --- include/sound/hdmi-codec.h | 6 ++++++ sound/soc/codecs/hdmi-codec.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index 9b162ac1e08e..ea834a838754 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -81,6 +81,12 @@ struct hdmi_codec_ops { struct hdmi_codec_daifmt *fmt, struct hdmi_codec_params *hparms); + /* + * PCM trigger callback. + * Optional + */ + int (*trigger)(struct device *dev, int cmd); + /* * Shuts down the audio stream. * Mandatory diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index d21f69f05342..6766b55c9b56 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -276,7 +276,31 @@ struct hdmi_codec_priv { u8 iec_status[AES_IEC958_STATUS_SIZE]; }; +static int hdmi_tx_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + if (hcp->hcd.ops->trigger) + hcp->hcd.ops->trigger(component->dev->parent, SNDRV_PCM_TRIGGER_START); + break; + case SND_SOC_DAPM_POST_PMD: + if (hcp->hcd.ops->trigger) + hcp->hcd.ops->trigger(component->dev->parent, SNDRV_PCM_TRIGGER_STOP); + break; + default: + break; + } + + return 0; +} + static const struct snd_soc_dapm_widget hdmi_widgets[] = { + SND_SOC_DAPM_OUT_DRV_E("SDB", SND_SOC_NOPM, 0, 0, NULL, 0, hdmi_tx_event, + SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMU), SND_SOC_DAPM_OUTPUT("TX"), SND_SOC_DAPM_OUTPUT("RX"), }; @@ -831,9 +855,13 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai) struct hdmi_codec_daifmt *daifmt; struct snd_soc_dapm_route route[] = { { - .sink = "TX", + .sink = "SDB", .source = dai->driver->playback.stream_name, }, + { + .sink = "TX", + .source = "SDB", + }, { .sink = dai->driver->capture.stream_name, .source = "RX", @@ -848,7 +876,7 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai) if (!route[i].source || !route[i].sink) continue; - ret = snd_soc_dapm_add_routes(dapm, &route[i], 1); + ret = snd_soc_dapm_add_routes(dapm, route, ARRAY_SIZE(route)); if (ret) return ret; } From patchwork Sun Jul 30 18:08:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxin Yu X-Patchwork-Id: 13333490 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 D42BBC001DF for ; Sun, 30 Jul 2023 18:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=5st1uPVswkp7Jf2ahEjpIkqtcT+MrlPvHk5P9itktPg=; b=4HLZy2hOC+w3O0EhJTZgtn4qK7 KawkfRZhbTV4qR6ojOQOVY5c2EQBJsgtbwaCLPZaGF2IHm0pOisXJCJtdRr3U90Gda5I4E5gFoHsx S9tuhEOlCjzhYJH796kGAAwqVPbiFpjjYt0Snt/5OfboOAa+Yb95G78cfvAgjXPN2eSsnuO/EKBBO upy9C8DeUmdJyhVqb8Hc4e8H20afnDi1kDyEvkFRsLqsW/W9S6WgSInHrZBU18SZmG+gVO+6GV3HG 9Z2qP4dACs/yPFtU/zt1vOGWdJ4K7vegGbE+6RwM4N8Hm1us6Kl8pbNnAUQE1is3JXXzzvWJKrBJa 7DEg1Tsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQAqH-00CMVY-2X; Sun, 30 Jul 2023 18:08:33 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQAq4-00CMNy-05; Sun, 30 Jul 2023 18:08:22 +0000 X-UUID: 0b49b2762f0411ee83ed1395ce914268-20230730 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=5st1uPVswkp7Jf2ahEjpIkqtcT+MrlPvHk5P9itktPg=; b=XCpqvtcR49Ekyqaj7sAPwu6zR1S5zAS56kjN8ujQwO+8eZQRAaqLKMdkmBfcklrskHsu6MyfypY1QpbElk9rS2uj5B2bN08BcKfwYtof1H7wyrliX7sI5ooC+szcEjudR9RzkcP7Ld5vul740MRN4C+uv3Scu4k7M2m35OOsZcU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.30,REQID:692bd265-aacf-419e-a22e-76c36876342f,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:95 X-CID-INFO: VERSION:1.1.30,REQID:692bd265-aacf-419e-a22e-76c36876342f,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:95 X-CID-META: VersionHash:1fcc6f8,CLOUDID:16fe7bd2-cd77-4e67-bbfd-aa4eaace762f,B ulkID:2307310208135RNVN48M,BulkQuantity:0,Recheck:0,SF:28|17|19|48|38|29,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SDM,TF_CID_SPAM_ASC,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD, TF_CID_SPAM_SNR X-UUID: 0b49b2762f0411ee83ed1395ce914268-20230730 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1687208522; Sun, 30 Jul 2023 11:08:11 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 31 Jul 2023 02:08:08 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 31 Jul 2023 02:08:07 +0800 From: Jiaxin Yu To: , , , , , , , CC: , , , , , , , , , Jiaxin Yu Subject: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets Date: Mon, 31 Jul 2023 02:08:02 +0800 Message-ID: <20230730180803.22570-3-jiaxin.yu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230730180803.22570-1-jiaxin.yu@mediatek.com> References: <20230730180803.22570-1-jiaxin.yu@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-20230730_110820_067413_598BA666 X-CRM114-Status: GOOD ( 10.28 ) 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 Use SND_SOC_DAPM_LINE instead of SND_SOC_DAPM_OUTPUT to trigger DAPM events to hdmi-codec when userspace control the DPAM pin. Signed-off-by: Jiaxin Yu --- sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c | 2 +- sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c index 0432f9d89020..ae51d70e2c0b 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c @@ -964,7 +964,7 @@ mt8186_mt6366_da7219_max98357_widgets[] = { SND_SOC_DAPM_SPK("Speakers", NULL), SND_SOC_DAPM_HP("Headphones", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_OUTPUT("HDMI1"), + SND_SOC_DAPM_LINE("HDMI1", NULL), SND_SOC_DAPM_MIXER(SOF_DMA_DL1, SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER(SOF_DMA_DL2, SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER(SOF_DMA_UL1, SND_SOC_NOPM, 0, 0, NULL, 0), diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c index 9c11016f032c..a39e37fa4e02 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c @@ -1032,7 +1032,7 @@ mt8186_mt6366_rt1019_rt5682s_widgets[] = { SND_SOC_DAPM_SPK("Speakers", NULL), SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_OUTPUT("HDMI1"), + SND_SOC_DAPM_LINE("HDMI1", NULL), SND_SOC_DAPM_MIXER(SOF_DMA_DL1, SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER(SOF_DMA_DL2, SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER(SOF_DMA_UL1, SND_SOC_NOPM, 0, 0, NULL, 0), From patchwork Sun Jul 30 18:08:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxin Yu X-Patchwork-Id: 13333489 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 955CBC41513 for ; Sun, 30 Jul 2023 18:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=rUtEDz36Ege3wRJGsZeZHbrLvnL2PPOHhITk/HK+wd0=; b=TP0OVvXkY8W8WKzY6EK2KwUuTT 0FsmnbSpSjQkxHsnSPqeywLg4tpxv+/gyeI1y60s7B+z+/xEus36E73okgfXdVUSs0ciJXLXuTkJo ehIh8ZdTH76wx/MEw3reqsJE1sukimTKZocFeweuMfyonMoxhpssu0Sz+Jjw4VnztpbZCfsly3uU0 ifjfzF86nVbOsEXqMES0MyzVNzyAiT89ZMjnOekwBGoMfj5KABobJKISVvk36eBD8zgH9jv8DRDPl I5HmBmSPLzD4+Q/dsRzWeVf+wUmcXKJkgxym2yw6TXUZwhsRi7759uzgLP9qjAg+SiZMF1qtlEfPV ZkGmcrOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQAq7-00CMQq-38; Sun, 30 Jul 2023 18:08:23 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQAq3-00CMO0-2M; Sun, 30 Jul 2023 18:08:21 +0000 X-UUID: 0bcbda8a2f0411ee83ed1395ce914268-20230730 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=rUtEDz36Ege3wRJGsZeZHbrLvnL2PPOHhITk/HK+wd0=; b=at7QoIuqMX8n3cyreCSdGqy1h85o7k9lAplZYTz3wrLdW1LIotoI8uAS4wegTuDfaImU8FVaRUm0T8bCHXWgw3yFNxtXl+OOQgrBX0iUO3uJQB1rTBYUtOH253TOz1ftsVwhivOh8AwhXIF721BNPUU+kcLRoq+TWZNrTF8qDmg=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.30,REQID:3658a779-b172-4a89-b0d2-91e2bae3317d,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:75 X-CID-INFO: VERSION:1.1.30,REQID:3658a779-b172-4a89-b0d2-91e2bae3317d,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACT ION:quarantine,TS:75 X-CID-META: VersionHash:1fcc6f8,CLOUDID:6f71b0a0-0933-4333-8d4f-6c3c53ebd55b,B ulkID:230731020813010OPTPV,BulkQuantity:0,Recheck:0,SF:17|19|48|38|29|28,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_ASC,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_SNR, TF_CID_SPAM_SDM X-UUID: 0bcbda8a2f0411ee83ed1395ce914268-20230730 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1502013647; Sun, 30 Jul 2023 11:08:11 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 31 Jul 2023 02:08:09 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 31 Jul 2023 02:08:08 +0800 From: Jiaxin Yu To: , , , , , , , CC: , , , , , , , , , Jiaxin Yu Subject: [v3 3/3] drm/bridge: it6505: Add audio support Date: Mon, 31 Jul 2023 02:08:03 +0800 Message-ID: <20230730180803.22570-4-jiaxin.yu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230730180803.22570-1-jiaxin.yu@mediatek.com> References: <20230730180803.22570-1-jiaxin.yu@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-20230730_110819_779576_9A0DBB3F X-CRM114-Status: GOOD ( 15.60 ) 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 audio support for it6505 1. Bridge to hdmi-codec to support audio feature. At the same time, the function of automatically detecting audio is removed. 2. It is observed that some DP-to-HDMI dongles will get into bad states if sending InfoFrame without audio data. Defer to enable it6505's audio feature when PCM triggers START or RESUME. Signed-off-by: Jiaxin Yu --- drivers/gpu/drm/bridge/ite-it6505.c | 81 ++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 504d51c42f79..1cfcb0731288 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2162,7 +2162,6 @@ static void it6505_stop_link_train(struct it6505 *it6505) static void it6505_link_train_ok(struct it6505 *it6505) { - struct device *dev = &it6505->client->dev; it6505->link_state = LINK_OK; /* disalbe mute enable avi info frame */ @@ -2170,11 +2169,6 @@ static void it6505_link_train_ok(struct it6505 *it6505) it6505_set_bits(it6505, REG_INFOFRAME_CTRL, EN_VID_CTRL_PKT, EN_VID_CTRL_PKT); - if (it6505_audio_input(it6505)) { - DRM_DEV_DEBUG_DRIVER(dev, "Enable audio!"); - it6505_enable_audio(it6505); - } - if (it6505->hdcp_desired) it6505_start_hdcp(it6505); } @@ -2846,6 +2840,45 @@ static void __maybe_unused it6505_audio_shutdown(struct device *dev, void *data) it6505_disable_audio(it6505); } +static int it6505_audio_hw_params(struct device *dev, void *data, + struct hdmi_codec_daifmt *daifmt, + struct hdmi_codec_params *params) +{ + struct it6505 *it6505 = dev_get_drvdata(dev); + + return it6505_audio_setup_hw_params(it6505, params); +} + +static int it6505_audio_setup_trigger(struct it6505 *it6505, int cmd) +{ + struct device *dev = &it6505->client->dev; + + DRM_DEV_DEBUG_DRIVER(dev, "event: %d", cmd); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + queue_delayed_work(system_wq, &it6505->delayed_audio, + msecs_to_jiffies(180)); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + cancel_delayed_work(&it6505->delayed_audio); + break; + default: + return -EINVAL; + } + + return 0; +} + +static int it6505_audio_trigger(struct device *dev, int cmd) +{ + struct it6505 *it6505 = dev_get_drvdata(dev); + + return it6505_audio_setup_trigger(it6505, cmd); +} + static int __maybe_unused it6505_audio_hook_plugged_cb(struct device *dev, void *data, hdmi_codec_plugged_cb fn, @@ -2860,6 +2893,36 @@ static int __maybe_unused it6505_audio_hook_plugged_cb(struct device *dev, return 0; } +static const struct hdmi_codec_ops it6505_audio_codec_ops = { + .hw_params = it6505_audio_hw_params, + .trigger = it6505_audio_trigger, + .audio_shutdown = it6505_audio_shutdown, + .hook_plugged_cb = it6505_audio_hook_plugged_cb, +}; + +static int it6505_register_audio_driver(struct device *dev) +{ + struct it6505 *it6505 = dev_get_drvdata(dev); + struct hdmi_codec_pdata codec_data = { + .ops = &it6505_audio_codec_ops, + .max_i2s_channels = 8, + .i2s = 1, + .data = it6505, + }; + struct platform_device *pdev; + + pdev = platform_device_register_data(dev, HDMI_CODEC_DRV_NAME, + PLATFORM_DEVID_AUTO, &codec_data, + sizeof(codec_data)); + if (IS_ERR(pdev)) + return PTR_ERR(pdev); + + INIT_DELAYED_WORK(&it6505->delayed_audio, it6505_delayed_audio); + DRM_DEV_DEBUG_DRIVER(dev, "bound to %s", HDMI_CODEC_DRV_NAME); + + return 0; +} + static inline struct it6505 *bridge_to_it6505(struct drm_bridge *bridge) { return container_of(bridge, struct it6505, bridge); @@ -3421,6 +3484,12 @@ static int it6505_i2c_probe(struct i2c_client *client) return err; } + err = it6505_register_audio_driver(dev); + if (err < 0) { + DRM_DEV_ERROR(dev, "Failed to register audio driver: %d", err); + return err; + } + INIT_WORK(&it6505->link_works, it6505_link_training_work); INIT_WORK(&it6505->hdcp_wait_ksv_list, it6505_hdcp_wait_ksv_list); INIT_DELAYED_WORK(&it6505->hdcp_work, it6505_hdcp_work);