-
Notifications
You must be signed in to change notification settings - Fork 140
Enable WAKEEN feature in sof hda driver #983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
|
|
||
| #include <linux/module.h> | ||
| #include <sound/hdaudio_ext.h> | ||
| #include <sound/hda_register.h> | ||
| #include <sound/hda_codec.h> | ||
| #include <sound/hda_i915.h> | ||
| #include <sound/sof.h> | ||
|
|
@@ -37,16 +38,55 @@ static void hda_codec_load_module(struct hda_codec *codec) | |
| static void hda_codec_load_module(struct hda_codec *codec) {} | ||
| #endif | ||
|
|
||
| /* check jack status after resuming from suspend mode */ | ||
| void hda_codec_jack_check(struct snd_sof_dev *sdev, int status) | ||
| { | ||
| struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; | ||
| struct hda_bus *hbus = sof_to_hbus(sdev); | ||
| struct hdac_bus *bus = sof_to_bus(sdev); | ||
| struct hda_codec *codec; | ||
| int mask; | ||
|
|
||
| /* | ||
| * there are two reasons for runtime resume | ||
| * (1) waken up by interrupt triggered by WAKEEN feature | ||
| * (2) waken up by pm get functions for some audio operations | ||
| * For case (1), the bits in status mean which codec triggers | ||
| * the interrupt and jacks will be checked on these codecs. | ||
| * For case (2), we need to check all the non-hdmi codecs for some | ||
| * cases like playback with HDMI or capture with DMIC. In these | ||
| * cases, only controller is active and codecs are suspended, so | ||
| * codecs can't send unsolicited event to controller. The jack polling | ||
| * operation will activate codecs and unsolicited event can work | ||
| * even codecs become suspended later. | ||
| */ | ||
| mask = status ? status : hda->hda_codec_mask; | ||
|
|
||
| list_for_each_codec(codec, hbus) | ||
| if (mask & BIT(codec->core.addr)) | ||
| schedule_delayed_work(&codec->jackpoll_work, | ||
| codec->jackpoll_interval); | ||
|
||
|
|
||
| /* disable controller Wake Up event*/ | ||
| snd_hdac_chip_writew(bus, WAKEEN, | ||
| snd_hdac_chip_readw(bus, WAKEEN) & | ||
| ~hda->hda_codec_mask); | ||
| } | ||
| #else | ||
| void hda_codec_jack_check(struct snd_sof_dev *sdev, int status) {} | ||
| #endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ | ||
| EXPORT_SYMBOL(hda_codec_jack_check); | ||
|
|
||
| /* probe individual codec */ | ||
| static int hda_codec_probe(struct snd_sof_dev *sdev, int address) | ||
| { | ||
| struct hda_bus *hbus = sof_to_hbus(sdev); | ||
| struct hdac_device *hdev; | ||
| #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) | ||
| struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; | ||
| struct hdac_hda_priv *hda_priv; | ||
| #endif | ||
| struct hda_bus *hbus = sof_to_hbus(sdev); | ||
| struct hdac_device *hdev; | ||
|
|
||
| u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) | | ||
| (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID; | ||
| u32 resp = -1; | ||
|
|
@@ -76,6 +116,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address) | |
| /* use legacy bus only for HDA codecs, idisp uses ext bus */ | ||
| if ((resp & 0xFFFF0000) != IDISP_VID_INTEL) { | ||
| hdev->type = HDA_DEV_LEGACY; | ||
| hda->hda_codec_mask |= BIT(address); | ||
| hda_codec_load_module(&hda_priv->codec); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -392,6 +392,9 @@ struct sof_intel_hda_dev { | |
|
|
||
| /* DMIC device */ | ||
| struct platform_device *dmic_dev; | ||
|
|
||
| /* hda codec mask excluding hdmi */ | ||
| u32 hda_codec_mask; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RanderWang @plbossart @ranj063 Is this really needed? Wouldn't it be enough to check codec->jacktbl.used?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hda_codec_mask is used by enable & disable WAKEEN, please check other change in the PR. codec->jacktbl.used is not available. |
||
| }; | ||
|
|
||
| static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s) | ||
|
|
@@ -550,6 +553,7 @@ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev, | |
| * HDA Codec operations. | ||
| */ | ||
| int hda_codec_probe_bus(struct snd_sof_dev *sdev); | ||
| void hda_codec_jack_check(struct snd_sof_dev *sdev, int status); | ||
|
|
||
| #endif /* CONFIG_SND_SOC_SOF_HDA */ | ||
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RanderWang @plbossart Sorry, I don't understand this. Now you check jack-status of every codec on every runtime-resume?.. This seems wrong to me. Jack status change should be detected when the change happens, not when the next rtpm-resume is happening. This really doesn't look right to me, please, explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check comments in this function