From patchwork Fri Nov 25 09:44:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxin Yu X-Patchwork-Id: 13055698 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 9F354C4332F for ; Fri, 25 Nov 2022 09:54:43 +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=vz32to7zdlLJ3qNpyb8VnolqTMd0LD/XvVaG+ohQNDo=; b=3KXdq9UkysOr5SqzNuazhiSlnh lG+/7ELcZL+xTulWDB5/m9gyfrqpb/KHKoJnGI1qs+/4EKD+209fGF3qXZDvLblOZRsiEFKCXVoT7 brQMaTtL+rTSSUF/bgkofhiPyPhXFQ3EQ0+vQil9Zw/ygWe390mcFIeq98J+XJ8q0wzBFLOUeEtXJ VDjQpyylxX6p+lruNWmHMoos1fqDdzpfVIsVoCac8PN+ujSn+cdyhbpoRdkEkVRcUzWLTIZJnPiZF PBpoDAopFOJCWgA3Ktj+B9NOiEnciK/dMIdcM0x2nEOmJh6wQkChJZh74/z+TQ6nI22t6ZU1Vb8Zx 3U8+GRqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyVPp-00F97c-3S; Fri, 25 Nov 2022 09:54:37 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyVGY-00F3To-C0; Fri, 25 Nov 2022 09:45:05 +0000 X-UUID: f54b045f1b1b40379dae7679d07b3749-20221125 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=vz32to7zdlLJ3qNpyb8VnolqTMd0LD/XvVaG+ohQNDo=; b=cYiRp+Ub5Io+eei5/b0IIGczKkYqkxZcGe8MFzEvxl4kxVgK86KwIFkpQk7kms37M+nYzrNCtRUVryitZA1qHHVjItFtblBmSYc6OoZVdz3IR3qsX6qe0N4CXYoDI7g1dhiIXYMEjwqqSB/d6zUoXkrs2iYVYrrLGcR891ln5ZM=; X-CID-UNFAMILIAR: 1 X-CID-P-RULE: Spam_GS6885AD X-CID-O-INFO: VERSION:1.1.14,REQID:74fe87d1-c6b5-42d6-9188-bc030b257a27,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:100,FILE:0,BULK:28,RULE:Spam_GS6885AD,AC TION:quarantine,TS:128 X-CID-INFO: VERSION:1.1.14,REQID:74fe87d1-c6b5-42d6-9188-bc030b257a27,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:100,FILE:0,BULK:28,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:128 X-CID-META: VersionHash:dcaaed0,CLOUDID:7c184ff9-3a34-4838-abcf-dfedf9dd068e,B ulkID:22112416551476AROU4C,BulkQuantity:8,Recheck:0,SF:38|28|16|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:41|20,QS:nil,BEC:nil,COL:0 X-UUID: f54b045f1b1b40379dae7679d07b3749-20221125 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 1342052539; Fri, 25 Nov 2022 02:44:50 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) 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; Fri, 25 Nov 2022 17:44:16 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Fri, 25 Nov 2022 17:44:15 +0800 From: Jiaxin Yu To: , , , , , , , CC: , , , , , , , , , Jiaxin Yu Subject: [PATCH v2 1/3] ASoC: hdmi-codec: Add event handler for hdmi TX Date: Fri, 25 Nov 2022 17:44:11 +0800 Message-ID: <20221125094413.4940-2-jiaxin.yu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125094413.4940-1-jiaxin.yu@mediatek.com> References: <20221125094413.4940-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-20221125_014502_497189_8F5B536F X-CRM114-Status: GOOD ( 17.04 ) 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 way of switching is through SOC_DAPM_PIN_SWITCH, however, such events can not be handled in hdmi-codec driver. So add event handler for hdmi TX to solve the above issue. Signed-off-by: Jiaxin Yu --- include/sound/hdmi-codec.h | 6 ++++++ sound/soc/codecs/hdmi-codec.c | 37 +++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index 48ad33aba393..dcbc09254144 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. + * Mandatory + */ + 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 0b1cdb2d6049..cb4479372e09 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"), }; @@ -808,18 +832,23 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai) struct hdmi_codec_daifmt *daifmt; struct snd_soc_dapm_route route[] = { { - .sink = "TX", + .sink = dai->driver->capture.stream_name, + .source = "RX", + }, + { + .sink = "SDB", .source = dai->driver->playback.stream_name, }, { - .sink = dai->driver->capture.stream_name, - .source = "RX", + .sink = "TX", + .source = "SDB", }, + }; int ret; dapm = snd_soc_component_get_dapm(dai->component); - ret = snd_soc_dapm_add_routes(dapm, route, 2); + ret = snd_soc_dapm_add_routes(dapm, route, ARRAY_SIZE(route)); if (ret) return ret;