Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2DD5C76196 for ; Fri, 31 Mar 2023 15:32:17 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id F19911F9; Fri, 31 Mar 2023 17:31:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F19911F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1680276735; bh=Bq+ghryQsYJ+zeQTO6IvULC9slWkhu0W/64FHfJXgqU=; h=Date:From:To:Subject:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PDIddZ6gRSjd8g7nUcxiexzt0I8SxLsaKfM43oyzWm2phQSeZwIc6Oov2pbj1PNWm YUs6xqEwQXto387A4XeC0EqO2wiBWDruVB5YqJYie82mErhIcOFXIQT0HLWN1RL22y Y5yftmzGlxBYfk4EsxPMKh+KheO9F6dPpgaA4fbI= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D76D6F80272; Fri, 31 Mar 2023 17:31:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 04A49F80272; Fri, 31 Mar 2023 17:30:59 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 13AE8F8021D for ; Fri, 31 Mar 2023 17:30:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 13AE8F8021D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ZhQ2vAqt; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=6hPpz/M4 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 40FC8219C6; Fri, 31 Mar 2023 15:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680276651; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=u6F6xATUAEVOoy5rP/5bDx7P9FAntX65m2lH47m4CVE=; b=ZhQ2vAqtUJiKlrSW+4IfOWqzpqnFYIgP1RDlz5mxRgxHI5sj97KGtvyawtktyHopjr1cGM zxIzguwldWRPRF1r1btaKPhdZXlm/y14MjQcxlGFfL933s6tAOdETx368hpQfXNkcWfLFI Ifmtgs8ZjkV7Lmhm6dYkJN2z9fsauEg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680276651; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=u6F6xATUAEVOoy5rP/5bDx7P9FAntX65m2lH47m4CVE=; b=6hPpz/M4UehqjMJdaegwm65CXPVHQ9LaBsOz8O+i9KbeKlhHizggYsVehOhQrZsmauhQ55 kVcCUg7LEEdh1xAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1C985133B6; Fri, 31 Mar 2023 15:30:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id g+s3Bqv8JmTnCwAAMHmgww (envelope-from ); Fri, 31 Mar 2023 15:30:51 +0000 Date: Fri, 31 Mar 2023 17:30:50 +0200 Message-ID: <87v8ihhr9x.wl-tiwai@suse.de> From: Takashi Iwai To: Jaroslav Kysela Subject: Re: [PATCH] ALSA: hda/hdmi: Preserve the previous PCM device upon re-enablement In-Reply-To: <57ffa8e0-83fa-a982-9f48-abbe5f098732@perex.cz> References: <20230331142217.19791-1-tiwai@suse.de> <57ffa8e0-83fa-a982-9f48-abbe5f098732@perex.cz> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Message-ID-Hash: QWRGW4WZRSLQPUK3JE6RPS4TP6PTXYOA X-Message-ID-Hash: QWRGW4WZRSLQPUK3JE6RPS4TP6PTXYOA X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: alsa-devel@alsa-project.org, Kai Vehmanen , Wim Taymans X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 31 Mar 2023 17:18:44 +0200, Jaroslav Kysela wrote: > > 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. Normally the device is assigned to the first PCM slot. And, it'll be always so, as long as you connect a single device. In this change, we don't keep the old empty slot, but just tries to use the previous slot at first. So a single device connection always leads to the first PCM slot. That said, the slot preservation becomes effective only when multiple devices are connected and they are on/off at the same time. In such a case, the device order may be changed at each screen on/off with the current code, while this patch allows keeping the order. Maybe I should emphasize about the multiple devices in the patch description. > 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). The name string appears actually in the dialog. But the automatic switch doesn't happen. So we need some improvement / fix. > > @@ -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. OK, I don't mind either position. > For now: > > Reviewed-by: Jaroslav Kysela thanks, Takashi