On 31. 03. 23 16:22, Takashi Iwai wrote:
When a DRM driver turns on or off the screen with the audio capability, it notifies the ELD to HD-audio HDMI codec driver via component ops. HDMI codec driver, in turn, attaches or detaches the PCM stream for the given port on the fly.
The problem is that, since the recent code change, the HDMI driver always treats the PCM stream assignment dynamically; this ended up the confusion of the PCM device appearance. e.g. when a screen goes once off and on again, it may appear on a different PCM device before the screen-off. Although the application should treat such a change, it doesn't seem working gracefully with the current pipewire (maybe PulseAudio, too).
As a workaround, this patch changes the HDMI codec driver behavior slightly to be more consistent. Now it remembers the previous PCM slot for the given port and try to assign to it. That is, if a port is re-enabled, the driver tries to use the same PCM slot that was assigned to that port previously. If it conflicts, a new slot is searched and used like before, instead.
I don't like this workaround so much, because the devices should be assigned from the first PCM device.
The sound server should combine the persistent path only from the ELD information for the HDMI devices (if present). The problem may be when multiple similar monitors are connected to the machine. It would be probably nice to have an unique PCM device name for this usage with the serial number of the connected monitor (but I don't think it's in ELD? - it is in the EDID spec thought).
@@ -1399,6 +1408,7 @@ static void hdmi_detach_hda_pcm(struct hdmi_spec *spec, idx = per_pin->pcm_idx; per_pin->pcm_idx = -1; per_pin->pcm = NULL;
- per_pin->prev_pcm_idx = idx;
Maybe this line should be moved up before 'pcm = NULL'. The pcm_idx and prev_pcm_idx members are related.
For now:
Reviewed-by: Jaroslav Kysela perex@perex.cz
Jaroslav