From patchwork Wed Jul 5 13:43:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 116149 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1884541vqx; Wed, 5 Jul 2023 06:53:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WEoHHMg1hqD/J9A2VPhU5nk94jmRj0T8qQGN5sYmTEm1d8jGU+1JclbNIS9NWMOvyK5Uw X-Received: by 2002:a05:6808:2387:b0:3a1:dcca:9628 with SMTP id bp7-20020a056808238700b003a1dcca9628mr18593234oib.10.1688565199404; Wed, 05 Jul 2023 06:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688565199; cv=none; d=google.com; s=arc-20160816; b=wvEW54lDQ0JpT3a7/xSLBqKvFg1l2XXwO5MlbS1BQgs1f4M4K/co3pnyuQkY1EZiSV DRIlBXTYOHAplNW839YvEEmdhO7fF60E54gOeu7rhmG2Dcp9sGz8jaEAhzWM3pWfB9FS dYUwvWSouidHrH7b78/3R5t+wuMaQqhsdYs6uSA2K+IbCyl27gwzXqs+KZH/DKoBsK64 /ArFwKraXdwsE1zZ3F0J7VPGV2d/Ebacm/oXzj+1LHeT6DTU6CZmGZxKguueJgNISBY/ EBU39fSMZgUZoi99583IB6ARrYgxu2q1ONtNeVxqaq6h4BBDc9zrXaYUoFScuDAHH3Xl dSmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9w3xwtSer5KurbsFI2Pu2uv8APImGMRcReZnBK5W0fo=; fh=WpwulVhbj4/4SUydfqjIitCcTK++J8QA/iGpwX/VPoo=; b=kzyVnT/MXJOq5rOu7o2gB3pDLYix9OPsM9hX9AO6YHsyjV+ZJ5ruzl6DVhI4Pm+IkP ZQjMt36stFuS2hIrTnwyQSvlEuAikcdSWUw7514oxJC0m9nxT+Ol1jLj2AjqWEphWcXI uil1qaGIZZTetMca6MiOHisOKGL4iT7ycDbti1EOy241sGRXIv2VvNt4Hsew61ep19XF kWgBal6TL7NKFKTBFbOtaii7N44KZfGdWsJwdUi/1g0FaVH4985zBkm0JXG6TRHgn51j jtOktji0Zv4oUa3QAuTe/9SXvbR52NcueIKis4vuU/Q5xppXr5uXSsUMFt9kxTX0z/TO urTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZywCBNp5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a17090a2e0b00b00261113f2843si1668946pjd.131.2023.07.05.06.53.03; Wed, 05 Jul 2023 06:53:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZywCBNp5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232123AbjGENnw (ORCPT + 99 others); Wed, 5 Jul 2023 09:43:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjGENnu (ORCPT ); Wed, 5 Jul 2023 09:43:50 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA189E5 for ; Wed, 5 Jul 2023 06:43:49 -0700 (PDT) Received: from localhost (unknown [188.24.137.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 711FB6606FB0; Wed, 5 Jul 2023 14:43:48 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688564628; bh=VTB4I9zZ57rcfuMONYpW7VWpXed1exZT873tCPi37oM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZywCBNp5GSeyrfKC+xwH0a4fNqw7bSAIOTfRidQahanxqberP+eTkhTIiLCn0yV8J LRJJgqFxN/m8Fqyx61ukOLsp5quivZwQOSckUQOrsMkcRkpyRnYtls1505wk6z3IWC /RhrASG5Ans9qt/Fp1JJ4dQ9rj2DoBjsLH6tecJaBsDng10jGb7UnB/NdImQraYSBt 93X+EaOivgdjo/5+8uNEkox2/J3lX4DNNDyot9NnbIX3ipkXuMsvh+0IpN+ExV2zRW VET38zRn3uJlbyUCqXMvPMxdFDnPwrlHsJ71Ogj/46j/uysBq1dK0WMPzZvQnzs0yK xSxI1AIZUy2sw== From: Cristian Ciocaltea To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Syed Saba Kareem , Vijendar Mukunda , Arnd Bergmann , Randy Dunlap , Charles Keepax , Kuninori Morimoto Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 1/3] ASoC: amd: vangogh: Make use of DRV_NAME Date: Wed, 5 Jul 2023 16:43:39 +0300 Message-ID: <20230705134341.175889-2-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230705134341.175889-1-cristian.ciocaltea@collabora.com> References: <20230705134341.175889-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770588942875351834?= X-GMAIL-MSGID: =?utf-8?q?1770588942875351834?= The "acp5x_mach" string is provided for both driver name and MODULE_ALIAS. Since they need to match, ensure DRV_NAME macro is used in both locations. Signed-off-by: Cristian Ciocaltea --- sound/soc/amd/vangogh/acp5x-mach.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/amd/vangogh/acp5x-mach.c b/sound/soc/amd/vangogh/acp5x-mach.c index e5bcd1e6eb73..5e36179cf611 100644 --- a/sound/soc/amd/vangogh/acp5x-mach.c +++ b/sound/soc/amd/vangogh/acp5x-mach.c @@ -381,7 +381,7 @@ static int acp5x_probe(struct platform_device *pdev) static struct platform_driver acp5x_mach_driver = { .driver = { - .name = "acp5x_mach", + .name = DRV_NAME, .pm = &snd_soc_pm_ops, }, .probe = acp5x_probe, From patchwork Wed Jul 5 13:43:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 116148 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1884500vqx; Wed, 5 Jul 2023 06:53:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlFZMCIVYEqaft2kZ77snPx4psyCTk8k2VVBwRcPZwrlDIo1qqZAT9u2WN8WgKAXkOut11rU X-Received: by 2002:a17:903:41c9:b0:1b5:6312:4c5b with SMTP id u9-20020a17090341c900b001b563124c5bmr11351362ple.63.1688565193538; Wed, 05 Jul 2023 06:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688565193; cv=none; d=google.com; s=arc-20160816; b=j19mwZLf4HqGBPnfUJJB15MbzCF/cFMeTuU+TstKQeU6TGGoKqEoPPDact+osc8SEL PC9WSlE/YjJiMTeGuigPowCBWqB/jb4cHvZ/ZvlaW9dNDiHgOwzkaBQvUsm9rgZbDGBL mYKRUUWIFwRdUqt02Ccu2JNNrcJErpWWKGic5zb1liESZHnmFQjYts0FJAFAR/uknsVY mDEW9iFTdfynLxchknYbs350pttcgshqbjnz8m/5v4hz2Lr9PzX25pfieNHpFglglNA3 m7MwKKehEy9eozSqYYzhmglpCfUEtASUqyQhnt/tw0MmBYe96tROW0/FJGDbDXwb4j40 sLGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iN/mvD3LBn+ZNcgz0QFQ8G04Gh/3Ak+rxzrga8HVBbU=; fh=cr2FL92h8TijVQGAjIwEJg7SUp/pazMAzWM7wR+E2Os=; b=VwPlpiQ8wUMP5vZMeP7v3saOADK9KSB0QYCXtmMRhDIF28Mj9uMed37K3D0KSE2lGr AjTrOcaz4LZGqnKVpOGNrl+bj2ZPGLi8td8uOttUOJKTv9ylZFV48eE3APynAOmzvUoc TzxnmDKU0RRL/apzo/9yby6pprmdvDD0porxdmhYXCwt/0S5cnMW51WwNRL2o6uWMZzH nMhNMPEgIAXYyEGqsc1iB1u05CCau/yHnioXYCNehLELCihYaMbqv2jEyf4Fovw6lubo GOQ5XJQQDH8pw9gag3XMPTBiwiXRGhhWXRPUO+syAjvqlWuPLfFPBIubbgHV0K8hLMw2 YZqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HFFlnTBE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a17090301c700b001b88997ababsi9876788plh.412.2023.07.05.06.52.58; Wed, 05 Jul 2023 06:53:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HFFlnTBE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232159AbjGENnz (ORCPT + 99 others); Wed, 5 Jul 2023 09:43:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230100AbjGENnx (ORCPT ); Wed, 5 Jul 2023 09:43:53 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E950CAF for ; Wed, 5 Jul 2023 06:43:52 -0700 (PDT) Received: from localhost (unknown [188.24.137.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 764286606FB7; Wed, 5 Jul 2023 14:43:51 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688564631; bh=f6qzZZCqh3StcdQmbdXHhNuewxQtRotpLidUnnuRtcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HFFlnTBETo0iHeYB2Qrywf+bBmiNt+Ds0V/JlmRmLtDmeit6hQityvE57Yoxef03o +hM+YPhMcFQJILn3KA5b8Rje0Rxw7SZieqjUv2ePaNGb4FjXGfdAFJnS7fZ458H2Y6 v3DPFTRfKZ8lOMBVpnUFftSYOxJT87NsJFg/FYN0inqAVAjqjpYhwzAfOXQiJ6TRkk 8yfWx/JeoMPmC3VXw8aWMm0891I+58SAIjKc3S6gW0YDjMvmbOcyP0Mawzw4jztZH2 R4l3//rm2wvVXkxps73a1amhy35JjNtWqznFjFq7cTo5Rcxwuo+USjUdNU5O6sBrpM w2wwF88R8yHPw== From: Cristian Ciocaltea To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Syed Saba Kareem , Vijendar Mukunda , Arnd Bergmann , Randy Dunlap , Charles Keepax , Kuninori Morimoto Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 2/3] ASoC: amd: vangogh: Use dmi_first_match() for DMI quirk handling Date: Wed, 5 Jul 2023 16:43:40 +0300 Message-ID: <20230705134341.175889-3-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230705134341.175889-1-cristian.ciocaltea@collabora.com> References: <20230705134341.175889-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770588936150249077?= X-GMAIL-MSGID: =?utf-8?q?1770588936150249077?= In preparation for supporting ACPI probing, move DMI quirk handling logic at the probe's top, to be able to return as quickly as possible in case there is no DMI matching. Additionally, simplify the code by replacing dmi_check_system() and related callback with dmi_first_match(). While at it, also drop a few unnecessary empty lines. Signed-off-by: Cristian Ciocaltea --- sound/soc/amd/vangogh/acp5x-mach.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/sound/soc/amd/vangogh/acp5x-mach.c b/sound/soc/amd/vangogh/acp5x-mach.c index 5e36179cf611..1efa8f8b77ab 100644 --- a/sound/soc/amd/vangogh/acp5x-mach.c +++ b/sound/soc/amd/vangogh/acp5x-mach.c @@ -22,7 +22,6 @@ #define DRV_NAME "acp5x_mach" #define DUAL_CHANNEL 2 -#define VG_JUPITER 1 #define ACP5X_NAU8821_BCLK 3072000 #define ACP5X_NAU8821_FREQ_OUT 12288000 #define ACP5X_NAU8821_COMP_NAME "i2c-NVTN2020:00" @@ -31,7 +30,6 @@ #define ACP5X_CS35L41_COMP_RNAME "spi-VLV1776:01" #define ACP5X_CS35L41_DAI_NAME "cs35l41-pcm" -static unsigned long acp5x_machine_id; static struct snd_soc_jack vg_headset; SND_SOC_DAILINK_DEF(platform, DAILINK_COMP_ARRAY(COMP_PLATFORM("acp5x_i2s_dma.0"))); @@ -242,7 +240,6 @@ static int acp5x_cs35l41_hw_params(struct snd_pcm_substream *substream, } return 0; - } static const struct snd_soc_ops acp5x_cs35l41_play_ops = { @@ -292,8 +289,6 @@ static struct snd_soc_dai_link acp5x_8821_35l41_dai[] = { }, }; - - static const struct snd_soc_dapm_widget acp5x_8821_35l41_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), @@ -331,16 +326,8 @@ static struct snd_soc_card acp5x_8821_35l41_card = { .num_controls = ARRAY_SIZE(acp5x_8821_controls), }; -static int acp5x_vg_quirk_cb(const struct dmi_system_id *id) -{ - acp5x_machine_id = VG_JUPITER; - - return 1; -} - static const struct dmi_system_id acp5x_vg_quirk_table[] = { { - .callback = acp5x_vg_quirk_cb, .matches = { DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Valve"), DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Jupiter"), @@ -351,23 +338,22 @@ static const struct dmi_system_id acp5x_vg_quirk_table[] = { static int acp5x_probe(struct platform_device *pdev) { + const struct dmi_system_id *dmi_id; struct acp5x_platform_info *machine; struct device *dev = &pdev->dev; struct snd_soc_card *card; int ret; + dmi_id = dmi_first_match(acp5x_vg_quirk_table); + if (!dmi_id) + return -ENODEV; + + card = &acp5x_8821_35l41_card; + machine = devm_kzalloc(dev, sizeof(*machine), GFP_KERNEL); if (!machine) return -ENOMEM; - dmi_check_system(acp5x_vg_quirk_table); - switch (acp5x_machine_id) { - case VG_JUPITER: - card = &acp5x_8821_35l41_card; - break; - default: - return -ENODEV; - } card->dev = dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); From patchwork Wed Jul 5 13:43:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 116150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1885666vqx; Wed, 5 Jul 2023 06:55:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlHHRBFWFrfinrzahsZwMqPvIHKcxqYYGTyjVMEc9TJczo53dXHHbmII7SbVNURAUDzZDf6z X-Received: by 2002:a17:902:aa0b:b0:1b8:b73d:a75b with SMTP id be11-20020a170902aa0b00b001b8b73da75bmr147411plb.44.1688565322771; Wed, 05 Jul 2023 06:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688565322; cv=none; d=google.com; s=arc-20160816; b=OQs1t3kIDjSf7mwnsbnx7bUgpyZvzOfiEMbXF7zrzBivr6R9mvHHBh+SX5m/67tbAJ 91qc9vgi8jgbBeGXJgdTDUYIzY/wGaoeH1xVDx9y/5k1Jdn597AoSummKxnXB8qx8Squ bVbNOnEkdbRutFAhdqP4T/IvbDJ/2GjteLM9cijh7a/6mKRf/qzP2v6ZdGtquWbwN+Xm DwRM4PG7FhpnMgY2GmJ0q9HszqhrmbcoWmiQpBdVw4hSvO9Sw0C6T/TylBVsBzYIXQHF X1VfzJS6dkPVFrBcwK6LNOXplbZayfR/0g4QRyOiklibaChusGXBBLfSskrT5Pt16KpU vdiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r46GWdBAztWptkW38GsshdcEhjrxhOaTnITZs4m3jCA=; fh=cr2FL92h8TijVQGAjIwEJg7SUp/pazMAzWM7wR+E2Os=; b=RBmdeYjKHSCnPvvuVO5JP8zUKW7wVsGMkKqod/D6x6RYqSZxZkKcmLwv0fo5nltE1W 2kxDCkXvre3M1TOhx9W1jNvLb6TeC3zGN5DjxdoYIrX2JADTh5q8LjOjxYng0rp0Gjz3 0yYm41JEkkB4dhOwb7DQjR01cyezSGdqG7WYJpdm6L1dFpNiqNAqGP3vEE9brGzDBNhL lw6LImBtYwoST9E/jjMx0rsypxxGGLzunCI1GMN3J3uHSTeqL/7D30bn3pyA6SBINVCF pVMaRxXbRtmTKNPlHdPUq6G1gEkCFtbVsyaysJzEDTOqzmTRsijS9OVYDHciII2rqGoU 5YFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=R9+hXXfo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a17090301c700b001b88997ababsi9876788plh.412.2023.07.05.06.54.55; Wed, 05 Jul 2023 06:55:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=R9+hXXfo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230100AbjGENoC (ORCPT + 99 others); Wed, 5 Jul 2023 09:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbjGENn5 (ORCPT ); Wed, 5 Jul 2023 09:43:57 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4820171B for ; Wed, 5 Jul 2023 06:43:55 -0700 (PDT) Received: from localhost (unknown [188.24.137.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 9BE1B6606FB9; Wed, 5 Jul 2023 14:43:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688564634; bh=RDOqL2QvBsWdGDtjLILdg3uwJMqeZ/zmgqZTS73BrJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R9+hXXfoQBhv2BkO+lcoUezRvdGuWvPh2dbcGjdiUWAMbQPVeqJwnAqnbekAXIlsR 6yzZVNYDX0U+bebjeEmbrL/imbi57wYBrbKbJoQM9syAQMeqr4sRW9LwiwBk4qMpjw +lgaaq6iKNBnL//EygYNxObX2Z/i+KxPk0R05yP+0ZZCoDw0DLJeZTXmcw2hK56+tW 3xqyG0wUtWFEafTvk5bFZwnypQCz72y+7/CiXEjqw6L4N+QDhXDlPHVDA27kRnC+aw z96Ik8w3KnlzUWAjdQmrz7wRcam7smUIs85hwYlGUghJ5XU5ZmCR6iU0Sj+UWuuQgB Em761I+1rgGyQ== From: Cristian Ciocaltea To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Syed Saba Kareem , Vijendar Mukunda , Arnd Bergmann , Randy Dunlap , Charles Keepax , Kuninori Morimoto Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 3/3] ASoC: amd: vangogh: Add support for NAU8821/MAX98388 variant Date: Wed, 5 Jul 2023 16:43:41 +0300 Message-ID: <20230705134341.175889-4-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230705134341.175889-1-cristian.ciocaltea@collabora.com> References: <20230705134341.175889-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770589072035927190?= X-GMAIL-MSGID: =?utf-8?q?1770589072035927190?= Extend the Vangogh machine driver to support a variant based on the Nuvoton NAU88L21 Codec and the Analog Devices MAX98388 Speaker Amplifier. Additionally, enable probing via ACPI match table for this and future hardware revisions. Co-developed-by: Lucas Tanure Signed-off-by: Lucas Tanure Signed-off-by: Cristian Ciocaltea --- sound/soc/amd/Kconfig | 5 +- sound/soc/amd/vangogh/acp5x-mach.c | 155 +++++++++++++++++++++++++++-- 2 files changed, 150 insertions(+), 10 deletions(-) diff --git a/sound/soc/amd/Kconfig b/sound/soc/amd/Kconfig index 1dd8579e8034..273688c05317 100644 --- a/sound/soc/amd/Kconfig +++ b/sound/soc/amd/Kconfig @@ -79,14 +79,15 @@ config SND_SOC_AMD_ACP5x ACP DMA driver, CPU DAI driver. config SND_SOC_AMD_VANGOGH_MACH - tristate "AMD Vangogh support for NAU8821 CS35L41" + tristate "AMD Vangogh support for NAU8821/CS35L41/MAX98388" select SND_SOC_NAU8821 select SND_SOC_CS35L41_SPI + select SND_SOC_MAX98388 select SND_AMD_ACP_CONFIG depends on SND_SOC_AMD_ACP5x && I2C && SPI_MASTER help This option enables machine driver for Vangogh platform - using NAU8821 and CS35L41 codecs. + using NAU8821 and either CS35L41 or MAX98388 codecs. Say m if you have such a device. If unsure select "N". diff --git a/sound/soc/amd/vangogh/acp5x-mach.c b/sound/soc/amd/vangogh/acp5x-mach.c index 1efa8f8b77ab..42e37f4f1495 100644 --- a/sound/soc/amd/vangogh/acp5x-mach.c +++ b/sound/soc/amd/vangogh/acp5x-mach.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Machine driver for AMD Vangogh platform using NAU8821 & CS35L41 - * codecs. + * Machine driver for AMD Vangogh platform using either + * NAU8821 & CS35L41 or NAU8821 & MAX98388 codecs. * * Copyright 2021 Advanced Micro Devices, Inc. */ @@ -29,6 +29,9 @@ #define ACP5X_CS35L41_COMP_LNAME "spi-VLV1776:00" #define ACP5X_CS35L41_COMP_RNAME "spi-VLV1776:01" #define ACP5X_CS35L41_DAI_NAME "cs35l41-pcm" +#define ACP5X_MAX98388_COMP_LNAME "i2c-ADS8388:00" +#define ACP5X_MAX98388_COMP_RNAME "i2c-ADS8388:01" +#define ACP5X_MAX98388_DAI_NAME "max98388-aif1" static struct snd_soc_jack vg_headset; @@ -326,6 +329,126 @@ static struct snd_soc_card acp5x_8821_35l41_card = { .num_controls = ARRAY_SIZE(acp5x_8821_controls), }; +static int acp5x_max98388_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct acp5x_platform_info *machine = snd_soc_card_get_drvdata(rtd->card); + struct snd_pcm_runtime *runtime = substream->runtime; + + machine->play_i2s_instance = I2S_HS_INSTANCE; + + runtime->hw.channels_max = DUAL_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + &constraints_rates); + return 0; +} + +static int acp5x_max98388_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_dai *dai = snd_soc_card_get_codec_dai(rtd->card, + ACP5X_MAX98388_DAI_NAME); + int ret; + + ret = snd_soc_dai_set_fmt(dai, + SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF); + if (ret < 0) + dev_err(dai->dev, "Failed to set format: %d\n", ret); + + return ret; +} + +static const struct snd_soc_ops acp5x_max98388_play_ops = { + .startup = acp5x_max98388_startup, + .hw_params = acp5x_max98388_hw_params, +}; + +static struct snd_soc_codec_conf acp5x_max98388_conf[] = { + { + .dlc = COMP_CODEC_CONF(ACP5X_MAX98388_COMP_LNAME), + .name_prefix = "Left", + }, + { + .dlc = COMP_CODEC_CONF(ACP5X_MAX98388_COMP_RNAME), + .name_prefix = "Right", + }, +}; + +SND_SOC_DAILINK_DEF(max98388, DAILINK_COMP_ARRAY(COMP_CODEC(ACP5X_MAX98388_COMP_LNAME, + ACP5X_MAX98388_DAI_NAME), + COMP_CODEC(ACP5X_MAX98388_COMP_RNAME, + ACP5X_MAX98388_DAI_NAME))); + +static struct snd_soc_dai_link acp5x_8821_98388_dai[] = { + { + .name = "acp5x-8821-play", + .stream_name = "Playback/Capture", + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBC_CFC, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ops = &acp5x_8821_ops, + .init = acp5x_8821_init, + SND_SOC_DAILINK_REG(acp5x_i2s, nau8821, platform), + }, + { + .name = "acp5x-max98388-play", + .stream_name = "MAX98388 Playback", + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBC_CFC, + .dpcm_playback = 1, + .playback_only = 1, + .ops = &acp5x_max98388_play_ops, + SND_SOC_DAILINK_REG(acp5x_bt, max98388, platform), + }, +}; + +static const struct snd_soc_dapm_widget acp5x_8821_98388_widgets[] = { + SND_SOC_DAPM_HP("Headphone", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Int Mic", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SPK("SPK", NULL), +}; + +static const struct snd_soc_dapm_route acp5x_8821_98388_route[] = { + { "Headphone", NULL, "HPOL" }, + { "Headphone", NULL, "HPOR" }, + { "MICL", NULL, "Headset Mic" }, + { "MICR", NULL, "Headset Mic" }, + { "DMIC", NULL, "Int Mic" }, + + { "Headphone", NULL, "Platform Clock" }, + { "Headset Mic", NULL, "Platform Clock" }, + { "Int Mic", NULL, "Platform Clock" }, + + { "SPK", NULL, "Left BE_OUT" }, + { "SPK", NULL, "Right BE_OUT" }, +}; + +static struct snd_soc_card acp5x_8821_98388_card = { + .name = "acp5x-max98388", + .owner = THIS_MODULE, + .dai_link = acp5x_8821_98388_dai, + .num_links = ARRAY_SIZE(acp5x_8821_98388_dai), + .dapm_widgets = acp5x_8821_98388_widgets, + .num_dapm_widgets = ARRAY_SIZE(acp5x_8821_98388_widgets), + .dapm_routes = acp5x_8821_98388_route, + .num_dapm_routes = ARRAY_SIZE(acp5x_8821_98388_route), + .codec_conf = acp5x_max98388_conf, + .num_configs = ARRAY_SIZE(acp5x_max98388_conf), + .controls = acp5x_8821_controls, + .num_controls = ARRAY_SIZE(acp5x_8821_controls), +}; + static const struct dmi_system_id acp5x_vg_quirk_table[] = { { .matches = { @@ -344,11 +467,20 @@ static int acp5x_probe(struct platform_device *pdev) struct snd_soc_card *card; int ret; - dmi_id = dmi_first_match(acp5x_vg_quirk_table); - if (!dmi_id) - return -ENODEV; - - card = &acp5x_8821_35l41_card; + card = (struct snd_soc_card *)device_get_match_data(dev); + if (!card) { + /* + * This is normally the result of directly probing the driver + * in pci-acp5x through platform_device_register_full(), which + * is necessary for the CS35L41 variant, as it doesn't support + * ACPI probing and relies on DMI quirks. + */ + dmi_id = dmi_first_match(acp5x_vg_quirk_table); + if (!dmi_id) + return -ENODEV; + + card = &acp5x_8821_35l41_card; + } machine = devm_kzalloc(dev, sizeof(*machine), GFP_KERNEL); if (!machine) @@ -365,10 +497,17 @@ static int acp5x_probe(struct platform_device *pdev) return 0; } +static const struct acpi_device_id acp5x_acpi_match[] = { + { "AMDI8821", (kernel_ulong_t)&acp5x_8821_98388_card }, + {}, +}; +MODULE_DEVICE_TABLE(acpi, acp5x_acpi_match); + static struct platform_driver acp5x_mach_driver = { .driver = { .name = DRV_NAME, .pm = &snd_soc_pm_ops, + .acpi_match_table = acp5x_acpi_match, }, .probe = acp5x_probe, }; @@ -376,6 +515,6 @@ static struct platform_driver acp5x_mach_driver = { module_platform_driver(acp5x_mach_driver); MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); -MODULE_DESCRIPTION("NAU8821 & CS35L41 audio support"); +MODULE_DESCRIPTION("NAU8821/CS35L41 & NAU8821/MAX98388 audio support"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" DRV_NAME);