From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D9210E6 for ; Tue, 28 Nov 2023 01:39:51 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 smtp-out2.suse.de (Postfix) with ESMTPS id 9E6DB1F74C; Tue, 28 Nov 2023 09:39:49 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4E4A91343E; Tue, 28 Nov 2023 09:39:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id l8SaEWW1ZWXZYgAAD6G6ig (envelope-from ); Tue, 28 Nov 2023 09:39:49 +0000 Date: Tue, 28 Nov 2023 10:39:48 +0100 Message-ID: <87y1eimd23.wl-tiwai@suse.de> From: Takashi Iwai To: =?ISO-8859-1?Q?P=E9ter?= Ujfalusi Cc: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, pierre-louis.bossart@linux.intel.com, kai.vehmanen@linux.intel.com, ranjani.sridharan@linux.intel.com Subject: Re: [PATCH 1/2] ALSA: hda/hdmi: Add helper function to check if a device is HDMI codec In-Reply-To: References: <20231127130245.24295-1-peter.ujfalusi@linux.intel.com> <20231127130245.24295-2-peter.ujfalusi@linux.intel.com> <87jzq3pc6r.wl-tiwai@suse.de> <87cyvvp8t6.wl-tiwai@suse.de> <8ede931b-8c9c-4b95-83e5-5f0db9819e8e@linux.intel.com> <878r6jp6jd.wl-tiwai@suse.de> <875y1np5g2.wl-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Level: X-Rspamd-Server: rspamd1 Authentication-Results: smtp-out2.suse.de; none X-Rspamd-Queue-Id: 9E6DB1F74C X-Spam-Score: -4.00 X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] On Tue, 28 Nov 2023 10:10:48 +0100, Péter Ujfalusi wrote: > > > > On 27/11/2023 17:43, Takashi Iwai wrote: > > On Mon, 27 Nov 2023 16:40:57 +0100, > >>> --- a/include/sound/hdaudio.h > >>> +++ b/include/sound/hdaudio.h > >>> @@ -95,6 +95,7 @@ struct hdac_device { > >>> bool lazy_cache:1; /* don't wake up for writes */ > >>> bool caps_overwriting:1; /* caps overwrite being in process */ > >>> bool cache_coef:1; /* cache COEF read/write too */ > >>> + bool is_hdmi:1; /* a HDMI/DP codec */ > >>> unsigned int registered:1; /* codec was registered */ > >>> }; > >>> > >>> --- a/sound/pci/hda/patch_hdmi.c > >>> +++ b/sound/pci/hda/patch_hdmi.c > >>> @@ -2597,6 +2597,7 @@ static int patch_generic_hdmi(struct hda_codec *codec) > >>> } > >>> > >>> generic_hdmi_init_per_pins(codec); > >>> + codec->core.is_hdmi = true; > >>> return 0; > >>> } > >>> > >>> @@ -3472,6 +3473,7 @@ static int patch_simple_hdmi(struct hda_codec *codec, > >>> spec->pcm_playback = simple_pcm_playback; > >>> > >>> codec->patch_ops = simple_hdmi_patch_ops; > >>> + codec->core.is_hdmi = true; > >>> > >>> return 0; > >>> } > >> > >> I see, so this is what I was not sure how to do ;) > >> I will rework the series and resend tomorrow. > >> > >> Thanks for the code snippet, I will make you as author of it, if it is > >> OK for you. > > > > Sure, no problem. > > The flag does not work with SOF stack which uses the hdac_hda codec driver: > > patch_generic_hdmi() and patch_simple_hdmi() is not entered at all, so > the flag is not set. > > The codec driver have is_hdmi_codec() helper to check the struct > hda_pcm.pcm_type, but that is not set early enough either. > > The is HDMI or not needs to be known in hdac_hda_dev_probe(), I think > this was one of the reason I have opted to have the exported function. > We just don't have other information at the dev probe time. > > # dmesg | grep peter > [ 3.810841] [peter] hdac_hda_dev_probe: is_hdmi_codec(): 0 > [ 3.810846] [peter] hdac_hda_dev_probe: hdev->is_hdmi: 0 > [ 3.810848] [peter] hdac_hda_dev_probe: snd_hda_device_is_hdmi(): 0 > ... > [ 3.814497] [peter] hdac_hda_dev_probe: is_hdmi_codec(): 0 > [ 3.814499] [peter] hdac_hda_dev_probe: hdev->is_hdmi: 0 > [ 3.814500] [peter] hdac_hda_dev_probe: snd_hda_device_is_hdmi(): 1 > ... > [ 3.986610] [peter] generic_hdmi_build_pcms: ENTER > [ 3.986627] [peter] hdac_hda_codec_probe: is_hdmi_codec(): 1 > ... > [ 3.996383] [peter] snd_hda_parse_pin_defcfg: ENTER > [ 4.001562] [peter] hdac_hda_codec_probe: is_hdmi_codec(): 0 Hm... I still find it's a bad move to use an exported symbol from another codec driver. And, I wonder what if you have a system that has only one HDMI codec without analog one? Would it still work with your change? Takashi