From patchwork Mon May 27 16:37:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 1940036 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vp1X01Qwrz20ds for ; Tue, 28 May 2024 02:37:19 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sBdLU-0008Ma-MT; Mon, 27 May 2024 16:37:12 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sBdLS-0008Lu-JO for kernel-team@lists.ubuntu.com; Mon, 27 May 2024 16:37:10 +0000 Received: from mail-il1-f200.google.com (mail-il1-f200.google.com [209.85.166.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 71F073F131 for ; Mon, 27 May 2024 16:37:09 +0000 (UTC) Received: by mail-il1-f200.google.com with SMTP id e9e14a558f8ab-37456dcde30so11698185ab.2 for ; Mon, 27 May 2024 09:37:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716827828; x=1717432628; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9JN9Cyuwe+SWcH8vnZh17cg2Sm1kOOFYPP4YIXXnvh8=; b=KLgXyoONfJlAv4CK/P7vtsrVjz/cEnbJx5p7xSiWQqJ07zvxBnfeN0oropxdhvHx4D Hv4F/05OFPyswU1sUk+NwpozNHqXXP9QgNMwLaq7vRR3mQqhgZiUEudpUi2vO9qVj7mT PI9RJOVyjCu4tvX42VKom1MktKgGKHLvoPBNRC8y1v8z5Vvq4uK5mcd/cM3zogR+8xQb UbX2KIGv+iQmmdGhKMzTq9TXu6XgHLr7fzNXRrwpf6G8gAjjb8xMIEKCURTVykzvc5Vl OhqHjs5CdyWJVzhTMyFnpynXzUiZ26Bcqr6PVOJFC35NmMBk4hSUG2Wdme0M8gdmCCbZ aB4g== X-Gm-Message-State: AOJu0Yy5HP4umvxaBp+JRnsAx+AYhMgeuBcvODctDqPS/XcsKJR/aJgC zBwts26ltSjYGHqp7n7+KEKuxU04SXOwadICeUTNRSedsTBHn/w+fhq3nmr9vZEDSL5jT+AzTvO u0F1+QNftJDahN53vsauI8BXFAwieC7PbHnZSF9W0fxwu7nIKfu+qZOSyCn+YCJkUTxyR64dojf i2PzJhHZuI1wgP X-Received: by 2002:a05:6e02:2146:b0:36c:42a0:7abb with SMTP id e9e14a558f8ab-3737b37a88bmr114377655ab.31.1716827827919; Mon, 27 May 2024 09:37:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqcTs+IaBbO0yZfDhlOk0qPcdTK3MaVLVglTQZ45iusVDMSfe/iDpgSyIVzbHkXcqr4MHu2A== X-Received: by 2002:a05:6e02:2146:b0:36c:42a0:7abb with SMTP id e9e14a558f8ab-3737b37a88bmr114377415ab.31.1716827827533; Mon, 27 May 2024 09:37:07 -0700 (PDT) Received: from u-XPS-9320.. (114-36-240-140.dynamic-ip.hinet.net. [114.36.240.140]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-682273c44absm6272064a12.88.2024.05.27.09.37.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 09:37:07 -0700 (PDT) From: Chris Chiu To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH v2 1/2] ALSA: hda: realtek: Re-work CS35L41 fixups to re-use for other amps Date: Tue, 28 May 2024 00:37:02 +0800 Message-Id: <20240527163703.732884-2-chris.chiu@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240527163703.732884-1-chris.chiu@canonical.com> References: <20240527163703.732884-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Richard Fitzgerald BugLink: https://bugs.launchpad.net/bugs/2062135 Slightly re-work the code around cs35l41_generic_fixup() and the component binding search so that it can be re-used for other amps that use the component binding mechanism. The match string is stored in struct scodec_dev_name instead of hardcoding it in the match function. The tas2781 does not use the amp index as part of the driver name match. But its match format string does not include a field for the index, so snprintf() would safely ignore the p->index argument. Because of this there is no need for a special match function for this case, the CS35L41 code can be re-used. Signed-off-by: Richard Fitzgerald Tested-by: Gergo Koteles Link: https://lore.kernel.org/r/20240124112607.77614-2-rf@opensource.cirrus.com Signed-off-by: Takashi Iwai (cherry picked from commit cf0d956635e7dabc5e85f100e37a1d64a48becb4) Signed-off-by: Chris Chiu --- sound/pci/hda/patch_realtek.c | 83 +++++++---------------------------- 1 file changed, 15 insertions(+), 68 deletions(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 1eab06d0d5ed..6e4b88cf3af4 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -6899,11 +6899,12 @@ static void comp_generic_playback_hook(struct hda_pcm_stream *hinfo, struct hda_ struct scodec_dev_name { const char *bus; const char *hid; + const char *match_str; int index; }; /* match the device name in a slightly relaxed manner */ -static int comp_match_cs35l41_dev_name(struct device *dev, void *data) +static int comp_match_dev_name(struct device *dev, void *data) { struct scodec_dev_name *p = data; const char *d = dev_name(dev); @@ -6917,32 +6918,12 @@ static int comp_match_cs35l41_dev_name(struct device *dev, void *data) if (isdigit(d[n])) n++; /* the rest must be exact matching */ - snprintf(tmp, sizeof(tmp), "-%s:00-cs35l41-hda.%d", p->hid, p->index); + snprintf(tmp, sizeof(tmp), p->match_str, p->hid, p->index); return !strcmp(d + n, tmp); } -static int comp_match_tas2781_dev_name(struct device *dev, - void *data) -{ - struct scodec_dev_name *p = data; - const char *d = dev_name(dev); - int n = strlen(p->bus); - char tmp[32]; - - /* check the bus name */ - if (strncmp(d, p->bus, n)) - return 0; - /* skip the bus number */ - if (isdigit(d[n])) - n++; - /* the rest must be exact matching */ - snprintf(tmp, sizeof(tmp), "-%s:00", p->hid); - - return !strcmp(d + n, tmp); -} - -static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char *bus, - const char *hid, int count) +static void comp_generic_fixup(struct hda_codec *cdc, int action, const char *bus, + const char *hid, const char *match_str, int count) { struct device *dev = hda_codec_dev(cdc); struct alc_spec *spec = cdc->spec; @@ -6957,10 +6938,11 @@ static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char return; rec->bus = bus; rec->hid = hid; + rec->match_str = match_str; rec->index = i; spec->comps[i].codec = cdc; component_match_add(dev, &spec->match, - comp_match_cs35l41_dev_name, rec); + comp_match_dev_name, rec); } ret = component_master_add_with_match(dev, &comp_master_ops, spec->match); if (ret) @@ -6974,83 +6956,48 @@ static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char } } -static void tas2781_generic_fixup(struct hda_codec *cdc, int action, - const char *bus, const char *hid) -{ - struct device *dev = hda_codec_dev(cdc); - struct alc_spec *spec = cdc->spec; - struct scodec_dev_name *rec; - int ret; - - switch (action) { - case HDA_FIXUP_ACT_PRE_PROBE: - rec = devm_kmalloc(dev, sizeof(*rec), GFP_KERNEL); - if (!rec) - return; - rec->bus = bus; - rec->hid = hid; - rec->index = 0; - spec->comps[0].codec = cdc; - component_match_add(dev, &spec->match, - comp_match_tas2781_dev_name, rec); - ret = component_master_add_with_match(dev, &comp_master_ops, - spec->match); - if (ret) - codec_err(cdc, - "Fail to register component aggregator %d\n", - ret); - else - spec->gen.pcm_playback_hook = - comp_generic_playback_hook; - break; - case HDA_FIXUP_ACT_FREE: - component_master_del(dev, &comp_master_ops); - break; - } -} - static void cs35l41_fixup_i2c_two(struct hda_codec *cdc, const struct hda_fixup *fix, int action) { - cs35l41_generic_fixup(cdc, action, "i2c", "CSC3551", 2); + comp_generic_fixup(cdc, action, "i2c", "CSC3551", "-%s:00-cs35l41-hda.%d", 2); } static void cs35l41_fixup_i2c_four(struct hda_codec *cdc, const struct hda_fixup *fix, int action) { - cs35l41_generic_fixup(cdc, action, "i2c", "CSC3551", 4); + comp_generic_fixup(cdc, action, "i2c", "CSC3551", "-%s:00-cs35l41-hda.%d", 4); } static void cs35l41_fixup_spi_two(struct hda_codec *codec, const struct hda_fixup *fix, int action) { - cs35l41_generic_fixup(codec, action, "spi", "CSC3551", 2); + comp_generic_fixup(codec, action, "spi", "CSC3551", "-%s:00-cs35l41-hda.%d", 2); } static void cs35l41_fixup_spi_four(struct hda_codec *codec, const struct hda_fixup *fix, int action) { - cs35l41_generic_fixup(codec, action, "spi", "CSC3551", 4); + comp_generic_fixup(codec, action, "spi", "CSC3551", "-%s:00-cs35l41-hda.%d", 4); } static void alc287_fixup_legion_16achg6_speakers(struct hda_codec *cdc, const struct hda_fixup *fix, int action) { - cs35l41_generic_fixup(cdc, action, "i2c", "CLSA0100", 2); + comp_generic_fixup(cdc, action, "i2c", "CLSA0100", "-%s:00-cs35l41-hda.%d", 2); } static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const struct hda_fixup *fix, int action) { - cs35l41_generic_fixup(cdc, action, "i2c", "CLSA0101", 2); + comp_generic_fixup(cdc, action, "i2c", "CLSA0101", "-%s:00-cs35l41-hda.%d", 2); } static void tas2781_fixup_i2c(struct hda_codec *cdc, const struct hda_fixup *fix, int action) { - tas2781_generic_fixup(cdc, action, "i2c", "TIAS2781"); + comp_generic_fixup(cdc, action, "i2c", "TIAS2781", "-%s:00", 1); } static void yoga7_14arb7_fixup_i2c(struct hda_codec *cdc, const struct hda_fixup *fix, int action) { - tas2781_generic_fixup(cdc, action, "i2c", "INT8866"); + comp_generic_fixup(cdc, action, "i2c", "INT8866", "-%s:00", 1); } /* for alc295_fixup_hp_top_speakers */ From patchwork Mon May 27 16:37:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 1940035 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vp1X018bBz20Pb for ; Tue, 28 May 2024 02:37:19 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sBdLU-0008Mw-Tz; Mon, 27 May 2024 16:37:12 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sBdLT-0008MD-Ir for kernel-team@lists.ubuntu.com; Mon, 27 May 2024 16:37:11 +0000 Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id ACA313F131 for ; Mon, 27 May 2024 16:37:10 +0000 (UTC) Received: by mail-il1-f199.google.com with SMTP id e9e14a558f8ab-3745c48156bso8335ab.3 for ; Mon, 27 May 2024 09:37:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716827829; x=1717432629; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sXEFDQje0vQGipXTFa0D7c8LKk1p/9mAzmO5u6734oE=; b=Q11mdgDsK9ZkNU/3XMi5C+8lquua21bLXYATQ8tKwlKU77Veub9fOvno5RZvZu240B 6+1nEfP8OFDkwT8VAxZC9tsEvkB6sQCaVbUMI6LLoeftIu8gsGNEiXQ3oTbCWsxTTwk/ waiwSxUFm7gwAOwobA98K1hTbK92yQuNKgb6DmSgGdczDSrPxo3jIlrVLpglsylzc2Re YuEgHTjusHnkl3wighZ5wTaVqKXUa52I/jCfp8oqSrzu1kUHlqbBJwljSiu7le++EXbJ 4Q88Az7K9IBFCoJwwtzYxxvgVxXBqiekzr/EKEJtaRRN0fE0hHKr3ll/ugtuBPIx4wEl aCxg== X-Gm-Message-State: AOJu0YyzNPIXMM3pSGNdtwcjBb/oO/u6hcv+bwsC8mJH2aQJ9PD9V2mr i5VTlzT7Trs+8Df2xf8A6IfTb4peQBqY+yQihbzMQ/ku7V9CEjbx6otq0Ew8wke6gyTxq4X5iWA FLhgpZ26OTmLW8YqCDNNcDoeOMMbLiNhVCne3/hcDy7iot8D1E90e7PdbD88pfG/YP0NBILHycV 8Gd0VSdlg1WhUD X-Received: by 2002:a05:6e02:1aad:b0:36c:4a9c:70b8 with SMTP id e9e14a558f8ab-3737b284243mr122374375ab.1.1716827828970; Mon, 27 May 2024 09:37:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhZDW+igSKw7f5i9JwRcOR3sQ7Om6TZN5KFjhgoG8cxFwunDEn2XE+9ypEosZ7SqJpLocEfw== X-Received: by 2002:a05:6e02:1aad:b0:36c:4a9c:70b8 with SMTP id e9e14a558f8ab-3737b284243mr122374055ab.1.1716827828531; Mon, 27 May 2024 09:37:08 -0700 (PDT) Received: from u-XPS-9320.. (114-36-240-140.dynamic-ip.hinet.net. [114.36.240.140]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-682273c44absm6272064a12.88.2024.05.27.09.37.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 09:37:08 -0700 (PDT) From: Chris Chiu To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH v2 2/2] ALSA: hda/realtek: Add quirks for HP G11 Laptops using CS35L56 Date: Tue, 28 May 2024 00:37:03 +0800 Message-Id: <20240527163703.732884-3-chris.chiu@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240527163703.732884-1-chris.chiu@canonical.com> References: <20240527163703.732884-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Simon Trimmer BugLink: https://bugs.launchpad.net/bugs/2062135 Add quirks for two HP G11 laptops that use a Realtek HDA codec combined with four CS35L56 amplifiers using SPI. The CS35L56 driver uses the component binding interface, so uses the same setup code as the CS35L41 quirks. Signed-off-by: Simon Trimmer Signed-off-by: Richard Fitzgerald Link: https://lore.kernel.org/r/20240125123301.41692-1-rf@opensource.cirrus.com Signed-off-by: Takashi Iwai (backported from commit b2d6a1fd0e3e513f5ebfc152d6fedae093df8e21) [Chris Chiu: remove un-necessary fixups from the kernel 6.9] Signed-off-by: Chris Chiu --- v2: fix compile error for the missing ALC256_FIXUP_HEADPHONE_AMP_VOL sound/pci/hda/patch_realtek.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 6e4b88cf3af4..b09689b537bd 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -6988,6 +6988,11 @@ static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st comp_generic_fixup(cdc, action, "i2c", "CLSA0101", "-%s:00-cs35l41-hda.%d", 2); } +static void cs35l56_fixup_spi_four(struct hda_codec *cdc, const struct hda_fixup *fix, int action) +{ + comp_generic_fixup(cdc, action, "spi", "CSC3556", "-%s:00-cs35l56-hda.%d", 4); +} + static void tas2781_fixup_i2c(struct hda_codec *cdc, const struct hda_fixup *fix, int action) { @@ -7502,6 +7507,7 @@ enum { ALC289_FIXUP_DELL_CS35L41_SPI_2, ALC294_FIXUP_CS35L41_I2C_2, ALC256_FIXUP_HEADPHONE_AMP_VOL, + ALC245_FIXUP_CS35L56_SPI_4_HP_GPIO_LED, }; /* A special fixup for Lenovo C940 and Yoga Duet 7; @@ -9695,6 +9701,12 @@ static const struct hda_fixup alc269_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc256_decrease_headphone_amp_val, }, + [ALC245_FIXUP_CS35L56_SPI_4_HP_GPIO_LED] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs35l56_fixup_spi_four, + .chained = true, + .chain_id = ALC285_FIXUP_HP_GPIO_LED, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = { @@ -10034,6 +10046,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x103c, 0x8c47, "HP EliteBook 840 G11", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8c48, "HP EliteBook 860 G11", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8c49, "HP Elite x360 830 2-in-1 G11", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x8c52, "HP EliteBook 1040 G11", ALC245_FIXUP_CS35L56_SPI_4_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x8c53, "HP Elite x360 1040 2-in-1 G11", ALC245_FIXUP_CS35L56_SPI_4_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8c70, "HP EliteBook 835 G11", ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8c71, "HP EliteBook 845 G11", ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8c72, "HP EliteBook 865 G11", ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED),