Actually the problem happens also with plain PCM rendered on the iec958 device.There's no way to use the IEC switch. So why do we have an S/PDIF switch in the first place?
Because the hardware has this switch; the driver just exposes all hardware features.
Then why not use it if it is supported by the hardware? Usually we use software as a workaround for hw limitations, not software to prevent use of hardware features.
Some codecs allow looping back the ADC output to the SPDIF transmitter. In these cases, disabling the SPDIF transmitter might be useful.
I am not sure I understand how your remark is related to the problem I reported. Yes disabling SPDIF whenever needed is a must. And no there's no risk with enabling the IEC switch when rendering on the iec958 device. I have IEC-formatted data, with C,U,V,P bits and preambles, this could not possibly be sent to anything else than the digital output. Again the IEC switch is functionally equivalent to a mute, and it shows as such in alsamixer with the MM symbol: the data keeps being rendered, only the receiver doesn't detect valid data (no sync detected) and will go to silence with an appropriate ramp. For AC3 passthrough, the filter history will be reset when the sync is lost, and that will cause an implicit fade-out/fade-in in addition to the PCM ramp. There is no need as you asserted to send zeroes instead. Removing the 'lock true' in /usr/share/alsa/cards/HDA-Intel.conf h works just fine to enable IEC controls. Thanks Pavel for the pointer. I suggest we modify this to remove artificial functionality limitations.