From patchwork Tue Aug 24 13:21:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hsieh X-Patchwork-Id: 12455007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2847AC4338F for ; Tue, 24 Aug 2021 13:22:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CD0BF61262 for ; Tue, 24 Aug 2021 13:22:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CD0BF61262 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=wistron.corp-partner.google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 81D611658; Tue, 24 Aug 2021 15:21:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 81D611658 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1629811337; bh=mbM8FmjBZ5KVRxEHBrq31pGImP150ESNBXVd+s68x0I=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=lhUhyOlaR0EMIcg3hAHX0JYzPwvdhvfnogWvCVLxU3QxB5ZDOScuBBce1vhOh3POh i2s9GZPr6ZlcDEbEEqJ1+W0el/w6wQEN+N7+DujDTSJkmQZ/NIt/WC0KPHXHqsoEwe 5wX21FEZ0DKstm9Dp4leNY/f7KeyxUxbtaqADr5E= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0E113F801D5; Tue, 24 Aug 2021 15:21:27 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 36282F801D8; Tue, 24 Aug 2021 15:21:25 +0200 (CEST) Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 29CFCF80087 for ; Tue, 24 Aug 2021 15:21:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 29CFCF80087 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=wistron-corp-partner-google-com.20150623.gappssmtp.com header.i=@wistron-corp-partner-google-com.20150623.gappssmtp.com header.b="cgcCu5mZ" Received: by mail-pg1-x52e.google.com with SMTP id r2so19748836pgl.10 for ; Tue, 24 Aug 2021 06:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wistron-corp-partner-google-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=MUvv2mp0uTHfXISXAC47FViwGrFbVVgYK+natZk5Dzc=; b=cgcCu5mZTNZFytmDj/6Lcegslsy0Jo+cEI0bHg2MO1XAYemLvBPlBMXUf0EMFsHcjE 86URDK0/IKK/TFWZfzfn2CMZ5MSRwXuMW1KhlgmcEJgM+x7GoMTqZlrlHFX8fN3StLCS n43CASSoz472WnzwVfucXhDM+09e57mGkpny1xnpzPCppJVuB2Kc72nHTAd706uvV7h3 h1zNlPaIDC87A9t0RevN+r5RW0hqxUbshW/hzLEQNNEZPGcJ3mnJYyGgriHSo98RFfbS 5X/6ZtfrAu0uPpPFxUDMSelCwKjrTs3Jo81v05V9GG8QLgljLfmSl7MMdUYs8/S6z60u Cj9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MUvv2mp0uTHfXISXAC47FViwGrFbVVgYK+natZk5Dzc=; b=hmBvGNslM8tSD3dzntFOI/8rEfeQqcQCZpo4yB4o2P4c8sflvMhPb5sd4u+2lGyUqS Uni8+8WwmsbLmvbwG+2SDRl7WknRby4TTmK+l36LUXpgNVF47pud8/fLuDAuEccK+GEy WjWGwI5uyv1RB5C1bSSOEjxIjMKPzW/Js0hZZNsy6I13HStmOZKC9AK3za9hR6j0K04w 2Np67O7E/6bgmDPuZtudJqxcBctHfpQbyiKHeG3zRrVqTd/8vTGYJNnrXTXj0o1p78Wx gslqNIH9usEfHH8z4Kv3F7uknIS4tt0A9FM/I5qkq9OeRtlwcLN0AJNfaDgDhPqlMXYo vZHw== X-Gm-Message-State: AOAM532tmMcXR1FizA7NZrGUuMNz37YgwUbNuXsVYnBZi0RXqf41WuHA f7GbsI2B/GSE2wtts092WESDNFTuD2s+zA== X-Google-Smtp-Source: ABdhPJz7YYIQVI+BsSWcMUk+3EXWizH8puqwfXCUNlP2edqj4Dc3Ykw+KlgPP8nYe0nLVjCD2BV4kw== X-Received: by 2002:a63:5c04:: with SMTP id q4mr36763054pgb.127.1629811277175; Tue, 24 Aug 2021 06:21:17 -0700 (PDT) Received: from localhost.localdomain (60-251-182-145.HINET-IP.hinet.net. [60.251.182.145]) by smtp.gmail.com with ESMTPSA id a25sm2664010pfo.200.2021.08.24.06.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 06:21:16 -0700 (PDT) From: Mark Hsieh To: alsa-devel@alsa-project.org Subject: [PATCH] [v2] ASoC: Intel: sof_rt5682: Add support for max98390 speaker amp Date: Tue, 24 Aug 2021 21:21:09 +0800 Message-Id: <20210824132109.1392-1-mark_hsieh@wistron.corp-partner.google.com> X-Mailer: git-send-email 2.17.1 Cc: lance.hou@intel.com, cezary.rojewski@intel.com, mark_hsieh@wistron.com, kai.vehmanen@linux.intel.com, linux-kernel@vger.kernel.org, yang.jie@linux.intel.com, pierre-louis.bossart@linux.intel.com, Mark Hsieh , liam.r.girdwood@linux.intel.com, mac.chiang@intel.com, broonie@kernel.org, brent.lu@intel.com, bard.liao@intel.com 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" Configure adl_max98390_rt5682 to support the rt5682 headset codec and max98390 speaker BUG=b:191811888 TEST=emerge-brya chromeos-kernel-5_10 Signed-off-by: Mark Hsieh --- sound/soc/intel/boards/Kconfig | 1 + sound/soc/intel/boards/sof_maxim_common.c | 59 +++++++++++++++++++ sound/soc/intel/boards/sof_maxim_common.h | 12 ++++ sound/soc/intel/boards/sof_rt5682.c | 20 ++++++- .../intel/common/soc-acpi-intel-adl-match.c | 13 ++++ 5 files changed, 104 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index 7e29b0d911e2..0017c08c5a62 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -470,6 +470,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH select SND_SOC_RT1015 select SND_SOC_RT1015P select SND_SOC_RT5682_I2C + select SND_SOC_MAX98390 select SND_SOC_DMIC select SND_SOC_HDAC_HDMI select SND_SOC_INTEL_HDA_DSP_COMMON diff --git a/sound/soc/intel/boards/sof_maxim_common.c b/sound/soc/intel/boards/sof_maxim_common.c index e9c52f8b6428..477883d571ab 100644 --- a/sound/soc/intel/boards/sof_maxim_common.c +++ b/sound/soc/intel/boards/sof_maxim_common.c @@ -133,6 +133,65 @@ void max_98373_set_codec_conf(struct snd_soc_card *card) } EXPORT_SYMBOL_NS(max_98373_set_codec_conf, SND_SOC_INTEL_SOF_MAXIM_COMMON); +/* + * Maxim MAX98390 + */ + +static struct snd_soc_codec_conf max_98390_codec_conf[] = { + { + .dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME), + .name_prefix = "Right", + }, + { + .dlc = COMP_CODEC_CONF(MAX_98390_DEV1_NAME), + .name_prefix = "Left", + }, +}; + +struct snd_soc_dai_link_component max_98390_components[] = { + { /* For Right */ + .name = MAX_98390_DEV0_NAME, + .dai_name = MAX_98390_CODEC_DAI, + }, + { /* For Left */ + .name = MAX_98390_DEV1_NAME, + .dai_name = MAX_98390_CODEC_DAI, + }, +}; +EXPORT_SYMBOL_NS(max_98390_components, SND_SOC_INTEL_SOF_MAXIM_COMMON); + +static int max_98390_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 *codec_dai; + int j; + + for_each_rtd_codec_dais(rtd, j, codec_dai) { + if (!strcmp(codec_dai->component->name, MAX_98390_DEV0_NAME)) { + /* DEV0 tdm slot configuration */ + snd_soc_dai_set_tdm_slot(codec_dai, 0x03, 3, 2, 16); + } + if (!strcmp(codec_dai->component->name, MAX_98390_DEV1_NAME)) { + /* DEV1 tdm slot configuration */ + snd_soc_dai_set_tdm_slot(codec_dai, 0x0C, 3, 2, 16); + } + } + return 0; +} + +struct snd_soc_ops max_98390_ops = { + .hw_params = max_98390_hw_params, +}; +EXPORT_SYMBOL_NS(max_98390_ops, SND_SOC_INTEL_SOF_MAXIM_COMMON); + +void max_98390_set_codec_conf(struct snd_soc_card *card) +{ + card->codec_conf = max_98390_codec_conf; + card->num_configs = ARRAY_SIZE(max_98390_codec_conf); +} +EXPORT_SYMBOL_NS(max_98390_set_codec_conf, SND_SOC_INTEL_SOF_MAXIM_COMMON); + /* * Maxim MAX98357A */ diff --git a/sound/soc/intel/boards/sof_maxim_common.h b/sound/soc/intel/boards/sof_maxim_common.h index 2674f1e373ef..2458758866f3 100644 --- a/sound/soc/intel/boards/sof_maxim_common.h +++ b/sound/soc/intel/boards/sof_maxim_common.h @@ -24,6 +24,18 @@ int max_98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd); void max_98373_set_codec_conf(struct snd_soc_card *card); int max_98373_trigger(struct snd_pcm_substream *substream, int cmd); +/* + * Maxim MAX98390 + */ +#define MAX_98390_CODEC_DAI "max98390-aif1" +#define MAX_98390_DEV0_NAME "i2c-MX98390:00" +#define MAX_98390_DEV1_NAME "i2c-MX98390:01" + +extern struct snd_soc_dai_link_component max_98390_components[2]; +extern struct snd_soc_ops max_98390_ops; + +void max_98390_set_codec_conf(struct snd_soc_card *card); + /* * Maxim MAX98357A */ diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index 39217223d50c..dc4966056b7d 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -49,6 +49,7 @@ #define SOF_RT1015P_SPEAKER_AMP_PRESENT BIT(16) #define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(17) #define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(18) +#define SOF_MAX98390_SPEAKER_AMP_PRESENT BIT(23) /* BT audio offload: reserve 3 bits for future */ #define SOF_BT_OFFLOAD_SSP_SHIFT 19 @@ -781,6 +782,13 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, } else if (sof_rt5682_quirk & SOF_RT1011_SPEAKER_AMP_PRESENT) { sof_rt1011_dai_link(&links[id]); + } else if (sof_rt5682_quirk & + SOF_MAX98390_SPEAKER_AMP_PRESENT) { + links[id].codecs = max_98390_components; + links[id].num_codecs = ARRAY_SIZE(max_98390_components); + links[id].init = max_98373_spk_codec_init; + links[id].ops = &max_98390_ops; + links[id].dpcm_capture = 1; } else { max_98357a_dai_link(&links[id]); } @@ -917,7 +925,8 @@ static int sof_audio_probe(struct platform_device *pdev) sof_rt1011_codec_conf(&sof_audio_card_rt5682); else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) sof_rt1015p_codec_conf(&sof_audio_card_rt5682); - + else if (sof_rt5682_quirk & SOF_MAX98390_SPEAKER_AMP_PRESENT) + max_98390_set_codec_conf(&sof_audio_card_rt5682); if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) sof_audio_card_rt5682.num_links++; @@ -1043,6 +1052,15 @@ static const struct platform_device_id board_ids[] = { SOF_RT5682_SSP_AMP(2) | SOF_RT5682_NUM_HDMIDEV(4)), }, + { + .name = "adl_max98390_rt5682", + .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | + SOF_RT5682_SSP_CODEC(0) | + SOF_SPEAKER_AMP_PRESENT | + SOF_MAX98390_SPEAKER_AMP_PRESENT | + SOF_RT5682_SSP_AMP(2) | + SOF_RT5682_NUM_HDMIDEV(4)), + }, { } }; MODULE_DEVICE_TABLE(platform, board_ids); diff --git a/sound/soc/intel/common/soc-acpi-intel-adl-match.c b/sound/soc/intel/common/soc-acpi-intel-adl-match.c index a0f6a69c7038..2db152998e4a 100644 --- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c @@ -280,6 +280,11 @@ static const struct snd_soc_acpi_codecs adl_max98357a_amp = { .codecs = {"MX98357A"} }; +static const struct snd_soc_acpi_codecs adl_max98390_amp = { + .num_codecs = 1, + .codecs = {"MX98390"} +}; + struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { { .id = "10EC5682", @@ -297,6 +302,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { .sof_fw_filename = "sof-adl.ri", .sof_tplg_filename = "sof-adl-max98357a-rt5682.tplg", }, + { + .id = "10EC5682", + .drv_name = "adl_max98390_rt5682", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &adl_max98390_amp, + .sof_fw_filename = "sof-adl.ri", + .sof_tplg_filename = "sof-adl-max98390-rt5682.tplg", + }, {}, }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines);