diff --git a/device/community/linux-postmarketos-mediatek-mt81/APKBUILD b/device/community/linux-postmarketos-mediatek-mt81/APKBUILD index 256ebab71..16cf77968 100644 --- a/device/community/linux-postmarketos-mediatek-mt81/APKBUILD +++ b/device/community/linux-postmarketos-mediatek-mt81/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: WeirdTreeThing pkgname=linux-postmarketos-mediatek-mt81 pkgver=6.12.36 -pkgrel=0 +pkgrel=1 pkgdesc="Mainline kernel for mediatek mt8183/mt8192/mt8195/mt8186" arch="aarch64" _flavor="${pkgname#linux-}" @@ -58,6 +58,10 @@ source=" STOPSHIP-arm64-dts-mediatek-asurada-Enable-HDMI-audio.patch mt8186-enable-dpi.patch mt8186-add-extcon-to-dp-bridge.patch + mt8186-ASoC-hdmi-codec-Add-event-handler-for-hdmi-TX.patch + mt8186-SoC-mediatek-mt8186-correct-the-HDMI-widgets.patch + mt8186-drm-bridge-it6505-Add-audio-support.patch + mt8186-ASoC-mediatek-mt8186-make-FE-nonatomic-and-no_pcm.patch mt8195-adsp.patch mt8195-dvfsrc.patch config-$_flavor.aarch64 @@ -113,4 +117,8 @@ e4eaff9d3ec1a56ae2503dd353ad57bf072219e68c26ba8b894feb90d6ccb01bd131cdde8d238451 7582a86506ec1ff0a08ae52d249fa465f436439b01b592fe01f7aaa2fbdb3b2ae989473cd5cd9d39e6e9dac60d847063fa66ef36b808be695aa62b512d722d2b mt8195-adsp.patch c61890785079aa67a4b92a30955cc7b2b1e1f8460255f2391b3d11f76c0e9568fe7dc9710e542392d42bf0a4426e1d47d7287621166e0cc9aa0333382ebd2cd2 mt8195-dvfsrc.patch 9990a6ba76a641cd9724e8b4369c1792a9650fbdf44142ca69dec83eff0bf56cac200fa3a0ec6e47380949e29988518dcf73c1aa96572a0387367ba3d19eccec config-postmarketos-mediatek-mt81.aarch64 +994f51fe70b49e324325b2d3d27b994c25af23210b579852424cc1c772f2189811cd51def49ab1be8f35b77e8bd1e387993f621238cc07dad4b805dab9e2f86b mt8186-ASoC-mediatek-mt8186-make-FE-nonatomic-and-no_pcm.patch +e09b8fc578742b0efcfb7e4419b30de39feecf3303def62576110c98e3a7101c68c78d1276f885e585ee21536df1f2474df5816f0dffa8f99ea1df1c787fe2c6 mt8186-drm-bridge-it6505-Add-audio-support.patch +2c282b7cd4f72c998d65e4160b9d1f9122676a6392ef45f734dbd5428754eccc06404a057ea19ea097bf6237e27b3483c271c1ed15b20e359419ab9fb61b8d83 mt8186-ASoC-hdmi-codec-Add-event-handler-for-hdmi-TX.patch +b2dcf3e3b9f80d185f587972ab6fc1f07e8ec7c7dbe3aa75c53ff6d3c7380ff4c3e6f394792976589d5e786923939a0860c70b486ae78925d0f122a5bf2516e0 mt8186-SoC-mediatek-mt8186-correct-the-HDMI-widgets.patch " diff --git a/device/community/linux-postmarketos-mediatek-mt81/mt8186-ASoC-hdmi-codec-Add-event-handler-for-hdmi-TX.patch b/device/community/linux-postmarketos-mediatek-mt81/mt8186-ASoC-hdmi-codec-Add-event-handler-for-hdmi-TX.patch new file mode 100644 index 000000000..f6e59e3d7 --- /dev/null +++ b/device/community/linux-postmarketos-mediatek-mt81/mt8186-ASoC-hdmi-codec-Add-event-handler-for-hdmi-TX.patch @@ -0,0 +1,105 @@ +From 919f122e1e81e7f83afc1097ab2c91c7ceada9f9 Mon Sep 17 00:00:00 2001 +From: Michal Bogdziewicz +Date: Sun, 27 Jul 2025 15:36:24 +0200 +Subject: [PATCH 2/4] ASoC: hdmi-codec: Add event handler for hdmi TX + +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. +--- + 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 5e1a9eafd10f..1d0f5307d77a 100644 +--- a/include/sound/hdmi-codec.h ++++ b/include/sound/hdmi-codec.h +@@ -80,6 +80,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 d9df29a26f4f..5cc6645e7a1e 100644 +--- a/sound/soc/codecs/hdmi-codec.c ++++ b/sound/soc/codecs/hdmi-codec.c +@@ -290,7 +290,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; + } +-- +2.50.0 + diff --git a/device/community/linux-postmarketos-mediatek-mt81/mt8186-ASoC-mediatek-mt8186-make-FE-nonatomic-and-no_pcm.patch b/device/community/linux-postmarketos-mediatek-mt81/mt8186-ASoC-mediatek-mt8186-make-FE-nonatomic-and-no_pcm.patch new file mode 100644 index 000000000..a28000488 --- /dev/null +++ b/device/community/linux-postmarketos-mediatek-mt81/mt8186-ASoC-mediatek-mt8186-make-FE-nonatomic-and-no_pcm.patch @@ -0,0 +1,229 @@ +From 7e4edd99d3e2fe9b6910398357d2101c7eb19d96 Mon Sep 17 00:00:00 2001 +From: Michal Bogdziewicz +Date: Sun, 27 Jul 2025 15:40:31 +0200 +Subject: [PATCH 4/4] ASoC: mediatek: mt8186: make FE nonatomic and no_pcm + +FE and BE for mt8186 are controled by SOF so they are +not connected in kernel. ALSA uses: + - SOF_DL1 + - SOF_DL2 + - SOF_UL1 + - SOF_DL2 +for audio. +--- + sound/soc/mediatek/mt8186/mt8186-mt6366.c | 45 +++++++++++++++++++++++ + 1 file changed, 45 insertions(+) + +diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366.c b/sound/soc/mediatek/mt8186/mt8186-mt6366.c +index da5db61af649..009fa78ce328 100644 +--- a/sound/soc/mediatek/mt8186/mt8186-mt6366.c ++++ b/sound/soc/mediatek/mt8186/mt8186-mt6366.c +@@ -647,6 +647,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_merged_format = 1, + .dpcm_merged_chan = 1, +@@ -660,6 +662,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + SND_SOC_DAILINK_REG(playback12), + }, +@@ -669,6 +673,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_merged_format = 1, + .dpcm_merged_chan = 1, +@@ -681,6 +687,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_merged_format = 1, + .dpcm_merged_chan = 1, +@@ -694,6 +702,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + SND_SOC_DAILINK_REG(playback4), + }, +@@ -703,6 +713,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + SND_SOC_DAILINK_REG(playback5), + }, +@@ -712,6 +724,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + SND_SOC_DAILINK_REG(playback6), + }, +@@ -721,6 +735,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + SND_SOC_DAILINK_REG(playback7), + }, +@@ -730,6 +746,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + SND_SOC_DAILINK_REG(playback8), + }, +@@ -739,6 +757,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_capture = 1, + SND_SOC_DAILINK_REG(capture1), + }, +@@ -748,6 +768,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_capture = 1, + .dpcm_merged_format = 1, + .dpcm_merged_chan = 1, +@@ -761,6 +783,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_capture = 1, + SND_SOC_DAILINK_REG(capture3), + }, +@@ -770,6 +794,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_capture = 1, + .dpcm_merged_format = 1, + .dpcm_merged_chan = 1, +@@ -783,6 +809,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_capture = 1, + SND_SOC_DAILINK_REG(capture5), + }, +@@ -792,6 +820,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_capture = 1, + .dpcm_merged_format = 1, + .dpcm_merged_chan = 1, +@@ -804,6 +834,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_capture = 1, + SND_SOC_DAILINK_REG(capture7), + }, +@@ -813,6 +845,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ignore_suspend = 1, +@@ -824,6 +858,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ignore_suspend = 1, +@@ -835,6 +871,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ignore_suspend = 1, +@@ -846,6 +884,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ignore_suspend = 1, +@@ -857,6 +897,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_capture = 1, + .ignore_suspend = 1, + SND_SOC_DAILINK_REG(hostless_hw_gain_aaudio), +@@ -867,6 +909,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + .trigger = {SND_SOC_DPCM_TRIGGER_PRE, + SND_SOC_DPCM_TRIGGER_PRE}, + .dynamic = 1, ++ .nonatomic = 1, ++ .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ignore_suspend = 1, +@@ -876,6 +920,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = { + { + .name = "Primary Codec", + .no_pcm = 1, ++ .nonatomic = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ignore_suspend = 1, +-- +2.50.0 + diff --git a/device/community/linux-postmarketos-mediatek-mt81/mt8186-SoC-mediatek-mt8186-correct-the-HDMI-widgets.patch b/device/community/linux-postmarketos-mediatek-mt81/mt8186-SoC-mediatek-mt8186-correct-the-HDMI-widgets.patch new file mode 100644 index 000000000..e0d3466ba --- /dev/null +++ b/device/community/linux-postmarketos-mediatek-mt81/mt8186-SoC-mediatek-mt8186-correct-the-HDMI-widgets.patch @@ -0,0 +1,27 @@ +From ffffe9745bc0f6925059165354c889053873cdd8 Mon Sep 17 00:00:00 2001 +From: Michal Bogdziewicz +Date: Sun, 27 Jul 2025 15:37:23 +0200 +Subject: [PATCH 3/4] SoC: mediatek: mt8186: correct the HDMI widgets + +Use SND_SOC_DAPM_LINE instead of SND_SOC_DAPM_OUTPUT to trigger +DAPM events to hdmi-codec when userspace control the DPAM pin. +--- + sound/soc/mediatek/mt8186/mt8186-mt6366.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366.c b/sound/soc/mediatek/mt8186/mt8186-mt6366.c +index 771d53611c2a..da5db61af649 100644 +--- a/sound/soc/mediatek/mt8186/mt8186-mt6366.c ++++ b/sound/soc/mediatek/mt8186/mt8186-mt6366.c +@@ -1053,7 +1053,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), +-- +2.50.0 + diff --git a/device/community/linux-postmarketos-mediatek-mt81/mt8186-drm-bridge-it6505-Add-audio-support.patch b/device/community/linux-postmarketos-mediatek-mt81/mt8186-drm-bridge-it6505-Add-audio-support.patch new file mode 100644 index 000000000..035712d27 --- /dev/null +++ b/device/community/linux-postmarketos-mediatek-mt81/mt8186-drm-bridge-it6505-Add-audio-support.patch @@ -0,0 +1,139 @@ +From 184d39288bb181eeb36640f9369bbc9409ecad56 Mon Sep 17 00:00:00 2001 +From: Michal Bogdziewicz +Date: Sun, 27 Jul 2025 15:34:04 +0200 +Subject: [PATCH 1/4] drm/bridge: it6505: Add audio support + +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. +--- + drivers/gpu/drm/bridge/ite-it6505.c | 82 ++++++++++++++++++++++++++--- + 1 file changed, 75 insertions(+), 7 deletions(-) + +diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c +index 967aa24b7c53..b176e80b4132 100644 +--- a/drivers/gpu/drm/bridge/ite-it6505.c ++++ b/drivers/gpu/drm/bridge/ite-it6505.c +@@ -2175,19 +2175,12 @@ static void it6505_stop_link_train(struct it6505 *it6505) + + static void it6505_link_train_ok(struct it6505 *it6505) + { +- struct device *dev = it6505->dev; +- + it6505->link_state = LINK_OK; + /* disalbe mute enable avi info frame */ + it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, EN_VID_MUTE, 0x00); + 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); + } +@@ -2896,6 +2889,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->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, +@@ -2910,6 +2942,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); +@@ -3470,6 +3532,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); +-- +2.50.0 +