From patchwork Wed Oct 25 14:35:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 737875 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 96F71C07545 for ; Wed, 25 Oct 2023 14:37:38 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5F57E828; Wed, 25 Oct 2023 16:36:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5F57E828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698244651; bh=xIkxvdeMV2GXyZ5FW59lXpxqG+Lu0mULcWyxGpix2U8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=qgcLY2HrhtdewZyxhQerUGpxe1d2fVJszKU1iJ6r2IVyOEs3kfJF7QmEhdOTOoLhN myIkxBJlmTXSv3SFWZ+YG5A/NA5B262thZt4XQXk0EzdzSKgp84hPCsfI7LPxN8t1E r31H6vFQydoAA9fJprtjq3ay4StmgJE1xaBXrBao= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3146AF8056F; Wed, 25 Oct 2023 16:35:53 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 66016F80558; Wed, 25 Oct 2023 16:35:53 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0E6D6F80558; Wed, 25 Oct 2023 16:35:49 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 929EBF8012B for ; Wed, 25 Oct 2023 16:35:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 929EBF8012B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=b5lAjIN+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698244531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yw/16KSbGLUNXTmYOD7LjLHHCKABmAFpa2M57ewjo8E=; b=b5lAjIN+RbGhnU/hBRfoBU6wUIjjGSIrh6iyHODOtYkjWrLUnZG+/CaKcTDgzdwaqdtV9Z 2cjot4KIn4vckiI6caTOgFM4VECXshT81PVTVtyDFLSw8YOftkXp4l+7pvr0nE7n0PrbEC MBw2wLwChf7SQl+tnd7X2nkpZIU603g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-552-q8V-i2JFNk6fNeGtgiW_ig-1; Wed, 25 Oct 2023 10:35:27 -0400 X-MC-Unique: q8V-i2JFNk6fNeGtgiW_ig-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 510D880E993; Wed, 25 Oct 2023 14:35:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55D832026D4C; Wed, 25 Oct 2023 14:35:26 +0000 (UTC) From: Hans de Goede To: Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Peter Ujfalusi , Mark Brown Cc: Hans de Goede , alsa-devel@alsa-project.org Subject: [PATCH v2 4/4] ASoC: Intel: bytcr_wm5102: Add BYT_WM5102_IN_MAP quirk Date: Wed, 25 Oct 2023 16:35:13 +0200 Message-ID: <20231025143513.291753-5-hdegoede@redhat.com> In-Reply-To: <20231025143513.291753-1-hdegoede@redhat.com> References: <20231025143513.291753-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: SI3SG4D2CI3PZW5OZVVONATGYIPVA5BD X-Message-ID-Hash: SI3SG4D2CI3PZW5OZVVONATGYIPVA5BD X-MailFrom: hdegoede@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Unlike all designs supported sofar the Lenovo Yoga Tab 3 YT3-X90 does not have its internal microphone (intmic) on IN3L with the headset microphone on IN1L. Instead this tablet has the intmic on IN1L and the hsmic on IN2L. Add a BYT_WM5102_IN_MAP quirk mechanism to allow selecting between different input maps and add support for both setups with the current settings being the default map. The new INTMIC_IN1L_HSMIC_IN2L map is enabled by default on CHT because the Lenovo Yoga Tab 3 YT3-X90 model is the only Cherry Trail design currently supported. If different CHT designs turn up which need different input maps we can add DMI quirks to select a different map later. The userspace UCM profile also needs to know about this so extend the components string with this info too. Acked-by: Pierre-Louis Bossart Signed-off-by: Hans de Goede --- sound/soc/intel/boards/bytcr_wm5102.c | 60 +++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_wm5102.c b/sound/soc/intel/boards/bytcr_wm5102.c index 5425f757c2bb..6978ebde6693 100644 --- a/sound/soc/intel/boards/bytcr_wm5102.c +++ b/sound/soc/intel/boards/bytcr_wm5102.c @@ -38,11 +38,16 @@ struct byt_wm5102_private { int mclk_freq; }; -/* Bits 0-3 are reserved for the input-map */ +#define BYT_WM5102_IN_MAP GENMASK(3, 0) #define BYT_WM5102_OUT_MAP GENMASK(7, 4) #define BYT_WM5102_SSP2 BIT(16) #define BYT_WM5102_MCLK_19_2MHZ BIT(17) +enum { + BYT_WM5102_INTMIC_IN3L_HSMIC_IN1L, + BYT_WM5102_INTMIC_IN1L_HSMIC_IN2L, +}; + /* Note these values are pre-shifted for easy use of setting quirks */ enum { BYT_WM5102_SPK_SPK_MAP = FIELD_PREP_CONST(BYT_WM5102_OUT_MAP, 0), @@ -57,6 +62,20 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override"); static void log_quirks(struct device *dev) { + switch (quirk & BYT_WM5102_IN_MAP) { + case BYT_WM5102_INTMIC_IN3L_HSMIC_IN1L: + dev_info_once(dev, "quirk INTMIC_IN3L_HSMIC_IN1L enabled\n"); + break; + case BYT_WM5102_INTMIC_IN1L_HSMIC_IN2L: + dev_info_once(dev, "quirk INTMIC_IN1L_HSMIC_IN2L enabled\n"); + break; + default: + dev_warn_once(dev, "quirk sets invalid input map: 0x%lx, defaulting to INTMIC_IN3L_HSMIC_IN1L\n", + quirk & BYT_WM5102_IN_MAP); + quirk &= ~BYT_WM5102_IN_MAP; + quirk |= BYT_WM5102_INTMIC_IN3L_HSMIC_IN1L; + break; + } switch (quirk & BYT_WM5102_OUT_MAP) { case BYT_WM5102_SPK_SPK_MAP: dev_info_once(dev, "quirk SPK_SPK_MAP enabled\n"); @@ -191,16 +210,13 @@ static const struct snd_soc_dapm_route byt_wm5102_audio_map[] = { {"Headphone", NULL, "HPOUT1L"}, {"Headphone", NULL, "HPOUT1R"}, - {"Internal Mic", NULL, "MICBIAS3"}, - {"IN3L", NULL, "Internal Mic"}, - /* * The Headset Mix uses MICBIAS1 or 2 depending on if a CTIA/OMTP Headset * is connected, as the MICBIAS is applied after the CTIA/OMTP cross-switch. */ {"Headset Mic", NULL, "MICBIAS1"}, {"Headset Mic", NULL, "MICBIAS2"}, - {"IN1L", NULL, "Headset Mic"}, + {"Internal Mic", NULL, "MICBIAS3"}, }; static const struct snd_soc_dapm_route bytcr_wm5102_ssp0_map[] = { @@ -231,6 +247,16 @@ static const struct snd_soc_dapm_route byt_wm5102_spk_hpout2_map[] = { {"Speaker", NULL, "HPOUT2R"}, }; +static const struct snd_soc_dapm_route byt_wm5102_intmic_in3l_hsmic_in1l_map[] = { + {"IN3L", NULL, "Internal Mic"}, + {"IN1L", NULL, "Headset Mic"}, +}; + +static const struct snd_soc_dapm_route byt_wm5102_intmic_in1l_hsmic_in2l_map[] = { + {"IN1L", NULL, "Internal Mic"}, + {"IN2L", NULL, "Headset Mic"}, +}; + static const struct snd_kcontrol_new byt_wm5102_controls[] = { SOC_DAPM_PIN_SWITCH("Headphone"), SOC_DAPM_PIN_SWITCH("Headset Mic"), @@ -271,6 +297,20 @@ static int byt_wm5102_init(struct snd_soc_pcm_runtime *runtime) return ret; } + switch (quirk & BYT_WM5102_IN_MAP) { + case BYT_WM5102_INTMIC_IN3L_HSMIC_IN1L: + custom_map = byt_wm5102_intmic_in3l_hsmic_in1l_map; + num_routes = ARRAY_SIZE(byt_wm5102_intmic_in3l_hsmic_in1l_map); + break; + case BYT_WM5102_INTMIC_IN1L_HSMIC_IN2L: + custom_map = byt_wm5102_intmic_in1l_hsmic_in2l_map; + num_routes = ARRAY_SIZE(byt_wm5102_intmic_in1l_hsmic_in2l_map); + break; + } + ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); + if (ret) + return ret; + switch (quirk & BYT_WM5102_OUT_MAP) { case BYT_WM5102_SPK_SPK_MAP: custom_map = byt_wm5102_spk_spk_map; @@ -481,6 +521,8 @@ static char byt_wm5102_components[64]; /* = "cfg-spk:* cfg-int-mic:* cfg-hs-mic: static int snd_byt_wm5102_mc_probe(struct platform_device *pdev) { static const char * const out_map_name[] = { "spk", "hpout2" }; + static const char * const intmic_map_name[] = { "in3l", "in1l" }; + static const char * const hsmic_map_name[] = { "in1l", "in2l" }; char codec_name[SND_ACPI_I2C_ID_LEN]; struct device *dev = &pdev->dev; struct byt_wm5102_private *priv; @@ -541,9 +583,10 @@ static int snd_byt_wm5102_mc_probe(struct platform_device *pdev) /* * CHT always uses SSP2 and 19.2 MHz; and * the one currently supported CHT design uses HPOUT2 as - * speaker output. + * speaker output and has the intmic on IN1L + hsmic on IN2L. */ quirk = BYT_WM5102_SSP2 | BYT_WM5102_MCLK_19_2MHZ | + BYT_WM5102_INTMIC_IN1L_HSMIC_IN2L | BYT_WM5102_SPK_HPOUT2_MAP; } if (quirk_override != -1) { @@ -554,7 +597,10 @@ static int snd_byt_wm5102_mc_probe(struct platform_device *pdev) log_quirks(dev); snprintf(byt_wm5102_components, sizeof(byt_wm5102_components), - "cfg-spk:%s", out_map_name[FIELD_GET(BYT_WM5102_OUT_MAP, quirk)]); + "cfg-spk:%s cfg-intmic:%s cfg-hsmic:%s", + out_map_name[FIELD_GET(BYT_WM5102_OUT_MAP, quirk)], + intmic_map_name[FIELD_GET(BYT_WM5102_IN_MAP, quirk)], + hsmic_map_name[FIELD_GET(BYT_WM5102_IN_MAP, quirk)]); byt_wm5102_card.components = byt_wm5102_components; /* find index of codec dai */