Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp717088pxb; Fri, 14 Jan 2022 14:53:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJEMVkLYXQ91gVmcsi4tTHRIe4bupgOZZwa3sWVkZN1a9h0H4fnHqTlpgI0tH29Gj+5P1/ X-Received: by 2002:a17:907:3e09:: with SMTP id hp9mr9347244ejc.537.1642200800599; Fri, 14 Jan 2022 14:53:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642200800; cv=none; d=google.com; s=arc-20160816; b=ND8YG7pMZjFBTfsjmdo8dc2NXKL0H+79ZWGDPaRpmfWmpFs8TB3BHhphmXfw+pcsqA VRR8ytKjXl6+JgyuUDT4HScMdv7F1g+ZwPZJU7fC29MyDrCPUG8iqhiSbjpYwdIY5hzN p02Sg3k6Hy7Q9yoz0PaKBfBUuKQFHhVb3SEiwChWRcyFlFG/Uol7t7afFJDn37RYT3jM wGYGfDAB/CI5pAtIn9Xaz1IXOTg8x0g8pctP63f1YUWTmFzZiDlv24sRvi/grgGhxzxs /cd7C47S0RqATDJCnwmzgzL9Tps4BZjo50zp3ksr16iSX8odI5p43wV1Mf/76wRgJ5CN Sd0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=zmtoZZdmqikoLleBgA5rE7Gqlol+bSO79e6psKPWRU4=; b=AozX15Elr+wQhwgpGadbViDdsKwAsjhNdX0FC0tRwGZbMp6PCHIEnQPFmQiyH+YFhG m12sjgwm5AfUfKW9hnzOQaGs/ExXjeGkev7fImQrkCxvY9BppWQ8BQolb4r+rfidmBIo 0UZ1HJYAfyk0VaJdFn0uaBjyEBzWwj2odrpMS5pAjzQ8FzXP/wClQjAbCwciEkWQYNK5 Bdu3b+bwN9Fd1PG2sPeKR+tNShPliaj3o7rKRBGTEw/owPWHjekZZP7j/reM094Jumc/ 6TEtwLTi5TBtotUPGSOmfYpkl2AY6S9ehuFoGpesVfBtq+Kc806nJe3fL7JowPND3m/Y otvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CD+sUNNS; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cq6si4069078edb.400.2022.01.14.14.52.55; Fri, 14 Jan 2022 14:53:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CD+sUNNS; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243463AbiANQht (ORCPT + 99 others); Fri, 14 Jan 2022 11:37:49 -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 */