From nobody Fri Apr 3 08:36:08 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8AE9ECAAD3 for ; Thu, 15 Sep 2022 12:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230163AbiIOM4s (ORCPT ); Thu, 15 Sep 2022 08:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230096AbiIOM4j (ORCPT ); Thu, 15 Sep 2022 08:56:39 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85ECC9C2C5 for ; Thu, 15 Sep 2022 05:56:29 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id n40-20020a05600c3ba800b003b49aefc35fso4479170wms.5 for ; Thu, 15 Sep 2022 05:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=QFHrDBmOgjQNltcQ0NOpoAX3KMBSQJ+P+IQdQCe6YjM=; b=i94W9vPeB3iQhYc0u0wLbmyX6MEeuNaog5wfMu/+9uiNqJij2rVE5ujaeb7vKGnT27 uIkiF6ac1jMX8W8HH9TUmsFtRxvmvuMna0QcIXpL5b2ZoTtgvFZm9vb3jTmR/qFRit30 56sV4vbdwPu5ZLH/+3hidYwfcUELJBqKox5mkenv8ecjBj4Wv91ccIDgWtocreT/s400 wXPbCGcUq47+M5jHbG0A5blADigUSFIMq/Ui6eWJa77/96Nf9w6KjEtNJvOO675XrAHk GavwW+zDncMOvNECfqi774Tk7tsCIag2C+HR/JGe07b5dHxl7IPQ8FvcpnKFNkr3zH4A XEEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=QFHrDBmOgjQNltcQ0NOpoAX3KMBSQJ+P+IQdQCe6YjM=; b=a3V42S7HpvM86KtpjLMIC2LbK2H5DbwvPFdjC3X/zUzCWE0q5ne0/jAcUNj3LH4j30 0JsBQ0Tf1kvmq5LhiHc7tKwz0K6ZJWlTvexLczL7uZvucwR2O+/pd/qkIrnMeqTjt9bi nHmNO0K5eX0SnsSvEpUrKs+VZrZ6xcBDDATwCA28AGO8ZF+fTlxVa5vTOl/IKwoBnOor +y++i5rUOlTUoiWx7ZASJ+DYKD2m+K65VLUl0WDJufvMWa6sD3C17GJTksHzbQYckIJH 3uviP4gMGb2leP1kAKFKNQ4vkGguTcEe+O24DunluvTIo0rlYWbjaRzu6DXec6RwWF0i rdvA== X-Gm-Message-State: ACgBeo2Q8k11sbHkPJ1xRfZAxBX/8YfO4+W7wqEzRQ0g7yBKherKVPF0 KUtZeyS6q1nWu/F8rqGTqRRkpw== X-Google-Smtp-Source: AA6agR5wQmDS9NVIm/Fef48EtgUk61VlJBe8+Luu17wFjPkahhU72GwomXl2CggvRhgQPqnUs9ax5Q== X-Received: by 2002:a7b:ca53:0:b0:3b4:90c4:e07 with SMTP id m19-20020a7bca53000000b003b490c40e07mr6827104wml.150.1663246587778; Thu, 15 Sep 2022 05:56:27 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id o11-20020a05600c510b00b003a845621c5bsm2764776wms.34.2022.09.15.05.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:56:27 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 4/4] ASoC: qcom: add machine driver for sc8280xp Date: Thu, 15 Sep 2022 13:56:11 +0100 Message-Id: <20220915125611.22473-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915125611.22473-1-srinivas.kandagatla@linaro.org> References: <20220915125611.22473-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add machine driver for sc8280xp SoC. This intial supports only includes WSA883x Speakers and WCD938x based heads= et. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/Kconfig | 12 +++ sound/soc/qcom/Makefile | 2 + sound/soc/qcom/sc8280xp.c | 157 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 sound/soc/qcom/sc8280xp.c diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index 750653404ba3..1b0252ec4665 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -173,6 +173,18 @@ config SND_SOC_SM8250 SM8250 SoC-based systems. Say Y if you want to use audio device on this SoCs. =20 +config SND_SOC_SC8280XP + tristate "SoC Machine driver for SC8280XP boards" + depends on QCOM_APR || COMPILE_TEST + depends on SOUNDWIRE + depends on COMMON_CLK + select SND_SOC_QDSP6 + select SND_SOC_QCOM_COMMON + help + To add support for audio on Qualcomm Technologies Inc. + SC8280XP SoC-based systems. + Say Y if you want to use audio device on this SoCs. + config SND_SOC_SC7180 tristate "SoC Machine driver for SC7180 boards" depends on I2C && GPIOLIB diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile index 8b7b876899a8..8b97172cf990 100644 --- a/sound/soc/qcom/Makefile +++ b/sound/soc/qcom/Makefile @@ -26,6 +26,7 @@ snd-soc-sc7180-objs :=3D sc7180.o snd-soc-sc7280-objs :=3D sc7280.o snd-soc-sdm845-objs :=3D sdm845.o snd-soc-sm8250-objs :=3D sm8250.o +snd-soc-sc8280xp-objs :=3D sc8280xp.o snd-soc-qcom-common-objs :=3D common.o =20 obj-$(CONFIG_SND_SOC_STORM) +=3D snd-soc-storm.o @@ -33,6 +34,7 @@ obj-$(CONFIG_SND_SOC_APQ8016_SBC) +=3D snd-soc-apq8016-sb= c.o obj-$(CONFIG_SND_SOC_MSM8996) +=3D snd-soc-apq8096.o obj-$(CONFIG_SND_SOC_SC7180) +=3D snd-soc-sc7180.o obj-$(CONFIG_SND_SOC_SC7280) +=3D snd-soc-sc7280.o +obj-$(CONFIG_SND_SOC_SC8280XP) +=3D snd-soc-sc8280xp.o obj-$(CONFIG_SND_SOC_SDM845) +=3D snd-soc-sdm845.o obj-$(CONFIG_SND_SOC_SM8250) +=3D snd-soc-sm8250.o obj-$(CONFIG_SND_SOC_QCOM_COMMON) +=3D snd-soc-qcom-common.o diff --git a/sound/soc/qcom/sc8280xp.c b/sound/soc/qcom/sc8280xp.c new file mode 100644 index 000000000000..ade44ad7c585 --- /dev/null +++ b/sound/soc/qcom/sc8280xp.c @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2022, Linaro Limited + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "qdsp6/q6afe.h" +#include "common.h" + +#define DRIVER_NAME "sc8280xp" + +struct sc8280xp_snd_data { + bool stream_prepared[AFE_PORT_MAX]; + struct snd_soc_card *card; + struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; + struct snd_soc_jack jack; + bool jack_setup; +}; + +static int sc8280xp_snd_init(struct snd_soc_pcm_runtime *rtd) +{ + struct sc8280xp_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); + + return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); +} + +static int sc8280xp_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_dai *cpu_dai =3D asoc_rtd_to_cpu(rtd, 0); + struct snd_interval *rate =3D hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels =3D hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + rate->min =3D rate->max =3D 48000; + channels->min =3D 2; + channels->max =3D 2; + switch (cpu_dai->id) { + case TX_CODEC_DMA_TX_0: + case TX_CODEC_DMA_TX_1: + case TX_CODEC_DMA_TX_2: + case TX_CODEC_DMA_TX_3: + channels->min =3D 1; + break; + default: + break; + } + + + return 0; +} + +static int sc8280xp_snd_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd =3D substream->private_data; + struct snd_soc_dai *cpu_dai =3D asoc_rtd_to_cpu(rtd, 0); + struct sc8280xp_snd_data *pdata =3D snd_soc_card_get_drvdata(rtd->card); + + return qcom_snd_sdw_hw_params(substream, params, &pdata->sruntime[cpu_dai= ->id]); +} + +static int sc8280xp_snd_prepare(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd =3D substream->private_data; + struct snd_soc_dai *cpu_dai =3D asoc_rtd_to_cpu(rtd, 0); + struct sc8280xp_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); + struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; + + return qcom_snd_sdw_prepare(substream, sruntime, + &data->stream_prepared[cpu_dai->id]); +} + +static int sc8280xp_snd_hw_free(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd =3D substream->private_data; + struct sc8280xp_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *cpu_dai =3D asoc_rtd_to_cpu(rtd, 0); + struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; + + return qcom_snd_sdw_hw_free(substream, sruntime, + &data->stream_prepared[cpu_dai->id]); +} + +static const struct snd_soc_ops sc8280xp_be_ops =3D { + .hw_params =3D sc8280xp_snd_hw_params, + .hw_free =3D sc8280xp_snd_hw_free, + .prepare =3D sc8280xp_snd_prepare, +}; + +static void sc8280xp_add_be_ops(struct snd_soc_card *card) +{ + struct snd_soc_dai_link *link; + int i; + + for_each_card_prelinks(card, i, link) { + if (link->no_pcm =3D=3D 1) { + link->init =3D sc8280xp_snd_init; + link->be_hw_params_fixup =3D sc8280xp_be_hw_params_fixup; + link->ops =3D &sc8280xp_be_ops; + } + } +} + +static int sc8280xp_platform_probe(struct platform_device *pdev) +{ + struct snd_soc_card *card; + struct sc8280xp_snd_data *data; + struct device *dev =3D &pdev->dev; + int ret; + + card =3D devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + card->owner =3D THIS_MODULE; + /* Allocate the private data */ + data =3D devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + card->dev =3D dev; + dev_set_drvdata(dev, card); + snd_soc_card_set_drvdata(card, data); + ret =3D qcom_snd_parse_of(card); + if (ret) + return ret; + + card->driver_name =3D DRIVER_NAME; + sc8280xp_add_be_ops(card); + return devm_snd_soc_register_card(dev, card); +} + +static const struct of_device_id snd_sc8280xp_dt_match[] =3D { + {.compatible =3D "qcom,sc8280xp-sndcard",}, + {} +}; + +MODULE_DEVICE_TABLE(of, snd_sc8280xp_dt_match); + +static struct platform_driver snd_sc8280xp_driver =3D { + .probe =3D sc8280xp_platform_probe, + .driver =3D { + .name =3D "snd-sc8280xp", + .of_match_table =3D snd_sc8280xp_dt_match, + }, +}; +module_platform_driver(snd_sc8280xp_driver); +MODULE_AUTHOR("Srinivas Kandagatla