ALSA: hda/hdmi: Add Intel silent stream support
PATCH v2 1/1 ALSA: hda/hdmi: Add Intel silent stream support
External HDMI receivers have analog circuitry that needs to be powered-on when exiting standby, and a mechanism to detect PCM v. IEC61937 data. These two steps take time and up to 2-3 seconds of audio may be muted when starting playback.
Intel hardware can keep the link active with a 'silent stream', so that the receiver does not go through those two steps when valid audio is transmitted. This mechanism relies on an info packet and preventing the codec from going to D3, which will increase the platform static power consumption. The info packet assumes a basic 2ch stereo, and the silent stream is enabled when connecting a monitor. In case of format changes the detection of PCM v. IEC61937 needs to be re-run. In this case there is no way to avoid the 2-3s mute.
The silent stream is enabled with a Kconfig option, as well as a kernel parameter should there be a need to override the build time default. This approach is used based on the power_save capability as an example, but in the future, it may be used with a kcontrol, depending on UCM support for HDaudio legacy.
Silent stream is supported in Intel platforms Skylake and beyond. Tested HDMI plug-out plug-in from Intel Cometlake based Chromebook connected to few different monitors.
---
Change History:
v2:
- Kconfig symbol depends on SND_HDA_INTEL.
- Added valid eld check to along side of silent stream enable check, under which silent stream is enabled.
- Error prints added for codec power up, power down functions.
- The silent stream is enabled with a Kconfig/module parameter following the power_save capability as an example. But in the future, it may be used with a kcontrol, depending on UCM support for HDaudio legacy.
v1:
- Initial version.
sound/pci/hda/Kconfig | 16 ++++++++++++++ sound/pci/hda/patch_hdmi.c | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+)
sound/pci/hda/Kconfig +16 -0
@@ -232,4 +232,20 @@ config SND_HDA_POWER_SAVE_DEFAULT endif +config SND_HDA_INTEL_HDMI_SILENT_STREAM + bool "Enable Silent Stream always for HDMI" + depends on SND_HDA_INTEL + help + Intel hardware has a feature called 'silent stream', that + keeps external HDMI receiver's analog circuitry powered on + avoiding 2-3 sec silence during playback start. This mechanism + relies on an info packet and preventing the codec from going to + D3. (increasing the platform static power consumption when a + HDMI receiver is plugged-in). 2-3 sec silence at the playback + start is expected whenever there is format change. (default is + 2 channel format). + Say Y to enable Silent Stream feature. + +endif + endmenu
sound/pci/hda/patch_hdmi.c +45 -0
72 lines not on this page · raw message
Signature · 1 line
2.17.1
Hi,
hmm, I think a few review comments from Takashi were missed. See inline:
sound/pci/hda/Kconfig config SND_HDA_POWER_SAVE_DEFAULT · line 237
Quoted 9 lines · Harsha Priya
sound/pci/hda/Kconfig +3
-0@@ -232,4 +232,20 @@ config SND_HDA_POWER_SAVE_DEFAULT endif +config SND_HDA_INTEL_HDMI_SILENT_STREAM + bool "Enable Silent Stream always for HDMI" + depends on SND_HDA_INTEL
Takashi requested to limit this to Intel hardware only, and despite the its name, SND_HDA_INTEL is not sufficient to do this.
I think best would be to take silent stream into use in intel_hsw_common_init(). That indirection would also protect against user-space modifying the module parameter value during execution (it is only evaluated in intel_hsw_common_init()).
Quoted 8 lines
sound/pci/hda/Kconfig +8
-0+ if (enable_silent_stream && eld->eld_valid) { + int pm_ret; + + if (!monitor_prev && monitor_next && eld->eld_valid) { + pm_ret = snd_hda_power_up_pm(codec); + if (pm_ret < 0) + codec_err(codec, + "Monitor plugged-in, Failed to power up codec ret=[%d]\n",
sound/pci/hda/Kconfig config SND_HDA_POWER_SAVE_DEFAULT
Quoted 10 lines
sound/pci/hda/Kconfig +10
-0+ pm_ret); + silent_stream_enable(codec, per_pin); + } else if (monitor_prev && !monitor_next && !eld->eld_valid) { + pm_ret = snd_hda_power_down_pm(codec); + if (pm_ret < 0) + codec_err(codec, + "Monitor plugged-out, Failed to power down codec ret=[%d]\n", + pm_ret); + } + }
There a bug in above, outer "if" checks for "eld_valid" while inner "else-if" checks for "!eld_valid" -> latter can never be reached.
Takashi, I was checking older code history on the acomp interface, and at least on Intel platforms using acomp, it is sufficient to check for eld->monitor_present. I.e. in
» eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, » » » » per_pin->dev_id, &eld->monitor_present, » » » » eld->eld_buffer, ELD_MAX_SIZE); » eld->eld_valid = (eld->eld_size > 0);
... monitor_present will always be 0 if eld_size<0 (and eld_valid is set to 0). An error monitor_present will not be set, but sync_eld_via_acomp() initialized the value to 0 for this case.
The additional checks in the patch are thus harmless, but make the code a bit suspicious looking. If the above did not hold, you could have a sequence like
monitor_prev=0, monitor_next=1, eld_valid=1 -> power-up monitor_prev=1, monitor_next=0, eld_valid=0 -> no op monitor_prev=0, monitor_next=1, eld_valid=1 -> power-up again
.. so the refcounting would go out of sync. So I'd rather just track the two variables.
Br, Kai
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Harsha,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on sound/for-next]
[also build test ERROR on v5.8-rc3 next-20200701]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Harsha-Priya/ALSA-hda-hdmi-Add-Intel-silent-stream-support/20200630-082719 base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next config: ia64-randconfig-s032-20200701 compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-3-gfa153962-dirty
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> sound/pci/hda/Kconfig:258: unexpected 'if' within menu block >> sound/pci/hda/Kconfig:260: unexpected 'menu' within if block sound/Kconfig:102: 'if' in different file than 'if' sound/pci/hda/Kconfig:2: location of the 'if' sound/Kconfig:104: 'if' in different file than 'if' sound/pci/hda/Kconfig:2: location of the 'if' >> sound/Kconfig:106: unexpected 'if' within menu block >> drivers/Kconfig:239: syntax error
drivers/Kconfig:238: invalid statement
make[2]: *** [scripts/kconfig/Makefile:71: oldconfig] Error 1 make[1]: *** [Makefile:606: oldconfig] Error 2
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'oldconfig' not remade because of errors.
--
>> sound/pci/hda/Kconfig:258: unexpected 'if' within menu block >> sound/pci/hda/Kconfig:260: unexpected 'menu' within if block sound/Kconfig:102: 'if' in different file than 'if' sound/pci/hda/Kconfig:2: location of the 'if' sound/Kconfig:104: 'if' in different file than 'if' sound/pci/hda/Kconfig:2: location of the 'if' >> sound/Kconfig:106: unexpected 'if' within menu block >> drivers/Kconfig:239: syntax error
drivers/Kconfig:238: invalid statement
make[2]: *** [scripts/kconfig/Makefile:71: olddefconfig] Error 1 make[1]: *** [Makefile:606: olddefconfig] Error 2
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'olddefconfig' not remade because of errors.
vim +/if +258 sound/pci/hda/Kconfig
243
244 config SND_HDA_INTEL_HDMI_SILENT_STREAM
245 bool "Enable Silent Stream always for HDMI"
246 depends on SND_HDA_INTEL
247 help
248 Intel hardware has a feature called 'silent stream', that 249 keeps external HDMI receiver's analog circuitry powered on 250 avoiding 2-3 sec silence during playback start. This mechanism 251 relies on an info packet and preventing the codec from going to 252 D3. (increasing the platform static power consumption when a 253 HDMI receiver is plugged-in). 2-3 sec silence at the playback 254 start is expected whenever there is format change. (default is 255 2 channel format). 256 Say Y to enable Silent Stream feature. 257 > 258 endif 259 > 260 endmenu
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org