From patchwork Thu Jan 23 16:36:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948427 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C14A212FA4 for ; Thu, 23 Jan 2025 16:22:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649379; cv=none; b=ch0chwS99Q/flYVW1aEuYHwaa4R1lYzNCRXno5cqk7L5TWeeuOvXn0AywhOO0OBm7EYFVJSaKevdFi1eiSIn9RFRxNhPXjQedeGH74Agh3wyHgbjQtJ7XILukVItOTV4Rq4ywVbjf3NktNgU4RqwDWHYCIviKvjRAjCEdapZUMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649379; c=relaxed/simple; bh=PqG3ZBpKC7whP9e1RnMw4SJw/XVO/fWuN3obFwVNTV4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RbBleoiFJUk+WFUGNiOXENFkDPjhT7dGoLnr2vOq/oBRMfPOQAkIhreciI0Efxv80Yw+mRhwVkkeKl2EjJFdDl+eyIf2F4W/5mMHkkp2iRhTfLg5Qa9t0SWmQOQkirHKWw8sLWjdpeOBlsw5Ced3bgj6k4lvCzJNhobW5G29Q4k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=MtDBw5+T; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MtDBw5+T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649379; x=1769185379; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PqG3ZBpKC7whP9e1RnMw4SJw/XVO/fWuN3obFwVNTV4=; b=MtDBw5+T5Sp3UqXYFuVYwnWohR4O5fBEBRkh1jXpO8wYrtjbvlSaiFPi /npaMBNATH7WcIw+k8anWARABCQWomxE03pwRVatvQssbOulTWfJKQU8q eL2wPZ/G6aK2dfVrs+1gWWwG0acuEbYnTzRTQgEzfgEKiv/3dBL1q0BgO YNY+zhut6i505P6EPXw1a0G3NwcHkIFY5b0poU4ZH0Y/IyswBgRtbwyNp fwC5KqrvIrSqN4n/KQ6OSmG/yHPLATiegtEIVh+YDDSImOrTV3fNq2yPQ WID3vHSqI9nDleqcrT9BIhAd1ofzBKGMk9IkklEVa/1vk4UqO0hWRhQ33 Q==; X-CSE-ConnectionGUID: 5s4VmH88RQC2dWkS4K+OFw== X-CSE-MsgGUID: 0V9r1Wf3Qd+E+SbLiifuEw== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572468" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572468" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:22:59 -0800 X-CSE-ConnectionGUID: kB8ksy9YQR6OirliSAiKfg== X-CSE-MsgGUID: S0gp4ZK9QMeFNEeoTHJIOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346693" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:22:56 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski Subject: [PATCH v2 01/11] ASoC: codecs: pcm3168a: Add ACPI match table Date: Thu, 23 Jan 2025 17:36:24 +0100 Message-Id: <20250123163634.1451237-2-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Support ACPI-based systems by adding relevant match table. Signed-off-by: Cezary Rojewski --- sound/soc/codecs/pcm3168a-i2c.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sound/soc/codecs/pcm3168a-i2c.c b/sound/soc/codecs/pcm3168a-i2c.c index 7052cc0c97d1..4da608ba514d 100644 --- a/sound/soc/codecs/pcm3168a-i2c.c +++ b/sound/soc/codecs/pcm3168a-i2c.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -37,6 +38,13 @@ static const struct i2c_device_id pcm3168a_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, pcm3168a_i2c_id); +static const struct acpi_device_id pcm3168a_acpi_match[] = { + { "PCM3168A" }, + { "104C3168" }, + {} +}; +MODULE_DEVICE_TABLE(acpi, pcm3168a_acpi_match); + static const struct of_device_id pcm3168a_of_match[] = { { .compatible = "ti,pcm3168a", }, { } @@ -49,6 +57,7 @@ static struct i2c_driver pcm3168a_i2c_driver = { .id_table = pcm3168a_i2c_id, .driver = { .name = "pcm3168a", + .acpi_match_table = pcm3168a_acpi_match, .of_match_table = pcm3168a_of_match, .pm = &pcm3168a_pm_ops, }, From patchwork Thu Jan 23 16:36:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948428 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92C481C5D4D for ; Thu, 23 Jan 2025 16:23:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649382; cv=none; b=dnDuOp4flpuJVklwmQ45oGB8lvjRsNM9MNDxGLdKeXXoiKIHG8VfMEc8wLEkMzztn0xBk8bVllH8QbrQrfJ69eclKlrtyVXM7Fe2z5grwI96S2gPugAgs1JgVJXDEj5VMYTl3w8vvnbxGSjCCWka6rX/ZjDU2KE76oS6BiyPgM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649382; c=relaxed/simple; bh=2HwFycZ0Oc3hA3qSQszAwsZKRAtBO7XsKQ2hvXcJvJ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gk9ke6qloDmBwv97QAhWX3ENuVCQjU7IUhHe6S3H4UIPlYmQCuw4qsJcaaEZHtks70JQy8gcXTL72AMQtgfQkux+f09VFLSzak4v54dPo6i9jLBZelC9PtQlVrs0SO+7s20OZw3Nr54/NdybSbtgua96cljc7EI7G0lTq0CuBjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=A/NdhW68; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="A/NdhW68" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649381; x=1769185381; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2HwFycZ0Oc3hA3qSQszAwsZKRAtBO7XsKQ2hvXcJvJ4=; b=A/NdhW68FFme5mIHA3YcHg6D288vVD+pt3aoqneDmCwFcEnAx3Sw+Cqk uI7ZFMFNp8fF9oCUcFg8KtZTkHlG70zSDKFqixqwozt65yzOOnZuFd3G2 I6Vp9zjTE8/fHmA2pdJ70pBShmw31gxpbpedvApTTK/XsSTyZlK/oxX9H r+US1LMarL/7Q3cFdFvhH3dCOe9MTlEz3Feu8ISXJWwt7NKHWumoVus6N ZXefgFk/HquBrovPdXUDSmGDvJuSZ8tkgcrIZerqHQyxCq0CAHQVrzLfE LQ/QlqyXswur3n0cgTbj9kC+NYPqX4dP6t6fgXnsDvgRWce3woR6olzQX g==; X-CSE-ConnectionGUID: fSpNeBFkSSu7jyKHm6Yzag== X-CSE-MsgGUID: LkugOk6pSo2G/dnWNyk9wg== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572481" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572481" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:23:01 -0800 X-CSE-ConnectionGUID: 5V/EJwKDRPqdq87LHM49ew== X-CSE-MsgGUID: /zKEreauRKeACT+2634GmA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346716" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:22:58 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski Subject: [PATCH v2 02/11] ASoC: codecs: pcm3168a: Relax probing conditions Date: Thu, 23 Jan 2025 17:36:25 +0100 Message-Id: <20250123163634.1451237-3-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On ACPI-based systems with Intel MalibouLake there is no "scki" clock entry defined. Make that initialization part optional and default to 24.576 MHz rate if not set. The rate is the default for both TI and Intel devices. Signed-off-by: Cezary Rojewski --- sound/soc/codecs/pcm3168a.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c index fac0617ab95b..43c0cb5e538e 100644 --- a/sound/soc/codecs/pcm3168a.c +++ b/sound/soc/codecs/pcm3168a.c @@ -743,7 +743,7 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) return dev_err_probe(dev, PTR_ERR(pcm3168a->gpio_rst), "failed to acquire RST gpio\n"); - pcm3168a->scki = devm_clk_get(dev, "scki"); + pcm3168a->scki = devm_clk_get_optional(dev, "scki"); if (IS_ERR(pcm3168a->scki)) return dev_err_probe(dev, PTR_ERR(pcm3168a->scki), "failed to acquire clock 'scki'\n"); @@ -755,6 +755,9 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) } pcm3168a->sysclk = clk_get_rate(pcm3168a->scki); + /* Fallback to the default if no clk entry available. */ + if (!pcm3168a->sysclk) + pcm3168a->sysclk = 24576000; for (i = 0; i < ARRAY_SIZE(pcm3168a->supplies); i++) pcm3168a->supplies[i].supply = pcm3168a_supply_names[i]; From patchwork Thu Jan 23 16:36:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948429 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3472B1C5D4D for ; Thu, 23 Jan 2025 16:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649384; cv=none; b=IM4VUSfmb53/UNCEIzTvMk7F8/JiRw/MDJgbSe3NF600LsxgfQo8Ri8S8HV2343H9MtGPbjFMumAZ3uL0KXWK9l3NhvDKK8FEVPS/wItNJqWMl9sXcgMcQl9EDu5U4x6ZxUWxF3yn/plKc8DfhLQf88xMXHZRXKdy36mlaaLXWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649384; c=relaxed/simple; bh=MJXmrdwNrmvQEeN+W+ekUyJcmdDLNGrGao1tIPCPey0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GdYL/jUdj0mbV13IRyo4TUYgUvXB40P/OLUEad74hqakZKcPcxofZfaId6O3gx1jCL416IGWcGZNAln78qlGMFk5cW8d3+zLzT/Op2rya+SW4GxgiR9JV4KjZlT0Gb8TB926GyT2L+4vWx5lU9JD393tvznNnubC9GMIT9+wvs0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Bl3eDkeJ; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Bl3eDkeJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649384; x=1769185384; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MJXmrdwNrmvQEeN+W+ekUyJcmdDLNGrGao1tIPCPey0=; b=Bl3eDkeJByLNvB0I+8XukbfDnY2zXLGQjKbJpBzQnGmruCxitOF16V0T Vt0fRmBK9Opx6JDIu0PoLzAFCaYqvJ37lpjowKH3wgCroZlmwlaYzY0jQ SboP2U5jZf2rDolVQKLUk8t0ART9c18ns4SnVTY7XkfSdxXI2IYmMyfxE 0Dd/wnTAA8CF/+NKkpLlII9FS5/qPGi8IokLjsOWrpRMVghebgk+SWofL frqehnCJOKH+XrFjFSVGgfgnHDYUOGsjoGEiZfcGMcYz20pW90SlWUXDA asGuu81rwfRoz0Bj0hnk7n2d3MAWLj+LEvgfrWf61gfIobmOAaOt3wtao Q==; X-CSE-ConnectionGUID: YJzHdkpkQK6IQR26G5+Uww== X-CSE-MsgGUID: 4kxDyu3rQ4CybB665Dr5pA== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572494" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572494" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:23:03 -0800 X-CSE-ConnectionGUID: wrkHLxnrQx2I8Xjl5KpTHw== X-CSE-MsgGUID: Zued4RBfTwWV/RY58XAxQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346736" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:23:01 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski Subject: [PATCH v2 03/11] ASoC: codecs: pcm3168a: Allow for 24-bit in provider mode Date: Thu, 23 Jan 2025 17:36:26 +0100 Message-Id: <20250123163634.1451237-4-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As per codec device specification, 24-bit is allowed in provider mode. Update the code to reflect that. Signed-off-by: Cezary Rojewski --- sound/soc/codecs/pcm3168a.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c index 43c0cb5e538e..df6836a652ef 100644 --- a/sound/soc/codecs/pcm3168a.c +++ b/sound/soc/codecs/pcm3168a.c @@ -493,9 +493,9 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream, } break; case 24: - if (provider_mode || (format == SND_SOC_DAIFMT_DSP_A) || - (format == SND_SOC_DAIFMT_DSP_B)) { - dev_err(component->dev, "24-bit slots not supported in provider mode, or consumer mode using DSP\n"); + if (!provider_mode && ((format == SND_SOC_DAIFMT_DSP_A) || + (format == SND_SOC_DAIFMT_DSP_B))) { + dev_err(component->dev, "24-bit slots not supported in consumer mode using DSP\n"); return -EINVAL; } break; From patchwork Thu Jan 23 16:36:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948430 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CD401C5D4D for ; Thu, 23 Jan 2025 16:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649387; cv=none; b=t5sdxz6q+kAMAXz69ixIffkrl3ZGeTtDu0YtqF3xxu/o54vnkeoBW0ujioZKlRdAaDWrta073GVIFJCVPWQTWMZUhcFisuTp7UOXvPtMXUio4E4rmwKkR7a68t5xV2x48rk47E6+a3V5LKS6GOjPOpmIkR8WYuHBngHMph1hpuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649387; c=relaxed/simple; bh=VG0XAZlE/WUXsVFESXR2camOCqaes5FU/Hr3y51b5KY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S2LSzBd4298+k7CQWsQkK/79/0a/wruSCi/t08Wpyao0rulwmDafIu2ClvwdZiuR4AupkCSWz4C+Z4TnTdGt9E+YA2yirxgJ1i8OjeYuQDkb0O0h0Qea1TrDzly4ZZjXXg5jSWdXp3UudB9Lx5xPu1OkVc31AXrQzCw8MY3rL6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ghMOs7Uw; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ghMOs7Uw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649386; x=1769185386; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VG0XAZlE/WUXsVFESXR2camOCqaes5FU/Hr3y51b5KY=; b=ghMOs7Uw1DD2UAIlFSc4TAuRWWeXuj2/5KL+a/Z4PULRjxiUoVRFiou3 D8R9AeT7QfXYKXlId3k1Ic0hrSVpAnZF4cWX9xcy8d9U5MmedytIYDPG9 98zDM0D3BfVxZ9XQwHkIvNLID+VhzPfms9OTQFvSgmZrcdiwB207eR8zA XDZ59RZIu7RXM7R2L77VenBGcDRFeBdKkKMt8/P64nWiBSQEpkqbTXujS bgsx6GCLFJTMiGsBCFJZNBpZ1YnJRD/AJ1GH6nJ/bvtxDSVcheH0KF9Te qMY048BR5WlGhmj1xGBzrg2O8qQh4WdA4CYWDWtVjkV8VSeIEjv+a1DQX w==; X-CSE-ConnectionGUID: +OOlBe2KSXm0NcRxEkQ1AA== X-CSE-MsgGUID: jFQHvg2CRX+4isUSRyVtYg== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572512" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572512" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:23:06 -0800 X-CSE-ConnectionGUID: KSBd7lh6Q6Cel6ubTQNBFQ== X-CSE-MsgGUID: 7tAeKGhbQOOhxpGfClH5Fg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346745" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:23:03 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski Subject: [PATCH v2 04/11] ASoC: Intel: avs: Add pcm3168a machine board Date: Thu, 23 Jan 2025 17:36:27 +0100 Message-Id: <20250123163634.1451237-5-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To support AVS-pcm3168a configuration add machine board connecting AVS platform component driver with pcm3168a codec one. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/boards/Kconfig | 10 ++ sound/soc/intel/avs/boards/Makefile | 2 + sound/soc/intel/avs/boards/pcm3168a.c | 161 ++++++++++++++++++++++++++ 3 files changed, 173 insertions(+) create mode 100644 sound/soc/intel/avs/boards/pcm3168a.c diff --git a/sound/soc/intel/avs/boards/Kconfig b/sound/soc/intel/avs/boards/Kconfig index 00b0f6c176d6..ba4bee42124c 100644 --- a/sound/soc/intel/avs/boards/Kconfig +++ b/sound/soc/intel/avs/boards/Kconfig @@ -87,6 +87,16 @@ config SND_SOC_INTEL_AVS_MACH_NAU8825 Say Y or m if you have such a device. This is a recommended option. If unsure select "N". +config SND_SOC_INTEL_AVS_MACH_PCM3168A + tristate "pcm3168a I2S board" + depends on I2C + depends on MFD_INTEL_LPSS || COMPILE_TEST + select SND_SOC_PCM3168A_I2C + help + This adds support for AVS with PCM3168A I2C codec configuration. + Say Y or m if you have such a device. This is a recommended option. + If unsure select "N". + config SND_SOC_INTEL_AVS_MACH_PROBE tristate "Probing (data) board" depends on DEBUG_FS diff --git a/sound/soc/intel/avs/boards/Makefile b/sound/soc/intel/avs/boards/Makefile index 4fbd936ffb3e..a95256b94dc8 100644 --- a/sound/soc/intel/avs/boards/Makefile +++ b/sound/soc/intel/avs/boards/Makefile @@ -9,6 +9,7 @@ snd-soc-avs-max98927-y := max98927.o snd-soc-avs-max98357a-y := max98357a.o snd-soc-avs-max98373-y := max98373.o snd-soc-avs-nau8825-y := nau8825.o +snd-soc-avs-pcm3168a-y := pcm3168a.o snd-soc-avs-probe-y := probe.o snd-soc-avs-rt274-y := rt274.o snd-soc-avs-rt286-y := rt286.o @@ -27,6 +28,7 @@ obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_MAX98927) += snd-soc-avs-max98927.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_MAX98357A) += snd-soc-avs-max98357a.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_MAX98373) += snd-soc-avs-max98373.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_NAU8825) += snd-soc-avs-nau8825.o +obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_PCM3168A) += snd-soc-avs-pcm3168a.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_PROBE) += snd-soc-avs-probe.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT274) += snd-soc-avs-rt274.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT286) += snd-soc-avs-rt286.o diff --git a/sound/soc/intel/avs/boards/pcm3168a.c b/sound/soc/intel/avs/boards/pcm3168a.c new file mode 100644 index 000000000000..e26e9ceb8baf --- /dev/null +++ b/sound/soc/intel/avs/boards/pcm3168a.c @@ -0,0 +1,161 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2024-2025 Intel Corporation +// +// Author: Cezary Rojewski +// + +#include +#include +#include +#include +#include +#include + +static const struct snd_soc_dapm_widget card_widgets[] = { + SND_SOC_DAPM_HP("CPB Stereo HP 1", NULL), + SND_SOC_DAPM_HP("CPB Stereo HP 2", NULL), + SND_SOC_DAPM_HP("CPB Stereo HP 3", NULL), + SND_SOC_DAPM_LINE("CPB Line Out", NULL), + SND_SOC_DAPM_MIC("CPB Stereo Mic 1", NULL), + SND_SOC_DAPM_MIC("CPB Stereo Mic 2", NULL), + SND_SOC_DAPM_LINE("CPB Line In", NULL), +}; + +static const struct snd_soc_dapm_route card_routes[] = { + { "CPB Stereo HP 1", NULL, "AOUT1L" }, + { "CPB Stereo HP 1", NULL, "AOUT1R" }, + { "CPB Stereo HP 2", NULL, "AOUT2L" }, + { "CPB Stereo HP 2", NULL, "AOUT2R" }, + { "CPB Stereo HP 3", NULL, "AOUT3L" }, + { "CPB Stereo HP 3", NULL, "AOUT3R" }, + { "CPB Line Out", NULL, "AOUT4L" }, + { "CPB Line Out", NULL, "AOUT4R" }, + + { "AIN1L", NULL, "CPB Stereo Mic 1" }, + { "AIN1R", NULL, "CPB Stereo Mic 1" }, + { "AIN2L", NULL, "CPB Stereo Mic 2" }, + { "AIN2R", NULL, "CPB Stereo Mic 2" }, + { "AIN3L", NULL, "CPB Line In" }, + { "AIN3R", NULL, "CPB Line In" }, +}; + +static int avs_pcm3168a_be_fixup(struct snd_soc_pcm_runtime *runtime, + struct snd_pcm_hw_params *params) +{ + struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + /* Set SSP to 24 bit. */ + snd_mask_none(fmt); + snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); + + return 0; +} + +static int avs_pcm3168a_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); + int ret; + + ret = snd_soc_dai_set_sysclk(codec_dai, 0, 24576000, SND_SOC_CLOCK_IN); + if (ret < 0) + dev_err(rtd->dev, "Set codec sysclk failed: %d\n", ret); + + return ret; +} + +static const struct snd_soc_ops avs_pcm3168a_ops = { + .hw_params = avs_pcm3168a_hw_params, +}; + +SND_SOC_DAILINK_DEF(pcm3168a_dac, + DAILINK_COMP_ARRAY(COMP_CODEC("i2c-PCM3168A:00", "pcm3168a-dac"))); +SND_SOC_DAILINK_DEF(pcm3168a_adc, + DAILINK_COMP_ARRAY(COMP_CODEC("i2c-PCM3168A:00", "pcm3168a-adc"))); +SND_SOC_DAILINK_DEF(cpu_ssp0, DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin"))); +SND_SOC_DAILINK_DEF(cpu_ssp2, DAILINK_COMP_ARRAY(COMP_CPU("SSP2 Pin"))); + +static int avs_create_dai_links(struct device *dev, struct snd_soc_dai_link **links, int *num_links) +{ + struct snd_soc_dai_link_component *platform; + struct snd_soc_dai_link *dl; + const int num_dl = 2; + + dl = devm_kcalloc(dev, num_dl, sizeof(*dl), GFP_KERNEL); + platform = devm_kzalloc(dev, sizeof(*platform), GFP_KERNEL); + if (!dl || !platform) + return -ENOMEM; + + platform->name = dev_name(dev); + dl[0].num_cpus = 1; + dl[0].num_codecs = 1; + dl[0].platforms = platform; + dl[0].num_platforms = 1; + dl[0].dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBP_CFP; + dl[0].be_hw_params_fixup = avs_pcm3168a_be_fixup; + dl[0].nonatomic = 1; + dl[0].no_pcm = 1; + memcpy(&dl[1], &dl[0], sizeof(*dl)); + + dl[0].name = "SSP0-Codec-dac"; + dl[0].cpus = cpu_ssp0; + dl[0].codecs = pcm3168a_dac; + dl[1].name = "SSP2-Codec-adc"; + dl[1].cpus = cpu_ssp2; + dl[1].codecs = pcm3168a_adc; + + *links = dl; + *num_links = num_dl; + return 0; +} + +static int avs_pcm3168a_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct snd_soc_card *card; + int ret; + + card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + ret = avs_create_dai_links(dev, &card->dai_link, &card->num_links); + if (ret) + return ret; + + card->name = "avs_pcm3168a"; + card->dev = dev; + card->owner = THIS_MODULE; + card->dapm_widgets = card_widgets; + card->num_dapm_widgets = ARRAY_SIZE(card_widgets); + card->dapm_routes = card_routes; + card->num_dapm_routes = ARRAY_SIZE(card_routes); + card->fully_routed = true; + + return devm_snd_soc_register_card(dev, card); +} + +static const struct platform_device_id avs_pcm3168a_driver_ids[] = { + { + .name = "avs_pcm3168a", + }, + {}, +}; +MODULE_DEVICE_TABLE(platform, avs_pcm3168a_driver_ids); + +static struct platform_driver avs_pcm3168a_driver = { + .probe = avs_pcm3168a_probe, + .driver = { + .name = "avs_pcm3168a", + .pm = &snd_soc_pm_ops, + }, + .id_table = avs_pcm3168a_driver_ids, +}; + +module_platform_driver(avs_pcm3168a_driver); + +MODULE_DESCRIPTION("Intel pcm3168a machine driver"); +MODULE_AUTHOR("Cezary Rojewski "); +MODULE_LICENSE("GPL"); From patchwork Thu Jan 23 16:36:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948431 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AAA12135D7 for ; Thu, 23 Jan 2025 16:23:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649389; cv=none; b=MC+wNxGCr45sE1RL2qTmZHhtwoPEe2CzvNf+qGcBCLBR/kkSsA+Dxxf4mA/bUxOeLE0Cu9AP0iVuoti4aawovQPq7ckTxiRGc3g+o3NQCtukZIfPrOGyr8ZmCHdZErz9dhiRN09Cx7aXGkRgQkm7U77s3NibskF0tyWdHUDTNkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649389; c=relaxed/simple; bh=Q2tTV+81G4/MIjWZ/sbni7M/iC9q+LSXApJ+OP1JbQ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WMmy6eJOgWB44wASDSuQRLab1I2Sl06D6B/mMZoFWiqmRbenKemoUi/GGuAu1bRUzfXpGySeKFaCxnl9xQEsPgjlgTwht+j+X/czdvlXios4Sirt9+mBeBQt0NKW6goKGM/357a/ECLMvR9sSgR88miT1joTLAS/X10T1Ws39dM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=A6ZM2Ab1; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="A6ZM2Ab1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649388; x=1769185388; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q2tTV+81G4/MIjWZ/sbni7M/iC9q+LSXApJ+OP1JbQ0=; b=A6ZM2Ab16mjaRrU+db/37AyiG9nzH92M4RPmTrCQooL6ClzX8yomU02e 4R/aVXYQ3yETxIx1gadd6kl8QgSZR3RZP+Z1gp18ALIngxYNdhtja4VHS 7PMc4g9d47HvsoEh9Va1yUlOJz9IfPpdT8KSEAWzH1f0ocUGM9Ml4Ljv6 aJ+Vd2nFMjbwN1c4dfOI7qi2ReRVzPbG5B1gvmAZfQm7OgqUdeAtKu4E7 h16Z/3lbMoPPINwMXjnKRozNcWeB7GouAM88M2GJUrsRajlrvk8kohpWV W4T3aYMyM9t/Kqj4+xbI00dyrXun9jA40GU9636IyW/Fic+i+c7ZsvJAH A==; X-CSE-ConnectionGUID: lsvOHL6kQ3efNuVaEMEthA== X-CSE-MsgGUID: crprbzv0TcGMIAJcg5vi5g== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572520" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572520" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:23:08 -0800 X-CSE-ConnectionGUID: KyWJ/JsWQDmP+xxivozH3Q== X-CSE-MsgGUID: TglyT64nSCKtDI24nmabcg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346749" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:23:05 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski Subject: [PATCH v2 05/11] ASoC: Intel: avs: pcm3168a board selection Date: Thu, 23 Jan 2025 17:36:28 +0100 Message-Id: <20250123163634.1451237-6-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Populate board table with avs_pcm3168a machine driver for RPL-M-based and ADL-N-based platforms with pcm3168a codec onboard to allow the sound card to enumerate. While at it, drop comma the terminator entries to align with the coding standard. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/board_selection.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/avs/board_selection.c b/sound/soc/intel/avs/board_selection.c index 0266edeafc19..2d706edcbf92 100644 --- a/sound/soc/intel/avs/board_selection.c +++ b/sound/soc/intel/avs/board_selection.c @@ -312,6 +312,18 @@ static struct snd_soc_acpi_mach avs_tgl_i2s_machines[] = { {}, }; +static struct snd_soc_acpi_mach avs_mbl_i2s_machines[] = { + { + .id = "PCM3168A", + .drv_name = "avs_pcm3168a", + .mach_params = { + .i2s_link_mask = AVS_SSP(0) | AVS_SSP(2), + }, + .tplg_filename = "pcm3168a-tplg.bin", + }, + {} +}; + static struct snd_soc_acpi_mach avs_test_i2s_machines[] = { { .drv_name = "avs_i2s_test", @@ -378,10 +390,11 @@ static const struct avs_acpi_boards i2s_boards[] = { AVS_MACH_ENTRY(HDA_ICL_LP, avs_icl_i2s_machines), AVS_MACH_ENTRY(HDA_TGL_LP, avs_tgl_i2s_machines), AVS_MACH_ENTRY(HDA_EHL_0, avs_tgl_i2s_machines), + AVS_MACH_ENTRY(HDA_ADL_N, avs_mbl_i2s_machines), AVS_MACH_ENTRY(HDA_ADL_P, avs_tgl_i2s_machines), AVS_MACH_ENTRY(HDA_RPL_P_0, avs_tgl_i2s_machines), - AVS_MACH_ENTRY(HDA_RPL_M, avs_tgl_i2s_machines), - {}, + AVS_MACH_ENTRY(HDA_RPL_M, avs_mbl_i2s_machines), + {} }; static const struct avs_acpi_boards *avs_get_i2s_boards(struct avs_dev *adev) From patchwork Thu Jan 23 16:36:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948432 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F07B2139BF for ; Thu, 23 Jan 2025 16:23:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649391; cv=none; b=cTVNtkNEuo+OllxLOvmPvSZ+B82UwyKbF545Re3ynI3zu1eIaCwScbjgm9AKOm8VtGNt/pe2sW5svWCpmrxsF2yX9ckn+cveO6BrYPbTYsYnKdrSS6eQQ4Npsu0IsjEzY8pJ40S3M3HP4aV3CXLAp6+ij8JLkjMvRpAY6QmK370= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649391; c=relaxed/simple; bh=WW8ypsnsHeYCqNbh1BRe3q9h4avF+3PZbincjq4qkBg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GKdv3krN3mhFSIFcAR4shtwPUbbJsg6sPuCfBGY6b8PovCLyeCXKAumkizynWtkFcy7DvZiA4w46A+tTh/id8e61NXvSgLGLZG/Tj+tZsNvo0FhT2FeDxXpIUOAdWtnp1TavrBTQF6wGSqhcceJs1UnM2YF/hvzb6FseTA5+KWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=coqhJ9x8; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="coqhJ9x8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649391; x=1769185391; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WW8ypsnsHeYCqNbh1BRe3q9h4avF+3PZbincjq4qkBg=; b=coqhJ9x8dALAQWOaNZ2cqMicXAYNCN7tJJCUOTvOOFs6UPPpRbyfedyO 8HbkiB2Z91JlBrMmhmdMkz0naba3jNS9NiGvOLCtymOslb34gT3RfSdju FJ7Q78NpQyrte5+PftpxzBgvm9JBCvDzuWbdwYan4vAr9lffCIP3fZLA8 lvfPcykU5Y2X45H/fJJAt7eRs5I9t6hhlXvBkp2g/G/VJM+i4jO2p/BfY 5/2TqN9S2Wxq6tpuLY3QIs4g/GRjiMQL74bUORGrelFIKcWbOK7FxfmmM W2U83cIzs75AHumfLO+LoL6MO8xd5idFM6nuPQ95+J2SJkFxJwHaXGwWd g==; X-CSE-ConnectionGUID: iEzdVvrRRWujyxnvxmIz3g== X-CSE-MsgGUID: NrDSBfZdSweJ87nWac4X5A== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572530" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572530" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:23:11 -0800 X-CSE-ConnectionGUID: vNwIFDf7R6mxJA7n3BPr4Q== X-CSE-MsgGUID: rBSgqtpBT3u2UaWtYY3InQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346781" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:23:08 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski Subject: [PATCH v2 06/11] ASoC: Intel: avs: Move DSP-boot steps into individual functions Date: Thu, 23 Jan 2025 17:36:29 +0100 Message-Id: <20250123163634.1451237-7-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To make DSP-boot code more readable, move each logical step into an individual function and add the configure step which will be utilized by follow up changes. To summarize, the steps are: loading the firmware code, configuring the base firmware and, allocating driver resources based on FW and HW capabilities. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/avs.h | 1 + sound/soc/intel/avs/loader.c | 64 ++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/sound/soc/intel/avs/avs.h b/sound/soc/intel/avs/avs.h index eca6ec0428bb..585543f872fc 100644 --- a/sound/soc/intel/avs/avs.h +++ b/sound/soc/intel/avs/avs.h @@ -51,6 +51,7 @@ struct avs_dsp_ops { int (* const load_basefw)(struct avs_dev *, struct firmware *); int (* const load_lib)(struct avs_dev *, struct firmware *, u32); int (* const transfer_mods)(struct avs_dev *, bool, struct avs_module_entry *, u32); + int (* const config_basefw)(struct avs_dev *); int (* const enable_logs)(struct avs_dev *, enum avs_log_enable, u32, u32, unsigned long, u32 *); int (* const log_buffer_offset)(struct avs_dev *, u32); diff --git a/sound/soc/intel/avs/loader.c b/sound/soc/intel/avs/loader.c index 9ff7818395cd..0b29941feb0e 100644 --- a/sound/soc/intel/avs/loader.c +++ b/sound/soc/intel/avs/loader.c @@ -603,7 +603,7 @@ static int avs_dsp_load_basefw(struct avs_dev *adev) return ret; } -int avs_dsp_boot_firmware(struct avs_dev *adev, bool purge) +static int avs_load_firmware(struct avs_dev *adev, bool purge) { struct avs_soc_component *acomp; int ret, i; @@ -657,28 +657,33 @@ int avs_dsp_boot_firmware(struct avs_dev *adev, bool purge) return 0; } -int avs_dsp_first_boot_firmware(struct avs_dev *adev) +static int avs_config_basefw(struct avs_dev *adev) { - int ret, i; + int ret; - if (avs_platattr_test(adev, CLDMA)) { - ret = hda_cldma_init(&code_loader, &adev->base.core, - adev->dsp_ba, AVS_CL_DEFAULT_BUFFER_SIZE); - if (ret < 0) { - dev_err(adev->dev, "cldma init failed: %d\n", ret); + if (adev->spec->dsp_ops->config_basefw) { + ret = avs_dsp_op(adev, config_basefw); + if (ret) return ret; - } } - ret = avs_dsp_core_disable(adev, AVS_MAIN_CORE_MASK); - if (ret < 0) - return ret; + return 0; +} + +int avs_dsp_boot_firmware(struct avs_dev *adev, bool purge) +{ + int ret; - ret = avs_dsp_boot_firmware(adev, true); - if (ret < 0) { - dev_err(adev->dev, "firmware boot failed: %d\n", ret); + ret = avs_load_firmware(adev, purge); + if (ret) return ret; - } + + return avs_config_basefw(adev); +} + +static int avs_dsp_alloc_resources(struct avs_dev *adev) +{ + int ret, i; ret = avs_ipc_get_hw_config(adev, &adev->hw_cfg); if (ret) @@ -705,6 +710,31 @@ int avs_dsp_first_boot_firmware(struct avs_dev *adev) strscpy(adev->lib_names[0], "BASEFW", AVS_LIB_NAME_SIZE); ida_init(&adev->ppl_ida); - return 0; } + +int avs_dsp_first_boot_firmware(struct avs_dev *adev) +{ + int ret; + + if (avs_platattr_test(adev, CLDMA)) { + ret = hda_cldma_init(&code_loader, &adev->base.core, + adev->dsp_ba, AVS_CL_DEFAULT_BUFFER_SIZE); + if (ret < 0) { + dev_err(adev->dev, "cldma init failed: %d\n", ret); + return ret; + } + } + + ret = avs_dsp_core_disable(adev, AVS_MAIN_CORE_MASK); + if (ret < 0) + return ret; + + ret = avs_dsp_boot_firmware(adev, true); + if (ret < 0) { + dev_err(adev->dev, "firmware boot failed: %d\n", ret); + return ret; + } + + return avs_dsp_alloc_resources(adev); +} From patchwork Thu Jan 23 16:36:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948434 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2CFB213252 for ; Thu, 23 Jan 2025 16:23:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649399; cv=none; b=s4rQTXuVE4eAvw/zLUDVCKdN0N+wagnt9brYM4jbTyH7ZnZlWagxjhCTKo9u3vSiKvHs02G1zFJ8ZGHs/NECordIn7VdZ4P0e1obv2Okh9qc/QDbBw2J03Px6DTpCLkS8MhMUPzntORRnxYChVY2B3hH7IwWRaOxJZLwtEaooUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649399; c=relaxed/simple; bh=s9wo7SLMtXruic1MhYBKouirxtYzQFaT+Dz+qbVSKXM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=IXAcy18xDX8bvxbAY4UHnlnJOr3/l7ftmG7TYk0RxtxCb9iM334lwqEOIexIFKsJHia0xE7OIPnABR2vlYVcsyIoorlzsXPgg97EUIy64tcfWilcapfdMnbsX2r4oztTJ7r5qSRvq20csFy4qaTVoR9MlqYxOVpL5CLPm8G41cs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CAFw+Djb; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CAFw+Djb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649398; x=1769185398; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s9wo7SLMtXruic1MhYBKouirxtYzQFaT+Dz+qbVSKXM=; b=CAFw+Djb+juOZimux2SWPnFRNeQkCCbFHbogfBg56f4F8U96YkIH9oNa j8qXXq6zv47yvTZXiBBaGWYlsT3R29dwRVgp7GpdwRgY6wDY1q13Yu/qv rqZ2jGnLP/PcA6Fq4QO9y3kO2K27pUe8c/bMxSobwZj2mv3C+ugIkZoo7 VwLLvPM84fafBa46AHFSFTyoS2DJxuE/dsIWGXa4Yr82/9iakBOLeSP0e iyn+7S6QAlr8uyqv6jmHcPhwGJvwf1sxaaAeEhiXs0EBcePB8uEC8U1Ht TALTLDb+6J5B1NIVCbqWbXpqlqPN0uCe/O7pEt7xXVpMLwJThVRE92tzT g==; X-CSE-ConnectionGUID: UfqeSkfmQuWQVIOtYuY+ow== X-CSE-MsgGUID: 1mEQ0fKuR4qevWljrZh1Yg== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572563" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572563" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:23:17 -0800 X-CSE-ConnectionGUID: VNbnxS4qRmmfJ9Chu2Wovw== X-CSE-MsgGUID: YS++sTkFRR2Jl+6kWYEGvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346790" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:23:10 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski Subject: [PATCH v2 07/11] ASoC: Intel: avs: Configure basefw on TGL-based platforms Date: Thu, 23 Jan 2025 17:36:30 +0100 Message-Id: <20250123163634.1451237-8-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Amadeusz Sławiński The AudioDSP firmware requires additional information about the configuration on selected devices. That information is unaccessible from the DSP side and shall be sent before any streaming starts. To achieve the goal, introduce FW_CONFIG_SET request. FW_CONFIG_SET message allows driver to modify firmware's configuration. Multiple parameters can be modified at once, thanks to payload being an array of TLVs. Signed-off-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/messages.c | 38 ++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 9 ++++++++ sound/soc/intel/avs/tgl.c | 31 +++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/sound/soc/intel/avs/messages.c b/sound/soc/intel/avs/messages.c index 30b666f8909b..242a175381c2 100644 --- a/sound/soc/intel/avs/messages.c +++ b/sound/soc/intel/avs/messages.c @@ -510,6 +510,44 @@ int avs_ipc_get_fw_config(struct avs_dev *adev, struct avs_fw_cfg *cfg) return ret; } +int avs_ipc_set_fw_config(struct avs_dev *adev, size_t num_tlvs, ...) +{ + struct avs_tlv *tlv; + void *payload; + size_t offset; + va_list args; + int ret, i; + + payload = kzalloc(AVS_MAILBOX_SIZE, GFP_KERNEL); + if (!payload) + return -ENOMEM; + + va_start(args, num_tlvs); + for (offset = i = 0; i < num_tlvs && offset < AVS_MAILBOX_SIZE - sizeof(*tlv); i++) { + tlv = (struct avs_tlv *)(payload + offset); + tlv->type = va_arg(args, u32); + tlv->length = va_arg(args, u32); + + offset += sizeof(*tlv) + tlv->length; + if (offset > AVS_MAILBOX_SIZE) + break; + + memcpy(tlv->value, va_arg(args, u8*), tlv->length); + } + + if (i == num_tlvs) + ret = avs_ipc_set_large_config(adev, AVS_BASEFW_MOD_ID, AVS_BASEFW_INST_ID, + AVS_BASEFW_FIRMWARE_CONFIG, payload, offset); + else + ret = -ERANGE; + + va_end(args); + kfree(payload); + if (ret) + dev_err(adev->dev, "set fw cfg failed: %d\n", ret); + return ret; +} + int avs_ipc_get_hw_config(struct avs_dev *adev, struct avs_hw_cfg *cfg) { struct avs_tlv *tlv; diff --git a/sound/soc/intel/avs/messages.h b/sound/soc/intel/avs/messages.h index 0378633c7f96..84b0d4b69ecb 100644 --- a/sound/soc/intel/avs/messages.h +++ b/sound/soc/intel/avs/messages.h @@ -451,6 +451,8 @@ enum avs_fw_cfg_params { AVS_FW_CFG_RESERVED, AVS_FW_CFG_POWER_GATING_POLICY, AVS_FW_CFG_ASSERT_MODE, + AVS_FW_CFG_RESERVED2, + AVS_FW_CFG_BUS_HARDWARE_ID, }; struct avs_fw_cfg { @@ -475,7 +477,14 @@ struct avs_fw_cfg { u32 power_gating_policy; }; +struct avs_bus_hwid { + u32 device; + u32 subsystem; + u8 revision; +}; + int avs_ipc_get_fw_config(struct avs_dev *adev, struct avs_fw_cfg *cfg); +int avs_ipc_set_fw_config(struct avs_dev *adev, size_t num_tlvs, ...); enum avs_hw_cfg_params { AVS_HW_CFG_AVS_VER, diff --git a/sound/soc/intel/avs/tgl.c b/sound/soc/intel/avs/tgl.c index a9019ff5e3af..f18fa394aa53 100644 --- a/sound/soc/intel/avs/tgl.c +++ b/sound/soc/intel/avs/tgl.c @@ -6,7 +6,12 @@ // Amadeusz Slawinski // +#include +#include #include "avs.h" +#include "messages.h" + +#define CPUID_TSC_LEAF 0x15 static int avs_tgl_dsp_core_power(struct avs_dev *adev, u32 core_mask, bool power) { @@ -35,6 +40,31 @@ static int avs_tgl_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stal return avs_dsp_core_stall(adev, core_mask, stall); } +static int avs_tgl_config_basefw(struct avs_dev *adev) +{ + struct pci_dev *pci = adev->base.pci; + struct avs_bus_hwid hwid; + unsigned int ecx; + int ret; + + ecx = cpuid_ecx(CPUID_TSC_LEAF); + if (ecx) { + ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(ecx), &ecx); + if (ret) + return AVS_IPC_RET(ret); + } + + hwid.device = pci->device; + hwid.subsystem = pci->subsystem_vendor | (pci->subsystem_device << 16); + hwid.revision = pci->revision; + + ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_BUS_HARDWARE_ID, sizeof(hwid), &hwid); + if (ret) + return AVS_IPC_RET(ret); + + return 0; +} + const struct avs_dsp_ops avs_tgl_dsp_ops = { .power = avs_tgl_dsp_core_power, .reset = avs_tgl_dsp_core_reset, @@ -44,6 +74,7 @@ const struct avs_dsp_ops avs_tgl_dsp_ops = { .load_basefw = avs_icl_load_basefw, .load_lib = avs_hda_load_library, .transfer_mods = avs_hda_transfer_modules, + .config_basefw = avs_tgl_config_basefw, .log_buffer_offset = avs_icl_log_buffer_offset, .log_buffer_status = avs_apl_log_buffer_status, .coredump = avs_apl_coredump, From patchwork Thu Jan 23 16:36:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948433 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D88AB20F973 for ; Thu, 23 Jan 2025 16:23:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649397; cv=none; b=NthiSCN/rRdrcjv9Luk/rUAZGmPVKYas0QiLn4Yq7CwyVZeucydzMhU9+4kkphc4+eLvTPrjvIKOAgY6E6JKHqmNHSEuZ6LUUvuDXeNdKDMtaSz09w7h+vc7BftJPlb511f0JI5jEiSIh+KmK+d+hGzHqYW1LONXbJVtDsXvmGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649397; c=relaxed/simple; bh=XSG6QkLd4N8rhs02fOL8CmoS+QHescTPBiUs8lCnmfg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gIdEcIiMh4aV0gCV0YL9rzLKdvdourPRVwPmzwKc+11Fj3gMA+CVcg6O2s0cqTaMW5r+74zxv80ZcZUVKQqYaTlp/00UU4RFcOLqL0aXB+yrRy7vRKyHZQ99MAocLxizI3zbVyO6R0/cZl2MfOhNxeV0L+mA0yhsaAxfuLKdfWE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kHg1b0jH; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kHg1b0jH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649396; x=1769185396; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XSG6QkLd4N8rhs02fOL8CmoS+QHescTPBiUs8lCnmfg=; b=kHg1b0jHniYzNlCovy32uR4IQOEFKezJXHx6+R1QfepnfniWbX2tfVVz NbHO6ouCPpqi7z8rPfCIRsBqpZ+ajBainZeIRh8WoATeRxec0hP0SSa4c MEfRrTkNlYeEoAKPTcXtmYFYcC5TfmDGdbqo0ZL9Ui/GCPrSWkk9GIEF6 HMx9sgGtb7hrxZpBEOzlPAR1BS3O2TdejxeY9DhkjgDQ+mUR8PHhAHKuw 5BIczVNn+bqr4v7llYxZ9jM3eYxPfesjVrot5KijWrE6EJzvvDZoCXCN1 KtORlZAfFNluzGpSDOueMuMN7KsQOtagWAM8irNN3NCbjT9hiPXOzpoPj A==; X-CSE-ConnectionGUID: Kkd+lHpHQ0S5qxd7PEGogw== X-CSE-MsgGUID: iGnqR50iS3W3aAv19MH6nw== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572555" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572555" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:23:16 -0800 X-CSE-ConnectionGUID: GftGeVOaSPOiz8ZtwidBIQ== X-CSE-MsgGUID: hrsGXRk4QjiWZc930QY6bg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346797" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:23:13 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski Subject: [PATCH v2 08/11] ASoC: Intel: avs: New gateway configuration mechanism Date: Thu, 23 Jan 2025 17:36:31 +0100 Message-Id: <20250123163634.1451237-9-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Creation of a module which contains gateway configuration consists of few additional steps, namely: - assigning ID (node_id) for the gateway - attaching hardware configuration from the NHLT table (optional) By splitting the steps into separate functions code becomes easier to read and understand. Any redundancy created by this patch will be addressed by follow up changes. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/path.c | 150 +++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c index f31d5e2caa7b..698a3d542244 100644 --- a/sound/soc/intel/avs/path.c +++ b/sound/soc/intel/avs/path.c @@ -115,6 +115,156 @@ avs_path_find_variant(struct avs_dev *adev, return NULL; } +static void avs_init_node_id(union avs_connector_node_id *node_id, + struct avs_tplg_modcfg_ext *te, u32 dma_id) +{ + node_id->val = 0; + node_id->dma_type = te->copier.dma_type; + + switch (node_id->dma_type) { + case AVS_DMA_DMIC_LINK_INPUT: + case AVS_DMA_I2S_LINK_OUTPUT: + case AVS_DMA_I2S_LINK_INPUT: + /* Gateway's virtual index is statically assigned in the topology. */ + node_id->vindex = te->copier.vindex.val; + break; + + case AVS_DMA_HDA_HOST_OUTPUT: + case AVS_DMA_HDA_HOST_INPUT: + /* Gateway's virtual index is dynamically assigned with DMA ID */ + node_id->vindex = dma_id; + break; + + case AVS_DMA_HDA_LINK_OUTPUT: + case AVS_DMA_HDA_LINK_INPUT: + node_id->vindex = te->copier.vindex.val | dma_id; + break; + + default: + *node_id = INVALID_NODE_ID; + break; + } +} + +/* Every BLOB contains at least gateway attributes. */ +static struct acpi_nhlt_config *default_blob = (struct acpi_nhlt_config *)&(u32[2]) {4}; + +static struct acpi_nhlt_config * +avs_nhlt_config_or_default(struct avs_dev *adev, struct avs_tplg_module *t) +{ + struct acpi_nhlt_format_config *fmtcfg; + struct avs_tplg_modcfg_ext *te; + struct avs_audio_format *fmt; + int link_type, dev_type; + int bus_id, dir; + + te = t->cfg_ext; + + switch (te->copier.dma_type) { + case AVS_DMA_I2S_LINK_OUTPUT: + link_type = ACPI_NHLT_LINKTYPE_SSP; + dev_type = ACPI_NHLT_DEVICETYPE_CODEC; + bus_id = te->copier.vindex.i2s.instance; + dir = SNDRV_PCM_STREAM_PLAYBACK; + fmt = te->copier.out_fmt; + break; + + case AVS_DMA_I2S_LINK_INPUT: + link_type = ACPI_NHLT_LINKTYPE_SSP; + dev_type = ACPI_NHLT_DEVICETYPE_CODEC; + bus_id = te->copier.vindex.i2s.instance; + dir = SNDRV_PCM_STREAM_CAPTURE; + fmt = t->in_fmt; + break; + + case AVS_DMA_DMIC_LINK_INPUT: + link_type = ACPI_NHLT_LINKTYPE_PDM; + dev_type = -1; /* ignored */ + bus_id = 0; + dir = SNDRV_PCM_STREAM_CAPTURE; + fmt = t->in_fmt; + break; + + default: + return default_blob; + } + + /* Override format selection if necessary. */ + if (te->copier.blob_fmt) + fmt = te->copier.blob_fmt; + + fmtcfg = acpi_nhlt_find_fmtcfg(link_type, dev_type, dir, bus_id, + fmt->num_channels, fmt->sampling_freq, fmt->valid_bit_depth, + fmt->bit_depth); + if (!fmtcfg) { + dev_warn(adev->dev, "Endpoint format configuration not found.\n"); + return ERR_PTR(-ENOENT); + } + + if (fmtcfg->config.capabilities_size < default_blob->capabilities_size) + return ERR_PTR(-ETOOSMALL); + /* The firmware expects the payload to be DWORD-aligned. */ + if (fmtcfg->config.capabilities_size % sizeof(u32)) + return ERR_PTR(-EINVAL); + + return &fmtcfg->config; +} + +static int avs_fill_gtw_config(struct avs_dev *adev, struct avs_copier_gtw_cfg *gtw, + struct avs_tplg_module *t, size_t *cfg_size) +{ + struct acpi_nhlt_config *blob; + size_t gtw_size; + + blob = avs_nhlt_config_or_default(adev, t); + if (IS_ERR(blob)) + return PTR_ERR(blob); + + gtw_size = blob->capabilities_size; + if (*cfg_size + gtw_size > AVS_MAILBOX_SIZE) + return -E2BIG; + + gtw->config_length = gtw_size / sizeof(u32); + memcpy(gtw->config.blob, blob->capabilities, blob->capabilities_size); + *cfg_size += gtw_size; + + return 0; +} + +static __maybe_unused int avs_copier_create2(struct avs_dev *adev, struct avs_path_module *mod) +{ + struct avs_tplg_module *t = mod->template; + struct avs_tplg_modcfg_ext *te; + struct avs_copier_cfg *cfg; + size_t cfg_size; + u32 dma_id; + int ret; + + te = t->cfg_ext; + cfg = adev->modcfg_buf; + dma_id = mod->owner->owner->dma_id; + cfg_size = offsetof(struct avs_copier_cfg, gtw_cfg.config); + + ret = avs_fill_gtw_config(adev, &cfg->gtw_cfg, t, &cfg_size); + if (ret) + return ret; + + cfg->base.cpc = t->cfg_base->cpc; + cfg->base.ibs = t->cfg_base->ibs; + cfg->base.obs = t->cfg_base->obs; + cfg->base.is_pages = t->cfg_base->is_pages; + cfg->base.audio_fmt = *t->in_fmt; + cfg->out_fmt = *te->copier.out_fmt; + cfg->feature_mask = te->copier.feature_mask; + avs_init_node_id(&cfg->gtw_cfg.node_id, te, dma_id); + cfg->gtw_cfg.dma_buffer_size = te->copier.dma_buffer_size; + mod->gtw_attrs = cfg->gtw_cfg.config.attrs; + + ret = avs_dsp_init_module(adev, mod->module_id, mod->owner->instance_id, t->core_id, + t->domain, cfg, cfg_size, &mod->instance_id); + return ret; +} + __maybe_unused static bool avs_dma_type_is_host(u32 dma_type) { From patchwork Thu Jan 23 16:36:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948435 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A9CF2116ED for ; Thu, 23 Jan 2025 16:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649400; cv=none; b=d2xoccmOKLNGgGoGCeQoQZ8cZ2Zq70pdZFTNVvfvj2r1JyMVA9lMA6V73RuKlj2VkD79ymAbdeP85rkHwiQSC4jrE3S+zKVGs6jW6Wfr0JkGUwDdNIr+BXcQp1nv8KAg5d8a3guYycuirudOCGTxG6vboGu///T+PTgly6BR4Lg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649400; c=relaxed/simple; bh=FaUdIe8pMgEeyYSpc0pzx+UXJIxA2QinYRqwfuII/NM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FyF2/tBMm3lg+jDeJ8TCTf1dFxhMsWLxSrilIYxS9SJnUR+tQcvmpDeRXlIlIugUQA5P4UnZD2dFQAaysJsPVMUm3BP459xUk3rKDMGI1LONm66aa3SFM3gI6jowJTYfWZ5OlqsZ1NkX/ZniBB9gTwiEl9FwTm7bi+tbiEzpDtg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=D2HaU8v1; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="D2HaU8v1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649400; x=1769185400; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FaUdIe8pMgEeyYSpc0pzx+UXJIxA2QinYRqwfuII/NM=; b=D2HaU8v1e/n/mQW+rsLEoBschYWgham3kr5Eno8UvcIMgGr5nDPSWUdx bnckxHl9xrIqn+F4x30rncg10cd1J9fY1qe3hsS6xuVxL1rwsWaFB6WdJ 0giJxlTq51Ie+/2Geh+8H5xYQvl3NFY9dZ0cikWhdi+B3JFHRvmlYkQdl Cd7XTqYiZ3pGZip5Ad1IeDpnPD2ZE+pG4dj96dzaU5U1AIFsbEu/jjnnU r/t79Q5iWLKIHqQFz1qBeSKmHH1PKH6AvInqO4OHtWryjhY7Vtn/3ZHL+ VC94sccA/pBXU3RW7HTbv7lIUauSK81Xv8yzaegtMueKiBbSsn6Rt4W1A Q==; X-CSE-ConnectionGUID: S68evhLLSWCrQVREGCKnoQ== X-CSE-MsgGUID: 2PLveUqkRQuoN5HlOYNe2w== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572572" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572572" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:23:19 -0800 X-CSE-ConnectionGUID: LJe+tUNhS0yolaGFglHBBw== X-CSE-MsgGUID: LjS0zvAwRzCgnogfNx1BvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346816" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:23:16 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski Subject: [PATCH v2 09/11] ASoC: Intel: avs: Remove unused gateway configuration code Date: Thu, 23 Jan 2025 17:36:32 +0100 Message-Id: <20250123163634.1451237-10-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Switch to new copier module constructor and remove code that becomes unused because of that. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/path.c | 149 +-------------------------------- sound/soc/intel/avs/topology.h | 2 - 2 files changed, 1 insertion(+), 150 deletions(-) diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c index 698a3d542244..cfa19e4820d2 100644 --- a/sound/soc/intel/avs/path.c +++ b/sound/soc/intel/avs/path.c @@ -231,7 +231,7 @@ static int avs_fill_gtw_config(struct avs_dev *adev, struct avs_copier_gtw_cfg * return 0; } -static __maybe_unused int avs_copier_create2(struct avs_dev *adev, struct avs_path_module *mod) +static int avs_copier_create(struct avs_dev *adev, struct avs_path_module *mod) { struct avs_tplg_module *t = mod->template; struct avs_tplg_modcfg_ext *te; @@ -265,153 +265,6 @@ static __maybe_unused int avs_copier_create2(struct avs_dev *adev, struct avs_pa return ret; } -__maybe_unused -static bool avs_dma_type_is_host(u32 dma_type) -{ - return dma_type == AVS_DMA_HDA_HOST_OUTPUT || - dma_type == AVS_DMA_HDA_HOST_INPUT; -} - -__maybe_unused -static bool avs_dma_type_is_link(u32 dma_type) -{ - return !avs_dma_type_is_host(dma_type); -} - -__maybe_unused -static bool avs_dma_type_is_output(u32 dma_type) -{ - return dma_type == AVS_DMA_HDA_HOST_OUTPUT || - dma_type == AVS_DMA_HDA_LINK_OUTPUT || - dma_type == AVS_DMA_I2S_LINK_OUTPUT; -} - -__maybe_unused -static bool avs_dma_type_is_input(u32 dma_type) -{ - return !avs_dma_type_is_output(dma_type); -} - -static int avs_copier_create(struct avs_dev *adev, struct avs_path_module *mod) -{ - struct avs_tplg_module *t = mod->template; - struct avs_copier_cfg *cfg; - struct acpi_nhlt_format_config *ep_blob; - struct acpi_nhlt_endpoint *ep; - union avs_connector_node_id node_id = {0}; - size_t cfg_size, data_size; - void *data = NULL; - u32 dma_type; - int ret; - - data_size = sizeof(cfg->gtw_cfg.config); - dma_type = t->cfg_ext->copier.dma_type; - node_id.dma_type = dma_type; - - switch (dma_type) { - struct avs_audio_format *fmt; - int direction; - - case AVS_DMA_I2S_LINK_OUTPUT: - case AVS_DMA_I2S_LINK_INPUT: - if (avs_dma_type_is_input(dma_type)) - direction = SNDRV_PCM_STREAM_CAPTURE; - else - direction = SNDRV_PCM_STREAM_PLAYBACK; - - if (t->cfg_ext->copier.blob_fmt) - fmt = t->cfg_ext->copier.blob_fmt; - else if (direction == SNDRV_PCM_STREAM_CAPTURE) - fmt = t->in_fmt; - else - fmt = t->cfg_ext->copier.out_fmt; - - ep = acpi_nhlt_find_endpoint(ACPI_NHLT_LINKTYPE_SSP, - ACPI_NHLT_DEVICETYPE_CODEC, direction, - t->cfg_ext->copier.vindex.i2s.instance); - ep_blob = acpi_nhlt_endpoint_find_fmtcfg(ep, fmt->num_channels, fmt->sampling_freq, - fmt->valid_bit_depth, fmt->bit_depth); - if (!ep_blob) { - dev_err(adev->dev, "no I2S ep_blob found\n"); - return -ENOENT; - } - - data = ep_blob->config.capabilities; - data_size = ep_blob->config.capabilities_size; - /* I2S gateway's vindex is statically assigned in topology */ - node_id.vindex = t->cfg_ext->copier.vindex.val; - - break; - - case AVS_DMA_DMIC_LINK_INPUT: - direction = SNDRV_PCM_STREAM_CAPTURE; - - if (t->cfg_ext->copier.blob_fmt) - fmt = t->cfg_ext->copier.blob_fmt; - else - fmt = t->in_fmt; - - ep = acpi_nhlt_find_endpoint(ACPI_NHLT_LINKTYPE_PDM, -1, direction, 0); - ep_blob = acpi_nhlt_endpoint_find_fmtcfg(ep, fmt->num_channels, fmt->sampling_freq, - fmt->valid_bit_depth, fmt->bit_depth); - if (!ep_blob) { - dev_err(adev->dev, "no DMIC ep_blob found\n"); - return -ENOENT; - } - - data = ep_blob->config.capabilities; - data_size = ep_blob->config.capabilities_size; - /* DMIC gateway's vindex is statically assigned in topology */ - node_id.vindex = t->cfg_ext->copier.vindex.val; - - break; - - case AVS_DMA_HDA_HOST_OUTPUT: - case AVS_DMA_HDA_HOST_INPUT: - /* HOST gateway's vindex is dynamically assigned with DMA id */ - node_id.vindex = mod->owner->owner->dma_id; - break; - - case AVS_DMA_HDA_LINK_OUTPUT: - case AVS_DMA_HDA_LINK_INPUT: - node_id.vindex = t->cfg_ext->copier.vindex.val | - mod->owner->owner->dma_id; - break; - - case INVALID_OBJECT_ID: - default: - node_id = INVALID_NODE_ID; - break; - } - - cfg_size = offsetof(struct avs_copier_cfg, gtw_cfg.config) + data_size; - if (cfg_size > AVS_MAILBOX_SIZE) - return -EINVAL; - - cfg = adev->modcfg_buf; - memset(cfg, 0, cfg_size); - cfg->base.cpc = t->cfg_base->cpc; - cfg->base.ibs = t->cfg_base->ibs; - cfg->base.obs = t->cfg_base->obs; - cfg->base.is_pages = t->cfg_base->is_pages; - cfg->base.audio_fmt = *t->in_fmt; - cfg->out_fmt = *t->cfg_ext->copier.out_fmt; - cfg->feature_mask = t->cfg_ext->copier.feature_mask; - cfg->gtw_cfg.node_id = node_id; - cfg->gtw_cfg.dma_buffer_size = t->cfg_ext->copier.dma_buffer_size; - /* config_length in DWORDs */ - cfg->gtw_cfg.config_length = DIV_ROUND_UP(data_size, 4); - if (data) - memcpy(&cfg->gtw_cfg.config.blob, data, data_size); - - mod->gtw_attrs = cfg->gtw_cfg.config.attrs; - - ret = avs_dsp_init_module(adev, mod->module_id, mod->owner->instance_id, - t->core_id, t->domain, cfg, cfg_size, - &mod->instance_id); - return ret; -} - static struct avs_control_data *avs_get_module_control(struct avs_path_module *mod) { struct avs_tplg_module *t = mod->template; diff --git a/sound/soc/intel/avs/topology.h b/sound/soc/intel/avs/topology.h index 7892e3797f63..dcfc568081a3 100644 --- a/sound/soc/intel/avs/topology.h +++ b/sound/soc/intel/avs/topology.h @@ -74,8 +74,6 @@ struct avs_tplg_modcfg_ext { union avs_virtual_index vindex; u32 dma_type; u32 dma_buffer_size; - u32 config_length; - /* config_data part of priv data */ } copier; struct { u32 out_channel_config; From patchwork Thu Jan 23 16:36:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948436 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F075A2116ED for ; Thu, 23 Jan 2025 16:23:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649404; cv=none; b=FRRB7P/e3Z8q7qizQvTZ24EtOuDO3NBei4Ukm7bHUQYfvAa+gRpsoNpp2xzPxWeUpugApAkF/cmVH65QEdd39GJXOlzngyHskZ0l/ML11kdiFnnkr1Egi8obFAouLaCJaVcFqD/VpArFTbCqj2cnMEuvIVRRJMqZM31LUeyEei8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649404; c=relaxed/simple; bh=EwwB9HNJNYNP5dCk5zvTqDXbSbfqDwkE3llaOGnllDw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bmPbn8SukW33osdIazg0idZLu8W6oCgHEQ2S7tckLGcbJGkTwhALgis5ahfBbMC5v24hqkRxxdTJtwoSSVklDdKrEYLv/oSY1SuNC7jrLWU7iO3SwcBUmicgtJSKt/9eQlR6bmNxm9FQe0FaGm7I2VHVvAIJfq+34P1LNDI2LXY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=E0qRNjhY; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="E0qRNjhY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649403; x=1769185403; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EwwB9HNJNYNP5dCk5zvTqDXbSbfqDwkE3llaOGnllDw=; b=E0qRNjhYwSBLtJlBtDjJV8iQW2rUnP3BRdaJ3EfT37G4Xa+t9Nl+RQz4 chs2cBFaQSxtI3I5hPr2qvUYSisWBFOqioFm5n7lGQwrEd8KLFSF9w9CI gM/znPN03CCfty/ijtph5lGlbbxea4uJjq3HhYihNKfDyLHWnGljo2PB0 tubw3B0bHkcXrzgYjopBMb5flwRCa6DbDKmmAQ3BzFFzJHZPYnFKS7FRY X+JpfiMc6tWHeH3UCWrimnq0Yq4MJIRTUwfEbTurSRsqoq8dHrfDqwu58 v9P/DZKLLtBEpGsF4hWWYuXds2GWvKuEJjuELRg54SFbyfER/LRHek9au g==; X-CSE-ConnectionGUID: 6jfCDkwZRNa7CNGoxVzcGw== X-CSE-MsgGUID: NzN2qTasRaibej5gGocM5A== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572578" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572578" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:23:23 -0800 X-CSE-ConnectionGUID: HOSQ/OrPThuDbxFmbOG1/Q== X-CSE-MsgGUID: fsK7Eh4LR6miLBqsj4v3YQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346834" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:23:19 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski , Piotr Maziarz Subject: [PATCH v2 10/11] ASoC: Intel: avs: Add WHM module support Date: Thu, 23 Jan 2025 17:36:33 +0100 Message-Id: <20250123163634.1451237-11-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 WovHostModule (WHM) is used in wake-on-voice scenarios to optimize power consumption. It combines capabilities of Copier, KeyPhraseBuffer, WakeOnVoice and Muxer modules. Signed-off-by: Piotr Maziarz Signed-off-by: Cezary Rojewski --- include/uapi/sound/intel/avs/tokens.h | 7 +++++ sound/soc/intel/avs/messages.h | 13 +++++++++ sound/soc/intel/avs/path.c | 36 +++++++++++++++++++++++ sound/soc/intel/avs/topology.c | 42 +++++++++++++++++++++++++++ sound/soc/intel/avs/topology.h | 9 ++++++ 5 files changed, 107 insertions(+) diff --git a/include/uapi/sound/intel/avs/tokens.h b/include/uapi/sound/intel/avs/tokens.h index 3e3fb258dd54..06ff30537f47 100644 --- a/include/uapi/sound/intel/avs/tokens.h +++ b/include/uapi/sound/intel/avs/tokens.h @@ -77,6 +77,13 @@ enum avs_tplg_token { AVS_TKN_MODCFG_UPDOWN_MIX_CHAN_MAP_U32 = 430, AVS_TKN_MODCFG_EXT_NUM_INPUT_PINS_U16 = 431, AVS_TKN_MODCFG_EXT_NUM_OUTPUT_PINS_U16 = 432, + AVS_TKN_MODCFG_WHM_REF_AFMT_ID_U32 = 433, + AVS_TKN_MODCFG_WHM_OUT_AFMT_ID_U32 = 434, + AVS_TKN_MODCFG_WHM_WAKE_TICK_PERIOD_U32 = 435, + AVS_TKN_MODCFG_WHM_VINDEX_U8 = 436, + AVS_TKN_MODCFG_WHM_DMA_TYPE_U32 = 437, + AVS_TKN_MODCFG_WHM_DMABUFF_SIZE_U32 = 438, + AVS_TKN_MODCFG_WHM_BLOB_AFMT_ID_U32 = 439, /* struct avs_tplg_pplcfg */ AVS_TKN_PPLCFG_ID_U32 = 1401, diff --git a/sound/soc/intel/avs/messages.h b/sound/soc/intel/avs/messages.h index 84b0d4b69ecb..f44fcfc81de7 100644 --- a/sound/soc/intel/avs/messages.h +++ b/sound/soc/intel/avs/messages.h @@ -652,6 +652,9 @@ int avs_ipc_set_system_time(struct avs_dev *adev); #define AVS_INTELWOV_MOD_UUID \ GUID_INIT(0xEC774FA9, 0x28D3, 0x424A, 0x90, 0xE4, 0x69, 0xF9, 0x84, 0xF1, 0xEE, 0xB7) +#define AVS_WOVHOSTM_MOD_UUID \ + GUID_INIT(0xF9ED62B7, 0x092E, 0x4A90, 0x8F, 0x4D, 0x82, 0xDA, 0xA8, 0xB3, 0x8F, 0x3B) + /* channel map */ enum avs_channel_index { AVS_CHANNEL_LEFT = 0, @@ -881,6 +884,16 @@ struct avs_wov_cfg { } __packed; static_assert(sizeof(struct avs_wov_cfg) == 44); +struct avs_whm_cfg { + struct avs_modcfg_base base; + /* Audio format for output pin 0 */ + struct avs_audio_format ref_fmt; + struct avs_audio_format out_fmt; + u32 wake_tick_period; + struct avs_copier_gtw_cfg gtw_cfg; +} __packed; +static_assert(sizeof(struct avs_whm_cfg) == 108); + /* Module runtime parameters */ enum avs_copier_runtime_param { diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c index cfa19e4820d2..dfb85bd2b665 100644 --- a/sound/soc/intel/avs/path.c +++ b/sound/soc/intel/avs/path.c @@ -265,6 +265,41 @@ static int avs_copier_create(struct avs_dev *adev, struct avs_path_module *mod) return ret; } +static int avs_whm_create(struct avs_dev *adev, struct avs_path_module *mod) +{ + struct avs_tplg_module *t = mod->template; + struct avs_tplg_modcfg_ext *te; + struct avs_whm_cfg *cfg; + size_t cfg_size; + u32 dma_id; + int ret; + + te = t->cfg_ext; + cfg = adev->modcfg_buf; + dma_id = mod->owner->owner->dma_id; + cfg_size = offsetof(struct avs_whm_cfg, gtw_cfg.config); + + ret = avs_fill_gtw_config(adev, &cfg->gtw_cfg, t, &cfg_size); + if (ret) + return ret; + + cfg->base.cpc = t->cfg_base->cpc; + cfg->base.ibs = t->cfg_base->ibs; + cfg->base.obs = t->cfg_base->obs; + cfg->base.is_pages = t->cfg_base->is_pages; + cfg->base.audio_fmt = *t->in_fmt; + cfg->ref_fmt = *te->whm.ref_fmt; + cfg->out_fmt = *te->whm.out_fmt; + cfg->wake_tick_period = te->whm.wake_tick_period; + avs_init_node_id(&cfg->gtw_cfg.node_id, te, dma_id); + cfg->gtw_cfg.dma_buffer_size = te->whm.dma_buffer_size; + mod->gtw_attrs = cfg->gtw_cfg.config.attrs; + + ret = avs_dsp_init_module(adev, mod->module_id, mod->owner->instance_id, t->core_id, + t->domain, cfg, cfg_size, &mod->instance_id); + return ret; +} + static struct avs_control_data *avs_get_module_control(struct avs_path_module *mod) { struct avs_tplg_module *t = mod->template; @@ -536,6 +571,7 @@ static struct avs_module_create avs_module_create[] = { { &AVS_ASRC_MOD_UUID, avs_asrc_create }, { &AVS_INTELWOV_MOD_UUID, avs_wov_create }, { &AVS_PROBE_MOD_UUID, avs_probe_create }, + { &AVS_WOVHOSTM_MOD_UUID, avs_whm_create }, }; static int avs_path_module_type_create(struct avs_dev *adev, struct avs_path_module *mod) diff --git a/sound/soc/intel/avs/topology.c b/sound/soc/intel/avs/topology.c index d612f20ed989..471b00b9a149 100644 --- a/sound/soc/intel/avs/topology.c +++ b/sound/soc/intel/avs/topology.c @@ -815,6 +815,48 @@ static const struct avs_tplg_token_parser modcfg_ext_parsers[] = { .offset = offsetof(struct avs_tplg_modcfg_ext, generic.num_output_pins), .parse = avs_parse_short_token, }, + { + .token = AVS_TKN_MODCFG_WHM_REF_AFMT_ID_U32, + .type = SND_SOC_TPLG_TUPLE_TYPE_WORD, + .offset = offsetof(struct avs_tplg_modcfg_ext, whm.ref_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token = AVS_TKN_MODCFG_WHM_OUT_AFMT_ID_U32, + .type = SND_SOC_TPLG_TUPLE_TYPE_WORD, + .offset = offsetof(struct avs_tplg_modcfg_ext, whm.out_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token = AVS_TKN_MODCFG_WHM_WAKE_TICK_PERIOD_U32, + .type = SND_SOC_TPLG_TUPLE_TYPE_WORD, + .offset = offsetof(struct avs_tplg_modcfg_ext, whm.wake_tick_period), + .parse = avs_parse_word_token, + }, + { + .token = AVS_TKN_MODCFG_WHM_VINDEX_U8, + .type = SND_SOC_TPLG_TUPLE_TYPE_BYTE, + .offset = offsetof(struct avs_tplg_modcfg_ext, whm.vindex), + .parse = avs_parse_byte_token, + }, + { + .token = AVS_TKN_MODCFG_WHM_DMA_TYPE_U32, + .type = SND_SOC_TPLG_TUPLE_TYPE_WORD, + .offset = offsetof(struct avs_tplg_modcfg_ext, whm.dma_type), + .parse = avs_parse_word_token, + }, + { + .token = AVS_TKN_MODCFG_WHM_DMABUFF_SIZE_U32, + .type = SND_SOC_TPLG_TUPLE_TYPE_WORD, + .offset = offsetof(struct avs_tplg_modcfg_ext, whm.dma_buffer_size), + .parse = avs_parse_word_token, + }, + { + .token = AVS_TKN_MODCFG_WHM_BLOB_AFMT_ID_U32, + .type = SND_SOC_TPLG_TUPLE_TYPE_WORD, + .offset = offsetof(struct avs_tplg_modcfg_ext, whm.blob_fmt), + .parse = avs_parse_audio_format_ptr, + }, }; static const struct avs_tplg_token_parser pin_format_parsers[] = { diff --git a/sound/soc/intel/avs/topology.h b/sound/soc/intel/avs/topology.h index dcfc568081a3..23d5ccd19959 100644 --- a/sound/soc/intel/avs/topology.h +++ b/sound/soc/intel/avs/topology.h @@ -75,6 +75,15 @@ struct avs_tplg_modcfg_ext { u32 dma_type; u32 dma_buffer_size; } copier; + struct { + struct avs_audio_format *ref_fmt; + struct avs_audio_format *out_fmt; + u32 wake_tick_period; + union avs_virtual_index vindex; + u32 dma_type; + u32 dma_buffer_size; + struct avs_audio_format *blob_fmt; /* optional override */ + } whm; struct { u32 out_channel_config; u32 coefficients_select; From patchwork Thu Jan 23 16:36:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13948437 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D98D4212D86 for ; Thu, 23 Jan 2025 16:23:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649406; cv=none; b=o71FLnIV5UaWjDzZSQBgMSmzfEsQE3eaG65E6FTG8Vmc79sndxPGCK5pTLy+ZX1bK6vNlHPQdKMvMZtlgJyaO+1ZbNu6pDsXfOcNFBnrvnfc6WQRAT0kGV/4Y3YvEl4/zNv/M0vLW85bPBPG1saHcHgwMM4rIyGuaT+nnauBbVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737649406; c=relaxed/simple; bh=CtcjxbxSMe9+UWegxhwcaOmTq/vY0kvzO1AvhGKXPgk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P4FOfI2y/Ff4zRs7VnBkp2ZRH1Qzff06/KRW7tqo5L3ee2avpBZf3JPIl9muZjb60E+B8oeJskmyCcWCjzTRlu/ZOwMWB9cjoH+CnGB0BLbDK02B8TWt9kC61BTJk13j85IE78z7m8rUgeM5Bq+90U2fWbpBPrgotosTHBTW+vE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hCYCmOxa; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hCYCmOxa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737649405; x=1769185405; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CtcjxbxSMe9+UWegxhwcaOmTq/vY0kvzO1AvhGKXPgk=; b=hCYCmOxauxW+r5zPot06ZZ/cdyDxRDV6pnDTD2/T0wPvR0ztTL4vsXBV YwTxFoLt/T7SW2UmX4yL7K0NwzgMZDdGfyvEu7EGMO8ES5MrlxUFKsSZc jddfGZf6VJQj4XPimUaEz4TLpespMPeGEp6xj4sCk6z79RL4Wep2VNjuJ jLf9RED6EirQ4VFpk2ijF9ghwbESbM9khBpJM+lri8TyHxJV63SFpM0nN No23Faophraf8ChiLvpAef9II6ZEms2YOnK6cKRsb8LUiATwCzv3cp06k s5eJ4KSQQgLgmWHmXc/BbiXVc9A3WCVUkps5CNaDvoJ2I8n6ADpuyDkl2 w==; X-CSE-ConnectionGUID: 8dT6LCHuRryrYsaY7YcwiA== X-CSE-MsgGUID: IAT02yblSzmcsJiQY6BAEw== X-IronPort-AV: E=McAfee;i="6700,10204,11324"; a="55572586" X-IronPort-AV: E=Sophos;i="6.13,228,1732608000"; d="scan'208";a="55572586" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2025 08:23:25 -0800 X-CSE-ConnectionGUID: paFjBUZGS8SL/bAZvsX/SQ== X-CSE-MsgGUID: 9lydH2isSNibEGiNJJThzA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="107346846" Received: from crojewsk-ctrl.igk.intel.com ([10.237.149.254]) by orviesa010.jf.intel.com with ESMTP; 23 Jan 2025 08:23:22 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, linux-sound@vger.kernel.org, Cezary Rojewski Subject: [PATCH v2 11/11] ALSA: hda: Select avs-driver by default on MBL Date: Thu, 23 Jan 2025 17:36:34 +0100 Message-Id: <20250123163634.1451237-12-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250123163634.1451237-1-cezary.rojewski@intel.com> References: <20250123163634.1451237-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The avs-driver is the recommended solution for MalibouLake (MBL, also known as RPL-M) platform. Signed-off-by: Cezary Rojewski --- sound/hda/intel-dsp-config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c index f564ec7af194..9a8ead75be17 100644 --- a/sound/hda/intel-dsp-config.c +++ b/sound/hda/intel-dsp-config.c @@ -108,6 +108,10 @@ static const struct config_entry config_table[] = { {} } }, + { + .flags = FLAG_SST, + .device = PCI_DEVICE_ID_INTEL_HDA_RPL_M, + }, #endif #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE) {