From patchwork Fri Oct 21 16:52:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13015135 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 6C2FCFA373D for ; Fri, 21 Oct 2022 16:55:43 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 92DB68A4B; Fri, 21 Oct 2022 18:54:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 92DB68A4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1666371341; bh=GlMxWcoLptaQtZl/3mWaRiSQlBZxjYDym9NjqCRHiTk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QIgFZxrtQCugjQOm/UV9DPpQwIPL/lOwjz8Vy9T1qBSiy2Suokz5lFh+7PffOh0TY Br/x++8DdZUM6WiauzgrawaIuJPA3Auz+iIG2oKfcF/JJH0e4kiZAK40NF2Iw5Hsm4 0Bgjt7CxGzLsQqUo1wI/2u+FGl4wtLccSf9kME94= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1A4CBF8057A; Fri, 21 Oct 2022 18:53:23 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 040F4F80578; Fri, 21 Oct 2022 18:53:21 +0200 (CEST) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DA36EF80553 for ; Fri, 21 Oct 2022 18:53:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DA36EF80553 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rOBozg/n" Received: by mail-wr1-x431.google.com with SMTP id bu30so5873234wrb.8 for ; Fri, 21 Oct 2022 09:53:15 -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 :message-id:reply-to; bh=9OQ1Vt/2QFgasQ2MWgN87SiOCnuqeXhPBQT7NHiM0Fk=; b=rOBozg/nN2RN5je3p1RPl2XMpNpj4WdvTEXpCZC39tWajzVNcG57vXDDtC/MoQHnDq iFoHhelA5qAfzuHtriP5L0hDlSiJcWgfGp5Yigq7/6UaPfn2NAsNv6wZThLHWzJTp1ns AT3moeIhKX97fwlQHM7n7BQl2allYwL5qAoOogJNOPBqitKiJZ4XXoquFQ4Oc9yIRSvw lOLEjjfPBIaM5uuIHpX2T7x0Lyp2v+li7wNgcGJihxz0fNkjwcWbnIziYMzZhM9A8nBn u6dX1acsvWY51aed0ODYrMRxVHIirGvwyzEclbHoUmOF5PXo/z9Jrx6Gn5mauAohlNwo tLdw== 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:message-id:reply-to; bh=9OQ1Vt/2QFgasQ2MWgN87SiOCnuqeXhPBQT7NHiM0Fk=; b=X58bEPK0ePI3X5GpKFW6DIMGiN62S7UiQxrj9/6VpFMFOaShnUpyzbOLnmAPLrSe6Q VfQbm8Y6GjdlvOGqXkOEx8kbvxemMf8Z6d1Y33ccyMFzC17DV4S/eRP+WXGfqeyeAIZG k7M8u4wv3CubdN9yD5q7eEvuFNgkCSNezRyXusNbsY0h+VZWScM1Byaju7AhEeAmrpgY Uy0VlJOlIsOTAU1yHnBWBRYISXfFT/ugnV+uzE2hFcUTq5SCplDldtxfvO46aYmPVjpX apR8ql1Or0XK3E/owWTFuCM/LSyYINwcPNV6yFaVzz8o5MlvSViFRWXM86Rz1IqIMrJP Y6Vw== X-Gm-Message-State: ACrzQf0L2dQiHAZFOtlje2iJ0vy7OOqxyJot8T/s7N3CJ52XgDXFF+2X li+b3ljUekPAr8dbTKrHfpnOmQ== X-Google-Smtp-Source: AMsMyM4cGDyO0hJjHABKAuO/68s01dMDB9b10k8bO/7x7PTx760dRVJMpnmJhnBY8AIMQ53rlFpI1g== X-Received: by 2002:a05:6000:15c5:b0:22e:44c5:4973 with SMTP id y5-20020a05600015c500b0022e44c54973mr13466496wry.513.1666371194035; Fri, 21 Oct 2022 09:53:14 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id n14-20020a5d400e000000b0022ae401e9e0sm19541773wrp.78.2022.10.21.09.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 09:53:12 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 7/9] ASoC: qdsp6: audioreach: add support to enable SAL Module Date: Fri, 21 Oct 2022 17:52:05 +0100 Message-Id: <20221021165207.13220-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20221021165207.13220-1-srinivas.kandagatla@linaro.org> References: <20221021165207.13220-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, tiwai@suse.com, lgirdwood@gmail.com, Srinivas Kandagatla , bgoswami@quicinc.com, linux-kernel@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add support to Simple Accumulator-Limiter module. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 77 +++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/audioreach.h | 11 +++++ 2 files changed, 88 insertions(+) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 99cade6d8a48..be7068742fe4 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -658,6 +658,77 @@ static int audioreach_codec_dma_set_media_format(struct q6apm_graph *graph, return rc; } +static int audioreach_sal_limiter_enable(struct q6apm_graph *graph, + struct audioreach_module *module, bool enable) +{ + struct apm_module_param_data *param_data; + struct param_id_sal_limiter_enable *limiter_enable; + int payload_size; + struct gpr_pkt *pkt; + int rc; + void *p; + + payload_size = sizeof(*limiter_enable) + APM_MODULE_PARAM_DATA_SIZE; + + pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); + if (IS_ERR(pkt)) + return PTR_ERR(pkt); + + p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + + param_data = p; + param_data->module_instance_id = module->instance_id; + param_data->error_code = 0; + param_data->param_id = PARAM_ID_SAL_LIMITER_ENABLE; + param_data->param_size = sizeof(*limiter_enable); + p = p + APM_MODULE_PARAM_DATA_SIZE; + limiter_enable = p; + + limiter_enable->enable_lim = enable; + + rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); + + kfree(pkt); + + return rc; +} + +static int audioreach_sal_set_media_format(struct q6apm_graph *graph, + struct audioreach_module *module, + struct audioreach_module_config *cfg) +{ + struct apm_module_param_data *param_data; + struct param_id_sal_output_config *media_format; + int payload_size; + struct gpr_pkt *pkt; + int rc; + void *p; + + payload_size = sizeof(*media_format) + APM_MODULE_PARAM_DATA_SIZE; + + pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); + if (IS_ERR(pkt)) + return PTR_ERR(pkt); + + p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + + param_data = p; + param_data->module_instance_id = module->instance_id; + param_data->error_code = 0; + param_data->param_id = PARAM_ID_SAL_OUTPUT_CFG; + param_data->param_size = sizeof(*media_format); + p = p + APM_MODULE_PARAM_DATA_SIZE; + media_format = p; + + media_format->bits_per_sample = cfg->bit_width; + + rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); + + kfree(pkt); + + return rc; +} + static int audioreach_i2s_set_media_format(struct q6apm_graph *graph, struct audioreach_module *module, struct audioreach_module_config *cfg) @@ -978,6 +1049,12 @@ int audioreach_set_media_format(struct q6apm_graph *graph, struct audioreach_mod case MODULE_ID_CODEC_DMA_SOURCE: rc = audioreach_codec_dma_set_media_format(graph, module, cfg); break; + case MODULE_ID_SAL: + rc = audioreach_sal_set_media_format(graph, module, cfg); + if (!rc) + rc = audioreach_sal_limiter_enable(graph, module, true); + break; + default: rc = 0; } diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index df5026b646c1..f2b51d8fc718 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -15,6 +15,7 @@ struct q6apm_graph; #define MODULE_ID_PCM_CNV 0x07001003 #define MODULE_ID_PCM_ENC 0x07001004 #define MODULE_ID_PCM_DEC 0x07001005 +#define MODULE_ID_SAL 0x07001010 #define MODULE_ID_CODEC_DMA_SINK 0x07001023 #define MODULE_ID_CODEC_DMA_SOURCE 0x07001024 #define MODULE_ID_I2S_SINK 0x0700100A @@ -499,6 +500,16 @@ struct data_logging_config { uint32_t mode; } __packed; +#define PARAM_ID_SAL_OUTPUT_CFG 0x08001016 +struct param_id_sal_output_config { + uint32_t bits_per_sample; +} __packed; + +#define PARAM_ID_SAL_LIMITER_ENABLE 0x0800101E +struct param_id_sal_limiter_enable { + uint32_t enable_lim; +} __packed; + #define PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT 0x08001024 struct param_id_mfc_media_format {