From patchwork Wed Mar 27 11:32:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Rafi Shaik X-Patchwork-Id: 784892 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6041AC47DD9 for ; Wed, 27 Mar 2024 11:35:01 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3F1302C2B; Wed, 27 Mar 2024 12:34:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3F1302C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711539299; bh=chQOriCcdkcinLVrEULf9YxwIegyP3O7ewgsFxV0HEw=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WGh89+PWxQTl9MwiAMECS7FOUr5H9zOD2n2+uDmI6o1Ft6eravYT9WulObcQDBie7 bgr+MZipvvb7n/MuI7bafvC7/BXr57wHYifNeB0m1wiSb0GSC2rDZDQVqVHRuv5FAs yJmTWeFuqK2C/zxGYL40fH0wtzT4stfYTWty2IhE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8EC02F805F5; Wed, 27 Mar 2024 12:34:02 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 59FB8F805F8; Wed, 27 Mar 2024 12:34:02 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3D225F805B1; Wed, 27 Mar 2024 12:33:56 +0100 (CET) Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 694EFF801EB for ; Wed, 27 Mar 2024 12:33:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 694EFF801EB Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=eI2OcRav Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42RBSS3x009614; Wed, 27 Mar 2024 11:33:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=gjYgKZysAdJ/6lsaItzbhE3A6ZDUQSjKQ4yNHWtXIeo=; b=eI 2OcRavPsRdh5UHT+rJ2xtHd+It0Ze2g882S7EmGF6L2OxqHMcNGmdPLDs7R70M5u Hx3rsGfdUDjL4cMX4lvlcLmvx0e5/92fgQWxsydVuDWelrUeOynAIzZcWhVW9eYg nV8h6C9sTvyRR2pHzEcUKp+26sMxcgAwkf8mYzNew14nZo1P44YaxpsTvKPgd4ps H3hWKnczptbZ6VcNsbJ8e2K/JJwxfWqFUavV+W8ICLw6Sc4Ga7GeR2vKNzTYK00F 4tgVEVZV1/EyeTC68V0FAl8fXTN3ih3DvtkN7n9ufqeXWjDa9nspJc9V/OPmZCK9 5VJ/oL1bh+d4MIjlsh4g== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4780hh8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Mar 2024 11:33:29 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42RBXT8c026055 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Mar 2024 11:33:29 GMT Received: from hu-mohs-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 27 Mar 2024 04:33:25 -0700 From: Mohammad Rafi Shaik To: , , , , , , , , , , , , CC: Mohammad Rafi Shaik Subject: [PATCH v1 1/2] ASoC: dt-bindings: qcom,qcm6490: Add qcm6490 snd qcs6490 sound card Date: Wed, 27 Mar 2024 17:02:27 +0530 Message-ID: <20240327113228.1706975-2-quic_mohs@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240327113228.1706975-1-quic_mohs@quicinc.com> References: <20240327113228.1706975-1-quic_mohs@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: uboyo8qX74Us4xD8GGAWD__tKzdZSHq8 X-Proofpoint-GUID: uboyo8qX74Us4xD8GGAWD__tKzdZSHq8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-27_08,2024-03-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 clxscore=1015 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403270078 Message-ID-Hash: TBICEYI4B2NX76K2NFDPCWME7WPKY3O4 X-Message-ID-Hash: TBICEYI4B2NX76K2NFDPCWME7WPKY3O4 X-MailFrom: quic_mohs@quicinc.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Document bindings for the Qualcomm qcm6490 and qcs6490 SoC sound card. The bindings are the same as for other newer Qualcomm ADSP sound cards, thus keep them in existing qcom,sm8250.yaml file, even though Linux driver is separate. Signed-off-by: Mohammad Rafi Shaik --- Documentation/devicetree/bindings/sound/qcom,sm8250.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml b/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml index 2ab6871e89e5..247ad3d10933 100644 --- a/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml @@ -29,6 +29,8 @@ properties: - enum: - qcom,apq8016-sbc-sndcard - qcom,msm8916-qdsp6-sndcard + - qcom,qcm6490-sndcard + - qcom,qcs6490-sndcard - qcom,qrb5165-rb5-sndcard - qcom,sc7180-qdsp6-sndcard - qcom,sc8280xp-sndcard From patchwork Wed Mar 27 11:32:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Rafi Shaik X-Patchwork-Id: 783179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 72318C54E67 for ; Wed, 27 Mar 2024 11:34:40 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B58A52C22; Wed, 27 Mar 2024 12:34:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B58A52C22 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711539278; bh=ZmZY4klLx60T3u+pxYJnT+s1JREgAnxFC27meQibGHo=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=qouNHarEAxdLiM1vucmaRI5ouhswX9NXhYBClbHu2D97ZtLq6qEwLSL02p5Y5uUzA jBv/LVTT93TRLTQrGx8Bct2LrbLUd2Q6EZow2M3HPSKTKjTYNtAd5DkPmtYq+89Trw FsTKOzsc05Pe/+0LJnHT1wLL2D2cAAZ8AGMztqEQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 057C3F801EB; Wed, 27 Mar 2024 12:33:58 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 62B4BF805CA; Wed, 27 Mar 2024 12:33:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C5028F802DB; Wed, 27 Mar 2024 12:33:52 +0100 (CET) Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BF29AF80093 for ; Wed, 27 Mar 2024 12:33:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BF29AF80093 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=YA8pe27b Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42RAZM3E023786; Wed, 27 Mar 2024 11:33:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=snMIH5GFrI8kPEs9bEqq+/1eqkN3sd/QEbs6jLOH8UM=; b=YA 8pe27bBy/A0E3nofalczo9lW+2+2S6ZxOeNx6C+3PxJ4zQK8sglAZJwxsfIauj/6 Nvny/QjrImQN2BcemXkpSZUZv5bI9lnNheKIrgj2Ln2IEBbDJLv/FvIEM65+O+ev TzcDX8NzGwlp2yaPcdXDta9fHKG3Ch3GgjiMeHhLYLmPscelqoE1dAHv+FDAp6qB qpPPj6pF6fqAs3Y8hKSmmhcvA9tq6aOUvZVmWiE1JzQ4IsWH47J8wJLQl5EYwodr eCGfQvL9qlydHxNzlhEj0kN7hJeBjRe6F/QuXaDa6QCirrVcGmVj7TWcsmEitWuu YQNbq9yvr55yuvOEJ90g== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4hu2r4e4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Mar 2024 11:33:34 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42RBXXLw000457 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Mar 2024 11:33:33 GMT Received: from hu-mohs-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 27 Mar 2024 04:33:29 -0700 From: Mohammad Rafi Shaik To: , , , , , , , , , , , , CC: Mohammad Rafi Shaik Subject: [PATCH v1 2/2] ASoC: qcom: qcm6490: Add machine driver for qcm6490 Date: Wed, 27 Mar 2024 17:02:28 +0530 Message-ID: <20240327113228.1706975-3-quic_mohs@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240327113228.1706975-1-quic_mohs@quicinc.com> References: <20240327113228.1706975-1-quic_mohs@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: iKC408_5rAsw8AZoUPNKKH92s9V9FzS3 X-Proofpoint-GUID: iKC408_5rAsw8AZoUPNKKH92s9V9FzS3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-27_08,2024-03-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 bulkscore=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403270078 Message-ID-Hash: 6SSCLVEZUG7R7WRZSWLM6VJ4BZZVJK5Z X-Message-ID-Hash: 6SSCLVEZUG7R7WRZSWLM6VJ4BZZVJK5Z X-MailFrom: quic_mohs@quicinc.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add machine driver for qcm6490 SoC. This initial supports which includes WSA883x Speakers with onboard DMIC connected to internal LPASS codec via VA macros respectively and also WCD937x based headset. Add compatible for sound card on Qualcomm qcs6490 boards. Signed-off-by: Mohammad Rafi Shaik --- sound/soc/qcom/Kconfig | 13 +++ sound/soc/qcom/Makefile | 2 + sound/soc/qcom/qcm6490.c | 173 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 sound/soc/qcom/qcm6490.c diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index 762491d6f2f2..0bc536766872 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -151,6 +151,19 @@ config SND_SOC_MSM8996 APQ8096 SoC-based systems. Say Y if you want to use audio device on this SoCs +config SND_SOC_QCM6490 + tristate "SoC Machine driver for QCM6490 boards" + depends on QCOM_APR && SOUNDWIRE + depends on COMMON_CLK + select SND_SOC_QDSP6 + select SND_SOC_QCOM_COMMON + select SND_SOC_QCOM_SDW + help + Add support for audio on Qualcomm Technologies Inc. + QCM6490 SoC-based systems. + To compile this driver say Y or M if you want to + use audio device on this SoCs. + config SND_SOC_SDM845 tristate "SoC Machine driver for SDM845 boards" depends on QCOM_APR && I2C && SOUNDWIRE diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile index 34f3fcb8ee9a..feb2c164be69 100644 --- a/sound/soc/qcom/Makefile +++ b/sound/soc/qcom/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_SND_SOC_LPASS_SC7280) += snd-soc-lpass-sc7280.o snd-soc-storm-objs := storm.o snd-soc-apq8016-sbc-objs := apq8016_sbc.o snd-soc-apq8096-objs := apq8096.o +snd-soc-qcm6490-objs := qcm6490.o snd-soc-sc7180-objs := sc7180.o snd-soc-sc7280-objs := sc7280.o snd-soc-sdm845-objs := sdm845.o @@ -34,6 +35,7 @@ snd-soc-x1e80100-objs := x1e80100.o obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-apq8096.o +obj-$(CONFIG_SND_SOC_QCM6490) += snd-soc-qcm6490.o obj-$(CONFIG_SND_SOC_SC7180) += snd-soc-sc7180.o obj-$(CONFIG_SND_SOC_SC7280) += snd-soc-sc7280.o obj-$(CONFIG_SND_SOC_SC8280XP) += snd-soc-sc8280xp.o diff --git a/sound/soc/qcom/qcm6490.c b/sound/soc/qcom/qcm6490.c new file mode 100644 index 000000000000..5b0dc95963f5 --- /dev/null +++ b/sound/soc/qcom/qcm6490.c @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lpass.h" +#include "qdsp6/q6afe.h" +#include "common.h" +#include "sdw.h" + +struct qcm6490_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 qcm6490_snd_init(struct snd_soc_pcm_runtime *rtd) +{ + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + + switch (cpu_dai->id) { + case TX_CODEC_DMA_TX_3: + case LPASS_CDC_DMA_TX3: + case RX_CODEC_DMA_RX_0: + return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); + case VA_CODEC_DMA_TX_0: + case WSA_CODEC_DMA_RX_0: + return 0; + default: + dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); + } + + return -EINVAL; +} + +static int qcm6490_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + rate->min = 48000; + rate->max = 48000; + channels->min = 2; + channels->max = 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 = 1; + break; + default: + break; + } + + return 0; +} + +static int qcm6490_snd_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + struct qcm6490_snd_data *pdata = snd_soc_card_get_drvdata(rtd->card); + + return qcom_snd_sdw_hw_params(substream, params, &pdata->sruntime[cpu_dai->id]); +} + +static int qcm6490_snd_prepare(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); + struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; + + return qcom_snd_sdw_prepare(substream, sruntime, + &data->stream_prepared[cpu_dai->id]); +} + +static int qcm6490_snd_hw_free(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + struct sdw_stream_runtime *sruntime = 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 qcm6490_be_ops = { + .hw_params = qcm6490_snd_hw_params, + .hw_free = qcm6490_snd_hw_free, + .prepare = qcm6490_snd_prepare, +}; + +static void qcm6490_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 == 1) { + link->init = qcm6490_snd_init; + link->be_hw_params_fixup = qcm6490_be_hw_params_fixup; + link->ops = &qcm6490_be_ops; + } + } +} + +static int qcm6490_platform_probe(struct platform_device *pdev) +{ + struct snd_soc_card *card; + struct qcm6490_snd_data *data; + struct device *dev = &pdev->dev; + int ret; + + card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + card->owner = THIS_MODULE; + /* Allocate the private data */ + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + card->dev = dev; + dev_set_drvdata(dev, card); + snd_soc_card_set_drvdata(card, data); + ret = qcom_snd_parse_of(card); + if (ret) + return ret; + + card->driver_name = of_device_get_match_data(dev); + qcm6490_add_be_ops(card); + return devm_snd_soc_register_card(dev, card); +} + +static const struct of_device_id snd_qcm6490_dt_match[] = { + {.compatible = "qcom,qcm6490-sndcard", "qcm6490"}, + {.compatible = "qcom,qcs6490-sndcard", "qcs6490"}, + {} +}; + +MODULE_DEVICE_TABLE(of, snd_qcm6490_dt_match); + +static struct platform_driver snd_qcm6490_driver = { + .probe = qcm6490_platform_probe, + .driver = { + .name = "snd-qcm6490", + .of_match_table = snd_qcm6490_dt_match, + }, +}; +module_platform_driver(snd_qcm6490_driver); +MODULE_DESCRIPTION("qcm6490 ASoC Machine Driver"); +MODULE_LICENSE("GPL");