Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp975010ybt; Wed, 17 Jun 2020 19:37:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvhrHdXsQqs7EFSSpKpK1H5JggTzFKLcXCSJV4qS61FwXD2g4Wmz6SP1qnV4Mq3CsdSniL X-Received: by 2002:a05:6402:1592:: with SMTP id c18mr2141287edv.40.1592447849461; Wed, 17 Jun 2020 19:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592447849; cv=none; d=google.com; s=arc-20160816; b=Pc1gUusyCsXX5fLjZM8RFFN2Vtv0UiIv7GhpVolAdxiwS9gibgixpdYvAx5MEdCkR7 l0k9GufE9FwJ32jvGOl67PmvbDorJSX9yeKtHzD2vzAZ6BEcyUWVEjGoPJI9NPAob1PE HxpyruBK1YXXqjjeoDVou1PcfIful2KDgvcHv57ptqEeCw3rswCLYe57v4a3mLjXi5j2 nAgrENC/nwPZ19uR8u+ISNoN2zDcRp+U9rkFrSuYCojxi13upsNsJnu6df8s7t5y9xx/ QlbSzO1HVZbM1Mq76vyPXKutpN2nv+KaMXEb+r6IReRT2H18RtyTW28CfoJ6dxOwVUBA pNuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ej2E72S8IktaB5aW4ntVSTmZUSUUKMuCmIE88Sc3SoE=; b=Q/ORy8xh5bHB3d6fLazIRwYXfhxAKAurhiSDtKriVHPRl45OS0ppMi4fzRGQtLE7GM acxh/0BAecqW4mgDxPGwX5xrLyn5rZOGRPpsGtcf3GGwBwFrMKkIGsm4vt5lKBDjbM8r dV3JcDjow7aUBepAtZ3GteBMe525FyJumFMRMeW/4XbeVExMvzYsC2Iuua/VcJrbFotS 49f2ncsK3q69MivIj6XhTYFCgmxD+J8N+g7rUsXg95YArRQJ0AA95pnBuqz3LTXj+gEb maGdlMw9VUaazTOnGjqg40qdF9Iksjw0w2YMADXHy1QzBmcbhHBZjcnss03LRxoJi8d7 HFcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QNaUCmsx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si1105630edu.320.2020.06.17.19.37.07; Wed, 17 Jun 2020 19:37:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QNaUCmsx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387669AbgFRCdf (ORCPT + 99 others); Wed, 17 Jun 2020 22:33:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:44460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728347AbgFRBOo (ORCPT ); Wed, 17 Jun 2020 21:14:44 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 82601221F2; Thu, 18 Jun 2020 01:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592442883; bh=kPxEmnmOMxuJtqjZV6a2AVPBdrlNhs4Uq5+RKIVKpaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QNaUCmsxjy3lRmut9fU0KMqHYXcJydVlkMIgQ1yp1DKL0gOFkGAPWSUrPbXr/BkLm ynBVrQa2t3S5b1QdeWrstSiKABP3ni617sM/BICtkVG8ZZH0zHirL7G/5EkeClanSU jcD3SLfBSLjgdyLHcf7A2Ru3kwBoC6y+Fd26mWZ0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kai Vehmanen , Hui Wang , Guennadi Liakhovetski , Pierre-Louis Bossart , Mark Brown , Sasha Levin , sound-open-firmware@alsa-project.org, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 5.7 307/388] ASoC: SOF: Intel: hda: fix generic hda codec support Date: Wed, 17 Jun 2020 21:06:44 -0400 Message-Id: <20200618010805.600873-307-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618010805.600873-1-sashal@kernel.org> References: <20200618010805.600873-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kai Vehmanen [ Upstream commit 89d73ccab20a684d8446cea4d8ac6a2608c8d390 ] Add support for using generic codec driver with SOF. Generic driver is used if: - snd_sof_intel_hda_common.hda_model="generic" is set, or - fallback if no other codec driver is found The implementation is aligned with snd-hda-intel driver, and fixes audio support for systems like Acer Swift 3 SF314-57G, on which this issue was originally reported. Signed-off-by: Kai Vehmanen Reviewed-by: Hui Wang Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart BugLink: https://github.com/thesofproject/linux/issues/1807 BugLink: https://bugs.launchpad.net/bugs/1877757 Link: https://lore.kernel.org/r/20200529160358.12134-1-kai.vehmanen@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/intel/hda-codec.c | 51 +++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c index 3041fbbb010a..ea021db697b8 100644 --- a/sound/soc/sof/intel/hda-codec.c +++ b/sound/soc/sof/intel/hda-codec.c @@ -24,19 +24,44 @@ #define IDISP_VID_INTEL 0x80860000 /* load the legacy HDA codec driver */ -static int hda_codec_load_module(struct hda_codec *codec) +static int request_codec_module(struct hda_codec *codec) { #ifdef MODULE char alias[MODULE_NAME_LEN]; - const char *module = alias; + const char *mod = NULL; - snd_hdac_codec_modalias(&codec->core, alias, sizeof(alias)); - dev_dbg(&codec->core.dev, "loading codec module: %s\n", module); - request_module(module); + switch (codec->probe_id) { + case HDA_CODEC_ID_GENERIC: +#if IS_MODULE(CONFIG_SND_HDA_GENERIC) + mod = "snd-hda-codec-generic"; #endif + break; + default: + snd_hdac_codec_modalias(&codec->core, alias, sizeof(alias)); + mod = alias; + break; + } + + if (mod) { + dev_dbg(&codec->core.dev, "loading codec module: %s\n", mod); + request_module(mod); + } +#endif /* MODULE */ return device_attach(hda_codec_dev(codec)); } +static int hda_codec_load_module(struct hda_codec *codec) +{ + int ret = request_codec_module(codec); + + if (ret <= 0) { + codec->probe_id = HDA_CODEC_ID_GENERIC; + ret = request_codec_module(codec); + } + + return ret; +} + /* enable controller wake up event for all codecs with jack connectors */ void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev) { @@ -78,6 +103,13 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev) {} EXPORT_SYMBOL_NS(hda_codec_jack_wake_enable, SND_SOC_SOF_HDA_AUDIO_CODEC); EXPORT_SYMBOL_NS(hda_codec_jack_check, SND_SOC_SOF_HDA_AUDIO_CODEC); +#if IS_ENABLED(CONFIG_SND_HDA_GENERIC) +#define is_generic_config(bus) \ + ((bus)->modelname && !strcmp((bus)->modelname, "generic")) +#else +#define is_generic_config(x) 0 +#endif + /* probe individual codec */ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, bool hda_codec_use_common_hdmi) @@ -87,6 +119,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, #endif struct hda_bus *hbus = sof_to_hbus(sdev); struct hdac_device *hdev; + struct hda_codec *codec; u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) | (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID; u32 resp = -1; @@ -108,6 +141,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, hda_priv->codec.bus = hbus; hdev = &hda_priv->codec.core; + codec = &hda_priv->codec; ret = snd_hdac_ext_bus_device_init(&hbus->core, address, hdev); if (ret < 0) @@ -122,6 +156,11 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, hda_priv->need_display_power = true; } + if (is_generic_config(hbus)) + codec->probe_id = HDA_CODEC_ID_GENERIC; + else + codec->probe_id = 0; + /* * if common HDMI codec driver is not used, codec load * is skipped here and hdac_hdmi is used instead @@ -129,7 +168,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, if (hda_codec_use_common_hdmi || (resp & 0xFFFF0000) != IDISP_VID_INTEL) { hdev->type = HDA_DEV_LEGACY; - ret = hda_codec_load_module(&hda_priv->codec); + ret = hda_codec_load_module(codec); /* * handle ret==0 (no driver bound) as an error, but pass * other return codes without modification -- 2.25.1