From patchwork Thu Aug 4 09:13:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunxu Li X-Patchwork-Id: 12936240 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 17CD8C19F2B for ; Thu, 4 Aug 2022 09:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xbm63bG2m20HOenxWe9HHMe7Re9TgrNrrbO8Mz3BSF4=; b=yc3DeOerclPsRSZux1UJFKVobp PQmFgmmeqhFG3SXhfVeCDe+ZQsRgYi6JFbqdBdoIU0xo+7y6ETYglsI+6bywSD2sI9xFt2YKk6Eoa swOV3iA2exrgwo+oBTxKyuLAEO1OAr6hUjqpBeOdKiAlfGuxk8olRajpRocXZQs76SlaIarIEa3Tt TGe1sLKOQm/JNLjfuKpBFmpCKoibgeHtm1pNqPdl2p8t/e0zj71kbdVFxl6Gc09bqoc834mzqLE9m lGYPc3y8K9Zcg2bEZWhzaw8bcSdd7JWjkSDuT86+p5oZQnAJ/beaNecutM7+Woarozsd8GE0puqWy 212iXeMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJXPU-004wdQ-FW; Thu, 04 Aug 2022 09:44:56 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJXPQ-004waj-28; Thu, 04 Aug 2022 09:44:55 +0000 X-UUID: 909401551dee48bcb2512a08f9c73de7-20220804 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8,REQID:76176eb0-c027-4c79-8663-fdc61e71d308,OB:0,LO B:0,IP:0,URL:5,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:0 X-CID-META: VersionHash:0f94e32,CLOUDID:25fa38d1-841b-4e95-ad42-8f86e18f54fc,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:1,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: 909401551dee48bcb2512a08f9c73de7-20220804 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 940544518; Thu, 04 Aug 2022 02:44:44 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Thu, 4 Aug 2022 17:14:09 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 4 Aug 2022 17:14:08 +0800 From: Chunxu Li To: , , , , , CC: , , , , , , , , , Chunxu Li Subject: [PATCH 1/2] ASoC: SOF: Introduce optional callback of_machine_select Date: Thu, 4 Aug 2022 17:13:58 +0800 Message-ID: <20220804091359.31449-2-chunxu.li@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220804091359.31449-1-chunxu.li@mediatek.com> References: <20220804091359.31449-1-chunxu.li@mediatek.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220804_024452_234806_E1B3B54A X-CRM114-Status: GOOD ( 21.12 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From current design in sof_machine_check and snd_sof_new_platform_drv, the SOF can only support ACPI type machine. 1. In sof_machine_check if there is no ACPI machine exist, the function will return -ENODEV directly, that's we don't expected if we do not base on ACPI machine. 2. In snd_sof_new_platform_drv the component driver need a driver name to do ignore_machine, currently the driver name is obtained from machine->drv_name, and the type of machine is snd_soc_acpi_mach. So we add a new function snd_sof_of_machine_select that we can pass sof_machine_check and obtain info required by snd_sof_new_platform_drv. this callback is optional, each machine that do not based on ACPI can use common code implemented in sof-of-dev.c or implement their customized specific routine. Signed-off-by: Chunxu Li --- include/sound/sof.h | 2 ++ sound/soc/sof/ops.h | 9 +++++++++ sound/soc/sof/pcm.c | 8 +++++++- sound/soc/sof/sof-audio.c | 7 +++++++ sound/soc/sof/sof-of-dev.c | 23 +++++++++++++++++++++++ sound/soc/sof/sof-of-dev.h | 8 ++++++++ sound/soc/sof/sof-priv.h | 1 + 7 files changed, 57 insertions(+), 1 deletion(-) diff --git a/include/sound/sof.h b/include/sound/sof.h index 367dccfea7ad..341fef19e612 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -89,6 +89,7 @@ struct snd_sof_pdata { /* machine */ struct platform_device *pdev_mach; const struct snd_soc_acpi_mach *machine; + const struct snd_sof_of_mach *of_machine; void *hw_pdata; @@ -102,6 +103,7 @@ struct snd_sof_pdata { struct sof_dev_desc { /* list of machines using this configuration */ struct snd_soc_acpi_mach *machines; + struct snd_sof_of_mach *of_machines; /* alternate list of machines using this configuration */ struct snd_soc_acpi_mach *alt_machines; diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index 55d43adb6a29..e20720c09744 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -522,6 +522,15 @@ snd_sof_set_mach_params(struct snd_soc_acpi_mach *mach, sof_ops(sdev)->set_mach_params(mach, sdev); } +static inline struct snd_sof_of_mach * +snd_sof_of_machine_select(struct snd_sof_dev *sdev) +{ + if (sof_ops(sdev) && sof_ops(sdev)->of_machine_select) + return sof_ops(sdev)->of_machine_select(sdev); + + return NULL; +} + /** * snd_sof_dsp_register_poll_timeout - Periodically poll an address * until a condition is met or a timeout occurs diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 6cb6a432be5e..49f7cb049f62 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -13,6 +13,7 @@ #include #include #include +#include "sof-of-dev.h" #include "sof-priv.h" #include "sof-audio.h" #include "sof-utils.h" @@ -655,7 +656,12 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev) struct snd_sof_pdata *plat_data = sdev->pdata; const char *drv_name; - drv_name = plat_data->machine->drv_name; + if (plat_data->machine) + drv_name = plat_data->machine->drv_name; + else if (plat_data->of_machine) + drv_name = plat_data->of_machine->drv_name; + else + drv_name = NULL; pd->name = "sof-audio-component"; pd->probe = sof_pcm_probe; diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index 28976098a89e..7b3c99d1b2a4 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -794,6 +794,7 @@ int sof_machine_check(struct snd_sof_dev *sdev) struct snd_soc_acpi_mach *mach; if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) { + const struct snd_sof_of_mach *of_mach; /* find machine */ mach = snd_sof_machine_select(sdev); @@ -803,6 +804,12 @@ int sof_machine_check(struct snd_sof_dev *sdev) return 0; } + of_mach = snd_sof_of_machine_select(sdev); + if (of_mach) { + sof_pdata->of_machine = of_mach; + return 0; + } + if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) { dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n"); return -ENODEV; diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 53faeccedd4f..8df588f9349a 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -31,6 +31,29 @@ const struct dev_pm_ops sof_of_pm = { }; EXPORT_SYMBOL(sof_of_pm); +struct snd_sof_of_mach *sof_of_machine_select(struct snd_sof_dev *sdev) +{ + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; + struct snd_sof_of_mach *mach = desc->of_machines; + + if (!mach) + return NULL; + + for (; mach->board; mach++) { + if (of_machine_is_compatible(mach->board)) { + sof_pdata->tplg_filename = mach->sof_tplg_filename; + if (mach->fw_filename) + sof_pdata->fw_filename = mach->fw_filename; + + return mach; + } + } + + return NULL; +} +EXPORT_SYMBOL(sof_of_machine_select); + static void sof_of_probe_complete(struct device *dev) { /* allow runtime_pm */ diff --git a/sound/soc/sof/sof-of-dev.h b/sound/soc/sof/sof-of-dev.h index fd950a222ba4..2ab81ced139d 100644 --- a/sound/soc/sof/sof-of-dev.h +++ b/sound/soc/sof/sof-of-dev.h @@ -9,8 +9,16 @@ #ifndef __SOUND_SOC_SOF_OF_H #define __SOUND_SOC_SOF_OF_H +struct snd_sof_of_mach { + const char *board; + const char *drv_name; + const char *fw_filename; + const char *sof_tplg_filename; +}; + extern const struct dev_pm_ops sof_of_pm; +struct snd_sof_of_mach *sof_of_machine_select(struct snd_sof_dev *sdev); int sof_of_probe(struct platform_device *pdev); int sof_of_remove(struct platform_device *pdev); void sof_of_shutdown(struct platform_device *pdev); diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 823583086279..c5ed18f99d00 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -284,6 +284,7 @@ struct snd_sof_dsp_ops { void (*machine_unregister)(struct snd_sof_dev *sdev, void *pdata); /* optional */ struct snd_soc_acpi_mach * (*machine_select)(struct snd_sof_dev *sdev); /* optional */ + struct snd_sof_of_mach * (*of_machine_select)(struct snd_sof_dev *sdev); /* optional */ void (*set_mach_params)(struct snd_soc_acpi_mach *mach, struct snd_sof_dev *sdev); /* optional */ From patchwork Thu Aug 4 09:13:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunxu Li X-Patchwork-Id: 12936232 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 8779CC19F2B for ; Thu, 4 Aug 2022 09:25:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VYUfT68RNsoGGWKKnAeyYhCj4GxAS2uI+JLm2JoABYs=; b=GtbPPeRzmyTLuWK1xzLhZgfqAl Uzl3om+cyOLun4UqrWOlsRmC+LbL/PfsN2m/RKVrAHwI1d6pGhlP99NuFODwlpp0RSXeMPGQ9BI1J 631Y1wqsLF/b6jMXWLCKqdPqinUEtTTJe6odw6hcwUsv88tFgEvLE0tHG9Zlks611jbEe4iwmpk2n cF1IRIfpbYFkx0DqMME4W4ilc2ebbMkpTx5xtD9Hg14kxApEkxMMu7Lapn7y2WKNjvvUV/Y36Adzl MSkGGvFduFdyxIn2zcNZ0DEcZZsMKhFUdzUKbMxWw48qosAIOIs23ZwQOpmOR1XfezgsSeWOP4HwH vWwJjyHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJX6O-004nig-3c; Thu, 04 Aug 2022 09:25:12 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJX62-004nXR-Ue; Thu, 04 Aug 2022 09:24:52 +0000 X-UUID: d7f3ca992a7b4ad8bf90fb21c0e315d0-20220804 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8,REQID:bd517d54-96d8-4c4b-a096-effcd9dd67e6,OB:0,LO B:0,IP:0,URL:5,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:0 X-CID-META: VersionHash:0f94e32,CLOUDID:26ee47d0-a6cf-4fb6-be1b-c60094821ca2,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:1,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: d7f3ca992a7b4ad8bf90fb21c0e315d0-20220804 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 841998729; Thu, 04 Aug 2022 02:24:48 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Thu, 4 Aug 2022 17:14:10 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 4 Aug 2022 17:14:09 +0800 From: Chunxu Li To: , , , , , CC: , , , , , , , , , Chunxu Li Subject: [PATCH 2/2] ASoC: SOF: mediatek: Add .of_machine_select field for mt8186 Date: Thu, 4 Aug 2022 17:13:59 +0800 Message-ID: <20220804091359.31449-3-chunxu.li@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220804091359.31449-1-chunxu.li@mediatek.com> References: <20220804091359.31449-1-chunxu.li@mediatek.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220804_022451_021951_599A1BF0 X-CRM114-Status: GOOD ( 10.39 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org As the mt8186 do not use ACPI type machine, the of_machine_select is used to distinguish different machines in sof_machine_check. Signed-off-by: Chunxu Li --- sound/soc/sof/mediatek/mt8186/mt8186.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c index e006532caf2f..cb8bed383064 100644 --- a/sound/soc/sof/mediatek/mt8186/mt8186.c +++ b/sound/soc/sof/mediatek/mt8186/mt8186.c @@ -497,6 +497,8 @@ static struct snd_sof_dsp_ops sof_mt8186_ops = { /* misc */ .get_bar_index = mt8186_get_bar_index, + .of_machine_select = sof_of_machine_select, + /* firmware loading */ .load_firmware = snd_sof_load_firmware_memcpy, @@ -515,7 +517,16 @@ static struct snd_sof_dsp_ops sof_mt8186_ops = { SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, }; +static struct snd_sof_of_mach sof_mt8186_machs[] = { + { + .board = "mediatek,mt8186", + .sof_tplg_filename = "sof-mt8186.tplg", + }, + {} +}; + static const struct sof_dev_desc sof_of_mt8186_desc = { + .of_machines = sof_mt8186_machs, .ipc_supported_mask = BIT(SOF_IPC), .ipc_default = SOF_IPC, .default_fw_path = {