From patchwork Wed Mar 8 07:35:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Svyatoslav Ryhel X-Patchwork-Id: 66061 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp194534wrd; Tue, 7 Mar 2023 23:48:46 -0800 (PST) X-Google-Smtp-Source: AK7set9yFDV74zHkua6JNuz6wSAorjIZ+5uNUKNpw3HShHdEDNx5xhxpQQpMDGvjXxWxccsH4Mft X-Received: by 2002:a17:906:eb49:b0:8f7:7876:fd96 with SMTP id mc9-20020a170906eb4900b008f77876fd96mr16096733ejb.58.1678261726400; Tue, 07 Mar 2023 23:48:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678261726; cv=none; d=google.com; s=arc-20160816; b=D8+9KZqa67MJXD9SCl5WB2nTw/2gjKYX2gL++IWhWkUZLIV1HKypS49ZEkPsx3bqOl YC36e0tKUY/AbCE5NwRMIuXuzcxD/0xTYRg+3Ou8JLJ1sVzhVIWN97xMc/sj5hLnbNtI p6l9cyLPzwDWAraOqPKbRvyZDjSbD5Zr3oPgiahPlVBWHh4MH/U26tbA93iHfB///pPO dTvi4uiuBeUaIdsKvaIYZmeO90yTlF/TZZPxlH48slhFA0DtRDdkEcuAJYYOxHQwuwtq 20E5+vxTlQfwn8HgQRvdA7LwmVuIPAeFyDZxHA4e4yu/m1f2nqJ6xmG+ibodba7PIpXg DUMA== 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=uwmnzBCq63isuXl3Q6C2EI4fASZ8/CUk+jrNqzYxJ44=; b=SEsQ9PoxI3oQvjzTEPXH2/B/6sqGCySd+xEdopjL75V0HV/0h37MsEzy+WGIFbHVJR XI7wOGHNe9k3NdA8sEfruloAXVZHY7nY/EQyKevcqYDOuh7XgX9Cz5xx9BtV6xi+328m 9qJL427/q0xPlCj0wgXf4/lE/ZwwP+gwuLIbTwwDY5Bf3RPag6ZxhmWC0NdaA5m5SbD6 2Wortq37EClMxK/atsYgFJbiSoAQmExHY46Xkclb4AfZH9P5febDtoRs45S0YpqCH6uk lRKYTb7f60EAbRaw8U3vRuvBTCYIbrTF1e1gB0jGlV1u4flyZNCTGd8TmWxH1cU4jo62 L4wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="VbzEV/Vv"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca10-20020a170906a3ca00b008cec55af403si1111967ejb.832.2023.03.07.23.48.22; Tue, 07 Mar 2023 23:48:46 -0800 (PST) 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=@gmail.com header.s=20210112 header.b="VbzEV/Vv"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbjCHHgN (ORCPT + 99 others); Wed, 8 Mar 2023 02:36:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbjCHHfj (ORCPT ); Wed, 8 Mar 2023 02:35:39 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F420768F; Tue, 7 Mar 2023 23:35:34 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id i34so62023467eda.7; Tue, 07 Mar 2023 23:35:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678260932; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uwmnzBCq63isuXl3Q6C2EI4fASZ8/CUk+jrNqzYxJ44=; b=VbzEV/VvOn0aSQHQgw9+0pNrIzr+/yH5ubUhN1HKeSmTXf94BdvU0QAKeTG/UexecP ZICikcpLbHW2e0fYNwJ1vyGRLpXhwmMMlXD9YP4uO+DI5vvTfwVk203z/MAYV7iNWyaM LzAP5cU4wfatBnoKPgcGA8qelmXohuXnpZcu1lSeTbjjW3JnQg7Lwe2dS93Db7T778FE cBvDSoBmgp6dMUeoYjAojgWZRchmdsvquJU223oHpOImJgsuy1k8R4gIJQ1WmoZmx8pJ N8S7zxDTRsGGvpgIvE+YkAOd2Hsg6lQsjUcJTHv2ZjlZBM3GeR1S2dA9jZ8xNEj38m4l TbHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678260932; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uwmnzBCq63isuXl3Q6C2EI4fASZ8/CUk+jrNqzYxJ44=; b=QRoaVuvEejaXxFL2QIvvozunDgJzuBpF7ocfTTsI6MnpkT1KPvjWGZULa9UK8gDiEq Uhz7WnvmXhp5dukvcWWMNNI8cJrHLwSM2XJLu6zPSDQtbOtQJV21C3u34HGCQPdzz5BQ sjXLBNhWZTdwpwe45/RcNCkw0ibJ2fZrkWwQxs4d6ItgC76j1tHkipLhzKBVGZ08Xi3d TW43zwxj+ZCQraDrPPtRrbaOrxLsgqYUlKvuSV3SsDD5NfJmrT4amUOjjQR+776P11W3 +P3mH8YaaMHkmagD5iqPx9mxc3p/u6dmy+J1c1GlBDXfRcJys6v5LD9JfBOvtLxDNMyv wghA== X-Gm-Message-State: AO0yUKW7lnkhdWkFF+bhVImY7MbB6uzEWL0lIB9d+CP3NP5xDv52hSr6 FN3EdzqZcfYJZZyC7Nn0txop5dkczr0= X-Received: by 2002:a17:907:6f18:b0:8f8:5779:f1af with SMTP id sy24-20020a1709076f1800b008f85779f1afmr18421549ejc.15.1678260932432; Tue, 07 Mar 2023 23:35:32 -0800 (PST) Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id h15-20020a1709062dcf00b008dffda52d71sm7051880eji.124.2023.03.07.23.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 23:35:32 -0800 (PST) From: Svyatoslav Ryhel To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Jaroslav Kysela , Takashi Iwai , Svyatoslav Ryhel , Maxim Schwalm , Dmitry Osipenko Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-tegra@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 8/8] ASoC: tegra: Support MAX9808x by machine driver Date: Wed, 8 Mar 2023 09:35:02 +0200 Message-Id: <20230308073502.5421-9-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230308073502.5421-1-clamor95@gmail.com> References: <20230308073502.5421-1-clamor95@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1759784967931072400?= X-GMAIL-MSGID: =?utf-8?q?1759784967931072400?= Add Maxim MAX9808x codec support to the Tegra ASoC machine driver. This codec is found on LG T30 devices like Optimus 4X HD and Optimus Vu. Signed-off-by: Svyatoslav Ryhel --- sound/soc/tegra/Kconfig | 9 ++++++ sound/soc/tegra/tegra_asoc_machine.c | 46 +++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index ff905e5dcd86..950f490b8d54 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -263,6 +263,15 @@ config SND_SOC_TEGRA_MAX98090 Say Y or M here if you want to add support for SoC audio on Tegra boards using the MAX98090 codec, such as Venice2. +config SND_SOC_TEGRA_MAX98088 + tristate "SoC Audio support for Tegra boards using a MAX9808x codec" + depends on I2C && GPIOLIB + select SND_SOC_TEGRA_MACHINE_DRV + select SND_SOC_MAX98088 + help + Say Y or M here if you want to add support for SoC audio on Tegra + boards using the MAX98088 codec, such as LG X3. + config SND_SOC_TEGRA_RT5677 tristate "SoC Audio support for Tegra boards using a RT5677 codec" depends on I2C && GPIOLIB diff --git a/sound/soc/tegra/tegra_asoc_machine.c b/sound/soc/tegra/tegra_asoc_machine.c index 020f03349373..cc08325d523b 100644 --- a/sound/soc/tegra/tegra_asoc_machine.c +++ b/sound/soc/tegra/tegra_asoc_machine.c @@ -86,11 +86,11 @@ static int tegra_machine_event(struct snd_soc_dapm_widget *w, gpiod_set_value_cansleep(machine->gpiod_spkr_en, SND_SOC_DAPM_EVENT_ON(event)); - if (!strcmp(w->name, "Mic Jack")) + if (!strcmp(w->name, "Mic Jack") || !strcmp(w->name, "Headset Mic")) gpiod_set_value_cansleep(machine->gpiod_ext_mic_en, SND_SOC_DAPM_EVENT_ON(event)); - if (!strcmp(w->name, "Int Mic")) + if (!strcmp(w->name, "Int Mic") || !strcmp(w->name, "Internal Mic 2")) gpiod_set_value_cansleep(machine->gpiod_int_mic_en, SND_SOC_DAPM_EVENT_ON(event)); @@ -108,11 +108,12 @@ static const struct snd_soc_dapm_widget tegra_machine_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphones", NULL), SND_SOC_DAPM_SPK("Speakers", tegra_machine_event), SND_SOC_DAPM_SPK("Int Spk", tegra_machine_event), + SND_SOC_DAPM_SPK("Earpiece", NULL), SND_SOC_DAPM_MIC("Int Mic", tegra_machine_event), SND_SOC_DAPM_MIC("Mic Jack", tegra_machine_event), SND_SOC_DAPM_MIC("Internal Mic 1", NULL), - SND_SOC_DAPM_MIC("Internal Mic 2", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Internal Mic 2", tegra_machine_event), + SND_SOC_DAPM_MIC("Headset Mic", tegra_machine_event), SND_SOC_DAPM_MIC("Digital Mic", NULL), SND_SOC_DAPM_MIC("Mic", NULL), SND_SOC_DAPM_LINE("Line In Jack", NULL), @@ -123,6 +124,7 @@ static const struct snd_soc_dapm_widget tegra_machine_dapm_widgets[] = { static const struct snd_kcontrol_new tegra_machine_controls[] = { SOC_DAPM_PIN_SWITCH("Speakers"), SOC_DAPM_PIN_SWITCH("Int Spk"), + SOC_DAPM_PIN_SWITCH("Earpiece"), SOC_DAPM_PIN_SWITCH("Int Mic"), SOC_DAPM_PIN_SWITCH("Headset Mic"), SOC_DAPM_PIN_SWITCH("Internal Mic 1"), @@ -718,6 +720,40 @@ static const struct tegra_asoc_data tegra_max98090_data = { .add_hp_jack = true, }; +/* MAX98088 machine */ + +SND_SOC_DAILINK_DEFS(max98088_hifi, + DAILINK_COMP_ARRAY(COMP_EMPTY()), + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "HiFi")), + DAILINK_COMP_ARRAY(COMP_EMPTY())); + +static struct snd_soc_dai_link tegra_max98088_dai = { + .name = "MAX98088", + .stream_name = "MAX98088 PCM", + .init = tegra_asoc_machine_init, + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + SND_SOC_DAILINK_REG(max98088_hifi), +}; + +static struct snd_soc_card snd_soc_tegra_max98088 = { + .components = "codec:max98088", + .dai_link = &tegra_max98088_dai, + .num_links = 1, + .fully_routed = true, +}; + +static const struct tegra_asoc_data tegra_max98088_data = { + .mclk_rate = tegra_machine_mclk_rate_12mhz, + .card = &snd_soc_tegra_max98088, + .add_common_dapm_widgets = true, + .add_common_controls = true, + .add_common_snd_ops = true, + .add_mic_jack = true, + .add_hp_jack = true, +}; + /* SGTL5000 machine */ SND_SOC_DAILINK_DEFS(sgtl5000_hifi, @@ -946,6 +982,8 @@ static const struct tegra_asoc_data tegra_rt5631_data = { static const struct of_device_id tegra_machine_of_match[] = { { .compatible = "nvidia,tegra-audio-trimslice", .data = &tegra_trimslice_data }, { .compatible = "nvidia,tegra-audio-max98090", .data = &tegra_max98090_data }, + { .compatible = "nvidia,tegra-audio-max98088", .data = &tegra_max98088_data }, + { .compatible = "nvidia,tegra-audio-max98089", .data = &tegra_max98088_data }, { .compatible = "nvidia,tegra-audio-sgtl5000", .data = &tegra_sgtl5000_data }, { .compatible = "nvidia,tegra-audio-wm9712", .data = &tegra_wm9712_data }, { .compatible = "nvidia,tegra-audio-wm8753", .data = &tegra_wm8753_data },