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: =?utf-8?b?SmlheGluIFl1ICjkv57lrrbpkasp?= X-Patchwork-Id: 25903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3888151wrr; Fri, 25 Nov 2022 01:46:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf5GF4RwOWm802QtwSjx1c+lnJ1AwUW/cLz1lUnT/Osd1lIvyzWEdbYDxpTEneUBUXrnrmkY X-Received: by 2002:a05:6402:2421:b0:461:524f:a8f4 with SMTP id t33-20020a056402242100b00461524fa8f4mr33181390eda.260.1669369592377; Fri, 25 Nov 2022 01:46:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669369592; cv=none; d=google.com; s=arc-20160816; b=K7lwnAJRVs7fmQzfX7ouAYWE9qz8x5RskMNwWFxGV913BT4pqSq44n8qoww53O3Zqs IamYct+BExhhP6N80DoAlwFCKF1BWX6UhmWce+qKkLFDngYfGkPQqrCxRSRdxL/b4M47 j8nDdXbz/nQpwscWvokRf6cfVOuZUMSYQ4qFqUFOoTBLsODg4im41eL+V3cLnhxW/d21 yGStbYg07GNuQoP22/HY8g9SlxkSZblDfKFpBkJrCMUOjfMc1DHJNtKcdVQ72w1QQVJk cVjTM0VeqmKzvsOw0M+BY0GILK4vnB+c2BgyXkLZyouVbSV/KKD8UB5l3BzCMZT+Ihck p1rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vz32to7zdlLJ3qNpyb8VnolqTMd0LD/XvVaG+ohQNDo=; b=kwCO7W9Yu31sm2SoHmpWH4NiU9vohePT8RSvzvJ6ewXMWb8rwpH/i5Pm180pP7ziNc IiQ9vZVHNNoUElheT+BBfzOgYdWJV6xmuwOu7Nax/OIeAASEnGZwLY5wnp67cqsHpEtR GIViQL13qerM4hxgOmAxdbQ6poLgIMardADSgH+dSdbEbhBOl3GL3LvZQB0s4UE21xBa kBRORNd4SqoiVVRH20oRRi06VOif9LGRMSqFdYgQJxFbPCRQbzsVFdPMfw26zZlE71Vg L9lK6CVUiw1si4Bo+ij3xTJJdeczU1dCt+fVD1w53ufdfUwvdXc/vX/HKHmkply5nD4I D1Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=cYiRp+Ub; 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=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a17090658d100b00715867834e3si3348330ejs.506.2022.11.25.01.46.09; Fri, 25 Nov 2022 01:46:32 -0800 (PST) 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=@mediatek.com header.s=dk header.b=cYiRp+Ub; 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=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229502AbiKYJod (ORCPT + 99 others); Fri, 25 Nov 2022 04:44:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbiKYJo1 (ORCPT ); Fri, 25 Nov 2022 04:44:27 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6B7D2628 for ; Fri, 25 Nov 2022 01:44:24 -0800 (PST) X-UUID: 7a1b3bc6958d4fdd94cb8e2acb2f1945-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-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:6af8dfbc-96aa-4faf-84f7-ad8ae3da7153,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:dcaaed0,CLOUDID:c4144ff9-3a34-4838-abcf-dfedf9dd068e,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 7a1b3bc6958d4fdd94cb8e2acb2f1945-20221125 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 96714378; Fri, 25 Nov 2022 17:44:17 +0800 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-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,RDNS_NONE, SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY,URIBL_CSS autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750460889835208844?= X-GMAIL-MSGID: =?utf-8?q?1750460889835208844?= 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;