From mboxrd@z Thu Jan 1 00:00:00 1970 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 A0ADCC636D3 for ; Wed, 1 Feb 2023 13:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232460AbjBANwU (ORCPT ); Wed, 1 Feb 2023 08:52:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232527AbjBANwB (ORCPT ); Wed, 1 Feb 2023 08:52:01 -0500 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D379566024; Wed, 1 Feb 2023 05:51:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1675259517; x=1706795517; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V7EmJUdAxv6/nKFaKh+7o2Yn5gFfRK96nWW8cz9JF/8=; b=xTozla5E8E6ii/tp6NUbbmzQPGPO3kdS06GTbyjPGfKmFSaAfFtozIAL /MqhP8RdD+9MIECgP/ccqg0AfPpf+jPW9qbMmWW6TNarbg/oZxuBrDMkx MKN4WTjUQqC1Pky8awqJu5lY/t3ZRUC01tUss76ygkm2v2GF87tT2z9YO k=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-02.qualcomm.com with ESMTP; 01 Feb 2023 05:51:57 -0800 X-QCInternal: smtphost Received: from nalasex01b.na.qualcomm.com ([10.47.209.197]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2023 05:51:57 -0800 Received: from hu-mohs-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 1 Feb 2023 05:51:51 -0800 From: Mohammad Rafi Shaik To: , , , , , , , , , , , , , , , , CC: Mohammad Rafi Shaik Subject: [PATCH 05/14] ASoC: q6dsp: audioreach: Add support to set compress params Date: Wed, 1 Feb 2023 19:19:38 +0530 Message-ID: <20230201134947.1638197-6-quic_mohs@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230201134947.1638197-1-quic_mohs@quicinc.com> References: <20230201134947.1638197-1-quic_mohs@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add function for setting compress params to set the next track parameters during gapless playback. Signed-off-by: Mohammad Rafi Shaik Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 51 +++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/audioreach.h | 1 + sound/soc/qcom/qdsp6/q6apm-dai.c | 1 + 3 files changed, 53 insertions(+) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index a11bab69a676..a87df09d187f 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -1314,3 +1314,54 @@ int audioreach_enable_module(struct q6apm *apm, struct audioreach_module *module return audioreach_send_u32_param(apm, module, PARAM_ID_MODULE_ENABLE, en); } EXPORT_SYMBOL_GPL(audioreach_enable_module); + +int audioreach_compr_set_param(struct q6apm_graph *graph, struct audioreach_module_config *mcfg) +{ + struct media_format *header; + struct gpr_pkt *pkt; + struct payload_media_fmt_pcm *cfg; + uint32_t num_channels = mcfg->num_channels; + int iid, payload_size, rc; + void *p; + + payload_size = sizeof(struct apm_sh_module_media_fmt_cmd); + + iid = q6apm_graph_get_rx_shmem_module_iid(graph); + pkt = audioreach_alloc_cmd_pkt(payload_size, DATA_CMD_WR_SH_MEM_EP_MEDIA_FORMAT, + 0, graph->port->id, iid); + + if (IS_ERR(pkt)) + return -ENOMEM; + + p = (void *)pkt + GPR_HDR_SIZE; + header = p; + + if (mcfg->fmt == SND_AUDIOCODEC_PCM) { + header->data_format = DATA_FORMAT_FIXED_POINT; + header->fmt_id = MEDIA_FMT_ID_PCM; + header->payload_size = sizeof(*cfg); + + p = p + sizeof(*header); + cfg = p; + cfg->sample_rate = mcfg->sample_rate; + cfg->bit_width = mcfg->bit_width; + cfg->alignment = PCM_LSB_ALIGNED; + cfg->bits_per_sample = mcfg->bit_width; + cfg->q_factor = mcfg->bit_width - 1; + cfg->endianness = PCM_LITTLE_ENDIAN; + cfg->num_channels = mcfg->num_channels; + + if (mcfg->num_channels == 1) + cfg->channel_mapping[0] = PCM_CHANNEL_L; + else if (num_channels == 2) { + cfg->channel_mapping[0] = PCM_CHANNEL_L; + cfg->channel_mapping[1] = PCM_CHANNEL_R; + } + } + + rc = gpr_send_port_pkt(graph->port, pkt); + kfree(pkt); + + return rc; +} +EXPORT_SYMBOL_GPL(audioreach_compr_set_param); diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index 76dea97773cc..4c4bdff45cf1 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -786,4 +786,5 @@ int audioreach_remove_initial_silence(struct q6apm *apm, struct audioreach_modul uint32_t initial_samples); int audioreach_remove_trailing_silence(struct q6apm *apm, struct audioreach_module *module, uint32_t trailing_samples); +int audioreach_compr_set_param(struct q6apm_graph *graph, struct audioreach_module_config *mcfg); #endif /* __AUDIOREACH_H__ */ diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c index ee59ef36b85a..8f5d744b3365 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -146,6 +146,7 @@ static int q6apm_dai_prepare(struct snd_soc_component *component, cfg.sample_rate = runtime->rate; cfg.num_channels = runtime->channels; cfg.bit_width = prtd->bits_per_sample; + cfg.fmt = SND_AUDIOCODEC_PCM; if (prtd->state) { /* clear the previous setup if any */ -- 2.25.1