From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8BD7C433F5 for ; Fri, 14 Jan 2022 16:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243468AbiANQhu (ORCPT ); Fri, 14 Jan 2022 11:37:50 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:60684 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243446AbiANQhn (ORCPT ); Fri, 14 Jan 2022 11:37:43 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 68474219B1; Fri, 14 Jan 2022 16:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1642178262; 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=zmtoZZdmqikoLleBgA5rE7Gqlol+bSO79e6psKPWRU4=; b=CD+sUNNSN9tVqehrxHGx5KfPnOXDoPY10gAO9uei6jI1iwiux2whwt7V4Q/lz9BnJcPP5t uSyNz+NVN0nCRHgS9qc3T4+B2wgHTuCBTMUgKDo5rtIfUW64r76QwDa6Spek0j4QNspe03 rrw5hU4Tx/e5QCW0xez+rdQToj1skiQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1642178262; 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=zmtoZZdmqikoLleBgA5rE7Gqlol+bSO79e6psKPWRU4=; b=QOJpi+G392iy1rUzQiH2qUm8F399GzzE5BgmRPjy0z85FDm8LnbfJMpZWySH32MJgoxSUi UrhHPEp7Oc9qPcDQ== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 53C3FA3B84; Fri, 14 Jan 2022 16:37:42 +0000 (UTC) Date: Fri, 14 Jan 2022 17:37:42 +0100 Message-ID: From: Takashi Iwai To: Alexander Sergeyev Cc: Jeremy Szu , tiwai@suse.com, "moderated list:SOUND" , Kailang Yang , open list , Huacai Chen , Jian-Hong Pan , Hui Wang , PeiSen Hou Subject: Re: [PATCH 1/4] ALSA: hda/realtek: fix mute/micmute LEDs for HP 855 G8 In-Reply-To: <20220113183141.kla37mbqmo4x6wxp@localhost.localdomain> References: <20210519170357.58410-1-jeremy.szu@canonical.com> <20220111195229.a77wrpjclqwrx4bx@localhost.localdomain> <20220112101249.ya73jvpmqmeh4ggg@localhost.localdomain> <20220112104827.4aymoth7ua65nwge@localhost.localdomain> <20220112201824.qmphnz2hx4frda6e@localhost.localdomain> <20220113183141.kla37mbqmo4x6wxp@localhost.localdomain> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Jan 2022 19:31:41 +0100, Alexander Sergeyev wrote: > > On Thu, Jan 13, 2022 at 08:14:29AM +0100, Takashi Iwai wrote: > >> First, about unbind and bind via sysfs -- attempts to unbind the > >> HD-audio controller immediately trigger BUGs: > >> Is it normal/expected? > > > >A sort of. The sysfs unbind is little tested and may be still buggy > >if done during the stream operation. > > > >To be sure, could you check with my latest sound.git tree for-linus > >branch? There are a few fixes that harden the dynamic unbind. > > I assume that the referred repository is the one at [1]. I've tried > 081c73701ef0 "ALSA: hda: intel-dsp-config: reorder the config > table". It crashed with nearly identical logs. OK, then it's still something to do with the led cdev unregisteration. Could you try the patch below? > >> 1) Coeff 0x0b is flapping between 0x8003 and 0x7770 and does not seem > >> to have any effect in both non-working and working versions. Not sure > >> about this, maybe microphone is not operational since I haven't > >> checked it yet. > > I got some time to poke the internal microphone. It works, but > oddities are there as well. Initially I get "Mic Boost", "Capture" and > "Internal Mic Boost" controls in alsamixer. When I run arecord, > "Digital" control appears, but it cannot be changed until arecord is > stopped. Subsequent arecord calls do not lock "Digital" control. This > control affects sensitivity of the microphone and seems useful. That's presumably an alsa-lib softvol stuff. It's created dynamically. So not really a kernel problem. Takashi --- diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 3bf5e3410703..503cd979c908 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -84,13 +84,21 @@ static void free_kctls(struct hda_gen_spec *spec) snd_array_free(&spec->kctls); } -static void snd_hda_gen_spec_free(struct hda_gen_spec *spec) +static void snd_hda_gen_spec_free(struct hda_codec *codec) { + struct hda_gen_spec *spec = codec->spec; + if (!spec) return; free_kctls(spec); snd_array_free(&spec->paths); snd_array_free(&spec->loopback_list); +#ifdef CONFIG_SND_HDA_GENERIC_LEDS + if (spec->led_cdevs[LED_AUDIO_MUTE]) + led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MUTE]); + if (spec->led_cdevs[LED_AUDIO_MICMUTE]) + led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MICMUTE]); +#endif } /* @@ -3922,7 +3930,9 @@ static int create_mute_led_cdev(struct hda_codec *codec, enum led_brightness), bool micmute) { + struct hda_gen_spec *spec = codec->spec; struct led_classdev *cdev; + int err; cdev = devm_kzalloc(&codec->core.dev, sizeof(*cdev), GFP_KERNEL); if (!cdev) @@ -3935,7 +3945,11 @@ static int create_mute_led_cdev(struct hda_codec *codec, cdev->brightness = ledtrig_audio_get(micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE); cdev->flags = LED_CORE_SUSPENDRESUME; - return devm_led_classdev_register(&codec->core.dev, cdev); + err = led_classdev_register(&codec->core.dev, cdev); + if (err < 0) + return err; + spec->led_cdevs[micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE] = cdev; + return 0; } /** @@ -5998,7 +6012,7 @@ EXPORT_SYMBOL_GPL(snd_hda_gen_init); void snd_hda_gen_free(struct hda_codec *codec) { snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE); - snd_hda_gen_spec_free(codec->spec); + snd_hda_gen_spec_free(codec); kfree(codec->spec); codec->spec = NULL; } diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index 8e1bc8ea74fc..34eba40cc6e6 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h @@ -294,6 +294,9 @@ struct hda_gen_spec { struct hda_jack_callback *cb); void (*mic_autoswitch_hook)(struct hda_codec *codec, struct hda_jack_callback *cb); + + /* leds */ + struct led_classdev *led_cdevs[NUM_AUDIO_LEDS]; }; /* values for add_stereo_mix_input flag */ From mboxrd@z Thu Jan 1 00:00:00 1970 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 0A25CC433EF for ; Fri, 14 Jan 2022 16:38:43 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 85AB51AA5; Fri, 14 Jan 2022 17:37:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 85AB51AA5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642178321; bh=SM111OD0y1D8Zn9+oNsxsrayK//LCF6qn3lo8C3aQ+g=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=XeK+HzWwLmZpH2vkT/v1OrkeFCgv3EwMz7VilNpTW2AHFeuJld5DhzpsKHVKXLFS3 loVKzHhq3zhAjBW2xTa6ePLcGick1XJhJV4U7fgQZrGJsJ5w+TeXWVRNVfW+5R/Pdl Cq0TvD2g+OUn9+UGjp26GD5CIpGLlSA+82nvSHlQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 24180F8027C; Fri, 14 Jan 2022 17:37:51 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 98EE0F8030F; Fri, 14 Jan 2022 17:37:49 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3854AF800CE for ; Fri, 14 Jan 2022 17:37:43 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3854AF800CE Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="CD+sUNNS"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="QOJpi+G3" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 68474219B1; Fri, 14 Jan 2022 16:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1642178262; 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=zmtoZZdmqikoLleBgA5rE7Gqlol+bSO79e6psKPWRU4=; b=CD+sUNNSN9tVqehrxHGx5KfPnOXDoPY10gAO9uei6jI1iwiux2whwt7V4Q/lz9BnJcPP5t uSyNz+NVN0nCRHgS9qc3T4+B2wgHTuCBTMUgKDo5rtIfUW64r76QwDa6Spek0j4QNspe03 rrw5hU4Tx/e5QCW0xez+rdQToj1skiQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1642178262; 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=zmtoZZdmqikoLleBgA5rE7Gqlol+bSO79e6psKPWRU4=; b=QOJpi+G392iy1rUzQiH2qUm8F399GzzE5BgmRPjy0z85FDm8LnbfJMpZWySH32MJgoxSUi UrhHPEp7Oc9qPcDQ== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 53C3FA3B84; Fri, 14 Jan 2022 16:37:42 +0000 (UTC) Date: Fri, 14 Jan 2022 17:37:42 +0100 Message-ID: From: Takashi Iwai To: Alexander Sergeyev Subject: Re: [PATCH 1/4] ALSA: hda/realtek: fix mute/micmute LEDs for HP 855 G8 In-Reply-To: <20220113183141.kla37mbqmo4x6wxp@localhost.localdomain> References: <20210519170357.58410-1-jeremy.szu@canonical.com> <20220111195229.a77wrpjclqwrx4bx@localhost.localdomain> <20220112101249.ya73jvpmqmeh4ggg@localhost.localdomain> <20220112104827.4aymoth7ua65nwge@localhost.localdomain> <20220112201824.qmphnz2hx4frda6e@localhost.localdomain> <20220113183141.kla37mbqmo4x6wxp@localhost.localdomain> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: "moderated list:SOUND" , Kailang Yang , Jeremy Szu , Huacai Chen , open list , tiwai@suse.com, Hui Wang , PeiSen Hou , Jian-Hong Pan X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Thu, 13 Jan 2022 19:31:41 +0100, Alexander Sergeyev wrote: > > On Thu, Jan 13, 2022 at 08:14:29AM +0100, Takashi Iwai wrote: > >> First, about unbind and bind via sysfs -- attempts to unbind the > >> HD-audio controller immediately trigger BUGs: > >> Is it normal/expected? > > > >A sort of. The sysfs unbind is little tested and may be still buggy > >if done during the stream operation. > > > >To be sure, could you check with my latest sound.git tree for-linus > >branch? There are a few fixes that harden the dynamic unbind. > > I assume that the referred repository is the one at [1]. I've tried > 081c73701ef0 "ALSA: hda: intel-dsp-config: reorder the config > table". It crashed with nearly identical logs. OK, then it's still something to do with the led cdev unregisteration. Could you try the patch below? > >> 1) Coeff 0x0b is flapping between 0x8003 and 0x7770 and does not seem > >> to have any effect in both non-working and working versions. Not sure > >> about this, maybe microphone is not operational since I haven't > >> checked it yet. > > I got some time to poke the internal microphone. It works, but > oddities are there as well. Initially I get "Mic Boost", "Capture" and > "Internal Mic Boost" controls in alsamixer. When I run arecord, > "Digital" control appears, but it cannot be changed until arecord is > stopped. Subsequent arecord calls do not lock "Digital" control. This > control affects sensitivity of the microphone and seems useful. That's presumably an alsa-lib softvol stuff. It's created dynamically. So not really a kernel problem. Takashi --- diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 3bf5e3410703..503cd979c908 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -84,13 +84,21 @@ static void free_kctls(struct hda_gen_spec *spec) snd_array_free(&spec->kctls); } -static void snd_hda_gen_spec_free(struct hda_gen_spec *spec) +static void snd_hda_gen_spec_free(struct hda_codec *codec) { + struct hda_gen_spec *spec = codec->spec; + if (!spec) return; free_kctls(spec); snd_array_free(&spec->paths); snd_array_free(&spec->loopback_list); +#ifdef CONFIG_SND_HDA_GENERIC_LEDS + if (spec->led_cdevs[LED_AUDIO_MUTE]) + led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MUTE]); + if (spec->led_cdevs[LED_AUDIO_MICMUTE]) + led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MICMUTE]); +#endif } /* @@ -3922,7 +3930,9 @@ static int create_mute_led_cdev(struct hda_codec *codec, enum led_brightness), bool micmute) { + struct hda_gen_spec *spec = codec->spec; struct led_classdev *cdev; + int err; cdev = devm_kzalloc(&codec->core.dev, sizeof(*cdev), GFP_KERNEL); if (!cdev) @@ -3935,7 +3945,11 @@ static int create_mute_led_cdev(struct hda_codec *codec, cdev->brightness = ledtrig_audio_get(micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE); cdev->flags = LED_CORE_SUSPENDRESUME; - return devm_led_classdev_register(&codec->core.dev, cdev); + err = led_classdev_register(&codec->core.dev, cdev); + if (err < 0) + return err; + spec->led_cdevs[micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE] = cdev; + return 0; } /** @@ -5998,7 +6012,7 @@ EXPORT_SYMBOL_GPL(snd_hda_gen_init); void snd_hda_gen_free(struct hda_codec *codec) { snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE); - snd_hda_gen_spec_free(codec->spec); + snd_hda_gen_spec_free(codec); kfree(codec->spec); codec->spec = NULL; } diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index 8e1bc8ea74fc..34eba40cc6e6 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h @@ -294,6 +294,9 @@ struct hda_gen_spec { struct hda_jack_callback *cb); void (*mic_autoswitch_hook)(struct hda_codec *codec, struct hda_jack_callback *cb); + + /* leds */ + struct led_classdev *led_cdevs[NUM_AUDIO_LEDS]; }; /* values for add_stereo_mix_input flag */