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; From patchwork Fri Nov 25 09:44:12 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: 25900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3887889wrr; Fri, 25 Nov 2022 01:46:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf7dkLGMaiiAX+vUeLC+OciIKkGkUU8ndwII0s96OPSGv0vBOa3//gENteG+RN9JDk7xO493 X-Received: by 2002:a17:902:ce04:b0:187:3a54:9b93 with SMTP id k4-20020a170902ce0400b001873a549b93mr26345836plg.2.1669369562016; Fri, 25 Nov 2022 01:46:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669369562; cv=none; d=google.com; s=arc-20160816; b=PuxJ80bZXw87xnzR5nxHpsg58x4Y5dHm9YMTCR/zgf7UCMe+tVzrckPh1jcUax1fjY B90YJlAKAH46UU7q1V67Ub4ejDO/xu/psL6dPQJeQKlVTUAoHixWkw3DXj7AIO/KGJkW HPlFK92F9uNf+sOxU/oeewNDI2qnGDEBPObu02RQWVdzYTDRQmkIuOvpJzgW4LDOa1WB /ZkQzOOtMZOH6iCIbOFK0rk6MMujufqt3WJd1xd79UM2lNAwO4IN1zCLLY6QNMQi9PZb v5sOV12kt05TZIKXUeCt4fUAB6FRhmq1p2FEQ+Hts8zmFtLEJp62ekHLKLVjS66dI2gN ul5Q== 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=ViGNiKiDlpdTwQms22X0e/YbhcaMRLoQ4ODpbxaV73U=; b=zGBRGTdBZwrKCqRLkxrypV9xNINWYmca5vRFdui5BhT2RRar2WGQngPCabFyIsq1R6 /lt0DUXWVxwdbcqv5u6MNVGC35GzODy9WYB5s624OPD6iz1H+zDqWxEFTewgypnUNhKH WvDvKOcx06t6OJS8kWwv4Z0J9PyR3Ghdu84PhZW4gtTKD3y8zV2SBgNFCV5gIiOWGoP5 MmsJyC14jMKF1waVLQsXOU8x62A5mbjkaa6ZkwfPyYlo45x6SanJM7pyjgolZ3aLmTcC ar3nOONThWbmWPpe9AE0J3G6vYNCh29+Zy2JMXGWUO+JKeXbgsrYb3TyVHg+fOZv/3s1 EI5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Nk1868Hc; 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 r10-20020a63514a000000b00476f2b0b330si3791639pgl.700.2022.11.25.01.45.49; Fri, 25 Nov 2022 01:46:02 -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=Nk1868Hc; 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 S229681AbiKYJog (ORCPT + 99 others); Fri, 25 Nov 2022 04:44:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbiKYJo2 (ORCPT ); Fri, 25 Nov 2022 04:44:28 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23FB2263D for ; Fri, 25 Nov 2022 01:44:26 -0800 (PST) X-UUID: bacdaa27b4764b6eab6e6b8029f02a0b-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=ViGNiKiDlpdTwQms22X0e/YbhcaMRLoQ4ODpbxaV73U=; b=Nk1868Hcgm4Sga+1ga5TWD8mgqbGNFuaB+9VgtOxMoS0flBMK/6EB8jURuDUtVvhSRdk0q2GlCYbDjtFIliWz6hnAuN22WNVa4szQfY54yRoUkua9P9/OpujD28QjSWG6bgkmmFj0W4KFeYT6R1ztPGax6tacy/kznQsVfjwong=; X-CID-P-RULE: Spam_GS6885AD X-CID-O-INFO: VERSION:1.1.14,REQID:c6786ccd-b2fa-4eea-af45-1140bcce76df,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:28,RULE:Spam_GS6885AD,AC TION:quarantine,TS:118 X-CID-INFO: VERSION:1.1.14,REQID:c6786ccd-b2fa-4eea-af45-1140bcce76df,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:28,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:118 X-CID-META: VersionHash:dcaaed0,CLOUDID:b9843ddc-6ad4-42ff-91f3-18e0272db660,B ulkID:221124165445AUVM93DU,BulkQuantity:8,Recheck:0,SF:38|28|17|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: bacdaa27b4764b6eab6e6b8029f02a0b-20221125 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 631387422; Fri, 25 Nov 2022 17:44:19 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) 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:17 +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:16 +0800 From: Jiaxin Yu To: , , , , , , , CC: , , , , , , , , , Jiaxin Yu Subject: [PATCH v2 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets Date: Fri, 25 Nov 2022 17:44:12 +0800 Message-ID: <20221125094413.4940-3-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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY,URIBL_CSS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750460857952889008?= X-GMAIL-MSGID: =?utf-8?q?1750460857952889008?= 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 d8c93d66b4e6..f4960b0c8298 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c @@ -965,7 +965,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 e59d92e2afa3..c61e9bb419d4 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c @@ -1033,7 +1033,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 Fri Nov 25 09:44:13 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: 25904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3888347wrr; Fri, 25 Nov 2022 01:46:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf4CdWZTXiI0Bo+o/5D8OxknaApM451LX7hP35DMvAdYityRx7UMGRh8hf8Nrp7ukP8LnRFG X-Received: by 2002:a17:907:8d03:b0:7ae:1d34:4da5 with SMTP id tc3-20020a1709078d0300b007ae1d344da5mr27393773ejc.340.1669369611437; Fri, 25 Nov 2022 01:46:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669369611; cv=none; d=google.com; s=arc-20160816; b=Gb2yEgTpkqu891MpJwp/l/uleUrrPhCDy+SWhEqR7NbM6zrjgWyYH9UBbv36WfJPE/ 8DP7wz8DWxnzZJ6h4tfcVdtoTCNc8lWEBPMnXivg21wzJYp7bi19AeCzuY985E8c8N2G 19ERzOmSMGggKBHi8rB8yr3hOAqYmfGafp5UW8pIwW5hFr4MRjh26GxKNSxSQ1QdQiKy yfxa1u03LfaeD6uXwDbiPEOajxpNqCjPSlFSN1CwC0Z+WRTJkYeZsDnTGABtr/S/7PdE aAV94/TVl+PZHwpxWzJ0Y7+JFmo9PqELhu39zbLuuuGaZF3417m90bglRGYMrq6X3lZ3 nGew== 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=JypvWOdNIEwz4ySGYXhZj/2FoIW7K0jRr/E327f+FUM=; b=c6NuzpHjM5EICqF2vH9n9QluII/ict1PQD0l7urxaP6kcadOcN+5nrYMUG2JThwv2u 0mYt4jDZwfdfWtwLNCXxPpbMSVkbIvEmG+HHNkygERZxxIobKhAhBkqllxNwsj7oRWKM qmJGhoNWGfmjUCJBPkTioHTjaVNHkUbKFO9snx6kGoIfrJR8RYmTnRbyfa1y67YP1bfO H2+W5+gGxSQz70ouMmSSrrmc20K/HKFLes7LNvfCGcqk19Cy4sBpRD2k+LevSwBxHkUl Ka+wj2yCF22yNTmqZDNAgLKl4a+ca4LPLDWE4PfmhK11T3mYOBAiNSYtWXRg8KYxPaVj aVHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=gfzpOjLy; 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 dp22-20020a170906c15600b007bc30c06aa2si2038591ejc.902.2022.11.25.01.46.27; Fri, 25 Nov 2022 01:46:51 -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=gfzpOjLy; 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 S229706AbiKYJoj (ORCPT + 99 others); Fri, 25 Nov 2022 04:44:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbiKYJo2 (ORCPT ); Fri, 25 Nov 2022 04:44:28 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0786A21E37 for ; Fri, 25 Nov 2022 01:44:26 -0800 (PST) X-UUID: d7b13b76b8ca41439f178262884ac1ef-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=JypvWOdNIEwz4ySGYXhZj/2FoIW7K0jRr/E327f+FUM=; b=gfzpOjLywtPVCJsbZSnPvfHNTndgTWxnbMctwJlUDjrFBFvXwy9rRtnoJ/9FtrkOPLqZZtw5HvA6yIICYgoKppIXodZ7KdCd4Y2zilkYzIS2GWckPR78+13ot9RtSDU2f3ndaJnrSz8uCcFGXR1peua/3jSGCEizapkABWB9d5w=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:4d4efb44-c9d1-4d32-bb52-4da65630d1fe,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.14,REQID:4d4efb44-c9d1-4d32-bb52-4da65630d1fe,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:dcaaed0,CLOUDID:d4144ff9-3a34-4838-abcf-dfedf9dd068e,B ulkID:221125174421V9P0XGPU,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: d7b13b76b8ca41439f178262884ac1ef-20221125 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1112659408; Fri, 25 Nov 2022 17:44:20 +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:19 +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:18 +0800 From: Jiaxin Yu To: , , , , , , , CC: , , , , , , , , , Jiaxin Yu Subject: [PATCH v2 3/3] drm/bridge: it6505: Add audio support Date: Fri, 25 Nov 2022 17:44:13 +0800 Message-ID: <20221125094413.4940-4-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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY,URIBL_CSS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750460909513910522?= X-GMAIL-MSGID: =?utf-8?q?1750460909513910522?= 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 dfe4351c9bdd..1f1f37b3df83 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2159,7 +2159,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 */ @@ -2167,11 +2166,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); } @@ -2823,6 +2817,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, @@ -2837,6 +2870,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); @@ -3302,6 +3365,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);