2020-05-01 22:58:50 +08:00
|
|
|
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
|
2019-04-13 00:08:56 +08:00
|
|
|
//
|
|
|
|
// This file is provided under a dual BSD/GPLv2 license. When using or
|
|
|
|
// redistributing this file, you may do so under either license.
|
|
|
|
//
|
|
|
|
// Copyright(c) 2018 Intel Corporation. All rights reserved.
|
|
|
|
//
|
|
|
|
// Authors: Keyon Jie <yang.jie@linux.intel.com>
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <sound/hdaudio_ext.h>
|
2019-07-22 22:13:53 +08:00
|
|
|
#include <sound/hda_register.h>
|
2019-04-13 00:08:56 +08:00
|
|
|
#include <sound/hda_codec.h>
|
|
|
|
#include <sound/hda_i915.h>
|
|
|
|
#include <sound/sof.h>
|
|
|
|
#include "../ops.h"
|
|
|
|
#include "hda.h"
|
|
|
|
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
|
|
|
|
#include "../../codecs/hdac_hda.h"
|
|
|
|
#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */
|
|
|
|
|
2021-12-03 23:47:21 +08:00
|
|
|
#define CODEC_PROBE_RETRIES 3
|
|
|
|
|
2019-04-13 00:08:56 +08:00
|
|
|
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
|
|
|
|
#define IDISP_VID_INTEL 0x80860000
|
|
|
|
|
|
|
|
/* load the legacy HDA codec driver */
|
2020-05-30 00:03:58 +08:00
|
|
|
static int request_codec_module(struct hda_codec *codec)
|
2019-04-13 00:08:56 +08:00
|
|
|
{
|
2020-01-11 07:57:50 +08:00
|
|
|
#ifdef MODULE
|
2019-04-13 00:08:56 +08:00
|
|
|
char alias[MODULE_NAME_LEN];
|
2020-05-30 00:03:58 +08:00
|
|
|
const char *mod = NULL;
|
2019-04-13 00:08:56 +08:00
|
|
|
|
2020-05-30 00:03:58 +08:00
|
|
|
switch (codec->probe_id) {
|
|
|
|
case HDA_CODEC_ID_GENERIC:
|
|
|
|
#if IS_MODULE(CONFIG_SND_HDA_GENERIC)
|
|
|
|
mod = "snd-hda-codec-generic";
|
2019-04-13 00:08:56 +08:00
|
|
|
#endif
|
2020-05-30 00:03:58 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snd_hdac_codec_modalias(&codec->core, alias, sizeof(alias));
|
|
|
|
mod = alias;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mod) {
|
|
|
|
dev_dbg(&codec->core.dev, "loading codec module: %s\n", mod);
|
|
|
|
request_module(mod);
|
|
|
|
}
|
|
|
|
#endif /* MODULE */
|
2020-01-11 07:57:50 +08:00
|
|
|
return device_attach(hda_codec_dev(codec));
|
|
|
|
}
|
2019-04-13 00:08:56 +08:00
|
|
|
|
2020-05-30 00:03:58 +08:00
|
|
|
static int hda_codec_load_module(struct hda_codec *codec)
|
|
|
|
{
|
|
|
|
int ret = request_codec_module(codec);
|
|
|
|
|
|
|
|
if (ret <= 0) {
|
|
|
|
codec->probe_id = HDA_CODEC_ID_GENERIC;
|
|
|
|
ret = request_codec_module(codec);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-07-22 22:13:53 +08:00
|
|
|
/* enable controller wake up event for all codecs with jack connectors */
|
2021-01-13 02:11:24 +08:00
|
|
|
void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable)
|
2019-07-22 22:13:53 +08:00
|
|
|
{
|
|
|
|
struct hda_bus *hbus = sof_to_hbus(sdev);
|
|
|
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
|
|
|
struct hda_codec *codec;
|
|
|
|
unsigned int mask = 0;
|
|
|
|
|
2021-01-13 02:11:24 +08:00
|
|
|
if (enable) {
|
|
|
|
list_for_each_codec(codec, hbus)
|
|
|
|
if (codec->jacktbl.used)
|
|
|
|
mask |= BIT(codec->core.addr);
|
|
|
|
}
|
2019-07-22 22:13:53 +08:00
|
|
|
|
|
|
|
snd_hdac_chip_updatew(bus, WAKEEN, STATESTS_INT_MASK, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check jack status after resuming from suspend mode */
|
|
|
|
void hda_codec_jack_check(struct snd_sof_dev *sdev)
|
|
|
|
{
|
|
|
|
struct hda_bus *hbus = sof_to_hbus(sdev);
|
|
|
|
struct hda_codec *codec;
|
|
|
|
|
|
|
|
list_for_each_codec(codec, hbus)
|
|
|
|
/*
|
|
|
|
* Wake up all jack-detecting codecs regardless whether an event
|
|
|
|
* has been recorded in STATESTS
|
|
|
|
*/
|
|
|
|
if (codec->jacktbl.used)
|
2021-01-13 02:11:23 +08:00
|
|
|
pm_request_resume(&codec->core.dev);
|
2019-07-22 22:13:53 +08:00
|
|
|
}
|
|
|
|
#else
|
2021-01-13 02:11:24 +08:00
|
|
|
void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable) {}
|
2019-07-22 22:13:53 +08:00
|
|
|
void hda_codec_jack_check(struct snd_sof_dev *sdev) {}
|
2019-04-13 00:08:56 +08:00
|
|
|
#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */
|
2019-12-18 04:22:29 +08:00
|
|
|
EXPORT_SYMBOL_NS(hda_codec_jack_wake_enable, SND_SOC_SOF_HDA_AUDIO_CODEC);
|
|
|
|
EXPORT_SYMBOL_NS(hda_codec_jack_check, SND_SOC_SOF_HDA_AUDIO_CODEC);
|
2019-04-13 00:08:56 +08:00
|
|
|
|
2020-05-30 00:03:58 +08:00
|
|
|
#if IS_ENABLED(CONFIG_SND_HDA_GENERIC)
|
|
|
|
#define is_generic_config(bus) \
|
|
|
|
((bus)->modelname && !strcmp((bus)->modelname, "generic"))
|
|
|
|
#else
|
|
|
|
#define is_generic_config(x) 0
|
|
|
|
#endif
|
|
|
|
|
2022-08-16 19:17:23 +08:00
|
|
|
static void hda_codec_device_exit(struct device *dev)
|
|
|
|
{
|
|
|
|
snd_hdac_device_exit(dev_to_hdac_dev(dev));
|
|
|
|
}
|
|
|
|
|
2022-08-16 19:17:24 +08:00
|
|
|
static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, int type)
|
2022-08-16 19:17:23 +08:00
|
|
|
{
|
|
|
|
struct hda_codec *codec;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
codec = snd_hda_codec_device_init(to_hda_bus(bus), addr, "ehdaudio%dD%d", bus->idx, addr);
|
|
|
|
if (IS_ERR(codec)) {
|
|
|
|
dev_err(bus->dev, "device init failed for hdac device\n");
|
|
|
|
return codec;
|
|
|
|
}
|
|
|
|
|
|
|
|
codec->core.type = type;
|
|
|
|
codec->core.dev.release = hda_codec_device_exit;
|
|
|
|
|
|
|
|
ret = snd_hdac_device_register(&codec->core);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(bus->dev, "failed to register hdac device\n");
|
|
|
|
snd_hdac_device_exit(&codec->core);
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
return codec;
|
|
|
|
}
|
|
|
|
|
2019-04-13 00:08:56 +08:00
|
|
|
/* probe individual codec */
|
2022-10-28 03:35:20 +08:00
|
|
|
static int hda_codec_probe(struct snd_sof_dev *sdev, int address)
|
2019-04-13 00:08:56 +08:00
|
|
|
{
|
|
|
|
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
|
|
|
|
struct hdac_hda_priv *hda_priv;
|
2020-09-21 18:08:41 +08:00
|
|
|
int type = HDA_DEV_LEGACY;
|
2019-04-13 00:08:56 +08:00
|
|
|
#endif
|
2019-07-22 22:13:53 +08:00
|
|
|
struct hda_bus *hbus = sof_to_hbus(sdev);
|
2022-08-16 19:17:24 +08:00
|
|
|
struct hda_codec *codec;
|
2019-04-13 00:08:56 +08:00
|
|
|
u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) |
|
|
|
|
(AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
|
|
|
|
u32 resp = -1;
|
ASoC: SOF: Intel: Retry codec probing if it fails
On the latest Lenovo Thinkstation laptops, we often experience the
speaker failure after rebooting, check the dmesg, we could see:
sof-audio-pci-intel-tgl 0000:00:1f.3: codec #0 probe error, ret: -5
The analogue codec on the machine is ALC287, then we designed a
testcase to reboot and check the codec probing result repeatedly, we
found the analogue codec probing always failed at least once within
several minutes to several hours (roughly 1 reboot per min). This
issue happens on all laptops of this Thinkstation model, but with
legacy HDA driver, we couldn't reproduce this issue on those laptops.
And so far, this issue is not reproduced on machines which don't
belong to this model.
We tried to make the hda_dsp_ctrl_init_chip() same as
hda_intel_init_chip() which is the controller init routine in the
legacy HDA driver, but it didn't help.
We found when issue happens, the resp is -1, and if we let driver
re-run send_cmd() and get_response(), it will get the correct response
10ec0287, then driver continues the rest work, finally boot to the
desktop and all audio function work well.
Here adding codec probing retries to 3 times, it could fix the issue
on this Thinkstation model, and it doesn't bring impact to other
machines.
Reviewed-by: Bard Liao <bard.liao@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211130090606.529348-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-11-30 17:06:06 +08:00
|
|
|
int ret, retry = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
mutex_lock(&hbus->core.cmd_mutex);
|
|
|
|
snd_hdac_bus_send_cmd(&hbus->core, hda_cmd);
|
|
|
|
snd_hdac_bus_get_response(&hbus->core, address, &resp);
|
|
|
|
mutex_unlock(&hbus->core.cmd_mutex);
|
|
|
|
} while (resp == -1 && retry++ < CODEC_PROBE_RETRIES);
|
2019-04-13 00:08:56 +08:00
|
|
|
|
|
|
|
if (resp == -1)
|
|
|
|
return -EIO;
|
|
|
|
dev_dbg(sdev->dev, "HDA codec #%d probed OK: response: %x\n",
|
|
|
|
address, resp);
|
|
|
|
|
|
|
|
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
|
2019-06-26 15:04:50 +08:00
|
|
|
hda_priv = devm_kzalloc(sdev->dev, sizeof(*hda_priv), GFP_KERNEL);
|
2019-04-13 00:08:56 +08:00
|
|
|
if (!hda_priv)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2022-08-16 19:17:24 +08:00
|
|
|
codec = hda_codec_device_init(&hbus->core, address, type);
|
|
|
|
ret = PTR_ERR_OR_ZERO(codec);
|
2019-04-13 00:08:56 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2022-08-16 19:17:24 +08:00
|
|
|
hda_priv->codec = codec;
|
|
|
|
dev_set_drvdata(&codec->core.dev, hda_priv);
|
|
|
|
|
2020-02-21 01:10:28 +08:00
|
|
|
if ((resp & 0xFFFF0000) == IDISP_VID_INTEL) {
|
2022-08-16 19:17:24 +08:00
|
|
|
if (!hbus->core.audio_component) {
|
2020-02-21 01:10:28 +08:00
|
|
|
dev_dbg(sdev->dev,
|
|
|
|
"iDisp hw present but no driver\n");
|
ASoC: SOF: Intel: fix page fault at probe if i915 init fails
The earlier commit to fix runtime PM in case i915 init fails,
introduces a possibility to hit a page fault.
snd_hdac_ext_bus_device_exit() is designed to be called from
dev.release(). Calling it outside device reference counting, is
not safe and may lead to calling the device_exit() function
twice. Additionally, as part of ext_bus_device_init(), the device
is also registered with snd_hdac_device_register(). Thus before
calling device_exit(), the device must be removed from device
hierarchy first.
Fix the issue by rolling back init actions by calling
hdac_device_unregister() and then releasing device with put_device().
This matches with existing code in hdac-ext module.
To complete the fix, add handling for the case where
hda_codec_load_module() returns -ENODEV, and clean up the hdac_ext
resources also in this case.
In future work, hdac-ext interface should be extended to allow clients
more flexibility to handle the life-cycle of individual devices, beyond
just the current snd_hdac_ext_bus_device_remove(), which removes all
devices.
BugLink: https://github.com/thesofproject/linux/issues/2646
Reported-by: Jaroslav Kysela <perex@perex.cz>
Fixes: 6c63c954e1c5 ("ASoC: SOF: fix a runtime pm issue in SOF when HDMI codec doesn't work")
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Libin Yang <libin.yang@intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Link: https://lore.kernel.org/r/20210113150715.3992635-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-01-13 23:07:15 +08:00
|
|
|
ret = -ENOENT;
|
|
|
|
goto out;
|
2020-02-21 01:10:28 +08:00
|
|
|
}
|
2019-10-29 21:40:13 +08:00
|
|
|
hda_priv->need_display_power = true;
|
2020-02-21 01:10:28 +08:00
|
|
|
}
|
2019-10-29 21:40:13 +08:00
|
|
|
|
2020-05-30 00:03:58 +08:00
|
|
|
if (is_generic_config(hbus))
|
|
|
|
codec->probe_id = HDA_CODEC_ID_GENERIC;
|
|
|
|
else
|
|
|
|
codec->probe_id = 0;
|
|
|
|
|
2020-09-21 18:08:41 +08:00
|
|
|
if (type == HDA_DEV_LEGACY) {
|
2020-05-30 00:03:58 +08:00
|
|
|
ret = hda_codec_load_module(codec);
|
2020-01-11 07:57:50 +08:00
|
|
|
/*
|
|
|
|
* handle ret==0 (no driver bound) as an error, but pass
|
|
|
|
* other return codes without modification
|
|
|
|
*/
|
|
|
|
if (ret == 0)
|
ASoC: SOF: Intel: fix page fault at probe if i915 init fails
The earlier commit to fix runtime PM in case i915 init fails,
introduces a possibility to hit a page fault.
snd_hdac_ext_bus_device_exit() is designed to be called from
dev.release(). Calling it outside device reference counting, is
not safe and may lead to calling the device_exit() function
twice. Additionally, as part of ext_bus_device_init(), the device
is also registered with snd_hdac_device_register(). Thus before
calling device_exit(), the device must be removed from device
hierarchy first.
Fix the issue by rolling back init actions by calling
hdac_device_unregister() and then releasing device with put_device().
This matches with existing code in hdac-ext module.
To complete the fix, add handling for the case where
hda_codec_load_module() returns -ENODEV, and clean up the hdac_ext
resources also in this case.
In future work, hdac-ext interface should be extended to allow clients
more flexibility to handle the life-cycle of individual devices, beyond
just the current snd_hdac_ext_bus_device_remove(), which removes all
devices.
BugLink: https://github.com/thesofproject/linux/issues/2646
Reported-by: Jaroslav Kysela <perex@perex.cz>
Fixes: 6c63c954e1c5 ("ASoC: SOF: fix a runtime pm issue in SOF when HDMI codec doesn't work")
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Libin Yang <libin.yang@intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Link: https://lore.kernel.org/r/20210113150715.3992635-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-01-13 23:07:15 +08:00
|
|
|
ret = -ENOENT;
|
2019-04-13 00:08:56 +08:00
|
|
|
}
|
|
|
|
|
ASoC: SOF: Intel: fix page fault at probe if i915 init fails
The earlier commit to fix runtime PM in case i915 init fails,
introduces a possibility to hit a page fault.
snd_hdac_ext_bus_device_exit() is designed to be called from
dev.release(). Calling it outside device reference counting, is
not safe and may lead to calling the device_exit() function
twice. Additionally, as part of ext_bus_device_init(), the device
is also registered with snd_hdac_device_register(). Thus before
calling device_exit(), the device must be removed from device
hierarchy first.
Fix the issue by rolling back init actions by calling
hdac_device_unregister() and then releasing device with put_device().
This matches with existing code in hdac-ext module.
To complete the fix, add handling for the case where
hda_codec_load_module() returns -ENODEV, and clean up the hdac_ext
resources also in this case.
In future work, hdac-ext interface should be extended to allow clients
more flexibility to handle the life-cycle of individual devices, beyond
just the current snd_hdac_ext_bus_device_remove(), which removes all
devices.
BugLink: https://github.com/thesofproject/linux/issues/2646
Reported-by: Jaroslav Kysela <perex@perex.cz>
Fixes: 6c63c954e1c5 ("ASoC: SOF: fix a runtime pm issue in SOF when HDMI codec doesn't work")
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Libin Yang <libin.yang@intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Link: https://lore.kernel.org/r/20210113150715.3992635-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-01-13 23:07:15 +08:00
|
|
|
out:
|
|
|
|
if (ret < 0) {
|
2022-08-16 19:17:24 +08:00
|
|
|
snd_hdac_device_unregister(&codec->core);
|
|
|
|
put_device(&codec->core.dev);
|
ASoC: SOF: Intel: fix page fault at probe if i915 init fails
The earlier commit to fix runtime PM in case i915 init fails,
introduces a possibility to hit a page fault.
snd_hdac_ext_bus_device_exit() is designed to be called from
dev.release(). Calling it outside device reference counting, is
not safe and may lead to calling the device_exit() function
twice. Additionally, as part of ext_bus_device_init(), the device
is also registered with snd_hdac_device_register(). Thus before
calling device_exit(), the device must be removed from device
hierarchy first.
Fix the issue by rolling back init actions by calling
hdac_device_unregister() and then releasing device with put_device().
This matches with existing code in hdac-ext module.
To complete the fix, add handling for the case where
hda_codec_load_module() returns -ENODEV, and clean up the hdac_ext
resources also in this case.
In future work, hdac-ext interface should be extended to allow clients
more flexibility to handle the life-cycle of individual devices, beyond
just the current snd_hdac_ext_bus_device_remove(), which removes all
devices.
BugLink: https://github.com/thesofproject/linux/issues/2646
Reported-by: Jaroslav Kysela <perex@perex.cz>
Fixes: 6c63c954e1c5 ("ASoC: SOF: fix a runtime pm issue in SOF when HDMI codec doesn't work")
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Libin Yang <libin.yang@intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Link: https://lore.kernel.org/r/20210113150715.3992635-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-01-13 23:07:15 +08:00
|
|
|
}
|
2019-04-13 00:08:56 +08:00
|
|
|
#else
|
2022-08-19 20:47:40 +08:00
|
|
|
codec = hda_codec_device_init(&hbus->core, address, HDA_DEV_ASOC);
|
2022-08-16 19:17:24 +08:00
|
|
|
ret = PTR_ERR_OR_ZERO(codec);
|
ASoC: SOF: Intel: fix page fault at probe if i915 init fails
The earlier commit to fix runtime PM in case i915 init fails,
introduces a possibility to hit a page fault.
snd_hdac_ext_bus_device_exit() is designed to be called from
dev.release(). Calling it outside device reference counting, is
not safe and may lead to calling the device_exit() function
twice. Additionally, as part of ext_bus_device_init(), the device
is also registered with snd_hdac_device_register(). Thus before
calling device_exit(), the device must be removed from device
hierarchy first.
Fix the issue by rolling back init actions by calling
hdac_device_unregister() and then releasing device with put_device().
This matches with existing code in hdac-ext module.
To complete the fix, add handling for the case where
hda_codec_load_module() returns -ENODEV, and clean up the hdac_ext
resources also in this case.
In future work, hdac-ext interface should be extended to allow clients
more flexibility to handle the life-cycle of individual devices, beyond
just the current snd_hdac_ext_bus_device_remove(), which removes all
devices.
BugLink: https://github.com/thesofproject/linux/issues/2646
Reported-by: Jaroslav Kysela <perex@perex.cz>
Fixes: 6c63c954e1c5 ("ASoC: SOF: fix a runtime pm issue in SOF when HDMI codec doesn't work")
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Libin Yang <libin.yang@intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Link: https://lore.kernel.org/r/20210113150715.3992635-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-01-13 23:07:15 +08:00
|
|
|
#endif
|
2019-04-13 00:08:56 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Codec initialization */
|
2022-10-28 03:35:20 +08:00
|
|
|
void hda_codec_probe_bus(struct snd_sof_dev *sdev)
|
2019-04-13 00:08:56 +08:00
|
|
|
{
|
|
|
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
/* probe codecs in avail slots */
|
|
|
|
for (i = 0; i < HDA_MAX_CODECS; i++) {
|
|
|
|
|
|
|
|
if (!(bus->codec_mask & (1 << i)))
|
|
|
|
continue;
|
|
|
|
|
2022-10-28 03:35:20 +08:00
|
|
|
ret = hda_codec_probe(sdev, i);
|
2019-04-13 00:08:56 +08:00
|
|
|
if (ret < 0) {
|
2019-12-18 08:26:13 +08:00
|
|
|
dev_warn(bus->dev, "codec #%d probe error, ret: %d\n",
|
|
|
|
i, ret);
|
|
|
|
bus->codec_mask &= ~BIT(i);
|
2019-04-13 00:08:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-18 04:22:29 +08:00
|
|
|
EXPORT_SYMBOL_NS(hda_codec_probe_bus, SND_SOC_SOF_HDA_AUDIO_CODEC);
|
2019-04-13 00:08:56 +08:00
|
|
|
|
2019-10-29 21:40:13 +08:00
|
|
|
#if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI) || \
|
|
|
|
IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)
|
2019-04-13 00:08:56 +08:00
|
|
|
|
2020-01-21 00:01:15 +08:00
|
|
|
void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable)
|
2019-04-13 00:08:56 +08:00
|
|
|
{
|
|
|
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
|
|
|
|
2020-02-07 04:02:22 +08:00
|
|
|
if (HDA_IDISP_CODEC(bus->codec_mask)) {
|
|
|
|
dev_dbg(bus->dev, "Turning i915 HDAC power %d\n", enable);
|
|
|
|
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, enable);
|
|
|
|
}
|
2019-04-13 00:08:56 +08:00
|
|
|
}
|
2020-01-21 00:01:15 +08:00
|
|
|
EXPORT_SYMBOL_NS(hda_codec_i915_display_power, SND_SOC_SOF_HDA_AUDIO_CODEC_I915);
|
2019-04-13 00:08:56 +08:00
|
|
|
|
|
|
|
int hda_codec_i915_init(struct snd_sof_dev *sdev)
|
|
|
|
{
|
|
|
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* i915 exposes a HDA codec for HDMI audio */
|
|
|
|
ret = snd_hdac_i915_init(bus);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2020-02-07 04:02:22 +08:00
|
|
|
/* codec_mask not yet known, power up for probe */
|
|
|
|
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
|
2019-04-13 00:08:56 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2019-12-18 04:22:29 +08:00
|
|
|
EXPORT_SYMBOL_NS(hda_codec_i915_init, SND_SOC_SOF_HDA_AUDIO_CODEC_I915);
|
2019-04-13 00:08:56 +08:00
|
|
|
|
|
|
|
int hda_codec_i915_exit(struct snd_sof_dev *sdev)
|
|
|
|
{
|
|
|
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
|
|
|
|
2020-02-21 01:10:28 +08:00
|
|
|
if (!bus->audio_component)
|
|
|
|
return 0;
|
|
|
|
|
2020-02-07 04:02:22 +08:00
|
|
|
/* power down unconditionally */
|
|
|
|
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
|
2019-04-13 00:08:56 +08:00
|
|
|
|
2020-04-10 02:48:52 +08:00
|
|
|
return snd_hdac_i915_exit(bus);
|
2019-04-13 00:08:56 +08:00
|
|
|
}
|
2019-12-18 04:22:29 +08:00
|
|
|
EXPORT_SYMBOL_NS(hda_codec_i915_exit, SND_SOC_SOF_HDA_AUDIO_CODEC_I915);
|
2019-04-13 00:08:56 +08:00
|
|
|
|
2019-10-29 21:40:13 +08:00
|
|
|
#endif
|
2019-04-13 00:08:56 +08:00
|
|
|
|
|
|
|
MODULE_LICENSE("Dual BSD/GPL");
|